@panphora/clayjs 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +7917 -5621
- package/dist/m/attrs/refetch-on-save-ZUE7PSCI.js +1 -0
- package/dist/m/attrs/save-freeze-MYNVXREN.js +1 -0
- package/dist/m/c-2YYDMLNZ.js +1 -0
- package/dist/m/c-336SGU5W.js +1 -0
- package/dist/m/c-3H6BZDNJ.js +6 -0
- package/dist/m/{c-LR4CGEPT.js → c-3RUU4TPX.js} +1 -1
- package/dist/m/c-3XIRD4NU.js +1 -0
- package/dist/m/c-4DFEJ2PO.js +3 -0
- package/dist/m/c-56QRZTZH.js +1 -0
- package/dist/m/c-5J4E7O4Y.js +4 -0
- package/dist/m/c-5LKDWQTL.js +19 -0
- package/dist/m/c-5QWQ7A5L.js +1 -0
- package/dist/m/c-5RJFTLSF.js +1 -0
- package/dist/m/c-6AZOGAPE.js +1 -0
- package/dist/m/{c-Y6USGTS5.js → c-6CRUUXOX.js} +5 -5
- package/dist/m/{c-54RCDCBU.js → c-6KEVEQ7L.js} +1 -1
- package/dist/m/{c-LTGMXXKO.js → c-6NC5I2TV.js} +1 -1
- package/dist/m/{c-YDH7Q3NY.js → c-74MGYWZF.js} +1 -1
- package/dist/m/{c-Z36J63PP.js → c-7OLLJPWP.js} +1 -1
- package/dist/m/c-A3E3NIMC.js +1 -0
- package/dist/m/{c-5R4PTRG2.js → c-AMSNPOCX.js} +1 -1
- package/dist/m/c-B3JM5ZXC.js +1 -0
- package/dist/m/c-BPF2NSPV.js +1 -0
- package/dist/m/c-BQ6LOBEE.js +1 -0
- package/dist/m/c-CJ3A7ZKE.js +1 -0
- package/dist/m/c-CQHPGKX2.js +1 -0
- package/dist/m/c-DCXOXBF3.js +1 -0
- package/dist/m/c-DFS4XZJV.js +2 -0
- package/dist/m/{c-F3CKJTJS.js → c-DNENWY4O.js} +1 -1
- package/dist/m/c-E4LIR5X5.js +1 -0
- package/dist/m/c-EVCQ3BKA.js +1 -0
- package/dist/m/{c-5Y6TNX5W.js → c-EZU56NQV.js} +2 -2
- package/dist/m/c-FDNHHZY5.js +1 -0
- package/dist/m/{c-SWRJFCNN.js → c-FRLHSY7E.js} +1 -1
- package/dist/m/c-FROJUZMV.js +1 -0
- package/dist/m/c-G2JPKCTP.js +1 -0
- package/dist/m/c-GB6TU7WV.js +1 -0
- package/dist/m/{c-GB3JTV6E.js → c-GFJJEBTU.js} +1 -1
- package/dist/m/{c-J7CA54IP.js → c-GSFIGKOP.js} +1 -1
- package/dist/m/{c-OYTFP5QN.js → c-GY422N3Q.js} +1 -1
- package/dist/m/c-HAWFNBYG.js +1 -0
- package/dist/m/{c-33HUYEDI.js → c-HDDEEL77.js} +1 -1
- package/dist/m/c-HFKUVACH.js +1 -0
- package/dist/m/c-HHDFCNHV.js +1 -0
- package/dist/m/c-I2ZATQCD.js +2 -0
- package/dist/m/c-IEM4NTCS.js +1 -0
- package/dist/m/c-IW6GGOU2.js +1 -0
- package/dist/m/{c-SGCCC4FW.js → c-JDCX26UP.js} +2 -2
- package/dist/m/c-JRKY44DK.js +1 -0
- package/dist/m/c-JU3NK25H.js +1 -0
- package/dist/m/{c-VFX45IZQ.js → c-KAU6E43D.js} +1 -1
- package/dist/m/c-KBS3UV6B.js +1 -0
- package/dist/m/c-KGVGROZT.js +1 -0
- package/dist/m/{c-YG2NJYS6.js → c-KQ6TYJAP.js} +2 -2
- package/dist/m/{c-2JL6E75N.js → c-KU3ZFADW.js} +1 -1
- package/dist/m/c-LWLBHLVC.js +3 -0
- package/dist/m/c-M2L47S2X.js +7 -0
- package/dist/m/c-MFP2ZWD4.js +1 -0
- package/dist/m/{c-4YSCRICO.js → c-MKSQ4Y57.js} +1 -1
- package/dist/m/{c-2M73252O.js → c-NUFFJVVJ.js} +1 -1
- package/dist/m/c-NUHSPT5P.js +1 -0
- package/dist/m/c-O72HVYSA.js +1 -0
- package/dist/m/c-OW5QIGG3.js +1 -0
- package/dist/m/c-PGRCK73F.js +1 -0
- package/dist/m/{c-4DRMS4QG.js → c-PS5ARVWR.js} +1 -1
- package/dist/m/c-Q622NS2Y.js +1 -0
- package/dist/m/c-Q7NQD65V.js +1 -0
- package/dist/m/c-QH63LQOS.js +1 -0
- package/dist/m/{c-TQZ2JYHD.js → c-QICP2YR5.js} +1 -1
- package/dist/m/{c-7VGZ7RU5.js → c-QJ4OM3G6.js} +1 -1
- package/dist/m/{c-MMUIUUZG.js → c-R3L7ZJGB.js} +1 -1
- package/dist/m/c-R7IWVINQ.js +1 -0
- package/dist/m/{c-HVYXIS72.js → c-RSMOODDU.js} +1 -1
- package/dist/m/{c-KKWLDOPM.js → c-RYUXUUBX.js} +1 -1
- package/dist/m/c-S4ZEH46B.js +9 -0
- package/dist/m/c-SDAXDM2D.js +1 -0
- package/dist/m/c-SMBZG5X4.js +1 -0
- package/dist/m/{c-UXBMRDZB.js → c-SMGU7RT3.js} +1 -1
- package/dist/m/c-SPIORRYS.js +1 -0
- package/dist/m/c-SWLRT66R.js +1 -0
- package/dist/m/c-SZGYW5HT.js +1 -0
- package/dist/m/c-TCJTVAFN.js +1 -0
- package/dist/m/{c-HRDCD3WN.js → c-TJ6WOJL3.js} +1 -1
- package/dist/m/c-TYLXX4NF.js +21 -0
- package/dist/m/c-U62OB4BT.js +1 -0
- package/dist/m/{c-NMJRXKPC.js → c-U6YWUAR3.js} +1 -1
- package/dist/m/c-UDCSU5G5.js +2 -0
- package/dist/m/{c-NZMNXVF6.js → c-UDUUJPFZ.js} +1 -1
- package/dist/m/c-VE6ZMYMC.js +1 -0
- package/dist/m/c-VG5XIN4T.js +1 -0
- package/dist/m/c-VHM5XQHK.js +1 -0
- package/dist/m/c-VI5RMSVY.js +1 -0
- package/dist/m/c-VRZN56XY.js +1 -0
- package/dist/m/c-W5MCHEGA.js +1 -0
- package/dist/m/c-WDC5GVKU.js +1 -0
- package/dist/m/c-WWXIDH4O.js +28 -0
- package/dist/m/{c-QIX5BJYN.js → c-XCNTK76U.js} +1 -1
- package/dist/m/c-XMS6DPBR.js +1 -0
- package/dist/m/c-Y5HBBIQ4.js +1 -0
- package/dist/m/{c-5M4YEKCX.js → c-ZVPVXTJF.js} +1 -1
- package/dist/m/c-ZVRKXKM7.js +1 -0
- package/dist/m/{c-HT33EQRN.js → c-ZWIOJGMT.js} +1 -1
- package/dist/m/core/admin-attrs-QHOKPJ7W.js +1 -0
- package/dist/m/core/autosave-HRYGUWV6.js +1 -0
- package/dist/m/core/conflict-notice-6MROJN2L.js +1 -0
- package/dist/m/core/host-permission-FNXVEFNE.js +1 -0
- package/dist/m/core/is-edit-mode-KTWA3O5N.js +1 -0
- package/dist/m/core/{persist-HKHA66IY.js → persist-JFYRHMRJ.js} +1 -1
- package/dist/m/core/recovery-FLTCC2OC.js +1 -0
- package/dist/m/core/save-HQZ4S667.js +1 -0
- package/dist/m/core/save-core-KGQWFUNH.js +1 -0
- package/dist/m/core/snapshot-EGQZNT45.js +1 -0
- package/dist/m/core/unsaved-warning-IDJLD66H.js +1 -0
- package/dist/m/events/index-RN2JNGBV.js +1 -0
- package/dist/m/internals/index-PVXGPUDA.js +1 -0
- package/dist/m/lib/cache-bust-MUMFXZK6.js +1 -0
- package/dist/m/loader-S4I7GKXR.js +1 -0
- package/dist/m/manifest-4C419D67.js +1 -0
- package/dist/m/manifest-edit-B077F288.js +1 -0
- package/dist/m/manifest.json +1555 -1058
- package/dist/m/options/options-EJMS3K24.js +1 -0
- package/dist/m/page/{editor-XUTB2HB2.js → editor-NNJA4OKD.js} +21 -8
- package/dist/m/plugins/{ai-edit-ZQ4CGWIP.js → ai-edit-QN4PMMNL.js} +1 -1
- package/dist/m/plugins/demo-RM5IR6AO.js +1 -0
- package/dist/m/plugins/indicator-URDBBOQO.js +1 -0
- package/dist/m/plugins/live-HFWD4OIH.js +1 -0
- package/dist/m/plugins/{menu-HCKO3DSP.js → menu-3HIEQSI6.js} +2 -2
- package/dist/m/plugins/page-JOKB6XPR.js +2 -0
- package/dist/m/plugins/page-view-NXOJHNW6.js +1 -0
- package/dist/m/plugins/people-SGPJKANK.js +1 -0
- package/dist/m/plugins/{richclay-RC3L2F6X.js → richclay-NRQDSWX6.js} +2 -2
- package/dist/m/plugins/sortable-GWT4PWDV.js +1 -0
- package/dist/m/plugins/source-4ZRSAIYM.js +1 -0
- package/dist/m/plugins/undo-VDA5P7FH.js +1 -0
- package/dist/m/plugins/{upgrade-ZNYODP5Y.js → upgrade-W7FG5VFG.js} +1 -1
- package/dist/m/plugins/upload-WLYKK6TL.js +1 -0
- package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +21 -0
- package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +1 -0
- package/dist/m/plugins/wire-4N6GYAF6.js +1 -0
- package/dist/m/{reader-core-ILWLXVMP.js → reader-core-DXYCURFF.js} +2 -2
- package/dist/m/sync/live-sync-J7VMYTKS.js +1 -0
- package/dist/m/ui/{index-EVHKMKBL.js → index-3JLVI27O.js} +1 -1
- package/dist/offline-manifest.json +857 -623
- package/dist/page/themes/light-1.css +25 -1
- package/dist/server/core.cjs +115 -24
- package/package.json +1 -1
- package/src/core/boot-phase.js +2 -1
- package/src/core/conflict-download.js +3 -29
- package/src/core/download.js +32 -0
- package/src/core/host-meta.js +18 -0
- package/src/core/save-core.js +8 -4
- package/src/core/save.js +4 -4
- package/src/core/snapshot.js +39 -1
- package/src/lib/autosave-scheduler.js +3 -4
- package/src/page/blocks.js +34 -1
- package/src/page/board-views.js +2 -16
- package/src/page/chart-tables.js +11 -0
- package/src/page/chart.js +6 -10
- package/src/page/checkpoint-proof.js +289 -0
- package/src/page/chrome.js +24 -6
- package/src/page/document-title-dom.js +12 -0
- package/src/page/document-title-runtime.js +15 -1
- package/src/page/document-title.js +4 -1
- package/src/page/editor.js +77 -12
- package/src/page/emoji-data.js +162 -0
- package/src/page/features/board.js +12 -3
- package/src/page/features/chart.js +11 -0
- package/src/page/features/dates.js +180 -0
- package/src/page/features/emoji.js +187 -0
- package/src/page/features/mentions.js +188 -0
- package/src/page/features/registry.js +6 -1
- package/src/page/features/table.js +2 -2
- package/src/page/format-command.js +9 -0
- package/src/page/format-host.js +54 -0
- package/src/page/format-native-commands.js +142 -0
- package/src/page/format-native.js +42 -0
- package/src/page/inline.js +32 -8
- package/src/page/items.js +15 -3
- package/src/page/markdown.js +26 -2
- package/src/page/mention-picker.js +99 -0
- package/src/page/merge.js +1 -1
- package/src/page/projection.js +58 -15
- package/src/page/save-projection.js +39 -0
- package/src/page/save-states.js +1 -1
- package/src/page/schema.js +33 -0
- package/src/page/themes/content.css +25 -1
- package/src/page/themes/light-1.css +25 -1
- package/src/page/view-hooks.js +32 -0
- package/src/page/ybind/binding.js +31 -4
- package/src/page/ybind/marks.js +2 -1
- package/src/page/ybind/provider.js +13 -2
- package/src/page/ybind/recovery-replay.js +362 -4
- package/src/plugins/live.js +37 -1
- package/src/plugins/page.js +117 -3
- package/src/plugins/visitor-drafts/intro.js +2 -1
- package/src/server/checkpoint/index.js +2 -2
- package/src/sync/saved-stream.js +17 -8
- package/dist/m/attrs/refetch-on-save-NWPPXOCZ.js +0 -1
- package/dist/m/attrs/save-freeze-FUP4Q4X3.js +0 -1
- package/dist/m/c-35NBGMZB.js +0 -1
- package/dist/m/c-3IQRECYS.js +0 -1
- package/dist/m/c-4B6H4G5V.js +0 -1
- package/dist/m/c-4FFHZM32.js +0 -1
- package/dist/m/c-66O32MV3.js +0 -28
- package/dist/m/c-7O6AFR65.js +0 -1
- package/dist/m/c-ANQTJ3B5.js +0 -2
- package/dist/m/c-AYVOREBE.js +0 -1
- package/dist/m/c-B2ZXPOS3.js +0 -3
- package/dist/m/c-BMIZKMPV.js +0 -1
- package/dist/m/c-CJZSLMVQ.js +0 -1
- package/dist/m/c-DBE6ORSI.js +0 -1
- package/dist/m/c-EDHUR4MX.js +0 -1
- package/dist/m/c-EY6UOM54.js +0 -1
- package/dist/m/c-F7Y6FLPY.js +0 -1
- package/dist/m/c-FA4DZVTC.js +0 -1
- package/dist/m/c-G2BUZITR.js +0 -1
- package/dist/m/c-GBGWXTX4.js +0 -1
- package/dist/m/c-GHBCCVG4.js +0 -1
- package/dist/m/c-IB52R237.js +0 -1
- package/dist/m/c-IKWNE4R4.js +0 -1
- package/dist/m/c-IU3IYEU6.js +0 -1
- package/dist/m/c-IZ2EBRAJ.js +0 -1
- package/dist/m/c-KR4UW4KW.js +0 -1
- package/dist/m/c-KY3VJGUA.js +0 -8
- package/dist/m/c-LXENEBV7.js +0 -1
- package/dist/m/c-PPOSCAQD.js +0 -1
- package/dist/m/c-QQHEX6HA.js +0 -1
- package/dist/m/c-R7RMANJI.js +0 -9
- package/dist/m/c-RI4NT75Y.js +0 -1
- package/dist/m/c-RUJKSUQW.js +0 -1
- package/dist/m/c-T4VO4OCB.js +0 -1
- package/dist/m/c-TR6RMDQ7.js +0 -3
- package/dist/m/c-UKHTLWUW.js +0 -1
- package/dist/m/c-UNN7LWCT.js +0 -1
- package/dist/m/c-V7PZZRG7.js +0 -1
- package/dist/m/c-VL52ADDR.js +0 -1
- package/dist/m/c-WWDBYXLK.js +0 -1
- package/dist/m/c-XNNW2CWK.js +0 -1
- package/dist/m/c-Z4VRC7GU.js +0 -7
- package/dist/m/c-Z6K52OLP.js +0 -19
- package/dist/m/c-ZDY2MDAA.js +0 -21
- package/dist/m/core/admin-attrs-VGNLAUDK.js +0 -1
- package/dist/m/core/autosave-E4PEFPZ6.js +0 -1
- package/dist/m/core/conflict-notice-VQ6Y64PH.js +0 -1
- package/dist/m/core/host-permission-XN3K2IW3.js +0 -1
- package/dist/m/core/is-edit-mode-JXHDVGUL.js +0 -1
- package/dist/m/core/recovery-TBBSICE2.js +0 -1
- package/dist/m/core/save-WUCHTQBE.js +0 -1
- package/dist/m/core/save-core-FJVHT5M3.js +0 -1
- package/dist/m/core/snapshot-F3SWDZMM.js +0 -1
- package/dist/m/core/unsaved-warning-STKBHE6G.js +0 -1
- package/dist/m/events/index-23DPTUT4.js +0 -1
- package/dist/m/internals/index-WOVAP3RU.js +0 -1
- package/dist/m/lib/cache-bust-CGWT6ZJI.js +0 -1
- package/dist/m/loader-HXX6YNH5.js +0 -1
- package/dist/m/manifest-F22DEDAC.js +0 -1
- package/dist/m/manifest-edit-C3C7376B.js +0 -1
- package/dist/m/options/options-2LH76JQ3.js +0 -1
- package/dist/m/plugins/demo-ZIBFAA3R.js +0 -1
- package/dist/m/plugins/indicator-PV4YW2ID.js +0 -1
- package/dist/m/plugins/live-NUTTXSBS.js +0 -1
- package/dist/m/plugins/page-KSUH7G6J.js +0 -2
- package/dist/m/plugins/page-view-W73OW7WI.js +0 -1
- package/dist/m/plugins/people-AJJ32YCG.js +0 -1
- package/dist/m/plugins/sortable-YRMQX3ZU.js +0 -1
- package/dist/m/plugins/source-KHK5UUSK.js +0 -1
- package/dist/m/plugins/undo-OF2L3CXU.js +0 -1
- package/dist/m/plugins/upload-XSGNILUY.js +0 -1
- package/dist/m/plugins/visitor-drafts-XK5GW55Q.js +0 -21
- package/dist/m/plugins/visitor-drafts-owner-KSSH75EV.js +0 -1
- package/dist/m/plugins/wire-ZWVWKF76.js +0 -1
- package/dist/m/sync/live-sync-4AUVXVJU.js +0 -1
- /package/dist/m/plugins/{richclay-RC3L2F6X.js.LEGAL.txt → richclay-NRQDSWX6.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"../c-ZWIOJGMT.js";import"../c-IJUK2GPW.js";import{a as o,b as i,c as u,d as s}from"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-DCFSEJZG.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function m(e){if(e.parentNode){r.pause();try{e.remove()}finally{r.resume()}}}function p(e){let a=o(e);if(!a||s(e))return;let t=new URL(e.getAttribute(a),location.href);t.searchParams.set("v",Date.now());let f=t.origin===location.origin?t.pathname+t.search:t.href;r.pause();try{let n=document.createElement(e.tagName);for(let{name:d,value:l}of e.attributes)n.setAttribute(d,l);i(n,a,f),u(e),e.insertAdjacentElement("afterend",n),n.onload=()=>m(e),setTimeout(()=>m(e),2e3)}finally{r.resume()}}function c(){document.addEventListener("clay:save-saved",()=>{document.querySelectorAll("[refetch-on-save]").forEach(p)})}c();var g=c;export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../c-6NC5I2TV.js";import"../c-XCNTK76U.js";import"../c-ZWIOJGMT.js";import"../c-IJUK2GPW.js";import"../c-SPIORRYS.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-DCFSEJZG.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={holdSettle:!1,servedHash:typeof window>"u"?"":window.location.hash};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as X,B as W,d as S,f as M,g as I,i as O,k as D,l as H,m as b,n as C,o as N,p as $,r as F}from"./c-5J4E7O4Y.js";import{b as R,m as A}from"./c-WWXIDH4O.js";var P=new WeakMap,st=new WeakMap;function rt(s,t){let e=P.get(s)??new Set;return P.set(s,e),e.add(t),()=>e.delete(t)}function at(){return new R.Plugin({view:s=>({update:t=>{for(let e of P.get(t)??[])e.update?.(t)},destroy:()=>{let t=P.get(s);if(t){for(let e of t)e.destroy?.(s);t.clear()}}})})}var Y=new WeakMap;function v(s){let t=Y.get(s);return t||Y.set(s,t=I(s)),t}var _=A.nodes,y=s=>s.type===_.list_item,L=s=>s.type===_.toggle,w=s=>s.attrs.parent??null;function Q(s,t,e){if(e<0)return[null];let n=[],o=s[e].node;L(o)&&o.attrs.open&&!s[e].hidden&&n.unshift(o.attrs.id);for(let r=w(o);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=w(c.node)}let i=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;i.push(r)}return i}function K(s,t,e,n){let o=w(s[t].node),i=y(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||w(r.node)!==o?null:y(r.node)?{parent:n.parent,indent:r.node.attrs.indent+i}:{parent:n.parent}}function Z(s,t){let e=null;s.doc.forEach((n,o)=>{n.attrs.id===t&&L(n)&&(e={n,off:o})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function T(s,t,e,n,o,i=null){let r=K(t,e,n,o),c=t[e].at,d=t[n].end,p=i??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(o.at===c||o.at===d){a=s.tr;for(let l=e;l<=n;l++){let h=r(t[l]);h&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...h})}a.setSelection(p.map(a.doc,a.mapping)),a.setMeta(M,N(t,e,n,o.at,r))}else a=$(s,t,e,n,o.at,r,p);if(o.open){Z(a,o.open);let l=a.getMeta(M);l&&a.setMeta(M,{...l,attrs:{...l.attrs,[o.open]:{open:!0}}})}return a}function U(s,t,e,n,o){if(o.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===o.parent))return!1;let i=t[n].end-t[e].at,r=K(t,e,n,o);for(let a=e;a<=n;a++)if(y(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>F)return!1;let c=T(s,t,e,n,o),p=o.at===t[e].at||o.at===t[n].end?t[e].at:o.at>t[e].at?o.at-i:o.at;return O(c.doc,s.doc).every(a=>a.at>=p&&a.at<p+i)}function V(s,t,e,n,o){let i=new Map;t.forEach(l=>{L(l.node)&&l.node.attrs.id&&i.set(l.node.attrs.id,l.i)});let r=o<0?s.doc.content.size:t[o].at;if(r>t[e].at&&r<t[n].end)return[];let c=(o<0?t.length:o)-1,d=Q(t,i,c),p=d.indexOf(o<0?null:w(t[o].node)),a=[];for(let l of d.slice(Math.max(0,p))){let h=l===null?0:t[i.get(l)].depth+1,x=c>=0&&y(t[c].node)&&w(t[c].node)===l?t[c].node:null,f=y(t[e].node)&&x?x.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:h+(y(t[e].node)?u:0)};U(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,o){let i=t[o];if(!i||!L(i.node)||i.node.attrs.open||i.hidden||o>=e&&o<=n||i.at>t[e].at&&i.at<t[n].end)return null;let r=i.node.attrs.id,c={at:t[i.subEnd].end,parent:r,indent:0,depth:i.depth+1,open:r};return U(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var tt=4,k=56,j=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var G=new WeakMap;function nt(s,t){let e=G.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let o=t.nodeDOM(n.at);o?.getBoundingClientRect&&e.push({i:n.i,dom:o})}G.set(s,e)}return e}function ot(s,t){let e=0,n=s.length;for(;e<n;){let o=e+n>>1,i=s[o].dom.getBoundingClientRect();t<i.top+i.height/2?n=o:e=o+1}return e<s.length?e:-1}var J=class{constructor(t,e,{index:n,onClick:o}){this.view=t,this.grip=e,this.index=n,this.onClick=o,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=i=>this.move(i),this.onUp=i=>this.end(i),this.onCancel=i=>{i.pointerId===this.state?.pointer&&this.cancel()},this.onKey=i=>{i.key==="Escape"&&this.state?.active&&(i.preventDefault(),i.stopPropagation(),this.cancel())},e.addEventListener("pointerdown",i=>this.start(i))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),o=e.selection,i=Math.min(this.index(),n.length-1),r=o instanceof C&&n[i].at>=o.from&&n[i].end<=o.to,{lo:c,hi:d}=r?o.span(e.doc):D(n,i,i);this.state={index:i,span:H(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),t.preventDefault()}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,!e.active){if(Math.hypot(e.x-e.x0,e.y-e.y0)<=tt)return;if(e.touch)return this.stop();this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),o=b(n,t.span);if(!o)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(W(e.doc,o.lo,o.hi))),this.shell.classList.add("is-dragging");let i=this.shell.appendChild(document.createElement("div"));i.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=i.getBoundingClientRect().width||27,i.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let o=v(n.doc),i=b(o,t.span);if(!i)return this.cancel();let{lo:r,hi:c}=i,d=nt(o,e),p=ot(d,t.y),a=-1,l=null,h=null,x=p<0?d.length:p+1;for(let E=Math.max(0,x-2);E<x;E++){let g=d[E].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(h={i:d[E].i,bottom:g.bottom}),l=g.bottom+2}p>=0&&(a=d[p].i,l=d[p].dom.getBoundingClientRect().top-2);let f=r<0?null:h&&q(n,o,r,c,h.i),u=f?`summary:${h.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:V(n,o,r,c,a)),f&&(l=h.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let B=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-B.top}px`),this.line.style.setProperty("--page-drop-x",`${m-B.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;let n=this.scroller,o=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),i=0;e.y<o.top+k?i=-j*Math.min(1,(o.top+k-e.y)/k):e.y>o.bottom-k&&(i=j*Math.min(1,(e.y-(o.bottom-k))/k)),i&&(n.scrollTop+=i,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),h=b(l,e.span);h&&this.onClick(h.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,o=this.view.state,i=v(o.doc),r=b(i,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===i[c].at||n.at===i[d].end)&&n.parent===(i[c].node.attrs.parent??null)&&(i[c].node.type.name!=="list_item"||n.indent===i[c].node.attrs.indent))return;this.view.dispatch(X(T(o,i,c,d,n)).scrollIntoView());let a=d-c+1;S(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),S(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,J as c,st as d,rt as e,at as f};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{E as pt,J as Q,M as Ee,q as Me,u as Se,v as dt,w as Te}from"./c-4DFEJ2PO.js";import{A as ut,D as xe,E as we,x as ke}from"./c-6CRUUXOX.js";import{a as ht,c as _e,d as $e}from"./c-336SGU5W.js";import{c as Oe,e as Ae,f as ft,g as ve}from"./c-6KEVEQ7L.js";import{A as k,B as Rt,C as ze,D as Pt,E as He,F as Fe,a as Ce,d as j,e as Ie,g as Z,h as Le,k as De,n as B,q as Bt,s as Be,t as Re,v as Pe,w as Ne,z as x}from"./c-5J4E7O4Y.js";import{C as lt,E as L,F as C,G as D,H as O,I as b,J as ct,K as fe,N as U,S as me,T as at,U as Dt,V as ge,W as ye,X as be,b as E,d as It,f as it,g as ae,h as Lt,j as ue,l as de,la as J,m as g,o as pe,p as he}from"./c-WWXIDH4O.js";import{a as X}from"./c-4L3BTFRK.js";var Ke=new WeakMap;function je(n){let t=Ke.get(n);if(t)return t;t={};for(let[e,o]of O(n.attrs.cols).entries()){let s=[];n.forEach(r=>{e<r.childCount&&s.push(r.child(e).textContent.trim())}),t[o]=ye(n.attrs.cols[o].kind,s)}return Ke.set(n,t),t}var us=Object.freeze({text:"Aa",number:"#",date:"\u{1F4C5}"}),ds=Object.freeze({text:"Text",number:"Number",date:"Date"});var Nt=(n,t,e)=>{let o=n.attrs.get(t.baseId),s={};for(let r of xe(e))s[r]=o&&o.has(r)?o.get(r):we(e,r);return e.name==="board"&&Object.assign(s,Se(n.boardFields,t.baseId)),e.name==="table"&&Object.assign(s,Me(n.tableFields,t.baseId,{cols:s.cols,rows:s.rows})),s},Ve=n=>n===void 0?n:JSON.parse(JSON.stringify(n)),Rn=(n,t)=>{let e={},o=n.attrs.get(t.baseId);return o&&o.forEach((s,r)=>{r!=="pos"&&(e[r]=Ve(s))}),e.t=t.t,e};function ks(n,t){let e=t.visible.map(i=>{if(i.opaque){let u=i.recovered?{...Ve(i.fields??{})}:Rn(n,i);return{b:i,type:g.nodes.opaque_block,fields:u,opaque:!0}}let l=g.nodes[i.t]??g.nodes.paragraph;return{b:i,type:l,fields:{...i.fields??Nt(n,i,l)}}}),o=new Map(e.map(i=>[i.b.id,i])),s=i=>(i.b.recovered?n.gone._map.get(pt(i.b.sourceKey,"parent")):n.attrs.get(i.b.baseId)?._map.get("parent"))?.id??{clock:-1,client:-1};for(let i of o.keys()){let l=new Map,u=[],p=i;for(;o.has(p)&&!l.has(p);)l.set(p,u.length),u.push(p),p=o.get(p).fields.parent;if(!l.has(p))continue;let c=u.slice(l.get(p)).reduce((d,h)=>{let f=s(o.get(d)),m=s(o.get(h));return f.clock<m.clock||f.clock===m.clock&&f.client<m.client?d:h});o.get(c).fields.parent=null}let r=e.map(({b:i,type:l,fields:u,opaque:p})=>{if(p){let d=[];for(let h of i.runs)h.hole||(h.br?d.push(g.nodes.hard_break.create()):d.push(g.text(h.text,h.marks)));return l.create({id:i.id,pos:null,raw:u},d)}let a={id:i.id,pos:null,...u};if(l.name==="table"&&Object.keys(a.rows??{}).length&&Object.keys(a.cols??{}).length)return U(g,i.id,{t:"table",...a});if(!l.isTextblock)return l.create(a);let c=[];for(let d of i.runs)d.hole||(d.br?c.push(g.nodes.hard_break.create()):c.push(g.text(d.text,d.marks)));return l.create(a,c)});return r.length?g.nodes.doc.create(null,r):g.nodes.doc.createAndFill()}var M=n=>({status:"refused",code:n}),mt=n=>JSON.parse(JSON.stringify(n)),Pn=["title","owner","due"],Nn=/^\d{4}-\d{2}-\d{2}$/,gt=(n,t)=>n==="title"?typeof t=="string":n==="due"?t===null||typeof t=="string"&&Nn.test(t):t===null||typeof t=="string"&&t.length>0,zn=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);function qe(n,t){let e=t>0?n[t-1]:null,o=n.slice(t).find(r=>e===null||r>e)??null,s=r=>(e===null||r>e)&&(o===null||r<o);for(let[r,i]of[[e,o],[null,o],[e,null]]){if(r!==null&&!L(r)||i!==null&&!L(i)||r!==null&&i!==null&&r>=i)continue;let l=C(r,i);if(s(l))return l}return`${n.reduce((r,i)=>i>r?i:r,"")}V`}function zt(n,t,e){let o=n.map(t),s=e>0?o[e-1]:null,r=e;for(;s!==null&&r<o.length&&o[r]===s;)r++;if(r===e)return{pos:qe(o,e),rekey:[]};let i=o.slice(r).find(u=>u>s)??null,l=[];for(let u=e,p=s;u<=r;u++)l.push(p=qe(i===null?[p]:[p,i],1));return{pos:l[0],rekey:n.slice(e,r).map((u,p)=>[u,l[p+1]])}}var yt=(n,t,e)=>{let{pos:o,rekey:s}=zt(t,r=>n[r].pos,e);for(let[r,i]of s)n[r]={...n[r],pos:i};return o};function vs({pd:n,um:t=null,origins:e=null,render:o=()=>{}}){let s=a=>{if(typeof a!="string")return null;let c=Ee(n,e).visible.find(h=>h.id===a);if(!c||c.t!=="board")return null;let d=c.fields??Nt(n,c,g.nodes.board);return{columns:mt(d.columns??{}),cards:mt(d.cards??{})}},r=(a,c,d,h)=>{let f=Q(a);return t?.stopCapturing(),n.ydoc.transact(()=>{if(!f)Te(n,a,c,d);else for(let m of["columns","cards"])J(c[m])!==J(d[m])&&n.gone.set(pt(f,m),mt(d[m]))},ke),t?.stopCapturing(),o(),h},i=(a,c,d=null)=>O(Object.fromEntries(Object.entries(a.cards).filter(([h,f])=>f.col===c&&h!==d))),l=(a,c)=>c===void 0?a.length:c===null?0:a.indexOf(c)+1,u=(a,c)=>c!=null&&!a.includes(c),p=(a,c)=>{let d=s(a);return d?c(d,mt(d)):M("missing-board")};return{read:a=>s(a),removed(a){return s(a)?Q(a)?{columns:{},cards:{}}:dt(n.boardFields,a):null},createColumn:(a,{name:c="",afterId:d}={})=>p(a,(h,f)=>{if(typeof c!="string")return M("invalid-value");let m=O(h.columns);if(u(m,d))return M("missing-destination");let y=b("c");return f.columns[y]={pos:yt(f.columns,m,l(m,d)),name:c},r(a,h,f,{status:"created",id:y})}),renameColumn:(a,c,d)=>p(a,(h,f)=>Object.hasOwn(h.columns,c)?typeof d!="string"?M("invalid-value"):h.columns[c].name===d?{status:"unchanged"}:(f.columns[c].name=d,r(a,h,f,{status:"changed"})):M("missing-column")),moveColumn:(a,c,{afterId:d=null}={})=>p(a,(h,f)=>{if(!Object.hasOwn(h.columns,c))return M("missing-column");let m=O(h.columns).filter(A=>A!==c);if(u(m,d))return M("missing-destination");let y=l(m,d),S=O(h.columns);return[...m.slice(0,y),c,...m.slice(y)].every((A,K)=>A===S[K])?{status:"unchanged"}:(f.columns[c].pos=yt(f.columns,m,y),r(a,h,f,{status:"moved"}))}),removeColumn:(a,c)=>p(a,(d,h)=>Object.hasOwn(d.columns,c)?(delete h.columns[c],r(a,d,h,{status:"removed",cards:i(d,c).length})):M("missing-column")),restoreColumn:(a,c)=>p(a,(d,h)=>{if(Object.hasOwn(d.columns,c))return{status:"unchanged"};let f=Q(a)?null:dt(n.boardFields,a).columns[c];return f?(h.columns[c]=f,r(a,d,h,{status:"restored"})):M("missing-column")}),createCard:(a,{columnId:c,title:d="",owner:h=null,due:f=null,afterId:m}={})=>p(a,(y,S)=>{if(!Object.hasOwn(y.columns,c))return M("missing-column");if(!gt("title",d)||!gt("owner",h)||!gt("due",f))return M("invalid-value");let A=i(y,c);if(u(A,m))return M("missing-destination");let K=b("k");return S.cards[K]={pos:yt(S.cards,A,l(A,m)),col:c,title:d,...h!==null?{owner:h}:{},...f!==null?{due:f}:{}},r(a,y,S,{status:"created",id:K})}),editCard:(a,c,d)=>p(a,(h,f)=>{if(!Object.hasOwn(h.cards,c))return M("missing-card");if(!zn(d)||!Object.keys(d).length||Object.keys(d).some(y=>!Pn.includes(y)))return M("invalid-field");if(Object.entries(d).some(([y,S])=>!gt(y,S)))return M("invalid-value");let m={...h.cards[c]};for(let[y,S]of Object.entries(d))S===null?delete m[y]:m[y]=S;return J(m)===J(h.cards[c])?{status:"unchanged"}:(f.cards[c]=m,r(a,h,f,{status:"changed"}))}),moveCard:(a,c,{columnId:d,afterId:h=null}={})=>p(a,(f,m)=>{if(!Object.hasOwn(f.cards,c))return M("missing-card");if(!Object.hasOwn(f.columns,d))return M("missing-column");let y=i(f,d,c);if(u(y,h))return M("missing-destination");let S=l(y,h),A=f.cards[c];if(A.col===d){let K=i(f,d);if([...y.slice(0,S),c,...y.slice(S)].every((rt,Bn)=>rt===K[Bn]))return{status:"unchanged"}}return m.cards[c]={...A,col:d,pos:yt(m.cards,y,S)},r(a,f,m,{status:"moved"})}),removeCard:(a,c)=>p(a,(d,h)=>Object.hasOwn(d.cards,c)?(delete h.cards[c],r(a,d,h,{status:"removed"})):M("missing-card")),restoreCard:(a,c)=>p(a,(d,h)=>{if(Object.hasOwn(d.cards,c))return{status:"unchanged"};let f=Q(a)?null:dt(n.boardFields,a).cards[c];return f?(h.cards[c]=f,r(a,d,h,{status:"restored"})):M("missing-card")})}}var bt="page-history-intent",Hn=500,Fn=(n,t)=>{let e=n.resolve(t);return e.depth?e.node(1).attrs.id:null},Kn=n=>(n.storedMarks??n.selection.$from.marks()).map(t=>`${t.type.name}:${JSON.stringify(t.attrs)}`).sort().join(",");function Ft(n,t,e,o){return{kind:"insert",blockId:Fn(n.doc,t),from:t,end:t+o.length,replaced:t!==e,text:o,marks:Kn(n),at:Date.now()}}function Ls(n,t){return!n||!t||n.kind!==t.kind?!1:t.kind==="compose"?n.id===t.id:n.blockId!==t.blockId||t.at-n.at>Hn?!1:t.kind==="insert"?!t.replaced&&t.from===n.end&&t.marks===n.marks&&!(/\s$/.test(n.text)&&/^\S/.test(t.text)):t.direction===n.direction&&(t.direction<0?t.to===n.from:t.from===n.from)}var jn={deleteContentBackward:-1,deleteContentForward:1},Ht=new WeakMap,Vn=1e3,Kt="page-derived";function qn(n){let t=Ht.get(n)??null;return Ht.delete(n),t}function Wn(n,t){if(!t||n.before!==t.doc||Date.now()-t.at>Vn||n.getMeta(Ie)||n.steps.length!==1)return null;let e=n.steps[0];if(e.slice?.size!==0||e.from===e.to)return null;let o=n.before.resolve(e.from),s=n.before.resolve(e.to);return!o.parent.isTextblock||!o.sameParent(s)?null:{kind:"delete",blockId:o.depth?o.node(1).attrs.id:null,direction:t.direction,from:e.from,to:e.to,at:t.at}}function Ds(n,t=null){let e=t?qn(t):null,o=n.filter(i=>!i.getMeta(Kt));if(o.length!==1)return null;let s=o[0],r=s.getMeta("composition");return r!=null?{kind:"compose",id:r,at:Date.now()}:s.getMeta(bt)??Wn(s,e)}function Bs(){return new E.Plugin({props:{handleTextInput(n,t,e,o,s){return n.dispatch(s().setMeta(bt,Ft(n.state,t,e,o))),!0},handleDOMEvents:{beforeinput(n,t){let e=jn[t.inputType];return e&&Ht.set(n,{direction:e,at:Date.now(),doc:n.state.doc}),!1}}}})}function Un(n,t){if(!n||!/<table[\s>]/i.test(n))return null;let e=t.defaultView?.DOMParser??globalThis.DOMParser;if(!e)return null;let o=new e().parseFromString(n,"text/html").body,s=[...o.querySelectorAll("table")].filter(p=>!p.parentElement.closest("table"));if(s.length!==1)return null;let r=o.cloneNode(!0);for(let p of r.querySelectorAll("table, style, script, template, meta, title"))p.remove();if(r.textContent.trim())return null;let i=s[0];return{grid:[...i.querySelectorAll("tr")].filter(p=>p.closest("table")===i).map(p=>[...p.children].filter(a=>a.tagName==="TD"||a.tagName==="TH").map(a=>ct(Pe.parse(a,{topNode:g.nodes.table_cell.create()})))).filter(p=>p.length),own:!!i.querySelector("td[data-col]")}}function Gn(n){if(!n||!n.includes(" "))return null;let{header:t,rows:e}=at(n.replace(/\r?\n$/,""),{delimiter:" "});return{grid:[t,...e],own:!1}}function We(n,t,e=globalThis.document){let o=null;try{o=Un(n,e)}catch{o=null}if(!o)try{o=Gn(t)}catch{o=null}if(!o||!o.grid.length)return null;let s=Math.max(...o.grid.map(r=>r.length));for(let r of o.grid)for(;r.length<s;)r.push("");return{...o,width:s,height:o.grid.length}}function kt(n,{header:t=n.length>1}={}){let e=Math.max(0,...n.map(c=>c.length));if(!e)return null;let o=t?n[0]:[],s=t?n.slice(1):n,r=Array.from({length:e},()=>b("c")),i=D(null,null,e),l=Object.fromEntries(r.map((c,d)=>[c,{pos:i[d],name:lt(o[d]??"").replace(/\s+/g," ").trim()||`Column ${d+1}`}])),u=s.length?s:[[]],p=D(null,null,u.length),a=Object.fromEntries(u.map((c,d)=>[b("r"),{pos:p[d],cells:Object.fromEntries(r.map((h,f)=>[h,c[f]??""]))}]));return U(g,b(),{t:"table",pos:null,cols:l,rows:a})}var{Plugin:Yn,TextSelection:Jn}=E,jt=g.nodes;var Je=(n,t)=>{let e=null;return n.forEach((o,s)=>{!e&&o.type===jt.table&&o.attrs.id===t&&(e={node:o,pos:s})}),e};function N(n,t){if(!t)return null;let e=Je(n,t.table);if(!e)return null;let o=[];e.node.forEach(h=>o.push(h.attrs.id));let s=O(e.node.attrs.cols),r=[o.indexOf(t.anchor[0]),o.indexOf(t.head[0])],i=[s.indexOf(t.anchor[1]),s.indexOf(t.head[1])];if(r.includes(-1)||i.includes(-1))return null;let l=Math.min(...r),u=Math.max(...r),p=Math.min(...i),a=Math.max(...i),c=[],d=e.pos+1;return e.node.forEach((h,f,m)=>{if(m>=l&&m<=u){let y=[],S=d+1;h.forEach((A,K,rt)=>{rt>=p&&rt<=a&&y.push({cell:A,pos:S}),S+=A.nodeSize}),c.push(y)}d+=h.nodeSize}),{...e,top:l,bottom:u,left:p,right:a,cells:c}}var tt=(n,t)=>{let e=n.resolve(t);for(let o=e.depth;o>0;o--)if(e.node(o).type===jt.table_cell&&o>=3)return{table:e.node(o-2).attrs.id,row:e.node(o-1).attrs.id,col:e.node(o).attrs.col,start:e.start(o)};return null};function xt(n,t,e){let o=tt(n.state.doc,t),s=tt(n.state.doc,e);if(!o||!s||o.table!==s.table)return!1;let r={table:o.table,anchor:[o.row,o.col],head:[s.row,s.col]},i=n.state.tr.setSelection(Jn.create(n.state.doc,s.start)).setMeta(x,r);n.dispatch(i);let l=N(n.state.doc,r),u=l?(l.bottom-l.top+1)*(l.right-l.left+1):0;return j(n,`${u} ${u===1?"cell":"cells"} selected`),!0}function Xs(n,t,e,o){let s=n.state.doc.nodeAt(t);if(s?.type!==jt.table||!s.childCount)return!1;let r=s.childCount-1,i=s.child(0).childCount-1,l=(u,p)=>{let a=t+1;for(let c=0;c<u;c++)a+=s.child(c).nodeSize;a++;for(let c=0;c<p;c++)a+=s.child(u).child(c).nodeSize;return a+1};return e==="row"?xt(n,l(o,0),l(o,i)):xt(n,l(0,o),l(r,o))}var Qn=new Set(["Shift","Control","Alt","Meta","CapsLock"]),Xn=n=>/[\t\n\r"]/.test(n)?`"${n.replace(/"/g,'""')}"`:n;function Zn(n,t){let e=n.cells.map(r=>r.map(({cell:i})=>Xn(lt(ct(i)))).join(" ")).join(`
|
|
2
|
+
`),o=t.createElement("table"),s=o.appendChild(t.createElement("tbody"));for(let r of n.cells){let i=s.appendChild(t.createElement("tr"));for(let{cell:l}of r){let u=i.appendChild(t.createElement("td"));u.dataset.col=l.attrs.col,u.append(Ne.serializeFragment(l.content,{document:t}))}}return{text:e,html:o.outerHTML}}function Ue(n,t){let e=N(n.doc,x.getState(n));if(!e)return!1;if(t){let o=n.tr;for(let s of[...e.cells].reverse())for(let{cell:r,pos:i}of[...s].reverse())r.content.size&&o.delete(i+1,i+r.nodeSize-1);o.setMeta(x,x.getState(n)),t(k(o))}return!0}var Ge=(n,t,e)=>{let{text:o,html:s}=Zn(t,e.dom.ownerDocument);n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",s),n.preventDefault()},to=(n,t)=>(e,o,s)=>{let r=x.getState(e),i=N(e.doc,r);if(!i||!s)return!1;let l=[],u=O(i.node.attrs.cols);i.node.forEach(c=>l.push(c.attrs.id));let p=Math.max(0,Math.min(l.length-1,l.indexOf(r.head[0])+n)),a=Math.max(0,Math.min(u.length-1,u.indexOf(r.head[1])+t));return o&&o(e.tr.setMeta(x,{...r,head:[l[p],u[a]]})),!0},Ye=(n,t)=>{let e=t.target?.closest?.("td");if(!e||!n.dom.contains(e))return null;try{return n.posAtDOM(e,0)}catch{return null}};function Zs(){let n=null;return new Yn({key:x,state:{init:()=>null,apply(t,e,o,s){let r=t.getMeta(x);return r!==void 0?r:!e||t.selectionSet||t.docChanged&&!t.getMeta(ut)?null:N(s.doc,e)?e:null}},props:{attributes:t=>x.getState(t)?{class:"has-cell-rect"}:{},createSelectionBetween:t=>x.getState(t.state)?t.state.selection:null,decorations(t){let e=N(t.doc,x.getState(t));return e?It.DecorationSet.create(t.doc,e.cells.flat().map(({cell:o,pos:s})=>It.Decoration.node(s,s+o.nodeSize,{class:"is-cell-selected"}))):null},handleKeyDown(t,e){let o=t.state;if(!x.getState(o))return!1;if(e.key==="Escape")return t.dispatch(o.tr.setMeta(x,null)),!0;if(e.key==="Backspace"||e.key==="Delete")return Ue(o,t.dispatch);if(e.shiftKey){let s={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[e.key];if(s)return to(...s)(o,t.dispatch,t)}return Qn.has(e.key)||(e.metaKey||e.ctrlKey)&&(e.key==="a"||e.key==="c"||e.key==="x"||e.key==="v")||t.dispatch(o.tr.setMeta(x,null)),!1},handleDOMEvents:{mousedown(t,e){if(e.button!==0)return!1;!e.shiftKey&&x.getState(t.state)&&t.dispatch(t.state.tr.setMeta(x,null));let o=Ye(t,e);if(o===null)return!1;if(e.shiftKey){let u=x.getState(t.state),p=(u&&eo(t.state.doc,u))??t.state.selection.$anchor.pos;return tt(t.state.doc,p)?(e.preventDefault(),xt(t,p,o)):!1}let s=t.dom.ownerDocument,r=o,i=u=>{let p=Ye(t,u);if(p===null)return;let a=tt(t.state.doc,r),c=tt(t.state.doc,p);if(!a||!c||a.table!==c.table)return;let d=x.getState(t.state);a.row===c.row&&a.col===c.col&&!d||d&&d.head[0]===c.row&&d.head[1]===c.col||(u.preventDefault(),xt(t,r,p))},l=()=>{s.removeEventListener("mouseover",i),s.removeEventListener("mouseup",l),n=null};return n?.(),n=l,s.addEventListener("mouseover",i),s.addEventListener("mouseup",l),!1},copy(t,e){let o=N(t.state.doc,x.getState(t.state));return!o||!e.clipboardData?!1:(Ge(e,o,t),!0)},cut(t,e){let o=N(t.state.doc,x.getState(t.state));return!o||!e.clipboardData?!1:(Ge(e,o,t),Ue(t.state,t.dispatch),!0)}}},view:()=>({destroy:()=>n?.()})})}function eo(n,t){let e=Je(n,t.table),o=null;return e?.node.forEach((s,r)=>{if(s.attrs.id!==t.anchor[0])return;let i=e.pos+1+r+1;s.forEach(l=>{l.attrs.col===t.anchor[1]&&(o=i+1),i+=l.nodeSize})}),o}var Qe=n=>{let t=N(n.doc,x.getState(n));return t?{row:t.top,cell:t.left,rows:t.bottom-t.top+1,cols:t.right-t.left+1}:null};var Xe=new WeakMap;var{Plugin:no,TextSelection:V}=E,w=g.nodes,qt=256*1024,P=n=>O(n.attrs.cols),Ze=n=>{let t=n.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type===w.table){let o=t.node(e),s=e<t.depth?t.index(e):0,r=e+1<t.depth?t.index(e+1):0;return{table:o,pos:t.before(e),row:s,cell:r}}return null},et=(n,t,e,o)=>{let s=n.nodeAt(t);if(!s||!s.childCount)return null;e=Math.max(0,Math.min(e,s.childCount-1)),o=Math.max(0,Math.min(o,s.child(e).childCount-1));let r=t+1;for(let i=0;i<e;i++)r+=s.child(i).nodeSize;r++;for(let i=0;i<o;i++)r+=s.child(e).child(i).nodeSize;return r+1},wt=(n,t=C())=>w.table_row.create({id:b("r"),pos:t},n.map(e=>w.table_cell.create({col:e}))),v=(n,t,e)=>w.table.create({...n.attrs,...t},e);function _(n,t,e){let o=Ze(n);if(!o)return!1;let s=e(o.table,o);if(!s)return!1;if(t){let{table:r,row:i=o.row,cell:l=o.cell}=s,u=n.tr.replaceWith(o.pos,o.pos+o.table.nodeSize,r),p=et(u.doc,o.pos,i,l);p!==null&&u.setSelection(V.create(u.doc,p)),t(k(u))}return!0}function R(n,t,e,o=null,s=null,r=null){r??=o?n.doc.resolve(o.from).index(0):n.selection.$head.index(0);let i=n.doc.child(r),l=0;for(let d=0;d<r;d++)l+=n.doc.child(d).nodeSize;let u=i.isTextblock&&(i.content.size===0||o?.from===l+1&&o?.to===l+i.nodeSize-1),p=n.doc.maybeChild(r+1),a=u?i.attrs.pos:C(i.attrs.pos,p?.attrs.pos??null),c=e.type.create({...e.attrs,pos:a,parent:i.attrs.parent??null},e.content);if(t){let d=n.tr;o&&d.delete(o.from,o.to);let h=d.mapping.map(l),f=d.doc.child(r),m=u?h:h+f.nodeSize;if(d.replaceWith(m,u?h+f.nodeSize:m,c),s){let y=s.type.create({...s.attrs,pos:C(a,p?.attrs.pos??null),parent:i.attrs.parent??null},s.content);d.insert(m+c.nodeSize,y)}d.setSelection(V.create(d.doc,et(d.doc,m,0,0))),t(k(d).scrollIntoView())}return!0}function tn(n=3,t=3){if(!Number.isInteger(n)||!Number.isInteger(t)||n<1||t<1)return null;let e=Array.from({length:t},()=>b("c")),o=D(null,null,t),s=Object.fromEntries(e.map((l,u)=>[l,{pos:o[u],name:`Column ${u+1}`}])),i=D(null,null,n).map(l=>wt(e,l));return w.table.create({id:b(),cols:s},i)}var Wt=n=>(t,e)=>{let o=Ze(t);if(!o||t.selection.$head.parent.type!==w.table_cell)return!1;let s=o.table.child(o.row).childCount,r=o.row,i=o.cell;return n==="down"?r++:(i+=n,i>=s&&(r++,i=0),i<0&&(r--,i=s-1)),r<0?!0:r>=o.table.childCount?n===-1?!0:oo(t,e,o,i):(e&&e(t.tr.setSelection(V.create(t.doc,et(t.doc,o.pos,r,i))).scrollIntoView()),!0)};function oo(n,t,e,o){let s=[...e.table.content.content];if(s.push(wt(P(e.table),C(s.at(-1).attrs.pos,null))),t){let r=n.tr.replaceWith(e.pos,e.pos+e.table.nodeSize,v(e.table,{sort:null},s));r.setSelection(V.create(r.doc,et(r.doc,e.pos,s.length-1,o))),t(k(r).scrollIntoView())}return!0}var so=Wt(1),ro=Wt(-1),io=Wt("down"),lo=(n=!0)=>(t,e)=>_(t,e,(o,s)=>{let r=[...o.content.content],i=s.row+(n?1:0),l=C(r[i-1]?.attrs.pos??null,r[i]?.attrs.pos??null);return r.splice(i,0,wt(P(o),l)),{table:v(o,{sort:null},r),row:i}}),mr=(n,t)=>_(n,t,(e,o)=>{let s=[...e.content.content];if(s.length===1){let r=s[0];s[0]=w.table_row.create(r.attrs,P(e).map(i=>w.table_cell.create({col:i})))}else s.splice(o.row,1);return{table:v(e,{sort:null},s),row:Math.min(o.row,s.length-1)}}),en=(n,t,e,o,s)=>{let{pos:r,rekey:i}=zt(t,u=>n[u]?.pos??"",e),l={...n,[o]:{...s,pos:r}};for(let[u,p]of i)l[u]={...l[u],pos:p};return l},gr=(n=!0)=>(t,e)=>_(t,e,(o,s)=>{let r=P(o),i=s.cell+(n?1:0),l=b("c"),u=en(o.attrs.cols,r,i,l,{name:`Column ${r.length+1}`}),p=o.content.content.map(a=>{let c=[...a.content.content];return c.splice(i,0,w.table_cell.create({col:l})),w.table_row.create(a.attrs,c)});return{table:v(o,{cols:u},p),cell:i}}),yr=(n,t)=>_(n,t,(e,o)=>{let s=P(e);if(s.length<=1)return null;let r={...e.attrs.cols};delete r[s[o.cell]];let i=e.content.content.map(l=>w.table_row.create(l.attrs,l.content.content.filter((u,p)=>p!==o.cell)));return{table:v(e,{cols:r,sort:e.attrs.sort?.col===s[o.cell]?null:e.attrs.sort},i),cell:Math.min(o.cell,s.length-2)}}),br=n=>(t,e)=>_(t,e,(o,s)=>{let r=s.row+n;if(r<0||r>=o.childCount)return null;let i=[...o.content.content],[l]=i.splice(s.row,1);i.splice(r,0,l);let u=C(i[r-1]?.attrs.pos??null,i[r+1]?.attrs.pos??null);return i[r]=w.table_row.create({...l.attrs,pos:u},l.content),{table:v(o,{sort:null},i),row:r}}),kr=n=>(t,e)=>_(t,e,(o,s)=>{let r=P(o),i=s.cell+n;if(i<0||i>=r.length)return null;let l=[...r],[u]=l.splice(s.cell,1);l.splice(i,0,u);let p=en(o.attrs.cols,l.filter(c=>c!==u),i,u,o.attrs.cols[u]),a=o.content.content.map(c=>{let d=[...c.content.content],[h]=d.splice(s.cell,1);return d.splice(i,0,h),w.table_row.create(c.attrs,d)});return{table:v(o,{cols:p},a),cell:i}}),co=48,ao=1200,xr=160,uo=n=>Number.isFinite(n)&&n>0?Math.round(Math.min(ao,Math.max(co,n))):null,wr=(n,t)=>(e,o)=>_(e,o,s=>{let r=s.attrs.cols[n];if(!r)return null;let i=t===null?null:uo(t);if(t!==null&&i===null||(r.width??null)===i)return null;let{width:l,...u}=r,p={...s.attrs.cols,[n]:i===null?u:{...r,width:i}};return{table:v(s,{cols:p},s.content),cell:P(s).indexOf(n)}}),Mr=(n,t)=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!String(t).trim())return null;let r={...s.attrs.cols,[n]:{...s.attrs.cols[n],name:String(t).trim()}};return{table:v(s,{cols:r},s.content)}}),Sr=(n,t)=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!(t==="auto"||ge.includes(t)))return null;let{kind:r,...i}=s.attrs.cols[n],l={...s.attrs.cols,[n]:t==="auto"?i:{...s.attrs.cols[n],kind:t}};return{table:v(s,{cols:l,sort:s.attrs.sort?.col===n?null:s.attrs.sort},s.content)}}),Tr=(n,t="asc")=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!["asc","desc"].includes(t))return null;let r=P(s).indexOf(n),i=je(s)[n],l=[...s.content.content].map((a,c)=>({row:a,previous:c,text:a.child(r).textContent.trim()}));l.sort((a,c)=>{if(!a.text||!c.text)return!a.text&&!c.text?a.previous-c.previous:a.text?-1:1;let d=i==="number"?Dt(a.text):a.text,h=i==="number"?Dt(c.text):c.text;if(d==null||h==null)return d==null&&h==null?a.previous-c.previous:d==null?1:-1;let f=i==="number"?d-h:i==="date"?d<h?-1:d>h?1:0:d.localeCompare(h,void 0,{numeric:!0,sensitivity:"base"});return f?t==="asc"?f:-f:a.previous-c.previous});let u=D(null,null,l.length),p=l.map(({row:a},c)=>w.table_row.create({...a.attrs,pos:u[c]},a.content));return{table:v(s,{sort:{col:n,dir:t}},p)}}),Vt=(n,t=null)=>(e,o)=>_(e,o,(s,r)=>{let i=P(s),l=t?.row??r.row,u=t?.cell??r.cell,p=[...s.content.content];n.forEach((c,d)=>{let h=l+d;h>=p.length&&p.push(wt(i,C(p.at(-1).attrs.pos,null)));let f=[...p[h].content.content];c.forEach((m,y)=>{u+y<i.length&&(f[u+y]=w.table_cell.create({col:i[u+y]},fe(g,m)))}),p[h]=w.table_row.create(p[h].attrs,f)});let a=Math.max(1,...n.map(c=>c.length));return{table:v(s,{sort:null},p),row:l+n.length-1,cell:Math.min(u+a-1,i.length-1)}}),po=n=>new TextEncoder().encode(JSON.stringify(n.toJSON())).length;function ho(n,t){let e=t.clipboardData;if(!e||e.files?.length)return!1;let o=n.state;if(o.selection.$from.parent.type.spec.code)return!1;let s=Qe(o),r=e.getData("text/plain").replace(/\r?\n$/,""),i=We(e.getData("text/html"),e.getData("text/plain"),n.dom.ownerDocument)??(s&&r&&!/[\r\n]/.test(r)?{grid:[[r]],width:1,height:1,own:!1}:null);if(!i)return!1;if(s&&s.rows*s.cols>1&&i.width*i.height===1)return Vt(Array.from({length:s.rows},()=>Array(s.cols).fill(i.grid[0][0])),{row:s.row,cell:s.cell})(o,n.dispatch);if(s)return Vt(i.grid,{row:s.row,cell:s.cell})(o,n.dispatch);if(o.selection.$head.parent.type===w.table_cell)return i.width*i.height<2?!1:Vt(i.grid)(o,n.dispatch);if(i.width*i.height<2||i.height<2&&!/<table[\s>]/i.test(e.getData("text/html")))return!1;let l=kt(i.grid,{header:!i.own&&i.height>1});if(!l)return!1;if(po(l)>qt)return X("This paste is too large for one table.","error"),!0;let{from:u,to:p,empty:a,$from:c,$to:d}=o.selection;if(!a&&c.index(0)!==d.index(0)){let h=o.tr.deleteSelection();return R(o.apply(h),f=>{for(let m of f.steps)h.step(m);h.setSelection(V.create(h.doc,f.selection.from)),n.dispatch(k(h).scrollIntoView())},l)}return R(o,n.dispatch,l,a?null:{from:u,to:p})}var Er=it.keymap({Tab:so,"Shift-Tab":ro,Enter:io,"Mod-Enter":lo(!0)});function Cr(){return new no({props:{handlePaste:ho,handleClickOn(n,t,e,o,s,r){if(e.type!==w.table_cell||!r||s.button)return!1;let i=n.nodeDOM(o),l=i&&Xe.get(i);return l&&l.openDate(),!1}},appendTransaction(n,t,e){if(!n.some(r=>r.docChanged&&!r.getMeta(ut)))return null;let o=new Map;t.doc.forEach(r=>{r.type===w.table&&o.set(r.attrs.id,r)});let s=e.tr;return e.doc.forEach((r,i)=>{if(r.type!==w.table||!r.attrs.sort)return;let l=o.get(r.attrs.id),u=r.attrs.sort.col;if(!l)return;let p=d=>Object.fromEntries(d.content.content.map(h=>[h.attrs.id,h.content.content.find(f=>f.attrs.col===u)?.textContent])),a=p(l),c=p(r);(Object.keys(a).length!==Object.keys(c).length||Object.keys(a).some(d=>a[d]!==c[d]||!Object.hasOwn(c,d)))&&s.setNodeMarkup(i,null,{...r.attrs,sort:null})}),s.docChanged?s.setMeta(Kt,!0):null}})}function Or(n,t,e){let o=n.state.doc.nodeAt(t);if(o?.type!==w.table_cell)return!1;let s=n.state.tr.replaceWith(t+1,t+o.nodeSize-1,e?g.text(e):[]);return n.dispatch(s.setSelection(V.create(s.doc,t+1+e.length))),!0}function Ar(n,t,e,o){let s=et(n.state.doc,t,e,o);return s===null?!1:(n.dispatch(n.state.tr.setSelection(V.create(n.state.doc,s))),!0)}var{TextSelection:fo}=E,Ut=g.nodes,mo=Object.freeze(["To do","In progress","Done"]),nn=(n,t)=>L(n)&&(t===null||L(t)&&n<t)?C(n,t):null;function Gt(n=mo){let t=D(null,null,n.length),e=Object.fromEntries(n.map((o,s)=>[b("c"),{pos:t[s],name:o}]));return Ut.board.create({id:b(),columns:e,cards:{}})}function on(n,t,e=Gt(),o=null,s=null){let r=n.tr;o&&r.delete(o.from,o.to),s??=r.doc.resolve(r.mapping.map(n.selection.head)).index(0);let i=Z(r.doc),l=r.doc.child(s),u=l.isTextblock&&l.content.size===0,p=u?s:i[s].subEnd,a=u?i[s].at:i[p].end,c=i[p+1]?.node.attrs.pos??null,d=l.attrs.parent??null,h=u?l.attrs.pos:nn(i[p].node.attrs.pos,c),f=Ut.board.create({...e.attrs,pos:h,parent:d}),m=Ut.paragraph.create({id:b(),pos:nn(h,c),parent:d});return r.replaceWith(a,u?i[s].end:a,[f,m]),r.setSelection(fo.create(r.doc,a+f.nodeSize+1)),t&&t(k(r).scrollIntoView()),!0}function sn(n){let t=[];return n.forEach(e=>{e.type===g.nodes.table&&O(e.attrs.cols).length&&t.push(e)}),t}var{TextSelection:Jt}=E,I=g.nodes,z=[{key:"text",label:"Text",description:"Plain writing",icon:"T",type:"paragraph",aliases:["p","paragraph","plain"]},{key:"h1",label:"Heading 1",description:"Big section heading",icon:"H1",type:"heading",attrs:{level:1},hint:"#",aliases:["h1","title"]},{key:"h2",label:"Heading 2",description:"Medium section heading",icon:"H2",type:"heading",attrs:{level:2},hint:"##",aliases:["h2","subtitle"]},{key:"h3",label:"Heading 3",description:"Small section heading",icon:"H3",type:"heading",attrs:{level:3},hint:"###",aliases:["h3"]},{key:"bullet",label:"Bulleted list",description:"A simple list",icon:"\u2022",type:"list_item",attrs:{kind:"bullet"},hint:"-",aliases:["ul","bullet","list","unordered"]},{key:"ordered",label:"Numbered list",description:"A list with numbers",icon:"1.",type:"list_item",attrs:{kind:"ordered"},hint:"1.",aliases:["ol","num","numbered","ordered"]},{key:"check",label:"Checklist",description:"Tasks to tick off",icon:"\u2610",type:"list_item",attrs:{kind:"check"},hint:"[]",aliases:["todo","to-do","task","check","checkbox"]},{key:"toggle",label:"Toggle",description:"Hide details under a line",icon:"\u25B8",type:"toggle",attrs:{open:!0},hint:">",aliases:["collapse","details","fold"]},{key:"callout",label:"Callout",description:"Make a note stand out",icon:"!",type:"callout",aliases:["note","aside","info"]},{key:"quote",label:"Quote",description:"Set text apart as a quotation",icon:"\u201C",type:"quote",hint:'"',aliases:["blockquote","quotation","cite"]},{key:"code",label:"Code",description:"Code with highlighting",icon:"</>",type:"code_block",hint:"```",aliases:["pre","snippet"]}],go=[{key:"divider",label:"Divider",description:"A line between sections",icon:"\u2014",hint:"---",aliases:["hr","line","separator","rule"],insert:"divider"},{key:"image",label:"Image",description:"Upload or paste a picture",icon:"\u25A3",aliases:["img","picture","photo"],insert:"image"},{key:"file",label:"File",description:"Attach any file",icon:"\u2398",aliases:["upload","attachment","pdf"],insert:"file"},{key:"table",label:"Table",description:"Rows and columns, paste from a spreadsheet",icon:"\u25A6",aliases:["grid","spreadsheet"],insert:"table"},{key:"csv",label:"Import CSV\u2026",description:"Turn a CSV file into a table",icon:"\u21E7",aliases:["comma separated","import"],insert:"csv"},{key:"board",label:"Board",description:"Cards in columns, like a kanban",icon:"\u25A5",aliases:["kanban","cards","columns","status"],insert:"board"}],yo={key:"chart",label:"Chart",description:"A bar or line chart from a table",icon:"\u{1F4CA}",aliases:["graph","plot","bar","line"],insert:"chart"},Qt=n=>($e.get(n)?.ensure("chart")??Promise.resolve()).catch(()=>{}).then(()=>import("./c-E4LIR5X5.js")),St=[...z,...go],ln=(n,t=St)=>sn(n.doc).length?[...t,yo]:t;function Tt(n){let t=n.type.name;return z.find(e=>e.type===t&&(!e.attrs||(t==="heading"?e.attrs.level===n.attrs.level:t==="list_item"?e.attrs.kind===n.attrs.kind:!0)))??z[0]}var cn=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e};function q(n,t,e){let o=cn(n.doc,t),s=n.doc.child(t),r={id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent};return s.type===I.list_item&&e.type==="list_item"&&(r.indent=s.attrs.indent),n.setBlockType(o+1,o+s.nodeSize-1,I[e.type],{...r,...e.attrs||{}})}var bo=Object.freeze({status:"refused",code:"unsupported-format"}),ko=he([]).type,xo=n=>{let t=!1;return n.forEach(e=>{!t&&e.marks.some(pe)&&(t=!0)}),t};function nt(n,t){return!n.isTextblock||n.type===I.opaque_block?!1:!xo(n)||I[t.type].allowsMarkType(ko)}function an(n,t,e=n.tr){let o=Z(e.doc),{to:s}=Le(o,t),r=e.doc.child(t);return e.insert(s,I.paragraph.create({parent:r.attrs.parent??null})),e.setSelection(Jt.create(e.doc,s+1))}var Yt=(n,t)=>L(n)&&(t===null||L(t)&&n<t)?C(n,t):null;function Xt(n,t){let e=cn(n.doc,t),o=n.doc.child(t),s=n.doc.maybeChild(t+1),{id:r,pos:i,parent:l}=o.attrs;return n.replaceWith(e,e+o.nodeSize,[I.divider.create({id:r,pos:i,parent:l}),I.paragraph.create({id:b(),pos:Yt(i,s?s.attrs.pos:null),parent:l})]),n.setSelection(Jt.create(n.doc,e+2))}function wo(n,t,e=n.tr){let o=e.doc.child(t);if(o.type===I.paragraph&&o.content.size===0)return Xt(e,t);let s=Z(e.doc),r=s[t].subEnd,i=s[r].end,l=s[r+1]?.node.attrs.pos??null,u=Yt(s[r].node.attrs.pos,l),p=o.attrs.parent??null;return e.insert(i,[I.divider.create({id:b(),pos:u,parent:p}),I.paragraph.create({id:b(),pos:Yt(u,l),parent:p})]),e.setSelection(Jt.create(e.doc,i+2))}function Mo(n,t){if(n.length<2||n.length>32)return 1/0;let e=-1,o=0;for(let s of n){let r=t.indexOf(s,e+1);if(r<0)return 1/0;o+=r-e-1,e=r}return o}function un(n,t){let e=t.trim().toLowerCase();if(!e)return n;let o=s=>{let r=s.label.toLowerCase(),i=[s.key,...s.aliases||[],...s.hint?[s.hint]:[]].map(u=>u.toLowerCase());if(r===e||i.includes(e))return[0,0];if(r.startsWith(e))return[1,0];if([...r.split(/\s+/),...i].some(u=>u.startsWith(e)))return[2,0];if([r,...i].some(u=>u.includes(e)))return[3,0];if(e.length>=3&&s.description&&s.description.toLowerCase().split(/[^a-z0-9]+/).some(u=>u.startsWith(e)))return[4,0];let l=Math.min(...[r,s.key,...s.aliases||[]].map(u=>Mo(e,u.toLowerCase())));return l===1/0?null:[5,l]};return n.map((s,r)=>({it:s,order:r,rank:o(s)})).filter(s=>s.rank).sort((s,r)=>s.rank[0]-r.rank[0]||s.rank[1]-r.rank[1]||s.order-r.order).map(s=>s.it)}function dn(n,t,e,o=null){return t.type!=="quote"?rn(n,t,e,o):import("./c-DFS4XZJV.js").then(({runFormat:s})=>s(n,()=>rn(n,t,e,o)))}function rn(n,t,e,o=null){let s=n.state;if(t.insert==="image"||t.insert==="file")return Ae(n,t.insert==="image"?"image/*":"",Oe(s,e),o);if(t.insert==="csv")return Mt(n,o);if(t.insert==="table")return R(s,n.dispatch,tn(),o,null,e);if(t.insert==="board")return on(s,n.dispatch,Gt(),o,e);if(t.insert==="chart")return Qt(n).then(({chartFromSlash:l})=>l(n,e,o));let r=s.tr;o&&r.delete(o.from,o.to);let i=r.doc.child(e);return i.isTextblock&&i.content.size===0&&!nt(i,t)?bo:(t.insert==="divider"?r=wo(s,e,r):i.isTextblock&&i.content.size===0?r=q(r,e,t):(r=an(s,e,r),r=q(r,r.doc.resolve(r.selection.head).index(0),t)),n.dispatch(k(r).scrollIntoView()),n.focus(),!0)}var{InputRule:ee}=Lt,H=g.nodes,Et=(n,t,e)=>n.doc.rangeHasMark(t,e,g.marks.code)||!!g.marks.code.isInSet(n.storedMarks||n.selection.$from.marks()),G=(n,t,e=["paragraph"],o=!1)=>new ee(n,(s,r,i,l)=>{let u=s.doc.resolve(i);return!s.selection.empty||u.depth!==1||u.parentOffset!==0||!e.includes(u.parent.type.name)||o&&l!==u.end()||Et(s,i,l)?null:k(q(s.tr.delete(i,l),u.index(0),typeof t=="function"?t(r):t))}),So=new ee(/^---$/,(n,t,e,o)=>{let s=n.doc.resolve(e);return!n.selection.empty||s.depth!==1||s.parent.type!==H.paragraph||s.parentOffset!==0||s.parent.content.size!==o-e||Et(n,e,o)?null:k(Xt(n.tr,s.index(0)))}),ne=`\\s\\(\\[\\{'\u2018\u201C"`,To=new RegExp(`[${ne}]`),Zt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),pn=n=>`([^\\s${n}](?:[\\s\\S]*?[^\\s${n}])?)`,Ct=(n,t)=>!!n?.isComposing||n?.keyCode===229||!!t?.composing,hn=n=>{let t=0;for(let e=n.length-1;e>=0&&n[e]==="\\";e--)t++;return t},Eo=(n,t)=>{let e=n.doc.resolve(t);return!e.parent.inlineContent||hn(e.parent.textBetween(0,e.parentOffset,null,"\uFFFC"))%2?!1:e.parentOffset===0||To.test(e.parent.textBetween(e.parentOffset-1,e.parentOffset))},Co=(n,t,e,o,s)=>{let r=s(t);if(!r||!n.selection.empty||e<0||e>o||o>n.doc.content.size)return null;let i=n.doc.resolve(e),l=n.doc.resolve(o);if(!i.sameParent(l)||!i.parent.inlineContent)return null;let[u,p,a,c]=t;if(Et(n,e,o))return null;let d=u.slice(p.length,u.length-a.length-c.length),h=e+p.length;if(!Eo(n,h)||hn(u.slice(0,u.length-c.length))%2)return null;let f=u.length-(o-e);if(f<0)return null;let m=n.tr;f&&m.insertText(u.slice(-f),o,o);let y=h+d.length,S=y+a.length;return m.delete(S,e+u.length),m.delete(h,y),m.addMark(h,h+a.length,r),m.removeStoredMark(r.type),k(m)},fn=(n,t)=>new ee(n,(e,o,s,r)=>Co(e,o,s,r,t),{inCodeMark:!1}),Y=(n,t,e)=>fn(new RegExp(`(^|[${ne}])${Zt(n)}${pn(Zt(t))}(${Zt(t)})$`),()=>e.create()),Oo=fn(new RegExp(`(^|[${ne}])\\[${pn("\\[\\]")}(\\]\\([^()\\s]*\\))$`),n=>{let t=ue(n[3].slice(2,-1));return t?g.marks.link.create({href:t}):null}),Ao=[Y("**","**",g.marks.strong),Y("__","__",g.marks.strong),Y("*","*",g.marks.em),Y("_","_",g.marks.em),Y("`","`",g.marks.code),Y("~~","~~",g.marks.strike),Oo],te=["paragraph","list_item"],vo=[G(/^(#{1,3})\s$/,n=>({type:"heading",attrs:{level:n[1].length}})),G(/^[-*+]\s$/,{type:"list_item",attrs:{kind:"bullet"}},te),G(/^\d+[.)]\s$/,{type:"list_item",attrs:{kind:"ordered"}},te),G(/^\[( |x|X)?\]\s$/,n=>({type:"list_item",attrs:{kind:"check",checked:!!n[1]&&n[1]!==" "}}),te),G(/^>\s$/,{type:"toggle",attrs:{open:!0}}),G(/^```$/,{type:"code_block"},["paragraph"],!0),So,...Ao];function _o(n,t,e,o,s){if(s!==" "||e!==o)return!1;let r=t.state,i=r.doc.resolve(e),l=i.parent;if(i.depth!==1||l.type!==H.paragraph||i.parentOffset!==1||l.textContent!=='"'||!t.editable||typeof t.runFormatCommand!="function")return!1;let u=()=>{t.isDestroyed||t.dispatch(r.tr.insertText(" ",e,o))},p=i.before(1);return import("./c-DFS4XZJV.js").then(({quoteFromSpace:a})=>a(n,t,{at:p,from:e,to:o},u),u),!0}var ri=()=>{let n=Lt.inputRules({rules:vo}),t=n.props.handleTextInput;return n.props.handleTextInput=(e,o,s,r)=>_o(n,e,o,s,r)||t(e,o,s,r),n},$o=/^\s*\|(.*)\|\s*$/;function Io(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parent.type!==H.paragraph||e.parentOffset!==e.parent.content.size||Et(n,e.start(),e.end()))return!1;let s=$o.exec(e.parent.textContent);if(!s)return!1;let r=s[1].split("|").map(l=>l.trim());if(!r.some(Boolean))return!1;let i=kt([r,r.map(()=>"")],{header:!0});return R(n,t,i,{from:e.start(),to:e.end()})}var ii=()=>it.keymap({Enter:(n,t,e)=>!Ct(null,e)&&Io(n,t)});function li(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0)return!1;let s=e.parent;return s.type===H.heading||s.type===H.callout||s.type===H.quote||s.type===H.code_block&&s.content.size===0?(t&&t(k(n.tr.setNodeMarkup(e.before(),H.paragraph,{id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent}))),!0):!1}var{Plugin:xn,PluginKey:wn,TextSelection:vt,NodeSelection:Lo}=E,Mn=g.marks,F=g.nodes,At=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"\u2318":"Ctrl+",Sn=n=>{let t=ht(n.doc),{lo:e,hi:o}=n.selection.span(n.doc);return t.slice(e,o+1).filter(s=>s.up===t[e].up)},Ot=(n,t)=>n.state.doc.child(t).attrs.id,Do=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e},mn=["aria-haspopup","aria-controls","aria-activedescendant"],Bo="That block is no longer available.",ie="This block holds content from a newer version, so it can't be converted here.";function gn(n){let t=n.visualViewport;return t?{left:t.offsetLeft,top:t.offsetTop,width:t.width,height:t.height}:{left:0,top:0,width:n.innerWidth,height:n.innerHeight}}function Ro(n,t,e,o=0){let s=W,r=Math.min(t,Math.max(0,n.width-s*2));return{left:n.left+(n.width-r)/2,top:Math.max(n.top+s,n.top+n.height-e-o-s),width:r}}function Po(n,t=globalThis.location){return`${t.origin}${t.pathname}${t.search}#${encodeURIComponent(n)}`}function No(n){if(!n)return;let t=()=>X("Link copied"),e=()=>X("Could not copy the link.","error");if(!globalThis.navigator?.clipboard?.writeText){e();return}globalThis.navigator.clipboard.writeText(Po(n)).then(t,e)}var Tn=[{key:"up",label:"Move up",icon:"\u2191",hint:`${At}\u21E7\u2191`,run:n=>Bt(-1)(n.state,n.dispatch)},{key:"down",label:"Move down",icon:"\u2193",hint:`${At}\u21E7\u2193`,run:n=>Bt(1)(n.state,n.dispatch)},{key:"indent",label:"Indent",icon:"\u2192",hint:"Tab",run:n=>Be(n.state,n.dispatch)},{key:"outdent",label:"Outdent",icon:"\u2190",hint:"\u21E7Tab",run:n=>Re(n.state,n.dispatch)},{key:"duplicate",label:"Duplicate",icon:"\u29C9",hint:`${At}D`,run:n=>He(n.state,n.dispatch)},{key:"delete",label:"Delete",icon:"\xD7",hint:"Del",run:n=>Pt(n.state,n.dispatch)},{key:"turn",label:"Turn into",icon:"\u21BB",hint:"\u203A",only:"text",run:(n,t)=>t.openMenu("turn",t.plus)},{key:"link",label:"Copy link",icon:"\u{1F517}",run:(n,t,e)=>No(n.state.doc.child(e).attrs.id)},{key:"alt",label:"Alt text\u2026",icon:"Aa",only:"image",focus:!1,run:(n,t,e)=>ve(n,Ot(n,e))},{key:"small",label:"Small",icon:"\u25AB",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:240})},{key:"medium",label:"Medium",icon:"\u25FB",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:480})},{key:"full",label:"Full width",icon:"\u2B1C",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:null})},{key:"chart",label:"Chart this table",icon:"\u{1F4CA}",only:"table",run:(n,t,e)=>{let o=Do(n.state.doc,e);return Qt(n).then(({insertChartAfterTable:s})=>s(n,o))}},{key:"csv",label:"Import CSV\u2026",icon:"\u21E7",only:"table",focus:!1,run:(n,t,e)=>Mt(n,null,n.state.doc.child(e).attrs.id)}],zo=n=>{if(!(n.selection instanceof B))return[];let t=Sn(n),e=t.every(r=>r.node.isTextblock),o=t.length===1&&t[0].node.type===F.image,s=t.length===1&&t[0].node.type===F.table;return Tn.filter(r=>r.only==="text"?e:r.only==="image"?o:r.only==="table"?s:!0)},$=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,ot={plus:$('<path d="M8 3.5v9M3.5 8h9"/>'),grip:$('<path stroke-width="2.2" d="M6 3.5h.01M10 3.5h.01M6 8h.01M10 8h.01M6 12.5h.01M10 12.5h.01"/>'),strong:$('<path d="M5 3h4a2.5 2.5 0 0 1 0 5H5zM5 8h4.6a2.5 2.5 0 0 1 0 5H5z"/>'),em:$('<path d="M10 3H6.5M9.5 13H6M9 3l-2 10"/>'),strike:$('<path d="M3 8h10M10.8 5.2C10.5 4 9.4 3.2 8 3.2c-1.7 0-2.8.9-2.8 2.1M5.2 10.8c.3 1.2 1.4 2 2.8 2 1.7 0 2.8-.9 2.8-2.1"/>'),code:$('<path d="M6 4.5 2.5 8 6 11.5M10 4.5 13.5 8 10 11.5"/>'),link:$('<path d="M7 9a2.5 2.5 0 0 0 3.5 0l2-2A2.5 2.5 0 0 0 9 3.5l-.7.7M9 7a2.5 2.5 0 0 0-3.5 0l-2 2A2.5 2.5 0 0 0 7 12.5l.7-.7"/>'),bullet:$('<path d="M6.5 4.5h7M6.5 8h7M6.5 11.5h7"/><path stroke-width="2.4" d="M3 4.5h.01M3 8h.01M3 11.5h.01"/>'),ordered:$('<path d="M7 4.5h6.5M7 8h6.5M7 11.5h6.5M2.5 3.5l1-.5v3M2.5 9.3c.2-.5.6-.8 1.1-.8.6 0 1 .4 1 .9 0 .9-2.1 1.4-2.1 2.6h2.1"/>'),check:$('<rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8.2l1.8 1.8 3.4-4"/>'),more:$('<path stroke-width="2.2" d="M3 8h.01M8 8h.01M13 8h.01"/>')},oe=[["strong","Bold"],["em","Italic"],["strike","Strikethrough"],["link","Link"],["bullet","Bulleted list"],["ordered","Numbered list"],["check","Checklist"],["code","Code"]],En=new Set(["strong","em","link"]),Ho=new Set(["up","down","indent","outdent"]),Fo=204,Ko=52,W=8,Cn=new Set(["bullet","ordered","check"]),jo=new Set(["paragraph","heading","list_item"]),st=n=>{let t=n.selection;if(t instanceof B)return Sn(n).map(l=>l.i);let{$from:e,$to:o,empty:s}=t,r=Math.min(!s&&o.depth===0?o.index(0)-1:o.index(0),n.doc.childCount-1),i=[];for(let l=e.index(0);l<=r;l++)i.push(l);return i},On=n=>st(n).filter(t=>{let e=n.doc.child(t);return e.isTextblock&&e.type!==F.code_block}),An=(n,t)=>n.type===F.list_item&&n.attrs.kind===t,vn=(n,t)=>{let e=On(n);return e.length>0&&e.every(o=>An(n.doc.child(o),t))},Vo=n=>{let t="";return n.forEach(e=>{t+=e.isText?e.text:e.type===F.hard_break?`
|
|
3
|
+
`:""}),t};function qo(n){let{$from:t,$to:e,empty:o}=n.selection;if(o||!(n.selection instanceof vt)||t.depth!==1||e.depth!==1||t.parentOffset!==0||e.parentOffset!==e.parent.content.size)return null;let s=st(n);return s.every(r=>jo.has(n.doc.child(r).type.name))?s:null}function Wo(n,t){let e=n.doc.child(t[0]),o=n.selection.$from.before(1),s=n.selection.$to.after(1),r=t.map(a=>Vo(n.doc.child(a))).join(`
|
|
4
|
+
`),{id:i,pos:l,parent:u}=e.attrs,p=n.tr.replaceWith(o,s,F.code_block.create({id:i,pos:l,parent:u},r?g.text(r):null));return p.setSelection(vt.create(p.doc,o+1,o+1+r.length))}function Uo(n,t){let e=n.tr,o=n.doc.resolve(n.selection.from).before(1),s=0;for(let r of[...t].reverse()){let i=0;for(let d=0;d<r;d++)i+=n.doc.child(d).nodeSize;let l=n.doc.child(r),{id:u,pos:p,parent:a}=l.attrs,c=l.textContent.split(`
|
|
5
|
+
`).map((d,h)=>F.paragraph.create(h===0?{id:u,pos:p,parent:a}:{parent:a},d?g.text(d):null));e.replaceWith(i,i+l.nodeSize,c),s||(s=i+c.reduce((d,h)=>d+h.nodeSize,0))}return s=e.mapping.slice(1).map(s),e.setSelection(vt.create(e.doc,o+1,s-1))}var _n=n=>{let t=st(n);return t.length>0&&t.every(e=>n.doc.child(e).type===F.code_block)?t:null};function yn(n,t){if(Cn.has(t))return vn(n,t);if(t==="code"&&_n(n))return!0;let e=Mn[t],{from:o,to:s,empty:r,$from:i}=n.selection;return r?!!e.isInSet(n.storedMarks||i.marks()):n.doc.rangeHasMark(o,s,e)}function Go(n,t){let e=n.state,o=vn(e,t),s=z.find(l=>l.key===(o?"text":t)),r=On(e).filter(l=>o||!An(e.doc.child(l),t));if(r.some(l=>!nt(e.doc.child(l),s))){j(n,ie);return}let i=e.tr;for(let l of r)q(i,l,s);i.docChanged&&n.dispatch(k(i))}var se=(n,t,e)=>import("./c-DFS4XZJV.js").then(o=>o.nativeMenu(n,e,t.more));function bn(n,t){if(t==="link")return Ce(n);let e=n.state,o=t==="code"?_n(e):null,s=t==="code"&&!o?qo(e):null;Cn.has(t)?Go(n,t):o?n.dispatch(k(Uo(e,o)).scrollIntoView()):s&&s.some(r=>!nt(e.doc.child(r),z.find(i=>i.key==="code")))?j(n,ie):s?n.dispatch(k(Wo(e,s)).scrollIntoView()):ae.toggleMark(Mn[t])(e,n.dispatch),n.focus()}var T=(n,t,e={})=>{let o=document.createElement(n);t&&(o.className=t);for(let[s,r]of Object.entries(e))o.setAttribute(s,r);return o};function kn(n,t){let e=T("button",`page-tool${En.has(n)?" page-tool-primary":" page-tool-desk"}`,{type:"button","data-cmd":n,"aria-label":t,title:t});return e.innerHTML=ot[n],e}var Yo=1600,Jo=0,Qo=new wn("page-chrome"),$n=new WeakMap,_t=new wn("page-slash-range"),Xo={init:()=>null,apply(n,t){let e=t;if(e&&n.docChanged){let s=n.mapping.map(e.from,1),r=n.mapping.map(e.to,-1);e=s<=r&&n.doc.textBetween(s,r)===e.text?{...e,from:s,to:r}:null}let o=n.getMeta(_t);return o!==void 0&&(e=o),e}},Ci=()=>new xn({key:_t,state:Xo}),In=(n,t)=>{let e=t?n.state.doc.textBetween(t.from,t.to):null;n.dispatch(n.state.tr.setMeta(_t,t?{...t,text:e}:null))},Ln=n=>{let t=_t.getState(n);return t?{from:t.from,to:t.to}:null};function Oi(n,t,e){let o=$n.get(n);return o?(o.openMenu("external",t),o.menu.externalItems=e,o.renderMenu(),!0):!1}var re=class{constructor(t,e){this.view=t,this.onAiTool=e,this.shell=t.dom.parentElement,this.menu=null,this.priorAria=null,this.movedTimer=0,this.hover=null,this.pendingHover=null,this.win=t.dom.ownerDocument.defaultView??globalThis,this.frame=null,this.destroyed=!1,this.probe=null,this.roving=null,this.dock=T("div","page-dock",{role:"toolbar","aria-label":"Formatting"}),this.turn=T("button","page-tool page-tool-turn page-tool-desk",{type:"button","aria-haspopup":"menu"}),this.more=T("button","page-tool page-tool-primary page-tool-more",{type:"button","aria-label":"More",title:"More","aria-haspopup":"menu"}),this.more.innerHTML=ot.more,this.dock.append(this.turn,T("span","page-tool-sep page-tool-desk"),...oe.map(([s,r])=>kn(s,r)),this.more),this.plus=T("button","page-plus",{type:"button","aria-label":"Add a block",title:"Add a block"}),this.plus.innerHTML=ot.plus,this.grip=T("button","page-grip",{type:"button","aria-label":"Block actions",title:"Drag to move, click for actions","aria-haspopup":"menu"}),this.grip.innerHTML=ot.grip,this.bubble=T("div","page-bubble",{role:"toolbar","aria-label":"Selection",hidden:""}),this.bubble.append(...oe.map(([s,r])=>kn(s,r))),this.menuId=`page-menu-${++Jo}`,this.menuEl=T("div","page-menu",{role:"menu",id:this.menuId,hidden:""}),this.scrim=T("div","page-scrim",{hidden:""}),this.shell.insertBefore(this.dock,t.dom),this.shell.append(this.plus,this.grip,this.bubble,this.scrim,this.menuEl);let o=s=>s.preventDefault();for(let s of[this.dock,this.plus,this.grip,this.bubble,this.menuEl])s.addEventListener("mousedown",o);for(let s of[this.dock,this.bubble])s.addEventListener("click",r=>{let i=r.target.closest("[data-cmd]");i&&bn(this.view,i.dataset.cmd)});this.turn.addEventListener("click",()=>this.toggleMenu("turn",this.turn)),this.more.addEventListener("click",()=>this.toggleMenu("more",this.more)),this.dock.addEventListener("keydown",s=>this.dockKey(s)),this.plus.addEventListener("click",()=>this.fromPlus()),this.grip.addEventListener("click",s=>{s.detail===0&&this.gripAction(this.gutterIndex())}),this.drag=new _e(t,this.grip,{index:()=>this.gutterIndex(),onClick:s=>this.gripAction(s)}),this.scrim.addEventListener("click",()=>this.closeMenu()),this.menuEl.addEventListener("click",s=>{let r=s.target.closest(".page-menu-item");r&&this.pick(Number(r.dataset.index))}),this.menuEl.addEventListener("keydown",s=>{this.key(s)&&s.preventDefault()}),this.onMove=s=>{this.shell.classList.add("is-moved"),clearTimeout(this.movedTimer),this.movedTimer=setTimeout(()=>this.shell.classList.remove("is-moved"),Yo),this.trackHover(s)},this.onKey=()=>{clearTimeout(this.movedTimer),this.shell.classList.remove("is-moved"),this.pendingHover=null,this.setHover(null)},this.onLeave=()=>{this.pendingHover=null,this.setHover(null)},this.onResize=()=>this.scheduleLayout(),this.onDocDown=s=>{this.menu&&([this.menuEl,this.plus,this.grip,this.turn].some(r=>r.contains(s.target))||this.closeMenu())},document.addEventListener("mousedown",this.onDocDown,!0),this.shell.addEventListener("mousemove",this.onMove),this.shell.addEventListener("mouseleave",this.onLeave),this.shell.addEventListener("keydown",this.onKey),this.win.addEventListener("resize",this.onResize),this.win.addEventListener("scroll",this.onResize,!0),this.win.visualViewport?.addEventListener("resize",this.onResize),this.win.visualViewport?.addEventListener("scroll",this.onResize),this.update(t,null)}blockIndex(){let t=this.view.state,e=t.selection,o=e instanceof B||e instanceof Lo?e.from:e.head;return Math.min(t.doc.resolve(o).index(0),t.doc.childCount-1)}isPhone(){return!!this.win?.matchMedia?.("(max-width: 560px)").matches}gutterIndex(){return this.isPhone()?this.blockIndex():(this.settleHover(),Math.min(this.hover??this.blockIndex(),this.view.state.doc.childCount-1))}dockControls(){let t=[...this.dock.querySelectorAll("button")].filter(e=>this.rendered(e));return this.isPhone()?t.filter(e=>e.classList.contains("page-tool-primary")):t}inRoving(t){return!t||!this.dock.contains(t)||this.isPhone()&&!t.classList.contains("page-tool-primary")?!1:this.rendered(t)}rendered(t){if(t.hidden)return!1;let e=this.win?.getComputedStyle?.(t);return!e||e.display!=="none"}setRoving(t){this.roving=t;let e=new Set(this.dockControls());for(let o of this.dock.querySelectorAll("button"))o.tabIndex=o===t&&e.has(o)?0:-1}leaveToToolbar(){queueMicrotask(()=>{this.view.isDestroyed||this.focusToolbar()})}focusToolbar(){let[t]=this.dockControls();return t?(this.setRoving(t),t.focus(),!0):!1}dockKey(t){if(t.key==="Escape"){t.preventDefault(),this.view.focus();return}if(t.key!=="ArrowRight"&&t.key!=="ArrowLeft")return;let e=this.dockControls(),o=e.indexOf(t.target);if(o<0)return;t.preventDefault();let s=e[(o+(t.key==="ArrowRight"?1:-1)+e.length)%e.length];this.setRoving(s),s.focus()}selectionIds(){let t=this.view.state;return st(t).map(e=>t.doc.child(e).attrs.id)}idIndex(t){let e=-1;return this.view.state.doc.forEach((o,s,r)=>{o.attrs.id===t&&(e=r)}),e}invoker(){let t=this.menu;if(!t||t.slashAt!==null)return this.view.dom;let e=t.anchor;return e&&e!==this.view.dom&&(e.tagName==="BUTTON"||e.hasAttribute("tabindex"))?e:this.view.dom}selectCaretBlock(t=null){let e=this.view.state;if(e.selection instanceof B)return;let o=(t??[]).map(r=>this.idIndex(r)).filter(r=>r>=0),s=o.length?o[0]:this.blockIndex();this.view.dispatch(e.tr.setSelection(Rt(e.doc,s,o.length?o[o.length-1]:s)))}gripAction(t){this.menu?this.closeMenu():this.openActions(this.grip,t)}trackHover(t){this.menu||this.drag.state||[this.plus,this.grip,this.dock,this.bubble].some(e=>e.contains(t.target))||(this.pendingHover={clientY:t.clientY},this.scheduleLayout())}hoverAt(t){let e=this.view,o=e.posAtCoords({left:e.dom.getBoundingClientRect().left+2,top:t});if(!o)return;let s=e.state.doc,r=ht(s),i=Math.min(s.resolve(o.inside>=0?o.inside:o.pos).index(0),r.length-1);for(;i>0&&r[i].hidden;)i--;this.hover=i}setHover(t){t!==this.hover&&(this.hover=t,this.scheduleLayout())}settleHover(){if(!this.pendingHover)return;let{clientY:t}=this.pendingHover;this.pendingHover=null,this.hoverAt(t)}fromPlus(){this.view.focus();let t=this.gutterIndex();this.openMenu("insert",this.plus,null,null,this.view.state.doc.child(t).attrs.id)}toggleMenu(t,e){this.menu?this.closeMenu():this.openMenu(t,e)}openMenu(t,e,o=null,s=null,r=null){this.menu={mode:t,anchor:e,slashAt:o,anchorId:r,ids:s??(t==="insert"?[]:this.selectionIds()),query:"",active:0,items:[]},e.setAttribute("aria-expanded","true"),o!==null?(this.priorAria||(this.priorAria=mn.map(i=>[i,this.view.dom.getAttribute(i)])),this.view.dom.setAttribute("aria-haspopup","listbox")):this.view.dom.setAttribute("aria-haspopup","menu"),this.view.dom.setAttribute("aria-controls",this.menuId),this.renderMenu()}closeMenu(){if(this.menu?.anchor.setAttribute("aria-expanded","false"),this.menu=null,this.menuEl.hidden=!0,this.scrim.hidden=!0,this.priorAria){for(let[t,e]of this.priorAria)e===null?this.view.dom.removeAttribute(t):this.view.dom.setAttribute(t,e);this.priorAria=null}else for(let t of mn)this.view.dom.removeAttribute(t)}moreItems(){let t=oe.filter(([o])=>!En.has(o)).map(([o,s])=>({key:o,label:s,icon:ot[o],run:r=>bn(r,o)})),e=Tn.filter(o=>Ho.has(o.key)).map(o=>({...o,blocks:!0}));return[...t,{key:"underline",label:"Underline",icon:"U",hint:`${At}u`,run:(o,s)=>se(o,s,"underline")},{key:"text_color",label:"Text color",icon:"A",hint:"\u203A",run:(o,s)=>se(o,s,"text_color")},{key:"highlight",label:"Highlight",icon:"\u25A0",hint:"\u203A",run:(o,s)=>se(o,s,"highlight")},{key:"turn",label:"Turn into",icon:"\u21BB",run:(o,s)=>s.openMenu("turn",s.more)},{key:"insert",label:"Insert",icon:"+",run:(o,s)=>s.openMenu("insert",s.more,null,null,o.state.doc.child(s.blockIndex()).attrs.id)},...e]}menuItems(t){if(t.mode==="external")return t.externalItems||[];if(t.mode==="actions")return zo(this.view.state);if(t.mode==="more")return this.moreItems();let e=t.mode==="turn"?z:ln(this.view.state,this.onAiTool?[...St,{key:"ai",label:"Make a tool with AI\u2026",icon:"\u2726",aliases:["tool","generate"],insert:"ai"}]:St);return un(e,t.query)}currentTypes(){let t=this.view.state;return new Set(st(t).map(e=>Tt(t.doc.child(e)).key))}openActions(t=this.plus,e=null){let o=this.view.state,s=ht(o.doc),r=o.selection,i=e!==null&&r instanceof B&&r.span(o.doc).lo<=e&&e<=r.span(o.doc).hi,{lo:l,hi:u}=e===null||i?ze(o,s):De(s,e,e);this.view.dispatch(o.tr.setSelection(Rt(o.doc,l,u,s)));let p=[];for(let a=l;a<=u;a++)p.push(o.doc.child(a).attrs.id);this.openMenu("actions",t,null,p)}renderMenu(){let t=this.menu;t.items=this.menuItems(t),t.active=Math.min(t.active,Math.max(0,t.items.length-1));let e=t.slashAt!==null,o=t.mode==="turn"?this.currentTypes():null;this.menuEl.setAttribute("role",e?"listbox":"menu");let s=[];if(t.mode==="turn"){let r=T("div","page-menu-title");r.textContent=t.query?`Turn into \u201C${t.query}\u201D`:"Turn into",s.push(r)}if(!t.items.length){let r=T("div","page-menu-empty");r.textContent="No matching blocks",s.push(r)}t.items.forEach((r,i)=>{let l=i===t.active,u=o?o.size===1&&r.key===[...o][0]:typeof r.checked=="boolean"?r.checked:null,p=t.mode==="turn"?"menuitemradio":typeof u=="boolean"?"menuitemcheckbox":e?"option":"menuitem",a=T("button",`page-menu-item${l?" is-active":""}`,{type:"button",role:p,tabindex:!e&&l?"0":"-1",id:`${this.menuId}-${i}`,"data-index":String(i),...p==="menuitemradio"?{}:{"aria-selected":l?"true":"false"},...typeof u=="boolean"?{"aria-checked":String(u)}:{}}),c=T("span","page-menu-icon");c.textContent=r.icon||"";let d=T("span","page-menu-label");if(d.textContent=r.label,r.description){let h=T("span","page-menu-text"),f=T("span","page-menu-desc");f.textContent=r.description,h.append(d,f),a.append(c,h)}else a.append(c,d);if(r.hint){let h=T("span","page-menu-hint");h.textContent=r.hint,a.append(h)}s.push(a)}),this.menuEl.replaceChildren(...s),e&&t.items.length?this.view.dom.setAttribute("aria-activedescendant",`${this.menuId}-${t.active}`):this.view.dom.removeAttribute("aria-activedescendant"),this.menuEl.hidden=!1,this.scrim.hidden=!1,this.scheduleLayout(),e||this.menuEl.querySelectorAll("button")[t.active]?.focus()}pick(t){let e=this.menu,o=e?.items[t];if(!o)return;let s=this.view.state,r=e.slashAt!==null&&s.selection.head>=e.slashAt?{from:e.slashAt-1,to:s.selection.head}:null,i=e.mode==="insert"?e.anchorId?[e.anchorId]:[]:e.ids,l=i.some(p=>!p||this.idIndex(p)<0),u=i.length?this.idIndex(i[0]):-1;if(this.closeMenu(),l&&e.mode!=="external"){j(this.view,Bo),this.view.focus();return}if(e.mode==="turn"){if(i.some(a=>!nt(s.doc.child(this.idIndex(a)),o))){j(this.view,ie),this.view.focus();return}let p=()=>{let a=this.view.state.tr;for(let c of i){let d=this.idIndex(c);d>=0&&q(a,d,o)}return a.docChanged&&this.view.dispatch(k(a).scrollIntoView()),!0};if(o.type==="quote"){let a=this.view;import("./c-DFS4XZJV.js").then(c=>c.gateTurn(a,p))}else p();this.view.focus()}else e.mode==="actions"||e.mode==="more"||e.mode==="external"?(o.blocks&&this.selectCaretBlock(i),o.run(this.view,this,u>=0?u:this.blockIndex()),!this.menu&&o.focus!==!1&&this.view.focus()):o.insert==="ai"?this.onAiTool(this.view,r):dn(this.view,o,u>=0?u:this.blockIndex(),r)}key(t){if(Ct(t,this.view))return!1;let e=this.menu;if(!e)return t.key==="Escape"&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&this.view.state.selection instanceof B&&this.leaveToToolbar(),!1;if((t.key==="Backspace"||t.key==="Delete")&&e.mode==="actions"&&this.view.state.selection instanceof B)return this.closeMenu(),this.view.focus(),Pt(this.view.state,this.view.dispatch),!0;if(t.key==="ArrowDown"||t.key==="ArrowUp")return e.items.length&&(e.active=(e.active+(t.key==="ArrowDown"?1:-1)+e.items.length)%e.items.length,this.renderMenu()),!0;if(t.key==="Enter")return e.items.length&&this.pick(e.active),!0;if(t.key==="Escape"){let o=this.invoker();return this.closeMenu(),o===this.view.dom?this.view.focus():o?.focus?.(),!0}return!1}slashQuery(){let t=this.menu;if(!t||t.slashAt===null)return;let{$head:e}=this.view.state.selection,o=e.start();if(e.pos<t.slashAt||t.slashAt<o||this.view.state.doc.textBetween(t.slashAt-1,t.slashAt)!=="/")return this.closeMenu();if(t.query=this.view.state.doc.textBetween(t.slashAt,e.pos),t.active=0,/\s$/.test(t.query)&&!this.menuItems(t).length)return this.closeMenu();this.renderMenu()}scheduleLayout(){this.frame!==null||this.destroyed||(this.frame=this.win.requestAnimationFrame(()=>{if(this.frame=null,this.destroyed)return;let t=this.measureLayout();this.paintLayout(t)}))}safeBottom(){return this.probe||(this.probe=T("div","page-safe-probe"),this.shell.append(this.probe)),parseFloat(this.win.getComputedStyle(this.probe).paddingBottom)||0}menuBox(t){let e=gn(this.win),o=Math.max(0,e.height-W*2),s=Math.min(280,Math.max(0,e.width-W*2)),r=this.menuEl.style.getPropertyValue("--page-pop-max");this.menuEl.style.removeProperty("--page-pop-max");let i=this.menuEl.offsetHeight||0;r&&this.menuEl.style.setProperty("--page-pop-max",r);let l=Math.min(i,o),u=Math.max(e.left+W,Math.min(t.left,e.left+e.width-W-s)),p=t.top-6-l;return p<e.top+W&&(p=Math.min(t.top+t.height+6,e.top+e.height-W-l)),{left:u,top:p,width:s,maxHeight:o}}measureLayout(){let t=this.view,e=t.state;this.settleHover();let o=this.shell.getBoundingClientRect(),s=t.dom.getBoundingClientRect(),r=this.gutterIndex(),i=0;for(let c=0;c<r;c++)i+=e.doc.child(c).nodeSize;let l=t.nodeDOM(i),u={textLeft:s.left-o.left,gutter:null,bubble:null,menu:null,bar:null,desk:!1};if(l&&l.getBoundingClientRect){let c=l.getBoundingClientRect(),d=parseFloat(getComputedStyle(l).lineHeight)||c.height;u.gutter={top:c.top-o.top+Math.min(c.height,d)/2,left:c.left-o.left}}let p=this.isPhone();if(p){let c=gn(this.win),d=this.dock.offsetHeight||Ko;u.bar={...Ro(c,this.dock.offsetWidth||Fo,d,this.safeBottom()),height:d}}else u.desk=!!this.dock.style.left;let a=e.selection;if(!this.bubble.hidden&&!p){let c=t.coordsAtPos(a.from),d=t.coordsAtPos(a.to,-1),h=(Math.min(c.left,d.left)+Math.max(c.right,d.right))/2;u.bubble={x:h-o.left,y:Math.min(c.top,d.top)-o.top}}if(this.menu&&p){let c=this.menuBox(u.bar);u.menu={x:c.left,y:c.top,width:c.width,maxHeight:c.maxHeight}}else if(this.menu){let c=this.menu,d,h;if(c.slashAt!==null){let f=t.coordsAtPos(c.slashAt-1);d=f.left,h=f.bottom+6;let m=this.menuEl.offsetHeight;h+m>this.win.innerHeight-8&&f.top-6-m>=8&&(h=f.top-6-m)}else{let f=c.anchor===this.plus?l?.getBoundingClientRect?.()??s:c.anchor.getBoundingClientRect();d=f.left,h=f.bottom+6}u.menu={x:Math.max(8,Math.min(d-o.left,o.width-280)),y:h-o.top}}return u}paintLayout(t){if(t.bar)this.dock.style.left=`${t.bar.left}px`,this.dock.style.top=`${t.bar.top}px`,this.dock.style.width=`${t.bar.width}px`,this.grip.style.setProperty("--page-grip-lift",`${t.bar.height}px`);else{if(t.desk)for(let e of["left","top","width"])this.dock.style.removeProperty(e);this.grip.style.removeProperty("--page-grip-lift")}if(t.gutter)for(let e of[this.plus,this.grip])e.style.setProperty("--page-plus-top",`${t.gutter.top}px`),e.style.setProperty("--page-plus-left",`${t.gutter.left}px`);this.plus.style.setProperty("--page-text-left",`${t.textLeft}px`),t.bubble&&(this.bubble.style.setProperty("--page-pop-x",`${t.bubble.x}px`),this.bubble.style.setProperty("--page-pop-y",`${t.bubble.y}px`)),t.menu&&(this.menuEl.style.setProperty("--page-pop-x",`${t.menu.x}px`),this.menuEl.style.setProperty("--page-pop-y",`${t.menu.y}px`),t.menu.width!==void 0&&(this.menuEl.style.setProperty("--page-pop-width",`${t.menu.width}px`),this.menuEl.style.setProperty("--page-pop-max",`${t.menu.maxHeight}px`)))}update(t,e){if(this.view=t,this.menu&&this.menu.slashAt===null&&e&&e.doc!==t.state.doc){let i=this.menuEl.contains(document.activeElement);this.closeMenu(),i&&t.focus()}let o=t.state,s=o.doc.child(this.blockIndex());this.turn.textContent=`${Tt(s).label} \u25BE`;for(let i of this.dock.querySelectorAll("[data-cmd]"))i.setAttribute("aria-pressed",String(yn(o,i.dataset.cmd)));let r=!o.selection.empty&&o.selection instanceof vt&&t.hasFocus();if(this.bubble.hidden=!r,r)for(let i of this.bubble.querySelectorAll("[data-cmd]"))i.setAttribute("aria-pressed",String(yn(o,i.dataset.cmd)));this.grip.classList.toggle("is-on",o.selection instanceof B),this.inRoving(this.roving)||this.setRoving(this.dockControls()[0]),this.slashQuery(),this.scheduleLayout()}destroy(){this.destroyed=!0,this.frame!==null&&this.win.cancelAnimationFrame(this.frame),this.frame=null,clearTimeout(this.movedTimer),this.drag.destroy(),this.shell.removeEventListener("mousemove",this.onMove),this.shell.removeEventListener("mouseleave",this.onLeave),this.shell.removeEventListener("keydown",this.onKey),this.win.removeEventListener("resize",this.onResize),this.win.removeEventListener("scroll",this.onResize,!0),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onResize),document.removeEventListener("mousedown",this.onDocDown,!0);for(let t of[this.dock,this.plus,this.grip,this.bubble,this.scrim,this.menuEl,this.probe])t?.remove()}};function Ai({onAiTool:n=null}={}){let t=null;return new xn({key:Qo,view(e){return t=new re(e,n),$n.set(e,t),t},props:{handleKeyDown(e,o){return t?o.key==="/"&&(o.metaKey||o.ctrlKey)&&!o.altKey&&!t.menu?(o.preventDefault(),t.openActions(),!0):t.key(o):!1},handleTextInput(e,o,s,r){if(r!=="/"||!t)return!1;let i=Fe(e,r);i&&(o=e.state.selection.from-1);let l=e.state.doc.resolve(o);if(l.depth!==1||!l.parent.isTextblock||l.parent.type.spec.code||l.parentOffset>0&&!/\s/.test(e.state.doc.textBetween(o-1,o,"",`
|
|
6
|
+
`)))return i;i||e.dispatch(e.state.tr.insertText("/",o,s).setMeta(bt,Ft(e.state,o,s,"/")));let u=Math.min(e.state.doc.resolve(o).index(0),e.state.doc.childCount-1);return t.openMenu("insert",t.plus,o+1,null,e.state.doc.child(u).attrs.id),!0},handleDOMEvents:{keydown(e,o){return Ct(o,e)},blur(e){return t&&(t.bubble.hidden=!0),!1}}}})}var{Plugin:Zo}=E,ce=new WeakMap,ts=n=>typeof n.text=="function"?n.text():new Promise((t,e)=>{let o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>e(o.error),o.readAsText(n)});function $t(n,t){let e=n.dom.ownerDocument,o=n.dom.parentElement.querySelector(".page-csv-error");o||(o=e.createElement("div"),o.className="page-csv-error",o.setAttribute("role","alert"),n.dom.parentElement.append(o)),o.textContent=t}function es(n){let t=0,e=be(n,{maxBytes:qt,newId:()=>b(t++<n.header.length?"c":"r")});if(!Object.keys(e.cols).length)return null;if(!Object.keys(e.rows).length){let o=Object.fromEntries(Object.keys(e.cols).map(s=>[s,""]));e.rows[b("r")]={pos:C(),cells:o}}return{node:U(g,b(),{t:"table",pos:null,cols:e.cols,rows:e.rows}),truncated:e.truncated}}async function ns({kept:n,total:t}){let e=`This file has ${t} rows. The first ${n} fit in a table.`,o=globalThis.clay?.confirm,s=globalThis.clay?.modal;o||(o=(await import("./c-DNENWY4O.js")).consent,s=(await import("./c-RM7J7BV2.js")).default);let r=o(e);s&&(s.yes=`Insert first ${n} rows and attach the file`);try{return await r,!0}catch{return!1}}var os=(n,t)=>{let e=-1;return n.forEach((o,s,r)=>{e<0&&o.type===g.nodes.table&&o.attrs.id===t&&(e=r)}),e},ss=n=>{let t=!0;return n.descendants(e=>(e.isText&&(t=!1),t)),t};function rs(n,t,e,o){let s=n.state,r=os(s.doc,e);if(r<0)return R(s,n.dispatch,t,null,o);let i=0;for(let a=0;a<r;a++)i+=s.doc.child(a).nodeSize;let l=s.doc.child(r);if(!ss(l)||o){let a=s.doc.maybeChild(r+1),c=l.attrs.parent??null,d=C(l.attrs.pos,a?.attrs.pos??null),h=t.type.create({...t.attrs,pos:d,parent:c},t.content),f=i+l.nodeSize,m=s.tr.insert(f,h);return o&&m.insert(f+h.nodeSize,o.type.create({...o.attrs,pos:C(d,a?.attrs.pos??null),parent:c},o.content)),m.setSelection(E.TextSelection.create(m.doc,f+3)),n.dispatch(k(m).scrollIntoView()),!0}let u=t.type.create({...t.attrs,id:l.attrs.id,pos:l.attrs.pos,parent:l.attrs.parent},t.content),p=s.tr.replaceWith(i,i+l.nodeSize,u);return p.setSelection(E.TextSelection.create(p.doc,i+3)),n.dispatch(k(p).scrollIntoView()),!0}async function le(n,t,{upload:e,remove:o=null,table:s=null}={}){try{n.dom.parentElement.querySelector(".page-csv-error")?.remove();let r=at(await ts(t)),i=es(r);if(!i)return $t(n,"Couldn't read this CSV: no columns."),!1;let l=null;if(i.truncated){if(!await ns(i.truncated))return!1;let a=await e?.(t),c=de(a?.uploads?.[0]?.url);if(!a?.ok||!c)return $t(n,"Couldn't attach the original CSV."),!1;l=g.nodes.file.create({id:b(),src:c,name:t.name,size:t.size??null,mime:t.type||"text/csv"})}if(n.isDestroyed)return!1;if(s)return rs(n,i.node,s,l);let u=o?Ln(n.state):null;return o&&!u&&ls(n,o.block),R(n.state,n.dispatch,i.node,u,l)}catch(r){return r instanceof me?$t(n,`Couldn't read this CSV: unclosed quote on line ${r.line}.`):$t(n,"Couldn't read this CSV."),!1}}function Mt(n,t=null,e=null){let o=ce.get(n);return o?(t&&In(n,t),o._remove=t?{...t,block:is(n.state.doc,t.from)}:null,o._table=e,o.click(),!0):!1}var is=(n,t)=>n.child(n.resolve(Math.max(0,Math.min(t,n.content.size))).index(0)).attrs.id;function ls(n,t){let e=n.state,o=null;return e.doc.forEach((s,r)=>{o===null&&s.attrs.id===t&&(o=r)}),o===null?!1:(n.dispatch(e.tr.setSelection(E.TextSelection.near(e.doc.resolve(o)))),!0)}var Dn=n=>[...n].filter(t=>/\.csv$/i.test(t.name||"")||/^(text\/csv|application\/csv)$/i.test(t.type||""));function zi({upload:n}){return new Zo({view(t){let e=t.dom.ownerDocument.createElement("input");return e.type="file",e.accept=".csv,text/csv",e.hidden=!0,e.className="page-csv-input",t.dom.parentElement.append(e),ce.set(t,e),e.addEventListener("change",()=>{let o=e.files?.[0];o&&le(t,o,{upload:n,remove:e._remove,table:e._table}),e._remove=null,e._table=null,e.value=""}),{destroy(){ce.delete(t),e.remove()}}},props:{handlePaste(t,e){let o=Dn(e.clipboardData?.files||[]);return o.length?(e.preventDefault(),le(t,o[0],{upload:n}),!0):!1},handleDrop(t,e,o,s){let r=Dn(e.dataTransfer?.files||[]);if(s||!r.length)return!1;e.preventDefault();let i=t.posAtCoords({left:e.clientX,top:e.clientY});return i&&t.dispatch(t.state.tr.setSelection(E.TextSelection.near(t.state.doc.resolve(i.pos)))),le(t,r[0],{upload:n}),!0}}})}export{ks as a,vs as b,je as c,us as d,ds as e,zi as f,sn as g,Qt as h,Ls as i,Ds as j,Bs as k,Ct as l,ri as m,ii as n,li as o,Ci as p,In as q,Ln as r,Oi as s,Ai as t,Xs as u,Zs as v,Xe as w,lo as x,mr as y,gr as z,yr as A,br as B,kr as C,co as D,ao as E,xr as F,wr as G,Mr as H,Sr as I,Tr as J,Er as K,Cr as L,Or as M,Ar as N};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as h}from"./c-
|
|
1
|
+
import{a as h}from"./c-KAU6E43D.js";import"./c-2SPVQSHC.js";import"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var A=`.clay-upload {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-wrap: wrap;
|
|
4
4
|
align-items: center;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f}from"./c-74MGYWZF.js";import"./c-N326R2JD.js";import"./c-2SPVQSHC.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.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,3 @@
|
|
|
1
|
+
import{D as Ve,E as Be,F as Se,G as te,H as xe,P as $t,R as Kt,S as _e,T as Nt,a as Ct,b as jt,c as Et,d as ot,e as Yt,f as st,g as Re,h as we,i as ve,j as Te,o as Oe,q as Mt,r as Ie,t as X,u as rt,v as ie,w as De,y as pe}from"./c-6CRUUXOX.js";import{$ as xt,_ as St,da as nt,ha as At,la as ce,m as G,x as It}from"./c-WWXIDH4O.js";import{a as be,b as Ot,c as W,d as Ne}from"./c-5V3MOVJT.js";var Je="page-origins",wn="page-undo-overlap-repair",Rt=(e,t)=>JSON.stringify(["span",e,t]),lt=(e,t)=>JSON.stringify(["alias",e,t]),Tt=(e,t)=>JSON.stringify(["boundary",e,t]),vn=["copy","removed","restore"],Dt=/^(?:0|[1-9]\d*)$/,fe=(e,t)=>`${e}.${t}`,_=e=>Number.isSafeInteger(e)&&e>=0,On=e=>Number.isSafeInteger(e)&&e>0,In=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Fe=e=>new Error(`Conflicting immutable origin record: ${e}`),Sn=e=>{if(typeof e!="string")return!1;let t=e.indexOf(".");if(t<1||t===e.length-1)return!1;let o=e.slice(0,t),s=e.slice(t+1);return Dt.test(o)&&Dt.test(s)&&_(Number(o))&&_(Number(s))},ct=e=>{if(!In(e))return null;for(let t of Object.keys(e))if(t!=="blockId"&&t!=="kind"&&t!=="recoveryOf")return null;return typeof e.blockId!="string"||!e.blockId||!vn.includes(e.kind)||e.recoveryOf!==void 0&&!Sn(e.recoveryOf)?null:e.recoveryOf===void 0?{blockId:e.blockId,kind:e.kind}:{blockId:e.blockId,kind:e.kind,recoveryOf:e.recoveryOf}},xn=(e,t)=>e.blockId===t.blockId&&e.kind===t.kind&&e.recoveryOf===t.recoveryOf,An=e=>{if(typeof e!="string"||e.charCodeAt(0)!==91)return null;let t;try{t=JSON.parse(e)}catch{return null}return!Array.isArray(t)||t.length!==3||t[0]!=="span"&&t[0]!=="alias"&&t[0]!=="boundary"?null:_(t[1])&&_(t[2])?t:null};function Ae(e){let t=new Map,o=new Map,s=new Map,c=(f,d)=>{let b=0,w=f.length;for(;b<w;){let I=b+w>>1;f[I].clock<d?b=I+1:w=I}return b},r=(f,d)=>{let b=An(f);if(!b)return;let[w,I,j]=b;if(w==="alias"){d&&_(d.sourceClient)&&_(d.sourceClock)?o.set(fe(I,j),{client:d.sourceClient,clock:d.sourceClock}):o.delete(fe(I,j));return}if(w==="boundary"){let S=ct(d);S?s.set(fe(I,j),S):s.delete(fe(I,j));return}let M=t.get(I)??[],R=c(M,j);M[R]?.clock===j&&M.splice(R,1),d&&On(d.length)&&_(d.sourceClient)&&_(d.sourceClock)&&M.splice(c(M,j),0,{client:I,clock:j,length:d.length,sourceClient:d.sourceClient,sourceClock:d.sourceClock}),M.length?t.set(I,M):t.delete(I)};for(let[f,d]of e)r(f,d);let a=f=>{for(let d of f.keysChanged)r(d,e.get(d))};e.observe(a);let m=f=>{let d=o.get(fe(f.client,f.clock));if(d)return{client:d.client,clock:d.clock};let b=t.get(f.client);if(!b)return{client:f.client,clock:f.clock};let w=0,I=b.length-1,j=-1;for(;w<=I;){let S=w+I>>1;b[S].clock<=f.clock?(j=S,w=S+1):I=S-1}if(j<0)return{client:f.client,clock:f.clock};let M=b[j],R=f.clock-M.clock;return R>=M.length?{client:f.client,clock:f.clock}:{client:M.sourceClient,clock:M.sourceClock+R}},v=f=>{if(!f||!_(f.client)||!_(f.clock))return null;let d=fe(f.client,f.clock),b=new Set;for(;!b.has(d);){b.add(d);let I=o.get(d);if(!I)break;d=fe(I.client,I.clock)}if(b.has(d)&&o.has(d))return null;let w=s.get(d);return w?{...w}:null},p=(f,d,b)=>{let w=Rt(f,d),I=e.get(w);if(I!==void 0&&(I.length!==b.length||I.sourceClient!==b.sourceClient||I.sourceClock!==b.sourceClock))throw Fe(w);let j=t.get(f)??[],M=c(j,d);for(let R of[j[M-1],j[M]])if(R&&R.clock!==d&&R.clock<d+b.length&&d<R.clock+R.length)throw Fe(w);I===void 0&&e.set(w,b)};return{origins:e,resolve:m,recordSpans:f=>{let d=[],b=()=>{if(!d.length)return;let w=d[0],I={length:d.length,sourceClient:w.source.client,sourceClock:w.source.clock};if(!_(I.sourceClock+I.length-1))throw new Error(`Unsafe origin span: ${Rt(w.dest.client,w.dest.clock)}`);p(w.dest.client,w.dest.clock,I),d.length=0};for(let w of f){if(!w?.dest||!w?.source)throw new Error("Invalid origin destination");let I=w.dest,j=w.source;if(!_(I.client)||!_(I.clock)||!_(j.client)||!_(j.clock))throw new Error("Invalid origin destination");let M=m(j),R=d[d.length-1];R&&R.dest.client===I.client&&R.dest.clock+1===I.clock&&R.source.client===M.client&&R.source.clock+1===M.clock?d.push({dest:I,source:M}):(b(),d.push({dest:I,source:M}))}b()},recordAlias:(f,d)=>{if(!f||!d||!_(f.client)||!_(f.clock)||!_(d.client)||!_(d.clock))throw new Error("Invalid origin destination");let b=m(d),w=lt(f.client,f.clock),I=e.get(w);if(I!==void 0&&(I.sourceClient!==b.client||I.sourceClock!==b.clock))throw Fe(w);I===void 0&&e.set(w,{sourceClient:b.client,sourceClock:b.clock})},recordBoundary:(f,d)=>{if(!f||!_(f.client)||!_(f.clock))throw new Error("Invalid origin destination");let b=ct(d);if(!b)throw new Error(`Invalid boundary record: ${Tt(f.client,f.clock)}`);let w=Tt(f.client,f.clock),I=e.get(w);if(I===void 0){e.set(w,b);return}let j=ct(I);if(!j||!xn(j,b))throw Fe(w)},boundaryOf:v,get size(){return e.size},dispose(){e.unobserve(a)}}}function ho(e,t,o){let s=[],c=0;for(let r=e._start;r&&c<o;r=r.right){if(r.deleted||!r.countable)continue;let a=c;if(c+=r.length,c<=t)continue;let m=Math.max(0,t-a),v=Math.min(r.length,o-a);for(let p=m;p<v;p++)s.push({client:r.id.client,clock:r.id.clock+p})}return s}var Cn=(e,t,o)=>e.some(s=>s.actor===t||s.client!==o.client||o.clock<s.clock||o.clock>=s.clock+s.length?!1:s.sv.some(([c,r])=>c===o.client&&r>o.clock)),jn=(e,t)=>{let o=0;for(let s=e._start;s;s=s.right)if(!(s.deleted||!s.countable)){if(s.id.client===t.client&&s.id.clock<=t.clock&&t.clock<s.id.clock+s.length)return o+t.clock-s.id.clock;o+=s.length}return null},En=(e,t)=>{let o=[];for(let c of t){let r=jn(e.flow,c);r!==null&&o.push(r)}o.sort((c,r)=>c-r);let s=[];for(let c of o){let r=s[s.length-1];r&&c<=r[1]?r[1]=Math.max(r[1],c+1):s.push([c,c+1])}for(let c=s.length-1;c>=0;c--){let[r,a]=s[c];a>r&&e.flow.delete(r,a-r)}};function mo(e,t,o=Ae(e.origins),s=()=>[]){let c=r=>{if(r.origin!==t||!t.currStackItem)return;let a=[],m=[],v=[],p=s(e.gone);Et(r,t.currStackItem.deletions,u=>{if(!(u instanceof De)||u.parent!==e.flow||!u.countable||!u.redone)return;let h=u.content instanceof X&&u.content.embed?.b!==void 0;for(let g=0;g<u.length;g++){let f={client:u.id.client,clock:u.id.clock+g},d=o.resolve(f),b={client:u.redone.client,clock:u.redone.clock+g},w=Oe(e.ydoc.store,b);for(;w instanceof De&&w.redone;)b={client:w.redone.client,clock:w.redone.clock+b.clock-w.id.clock},w=Oe(e.ydoc.store,b);if(!(!(w instanceof De)||w.deleted)&&!(b.clock<(r.beforeState.get(b.client)??0))){if(!h&&Cn(p,e.ydoc.clientID,f)){v.push(b);continue}(h?m:a).push({dest:b,source:d})}}}),(a.length||m.length)&&e.ydoc.transact(()=>{a.length&&o.recordSpans(a);for(let u of m)o.recordAlias(u.dest,u.source)},Je),v.length&&e.ydoc.transact(()=>En(e,v),wn)};return e.ydoc.on("beforeObserverCalls",c),()=>e.ydoc.off("beforeObserverCalls",c)}var at=e=>Ct(e),le=e=>jt(e),Ue=12*1024,Yn="page-recovery",Le=e=>be.exec(e)?.[1]??e;function So(e){return{v:1,g:0,y:{seed:at(we(e))}}}var L=class extends Error{constructor(t,o){super(o),this.name="YDecodeError",this.code=t}};function Mn(e){if(e?.v!==1||!e.y||typeof e.y!="object"||Array.isArray(e.y))throw new L("invalid-value","Expected a version 1 Yjs page value");let t=new Map,o=new Set;for(let[s,c]of Object.entries(e.y)){if(typeof c!="string")throw new L("invalid-update",`Invalid Yjs update: ${s}`);let r=be.exec(s);if(!r){o.add(s);continue}let a=Number(r[2]),m=Number(r[3]);if(!Number.isSafeInteger(a)||!Number.isSafeInteger(m)||m<1||a>=m)throw new L("invalid-update",`Invalid Yjs update part: ${s}`);let v=t.get(r[1])??{count:m,indices:new Set};if(v.count!==m||v.indices.has(a))throw new L("invalid-update",`Conflicting Yjs update parts: ${r[1]}`);v.indices.add(a),t.set(r[1],v)}for(let[s,c]of t){if(o.has(s))throw new L("invalid-update",`Conflicting Yjs update forms: ${s}`);if(c.indices.size!==c.count)throw new L("incomplete-update",`Incomplete Yjs update: ${s}`)}return W(e.y)}function Bt(e,{strict:t=!1}={}){let o=t?Mn(e):W(e.y),s=new st;try{for(let[c,r]of o){let a=t?r.replace(/[\t\n\f\r ]/g,""):r;if(t&&!Ot.test(a))throw new L("invalid-update",`Invalid base64 in Yjs update: ${c}`);Re(s,le(a),pe)}if(t&&(s.store.pendingStructs||s.store.pendingDs))throw new L("unresolved-update","Yjs page updates have missing prerequisites");return s}catch(c){throw s.destroy(),t&&!(c instanceof L)?new L("invalid-update",`Invalid Yjs page update: ${c.message}`):c}}var Vt=typeof TextEncoder=="function"?new TextEncoder:null,$n=e=>Vt?Vt.encode(e).length:e.length*2,Kn=(e,t)=>Yt(ot(e.store),ot(t.store)),Nn=(e,t)=>{if(e.size!==t.size)return!1;for(let[o,s]of e)if(t.get(o)!==s)return!1;return!0};function xo({store:e,ydoc:t,compact:o={},setTimer:s=setTimeout,clearTimer:c=clearTimeout,onStopped:r=()=>{},stats:a={applied:0,offered:0,compactions:0},journal:m=null}){let v=W(e.value.y),p=new Set,u=null,h=y=>{u||(u=y,r(y))},g=!v.some(([y])=>y[0]==="m"),f=0,d=t.clientID.toString(36),b=y=>`${y}${d}-${(f++).toString(36)}`,w=null,I=e.value.g,j=new Set,M=(y,k)=>{if(k.length<=Ue)return[[y,k]];let x=Math.ceil(k.length/Ue);return Array.from({length:x},(n,l)=>[`${y}.${l}.${x}`,k.slice(l*Ue,(l+1)*Ue)])},R=(y,k)=>{g=!0,p.add(y),j.add(y);let x=M(y,at(k));e.handle.update(n=>{for(let[l,i]of x)n.y[l]=i})};for(let[y]of v)p.add(y);let S=(y,k)=>{k!==pe&&k!==Je&&k!==Yn&&m?.local(y),!(u||k===pe||k===Je)&&R(b("u"),y)};t.on("updateV2",S);let E=(y,k)=>{if(u||p.has(y))return;g=!0,p.add(y),a.applied++;let x=le(k);Re(t,x,pe),m?.dependency(x)},V=!1,B=!1,q=(y,k)=>{V||=y,B||=k,!w&&(w=s(()=>{w=null,V&&oe(),H()},0))},ne=()=>{oe(),H()};function oe(){if(u)return!1;let y=e.value.y,k=new st;for(let[,O]of W(y))Re(k,le(O),pe);let x=Te(k),n=ve(Te(t)),l=ve(x);if(Nn(n,l)&&Kn(t,k))return k.destroy(),V=!1,B=!1,!1;let i=we(t,x);return k.destroy(),a.offered++,R(b("r"),i),V=!1,B=!1,!0}let Y={keys:32,room:3840*1024,...o},P=null,N=0,Ye=256,J=new Map,Me=y=>e.handle.update(k=>{for(let x of y)delete k.y[x]}),re=(y,k)=>Object.keys(y).filter(x=>k.has(Le(x))),de=(y,k)=>{let x=e.value.y??{};Me(k.filter(n=>n in x&&x[n]===y[n]))};function ee(){let y=e.authoritative.y??{},k=e.value.y??{};for(let i of j)i in k||j.delete(i);let x=P?[...P.parts.map(([i])=>i),...P.inputs.keys()]:[],n=new Set([...Object.keys(y),...j,...x]);for(let i of p)n.has(i)||p.delete(i);let l=new Map(W(y));for(let[i,O]of J)(!n.has(i)||l.get(i)!==O.value)&&J.delete(i)}function ge(y,k,x,n){let l=J.get(y);return l&&l.value!==k&&(J.delete(y),l=null),l||(J.size>=Ye&&J.delete(J.keys().next().value),l={value:k,folds:new Map},J.set(y,l)),l.folds.has(x)||l.folds.set(x,ft(n,le(k))),l.folds.get(x)}let $e=(y,k)=>{for(let[x,n]of k.held)if(y[x]!==void 0&&y[x]!==n)return!1;return!0},Qe=y=>{let k=le(y.merged);for(let[x,n]of y.inputs)if(n!==null&&!ge(x,n,y.key,k))return!1;return!0};function Ze(y){let k=P,x=Ne({v:1,y}).y,n=k.parts.filter(([l,i])=>y[l]===i&&x[l]===i);return n.length!==k.parts.length?e.pending.length?!1:(P=null,n.length&&de(y,n.map(([l])=>l)),N=W(y).length+Y.keys,ee(),!0):e.pending.length||!$e(y,k)||!Qe(k)?!1:(P=null,de(y,re(y,k.inputs)),ee(),!0)}function Ke(y,k,x){let n=k.filter(([$])=>$[0]==="m"),l=new Map(k),i=new Map(n),O=$=>{let F=i.get($);return typeof F=="string"&&i.set($,Ie([le(F)])),i.get($)},C=($,F,K)=>ge($,F,K,O(K)),A=new Set;for(let[$,F]of k)if(!(!x&&$[0]!=="m")){for(let[K]of n)if(!(K===$||A.has(K)||!C($,F,K))&&!($[0]==="m"&&$<K&&C(K,l.get(K),$))){A.add($);break}}return A.size?(de(y,re(y,A)),!0):!1}function H(){if(u||!g||e.value.g!==I)return!1;let y=e.authoritative.y;if(P)return Ze(y);let k=W(y),x=k.length>Math.max(Y.keys,N);if(!x&&k.filter(([K])=>K[0]==="m").length<2)return!1;if(Ke(y,k,x))return ee(),!0;if(!x)return!1;let n=at(Ie(k.map(([,K])=>le(K)))),l=b("m"),i=M(l,n),O={...e.value,y:{...e.value.y}};for(let[K,T]of i)O.y[K]=T;if($n(JSON.stringify(O))>Y.room)return N=k.length+Y.keys,!1;let C=Ne({v:1,y}).y,A=Object.keys(y).filter(K=>!(K in C)).map(Le).filter(K=>K[0]==="m"),$=new Map(k);for(let K of A)$.set(K,null);let F=new Map;for(let K of re(y,$))$.get(Le(K))!==null&&F.set(K,C[K]??y[K]);return P={key:l,parts:i,merged:n,inputs:$,held:F},p.add(l),e.handle.update(K=>{for(let[T,z]of i)K.y[T]=z}),a.compactions++,!0}let et=y=>{let k=new Set;for(let[,x]of W(y??{}))for(let n of ve(Mt(le(x))).keys())k.add(n);return k},ye=new Map(v),he=y=>{let k=et(y),x=[...ve(Te(t)).keys()];return!k.size||!x.length||x.some(n=>k.has(n))?!0:W(y??{}).some(([n,l])=>ye.get(n)===l)},me=e.onRebase(y=>{if(u)return;let k=y.source==="remote"&&y.frame?y.frame.ops:null,x=k&&k.every(n=>n.path[0]==="y"&&n.path.length===2&&!be.test(n.path[1]));if(!x&&y.cause!=="refused"&&!he(y.next.y)){h("lineage");return}if(x)for(let n of k)n.op==="set"&&E(n.path[1],n.value);else for(let[n,l]of W(y.next.y??{}))E(n,l);ee(),q(y.source!=="remote"||!k,y.source!=="remote")}),ke=e.onDelivery(y=>{if(y.phase!=="refused")return;if(y.code!=="too-large"||u){ee();return}h("too-large");let k=e.authoritative.y??{},x=Ne({v:1,y:k}).y,n=Object.keys(e.value.y??{}).filter(i=>!(i in k)),l=Object.keys(k).filter(i=>be.test(i)&&!(i in x)&&Le(i).slice(1).startsWith(`${d}-`));(n.length||l.length)&&Me([...n,...l]),ee()});return{known:p,stats:a,settle:ne,reconcile:oe,get reconcilePending(){return B},get stopped(){return u},_diagnostics:()=>({known:p.size,cover:J.size,fold:P?P.parts.length:0,generation:I}),compact:H,dispose(){me(),ke(),t.off("updateV2",S),w&&c(w)}}}var ut=class extends Error{constructor(t,o){super(o),this.name="PageProofError",this.code=t}},U=(e,t)=>{throw new ut(e,t)},_t=/^[0-9a-f]{64}$/,Ft=typeof TextEncoder=="function"?new TextEncoder:null,dt=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Jt=e=>typeof e=="string"?e:JSON.stringify(e),Rn=e=>Array.isArray(e)?[...e]:e,Tn=e=>({v:e.v,g:e.g,y:{...e.y??{}}}),Dn=(e,t)=>e.length===t.length&&e.every((o,s)=>o===t[s]);function ft(e,t,o=null){let s=o?.mergeUpdatesV2??Ie,c=s([e]);return Dn(c,s([c,t]))}async function Pe(e){let t=await globalThis.crypto.subtle.digest("SHA-256",e);return[...new Uint8Array(t)].map(o=>o.toString(16).padStart(2,"0")).join("")}function Ut(e){let t;try{t=Bt(e,{strict:!0})}catch(o){U("invalid-state",`The accepted page state does not decode: ${o.message}`)}try{return we(t)}finally{t.destroy()}}var Vn=(e,t)=>!!(e&&t)&&!!(e.host&&e.documentId&&e.principalId)&&e.host===t.host&&e.documentId===t.documentId&&e.principalId===t.principalId,Bn=(e,t)=>!!(e&&t)&&typeof e.generation=="string"&&!!e.generation&&e.generation===t.generation;async function Yo({capture:e,records:t=[],accepted:o,article:s,state:c,receipt:r,saved:a=!0}={}){let m=[];for(let p of t){(!p||p.id===void 0||typeof p.revision!="number")&&U("invalid-record","A proof names each record by id and revision");let u=dt(p.update);(!u||!u.length)&&U("invalid-record","A proof needs the bytes each record owns"),m.push({id:Rn(p.id),revision:p.revision,update:u.slice(),context:p.context??null})}typeof s!="string"&&U("missing-article","A proof names the final outgoing article");let v=Ut(c);return{saved:a===!0,capture:e,accepted:o,article:s,state:Tn(c),stateDigest:await Pe(v),articleDigest:await Pe(Ft.encode(s)),receipt:r,records:m}}async function _n(e){(!e||typeof e!="object"||Array.isArray(e))&&U("missing-proof","A page checkpoint needs a proof"),e.saved!==!0&&U("not-saved","Only a save that succeeded under admission makes a proof"),(typeof e.capture!="string"||!e.capture)&&U("missing-capture","A proof belongs to the capture it saved");let t=e.receipt;(!t||typeof t.file!="string"||!t.file||typeof t.pageState!="string"||!t.pageState)&&U("missing-receipt","A proof names the persisted file and page-state pair");let o=e.accepted;(!o||!o.authority||!o.lineage||typeof o.lineage.generation!="string"||!o.lineage.generation)&&U("missing-identity","A proof names the authority and generation it was saved under"),typeof e.article!="string"&&U("missing-article","A proof names the final outgoing article"),Array.isArray(e.records)||U("missing-records","A proof names the records it covers"),(typeof e.stateDigest!="string"||!_t.test(e.stateDigest))&&U("missing-digest","A proof carries the accepted state digest"),(typeof e.articleDigest!="string"||!_t.test(e.articleDigest))&&U("missing-digest","A proof carries the final article digest");let s=Ut(e.state);await Pe(s)!==e.stateDigest&&U("state-digest-mismatch","The page state is not the one the proof was made over"),await Pe(Ft.encode(e.article))!==e.articleDigest&&U("article-digest-mismatch","The article is not the one the proof was made over");let c=new Map;for(let r of e.records){(!r||r.id===void 0||typeof r.revision!="number")&&U("invalid-record","A proof names each record by id and revision");let a=dt(r.update);(!a||!a.length)&&U("invalid-record","A proof needs the bytes each record owns"),c.set(Jt(r.id),r)}return{stateBytes:s,entries:c,accepted:o}}function Fn(e,t){let o=t.context;if(!o||!Vn(o.authority,e.accepted.authority)||!Bn(o.lineage,e.accepted.lineage))return!1;let s=dt(t.update);return!!s&&s.length>0&&ft(e.stateBytes,s)}async function Mo(e,t=[]){let o=await _n(e);return(t||[]).filter(s=>{if(!s||s.id===void 0||typeof s.revision!="number")return!1;let c=o.entries.get(Jt(s.id));return!!c&&c.revision===s.revision&&Fn(o,c)})}var Lt=Object.freeze({row:Object.freeze(["alive","pos"]),col:Object.freeze(["alive","name","kind","width","pos"])}),zt=["name","kind","width","pos"],Jn=new Set(["kind","width"]),ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),pt=e=>typeof e=="string"&&e.length>0&&!["__proto__","constructor","prototype"].includes(e),Ce=e=>{throw new L("unsupported-content",`Unsupported table field: ${e}`)},Gt=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),se=(e,t,o,s)=>JSON.stringify([e,t,o,s]);function Un(e){if(typeof e=="string")return!0;if(!ue(e)||Object.keys(e).sort().join(",")!=="c,m"||typeof e.c!="string"||!Array.isArray(e.m)||!e.m.every(Array.isArray))return!1;let t=At(e.m,e.c.length);return t?t.every((o,s)=>{if(typeof o!="string")return!1;if(o.startsWith("@"))return o===xt&&e.c[s]===St;try{return It(G,o),!0}catch{return!1}}):!1}var Ln=(e,t)=>e==="alive"?typeof t=="boolean":e==="width"?t===null||typeof t=="number"&&Number.isFinite(t)&&t>0:e==="kind"&&t===null||typeof t=="string";function Pt(e,t){if(Object.keys(e).length)return;let[o]=Object.keys(t).sort((s,c)=>{let r=t[s].pos??"",a=t[c].pos??"";return r!==a?r<a?-1:1:s<c?-1:s>c?1:0});o&&(e[o]=t[o])}function qt(e,t=null,o=null){let s=new Map,c=new Map,r=new Map;for(let[u,h]of e){let g;try{g=JSON.parse(u)}catch{Ce(u)}(!Array.isArray(g)||g.length!==4)&&Ce(u);let[f,d,b,w]=g;if((!pt(f)||!pt(b))&&Ce(u),d==="cell"?(!pt(w)||!Un(h))&&Ce(u):(!Object.hasOwn(Lt,d)||!Lt[d].includes(w)||!Ln(w,h))&&Ce(u),f!==t)continue;if(d==="cell"){let M=r.get(b)??new Map;M.set(w,h),r.set(b,M);continue}let I=d==="row"?s:c,j=I.get(b)??{};j[w]=h,I.set(b,j)}let a={...ue(o?.cols)?o.cols:{}},m={...ue(o?.rows)?o.rows:{}},v={},p={};for(let[u,h]of c){let g=ue(a[u])?{...a[u]}:{};Object.hasOwn(g,"pos")||(g.pos=""),Object.hasOwn(g,"name")||(g.name="");for(let f of zt)Object.hasOwn(h,f)&&(h[f]===null?delete g[f]:g[f]=h[f]);if(h.alive===!1||!Object.hasOwn(a,u)&&h.alive!==!0){h.alive===!1&&(v[u]=g),delete a[u];continue}a[u]=g}for(let u of new Set([...s.keys(),...r.keys()])){let h=s.get(u)??{},g={pos:"",cells:{},...ue(m[u])?m[u]:{}};Object.hasOwn(h,"pos")&&(g.pos=h.pos);let f=r.get(u);if(f&&(g.cells={...ue(g.cells)?g.cells:{},...Object.fromEntries([...f].map(([d,b])=>[d,Gt(b)]))}),h.alive===!1||!Object.hasOwn(m,u)&&h.alive!==!0){h.alive===!1&&(p[u]=g),delete m[u];continue}m[u]=g}return Pt(a,v),Pt(m,p),{cols:a,rows:m}}var ze=(e,t)=>e?.[t]??(Jn.has(t)?null:"");function Pn(e,t,o,s,c){let r=[],a=(g,f)=>t.has(g)?t.get(g):f,m=(g,f)=>r.push([g,Gt(f)]),v=s?.cols??{},p=c?.cols??{},u=s?.rows??{},h=c?.rows??{};for(let g of new Set([...Object.keys(v),...Object.keys(p)])){let f=v[g],d=p[g];if(!d){f&&m(se(e,"col",g,"alive"),!1);continue}(!f||a(se(e,"col",g,"alive"),!0)===!1)&&m(se(e,"col",g,"alive"),!0);for(let b of zt){let w=se(e,"col",g,b),I=f?ze(f,b):a(w,ze(o?.cols?.[g],b));ce(I)!==ce(ze(d,b))&&m(w,ze(d,b))}}for(let g of new Set([...Object.keys(u),...Object.keys(h)])){let f=u[g],d=h[g];if(!d){f&&m(se(e,"row",g,"alive"),!1);continue}(!f||a(se(e,"row",g,"alive"),!0)===!1)&&m(se(e,"row",g,"alive"),!0);let b=se(e,"row",g,"pos"),w=d.pos??"";a(b,o?.rows?.[g]?.pos??"")!==w&&m(b,w);let I=ue(d.cells)?d.cells:{};for(let j of Object.keys(p)){let M=se(e,"cell",g,j),R=I[j]??"",S=f&&v[j]?f.cells?.[j]??"":a(M,o?.rows?.[g]?.cells?.[j]??"");ce(S)!==ce(R)&&m(M,R)}}return r}function zn(e,t){let o=e.attrs.get(t);return{cols:o?.get("cols")??{},rows:o?.get("rows")??{}}}function Bo(e,t,o,s){let c=zn(e,t);for(let[r,a]of Pn(t,e.tableFields,c,o,s))e.tableFields.set(r,a)}var yt=Object.freeze({column:Object.freeze(["alive","name","pos"]),card:Object.freeze(["alive","title","owner","due","placement"])}),Ht={column:new Set(yt.column),card:new Set(yt.card)},Gn=[["column","columns"],["card","cards"]],ht=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Wt=e=>typeof e=="string"&&e.length>0&&!["__proto__","constructor","prototype"].includes(e),Ge=e=>{throw new L("unsupported-content",`Unsupported board field: ${e}`)},qn=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),gt=(e,t,o,s)=>JSON.stringify([e,t,o,s]);function Qt(e,t){let o=new Map;for(let[s,c]of e){let r;try{r=JSON.parse(s)}catch{Ge(s)}(!Array.isArray(r)||r.length!==4)&&Ge(s);let[a,m,v,p]=r;if((!Wt(a)||!Wt(v)||!Object.hasOwn(Ht,m)||!Ht[m].has(p))&&Ge(s),(p==="alive"?typeof c!="boolean":p==="placement"?!ht(c)||Object.keys(c).sort().join(",")!=="columnId,pos"||typeof c.columnId!="string"||typeof c.pos!="string":p==="owner"||p==="due"?c!==null&&typeof c!="string":typeof c!="string")&&Ge(s),a!==t)continue;let u=o.get(m)??new Map,h=u.get(v)??{};h[p]=c,u.set(v,h),o.set(m,u)}return o}var Zt=e=>({pos:e.pos??"",name:e.name??""}),en=e=>({pos:e.placement?.pos??"",col:e.placement?.columnId??"",title:e.title??"",...e.owner!=null?{owner:e.owner}:{},...e.due!=null?{due:e.due}:{}}),qe=(e,t,o,s)=>Object.fromEntries([...e.get(t)??[]].filter(([,c])=>c.alive!==!1===s).map(([c,r])=>[c,o(r)]));function tn(e,t=null){let o=Qt(e,t),s=qe(o,"column",Zt,!0),c=qe(o,"card",en,!0),r=nt(s),a=[...new Set(Object.values(c).map(v=>v.col))].filter(v=>!Object.hasOwn(s,v)).sort(),m=[...r,...a].flatMap(v=>nt(Object.fromEntries(Object.entries(c).filter(([,p])=>p.col===v))));return{columns:Object.fromEntries(r.map(v=>[v,s[v]])),cards:Object.fromEntries(m.map(v=>[v,c[v]]))}}function Uo(e,t){let o=Qt(e,t);return{columns:qe(o,"column",Zt,!1),cards:qe(o,"card",en,!1)}}var nn={name:"",pos:"",title:"",owner:null,due:null,placement:{columnId:"",pos:""}},Xt=(e,t,o)=>e==="card"&&o==="placement"?{columnId:t.col??"",pos:t.pos??""}:t[o]??nn[o];function Hn(e,t,o,s){let c=[];for(let[r,a]of Gn){let m=ht(o?.[a])?o[a]:{},v=ht(s?.[a])?s[a]:{};for(let p of new Set([...Object.keys(m),...Object.keys(v)])){let u=m[p],h=v[p];if(!h){u&&c.push([gt(e,r,p,"alive"),!1]);continue}u||c.push([gt(e,r,p,"alive"),!0]);for(let g of yt[r]){if(g==="alive")continue;let f=gt(e,r,p,g),d=Xt(r,h,g),b=u?Xt(r,u,g):t.has(f)?t.get(f):nn[g];ce(b)!==ce(d)&&c.push([f,qn(d)])}}}return c}function Lo(e,t,o,s){for(let[c,r]of Hn(t,e.boardFields,o,s))e.boardFields.set(c,r)}var on=e=>{let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Wn=(e,t)=>e.id.client===t.client&&t.clock>=e.id.clock&&t.clock<e.id.clock+e.length,Xn=e=>{if(typeof e!="string"||e.charCodeAt(0)!==91)return null;let t;try{t=JSON.parse(e)}catch{return null}return Array.isArray(t)&&t.length===2&&t[0]===He&&typeof t[1]=="string"?t[1]:null},Qn=e=>e.reduce((t,o)=>o.brk.client<t.brk.client||o.brk.client===t.brk.client&&o.brk.clock<t.brk.clock?o:t);function ln(e,t=null){let o=t?null:Ae(e.origins);try{return Zn(e,o??t)}finally{o&&o.dispose()}}function Zn(e,t){let o=e.ydoc.store,s=mt(e.gone),c=new Map,r=new Map;for(let n=e.flow._start;n;n=n.right){if(n.deleted||!(n.content instanceof X)||n.content.embed.b===void 0)continue;r.set(n.content.embed.b,(r.get(n.content.embed.b)??0)+1);let l=te(t.resolve(n.id)),i=c.get(l);(!i||n.id.client<i.id.client||n.id.client===i.id.client&&n.id.clock<i.id.clock)&&c.set(l,n)}let a=new Set(c.keys()),m=new Set,v=[],p=new Map;for(let n of e.origins.keys()){let l;try{l=JSON.parse(n)}catch{continue}if(!Array.isArray(l)||l.length!==3||l[0]!=="boundary"&&l[0]!=="alias")continue;let[,i,O]=l;if(!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(O)||O<0)continue;if(l[0]==="boundary"){let A=`${i}.${O}`,$=t.boundaryOf({client:i,clock:O});$&&$.kind==="copy"&&(s.copyActive.has(A)?$.recoveryOf&&m.add($.recoveryOf):a.has(A)&&v.push({key:sn(A),sourceKey:A,source:{client:i,clock:O},operationId:null,blockId:$.blockId,end:null,sv:[],legacy:!1,implicit:!0}))}(p.get(i)??p.set(i,new Set).get(i)).add(O)}let u=[],h=new Set(v.map(n=>n.key));for(let n of s.restores)for(let l of n.covers){let i=Xn(l);i===null||h.has(l)||!c.has(i)||(h.add(l),u.push({key:l,sourceKey:i,source:xe(i),operationId:null,blockId:c.get(i).content.embed.b,end:null,sv:[],legacy:!1,implicit:!0}))}let g=v.length||u.length?[...s.removals,...v,...u]:s.removals,f=new Map,d=new Map,b=new Map;for(let n of g){(b.get(n.sourceKey)??b.set(n.sourceKey,[]).get(n.sourceKey)).push(n);let i=null;if(n.implicit)i=c.get(n.sourceKey);else try{i=Oe(o,n.source)}catch{i=null}let O=te(t.resolve(n.source)),C=c.get(O);if((!i||i.deleted)&&C?.content.embed.b===n.blockId&&(i=C),!i)continue;if(n.legacy){!i.deleted&&i.content instanceof X&&i.content.embed.b===n.blockId&&te(t.resolve(i.id))===O&&f.set(i,{key:n.key,blockId:n.blockId,end:n.end?xe(n.end):null});continue}(d.get(i)??d.set(i,[]).get(i)).push(n)}let w=new Map,I=new Set(s.restores.map(n=>n.sourceKey)),j=(n,l)=>{let i=cn(l);if(i===null)return null;let O=t.boundaryOf({client:n.id.client,clock:n.id.clock});return O&&O.blockId===l&&O.recoveryOf===i?O:null},M=(n,l)=>{let i=j(n,l);return i&&i.kind==="restore"?i.recoveryOf:null},R=(n,l)=>{let i=j(n,l);return i&&i.kind==="copy"?i.recoveryOf:null},S=(n,l)=>{let i=M(n,l);return i!==null&&I.has(i)&&b.has(i)?i:null};for(let n of s.restores){let l=w.get(n.sourceKey)??w.set(n.sourceKey,new Set).get(n.sourceKey);for(let i of n.covers)l.add(i)}let E=new Map;for(let n=e.flow._start;n;n=n.right){if(n.deleted)continue;let l=n.content instanceof X?S(n,n.content.embed&&n.content.embed.b):null;if(l===null)continue;(E.get(l)??E.set(l,[]).get(l)).push(n)}let V=n=>{let l=b.get(n);if(!l||!l.length)return!1;let i=w.get(n);if(!i)return!1;for(let O of l)if(!i.has(O.key))return!1;return(E.get(n)?.length??0)>0||m.has(n)},B=[],q=[],ne=[],oe=[],Y=null,P="start",N=null,Ye=0,J={},Me=n=>{let l=e.attrs.get(n);return l&&l.get("t")||"paragraph"},re=n=>{n&&(Y&&!Y.atom?Y.runs.push({hole:n}):B.push({kind:"h",len:n,key:null}))},de=(n,l,i=!1)=>{let O=kt(n,b.get(n)??[],s),C=`recovered:${n}`,A=O?O.type:"paragraph",$=!Object.hasOwn(G.nodes,A);Y={kind:"b",id:C,baseId:C,brk:{client:l.id.client,clock:l.id.clock},implicit:!1,runs:[],len:1,atom:!$&&!G.nodes[A]?.isTextblock,opaque:$,recovered:!0,restored:!i,sourceKey:n,t:A,fields:O?O.attrs:null},B.push(Y),P=C},ee=(n,l,i)=>{Y={kind:"b",id:n,baseId:n,brk:l,implicit:i,runs:[],len:i?0:1,atom:!1,items:!i&&(r.get(n)??0)>1?[]:null},i?Y.t="paragraph":(Y.t=Me(n),Y.opaque=!Object.hasOwn(G.nodes,Y.t),Y.atom=!Y.opaque&&!G.nodes[Y.t]?.isTextblock),B.push(Y),P=n},ge=()=>{N&&(N.len&&(N.resume?N.resume.runs.push({hole:N.len}):B.push({kind:"h",len:N.len,key:N.active[0]?.key})),Y=N.resume,N=null)},$e=n=>{n.legacy&&n.text&&q.push({key:n.key,id:n.blockId,text:n.text,h:on(n.text)}),ne.push({key:n.key,sourceKey:n.sourceKey,blockId:n.blockId,end:n.end,sv:n.sv,at:n.at,live:n.live,items:n.items})},Qe=(n,l)=>Wn(n,l)?!0:Ke(n).some(i=>{if(!e.origins.has(lt(i.client,i.clock)))return!1;let O=t.resolve(i);return O.client===l.client&&O.clock===l.clock}),Ze=new Map([...p].map(([n,l])=>[n,[...l].sort((i,O)=>i-O)])),Ke=n=>{let l=Ze.get(n.id.client)??[],i=0,O=l.length;for(;i<O;){let A=i+O>>1;l[A]<n.id.clock?i=A+1:O=A}let C=[];for(let A=i;A<l.length&&l[A]<n.id.clock+n.length;A++)C.push({client:n.id.client,clock:l[A]});return C},H=[],et=n=>({blockId:n.blockId,end:n.end?xe(n.end):null,implicit:n.implicit===!0,sourceKey:n.sourceKey});for(let n=e.flow._start;n;n=n.right){let l=Ye;if(!n.deleted&&n.countable&&(Ye+=n.length),N||H.length){let A=!n.deleted&&n.content instanceof X?n.content.embed.b:void 0,$=A!==void 0&&M(n,A)===null,F=n.deleted?Ke(n).flatMap(T=>{let z=te(t.resolve(T)),tt=t.boundaryOf(T);return!tt||tt.kind!=="removed"||a.has(z)?[]:[{blockId:tt.blockId,sourceKey:z}]}):[],K=T=>T.end?Qe(n,T.end):T.implicit?$||F.some(z=>z.sourceKey!==T.sourceKey):$&&A!==T.blockId||F.some(z=>z.blockId!==T.blockId);if(N){let T=[];for(let z of N.active)K(z)?$e(z):T.push(z);N.active=T,T.length||ge()}for(let T=H.length-1;T>=0;T--)H[T].active=H[T].active.filter(z=>!K(z)),H[T].active.length||H.splice(T,1)}let i=d.get(n);if(i){if(!N&&V(i[0].sourceKey)){n.deleted||re(n.length),H.push({active:i.map(et),sourceKey:i[0].sourceKey,root:null});continue}!N&&n.deleted&&oe.push({client:n.id.client,clock:n.id.clock});for(let A of i){let $={legacy:!1,implicit:A.implicit===!0,key:A.key,sourceKey:A.sourceKey,blockId:A.blockId,end:A.end?xe(A.end):null,sv:A.sv,at:l,live:!n.deleted,items:[]};N?N.active.push($):N={active:[$],len:0,resume:Y}}n.deleted||(N.len+=n.length);continue}let O=f.get(n);if(O){if(!N&&V(O.key)){n.deleted||re(n.length),H.push({active:[{blockId:O.blockId,end:O.end}],sourceKey:O.key,root:null});continue}let A={legacy:!0,key:O.key,sourceKey:O.key,blockId:O.blockId,end:O.end,sv:[],at:l,live:!0,items:[],text:""};N?N.active.push(A):N={active:[A],len:0,resume:Y},N.len+=1;continue}if(n.deleted)continue;let C=n.content;if(C instanceof rt){C.value===null?delete J[C.key]:J[C.key]=C.value;continue}if(N){if(C instanceof ie||C instanceof X){let A=C instanceof ie?C.str:C.embed.b!==void 0?"\xB6":`
|
|
2
|
+
`,$={...J};for(let F of N.active)F.legacy&&(F.text+=A),F.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:C instanceof ie?"text":C.embed.b!==void 0?"marker":"br",text:C instanceof ie?C.str:null,blockId:C instanceof X&&C.embed.b!==void 0?C.embed.b:null,raw:$});N.len+=n.length}continue}if(C instanceof rt){C.value===null?delete J[C.key]:J[C.key]=C.value;continue}if(C instanceof X){let A=S(n,C.embed.b);if(A!==null){let K=H.find(T=>T.sourceKey===A&&!T.root);K&&!m.has(A)?(de(A,n),K.root=Y):re(n.length);continue}if(M(n,C.embed.b)!==null){re(n.length);continue}let $=R(n,C.embed.b);if($!==null){de($,n,!0);continue}let F=C.embed;F.b!==void 0?ee(F.b,{client:n.id.client,clock:n.id.clock},!1):((!Y||Y.atom)&&ee(`~${P}`,null,!0),Y.runs.push({br:!0}),Y.items&&Y.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:"br",text:null,blockId:null,raw:{...J}}),Y.len+=1);continue}if(C instanceof ie){(!Y||Y.atom)&&ee(`~${P}`,null,!0);let A=_e(J,Y.t);Y.runs.push({text:C.str,marks:A,mk:Kt(A)}),Y.items&&Y.items.push({at:l,id:te(n.id),client:n.id.client,clock:n.id.clock,length:n.length,kind:"text",text:C.str,blockId:null,raw:{...J}}),Y.len+=C.str.length}}if(N){for(let n of N.active)$e(n);ge()}let ye=new Map;for(let n of B)n.kind!=="b"||n.implicit||(ye.get(n.baseId)??ye.set(n.baseId,[]).get(n.baseId)).push(n);let he=n=>n.runs.map(l=>l.br?`
|
|
3
|
+
`:l.hole?"":l.text).join(""),me=new Map,ke=[];for(let[n,l]of ye){if(l.length<2)continue;let i=Qn(l);for(let O of l)if(O!==i&&(O.hide=!0,(me.get(n)??me.set(n,[]).get(n)).push(te(O.brk)),!(Se(O.runs,i.runs)&&O.t===i.t)&&he(O)&&(q.push({key:`d${O.brk.client}.${O.brk.clock}`,id:n,text:he(O),h:on(he(O)),copy:!0}),O.items?.length))){let C=te(t.resolve(O.brk)),A=rn(C);ke.push({key:A,sourceKey:C,source:{client:O.brk.client,clock:O.brk.clock},operationId:null,blockId:n,end:null,sv:[],legacy:!1,implicit:!0}),ne.push({key:A,sourceKey:C,blockId:n,end:null,sv:[],at:O.items[0].at,live:!0,items:O.items})}}let y=[],k=[],x=0;for(let n of B){if(n.kind==="h"){k.push({at:x,len:n.len});continue}if(n.hide){k.push({at:x,len:n.len+n.runs.reduce((i,O)=>i+(O.hole??0),0)});continue}y.push(n);let l=n.implicit?0:1;for(let i of n.runs)i.hole?k.push({at:x+l,len:i.hole}):l+=i.br?1:i.text.length;x+=n.len}return{visible:y,holes:k,orphans:q,tokens:x,copies:me,hidden:ne,removals:ke.length?[...g,...ke]:g,fences:oe}}var wt="remove",yn="restore",vt="copy-active",He="copy-lost",hn="attr",mn="text-delete",We=class extends Error{constructor(t){super(t),this.name="RecoveryError"}},D=e=>{throw new We(e)},ae=e=>Number.isSafeInteger(e)&&e>=0,eo=e=>Number.isSafeInteger(e)&&e>0,an=/^(?:0|[1-9]\d*)$/,kn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Q=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),Ee=(e,t)=>e<t?-1:e>t?1:0,bn=e=>[...e].sort(Ee),fn=e=>`${e.client}.${e.clock}`,to=e=>JSON.stringify(["author",e]),cs=(e,t)=>JSON.stringify([wt,e,t]),is=(e,t)=>JSON.stringify([yn,e,t]),sn=e=>JSON.stringify([vt,e]),rn=e=>JSON.stringify([He,e]),ls=(e,t,o)=>JSON.stringify([mn,e,t,o]),as=(e,t)=>JSON.stringify([hn,e,t]);function Z(e){if(typeof e!="string")return null;let t=e.indexOf(".");if(t<1||t===e.length-1)return null;let o=e.slice(0,t),s=e.slice(t+1);if(!an.test(o)||!an.test(s))return null;let c=Number(o),r=Number(s);return ae(c)&&ae(r)?{client:c,clock:r}:null}var je=(e,t,o)=>{kn(e)||D(`Invalid gone record: ${o}`);for(let s of Object.keys(e))t.includes(s)||D(`Unsupported gone field ${s} in ${o}`)},un=(e,t)=>{Array.isArray(e)||D(`Invalid state vector in ${t}`);let o=[],s=-1;for(let c of e){(!Array.isArray(c)||c.length!==2)&&D(`Invalid state vector in ${t}`);let[r,a]=c;(!ae(r)||!ae(a)||r<=s)&&D(`Invalid state vector in ${t}`),s=r,o.push([r,a])}return o},no=e=>{if(typeof e!="string")return!1;if(e.charCodeAt(0)!==91)return Z(e)!==null;let t;try{t=JSON.parse(e)}catch{return!1}return!Array.isArray(t)||!Z(t[1])?!1:t[0]===wt?t.length===3&&typeof t[2]=="string"&&t[2]!=="":(t[0]===vt||t[0]===He)&&t.length===2},oo=(e,t,o)=>{if(t.charCodeAt(0)===91){let r=null;try{r=JSON.parse(t)}catch{D(`Malformed gone key: ${t}`)}if((!Array.isArray(r)||typeof r[0]!="string")&&D(`Malformed gone key: ${t}`),r[0]===wt){(r.length!==3||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`);let a=Z(r[1]);a||D(`Malformed gone key: ${t}`),je(e,["blockId","end","sv"],t),(typeof e.blockId!="string"||!e.blockId)&&D(`Invalid removal record: ${t}`);let m=e.end??null;m!==null&&!Z(m)&&D(`Invalid removal record: ${t}`),o.removals.push({key:t,sourceKey:r[1],source:a,operationId:r[2],blockId:e.blockId,end:m,sv:un(e.sv,t),legacy:!1});return}if(r[0]===yn){(r.length!==3||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`),Z(r[1])||D(`Malformed gone key: ${t}`),je(e,["covers","baseline"],t),(!Array.isArray(e.covers)||e.covers.some(m=>!no(m)))&&D(`Invalid restore record: ${t}`);let a=e.baseline??{};je(a,["type","attrs"],t),(typeof a.type!="string"||!kn(a.attrs))&&D(`Invalid restore record: ${t}`),o.restores.push({key:t,sourceKey:r[1],operationId:r[2],covers:bn(e.covers),baseline:{type:a.type,attrs:Q(a.attrs)}});return}if(r[0]===vt){(r.length!==2||!Z(r[1]))&&D(`Malformed gone key: ${t}`),e!==!0&&D(`Invalid copy-active record: ${t}`),o.copyActive.add(r[1]);return}if(r[0]===mn){(r.length!==4||!ae(r[1])||!ae(r[2])||typeof r[3]!="string"||!r[3])&&D(`Malformed gone key: ${t}`),je(e,["length","actor","sv"],t),(!eo(e.length)||!ae(r[2]+e.length-1))&&D(`Invalid text-delete record: ${t}`),ae(e.actor)||D(`Invalid text-delete record: ${t}`),o.textDeletes.push({key:t,client:r[1],clock:r[2],length:e.length,actor:e.actor,sv:un(e.sv,t)});return}if(r[0]===hn){(r.length!==3||!Z(r[1])||typeof r[2]!="string"||!r[2])&&D(`Malformed gone key: ${t}`),e===void 0&&D(`Invalid attribute override: ${t}`);let a=o.attrs.get(r[1])??new Map;a.set(r[2],Q(e)),o.attrs.set(r[1],a);return}D(`Unsupported gone record: ${t}`)}let s=Z(t);s||D(`Malformed gone key: ${t}`),je(e,["b","e"],t),(typeof e.b!="string"||!e.b)&&D(`Invalid gone record: ${t}`);let c=e.e??null;c!==null&&!Z(c)&&D(`Invalid gone record: ${t}`),o.removals.push({key:t,sourceKey:t,source:s,operationId:null,blockId:e.b,end:c,sv:[],legacy:!0})};function mt(e,{strict:t=!1}={}){let o={removals:[],restores:[],copyActive:new Set,attrs:new Map,textDeletes:[]};return e.forEach((s,c)=>{try{oo(s,c,o)}catch(r){if(t||!(r instanceof We))throw r}}),o}var bt=e=>{if(Array.isArray(e))return e.map(bt);if(e!==null&&typeof e=="object"){let t={};for(let o of Object.keys(e).sort())t[o]=bt(e[o]);return t}return e},so=e=>JSON.stringify(bt(e)),Xe=e=>G.nodes[e]??G.nodes.paragraph,ro=(e,t,o=null)=>{let s=e.attrs.get(t),c=o?.get("t"),r=s&&s.get("t")||"paragraph",a=typeof c=="string"&&G.nodes[c]?c:r,m=Xe(a),v={};for(let p of Ve(m))v[p]=Q(s&&s.has(p)?s.get(p):Be(m,p));if(a==="table"&&Object.assign(v,Q(qt(e.tableFields,t,{cols:v.cols,rows:v.rows}))),a==="board"&&Object.assign(v,Q(tn(e.boardFields,t))),o)for(let[p,u]of o)p!=="t"&&Object.hasOwn(v,p)&&(v[p]=Q(u));return{id:t,type:a,attrs:v}},co=e=>{let t={};if(!e)return t;for(let o of[...e.keys()].sort())t[o]=Q(e.get(o));return t},dn="recovered:",cn=e=>typeof e=="string"&&e.startsWith(dn)?e.slice(dn.length):null;function kt(e,t,o){let s=new Set(t.map(h=>h.key)),c=null;for(let h of o.restores){if(h.sourceKey!==e)continue;let g=h.covers.reduce((f,d)=>f+(s.has(d)?1:0),0);(!c||g>c.count||g===c.count&&Ee(h.key,c.restore.key)<0)&&(c={restore:h,count:g})}if(!c)return null;let r=o.attrs.get(e),a=r?.get("t"),m=G.nodes[c.restore.baseline.type]?c.restore.baseline.type:"paragraph",v=typeof a=="string"&&G.nodes[a]?a:m,p=Xe(v),u={};for(let h of Ve(p))r&&r.has(h)?u[h]=Q(r.get(h)):Object.hasOwn(c.restore.baseline.attrs,h)?u[h]=Q(c.restore.baseline.attrs[h]):u[h]=Q(Be(p,h));return{type:v,attrs:u,key:c.restore.key}}var io=e=>{let t={};for(let o of Object.keys(e).sort())t[o]=Q(e[o]);return t},lo=(e,t)=>t.some(o=>e.clock>=(o.get(e.client)??0)),ao=(e,t)=>{let o=e[e.length-1];if(o&&t<=o.end){t===o.end&&(o.end=t+1);return}e.push({start:t,end:t+1})},fo=e=>{let t=[];for(let o of[...e].sort(Ee))ao(t,o);return t},uo=(e,t)=>{let o=0,s=e.length-1;for(;o<=s;){let c=o+s>>1,r=e[c];if(t<r.start)s=c-1;else if(t>=r.end)o=c+1;else return!0}return!1},po=(e,t,o)=>{let s=Nt(t,e.length).physicalRanges(0,t.tokens),c=new Map,r=(p,u,h)=>{for(let g=u;g<h;g++){let f=o.resolve({client:p.id.client,clock:p.id.clock+g}),d=c.get(f.client);d?d.push(f.clock):c.set(f.client,[f.clock])}},a=0,m=0;for(let p=e._start;p&&m<s.length;p=p.right){if(p.deleted||!p.countable)continue;let u=a;a+=p.length;let h=p.content,g=h instanceof ie;if(!g&&!(h instanceof X)||!g&&h.embed.b!==void 0)continue;for(;m<s.length&&s[m][1]<=u;)m++;let f=m;for(;f<s.length&&s[f][0]<a&&(r(p,Math.max(u,s[f][0])-u,Math.min(a,s[f][1])-u),!(s[f][1]>=a));)f++;m=f}let v=new Map;for(let[p,u]of c)v.set(p,fo(u));return(p,u)=>{let h=v.get(p);return h?uo(h,u):!1}},pn=(e,t,o,s,c)=>{let r=e.resolve({client:t.client,clock:t.clock}),a=t.kind==="text"?$t(_e(t.raw,s)):{},m=!lo(t,o);return{client:t.client,clock:t.clock,length:t.length,sourceClient:r.client,sourceClock:r.clock,baseline:m,displaced:!m&&!c(r.client,r.clock),kind:t.kind,text:t.kind==="text"?t.text:null,marks:a,raw:io(t.raw)}},gn=(e,t)=>{let o=e[e.length-1];if(o&&o.kind===t.kind&&o.baseline===t.baseline&&o.displaced===t.displaced&&o.client===t.client&&o.clock+o.length===t.clock&&o.sourceClient===t.sourceClient&&o.sourceClock+o.length===t.sourceClock&&Se(o.marks,t.marks)&&Se(o.raw,t.raw)){o.length+=t.length,o.kind==="text"&&(o.text+=t.text);return}e.push(t)},go=(e,t)=>({id:fn(e),length:e.length,source:fn({client:e.sourceClient,clock:e.sourceClock}),baseline:e.baseline,displaced:e.displaced,kind:e.kind,...e.kind==="text"?{text:e.text}:{},marks:e.marks,raw:e.raw,author:t(e.sourceClient)});function yo(e,t,o,s,c,r,a,m){let v=(S,E,V=null)=>{let B=t.boundaryOf(E);if(!B||B.blockId!==S||!B.recoveryOf)return ro(e,S,V);let q=kt(B.recoveryOf,m.get(B.recoveryOf)??[],r),ne=typeof V?.get("t")=="string"&&G.nodes[V.get("t")]?V.get("t"):q?.type??"paragraph",oe={};for(let Y of Ve(Xe(ne)))oe[Y]=Q(V?.has(Y)?V.get(Y):q&&Object.hasOwn(q.attrs,Y)?q.attrs[Y]:Be(Xe(ne),Y));return{id:S,type:ne,attrs:oe}},p=S=>{let E=e.origins.get(to(S));return typeof E=="string"&&E?E:null},u=[...s].sort((S,E)=>Ee(S.key,E.key)),h=u[0].blockId,g=r.attrs.get(o),f=co(g),d=v(h,u[0].source,g),b=new Map(u.map(S=>[S.key,new Map(S.sv)])),w=new Map;for(let S of u){let E=c.get(S.key);if(!E)continue;let V=b.get(S.key);for(let B of E.items){let q=w.get(B.id);q?q.vectors.push(V):w.set(B.id,{item:B,vectors:[V]})}}let I=[...w.values()].sort((S,E)=>S.item.at-E.item.at),j=[{...d,author:p(t.resolve(u[0].source).client),runs:[]}],M=j[0];for(let S of I){let E=S.item;if(E.kind==="marker"){if(t.boundaryOf({client:E.client,clock:E.clock})?.kind==="restore"||!E.blockId||E.blockId===M.id)continue;M={...v(E.blockId,{client:E.client,clock:E.clock}),author:p(t.resolve({client:E.client,clock:E.clock}).client),runs:[]},j.push(M);continue}if(E.kind==="text")for(let V=0;V<E.length;V++)gn(M.runs,pn(t,{...E,clock:E.clock+V,length:1,text:E.text[V]},S.vectors,M.type,a));else gn(M.runs,pn(t,E,S.vectors,M.type,a))}let R={source:o,blockId:h,type:d.type,attrs:d.attrs,author:j[0].author,blocks:j.map(S=>({id:S.id,type:S.type,attrs:S.attrs,author:S.author,runs:S.runs.map(E=>go(E,p))})),removals:u.map(S=>({key:S.key,operationId:S.operationId,end:S.end,sv:S.sv})),restores:r.restores.filter(S=>S.covers.some(E=>u.some(V=>V.key===E))).sort((S,E)=>Ee(S.key,E.key)).map(S=>({key:S.key,covers:bn(S.covers)})),copyActive:r.copyActive.has(o),overrides:f,recoverable:j.some(S=>S.runs.some(E=>E.displaced))};return{...R,revision:so(R)}}function fs(e,t={}){let o=t.index??Ae(e.origins);try{let s=t.walked??ln(e,o),c=t.intents??mt(e.gone,{strict:t.strict===!0}),r=new Map;for(let h of s.hidden??[])r.set(h.key,h);let a=new Map;for(let h of s.removals??c.removals){let g=a.get(h.sourceKey);g?g.push(h):a.set(h.sourceKey,[h])}let m=null,v=(h,g)=>(m||(m=po(e.flow,s,o)),m(h,g)),p=new Map;for(let[h,g]of a)p.set(h,yo(e,o,h,g,r,c,v,a));let u=[...p.values()].sort((h,g)=>{let f=Z(h.source),d=Z(g.source);return f.client-d.client||f.clock-d.clock});return{sources:p,list:u,intents:c}}finally{t.index||o.dispose()}}export{Ae as a,ho as b,mo as c,ft as d,Pe as e,Ut as f,Yo as g,Mo as h,at as i,le as j,Ue as k,Yn as l,So as m,L as n,Bt as o,xo as p,qt as q,zn as r,Bo as s,gt as t,tn as u,Uo as v,Lo as w,We as x,fn as y,to as z,cs as A,is as B,sn as C,ls as D,as as E,Z as F,mt as G,so as H,dn as I,cn as J,kt as K,fs as L,ln as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as P,c as S,q as c,s as d,u as h,v as k}from"./c-TCJTVAFN.js";import"./c-GQ6F6IDK.js";import{b as f,d as y}from"./c-2SPVQSHC.js";import"./c-5VYOWDTI.js";import"./c-QJ4OM3G6.js";import"./c-MKSQ4Y57.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-ZWIOJGMT.js";import{j as l,m as w,n as D,o as x}from"./c-LWLBHLVC.js";import"./c-SDAXDM2D.js";import"./c-TQEMVJCS.js";import"./c-DCXOXBF3.js";import"./c-VRZN56XY.js";import"./c-IJUK2GPW.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var E=15e3,b=Symbol("the barrier deadline passed"),M=2,e=(n,t={})=>({ok:!1,code:n,...t});async function I(n,t){let s=null,u=new Promise(r=>{s=setTimeout(()=>r(b),Math.max(0,t-Date.now()))});try{return await Promise.race([Promise.resolve(n),u])}finally{clearTimeout(s)}}async function X({generation:n=d(),keepalive:t=!1,timeoutMs:s=E,operation:u=null}={}){let r=u?null:w("mode");if(!u&&!r)return e("busy");let i=Date.now()+s,p=h(n);try{for(let m=0;;m++){if(n!==d())return e("stale-document");if(Date.now()>=i)return e("timeout");let a=await I(y(),i);if(a===b)return e("timeout");if(!a.ok)return e("pending-input",{pending:a.pending});if(a.pending.length)return e("pending-input",{pending:a.pending});if(c())return e("conflict");if(l())return e("save-unknown");let o;try{o=await P({keepalive:t,timeoutMs:Math.max(0,i-Date.now()),permit:p})}catch(v){return v?.state==="conflict"?e("conflict"):v?.state==="blocked"?e("pending-input",{pending:f()}):l()?e("save-unknown"):Date.now()>=i?e("timeout"):e("save-failed")}if(o.state!=="clean"&&o.state!=="saved")return e("save-failed");if(c())return e("conflict");if(l())return e("save-unknown");let g=f();if(g.length)return e("pending-input",{pending:g});if(S()){if(m+1<M&&Date.now()<i)continue;return e("pending-input")}return{ok:!0,state:o.state,etag:o.etag??null}}}finally{k(p),r&&D(r)}}export{w as claimOperation,x as operationKind,D as releaseOperation,X as runSaveBarrier};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{A as zt,B as Vt,D as et,G as it,H as ct,I as z,a as N,aa as Rt,b as O,ba as lt,ca as qt,d as B,e as Y,ea as _t,f as Dt,fa as Kt,g as J,ga as Ht,j as C,k as Z,m as T,n as tt,p as $t,qa as jt,s as Bt,u as at,y as Lt,z as Pt}from"./c-WWXIDH4O.js";var fe=n=>n==="left"||n==="right"?n:null,{Plugin:xt,PluginKey:pe,TextSelection:I,NodeSelection:Ut,Selection:ot}=O,E=T.nodes,A=n=>n.type===E.list_item,S=n=>n.type===E.toggle,b=n=>n.attrs.parent??null,yt="page-step",R="page-move",At=n=>n&&(t=>n(Y.closeHistory(t).setMeta(yt,!0)));function y(n){let t=[],e=new Map,o=[];n.forEach((r,a)=>{let s=t.length,i=t[s-1],l=b(r),c=l!==null&&e.has(l)?e.get(l):-1,u=c;if(A(r)){for(i&&A(i.node)&&b(i.node)===l||(o=[]);o.length&&t[o[o.length-1]].node.attrs.indent>=r.attrs.indent;)o.pop();o.length&&(u=o[o.length-1]),o.push(s)}else o=[];let p=c>=0&&(t[c].hidden||!t[c].node.attrs.open);t.push({node:r,at:a,end:a+r.nodeSize,i:s,up:u,depth:c>=0?t[c].depth+1:0,hidden:p,subEnd:s}),S(r)&&r.attrs.id&&e.set(r.attrs.id,s)});for(let r=t.length-1;r>=0;r--){let a=t[r].up;a>=0&&t[r].subEnd>t[a].subEnd&&(t[a].subEnd=t[r].subEnd)}return t}var Hn=(n,t)=>({from:n[t].at,to:n[n[t].subEnd].end});function he(n,t=null){let e=new Map;t?.forEach(c=>{c.attrs.id&&e.set(c.attrs.id,b(c))}),n.forEach(c=>{c.attrs.id&&e.set(c.attrs.id,b(c))});let o=[];n.forEach((c,u)=>o.push({node:c,at:u}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let u=b(o[c+1].node);r[c]=u!==b(o[c].node)?u:r[c+1]}let a=[],s=[null],i=null,l=[];return o.forEach(({node:c,at:u},p)=>{let d=b(c),f=new Set;for(;d!==null&&!s.includes(d)&&!f.has(d);)f.add(d),d=e.has(d)?e.get(d):null;s.includes(d)||(d=null);let m=r[p];s.indexOf(m)>s.indexOf(d)&&(d=m);let h=s.slice(0,s.indexOf(d)+1),x=c.attrs.indent;if(A(c)){let g=Number.isInteger(x)&&x>0?x:0,v=i&&A(i.node)&&i.parent===d;for(v||(l=[]);l.length&&l[l.length-1].orig>g;)l.pop();let D=0;if(l.length){let w=l[l.length-1];D=w.shift,w.orig===g&&l.pop()}x=Math.max(0,Math.min(g-D,v?i.indent+1:0)),l.push({orig:g,shift:g-x})}else l=[];(d!==b(c)||A(c)&&x!==c.attrs.indent)&&a.push({at:u,attrs:{...c.attrs,parent:d,...A(c)?{indent:x}:{}}}),i={node:c,parent:d,indent:x},s=S(c)&&c.attrs.id?[...h,c.attrs.id]:h}),a}function jn(){return new xt({appendTransaction(n,t,e){if(!n.some(a=>a.docChanged&&!a.getMeta(et)))return null;let o=he(e.doc,t.doc);if(!o.length)return null;let r=e.tr;for(let a of o)r.setNodeMarkup(a.at,null,a.attrs);return r}})}function rt(n,t,e){let o=n.resolve(t.from).index(0),r=Math.min(n.resolve(t.to).index(0),e.length-1);return r>o&&t.to<=e[r].at&&r--,[Math.min(o,e.length-1),r]}var Yt=rt;function L(n,t,e){let o=t;for(;n[o].up>=0&&e>n[n[o].up].subEnd;)o=n[o].up;let r=n[o].up,a=n[o].subEnd;for(;a<e;)a=n[a+1].subEnd;return{lo:o,hi:a,up:r}}var me=(n,t,e)=>{let o=n.resolve(Math.max(0,Math.min(t,n.content.size)));return o.depth===0?o.pos:e<0?o.before(1):o.after(1)},Ft=n=>({id:n.node.attrs.id,at:n.at,node:n.node}),pt=(n,t)=>t.id?n.node.attrs.id===t.id:n.at===t.at&&n.node.type===t.node.type&&n.node.content.eq(t.node.content);function ge(n,t,e){let o=[];for(let r=t;r<=e;r=n[r].subEnd+1)o.push(Ft(n[r]));return{roots:o,members:n.slice(t,e+1).map(Ft)}}function be(n,t){let e=t.roots.map(s=>n.findIndex(i=>pt(i,s))).filter(s=>s>=0);if(!e.length||e.some(s=>n[s].hidden))return null;let o=e[0],r=n[o].up,a=n[o].subEnd;for(let s of e.slice(1)){if(s!==a+1||n[s].up!==r)return null;a=n[s].subEnd}return n.slice(o,a+1).some(s=>!t.members.some(i=>pt(s,i)))?null:{lo:o,hi:a}}var ke=(n,t)=>{let e=o=>({...o,at:t.map(o.at,1)});return{roots:n.roots.map(e),members:n.members.map(e)}},k=class n extends ot{map(t,e){return this.getBookmark().map(e).resolve(t)}eq(t){return t instanceof n&&t.anchor===this.anchor&&t.head===this.head}toJSON(){return{type:"page-block",anchor:this.anchor,head:this.head}}static fromJSON(t,e){return new n(t.resolve(e.anchor),t.resolve(e.head))}getBookmark(){let{lo:t,hi:e}=this.span();return new ht(this.anchor,this.head,ge(y(this.$from.doc),t,e))}span(t=this.$from.doc){return{lo:t.resolve(this.from).index(0),hi:t.resolve(this.to).index(0)-1}}};k.prototype.visible=!1;ot.jsonID("page-block",k);var ht=class n{constructor(t,e,o){this.anchor=t,this.head=e,this.span=o}map(t){let e=this.anchor<=this.head;return new n(t.map(this.anchor,e?1:-1),t.map(this.head,e?-1:1),ke(this.span,t))}resolve(t){let e=y(t),o=be(e,this.span);if(!o){let s=e.find(i=>pt(i,this.span.roots[0]));return ot.near(t.resolve(s?.at??me(t,Math.min(this.anchor,this.head),-1)))}let r=e[o.lo].at,a=e[o.hi].end;return this.anchor<=this.head?new k(t.resolve(r),t.resolve(a)):new k(t.resolve(a),t.resolve(r))}},Jt=(n,t)=>{for(let e=t-1;e>=0;e--)if(n[e].up===n[t].up)return e;return-1};function G(n,t,e,o,r=()=>null){let a=r(n[t])||{},s="parent"in a?a.parent:b(n[t].node),i=null;for(let u=0;u<n.length&&n[u].end<=o;u++)u>=t&&u<=e||b(n[u].node)===s&&(i=n[u].node.attrs.id);let l=[],c={};for(let u=t;u<=e;u++){let p=n[u].node,d=r(n[u]);l.push(p.attrs.id),d&&"indent"in d&&d.indent!==p.attrs.indent&&(c[p.attrs.id]={indent:d.indent})}return{ids:l,afterId:i,parent:s,attrs:c}}function Zt(n,t,e,o,r,a=()=>null,s=n.selection){let i=t[e].at,l=t[o].end,c=l-i,u=[];for(let m=e;m<=o;m++){let h=t[m].node;u.push(h.type.create({...h.attrs,...a(t[m])||{},pos:null},h.content,h.marks))}let p=n.tr.delete(i,l),d=r>i?r-c:r;p.insert(d,u);let f=d-i;return s instanceof k?p.setSelection(new k(p.doc.resolve(s.anchor+f),p.doc.resolve(s.head+f))):s instanceof Ut?p.setSelection(Ut.create(p.doc,s.from+f)):p.setSelection(I.create(p.doc,s.anchor+f,s.head+f)),p.setMeta(R,G(t,e,o,r,a))}function mt(n,t,e){let o=n[e].node;if(S(o)){let a=o.attrs.id,s=b(o);return i=>b(i.node)===a?{parent:s}:null}let r=o.attrs.indent-n[t].node.attrs.indent;return a=>A(a.node)?{indent:a.node.attrs.indent+r}:null}var Gt=n=>(t,e)=>{e=At(e);let o=y(t.doc);if(!o.length)return!1;let[r,a]=rt(t.doc,t.selection,o),{lo:s,hi:i,up:l}=L(o,r,a),c,u=()=>null;if(n<0){let p=Jt(o,s);if(p>=0)c=o[p].at;else if(l>=0)c=o[l].at,u=mt(o,s,l);else return!0}else{let p=i+1;if(p<o.length&&o[p].up===l)c=o[o[p].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,u=mt(o,s,l);else return!0}return e&&e(Zt(t,o,s,i,c,u).scrollIntoView()),!0},xe=8,nt=(n,t)=>A(n.node)&&A(t.node)&&b(n.node)===b(t.node);function ye(n,t){t=At(t);let e=y(n.doc);if(!e.length)return!1;let[o,r]=rt(n.doc,n.selection,e),a=e[o];if(A(a.node)&&o>0&&nt(e[o-1],a)){if(a.node.attrs.indent>e[o-1].node.attrs.indent)return!0;for(let i=o;i<=Math.max(r,a.subEnd);i++)if(e[i].node.attrs.indent>=xe)return!0;if(t){let i=n.tr,l=r;for(let u=o;u<=l;u++)l=Math.max(l,e[u].subEnd);let c=o-1;for(let u=o;u<=l&&nt(e[u],a);u++)i.setNodeMarkup(e[u].at,null,{...e[u].node.attrs,indent:e[u].node.attrs.indent+1}),c=u;i.setMeta(R,G(e,o,c,e[o].at,u=>u.i>=o&&u.i<=c?{indent:u.node.attrs.indent+1}:null)),t(i)}return!0}let s=Jt(e,o);if(s<0||!S(e[s].node)||e[s].subEnd!==o-1)return!0;if(t){let{hi:i}=L(e,o,r),l=n.tr,c=b(a.node),u=e[s].node.attrs.id,p=[];for(let f=o;f<=i;f++)b(e[f].node)===c&&(l.setNodeMarkup(e[f].at,null,{...e[f].node.attrs,parent:u}),p.push(e[f].node.attrs.id));e[s].node.attrs.open||l.setNodeMarkup(e[s].at,null,{...e[s].node.attrs,open:!0});let d=G(e,o,i,e[o].at,f=>f.i>=o&&f.i<=i&&b(f.node)===c?{parent:u}:null);l.setMeta(R,{...d,ids:p,attrs:e[s].node.attrs.open?d.attrs:{...d.attrs,[u]:{open:!0}}}),t(l)}return!0}function St(n,t){t=At(t);let e=y(n.doc);if(!e.length)return!1;let[o,r]=rt(n.doc,n.selection,e),a=e[o];if(A(a.node)&&a.node.attrs.indent>0){if(t){let{lo:u,hi:p}=L(e,o,r),d=n.tr,f=new Set;for(let m=o;m<=r;){let h=e[m];if(A(h.node)&&h.node.attrs.indent>0)for(let x=m;x<=h.subEnd;x++)A(e[x].node)&&(d.setNodeMarkup(e[x].at,null,{...e[x].node.attrs,indent:e[x].node.attrs.indent-1}),f.add(x));m=h.subEnd+1}d.setMeta(R,G(e,u,p,e[u].at,m=>f.has(m.i)?{indent:m.node.attrs.indent-1}:null)),t(d)}return!0}if(b(a.node)===null)return!0;let{lo:i,hi:l}=L(e,o,r),c=e[i].up;for(;c>=0&&!S(e[c].node);)c=e[c].up;if(c<0)return!0;if(t){let u=mt(e,i,c),p=e[c].subEnd;if(l===p){let d=n.tr;for(let f=i;f<=l;f++){let m=u(e[f]);m&&d.setNodeMarkup(e[f].at,null,{...e[f].node.attrs,...m})}d.setMeta(R,G(e,i,l,e[i].at,u)),t(d)}else t(Zt(n,e,i,l,e[p].end,u).scrollIntoView())}return!0}function te(n){let t=n.tr;return n.selection.empty||t.deleteSelection(),t}function Ae(n,t){let{$from:e,$to:o,empty:r}=n.selection;if(e.depth!==1||!A(e.parent)||!e.sameParent(o))return!1;if(r&&e.parent.content.size===0){let m=e.parent;return m.attrs.indent>0?St(n,t):(t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:m.attrs.id,pos:m.attrs.pos,parent:m.attrs.parent})),!0)}let a=te(n),s=a.selection.$from,i=s.parent,l=y(a.doc),c=s.index(0),u=s.parentOffset===0,p=s.parentOffset===i.content.size,d=l[c+1],f=p&&d&&nt(d,l[c])&&d.node.attrs.indent>i.attrs.indent;return u?(a.split(s.pos,1,[{type:E.list_item,attrs:i.attrs}]),a.setNodeMarkup(l[c].at,null,{...i.attrs,checked:!1})):a.split(s.pos,1,[{type:E.list_item,attrs:{...i.attrs,checked:!1,indent:i.attrs.indent+(f?1:0)}}]),t&&t(a.scrollIntoView()),!0}function Se(n,t){let{$from:e,$to:o}=n.selection;if(e.depth!==1||!S(e.parent)||!e.sameParent(o))return!1;let r=te(n),a=r.selection.$from,s=a.parent,i=y(r.doc),l=a.index(0),c=i[l],u=c.subEnd>l;if(s.content.size===0&&!u)return r.setNodeMarkup(c.at,E.paragraph,{id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent}),t&&t(r),!0;if(a.parentOffset===0&&s.content.size>0)return r.insert(c.at,E.paragraph.create({parent:b(s)})),t&&t(r.scrollIntoView()),!0;let p=s.content.cut(a.parentOffset);if(s.attrs.open)r.split(a.pos,1,[{type:E.paragraph,attrs:{parent:s.attrs.id}}]);else{let d=i[c.subEnd].end,f=r.steps.length;r.delete(a.pos,c.end-1);let m=r.mapping.slice(f).map(d);r.insert(m,E.toggle.create({parent:b(s),open:!1},p)),r.setSelection(I.create(r.doc,m+1))}return t&&t(r.scrollIntoView()),!0}function we(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parent.type!==E.paragraph||e.parent.content.size)return!1;let r=b(e.parent);if(r===null)return!1;let a=y(n.doc),s=e.index(0),i=a.findIndex(l=>l.node.attrs.id===r);if(i<0||a[i].subEnd!==s)return!1;if(t){let l=a[s].node.attrs.id,c=b(a[i].node),u=s>0?a[s-1].node:null,p=n.tr.setNodeMarkup(a[s].at,null,{...e.parent.attrs,parent:c});p.setMeta(R,{ids:[l],afterId:u?u.attrs.id:null,parent:b(u??a[s].node),attrs:{[l]:{parent:c}}}),t(p)}return!0}function Ee(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!e.parent.isTextblock||e.parent.type.spec.code)return!1;let r=e.parent;if(A(r)||S(r)||b(r)===null||e.parentOffset!==r.content.size)return!1;if(t){let a=n.tr.split(e.pos,1,[{type:E.paragraph,attrs:{parent:b(r)}}]);t(a.scrollIntoView())}return!0}function Me(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!A(e.parent)||e.parentOffset!==0)return!1;if(e.parent.attrs.indent>0)return St(n,t);let r=e.parent;return t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Te(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!S(e.parent)||e.parentOffset!==0)return!1;let r=e.parent;return t&&t(n.tr.setNodeMarkup(e.before(),E.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function wt(n,t){if(t<=0||!n[t-1].hidden)return-1;let e=t-1;for(;e>=0&&n[e].hidden;)e--;return e>=0&&S(n[e].node)&&n[e].subEnd>=t-1?e:-1}function Et(n,t,e,o){let r=n.tr,a=t[o],s=t[e].end-1;return r.delete(a.at,a.end),a.node.content.size&&r.insert(s,a.node.content),r.setSelection(I.create(r.doc,s))}function ve(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0||!e.parent.isTextblock)return!1;let r=y(n.doc),a=e.index(0),s=wt(r,a);return s<0?!1:(t&&t(Et(n,r,s,a).scrollIntoView()),!0)}function Ie(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||!S(e.parent)||e.parent.attrs.open||e.parentOffset!==e.parent.content.size)return!1;let r=y(n.doc),a=e.index(0),s=r[a].subEnd+1;return s===a+1?!1:(s>=r.length||!r[s].node.isTextblock||t&&t(Et(n,r,a,s).scrollIntoView()),!0)}function Ne(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1)return!1;let r=e.parent,a=e.index(0);if(!r.isTextblock||r.type.spec.code||S(r)||!r.content.size||e.parentOffset!==r.content.size||a+1>=n.doc.childCount||!S(n.doc.child(a+1)))return!1;if(t&&r.type!==E.paragraph)t(n.tr.setSelection(I.create(n.doc,e.after()+1)).scrollIntoView());else if(t){let s=e.before(),i=n.tr.insert(e.after()+1,r.content).delete(s,e.after());t(i.setSelection(I.create(i.doc,s+1+r.content.size)).scrollIntoView())}return!0}var ee=n=>(t,e)=>{let{$from:o,empty:r}=t.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let a=o.parent,s=o.index(0);if(o.parentOffset!==(n<0?0:a.content.size))return!1;let i=y(t.doc),l=n<0?wt(i,s):-1,c=l>=0?l:s+n;if(c<0||c>=i.length)return!1;let u=i[c].node;if(!u.isTextblock||!a.type.spec.code&&!u.type.spec.code)return!1;if(!e)return!0;let p=t.tr,d=i[s],f=i[c],m=n<0?f.end-1:f.at+1;return!a.content.size&&!a.type.spec.code?p.delete(d.at,d.end).setSelection(I.create(p.doc,p.mapping.map(m))):!u.content.size&&!u.type.spec.code?p.delete(f.at,f.end):p.setSelection(I.create(p.doc,m)),e(p.scrollIntoView()),!0},Oe=ee(-1),Ce=ee(1);function De(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0||!e.parent.isTextblock)return!1;let r=e.parent;if(A(r)||S(r)||b(r)===null)return!1;let a=e.index(0);return n.doc.child(a-1).attrs.id!==b(r)?!1:(t&&t(Et(n,y(n.doc),a-1,a).scrollIntoView()),!0)}function ne(n,t,e,o=y(n.doc)){let r=o[t];return n.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:e}).setMeta("addToHistory",!1)}function $e(n,t){let{$from:e}=n.selection;return e.depth!==1||!S(e.parent)?!1:(t&&t(ne(n,e.index(0),!e.parent.attrs.open)),!0)}function Be(n){let t=[];for(let e of n)!S(e.node)||e.hidden||e.node.attrs.open||e.subEnd===e.i||t.push({line:e.at+1,sumEnd:e.end-1,from:e.end,to:n[e.subEnd].end});return t}var gt=(n,t)=>t>n.from&&t<n.to;function bt(n,t,e,o){if(o>0){let r=e.to;for(;;){let a=ot.findFrom(n.resolve(r),1,!0);if(!a)break;let s=t.find(i=>gt(i,a.head));if(!s)return a.head;r=s.to}}return e.sumEnd}function Wt(n,t,e,o=-1,r=!1){if(!e.length)return null;let{anchor:a,head:s}=t;if(!(t instanceof I)){let c=e.find(u=>t.from>=u.from&&t.from<u.to);return c?I.create(n,c.sumEnd):null}let i=e.find(c=>gt(c,s));i&&(s=bt(n,e,i,o));let l=e.find(c=>gt(c,a));if(l&&(a=l.sumEnd),!r&&a!==s){let c=Math.min(a,s),u=Math.max(a,s),p=e.find(d=>(c>d.line||c===d.sumEnd)&&c<d.from&&u>=d.to);if(p){let d=c===p.sumEnd?bt(n,e,p,1):p.line;a<s?a=d:s=d}}return a===t.anchor&&s===t.head?null:I.create(n,a,s)}var Le=n=>{let t="";for(;n>0;)n--,t=String.fromCharCode(97+n%26)+t,n=Math.floor(n/26);return t},Pe=n=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((t,[e,o])=>{for(;n>=e;)t+=o,n-=e;return t},"");function ze(n){let t=new Map,e=[];return n.forEach((o,r)=>{if(!A(o.node)){e=[];return}r>0&&!nt(n[r-1],o)&&(e=[]);let a=o.node.attrs.indent;if(e.length=a+1,o.node.attrs.kind!=="ordered"){e[a]=0;return}e[a]=(e[a]||0)+1;let s=e[a];t.set(r,`${a%3===0?s:a%3===1?Le(s):Pe(s)}.`)}),t}var U=new pe("page-collapse"),Ve=["id","parent","indent","kind","open"];function Re(n,t){if(n.childCount!==t.childCount)return!1;for(let e=0;e<n.childCount;e++){let o=n.child(e),r=t.child(e);if(o!==r){if(o.type!==r.type)return!1;for(let a of Ve)if(o.attrs[a]!==r.attrs[a])return!1}}return!0}function Xt(n){let t=y(n);return{decos:qe(n,t),ranges:Be(t)}}function qe(n,t=y(n)){let{Decoration:e,DecorationSet:o}=B,r=ze(t),a=[];for(let s of t){let i={};s.hidden&&(i.class="page-hidden",i["aria-hidden"]="true"),s.depth&&(i.style=`--page-depth:${s.depth}`),r.has(s.i)&&(i["data-marker"]=r.get(s.i)),S(s.node)&&(i["aria-expanded"]=s.node.attrs.open?"true":"false"),Object.keys(i).length&&a.push(e.node(s.at,s.end,i)),S(s.node)&&!s.hidden&&a.push(e.widget(s.at+1,()=>_e(s.node),{side:-1,ignoreSelection:!0,key:`t:${s.node.attrs.id}:${s.node.attrs.open}`}))}return o.create(n,a)}function _e(n){let t=document.createElement("button");return t.type="button",t.className="page-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n.attrs.open?"Collapse":"Expand"),t.setAttribute("data-toggle",n.attrs.id||""),t}function Un(){let n=!1;return new xt({key:U,state:{init:(t,e)=>Xt(e.doc),apply(t,e,o,r){if(!t.docChanged)return e;if(!Re(o.doc,r.doc))return Xt(r.doc);let a=t.mapping;return{decos:e.decos.map(a,r.doc),ranges:e.ranges.map(s=>({line:a.map(s.line,-1),sumEnd:a.map(s.sumEnd),from:a.map(s.from),to:a.map(s.to,-1)}))}}},appendTransaction(t,e,o){if(!t.some(i=>i.docChanged||i.selectionSet))return null;let a=t.some(i=>i.selectionSet)&&o.selection.head>=e.selection.head?1:-1,s=Wt(o.doc,o.selection,U.getState(o).ranges,a,n);return s?o.tr.setSelection(s):null},props:{decorations:t=>U.getState(t).decos,handleDOMEvents:{mousedown:(t,e)=>{let o=e.target.closest?.(".page-toggle-button");if(o){e.preventDefault();let s=y(t.state.doc),i=s.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return i>=0&&t.dispatch(ne(t.state,i,!s[i].node.attrs.open,s)),!0}n=!0;let r=t.dom.ownerDocument.defaultView,a=()=>{n=!1,r.removeEventListener("mouseup",a,!0);let s=Wt(t.state.doc,t.state.selection,U.getState(t.state).ranges,1,!1);s&&t.dispatch(t.state.tr.setSelection(s))};return r.addEventListener("mouseup",a,!0),!1}},handleKeyDown(t,e){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[e.key];if(!o||e.altKey||e.metaKey||e.ctrlKey)return!1;let{head:r}=t.state.selection,s=e.key==="ArrowDown"||e.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!t.endOfTextblock(s))return!1;let i=y(t.state.doc),{ranges:l}=U.getState(t.state),u=t.state.doc.resolve(r).index(0),p=null;if(o>0){let f=l.find(m=>m.from===i[u].end);f&&(p=bt(t.state.doc,l,f,1))}else{let f=wt(i,u);f>=0&&(p=e.shiftKey?i[f].at+1:i[f].end-1)}if(p===null||p===r)return!1;let d=e.shiftKey?t.state.selection.anchor:p;return t.dispatch(t.state.tr.setSelection(I.create(t.state.doc,d,p)).scrollIntoView()),!0}}})}var Qt=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Ke(n){let t=n.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`);if(!t.some(r=>Qt.test(r)))return null;let e=[],o=[];for(let r of t){if(!r.trim())continue;let a=Qt.exec(r);if(!a){e.length=0,o.push(E.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let s=a[1].replace(/\t/g," ").length;for(;e.length&&e[e.length-1]>s;)e.pop();(!e.length||e[e.length-1]<s)&&e.push(s);let i=Math.min(e.length-1,o.length&&A(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=a[4]!==void 0?"check":a[3]!==void 0?"ordered":"bullet";o.push(E.list_item.create({kind:l,indent:i,checked:a[4]==="x"||a[4]==="X"},a[5]?T.text(a[5]):null))}return new N.Slice(N.Fragment.from(o),0,0)}var dt=new Set(["UL","OL"]),ut=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function He(n){let t=n.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(t)return{check:!0,checked:t.checked||t.hasAttribute("checked")};if(n.getAttribute("role")==="checkbox"||n.hasAttribute("aria-checked"))return{check:!0,checked:n.getAttribute("aria-checked")==="true"};if(n.hasAttribute("data-checked"))return{check:!0,checked:n.getAttribute("data-checked")==="true"};let o=n.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||n.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!n.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function je(n){let t=(n.getAttribute("style")||"")+";"+(n.parentElement?.getAttribute("style")||""),e=/list-style-type\s*:\s*([a-z-]+)/i.exec(n.getAttribute("style")||"")?.[1];return e?/decimal|alpha|roman|latin|greek/.test(e)?"ordered":"bullet":n.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ue(n,t=globalThis.document){let e=t.createElement("div");e.innerHTML=n;for(let d of e.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))d.replaceWith(...d.childNodes);let o=0,r=t.createElement("div"),a=d=>{let f=parseInt(d.getAttribute("aria-level"),10);if(f>0)return f-1;let m=-1;for(let h=d.parentElement;h&&h!==e;h=h.parentElement)dt.has(h.tagName)&&m++;return Math.max(0,m)},s=[];function i(d,f,m){let h=t.createElement("div"),{check:x,checked:g}=He(d);h.setAttribute("data-page-li",""),h.setAttribute("data-kind",x?"check":je(d)),h.setAttribute("data-checked",g?"true":"false"),h.dataset.depth=String(a(d)),f&&h.setAttribute("data-page-parent",f);let v=!0,D=[];for(let w of[...d.childNodes]){if(w.nodeType===1&&dt.has(w.tagName)){D.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&ut.has(w.tagName)){v||h.appendChild(t.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||h.appendChild(P);v=!1;continue}h.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(v=!1)}}m.appendChild(h),s.push(h);for(let w of D)l(w,f,m)}function l(d,f,m){let h=null,x=g=>{h||(h=t.createElement("p"),f&&h.setAttribute("data-page-parent",f),m.appendChild(h)),h.appendChild(g)};for(let g of[...d.childNodes])if(!(g.nodeType===1&&(g.tagName==="META"||g.tagName==="STYLE"))){if(g.nodeType===1&&g.tagName==="BR"){h=null;continue}if(g.nodeType!==1){g.nodeType===3&&(h||g.textContent.trim())&&x(g);continue}if(!ut.has(g.tagName)&&g.tagName!=="ASIDE"){x(g);continue}if(h=null,dt.has(g.tagName)){l(g,f,m);continue}if(g.tagName==="LI"){i(g,f,m);continue}if(g.tagName==="DETAILS"){let v=`paste-${++o}`,D=g.querySelector(":scope > summary"),w=t.createElement("div");w.setAttribute("data-page-toggle",v),g.hasAttribute("open")&&w.setAttribute("data-open","true"),f&&w.setAttribute("data-page-parent",f),D&&w.append(...D.childNodes),m.appendChild(w);for(let P of[...g.childNodes])if(P!==D){let Ct=t.createElement("div");Ct.appendChild(P),l(Ct,v,m)}continue}if(g.tagName==="DIV"&&!g.hasAttribute("data-page-li")&&[...g.children].some(v=>ut.has(v.tagName))){l(g,f,m);continue}f&&g.setAttribute("data-page-parent",f),m.appendChild(g)}}l(e,null,r);let c=s.length?Math.min(...s.map(d=>+d.dataset.depth)):0,u=null;for(let d of s){let f=+d.dataset.depth-c,m=u&&d.previousElementSibling===u?+u.getAttribute("data-indent")+1:0;d.setAttribute("data-indent",String(Math.min(f,m))),d.removeAttribute("data-depth"),u=d}let p=d=>{if(d.nodeType!==1||d.tagName==="IMG")return[d.cloneNode(!0)];let f=[],m=d.cloneNode(!1);for(let h of d.childNodes)for(let x of p(h))x.nodeType===1&&x.tagName==="IMG"?(m.hasChildNodes()&&f.push(m),f.push(x),m=d.cloneNode(!1)):m.appendChild(x);return(m.hasChildNodes()||!f.length)&&f.push(m),f};for(let d of[...r.children]){if(!d.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-page-li], div.page-li")||!d.querySelector("img"))continue;let f=p(d),m=d.getAttribute("data-page-parent");if(m)for(let h of f)h.setAttribute("data-page-parent",m);d.replaceWith(...f)}return r.innerHTML}var ft=(n,t=0)=>n!==null&&n!==""&&Number.isInteger(+n)&&+n>=t?+n:null,M=n=>n.getAttribute("data-page-parent")||null,Fe=$t([]).type,Ge=Object.create(T,{marks:{value:{...T.marks,[tt]:Fe}}}),oe=n=>{let t;try{t=jt(n)}catch{return null}return!t||typeof t.t!="string"||t.t==="opaque_block"||Object.hasOwn(qt,t.t)?null:t},We=n=>{let t=oe(n);return t?{raw:t,parent:M(n)}:!1},Xe=n=>{let t=oe(n);if(!t||typeof t.c!="string"||!t.c)return N.Fragment.empty;let e=zt(t.m,t.c.length);return N.Fragment.from(Vt(T,t.c,e,T.nodes.opaque_block))},Qe=n=>{try{return{entries:_t(n.getAttribute(lt))}}catch{return!1}},Ye=new N.DOMParser(Ge,[{tag:`div[${Rt}]`,node:"opaque_block",getAttrs:We,getContent:Xe},{tag:`span[${lt}]`,mark:tt,getAttrs:Qe},{tag:"div[data-page-li]",node:"list_item",getAttrs:n=>({kind:n.getAttribute("data-kind")||"bullet",indent:+n.getAttribute("data-indent")||0,checked:n.getAttribute("data-checked")==="true",parent:M(n)})},{tag:"div.page-li",node:"list_item",getAttrs:n=>({kind:n.getAttribute("data-kind")||"bullet",indent:+n.getAttribute("data-indent")||0,checked:n.getAttribute("data-checked")==="true",parent:M(n)})},{tag:"div[data-page-toggle]",node:"toggle",getAttrs:n=>({id:n.getAttribute("data-page-toggle"),open:n.getAttribute("data-open")==="true",parent:M(n)})},{tag:"div.page-toggle",node:"toggle",getAttrs:n=>({id:n.getAttribute("data-id"),open:n.getAttribute("data-open")==="true",parent:null})},{tag:"h1",node:"heading",getAttrs:n=>({level:1,parent:M(n)})},{tag:"h2",node:"heading",getAttrs:n=>({level:2,parent:M(n)})},{tag:"h3",node:"heading",getAttrs:n=>({level:3,parent:M(n)})},{tag:"h4",node:"heading",getAttrs:n=>({level:3,parent:M(n)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:n=>({lang:n.getAttribute("data-lang")||"",parent:M(n)})},{tag:"hr",node:"divider",getAttrs:n=>({parent:M(n)})},{tag:"aside.page-callout",node:"callout",getAttrs:n=>({parent:M(n)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:n=>{let t=n.querySelector("img"),e=Z(t?.getAttribute("src"));return e?{src:e,alt:t.getAttribute("alt")||"",caption:n.querySelector("figcaption")?.textContent||"",width:ft(n.getAttribute("data-width")??t.getAttribute("width"),1),align:fe(n.getAttribute("data-align")),parent:M(n)}:!1}},{tag:"img[src]",node:"image",getAttrs:n=>{let t=Z(n.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",width:ft(n.getAttribute("width"),1),parent:M(n)}:!1}},{tag:'div.page-file, div[data-type="file"]',node:"file",getAttrs:n=>{let t=C(n.getAttribute("data-src"));return t?{src:t,name:n.getAttribute("data-name")||"file",size:ft(n.getAttribute("data-size")),mime:n.getAttribute("data-mime")||null,parent:M(n)}:!1}},{tag:"p",node:"paragraph",getAttrs:n=>({parent:M(n)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:n=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(n.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:n=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(n.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:n=>/font-style\s*:\s*italic/.test(n.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:n=>{let t=C(n.getAttribute("href"));return t?{href:t}:!1}},{tag:"blockquote",node:"quote",getAttrs:n=>({parent:M(n)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:n=>at("highlight",{color:n.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:n=>at("text_color",{color:n.getAttribute("data-color")})??!1}]);function Je(n,t){let e=t.selection.$from,o=t.selection instanceof k,r=o?t.doc.child(t.selection.span().lo):e.depth>=1?e.node(1):null,a=r?b(r):null,s=r&&A(r)?r.attrs.indent:0,i=new Map;n.content.forEach(h=>{S(h)&&h.attrs.id&&i.set(h.attrs.id,z())});let l=[];n.content.forEach(h=>{if(!h.type.spec.group?.includes("block")){l.push(h);return}let x=b(h),g={...h.attrs,pos:null,id:S(h)?i.get(h.attrs.id)??null:null,parent:x!==null&&i.has(x)?i.get(x):a};A(h)&&(g.indent=h.attrs.indent+s),l.push(h.type.create(g,h.content,h.marks))});let c=!r||!(A(r)||S(r)),u=h=>h&&(A(h)||S(h)),p=c&&u(l[0])?0:n.openStart,d=l[l.length-1],f=new Set(i.values()),m=c&&(u(d)||d&&f.has(b(d)))?0:n.openEnd;return new N.Slice(N.Fragment.from(l),o?0:p,o?0:m)}var kt=class extends N.DOMSerializer{serializeFragment(t,e,o){let r=super.serializeFragment(t,e,o);if(!t.firstChild?.isBlock)return r;let a=[...r.childNodes];return t.forEach((s,i,l)=>{let c=a[l];!c||c.nodeType!==1||(b(s)!==null&&c.setAttribute("data-page-parent",b(s)),S(s)&&s.attrs.id&&c.setAttribute("data-page-toggle",s.attrs.id),s.type===E.image&&s.attrs.width&&c.setAttribute("data-width",String(s.attrs.width)))}),r}},re=N.DOMSerializer.fromSchema(T),Ze=n=>{let{t,...e}=n.attrs.raw??{},{c:o,m:r}=Lt(n.content);return o?{t,...e,c:o,...r.some(Boolean)?{m:Pt(r)}:{}}:{t,...e}},tn=n=>["div",{"data-type":"newer-format",...Kt(Ze(n))},0],en=n=>["span",Ht(n.attrs.entries),0],nn={...re.nodes,opaque_block:tn},on={...re.marks,[tt]:en},rn=new kt(nn,on);function sn(n,t,e){let{$from:o}=n.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!S(r)||r.attrs.open||e.content.childCount<2)return!1;let a=n.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(e);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function an(n){let t=!1;return n?.content?.descendants(e=>t?!1:((e.type===E.quote||e.isText&&e.marks.some(o=>Bt.has(o.type.name)))&&(t=!0),!t)),t}function cn(n,t,e){let o=n.state.selection.from,r=n.state.selection.to,a=()=>{let s=e.content.textBetween(0,e.content.size,`
|
|
4
|
+
`," ");return!n.isDestroyed&&s&&n.dispatch(n.state.tr.insertText(s,o,r)),!1};return import("./c-DFS4XZJV.js").then(({pasteFormats:s})=>s(n,e,o,r),a),!0}function Fn(){return new xt({props:{handlePaste(n,t,e){return an(e)?cn(n,t,e):sn(n,t,e)},clipboardSerializer:rn,transformPastedHTML:n=>Ue(n),clipboardParser:Ye,clipboardTextParser:(n,t,e)=>e?null:Ke(n),transformPasted:(n,t)=>Je(n,t.state)}})}var F=J.chainCommands(Me,Te,Oe,De,ve),V=J.chainCommands(Ie,Ne,Ce),Gn={Enter:J.chainCommands(Ae,Se,we,Ee),Backspace:F,"Shift-Backspace":F,"Mod-Backspace":F,"Alt-Backspace":F,"Ctrl-h":F,Delete:V,"Shift-Delete":V,"Mod-Delete":V,"Alt-Delete":V,"Ctrl-d":V,"Ctrl-Alt-Backspace":V,Tab:ye,"Shift-Tab":St,"Mod-Shift-ArrowUp":Gt(-1),"Mod-Shift-ArrowDown":Gt(1),"Mod-Enter":$e};function Qn(){return new O.Plugin({view(n){let t=n.dom.ownerDocument.createElement("div");return t.className="page-live",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),n.dom.parentElement.appendChild(t),{destroy:()=>t.remove()}}})}function Mt(n,t){let e=n.dom.parentElement?.querySelector(".page-live");e&&(e.textContent="",e.textContent=t)}var se=new O.PluginKey("tableRect");var{Selection:ln,TextSelection:_,NodeSelection:dn,Plugin:un,PluginKey:fn}=O,W=T.nodes,K=n=>Y.closeHistory(n).setMeta(yt,!0);function X(n,t,e=t,o=y(n)){let{lo:r,hi:a}=L(o,Math.min(t,e),Math.max(t,e)),s=o[r].at,i=o[a].end;return t<=e?new k(n.resolve(s),n.resolve(i)):new k(n.resolve(i),n.resolve(s))}function pn(n,t=y(n.doc)){let[e,o]=Yt(n.doc,n.selection,t);return L(t,e,o)}var q=(n,t,e)=>{for(let o=t;o>=0&&o<n.length;o+=e)if(!n[o].hidden)return o;return-1};function hn(n,t){if(n.selection instanceof k)return!1;let e=Math.min(n.selection.$head.index(0),n.doc.childCount-1);return t&&t(n.tr.setSelection(X(n.doc,e))),!0}var ae=n=>(t,e)=>{let o=t.selection;if(!(o instanceof k))return!1;let r=y(t.doc),{lo:a,hi:s}=o.span(t.doc),i=n<0?q(r,a-1,-1):q(r,s+1,1);return i<0||e&&e(t.tr.setSelection(X(t.doc,i)).scrollIntoView()),!0};function vt(n,t,e,o){if(o<0)return t;let r=t;for(;n[r].subEnd<e;)r=n[r].subEnd+1;return r}function mn(n,t){for(let e=t-1;e>=0;e--)if(n[e].up===n[t].up)return e;return t}var ie=n=>(t,e)=>{let o=t.selection;if(!(o instanceof k))return!1;let r=y(t.doc),{lo:a,hi:s}=o.span(t.doc),i=o.anchor<=o.head,l=i?a:vt(r,a,s,1),c=i?vt(r,a,s,1):a;return n>0?i||a===s||c===l?c=q(r,(i?s:c)+1,1):c=q(r,r[c].subEnd+1,1):!i||c===l?c=q(r,(i?c:a)-1,-1):c=mn(r,c),c<0||e&&e(t.tr.setSelection(X(t.doc,l,c,r)).scrollIntoView()),!0};function st(n,t){let e=n.selection;if(!(e instanceof k))return!1;if(t){let o=n.tr.delete(e.from,e.to);o.doc.content.size===0&&o.insert(0,W.paragraph.create()),o.setSelection(ln.near(o.doc.resolve(Math.min(e.from,o.doc.content.size)),-1)),t(K(o).scrollIntoView())}return!0}function gn({columns:n={},cards:t={}}){let e=ct(n),o=new Map(e.map(s=>[s,z("c")])),r=it(null,null,e.length),a={};for(let s of new Set([...e,...Object.values(t).map(i=>i.col)])){let i=ct(Object.fromEntries(Object.entries(t).filter(([,c])=>c.col===s))),l=it(null,null,i.length);i.forEach((c,u)=>{a[z("k")]={...t[c],col:o.get(s)??s,pos:l[u]}})}return{columns:Object.fromEntries(e.map((s,i)=>[o.get(s),{...n[s],pos:r[i]}])),cards:a}}function bn(n,t){let e=y(n.doc);if(!e.length)return!1;let{lo:o,hi:r}=pn(n,e);if(t){let a=new Map;for(let p=o;p<=r;p++)e[p].node.type===W.toggle&&e[p].node.attrs.id&&a.set(e[p].node.attrs.id,z());let s=[];for(let p=o;p<=r;p++){let d=e[p].node,f=d.attrs.parent??null;s.push(d.type.create({...d.attrs,...d.type===W.board?gn(d.attrs):{},id:a.get(d.attrs.id)??null,pos:null,parent:a.get(f)??f},d.content,d.marks))}let i=e[r].end,l=i-e[o].at,c=n.tr.insert(i,s),u=n.selection;c.setSelection(u instanceof k?new k(c.doc.resolve(i),c.doc.resolve(i+l)):_.create(c.doc,u.anchor+l,u.head+l)),t(K(c).scrollIntoView())}return!0}var le=(n,t,e,o)=>{for(let r=e;r<=o;r++)if(t[r].node.isTextblock)return t[r].end-1;return-1};function ce(n,t){let e=n.selection;if(!(e instanceof k))return!1;let o=y(n.doc),{lo:r,hi:a}=e.span(n.doc);if(t){let s=le(n.doc,o,r,a);t(n.tr.setSelection(s>=0?_.create(n.doc,s):dn.create(n.doc,o[r].at)))}return!0}var kn=({$from:n,$to:t})=>{if(n.depth<2||t.depth<2)return null;let e=n.node(1);return e.type.name==="table"&&t.node(1)===e?{from:n.before(1),to:n.after(1)}:null};function xn(n,t){let e=n.selection,{$from:o,$to:r}=e,a=o.parent.isTextblock&&o.sameParent(r)&&!se.getState(n),s=a&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(a&&!s&&o.parent.content.size)return t&&t(n.tr.setSelection(_.create(n.doc,o.start(),o.end()))),!0;let i=kn(e);return i&&!(e instanceof k&&e.from===i.from&&e.to===i.to)?(t&&t(n.tr.setSelection(new k(n.doc.resolve(i.from),n.doc.resolve(i.to)))),!0):(t&&t(n.tr.setSelection(new k(n.doc.resolve(0),n.doc.resolve(n.doc.content.size)))),!0)}var yn=(n,t)=>{let e=n.state,o=e.selection;if(!(o instanceof k))return!1;let r=y(e.doc),{lo:a,hi:s}=o.span(e.doc),i=le(e.doc,r,a,s),l=e.tr;if(i<0){let c=r[s].end;l.insert(c,W.paragraph.create({parent:r[a].node.attrs.parent??null})),l.setSelection(_.create(l.doc,c+1)),K(l)}else l.setSelection(_.create(l.doc,i));return l.insertText(t),n.dispatch(l.scrollIntoView()),!0},An=(n,t,e)=>{let o=n.selection;if(!(o instanceof _)||!e?.endOfTextblock("down"))return!1;let{$anchor:r,$head:a}=o;if(r.depth!==1||r.parent.type!==W.toggle||r.parent.attrs.open||r.index(0)!==a.index(0))return!1;let s=y(n.doc),i=r.index(0),l=q(s,s[i].subEnd+1,1);return l<0?!1:(t&&t(n.tr.setSelection(X(n.doc,i,l,s)).scrollIntoView()),!0)},Sn=n=>(t,e,o)=>t.selection instanceof k&&n(t,e,o),wn={Escape:(n,t)=>ce(n,t)||hn(n,t),Enter:Sn(ce),ArrowUp:ae(-1),ArrowDown:ae(1),"Shift-ArrowUp":ie(-1),"Shift-ArrowDown":(n,t,e)=>ie(1)(n,t)||An(n,t,e),Backspace:st,"Alt-Backspace":st,"Ctrl-h":st,Delete:st,"Mod-d":bn,"Mod-a":xn},Tt=new fn("page-blocksel"),En=n=>{let t=n.selection,{lo:e,hi:o}=t.span(n.doc);return y(n.doc).filter(r=>r.i>=e&&r.i<=o&&!r.hidden).length};function ao(){let n=Dt.keymap(wn);return new un({key:Tt,state:{init:()=>0,apply:(t,e,o,r)=>t.getMeta(et)&&o.selection instanceof k&&!(r.selection instanceof k)?e+1:e},props:{handleKeyDown:(t,e)=>n.props.handleKeyDown(t,e),handleTextInput:(t,e,o,r)=>yn(t,r),decorations(t){let e=t.selection;if(!(e instanceof k))return null;let o=[];return t.doc.nodesBetween(e.from,e.to,(r,a)=>(o.push(B.Decoration.node(a,a+r.nodeSize,{class:"page-block-selected"})),!1)),B.DecorationSet.create(t.doc,o)},createSelectionBetween(t,e,o){let r=t.state.selection;return r instanceof k&&e.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(t,e){let o=t.state.selection;if(!e.shiftKey||!(o instanceof k)||e.button!==0)return!1;let r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return!1;let a=y(t.state.doc),s=Math.min(t.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),a.length-1),{lo:i,hi:l}=o.span(t.state.doc),c=o.anchor<=o.head?i:vt(a,i,l,1);return e.preventDefault(),t.dispatch(t.state.tr.setSelection(X(t.state.doc,c,s,a))),!0}}},view:()=>({update(t,e){let o=t.state.selection,r=e.selection;if(o instanceof k&&!o.eq(r)){let a=En(t.state);Mt(t,`${a} ${a===1?"block":"blocks"} selected`)}else r instanceof k&&!(o instanceof k)&&Mt(t,Tt.getState(t.state)!==Tt.getState(e)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Mn,PluginKey:Tn,TextSelection:Q}=O,{Decoration:vn,DecorationSet:In}=B,j=T.marks.link,Nn=n=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(n.trim())&&C(n)!==null;function It(n,t){let e=n.resolve(t);if(!e.parent.inlineContent)return null;let o=j.isInSet((e.nodeAfter??e.nodeBefore)?.marks??[]);if(!o)return null;let r=[];e.parent.forEach((c,u)=>r.push({n:c,off:u}));let a=r.findIndex(({n:c,off:u})=>u<=e.parentOffset&&e.parentOffset<=u+c.nodeSize&&o.isInSet(c.marks));if(a<0)return null;let s=a,i=a;for(;s>0&&o.isInSet(r[s-1].n.marks);)s--;for(;i<r.length-1&&o.isInSet(r[i+1].n.marks);)i++;let l=e.start();return{from:l+r[s].off,to:l+r[i].off+r[i].n.nodeSize,href:o.attrs.href}}function de(n,t,e,o){let r=n.tr.removeMark(t,e,j);return o&&r.addMark(t,e,j.create({href:o})),K(r)}var $=new Tn("page-link"),Nt=new WeakMap,ue=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,On=ue('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),Cn=ue('<path d="M4 4l8 8M12 4l-8 8"/>');function H(n,t,e,o={}){let r=n.createElement(t);e&&(r.className=e);for(let[a,s]of Object.entries(o))r.setAttribute(a,s);return r}function Dn(n,t,e){let o=null;return n.doc.nodesBetween(t,e,r=>{let a=j.isInSet(r.marks);a&&(o=a.attrs.href)}),o}var Ot=class{constructor(t){this.view=t,this.shell=t.dom.parentElement,this.doc=t.dom.ownerDocument,this.mode=null,this.range=null;let e=this.doc;this.dom=H(e,"div","page-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=H(e,"input","page-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=H(e,"a","page-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=H(e,"a","page-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=On,this.edit=H(e,"button","page-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=H(e,"button","page-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=Cn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Nt.set(t,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let t=this.view.state,e=t.selection;if(!(e instanceof Q)||!e.$from.sameParent(e.$to)||!e.$from.parent.inlineContent||e.$from.parent.type.spec.code)return!1;let o=e.empty?It(t.doc,e.head):null;return this.range=o??{from:e.from,to:e.to,href:e.empty?null:Dn(t,e.from,e.to)},this.mode="edit",this.view.dispatch(t.tr.setMeta($,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(t){let e=String(t).trim(),o=e?C(e):null;if(e&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,a=$.getState(r)??(this.mode==="view"?this.range:null);if(!a)return this.close();let s;if(a.from===a.to){if(!o)return this.close();s=r.tr.insert(a.from,T.text(e,[j.create({href:o})])),s.setSelection(Q.create(s.doc,a.from+e.length))}else s=de(r,a.from,a.to,o),s.setSelection(Q.create(s.doc,a.to));this.view.dispatch(K(s).setMeta($,null)),this.close()}close(t=!0){this.mode=null,this.range=null,$.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta($,null)),this.dom.hidden=!0,this.dom.dataset.mode="",t&&this.view.focus(),this.update(this.view)}render(){let t=this.mode==="edit",e=C(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!t,this.url.hidden=t,this.edit.hidden=t,this.open.hidden=!e,this.remove.hidden=!this.range?.href,e?(this.open.href=e,this.url.href=e,this.url.textContent=e.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let t=this.range;if(!t)return;let e=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(t.from),r=this.view.coordsAtPos(t.to,-1);this.dom.style.setProperty("--page-pop-x",`${Math.min(o.left,r.left)-e.left}px`),this.dom.style.setProperty("--page-pop-y",`${Math.max(o.bottom,r.bottom)-e.top+6}px`)}update(t){if(this.view=t,this.mode==="edit"){let r=$.getState(t.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let e=t.state.selection,o=e instanceof Q&&e.empty&&t.hasFocus()?It(t.state.doc,e.head):null;if(!o||e.head===o.from||e.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Nt.delete(this.view)}},$n=n=>Nt.get(n)?.openEdit()??!1;function Bn(n,t){if(t.clipboardData?.files?.length)return!1;let e=t.clipboardData?.getData("text/plain")??"";if(!Nn(e))return!1;let o=n.state.selection;if(!(o instanceof Q)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=C(e),a=o.empty?n.state.tr.replaceSelectionWith(T.text(e.trim(),[j.create({href:r})]),!1):de(n.state,o.from,o.to,r);return n.dispatch(a.scrollIntoView().setMeta("uiEvent","paste")),!0}function po(){return new Mn({key:$,state:{init:()=>null,apply(n,t){let e=n.getMeta($);if(e!==void 0)return e;if(!t||!n.docChanged)return t;let o=n.mapping.mapResult(t.from,1),r=n.mapping.mapResult(t.to,t.from===t.to?1:-1);return o.deletedAcross||r.deletedAcross||t.from!==t.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:n=>new Ot(n),props:{decorations(n){let t=$.getState(n);return t&&t.from<t.to?In.create(n.doc,[vn.inline(t.from,t.to,{class:"page-link-pending"})]):null},handleKeyDown(n,t){return(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()==="k"?(t.preventDefault(),$n(n)||!0):!1},handlePaste:Bn,handleClick(n,t,e){if(!(e.metaKey||e.ctrlKey))return!1;let o=It(n.state.doc,t),r=C(o?.href);return r?(n.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{$n as a,po as b,Qn as c,Mt as d,yt as e,R as f,y as g,Hn as h,he as i,jn as j,L as k,ge as l,be as m,k as n,G as o,Zt as p,Gt as q,xe as r,ye as s,St as t,Un as u,Ye as v,rn as w,Fn as x,Gn as y,se as z,K as A,X as B,pn as C,st as D,bn as E,yn as F,ao as G};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{b as s}from"./c-BTDI4Y23.js";import{a as p}from"./c-2YYDMLNZ.js";import"./c-VHNSBD2M.js";var h=`html:has(> body > .clay-intro) { height: auto !important; overflow-y: auto !important; }
|
|
2
|
+
body:has(> .clay-intro) { height: auto !important; overflow: visible !important; }
|
|
3
|
+
.clay-intro {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
}
|
|
7
|
+
.clay-intro__close {
|
|
8
|
+
position: absolute; top: 10px; right: 10px; z-index: 1;
|
|
9
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
10
|
+
width: 28px; height: 28px; min-height: 0; margin: 0; padding: 0;
|
|
11
|
+
border: 0; border-radius: 4px; background: none; box-shadow: none;
|
|
12
|
+
color: inherit; opacity: .55; cursor: pointer; line-height: 1;
|
|
13
|
+
}
|
|
14
|
+
.clay-intro .clay-intro__close:hover { opacity: 1; background: none; color: inherit; }
|
|
15
|
+
.clay-intro__close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 2px; }
|
|
16
|
+
.clay-intro__close svg { display: block; width: 12px; height: 12px; fill: currentColor; stroke: none; }
|
|
17
|
+
@media (pointer: coarse) { .clay-intro__close { width: 44px; height: 44px; top: 4px; right: 4px; } }
|
|
18
|
+
@media print { .clay-intro { display: none; } }
|
|
19
|
+
`;var m={close:"Hide this introduction",label:t=>`About ${t}`},b="a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])",g="textarea, select",x=["checkbox","radio","button","submit","reset","file"];function v(t){return t.isContentEditable||t.closest(g)?!0:t.tagName!=="INPUT"?!1:x.indexOf(t.type)<0}function w(){try{return new URLSearchParams(window.location.search).get("intro")==="1"}catch{return!1}}function _(){if(document.getElementById("clay-intro-style"))return;let t=document.createElement("style");t.id="clay-intro-style",t.setAttribute("clay","editor-ui"),t.textContent=h,document.head.appendChild(t)}function C(){let t=[...document.querySelectorAll(b)].find(o=>!o.disabled&&!v(o)&&!o.closest("[clay~='editor-ui']")&&(typeof o.checkVisibility!="function"||o.checkVisibility()));t?t.focus({preventScroll:!0}):document.body.focus({preventScroll:!0})}function k({memory:t,template:o,appName:c,hadDraft:e}){return!o||!o.content.textContent.trim()&&!o.content.querySelector("img, svg, video, canvas")||!w()&&(t.get().intro.done||e||p.servedHash||window.matchMedia&&window.matchMedia("print").matches)?null:E({memory:t,template:o,appName:c})}function E({memory:t,template:o,appName:c}){_();let e=document.createElement("section");e.className="clay-intro",e.setAttribute("clay","editor-ui"),e.setAttribute("sap-ignore",""),e.setAttribute("aria-label",m.label(c)),e.appendChild(o.content.cloneNode(!0));let i=document.createElement("button");i.type="button",i.className="clay-intro__close",i.setAttribute("aria-label",m.close),i.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg>',e.appendChild(i);let a=!1,r=0;function d(n){if(a)return;a=!0,removeEventListener("scroll",u),r&&cancelAnimationFrame(r);let l=e.getBoundingClientRect().height,f=window.scrollY;if(t.get().intro.done=n,t.save(),e.remove(),n==="scrolled"){let y=/hidden|clip/.test(getComputedStyle(document.body).overflowY+getComputedStyle(document.documentElement).overflowY);window.scrollTo(0,y?0:Math.max(0,f-l))}s(),n!=="scrolled"&&C()}function u(){r||(r=requestAnimationFrame(()=>{r=0;let n=e.getBoundingClientRect().bottom,l=scrollY>0&&scrollY+innerHeight>=document.documentElement.scrollHeight-1;(n<1||l&&n<innerHeight)&&d("scrolled")}))}return e.addEventListener("click",n=>{if(n.target.closest(".clay-intro__close, [visitor-intro-dismiss]")){d("closed");return}n.target.closest("[visitor-intro-start]")&&(n.preventDefault(),window.scrollTo({top:window.scrollY+e.getBoundingClientRect().bottom,behavior:"smooth"}))}),document.body.prepend(e),s(),addEventListener("scroll",u,{passive:!0}),e}export{m as COPY,k as mountIntro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w}from"./c-BBVGTQG7.js";import{b as m,c as v}from"./c-RYUXUUBX.js";import"./c-VKEDWYDF.js";import{l as f,n as y}from"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-SPIORRYS.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-DCFSEJZG.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var L="script[editmode\\:resource]";function d(e=document){let t=[...e.querySelectorAll(L)];return{reversible:t.length===0,scripts:t}}function R(e=document){return{enable(){m(e)},quiesce(){},resume(){},dispose(){v()}}}function g(e=document){return{id:"clay:resources",order:100,prepare(){let{reversible:t}=d(e);if(!t)throw Object.assign(new Error("clay.modeLifecycle: an editmode:resource script cannot be re-run"),{code:"unsupported-plugin"});return R(e)}}}var b=!1,S=()=>{let e=new Set;for(let t of f()){if(typeof t?.then=="function")continue;let n=t?.id;if(typeof n!="string"||typeof t?.prepare!="function"||e.has(n))return!1;e.add(n)}return!0},j=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[],...e?.view?.plugins??[],...e?.view?.late??[]];function A(e){return[...new Set(j(e))].filter(t=>w(t)===null)}function T(e){return S()&&A(e).length===0&&d().reversible}function _(){b||(b=!0,y(g()))}var l=()=>Object.assign(new Error("clay.modeLifecycle: the import was cancelled"),{name:"AbortError",code:"aborted"}),O=15e3,E=(e,t)=>Object.assign(new Error(`clayjs: ${e}`),{code:t}),q=(e,t)=>new Promise((n,s)=>{if(t?.aborted)return s(l());let o=()=>s(l());t?.addEventListener?.("abort",o),Promise.resolve(e).then(i=>{t?.removeEventListener?.("abort",o),n(i)},i=>{t?.removeEventListener?.("abort",o),s(i)})}),h=e=>!e?.represented||e.represented.bytes===null,P=e=>e&&(e.liveSync??e.default??e)||null;async function k(e,t={}){let n=t.signal,s={signal:n,deadline:O},o=e?.loaded?.["plugins/page-view.js"];if(o?.ready){await q(o.acquired,n);let a=await o.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}let i=P(e?.loaded?.["sync/live-sync.js"]);if(i&&!i.isDestroyed&&i.lane==="saved"){let a=await i.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}return null}function I(e,t=null){let n=e?.loaded?.["plugins/page-view.js"],s=Array.isArray(e?.view?.plugins)?e.view.plugins.includes("sync/live-sync.js"):!!e?.loaded?.["sync/live-sync.js"];if(n&&((n.restart??n.start)({sync:s,represented:t}),!s))return;let o=P(e?.loaded?.["sync/live-sync.js"]);if(o)return o.start(o.currentFile,{lane:"saved",represented:t})}async function V(e,t,{signal:n}={}){let s=e.inflight||=new Map,o=[],i=()=>{if(n?.aborted)throw l()},a=e.loadEditHints?.();if(a)try{await a}catch{}let u=r=>{if(!s.has(r)){let c=Promise.resolve().then(()=>e.modules[r]()).catch(x=>{throw s.delete(r),x});s.set(r,c)}return s.get(r)};for(let r of t.core??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,c.install?.()}e.attachEditCore(e.loaded);for(let r of t.plugins??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}let p=(t.late??[]).filter(r=>!e.loaded[r]);if(p.length){i();try{await e.late}catch{}for(let r of p){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}}return o}export{V as importPlan,T as liveAllowed,_ as openResources,k as prepareReader,I as startReader,A as unsupportedPaths};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as g,f as h}from"./c-TRS6TM6O.js";import{d as m}from"./c-DCXOXBF3.js";import"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import{b as f}from"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var v="clay.undo",S=1,x="conflict",N="text",k="undo";function R(){let e=f.local.get(k);return Number.isFinite(e?.count)&&e.count>0?e.count:0}function _(e){e>0?f.local.set(k,{count:e,at:Date.now()}):f.local.remove(k)}function T(){return(globalThis.window?.clay??globalThis.clay)?.recovery??null}var y=null;function p(){let e=T();if(!e||typeof e.register!="function")return null;if(y?.service===e)return y.channel;try{y={service:e,channel:e.register({channel:v,version:S})}}catch{return null}return y.channel}var O=(e,t)=>`refused:${e}:${t}`;function D(e){if(e==null||typeof document>"u")return null;let t=globalThis.CSS?.escape?globalThis.CSS.escape(String(e)):String(e).replace(/["\\]/g,"\\$&");try{return document.querySelector(`[data-id="${t}"]`)}catch{return null}}function E(){let t=(globalThis.window?.clay??globalThis.clay)?.conflicts;return typeof t?.contextFor=="function"?t:null}function A({id:e=null}={}){let t=e==null?null:String(e),r=E();return(r?r.contextFor({source:"undo",id:t,element:D(t)},null):null)??{kind:null,id:t,label:null,field:null}}function C(e){return e.map(t=>h(A(t)))}async function F(e,t,r){let n;try{n=await e.list()}catch{return}if(n?.ok){for(let o of n.records)if(!(o.key!==t||String(o.id)===String(r)))try{await e.dismiss(o.id,{revision:o.revision})}catch{}}}var w=Promise.resolve();function H(e,t){let r=w.then(()=>I(e,t));return w=r.catch(()=>{}),r}async function I(e,t){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=null;try{n=e?.describe?.(t?.entryId)??null}catch{n=null}if(!n)return{ok:!1,code:"unknown-entry"};let o=n.refused&&typeof n.refused=="object"?n.refused:{},c=t?.direction??o.direction??null,i=(Array.isArray(o.targets)?o.targets:[]).map(l=>({id:l?.id==null?null:String(l.id),kind:l?.kind==null?null:String(l.kind)})),s=O(n.id??t?.entryId,c),a=g({label:n.label??null,direction:c,code:t?.code??o.code??null,targets:i,context:C(i),steps:n.steps??[]},[],""),u;try{u=r.stage({key:s,kind:x,baseEtag:m()??null,base:null,payload:a})}catch(l){return console.error("clayjs: the refused step could not be kept for a later reload; it is still in this tab's history",l),{ok:!1,code:"error"}}let d=await r.flush();return d?.ok&&(await F(r,s,u.id),await b()),d?.ok?d:{ok:!1,code:d?.code||"error"}}async function K({key:e,label:t=null,context:r=null,payload:n=null}={}){let o=p();if(!o)return{ok:!1,code:"unavailable"};let c=e==null?"":String(e);if(!c)return{ok:!1,code:"invalid"};let i=n&&typeof n=="object"?n:{},s=g({...i,label:t,context:h(r)},[],"");try{o.stage({key:`app:${c}`,kind:typeof i.text=="string"?N:x,payload:s})}catch(u){return console.error("clayjs: the app's recovery copy could not be kept; it is still in this tab only",u),{ok:!1,code:"error"}}let a=await o.flush();return a?.ok&&await b(),a}async function b(){let e=p();if(!e)return{ok:!0,records:[]};let t=await e.list();return t?.ok&&_(Array.isArray(t.records)?t.records.length:0),t}async function q(e,{revision:t}={}){let r=p();if(!r)return{ok:!1,code:"unavailable"};let n=await r.dismiss(e,{revision:t});if(n?.ok)try{await b()}catch{}return n}export{v as UNDO_CHANNEL,x as UNDO_KIND,N as UNDO_TEXT,S as UNDO_VERSION,A as contextForTarget,q as dismissKept,K as keep,H as keepRefusal,b as kept,R as pendingUndo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./c-VRZN56XY.js";import"./c-OW5QIGG3.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-N7JPUPGC.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{d as hostMeta,c as hostMetaOrder,a as hostMetaOutcome,b as hostMetaPath,f as hostPageFormat,g as hostPageStateHref,e as hostSupports,h as hostVersions,j as querySaveOutcome,i as resetHostMeta};
|