@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 +1 @@
|
|
|
1
|
-
import{c as M,g as _,h as A,w as q}from"./c-CV4T65JE.js";import{C as G}from"./c-ZRGEN6QQ.js";import{A as B,D as R,Q as j,R as U,d as p,ea as F,u as O,x as $,z as y}from"./c-OH2FPYSY.js";import{b as z}from"./c-RETTCOWO.js";import{a as x}from"./c-WCG6AKA7.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function k(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),o=s.filter(a=>a!==s[0]&&i[a]==="number");return o.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:o,title:"",highlight:null}:null}function gt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,o=e.maybeChild(e.resolve(i).index(0)),a=Q(s,$(s.attrs.pos,o?.attrs.pos??null),s.attrs.parent);return a?(D.add(a.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(a))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!k(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let o=0;for(let b=0;b<t;b++)o+=i.doc.child(b).nodeSize;let a=i.doc.child(t),c=a.isTextblock&&a.content.size===0,h=i.doc.maybeChild(t+1),f=c?a.attrs.pos:$(a.attrs.pos,h?.attrs.pos??null),d=Q(e,f,a.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let g=p.nodes.chart.create(d);return i=c?i.replaceWith(o,o+a.nodeSize,g):i.insert(o+a.nodeSize,g),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function wt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,o=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,o,s.map(a=>({label:A(i,a.attrs.id)??"",description:`${a.childCount} ${a.childCount===1?"row":"rows"} \xB7 ${X(a)}`,icon:"\u25A6",run:()=>W(n,t,a,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function ot(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(o=>e[o]!=="number")??t[0],i=t.filter(o=>o!==s&&e[o]==="number");return{x:s,series:i.length?i:t.filter(o=>o!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","blockeditor-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="blockeditor-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","blockeditor-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","blockeditor-chart-title"),this.chip=l(i,"button","blockeditor-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","blockeditor-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","blockeditor-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","blockeditor-chart-plot"),this.broken=l(i,"div","blockeditor-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",o=>this.brokenClick(o)),this.panel=l(i,"div","blockeditor-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",o=>this.panelClick(o)),this.panel.addEventListener("change",o=>this.panelChange(o)),this.panel.addEventListener("mousedown",o=>{o.target.closest?.("button")&&o.preventDefault()}),this.outside=o=>{!this.panel.isConnected||this.dom.contains(o.target)||(this.commitTitle(),this.closePanel())},this.escape=o=>{!this.panel.isConnected||o.key!=="Escape"||(o.preventDefault(),o.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=k(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let o=this.doc;this.broken.textContent="",this.broken.append(l(o,"div","blockeditor-chart-broken-head","This chart's table was deleted"),l(o,"p","blockeditor-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let a=l(o,"div","blockeditor-chart-broken-actions");if(s.length){let h=T(o,"rescue","Source table");for(let d of s)h.append(C(o,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(o,"button","blockeditor-chart-use","Use this table");f.type="button",f.dataset.action="use",a.append(h,f)}let c=l(o,"button","blockeditor-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",a.append(c),this.broken.append(a)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!k(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","blockeditor-chart-row");return t&&s.append(l(this.doc,"span","blockeditor-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(k(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let o=[...this.panel.querySelectorAll("button, input, select")].find(a=>["field","kind","col","action"].every(c=>a.dataset[c]===e[c]));if(!o)return this.panel.focus();o.focus(),i&&o===this.titleInput&&o.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],o=s?.rows??[],a=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","blockeditor-chart-types");for(let[r,P]of st){let m=l(t,"button","blockeditor-chart-type",P);m.type="button",m.dataset.kind=r,m.setAttribute("aria-pressed",String(e.kind===r)),c.append(m)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let r of E(this.view.state.doc))h.append(C(t,r.id,`${r.name} (${r.rows} ${r.rows===1?"row":"rows"})`,r.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let r of i)f.append(C(t,r.id,r.name||r.id,r.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","blockeditor-chart-values");i.filter(r=>r.id!==e.x).forEach((r,P)=>{let m=l(t,"label","blockeditor-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=r.id,v.checked=e.series.includes(r.id);let I=l(t,"span","blockeditor-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),m.append(v,I,l(t,"span","blockeditor-chart-value-name",r.name||r.id)),d.append(m)});let g=this.row(a?"Value column":"Value columns",d);a&&g.append(l(t,"span","blockeditor-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(g);let b=T(t,"highlight","Highlight row");b.append(C(t,"","None",!e.highlight));for(let r of o)b.append(C(t,r.id,O(r.cells?.[e.x])||r.id,r.id===e.highlight));this.panel.append(this.row("Highlight row",b));let u=l(t,"input","blockeditor-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",r=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","blockeditor-chart-foot"),w=l(t,"button","blockeditor-chart-remove");w.type="button",w.dataset.action="remove",w.innerHTML=et,w.append("Remove");let L=l(t,"button","blockeditor-chart-done","Done");L.type="button",L.dataset.action="done",H.append(w,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=k(this.view.state.doc,t),s=e?ot(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=k(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".blockeditor-chart-head, .blockeditor-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{gt as a,X as b,wt as c,Y as d,vt as e};
|
|
1
|
+
import{c as M,g as _,h as A,w as q}from"./c-JWW6BHWD.js";import{C as G}from"./c-AI3H6ETU.js";import{A as B,D as R,Q as j,R as U,d as p,ea as F,u as O,x as $,z as y}from"./c-OH2FPYSY.js";import{b as z}from"./c-RETTCOWO.js";import{a as x}from"./c-WCG6AKA7.js";import{a as K}from"./c-I2SCCUEW.js";var{TextSelection:J}=z,S=new WeakMap,D=new Set;function k(n,t){let e=null;return n.forEach(s=>{s.type===p.nodes.table&&s.attrs.id===t&&(e=s)}),e}function N(n){return n?F({[n.attrs.id]:R(n)})[0]:null}function Q(n,t,e){let s=y(n.attrs.cols);if(!s.length)return null;let i=M(n),o=s.filter(a=>a!==s[0]&&i[a]==="number");return o.length?{id:B(),pos:t,parent:e,source:n.attrs.id,kind:"bar",x:s[0],series:o,title:"",highlight:null}:null}function gt(n,t){let e=n.state.doc,s=e.nodeAt(t);if(s?.type!==p.nodes.table)return!1;let i=t+s.nodeSize,o=e.maybeChild(e.resolve(i).index(0)),a=Q(s,$(s.attrs.pos,o?.attrs.pos??null),s.attrs.parent);return a?(D.add(a.id),n.dispatch(n.state.tr.insert(i,p.nodes.chart.create(a))),!0):(x("This table has no number column to chart yet."),!0)}function W(n,t,e,s){let i=n.state.tr;if(s&&i.delete(s.from,s.to),!k(i.doc,e.attrs.id)||t>=i.doc.childCount)return!1;let o=0;for(let b=0;b<t;b++)o+=i.doc.child(b).nodeSize;let a=i.doc.child(t),c=a.isTextblock&&a.content.size===0,h=i.doc.maybeChild(t+1),f=c?a.attrs.pos:$(a.attrs.pos,h?.attrs.pos??null),d=Q(e,f,a.attrs.parent??null);if(!d)return s&&n.dispatch(n.state.tr.delete(s.from,s.to)),x("This table has no number column to chart yet."),!0;let g=p.nodes.chart.create(d);return i=c?i.replaceWith(o,o+a.nodeSize,g):i.insert(o+a.nodeSize,g),D.add(d.id),n.dispatch(i.scrollIntoView()),!0}var X=n=>y(n.attrs.cols).map(t=>n.attrs.cols[t].name||"Untitled").join(", ");function wt(n,t,e=null){let s=_(n.state.doc);if(!s.length)return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),x("Add a table first: a chart plots the numbers in a table on this page."),!0;if(s.length===1)return W(n,t,s[0],e);let i=n.state.doc,o=n.nodeDOM(i.resolve(n.state.selection.head).before(1))??n.dom;return q(n,o,s.map(a=>({label:A(i,a.attrs.id)??"",description:`${a.childCount} ${a.childCount===1?"row":"rows"} \xB7 ${X(a)}`,icon:"\u25A6",run:()=>W(n,t,a,e)})))}var V=n=>`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,Z=V('<rect x="2.5" y="3" width="11" height="10" rx="1.5"/><path d="M2.5 6.5h11M6 6.5V13"/>'),tt=V('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),et=V('<path d="M2.75 4.5h10.5M6.25 4.5V2.75h3.5V4.5M4.25 4.5l.6 8.75h6.3l.6-8.75"/>'),st=[["bar","Bar"],["line","Line"],["pie","Pie"]],it="Untitled chart";function nt(n,t){let e=null;return n.forEach((s,i)=>{e===null&&s.type===p.nodes.table&&s.attrs.id===t&&(e=i)}),e}function E(n){let t=[];return n.forEach(e=>{e.type===p.nodes.table&&y(e.attrs.cols).length>1&&t.push(e)}),t.map(e=>({id:e.attrs.id,name:A(n,e.attrs.id),rows:e.childCount}))}function ot(n){let t=y(n.attrs.cols);if(!t.length)return null;let e=M(n),s=t.find(o=>e[o]!=="number")??t[0],i=t.filter(o=>o!==s&&e[o]==="number");return{x:s,series:i.length?i:t.filter(o=>o!==s).slice(0,1)}}function l(n,t,e,s=null){let i=n.createElement(t);return e&&(i.className=e),s!==null&&(i.textContent=s),i}function C(n,t,e,s=!1){let i=l(n,"option","",e);return i.value=t,i.selected=s,i}function T(n,t,e){let s=l(n,"select","blockeditor-chart-select");return s.dataset.field=t,s.setAttribute("aria-label",e),s}var Y=class{constructor(t,e,s){this.node=t,this.view=e,this.getPos=s,this.source=void 0,this.tables=null,this.frame=null,this.unsaved=null,this.titleInput=null;let i=e.dom.ownerDocument;this.doc=i,this.dom=i.createElement("figure"),this.dom.className="blockeditor-chart",this.dom.dataset.id=t.attrs.id??"",this.dom.dataset.type="chart",this.head=l(i,"div","blockeditor-chart-head"),this.head.contentEditable="false",this.title=l(i,"span","blockeditor-chart-title"),this.chip=l(i,"button","blockeditor-chart-source"),this.chip.type="button",this.chip.contentEditable="false",this.chip.setAttribute("aria-label","Go to source table"),this.chip.innerHTML=Z,this.chipName=l(i,"span","blockeditor-chart-source-name"),this.chip.append(this.chipName),this.chip.addEventListener("click",()=>this.goToSource()),this.edit=l(i,"button","blockeditor-chart-edit"),this.edit.type="button",this.edit.contentEditable="false",this.edit.setAttribute("aria-haspopup","dialog"),this.edit.setAttribute("aria-expanded","false"),this.edit.innerHTML=tt,this.edit.append("Edit chart"),this.edit.addEventListener("click",()=>this.panel.isConnected?this.closePanel(!0):this.openPanel()),this.head.append(this.title,this.chip,this.edit),this.plot=l(i,"div","blockeditor-chart-plot"),this.broken=l(i,"div","blockeditor-chart-broken"),this.broken.hidden=!0,this.broken.contentEditable="false",this.brokenKey=null,this.brokenSelect=null,this.broken.addEventListener("click",o=>this.brokenClick(o)),this.panel=l(i,"div","blockeditor-chart-panel"),this.panel.tabIndex=-1,this.panel.contentEditable="false",this.panel.setAttribute("role","dialog"),this.panel.setAttribute("aria-label","Chart settings"),this.panel.addEventListener("click",o=>this.panelClick(o)),this.panel.addEventListener("change",o=>this.panelChange(o)),this.panel.addEventListener("mousedown",o=>{o.target.closest?.("button")&&o.preventDefault()}),this.outside=o=>{!this.panel.isConnected||this.dom.contains(o.target)||(this.commitTitle(),this.closePanel())},this.escape=o=>{!this.panel.isConnected||o.key!=="Escape"||(o.preventDefault(),o.stopPropagation(),this.closePanel(!0))},i.addEventListener("mousedown",this.outside,!0),i.addEventListener("keydown",this.escape,!0),this.dom.append(this.head,this.plot,this.broken),S.has(e)||S.set(e,new Set),S.get(e).add(this),this.refresh(),D.delete(t.attrs.id)&&this.openSoon()}refresh(){this.renderHead(),this.panel.isConnected&&this.panelKey()!==this.renderedKey&&this.redrawPanel();let t=this.view.state.doc,e=k(t,this.node.attrs.source),s=E(t).map(i=>`${i.id}:${i.name}:${i.rows}`).join("|");e===this.source&&s===this.tables||(this.source=e,this.tables=s,this.schedule())}schedule(){if(this.frame!==null)return;let t=this.dom.ownerDocument.defaultView,e=t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0));this.frame=e(()=>{this.frame=null,this.draw()})}draw(){let t=this.node.attrs,e=j({id:t.id,type:t.kind,x:t.x,series:t.series,title:t.title,highlight:t.highlight},N(this.source));this.plot.innerHTML=U(e,{width:640,height:320,narrow:this.dom.getBoundingClientRect().width<480}),this.renderBroken(e)}renderBroken(t){let e=t.state==="missing"&&t.reason==="table";if(this.plot.hidden=e,this.broken.hidden=!e,!e){this.brokenKey!==null&&(this.broken.textContent="",this.brokenKey=null,this.brokenSelect=null);return}let s=E(this.view.state.doc),i=s.map(h=>`${h.id}:${h.name}:${h.rows}`).join("|");if(this.brokenKey===i)return;this.brokenKey=i,this.brokenSelect=null;let o=this.doc;this.broken.textContent="",this.broken.append(l(o,"div","blockeditor-chart-broken-head","This chart's table was deleted"),l(o,"p","blockeditor-chart-broken-text","Pick another table in this document, or delete the chart. Undo brings the table back."));let a=l(o,"div","blockeditor-chart-broken-actions");if(s.length){let h=T(o,"rescue","Source table");for(let d of s)h.append(C(o,d.id,`${d.name} (${d.rows} ${d.rows===1?"row":"rows"})`));this.brokenSelect=h;let f=l(o,"button","blockeditor-chart-use","Use this table");f.type="button",f.dataset.action="use",a.append(h,f)}let c=l(o,"button","blockeditor-chart-delete","Delete chart");c.type="button",c.dataset.action="delete",a.append(c),this.broken.append(a)}brokenClick(t){let e=t.target.closest?.("button[data-action]");e&&(e.dataset.action==="delete"?this.removeChart():e.dataset.action==="use"&&this.switchSource(this.brokenSelect?.value??""))}openSoon(){let t=this.dom.ownerDocument.defaultView;(t.requestAnimationFrame?.bind(t)??(s=>t.setTimeout(s,0)))(()=>{!this.view.isDestroyed&&this.dom.isConnected&&this.openPanel()})}renderHead(){let t=this.node.attrs,e=A(this.view.state.doc,t.source),s=!k(this.view.state.doc,t.source);this.title.textContent=t.title||it,this.title.classList.toggle("is-empty",!t.title),this.chipName.textContent=s?"No table":e??"",this.chip.disabled=s}setAttrs(t){let e=this.getPos();if(e==null)return;let s=this.view.state.doc.nodeAt(e);s?.type===p.nodes.chart&&this.view.dispatch(this.view.state.tr.setNodeMarkup(e,null,{...s.attrs,...t}))}row(t,...e){let s=l(this.doc,"div","blockeditor-chart-row");return t&&s.append(l(this.doc,"span","blockeditor-chart-label",t)),s.append(...e),s}panelKey(){let t=this.view.state.doc,e=E(t).map(s=>`${s.id}:${s.name}:${s.rows}`).join("|");return JSON.stringify([this.node.attrs,e,N(k(t,this.node.attrs.source))])}redrawPanel(){let t=this.doc.activeElement,e=t&&this.panel.contains(t)?t.dataset??{}:null,s=this.titleInput,i=s&&s.value!==this.renderedTitle?{value:s.value,start:s.selectionStart,end:s.selectionEnd}:null;if(this.renderPanel(),i&&this.titleInput&&(this.titleInput.value=i.value),!e)return;let o=[...this.panel.querySelectorAll("button, input, select")].find(a=>["field","kind","col","action"].every(c=>a.dataset[c]===e[c]));if(!o)return this.panel.focus();o.focus(),i&&o===this.titleInput&&o.setSelectionRange?.(i.start,i.end)}renderPanel(){let t=this.doc;this.renderedKey=this.panelKey(),this.renderedTitle=this.node.attrs.title??"";let e=this.node.attrs,s=N(this.source),i=s?.cols??[],o=s?.rows??[],a=e.kind==="pie";this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.textContent="";let c=l(t,"div","blockeditor-chart-types");for(let[r,P]of st){let m=l(t,"button","blockeditor-chart-type",P);m.type="button",m.dataset.kind=r,m.setAttribute("aria-pressed",String(e.kind===r)),c.append(m)}this.panel.append(this.row("Chart type",c));let h=T(t,"source","Source table");for(let r of E(this.view.state.doc))h.append(C(t,r.id,`${r.name} (${r.rows} ${r.rows===1?"row":"rows"})`,r.id===e.source));this.panel.append(this.row("Source table",h));let f=T(t,"labels","Labels column");for(let r of i)f.append(C(t,r.id,r.name||r.id,r.id===e.x));this.panel.append(this.row("Labels column",f));let d=l(t,"div","blockeditor-chart-values");i.filter(r=>r.id!==e.x).forEach((r,P)=>{let m=l(t,"label","blockeditor-chart-value"),v=l(t,"input");v.type="checkbox",v.dataset.field="series",v.dataset.col=r.id,v.checked=e.series.includes(r.id);let I=l(t,"span","blockeditor-chart-swatch");I.style.background=`var(--chart-${P%6+1})`,I.setAttribute("aria-hidden","true"),m.append(v,I,l(t,"span","blockeditor-chart-value-name",r.name||r.id)),d.append(m)});let g=this.row(a?"Value column":"Value columns",d);a&&g.append(l(t,"span","blockeditor-chart-hint","Pie charts plot the first value column across rows.")),this.panel.append(g);let b=T(t,"highlight","Highlight row");b.append(C(t,"","None",!e.highlight));for(let r of o)b.append(C(t,r.id,O(r.cells?.[e.x])||r.id,r.id===e.highlight));this.panel.append(this.row("Highlight row",b));let u=l(t,"input","blockeditor-chart-title-input");u.type="text",u.dataset.field="title",u.setAttribute("aria-label","Chart title"),u.value=e.title??"",u.addEventListener("keydown",r=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),this.commitTitle())}),u.addEventListener("change",()=>this.commitTitle()),u.addEventListener("blur",()=>this.commitTitle()),this.titleInput=u,this.panel.append(this.row("Chart title",u));let H=l(t,"div","blockeditor-chart-foot"),w=l(t,"button","blockeditor-chart-remove");w.type="button",w.dataset.action="remove",w.innerHTML=et,w.append("Remove");let L=l(t,"button","blockeditor-chart-done","Done");L.type="button",L.dataset.action="done",H.append(w,L),this.panel.append(H),this.unsaved=K({id:"chart-title",isPending:()=>u.isConnected&&u.value!==(this.node.attrs.title??"")})}openPanel(){this.panel.isConnected||(this.renderPanel(),this.dom.append(this.panel),this.edit.setAttribute("aria-expanded","true"),this.panel.focus())}closePanel(t=!1){this.panel.isConnected&&(this.unsaved?.dispose(),this.unsaved=null,this.titleInput=null,this.panel.remove(),this.edit.setAttribute("aria-expanded","false"),t&&this.edit.focus())}panelClick(t){let e=t.target.closest?.("button");e&&(e.dataset.action==="done"?(this.commitTitle(),this.closePanel(!0)):e.dataset.action==="remove"?this.removeChart():e.dataset.kind&&this.setAttrs({kind:e.dataset.kind}))}panelChange(t){let e=t.target;if(e?.dataset){if(e.dataset.field==="source")this.switchSource(e.value);else if(e.dataset.field==="labels")this.setAttrs({x:e.value,series:this.node.attrs.series.filter(s=>s!==e.value)});else if(e.dataset.field==="highlight")this.setAttrs({highlight:e.value||null});else if(e.dataset.field==="series"){let s=this.node.attrs.series.filter(i=>i!==e.dataset.col);this.setAttrs({series:e.checked?[...s,e.dataset.col]:s})}}}switchSource(t){let e=k(this.view.state.doc,t),s=e?ot(e):null;s&&this.setAttrs({source:t,x:s.x,series:s.series})}commitTitle(){let t=this.titleInput;!t||t.value===(this.node.attrs.title??"")||this.setAttrs({title:t.value})}goToSource(){let t=this.view.state.doc,e=nt(t,this.node.attrs.source),s=e===null?null:t.nodeAt(e);if(!s?.childCount||!s.child(0).childCount)return;let i=e+3;this.view.dispatch(this.view.state.tr.setSelection(J.create(t,i)).scrollIntoView()),this.view.focus?.()}removeChart(){let t=this.getPos();if(t==null)return;let e=this.view.state.doc.nodeAt(t);if(e?.type!==p.nodes.chart)return;this.closePanel();let s=this.view.state.tr.delete(t,t+e.nodeSize);s.setSelection(J.near(s.doc.resolve(Math.min(t,s.doc.content.size)),-1)),this.view.dispatch(G(s).scrollIntoView())}update(t){if(t.type!==p.nodes.chart)return!1;let e=!t.sameMarkup(this.node);return this.node=t,this.dom.dataset.id=t.attrs.id??"",e&&(this.source=k(this.view.state.doc,t.attrs.source),this.renderHead(),this.schedule()),!0}stopEvent(t){return!!t.target.closest?.(".blockeditor-chart-head, .blockeditor-chart-panel")}destroy(){if(this.unsaved?.dispose(),this.unsaved=null,this.doc.removeEventListener("mousedown",this.outside,!0),this.doc.removeEventListener("keydown",this.escape,!0),S.get(this.view)?.delete(this),this.frame!==null){let t=this.dom.ownerDocument.defaultView;t.cancelAnimationFrame?t.cancelAnimationFrame(this.frame):t.clearTimeout(this.frame)}}};function vt(n){for(let t of S.get(n)??[])t.refresh()}export{gt as a,X as b,wt as c,Y as d,vt as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./c-
|
|
1
|
+
import{a as d}from"./c-HGG7M2S3.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{g as m,l as v,n as x,q as s}from"./c-MR75YPRT.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-5RZNFTWD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}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 $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{b as U}from"./c-LD6UVV5R.js";import{a as se,g as ae,h as C}from"./c-PGSBXHUE.js";import{a as oe,b as ie,c as j}from"./c-KU3PX7LL.js";import{d as A}from"./c-EQ5NBOGA.js";import{c as Z,e as Q,g as ee}from"./c-IJUK2GPW.js";import{b as k,f as D}from"./c-C7SUMNMI.js";import{c as V}from"./c-BPF2NSPV.js";import{i as q}from"./c-U4TWEIKZ.js";import{a as M,g as te,h as ne,i as re}from"./c-PNZIJFG7.js";var F=null,ue=null,T=null;function Te(e){let t=e?.document?.maxBytes;return Number.isSafeInteger(t)&&t>0?t:null}function le(e){return F=Te(e),ue=e?.document?.maxBytesMeasures==="file"?"file":null,F}var be=/<script\b[^>]*\bmerge=(["'])blockeditor\1[^>]*>[\s\S]*?<\/script\s*>/i;function B(e,t=ue){if(t!=="file"||typeof e!="string")return e;let n=be.exec(e);if(!n)return e;let o=n.index,s=o+n[0].length,r=e.lastIndexOf(`
|
|
2
|
+
`,o-1)+1,a=e.indexOf(`
|
|
3
|
+
`,s),c=a===-1?e.length:a+1;return!/\S/.test(e.slice(r,o))&&!/\S/.test(e.slice(s,c))&&(o=r,s=c),e.slice(0,o)+e.slice(s)}function H(e,t){let n=new TextEncoder().encode(e).byteLength,o=Number.isSafeInteger(t)&&t>0;return{bytes:n,maxBytes:o?t:null,state:o?n>t?"over":n>=Math.ceil(t*.8)?"near":"ok":"unknown"}}function ce(){return F}function L({fresh:e=!1}={}){return e?(T=A({fresh:!0}).then(le),T):(T||(T=A().then(le)),T)}function St({fresh:e=!1}={}){return L({fresh:e}).then(t=>({maxBytes:t}))}async function xt(e){let t=await L();return H(B(e),t)}function fe(e){let t=new CustomEvent("clay:save-size",{detail:e});document.dispatchEvent(t),(e.state==="near"||e.state==="over")&&import("./c-M7ITYKMF.js").then(n=>n.start(t),()=>{})}var P="/_/clayjs/",Oe=/[\u0000-\u001F\u007F]/,Ee=/^[\t\n\f\r ]|[\t\n\f\r ]$/,$e=/^https:\/\/clayjs\.com\/v(\d+)\/([\s\S]*)$/,Re=/^https:\/\/clayjs\.com\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,de=/^\/_\/clayjs\/(\d+)\.(\d+)\.(\d+)\/([\s\S]*)$/,ke=/%2e|%2f|%5c/i;function Me(e){if(typeof e!="string")return null;let t=/^(\d+)\.\d+\.\d+$/.exec(e);return t?t[1]:null}function je(e){if(typeof e!="string"||e==="")return null;try{return new URL(e).origin}catch{return null}}function Le(e){let t=e.indexOf("#"),n=t<0?"":e.slice(t),o=t<0?e:e.slice(0,t),s=o.indexOf("?"),r=s<0?"":o.slice(s);return{head:s<0?o:o.slice(0,s),search:r,hash:n}}function Pe(e){if(e===""||e.includes("\\")||ke.test(e))return null;let t=e.split("/"),n=[];for(let o of t){if(o===""||o==="."||o==="..")return null;let s;try{s=decodeURIComponent(o)}catch{return null}if(s.includes("/")||s.includes("\\")||s==="."||s==="..")return null;n.push(s)}return n.join("/")}function b(e,{documentURL:t}={}){if(typeof e!="string"||e===""||Ee.test(e)||Oe.test(e))return null;let{head:n,search:o,hash:s}=Le(e),r=null,a=null,c=null,l=null,i=$e.exec(n);if(i&&(r="rolling",c=i[1],l=i[2]),r||(i=Re.exec(n),i&&(r="exact",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),r||(i=de.exec(n),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4])),!r){let f=je(t);f&&n.startsWith(`${f}/`)&&(i=de.exec(n.slice(f.length)),i&&(r="local",a=`${i[1]}.${i[2]}.${i[3]}`,c=i[1],l=i[4]))}if(!r)return null;let u=Pe(l);return u===null?null:{kind:r,major:c,version:a,rawPath:l,path:u,search:o,hash:s}}function Ie(e,t){let n=e&&typeof e=="object"?e[t]:null;return n&&typeof n.files=="object"&&n.files?n.files:null}function _e(e){return!e||typeof e!="object"?[]:Array.isArray(e.entries)?e.entries.filter(t=>t&&typeof t=="object"):[]}function Ne(e,t,n){if(!n)return!0;let o=Ie(n,t);return!!(o&&Object.hasOwn(o,e.path))}function he(e,{descriptor:t,releases:n,documentURL:o,aliases:s}={}){let r=b(e,{documentURL:o});if(!r||r.kind!=="local")return e;let a=_e(t),c=Me(r.version);for(let l of a){if(l.local!==e||typeof l.original!="string")continue;let i=n?.[r.version]?.aliases??s;if(i&&typeof i=="object"&&!r.search&&!r.hash&&Object.hasOwn(i,l.original)&&i[l.original]===r.path)return l.original;let u=b(l.original);if(u&&!(u.kind!=="rolling"&&u.kind!=="exact")&&u.rawPath===r.rawPath&&u.search===r.search&&u.hash===r.hash&&!(u.kind==="rolling"?u.major!==c:u.version!==r.version)&&Ne(r,r.version,n))return u.kind==="exact"?l.original:`https://clayjs.com/v${u.major}/${r.rawPath}${r.search}${r.hash}`}for(let l of a){if(typeof l.original!="string")continue;let i=b(l.original);if(i&&!(i.kind!=="rolling"&&i.kind!=="exact")&&i.rawPath===r.rawPath&&!(i.kind==="rolling"?i.major!==c:i.version!==r.version))return i.kind==="rolling"?`https://clayjs.com/v${i.major}/${r.rawPath}${r.search}${r.hash}`:`https://clayjs.com/${i.version}/${r.rawPath}${r.search}${r.hash}`}return`https://clayjs.com/${r.version}/${r.rawPath}${r.search}${r.hash}`}var De=Object.freeze({"https://cdn.jsdelivr.net/npm/overtype@2.6.1/dist/overtype.min.js":"compat/overtype-2.6.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js":"compat/highlight-11.9.0.min.js","https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap":"fonts/ibm-plex.css"}),z="clay-runtime-map",Ue=new Set(["stylesheet","preload","modulepreload"]),pe=null,J=null;function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||typeof t!="object"||t.schema!==1?null:t}function Fe(){if(typeof document>"u")return null;let e=document.getElementById(z);if(!e)return null;let t=e.textContent??"";return t===pe||(pe=t,J=Ce(t)),J}var Be=`script[src*="${P}"], link[href*="${P}"], #${z}`;function me(e){if(e.querySelector(Be))return!0;for(let t of e.querySelectorAll("template"))if(me(t.content))return!0;return!1}function He(e){let t=[],n=[e];for(;n.length;){let o=n.pop();for(let s of o.children??[])t.push(s),n.push(s),s.content&&n.push(s.content)}return t}function Je(e){return e.tagName==="SCRIPT"&&e.hasAttribute("src")?"src":e.tagName!=="LINK"||!e.hasAttribute("href")?null:(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).some(n=>Ue.has(n))?"href":null}function ze(e){if(!e||!me(e))return;let t=[],n=!1;for(let r of He(e)){if(r.getAttribute("id")===z){r.remove();continue}let a=Je(r);a&&(t.push({element:r,name:a}),!n&&(r.getAttribute(a)??"").includes(P)&&(n=!0))}if(!n)return;let o=location.href,s=Fe();for(let{element:r,name:a}of t){let c=r.getAttribute(a),l=b(c,{documentURL:o});!l||l.kind!=="local"||r.setAttribute(a,he(c,{descriptor:s,documentURL:o,aliases:De}))}}re(ze);var x=!1,$=null,ge="/_/save",Ke=12e3,ve=6e4,We=1024*1024,we="text/plain;charset=UTF-8",I=null,R=!1,K=new Map;function Ht(e,t){t==null?K.delete(e):K.set(e,String(t))}var W=new Set;function Jt(e){return W.add(e),()=>W.delete(e)}async function zt(e,t){R=!!e;try{return await t()}finally{R=!1}}function Gt(){return x}function Kt(){return x?null:(x=!0,$={reserved:!0},$)}function Wt(e){!e||$!==e||($=null,x=!1)}function Xt(){return R}var _=[],N=[];function Yt(e){return _.push(e),()=>{let t=_.indexOf(e);t>=0&&_.splice(t,1)}}function Vt(e){return N.push(e),()=>{let t=N.indexOf(e);t>=0&&N.splice(t,1)}}function Xe(e){for(let t of _)try{t(e)}catch(n){console.error("clayjs: onSaveAttempt hook failed:",n)}}function Ye(e){for(let t of N)try{t(e)}catch(n){console.error("clayjs: onSaveOutcome hook failed:",n)}}function ye(e){return{ok:!0,msg:e.msg??"Saved",msgType:e.msgType||"success",code:e.code??null,etag:e.etag??null,...e.siteData?{siteData:e.siteData}:{}}}var O=[],Ve=8,y=null;function qt(){return y!==null}function Se(){let e=window.crypto?.randomUUID?.();if(e)return e;if(window.crypto?.getRandomValues){let n=new Uint8Array(16);return window.crypto.getRandomValues(n),Array.from(n,o=>o.toString(16).padStart(2,"0")).join("")}let t=()=>Math.random().toString(36).slice(2,12).padEnd(10,"0");return`${Date.now().toString(36)}-${t()}${t()}${t()}`}function qe(e){O.push(e),O.length>Ve&&O.shift()}function Ze(e){return typeof e=="string"&&e!==""&&O.includes(e)}function Zt(){O.length=0,y=null}function X(e){let t=e.name==="AbortError",n=!t&&e.status===412,o=!t&&!n&&e.code==="save-already-applied";return{ok:!1,msg:t?"Server not responding":e.message||"Save failed",msgType:t||o?"unknown":n?"conflict":"error",code:t?"timeout":n?"conflict":e.code??null,changedBy:n?e.changedBy??null:null,afterTimeout:n&&y!==null,conflictEtag:n?e.etag??null:null,status:Number.isInteger(e.status)?e.status:null,hadTimeout:t||e.hadTimeout===!0,reason:e.reason??null,retryAfter:e.retryAfter??null,saveOutcome:e.saveOutcome??null,etag:null}}function E(e){return{ok:!1,msg:e,msgType:"skipped",code:null,etag:null}}function Qe(e){let t=new Error(`This document is ${e.bytes} bytes; this host saves at most ${e.maxBytes}`);return t.code="save-too-large",{...X(t),sent:!1,size:e}}var w=null;function et(e){return w?null:(w={kind:e},w)}function tt(e){w===e&&(w=null)}function nt(){return w?w.kind:null}function rt(){return{ok:!1,msg:"Invalid page conversion metadata",msgType:"error",code:"invalid-header",etag:null}}var ot=3,it=/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} \d{2}:\d{2}:\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4})$/;function st(e){if(e==null)return null;let t=String(e).trim();if(!t)return null;if(/^-?\d+$/.test(t))return Math.max(0,Math.min(3600,Number(t)));if(!it.test(t))return null;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,Math.min(3600,Math.round((n-Date.now())/1e3)))}var at=/^[0-9a-f]{64}$/,lt=/^[A-Za-z0-9-]{1,64}$/;function ut(e){if(e==null)return{header:null};if(typeof e!="object")return{invalid:!0};let{source:t,base:n,epoch:o}=e;return typeof n!="string"||!at.test(n)?{invalid:!0}:t==="file"?o!=null?{invalid:!0}:{header:`v1; source=file; base=${n}`}:t==="room"?typeof o!="string"||!lt.test(o)?{invalid:!0}:{header:`v1; source=room; base=${n}; epoch=${o}`}:{invalid:!0}}function ct(e,t,n,o,s,r=!1,a=null,c=!0){let l=V(),i=l?`${ge}/${l}`:ge,u={method:"POST",credentials:l?"omit":"same-origin",signal:n,headers:{"Document-URL":window.location.href,"Page-URL":window.location.href,"Save-Trigger":t?"user":"auto","Save-ID":o,[se]:String(1)},body:ft(e)};for(let[f,h]of K)u.headers[f]=h;if(c)for(let f of W){let h=null;try{h=f(e)}catch(p){console.error("clayjs: a save header source failed:",p)}if(h)for(let[p,S]of Object.entries(h))u.headers[p]=String(S)}return typeof u.body!="string"&&(u.headers["Content-Type"]=we),a&&(u.headers["Blockeditor-Conversion"]=a),s&&(u.headers["If-Match"]=s),r&&e.length<ve&&new Blob([e]).size<ve&&(u.keepalive=!0),{url:dt(i),options:u}}function ft(e){if(e.length<We)return e;if(I&&I.content===e)return I.blob;let t=new Blob([e],{type:we});return I={content:e,blob:t},t}function xe(){let e=oe();return ie()&&e?e:null}function dt(e){let t=window.location.origin;return!t||t==="null"?e:new URL(e,t).href}function G(e,t){let n=JSON.stringify(t);return{ok:e>=200&&e<300,status:e,statusText:e===200?"OK":"Insufficient Storage",text:()=>Promise.resolve(n)}}function ht(e,t){let n=q();return n?Promise.resolve().then(()=>n(e,t)).then(()=>G(200,{msg:"Saved in this browser",msgType:"success"}),o=>G(507,{msg:"Couldn't save in this browser. Storage is full or turned off.",msgType:"error",code:o?.code||"draft-storage"})):Promise.resolve(G(503,{msg:"Saving in this browser is not ready yet",msgType:"error",code:"draft-not-ready"}))}function pt(e,t,n,{captureId:o=null,conversionHeader:s=null,attempts:r=[],gateToken:a=null}={}){let c=new AbortController,l=setTimeout(()=>c.abort(),Ke),i=Q(),u=ee(),f=i||u,h=R;R=!1;let{url:p,options:S}=ct(e,f,c.signal,t,n,h,s);return qe(t),k||(r.some(d=>d.saveId===t&&d.etag===(n??null))||r.push({saveId:t,etag:n??null}),Xe({captureId:o,saveId:t,html:e,etag:n??null})),(k?ht(e,a):fetch(p,S)).then(d=>d.text().then(g=>{let m={};if(g)try{m=JSON.parse(g)}catch{if(d.ok)throw new Error("Server sent a response that was not JSON")}if(!d.ok){let v=new Error(m.msg||m.error||`HTTP ${d.status}: ${d.statusText}`);throw v.code=d.status===413?"save-too-large":m.code??null,v.status=d.status,v.changedBy=m.changedBy??null,v.etag=m.etag??null,v.saveId=m.saveId??null,v.reason=typeof m.reason=="string"?m.reason:null,v.saveOutcome=m.saveOutcome??null,v.retryAfter=st(d.headers?.get?.("Retry-After")),v}return j(m.etag??null),y=null,m})).catch(d=>{throw console.error("Failed to save page:",d),d.name==="AbortError"&&(y={saveId:t,etag:n}),f&&Z(),d}).finally(()=>{clearTimeout(l)})}async function mt(){let e=y;if(!e)return{landed:null,resend:!1};let n=(await A({fresh:!0})).document,o=typeof n?.etag=="string"&&n.etag?n.etag:null;return o?n.saveId&&n.saveId===e.saveId?(j(o),y=null,{landed:{msg:"Saved",msgType:"success",etag:o},resend:!1}):(n.saveId&&(y=null),{landed:null,resend:!!e.etag,etag:e.etag}):{landed:null,resend:!1}}async function gt(e,{captureId:t=null,conversionHeader:n=null,attempts:o=[],gateToken:s=null}={}){let r=Se(),a=xe(),c=!1,l=!1,i=0,u=t??M();for(;;)try{return await pt(e,r,a,{captureId:t,conversionHeader:n,attempts:o,gateToken:s})}catch(f){if(c&&(f.hadTimeout=!0),f.name==="AbortError"){if(c)throw f;let{landed:h,resend:p,etag:S}=await mt();if(h)return h;if(!p)throw f;a=S,c=!0;continue}if(f.status===412&&!l&&Ze(f.saveId)){j(f.etag??null),y=null,r=Se(),a=xe(),l=!0;continue}if(f.code==="blockeditor-converting"&&i<ot){if(M()!==u||(i+=1,await new Promise(h=>setTimeout(h,Math.max(0,f.retryAfter??1)*1e3)),M()!==u))throw f;continue}throw f}}function Y(e,t,n,o,s=null,r=0,a=null,c=null){return e=ae(e,Math.max(C(),r)),new Promise(l=>{let i=[],u=te(s),f=()=>a!==null&&$===a,h=()=>{f()||(x=!1)},p=(g,m=!1)=>{m&&U(e,t??null,u),ne(s),Ye({captureId:t??null,result:g,attempts:i,sent:i.length>0}),typeof n=="function"&&n(g),l(g)};if(!D&&!window.clay?.testMode)return p(E("Not in edit mode"));if(x&&!f())return p(E("Save already in progress"));let S=ut(o);if(S.invalid)return p(rt());if(x=!0,window.clay?.testMode){setTimeout(()=>{h(),p(ye({msg:"Test mode: save skipped"}))},0);return}L();let d=H(B(e),ce());if(fe(d),d.state==="over")return h(),p(Qe(d));gt(e,{captureId:t,conversionHeader:S.header,attempts:i,gateToken:c}).then(ye,X).then(g=>{h(),g.code==="save-too-large"&&!g.size&&(g.size=d),g.ok&&U(e,t??null,u,g.siteData??null),p(g)})})}function vt(e,t=()=>{}){return Y(e,null,t,null)}function Qt(e,t,n=()=>{},{conversion:o,capture:s=null,blockeditorFormatFloor:r,lane:a=null,gateToken:c=null}={}){return Y(e,t,n,o,s,r,a,c)}function en({html:e,captureId:t,conversion:n}){return Y(e,t??null,void 0,n)}function tn(e,t=()=>{}){return new Promise(n=>{let o=null,s=r=>{tt(o),typeof t=="function"&&t(r),n(r)};if(!D)return s(E("Not in edit mode"));if(nt())return s(E("Another document operation is in progress"));if(x)return s(E("Save already in progress"));if(k)return s(!1);o=et("replace"),fetch(new URL(e,window.location.href).href).then(r=>{if(!r.ok)throw new Error(`Template fetch failed: HTTP ${r.status} ${r.statusText}`);return r.text()}).then(r=>vt(r)).then(s).catch(r=>{console.error("Failed to fetch template:",r),s(X(r))})})}var Ae=null;function nn(e){Ae=e}function rn(){return Ae}export{L as a,St as b,xt as c,Ht as d,Jt as e,zt as f,Gt as g,Kt as h,Wt as i,Xt as j,Yt as k,Vt as l,qt as m,Se as n,Zt as o,et as p,tt as q,nt as r,ct as s,vt as t,Qt as u,en as v,tn as w,nn as x,rn as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as q}from"./c-2YYDMLNZ.js";var f="sap-error",g=[],F=/^(show-when|hide-when|option|option-not):/,O=new Set(["id","data-id","class","style","sap","scope","items","item","bind","state","template","cms-template","sap-ignore"]),C=new Set(["value","checked","selected"]);function D(t){return t.hasAttribute("bind")||t.hasAttribute("persist")||!!t.closest("select[bind]")}function k(t){return t.localName==="template"||t.hasAttribute("template")||t.hasAttribute("cms-template")||t.hasAttribute("sap-ignore")}var M=["sap","item","scope","items","detail","each"],h=[],d={rules:h,within:"",seen:h,counted:0};function v(){let t=typeof window<"u"&&Array.isArray(window.sapPlugins)?window.sapPlugins:h,n=t.length+g.length;if(t===d.seen&&n===d.counted)return d;let e=g.slice();for(let s of t)if(!(!s||!Array.isArray(s.ownership)||g.some(r=>r.plugin===s.name)))for(let r of s.ownership)B(r)&&e.push({...r,plugin:s.name});return d={rules:e,within:[...new Set(e.map(s=>s.within))].join(","),seen:t,counted:n},d}function B(t){if(!t||typeof t.within!="string"||typeof t.select!="string"||t.attrs&&!Array.isArray(t.attrs))return!1;try{let n=document.createDocumentFragment();return n.querySelector(t.within),n.querySelector(t.select),!0}catch{return!1}}function P(t){return!M.some(n=>t.hasAttribute(n))}function y(t,n,e=null){for(let s=t;s;s=s.parentElement){let r=s.closest(n);if(!r)break;if(P(r)&&l(r,e))return r;s=r}return e&&!t.isConnected?y(e,n):null}function E(t,n,e=null){let s=t.parentElement||(t.isConnected?null:e);return s?y(s,n,e):null}function N(t,n,e,s=null){return(!e||e(t.plugin))&&n.matches(t.select)&&!!y(n,t.within,s)}function l(t,n=null){let e=null;for(let s=t;s&&s.nodeType===1;s=s.parentElement){if(k(s))return null;if(s.hasAttribute("sap"))return s;e=s}return n&&e&&!e.isConnected?l(n):null}function _(t,n){let e=t.getAttribute("state");if(!e)return!1;for(let s of e.trim().split(/\s+/))if(s.split("=")[0].split(":")[0]===n)return!0;return!1}function W(t){if(t.hasAttribute("show"))return!0;for(let n of t.attributes)if(F.test(n.name))return!0;return!1}function j(t,n,e=null,s=null){if(!t||t.nodeType!==1||!n)return!1;let{rules:r,within:i}=v();if(r.length&&y(t,i,e)){for(let o of r)if(o.attrs&&o.attrs.includes(n)&&N(o,t,s,e))return!0;if(E(t,i,e))return n===f}return n===f?!!l(t,e):O.has(n)||C.has(n)&&D(t)?!1:n==="hidden"?W(t)&&!!l(t,e):t.hasAttribute("attr:"+n)&&!_(t,n)&&!!l(t,e)}var m=()=>({attrs:[],classes:[],vars:[],text:!1});function A(t,n=null){if(!t||t.nodeType!==1)return null;let{rules:e,within:s}=v();if(!e.length||!y(t,s))return l(t)?x(t,null):null;let r=null;for(let i of e)N(i,t,n)&&(r=L(r,i));return E(t,s)?(t.hasAttribute(f)&&(r||(r=m())).attrs.push(f),r):x(t,r)}function x(t,n){let e=(s,r)=>(n||(n=m()))[s].push(r);for(let s of t.attributes){let r=s.name;if(r==="text"||r.startsWith("text:"))t.hasAttribute("bind")||((n||(n=m())).text=!0);else if(r.startsWith("attr:")){let i=r.slice(5);i&&!O.has(i)&&!(C.has(i)&&D(t))&&!_(t,i)&&e("attrs",i)}else r.startsWith("class:")?e("classes",r.slice(6)):r.startsWith("css:")&&e("vars","--"+r.slice(4))}return W(t)&&e("attrs","hidden"),t.hasAttribute(f)&&e("attrs",f),n}function L(t,n){t=t||m(),n.text&&(t.text=!0);for(let e of n.attrs||h)t.attrs.includes(e)||t.attrs.push(e);return t}function T(t,n,e=null){if(!t||t.nodeType!==1&&t.nodeType!==9)return;let s=t.nodeType===1&&t.hasAttribute("sap")?[t]:[...t.querySelectorAll("[sap]")].filter(i=>!i.parentElement||!i.parentElement.closest("[sap]")),r=v();for(let i of s){if(r.rules.length&&!E(i,r.within)){S(i,r,e,n);continue}for(let o of[i,...i.querySelectorAll("*")]){let c=A(o,e);c&&n(o,c)}}}function S(t,n,e,s){if(k(t)){let o=null;for(let c of t.querySelectorAll("[sap]"))o&&o.contains(c)||(S(c,n,e,s),o=c);return}let r=t.matches(n.within)&&P(t),i=r?A(t,e):x(t,null);if(i&&s(t,i),r)H(t,n.rules,e,s);else for(let o=t.firstElementChild;o;o=o.nextElementSibling)S(o,n,e,s)}function H(t,n,e,s){let r=new Map,i=(u,a)=>r.set(u,L(r.get(u),a)),o=["["+f+"]"],c=h;for(let u of n)if(!(e&&!e(u.plugin))){if(o.push(u.select),t.matches(u.within)){let a=t.querySelectorAll(u.select);for(let w of a)i(w,u);a.length>c.length&&(c=a);continue}for(let a of t.querySelectorAll(u.within))if(!(!P(a)||!l(a))){a.matches(u.select)&&i(a,u);for(let w of a.querySelectorAll(u.select))i(w,u)}}let p=t.querySelectorAll("["+f+"]");for(let u of p){let a=r.get(u)||m();a.attrs.push(f),r.set(u,a)}c.length<r.size&&(c=t.querySelectorAll(o.join(",")));for(let u of c){let a=r.get(u);a&&s(u,a)}}function R(t,n=null){T(t,(e,s)=>{for(let r of s.attrs)e.hasAttribute(r)&&e.removeAttribute(r);for(let r of s.classes)e.classList.contains(r)&&e.classList.remove(r);s.classes.length&&!e.getAttribute("class")&&e.hasAttribute("class")&&e.removeAttribute("class");for(let r of s.vars)e.style.getPropertyValue(r)!==""&&e.style.removeProperty(r);s.vars.length&&e.hasAttribute("style")&&!e.getAttribute("style").trim()&&e.removeAttribute("style"),s.text&&e.firstChild&&e.replaceChildren()},n)}var z=(t,n,e=null)=>j(t,n,e),U=t=>!!t&&t.nodeType===1&&!!A(t)?.text,Z=t=>R(t);function G(t){let n=[];return T(t,(e,s)=>{n.push(e.localName);for(let r of s.attrs)r!=="sap-error"&&n.push(r+"="+(e.getAttribute(r)??"\0"));for(let r of s.classes)n.push("."+r+"="+e.classList.contains(r));for(let r of s.vars)n.push(r+"="+e.style.getPropertyValue(r));s.text&&n.push("#"+e.textContent)}),n.join("")}function $(t){return G(new DOMParser().parseFromString(t,"text/html"))}function V(t,n,e,s,r){return e(t||"").map(i=>i.trim()).filter(i=>i&&!n.includes(r(i))).sort().join(s)}function I(t,n,e,s){let r=A(t);if(!r)return!1;if(n==="class"){if(!r.classes.length)return!1;let o=c=>V(c,r.classes,p=>p.split(/\s+/)," ",p=>p);return o(e)===o(s)}if(!r.vars.length)return!1;let i=o=>V(o,r.vars,c=>c.split(";"),";",c=>c.split(":")[0].trim());return i(e)===i(s)}function tt(t){if(t.__derived!==void 0)return t.__derived;let n=t.element,e=!1;if(n&&n.nodeType===1)if(t.type==="attribute"){let s=t.attribute;e=z(n,s)||(s==="class"||s==="style")&&I(n,s,t.oldValue,t.newValue)}else t.type==="characterData"&&(e=U(n));return t.__derived=e,e}var b=new Set,J=!1;function et(){return b.size>0||q.holdSettle}var K=[];function nt(){for(let t of[...b])try{t()}catch(n){console.error("clayjs: a derived repaint failed:",n)}}var rt={register(t){return b.add(t),()=>b.delete(t)},mounted(){J=!0;for(let t of K.splice(0))t()}};export{z as a,U as b,Z as c,G as d,$ as e,tt as f,et as g,nt as h,rt as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-
|
|
1
|
+
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-MFB74XVN.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import{b as Y,c as Oe,d as Ie,l as ce,u as fe}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"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">"),Fe=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/"/g,""");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
|
|
2
2
|
`);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&").replace(/ /g," ");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,""")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
|
|
3
3
|
`)!==g.join(`
|
|
4
4
|
`))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as c,f as s}from"./c-
|
|
1
|
+
import{e as c,f as s}from"./c-QCDVDZIR.js";import{k as g,r as u}from"./c-PNZIJFG7.js";import{i as l}from"./c-ICMAOOGK.js";var p={debug:!1};function t(...n){p.debug&&console.log("[save-freeze]",...n)}var f=new WeakMap;function m(n,o){f=new WeakMap;let e=n.querySelectorAll(l);t("freezing clone:",e.length);for(let r of e){let a=o.original(r);if(!a)continue;let i=c(a);i!==void 0&&(f.set(r,i),r.innerHTML!==i&&(t("restoring original"),r.innerHTML=i))}}function d(n){for(let o of n.querySelectorAll(l)){let e=f.get(o);e!==void 0&&o.innerHTML!==e&&(t("re-restoring original after prepare-phase change"),o.innerHTML=e)}}function E(){t("init"),s(),g(m),u(d)}E();var h=p;export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-VG5XIN4T.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-ICMAOOGK.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
|
|
1
|
+
import{b as O,c as N}from"./c-IJUK2GPW.js";import{f as v}from"./c-MOP5KBWZ.js";import{a as y,h as k,j as C,k as R}from"./c-HA6INT6J.js";import{b as E,s as g,t as _,u as S,v as m}from"./c-ICMAOOGK.js";import{g as w}from"./c-WRBKEJD4.js";import{a as M}from"./c-VHNSBD2M.js";var L={};M(L,{default:()=>B});var P=document.createElement("div"),x=new Set(k);function T(e){if(e.type!=="attributes")return!1;let t=e.attributeName;return t===R||y(t,e.target)?!0:e.target===document.documentElement&&(x.has(t)||t.startsWith(C))}function A(e){return e.some(T)?e.filter(t=>!T(t)):e}var V={_callbacks:{anyChange:[],addOrRemove:[],addElement:[],removeElement:[],attribute:[]},_observing:!1,_pauseDepth:0,_hasNonPausable:!1,debug:!1,_rawSubscribers:[],_deferredChangeRecords:null,_deferredChangeScheduled:!1,pause(){this._pauseDepth===0&&this._deliverBeforePause(),this._pauseDepth++,typeof window<"u"&&window.clay?.undo?.pause&&window.clay.undo.pause(),this._log("Paused",this._pauseDepth)},_deliverBeforePause(){if(!this._observer)return;let e=this._observer.takeRecords();e.length&&this._onRecords(e)},dropQueued(){this._observer&&this._drainBrowserQueue(this)},resume(){this._pauseDepth!==0&&(this._pauseDepth--,this._pauseDepth===0&&this._observer&&this._drainBrowserQueue(this),typeof window<"u"&&window.clay?.undo?.resume&&window.clay.undo.resume(),this._log("Resumed",this._pauseDepth))},_log(e,t=null,s="log"){if(!this.debug)return;let i=`[Mutation ${new Date().toISOString()}]`;t?console[s](i,e,t):console[s](i,e)},_notify(e,t,s=!1){this._log(`Notifying ${this._callbacks[e].length} callbacks of type "${e}"`,{changes:t});for(let r of this._callbacks[e]){if(s&&r.pausable!==!1)continue;let{fn:i,debounce:u=0,maxWait:l=0,selectorFilter:n,omitChangeDetails:c,require:h,skip:d}=r,f=t.filter(o=>{if(h!=="observed"&&v(o))return!1;let a=m(this._policyForChange(o),h,d);if(!o.policyTransition)return!a;let b=m(o.previousPolicy,h,d);return!(a&&b)});if(!f.length){this._log("No changes passed the region policy, skipping callback");continue}if(n&&(this._log("Applying selector filter",{selectorFilter:n}),f=f.filter(o=>{if(typeof n=="string"){let a=o.element.matches?.(n)||!1;return this._log(`Selector "${n}" match:`,{element:o.element,matches:a}),a}if(typeof n=="function"){let a=n(o.element);return this._log("Custom filter match:",{element:o.element,matches:a}),a}return!1}),this._log("Changes after filtering:",{filteredChanges:f})),!f.length){this._log("No changes passed the filter, skipping callback");continue}if(u===0)try{c?i():i(f)}catch(o){this._log("Error in callback execution:",o,"error"),console.error("Error in Mutation callback:",o)}else{r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.firstPendingAt||(r.firstPendingAt=Date.now());let o=l>0?Math.max(0,Math.min(u,l-(Date.now()-r.firstPendingAt))):u;c?r.timeout=setTimeout(()=>{r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback (no details)"),i()}catch(a){this._log("Error in callback execution:",a,"error"),console.error("Error in Mutation callback:",a)}},o):(r.pendingChanges||(r.pendingChanges=[]),r.pendingChanges.push(...f),r.timeout=setTimeout(()=>{let a=r.pendingChanges;r.pendingChanges=null,r.timeout=null,r.firstPendingAt=null;try{this._log("Executing debounced callback with changes:",{changes:a}),a&&a.length>0&&i(a)}catch(b){this._log("Error in callback execution:",b,"error"),console.error("Error in Mutation callback:",b)}},o))}}},_policyForChange(e){if(e.__policy)return e.__policy;let t=e.element,s=g(t);return e.parent&&t&&t.isConnected===!1&&(s=S(s,g(e.parent))),e.__policy=s,s},_onRecords(e){let t=A(e);t.length&&(this._fanOutRaw(t),this._handleMutations(t))},_fanOutRaw(e){if(!(!this._rawSubscribers.length||!e.length))for(let t of this._rawSubscribers)try{t.cb(e)}catch(s){this._log("Error in raw subscriber callback:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}},_drainBrowserQueue(e){let t=A(this._observer?this._observer.takeRecords():[]),s=!!e&&this._rawSubscribers.indexOf(e)!==-1;if(t.length){for(let r of this._rawSubscribers)r!==e&&(r.buffer.push(...t),this._scheduleBufferFlush(r));s?this._deferChangeLane(t):this._hasNonPausable&&this._processMutations(t,!0)}if(s){let r=e.buffer;return e.buffer=[],r.length?r.concat(t):t}return t},_scheduleBufferFlush(e){e._flushScheduled||(e._flushScheduled=!0,queueMicrotask(()=>{if(e._flushScheduled=!1,!e.buffer.length)return;let t=e.buffer;e.buffer=[];try{e.cb(t)}catch(s){this._log("Error in raw subscriber flush:",s,"error"),console.error("Error in Mutation raw subscriber:",s)}}))},_deferChangeLane(e){this._deferredChangeRecords||(this._deferredChangeRecords=[]),this._deferredChangeRecords.push(...e),!this._deferredChangeScheduled&&(this._deferredChangeScheduled=!0,queueMicrotask(()=>{this._deferredChangeScheduled=!1;let t=this._deferredChangeRecords;this._deferredChangeRecords=null,t&&t.length&&this._handleMutations(t)}))},subscribeRaw(e){let t={cb:e,buffer:[],_flushScheduled:!1};return this._rawSubscribers.push(t),this._startObserving(),{drain:()=>this._drainBrowserQueue(t),unsubscribe:()=>{let s=this._rawSubscribers.indexOf(t);s!==-1&&this._rawSubscribers.splice(s,1)}}},createObserver(e){let t=null;return{observe:s=>{if(s!==document.body)throw new Error("Mutation.createObserver only supports observing document.body");this._startObserving(),t||(t=this.subscribeRaw(e))},disconnect:()=>{t&&(t.unsubscribe(),t=null)},takeRecords:()=>t?t.drain():[]}},_handleMutations(e){if(this._pauseDepth>0){if(!this._hasNonPausable){this._log(`Skipping ${e.length} mutations (paused)`);return}this._processMutations(e,!0);return}this._processMutations(e,!1)},_processMutations(e,t=!1){let s=[],r={add:[],remove:[],attribute:[],characterData:[]};for(let i of e){let u=i.type==="attributes"&&w(i.attributeName);if(!(!u&&_(i.target))&&!(i.type==="attributes"&&i.attributeName&&E.test(i.attributeName.toLowerCase()))){if(i.type==="characterData"){this._log("Processing characterData mutation",{element:i.target.parentElement,oldValue:i.oldValue,newValue:i.target.textContent});let l={type:"characterData",element:i.target.parentElement??P,oldValue:i.oldValue,newValue:i.target.textContent};s.push(l),r.characterData.push(l)}if(i.type==="childList"){this._log("Processing childList mutation",{addedNodes:i.addedNodes,removedNodes:i.removedNodes});for(let n of i.addedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} added nodes`,{addedNodes:c});for(let h of c){let d={type:"add",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.add.push(d)}}for(let n of i.removedNodes)if(n.nodeType===1&&!_(n)){let c=[n,...n.querySelectorAll("*")];this._log(`Processing ${c.length} removed nodes`,{removedNodes:c});for(let h of c){let d={type:"remove",element:h,parent:i.target,previousSibling:i.previousSibling,nextSibling:i.nextSibling};s.push(d),r.remove.push(d)}}let l=!1;for(let n of i.addedNodes)if(n.nodeType===3){l=!0;break}if(!l){for(let n of i.removedNodes)if(n.nodeType===3){l=!0;break}}if(l&&i.target.nodeType===1){let n={type:"characterData",element:i.target,oldValue:void 0,newValue:i.target.textContent};s.push(n),r.characterData.push(n)}}if(i.type==="attributes"){this._log("Processing attribute mutation",{element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName)});let l={type:"attribute",element:i.target,attribute:i.attributeName,oldValue:i.oldValue,newValue:i.target.getAttribute(i.attributeName),policyTransition:u,previousPolicy:u?F(i):null};s.push(l),r.attribute.push(l)}}}if(s.length){if(this._log("Processing collected changes",{total:s.length,byType:{add:r.add.length,remove:r.remove.length,attribute:r.attribute.length}}),!t&&O()){for(let u of s)if(!v(u)&&!m(this._policyForChange(u),"dirty")){N();break}}this._notify("anyChange",s,t);let i=[...r.add,...r.remove];i.length&&this._notify("addOrRemove",i,t),r.add.length&&this._notify("addElement",r.add,t),r.remove.length&&this._notify("removeElement",r.remove,t),r.attribute.length&&this._notify("attribute",r.attribute,t)}},_observer:null,_initializeObserver(){this._observer||(this._log("Initializing MutationObserver"),this._observer=new MutationObserver(this._onRecords.bind(this)))},_addCallback(e,t={},s){this._log("Adding callback",{type:e,options:t}),t.debug&&(this.debug=!0);let r={fn:s,debounce:t.debounce||0,maxWait:t.maxWait||0,selectorFilter:t.selectorFilter,omitChangeDetails:t.omitChangeDetails,require:t.require,skip:t.skip,pausable:t.pausable!==!1,timeout:null,pendingChanges:null,firstPendingAt:null};return this._callbacks[e].push(r),this._recomputeHasNonPausable(),this._log(`Added callback to ${e}. Total callbacks:`,{[e]:this._callbacks[e].length}),this._startObserving(),()=>{this._log("Removing callback",{type:e});let i=this._callbacks[e].indexOf(r);i!==-1&&(clearTimeout(r.timeout),r.pendingChanges=null,this._callbacks[e].splice(i,1),this._recomputeHasNonPausable(),this._log(`Removed callback from ${e}. Remaining callbacks:`,{[e]:this._callbacks[e].length}))}},_recomputeHasNonPausable(){this._hasNonPausable=Object.values(this._callbacks).some(e=>e.some(t=>t.pausable===!1))},_startObserving(){if(this._observing){this._log("Already observing, skipping initialization");return}this._log("Starting observation"),this._initializeObserver(),this._observer.observe(document.documentElement,{childList:!0,attributes:!0,subtree:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this._observing=!0,this._log("Observation started")},onAnyChange(e={},t){return this._addCallback("anyChange",e,t)},onAddOrRemove(e={},t){return this._addCallback("addOrRemove",e,t)},onAddElement(e={},t){return this._addCallback("addElement",e,t)},onRemoveElement(e={},t){return this._addCallback("removeElement",e,t)},onAttribute(e={},t){return this._addCallback("attribute",e,t)},ensureObserving(){this._startObserving()}},D=typeof window<"u"&&window.__clayMutation,p=D||V;if(typeof window<"u"&&!D){window.__clayMutation=p,window.clay=window.clay||{},window.clay.Mutation=p;try{document.dispatchEvent(new CustomEvent("clay:mutation-ready",{detail:{Mutation:p}}))}catch{}}var B=p;function F(e){let t=e.target,s=t.cloneNode(!1),r=s;for(;t.parentElement;){t=t.parentElement;let i=t.cloneNode(!1);i.appendChild(s),s=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),g(r)}export{B as a,L as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-
|
|
1
|
+
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}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-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=.8,c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},L=`.clay-owner {
|
|
2
2
|
--hcp-surface: light-dark(#FFFCF6, #11131E);
|
|
3
3
|
--hcp-ground: var(--bevel-surface, var(--hcp-surface));
|
|
4
4
|
--hcp-ink: light-dark(#2B241B, #ECEAF2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./c-BKM46LUJ.js";import{d as h,h as p,w as g}from"./c-
|
|
1
|
+
import{a as d}from"./c-BKM46LUJ.js";import{d as h,h as p,w as g}from"./c-AI3H6ETU.js";import{E as u,X as c,d as m,ea as f}from"./c-OH2FPYSY.js";import{b as l}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{TextSelection:b}=l;function T(r,t){let e=p(r.state.doc),n=e.findIndex(o=>o.node.attrs.id===t);if(n<0)return h(r,"That link's block is gone"),null;let s=[];for(let o=e[n].up;o>=0;o=e[o].up)e[o].node.type===m.nodes.toggle&&!e[o].open&&s.push(e[o].node.attrs.id);let i=r.state.tr.setSelection(b.create(r.state.doc,e[n].at+1)).setMeta("addToHistory",!1);return r.dispatch(g(i,s).scrollIntoView()),e[n]}var a=class{constructor(t,e){this.node=t,this.view=e,this.doc=e.state.doc;let n=e.dom.ownerDocument;this.dom=n.createElement("div"),this.dom.className="blockeditor-toc",this.dom.contentEditable="false",this.dom.setAttribute("role","group"),this.dom.setAttribute("aria-label","Table of contents"),this.dom.addEventListener("mousedown",s=>{s.target.closest?.("a")&&s.preventDefault()}),this.dom.addEventListener("click",s=>{let i=s.target.closest?.("a");if(!i)return;s.preventDefault();let o=d(i.getAttribute("href"));o!==null&&T(this.view,o)}),this.render()}update(t){return this.node=t,this.view.state.doc!==this.doc&&(this.doc=this.view.state.doc,this.render()),!0}render(){let t=c(this.node.attrs,f(u(this.doc)));this.dom.innerHTML!==t&&(this.dom.innerHTML=t)}stopEvent(t){return!!t.target.closest?.("a")}ignoreMutation(){return!0}};function I(){return{id:"toc",nodeViews:{toc:(r,t)=>new a(r,t)},css:null,dispose(){}}}export{a as TocView,I as createFeature,T as followTocLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-
|
|
1
|
+
import{a as f,b as u}from"./c-7SWMYKAI.js";import{b as l}from"./c-UGHH4MB3.js";import{a as s}from"./c-MZCOGNZL.js";var c=(t=[])=>i=>{let e=(i.getAttribute("clay")??"").split(/\s+/).filter(Boolean),n=["no-dirty",...t].filter(r=>!e.includes(r));n.length&&i.setAttribute("clay",[...e,...n].join(" "))},p=c();function S(t,i){return y(t,i)}function b(t,i,e,n=[]){return y(t,i,e,n)}function y(t,i,e,n=[]){let r=typeof i=="string",a=r?{name:t,legacyId:e}:{href:f(t)},d=e===void 0?[]:document.querySelectorAll(`style[id="${e}"]:not([data-name])`);s.pause();try{l(a);for(let o of d)o.dataset.name=t;if(r){let o=u(t,i,c(n));return e!==void 0&&(o.id=e),o}return u(t,o=>{p(o),o.getAttribute("href")!==t&&o.setAttribute("href",t)})}finally{s.resume()}}export{S as a,b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-
|
|
1
|
+
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-RETTCOWO.js";import{a as f}from"./c-
|
|
1
|
+
import{a as T,b as x,c as m,d as D,e as P}from"./c-IW6GGOU2.js";import{a as y}from"./c-HAWFNBYG.js";import{b}from"./c-RETTCOWO.js";import{a as f}from"./c-MZCOGNZL.js";var E="\uFFFC";function g(t){let r=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);if(n.type.name!=="heading"||n.attrs.level!==1||(n.attrs.parent??null)!==null)continue;let o="";n.forEach(l=>{o+=l.isText?l.text:l.type.name==="hard_break"?E:""}),r.push({t:"heading",level:1,parent:null,c:o});break}return r}function d(t){if(!t||t.isDestroyed)return null;let r=t.dom?.ownerDocument??(typeof document>"u"?null:document);if(!r)return null;let s=g(t.state.doc),{custom:n,title:o}=P(r,s);if(n)return o;let l=m(r);if(l===""&&!s.length||l===o)return o;f.pause();try{D(r,o)}finally{f.resume()}return o}function L(t){let r=t?.dom?.ownerDocument??null;if(!r||T(r)||g(t.state.doc).length||["",y].includes(m(r).trim()))return!1;f.pause();try{return x(r)}finally{f.resume()}}function C(){return new b.Plugin({view(t){let r=null,s=()=>{r=t.state.doc,d(t)};return L(t),s(),{update(n){n.state.doc!==r&&s()}}}})}function O(t){let r=t?.dom?.ownerDocument?.head??null;if(!r)return{refresh:()=>d(t),dispose(){}};let s=!1,n=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,d(t)}))},o=new MutationObserver(n);return o.observe(r,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["content","name"]}),d(t),{refresh:n,dispose(){o.disconnect()}}}function I({load:t,install:r,reportError:s=n=>console.error("clayjs: an editor feature failed to load",n)}){let n=new Map,o=new Map,l=new Map,c=!1;function v(e){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));let u=l.get(e);return u||(u=Promise.resolve(t(e)),l.set(e,u),u.catch(()=>{})),u}function F(e){let u=l.get(e);return u?(l.delete(e),u):t(e)}function M(e,{signal:u}={}){if(c)return Promise.reject(new Error(`page: feature loader disposed before ${e}`));if(n.has(e))return Promise.resolve(n.get(e));let i=o.get(e);return i||(i=F(e).then(a=>c?null:Promise.resolve(r(e,a))).then(a=>c?(a?.dispose?.(),a):(n.set(e,a),a)),i.catch(a=>{c||s(a,e)}).finally(()=>o.delete(e)),o.set(e,i)),u?u.aborted?Promise.reject(u.reason):new Promise((a,p)=>{let h=()=>p(u.reason);u.addEventListener("abort",h,{once:!0}),i.then(a,p).finally(()=>u.removeEventListener("abort",h))}):i}return{prepare:v,ensure:M,has:e=>n.has(e),dispose(){c=!0;for(let e of n.values())e?.dispose?.();n.clear(),o.clear(),l.clear()}}}export{C as a,O as b,I as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-
|
|
1
|
+
import{b as a}from"./c-PZ4XEPUP.js";import{L as u}from"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import{i as s}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d=20,i=null,l=!1,c=[];function h(){i||l||(l=!0,import("./c-OIDRZKAF.js").then(e=>{i=e,l=!1,f()},e=>{l=!1,console.error("clayjs: the conflict recovery module could not be downloaded; conflicts stay in this tab only",e)}))}function f(){if(!i){h();return}for(;c.length;){let e=c.shift();try{i.recordConflicts(e)}catch(o){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",o)}}}function m(e,o){let t=null;try{t=a(e)}catch{}let n=r=>r?(r.cutBefore?"\u2026":"")+r.before+r.hit+r.after+(r.cutAfter?"\u2026":""):"";return{id:String(e.id),kind:String(e.kind??""),key:e.recovery?.key==null?"":String(e.recovery.key),name:t?.name?String(t.name):"",sentence:t?.sentence?String(t.sentence):"",yours:n(t?.yours),now:n(t?.now),context:o}}function y(e){try{let t=(e.recoveryRoot??e.root)?.cloneNode?.(!0);if(!t)return null;for(let n of s)t.removeAttribute(n);return u(t,{prepared:e.domain==="save"})}catch(o){return console.error("clayjs: the conflict recovery page could not be serialized; the conflict text is still stored",o),null}}function k({apply:e,records:o}){try{c.push({apply:{id:e.id,source:e.source,domain:e.domain,seq:e.seq,etag:e.etag,ticket:e.ticket},root:y(e),conflicts:o.map(({rec:t,context:n})=>m(t,n))}),c.length>d&&c.shift(),f()}catch(t){console.error("clayjs: the conflict could not be stored for a later reload; it is still here",t)}}function A(e){import("./c-OIDRZKAF.js").then(o=>o.dismissConflicts(e),()=>{}).catch(()=>{})}export{A as dismiss,k as keep};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./c-WYFDLITL.js";import{a as o}from"./c-MZCOGNZL.js";import{f as c}from"./c-C7SUMNMI.js";import{f as l}from"./c-U4TWEIKZ.js";import{n as p,o as m}from"./c-ICMAOOGK.js";var n=0,h=0,d=!1,y=!1,g=!1,f=!1;function i(){!c||f||(f=!0,queueMicrotask(()=>{if(f=!1,typeof document>"u")return;let e=C();if(e===g)return;g=e;let t=document.documentElement;e?t.setAttribute("unsaved","true"):t.removeAttribute("unsaved"),document.dispatchEvent(new CustomEvent(e?"clay:dirty":"clay:clean"))}))}var S=`input${u}, textarea${u}, select${u}`,v=`${p}, ${m}`,s=new WeakMap;function x(){let e=[];for(let t of document.querySelectorAll(S))t.closest(v)||e.push(t);return e}function E(e){let t=e.target;!t||t.nodeType!==1||(t.matches("input, textarea, select")||t.isContentEditable)&&(t.closest(v)||(n++,i()))}function T(){y||(y=!0,o.onAnyChange({omitChangeDetails:!0,require:"dirty"},()=>{d||(n++,i())}),document.addEventListener("input",E,!0),document.addEventListener("change",E,!0),l({token:w,unchangedSince:R}))}function P(){d=!0}function H(){d=!1}function a(e){return e instanceof HTMLSelectElement?Array.from(e.selectedOptions,t=>t.value).join("\0"):e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?e.checked?"1":"0":e.value}function M(e){return e instanceof HTMLSelectElement?Array.from(e.options).every(t=>t.selected===t.defaultSelected):e instanceof HTMLInputElement?e.type==="checkbox"||e.type==="radio"?e.checked===e.defaultChecked:e.value===e.defaultValue:e instanceof HTMLTextAreaElement?e.hasAttribute("data-value")?e.value===e.getAttribute("data-value"):e.value===e.defaultValue:!0}function b(){for(let e of x()){let t=a(e);if(s.get(e)!==t){if(M(e)){s.set(e,t);continue}return!0}}return!1}function C(){return n>h||b()}function G(){return n}function A(){let e=[];for(let t of x())e.push([t,a(t)]);return{gen:n,probe:e}}function w(){return o._deliverBeforePause(),A()}function R(e){return e?(o._deliverBeforePause(),n===e.gen&&e.probe.every(([t,r])=>a(t)===r)):!1}function D(){n++,i()}function $(e){if(e){n===e.gen&&(h=e.gen);for(let[t,r]of e.probe)a(t)===r&&s.set(t,r);i()}}typeof document<"u"&&c&&T();typeof window<"u"&&(window.clay=window.clay||{},window.clay.markDirty=D);export{T as a,P as b,H as c,C as d,G as e,A as f,D as g,$ as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./c-XQXZAO7N.js";import{e as Y}from"./c-S7LK4KUE.js";import{c as z}from"./c-
|
|
1
|
+
import{a as $}from"./c-XQXZAO7N.js";import{e as Y}from"./c-S7LK4KUE.js";import{c as z}from"./c-MOP5KBWZ.js";import{b as H,i as I,o as F}from"./c-HA6INT6J.js";import{c as D,h as A,j as T,k as _,n as C,o as L}from"./c-ICMAOOGK.js";var K=[],f=[],g=new WeakMap,w=null,U=null,b=0;function de(){return b}function G(e){return g.get(e)||null}var M=new WeakMap,v=null;function he(){return v}function me(e){v&&e&&(v.artifact=e)}var R=null,x=new Map;function ye(e){R=e}function ve(e){return e==null?null:x.get(e)??null}function Se(e){return e&&M.get(e)||null}function X(e){e&&(M.delete(e),x.delete(e.captureId))}function J(e){let t=o=>{if(o.hasAttribute("onbeforesave")||o.hasAttribute("onbeforesnapshot"))return!0;let r=o.localName==="template"&&o.content?o.content:o;for(let n of r.children)if(t(n))return!0;return!1};return e.nodeType===1?t(e):!1}function a(e){for(let t of e.querySelectorAll(L))t.remove()}function m(e,t){for(let o of e.querySelectorAll(`[${t}]`))if(a(e),!(o!==e&&!e.contains(o)))try{new Function(o.getAttribute(t)).call(o)}catch(r){console.error(`[${t}] handler failed:`,r)}}var O=null;function Ce(e){O=e}function xe(e){return O?.(e),e}function Ae(e){K.push(e)}function Te(e,{steps:t=null}={}){w=e,U=t}var j="http://www.w3.org/1999/xhtml";function P(e){let t=B(e);if(!t.length)return"<!DOCTYPE html>"+e.outerHTML;let o=V(t),r;try{r="<!DOCTYPE html>"+e.outerHTML}finally{for(let[n,c]of t)n.replaceChildren(...c)}for(let[n,c]of o)r=r.split(n).join(c);return r}function B(e){let t=[],o=r=>{for(let n of r.childNodes)if(n.nodeType===1){if(n.localName==="noscript"&&n.namespaceURI===j){let c=Array.from(n.childNodes);c.length&&c.every(l=>l.nodeType===3)&&t.push([n,c]);continue}o(n.localName==="template"&&n.content?n.content:n)}};return o(e),t}function ge(e){let t=[],o=r=>{for(let n of r.childNodes)if(n.nodeType===1){if(n.localName==="noscript"&&n.namespaceURI===j){n.firstChild&&t.push(n);continue}o(n.localName==="template"&&n.content?n.content:n)}};o(e.documentElement??e);for(let r of t)r.replaceChildren(r.ownerDocument.createTextNode(r.innerHTML));return e}function V(e){let t=Math.random().toString(36).slice(2);return e.map(([o,r],n)=>{let c=`\uE000clay-noscript-${t}-${n}\uE000`;return o.replaceChildren(o.ownerDocument.createTextNode(c)),[c,r.map(l=>l.data).join("")]})}function W(e,t){let o=v;v=e;try{return t()}finally{v=o}}function N(e,t=null){if(t&&R){let r=null;try{r=R(e)}catch{}r&&x.set(t.captureId,r)}let o=P(e);if(!w)return o;try{return W(t,()=>w(e,o))}catch(r){return console.error("clayjs: save renderer failed, sending the full serialization",r),o}}function we(e){f.push(e)}function h(e,t=!0){let o=window.__preventOnclone;window.__preventOnclone=!0;try{return e.cloneNode(t)}finally{window.__preventOnclone=o}}function k(e,t){let o=g.get(e);o&&g.set(t,o);let r=e.children,n=t.children;for(let c=0;c<r.length;c++)k(r[c],n[c])}function p({flushUndo:e=!0,authored:t=!0,forSave:o=!1,requestRefresh:r=!1,context:n=null}={}){e&&typeof window<"u"&&window.clay?.undo?.flush&&window.clay.undo.flush();let l=$(document.documentElement,{capability:"snapshot",provenance:g}).root;for(let u of K)a(l),u(l,{original:G,forSave:o,requestRefresh:r});return Y(l),O?.(l),a(l),n&&(n.authoredHandlers=J(l)),t&&m(l,"onbeforesnapshot"),a(l),D(l),F(l),H(l),l}function E(e,{authored:t=!0}={}){a(e),t&&m(e,"onbeforesave");for(let o of f)a(e),o(e);a(e);for(let o of e.querySelectorAll(A))o.remove();return q(e),e}function q(e){for(let t of e.querySelectorAll("[sap-error]"))t.removeAttribute("sap-error")}function Q({flushUndo:e=!0,authored:t=!0}={}){return E(p({flushUndo:e,authored:t}),{authored:t})}var Z=["style","class"];function ee(e){z(e);for(let t of Z){e.getAttribute(t)===""&&e.removeAttribute(t);for(let o of e.querySelectorAll(`[${t}=""]`))o.removeAttribute(t)}}function S(e){return ee(e),"<!DOCTYPE html>"+e.outerHTML}function Re({flushUndo:e=!0}={}){let t=p({flushUndo:e});m(t,"onbeforesave");for(let o of t.querySelectorAll(T))o.remove();for(let o of f)a(t),o(t);return a(t),S(t)}function ke({flushUndo:e=!0}={}){let t=p({flushUndo:e});m(t,"onbeforesave");for(let o of t.querySelectorAll(C))o.remove();for(let o of f)a(t),o(t);return a(t),S(t)}function Ee({flushUndo:e=!0}={}){let t=p({flushUndo:e});m(t,"onbeforesave");let o=t.querySelector(_)?h(t):null;o&&k(t,o);for(let c of t.querySelectorAll(T))c.remove();for(let c of f)a(t),c(t);a(t);let r=S(t),n=r;if(o){for(let c of o.querySelectorAll(C))c.remove();for(let c of f)a(o),c(o);a(o),n=S(o)}return{forComparison:r,forDirty:n}}function te({emitForSync:e=!0,flushUndo:t=!0,requestRefresh:o=!1,forRequest:r=!1,pageFormatMarker:n=null,sliced:c=!1}={}){if(!Number.isSafeInteger(b+1))throw new Error("Save capture identity exhausted");let l=++b,u=r?{captureId:l,authoredHandlers:!1,artifact:null}:null,s=p({flushUndo:t,forSave:e,requestRefresh:o,context:u});e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:s,forSave:!0,captureId:l,sliced:c}})),m(s,"onbeforesave");let y=h(s);k(s,y);let d=s.querySelector(_)?h(s):null;d&&k(s,d);for(let i of f)a(s),i(s);a(s);for(let i of s.querySelectorAll(A))i.remove();q(s);for(let i of y.querySelectorAll(T))i.remove();for(let i of f)a(y),i(y);if(a(y),d){for(let i of d.querySelectorAll(C))i.remove();for(let i of f)a(d),i(d);a(d)}return{captureId:l,context:u,pageFormatMarker:n,clone:s,compareClone:y,dirtyClone:d,renderer:w,rendererSteps:U,pageStateReader:R,result:null}}function oe(e){if(!e.context||!e.pageStateReader)return;let t=null;try{t=e.pageStateReader(e.clone)}catch{}t&&x.set(e.captureId,t)}function re(e,{forSave:t,forComparison:o,forDirty:r}){let n={forSave:t,forComparison:o,forDirty:r,captureId:e.captureId};return e.context&&e.context.artifact&&M.set(n,e.context.artifact),e.result=n,n}function ne(e){X(e.result),x.delete(e.captureId),e.context&&(e.context.artifact=null),e.clone=e.compareClone=e.dirtyClone=null,e.result=null}function _e(e={}){let t=te(e);try{oe(t);let o=P(t.clone),r=t.compareClone?S(t.compareClone):null,n=t.dirtyClone?S(t.dirtyClone):r,c=t.renderer?W(t.context,()=>t.renderer(t.clone,o)):o;return re(t,{forSave:c,forComparison:r,forDirty:n})}catch(o){throw ne(t),o}}function be(){let e=p({flushUndo:!1});m(e,"onbeforesave");let t=h(e),o=new WeakMap;(function r(n,c){o.set(n,c);let l=n.children,u=c.children;for(let s=0;s<l.length;s++)r(l[s],u[s])})(t,e);for(let r of f)a(e),r(e);a(e);for(let r of e.querySelectorAll(A))r.remove();q(e);for(let r of t.querySelectorAll(C))r.remove();for(let r of f)a(t),r(t);return a(t),{saveClone:e,compareClone:t,pairMap:o}}function ce({emitForSync:e=!0}={}){let t=p();return e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:t}})),N(E(t))}function Me(e){let t=h(e,!1);for(let u of I)t.removeAttribute(u);let o=t.outerHTML,r=`</${t.localName}>`,n=B(e),c=n.length?V(n):[],l;try{l=e.innerHTML}finally{for(let[u,s]of n)u.replaceChildren(...s)}for(let[u,s]of c)l=l.split(u).join(s);return"<!DOCTYPE html>"+o.slice(0,o.length-r.length)+l+r}function Oe(e){return h(e)}function Pe(){return p().querySelector("body").innerHTML}function Ne({transform:e=null,flushUndo:t=!0}={}){if(!e&&t)return ce({emitForSync:!1});let o=p({flushUndo:t});if(e){let r=e(o);if(r&&typeof r.then=="function")throw new TypeError("getHTML: the transform must be synchronous")}return N(E(o))}function qe(e,{prepared:t=!1}={}){let o=h(e);return P(t?o:E(o,{authored:!1}))}function He(){return N(Q({flushUndo:!1,authored:!1}))}export{de as a,G as b,he as c,me as d,ye as e,ve as f,Se as g,X as h,Ce as i,xe as j,Ae as k,Te as l,P as m,B as n,ge as o,V as p,W as q,we as r,h as s,p as t,Q as u,ee as v,S as w,Re as x,ke as y,Ee as z,te as A,oe as B,re as C,ne as D,_e as E,be as F,ce as G,Me as H,Oe as I,Pe as J,Ne as K,qe as L,He as M};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as me,b as pe,c as he}from"./c-SIM7Z3U7.js";import{a as de,b as fe}from"./c-OYW5MFPZ.js";import{a as F,b as U,c as ue}from"./c-H3FNLBHN.js";import{C as X,E as le,h as z,l as ce,m as Y}from"./c-ZRGEN6QQ.js";import{A as se,d as N,x as oe}from"./c-OH2FPYSY.js";import"./c-VPXCXBDT.js";import{b as $,c as ae,d as R}from"./c-Z6MROEQ4.js";import{b as ie}from"./c-Q26XHBLQ.js";import{a as H,b as V}from"./c-RETTCOWO.js";import{a as re}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var ge=16384,we=i=>new TextEncoder().encode(JSON.stringify(i)).length,G=class extends Error{constructor(n,t=n){super(t),this.name="ToolRequestError",this.code=n}};function Oe(i){let n=re(i);for(Array.isArray(n.tables)||(n.tables=[]),Array.isArray(n.outline)||(n.outline=[]);we(n)>ge;){let t=[...n.tables].reverse().find(r=>Array.isArray(r.rows)&&r.rows.length);if(t)t.rows.pop();else if(n.outline.length)n.outline.pop();else break}if(we(n)>ge)throw new G("context-too-large");return n}var Me=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function ve({transport:i,newId:n=Me}){let t=null,r=s=>{!s||s.discarded||s.done||(s.discarded=!0,t===s&&(t=null),i.cancel(s.requestId),s.resolve({requestId:s.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(s,a,v=null,h=null){let o=Oe(a);t&&r(t);let m=n(),l={requestId:m,discarded:!1,done:!1};l.promise=new Promise(u=>{l.resolve=u}),t=l;let e={protocol:"blockeditor-tool/1",requestId:m,prompt:s,context:o,target:v,current:h};l.request=e;let f=u=>{if(!(l.discarded||l.done||u?.requestId!==m))if(l.done=!0,t===l&&(t=null),u?.artifact!==void 0){let g=F(u.artifact),d=U(u.state),p=g.ok?d.ok?null:d:g;l.resolve(p?{requestId:m,code:p.code,message:p.code}:u)}else l.resolve(typeof u?.code=="string"?u:{requestId:m,code:"invalid-result",message:"invalid-result"})};try{let u=g=>f({requestId:m,code:typeof g?.code=="string"?g.code:"transport-error",message:String(g?.message??g)});Promise.resolve(i.request(e)).then(f,u)}catch(u){f({requestId:m,code:typeof u?.code=="string"?u.code:"transport-error",message:String(u?.message??u)})}return l},discard:r,async wait(s,{signal:a}={}){if(a?.aborted)throw new DOMException("Aborted","AbortError");let v,h=await(a?Promise.race([s.promise,new Promise((o,m)=>{v=()=>m(new DOMException("Aborted","AbortError")),a.addEventListener("abort",v,{once:!0})})]).finally(()=>a.removeEventListener("abort",v)):s.promise);if(h?.code)throw new G(h.code,h.message);return h}}}var J=class extends Error{constructor(n){super(n),this.name="ToolTransportError",this.code=n}};function ye({getWire:i=()=>globalThis.window?.clay?.wire??null}={}){let n=new Map;return{request(t,{onStatus:r=null}={}){let s=i();if(!s||typeof s.send!="function")return Promise.reject(new J("no-wire"));let a=t?.requestId,v;try{v=s.send(t,{helper:"blockeditor-tool",document:"none",id:a,onStatus:r})}catch{return Promise.reject(new J("no-wire"))}return n.set(a,v),Promise.resolve(v.done).then(h=>{if(n.get(a)===v&&n.delete(a),h?.state==="done"){let o=h.result??{};return{requestId:typeof o.requestId=="string"?o.requestId:a,artifact:o.artifact,state:o.state,model:o.model}}return{requestId:a,code:h?.errorCode||(h?.state==="cancelled"?"cancelled":"transport-error"),message:h?.error||"the helper reported an error"}},()=>({requestId:a,code:"transport-error",message:"the helper reported an error"}))},cancel(t){let r=n.get(t);n.delete(t),r?.cancel?.()}}}var{Selection:Be}=V,W="This page is not open for editing any more.",Ie="AI tool making isn't available on this page right now.",Te="This document can't save tool data.",K="The place for this tool moved. Close this and run /ai where you want the tool.",be="This tool changed while you were revising, so nothing was replaced. Ask again.",Q="AI did not make a usable tool. Try again.",Ne="The tool data from AI is too large or not usable. Try again.",xe="This tool's data changed while AI was working, so it was not replaced. Ask again to include the latest data.",Ae="The tool could not be saved, so it was not added. Try again.",Re="Your tool is in the document, but saving failed. It will be saved with your next edit.";function _(i,n){let t=null;return i.forEach((r,s,a)=>{r.attrs.id===n&&(t={node:r,at:s,index:a})}),t}function Pe(i,n){let t=i.selection.$head,r=Math.min(Math.max(t.index(0),0),i.doc.childCount-1);return{hostId:i.doc.child(r)?.attrs.id??null,slashText:n?i.doc.textBetween(n.from,n.to):null,slashOffset:n&&t.depth?n.from-t.before(1)-1:null}}function Z(i,n){let t=n?.hostId?_(i.doc,n.hostId):null;if(!t)return null;let r=i.doc.maybeChild(t.index+1),s=t.node.isTextblock&&(t.node.content.size===0||t.node.textContent===n.slashText);return{...t,replace:s,pos:s?t.node.attrs.pos:oe(t.node.attrs.pos,r?.attrs.pos??null),insertAt:s?t.at:t.at+t.node.nodeSize}}function _e(i,n,t){let r=i.state,s=Z(r,t);if(!s)return!1;let{node:a,at:v,insertAt:h,replace:o}=s,m=N.nodes.tool.create({id:n.id,pos:s.pos,parent:a.attrs.parent??null,artifact:n.artifact,rev:n.rev,state:n.state}),l=r.tr;if(!o&&t?.hostId===a.attrs.id&&t.slashText&&t.slashOffset>=0){let f=v+1+t.slashOffset,u=f+t.slashText.length;u<=v+a.nodeSize-1&&r.doc.textBetween(f,u)===t.slashText&&l.delete(f,u)}let e=l.mapping.map(h);return l.replaceWith(e,o?l.mapping.map(v+a.nodeSize):e,m),l.setSelection(Be.near(l.doc.resolve(Math.min(e+m.nodeSize,l.doc.content.size)))),i.dispatch(X(l).scrollIntoView()),!0}var Se=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Ee({getView:i,store:n=()=>null,acceptState:t=()=>globalThis.clay?.save?.flush?.(),newId:r=se,transport:s=ye()}={}){let a=()=>{let e=i();return e&&!e.isDestroyed?e:null},v=()=>typeof n=="function"?n():n,h=(e,f)=>{let u=v()?.data?.[e]?.[f];return u===void 0?{}:u},o=new Map,m=e=>Array.isArray(e)?`[${e.map(m).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(u=>`${JSON.stringify(u)}:${m(e[u])}`).join(",")}}`:JSON.stringify(e)??"null";function l(e=null,f=null){let u=a(),g=e||!u?null:Pe(u.state,f),d=null,p=ve({transport:{request:c=>s.request(c,{onStatus:T=>d?.(T)}),cancel:c=>s.cancel(c)}}),b=null,w=null,y=null,M=!1,k=null,O=null,C=()=>{y?.host?.dispose(),y=null},L=()=>{let c=a();return c&&e?ie.get(c)?.get(e)??null:null},j=()=>L()?.suspend(),B=()=>L()?.resume(),q=c=>{M=!1;let T=a();return C(),T&&R(T),B(),{status:"failed",message:c}},ne={aiTarget:!0,label:e?"This tool":"New tool",ref:e?[e]:[],placeholder:e?"What should change?":"Describe the tool",get isConnected(){let c=a();return c?e?!!_(c.state.doc,e):!0:!1},getBoundingClientRect(){let c=a();if(!c)return Se();if(y)return y.dom.getBoundingClientRect();let T=e??g?.hostId,A=T?_(c.state.doc,T):null,E=A?c.nodeDOM(A.at):null;return E&&typeof E.getBoundingClientRect=="function"?E.getBoundingClientRect():Se()},async start(c){w=null,M=!1;let T=a();if(!T)return{status:"refused",code:"gone",message:W};if(!globalThis.window?.clay?.wire)return{status:"refused",code:"no-wire",message:Ie};let A=null,E=null;if(e){let x=_(T.state.doc,e);if(x?.node.type!==N.nodes.tool)return{status:"refused",code:"gone",message:W};k=x.node.attrs.rev,A={toolId:e,rev:k},j(),E={artifact:x.node.attrs.artifact,state:h(e,k)},O=m(E.state)}return b=p.request(c,fe(T.state.doc,T.dom.ownerDocument.title),A,E),{status:"ok",id:b.requestId,send:(x={})=>(d=typeof x.onStatus=="function"?x.onStatus:null,{done:p.wait(b).then(S=>(w={id:e,rev:null,artifact:S.artifact,state:S.state},{state:"done",result:S}),S=>(B(),{state:"error",error:S?.message||S?.code||"the helper reported an error",code:S?.code??null})),cancel:()=>{B(),p.discard(b)}})}},async propose(c){let T=a();if(!T||!c)return{status:"refused",message:W};if(!F(c.artifact).ok)return{status:"refused",message:Q};if(!U(c.state).ok)return{status:"refused",message:Ne};w={id:e,rev:null,artifact:c.artifact,state:c.state};let x=De(T);return x.status!=="ready"&&(w=null),x},async keep(){if(!w||M)return q(be);let c=a();if(!c)return q(W);let T=v();if(!T)return q(Te);let A=()=>e&&O!==null&&m(h(e,k))!==O;if(A())return q(xe);M=!0;let E=w.id??r("b"),x=r("rev"),I={...w,id:E,rev:x};try{await T.set([E,x],I.state)}catch(D){return q(D?.message??Te)}let S=null;try{S=await t()}catch{return q(Ae)}if(S?.ok!==!0&&!["saved","clean"].includes(S?.state))return q(S?.msg??S?.message??Ae);if(e){let D=_(c.state.doc,e);if(D?.node.type!==N.nodes.tool||D.node.attrs.rev!==k)return q(be)}else if(!Z(c.state,g))return q(K);if(A())return q(xe);if(C(),R(c),e){let D=_(c.state.doc,e);c.dispatch(X(c.state.tr.setNodeMarkup(D.at,null,{...D.node.attrs,artifact:I.artifact,rev:I.rev})))}else if(!_e(c,I,g))return q(K);let P=!1;for(let D=0;D<2&&!P;D++)try{P=(await t())?.ok!==!1}catch{P=!1}return P?(o.delete(e??"new"),{status:"kept"}):{status:"failed",message:Re}},discard(){C();let c=a();c&&R(c),p.discard(b),B(),o.delete(e??"new")}};function De(c){C();let T=ue({mode:"view",tables:()=>de(c.state.doc).map(({id:I,cols:S,rows:P})=>({id:I,cols:S,rows:P}))}),A=c.dom.ownerDocument.createElement("div");A.className="blockeditor-ai-preview";let E=null;try{E=T.mount(A,{id:"preview",rev:"preview",artifact:w.artifact,seed:w.state})}catch{return T.dispose(),{status:"refused",message:Q}}if(E.failed)return T.dispose(),{status:"refused",message:Q};if(y={host:T,dom:A},e)return $(c,{ids:[e],dom:A}),{status:"ready"};let x=Z(c.state,g);return x?(x.replace?$(c,{ids:[x.node.attrs.id],dom:A}):ae(c,{at:x.insertAt,dom:A}),{status:"ready"}):(C(),{status:"refused",message:K})}return e&&o.set(e,ne),ne}return{newTool(e=null){return l(null,e)},reviseTool(e){let f=o.get(e);return f?.isConnected?f:(o.delete(e),l(e))}}}var{TextSelection:$e}=V,ze="ai-edit",Le="page area",je="This section is too large for AI editing. Select a smaller part.",Ce="Someone changed this area while AI was working, so nothing was changed.",Ve="This page is not open for editing any more.",Fe="AI editing isn't available on this page right now.",Ue=0;function te(i,n){let t=null;return i.forEach((r,s)=>{r.attrs?.id===n&&(t={node:r,at:s})}),t}var qe=(i,n)=>te(i,n)?.node?.type===N.nodes.tool,ee=(i,n,t)=>i.slice(n,t+1).map(r=>r.node.attrs.id).filter(Boolean),Ge=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ke=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Je(i){if(!i.length)return ke();let n=Math.min(...i.map(a=>a.left)),t=Math.min(...i.map(a=>a.top)),r=Math.max(...i.map(a=>a.right)),s=Math.max(...i.map(a=>a.bottom));return{x:n,y:t,left:n,top:t,right:r,bottom:s,width:r-n,height:s-t}}function We(i,n,t){let r=i.selection;if(!(r instanceof $e)||r.empty)return null;let[s,a]=ce(i.doc,r,n);if(s!==a||t.lo!==s||t.hi!==s)return null;let v=n[s];if(r.from<v.at||r.to>v.end)return null;let h=i.doc.textBetween(r.from,r.to," ");if(!h.trim())return null;let o=i.doc.textBetween(v.at+1,r.from," ").length;return{text:h,start:o,end:o+h.length}}function Tt({getView:i,store:n=()=>null,acceptState:t}={}){let r=()=>{let o=i();return o&&!o.isDestroyed?o:null},s=new Map,a=Ee({getView:r,store:n,acceptState:t}),v=o=>a.reviseTool(o);function h(o,{quote:m=null,label:l=null}={}){for(let[d,p]of s)p.isConnected||s.delete(d);let e=s.get(o.join(","));if(e)return e.quote=m??void 0,e;let f=null,u=null,g={aiTarget:!0,label:l??(o.length===1?"This block":`${o.length} blocks`),ref:[...o],get isConnected(){let d=r();return!!d&&o.some(p=>te(d.state.doc,p))},getBoundingClientRect(){let d=r();if(!d)return ke();let p=d.dom.querySelector(".blockeditor-ai-preview");if(p)return p.getBoundingClientRect();let w=[g.ref[0],g.ref[g.ref.length-1]].map(y=>te(d.state.doc,y)).map(y=>y?d.nodeDOM(y.at):null).filter(y=>y&&typeof y.getBoundingClientRect=="function").map(y=>y.getBoundingClientRect());return Je(w)},async start(d,p){let b=r();if(!b)return{status:"refused",code:"gone",message:Ve};let w=window.clay?.wire;if(!w)return{status:"refused",code:"no-wire",message:Fe};let{captureArea:y,AREA_GUIDE:M}=await import("./c-47IBJGPQ.js"),k=y(b.state.doc,g.ref);if(f=null,u=null,k.status!=="ok")return{status:"refused",code:k.code,message:k.message};let O=p??g.quote,C={id:"req-"+Date.now().toString(36)+"-"+ ++Ue,editId:Le,tag:"div",elementHTML:k.capture.html,comment:d+`
|
|
1
|
+
import{a as me,b as pe,c as he}from"./c-SIM7Z3U7.js";import{a as de,b as fe}from"./c-OYW5MFPZ.js";import{a as F,b as U,c as ue}from"./c-H3FNLBHN.js";import{C as X,E as le,h as z,l as ce,m as Y}from"./c-AI3H6ETU.js";import{A as se,d as N,x as oe}from"./c-OH2FPYSY.js";import"./c-VPXCXBDT.js";import{b as $,c as ae,d as R}from"./c-Z6MROEQ4.js";import{b as ie}from"./c-Q26XHBLQ.js";import{a as H,b as V}from"./c-RETTCOWO.js";import{a as re}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var ge=16384,we=i=>new TextEncoder().encode(JSON.stringify(i)).length,G=class extends Error{constructor(n,t=n){super(t),this.name="ToolRequestError",this.code=n}};function Oe(i){let n=re(i);for(Array.isArray(n.tables)||(n.tables=[]),Array.isArray(n.outline)||(n.outline=[]);we(n)>ge;){let t=[...n.tables].reverse().find(r=>Array.isArray(r.rows)&&r.rows.length);if(t)t.rows.pop();else if(n.outline.length)n.outline.pop();else break}if(we(n)>ge)throw new G("context-too-large");return n}var Me=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function ve({transport:i,newId:n=Me}){let t=null,r=s=>{!s||s.discarded||s.done||(s.discarded=!0,t===s&&(t=null),i.cancel(s.requestId),s.resolve({requestId:s.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(s,a,v=null,h=null){let o=Oe(a);t&&r(t);let m=n(),l={requestId:m,discarded:!1,done:!1};l.promise=new Promise(u=>{l.resolve=u}),t=l;let e={protocol:"blockeditor-tool/1",requestId:m,prompt:s,context:o,target:v,current:h};l.request=e;let f=u=>{if(!(l.discarded||l.done||u?.requestId!==m))if(l.done=!0,t===l&&(t=null),u?.artifact!==void 0){let g=F(u.artifact),d=U(u.state),p=g.ok?d.ok?null:d:g;l.resolve(p?{requestId:m,code:p.code,message:p.code}:u)}else l.resolve(typeof u?.code=="string"?u:{requestId:m,code:"invalid-result",message:"invalid-result"})};try{let u=g=>f({requestId:m,code:typeof g?.code=="string"?g.code:"transport-error",message:String(g?.message??g)});Promise.resolve(i.request(e)).then(f,u)}catch(u){f({requestId:m,code:typeof u?.code=="string"?u.code:"transport-error",message:String(u?.message??u)})}return l},discard:r,async wait(s,{signal:a}={}){if(a?.aborted)throw new DOMException("Aborted","AbortError");let v,h=await(a?Promise.race([s.promise,new Promise((o,m)=>{v=()=>m(new DOMException("Aborted","AbortError")),a.addEventListener("abort",v,{once:!0})})]).finally(()=>a.removeEventListener("abort",v)):s.promise);if(h?.code)throw new G(h.code,h.message);return h}}}var J=class extends Error{constructor(n){super(n),this.name="ToolTransportError",this.code=n}};function ye({getWire:i=()=>globalThis.window?.clay?.wire??null}={}){let n=new Map;return{request(t,{onStatus:r=null}={}){let s=i();if(!s||typeof s.send!="function")return Promise.reject(new J("no-wire"));let a=t?.requestId,v;try{v=s.send(t,{helper:"blockeditor-tool",document:"none",id:a,onStatus:r})}catch{return Promise.reject(new J("no-wire"))}return n.set(a,v),Promise.resolve(v.done).then(h=>{if(n.get(a)===v&&n.delete(a),h?.state==="done"){let o=h.result??{};return{requestId:typeof o.requestId=="string"?o.requestId:a,artifact:o.artifact,state:o.state,model:o.model}}return{requestId:a,code:h?.errorCode||(h?.state==="cancelled"?"cancelled":"transport-error"),message:h?.error||"the helper reported an error"}},()=>({requestId:a,code:"transport-error",message:"the helper reported an error"}))},cancel(t){let r=n.get(t);n.delete(t),r?.cancel?.()}}}var{Selection:Be}=V,W="This page is not open for editing any more.",Ie="AI tool making isn't available on this page right now.",Te="This document can't save tool data.",K="The place for this tool moved. Close this and run /ai where you want the tool.",be="This tool changed while you were revising, so nothing was replaced. Ask again.",Q="AI did not make a usable tool. Try again.",Ne="The tool data from AI is too large or not usable. Try again.",xe="This tool's data changed while AI was working, so it was not replaced. Ask again to include the latest data.",Ae="The tool could not be saved, so it was not added. Try again.",Re="Your tool is in the document, but saving failed. It will be saved with your next edit.";function _(i,n){let t=null;return i.forEach((r,s,a)=>{r.attrs.id===n&&(t={node:r,at:s,index:a})}),t}function Pe(i,n){let t=i.selection.$head,r=Math.min(Math.max(t.index(0),0),i.doc.childCount-1);return{hostId:i.doc.child(r)?.attrs.id??null,slashText:n?i.doc.textBetween(n.from,n.to):null,slashOffset:n&&t.depth?n.from-t.before(1)-1:null}}function Z(i,n){let t=n?.hostId?_(i.doc,n.hostId):null;if(!t)return null;let r=i.doc.maybeChild(t.index+1),s=t.node.isTextblock&&(t.node.content.size===0||t.node.textContent===n.slashText);return{...t,replace:s,pos:s?t.node.attrs.pos:oe(t.node.attrs.pos,r?.attrs.pos??null),insertAt:s?t.at:t.at+t.node.nodeSize}}function _e(i,n,t){let r=i.state,s=Z(r,t);if(!s)return!1;let{node:a,at:v,insertAt:h,replace:o}=s,m=N.nodes.tool.create({id:n.id,pos:s.pos,parent:a.attrs.parent??null,artifact:n.artifact,rev:n.rev,state:n.state}),l=r.tr;if(!o&&t?.hostId===a.attrs.id&&t.slashText&&t.slashOffset>=0){let f=v+1+t.slashOffset,u=f+t.slashText.length;u<=v+a.nodeSize-1&&r.doc.textBetween(f,u)===t.slashText&&l.delete(f,u)}let e=l.mapping.map(h);return l.replaceWith(e,o?l.mapping.map(v+a.nodeSize):e,m),l.setSelection(Be.near(l.doc.resolve(Math.min(e+m.nodeSize,l.doc.content.size)))),i.dispatch(X(l).scrollIntoView()),!0}var Se=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Ee({getView:i,store:n=()=>null,acceptState:t=()=>globalThis.clay?.save?.flush?.(),newId:r=se,transport:s=ye()}={}){let a=()=>{let e=i();return e&&!e.isDestroyed?e:null},v=()=>typeof n=="function"?n():n,h=(e,f)=>{let u=v()?.data?.[e]?.[f];return u===void 0?{}:u},o=new Map,m=e=>Array.isArray(e)?`[${e.map(m).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(u=>`${JSON.stringify(u)}:${m(e[u])}`).join(",")}}`:JSON.stringify(e)??"null";function l(e=null,f=null){let u=a(),g=e||!u?null:Pe(u.state,f),d=null,p=ve({transport:{request:c=>s.request(c,{onStatus:T=>d?.(T)}),cancel:c=>s.cancel(c)}}),b=null,w=null,y=null,M=!1,k=null,O=null,C=()=>{y?.host?.dispose(),y=null},L=()=>{let c=a();return c&&e?ie.get(c)?.get(e)??null:null},j=()=>L()?.suspend(),B=()=>L()?.resume(),q=c=>{M=!1;let T=a();return C(),T&&R(T),B(),{status:"failed",message:c}},ne={aiTarget:!0,label:e?"This tool":"New tool",ref:e?[e]:[],placeholder:e?"What should change?":"Describe the tool",get isConnected(){let c=a();return c?e?!!_(c.state.doc,e):!0:!1},getBoundingClientRect(){let c=a();if(!c)return Se();if(y)return y.dom.getBoundingClientRect();let T=e??g?.hostId,A=T?_(c.state.doc,T):null,E=A?c.nodeDOM(A.at):null;return E&&typeof E.getBoundingClientRect=="function"?E.getBoundingClientRect():Se()},async start(c){w=null,M=!1;let T=a();if(!T)return{status:"refused",code:"gone",message:W};if(!globalThis.window?.clay?.wire)return{status:"refused",code:"no-wire",message:Ie};let A=null,E=null;if(e){let x=_(T.state.doc,e);if(x?.node.type!==N.nodes.tool)return{status:"refused",code:"gone",message:W};k=x.node.attrs.rev,A={toolId:e,rev:k},j(),E={artifact:x.node.attrs.artifact,state:h(e,k)},O=m(E.state)}return b=p.request(c,fe(T.state.doc,T.dom.ownerDocument.title),A,E),{status:"ok",id:b.requestId,send:(x={})=>(d=typeof x.onStatus=="function"?x.onStatus:null,{done:p.wait(b).then(S=>(w={id:e,rev:null,artifact:S.artifact,state:S.state},{state:"done",result:S}),S=>(B(),{state:"error",error:S?.message||S?.code||"the helper reported an error",code:S?.code??null})),cancel:()=>{B(),p.discard(b)}})}},async propose(c){let T=a();if(!T||!c)return{status:"refused",message:W};if(!F(c.artifact).ok)return{status:"refused",message:Q};if(!U(c.state).ok)return{status:"refused",message:Ne};w={id:e,rev:null,artifact:c.artifact,state:c.state};let x=De(T);return x.status!=="ready"&&(w=null),x},async keep(){if(!w||M)return q(be);let c=a();if(!c)return q(W);let T=v();if(!T)return q(Te);let A=()=>e&&O!==null&&m(h(e,k))!==O;if(A())return q(xe);M=!0;let E=w.id??r("b"),x=r("rev"),I={...w,id:E,rev:x};try{await T.set([E,x],I.state)}catch(D){return q(D?.message??Te)}let S=null;try{S=await t()}catch{return q(Ae)}if(S?.ok!==!0&&!["saved","clean"].includes(S?.state))return q(S?.msg??S?.message??Ae);if(e){let D=_(c.state.doc,e);if(D?.node.type!==N.nodes.tool||D.node.attrs.rev!==k)return q(be)}else if(!Z(c.state,g))return q(K);if(A())return q(xe);if(C(),R(c),e){let D=_(c.state.doc,e);c.dispatch(X(c.state.tr.setNodeMarkup(D.at,null,{...D.node.attrs,artifact:I.artifact,rev:I.rev})))}else if(!_e(c,I,g))return q(K);let P=!1;for(let D=0;D<2&&!P;D++)try{P=(await t())?.ok!==!1}catch{P=!1}return P?(o.delete(e??"new"),{status:"kept"}):{status:"failed",message:Re}},discard(){C();let c=a();c&&R(c),p.discard(b),B(),o.delete(e??"new")}};function De(c){C();let T=ue({mode:"view",tables:()=>de(c.state.doc).map(({id:I,cols:S,rows:P})=>({id:I,cols:S,rows:P}))}),A=c.dom.ownerDocument.createElement("div");A.className="blockeditor-ai-preview";let E=null;try{E=T.mount(A,{id:"preview",rev:"preview",artifact:w.artifact,seed:w.state})}catch{return T.dispose(),{status:"refused",message:Q}}if(E.failed)return T.dispose(),{status:"refused",message:Q};if(y={host:T,dom:A},e)return $(c,{ids:[e],dom:A}),{status:"ready"};let x=Z(c.state,g);return x?(x.replace?$(c,{ids:[x.node.attrs.id],dom:A}):ae(c,{at:x.insertAt,dom:A}),{status:"ready"}):(C(),{status:"refused",message:K})}return e&&o.set(e,ne),ne}return{newTool(e=null){return l(null,e)},reviseTool(e){let f=o.get(e);return f?.isConnected?f:(o.delete(e),l(e))}}}var{TextSelection:$e}=V,ze="ai-edit",Le="page area",je="This section is too large for AI editing. Select a smaller part.",Ce="Someone changed this area while AI was working, so nothing was changed.",Ve="This page is not open for editing any more.",Fe="AI editing isn't available on this page right now.",Ue=0;function te(i,n){let t=null;return i.forEach((r,s)=>{r.attrs?.id===n&&(t={node:r,at:s})}),t}var qe=(i,n)=>te(i,n)?.node?.type===N.nodes.tool,ee=(i,n,t)=>i.slice(n,t+1).map(r=>r.node.attrs.id).filter(Boolean),Ge=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ke=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Je(i){if(!i.length)return ke();let n=Math.min(...i.map(a=>a.left)),t=Math.min(...i.map(a=>a.top)),r=Math.max(...i.map(a=>a.right)),s=Math.max(...i.map(a=>a.bottom));return{x:n,y:t,left:n,top:t,right:r,bottom:s,width:r-n,height:s-t}}function We(i,n,t){let r=i.selection;if(!(r instanceof $e)||r.empty)return null;let[s,a]=ce(i.doc,r,n);if(s!==a||t.lo!==s||t.hi!==s)return null;let v=n[s];if(r.from<v.at||r.to>v.end)return null;let h=i.doc.textBetween(r.from,r.to," ");if(!h.trim())return null;let o=i.doc.textBetween(v.at+1,r.from," ").length;return{text:h,start:o,end:o+h.length}}function Tt({getView:i,store:n=()=>null,acceptState:t}={}){let r=()=>{let o=i();return o&&!o.isDestroyed?o:null},s=new Map,a=Ee({getView:r,store:n,acceptState:t}),v=o=>a.reviseTool(o);function h(o,{quote:m=null,label:l=null}={}){for(let[d,p]of s)p.isConnected||s.delete(d);let e=s.get(o.join(","));if(e)return e.quote=m??void 0,e;let f=null,u=null,g={aiTarget:!0,label:l??(o.length===1?"This block":`${o.length} blocks`),ref:[...o],get isConnected(){let d=r();return!!d&&o.some(p=>te(d.state.doc,p))},getBoundingClientRect(){let d=r();if(!d)return ke();let p=d.dom.querySelector(".blockeditor-ai-preview");if(p)return p.getBoundingClientRect();let w=[g.ref[0],g.ref[g.ref.length-1]].map(y=>te(d.state.doc,y)).map(y=>y?d.nodeDOM(y.at):null).filter(y=>y&&typeof y.getBoundingClientRect=="function").map(y=>y.getBoundingClientRect());return Je(w)},async start(d,p){let b=r();if(!b)return{status:"refused",code:"gone",message:Ve};let w=window.clay?.wire;if(!w)return{status:"refused",code:"no-wire",message:Fe};let{captureArea:y,AREA_GUIDE:M}=await import("./c-SFZRY6RT.js"),k=y(b.state.doc,g.ref);if(f=null,u=null,k.status!=="ok")return{status:"refused",code:k.code,message:k.message};let O=p??g.quote,C={id:"req-"+Date.now().toString(36)+"-"+ ++Ue,editId:Le,tag:"div",elementHTML:k.capture.html,comment:d+`
|
|
2
2
|
|
|
3
|
-
`+M,contextRefs:pe(d)};return O&&(C.quote=O.text,Number.isInteger(O.start)&&(C.selection={start:O.start,end:O.end})),he(d)&&(C.page=!0),new Blob([JSON.stringify(C)]).size>921600?{status:"refused",code:"too-large",message:je}:(f=k.capture,{status:"ok",id:C.id,send:(L={})=>{let j=!0,B=null;return{done:(async()=>(C.page&&await window.clay?.save?.(),j?(B=w.send(C,{helper:ze,onStatus:L.onStatus}),B.done):{state:"cancelled"}))(),cancel(){j=!1,B?.cancel()}}}})},async propose(d){let p=r();if(!p||!f)return{status:"refused",message:"This area is no longer open for AI editing."};let{proposeArea:b}=await import("./c-
|
|
3
|
+
`+M,contextRefs:pe(d)};return O&&(C.quote=O.text,Number.isInteger(O.start)&&(C.selection={start:O.start,end:O.end})),he(d)&&(C.page=!0),new Blob([JSON.stringify(C)]).size>921600?{status:"refused",code:"too-large",message:je}:(f=k.capture,{status:"ok",id:C.id,send:(L={})=>{let j=!0,B=null;return{done:(async()=>(C.page&&await window.clay?.save?.(),j?(B=w.send(C,{helper:ze,onStatus:L.onStatus}),B.done):{state:"cancelled"}))(),cancel(){j=!1,B?.cancel()}}}})},async propose(d){let p=r();if(!p||!f)return{status:"refused",message:"This area is no longer open for AI editing."};let{proposeArea:b}=await import("./c-SFZRY6RT.js"),w=b(p.state,f,d?.html??"",{seed:Ge()});if(w.status!=="ready")return{status:"refused",message:w.message};u=w;let y=p.dom.ownerDocument.createElement("div");y.className="blockeditor-ai-preview";let M=H.DOMSerializer.fromSchema(N);return y.appendChild(M.serializeFragment(H.Fragment.from(w.nodes),{document:p.dom.ownerDocument})),$(p,{ids:f.ids,dom:y}),{status:"ready"}},async keep(){let d=r();if(!d||!f||!u)return{status:"failed",message:Ce};let{keepAreaTransaction:p}=await import("./c-SFZRY6RT.js"),b=p(d.state,f,u);if(R(d),b.status!=="ok")return{status:"failed",message:Ce};d.dispatch(b.tr),d.dom.isConnected&&d.focus();try{await window.clay?.save?.flush?.()}catch{return{status:"failed",message:"Your change is in the document, but saving failed. It will be saved with your next edit."}}return{status:"kept"}},discard(){let d=r();d&&(R(d),d.dom.isConnected&&d.focus())}};return g.quote=m??void 0,s.set(o.join(","),g),g}return{active:()=>!!r(),targetFromSelection(){let o=r();if(!o)return null;let m=z(o.state.doc);if(!m.length)return null;let l=le(o.state,m),e=ee(m,l.lo,l.hi);return e.length?e.length===1&&qe(o.state.doc,e[0])?v(e[0]):h(e,{quote:We(o.state,m,l)}):null},targetAt(o,m){let l=r();if(!l)return null;let e=l.posAtCoords({left:o,top:m});if(!e)return null;let f=z(l.state.doc);if(!f.length)return null;let u=e.inside>=0?e.inside:e.pos,g=f.findIndex(y=>y.node.type===N.nodes.tool&&y.end===u),d=g>=0?g:Math.min(Math.max(l.state.doc.resolve(u).index(0),0),f.length-1),{lo:p,hi:b}=Y(f,d,d),w=ee(f,p,b);return w.length?w.length===1&&qe(l.state.doc,w[0])?v(w[0]):h(w):null},between(o,m){let l=r();if(!l)return null;let e=z(l.state.doc),f=[...o?.ref??[],...m?.ref??[]].map(p=>e.findIndex(b=>b.node.attrs.id===p)).filter(p=>p>=0);if(!f.length)return null;let{lo:u,hi:g}=Y(e,Math.min(...f),Math.max(...f)),d=ee(e,u,g);return d.length?h(d):null},wholePage(){let o=r(),m=o?z(o.state.doc).map(l=>l.node.attrs.id).filter(Boolean):[];return h(m,{label:"This page"})},newTool(o){return a.newTool(o??null)},reviseTool(o){return a.reviseTool(o)}}}export{Tt as createPageAi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./c-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{i as hostActions,d as hostMeta,c as hostMetaOrder,a as hostMetaOutcome,b as hostMetaPath,f as hostPageFormat,g as hostPageStateHref,e as hostSupports,h as hostVersions,k as querySaveOutcome,j as resetHostMeta};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./c-
|
|
1
|
+
import{a as d}from"./c-MZCOGNZL.js";import{b as A,k as c}from"./c-HA6INT6J.js";import{i as s}from"./c-ICMAOOGK.js";import{a as v}from"./c-VHNSBD2M.js";var O={};v(O,{CONTROLLED_SELECTOR:()=>m,authoredAttr:()=>b,canonicalContentEditable:()=>x,canonicalContentEditableValue:()=>E,captureAll:()=>h,captureAuthored:()=>u,captureFrozen:()=>p,frozenOriginal:()=>L,restoreAuthoredOrder:()=>T});var m="[editmode\\:contenteditable], [editmode\\:onclick], [viewmode\\:disabled], [viewmode\\:readonly]",l=new WeakMap,f=new WeakMap;function u(e){let t=l.get(e);if(!t){let r=e.getAttributeNames(),n={};for(let i of r)n[i]=e.getAttribute(i);t={order:r,values:n},l.set(e,t)}return t}function b(e,t){if(!e)return null;let{values:r}=u(e);return t in r?r[t]:null}function T(e,t=e){let r=l.get(t);if(!r)return;let n=e.getAttributeNames(),i=[...r.order.filter(o=>n.includes(o)),...n.filter(o=>!r.order.includes(o))];if(i.every((o,a)=>o===n[a]))return;let g=i.map(o=>[o,e.getAttribute(o)]);for(let o of n)e.removeAttribute(o);for(let[o,a]of g)e.setAttribute(o,a)}function E(e){return e.getAttribute("contenteditable")??e.getAttribute("inert-contenteditable")??b(e,"inert-contenteditable")??b(e,"contenteditable")??"true"}function x(e){e.setAttribute("inert-contenteditable",E(e)),e.removeAttribute("contenteditable")}function y(e){let t=e.innerHTML;if(!e.querySelector(`[${c}]`)&&!t.includes("ephemeral")&&!t.includes("<dialog"))return t;let r=e.cloneNode(!0);for(let n of r.querySelectorAll(`[${c}]`))n.removeAttribute(c);for(let n of r.children)A(n);return r.innerHTML}function p(e){f.has(e)||f.set(e,y(e))}function L(e){return f.get(e)}function h(){for(let e of document.querySelectorAll(m))u(e);for(let e of document.querySelectorAll(s))p(e)}h();d.onAddElement({selectorFilter:m,require:"observed",pausable:!1,debounce:0},e=>{e.forEach(({element:t})=>u(t))});d.onAddElement({selectorFilter:s,require:"observed",pausable:!1,debounce:0},e=>{e.forEach(({element:t})=>p(t))});export{u as a,b,T as c,x as d,L as e,h as f,O as g};
|