@panphora/clayjs 1.25.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +4432 -3831
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-2A2ATCIH.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/{c-JD2VFAYG.js → c-2GB34XL4.js} +2 -2
- package/dist/m/{c-CITLTVQ4.js → c-2TJCFPX4.js} +1 -1
- package/dist/m/c-33SS5A4Y.js +1 -0
- package/dist/m/{c-V2FPBRO6.js → c-34J5HC7N.js} +1 -1
- package/dist/m/{c-ZEA3DCG3.js → c-3AAQJAKJ.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-QWB53KRW.js → c-3XNTQQEJ.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3Y234AUB.js} +2 -2
- package/dist/m/{c-GEAG5XAK.js → c-42RLKGEY.js} +1 -1
- package/dist/m/{c-XQTERKQA.js → c-44WITKWQ.js} +1 -1
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-4NAYDOWH.js} +1 -1
- package/dist/m/{c-TLQINES7.js → c-4OZZ7ENT.js} +2 -2
- package/dist/m/{c-QDVG4NAZ.js → c-5IIEOPIV.js} +1 -1
- package/dist/m/{c-4Q6QIODW.js → c-755ZOHOM.js} +1 -1
- package/dist/m/c-7Q4XYDF4.js +1 -0
- package/dist/m/c-7RHOMAMR.js +1 -0
- package/dist/m/{c-BCWYEG6P.js → c-7Z2625LX.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-A3OKSYRI.js} +1 -1
- package/dist/m/{c-RGAALCDU.js → c-A5IYL7JI.js} +1 -1
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-IESDKFO6.js → c-ASGHHLFX.js} +1 -1
- package/dist/m/c-ASMLERFA.js +7 -0
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-TCFVG3I4.js → c-BHLYQGTA.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-C27EVUQ6.js} +1 -1
- package/dist/m/{c-SUAC5RSG.js → c-C5UGNOC2.js} +1 -1
- package/dist/m/c-C6DXZIXD.js +1 -0
- package/dist/m/{c-WSTUCBHV.js → c-CPRGR2II.js} +1 -1
- package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
- package/dist/m/{c-PRZNJUYZ.js → c-D4N4UJCQ.js} +2 -2
- package/dist/m/{c-D62HRSZK.js → c-DAUQ6JZ3.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-DDCYVLGG.js} +1 -1
- package/dist/m/{c-FBOO2UY3.js → c-DVMDYRAE.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.js} +1 -1
- package/dist/m/{c-O2QZDVZ2.js → c-EEWPNUM2.js} +1 -1
- package/dist/m/{c-MFB74XVN.js → c-EHAR4RJJ.js} +2 -2
- package/dist/m/c-EIDZHQHZ.js +1 -0
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-4AE2A2LK.js → c-GNFDX6SU.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.js} +1 -1
- package/dist/m/{c-MUM53J5J.js → c-H4M2T4A6.js} +1 -1
- package/dist/m/{c-U7F66I64.js → c-HYNM5U6B.js} +1 -1
- package/dist/m/c-J2YYLEVM.js +1 -0
- package/dist/m/c-J2ZW4HMR.js +1 -0
- package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
- package/dist/m/c-K2ZHQMPF.js +1 -0
- package/dist/m/{c-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-JWW6BHWD.js → c-LUBZU4AZ.js} +4 -4
- package/dist/m/{c-SEVOS4UE.js → c-LYNLY3MR.js} +1 -1
- package/dist/m/{c-NADLYVAH.js → c-MHTO3QAD.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/c-MLMJUNRV.js +1 -0
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-NW4ZFKCY.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-O4YIDULY.js +1 -0
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/c-PP3CUF3U.js +1 -0
- package/dist/m/{c-GY4BREDT.js → c-QL4NYM2L.js} +1 -1
- package/dist/m/c-RES2S5Q3.js +1 -0
- package/dist/m/c-RFGELYEU.js +2 -0
- package/dist/m/c-RGFPLQGV.js +1 -0
- package/dist/m/{c-FKTALXNV.js → c-STAPQ2X6.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-X3V4RWMA.js → c-T5IWJOMW.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-T7LOTEWO.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-TWB5ZQU4.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/c-UW6MMZ4V.js +1 -0
- package/dist/m/c-VGG3UR7I.js +1 -0
- package/dist/m/c-VU4WEWPH.js +4 -0
- package/dist/m/{c-5Q5XBN56.js → c-W7LWCJHD.js} +1 -1
- package/dist/m/c-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-XCOQNISP.js} +1 -1
- package/dist/m/{c-IL5IVTOG.js → c-XS7G6U3Z.js} +1 -1
- package/dist/m/{c-HGG7M2S3.js → c-Y3J5LDKB.js} +1 -1
- package/dist/m/{c-JB5YU57S.js → c-Y3MPVURA.js} +1 -1
- package/dist/m/c-Y6HH7LTM.js +1 -0
- package/dist/m/{c-52OC3OH3.js → c-YRDKVEGR.js} +1 -1
- package/dist/m/{c-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-ZJ7726FO.js} +1 -1
- package/dist/m/core/{admin-attrs-ZI6K6UGM.js → admin-attrs-43JBA6JB.js} +1 -1
- package/dist/m/core/{autosave-BSM2ABJL.js → autosave-HD7Y7UNV.js} +1 -1
- package/dist/m/core/{conflict-notice-7EQLDYPA.js → conflict-notice-Y2NTMDGJ.js} +1 -1
- package/dist/m/core/{persist-2SZO3PCE.js → persist-MX3VYVBN.js} +1 -1
- package/dist/m/core/{save-K6Q47J2X.js → save-JZ7R4ET2.js} +1 -1
- package/dist/m/core/{save-core-U3Z44XBO.js → save-core-I4N6S4ED.js} +1 -1
- package/dist/m/core/{site-edits-CFMF6GHD.js → site-edits-TIJDPG6H.js} +1 -1
- package/dist/m/core/{snapshot-PWCHYFL6.js → snapshot-N5MKDGNI.js} +1 -1
- package/dist/m/core/{unsaved-warning-2WRZLJH5.js → unsaved-warning-BP6ZY3PG.js} +1 -1
- package/dist/m/internals/{index-FSLC4M7J.js → index-3LAVREAU.js} +1 -1
- package/dist/m/{loader-RC54UV7H.js → loader-7ORQVRCK.js} +1 -1
- package/dist/m/manifest-A27A4278.js +1 -0
- package/dist/m/manifest-edit-E8A61EB4.js +1 -0
- package/dist/m/manifest.json +1099 -1039
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-HS2CAV3W.js} +5 -5
- package/dist/m/plugins/{ai-edit-3LG6MGS3.js → ai-edit-WDV2GLDU.js} +2 -2
- package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
- package/dist/m/plugins/{derive-7DR5TUDH.js → derive-R4USHZ7P.js} +1 -1
- package/dist/m/plugins/{indicator-CTKX4EY7.js → indicator-OLPZ4WFI.js} +1 -1
- package/dist/m/plugins/{live-IFLL6YN5.js → live-CO4VJS46.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/{page-GTDPYGE4.js → page-L3VKIQU2.js} +2 -2
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-6KNTXABH.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
- package/dist/m/plugins/{richclay-L3BZMX4I.js → richclay-V6WKJTUF.js} +17 -17
- package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
- package/dist/m/plugins/{source-7LSGOV46.js → source-OYHDXKTB.js} +1 -1
- package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
- package/dist/m/plugins/{upgrade-MMPZUCDM.js → upgrade-SZQJYEQQ.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-V5YB7XDH.js → visitor-drafts-ZE6PCAFP.js} +2 -2
- package/dist/m/plugins/{visitor-menu-QDV2MYJN.js → visitor-menu-5XY57JQA.js} +1 -1
- package/dist/m/plugins/{wire-3YGUO3GE.js → wire-S5ATC4QI.js} +1 -1
- package/dist/m/reader-core-AHOAP5DH.js +77 -0
- package/dist/m/sync/{live-sync-XMXXZS3G.js → live-sync-DX4K5GDB.js} +1 -1
- package/dist/m/ui/index-G7ZJXNMG.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-JANUQULT.js → sap-core.vendor-5TWOJYVM.js} +4 -4
- package/dist/offline-manifest.json +707 -677
- package/dist/server/core.cjs +4245 -2614
- package/dist/server/markdown.cjs +1 -0
- package/dist/server/markdown.mjs +7 -0
- package/docs/guide.md +26 -37
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +5 -5
- package/package.json +6 -2
- package/packed-contract.json +3 -0
- package/src/attrs/save-freeze.js +1 -1
- package/src/core/admin-contenteditable.js +1 -1
- package/src/core/admin-inputs.js +1 -1
- package/src/core/admin-onclick.js +1 -1
- package/src/core/admin-resources.js +5 -2
- package/src/core/conflict-notice-ui.js +59 -34
- package/src/core/save.js +9 -9
- package/src/core/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/page/editor.js +10 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/sortable.js +25 -9
- package/src/server/markdown/index.js +23 -0
- package/src/sync/conflicts.js +3 -1
- package/src/sync/data-guard-notice.js +137 -18
- package/src/ui/bevel-controls.js +4 -1
- package/src/ui/dialogs.js +11 -7
- package/src/ui/modal.js +9 -7
- package/src/ui/toast.js +67 -32
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +7 -7
- package/src/vendor/richclay.vendor.js +16 -16
- package/src/vendor/sap-core.vendor.js +4 -4
- package/tool-generation/context.md +69 -0
- package/tool-generation/system.md +1 -1
- package/dist/m/c-277QP5ET.js +0 -1
- package/dist/m/c-5SZ6KFR5.js +0 -1
- package/dist/m/c-CU33V6RW.js +0 -4
- package/dist/m/c-CVSWLX3X.js +0 -1
- package/dist/m/c-DXPOFLEJ.js +0 -1
- package/dist/m/c-EODTTNVA.js +0 -1
- package/dist/m/c-ESK4S67I.js +0 -1
- package/dist/m/c-FDWR3FL7.js +0 -1
- package/dist/m/c-FJDTDGDA.js +0 -1
- package/dist/m/c-FYDKYW6E.js +0 -1
- package/dist/m/c-HKSLOVU4.js +0 -1
- package/dist/m/c-IJHF4IO6.js +0 -1
- package/dist/m/c-IUL7PU4P.js +0 -1
- package/dist/m/c-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- package/dist/m/c-NHXOBD6A.js +0 -1
- package/dist/m/c-NVU3DORS.js +0 -1
- package/dist/m/c-PNZIJFG7.js +0 -1
- package/dist/m/c-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.js +0 -1
- package/dist/m/c-SGG6MUXW.js +0 -1
- package/dist/m/c-SXNSSHPP.js +0 -1
- package/dist/m/c-TFLRT5JX.js +0 -1
- package/dist/m/c-U65PREMC.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- package/dist/m/plugins/sortable-365SRRL3.js +0 -1
- package/dist/m/plugins/undo-UES4KS7B.js +0 -1
- package/dist/m/reader-core-VR7EL4WV.js +0 -77
- package/dist/m/ui/index-MGTWOW2C.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
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
|
+
import{c as M,g as _,h as A,w as q}from"./c-LUBZU4AZ.js";import{C as G}from"./c-3Y234AUB.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-JC4RZW4E.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,b,c,d,e,f}from"./c-
|
|
1
|
+
import{a,b,c,d,e,f}from"./c-7RHOMAMR.js";import"./c-N326R2JD.js";import"./c-I2SCCUEW.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{c as beginApply,d as completeApply,f as conflicts,e as failApply,a as loadEdit,b as registerContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t,e as o}from"./c-NW4ZFKCY.js";import"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-3Y234AUB.js";import"./c-OH2FPYSY.js";import{c as e}from"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";function c({view:r=null}={}){let a=r?e(r,{update:o}):()=>{};return{id:"chart",nodeViews:{chart:(i,n,d)=>new t(i,n,d)},dispose(){a()}}}export{c as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as C,f as v,g as M,h as P,j as S}from"./c-J2ZW4HMR.js";import{a as L,d as T,e as w,f as A}from"./c-A5LASUEZ.js";import{b as N,e as b,f as O,g as f}from"./c-5RZNFTWD.js";import{a as D}from"./c-PKCCHJ5X.js";import{a as I,b as c}from"./c-NUHP2XDB.js";var q=new WeakMap,W='a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [contenteditable], [tabindex]:not([tabindex^="-"])';function G(u,a){let t=[...u.querySelectorAll(W)].filter(i=>i.offsetParent!==null);if(!t.length)return;let s=t.indexOf(document.activeElement);s===-1?(t[0].focus(),a.preventDefault()):a.shiftKey&&s===0?(t[t.length-1].focus(),a.preventDefault()):!a.shiftKey&&s===t.length-1&&(t[0].focus(),a.preventDefault())}var B=`1px solid ${b["line-2"]}`;function K(u,a,t=null,s=[],i=[]){let x=f.dialogCloseHover[0].slice(11),g=["position:absolute","top:-1px","right:-1px","z-index:2","display:grid","place-items:center",a?"height:calc(100% + 1px)":"height:62px","margin:0","padding:0","border:0",...f.dialogClose,...a?[]:[`border-bottom:${B}`],"cursor:pointer","outline:none"],e=v("button",g);if(e.type="button",e.setAttribute("aria-label",u),e.title=u,e.innerHTML=O.dialogClose,!L(t))return C(e.firstElementChild,16),e.addEventListener("pointerenter",()=>c(e,"background",x)),e.addEventListener("pointerleave",()=>c(e,"background",b.face)),e.addEventListener("focus",()=>{c(e,"outline",`2px solid ${b.brass}`),c(e,"outline-offset","-4px")}),e.addEventListener("blur",()=>c(e,"outline","none")),e;let n=["close",...s],r=["icon",...i];A(e,t,n),A(e.firstElementChild,t,r);let o={hover:!1,focus:!1,pressed:!1},l=()=>{let d={hover:o.hover,active:o.pressed,focus:o.focus},h=e.firstElementChild;h.style.cssText="",C(h,16),I(h,w(t,r,d)),M(e,[...g,...o.hover?[`background:${x}`]:[],...o.focus?[`outline:2px solid ${b.brass}`,"outline-offset:-4px"]:[],...T(t,"close",d),...w(t,n,d)])};return e.addEventListener("pointerenter",()=>{o.hover=!0,l()}),e.addEventListener("pointerleave",()=>{o.hover=!1,o.pressed=!1,l()}),e.addEventListener("pointerdown",d=>{d.button!==void 0&&d.button!==0||(o.pressed=!0,l())}),e.addEventListener("pointerup",()=>{o.pressed=!1,l()}),e.addEventListener("focus",()=>{o.focus=!0,l()}),e.addEventListener("blur",()=>{o.focus=!1,o.pressed=!1,l()}),l(),e}function Y({zIndex:u="100",width:a="600px",closable:t=!1,titled:s=!1,theme:i=null,surface:x="modal"}={}){let g=L(i),e=g?i.tokens:{},n=e.spacing,r=k=>x==="modal"?[`dialog.${k}`]:[`dialog.${k}`,`${x}.${k}`],o=v("div",["display:block"],{theme:i,parts:r("root")});o.setAttribute("data-clay-modal",""),g&&o.setAttribute("data-clay-ui",x),o.setAttribute("aria-hidden","true");let l=g&&i.scheme!=="light dark",d=Math.min(parseFloat(a)||600,innerWidth-32),h={x:(innerWidth-d)/2,y:Math.min(96,innerHeight*.1),width:d,height:160};c(o,"color-scheme",l?i.scheme:D(h).scheme);let m=v("div",["position:fixed","inset:0",`z-index:${u}`,"overflow:auto","display:flex","align-items:flex-start","justify-content:center","padding:min(96px, 10vh) 16px 16px",`background:color-mix(in srgb, ${b.ground} 72%, transparent)`],{theme:i,parts:r("overlay"),role:"overlay"});m.tabIndex=-1;let p=P("form",["position:relative","display:flex","flex-direction:column","margin:0",`width:min(${a}, 100%)`,"max-height:calc(100dvh - min(96px, 10vh) - 16px)",...f.dialogPanel],{theme:i,parts:r("panel")});p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true");let $=null,y=null;s&&($=v("div",["position:relative","display:block","flex:none",`padding:20px ${t?"68px":"22px"} 16px 22px`,...f.dialogHeader,...e.border?[`border-bottom-color:${e.border}`]:[],...n?[`padding:${n} ${t?`calc(${n} + 46px)`:n} calc(${n} * .7) ${n}`]:[]],{theme:i,parts:r("header")}),y=S("div",["display:block",...f.dialogHeading,"overflow-wrap:anywhere"],void 0,{theme:i,parts:r("title"),role:"heading"}),y.setAttribute("role","heading"),y.setAttribute("aria-level","2"),$.append(y),p.append($));let F=S("div",["display:block","flex:1 1 auto","min-height:0","overflow-y:auto","overflow-x:hidden",`padding:20px ${t&&!s?"84px":"22px"} 20px 22px`,"overflow-wrap:anywhere",`font:14.5px/1.55 ${N}`,...n?[`padding:${n} ${t&&!s?`calc(${n} + 62px)`:n} ${n} ${n}`]:[]],void 0,{theme:i,parts:r("body")}),H=v("div",["display:flex","flex:none","flex-wrap:wrap","justify-content:flex-end","align-items:center",...f.dialogFooter,...e.border?[`border-top-color:${e.border}`]:[],...n?[`padding:calc(${n} * .65) ${n}`,`gap:calc(${n} / 2)`]:[]],{theme:i,parts:[...r("footer"),...r("actions")]});p.append(F,H);let E=t?K("Close",s,i,r("close"),r("closeIcon")):null;return E&&($||p).append(E),m.append(p),o.append(m),{root:o,overlay:m,panel:p,header:$,heading:y,body:F,footer:H,close:E,theme:i}}export{q as a,G as b,Y as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as c,f as s}from"./c-QCDVDZIR.js";import{k as g,r as u}from"./c-
|
|
1
|
+
import{e as c,f as s}from"./c-QCDVDZIR.js";import{k as g,r as u}from"./c-UW6MMZ4V.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 d(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 m(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(d),u(m,{required:!0})}E();var h=p;export{h as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ae}from"./c-7WZSUTYP.js";import{i as re,j as se}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as ce}from"./c-3Y234AUB.js";import{A as _,F as te,a as W,b as Y,d as V,ea as oe,ia as ne,o as Z,r as U,y as N,z as ee}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as Q}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import{a as G}from"./c-I2SCCUEW.js";import"./c-PGSBXHUE.js";import"./c-VHNSBD2M.js";var ye="iframe, frame, frameset, object, embed, applet, meta, base, link, form, style, animate, set, animateMotion, animateTransform, portal",we=/^(srcdoc|data|formaction|codebase|archive|ping|background|poster|lowsrc|dynsrc)$/i,xe=/^\s*(javascript|vbscript|data):/i;function Me(o,a){let c=a.createElement("template");c.innerHTML=o;for(let d of c.content.querySelectorAll(ye))d.remove();for(let d of c.content.querySelectorAll("*"))for(let{name:h,value:m}of[...d.attributes])(we.test(h)||xe.test(m.replace(/[\u0000-\u0020]/g,"")))&&d.removeAttribute(h);return c.innerHTML}var H=2*1024*1024,le=32,ie=1e4,I=class extends Error{constructor(a,c){super(c),this.name="MarkdownImportError",this.code=a}},pe="\uFFFC",ue={type:"hard_break"},fe=new Set(["paragraph","heading","list","blockquote","code","table","hr","html","def","space"]),Se=new TextEncoder,de=V.marks,me=o=>o.slice().sort((a,c)=>a.type.rank-c.type.rank);function R(o,a,c){return o.some(d=>d.type===de[a])?o:me([...o,de[a].create(c)])}var he=/^(?![a-z][a-z0-9+.-]*:|[/#?])\S/i;function Ee(o,a){let c=typeof a=="function"?a(o):null;return typeof c=="string"&&c?W(c):he.test(o.trim())?null:W(o)}function Te(o,{images:a=!0,refused:c=[],unsupported:d=[],resolveLink:h=null}={}){let m=[],O="",v=[],q=()=>{O&&m.push({c:O,m:v}),O="",v=[]},M=($,k)=>{let u=String($??"");if(!u)return;let P=Z(me(k));O+=u;for(let b=0;b<u.length;b++)v.push(P)},S=$=>{O+=pe,v.push("@"+JSON.stringify($))},E=($,k)=>{for(let u of $??[]){let P=u?.type;if(typeof P!="string")throw new I("malformed-input","A Markdown token has no type.");switch(P){case"text":Array.isArray(u.tokens)?E(u.tokens.filter(b=>typeof b?.type=="string"&&!fe.has(b.type)),k):M(u.text,k);break;case"escape":M(u.text,k);break;case"strong":E(u.tokens,R(k,"strong"));break;case"em":E(u.tokens,R(k,"em"));break;case"del":case"strike":E(u.tokens,R(k,"strike"));break;case"codespan":M(u.text,R(k,"code"));break;case"br":S(ue);break;case"link":{let b=Ee(String(u.href??""),h);b?E(u.tokens,R(k,"link",{href:b})):(c.push({type:"link",href:String(u.href??"")}),E(u.tokens,k));break}case"image":{let b={src:String(u.href??""),alt:String(u.text??""),title:u.title??""};if(!a){M(b.alt,k);break}q(),m.push({image:b});break}case"html":M(u.text??u.raw,k);break;case"checkbox":break;default:d.push({type:P,text:String(u.raw??u.text??"")}),M(u.raw??u.text,k);break}}};return E(o,[]),q(),{parts:m}}function ke(o,{document:a=globalThis.document,resolveImage:c=null,resolveLink:d=null}={}){if(!Array.isArray(o))throw new I("malformed-input","Markdown import needs the lexer's token list.");let h=0;for(let n of o){if(!n||typeof n!="object"||typeof n.type!="string")throw new I("malformed-input","A Markdown token has no type.");h+=Se.encode(String(n.raw??"")).length}if(h>H)throw new I("input-too-large",`Markdown import is limited to ${H} bytes; this file is ${h}.`);let m=[],O=[],v=[],q=new Set,M=n=>{let r=_(n);for(;q.has(r);)r=_(n);return q.add(r),r},S=n=>{if(m.length+1>ie)throw new I("too-many-blocks",`Markdown import is limited to ${ie} blocks.`);m.push(n)},E=n=>{let r=n.depth+1;if(r>le)throw new I("nesting-too-deep",`Markdown import is limited to ${le} levels of nesting.`);return r},$=(n,r,{c:t,m:p})=>{let s={t:n,...r,c:t};return p.some(Boolean)&&(s.m=U(p)),s},k=n=>{let r=typeof c=="function"?c(n.src):null,t=typeof r=="string"&&r?r:null,p=t?Y(t):he.test(String(n.src).trim())?null:Y(n.src);return p?{t:"image",src:p,...n.alt?{alt:n.alt}:{},...n.title?{caption:n.title}:{}}:(v.push({type:"image",href:n.src}),n.alt?$("paragraph",{},{c:n.alt,m:[]}):null)},u=(n,r,t)=>{for(let p of t.parts){if(!p.image){S($(n,r,p));continue}let s=k(p.image);s&&S(s)}},P=(n,r)=>u(r.quote?"quote":"paragraph",{},n),b=(n,r={})=>Te(n,{refused:v,unsupported:O,resolveLink:d,...r}),K=n=>{let r=String(n.raw??n.text??"");O.push({type:n.type,text:r}),S({t:"code_block",lang:"markdown",c:r})},e=(n,r)=>{for(let t of n??[]){let p=t?.type;if(typeof p!="string")throw new I("malformed-input","A Markdown token has no type.");switch(p){case"space":break;case"heading":{let s=Math.min(6,Math.max(1,Number.parseInt(t.depth,10)||1));u("heading",s===2?{}:{level:s},b(t.tokens,{images:!1}));break}case"paragraph":case"text":P(b(t.tokens??[t]),r);break;case"hr":S({t:"divider"});break;case"code":S({t:"code_block",...t.lang?{lang:String(t.lang)}:{},c:String(t.text??"")});break;case"html":{let s=String(t.text??t.raw??"");O.push({type:"HTML block cleaned",text:s}),S({t:"preserved",html:Me(ne(a).fallback(s),a)});break}case"blockquote":{let s=E(r);e(t.tokens,{...r,depth:s,quote:!0});break}case"list":{let s=E(r),y=r.indent??0,f=t.ordered?"ordered":"bullet";for(let w of t.items??[]){let A={c:"",m:[]},C=[];for(let x of w?.tokens??[]){let g=x?.type;if(!(g==="checkbox"||g==="space"))if(g==="text"||g==="paragraph"){A.c&&(A={c:A.c+pe,m:[...A.m,"@"+JSON.stringify(ue)]});let j=g==="paragraph"?x.tokens??[]:[x];for(let T of b(j,{images:!1}).parts)A={c:A.c+T.c,m:[...A.m,...T.m]};C.push(...(x.tokens??[]).filter(T=>typeof T?.type=="string"&&fe.has(T.type)&&T.type!=="space"))}else C.push(x)}let D=w?.task?"check":f,B={...D==="bullet"?{}:{kind:D},...y?{indent:y}:{},...w?.task&&w.checked?{checked:!0}:{}};S($("list_item",B,A)),C.length&&e(C,{...r,depth:s,indent:y+1,quote:!1})}break}case"table":{let s=t.header??[];if(!s.length){K(t);break}let y=x=>b(x,{images:!1}).parts[0]??{c:"",m:[]},f=s.map(()=>M("c")),w=N(null,null,s.length),A=Object.fromEntries(f.map((x,g)=>[x,{pos:w[g],name:y(s[g]?.tokens).c}])),C=t.rows?.length?t.rows:[[]],D=N(null,null,C.length),B=C.map(x=>Object.fromEntries(f.map((g,j)=>{let T=y(x?.[j]?.tokens);return[g,T.m.some(Boolean)?{c:T.c,m:U(T.m)}:T.c]})));S({t:"table",cols:A,rows:Object.fromEntries(B.map((x,g)=>[M("r"),{pos:D[g],cells:x}]))});break}default:K(t);break}}};e(o,{depth:0,indent:0,quote:!1});let l=N(null,null,m.length),i={};return m.forEach((n,r)=>{i[M("b")]={...n,pos:l[r]}}),{blocks:i,unsupported:O,refused:v}}var Ae="markdown-import-preview",ze=new TextEncoder,Oe=o=>{let a=String(o??"").replace(/\s+/g," ").trim();return a.length>60?`${a.slice(0,60)}\u2026`:a},$e=o=>typeof o.text=="function"?o.text():new Promise((a,c)=>{let d=new FileReader;d.onload=()=>a(d.result),d.onerror=()=>c(d.error),d.readAsText(o)}),Ce=()=>globalThis.clay?.assets?.load?.("marked")??import("./c-XN6MBKI6.js"),ve=(o,a)=>{let c=-1;return o.forEach((d,h,m)=>{c<0&&d.attrs.id===a&&(c=m)}),c};function Pe(o){let a=o.selection.$from;if(a.depth>=1)return{node:a.node(1),at:a.before(1),textblock:a.parent.isTextblock};let c=Math.min(a.index(0),Math.max(0,o.doc.childCount-1)),d=0;for(let h=0;h<c;h++)d+=o.doc.child(h).nodeSize;return{node:o.doc.child(c),at:d,textblock:!1}}function Be(o){let{node:a,at:c,textblock:d}=Pe(o),h=o.selection,m=d?Math.max(0,h.from-c-1):0;return{id:a.attrs.id,textblock:d,size:a.isTextblock?a.content.size:0,fromOff:m,toOff:d?Math.max(m,h.to-c-1):0}}var Ie=o=>{try{return ae(oe(o))>0}catch{return!0}},qe=o=>o?.code==="blockeditor-format-upgrade-required"?"This document needs a newer page format before Markdown can be added. The preview stays open.":o?.code==="blockeditor-format-unsupported"?"This host cannot record the newer page format this file needs. The preview stays open.":o?.code==="stale-target"?"The place this import was started from changed. The preview stays open.":o?.code==="empty-import"?"This file holds nothing that can be inserted.":"The Markdown could not be inserted. The preview stays open.";function Qe({view:o=null,load:a=Ce}={}){if(!o)return{run:()=>Promise.resolve({ok:!1,code:"not-editing"}),dispose(){}};let c=o.dom.ownerDocument,d=null,h=null,m=!1,O=G({id:Ae,isPending:()=>d!==null}),v=()=>h??=Promise.resolve().then(a).catch(e=>{throw h=null,e});function q(){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},l=o.coordsAtPos(Math.min(o.state.selection.from,o.state.doc.content.size));return{x:Math.max(8,l.left-e.left),y:l.bottom+6-e.top}}catch{return null}}function M(){let e=d;if(!e)return!1;d=null;for(let[l,i,n,r]of e.listen)l.removeEventListener(i,n,r);return e.panel.remove(),!0}function S(){return M()?(o.focus?.(),{ok:!0,cancelled:!0}):{ok:!1,code:"cancelled"}}function E(e){let l=[],i=(s,y)=>{let f=c.createElement("div");return f.className=s,f.textContent=y,f};if(l.push(i("blockeditor-menu-title",e.error?"Couldn't read that Markdown":`Import ${e.name}`)),!e.error){let s=[`${e.count} block${e.count===1?"":"s"}`];e.unsupported.length&&s.push(`${e.unsupported.length} kept as written`),e.refused.length&&s.push(`${e.refused.length} address${e.refused.length===1?"":"es"} left out`),l.push(i("blockeditor-menu-title blockeditor-import-summary",s.join(" \xB7 ")))}let n=(s,y)=>{let f=c.createElement("div");return f.className=s,f.replaceChildren(...y.map(w=>i("blockeditor-import-row",w))),f};e.unsupported.length&&l.push(n("blockeditor-import-unsupported",e.unsupported.map(s=>`${s.type}: ${Oe(s.text)}`))),e.refused.length&&l.push(n("blockeditor-import-refused",e.refused.map(s=>`${s.type}: ${s.href}`)));let r=e.error??e.notice??null;if(r){let s=c.createElement("p");s.className="blockeditor-import-error",s.setAttribute("role","alert"),s.textContent=r,l.push(s)}let t=(s,y)=>{let f=c.createElement("button");return f.type="button",f.className="blockeditor-menu-item",f.dataset.import=s,f.textContent=y,f.addEventListener("mousedown",w=>w.preventDefault()),f.addEventListener("click",()=>s==="insert"?k():S()),f},p=t("insert","Insert at the selection");p.disabled=!!e.error,l.push(p,t("cancel","Cancel")),e.panel.replaceChildren(...l)}function $(e,l){let i=o.state,n=i.doc,r=ve(n,e.id);if(r<0)return{ok:!1,code:"stale-target"};let t=n.child(r);if(e.textblock?!t.isTextblock||t.content.size!==e.size:t.isTextblock)return{ok:!1,code:"stale-target"};let p=ee(l).map(z=>te(V,z,{...l[z],pos:null,parent:null}));if(!p.length)return{ok:!1,code:"empty-import"};let s=0;for(let z=0;z<r;z++)s+=n.child(z).nodeSize;let y=n.maybeChild(r+1),f=t.type.name==="toggle",w=e.textblock&&!f&&t.content.size>0,A=w||e.textblock&&!f&&t.content.size===0,C=w?Math.min(e.fromOff,t.content.size):0,D=w?Math.min(Math.max(C,e.toOff),t.content.size):0,B=w&&C>0?t.type.create({...t.attrs},t.content.cut(0,C)):null,x=w?t.content.cut(D):null,g=x&&x.size?t.type.create({...t.attrs,id:_(),pos:null},x):null,j=w&&!B?r>0?n.child(r-1).attrs.pos:null:t.attrs.pos,T=N(j,y?.attrs.pos??null,p.length+(g?1:0)),be=f?t.attrs.id:t.attrs.parent??null,F=p.map((z,ge)=>z.type.create({...z.attrs,pos:T[ge],parent:be},z.content,z.marks)),X=g?g.type.create({...g.attrs,pos:T[p.length]},g.content,g.marks):null,L=i.tr;A?L.replaceWith(s,s+t.nodeSize,[...B?[B]:[],...F,...X?[X]:[]]):L.insert(s+t.nodeSize,F),f&&!t.attrs.open&&F.length>0&&L.setNodeMarkup(s,null,{...t.attrs,open:!0});let J=s+(A?B?B.nodeSize:0:t.nodeSize);for(let z of F)J+=z.nodeSize;return L.setSelection(Q.TextSelection.near(L.doc.resolve(X?J:Math.max(0,J-1)),X?1:-1)),o.dispatch(ce(L).scrollIntoView()),o.focus?.(),{ok:!0,blocks:F.length}}async function k(){let e=d;if(!e||e.error)return e?{ok:!1,code:"no-import"}:{ok:!1,code:"not-editing"};e.notice&&(e.notice=null,E(e));let l=()=>$(e.target,e.blocks),i=e.floor?await re(o,l):l();return i?.ok?(M(),i):(d===e&&(e.notice=qe(i),E(e)),i??{ok:!1,code:"import-failed"})}function u(e){!d||se(e,o)||(e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),S()):e.key==="Enter"&&!e.target?.closest?.("[data-import]")&&(e.preventDefault(),e.stopPropagation(),k()))}function P(){return new Promise(e=>{let l=c.createElement("input");l.type="file",l.accept=".md,.markdown,text/markdown,text/plain",l.hidden=!0,l.className="blockeditor-markdown-input";let i=n=>{l.remove(),e(n)};l.addEventListener("change",()=>i(l.files?.[0]??null)),l.addEventListener("cancel",()=>i(null)),(o.dom.parentElement??c.body).appendChild(l),l.click()})}async function b(e,l=null){e.error=l;let i=c.createElement("div");i.className="blockeditor-menu blockeditor-import-preview",i.setAttribute("role","dialog"),i.setAttribute("aria-label","Import Markdown"),e.panel=i,d=e;let n=(p,s,y,f)=>{p.addEventListener(s,y,f),e.listen.push([p,s,y,f])};n(c,"keydown",p=>u(p),!0),n(c,"mousedown",p=>{e.panel.contains(p.target)||S()},!0),(o.dom.parentElement??c.body).appendChild(i),E(e);let r=q();r&&(i.style.setProperty("--blockeditor-pop-x",`${r.x}px`),i.style.setProperty("--blockeditor-pop-y",`${r.y}px`));let t=i.querySelector('[data-import="insert"]');return t&&!t.disabled&&t.focus?.(),{ok:!0,preview:!0}}async function K(e={}){if(m||o.isDestroyed)return{ok:!1,code:"not-editing"};M();let l=Be(o.state),i=e?.file??await P();if(!i)return{ok:!1,code:"cancelled"};if(typeof i.size=="number"&&i.size>H)return{ok:!1,code:"input-too-large"};let n;try{n=await $e(i)}catch(p){return{ok:!1,code:"unreadable",error:p}}if(m||o.isDestroyed)return{ok:!1,code:"not-editing"};if(ze.encode(n).length>H)return{ok:!1,code:"input-too-large"};let r={target:l,name:String(i.name??"Markdown"),blocks:{},count:0,unsupported:[],refused:[],floor:0,panel:null,error:null,notice:null,listen:[]},t;try{let p=await v();t=ke(new p.Marked().lexer(n))}catch(p){return m||o.isDestroyed?{ok:!1,code:"not-editing"}:b(r,String(p?.message??"The Markdown could not be read."))}return m||o.isDestroyed?{ok:!1,code:"not-editing"}:(r.blocks=t.blocks,r.count=Object.keys(t.blocks).length,r.unsupported=t.unsupported,r.refused=t.refused,r.floor=Ie(t.blocks)?1:0,b(r))}return{async run(e){return K(e)},dispose(){m=!0,M(),O.dispose()}}}export{Qe as createFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as S}from"./c-RWJ3OSCP.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-QWB53KRW.js";import"./c-QDVG4NAZ.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-IJHF4IO6.js";import{b as Z}from"./c-U65PREMC.js";import{b as se}from"./c-FJDTDGDA.js";import"./c-QTTJYJMA.js";import"./c-QCDVDZIR.js";import"./c-VKEDWYDF.js";import{E as te}from"./c-VMXCX52Q.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-MZCOGNZL.js";import"./c-MFB74XVN.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-PNZIJFG7.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
1
|
+
import{f as S}from"./c-7RHOMAMR.js";import{a as ne,b as F,c as re,d as oe}from"./c-N326R2JD.js";import{a as H}from"./c-JAX2667S.js";import{b as le,c as ae}from"./c-3XNTQQEJ.js";import"./c-5IIEOPIV.js";import"./c-LZJPNR2W.js";import{b as ce,g as ie}from"./c-U35T5NAY.js";import{b as Z}from"./c-WOJ2RTV4.js";import{b as se}from"./c-RGFPLQGV.js";import"./c-FILLTJA7.js";import"./c-QCDVDZIR.js";import"./c-VKEDWYDF.js";import{E as te}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import{g as ee}from"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import{a as J}from"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import{f as X}from"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import{h as Q}from"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var T="This spot changed again. Review the latest edit or download your copy.",ue="\uFFFC",C="",M=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),ge=new Set(["BR","WBR","IMG"]),L=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" ")),ke=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),we=new Set("P H1 H2 H3 H4 H5 H6 SUMMARY".split(" ")),Ne=/[\u001E]/,ve={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0},k=e=>!!e&&e.nodeType===1,W=e=>k(e)&&M.has(e.tagName),B=e=>e.matches(le),z=e=>e.matches(ae),y=e=>e.localName==="template"&&e.content?e.content:e,w=e=>Array.prototype.indexOf.call(e.parentNode.childNodes,e),x=e=>e.getAttribute("data-id")||e.getAttribute("id")||null;function Ce(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ye(e){if(e.nodeType===3)return!0;if(!k(e))return!1;if(B(e)||ge.has(e.tagName))return!0;if(!M.has(e.tagName))return!L.has(e.tagName);if(z(e))return!1;for(let n of e.childNodes)if(!ye(n))return!1;return!0}function Y(e){if(!ke.has(e.tagName)||B(e)||z(e))return!1;for(let n of e.childNodes)if(n.nodeType===8||!ye(n))return!1;return!0}function xe(e,n=document){for(let t of n.querySelectorAll("template")){if(t.content===e)return t;let r=xe(e,t.content);if(r)return r}return null}function m(e,n){for(let t=e;t;t=t.nodeType===11?xe(t):t.parentNode)if(t===n)return!0;return!1}var h=e=>m(e,document);function Ae(e,n){let t=e;for(let r of n)if(t=r==="content"?t.content:t.childNodes[r],!t)return null;return t}function D(e,n=new Set){if(k(e)){let t=x(e);t&&n.add(t)}if(e.nodeType===1||e.nodeType===11)for(let t of y(e).childNodes)D(t,n);return n}function Re(e){let n=document.createElement("template");return n.innerHTML=e,n.content}var Ie=e=>[...e.querySelectorAll("*")].some(n=>L.has(n.tagName));function Se(e){let n=[];for(let t=e;t.childNodes.length===1&&k(t.firstChild);t=t.firstChild)n.push(t.firstChild);return n}function De(e,n){let t=e.lastIndexOf("content");if(t<0)return document;let r=$(e.slice(0,t),n);return r&&r.content?r.content:null}function $(e,n){let t=Ae(n.root,e);if(!k(t))return null;let r=x(t),o=r?De(e,n):null;if(!o)return null;let s=[...o.querySelectorAll(t.localName)].filter(i=>i.namespaceURI===t.namespaceURI&&x(i)===r);return s.length===1?s[0]:null}function Me(e){let n=x(e);if(!n)return null;let t=[...document.querySelectorAll(e.localName)].filter(r=>r.namespaceURI===e.namespaceURI&&x(r)===n);return t.length===1?t[0]:null}function b(e,n,t=e?e.nodeType:1){if(!e)return null;for(let o of e.live)if(o.nodeType===t&&h(o))return o;if(t!==1)return null;if(e.local.length)return $(e.local[0],n);let r=e.live.find(k);return r?Me(r):null}function Pe(e){let n=e.live.find(k),t=n?x(n):null;return!!t&&![...document.querySelectorAll(n.localName)].some(r=>x(r)===t)}function _(e){let n=y(e),t={root:e,container:n,text:"",nodes:[],atoms:[],blocks:[]},r=s=>{for(let i of s){if(i.nodeType===3){if(!i.data)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+i.data.length}),t.text+=i.data;continue}if(!k(i)||B(i))continue;if(Y(i)){t.text.length&&t.text[t.text.length-1]!==C&&(t.text+=C);let l={el:i,from:t.text.length,to:-1};t.blocks.push(l),r(i.childNodes),t.text+=C,l.to=t.text.length;continue}let c=M.has(i.tagName)&&Ce(i);if(ge.has(i.tagName)||!M.has(i.tagName)||z(i)||c){t.atoms.push({i:t.text.length,el:i}),t.text+=ue;continue}r(i.childNodes)}};if(r(n.childNodes),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&!t.blocks.length&&t.text.replace(ue,"").trim()===""){let s=t.atoms[0].i;t.text=t.text.slice(0,s)+t.text.slice(s+1),t.atoms=[];for(let i of t.nodes)i.s>s&&(i.s--,i.e--)}return t}function fe(e,n,t){for(let s of e.nodes)if(t==="start"?s.s<=n&&n<s.e:s.s<n&&n<=s.e)return[s.node,n-s.s];let r=t==="start"?n:n-1,o=e.atoms.find(s=>s.i===r);if(o)return[o.el.parentNode,w(o.el)+(t==="start"?0:1)];if(e.text[r]===C){let s=e.blocks.find(c=>c.to===r+1);if(s)return t==="start"?[s.el,s.el.childNodes.length]:[s.el.parentNode,w(s.el)+1];let i=e.blocks.find(c=>c.from===r+1);if(i)return t==="start"?[i.el,0]:[i.el.parentNode,w(i.el)]}for(let s of e.nodes)if(s.s===n||s.e===n)return[s.node,n-s.s];return[e.container,n===0?0:e.container.childNodes.length]}function j(e,n){let t=document.createRange();return t.setStart(e,n),t.setEnd(e,n),t}function K(e,n,t){if(n.nodeType===3){let i=e.nodes.find(c=>c.node===n);return i?i.s+t:null}if(n!==e.container&&!m(n,e.root))return null;let r=j(n,t),o=e.text.length,s=(i,c)=>{try{return r.comparePoint(i,c)>=0}catch{return!1}};for(let i of e.nodes)s(i.node,0)&&(o=Math.min(o,i.s));for(let i of e.atoms)s(i.el.parentNode,w(i.el))&&(o=Math.min(o,i.i));return o}function Le(e,n){let t=e.slice(n.bs,n.be),r=0;for(;r<t.length&&r<n.text.length&&t[r]===n.text[r];)r++;let o=0;for(;o<t.length-r&&o<n.text.length-r&&t[t.length-1-o]===n.text[n.text.length-1-o];)o++;return{bs:n.bs+r,be:n.be-o,text:n.text.slice(r,n.text.length-o)}}function G(e,n,t,r){if(e===n)return{s:t,e:r};let o=0,s=0,i=H.diff(e,n).map(c=>Le(e,c)).sort((c,l)=>c.bs-l.bs);for(let c of i){if(c.bs===c.be&&!c.text)continue;let l=c.text.length-(c.be-c.bs);if(c.be<=t)o+=l;else{if(c.bs>=r)continue;if(c.bs>=t&&c.be<=r){if(Ne.test(e.slice(c.bs,c.be)+c.text))return null;s+=l}else return null}}return{s:t+o,e:r+o+s}}function Be(e,n,t){let r=e.liveScope;if(r&&r.startContainer&&m(r.startContainer,n)&&m(r.endContainer,n)){let s=K(t,r.startContainer,r.startOffset);if(s!==null)return s}if(Y(n))return 0;let o=e.merged.text?t.text.indexOf(e.merged.text):-1;return o>=0&&t.text.indexOf(e.merged.text,o+1)<0?o:null}function Te(e,n){let t=e.commonAncestorContainer;for(t.nodeType===3&&(t=t.parentNode);t&&t!==n;t=t.parentNode)if(k(t)&&Y(t))return t;return n}var Oe=(e,n)=>e.tagName===n.tagName&&e.attributes.length===n.attributes.length&&[...e.attributes].every(t=>n.getAttribute(t.name)===t.value);function de(e,n){let t=[];for(let r=k(e)?e:e.parentNode;r&&r!==n&&W(r);r=r.parentNode)t.unshift(r);return t}function Ue(e,n,t){let[r,o]=e;if(r.nodeType===3){if(o!==0&&o!==r.data.length)return e;[r,o]=[r.parentNode,w(r)+(o===0?0:1)]}let s=!1;for(;r!==n&&W(r)&&(o===0||o===r.childNodes.length)&&!t.some(i=>Oe(i,r));)[r,o]=[r.parentNode,w(r)+(o===0?0:1)],s=!0;return s?[r,o]:e}function He(e,n,t){let r=de(n.startContainer,t),o=de(n.endContainer,t);return r.length!==o.length||r.some((s,i)=>s!==o[i])||r.length>e.wrappers.length||r.some((s,i)=>!Oe(s,e.wrappers[i]))?!1:(e.peel=r.length,!e.wrappers.slice(e.peel).some(s=>r.some(i=>i.tagName===s.tagName)))}function Fe(e,n,t,r){let o=e.childNodes.length===1&&k(e.firstChild)?e.firstChild:null;if(!o||!L.has(o.tagName))return;let s=document.createRange();s.setStart(...n),s.setEnd(...t);let i=Te(s,r);i===r||i.tagName!==o.tagName||i.namespaceURI!==o.namespaceURI||x(i)!==x(o)||o.replaceWith(...o.childNodes)}function Ge(e){if(!e.parsed)return e.fragment;let n=e.parsed.childNodes;return n.length?n.length===1&&n[0].nodeType===3?n[0].data:null:""}function Ve(e,n){let t=e.recovery.text,r=e.recovery.subject,o=b(r,n,r.nodeType);if(!o)return null;let s=o.nodeType===3&&o.parentNode?.localName==="textarea"?o.parentNode:o,i=t.local.text.slice(t.local.start,t.local.end);if(Ne.test(t.merged.text.slice(t.merged.start,t.merged.end))||i.includes(C))return null;let c={kind:"text",id:e.id,ticket:n.ticket,key:r.key,fragment:t.local.fragment,encoding:t.encoding,local:i,ids:new Set,range:document.createRange()};if(o.nodeType===8){let g=G(t.merged.text,o.data,t.merged.start,t.merged.end);return g?(c.range.setStart(o,g.s),c.range.setEnd(o,g.e),{...c,root:o,owner:o,scope:o,s:g.s,e:g.e,before:o.data,bs:g.s,be:g.e}):null}if(s.localName==="textarea"){if(c.encoding!=="plain")return null;let g=G(t.merged.text,s.value,t.merged.start,t.merged.end);return g?(c.range.selectNodeContents(s),{...c,root:s,field:s,scope:s,f:{text:s.value},s:g.s,e:g.e,before:s.value,bs:g.s,be:g.e}):null}let l=_(o),u=Be(t,o,l);if(u===null)return null;let d=G(t.merged.text,l.text.slice(u),t.merged.start,t.merged.end);if(!d)return null;let N=u+d.s,v=u+d.e,A=fe(l,N,"start"),a=N===v?A:fe(l,v,"end");if(c.parsed=c.encoding==="html"?Re(c.fragment):null,c.parsed&&Fe(c.parsed,A,a,o),c.parsed&&Ie(c.parsed)||(c.wrappers=c.parsed?Se(c.parsed):[],c.parsed&&D(c.parsed,c.ids),c.plain=Ge(c),N===v&&(A=a=Ue(A,o,c.wrappers)),c.range.setStart(...A),c.range.setEnd(...a),!He(c,c.range,o)))return null;let f=Te(c.range,o),p=f===o?l:_(f),E=K(p,...A),U=N===v?E:K(p,...a);return E===null||U===null||p.text.slice(E,U)!==l.text.slice(N,v)?null:{...c,root:o,f:l,s:N,e:v,scope:f,before:p.text,bs:E,be:U}}function qe(e){if(e.owner){let o=e.owner.data;e.owner.data=o.slice(0,e.s)+e.fragment+o.slice(e.e),e.check=()=>e.owner.data.slice(e.s,e.s+e.fragment.length)===e.fragment&&h(e.owner);return}if(e.field){let o=e.field,s=o.value.slice(0,e.s)+e.fragment+o.value.slice(e.e);o.textContent=s,o.value!==s&&(o.value=s,e.wroteProperty=!0),o.hasAttribute("data-value")&&o.setAttribute("data-value",s),e.check=()=>h(o)&&o.value===s&&o.textContent===s;return}let n=e.range,t=n.startContainer;if(e.plain!==null&&t.nodeType===3&&n.endContainer===t){let o=n.startOffset;t.replaceData(o,n.endOffset-o,e.plain),e.check=()=>h(t)&&t.data.slice(o,o+e.plain.length)===e.plain;return}n.deleteContents();let r=[];if(e.fragment)if(e.parsed){let o=document.importNode(e.parsed,!0),s=Se(o);for(let i=0;i<e.peel;i++)s[i].replaceWith(...s[i].childNodes);r=[...o.childNodes],n.insertNode(o)}else r=[document.createTextNode(e.fragment)],n.insertNode(r[0]);e.check=()=>r.every(h)&&(e.parsed||!r.length||r[0].data===e.fragment)}function _e(e,n){let t=b(e.recovery.subject,n,1);if(!t)return null;let r=e.recovery.attribute,o={kind:"attr",id:e.id,ticket:n.ticket,key:e.recovery.subject.key,el:t,ns:r.namespaceURI,name:r.qualifiedName,local:r.localName,value:e.local??null,ids:new Set};try{o.ns===null?document.createAttribute(o.name):document.createAttributeNS(o.ns,o.name)}catch{return null}return o}var je=new Set(["hidden","submit","image","reset","button","checkbox","radio","file"]);function Ke(e,n){let t=document.createElement("input");return t.type=e.type,t.value=n,t.value}function We(e){let n=e.el;return e.ns!==null||n.namespaceURI!=="http://www.w3.org/1999/xhtml"?null:n.localName==="input"&&e.name==="checked"&&(n.type==="checkbox"||n.type==="radio")?["checked",e.value!==null]:n.localName==="input"&&e.name==="value"&&!je.has(n.type)?["value",Ke(n,e.value??"")]:n.localName==="option"&&e.name==="selected"?["selected",e.value!==null]:null}function ze(e){e.ns===null?e.value===null?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,e.value):e.value===null?e.el.removeAttributeNS(e.ns,e.local):e.el.setAttributeNS(e.ns,e.name,e.value);let n=We(e);n&&e.el[n[0]]!==n[1]&&(e.el[n[0]]=n[1],e.wroteProperty=!0);let t=()=>e.ns===null?e.el.getAttribute(e.name):e.el.getAttributeNS(e.ns,e.local);e.check=()=>h(e.el)&&t()===e.value&&(!n||e.el[n[0]]===n[1])}function Ye(e,n){let t=e.recovery.structure,r=e.recovery.subject,o=b(r,n,r.nodeType),s={id:e.id,ticket:n.ticket,key:r.key,apply:n,ids:new Set},i=c=>c?b(c.parent,n,1):null;if(t.localAction==="deleted")return o?{...s,kind:"remove",node:o}:Pe(r)?{...s,kind:"done",check:()=>!0}:null;if(t.localAction==="moved"){let c=i(t.localPlacement);return!o||!c||o===c||m(c,o)?null:{...s,kind:"move",node:o,parent:c,placement:t.localPlacement}}if(t.localAction==="reordered"){if(!o||!t.localOrder)return null;let c=y(o),l=t.localOrder.map(u=>b(u,n,u.nodeType)).filter(u=>u&&u.parentNode===c);return l.length<2?null:{...s,kind:"reorder",parent:o,order:l}}if(t.localAction==="inserted"){let c=i(t.localPlacement);if(!c||o&&o.parentNode!==y(c))return null;if(t.fragmentKind!=="element")return typeof t.localFragment!="string"?null:{...s,kind:"run",node:o,parent:c,placement:t.localPlacement,text:t.localFragment,nodeType:r.nodeType};let l=r.local.length?Ae(n.root,r.local[0]):null;if(!k(l))return null;let u=o?o.tagName===l.tagName&&o.namespaceURI===l.namespaceURI?"morph":"replace":"place";return{...s,kind:"realize",node:o,parent:c,placement:t.localPlacement,src:l,mode:u,ids:D(l)}}return null}function V(e,n,t,r){let o=y(n),s=l=>{for(let u of l){let d=b(u,r,u.nodeType);if(d&&d!==e&&d.parentNode===o)return d}return null},i=s(t.before);if(i)return o.insertBefore(e,i);let c=s(t.after);return c?o.insertBefore(e,c.nextSibling):t.before.length?o.insertBefore(e,o.firstChild):o.appendChild(e)}function $e(e){let n=document.importNode(e.src,!0),t=document.createDocumentFragment();return t.append(n),e.apply.domain==="save"&&(se(t),ce(t),ie(t),Z(t)),n}function Qe(e,n){let t=e.filter(r=>r.kind==="move");for(let r of t)n.append(r.node);for(let r of e){if(r.kind==="run"){r.node?r.node.data=r.text:r.node=V(r.nodeType===8?document.createComment(r.text):document.createTextNode(r.text),r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)&&r.node.data===r.text;continue}if(r.kind!=="realize")continue;let o=$e(r);r.mode==="morph"?H.morphElement(r.node,o,{ignore:B,scripts:{execute:!1}}):r.mode==="replace"?(r.node.replaceWith(o),r.node=o):r.node=V(o,r.parent,r.placement,r.apply),r.check=()=>h(r.node)&&r.node.parentNode===y(r.parent)}for(let r of t)V(r.node,r.parent,r.placement,r.apply),r.check=()=>r.node.parentNode===y(r.parent)&&h(r.node);for(let r of e){if(r.kind!=="reorder")continue;let o=y(r.parent),s=r.order.filter(u=>u.parentNode===o),i=s.slice(),c=[...o.childNodes].map(u=>s.includes(u)?i.shift():u),l=null;for(let u=c.length-1;u>=0;u--){let d=c[u];s.includes(d)&&d.nextSibling!==l&&o.insertBefore(d,l),l=d}r.check=()=>{let u=[...o.childNodes].filter(d=>s.includes(d));return u.length===s.length&&u.every((d,N)=>d===s[N])}}for(let r of e)r.kind==="remove"&&(r.node.remove(),r.check=()=>!h(r.node))}function O(e){return e.kind==="move"||e.kind==="remove"?[e.node]:e.kind==="realize"||e.kind==="run"?e.node?[e.node]:[]:[]}function R(e){return e.kind==="text"?[e.scope]:e.kind==="move"||e.kind==="reorder"?[e.parent]:(e.kind==="realize"||e.kind==="run")&&!e.node?[e.parent]:[]}var be=e=>e.kind==="attr"?[e.el]:[...O(e),...R(e)];function Xe(e,n){try{let t=j(e.startContainer,e.startOffset),r=j(n.startContainer,n.startOffset);return e.collapsed&&n.collapsed?t.comparePoint(n.startContainer,n.startOffset)===0:t.comparePoint(n.endContainer,n.endOffset)>0&&r.comparePoint(e.endContainer,e.endOffset)>0}catch{return!1}}function Je(e,n){try{return e.comparePoint(n.startContainer,n.startOffset)===0&&e.comparePoint(n.endContainer,n.endOffset)===0}catch{return!1}}function Ze(e,n){try{return e.intersectsNode(n)&&!m(e.commonAncestorContainer,n)}catch{return!1}}function I(e,n){if(!e.ids.size&&!n.ids.size)return!1;let t=s=>{let i=new Set;for(let c of be(s))D(c,i);return i},r=e.ids.size?null:t(e),o=t(n);return[...e.ids].some(s=>n.ids.has(s)||o.has(s))||[...n.ids].some(s=>(r||t(e)).has(s))}function me(e,n){return n.kind==="text"?Ze(n.range,e.el):O(n).some(t=>m(e.el,t))||n.ids.has(x(e.el))}function pe(e,n){return n.kind==="reorder"?m(n.parent,e.scope)||I(e,n):O(n).some(t=>m(t,e.scope)||m(e.scope,t))||R(n).some(t=>m(t,e.scope))?!0:I(e,n)}function he(e,n){return O(n).some(t=>e.order.includes(t)||m(e.parent,t))||R(n).includes(e.parent)?!0:I(e,n)}function q(e,n){if(e.kind==="done"||n.kind==="done")return!1;if(e.kind==="text"&&n.kind==="text")return Xe(e.range,n.range);if(e.kind==="attr"&&n.kind==="attr")return e.el===n.el&&e.ns===n.ns&&e.local===n.local;if(e.kind==="attr")return me(e,n);if(n.kind==="attr")return me(n,e);if(e.kind==="text")return pe(e,n);if(n.kind==="text")return pe(n,e);if(e.kind==="reorder"&&n.kind==="reorder")return e.parent===n.parent||I(e,n);if(e.kind==="reorder")return he(e,n);if(n.kind==="reorder")return he(n,e);for(let t of O(e))for(let r of O(n))if(m(t,r)||m(r,t))return!0;for(let t of O(e))for(let r of R(n))if(m(r,t))return!0;for(let t of O(n))for(let r of R(e))if(m(r,t))return!0;return I(e,n)}function et(e,n){return e.kind==="done"?!1:e.kind==="attr"?m(e.el,n.node):be(e).some(t=>m(t,n.node)||m(n.node,t))?!0:e.ids.size?(n.ids||(n.ids=D(n.node)),[...e.ids].some(t=>n.ids.has(t))):!1}function tt(e,n){return e.kind==="text"&&n.kind==="text"&&!e.field&&e.root===n.root&&Je(e.range,n.range)}function nt(e,n){let t=oe(e);return t?t.nodes:[rt(e,n)]}function rt(e,n){let t=e.recovery,r=t.subject;for(let c of t.text?[t.text.liveSpan,t.text.liveScope]:[])if(c&&c.startContainer&&h(c.startContainer)&&h(c.endContainer))return st(ot(c));let o=r?b(r,n,r.nodeType):null;if(o)return o;let s=t.structure&&t.structure.localPlacement?b(t.structure.localPlacement.parent,n,1):null;if(s)return s;let i=r&&r.local.length?r.local[0]:[];for(let c=i.length-1;c>0;c--){if(i[c-1]==="content")continue;let l=$(i.slice(0,c),n);if(l)return l}return document.documentElement}function ot(e){let n=new Set;for(let r=e.startContainer;r;r=r.parentNode)n.add(r);let t=e.endContainer;for(;t&&!n.has(t);)t=t.parentNode;return t.nodeType===1||t.nodeType===11?t:t.parentNode}function st(e){for(let n=e;n;n=n.parentNode)if(k(n)&&ke.has(n.tagName))return n;return e}function ct(e,n){let t=e.recovery;return t.applied===!1||t.unavailable?null:t.structure?Ye(e,n):t.text?Ve(e,n):t.attribute?_e(e,n):null}var P=()=>`${re()}|${S.hasPendingApply()?1:0}|${S.list().map(e=>e.id).join(",")}`;function Ee(){let e={ids:new Map,nested:new Set},n=r=>{for(let o of["id","data-id"]){let s=r.getAttribute(o);s&&e.ids.set(`${o} ${s}`,(e.ids.get(`${o} ${s}`)||0)+1)}},t=(r,o)=>{for(let s of y(r).children)n(s),o&&L.has(s.tagName)&&e.nested.add(s),t(s,o||W(s)||we.has(s.tagName))};return n(document.documentElement),t(document.documentElement,!1),e}function it(e){let n=Ee();for(let[r,o]of n.ids)if(o>1&&(e.before.ids.get(r)||0)<=1)return!1;for(let r of n.nested)if(!e.before.nested.has(r))return!1;let t=new Map;for(let r of e.ops)r.kind==="text"&&t.set(r.scope,[...t.get(r.scope)||[],r]);for(let[r,o]of t){let s=o[0].before;for(let c of[...o].sort((l,u)=>u.bs-l.bs))s=s.slice(0,c.bs)+c.local+s.slice(c.be);if((o[0].owner?r.data:o[0].field?r.value:_(r).text)!==s)return!1}return!0}function lt(){let e=new Map,n=c=>{for(let l of c.querySelectorAll("*"))e.set(l,[...l.attributes].map(u=>[u,u.value])),l.localName==="template"&&l.content&&n(l.content)};n(document);let t=[];for(let c of document.querySelectorAll("input, textarea"))t.push([c,"value",c.value]);for(let c of document.querySelectorAll("input"))t.push([c,"checked",c.checked]);for(let c of document.querySelectorAll("option"))t.push([c,"selected",c.selected]);let r=document.activeElement,o=null;try{r&&typeof r.selectionStart=="number"&&(o=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{}let s=document.getSelection(),i=s&&s.rangeCount?[s.anchorNode,s.anchorOffset,s.focusNode,s.focusOffset]:null;return{attrs:e,controls:t,active:r,caret:o,selection:i}}function at(e,n){let t=e.attributes;return t.length===n.length&&n.every(([r,o],s)=>t[s]===r&&r.value===o)}function ut(e,n){let t=new Set;for(let s=e.length-1;s>=0;s--){let i=e[s];if(i.type==="characterData")i.target.data=i.oldValue;else if(i.type==="attributes")t.add(i.target);else{for(let c of i.addedNodes)c.parentNode===i.target&&i.target.removeChild(c);for(let c of i.removedNodes)i.target.insertBefore(c,i.nextSibling)}}for(let s of t){let i=n.attrs.get(s);if(!(!i||at(s,i))){for(let c of[...s.attributes])s.removeAttributeNode(c);for(let[c,l]of i)c.value=l,s.setAttributeNode(c)}}for(let[s,i,c]of n.controls)if(s[i]!==c)try{s[i]=c}catch{}let r=document.getSelection();r&&n.selection?h(n.selection[0])&&h(n.selection[2])&&r.setBaseAndExtent(...n.selection):r&&r.rangeCount&&r.removeAllRanges();let o=n.active;if(o&&o!==document.activeElement&&o!==document.body&&h(o)&&o.focus&&o.focus({preventScroll:!0}),n.caret&&document.activeElement===o)try{o.setSelectionRange(...n.caret)}catch{}}function ft(e){let n=t=>{e.observe(t,ve);for(let r of t.querySelectorAll("template"))r.content&&n(r.content)};n(document)}function dt(e){let n=new Set;for(let t of e)if(t.type==="characterData"){if(n.has(t.target))return!1;n.add(t.target)}return!0}function mt(e){let n=P(),t=new Map,r=new Map,o=[],s=new Set;for(let a of e){if(s.has(a))continue;s.add(a);let f=S.get(a);f&&(f.claimedBy||f.kind==="apply-incomplete"||f.kind==="json"||!f.recovery?t.set(a,T):o.push(f))}if(S.hasPendingApply()){for(let a of o)t.set(a.id,T);return{ops:[],covered:r,blocked:t,revision:n,before:null}}let i=[],c=a=>{let f=S.recoveryOf(a.id),p=f?ct(a,f):null;if(!p&&f)for(let E of nt(a,f))i.push({ticket:f.ticket,node:E});return p},l=[];for(let a of o){let f=c(a);f?l.push(f):t.set(a.id,T)}let u=[];for(let a of S.list())if(!s.has(a.id)){if(a.kind==="apply-incomplete")i.push({ticket:a.ticket,node:document.documentElement});else if(a.recovery){let f=c(a);f&&u.push(f)}}l.sort((a,f)=>f.ticket-a.ticket);let d=[],N=[],v=a=>{t.set(a.id,T),N.push(a)};for(let a of l){if(i.some(p=>p.ticket>a.ticket&&et(a,p))||u.some(p=>p.ticket>a.ticket&&q(p,a))||N.some(p=>q(p,a))){v(a);continue}let f=d.find(p=>q(p,a));if(!f){d.push(a);continue}if(tt(f,a)){r.set(a.id,f.id);continue}v(a),f.ticket===a.ticket&&(d.splice(d.indexOf(f),1),v(f))}let A=ne(i.filter(a=>d.some(f=>a.ticket>f.ticket)).map(a=>a.node));return{ops:d,covered:r,blocked:t,revision:P(),protectedWitnesses:A,before:Ee()}}function pt(e){if(e.revision!==P()||!F(e.protectedWitnesses||[])){for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}let n=lt(),t=window.clay?.undo;t?.pause?.();let r=new MutationObserver(()=>{}),o=document.createDocumentFragment(),s=[],i=!1;try{ft(r),r.observe(o,ve);let c=e.ops.filter(l=>l.kind==="text").sort((l,u)=>l.root===u.root?u.s-l.s||u.e-l.e:0);for(let l of c)qe(l);for(let l of e.ops)l.kind==="attr"&&ze(l);Qe(e.ops.filter(l=>l.kind!=="text"&&l.kind!=="attr"),o),s=r.takeRecords(),i=e.ops.every(l=>l.check())&&it(e)&&e.revision===P()&&F(e.protectedWitnesses||[])}catch(c){console.error("[clay] Revert to mine failed while writing and was undone",c)}finally{s=s.concat(r.takeRecords()),r.disconnect()}if(i)return dt(s)&&!e.ops.some(c=>c.wroteProperty)?t?.commitCaptured?.("Revert to mine"):t?.discardCaptured?.(),t?.resume?.(),[...e.ops.map(c=>c.id),...e.covered.keys()];try{ut(s,n)}finally{J.dropQueued(),t?.discardCaptured?.(),t?.resume?.()}for(let c of e.ops)e.blocked.set(c.id,T);for(let c of e.covered.keys())e.blocked.set(c,T);return[]}async function wt(e){await Promise.resolve();let n=mt(e),t=pt(n);Q();let r=null;return t.length&&(ee(),S.acknowledge(t,{reason:"reverted"}),X(),await Promise.resolve(),r=await te()),{revertedIds:t,blockedIds:[...n.blocked.keys()],saveResult:r}}export{T as BLOCKED,pt as applyRevert,mt as prepareRevert,wt as revertConflicts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./c-OZOACVUD.js";import"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{c as bevelDialog,a as dismissOf,b as keepFocusIn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as g}from"./c-2TJCFPX4.js";import{a as F,b as i}from"./c-4M2T676V.js";import"./c-Y6HH7LTM.js";import"./c-RHMPKZZ7.js";import"./c-OZOACVUD.js";import{d as P}from"./c-QHWJ5ZIJ.js";import{c as C,f as s,j as m,m as c}from"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import{c as $}from"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";function U(a,v){let u=0,e=async()=>{let l=++u;try{let n=await v(),d=n?await n.list():[];if(l!==u)return;if(!d.length)return a.removeItem("clay.earlier-drafts");a.addItem({id:"clay.earlier-drafts",label:g.label,run:()=>I(n,{refresh:e,anchor:a.goo}).catch(()=>a.note("The drafts could not be opened. Try again."))})}catch{l===u&&a.removeItem("clay.earlier-drafts")}};return a.beforeOpen.push(e),e(),e}async function I(a,{refresh:v=()=>{},anchor:u=document.activeElement}={}){let e=P(),l=s("div",["display:flex","flex-direction:column","gap:16px"],{theme:e,parts:["dialog.content"]});l.dataset.draftCopies="",l.append(m("p",["display:block","margin:0"],g.intro,{theme:e}));let n=m("p",["display:block","margin:0"],"",{theme:e});n.setAttribute("role","status");let d=s("ol",["display:flex","flex-direction:column","gap:16px","padding:0","margin:0","list-style:none"],{theme:e});l.append(n,d);let A=!1;async function T(){let S=await a.list();d.replaceChildren(),S.length||(n.textContent="No earlier drafts are kept.");for(let r of S){let h=s("li",["display:flex","flex-direction:column","gap:8px"],{theme:e});h.dataset.draftMark=r.mark;let D=new Date(r.savedAt),k=Number.isNaN(D.getTime())?"Time unavailable":D.toLocaleString(),q=m("time",["display:block",`font-family:${$}`],k,{theme:e});r.savedAt&&(q.dateTime=r.savedAt),h.append(q,m("p",["display:block","margin:0"],`${r.fields} saved ${r.fields===1?"field":"fields"}`,{theme:e,role:"mutedText"}));let E=s("div",["display:flex","flex-wrap:wrap","gap:8px"],{theme:e}),f=s("div",["display:block"],{theme:e});c(f,!1);let b=s("div",["display:flex","flex-wrap:wrap","gap:8px","align-items:center"],{theme:e});c(b,!1);let y=(o,w,p={})=>{let t=C(o,{small:!0,theme:e,...p,onClick:async()=>{if(!A){A=!0,t.setDisabled(!0),n.textContent="";try{await w(t)}catch(H){n.textContent=H.message||"That did not work. Try again."}finally{A=!1,t.setDisabled(!1)}}}});return t.setAttribute("aria-label",`${o}: ${k}`),t},x=y("Preview",()=>{if(!f.hidden){c(f,!1),x.setAttribute("aria-expanded","false");return}let o=new DOMParser().parseFromString(a.html(r.copy),"text/html");for(let t of o.querySelectorAll('script, meta[http-equiv="refresh" i]'))t.remove();for(let t of o.querySelectorAll("input, textarea, select, button"))t.disabled=!0;for(let t of o.querySelectorAll("[contenteditable]"))t.removeAttribute("contenteditable");for(let t of o.querySelectorAll("a, area"))t.removeAttribute("href"),t.removeAttributeNS("http://www.w3.org/1999/xlink","href"),t.removeAttribute("xlink:href");let w=o.createElement("meta");w.httpEquiv="Content-Security-Policy",w.content="default-src 'none'; style-src 'unsafe-inline'; img-src data: blob:; form-action 'none'",o.head.prepend(w);let p=s("iframe",["display:block","width:100%","height:45vh","border:0"],{theme:e});p.title=`Draft preview: ${k}`,p.setAttribute("sandbox",""),p.srcdoc=`<!DOCTYPE html>
|
|
2
|
+
`+o.documentElement.outerHTML,f.replaceChildren(p),c(f,!0),x.setAttribute("aria-expanded","true")});x.setAttribute("aria-expanded","false");let N=y("Restore",async()=>{await a.restore(r.mark),n.textContent="Draft restored. Reloading the page.",await v()}),R=y("Download",()=>a.download(r.copy));for(let o of[x,N,R])o.setDisabled(!r.available);let O=y("Remove",()=>{c(b,!0,"flex"),M.focus()}),M=C("Keep draft",{small:!0,theme:e,onClick:()=>{c(b,!1),O.focus()}});b.append(m("p",["margin:0"],"Remove this saved draft?",{theme:e}),M,y("Remove draft",async()=>{await a.remove(r.mark),await T(),await v(),d.querySelector("button")?.focus()},{variant:"danger"})),E.append(x,N,R,O),h.append(E,b,f),d.append(h)}}return await T(),i.title=g.label,i.html=l,i.width="720px",i[F]=e,i.closeHtml="x",i.no="Close",i.onNo(()=>u?.focus()),i.open(),l}export{U as attachRecoveryMenu,I as openRecovery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,b as c,c as o,d as n}from"./c-QCDVDZIR.js";import{a as u}from"./c-VKEDWYDF.js";import{f as a}from"./c-C7SUMNMI.js";import{b as l,r as b}from"./c-UW6MMZ4V.js";var r="[editmode\\:contenteditable]";function m(){b(e=>{e.querySelectorAll(r).forEach(t=>{n(t),o(t,l(t)??t)})},{required:!0})}function s(){a&&u(()=>{p()})}function p(e=document){e.querySelectorAll(r).forEach(t=>{d(t);let i=t.getAttribute("inert-contenteditable")??t.getAttribute("contenteditable")??c(t,"inert-contenteditable")??"true",f=i.toLowerCase();t.setAttribute("contenteditable",["","true","false","plaintext-only"].includes(f)?i:"true"),t.removeAttribute("inert-contenteditable")})}function y(){document.querySelectorAll(r).forEach(e=>{n(e),o(e)})}function S(){m(),s()}export{r as a,p as b,y as c,S as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./c-7NCWENHV.js";import{C as M}from"./c-
|
|
1
|
+
import{a as u}from"./c-7NCWENHV.js";import{C as M}from"./c-3Y234AUB.js";import{d as v}from"./c-OH2FPYSY.js";import{b as S,d as x}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var{Plugin:R}=S,{Decoration:D}=x;var O=[["","Plain text"],["javascript","JavaScript"],["typescript","TypeScript"],["jsx","JSX"],["tsx","TSX"],["json","JSON"],["html","HTML"],["css","CSS"],["python","Python"],["shellscript","Shell"],["sql","SQL"],["go","Go"],["rust","Rust"],["java","Java"],["c","C"],["cpp","C++"],["csharp","C#"],["ruby","Ruby"],["php","PHP"],["yaml","YAML"],["markdown","Markdown"],["diff","Diff"],["swift","Swift"],["kotlin","Kotlin"],["xml","XML"]],L=new Set(O.map(([s])=>s)),T={js:"javascript",mjs:"javascript",ts:"typescript",py:"python",sh:"shellscript",bash:"shellscript",shell:"shellscript",zsh:"shellscript",rb:"ruby",yml:"yaml",md:"markdown",htm:"html",golang:"go",rs:"rust","c++":"cpp",cs:"csharp","c#":"csharp",kt:"kotlin"},m=s=>{let t=String(s??"").trim().toLowerCase(),e=T[t]??t;return L.has(e)?e:""},n=s=>({color:s}),C={name:"page",appearance:"light",cssVariables:{prefix:"--blockeditor-code-token-"},style:{syntax:{comment:n("comment"),keyword:n("keyword"),operator:n("keyword"),preproc:n("keyword"),"punctuation.special":n("keyword"),string:n("string-expression"),"string.escape":n("constant"),"string.regex":n("constant"),"string.special":n("constant"),number:n("constant"),boolean:n("constant"),constant:n("constant"),type:n("constant"),property:n("constant"),enum:n("constant"),variant:n("constant"),namespace:n("constant"),label:n("constant"),function:n("function"),constructor:n("function"),selector:n("function"),attribute:n("function"),"variable.parameter":n("parameter"),tag:n("string-expression"),link_uri:n("link"),link_text:n("link"),"diff.plus":n("string-expression"),"diff.minus":n("keyword"),title:{font_weight:700},emphasis:{font_style:"italic"},"emphasis.strong":{font_weight:700}}}},E=null;async function P(s,t){E??=import("./c-3OWDMNJR.js");let{codeToTokens:e}=await E;return e(s,{lang:t,theme:C}).tokens}var _="var(--blockeditor-code-token-foreground)",A=s=>{let t=[];return s.color&&s.color!==_&&t.push(`color: ${s.color}`),s.fontStyle&1&&t.push("font-style: italic"),s.fontStyle&2&&t.push("font-weight: 600"),s.fontStyle&4&&t.push("text-decoration: underline"),t.join("; ")},H=200,y=class{constructor(t,e,i){this.view=t,this.run=e,this.delay=i,this.cache=new Map,this.pending=new Set,this.visible=new Set,this.targets=new Map,this.timer=0;let c=t.dom.ownerDocument.defaultView.IntersectionObserver;this.io=c?new c(a=>{for(let o of a){let r=o.target.dataset.id;this.targets.get(r)===o.target&&this.visible[o.isIntersecting?"add":"delete"](r)}this.schedule(0)},{rootMargin:"200px 0px"}):null,this.schedule(0)}update(t,e){(!e||t.state.doc!==e.doc)&&this.schedule(this.delay)}schedule(t){clearTimeout(this.timer),this.timer=setTimeout(()=>this.pass(),t)}pass(){let{view:t}=this;if(t.isDestroyed)return;let e=[],i=new Map,c=u.getState(t.state);t.state.doc.forEach((o,r)=>{if(o.type!==v.nodes.code_block)return;let d=o.attrs.id,p=t.nodeDOM(r);p&&i.set(d,p);let g=m(o.attrs.lang);if(!g)return;let k=o.textContent,h=`${g}
|
|
2
2
|
${k}`,b=this.cache.get(h);if(b)for(let l of b){let w=A(l);w&&l.content&&e.push(D.inline(r+1+l.offset,r+1+l.offset+l.content.length,{style:w}))}else{if(e.push(...c.find(r,r+o.nodeSize)),this.io&&!this.visible.has(d)||this.pending.has(h))return;this.pending.add(h),this.run(k,g).then(l=>l.flat(),()=>[]).then(l=>{this.pending.delete(h),this.cache.set(h,l),this.cache.size>H&&this.cache.delete(this.cache.keys().next().value),this.schedule(0)})}}),this.track(i);let a=o=>o.map(r=>`${r.from}:${r.to}:${r.type.attrs.style}`).join("|");a(e)!==a(u.getState(t.state).find())&&t.dispatch(t.state.tr.setMeta(u,e).setMeta("addToHistory",!1))}track(t){if(this.io){for(let[e,i]of this.targets)t.get(e)!==i&&(this.io.unobserve(i),this.targets.delete(e),this.visible.delete(e));for(let[e,i]of t)this.targets.get(e)!==i&&(this.targets.set(e,i),this.io.observe(i))}}destroy(){clearTimeout(this.timer),this.io?.disconnect()}};function j(s,{tokenize:t=P,delay:e=300}={}){let i=new y(s,t,e),c=s.dispatch.bind(s),a=s.state.doc,o=d=>{if(c(d),s.state.doc===a)return;let p={doc:a};a=s.state.doc,i.update(s,p)};s.dispatch=o;let r=i.destroy.bind(i);return i.destroy=()=>{s.dispatch===o&&(s.dispatch=c),r()},i}var f=class{constructor(t,e,i){this.node=t,this.view=e,this.getPos=i;let c=e.dom.ownerDocument;this.dom=c.createElement("pre"),this.contentDOM=c.createElement("code"),this.select=c.createElement("select"),this.select.className="blockeditor-code-lang",this.select.contentEditable="false",this.select.setAttribute("aria-label","Code language");for(let[a,o]of O)this.select.append(new Option(o,a));this.select.addEventListener("change",()=>this.setLang(this.select.value)),this.dom.append(this.select,this.contentDOM),this.render(t)}render(t){this.node=t,this.dom.dataset.id=t.attrs.id??"";let e=m(t.attrs.lang);e?this.dom.dataset.lang=e:delete this.dom.dataset.lang,this.select.value=e}setLang(t){let e=this.getPos();e==null||t===m(this.node.attrs.lang)||(this.view.dispatch(M(this.view.state.tr.setNodeMarkup(e,null,{...this.node.attrs,lang:t}))),this.view.focus())}update(t){return t.type!==this.node.type?!1:(this.render(t),!0)}stopEvent(t){return this.select.contains(t.target)}ignoreMutation(t){return t.type!=="selection"&&this.select.contains(t.target)}};function X({view:s=null,highlight:t={}}={}){let e=s?j(s,t):null;return{id:"code",nodeViews:{code_block:(i,c,a)=>new f(i,c,a)},css:null,dispose(){e?.destroy()}}}export{X as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as u}from"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import{a as d}from"./c-4JZDZFF6.js";import{b as c,e as n}from"./c-5RZNFTWD.js";import{b as s}from"./c-PKCCHJ5X.js";import{a as l,b as f}from"./c-5KXDKC5G.js";import{a,b as i}from"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";var p={error:"Couldn't save",offline:"Offline, will retry",blocked:"Can't save here",unavailable:"Can't store changes: download a copy"},x=new Set(["saving","pending","acknowledged"]),b=new Set(["saved","checkpointed"]),h=[`background:${n["ox-soft"]}`,`color:${n.ox}`,`border-color:color-mix(in srgb, ${n.ox} 28%, ${n["ox-soft"]})`],e=null;function g(){if(e&&e.isConnected)return e;let o=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return e=u("div",["position:fixed","right:16px","bottom:16px","z-index:2147483000","padding:4px 12px",`font:500 13px/1.6 ${c}`,"opacity:0",`transition:${o?"none":"opacity .25s"}`,"pointer-events:none",`color-scheme:${d()}`]),e.setAttribute("data-clay-indicator",""),e.setAttribute("role","status"),document.body.appendChild(e),e}function r(){e&&(i(e,"opacity","0"),e.textContent="",delete e.dataset.state)}function C(){r()}function S(o,m){if(x.has(o))return;if(b.has(o))return r();if(o==="retrying"){e?.dataset.state==="error"&&r();return}if(!p[o]||o==="error"&&m?.[f])return;if(l.toasts&&o!=="blocked"){r();return}let t=g();t.textContent=p[o],t.dataset.state=o,a(t,h),s(t,{background:null}),i(t,"opacity","1")}function k(){e?.remove(),e=null}export{k as remove,S as show,C as standDown};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{y as O}from"./c-
|
|
1
|
+
import{y as O}from"./c-3Y234AUB.js";import{A as $,d as N,y as x,z as C}from"./c-OH2FPYSY.js";import{a as A}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var g=N.nodes,H=e=>e.attrs.parent??null,_=e=>{let a=new Set;return e.forEach(t=>t.forEach(o=>a.add(o.attrs.col))),C(e.attrs.cols).filter(t=>a.has(t))};function S(e,a){let t=a.ownerDocument,o=t.createElement("thead").appendChild(t.createElement("tr"));for(let s of _(e)){let p=e.attrs.cols[s],r=o.appendChild(t.createElement("th"));r.setAttribute("data-col",s),r.setAttribute("scope","col"),p.kind&&r.setAttribute("data-kind",p.kind),p.width&&(r.setAttribute("data-width",String(p.width)),r.style.width=`${p.width}px`),r.textContent=p.name??""}a.prepend(o.parentNode),e.attrs.sort&&a.setAttribute("data-sort",JSON.stringify(e.attrs.sort))}function v(e,a){let t=[];e.forEach((o,s,p)=>{let r=a[p];if(!r||r.nodeType!==1)return;if(o.type===g.table&&S(o,r),o.type!==g.list_item||H(o)!==null){t=[];return}let f=r.ownerDocument,{indent:d,kind:i}=o.attrs,l=i==="ordered"?"OL":"UL";for(;t.length&&t.at(-1).indent>d;)t.pop();if(t.at(-1)?.indent===d&&t.at(-1).list.tagName!==l&&t.pop(),!t.length||t.at(-1).indent<d){let c=f.createElement(l);t.length?t.at(-1).li.append(c):r.before(c),t.push({indent:d,list:c,li:null})}let u=f.createElement("li");i==="check"&&(u.innerHTML=`<input type="checkbox" disabled${o.attrs.checked?" checked":""}>`),u.append(...r.childNodes),t.at(-1).list.append(u),t.at(-1).li=u,r.remove()})}var T=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function q(e){if(!e.content.firstChild?.type.spec.group?.includes("block"))return null;let a="",t=[],o=!1;return e.content.forEach((s,p,r)=>{let f=s.type===g.list_item,d=s.textBetween(0,s.content.size,`
|
|
2
2
|
|
|
3
3
|
`);if(f){let{indent:i,kind:l}=s.attrs;for(;t.length&&t.at(-1).indent>i;)t.pop();t.at(-1)?.indent===i&&t.at(-1).kind!==l&&t.pop(),(!t.length||t.at(-1).indent<i)&&t.push({indent:i,kind:l,n:0});let u=t.at(-1),c=l==="ordered"?`${++u.n}.`:l==="check"?`- [${s.attrs.checked?"x":" "}]`:"-";d=`${" ".repeat(t.length-1)}${c} ${d}`}else t=[];if(s.type===g.table){let i=[_(s).map(l=>T(s.attrs.cols[l].name??""))];s.forEach(l=>{let u=[];l.forEach(c=>u.push(T(c.textContent))),i.push(u)}),d=i.map(l=>l.join(" ")).join(`
|
|
4
4
|
`)}a+=(r?o&&f?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as h,d as f,h as x}from"./c-
|
|
1
|
+
import{C as h,d as f,h as x}from"./c-3Y234AUB.js";import{A as g,c as I,d as $}from"./c-OH2FPYSY.js";import{b as E}from"./c-RETTCOWO.js";var{Plugin:B,PluginKey:j}=E,k=$.nodes,m=new j("blockeditor-media"),L=1.5*1024*1024,u=new WeakMap,C=new WeakMap,U=(t,o)=>{let s=t.resolve(Math.max(0,Math.min(o,t.content.size)));return s.depth===0?s.pos:s.after(1)};function b(t,o){let s=x(t.doc),e=s[Math.min(o,s.length-1)],a=e.node.type===k.paragraph&&e.node.content.size===0;return{hostId:e.node.attrs.id,at:a?e.at:s[e.subEnd].end,parent:e.node.attrs.parent??null,replaceId:a?e.node.attrs.id:null}}var O={init:()=>({items:[],placed:{},picker:null}),apply(t,o){let{items:s,placed:e,picker:a}=o;if(t.docChanged&&(s=s.map(r=>({...r,pos:U(t.doc,t.mapping.map(r.pos,-1))}))),a&&t.docChanged&&(a={...a,place:{...a.place,at:U(t.doc,t.mapping.map(a.place.at,-1))}},a.remove)){let r=t.mapping.map(a.remove.from,1),c=t.mapping.map(a.remove.to,-1);a=r<=c&&t.doc.textBetween(r,c)===a.remove.text?{...a,remove:{...a.remove,from:r,to:c}}:null}let n=t.getMeta(m);if(n?.picker!==void 0&&(a=n.picker),n?.add&&(s=[...s,...n.add]),n?.update&&(s=s.map(r=>r.id===n.update.id?{...r,...n.update}:r)),n?.placed){let{id:r,at:c,size:d,blockId:p}=n.placed,i=o.items.find(l=>l.id===r);s=s.filter(l=>l.id!==r).map(l=>i&&l.pos===c&&l.group===i.group&&l.order>i.order?{...l,pos:l.pos+d}:l),i&&(e={...e,[i.group]:[...e[i.group]||[],p]})}n?.remove&&(s=s.filter(r=>r.id!==n.remove));for(let r of Object.keys(e))s.some(c=>c.group===r)||(e={...e},delete e[r]);return{items:s,placed:e,picker:a}}};function R(t,o,s){if(!o)return;let e=null,a=null;t.doc.forEach((n,r)=>{n.attrs.id===o&&e&&s.includes(e.attrs.id)&&(a={n,off:r}),e=n}),a&&a.n.type===k.paragraph&&a.n.content.size===0&&t.delete(a.off,a.off+a.n.nodeSize)}function P(t,o,s){let{items:e,placed:a}=m.getState(t),n=e.find(i=>i.id===o);if(!n)return null;let r=U(t.doc,n.pos),c=g(),d=(n.kind==="image"?k.image:k.file).create({...s,id:c,pos:null,parent:n.parent}),p=t.tr.insert(r,d);return e.some(i=>i.group===n.group&&i.id!==o)||R(p,n.replaceId,[...a[n.group]||[],c]),h(p).setMeta(m,{placed:{id:o,at:r,size:d.nodeSize,blockId:c}})}function F(t,o){let{items:s,placed:e}=m.getState(t),a=s.find(r=>r.id===o);if(!a)return null;let n=t.tr;return s.some(r=>r.group===a.group&&r.id!==o)||R(n,a.replaceId,e[a.group]||[]),n.docChanged&&h(n),n.setMeta(m,{remove:o})}function y(t,o,s=b(t.state,t.state.selection.$head.index(0))){if(o=[...o].filter(Boolean),!o.length)return!1;let e=g("g"),a=o.map((n,r)=>{let c=/^image\//.test(n.type||"")?"image":"file";return{id:g("u"),pos:s.at,group:e,order:r,file:n,kind:c,name:n.name||(c==="image"?"image":"file"),parent:s.parent,replaceId:s.replaceId,state:"uploading",percent:0,preview:c==="image"&&globalThis.URL?.createObjectURL?URL.createObjectURL(n):null}});t.dispatch(t.state.tr.setMeta(m,{add:a}));for(let n of a)H(t,n);return f(t,o.length===1?`Uploading ${a[0].name}`:`Uploading ${o.length} files`),!0}var z=(t,o)=>m.getState(t.state).items.find(s=>s.id===o),M=(t,o,s)=>t.dispatch(t.state.tr.setMeta(m,{update:{id:o,...s}})),A=(t,o)=>t.kind==="image"?{src:o,alt:"",caption:""}:{src:o,name:t.name,size:t.file.size??null,mime:t.file.type||null};function T(t,o,s){t.preview&&URL.revokeObjectURL?.(t.preview),s&&o.dispatch(s)}async function H(t,o){let s=u.get(t),e=new AbortController;s.aborts.set(o.id,e);let a=-5,n=({percent:d})=>{d-a<5&&d!==100||(a=d,u.has(t)&&z(t,o.id)&&M(t,o.id,{percent:d}))},r;try{r=await s.upload(o.file,{onProgress:n,signal:e.signal})}catch{r={code:"network",msg:"Upload failed"}}if(s.aborts.delete(o.id),!u.has(t)||!z(t,o.id))return;if(r?.ok){let d=I(r.uploads?.[0]?.url);if(d){T(o,t,P(t.state,o.id,A(o,d))),f(t,`${o.name} added`);return}r={code:"bad-response",msg:"The upload returned an invalid address"}}if((!r||typeof r!="object")&&(r={code:"bad-response",msg:"The upload returned an invalid response"}),r.code==="aborted")return T(o,t,F(t.state,o.id));if(r.code==="unsupported"){let d=/^image\/(png|jpeg|gif|webp)$/i.test(o.file.type)&&o.file.size<=L,p=d?"This host doesn't store files. You can keep this image inside the document, which makes the document larger.":o.kind==="image"&&o.file.size>L?"This host doesn't store files, and this image is over 1.5 MB, too large to keep inside the document.":"This host doesn't store files.";M(t,o.id,{state:d?"embed-choice":"error",code:r.code,message:p}),f(t,`${o.name}: ${p}`);return}let c=r.code==="timeout"?"The upload timed out. It may have arrived; trying again is safe.":r.msg||"Upload failed";M(t,o.id,{state:"error",code:r.code,message:c}),f(t,`${o.name}: ${c}`)}var Y=t=>t.replace(/<(meta|style|img)\b[^>]*>/gi,"").replace(/<[^>]+>/g,"").trim()!=="";function Q({upload:t,features:o=null}){let s=e=>{!o||o.has("media")||!u.has(e)||o.ensure("media").catch(()=>{})};return new B({key:m,state:O,view(e){let n=e.dom.ownerDocument.createElement("input");n.type="file",n.multiple=!0,n.hidden=!0,n.className="blockeditor-file-input",e.dom.parentElement.append(n),u.set(e,{upload:t,aborts:new Map,input:n}),n.addEventListener("change",()=>{let c=[...n.files??[]],d=m.getState(e.state).picker;if(e.dispatch(e.state.tr.setMeta(m,{picker:null})),c.length&&d){let{remove:p}=d;p&&e.state.doc.textBetween(p.from,p.to)===p.text&&e.dispatch(h(e.state.tr.delete(p.from,p.to)));let i=_(e.state.doc,d.place.hostId);(!d.place.hostId||i>=0)&&(y(e,c,i>=0?b(e.state,i):d.place),s(e))}n.value="",e.focus()}),n.addEventListener("cancel",()=>e.dispatch(e.state.tr.setMeta(m,{picker:null})));let r=c=>{let d=c.target.closest?.(".blockeditor-upload-btn");if(!d)return;c.preventDefault();let p=C.get(e),i=d.dataset.upload;d.dataset.act==="retry"?p?.retryUpload(e,i):d.dataset.act==="embed"?p?.embedUpload(e,i):p?.cancelUpload(e,i)};return e.dom.addEventListener("click",r),{destroy(){e.dom.removeEventListener("click",r);let c=u.get(e);u.delete(e);for(let d of m.getState(e.state).items)d.preview&&URL.revokeObjectURL?.(d.preview);for(let d of c.aborts.values())d.abort();n.remove()}}},props:{handlePaste(e,a){let n=a.clipboardData,r=[...n?.files??[]];if(!r.length||e.state.selection.$from.parent.type.spec.code||Y(n.getData("text/html")||""))return!1;let c=b(e.state,e.state.selection.$head.index(0));return a.preventDefault(),y(e,r,c),s(e),!0},handleDrop(e,a,n,r){let c=[...a.dataTransfer?.files??[]];if(r||!c.length)return!1;let d=e.posAtCoords({left:a.clientX,top:a.clientY});if(!d)return!1;let p=x(e.state.doc),i=Math.min(e.state.doc.resolve(d.pos).index(0),p.length-1),l=e.nodeDOM(p[i].at)?.getBoundingClientRect?.(),D=l&&a.clientY<l.top+l.height/2;a.preventDefault();let S={at:D?p[i].at:p[p[i].subEnd].end,parent:p[i].node.attrs.parent??null,replaceId:null};return y(e,c,S),s(e),!0}}})}var _=(t,o)=>{let s=-1;return t.forEach((e,a,n)=>{e.attrs.id===o&&(s=n)}),s};function V(t,o,s=b(t.state,t.state.selection.$head.index(0)),e=null){let a=u.get(t);if(!a)return!1;let n={place:s,remove:e&&{...e,text:t.state.doc.textBetween(e.from,e.to)}};return t.dispatch(t.state.tr.setMeta(m,{picker:n})),a.input.accept=o,a.input.click(),!0}export{m as a,L as b,u as c,C as d,U as e,b as f,P as g,F as h,z as i,M as j,A as k,T as l,H as m,Q as n,V as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as E,d as A,e as M,f as I}from"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as B}from"./c-
|
|
1
|
+
import{b as E,d as A,e as M,f as I}from"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as B}from"./c-3Y234AUB.js";import{E as m,fa as S,ia as L,ja as O,la as Y,ma as x}from"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var Q="This element holds blocks from a document editor. Reply with the same outer div. Inside it use p, h1, h2, h3, ul, ol, li, blockquote, pre with code, details with summary, hr, table with thead, tbody, tr, th, td, and the inline tags strong, em, s, u, code, a. You may also keep any tag already in the element. Keep each data-id on the block it belongs to, and give a new block no data-id. An hr with data-clay-keep stands for something you cannot see: keep it where it belongs unless the request says to remove it. Keep each checkbox on a list item unless the request says to remove it. No classes, no style attributes, no scripts.",U=new Set(["image","file","chart","board","toc","tool","preserved"]),$=new Set(["paragraph","heading","list_item","quote","callout","code_block","toggle","divider","table"]),p=(r,t)=>({status:"refused",code:r,message:t}),H=({id:r,parent:t,...i})=>({...i,parent:t??null}),F=(r,t)=>S(H(r))===S(H(t)),K=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,P=["owner","due","pageIcon","pageCoverSrc","pageCoverAlt","pageCoverX","pageCoverY"],G=(r,t)=>{let i={...t};for(let d of P)(i[d]===void 0||i[d]===null)&&r[d]!==void 0&&(i[d]=r[d]);return i},V=(r,t)=>{let i=new Set(r.cols.map(o=>o.id).filter(Boolean)),d=r.cols.map((o,l)=>{if(o.id)return o;let n=t.cols[l];return!n?.id||i.has(n.id)?o:(i.add(n.id),{...o,id:n.id})}).map(o=>{let l=o.id?t.cols.find(h=>h.id===o.id):null;if(!l)return o;let n={...o};return n.kind===void 0&&l.kind!==void 0&&(n.kind=l.kind),n.width===void 0&&l.width!==void 0&&(n.width=l.width),n});return{...r,cols:d}};function Z(r,t,{dom:i=document}={}){let d=m(r);if(t.some(s=>d[s]?.t==="opaque_block"))return p("opaque","This area holds a block this editor cannot rewrite.");let o=I(A(d),i),l=new Set(t),n=o.filter(s=>l.has(s.id));if(n.length!==t.length)return p("not-found","Some of these blocks are no longer in the document.");let h=new Map,a=new Map,g=n.map(s=>{let w=d[s.id]?.t??s.t;return U.has(w)?(h.set(s.id,s),a.set(s.id,w),{id:s.id,t:"divider",parent:s.parent}):s});if(n.every(s=>h.has(s.id)))return p("no-text","This area holds nothing that can be rewritten.");let b=i.createElement("template");b.innerHTML=O(g,{clean:L(i)});for(let s of b.content.querySelectorAll("hr[data-id]")){let w=s.getAttribute("data-id");h.has(w)&&s.setAttribute("data-clay-keep",a.get(w))}let f=o.indexOf(n[0]),y=o.indexOf(n[n.length-1]);return y-f+1!==n.length?p("not-found","These blocks are not next to each other."):{status:"ok",capture:{ids:n.map(s=>s.id),blocks:d,baseItems:o,before:o.slice(0,f),span:n,after:o.slice(y+1),parent:n[0].parent??null,held:h,html:`<div data-clay-area>${b.innerHTML}</div>`}}}function N(r,t,i=document){let d=I(A(m(r)),i),o=new Map(d.map(a=>[a.id,a])),l=t.span.filter(a=>!o.has(a.id)||!F(a,o.get(a.id))).map(a=>a.id);if(l.length)return l;let n=d.findIndex(a=>a.id===t.ids[0]);return t.ids.every((a,g)=>d[n+g]?.id===a)?[]:[...t.ids]}function ee(r,t,i,{seed:d="",dom:o=document}={}){if(N(r.doc,t,o).length)return p("stale","These blocks changed while AI was working, so nothing was changed.");let n=o.createElement("template");n.innerHTML=i??"";let h=[...n.content.children],a=h.length===1?h[0]:null,g=a&&a.tagName==="DIV"&&(a.hasAttribute("data-clay-area")||!a.hasAttribute("data-id"))?a:null,b=o.createElement("article");b.append(...g?g.childNodes:n.content.childNodes);let f=Y(b);if(!f.length)return p("empty","AI did not write any blocks. Try again.");let y=new Set(t.ids);if(f=f.map(e=>e.id&&!y.has(e.id)?{...e,id:null}:e),f.some(e=>!(e.id&&t.held.has(e.id))&&!$.has(e.t)))return p("active","AI used formatting this editor cannot put in a document. Try again.");let s=new Map(t.span.map(e=>[e.id,e])),w=new Set(f.map(e=>e.id).filter(Boolean)),v=0,q=f.map(e=>{if(e.id){let R=t.ids.indexOf(e.id);return R>=0&&(v=R+1),e}let c=t.ids[v],D=c?s.get(c):null;return!c||w.has(c)||!D||D.t!==e.t?e:(w.add(c),v++,{...e,id:c})}).map(e=>{let c=e.id?s.get(e.id):null;return c?.t==="table"&&e.t==="table"&&Array.isArray(e.cols)&&Array.isArray(c.cols)?V(e,c):e}),k=new Set(t.baseItems.filter(e=>!s.has(e.id)).map(e=>e.id)),u=x(q,{seed:d,known:s,taken:k});for(let e=0;e<4&&u.some(c=>k.has(c.id));e++)u=x(q,{seed:K(),known:s,taken:k});if(u.some(e=>k.has(e.id)))return p("active","The new blocks from AI could not be added to the document. Try again.");u=u.map(e=>e.id&&t.held.has(e.id)?{...t.held.get(e.id)}:e),u=u.map(e=>{let c=e.id?s.get(e.id):null;return c&&c.t===e.t?G(c,e):e}),t.parent!==null&&(u=u.map(e=>e.parent?e:{...e,parent:t.parent}));let T=E(t.blocks,[...t.before,...u,...t.after],t.baseItems);if(!T)return p("no-change","AI did not change anything.");let C=M(r,T);if(!C)return p("no-change","AI did not change anything.");let _=new Map;return C.doc.forEach(e=>_.set(e.attrs.id,e)),{status:"ready",plan:T,reply:u,nodes:u.map(e=>_.get(e.id)).filter(Boolean)}}function te(r,t,i,d=document){let o=N(r.doc,t,d);if(o.length)return{status:"stale",ids:o};let l=A(m(r.doc)),n=I(l,d),h=n.findIndex(f=>f.id===t.ids[0]);if(h<0)return{status:"stale",ids:[...t.ids]};let a=h+t.ids.length-1,g=E(l,[...n.slice(0,h),...i.reply,...n.slice(a+1)],n);if(!g)return{status:"stale",ids:[]};let b=M(r,g);return b?{status:"ok",tr:B(b)}:{status:"stale",ids:[]}}export{Q as AREA_GUIDE,Z as captureArea,te as keepAreaTransaction,ee as proposeArea,N as staleIds};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A,b as a,c as n}from"./c-QCDVDZIR.js";import{a as c}from"./c-VKEDWYDF.js";import{f as i}from"./c-C7SUMNMI.js";import{b as l,r as d}from"./c-UW6MMZ4V.js";var m="[editmode\\:onclick]";function b(){d(o=>{o.querySelectorAll(m).forEach(e=>{let t=e.getAttribute("onclick");t!==null&&(e.setAttribute("inert-onclick",t),e.removeAttribute("onclick"),n(e,l(e)??e))})},{required:!0})}function p(){i&&c(()=>{E()})}function E(o=document){o.querySelectorAll(m).forEach(e=>{let t=e.getAttribute("inert-onclick");t&&(e.setAttribute("onclick",t),e.removeAttribute("inert-onclick"))})}function C(){document.querySelectorAll(m).forEach(o=>{let e=o.getAttribute("onclick");e&&(o.setAttribute("inert-onclick",e),o.removeAttribute("onclick")),n(o)})}function D(){b(),p()}var O="[viewmode\\:disabled]",S="[viewmode\\:readonly]",f=[[O,"disabled"],[S,"readonly"]];function k(){d(o=>{for(let[e,t]of f)o.querySelectorAll(e).forEach(r=>{if(r.hasAttribute(t))return;let u=l(r),s=u?a(u,t):null;r.setAttribute(t,s===null?"":s),n(r,u??r)})},{required:!0})}function h(){i&&c(()=>{x()})}function x(o=document){for(let[e,t]of f)o.querySelectorAll(e).forEach(r=>{A(r),r.removeAttribute(t)})}function M(){for(let[o,e]of f)document.querySelectorAll(o).forEach(t=>{let r=a(t,e);r===null?t.removeAttribute(e):t.setAttribute(e,r),n(t)})}function P(){k(),h()}export{m as a,E as b,C as c,D as d,O as e,S as f,x as g,M as h,P as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as j}from"./c-XQXZAO7N.js";import{e as Y}from"./c-S7LK4KUE.js";import{c as $}from"./c-MOP5KBWZ.js";import{b as D,i as I,o as F}from"./c-HA6INT6J.js";import{c as L,h as w,j as A,k as _,n as C,o as z}from"./c-ICMAOOGK.js";var U=[],W=[],T=new WeakMap,g=null,B=null,M=0;function Se(){return M}function Z(e){return T.get(e)||null}var O=new WeakMap,h=null;function Ce(){return h}function xe(e){h&&e&&(h.artifact=e)}var R=null,x=new Map;function we(e){R=e}function Ae(e){return e==null?null:x.get(e)??null}function Te(e){return e&&O.get(e)||null}function ee(e){e&&(O.delete(e),x.delete(e.captureId))}function te(e){let t=r=>{if(r.hasAttribute("onbeforesave")||r.hasAttribute("onbeforesnapshot"))return!0;let n=r.localName==="template"&&r.content?r.content:r;for(let o of n.children)if(t(o))return!0;return!1};return e.nodeType===1?t(e):!1}function u(e){for(let t of e.querySelectorAll(z))t.remove()}function m(e,t){for(let r of e.querySelectorAll(`[${t}]`))if(u(e),!(r!==e&&!e.contains(r)))try{new Function(r.getAttribute(t)).call(r)}catch(n){console.error(`[${t}] handler failed:`,n)}}var K=new WeakSet,k=new WeakSet;function re(e,t,r){if(k.has(t)||typeof r?.code=="string")throw r;K.has(t)||(K.add(t),console.error(`clayjs: a ${e} callback threw; the save goes on without it`,r))}function V(e,t,r,n){let o=typeof MutationObserver=="function"?new MutationObserver(()=>{}):null;o?.observe(r,{subtree:!0,childList:!0,attributes:!0,characterData:!0});try{n()}catch(c){if(!o||o.takeRecords().length>0)throw c;re(e,t,c)}finally{o?.disconnect()}}function i(e){for(let t of W)u(e),V("addDocumentTransform",t,e,()=>t(e))}var H=null;function ge(e){H=e}function Re(e){return H?.(e),e}function be(e,{required:t=!1}={}){U.push(e),t&&k.add(e)}function Ee(e,{steps:t=null}={}){g=e,B=t}var G="http://www.w3.org/1999/xhtml";function P(e){let t=X(e);if(!t.length)return"<!DOCTYPE html>"+e.outerHTML;let r=J(t),n;try{n="<!DOCTYPE html>"+e.outerHTML}finally{for(let[o,c]of t)o.replaceChildren(...c)}for(let[o,c]of r)n=n.split(o).join(c);return n}function X(e){let t=[],r=n=>{for(let o of n.childNodes)if(o.nodeType===1){if(o.localName==="noscript"&&o.namespaceURI===G){let c=Array.from(o.childNodes);c.length&&c.every(a=>a.nodeType===3)&&t.push([o,c]);continue}r(o.localName==="template"&&o.content?o.content:o)}};return r(e),t}function _e(e){let t=[],r=n=>{for(let o of n.childNodes)if(o.nodeType===1){if(o.localName==="noscript"&&o.namespaceURI===G){o.firstChild&&t.push(o);continue}r(o.localName==="template"&&o.content?o.content:o)}};r(e.documentElement??e);for(let n of t)n.replaceChildren(n.ownerDocument.createTextNode(n.innerHTML));return e}function J(e){let t=Math.random().toString(36).slice(2);return e.map(([r,n],o)=>{let c=`\uE000clay-noscript-${t}-${o}\uE000`;return r.replaceChildren(r.ownerDocument.createTextNode(c)),[c,n.map(a=>a.data).join("")]})}function Q(e,t){let r=h;h=e;try{return t()}finally{h=r}}function N(e,t=null){if(t&&R){let n=null;try{n=R(e)}catch{}n&&x.set(t.captureId,n)}let r=P(e);if(!g)return r;try{return Q(t,()=>g(e,r))}catch(n){return console.error("clayjs: save renderer failed, sending the full serialization",n),r}}function Me(e,{required:t=!1}={}){W.push(e),t&&k.add(e)}function d(e,t=!0){let r=window.__preventOnclone;window.__preventOnclone=!0;try{return e.cloneNode(t)}finally{window.__preventOnclone=r}}function b(e,t){let r=T.get(e);r&&T.set(t,r);let n=e.children,o=t.children;for(let c=0;c<n.length;c++)b(n[c],o[c])}function f({flushUndo:e=!0,authored:t=!0,forSave:r=!1,requestRefresh:n=!1,context:o=null}={}){e&&typeof window<"u"&&window.clay?.undo?.flush&&window.clay.undo.flush();let a=j(document.documentElement,{capability:"snapshot",provenance:T}).root;for(let s of U)u(a),V("onSnapshot",s,a,()=>s(a,{original:Z,forSave:r,requestRefresh:n}));return Y(a),H?.(a),u(a),o&&(o.authoredHandlers=te(a)),t&&m(a,"onbeforesnapshot"),u(a),L(a),F(a),D(a),a}function E(e,{authored:t=!0}={}){u(e),t&&m(e,"onbeforesave"),i(e),u(e);for(let r of e.querySelectorAll(w))r.remove();return q(e),e}function q(e){for(let t of e.querySelectorAll("[sap-error]"))t.removeAttribute("sap-error")}function oe({flushUndo:e=!0,authored:t=!0}={}){return E(f({flushUndo:e,authored:t}),{authored:t})}var ne=["style","class"];function ce(e){$(e);for(let t of ne){e.getAttribute(t)===""&&e.removeAttribute(t);for(let r of e.querySelectorAll(`[${t}=""]`))r.removeAttribute(t)}}function y(e){return ce(e),"<!DOCTYPE html>"+e.outerHTML}function Oe({flushUndo:e=!0}={}){let t=f({flushUndo:e});m(t,"onbeforesave");for(let r of t.querySelectorAll(A))r.remove();return i(t),u(t),y(t)}function ke({flushUndo:e=!0}={}){let t=f({flushUndo:e});m(t,"onbeforesave");for(let r of t.querySelectorAll(C))r.remove();return i(t),u(t),y(t)}function He({flushUndo:e=!0}={}){let t=f({flushUndo:e});m(t,"onbeforesave");let r=t.querySelector(_)?d(t):null;r&&b(t,r);for(let c of t.querySelectorAll(A))c.remove();i(t),u(t);let n=y(t),o=n;if(r){for(let c of r.querySelectorAll(C))c.remove();i(r),u(r),o=y(r)}return{forComparison:n,forDirty:o}}function ae({emitForSync:e=!0,flushUndo:t=!0,requestRefresh:r=!1,forRequest:n=!1,pageFormatMarker:o=null,sliced:c=!1}={}){if(!Number.isSafeInteger(M+1))throw new Error("Save capture identity exhausted");let a=++M,s=n?{captureId:a,authoredHandlers:!1,artifact:null}:null,l=f({flushUndo:t,forSave:e,requestRefresh:r,context:s});e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:l,forSave:!0,captureId:a,sliced:c}})),m(l,"onbeforesave");let v=d(l);b(l,v);let p=l.querySelector(_)?d(l):null;p&&b(l,p),i(l),u(l);for(let S of l.querySelectorAll(w))S.remove();q(l);for(let S of v.querySelectorAll(A))S.remove();if(i(v),u(v),p){for(let S of p.querySelectorAll(C))S.remove();i(p),u(p)}return{captureId:a,context:s,pageFormatMarker:o,clone:l,compareClone:v,dirtyClone:p,renderer:g,rendererSteps:B,pageStateReader:R,result:null}}function le(e){if(!e.context||!e.pageStateReader)return;let t=null;try{t=e.pageStateReader(e.clone)}catch{}t&&x.set(e.captureId,t)}function ue(e,{forSave:t,forComparison:r,forDirty:n}){let o={forSave:t,forComparison:r,forDirty:n,captureId:e.captureId};return e.context&&e.context.artifact&&O.set(o,e.context.artifact),e.result=o,o}function se(e){ee(e.result),x.delete(e.captureId),e.context&&(e.context.artifact=null),e.clone=e.compareClone=e.dirtyClone=null,e.result=null}function Pe(e={}){let t=ae(e);try{le(t);let r=P(t.clone),n=t.compareClone?y(t.compareClone):null,o=t.dirtyClone?y(t.dirtyClone):n,c=t.renderer?Q(t.context,()=>t.renderer(t.clone,r)):r;return ue(t,{forSave:c,forComparison:n,forDirty:o})}catch(r){throw se(t),r}}function Ne(){let e=f({flushUndo:!1});m(e,"onbeforesave");let t=d(e),r=new WeakMap;(function n(o,c){r.set(o,c);let a=o.children,s=c.children;for(let l=0;l<a.length;l++)n(a[l],s[l])})(t,e),i(e),u(e);for(let n of e.querySelectorAll(w))n.remove();q(e);for(let n of t.querySelectorAll(C))n.remove();return i(t),u(t),{saveClone:e,compareClone:t,pairMap:r}}function ie({emitForSync:e=!0}={}){let t=f();return e&&document.dispatchEvent(new CustomEvent("clay:snapshot-ready",{detail:{documentElement:t}})),N(E(t))}function qe(e){let t=d(e,!1);for(let s of I)t.removeAttribute(s);let r=t.outerHTML,n=`</${t.localName}>`,o=X(e),c=o.length?J(o):[],a;try{a=e.innerHTML}finally{for(let[s,l]of o)s.replaceChildren(...l)}for(let[s,l]of c)a=a.split(s).join(l);return"<!DOCTYPE html>"+r.slice(0,r.length-n.length)+a+n}function De(e){return d(e)}function Ie(){return f().querySelector("body").innerHTML}function Fe({transform:e=null,flushUndo:t=!0}={}){if(!e&&t)return ie({emitForSync:!1});let r=f({flushUndo:t});if(e){let n=e(r);if(n&&typeof n.then=="function")throw new TypeError("getHTML: the transform must be synchronous")}return N(E(r))}function Le(e,{prepared:t=!1}={}){let r=d(e);return P(t?r:E(r,{authored:!1}))}function ze(){return N(oe({flushUndo:!1,authored:!1}))}export{Se as a,Z as b,Ce as c,xe as d,we as e,Ae as f,Te as g,ee as h,ge as i,Re as j,be as k,Ee as l,P as m,X as n,_e as o,J as p,Q as q,Me as r,d as s,f as t,oe as u,ce as v,y as w,Oe as x,ke as y,He as z,ae as A,le as B,ue as C,se as D,Pe as E,Ne as F,ie as G,qe as H,De as I,Ie as J,Fe as K,Le as L,ze as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./c-Y6HH7LTM.js";import"./c-VHNSBD2M.js";export{c as applyData,d as default,a as engine,b as extractData};
|