@panphora/clayjs 1.25.1 → 1.26.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 +1141 -345
- package/dist/m/c-2EPHRF47.js +1 -0
- package/dist/m/{c-2GB34XL4.js → c-2SUFMUZX.js} +2 -2
- package/dist/m/{c-BHLYQGTA.js → c-3S3647J6.js} +1 -1
- package/dist/m/{c-QL4NYM2L.js → c-3S5TNRZA.js} +1 -1
- package/dist/m/{c-3Y234AUB.js → c-3XGLJAS7.js} +2 -2
- package/dist/m/{c-O4YIDULY.js → c-42WBOKFM.js} +1 -1
- package/dist/m/{c-42RLKGEY.js → c-4TP3UXBT.js} +1 -1
- package/dist/m/{c-ASGHHLFX.js → c-5ELELG2F.js} +1 -1
- package/dist/m/{c-T5IWJOMW.js → c-5ZYLTN3Q.js} +1 -1
- package/dist/m/{c-DDCYVLGG.js → c-67TBU56I.js} +1 -1
- package/dist/m/{c-WNOLMHI2.js → c-6BGJAJ67.js} +1 -1
- package/dist/m/{c-XS7G6U3Z.js → c-ABOBD7F3.js} +1 -1
- package/dist/m/{c-5IIEOPIV.js → c-ARO6CPMA.js} +1 -1
- package/dist/m/{c-XUZMRQ7O.js → c-BCS3AZQZ.js} +1 -1
- package/dist/m/c-BOS7GONO.js +1 -0
- package/dist/m/{c-NICICT4P.js → c-DEYHCYJB.js} +1 -1
- package/dist/m/{c-T7LOTEWO.js → c-DZT6W2NG.js} +1 -1
- package/dist/m/c-EHJWIGWN.js +1 -0
- package/dist/m/{c-V2V5FKXX.js → c-EIUKME3W.js} +1 -1
- package/dist/m/{c-ASMLERFA.js → c-EXZOA6XY.js} +1 -1
- package/dist/m/{c-STAPQ2X6.js → c-EYFMAR3M.js} +1 -1
- package/dist/m/{c-DVMDYRAE.js → c-FUN6AKFE.js} +1 -1
- package/dist/m/{c-XMIDHEKF.js → c-GY36NO7C.js} +1 -1
- package/dist/m/{c-TWB5ZQU4.js → c-H47C6PJZ.js} +1 -1
- package/dist/m/c-KD2ME5UN.js +2 -0
- package/dist/m/{c-GO635CRU.js → c-LAKBBJOU.js} +2 -2
- package/dist/m/{c-GNFDX6SU.js → c-LETPPG2F.js} +1 -1
- package/dist/m/{c-LS7IVQVW.js → c-MMV5JULA.js} +1 -1
- package/dist/m/{c-NEQRFC4O.js → c-MVVEIJUU.js} +1 -1
- package/dist/m/{c-XCOQNISP.js → c-N362HNGO.js} +1 -1
- package/dist/m/{c-7K4SCQB7.js → c-ND3W7D5U.js} +1 -1
- package/dist/m/{c-4NAYDOWH.js → c-NNHNXD6M.js} +1 -1
- package/dist/m/{c-DAUQ6JZ3.js → c-NYJ577NL.js} +1 -1
- package/dist/m/{c-3AAQJAKJ.js → c-PWILUN4T.js} +1 -1
- package/dist/m/{c-7Z2625LX.js → c-QA3Q3MDI.js} +1 -1
- package/dist/m/{c-2A2ATCIH.js → c-QKOKMQXA.js} +1 -1
- package/dist/m/{c-TGIMBAWE.js → c-RBWVF4N5.js} +1 -1
- package/dist/m/{c-A5IYL7JI.js → c-SPOEDIMP.js} +1 -1
- package/dist/m/{c-ZJ7726FO.js → c-SRW5OBCF.js} +1 -1
- package/dist/m/{c-A3OKSYRI.js → c-SYOA4T7V.js} +1 -1
- package/dist/m/{c-MHTO3QAD.js → c-TJ5PFOJ2.js} +1 -1
- package/dist/m/{c-NW4ZFKCY.js → c-TKV273YU.js} +1 -1
- package/dist/m/{c-D4N4UJCQ.js → c-UEKJWXCB.js} +2 -2
- package/dist/m/{c-44WITKWQ.js → c-V4DBV5ZV.js} +1 -1
- package/dist/m/c-WHMZCRQD.js +6 -0
- package/dist/m/{c-WMRJKQ2V.js → c-WHQUZM2V.js} +1 -1
- package/dist/m/{c-C27EVUQ6.js → c-XHD7XJTE.js} +1 -1
- package/dist/m/{c-PP3CUF3U.js → c-XONFK3WC.js} +1 -1
- package/dist/m/c-YYIN4NAF.js +30 -0
- package/dist/m/c-ZFAPQQIB.js +1 -0
- package/dist/m/core/{conflict-notice-Y2NTMDGJ.js → conflict-notice-UNDOD4BL.js} +1 -1
- package/dist/m/core/site-edits-C22O53GS.js +1 -0
- package/dist/m/loader-DCKCZKY6.js +1 -0
- package/dist/m/{manifest-A27A4278.js → manifest-7954CBE3.js} +1 -1
- package/dist/m/{manifest-edit-E8A61EB4.js → manifest-edit-93AA79D7.js} +1 -1
- package/dist/m/manifest.json +442 -441
- package/dist/m/page/{editor-HS2CAV3W.js → editor-UF3CIA6V.js} +2 -2
- package/dist/m/plugins/{cms-4KET6RZT.js → cms-KG6TCTR3.js} +1 -1
- package/dist/m/plugins/{live-CO4VJS46.js → live-DF5YS5AH.js} +1 -1
- package/dist/m/plugins/page-GZSU77JS.js +2 -0
- package/dist/m/plugins/{page-view-6KNTXABH.js → page-view-7MM3FEAR.js} +1 -1
- package/dist/m/plugins/{quickcrop-VNRXGRPC.js → quickcrop-UHURKA2F.js} +2 -2
- package/dist/m/plugins/richclay-MXH2GFAZ.js +549 -0
- package/dist/m/plugins/undo-KLHAGV75.js +1 -0
- package/dist/m/sync/{live-sync-DX4K5GDB.js → live-sync-RZQSDMZW.js} +1 -1
- package/dist/offline-manifest.json +360 -360
- package/package.json +1 -1
- package/src/core/site-edits.js +1 -1
- package/src/loader-logic.js +0 -13
- package/src/page/boot-pack.js +1 -0
- package/src/page/history-intent.js +111 -4
- package/src/page/ybind/bridge.js +14 -7
- package/src/page/ybind/moves.js +437 -3
- package/src/page/ybind/origins.js +1 -1
- package/src/page/ybind/recovery.js +1 -1
- package/src/plugins/page.js +48 -4
- package/src/plugins/richclay.js +136 -0
- package/src/plugins/undo.js +169 -7
- package/src/recovery/undo.js +14 -7
- package/src/sync/live-sync.js +24 -0
- package/src/ui/vendor-skin.js +9 -4
- package/dist/m/c-3XNTQQEJ.js +0 -1
- package/dist/m/c-4OZZ7ENT.js +0 -30
- package/dist/m/c-D2OPWOWO.js +0 -2
- package/dist/m/c-LUBZU4AZ.js +0 -6
- package/dist/m/c-LYNLY3MR.js +0 -1
- package/dist/m/c-MLMJUNRV.js +0 -1
- package/dist/m/c-V5L6HWVL.js +0 -1
- package/dist/m/core/site-edits-TIJDPG6H.js +0 -1
- package/dist/m/loader-7ORQVRCK.js +0 -1
- package/dist/m/plugins/page-L3VKIQU2.js +0 -2
- package/dist/m/plugins/richclay-V6WKJTUF.js +0 -549
- package/dist/m/plugins/undo-WUK2NLBA.js +0 -1
- /package/dist/m/plugins/{quickcrop-VNRXGRPC.js.LEGAL.txt → quickcrop-UHURKA2F.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-V6WKJTUF.js.LEGAL.txt → richclay-MXH2GFAZ.js.LEGAL.txt} +0 -0
package/dist/m/c-4OZZ7ENT.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import{a as Ct,b as It,c as At,d as ze,e as Ye,f as Kn,g as Tt,h as Hn,i as qn,j as Pt,l as Rt}from"./c-NICICT4P.js";import{a as Et,b as Jn,c as Ro,f as Yo}from"./c-GNFDX6SU.js";import{a as $o}from"./c-WNOLMHI2.js";import{a as Bn,b as Dn,e as zn,f as it,g as Mt}from"./c-LS7IVQVW.js";import{a as Po}from"./c-NEQRFC4O.js";import{b as Co,c as Io}from"./c-OBMZASYQ.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{a as Re,b as _n,p as Nn,q as Fn,u as Ao,v as To}from"./c-LUBZU4AZ.js";import{A as An,B as Be,C as ot,D as Tn,E as Pn,F as De,G as Rn,H as Pe,I as rt,J as Yn,K as St,L as $n,M as st,N as jn,O as ue,a as Le,b as kt,c as wn,d as xn,f as Sn,j as On,m as Eo,p as Mn,q as En,r as Cn,s as In,t as vt,v as wt,x as xt,z as Oe}from"./c-GO635CRU.js";import{a as me,b as hn,d as Me,e as _e,g as xe,h as Ne,i as ye,j as Ee,k as gn,l as Fe,m as nt,n as be,o as bn,p as kn,q as Se,r as Ce,u as yn,v as vn,w as yt}from"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import{f as tn,g as nn,i as Qe,j as Ze,k as dt,n as pt,o as et,p as on,s as mt,t as rn,u as Ae,v as de,w as Te,x as ht,y as sn}from"./c-WMRJKQ2V.js";import{g as Ln,p as Ot}from"./c-3Y234AUB.js";import{E as gt,H as bt,I as dn,d as fe,fa as je,g as an,i as fn,ia as pn,ja as mn,na as tt,w as un}from"./c-OH2FPYSY.js";import{b as Vt}from"./c-QY7F6EN6.js";import"./c-FSQXFG5T.js";import{b as pe,c as ln,e as cn}from"./c-RETTCOWO.js";import{a as Wt,b as Ut,d as ft}from"./c-JC4RZW4E.js";import{a as Zt}from"./c-TCCA5BZN.js";import"./c-3LDGIBMN.js";import{c as en}from"./c-57XDY6HC.js";import"./c-OZVK3TFI.js";import{a as Qt,b as ut}from"./c-FILLTJA7.js";import"./c-QCDVDZIR.js";import{e as Gt,f as Xt}from"./c-FC5RUFPR.js";import"./c-4ASQPRQL.js";import"./c-GQ6F6IDK.js";import"./c-I2SCCUEW.js";import"./c-5VYOWDTI.js";import"./c-P73XPAOA.js";import"./c-ZPI7M5U5.js";import"./c-WYFDLITL.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var Yt=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),Je=(e,o)=>je(e)===je(o);function $t(e,o){let n=o.createElement("article");return n.setAttribute("data-blockeditor",""),n.innerHTML=mn([{id:e.id,t:"paragraph",c:e.c??"",...e.m?{m:e.m}:{}}],{clean:pn(o)}),n}function jo(e,o){let n=new Map(e.map((f,u)=>[f.id,u])),r=new Set(o.map(f=>f.id)),t=new Map,s=0;return o.map(f=>{let u=n.get(f.id);if(u!==void 0)return s=u+1,f;let p={c:f.c??"",m:f.m??null};for(let b=s;b<e.length;b++){let C=e[b];if(!(r.has(C.id)||C.t!==f.t||!Je({c:C.c??"",m:C.m??null},p)))return r.add(C.id),s=b+1,t.set(f.id,C.id),{...f,id:C.id}}return f}).map(f=>t.has(f.parent)?{...f,parent:t.get(f.parent)}:f)}function jt(e,o,n,{doc:r,merge3:t,mergeJson:s}){let a=[],f=jo(e,n),u=new Map(e.map(c=>[c.id,c])),p=new Map(o.map(c=>[c.id,c])),b=new Map(f.map(c=>[c.id,c])),C=o.map(c=>({...c})),M=f.map(c=>({...c})),h=new Map(C.map(c=>[c.id,c])),w=new Map(M.map(c=>[c.id,c]));for(let[c,E]of u){let i=p.get(c),g=b.get(c);if(!i||!g||!Yt.has(E.t)||!Yt.has(i.t)||!Yt.has(g.t))continue;let A={c:E.c??"",m:E.m??null},z={c:i.c??"",m:i.m??null},W={c:g.c??"",m:g.m??null};if(Je(z,A)||Je(W,A)||Je(z,W))continue;if(E.t==="code_block"){for(let P of[h.get(c),w.get(c)])P.c=g.c??"",g.m?P.m=g.m:delete P.m;a.push({id:c,kind:"text",local:i.c??"",remote:g.c??""});continue}let T=t($t(E,r),$t(i,r),$t(g,r));for(let P of T.conflicts)a.push({id:c,kind:"text",local:P.local?.textContent??null,remote:P.remote?.textContent??null});let[U]=tt(T.root,{seed:"",known:new Map});for(let P of[h.get(c),w.get(c)])P.c=U.c,U.m?P.m=U.m:delete P.m}let y=o.map(c=>c.id);for(let[c,E]of u){let i=h.get(c);if(!i||b.has(c)||Je(p.get(c),E))continue;let g=y.indexOf(c)-1;for(;g>=0&&!w.has(y[g]);)g--;let A=g<0?0:M.findIndex(z=>z.id===y[g])+1;M.splice(A,0,{...i}),w.set(c,M[A]),a.push({id:c,kind:"kept-edit"})}let N=s(e,C,M,{onConflict:c=>a.push({kind:"field",path:c.path,local:c.local,remote:c.remote,resolved:c.resolved})}),B=new Set(N.map(c=>c.id)),v=c=>(p.get(c)??u.get(c)??b.get(c))?.parent??null,L=N.map(c=>{let E=c.parent??null;for(;E&&!B.has(E);)E=v(E);return E===(c.parent??null)?c:{...c,parent:E}}),Y=new Map(L.map(c=>[c.id,c.parent??null])),$=c=>{let E=new Set([c]);for(let i=Y.get(c);i;i=Y.get(i)){if(E.has(i))return!0;E.add(i)}return!1};for(let c of L)if($(c.id)){for(let E of[p.get(c.id)?.parent,u.get(c.id)?.parent,null])if(Y.set(c.id,E&&B.has(E)?E:null),!$(c.id))break}return{items:L.map(c=>(c.parent??null)===Y.get(c.id)?c:{...c,parent:Y.get(c.id)}),conflicts:a}}var _o=e=>{try{return Zt(e)}catch{return null}},$e={ok:!0,outcome:"unchanged"},Ke={ok:!1,outcome:"disposed",reason:"adoption-disposed"},He={ok:!1,outcome:"refused",reason:"adoption-refused"},No={ok:!1,outcome:"refused",reason:"adoption-timeout"},Fo={ok:!1,outcome:"error",reason:"adoption-error"},Lo={ok:!0,outcome:"writer-adopts"},Vn=e=>({ok:!0,outcome:"adopted",counts:e}),Wn=1e4;function Bo(e){let o=e.querySelector(Et);return o?{article:o.cloneNode(!0),tags:Jn(e).map(n=>_o(n.textContent))}:null}function Un(e){return new Promise(o=>{if(!e.composing)return o();e.dom.addEventListener("compositionend",()=>setTimeout(()=>o(Un(e)),0),{once:!0})})}function Do({view:e,source:o=null,ready:n=Promise.resolve(),isAdopter:r=()=>!0,idle:t=()=>Un(e),requestCheckpoint:s=()=>{},notice:a=()=>{},snapshot:f=()=>null,mergeTagless:u=!1,seeded:p=!1,writerReady:b=()=>Promise.resolve(),adopted:C=()=>{},hold:M=Gt,release:h=Xt,holdMs:w=Wn,doc:y=document}){let N=o?o.article.innerHTML:null,B=o?o.article:null,v=new Map,L=P=>{let I=P.getAttribute("data-rev");if(!I)return;let K=v.get(I)??[];v.delete(I),v.set(I,K),K.push(P),K.length>10&&K.shift(),v.size>20&&v.delete(v.keys().next().value)};B&&L(B);let Y=Promise.resolve(),$=!1,x,c=new Promise(P=>x=P);async function E(){let P,I=new Promise(K=>{P=setTimeout(()=>K("timeout"),w)});try{return await Promise.race([Promise.resolve(n).then(()=>t()).then(()=>"ready"),c.then(()=>"disposed"),I])}finally{clearTimeout(P)}}function i(P,I,K,j){let{HyperMorph:Q}=Qt(),le=jt(K,I,j,{doc:y,merge3:Q.merge3,mergeJson:Q.mergeJson}),ee=le.conflicts.filter(D=>D.kind==="text"||D.kind==="field"),m=ee.length?f():null,l=Dn(P,le.items,I),k=l&&zn(e.state,l);if(!k)return null;e.dispatch(k),e.dispatch(cn.closeHistory(e.state.tr));let F={edited:l.edited.size,created:l.created.size,deleted:l.deleted.length,moved:l.reordered},{displaced:R}=k.getMeta(Bn);return Object.keys(R).length&&(F.displaced=R),ee.length&&(F.conflicts=ee),m&&(F.copy=m),F}async function g(P){if(u&&!P.tags.length)return A(P);let I=Mt(P.article,P.tags);if(I.kind==="unbased"&&console.warn("page: the article and its data changed together; kept the data"),I.kind!=="adopt")return $e;if(!r())return Lo;M();try{if(await ut(),$)return Ke;if(!r())return He;let K=await E();if(K==="timeout"&&console.warn("page: gave up waiting for the editor; the hand edit was not adopted"),K==="disposed"||$)return Ke;if(K!=="ready")return No;if(!r())return He;let j=gt(e.state.doc),Q=i(j,it(j,y),I.baseItems,I.parsed);return Q?(C(I.A),Vn(Q)):$e}finally{h()}}async function A(P){let I=P.article.getAttribute("data-rev"),K=I&&v.get(I)||[],j=K.at(-1)??B;if(K.slice(0,-1).some(Q=>Q.innerHTML===P.article.innerHTML)||(L(P.article),B=P.article,!j)||j.outerHTML===P.article.outerHTML)return $e;M();try{if(await ut(),$)return Ke;if(!r())return He;if(await b(),$)return Ke;if(!r())return He;if(await E()==="disposed"||$)return Ke;if(!r())return He;let le=gt(e.state.doc),ee=it(le,y),m=new Map(ee.map(F=>[F.id,F])),l=F=>tt(F,{seed:F.getAttribute("data-rev")??"",known:m}),k=i(le,ee,l(j),l(P.article));return k?Vn(k):$e}finally{h()}}async function z(P){try{return await g(P)}catch(I){return console.error("page: adoption failed",I),Fo}}let W=null;function T(P,I=!1){return Y=Y.then(()=>z(P)).then(K=>(I&&(W=K),!K.ok||K.outcome!=="adopted"||(s(),a(K.counts),y.dispatchEvent(new CustomEvent("clay:blockeditor-adopted",{detail:K.counts}))),K)),Y}function U(P){let I=P.detail?.html;if($||typeof I!="string")return;let K=Bo(new DOMParser().parseFromString(I,"text/html"));!K||K.article.innerHTML===N||(N=K.article.innerHTML,T(K))}return y.addEventListener("clay:sync-applied",U),o&&!p&&T(o,!0),{idle:async()=>(await Y,W),saved(P){if(!u||typeof P!="string")return;let I=new DOMParser().parseFromString(P,"text/html").querySelector(Et);I&&(L(I),B=I)},dispose(){$=!0,x(),y.removeEventListener("clay:sync-applied",U)}}}var Gn='["text-delete",',Xn=(e,o)=>o instanceof rn&&o._item&&o._item.parent===e.attrs&&typeof o._item.parentSub=="string"?o._item.parentSub:null,Qn=e=>e==="t"||e==="parent",_t=e=>e.content instanceof de&&e.content.embed.b!==void 0,zo=e=>e.content instanceof ht||e.content instanceof Te||e.content instanceof de&&e.content.embed.b===void 0,eo=e=>{let o=new Map;for(let n of e.stops)(o.get(n.client)??o.set(n.client,[]).get(n.client)).push(n);return o},to=(e,o)=>{let n=o.get(e.id.client);if(!n)return!1;let r=e.id.clock,t=r+e.length;return n.some(s=>s.clock<t&&r<s.clock+s.len)},Jo=(e,o)=>{for(let n=e.left;n;n=n.left){if(n.deleted){if(to(n,o))return null;continue}if(_t(n))return n}return null};function no(e,o,n){let r=eo(n),t=new Set,s=new Set,a=o.changed.get(e.tableFields)??new Set;for(let[h,w]of o.changed){if(h===e.flow)continue;if(h===e.attrs){if(!o.local)return null;for(let N of w){let B=e.attrs.get(N);if(!(B instanceof Ae)||B._item.left||B._item.id.clock<(o.beforeState.get(B._item.id.client)??0))return null;s.add(N)}if(s.size>1)return null;continue}if(h===e.tableFields){for(let N of w){let B=e.tableFields.has(N)?En(N,e.tableFields.get(N)):null;if(B===null)return null;t.add(B)}continue}let y=Xn(e,h);if(y!==null){for(let N of w)if(Qn(N))return null;t.add(y);continue}if(h!==e.gone)return null;for(let N of w)if(typeof N!="string"||!N.startsWith(Gn))return null}let f=e.ydoc.store,u=null,p=null,b=!1,C=h=>{if(!(h instanceof sn))return!1;if(h.parent===e.gone)return typeof h.parentSub=="string"&&h.parentSub.startsWith(Gn);if(h.parent===e.tableFields)return a.has(h.parentSub);if(h.parent===e.attrs)return s.has(h.parentSub);if(h.parent!==e.flow){let y=Xn(e,h.parent);return y!==null&&(s.has(y)||t.has(y)&&!Qn(h.parentSub))}if(_t(h)){if(h.deleted||!s.has(h.content.embed.b))return!1;p=h}else if(!zo(h))return!1;let w=Jo(h,r);return!w||u&&w!==u?!1:(u=w,h.content instanceof Te&&(b=!0),!0)};for(let[h,w]of o.afterState)for(let y=o.beforeState.get(h)??0;y<w;){let N=et(f,{client:h,clock:y});if(!C(N))return null;y=N.id.clock+N.length}let M=!1;for(let[h,w]of o.deleteSet.clients)for(let{clock:y,len:N}of w)for(let B=y;B<y+N;){let v=et(f,{client:h,clock:B});if(!C(v))return null;M=!0,B=v.id.clock+v.length}return s.size&&!p?null:u||t.size?{marker:u,split:p,deleted:M,formats:b,fields:t,remote:!o.local}:null}var Ko=e=>{for(let o in e)return{...e};return null};function oo(e,o,n,r=null){let t=r?.formats??!0,s=r?.split??null,a=o.visible,f=-1,u=0;for(let i=0;i<a.length;i++){let g=a[i];if(g.brk&&g.brk.client===n.id.client&&g.brk.clock===n.id.clock){f=i;break}u+=g.len}if(f<0)return null;let p=a[f];if(p.implicit||p.atom||p.opaque||p.recovered||p.hide)return null;let b=p.runs.findIndex(i=>i.hole!==void 0);if(b>=0&&t||p.items&&o.copies.has(p.baseId))return null;let C=eo(o),M={...p.fmtIn??{}},h=null,w={...p,runs:[],len:1};p.items&&(w.items=[]);let y=w,N=!1,B=Ye(o.holes,u),v=B+1;for(let i=n.right;i;i=i.right){if(i.deleted){if(to(i,C))return null;continue}if(_t(i)&&(i!==s||y!==w)){N=!0;break}let g=v;i.countable&&(v+=i.length);let A=i.content;if(i===s){let z=A.embed.b,W=e.attrs.get(z)?.get("t")||"paragraph";if(!Object.hasOwn(fe.nodes,W)||!fe.nodes[W].isTextblock)return null;let T=Ko(M);w.fmtOut=T,y={kind:"b",id:z,baseId:z,brk:{client:i.id.client,clock:i.id.clock},implicit:!1,runs:[],len:1,atom:!1,items:null,fmtIn:T,fmtOut:null,t:W,opaque:!1},h=null;continue}if(A instanceof Te){A.value===null?delete M[A.key]:M[A.key]=A.value,h=null;continue}if(A instanceof de){y.runs.push({br:!0}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"br",text:null,blockId:null,raw:{...M}}),y.len+=1;continue}if(A instanceof ht){if(!h){let z=vn(M,y.t);h={marks:z,mk:yn(z)}}y.runs.push({text:A.str,marks:h.marks,mk:h.mk}),y.items&&y.items.push({at:g,id:Ee(i.id),client:i.id.client,clock:i.id.clock,length:i.length,kind:"text",text:A.str,blockId:null,raw:{...M}}),y.len+=A.str.length}else if(i.countable)return null}let L=p.len;if(b<0){if(!ye(M,p.fmtOut??{}))return null}else{if(!N||y.t!==p.t)return null;L=1;for(let i=0;i<b;i++)L+=p.runs[i].br?1:p.runs[i].text.length}let Y=y===w?[w]:[w,y],$=Y.reduce((i,g)=>i+g.len,0)-L,x=B+L,c=i=>i.at>=x?{...i,at:i.at+$}:i;y.fmtOut=p.fmtOut,b>=0&&(y.runs=y.runs.concat(p.runs.slice(b)),y.len+=p.len-L,y.items&&(y.items=y.items.concat(p.items.filter(i=>i.at>=x).map(c))));let E={...o,visible:a.slice(),tokens:o.tokens+$};if(E.visible.splice(f,1,...Y),$){let i=u+L;E.holes=o.holes.map(g=>g.at>=i?{at:g.at+$,len:g.len}:g),E.hidden=o.hidden.map(g=>g.at>=x?{...g,at:g.at+$,items:g.items.map(c)}:g);for(let g=f+Y.length;g<E.visible.length;g+=1){let A=E.visible[g];A.items?.length&&(E.visible[g]={...A,items:A.items.map(c)})}}return E}var Ho=e=>e.br?`
|
|
2
|
-
`:e.hole!==void 0?{hole:e.hole}:{text:e.text,mk:e.mk},qo=e=>{let o=[];for(let n of e.map(Ho)){let r=o[o.length-1];r&&typeof r=="object"&&typeof n=="object"&&r.text!==void 0&&n.text!==void 0&&r.mk===n.mk?o[o.length-1]={text:r.text+n.text,mk:n.mk}:o.push(n)}return o},Zn=(e,o)=>{let n=et(e.ydoc.store,{client:o.client,clock:o.clock});return{client:n.id.client,clock:n.id.clock,len:n.length}},Ve=(e,o)=>rt({...o,copies:[...o.copies],fences:o.fences.map(n=>Zn(e,n)),stops:o.stops.map(n=>Zn(e,n)),visible:o.visible.map(n=>({...n,runs:qo(n.runs)}))});var ro=e=>e===!0?{}:e,so=(e,o)=>ye(ro(e),ro(o));function co(e,o,n,r){let t=e.attrs.get(o);t||(t=new Ae,e.attrs.set(o,t));let s=fe.nodes[n];if(!s){t.get("t")!==n&&t.set("t",n);for(let[p,b]of Object.entries(r??{}))p==="t"||p==="pos"||ye(t.has(p)?t.get(p):void 0,b)||t.set(p,b);return}let a=n==="table"&&t.get("t")==="table"&&!St(o),f=n==="board"&&!St(o),u=a?Cn(e.tableFields,o,In(e,o)):f?wt(e.boardFields,o):null;t.get("t")!==n&&t.set("t",n);for(let p of xe(s)){if(a&&(p==="rows"||p==="cols")||f&&(p==="columns"||p==="cards"))continue;let b=t.has(p)?t.get(p):Ne(s,p);ye(b,r[p])||t.set(p,r[p])}a&&vt(e,o,u,r),f&&xt(e,o,u,r)}function io(e,o){let n=new Map,r=o;for(let t=e.flow._start;t&&r>0;t=t.right){if(t.deleted)continue;let s=t.content;s instanceof Te?s.value===null?n.delete(s.key):n.set(s.key,s.value):t.countable&&(r-=t.length)}return n}function Vo(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&fe.marks[Se(r)]&&n.push([r,t]);return n}function ao(e){let o=new Set;for(let[r,t]of e)Ce(r)&&t&&o.add(r.split("!")[0]);let n=[];for(let[r,t]of e)!Ce(r)&&t!==null&&t!==void 0&&!o.has(r)&&!fe.marks[Se(r)]&&n.push([r,t]);return n}function fo(e,o={}){let n={},r=!1;for(let[t,s]of e)(Ce(t)||fe.marks[Se(t)])&&(n[t]=s);for(let[t,s]of ao(e))r=!0,o[Se(t)]!==void 0&&(n[t]=s);return{attrs:n,opaque:r}}function Wo(e,o,n){let r=be(e),t={},s=Vo(o),a=new Set;for(let[u,p]of s){let b=Se(u),C=n[b];C!==void 0&&so(C,p)?a.add(b):t[`${u}!${r}`]=!0}for(let[u,p]of ao(o)){let b=Se(u);n[b]!==void 0&&so(n[b],p)&&a.add(b)}for(let[u,p]of Object.entries(n))a.has(u)||(t[`${u}~${be(e)}`]=p);let f=fo(o,n);if(!(!Object.keys(t).length&&!f.opaque))return{...f.attrs,...t}}var Nt=2e3;function Uo(e){let o=[],n=[],r=0;for(let t=0;t<e.length;t++)if(n.push(e[t]),r+=1,r>=Nt&&t+1<e.length){let s=e[t];if(s.k==="c"&&Fe(s.ch.charCodeAt(0)))continue;o.push(n),n=[],r=0}return n.length&&o.push(n),o}function lt(e,o,n,r=s=>s(),t=null){let s=o;for(let a of Uo(n))r(()=>{s+=Xo(e,s,a,t)});return s-o}var Go=(e,o,n)=>{if(!n||!n.length)return null;let r=o,t=e.flow._start;for(;t&&r>0;){if(!t.deleted&&t.countable){if(r<t.length)return null;r-=t.length}t=t.right}for(;t&&(t.deleted||!t.countable);t=t.right)if(t.deleted&&n.some(s=>s.client===t.id.client&&s.clock>=t.id.clock&&s.clock<t.id.clock+t.length))return t;return null},We=(e,o,n,r)=>{let t=Go(e,o,n);if(!t)return r();t.deleted=!1;try{return r()}finally{t.deleted=!0,e.flow._searchMarker&&(e.flow._searchMarker.length=0)}};function Xo(e,o,n,r=null){let t=o,s="",a=null,f=null,u=()=>{if(!s)return;let b=Wo(e,io(e,t),f??{});We(e,t,r,()=>e.flow.insert(t,s,b)),t+=s.length,s=""},p=b=>{let C=fo(io(e,t)).attrs;We(e,t,r,()=>e.flow.insertEmbed(t,b,C)),t+=1};for(let b of n)b.k==="c"?(a!==null&&b.mk!==a&&u(),a=b.mk,f=b.ma,s+=b.ch):b.k==="h"?(u(),a=null,p({br:1})):(u(),a=null,p({b:b.id}),co(e,b.id,b.t,b.attrs));return u(),t-o}var Qo=(e,o,n,r)=>{let t=0;for(let s=e.flow._start;s&&t<r;s=s.right){if(s.deleted||!s.countable)continue;let a=t;if(t+=s.length,t<=n||s.content instanceof de&&s.content.embed?.b!==void 0)continue;let f=Math.max(0,n-a),u=Math.min(s.length,r-a);u<=f||e.gone.set(Pn(s.id.client,s.id.clock+f,o.operationId),{length:u-f,actor:e.ydoc.clientID,sv:o.sv})}};function lo(e,o,n,r=null){for(let t=n.length-1;t>=0;t--){let[s,a]=n[t];if(a<=s)continue;let f=o.physicalRanges(s,a);for(let u=f.length-1;u>=0;u--){let[p,b]=f[u];b<=p||(r&&Qo(e,r,p,b),e.flow.delete(p,b-p))}}}function Zo(e,o,n){let r=!1;for(let t=e.flow._start;t;t=t.right){let s=Ee(t.id);if(s===o){r=!0;continue}if(!r)continue;let a=t.content instanceof de?t.content.embed:null;if(a&&a.b!==void 0&&a.b!==n)return s}return null}function Ft(e,o,n,r,t=null){let{pd:s,map:a,bt:f}=e,u=i=>t===null||t[i],p=0;for(;p<n.length&&p<r.length&&ze(n[p],r[p])&&u(p);)p++;let b=0;for(;b<n.length-p&&b<r.length-p&&ze(n[n.length-1-b],r[r.length-1-b])&&u(n.length-1-b);)b++;let C=i=>i&&i.k==="c"?i.ch.charCodeAt(0):-1;p>0&&Fe(C(n[p-1]))&&(nt(C(n[p]))||nt(C(r[p])))&&p--,b>0&&nt(C(n[n.length-b]))&&(Fe(C(n[n.length-b-1]))||Fe(C(r[r.length-b-1])))&&b--;let M=n.slice(p,n.length-b),h=r.slice(p,r.length-b),w=o+p,y=w+M.length,N=M.filter(i=>i.k==="b").map(i=>i.id).join(",");if(!(M.some(i=>i.k==="b")&&N===h.filter(i=>i.k==="b").map(i=>i.id).join(","))){let i=Le(s.origins);try{for(let T of M){if(T.k!=="b"||!T.brk)continue;let U=i.resolve(T.brk);i.boundaryOf(U)||e.tx(()=>i.recordBoundary(U,{blockId:T.id,kind:"removed"}))}}finally{i.dispose()}let g=new Set;M.forEach((T,U)=>{if(T.k!=="b"||!T.brk)return;let P=w+U,I=P+1;for(;I<f.length&&f[I].k!=="b";)I++;let K=I<=y&&I!==P+1,j=I<f.length?f[I].brk:null;K&&(e.tx(()=>s.gone.set(Be(Ee(T.brk),e.operationId),{blockId:T.id,end:j?Ee(j):null,sv:e.sv})),g.add(P))});let A=[],z=w;for(let T=w;T<y;T++)g.has(T)&&(T>z&&A.push([z,T]),z=T+1);y>z&&A.push([z,y]),e.tx(()=>lo(s,a,A,M.some(T=>T.k==="b")?null:e));let W=new Set(h.filter(T=>T.k==="b").map(T=>T.id));for(let T of M)if(!(T.k!=="b"||!T.brk||W.has(T.id)))for(let U of e.copies.get(T.id)??[]){let P=Be(U,e.operationId);s.gone.has(P)||e.tx(()=>s.gone.set(P,{blockId:T.id,end:Zo(s,U,T.id),sv:e.sv}))}h.length&<(s,a.toPhysical(w,"before"),h,e.tx,e.fences);return}let v=[],L=[],Y=[],$=w,x=0,c=0;for(;x<M.length||c<h.length;){let i=x;for(;i<M.length&&M[i].k!=="b";)i++;let g=c;for(;g<h.length&&h[g].k!=="b";)g++;let A=M.slice(x,i),z=h.slice(c,g);if(A.length&&v.push([$,$+A.length]),z.length&&L.push({at:$,toks:z}),$+=A.length,i<M.length&&(Y.push([M[i],h[g]]),$+=1),x=i+(i<M.length?1:0),c=g+(g<h.length?1:0),i>=M.length&&g>=h.length)break}let E=[...v.map(i=>({at:i[0],d:i})),...L.map(i=>({at:i.at,i}))].sort((i,g)=>g.at-i.at||(i.d?-1:1));for(let i of E)i.d?e.tx(()=>lo(s,a,[i.d],e)):lt(s,a.toPhysical(i.at,"before"),i.i.toks,e.tx,e.fences);for(let[i,g]of Y)e.tx(()=>{if(!fe.nodes[g.t])return;let A=e.recovered.get(i.id);if(A){i.t!==g.t&&s.gone.set(De(A,"t"),g.t);for(let T of xe(fe.nodes[g.t]))ye(i.attrs[T],g.attrs[T])||s.gone.set(De(A,T),g.attrs[T]);return}let z=i.id,W=s.attrs.get(z);if(W){let T=i.t==="table"&&g.t==="table"&&W.get("t")==="table",U=g.t==="board",P=U?i.t==="board"&&W.get("t")==="board"?i.attrs:wt(s.boardFields,z):null;i.t!==g.t&&W.set("t",g.t);for(let I of xe(fe.nodes[g.t])){if(T&&(I==="rows"||I==="cols")||U&&(I==="columns"||I==="cards"))continue;let K=W.has(I)?W.get(I):Ne(fe.nodes[g.t],I);ye(K,g.attrs[I])||W.set(I,g.attrs[I])}T&&vt(s,z,i.attrs,g.attrs),U&&xt(s,z,P,g.attrs)}else co(s,z,g.t,g.attrs)})}function Lt(e,o,n,r,t,s){let{pd:a,map:f}=e,u=`${r}~${be(a)}`,p=be(a),b=o;for(;b<n;){if(s[b].k!=="c"){b++;continue}let C=b;for(;C<n&&s[C].k==="c";)C++;let M=f.physicalRanges(b,C);if(t!==null)for(let[h,w]of M)a.flow.format(h,w-h,{[u]:t});else{let h=0;for(let w of a.flow.toDelta()){let y=typeof w.insert=="string"?w.insert.length:1;for(let[N,B]of M){if(h>=B)break;let v=Math.max(h,N),L=Math.min(h+y,B);if(L>v&&w.attributes){let Y={};for(let[$,x]of Object.entries(w.attributes))Se($)===r&&!Ce($)&&x!==null&&(Y[`${$}!${p}`]=!0);Object.keys(Y).length&&a.flow.format(v,L-v,Y)}}h+=y}}b=C}}var{AddMarkStep:uo,RemoveMarkStep:er,AttrStep:tr,ReplaceStep:nr,Mapping:ct}=ln,po=(e,o,n)=>{let r=e.resolve(o),t=e.resolve(n);return[r.depth&&r.node(1).type.name==="table"?r.before(1):o,t.depth&&t.node(1).type.name==="table"?t.after(1):n]},or=(e,o,n)=>{let r=!1;return e.nodesBetween(o,n,t=>(t.type.name==="table"&&(r=!0),!r&&t.type.name!=="table")),r};function mo(e,o,n,r,t=null,s=!0,a=null,{join:f=!1,open:u=!1}={}){let p=()=>{if(a){let l=a;a=null,l()}},b=[],C=[],M=[];for(let l of o)l.steps.forEach((k,F)=>{b.push(k),C.push(l.docs[F]),M.push(k.getMap())});if(!b.length)return;let h=new ct(M),w=[...Qe(Ze(e.ydoc)).entries()].sort((l,k)=>l[0]-k[0]),y=be(e),N=C[0],B=o[o.length-1].doc,v=n.visible.length===0&&N.childCount===1&&N.firstChild.type.name==="paragraph"?[{id:N.firstChild.attrs.id,implicit:!0,t:"paragraph",len:0}]:n.visible,L=new Map,Y=[];{let l=0;v.forEach(k=>{k.implicit&&Y.push({tok:l,id:k.id,t:k.t}),l+=k.len})}Y.sort((l,k)=>k.tok-l.tok);for(let l of Y)l.alias=bn(e),L.set(l.id,l.alias);let $=L.size?n.holes.map(l=>({at:l.at+Y.filter(k=>k.tok<l.at).length,len:l.len})):n.holes,x=Tt(n.tokens+L.size,$,e.flow.length+L.size),c=[],E=[];b.forEach((l,k)=>{let F=l instanceof uo||l instanceof er;if(F&&!or(C[k],l.from,l.to)){E.push({i:k,step:l});return}let R=new ct(M.slice(0,k)).invert(),D=new ct(M.slice(k+1)),q=[];l instanceof tr?q.push([l.pos,l.pos+1,l.pos,l.pos+1]):F?q.push([l.from,l.to,l.from,l.to]):l.getMap().forEach((O,te,X,G)=>q.push([O,te,X,G]));for(let[O,te,X,G]of q){let[Z,oe]=po(N,R.map(O,-1),R.map(te,1)),[ne,Ge]=po(B,D.map(X,-1),D.map(G,1));c.push({oa:Z,ob:oe,na:ne,nb:Ge})}}),c.sort((l,k)=>l.oa-k.oa||l.na-k.na);let i=[];for(let l of c){let k=i[i.length-1];k&&(l.oa<=k.ob||l.na<=k.nb)?(k.ob=Math.max(k.ob,l.ob),k.nb=Math.max(k.nb,l.nb)):i.push({...l})}let g=!Y.length&&!E.length&&b.every(l=>l instanceof nr)&&o.every(dn),A=g?null:It(N,L,v),z=g?null:It(B,L,v),W=g?[]:Ct(N,L,v),T=g?[]:Ct(B,L,v),U=g?i.map(l=>({r:l,old:At(N,l.oa,l.ob),next:At(B,l.na,l.nb)})):null,P=g?U.reduce((l,k)=>l+k.next.end-k.next.start,0):i.reduce((l,k)=>l+(z[k.nb]-z[k.na]),0),I=P>Nt,K=I?l=>e.ydoc.transact(k=>{k.meta.set(_e,s),p(),l()},me):l=>l(),j={pd:e,map:x,bt:W,tx:K,copies:n.copies,fences:n.fences,sv:w,operationId:y,recovered:new Map(n.visible.filter(l=>l.recovered).map(l=>[l.id,l.sourceKey]))},Q=l=>l.filter(k=>k.k==="b").map(k=>`${k.id}|${k.t}|${JSON.stringify(k.attrs)}`).join(`
|
|
3
|
-
`),le=!g&&(E.length>0||Q(W)!==Q(T)),ee=()=>{for(let F of Y)lt(e,Ye(n.holes,F.tok),[{k:"b",id:F.alias,t:F.t,attrs:Object.fromEntries(xe(fe.nodes[F.t]).map(R=>[R,Ne(fe.nodes[F.t],R)]))}],K);for(let F=i.length-1;F>=0;F--)if(g){let{r:R,old:D,next:q}=U[F],O=D.tokens.map((te,X)=>{let G=h.mapResult(R.oa+X,1),Z=h.mapResult(R.oa+X+1,-1),oe=G.pos-R.na;return!G.deleted&&!Z.deleted&&Z.pos===G.pos+1&&oe>=0&&oe<q.tokens.length&&ze(te,q.tokens[oe])});Ft(j,D.start,D.tokens,q.tokens,O)}else{let R=i[F],D=A[R.oa],q=A[R.ob];Ft(j,D,W.slice(D,q),T.slice(z[R.na],z[R.nb]))}let l=E.length?ue(e):null,k=l?{...j,map:Tt(l.tokens,l.holes,e.flow.length)}:null;for(let{i:F,step:R}of E){let D=new ct(M.slice(F+1)),q=z[D.map(R.from,1)],O=z[D.map(R.to,-1)];if(O<=q)continue;let te=R.mark.type.name,X=R instanceof uo?R.mark.attrs&&Object.keys(R.mark.attrs).length?{...R.mark.attrs}:!0:null;if(an(R.mark)){if(X===null)continue;let G=fn(R.mark.attrs.entries);K(()=>{for(let[Z,oe]of Object.entries(G))Lt(k,q,O,Z,oe,T)});continue}K(()=>Lt(k,q,O,te,X,T))}};f||t?.stopCapturing();let m=t?.captureTimeout;t&&(t.captureTimeout=1/0);try{I?ee():e.ydoc.transact(l=>{l.meta.set(_e,s),p(),ee()},me)}finally{t&&(t.captureTimeout=m),u||t?.stopCapturing()}r.groups++,r.lastGroup={chunked:I,structural:le,regional:g,span:P}}var ke=e=>({status:"refused",code:e}),ho=e=>{if(!e)return"";let o=[];for(let n of Object.keys(e).sort())o.push(`${n}=${JSON.stringify(e[n])}`);return o.join(`
|
|
4
|
-
`)},rr=(e,o,n)=>{let r=n?n.state.doc:null,s=r&&r.childCount===o.visible.length&&o.visible.every((f,u)=>r.child(u).attrs.id===f.id)?r:Re(e,o),a=[];return s.forEach(f=>{f.attrs.id===null||f.attrs.id===void 0||a.push({id:f.attrs.id,parent:f.attrs.parent??null,t:f.type.name})}),a},sr=(e,o)=>{let n=[],r=e.get(o)?.parent??null,t=0;for(;r!=null&&t++<=e.size;)n.push(r),r=e.get(r)?.parent??null;return n},bo=(e,o,n)=>sr(e,n).includes(o),Bt=(e,o,n)=>o===n||bo(e,n,o),Dt=(e,o,n,r,t)=>{if(o?.recovered){let a=De(o.sourceKey,r);(e.gone.has(a)?e.gone.get(a):o.fields?.[r]??null)!==t&&e.gone.set(a,t);return}let s=e.attrs.get(n);s||(s=new Ae,e.attrs.set(n,s)),s.get(r)!==t&&s.set(r,t)},at=(e,o,n,r)=>Dt(e,o,n,"parent",r),ir=8,go={indent:(e,o)=>o.t==="list_item"&&Number.isInteger(e)&&e>=0&&e<=ir,open:(e,o)=>o.t==="toggle"&&typeof e=="boolean",parent:(e,o,n)=>e===null||typeof e=="string"&&n.get(e)?.t==="toggle"&&!Bt(n,e,o.id)},lr=(e,o)=>{if(e?.attrs===void 0)return[];if(!e.attrs||typeof e.attrs!="object"||Array.isArray(e.attrs))return null;let n=[];for(let[r,t]of Object.entries(e.attrs)){let s=o.get(r);if(!s||!t||typeof t!="object"||Array.isArray(t))return null;for(let[a,f]of Object.entries(t)){if(!go[a]||!go[a](f,s,o))return null;n.push({id:r,field:a,value:f})}}return n},cr=(e,o)=>{let n=kt(e.flow,0,e.flow.length),r=[],t=0;for(let s of e.flow.toDelta()){let a=s.attributes;if(typeof s.insert=="string")for(let f=0;f<s.insert.length;f++)r.push({ch:s.insert[f],attrs:a,source:o.resolve(n[t++])});else r.push({embed:s.insert,attrs:a,source:o.resolve(n[t++])})}if(t!==n.length)throw new Error(`The flow delta has ${t} units but the document has ${n.length}`);return r},ar=(e,o,n)=>{let r=new Map;for(let s of o.visible)n.has(s.id)&&s.brk&&r.set(Oe(s.brk),s.id);for(let s of n)for(let a of o.copies.get(s)??[])r.set(a,s);let t=[];for(let s=e.flow._start;s;s=s.right){if(s.deleted||!(s.content instanceof de))continue;let a=s.content.embed?.b;if(a===void 0||r.get(Oe(s.id))!==a)continue;let f=null;for(let u=s.right;u;u=u.right){if(u.deleted||!(u.content instanceof de))continue;let p=u.content.embed?.b;if(!(p===void 0||p===a)){f=Oe(u.id);break}}t.push({key:Oe(s.id),blockId:a,end:f})}return t};function zt({pd:e,view:o,um:n,origins:r,render:t,walked:s=null},a={}){let f=Array.isArray(a?.ids)?[...new Set(a.ids)]:[],u=a?.afterId===void 0?null:a.afterId,p=a?.parent!==void 0,b=s??ue(e,r),C=new Set(b.visible.filter(m=>m.opaque).map(m=>m.id)),M=rr(e,b,o),h=new Map(M.map(m=>[m.id,m])),w=M.map(m=>m.id);if(!f.length)return ke("missing-source");for(let m of f)if(!h.has(m))return ke("missing-source");let y=lr(a,h);if(!y)return ke("invalid-attrs");let N=y.filter(m=>m.field==="parent"),B=new Set(f.filter(m=>!f.some(l=>l!==m&&bo(h,l,m)))),v=M.filter(m=>f.some(l=>Bt(h,m.id,l))),L=new Set(v.map(m=>m.id));if(v.some(m=>C.has(m.id))||y.some(m=>C.has(m.id)))return ke("unsupported-format");let Y=new Map(b.visible.map(m=>[m.id,m]));for(let m of v){let l=Y.get(m.id);if(!l||l.implicit||!l.brk)return ke("missing-source")}let $;if(p)$=a.parent??null;else{let m=new Set(v.filter(l=>B.has(l.id)).map(l=>l.parent));if(m.size!==1)return ke("invalid-parent");$=[...m][0]}if(p&&$!==null){let m=h.get($);if(!m||m.t!=="toggle")return ke("invalid-parent");if(L.has($))return ke("cycle")}if(u!==null){if(typeof u!="string"||!h.has(u))return ke("missing-destination");if(L.has(u))return ke("cycle");if(h.get(u).parent!==$)return ke("missing-destination")}let x=M.filter(m=>!L.has(m.id)),c=0;if(u===null){if($!==null){let m=x.findIndex(k=>k.parent===$),l=x.findIndex(k=>k.id===$);c=m>=0?m:l<0?0:l+1}}else for(c=x.findIndex(m=>m.id===u)+1;c<x.length&&Bt(h,x[c].id,u);)c++;let E=[...x.slice(0,c),...v,...x.slice(c)],i=E.length===w.length&&E.every((m,l)=>m.id===w[l]),g=v.filter(m=>B.has(m.id)&&m.parent!==$),A=v.map(m=>m.id);if(i&&!g.length&&!y.length)return{status:"unchanged"};let z=(()=>{let m=o?.state.selection;if(!(m instanceof pe.TextSelection))return null;let l=R=>{let D=o.state.doc.resolve(R);return D.depth?{id:D.node(1).attrs.id,offset:D.parentOffset}:null},k=l(m.anchor),F=l(m.head);return k&&F&&(L.has(k.id)||L.has(F.id))?{anchor:k,head:F}:null})(),W=()=>{if(!z||!o)return;let m=({id:F,offset:R})=>{let D=null;return o.state.doc.forEach((q,O)=>{D===null&&q.attrs.id===F&&(D=O+1+Math.min(R,q.content.size))}),D},l=m(z.anchor),k=m(z.head);l!==null&&k!==null&&o.dispatch(o.state.tr.setSelection(pe.TextSelection.create(o.state.doc,l,k)).setMeta(Me,!0).setMeta("addToHistory",!1))};if(i)return n?.stopCapturing(),e.ydoc.transact(()=>{if(N.length)for(let m of N)at(e,Y.get(m.id),m.id,m.value);else for(let m of g)at(e,Y.get(m.id),m.id,$);for(let m of y)m.field!=="parent"&&Dt(e,Y.get(m.id),m.id,m.field,m.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A};let T=[...Qe(Ze(e.ydoc)).entries()].sort((m,l)=>m[0]-l[0]),U=be(e),P=cr(e,r),I=yt(b,e.flow.length),K=[],j=0;for(let m of b.visible){if(L.has(m.id)){let l=[];for(let[k,F]of I.physicalRanges(j,j+m.len))for(let R=k;R<F;R++)l.push(P[R]);K.push({seg:m,units:l})}j+=m.len}for(let m=0;m<K.length;m++){let l=K[m];if(l.seg.id!==A[m])throw new Error(`Captured ${l.seg.id} where ${A[m]} was expected`);if(!l.units.length||l.units[0].embed===void 0||l.units[0].embed.b!==l.seg.id)throw new Error(`The selected block ${l.seg.id} has no physical marker to copy`)}let Q=ar(e,b,L),le=Pe(e.gone),ee=new Map;for(let m of v){let l=Y.get(m.id);if(!l.recovered)continue;let k=b.removals.filter(D=>D.sourceKey===l.sourceKey),F=$n(l.sourceKey,k,le),R=le.restores.find(D=>D.key===F?.key)?.baseline??{type:l.t,attrs:l.fields??{}};ee.set(l.sourceKey,{covers:k.map(D=>D.key),baseline:JSON.parse(JSON.stringify(R))})}if(!Q.length)throw new Error("The selected blocks have no live physical markers to retire");return n?.stopCapturing(),e.ydoc.transact(()=>{for(let O of Q)e.gone.set(Be(O.key,U),{blockId:O.blockId,end:O.end,sv:T});let m=ue(e,r),l=yt(m,e.flow.length),k=m.visible.map(O=>O.id),F=0;if(c>0){let O=k.indexOf(x[c-1].id);F=O<0?0:O+1}let R=0;for(let O=0;O<F;O++)R+=m.visible[O].len;let D=l.toPhysical(R,"before"),q=[];for(let O of K){let te=D,X=null,G=null,Z=()=>{X!==null&&(We(e,D,m.fences,()=>e.flow.insert(D,X,G??void 0)),D+=X.length,X=null)};for(let ne of O.units)ne.ch!==void 0?(X!==null&&ho(ne.attrs)!==ho(G)&&Z(),X===null&&(X="",G=ne.attrs),X+=ne.ch):(Z(),We(e,D,m.fences,()=>e.flow.insertEmbed(D,ne.embed,ne.attrs)),D+=1);Z();let oe=kt(e.flow,te,D);if(oe.length!==O.units.length)throw new Error(`Copied ${O.seg.id} as ${oe.length} units instead of ${O.units.length}`);for(let ne=1;ne<O.units.length;ne++)q.push({dest:oe[ne],source:O.units[ne].source});r.recordBoundary(oe[0],O.seg.recovered?{blockId:O.seg.id,kind:"copy",recoveryOf:O.seg.sourceKey}:{blockId:O.seg.id,kind:"copy"}),O.seg.recovered&&e.gone.set(ot(O.seg.sourceKey,U),ee.get(O.seg.sourceKey)),e.gone.set(Tn(Oe(oe[0])),!0)}if(q.length&&r.recordSpans(q),N.length)for(let O of N)at(e,Y.get(O.id),O.id,O.value);else for(let O of g)at(e,Y.get(O.id),O.id,$);for(let O of y)O.field!=="parent"&&Dt(e,Y.get(O.id),O.id,O.field,O.value)},me),n?.stopCapturing(),t(),W(),{status:"moved",ids:A}}var Jt=e=>{let o=[];return e.forEach(n=>o.push([n.type.name,JSON.stringify(Object.fromEntries(xe(n.type).map(r=>[r,n.attrs[r]]))),n.isTextblock||n.type.name==="table"?JSON.stringify(n.content.toJSON()):null])),JSON.stringify(o)};function fr(e,o){if(e.childCount!==o.childCount)return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r!==t&&(r.type!==t.type||xe(r.type).some(s=>!ye(r.attrs[s],t.attrs[s]))||(r.isTextblock||r.type.name==="table")&&!r.content.eq(t.content)))return!1}return!0}var ur=e=>{let o=[];return e.forEach((n,r)=>{n.type.name==="opaque_block"&&o.push([r,r+n.nodeSize])}),o},dr=(e,o)=>{let n=typeof e.from=="number"?e.from:typeof e.pos=="number"?e.pos:null;if(n===null)return!1;let r=typeof e.to=="number"?e.to:n+1;return o.some(([t,s])=>n<s&&r>t)},Ue=(e,o)=>{let n=e.resolve(o);return n.depth&&n.node(1).type.name==="table"?[n.before(1),n.after(1)]:null};function ko(e,o){let n=e.content.findDiffStart(o.content);if(n===null)return null;let{a:r,b:t}=e.content.findDiffEnd(o.content),s=n-Math.min(r,t);s>0&&(r+=s,t+=s);let a=(f,u)=>{let p=f.resolve(n);return p.parent.isTextblock&&p.sameParent(f.resolve(u))};return(Ue(e,n)||Ue(e,r))&&!(a(e,r)&&a(o,t))?(n=Ue(e,n)?.[0]??n,r=Ue(e,r)?.[1]??r,t=Ue(o,t)?.[1]??t,{start:n,endA:r,endB:t,tables:!0}):{start:n,endA:r,endB:t}}function Kt(e,o=null){let n=new Map;o?.forEach(u=>{u.attrs.id&&n.set(u.attrs.id,u)});let r=[];e.forEach(u=>r.push(u));let t=r.map(u=>({id:u.attrs.id,pos:n.get(u.attrs.id)?.attrs.pos??u.attrs.pos})),s=bt(t,"b"),a=!1,f=r.map((u,p)=>{let b=s[p]?.pos??t[p].pos,C=u.content;if(u.type.name==="table"){let w=[];u.forEach(v=>w.push(v));let y=w.map(v=>({id:v.attrs.id,pos:v.attrs.pos})),N=bt(y,"r"),B=w.map((v,L)=>{let Y=N[L]?.pos??y[L].pos;return Y===v.attrs.pos?v:v.type.create({...v.attrs,pos:Y},v.content,v.marks)});B.some((v,L)=>v!==w[L])&&(C=B)}if(b===u.attrs.pos&&C===u.content)return u;a=!0;let M={...u.attrs,pos:b},h=n.get(u.attrs.id);return h&&C===u.content&&h.hasMarkup(u.type,M,u.marks)&&h.content.eq(C)?h:u.type.create(M,C,u.marks)});return a?e.type.create(e.attrs,f):e}var yo=e=>{let o=new Set,n=null;for(let r=0;r<e.childCount;r++){let{id:t,pos:s}=e.child(r).attrs;if(!t||o.has(t)||!un(s)||n!==null&&n>=s)return!1;o.add(t),n=s}return!0},pr=(e,o)=>{for(let n in e.attrs)if(n!=="pos"&&e.attrs[n]!==o.attrs[n])return!1;return!0};function mr(e,o){if(e.childCount!==o.childCount||!yo(e))return!1;for(let n=0;n<e.childCount;n++){let r=e.child(n),t=o.child(n);if(r===t)continue;if(!(r.type===t.type&&r.marks===t.marks&&pr(r,t))&&!r.hasMarkup(t.type,{...t.attrs,pos:r.attrs.pos},t.marks)||!r.content.eq(t.content)||r.type.name==="table"&&!yo(r))return!1}return!0}var wo=e=>{if(e&&typeof e=="object"){for(let o of Object.keys(e))wo(e[o]);Object.freeze(e)}return e},vo=e=>wo(JSON.parse(JSON.stringify(e))),hr=(e,o)=>{let n=gn(o),r=0;for(let t=e.flow._start;t;t=t.right){if(t.id.client===n.client&&t.id.clock===n.clock)return t.deleted?r:r+t.length;!t.deleted&&t.countable&&(r+=t.length)}return r},gr=(e,o)=>{let n=null;for(let r=e.flow._start;r;r=r.right)r.id.client!==e.ydoc.clientID||!(r.content instanceof de)||r.content.embed?.b!==o||(!n||r.id.clock>n.clock)&&(n=r.id);return n};function xo({pd:e,onNotice:o=()=>{},ownedTokens:n=[],authorToken:r=null,stats:t={groups:0,mismatch:0,renders:0,first:null},captureTimeout:s=500}){let a=null,f=null,u=0,p=-1,b=null,C=0,M=new WeakMap,h=Le(e.origins);f=ue(e,h);let w=new on([e.flow,e.attrs,e.gone,e.tableFields,e.boardFields],{trackedOrigins:new Set([me]),captureTimeout:s,captureTransaction:d=>d.meta.get(_e)!==!1,deleteFilter:d=>{if(d.parent!==e.flow||!(d.content instanceof de))return!0;let S=h.resolve(d.id);return S.client!==d.id.client||S.clock!==d.id.clock||h.boundaryOf(d.id)?.kind!=="copy"}}),y=wn(e,w,h,d=>Pe(d).textDeletes),N=new Set,B=new Set(r?[...n,r]:n),v=r?()=>{let d=An(e.ydoc.clientID);e.origins.get(d)!==r&&e.origins.set(d,r)}:null,L=new Set,Y=new Set,$=0,x=null,c=null,E=d=>{let S=new Set;for(let J of d.blocks)for(let V of J.runs){if(!V.displaced)continue;let H=Rn(V.source)?.client===e.ydoc.clientID;V.author&&(H||B.has(V.author))?S.add(V.author):H&&S.add(null)}if(!S.size)return null;let _=[...S].filter(Boolean).sort();return{kind:"recovered-change",source:d.source,revision:d.revision,blockId:d.blockId,author:_[0]??null,authors:_}},i=d=>{let S=d.list.filter(J=>J.recoverable).map(J=>vo(J)),_=vo(S.map(J=>E(J)).filter(J=>J&&!L.has(`${J.source}\0${J.revision}`)));return Object.freeze({recoverable:Object.freeze(S),notices:Object.freeze(_)})},g=(d,S)=>{if(JSON.stringify(i(st(e,{index:h,walked:S})))===JSON.stringify(d)){t.provedRecoveries=(t.provedRecoveries??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error("Recovery snapshot built from the displacing sources diverged from a full reduction")},A=()=>{if(x&&x.version===$)return x.snapshot;let d=p===u?f:void 0,S=i(jn(e,{index:h,walked:d}));return t.proveWalks&&g(S,d),x={version:$,snapshot:S},S},z=d=>rt({recoverable:d.recoverable.map(S=>[S.source,S.revision]),notices:d.notices}),W=()=>{$++;let d=A();for(let _ of d.notices){let J=`${_.source}\0${_.revision}`;N.has(J)||(N.add(J),o(_))}if(!Y.size){c=null;return}let S=z(d);if(S!==c){c=S;for(let _ of[...Y])_(d)}},T=d=>{f=d,p=u,b=null,C=0},U=()=>p===u?f:null,P=d=>{let S=Ve(e,d),_=Ve(e,ue(e));if(S===_){t.provedWalks=(t.provedWalks??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error(`Incremental walk diverged from the full walk:
|
|
5
|
-
${S}
|
|
6
|
-
---
|
|
7
|
-
${_}`)},I=d=>JSON.stringify([d.removals,d.restores,d.textDeletes,[...d.copyActive],[...d.attrs].map(([S,_])=>[S,[..._]])]),K=()=>{if(I(Pe(e.gone))===I(Pe(e.gone,{kept:!1}))){t.provedIntents=(t.provedIntents??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error("Removal records kept across writes diverged from a fresh parse of the gone map")},j=d=>{K();let S=Le(e.origins),_;try{_=Ve(e,ue(e,{resolve:S.resolve,boundaryOf:S.boundaryOf}))}finally{S.dispose()}let J=Ve(e,d);if(J===_){t.provedIndexWalks=(t.provedIndexWalks??0)+1;return}throw t.walkMismatch=(t.walkMismatch??0)+1,new Error(`A walk with the kept origin index diverged from one with a fresh index:
|
|
8
|
-
${J}
|
|
9
|
-
---
|
|
10
|
-
${_}`)},Q=()=>{if(JSON.stringify(i(st(e,{index:h,walked:f})))!==JSON.stringify(A()))throw t.walkMismatch=(t.walkMismatch??0)+1,new Error("Recovery snapshot kept across an incremental walk diverged from a fresh one")},le=()=>{let d=C===1?b:null,S=d?d.marker?oo(e,f,d.marker,d):f:null;if(!S){let _=ue(e,h);return t.proveWalks&&j(_),T(_),null}if(d.fields.size)for(let _ of S.visible)d.fields.has(_.baseId)&&M.delete(_);return t.incrementalWalks=(t.incrementalWalks??0)+1,t.proveWalks&&P(S),T(S),d},ee=d=>{if(d.childCount===f.visible.length)for(let S=0;S<d.childCount;S++)M.has(f.visible[S])||M.set(f.visible[S],d.child(S))},m=(d,S)=>{if(d.childCount!==f.visible.length)return;let _=ko(d,S);if(!_)return;let J=d.resolve(_.start).index(0),V=Math.min(d.childCount-1,d.resolve(_.endA).index(0));for(let H=J;H<=V;H++)M.delete(f.visible[H])},l=()=>{let d=le();return!d||d.deleted||d.fields.size||d.remote&&f.hidden.length?W():t.proveWalks&&Q(),Re(e,f,M)},k=null,F=null,R=!1,D=!1,q=(d=!1,S=null)=>{t.renders++;let _=k;k=null;let J=Kt(S??l(),a.state.doc),V=ko(a.state.doc,J);if(!V){ee(a.state.doc);return}let H=a.state.tr.replace(V.start,V.endA,J.slice(V.start,V.endB)).setMeta(Me,!0).setMeta("addToHistory",!1);if(d&&H.setMeta("yundo",!0),_){let ae=se=>se>=0&&f.holes.some(ie=>se>=Kn(f.holes,ie.at)&&se<Ye(f.holes,ie.at)),re=(se,ie)=>{let we=null;return H.doc.forEach((Ie,Xe)=>{we===null&&Ie.attrs.id===se&&Ie.isTextblock&&(we=Xe+1+Math.min(ie,Ie.content.size))}),we},ce=se=>{let ie=pt(se.right,e.ydoc);if(!ie)return null;let we=qn(H.doc,f.holes,f.tokens,ie.index,f.visible);if(!se.block)return we;let Ie=H.doc.resolve(we);if(Ie.depth&&Ie.node(1).attrs.id===se.block.id)return we;let Xe=se.left?pt(se.left,e.ydoc):null;return!ae(ie.index)&&!(Xe&&ae(Xe.index-1))?we:re(se.block.id,se.block.offset)??we},he=ce(_.anchor),ge=ce(_.head);he!==null&&ge!==null&&H.setSelection(pe.TextSelection.create(H.doc,he,ge))}else if(V.tables&&a.state.selection instanceof pe.TextSelection){let ae=Pt(a.state.doc,a.state.selection.anchor),re=Pt(a.state.doc,a.state.selection.head),ce=ae&&Rt(H.doc,ae),he=re&&Rt(H.doc,re);ce!=null&&he!==null&&he!==void 0&&H.setSelection(pe.TextSelection.create(H.doc,ce,he))}a.dispatch(H),ee(a.state.doc)},O=new WeakMap,te=new WeakSet,X=d=>{if(d.changed.size||d.deleteSet.clients.size)return!1;for(let[S,_]of d.afterState)if((d.beforeState.get(S)??0)!==_)return!1;return!0},G=d=>{O.set(d,u),u++},Z=d=>{if(X(d)){te.add(d),p===O.get(d)&&u===p+1&&(p=u);return}C++,b=C===1?no(e,d,f):null},oe=d=>{if(R&&!D&&d.origin===me&&(w.stopCapturing(),R=!1),!a||d.origin===me||d.origin===w||k)return;let S=a.state.selection;if(!(S instanceof pe.TextSelection)||[S.$anchor,S.$head].some(J=>J.depth&&J.node(1).type.name==="table"))return;let _=J=>{let V=Hn(a.state.doc,f.holes,J.pos,f.visible);return{right:dt(e.flow,V),left:V>0?dt(e.flow,V,-1):null,block:J.depth?{id:J.node(1).attrs.id,offset:J.parentOffset}:null}};k={anchor:_(S.$anchor),head:_(S.$head)}},ne=d=>{d.origin!==me&&(F=null,R=!1)},Ge=(d,S)=>{let _=!1,J=!1,V=!1;for(let H of S)te.has(H)||(_=!0,H.origin===me?J=!0:H.origin===w&&(V=!0));if(!_){k=null;return}if(!a){W();return}if(J){k=null;return}q(V)},Oo=(d,S)=>{let _=zt({pd:e,view:a,um:w,origins:h,render:q,walked:U()},S);if(_.status!=="moved")return _.status==="refused"&&(t.moveRefusals=(t.moveRefusals??0)+1),_;let J=d.selection;if(J instanceof pe.TextSelection)return _;let V=a.state.doc,H=null,ae=null;if(V.forEach((he,ge)=>{S.ids.includes(he.attrs.id)&&(H===null&&(H=ge),ae=ge+he.nodeSize)}),H===null)return _;let re=J instanceof pe.NodeSelection?pe.NodeSelection.create(V,H):J.anchor<=J.head?new Ot(V.resolve(H),V.resolve(ae)):new Ot(V.resolve(ae),V.resolve(H)),ce=a.state.tr.setSelection(re).setMeta(Me,!0).setMeta("addToHistory",!1);return a.dispatch(d.scrolledIntoView?ce.scrollIntoView():ce),_},Mo=_n({pd:e,um:w,origins:h,render:()=>a?q():l()});return e.ydoc.on("beforeTransaction",G),e.ydoc.on("beforeTransaction",oe),e.ydoc.on("afterTransaction",Z),e.ydoc.on("afterTransaction",ne),e.ydoc.on("afterAllTransactions",Ge),{pd:e,stats:t,render:q,um:w,board:Mo,attach(d){a=d,T(ue(e,h))},dispose(){e.ydoc.off("beforeTransaction",G),e.ydoc.off("beforeTransaction",oe),e.ydoc.off("afterTransaction",Z),e.ydoc.off("afterTransaction",ne),e.ydoc.off("afterAllTransactions",Ge),y(),h.dispose(),w.destroy(),Y.clear(),a=null},get walk(){return f},get recoverable(){return A().recoverable},get notices(){return A().notices},subscribeRecovery(d){if(typeof d!="function")throw new TypeError("subscribeRecovery needs a listener");Y.add(d);let S=A();return c===null&&(c=z(S)),d(S),()=>{Y.delete(d)}},dismiss(d,S){L.add(`${d}\0${S}`),W()},dispatch(d){let S=d.getMeta(Ln);if(S)return Oo(d,S);let _=ur(a.state.doc);if(_.length&&d.steps.some(ie=>dr(ie,_)))return{status:"refused",code:"unsupported-format"};let{state:J,transactions:V}=a.state.applyTransaction(d),H=V.filter(ie=>ie.docChanged&&!ie.getMeta(Me));if(a.updateState(J),!H.length){V.some(ie=>ie.selectionSet&&!ie.getMeta(Me))&&(F=null,R&&(w.stopCapturing(),R=!1));return}p!==u?le():t.reusedWalks=(t.reusedWalks??0)+1;let ae=V.every(ie=>ie.getMeta("addToHistory")!==!1),re=v;v=null;let ce=ae?Fn(H,a):null,he=R&&Nn(F,ce);F=ce,D=he;try{mo(e,H,f,t,w,ae,re,{join:he,open:ce!==null})}finally{D=!1}R=ce!==null;let ge=a.state.doc;m(H[0].before,ge);let se=l();if(!fr(se,ge))t.mismatch++,t.first??={before:Jt(H[0].before),pm:Jt(ge),y:Jt(se)};else if(mr(ge,se)){t.renders++,k=null,ee(ge);return}q(!1,se)},restore(d,S){let _=ue(e,h),J=st(e,{index:h,walked:_}).sources.get(d),V=_.visible.find(re=>re.sourceKey===d||re.brk&&Oe(re.brk)===d);if(V)return{status:"resolved",id:V.id};if(!J||J.revision!==S)return{status:"stale",notice:A().notices.find(ce=>ce.source===d)??null};let H=`${Yn}${d}`;w.stopCapturing();let ae=null;if(e.ydoc.transact(()=>{e.gone.set(ot(d,be(e)),{covers:J.removals.map(re=>re.key),baseline:{type:J.type,attrs:JSON.parse(JSON.stringify(J.attrs))}}),e.flow.insertEmbed(hr(e,d),{b:H}),ae=gr(e,H),h.recordBoundary(ae,{blockId:H,kind:"restore",recoveryOf:d})},me),w.stopCapturing(),q(),!f.visible.some(re=>re.sourceKey===d&&re.id===H))throw new Error(`Restore did not project ${H}`);return{status:"restored",id:H}},moveBlocks(d){return zt({pd:e,view:a,um:w,origins:h,render:q,walked:U()},d)},undo(){return w.undo()!==null},redo(){return w.redo()!==null}}}function So({changed:e=()=>{}}={}){let o=[],n=()=>{let r=o.filter(Boolean);if(!r.length)return null;let t=r.length===1?r[0]:mt(r);return o=o.map(()=>null),o[o.length-1]=t,t};return{local(r){let t=r.slice(),s=0;for(;o[s];s++)t=mt([o[s],t]),o[s]=null;o[s]=t,e()},pending(){return o.some(Boolean)},accepted(r){let t=n();if(!t)return!0;let s=!1;try{s=xn(Sn(r),t)}catch{}return s?(o=[],e(),!0):!1}}}function br({store:e,ydoc:o=new tn,onNotice:n=()=>{},ownedTokens:r=[],authorToken:t=null,setTimer:s=setTimeout,clearTimer:a=clearTimeout,compact:f,captureTimeout:u=500,checkpointWithin:p=()=>{},requestCheckpoint:b=null,requestExitCheckpoint:C=null,registerUnsavedState:M=null,onStopped:h=()=>{},journal:w=null,exitClosed:y=()=>!1,stats:N={groups:0,mismatch:0,renders:0,first:null}}){for(let[,j]of en(e.value.y))nn(o,On(j),hn);let B=kn(o),v=w||null,L=()=>{},Y=So({changed:()=>L()}),$=Mn({store:e,ydoc:o,setTimer:s,clearTimer:a,compact:f,onStopped:j=>{if(j!=="blockeditor-full"&&j!=="compaction-failed"){h(j);return}Promise.resolve(b?.({timeoutMs:1e4})).catch(()=>{}).finally(()=>h(j))},onLocalUpdate:Y.local,journal:{local:j=>v?.local(j),dependency:j=>v?.dependency(j)}}),x=xo({pd:B,onNotice:n,ownedTokens:r,authorToken:t,stats:N,captureTimeout:u}),c=new Set,E=!1,i=!1,g=M?.({id:"page:live",isPending:()=>y()&&Y.pending()||e.pending.length>0||$.pending||$.reconcilePending||!!(v&&v.pending()>(v.failure?1:0)),flush:I}),A=()=>{g?.changed(),!i&&(i=!0,Promise.resolve().then(()=>{if(i=!1,!E)for(let j of[...c])j.check()}))};L=A;let z=e.onLocal(()=>{p(1500),A()}),W=e.onRebase(A),T=e.onConfirm(()=>{v?.acknowledged(),A()});v&&(v.onChange=A);let U=()=>Y.pending()||e.pending.length>0||$.pending||$.reconcilePending||!!(v&&v.pending()>(v.failure?1:0));function P({permit:j,deadline:Q,keepalive:le,signal:ee,timeoutMs:m}){let l=Math.min(Q??1/0,Date.now()+m),k=()=>ee?.aborted||Date.now()>=l;return new Promise(F=>{let R=!1,D=null,q=null,O={check(){q?.()},finish(Z){R||(R=!0,c.delete(O),a(D),ee?.removeEventListener("abort",te),F(Z))}},te=()=>O.finish({ok:!1,code:"timeout"}),X=Z=>new Promise(oe=>{let ne=()=>{a(D),q=null,oe()};D=s(ne,Z),q=ne}),G=async()=>{if($.settle(),Y.pending()&&C){let Z=await C({permit:j,deadline:l,signal:ee,keepalive:le,needsSave:()=>Y.pending()});if(R)return;if(!Z?.ok){O.finish(Z?.ok===!1?Z:{ok:!1,code:"checkpoint-failed"});return}}for(;!R;){if(!U()){O.finish({ok:!0});return}if(k()){O.finish({ok:!1,code:"timeout"});return}await X(50)}};c.add(O),ee?.addEventListener("abort",te,{once:!0}),G().catch(Z=>O.finish({ok:!1,code:"flush-failed",message:Z?.message||String(Z)}))})}function I({permit:j=null,deadline:Q=null,keepalive:le=!1,signal:ee=null,timeoutMs:m=1e4}={}){return E?Promise.resolve({ok:!1,code:"disposed"}):j?P({permit:j,deadline:Q,keepalive:le,signal:ee,timeoutMs:m}):new Promise(l=>{let k=Date.now()+m,F=!1,R=!1,D=!1,q=null,O={check:X,finish:te};function te(G){F||(F=!0,c.delete(O),a(q),l(G))}function X(){if(!(F||R||D)){R=!0;try{if($.settle(),e.pending.length&&(p(0),e.pending.length))return;if(D=!0,!b){te({ok:!0});return}Promise.resolve().then(()=>{if(!F)return b({timeoutMs:Math.max(0,k-Date.now())})}).then(te,G=>te({ok:!1,code:"checkpoint-failed",message:G?.message||String(G)}))}catch(G){te({ok:!1,code:"flush-failed",message:G?.message||String(G)})}finally{R=!1}}}c.add(O),q=s(()=>te({ok:!1,code:"timeout"}),m),X()})}return{ydoc:o,pd:B,provider:$,bridge:x,stats:N,flush:I,awareness:{generation:()=>Number.isSafeInteger(e.value?.g)&&e.value.g>=0?e.value.g:0,map:()=>({pd:B,w:x.walk})},get journal(){return v},filePending:()=>Y.pending(),acceptFile:j=>Y.accepted(j),doc:()=>Kt(Re(B,ue(B))),attach:j=>x.attach(j),dispatch:j=>x.dispatch(j),moveBlocks:j=>x.moveBlocks(j),board:x.board,undo:()=>x.undo(),redo:()=>x.redo(),restore:(j,Q)=>x.restore(j,Q),get recoverable(){return x.recoverable},get notices(){return x.notices},subscribeRecovery:j=>x.subscribeRecovery(j),dismiss:(j,Q)=>x.dismiss(j,Q),dispose(){if(!E){E=!0,z(),W(),T(),g?.dispose(),v?.close(),Promise.resolve(v?.channel?.flush?.()).catch(()=>{});for(let j of[...c])j.finish({ok:!1,code:"disposed"});x.dispose(),$.dispose()}}}}var Ht="Some text you typed was kept aside when its block moved or was removed.",kr=`
|
|
11
|
-
:host { font: inherit !important; color: inherit !important; }
|
|
12
|
-
.blockeditor-recover-root { display: contents; }
|
|
13
|
-
.blockeditor-recover { position: fixed; right: 16px; bottom: 16px; z-index: 20; min-height: 36px; padding: 0 14px; font: inherit; font-size: 14px; color: var(--blockeditor-ink); background: var(--blockeditor-pop-bg); border: 1px solid var(--blockeditor-chrome-line-rest); border-radius: 999px; cursor: pointer; }
|
|
14
|
-
.blockeditor-recover[hidden], .blockeditor-recover-panel[hidden] { display: none; }
|
|
15
|
-
.blockeditor-recover-panel { position: fixed; right: 16px; bottom: 64px; z-index: 21; width: min(380px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; color: var(--blockeditor-ink); background: var(--blockeditor-pop-bg); border: 1px solid var(--blockeditor-chrome-line-rest); border-radius: var(--blockeditor-chrome-radius); padding: 8px; box-sizing: border-box; }
|
|
16
|
-
.blockeditor-recover-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 8px; font-weight: 600; }
|
|
17
|
-
.blockeditor-recover-note { margin: 0 6px 8px; font-size: 13px; opacity: .72; }
|
|
18
|
-
.blockeditor-recover-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; min-height: 44px; padding: 8px 6px; border-top: 1px solid var(--blockeditor-chrome-line-rest); }
|
|
19
|
-
.blockeditor-recover-row.is-target { outline: 2px solid var(--blockeditor-accent, currentColor); outline-offset: -2px; }
|
|
20
|
-
.blockeditor-recover-meta { grid-column: 1; font-size: 12px; opacity: .72; }
|
|
21
|
-
.blockeditor-recover-text { grid-column: 1; overflow-wrap: anywhere; }
|
|
22
|
-
.blockeditor-recover-text mark { background: var(--blockeditor-mark-bg, rgba(255, 214, 102, .45)); color: inherit; border-radius: 2px; }
|
|
23
|
-
.blockeditor-recover-row button, .blockeditor-recover-head button { grid-column: 2; grid-row: 1 / span 2; min-height: 36px; padding: 0 12px; font: inherit; font-size: 14px; color: inherit; background: transparent; border: 1px solid var(--blockeditor-chrome-line-rest); border-radius: var(--blockeditor-chrome-radius); cursor: pointer; }
|
|
24
|
-
@media (max-width: 560px) {
|
|
25
|
-
.blockeditor-recover { top: 12px; bottom: auto; min-height: 44px; }
|
|
26
|
-
.blockeditor-recover-panel { left: 0; right: 0; bottom: 0; width: 100%; max-height: 70vh; border-radius: var(--blockeditor-chrome-radius) var(--blockeditor-chrome-radius) 0 0; }
|
|
27
|
-
.blockeditor-recover-row button, .blockeditor-recover-head button { min-height: 44px; }
|
|
28
|
-
}
|
|
29
|
-
`,yr={heading:"Heading",list_item:"List item",toggle:"Toggle",quote:"Quote",code_block:"Code",callout:"Callout",table:"Table",image:"Image"},qt=280,ve=(e,o,n,r={})=>{let t=e.createElement(o);n&&(t.className=n);for(let[s,a]of Object.entries(r))t.setAttribute(s,a);return t};function vr(e,o){let n=ve(e,"div","blockeditor-recover-text"),r=0;for(let t of o.blocks){for(let s of t.runs){if(s.kind!=="text"||r>=qt)continue;let a=s.text.slice(0,qt-r);r+=a.length,n.append(s.displaced?Object.assign(e.createElement("mark"),{textContent:a}):e.createTextNode(a))}r<qt&&t!==o.blocks[o.blocks.length-1]&&n.append(e.createTextNode(" / "))}return n.textContent||(n.textContent="(no text)"),n}function wr(e){let o=new Set;for(let n of e.blocks)for(let r of n.runs)r.displaced&&o.add(r.author??null);return[...o]}function xr(e,o){let n=null;return e.state.doc.forEach((r,t)=>{n===null&&r.attrs.id===o&&(n=r.isTextblock?t+1:t)}),n===null?!1:(e.dispatch(e.state.tr.setSelection(pe.Selection.near(e.state.doc.resolve(n))).scrollIntoView()),e.focus(),!0)}function Sr({binding:e,mount:o,ownTokens:n=[],onRestored:r=()=>{},onStale:t=()=>{}}){let s=o.ownerDocument,a=new Set(n.filter(Boolean)),f=ve(s,"button","blockeditor-recover",{type:"button","aria-haspopup":"dialog","aria-expanded":"false"}),u=ve(s,"div","blockeditor-recover-panel",{role:"dialog","aria-label":"Recover changes"});f.hidden=!0,u.hidden=!0;let p=ve(s,"div","blockeditor-recover-root");p.append(f,u);let b=Vt({name:"blockeditor-recover",content:p,css:[kr],parent:o}),C={recoverable:[],notices:[]},M=null,h="",w=x=>x.some(c=>a.has(c))?x.length>1?"You and others":"You":x.some(c=>c!==null)?"Another editor":"An earlier edit",y=()=>{u.hidden=!0,M=null,f.setAttribute("aria-expanded","false")},N=x=>{let c;try{c=e.restore(x.source,x.revision)}catch(E){return console.error("[clay] Restore failed:",E),Wt("This change could not be restored.","error"),{status:"failed"}}return c.status==="restored"||c.status==="resolved"?r(c.id):c.status==="stale"&&t(c),c},B=()=>{u.replaceChildren();let x=ve(s,"div","blockeditor-recover-head");x.append(s.createTextNode("Recover changes"));let c=ve(s,"button","",{type:"button"});c.textContent="Close",c.addEventListener("click",()=>{y(),f.focus()}),x.append(c);let E=ve(s,"p","blockeditor-recover-note");E.textContent="Text typed while its block was moved or removed. Restore puts it back as a new block.",u.append(x,E);for(let i of C.recoverable){let g=ve(s,"div","blockeditor-recover-row",{"data-source":i.source});i.source===M&&g.classList.add("is-target");let A=ve(s,"div","blockeditor-recover-meta");A.textContent=`${yr[i.type]??"Paragraph"} \xB7 ${w(wr(i))}`;let z=ve(s,"button","",{type:"button"});z.textContent="Restore",z.addEventListener("click",()=>N(i)),g.append(A,vr(s,i),z),u.append(g)}},v=(x=null)=>{if(!C.recoverable.length)return;M=x,u.hidden=!1,f.setAttribute("aria-expanded","true"),B();let c=[...u.querySelectorAll(".blockeditor-recover-row")];(c.find(i=>i.dataset.source===x)??c[0])?.querySelector("button")?.focus()},L=x=>{let c=x.map(E=>`${E.source}\0${E.revision}`).join(`
|
|
30
|
-
`);if(c!==h){if(h=c,!x.length){ft(Ht);return}Ut(Ht,"warning",{actions:[{label:"Review",onClick:()=>v(x[0].source)},{label:"Dismiss",onClick:()=>{for(let E of x)e.dismiss(E.source,E.revision)}}]})}},Y=x=>{C=x;let c=x.recoverable.length;f.hidden=c===0,f.textContent=`Recover changes (${c})`,c?u.hidden||B():y(),L(x.notices)};f.addEventListener("click",()=>u.hidden?v():y()),u.addEventListener("keydown",x=>{x.key==="Escape"&&(x.stopPropagation(),y(),f.focus())});let $=e.subscribeRecovery(Y);return{open:v,close:y,restore:N,get count(){return C.recoverable.length},destroy(){$(),ft(Ht),b.remove()}}}import("./page/editor-HS2CAV3W.js").catch(()=>null);export{Wn as ADOPTION_TIMEOUT_MS,Yo as acceptedPageState,Po as blocksFromYValue,je as canon,Mt as classifyFile,Io as createFeatureLoader,Sr as createRecoverList,br as createYPageBinding,xr as focusBlock,To as heldSlashRange,Ao as holdSlashRange,Do as installAdoption,jt as mergePageModels,Co as observeDocumentTitle,it as readBack,Ro as renderFromTags,$o as seedPageFromArticle,Eo as yValueOf};
|
package/dist/m/c-D2OPWOWO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a}from"./c-J2ZW4HMR.js";import{a as c}from"./c-4JZDZFF6.js";var s=e=>e.nodeType===1&&e.hasAttribute("data-clay-skin");function f(e){for(let t of e.childNodes)if(!s(t))return t;return null}function d(e,t){if(t.parentNode!==e)return!1;for(let n=t.previousSibling;n;n=n.previousSibling)if(!s(n))return!1;return!0}var u=new Map;function y(e){return`
|
|
2
|
-
@layer clay-skin{:is(${e.join(", ")}){color-scheme:${c()} !important}}`}function m(e,t,{roots:n}={}){u.set(e,{css:t,roots:n});let o=document.head||document.documentElement,i=null;for(let l of o.querySelectorAll("style[data-clay-skin]"))l.getAttribute("data-clay-skin")===e&&(i=l);i||(i=document.createElement("style"),i.setAttribute("clay",a),i.setAttribute("data-clay-skin",e));let r=n?t+y(n):t;return i.textContent!==r&&(i.textContent=r),d(o,i)||o.insertBefore(i,f(o)),i}typeof document<"u"&&document.addEventListener("clay:sync-applied",()=>{for(let[e,{css:t,roots:n}]of u)m(e,t,{roots:n})});export{m as a};
|
package/dist/m/c-LUBZU4AZ.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{F as mt,K as ot,O as $e,r as Ie,v as Le,w as ft,x as De}from"./c-GO635CRU.js";import{a as Ae,d as pt,g as Oe,h as ve}from"./c-V2V5FKXX.js";import{f as Pe,o as Re}from"./c-T7LOTEWO.js";import{a as gt,c as Be}from"./c-A3OKSYRI.js";import{C as w,D as zt,E as We,F as Ft,G as Ue,H as Ge,a as _e,d as P,e as S,f as He,h as J,i as ze,m as Fe,p as z,s as Ht,u as Ke,v as Ve,y as je,z as qe}from"./c-3Y234AUB.js";import{A as y,B as dt,C as we,F as Y,K as Se,L as ht,M as Nt,N as Te,O as Ee,P as Ce,a as be,c as ke,d as g,fa as nt,g as ye,h as xe,u as ut,v as Me,w as N,x as A,y as H,z as I}from"./c-OH2FPYSY.js";import{b as Ne}from"./c-FSQXFG5T.js";import{b as C,d as Pt,f as at,g as ge,h as Rt}from"./c-RETTCOWO.js";import{a as R}from"./c-JC4RZW4E.js";var Ye=new WeakMap;function Je(n){let t=Ye.get(n);if(t)return t;t={};for(let[e,o]of I(n.attrs.cols).entries()){let s=[];n.forEach(r=>{e<r.childCount&&s.push(r.child(e).textContent.trim())}),t[o]=Ee(n.attrs.cols[o].kind,s)}return Ye.set(n,t),t}var Cs=Object.freeze({text:"Aa",number:"#",date:"\u{1F4C5}"}),As=Object.freeze({text:"Text",number:"Number",date:"Date"});var Kt=(n,t,e)=>{let o=n.attrs.get(t.baseId),s={};for(let r of Oe(e))s[r]=o&&o.has(r)?o.get(r):ve(e,r);return e.name==="board"&&Object.assign(s,Le(n.boardFields,t.baseId)),e.name==="table"&&Object.assign(s,Ie(n.tableFields,t.baseId,{cols:s.cols,rows:s.rows})),s},Xe=n=>n===void 0?n:JSON.parse(JSON.stringify(n)),qn=(n,t)=>{let e={},o=n.attrs.get(t.baseId);return o&&o.forEach((s,r)=>{r!=="pos"&&(e[r]=Xe(s))}),e.t=t.t,e};function Bs(n,t,e=null){let o=d=>{if(d.opaque){let a=d.recovered?{...Xe(d.fields??{})}:qn(n,d);return{b:d,type:g.nodes.opaque_block,fields:a,opaque:!0}}let u=g.nodes[d.t]??g.nodes.paragraph;return{b:d,type:u,fields:{...d.fields??Kt(n,d,u)}}},s=t.visible.map(d=>{let u=e?.get(d);return u?{b:d,node:u}:o(d)}),r=new Map(s.map((d,u)=>[d.b.id,u])),i=d=>s[d].node?s[d].node.attrs.parent:s[d].fields.parent,l=d=>(d.b.recovered?n.gone._map.get(mt(d.b.sourceKey,"parent")):n.attrs.get(d.b.baseId)?._map.get("parent"))?.id??{clock:-1,client:-1};for(let d of r.keys()){let u=new Map,a=[],h=d;for(;r.has(h)&&!u.has(h);)u.set(h,a.length),a.push(h),h=i(r.get(h));if(!u.has(h))continue;let f=a.slice(u.get(h)).reduce((b,x)=>{let O=l(s[r.get(b)]),_=l(s[r.get(x)]);return O.clock<_.clock||O.clock===_.clock&&O.client<_.client?b:x}),m=r.get(f);s[m].node&&(s[m]=o(s[m].b)),s[m].fields.parent=null}let c=s.map(({b:d,node:u,type:a,fields:h,opaque:p})=>{if(u)return u;if(p){let b=[];for(let x of d.runs)x.hole||(x.br?b.push(g.nodes.hard_break.create()):b.push(g.text(x.text,x.marks)));return a.create({id:d.id,pos:null,raw:h},b)}let f={id:d.id,pos:null,...h};if(a.name==="table"&&Object.keys(f.rows??{}).length&&Object.keys(f.cols??{}).length)return Y(g,d.id,{t:"table",...f});if(!a.isTextblock)return a.create(f);let m=[];for(let b of d.runs)b.hole||(b.br?m.push(g.nodes.hard_break.create()):m.push(g.text(b.text,b.marks)));return a.create(f,m)});return c.length?g.nodes.doc.create(null,c):g.nodes.doc.createAndFill()}var E=n=>({status:"refused",code:n}),bt=n=>JSON.parse(JSON.stringify(n)),Wn=["title","owner","due"],Un=/^\d{4}-\d{2}-\d{2}$/,kt=(n,t)=>n==="title"?typeof t=="string":n==="due"?t===null||typeof t=="string"&&Un.test(t):t===null||typeof t=="string"&&t.length>0,Gn=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&&!N(r)||i!==null&&!N(i)||r!==null&&i!==null&&r>=i)continue;let l=A(r,i);if(s(l))return l}return`${n.reduce((r,i)=>i>r?i:r,"")}V`}function Vt(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(c=>c>s)??null,l=[];for(let c=e,d=s;c<=r;c++)l.push(d=Qe(i===null?[d]:[d,i],1));return{pos:l[0],rekey:n.slice(e,r).map((c,d)=>[c,l[d+1]])}}var yt=(n,t,e)=>{let{pos:o,rekey:s}=Vt(t,r=>n[r].pos,e);for(let[r,i]of s)n[r]={...n[r],pos:i};return o};function qs({pd:n,um:t=null,origins:e=null,render:o=()=>{}}){let s=u=>{if(typeof u!="string")return null;let a=$e(n,e).visible.find(p=>p.id===u);if(!a||a.t!=="board")return null;let h=a.fields??Kt(n,a,g.nodes.board);return{columns:bt(h.columns??{}),cards:bt(h.cards??{})}},r=(u,a,h,p)=>{let f=ot(u);return t?.stopCapturing(),n.ydoc.transact(()=>{if(!f)De(n,u,a,h);else for(let m of["columns","cards"])nt(a[m])!==nt(h[m])&&n.gone.set(mt(f,m),bt(h[m]))},Ae),t?.stopCapturing(),o(),p},i=(u,a,h=null)=>I(Object.fromEntries(Object.entries(u.cards).filter(([p,f])=>f.col===a&&p!==h))),l=(u,a)=>a===void 0?u.length:a===null?0:u.indexOf(a)+1,c=(u,a)=>a!=null&&!u.includes(a),d=(u,a)=>{let h=s(u);return h?a(h,bt(h)):E("missing-board")};return{read:u=>s(u),removed(u){return s(u)?ot(u)?{columns:{},cards:{}}:ft(n.boardFields,u):null},createColumn:(u,{name:a="",afterId:h}={})=>d(u,(p,f)=>{if(typeof a!="string")return E("invalid-value");let m=I(p.columns);if(c(m,h))return E("missing-destination");let b=y("c");return f.columns[b]={pos:yt(f.columns,m,l(m,h)),name:a},r(u,p,f,{status:"created",id:b})}),renameColumn:(u,a,h)=>d(u,(p,f)=>Object.hasOwn(p.columns,a)?typeof h!="string"?E("invalid-value"):p.columns[a].name===h?{status:"unchanged"}:(f.columns[a].name=h,r(u,p,f,{status:"changed"})):E("missing-column")),moveColumn:(u,a,{afterId:h=null}={})=>d(u,(p,f)=>{if(!Object.hasOwn(p.columns,a))return E("missing-column");let m=I(p.columns).filter(O=>O!==a);if(c(m,h))return E("missing-destination");let b=l(m,h),x=I(p.columns);return[...m.slice(0,b),a,...m.slice(b)].every((O,_)=>O===x[_])?{status:"unchanged"}:(f.columns[a].pos=yt(f.columns,m,b),r(u,p,f,{status:"moved"}))}),removeColumn:(u,a)=>d(u,(h,p)=>Object.hasOwn(h.columns,a)?(delete p.columns[a],r(u,h,p,{status:"removed",cards:i(h,a).length})):E("missing-column")),restoreColumn:(u,a)=>d(u,(h,p)=>{if(Object.hasOwn(h.columns,a))return{status:"unchanged"};let f=ot(u)?null:ft(n.boardFields,u).columns[a];return f?(p.columns[a]=f,r(u,h,p,{status:"restored"})):E("missing-column")}),createCard:(u,{columnId:a,title:h="",owner:p=null,due:f=null,afterId:m}={})=>d(u,(b,x)=>{if(!Object.hasOwn(b.columns,a))return E("missing-column");if(!kt("title",h)||!kt("owner",p)||!kt("due",f))return E("invalid-value");let O=i(b,a);if(c(O,m))return E("missing-destination");let _=y("k");return x.cards[_]={pos:yt(x.cards,O,l(O,m)),col:a,title:h,...p!==null?{owner:p}:{},...f!==null?{due:f}:{}},r(u,b,x,{status:"created",id:_})}),editCard:(u,a,h)=>d(u,(p,f)=>{if(!Object.hasOwn(p.cards,a))return E("missing-card");if(!Gn(h)||!Object.keys(h).length||Object.keys(h).some(b=>!Wn.includes(b)))return E("invalid-field");if(Object.entries(h).some(([b,x])=>!kt(b,x)))return E("invalid-value");let m={...p.cards[a]};for(let[b,x]of Object.entries(h))x===null?delete m[b]:m[b]=x;return nt(m)===nt(p.cards[a])?{status:"unchanged"}:(f.cards[a]=m,r(u,p,f,{status:"changed"}))}),moveCard:(u,a,{columnId:h,afterId:p=null}={})=>d(u,(f,m)=>{if(!Object.hasOwn(f.cards,a))return E("missing-card");if(!Object.hasOwn(f.columns,h))return E("missing-column");let b=i(f,h,a);if(c(b,p))return E("missing-destination");let x=l(b,p),O=f.cards[a];if(O.col===h){let _=i(f,h);if([...b.slice(0,x),a,...b.slice(x)].every((ct,jn)=>ct===_[jn]))return{status:"unchanged"}}return m.cards[a]={...O,col:h,pos:yt(m.cards,b,x)},r(u,f,m,{status:"moved"})}),removeCard:(u,a)=>d(u,(h,p)=>Object.hasOwn(h.cards,a)?(delete p.cards[a],r(u,h,p,{status:"removed"})):E("missing-card")),restoreCard:(u,a)=>d(u,(h,p)=>{if(Object.hasOwn(h.cards,a))return{status:"unchanged"};let f=ot(u)?null:ft(n.boardFields,u).cards[a];return f?(p.cards[a]=f,r(u,h,p,{status:"restored"})):E("missing-card")})}}var xt="blockeditor-history-intent",Yn=500,Jn=(n,t)=>{let e=n.resolve(t);return e.depth?e.node(1).attrs.id:null},Xn=n=>(n.storedMarks??n.selection.$from.marks()).map(t=>`${t.type.name}:${JSON.stringify(t.attrs)}`).sort().join(",");function qt(n,t,e,o){return{kind:"insert",blockId:Jn(n.doc,t),from:t,end:t+o.length,replaced:t!==e,text:o,marks:Xn(n),at:Date.now()}}function Ys(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>Yn?!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 Qn={deleteContentBackward:-1,deleteContentForward:1},jt=new WeakMap,Zn=1e3,Wt="blockeditor-derived";function to(n){let t=jt.get(n)??null;return jt.delete(n),t}function eo(n,t){if(!t||n.before!==t.doc||Date.now()-t.at>Zn||n.getMeta(He)||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 Js(n,t=null){let e=t?to(t):null,o=n.filter(i=>!i.getMeta(Wt));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(xt)??eo(s,e)}function Xs(){return new C.Plugin({props:{handleTextInput(n,t,e,o,s){return n.dispatch(s().setMeta(xt,qt(n.state,t,e,o))),!0},handleDOMEvents:{beforeinput(n,t){let e=Qn[t.inputType];return e&&jt.set(n,{direction:e,at:Date.now(),doc:n.state.doc}),!1}}}})}function no(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(d=>!d.parentElement.closest("table"));if(s.length!==1)return null;let r=o.cloneNode(!0);for(let d of r.querySelectorAll("table, style, script, template, meta, title"))d.remove();if(r.textContent.trim())return null;let i=s[0];return{grid:[...i.querySelectorAll("tr")].filter(d=>d.closest("table")===i).map(d=>[...d.children].filter(u=>u.tagName==="TD"||u.tagName==="TH").map(u=>dt(je.parse(u,{topNode:g.nodes.table_cell.create()})))).filter(d=>d.length),own:!!i.querySelector("td[data-col]")}}function oo(n){if(!n||!n.includes(" "))return null;let{header:t,rows:e}=ht(n.replace(/\r?\n$/,""),{delimiter:" "});return{grid:[t,...e],own:!1}}function Ze(n,t,e=globalThis.document){let o=null;try{o=no(n,e)}catch{o=null}if(!o&&!/<table[\s>]/i.test(n||""))try{o=oo(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 Mt(n,{header:t=n.length>1}={}){let e=Math.max(0,...n.map(a=>a.length));if(!e)return null;let o=t?n[0]:[],s=t?n.slice(1):n,r=Array.from({length:e},()=>y("c")),i=H(null,null,e),l=Object.fromEntries(r.map((a,h)=>[a,{pos:i[h],name:ut(o[h]??"").replace(/\s+/g," ").trim()||`Column ${h+1}`}])),c=s.length?s:[[]],d=H(null,null,c.length),u=Object.fromEntries(c.map((a,h)=>[y("r"),{pos:d[h],cells:Object.fromEntries(r.map((p,f)=>[p,a[f]??""]))}]));return Y(g,y(),{t:"table",pos:null,cols:l,rows:u})}var{Plugin:so,TextSelection:ro}=C,Ut=g.nodes;var on=(n,t)=>{let e=null;return n.forEach((o,s)=>{!e&&o.type===Ut.table&&o.attrs.id===t&&(e={node:o,pos:s})}),e};function V(n,t){if(!t)return null;let e=on(n,t.table);if(!e)return null;let o=[];e.node.forEach(p=>o.push(p.attrs.id));let s=I(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),c=Math.max(...r),d=Math.min(...i),u=Math.max(...i),a=[],h=e.pos+1;return e.node.forEach((p,f,m)=>{if(m>=l&&m<=c){let b=[],x=h+1;p.forEach((O,_,ct)=>{ct>=d&&ct<=u&&b.push({cell:O,pos:x}),x+=O.nodeSize}),a.push(b)}h+=p.nodeSize}),{...e,top:l,bottom:c,left:d,right:u,cells:a}}var st=(n,t)=>{let e=n.resolve(t);for(let o=e.depth;o>0;o--)if(e.node(o).type===Ut.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 wt(n,t,e){let o=st(n.state.doc,t),s=st(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(ro.create(n.state.doc,s.start)).setMeta(S,r);n.dispatch(i);let l=V(n.state.doc,r),c=l?(l.bottom-l.top+1)*(l.right-l.left+1):0;return P(n,`${c} ${c===1?"cell":"cells"} selected`),!0}function fr(n,t,e,o){let s=n.state.doc.nodeAt(t);if(s?.type!==Ut.table||!s.childCount)return!1;let r=s.childCount-1,i=s.child(0).childCount-1,l=(c,d)=>{let u=t+1;for(let a=0;a<c;a++)u+=s.child(a).nodeSize;u++;for(let a=0;a<d;a++)u+=s.child(c).child(a).nodeSize;return u+1};return e==="row"?wt(n,l(o,0),l(o,i)):wt(n,l(0,o),l(r,o))}var io=new Set(["Shift","Control","Alt","Meta","CapsLock"]),lo=n=>/[\t\n\r"]/.test(n)?`"${n.replace(/"/g,'""')}"`:n;function co(n,t){let e=n.cells.map(r=>r.map(({cell:i})=>lo(ut(dt(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 c=i.appendChild(t.createElement("td"));c.dataset.col=l.attrs.col,c.append(qe.serializeFragment(l.content,{document:t}))}}return{text:e,html:o.outerHTML}}function tn(n,t){let e=V(n.doc,S.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(S,S.getState(n)),t(w(o))}return!0}var en=(n,t,e)=>{let{text:o,html:s}=co(t,e.dom.ownerDocument);n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",s),n.preventDefault()},ao=(n,t)=>(e,o,s)=>{let r=S.getState(e),i=V(e.doc,r);if(!i||!s)return!1;let l=[],c=I(i.node.attrs.cols);i.node.forEach(a=>l.push(a.attrs.id));let d=Math.max(0,Math.min(l.length-1,l.indexOf(r.head[0])+n)),u=Math.max(0,Math.min(c.length-1,c.indexOf(r.head[1])+t));return o&&o(e.tr.setMeta(S,{...r,head:[l[d],c[u]]})),!0},nn=(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 mr(){let n=null;return new so({key:S,state:{init:()=>null,apply(t,e,o,s){let r=t.getMeta(S);return r!==void 0?r:!e||t.selectionSet||t.docChanged&&!t.getMeta(pt)?null:V(s.doc,e)?e:null}},props:{attributes:t=>S.getState(t)?{class:"has-cell-rect"}:{},createSelectionBetween:t=>S.getState(t.state)?t.state.selection:null,decorations(t){let e=V(t.doc,S.getState(t));return e?Pt.DecorationSet.create(t.doc,e.cells.flat().map(({cell:o,pos:s})=>Pt.Decoration.node(s,s+o.nodeSize,{class:"is-cell-selected"}))):null},handleKeyDown(t,e){let o=t.state;if(!S.getState(o))return!1;if(e.key==="Escape")return t.dispatch(o.tr.setMeta(S,null)),!0;if(e.key==="Backspace"||e.key==="Delete")return tn(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 ao(...s)(o,t.dispatch,t)}return io.has(e.key)||(e.metaKey||e.ctrlKey)&&(e.key==="a"||e.key==="c"||e.key==="x"||e.key==="v")||t.dispatch(o.tr.setMeta(S,null)),!1},handleDOMEvents:{mousedown(t,e){if(e.button!==0)return!1;!e.shiftKey&&S.getState(t.state)&&t.dispatch(t.state.tr.setMeta(S,null));let o=nn(t,e);if(o===null)return!1;if(e.shiftKey){let c=S.getState(t.state),d=(c&&uo(t.state.doc,c))??t.state.selection.$anchor.pos;return st(t.state.doc,d)?(e.preventDefault(),wt(t,d,o)):!1}let s=t.dom.ownerDocument,r=o,i=c=>{let d=nn(t,c);if(d===null)return;let u=st(t.state.doc,r),a=st(t.state.doc,d);if(!u||!a||u.table!==a.table)return;let h=S.getState(t.state);u.row===a.row&&u.col===a.col&&!h||h&&h.head[0]===a.row&&h.head[1]===a.col||(c.preventDefault(),wt(t,r,d))},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=V(t.state.doc,S.getState(t.state));return!o||!e.clipboardData?!1:(en(e,o,t),!0)},cut(t,e){let o=V(t.state.doc,S.getState(t.state));return!o||!e.clipboardData?!1:(en(e,o,t),tn(t.state,t.dispatch),!0)}}},view:()=>({destroy:()=>n?.()})})}function uo(n,t){let e=on(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 sn=n=>{let t=V(n.doc,S.getState(n));return t?{row:t.top,cell:t.left,rows:t.bottom-t.top+1,cols:t.right-t.left+1}:null};var Gt=new WeakMap;var{Plugin:ho,TextSelection:j}=C,T=g.nodes,Jt=256*1024,B=n=>I(n.attrs.cols),rn=n=>{let t=n.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type===T.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},rt=(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},St=(n,t=A())=>T.table_row.create({id:y("r"),pos:t},n.map(e=>T.table_cell.create({col:e}))),L=(n,t,e)=>T.table.create({...n.attrs,...t},e);function D(n,t,e){let o=rn(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,c=n.tr.replaceWith(o.pos,o.pos+o.table.nodeSize,r),d=rt(c.doc,o.pos,i,l);d!==null&&c.setSelection(j.create(c.doc,d)),t(w(c))}return!0}function F(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 h=0;h<r;h++)l+=n.doc.child(h).nodeSize;let c=i.isTextblock&&(i.content.size===0||o?.from===l+1&&o?.to===l+i.nodeSize-1),d=n.doc.maybeChild(r+1),u=c?i.attrs.pos:A(i.attrs.pos,d?.attrs.pos??null),a=e.type.create({...e.attrs,pos:u,parent:i.attrs.parent??null},e.content);if(t){let h=n.tr;o&&h.delete(o.from,o.to);let p=h.mapping.map(l),f=h.doc.child(r),m=c?p:p+f.nodeSize;if(h.replaceWith(m,c?p+f.nodeSize:m,a),s){let b=s.type.create({...s.attrs,pos:A(u,d?.attrs.pos??null),parent:i.attrs.parent??null},s.content);h.insert(m+a.nodeSize,b)}h.setSelection(j.create(h.doc,rt(h.doc,m,0,0))),t(w(h).scrollIntoView())}return!0}function ln(n=3,t=3){if(!Number.isInteger(n)||!Number.isInteger(t)||n<1||t<1)return null;let e=Array.from({length:t},()=>y("c")),o=H(null,null,t),s=Object.fromEntries(e.map((l,c)=>[l,{pos:o[c],name:`Column ${c+1}`}])),i=H(null,null,n).map(l=>St(e,l));return T.table.create({id:y(),cols:s},i)}var Xt=n=>(t,e)=>{let o=rn(t);if(!o||t.selection.$head.parent.type!==T.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:po(t,e,o,i):(e&&e(t.tr.setSelection(j.create(t.doc,rt(t.doc,o.pos,r,i))).scrollIntoView()),!0)};function po(n,t,e,o){let s=[...e.table.content.content];if(s.push(St(B(e.table),A(s.at(-1).attrs.pos,null))),t){let r=n.tr.replaceWith(e.pos,e.pos+e.table.nodeSize,L(e.table,{sort:null},s));r.setSelection(j.create(r.doc,rt(r.doc,e.pos,s.length-1,o))),t(w(r).scrollIntoView())}return!0}var fo=Xt(1),mo=Xt(-1),go=Xt("down"),bo=(n=!0)=>(t,e)=>D(t,e,(o,s)=>{let r=[...o.content.content],i=s.row+(n?1:0),l=A(r[i-1]?.attrs.pos??null,r[i]?.attrs.pos??null);return r.splice(i,0,St(B(o),l)),{table:L(o,{sort:null},r),row:i}}),Lr=(n,t)=>D(n,t,(e,o)=>{let s=[...e.content.content];if(s.length===1){let r=s[0];s[0]=T.table_row.create(r.attrs,B(e).map(i=>T.table_cell.create({col:i})))}else s.splice(o.row,1);return{table:L(e,{sort:null},s),row:Math.min(o.row,s.length-1)}}),cn=(n,t,e,o,s)=>{let{pos:r,rekey:i}=Vt(t,c=>n[c]?.pos??"",e),l={...n,[o]:{...s,pos:r}};for(let[c,d]of i)l[c]={...l[c],pos:d};return l},Dr=(n=!0)=>(t,e)=>D(t,e,(o,s)=>{let r=B(o),i=s.cell+(n?1:0),l=y("c"),c=cn(o.attrs.cols,r,i,l,{name:`Column ${r.length+1}`}),d=o.content.content.map(u=>{let a=[...u.content.content];return a.splice(i,0,T.table_cell.create({col:l})),T.table_row.create(u.attrs,a)});return{table:L(o,{cols:c},d),cell:i}}),$r=(n,t)=>D(n,t,(e,o)=>{let s=B(e);if(s.length<=1)return null;let r={...e.attrs.cols};delete r[s[o.cell]];let i=e.content.content.map(l=>T.table_row.create(l.attrs,l.content.content.filter((c,d)=>d!==o.cell)));return{table:L(e,{cols:r,sort:e.attrs.sort?.col===s[o.cell]?null:e.attrs.sort},i),cell:Math.min(o.cell,s.length-2)}}),_r=n=>(t,e)=>D(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 c=A(i[r-1]?.attrs.pos??null,i[r+1]?.attrs.pos??null);return i[r]=T.table_row.create({...l.attrs,pos:c},l.content),{table:L(o,{sort:null},i),row:r}}),Br=n=>(t,e)=>D(t,e,(o,s)=>{let r=B(o),i=s.cell+n;if(i<0||i>=r.length)return null;let l=[...r],[c]=l.splice(s.cell,1);l.splice(i,0,c);let d=cn(o.attrs.cols,l.filter(a=>a!==c),i,c,o.attrs.cols[c]),u=o.content.content.map(a=>{let h=[...a.content.content],[p]=h.splice(s.cell,1);return h.splice(i,0,p),T.table_row.create(a.attrs,h)});return{table:L(o,{cols:d},u),cell:i}}),ko=48,yo=1200,Pr=160,an=n=>Number.isFinite(n)&&n>0?Math.round(Math.min(yo,Math.max(ko,n))):null,Rr=n=>(t,e)=>D(t,e,o=>{let s=B(o);if(!s.some(i=>o.attrs.cols[i].width))return null;let r={};for(let i of s){let{width:l,...c}=o.attrs.cols[i];r[i]=c}return{table:L(o,{cols:r},o.content),cell:Math.max(0,s.indexOf(n))}}),Nr=(n,t)=>(e,o)=>D(e,o,s=>{let r={...s.attrs.cols},i=!1;for(let[l,c]of Object.entries(n)){let d=an(c);!r[l]||d===null||r[l].width===d||(r[l]={...r[l],width:d},i=!0)}return i?{table:L(s,{cols:r},s.content),cell:B(s).indexOf(t)}:null}),Hr=(n,t)=>(e,o)=>D(e,o,s=>{let r=s.attrs.cols[n];if(!r)return null;let i=t===null?null:an(t);if(t!==null&&i===null||(r.width??null)===i)return null;let{width:l,...c}=r,d={...s.attrs.cols,[n]:i===null?c:{...r,width:i}};return{table:L(s,{cols:d},s.content),cell:B(s).indexOf(n)}}),zr=(n,t)=>(e,o)=>D(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:L(s,{cols:r},s.content)}}),Fr=(n,t)=>(e,o)=>D(e,o,s=>{if(!s.attrs.cols[n]||!(t==="auto"||Te.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:L(s,{cols:l,sort:s.attrs.sort?.col===n?null:s.attrs.sort},s.content)}}),Kr=(n,t="asc")=>(e,o)=>D(e,o,s=>{if(!s.attrs.cols[n]||!["asc","desc"].includes(t))return null;let r=B(s).indexOf(n),i=Je(s)[n],l=[...s.content.content].map((u,a)=>({row:u,previous:a,text:u.child(r).textContent.trim()}));l.sort((u,a)=>{if(!u.text||!a.text)return!u.text&&!a.text?u.previous-a.previous:u.text?-1:1;let h=i==="number"?Nt(u.text):u.text,p=i==="number"?Nt(a.text):a.text;if(h==null||p==null)return h==null&&p==null?u.previous-a.previous:h==null?1:-1;let f=i==="number"?h-p:i==="date"?h<p?-1:h>p?1:0:h.localeCompare(p,void 0,{numeric:!0,sensitivity:"base"});return f?t==="asc"?f:-f:u.previous-a.previous});let c=H(null,null,l.length),d=l.map(({row:u},a)=>T.table_row.create({...u.attrs,pos:c[a]},u.content));return{table:L(s,{sort:{col:n,dir:t}},d)}}),Yt=(n,t=null)=>(e,o)=>D(e,o,(s,r)=>{let i=B(s),l=t?.row??r.row,c=t?.cell??r.cell,d=[...s.content.content];n.forEach((a,h)=>{let p=l+h;p>=d.length&&d.push(St(i,A(d.at(-1).attrs.pos,null)));let f=[...d[p].content.content];a.forEach((m,b)=>{c+b<i.length&&(f[c+b]=T.table_cell.create({col:i[c+b]},we(g,m)))}),d[p]=T.table_row.create(d[p].attrs,f)});let u=Math.max(1,...n.map(a=>a.length));return{table:L(s,{sort:null},d),row:l+n.length-1,cell:Math.min(c+u-1,i.length-1)}}),xo=n=>new TextEncoder().encode(JSON.stringify(n.toJSON())).length;function Mo(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=sn(o),r=e.getData("text/plain").replace(/\r?\n$/,""),i=Ze(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 Yt(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 Yt(i.grid,{row:s.row,cell:s.cell})(o,n.dispatch);if(o.selection.$head.parent.type===T.table_cell)return i.width*i.height<2?!1:Yt(i.grid)(o,n.dispatch);if(i.width*i.height<2||i.own||i.height<2&&!/<table[\s>]/i.test(e.getData("text/html")))return!1;let l=Mt(i.grid,{header:i.height>1});if(!l)return!1;if(xo(l)>Jt)return R("This paste is too large for one table.","error"),!0;let{from:c,to:d,empty:u,$from:a,$to:h}=o.selection;if(!u&&a.index(0)!==h.index(0)){let p=o.tr.deleteSelection();return F(o.apply(p),f=>{for(let m of f.steps)p.step(m);p.setSelection(j.create(p.doc,f.selection.from)),n.dispatch(w(p).scrollIntoView())},l)}return F(o,n.dispatch,l,u?null:{from:c,to:d})}var Vr=at.keymap({Tab:fo,"Shift-Tab":mo,Enter:go,"Mod-Enter":bo(!0)});function wo(n,t){let e=Gt.get(t.target),o=e?.getPos();if(o==null||t.button||t.shiftKey||!n.editable)return!1;t.preventDefault();let s=t.clientX<e.contentDOM.getBoundingClientRect().left;return n.dispatch(n.state.tr.setSelection(j.create(n.state.doc,o+1+(s?0:e.node.content.size)))),n.focus(),e.openDate(),!0}function jr(){return new ho({props:{handlePaste:Mo,handleDOMEvents:{mousedown:wo},handleClickOn(n,t,e,o,s,r){if(e.type!==T.table_cell||!r||s.button)return!1;let i=n.nodeDOM(o),l=i&&Gt.get(i);return l&&l.openDate(),!1}},appendTransaction(n,t,e){if(!n.some(r=>r.docChanged&&!r.getMeta(pt)))return null;let o=new Map;t.doc.forEach(r=>{r.type===T.table&&o.set(r.attrs.id,r)});let s=e.tr;return e.doc.forEach((r,i)=>{if(r.type!==T.table||!r.attrs.sort)return;let l=o.get(r.attrs.id),c=r.attrs.sort.col;if(!l)return;let d=h=>Object.fromEntries(h.content.content.map(p=>[p.attrs.id,p.content.content.find(f=>f.attrs.col===c)?.textContent])),u=d(l),a=d(r);(Object.keys(u).length!==Object.keys(a).length||Object.keys(u).some(h=>u[h]!==a[h]||!Object.hasOwn(a,h)))&&s.setNodeMarkup(i,null,{...r.attrs,sort:null})}),s.docChanged?s.setMeta(Wt,!0):null}})}function qr(n,t,e){let o=n.state.doc.nodeAt(t);if(o?.type!==T.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(j.create(s.doc,t+1+e.length))),!0}function Wr(n,t,e,o){let s=rt(n.state.doc,t,e,o);return s===null?!1:(n.dispatch(n.state.tr.setSelection(j.create(n.state.doc,s))),!0)}var{TextSelection:So}=C,Qt=g.nodes,To=Object.freeze(["To do","In progress","Done"]),un=(n,t)=>N(n)&&(t===null||N(t)&&n<t)?A(n,t):null;function Zt(n=To){let t=H(null,null,n.length),e=Object.fromEntries(n.map((o,s)=>[y("c"),{pos:t[s],name:o}]));return Qt.board.create({id:y(),columns:e,cards:{}})}function dn(n,t,e=Zt(),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=J(r.doc),l=r.doc.child(s),c=l.isTextblock&&l.content.size===0,d=c?s:i[s].subEnd,u=c?i[s].at:i[d].end,a=i[d+1]?.node.attrs.pos??null,h=l.attrs.parent??null,p=c?l.attrs.pos:un(i[d].node.attrs.pos,a),f=Qt.board.create({...e.attrs,pos:p,parent:h}),m=Qt.paragraph.create({id:y(),pos:un(p,a),parent:h});return r.replaceWith(u,c?i[s].end:u,[f,m]),r.setSelection(So.create(r.doc,u+f.nodeSize+1)),t&&t(w(r).scrollIntoView()),!0}function hn(n){let t=[];return n.forEach(e=>{e.type===g.nodes.table&&I(e.attrs.cols).length>1&&t.push(e)}),t}function ni(n,t){let e="",o=0,s=null;return n.forEach(r=>{s===null&&(r.type===g.nodes.heading&&(e=r.textContent),r.type===g.nodes.table&&(o+=1,r.attrs.id===t&&(s=e||`Table ${o}`),e=""))}),s}var pn=new Set(["blockeditor-format-unsupported","unsupported-host"]),Eo="This host can't store that yet, so nothing was added.",Co="That didn't go through. Try again.",Ao="That couldn't be added here.";function fn(n,t){let e=t?.status==="upgrade-required"&&t.message?t.message:pn.has(t?.code)||pn.has(t?.status)?Eo:t?.retry===!0?Co:Ao;n.isDestroyed||(P(n,e),R(e,"error"))}async function Tt(n,t){if(typeof n.runFormatCommand!="function")return fn(n,{code:"blockeditor-format-unsupported"}),{ok:!1,code:"blockeditor-format-unsupported"};let e=await n.runFormatCommand(t);return e?.status==="applied"?e.result:(fn(n,e),{ok:!1,code:e?.code??e?.status??"blockeditor-format-refused",retry:e?.retry===!0})}var{TextSelection:it}=C,v=g.nodes,q=[{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:"toggle-h1",label:"Toggle heading 1",description:"Collapsible heading",icon:"H1",type:"toggle",attrs:{open:!0,level:1},aliases:["toggle heading"]},{key:"toggle-h2",label:"Toggle heading 2",description:"Collapsible heading",icon:"H2",type:"toggle",attrs:{open:!0,level:2},aliases:["toggle heading"]},{key:"toggle-h3",label:"Toggle heading 3",description:"Collapsible heading",icon:"H3",type:"toggle",attrs:{open:!0,level:3},aliases:["toggle heading"]},{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"]}],Oo=[{key:"divider",label:"Divider",description:"A line between sections",icon:"\u2014",hint:"---",aliases:["hr","line","separator","rule"],insert:"divider"},{key:"toc",label:"Table of contents",description:"Links to this page's headings",icon:"\u2261",aliases:["toc","contents","outline","index"],insert:"toc"},{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"},{key:"mention",label:"Mention",description:"Name someone on the page",icon:"@",aliases:["person","people","assign"],command:"mentions"},{key:"date",label:"Date",description:"Today, tomorrow or a calendar day",icon:"\u25A7",aliases:["calendar","today","tomorrow","due"],command:"dates"},{key:"emoji",label:"Emoji",description:"Insert one glyph",icon:"\u263A",aliases:["smiley","glyph","symbol"],command:"emoji"},{key:"import-markdown",label:"Import Markdown\u2026",description:"Turn a Markdown file into blocks",icon:"M\u2193",aliases:["md","markdown","import"],command:"importMarkdown"}],vo={key:"chart",label:"Chart",description:"A bar or line chart from a table",icon:"\u{1F4CA}",aliases:["graph","plot","bar","line"],insert:"chart"},te=n=>(Ne.get(n)?.ensure("chart")??Promise.resolve()).catch(()=>{}).then(()=>n.isDestroyed?null:import("./c-MLMJUNRV.js")),At=[...q,...Oo],gn=(n,t=At)=>hn(n.doc).length?[...t,vo]:t;function Ot(n){let t=n.type.name;return q.find(e=>e.type===t&&(!e.attrs||(t==="heading"||t==="toggle"?(e.attrs.level??null)===(n.attrs.level??null):t==="list_item"?e.attrs.kind===n.attrs.kind:!0)))??q[0]}var ee=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e};function G(n,t,e){let o=ee(n.doc,t),s=n.doc.child(t),r={id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent};return s.type===v.list_item&&e.type==="list_item"&&(r.indent=s.attrs.indent),n.setBlockType(o+1,o+s.nodeSize-1,v[e.type],{...r,...e.attrs||{}})}var bn=Object.freeze({status:"refused",code:"unsupported-format"}),Io=xe([]).type,Lo=n=>{let t=!1;return n.forEach(e=>{!t&&e.marks.some(ye)&&(t=!0)}),t};function Q(n,t){return!n.isTextblock||n.type===v.opaque_block?!1:!Lo(n)||v[t.type].allowsMarkType(Io)}var kn=n=>n.type==="toggle"&&n.attrs?.level!=null,Et=(n,t)=>{let e=-1;return n.forEach((o,s,r)=>{o.attrs.id===t&&(e=r)}),e},ne={ok:!1,code:"stale-target"};function yn(n,t,e){let o=()=>e.map(r=>Et(n.state.doc,r)),s=()=>{let r=o();if(r.includes(-1))return ne;if(r.some(l=>!Q(n.state.doc.child(l),t)))return bn;let i=n.state.tr;for(let l of r)G(i,l,t);return n.dispatch(w(i).scrollIntoView()),n.focus(),{ok:!0}};return kn(t)?Tt(n,s):t.type==="quote"?import("./c-BHLYQGTA.js").then(r=>n.isDestroyed?!1:r.gateTurn(n,s)):s()}function xn(n,t,e=n.tr){let o=J(e.doc),{to:s}=ze(o,t),r=e.doc.child(t);return e.insert(s,v.paragraph.create({parent:r.attrs.parent??null})),e.setSelection(it.create(e.doc,s+1))}var X=(n,t)=>N(n)&&(t===null||N(t)&&n<t)?A(n,t):null;function oe(n,t){let e=ee(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,[v.divider.create({id:r,pos:i,parent:l}),v.paragraph.create({id:y(),pos:X(i,s?s.attrs.pos:null),parent:l})]),n.setSelection(it.create(n.doc,e+2))}function Do(n,t,e=n.tr){let o=e.doc.child(t);if(o.type===v.paragraph&&o.content.size===0)return oe(e,t);let s=J(e.doc),r=s[t].subEnd,i=s[r].end,l=s[r+1]?.node.attrs.pos??null,c=X(s[r].node.attrs.pos,l),d=o.attrs.parent??null;return e.insert(i,[v.divider.create({id:y(),pos:c,parent:d}),v.paragraph.create({id:y(),pos:X(c,l),parent:d})]),e.setSelection(it.create(e.doc,i+2))}function $o(n,t){let e=ee(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,[v.toc.create({id:r,pos:i,parent:l,maxLevel:3}),v.paragraph.create({id:y(),pos:X(i,s?s.attrs.pos:null),parent:l})]),n.setSelection(it.create(n.doc,e+2))}function _o(n,t,e=n.tr){let o=e.doc.child(t);if(o.type===v.paragraph&&o.content.size===0)return $o(e,t);let s=J(e.doc),r=s[t].subEnd,i=s[r].end,l=s[r+1]?.node.attrs.pos??null,c=X(s[r].node.attrs.pos,l),d=o.attrs.parent??null;return e.insert(i,[v.toc.create({id:y(),pos:c,parent:d,maxLevel:3}),v.paragraph.create({id:y(),pos:X(c,l),parent:d})]),e.setSelection(it.create(e.doc,i+2))}function Bo(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 Mn(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(c=>c.toLowerCase());if(r===e||i.includes(e))return[0,0];if(r.startsWith(e))return[1,0];if([...r.split(/\s+/),...i].some(c=>c.startsWith(e)))return[2,0];if([r,...i].some(c=>c.includes(e)))return[3,0];if(e.length>=3&&s.description&&s.description.toLowerCase().split(/[^a-z0-9]+/).some(c=>c.startsWith(e)))return[4,0];let l=Math.min(...[r,s.key,...s.aliases||[]].map(c=>Bo(e,c.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 mn(n,t,e,o){let s=n.state,r=s.tr;o&&r.delete(o.from,o.to);let i=r.doc.child(e);return i.isTextblock&&i.content.size===0&&!Q(i,t)?bn:(t.insert==="divider"?r=Do(s,e,r):i.isTextblock&&i.content.size===0?r=G(r,e,t):(r=xn(s,e,r),r=G(r,r.doc.resolve(r.selection.head).index(0),t)),n.dispatch(w(r).scrollIntoView()),n.focus(),!0)}function Po(n,t,e=null){let o=n.state,s=o.doc.maybeChild(t)?.attrs.id??null,r=e&&{...e,text:o.doc.textBetween(e.from,e.to)};return Tt(n,()=>{let i=n.state;if((s===null?-1:Et(i.doc,s))<0||r&&i.doc.textBetween(r.from,r.to)!==r.text)return ne;let c=r?i.tr.delete(r.from,r.to):i.tr;return c=_o(i,Et(c.doc,s),c),n.dispatch(w(c).scrollIntoView()),n.focus(),{ok:!0}})}var Z=(n,t,e)=>import("./page/editor-HS2CAV3W.js").then(({runPageCommand:o})=>n.isDestroyed?{ok:!1,code:"not-editing"}:o(n,t,e));function Ro(n,t,e){return e&&n.dispatch(n.state.tr.delete(e.from,e.to)),Z(n,t,{})}function wn(n,t,e,o=null){let s=n.state;if(t.insert==="image"||t.insert==="file")return Re(n,t.insert==="image"?"image/*":"",Pe(s,e),o);if(t.insert==="csv")return Ct(n,o);if(t.insert==="table")return F(s,n.dispatch,ln(),o,null,e);if(t.insert==="board")return dn(s,n.dispatch,Zt(),o,e);if(t.insert==="chart")return te(n).then(l=>l&&!n.isDestroyed?l.chartFromSlash(n,e,o):!1);if(t.insert==="toc")return Po(n,e,o);if(t.command)return Ro(n,t.command,o);if(!kn(t)&&t.type!=="quote")return mn(n,t,e,o);let r=s.doc.maybeChild(e)?.attrs.id??null,i=o&&{...o,text:s.doc.textBetween(o.from,o.to)};return Tt(n,()=>{let l=n.state,c=r===null?-1:Et(l.doc,r);return c<0||i&&l.doc.textBetween(i.from,i.to)!==i.text?ne:mn(n,t,c,i)})}var{InputRule:ie}=Rt,W=g.nodes,vt=(n,t,e)=>n.doc.rangeHasMark(t,e,g.marks.code)||!!g.marks.code.isInSet(n.storedMarks||n.selection.$from.marks()),tt=(n,t,e=["paragraph"],o=!1)=>new ie(n,(s,r,i,l)=>{let c=s.doc.resolve(i);return!s.selection.empty||c.depth!==1||c.parentOffset!==0||!e.includes(c.parent.type.name)||o&&l!==c.end()||vt(s,i,l)?null:w(G(s.tr.delete(i,l),c.index(0),typeof t=="function"?t(r):t))}),No=new ie(/^---$/,(n,t,e,o)=>{let s=n.doc.resolve(e);return!n.selection.empty||s.depth!==1||s.parent.type!==W.paragraph||s.parentOffset!==0||s.parent.content.size!==o-e||vt(n,e,o)?null:w(oe(n.tr,s.index(0)))}),le=`\\s\\(\\[\\{'\u2018\u201C"`,Ho=new RegExp(`[${le}]`),se=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Sn=n=>`([^\\s${n}](?:[\\s\\S]*?[^\\s${n}])?)`,It=(n,t)=>!!n?.isComposing||n?.keyCode===229||!!t?.composing,Tn=n=>{let t=0;for(let e=n.length-1;e>=0&&n[e]==="\\";e--)t++;return t},zo=(n,t)=>{let e=n.doc.resolve(t);return!e.parent.inlineContent||Tn(e.parent.textBetween(0,e.parentOffset,null,"\uFFFC"))%2?!1:e.parentOffset===0||Ho.test(e.parent.textBetween(e.parentOffset-1,e.parentOffset))},Fo=(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[c,d,u,a]=t;if(vt(n,e,o))return null;let h=c.slice(d.length,c.length-u.length-a.length),p=e+d.length;if(!zo(n,p)||Tn(c.slice(0,c.length-a.length))%2)return null;let f=c.length-(o-e);if(f<0)return null;let m=n.tr;f&&m.insertText(c.slice(-f),o,o);let b=p+h.length,x=b+u.length;return m.delete(x,e+c.length),m.delete(p,b),m.addMark(p,p+u.length,r),m.removeStoredMark(r.type),w(m)},En=(n,t)=>new ie(n,(e,o,s,r)=>Fo(e,o,s,r,t),{inCodeMark:!1}),et=(n,t,e)=>En(new RegExp(`(^|[${le}])${se(n)}${Sn(se(t))}(${se(t)})$`),()=>e.create()),Ko=En(new RegExp(`(^|[${le}])\\[${Sn("\\[\\]")}(\\]\\([^()\\s]*\\))$`),n=>{let t=be(n[3].slice(2,-1));return t?g.marks.link.create({href:t}):null}),Vo=[et("**","**",g.marks.strong),et("__","__",g.marks.strong),et("*","*",g.marks.em),et("_","_",g.marks.em),et("`","`",g.marks.code),et("~~","~~",g.marks.strike),Ko],re=["paragraph","list_item"],jo=[tt(/^(#{1,3})\s$/,n=>({type:"heading",attrs:{level:n[1].length}})),tt(/^[-*+]\s$/,{type:"list_item",attrs:{kind:"bullet"}},re),tt(/^\d+[.)]\s$/,{type:"list_item",attrs:{kind:"ordered"}},re),tt(/^\[( |x|X)?\]\s$/,n=>({type:"list_item",attrs:{kind:"check",checked:!!n[1]&&n[1]!==" "}}),re),tt(/^>\s$/,{type:"toggle",attrs:{open:!0}}),tt(/^```$/,{type:"code_block"},["paragraph"],!0),No,...Vo];function qo(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!==W.paragraph||i.parentOffset!==1||l.textContent!=='"'||!t.editable||typeof t.runFormatCommand!="function")return!1;let c=()=>{t.isDestroyed||t.state.doc!==r.doc||t.dispatch(t.state.tr.insertText(" ",e,o))},d=i.before(1);return import("./c-BHLYQGTA.js").then(({quoteFromSpace:u})=>u(n,t,{at:d,from:e,to:o},c),c),!0}var Oi=()=>{let n=Rt.inputRules({rules:jo}),t=n.props.handleTextInput;return n.props.handleTextInput=(e,o,s,r)=>qo(n,e,o,s,r)||t(e,o,s,r),n},Wo=/^\s*\|(.*)\|\s*$/;function Uo(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parent.type!==W.paragraph||e.parentOffset!==e.parent.content.size||vt(n,e.start(),e.end()))return!1;let s=Wo.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=Mt([r,r.map(()=>"")],{header:!0});return F(n,t,i,{from:e.start(),to:e.end()})}var vi=()=>at.keymap({Enter:(n,t,e)=>!It(null,e)&&Uo(n,t)});function Ii(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===W.heading||s.type===W.callout||s.type===W.quote||s.type===W.code_block&&s.content.size===0?(t&&t(w(n.tr.setNodeMarkup(e.before(),W.paragraph,{id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent}))),!0):!1}var{Plugin:In,PluginKey:Ln,TextSelection:$t,NodeSelection:Go}=C,Dn=g.marks,U=g.nodes,Dt=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"\u2318":"Ctrl+",$n=n=>{let t=gt(n.doc),{lo:e,hi:o}=n.selection.span(n.doc);return t.slice(e,o+1).filter(s=>s.up===t[e].up)},Lt=(n,t)=>n.state.doc.child(t).attrs.id,Yo=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e},Cn=["aria-haspopup","aria-controls","aria-activedescendant"],Jo="That block is no longer available.",he="This block holds content from a newer version, so it can't be converted here.";function ce(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 Xo(n,t,e,o=0){let s=$,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 Qo(n,t=globalThis.location){return`${t.origin}${t.pathname}${t.search}#${encodeURIComponent(n)}`}function Zo(n){if(!n)return;let t=()=>R("Link copied"),e=()=>R("Could not copy the link.","error");if(!globalThis.navigator?.clipboard?.writeText){e();return}globalThis.navigator.clipboard.writeText(Qo(n)).then(t,e)}var _n=[{key:"up",label:"Move up",icon:"up",hint:`${Dt}\u21E7\u2191`,run:n=>Ht(-1)(n.state,n.dispatch)},{key:"down",label:"Move down",icon:"down",hint:`${Dt}\u21E7\u2193`,run:n=>Ht(1)(n.state,n.dispatch)},{key:"indent",label:"Indent",icon:"indent",hint:"Tab",run:n=>{let t=n.state.doc;Ke(n.state,n.dispatch),n.state.doc===t&&(P(n,"Indent works on list items and inside toggles."),R("Indent works on list items and inside toggles."))}},{key:"outdent",label:"Outdent",icon:"outdent",hint:"\u21E7Tab",run:n=>Ve(n.state,n.dispatch)},{key:"duplicate",label:"Duplicate",icon:"duplicate",hint:`${Dt}D`,run:n=>Ue(n.state,n.dispatch)},{key:"delete",label:"Delete",icon:"trash",hint:"Del",run:n=>Ft(n.state,n.dispatch)},{key:"turn",label:"Turn into",icon:"turn",hint:"\u203A",only:"text",run:(n,t)=>t.openMenu("turn",t.plus)},{key:"link",label:"Copy link",icon:"link",run:(n,t,e)=>Zo(n.state.doc.child(e).attrs.id)},{key:"alt",label:"Alt text\u2026",icon:"alt",only:"image",focus:!1,run:(n,t,e)=>{let o=Lt(n,e);return import("./c-ASGHHLFX.js").then(s=>s.openAltEditor(n,o))}},{key:"small",label:"Small",icon:"small",only:"image",run:(n,t,e)=>{let o=Lt(n,e);return import("./c-ASGHHLFX.js").then(s=>s.setImageAttrs(n,o,{width:240}))}},{key:"medium",label:"Medium",icon:"medium",only:"image",run:(n,t,e)=>{let o=Lt(n,e);return import("./c-ASGHHLFX.js").then(s=>s.setImageAttrs(n,o,{width:480}))}},{key:"full",label:"Full width",icon:"full",only:"image",run:(n,t,e)=>{let o=Lt(n,e);return import("./c-ASGHHLFX.js").then(s=>s.setImageAttrs(n,o,{width:null}))}},{key:"chart",label:"Chart this table",icon:"chart",only:"table",run:(n,t,e)=>{let o=Yo(n.state.doc,e);return te(n).then(({insertChartAfterTable:s})=>s(n,o))}},{key:"csv",label:"Import CSV\u2026",icon:"csv",only:"table",focus:!1,run:(n,t,e)=>Ct(n,null,n.state.doc.child(e).attrs.id)}],ts=n=>{if(!(n.selection instanceof z))return[];let t=$n(n),e=t.every(r=>r.node.isTextblock),o=t.length===1&&t[0].node.type===U.image,s=t.length===1&&t[0].node.type===U.table;return _n.filter(r=>r.only==="text"?e:r.only==="image"?o:r.only==="table"?s:!0)},M=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>`,K={plus:M('<path d="M8 3.5v9M3.5 8h9"/>'),grip:M('<path stroke-width="2.2" d="M6 3.5h.01M10 3.5h.01M6 8h.01M10 8h.01M6 12.5h.01M10 12.5h.01"/>'),strong:M('<path d="M5 3h4a2.5 2.5 0 0 1 0 5H5zM5 8h4.6a2.5 2.5 0 0 1 0 5H5z"/>'),em:M('<path d="M10 3H6.5M9.5 13H6M9 3l-2 10"/>'),strike:M('<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:M('<path d="M6 4.5 2.5 8 6 11.5M10 4.5 13.5 8 10 11.5"/>'),link:M('<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:M('<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:M('<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:M('<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:M('<path stroke-width="2.2" d="M3 8h.01M8 8h.01M13 8h.01"/>'),gear:M('<g transform="scale(0.6667)" stroke-width="2.25"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g>'),close:M('<path d="M4 4l8 8M12 4l-8 8"/>'),up:M('<path d="M8 13V3.5M4 7.5 8 3.5l4 4"/>'),down:M('<path d="M8 3v9.5M4 8.5l4 4 4-4"/>'),indent:M('<path d="M2.5 3.5h11M7 8h6.5M2.5 12.5h11M2.5 6l2.5 2-2.5 2"/>'),outdent:M('<path d="M2.5 3.5h11M7 8h6.5M2.5 12.5h11M5 6 2.5 8 5 10"/>'),duplicate:M('<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 3.5v-.5A1.5 1.5 0 0 0 9 1.5H4A1.5 1.5 0 0 0 2.5 3v5A1.5 1.5 0 0 0 4 9.5h.5"/>'),trash:M('<path d="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.5h5.8l.6-8.5"/>'),turn:M('<path d="M3 5.5h9.5M10 3l2.5 2.5L10 8M13 10.5H3.5M6 8l-2.5 2.5L6 13"/>'),chart:M('<path d="M3 13V3M3 13h10.5M6 10.5V8M9 10.5V5.5M12 10.5V7"/>'),csv:M('<path d="M4 1.5h5L12.5 5v9.5h-8.5zM9 1.5V5h3.5M8 7.5v5M6 10.5l2 2 2-2"/>'),alt:M('<path d="M2.5 12.5 5.5 4l3 8.5M3.6 9.5h3.8M10 12.5V7.5M10 8.5c.4-.7 1.1-1 2-1h.5"/>'),small:M('<rect x="5" y="5" width="6" height="6" rx="1"/>'),medium:M('<rect x="3.5" y="3.5" width="9" height="9" rx="1.2"/>'),full:M('<rect x="1.5" y="3.5" width="13" height="9" rx="1.2"/>')},ae=[["strong","Bold"],["em","Italic"],["strike","Strikethrough"],["link","Link"],["bullet","Bulleted list"],["ordered","Numbered list"],["check","Checklist"],["code","Code"]],Bn=new Set(["strong","em","link"]),es=new Set(["up","down","indent","outdent"]),ns=204,os=52,$=8,Pn=new Set(["bullet","ordered","check"]),ss=[["assignees","Checklist assignees"],["dates","Checklist due dates"]],rs=new Set(["paragraph","heading","list_item"]),lt=n=>{let t=n.selection;if(t instanceof z)return $n(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},Rn=n=>lt(n).filter(t=>{let e=n.doc.child(t);return e.isTextblock&&e.type!==U.code_block}),Nn=(n,t)=>n.type===U.list_item&&n.attrs.kind===t,Hn=(n,t)=>{let e=Rn(n);return e.length>0&&e.every(o=>Nn(n.doc.child(o),t))},is=n=>{let t="";return n.forEach(e=>{t+=e.isText?e.text:e.type===U.hard_break?`
|
|
3
|
-
`:""}),t};function ls(n){let{$from:t,$to:e,empty:o}=n.selection;if(o||!(n.selection instanceof $t)||t.depth!==1||e.depth!==1||t.parentOffset!==0||e.parentOffset!==e.parent.content.size)return null;let s=lt(n);return s.every(r=>rs.has(n.doc.child(r).type.name))?s:null}function cs(n,t){let e=n.doc.child(t[0]),o=n.selection.$from.before(1),s=n.selection.$to.after(1),r=t.map(u=>is(n.doc.child(u))).join(`
|
|
4
|
-
`),{id:i,pos:l,parent:c}=e.attrs,d=n.tr.replaceWith(o,s,U.code_block.create({id:i,pos:l,parent:c},r?g.text(r):null));return d.setSelection($t.create(d.doc,o+1,o+1+r.length))}function as(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 h=0;h<r;h++)i+=n.doc.child(h).nodeSize;let l=n.doc.child(r),{id:c,pos:d,parent:u}=l.attrs,a=l.textContent.split(`
|
|
5
|
-
`).map((h,p)=>U.paragraph.create(p===0?{id:c,pos:d,parent:u}:{parent:u},h?g.text(h):null));e.replaceWith(i,i+l.nodeSize,a),s||(s=i+a.reduce((h,p)=>h+p.nodeSize,0))}return s=e.mapping.slice(1).map(s),e.setSelection($t.create(e.doc,o+1,s-1))}var zn=n=>{let t=lt(n);return t.length>0&&t.every(e=>n.doc.child(e).type===U.code_block)?t:null};function An(n,t){if(Pn.has(t))return Hn(n,t);if(t==="code"&&zn(n))return!0;let e=Dn[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 us(n,t){let e=n.state,o=Hn(e,t),s=q.find(l=>l.key===(o?"text":t)),r=Rn(e).filter(l=>o||!Nn(e.doc.child(l),t));if(r.some(l=>!Q(e.doc.child(l),s))){P(n,he);return}let i=e.tr;for(let l of r)G(i,l,s);i.docChanged&&n.dispatch(w(i))}var ue=(n,t,e)=>import("./c-BHLYQGTA.js").then(o=>o.nativeMenu(n,e,t.pickedFrom??t.more));function On(n,t){if(t==="link")return _e(n);let e=n.state,o=t==="code"?zn(e):null,s=t==="code"&&!o?ls(e):null;Pn.has(t)?us(n,t):o?n.dispatch(w(as(e,o)).scrollIntoView()):s&&s.some(r=>!Q(e.doc.child(r),q.find(i=>i.key==="code")))?P(n,he):s?n.dispatch(w(cs(e,s)).scrollIntoView()):ge.toggleMark(Dn[t])(e,n.dispatch),n.focus()}var k=(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 vn(n,t){let e=k("button",`blockeditor-tool${Bn.has(n)?" blockeditor-tool-primary":" blockeditor-tool-desk"}`,{type:"button","data-cmd":n,"aria-label":t,title:t});return e.innerHTML=K[n],e}var ds=1600,hs=0,ps=new Ln("blockeditor-chrome"),pe=new WeakMap,_t=new Ln("blockeditor-slash-range"),fs={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}},Yi=()=>new In({key:_t,state:fs}),Fn=(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))},Kn=n=>{let t=_t.getState(n);return t?{from:t.from,to:t.to}:null};function Ji(n,t,e,{persist:o=!1}={}){let s=pe.get(n);return s?(s.openMenu("external",t),s.menu.externalItems=e,s.menu.persist=o,s.renderMenu(),!0):!1}function Xi(n,t,e){let o=pe.get(n),s=o?.menu;return!s||s.anchor!==t||!e||e===t?!1:(s.anchor=e,e.setAttribute("aria-expanded","true"),n.dom.setAttribute("aria-controls",o.menuId),!0)}var de=class{constructor(t,e,o){this.view=t,this.onAiTool=e,this.mediaNote=o,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.remote=!1,this.dock=k("div","blockeditor-dock",{role:"toolbar","aria-label":"Formatting"}),this.turn=k("button","blockeditor-tool blockeditor-tool-turn blockeditor-tool-desk",{type:"button","aria-haspopup":"menu"}),this.more=k("button","blockeditor-tool blockeditor-tool-primary blockeditor-tool-more",{type:"button","aria-label":"More",title:"More","aria-haspopup":"menu"}),this.more.innerHTML=K.more,this.settingsBtn=k("button","blockeditor-tool blockeditor-tool-desk blockeditor-tool-settings",{type:"button","aria-label":"Document settings",title:"Document settings","aria-haspopup":"dialog","aria-expanded":"false"}),this.settingsBtn.innerHTML=K.gear,this.settingsEl=null,this.settingsOpen=!1,this.settingsAnchor=null,this.settingSwitches={},this.dock.append(this.turn,k("span","blockeditor-tool-sep blockeditor-tool-desk"),...ae.map(([i,l])=>vn(i,l)),this.more),this.dock.insertBefore(this.settingsBtn,this.more),this.settingsBtn.hidden=!this.settingsAPI,this.plus=k("button","blockeditor-plus",{type:"button","aria-label":"Add a block",title:"Add a block"}),this.plus.innerHTML=K.plus,this.grip=k("button","blockeditor-grip",{type:"button","aria-label":"Block actions",title:"Drag to move, click for actions","aria-haspopup":"menu"}),this.grip.innerHTML=K.grip,this.bubble=k("div","blockeditor-bubble",{role:"toolbar","aria-label":"Selection",hidden:""}),this.bubbleTurn=k("button","blockeditor-tool blockeditor-tool-turn",{type:"button","aria-haspopup":"menu"}),this.bubbleMore=k("button","blockeditor-tool blockeditor-tool-primary blockeditor-tool-more",{type:"button","aria-label":"More",title:"More","aria-haspopup":"menu"}),this.bubbleMore.innerHTML=K.more,this.bubble.append(this.bubbleTurn,k("span","blockeditor-tool-sep"),...ae.map(([i,l])=>vn(i,l)),this.bubbleMore),this.menuId=`blockeditor-menu-${++hs}`,this.menuEl=k("div","blockeditor-menu",{role:"menu",id:this.menuId,hidden:""}),this.scrim=k("div","blockeditor-scrim",{hidden:""}),this.shell.insertBefore(this.dock,t.dom),this.shell.append(this.plus,this.grip,this.bubble,this.scrim,this.menuEl);let s=i=>i.preventDefault();for(let i of[this.dock,this.plus,this.grip,this.bubble,this.menuEl])i.addEventListener("mousedown",s);for(let i of[this.dock,this.bubble])i.addEventListener("click",l=>{let c=l.target.closest("[data-cmd]");c&&On(this.view,c.dataset.cmd)});this.turn.addEventListener("click",()=>this.toggleMenu("turn",this.turn)),this.more.addEventListener("click",()=>this.toggleMenu("more",this.more)),this.settingsBtn.addEventListener("click",()=>this.toggleSettings()),this.bubbleTurn.addEventListener("click",()=>this.toggleMenu("turn",this.bubbleTurn)),this.bubbleMore.addEventListener("click",()=>this.toggleMenu("more",this.bubbleMore)),this.dock.addEventListener("keydown",i=>this.dockKey(i)),this.plus.addEventListener("click",()=>this.fromPlus()),this.grip.addEventListener("click",i=>{i.detail===0&&this.gripAction(this.gutterIndex())}),this.drag=new Be(t,this.grip,{index:()=>this.gutterIndex(),onClick:i=>this.gripAction(i)});let r=!1;this.scrim.addEventListener("pointerdown",()=>{r=!0}),this.scrim.addEventListener("click",()=>{r&&this.closeMenu(),r=!1}),this.menuEl.addEventListener("click",i=>{let l=i.target.closest(".blockeditor-menu-item");l&&this.pick(Number(l.dataset.index))}),this.menuEl.addEventListener("keydown",i=>{this.key(i)&&i.preventDefault()}),this.onMove=i=>{this.shell.classList.add("is-moved"),clearTimeout(this.movedTimer),this.movedTimer=setTimeout(()=>this.shell.classList.remove("is-moved"),ds),this.trackHover(i)},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.placeSettings()},this.onDocDown=i=>{this.settingsOpen&&![this.settingsEl,this.settingsAnchor].some(l=>l?.contains(i.target))&&this.closeSettings(),this.menu&&([this.menuEl,this.plus,this.grip,this.turn,this.bubbleTurn,this.bubbleMore].some(l=>l.contains(i.target))||this.closeMenu())},this.onSettingsKey=i=>{i.key!=="Escape"||!this.settingsOpen||(i.preventDefault(),i.stopPropagation(),this.closeSettings(!0))},document.addEventListener("mousedown",this.onDocDown,!0),document.addEventListener("keydown",this.onSettingsKey,!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 z||e instanceof Go?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("blockeditor-tool-primary")):t}inRoving(t){return!t||!this.dock.contains(t)||this.isPhone()&&!t.classList.contains("blockeditor-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 lt(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.isConnected&&(e.tagName==="BUTTON"||e.hasAttribute("tabindex"))?e:this.view.dom}selectCaretBlock(t=null){let e=this.view.state;if(e.selection instanceof z)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(zt(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=gt(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)}buildSettings(){if(this.settingsEl)return this.settingsEl;let t=k("div","blockeditor-settings",{role:"dialog","aria-label":"Document settings",hidden:""}),e=k("div","blockeditor-settings-head"),o=k("span","blockeditor-settings-title");o.textContent="Document settings";let s=k("button","blockeditor-settings-close",{type:"button","aria-label":"Close settings"});s.innerHTML=K.close,s.addEventListener("click",()=>this.closeSettings(!0)),e.append(o,s);let r=ss.map(([l,c])=>{let d=k("div","blockeditor-settings-row"),u=k("span","blockeditor-settings-name",{id:`${this.menuId}-set-${l}`});u.textContent=c;let a=k("button","blockeditor-settings-switch",{type:"button",role:"switch","aria-checked":"true","aria-labelledby":u.id,"data-setting":l});return a.append(k("span","blockeditor-settings-knob")),a.addEventListener("click",()=>this.flipSetting(l)),this.settingSwitches[l]=a,d.append(u,a),d}),i=k("div","blockeditor-settings-note");return i.textContent="Hidden values stay saved and come back when turned on.",t.append(e,...r,i),this.settingsEl=t,this.shell.append(t),t}flipSetting(t){let e=this.settingSwitches[t],o=e.getAttribute("aria-checked")!=="true";e.setAttribute("aria-checked",String(o)),Promise.resolve().then(()=>this.settingsAPI.set(t,o)).catch(()=>{e.setAttribute("aria-checked",String(!o)),R("That setting could not be saved.","error")})}openSettings(t=this.settingsBtn){if(!this.settingsAPI)return;this.menu&&this.closeMenu();let e=this.buildSettings(),o=this.settingsAPI.read();for(let[s,r]of Object.entries(this.settingSwitches))r.setAttribute("aria-checked",String(o[s]!==!1));this.settingsOpen=!0,this.settingsAnchor=t,t.setAttribute("aria-expanded","true"),e.hidden=!1,this.placeSettings(),e.querySelector(".blockeditor-settings-close")?.focus({preventScroll:!0})}closeSettings(t=!1){if(!this.settingsOpen)return;let e=this.settingsAnchor;this.settingsOpen=!1,this.settingsAnchor=null,this.settingsEl&&(this.settingsEl.hidden=!0),e?.setAttribute("aria-expanded","false"),t&&e?.isConnected&&e.focus({preventScroll:!0})}toggleSettings(){this.settingsOpen?this.closeSettings(!0):this.openSettings(this.settingsBtn)}placeSettings(){let t=this.settingsEl;if(!t||t.hidden||!this.settingsAnchor)return;let e=this.settingsAnchor.getBoundingClientRect(),o=t.offsetWidth||264,s=t.offsetHeight||0;if(this.isPhone()){let c=ce(this.win),d=Math.max(c.left+$,Math.min(e.right-o,c.left+c.width-$-o)),u=e.top-6-s;u<c.top+$&&(u=Math.min(e.bottom+6,c.top+c.height-$-s)),t.style.setProperty("--blockeditor-pop-x",`${d}px`),t.style.setProperty("--blockeditor-pop-y",`${Math.max(c.top+$,u)}px`);return}let r=this.shell.getBoundingClientRect(),i=Math.max(8,Math.min(e.right-r.left-o,Math.max(8,r.width-o-8))),l=e.bottom-r.top+6;l+s>this.win.innerHeight-8&&e.top-r.top-6-s>=8&&(l=e.top-r.top-6-s),t.style.setProperty("--blockeditor-pop-x",`${i}px`),t.style.setProperty("--blockeditor-pop-y",`${l}px`)}toggleMenu(t,e){this.menu?this.closeMenu():this.openMenu(t,e)}slashKey(t){let e=this.view.state.doc.resolve(t);return`${e.parent.attrs.id}\0${this.view.state.doc.textBetween(e.start(),t-1)}`}openMenu(t,e,o=null,s=null,r=null){this.closeSettings(),this.menu={mode:t,anchor:e,slashAt:o,anchorId:r,ids:s??(t==="insert"?[]:this.selectionIds()),query:"",active:0,items:[],persist:!1},e.setAttribute("aria-expanded","true"),o!==null?(this.priorAria||(this.priorAria=Cn.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 Cn)this.view.dom.removeAttribute(t)}moreItems(){let t=this.isPhone(),e=t?ae.filter(([s])=>!Bn.has(s)).map(([s,r])=>({key:s,label:r,icon:s,run:i=>On(i,s)})):[],o=_n.filter(s=>es.has(s.key)).map(s=>({...s,blocks:!0}));return[...e,{key:"underline",label:"Underline",icon:"U",hint:`${Dt}u`,run:(s,r)=>ue(s,r,"underline")},{key:"text_color",label:"Text color",icon:"A",hint:"\u203A",run:(s,r)=>ue(s,r,"text_color")},{key:"highlight",label:"Highlight",icon:"\u25A0",hint:"\u203A",run:(s,r)=>ue(s,r,"highlight")},...t?[{key:"turn",label:"Turn into",icon:"turn",run:(s,r)=>r.openMenu("turn",r.more)}]:[],{key:"insert",label:"Insert",icon:"+",run:(s,r)=>r.openMenu("insert",r.pickedFrom??r.more,null,null,s.state.doc.child(r.blockIndex()).attrs.id)},...o,...t&&this.settingsAPI?[{key:"settings",label:"Document settings",icon:"gear",focus:!1,run:(s,r)=>r.openSettings(r.more)}]:[],{key:"titleIcon",label:"Page icon",icon:"\u263A",run:s=>Z(s,"titleIcon")},...this.mediaNote?[]:[{key:"titleCover",label:"Add cover",icon:"\u25A4",run:s=>Z(s,"titleCover")}],{key:"exportHtml",label:"Export reading copy",icon:"\u21E9",run:s=>Z(s,"exportHtml")},{key:"exportMarkdown",label:"Export as Markdown",icon:"M\u21E9",run:s=>Z(s,"exportMarkdown")}]}menuItems(t){if(t.mode==="external")return t.externalItems||[];if(t.mode==="actions")return ts(this.view.state);if(t.mode==="more")return this.moreItems();let e=this.onAiTool?[...At,{key:"ai",label:"Make a tool with AI\u2026",icon:"\u2726",aliases:["tool","generate"],insert:"ai"}]:At,o=this.mediaNote?e.filter(r=>r.key!=="image"&&r.key!=="file"):e,s=t.mode==="turn"?q:gn(this.view.state,o);return Mn(s,t.query)}currentTypes(){let t=this.view.state;return new Set(lt(t).map(e=>Ot(t.doc.child(e)).key))}openActions(t=this.plus,e=null){let o=this.view.state,s=gt(o.doc),r=o.selection,i=e!==null&&r instanceof z&&r.span(o.doc).lo<=e&&e<=r.span(o.doc).hi,{lo:l,hi:c}=e===null||i?We(o,s):Fe(s,e,e);this.view.dispatch(o.tr.setSelection(zt(o.doc,l,c,s)));let d=[];for(let u=l;u<=c;u++)d.push(o.doc.child(u).attrs.id);this.openMenu("actions",t,null,d)}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=k("div","blockeditor-menu-title");r.textContent=t.query?`Turn into \u201C${t.query}\u201D`:"Turn into",s.push(r)}if(!t.items.length){let r=k("div","blockeditor-menu-empty");r.textContent="No matching blocks",s.push(r)}if(t.items.forEach((r,i)=>{let l=i===t.active,c=o?o.size===1&&r.key===[...o][0]:typeof r.checked=="boolean"?r.checked:null,d=t.mode==="turn"?"menuitemradio":typeof c=="boolean"?"menuitemcheckbox":e?"option":"menuitem",u=k("button",`blockeditor-menu-item${l?" is-active":""}`,{type:"button",role:d,tabindex:!e&&l?"0":"-1",id:`${this.menuId}-${i}`,"data-index":String(i),...d==="menuitemradio"?{}:{"aria-selected":l?"true":"false"},...typeof c=="boolean"?{"aria-checked":String(c)}:{}}),a=k("span","blockeditor-menu-icon");K[r.icon]?a.innerHTML=K[r.icon]:a.textContent=r.icon||"";let h=k("span","blockeditor-menu-label");if(h.textContent=r.label,r.description){let p=k("span","blockeditor-menu-text"),f=k("span","blockeditor-menu-desc");f.textContent=r.description,p.append(h,f),u.append(a,p)}else u.append(a,h);if(r.hint){let p=k("span","blockeditor-menu-hint");p.textContent=r.hint,u.append(p)}s.push(u)}),this.mediaNote&&t.mode!=="turn"&&t.mode!=="actions"&&t.mode!=="more"&&t.mode!=="external"){let r=k("div","blockeditor-menu-note",{role:"note"});r.textContent=this.mediaNote,s.push(r)}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({preventScroll:!0})}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(d=>!d||this.idIndex(d)<0),c=i.length?this.idIndex(i[0]):-1;if(this.pickedFrom=e.anchor,this.closeMenu(),l&&e.mode!=="external"){P(this.view,Jo),this.view.focus();return}if(e.mode==="turn"){if(i.some(d=>!Q(s.doc.child(this.idIndex(d)),o))){P(this.view,he),this.view.focus();return}yn(this.view,o,i)}else e.mode==="actions"||e.mode==="more"||e.mode==="external"?(o.blocks&&this.selectCaretBlock(i),o.run(this.view,this,c>=0?c:this.blockIndex()),!this.menu&&o.focus!==!1&&this.view.focus()):o.insert==="ai"?this.onAiTool(this.view,r):wn(this.view,o,c>=0?c:this.blockIndex(),r)}key(t){if(It(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 z&&this.leaveToToolbar(),!1;if((t.key==="Backspace"||t.key==="Delete")&&e.mode==="actions"&&this.view.state.selection instanceof z)return this.closeMenu(),this.view.focus(),Ft(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==="Tab"&&e.slashAt===null)return this.closeMenu(),!1;if(t.key==="Escape"){let o=this.invoker();return e.slashAt!==null&&(this.dismissedSlash=this.slashKey(e.slashAt)),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=k("div","blockeditor-safe-probe"),this.shell.append(this.probe)),parseFloat(this.win.getComputedStyle(this.probe).paddingBottom)||0}menuBox(t){let e=ce(this.win),o=Math.max(0,e.height-$*2),s=Math.min(280,Math.max(0,e.width-$*2)),r=this.menuEl.style.getPropertyValue("--blockeditor-pop-max");this.menuEl.style.removeProperty("--blockeditor-pop-max");let i=this.menuEl.offsetHeight||0;r&&this.menuEl.style.setProperty("--blockeditor-pop-max",r);let l=Math.min(i,o),c=Math.max(e.left+$,Math.min(t.left,e.left+e.width-$-s)),d=t.top-6-l;return d<e.top+$&&(d=Math.min(t.top+t.height+6,e.top+e.height-$-l)),{left:c,top:d,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 a=0;a<r;a++)i+=e.doc.child(a).nodeSize;let l=t.nodeDOM(i),c={textLeft:s.left-o.left,gutter:null,bubble:null,menu:null,bar:null,desk:!1};if(l&&l.getBoundingClientRect){let a=l.getBoundingClientRect(),h=parseFloat(getComputedStyle(l).lineHeight)||a.height;c.gutter={top:a.top-o.top+Math.min(a.height,h)/2,left:a.left-o.left}}let d=this.isPhone();if(d){let a=ce(this.win),h=this.dock.offsetHeight||os;c.bar={...Xo(a,this.dock.offsetWidth||ns,h,this.safeBottom()),height:h}}else c.desk=!!this.dock.style.left;let u=e.selection;if(!this.bubble.hidden&&!d){let a=t.coordsAtPos(u.from),h=t.coordsAtPos(u.to,-1),p=(Math.min(a.left,h.left)+Math.max(a.right,h.right))/2;c.bubble={x:p-o.left,y:Math.min(a.top,h.top)-o.top}}if(this.menu&&d){let a=this.menuBox(c.bar);c.menu={x:a.left,y:a.top,width:a.width,maxHeight:a.maxHeight}}else if(this.menu){let a=this.menu,h,p;if(a.slashAt!==null){let f=t.coordsAtPos(a.slashAt-1);h=f.left,p=f.bottom+6;let m=this.menuEl.offsetHeight;p+m>this.win.innerHeight-8&&f.top-6-m>=8&&(p=f.top-6-m)}else{let f=a.anchor===this.plus?l?.getBoundingClientRect?.()??s:a.anchor.getBoundingClientRect();h=f.left,p=f.bottom+6;let m=this.menuEl.offsetHeight;p+m>this.win.innerHeight-8&&f.top-6-m>=8&&(p=f.top-6-m)}c.menu={x:Math.max(8,Math.min(h-o.left,o.width-280)),y:p-o.top}}return c}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("--blockeditor-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("--blockeditor-grip-lift")}if(t.gutter)for(let e of[this.plus,this.grip])e.style.setProperty("--blockeditor-plus-top",`${t.gutter.top}px`),e.style.setProperty("--blockeditor-plus-left",`${t.gutter.left}px`);this.plus.style.setProperty("--blockeditor-text-left",`${t.textLeft}px`),t.bubble&&(this.bubble.style.setProperty("--blockeditor-pop-x",`${t.bubble.x}px`),this.bubble.style.setProperty("--blockeditor-pop-y",`${t.bubble.y}px`)),t.menu&&(this.menuEl.style.setProperty("--blockeditor-pop-x",`${t.menu.x}px`),this.menuEl.style.setProperty("--blockeditor-pop-y",`${t.menu.y}px`),t.menu.width!==void 0&&(this.menuEl.style.setProperty("--blockeditor-pop-width",`${t.menu.width}px`),this.menuEl.style.setProperty("--blockeditor-pop-max",`${t.menu.maxHeight}px`)))}get settingsAPI(){return globalThis.clay?.blockeditor?.settings??null}update(t,e){let o=!this.settingsAPI;if(this.settingsBtn.hidden!==o&&(this.settingsBtn.hidden=o),this.view=t,this.menu&&this.menu.slashAt===null&&e&&e.doc!==t.state.doc)if(this.menu.persist&&this.menu.anchor?.isConnected)this.scheduleLayout();else{let c=this.menuEl.contains(document.activeElement);this.closeMenu(),c&&t.focus()}let s=t.state,r=s.doc.child(this.blockIndex());this.turn.textContent=`${Ot(r).label} \u25BE`,this.bubbleTurn.textContent=this.turn.textContent;for(let c of this.dock.querySelectorAll("[data-cmd]"))c.setAttribute("aria-pressed",String(An(s,c.dataset.cmd)));let l=!!this.menu&&[this.bubbleTurn,this.bubbleMore].includes(this.menu.anchor)||!s.selection.empty&&s.selection instanceof $t&&t.hasFocus();if(this.bubble.hidden=!l,l)for(let c of this.bubble.querySelectorAll("[data-cmd]"))c.setAttribute("aria-pressed",String(An(s,c.dataset.cmd)));if(this.grip.classList.toggle("is-on",s.selection instanceof z),this.inRoving(this.roving)||this.setRoving(this.dockControls()[0]),!this.menu&&e&&e.doc!==s.doc&&!this.remote&&t.hasFocus()&&s.selection.empty){let c=s.selection.$head;if(c.depth===1&&c.parent.isTextblock&&!c.parent.type.spec.code){let d=s.doc.textBetween(c.start(),c.pos),u=/(?:^|\s)\/([a-z]*)$/i.exec(d),a=u?c.start()+u.index+u[0].indexOf("/")+1:null;u&&this.slashKey(a)!==this.dismissedSlash&&this.openMenu("insert",this.plus,a,null,c.parent.attrs.id)}}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),document.removeEventListener("keydown",this.onSettingsKey,!0);for(let t of[this.dock,this.plus,this.grip,this.bubble,this.scrim,this.menuEl,this.settingsEl,this.probe])t?.remove()}};function Qi({onAiTool:n=null,mediaNote:t=null}={}){let e=null;return new In({key:ps,view(o){return e=new de(o,n,t),pe.set(o,e),e},filterTransaction(o){return e&&o.docChanged&&(e.remote=!!o.getMeta(Me)),!0},props:{handleKeyDown(o,s){return e?s.key==="/"&&(s.metaKey||s.ctrlKey)&&!s.altKey&&!e.menu?(s.preventDefault(),e.openActions(),!0):e.key(s):!1},handleTextInput(o,s,r,i){if(i!=="/"||!e)return!1;let l=Ge(o,i);l&&(s=o.state.selection.from-1);let c=o.state.doc.resolve(s);if(c.depth!==1||!c.parent.isTextblock||c.parent.type.spec.code||c.parentOffset>0&&!/\s/.test(o.state.doc.textBetween(s-1,s,"",`
|
|
6
|
-
`)))return l;l||o.dispatch(o.state.tr.insertText("/",s,r).setMeta(xt,qt(o.state,s,r,"/")));let d=Math.min(o.state.doc.resolve(s).index(0),o.state.doc.childCount-1);return e.openMenu("insert",e.plus,s+1,null,o.state.doc.child(d).attrs.id),!0},handleDOMEvents:{keydown(o,s){return It(s,o)},blur(o){return e&&!(e.menu&&[e.bubbleTurn,e.bubbleMore].includes(e.menu.anchor))&&(e.bubble.hidden=!0),!1}}}})}var{Plugin:ms}=C,me=new WeakMap,gs=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 Bt(n,t){let e=n.dom.ownerDocument,o=n.dom.parentElement.querySelector(".blockeditor-csv-error");o||(o=e.createElement("div"),o.className="blockeditor-csv-error",o.setAttribute("role","alert"),n.dom.parentElement.append(o)),o.textContent=t}function bs(n){let t=0,e=Ce(n,{maxBytes:Jt,newId:()=>y(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[y("r")]={pos:A(),cells:o}}return{node:Y(g,y(),{t:"table",pos:null,cols:e.cols,rows:e.rows}),truncated:e.truncated}}async function ks({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-47M4QHCK.js")).consent,s=(await import("./c-J2YYLEVM.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 ys=(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},xs=n=>{let t=!0;return n.descendants(e=>(e.isText&&(t=!1),t)),t};function Ms(n,t,e,o){let s=n.state,r=ys(s.doc,e);if(r<0)return F(s,n.dispatch,t,null,o);let i=0;for(let u=0;u<r;u++)i+=s.doc.child(u).nodeSize;let l=s.doc.child(r);if(!xs(l)||o){let u=s.doc.maybeChild(r+1),a=l.attrs.parent??null,h=A(l.attrs.pos,u?.attrs.pos??null),p=t.type.create({...t.attrs,pos:h,parent:a},t.content),f=i+l.nodeSize,m=s.tr.insert(f,p);return o&&m.insert(f+p.nodeSize,o.type.create({...o.attrs,pos:A(h,u?.attrs.pos??null),parent:a},o.content)),m.setSelection(C.TextSelection.create(m.doc,f+3)),n.dispatch(w(m).scrollIntoView()),!0}let c=t.type.create({...t.attrs,id:l.attrs.id,pos:l.attrs.pos,parent:l.attrs.parent},t.content),d=s.tr.replaceWith(i,i+l.nodeSize,c);return d.setSelection(C.TextSelection.create(d.doc,i+3)),n.dispatch(w(d).scrollIntoView()),!0}async function fe(n,t,{upload:e,remove:o=null,table:s=null}={}){try{n.dom.parentElement.querySelector(".blockeditor-csv-error")?.remove();let r=ht(await gs(t)),i=bs(r);if(!i)return Bt(n,"Couldn't read this CSV: no columns."),!1;let l=null;if(i.truncated){if(!await ks(i.truncated))return!1;let u=await e?.(t),a=ke(u?.uploads?.[0]?.url);if(!u?.ok||!a)return Bt(n,"Couldn't attach the original CSV."),!1;l=g.nodes.file.create({id:y(),src:a,name:t.name,size:t.size??null,mime:t.type||"text/csv"})}if(n.isDestroyed)return!1;if(s)return Ms(n,i.node,s,l);let c=o?Kn(n.state):null;return o&&!c&&Ss(n,o.block),F(n.state,n.dispatch,i.node,c,l)}catch(r){return r instanceof Se?Bt(n,`Couldn't read this CSV: unclosed quote on line ${r.line}.`):Bt(n,"Couldn't read this CSV."),!1}}function Ct(n,t=null,e=null){let o=me.get(n);return o?(t&&Fn(n,t),o._remove=t?{...t,block:ws(n.state.doc,t.from)}:null,o._table=e,o.click(),!0):!1}var ws=(n,t)=>n.child(n.resolve(Math.max(0,Math.min(t,n.content.size))).index(0)).attrs.id;function Ss(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(C.TextSelection.near(e.doc.resolve(o)))),!0)}var Vn=n=>[...n].filter(t=>/\.csv$/i.test(t.name||"")||/^(text\/csv|application\/csv)$/i.test(t.type||""));function al({upload:n}){return new ms({view(t){let e=t.dom.ownerDocument.createElement("input");return e.type="file",e.accept=".csv,text/csv",e.hidden=!0,e.className="blockeditor-csv-input",t.dom.parentElement.append(e),me.set(t,e),e.addEventListener("change",()=>{let o=e.files?.[0];o&&fe(t,o,{upload:n,remove:e._remove,table:e._table}),e._remove=null,e._table=null,e.value=""}),{destroy(){me.delete(t),e.remove()}}},props:{handlePaste(t,e){let o=Vn(e.clipboardData?.files||[]);return o.length?(e.preventDefault(),fe(t,o[0],{upload:n}),!0):!1},handleDrop(t,e,o,s){let r=Vn(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(C.TextSelection.near(t.state.doc.resolve(i.pos)))),fe(t,r[0],{upload:n}),!0}}})}export{Bs as a,qs as b,Je as c,Cs as d,As as e,al as f,hn as g,ni as h,Tt as i,It as j,Oi as k,vi as l,Ii as m,fr as n,mr as o,Ys as p,Js as q,Xs as r,te as s,Yi as t,Fn as u,Kn as v,Ji as w,Xi as x,Qi as y,Gt as z,bo as A,Lr as B,Dr as C,$r as D,_r as E,Br as F,ko as G,yo as H,Pr as I,Rr as J,Nr as K,Hr as L,zr as M,Fr as N,Kr as O,Vr as P,jr as Q,qr as R,Wr as S};
|
package/dist/m/c-LYNLY3MR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as v,e as m}from"./c-GNFDX6SU.js";import"./c-NEQRFC4O.js";import"./c-IW6GGOU2.js";import"./c-HAWFNBYG.js";import{e as h,f as p,g,h as k}from"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-TCCA5BZN.js";import"./c-57XDY6HC.js";import"./c-OZVK3TFI.js";import"./c-QCDVDZIR.js";import"./c-MZCOGNZL.js";import"./c-IJUK2GPW.js";import{c as b}from"./c-BPF2NSPV.js";import{e as T}from"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";T(v);var x=1,y=class extends Error{constructor(o,n){super(n),this.name="PageCheckpointError",this.code=o}},w=(e,o)=>{throw new y(e,o)},t=(e,o)=>({ok:!1,code:e,message:o}),A=/^[0-9a-f]{64}$/,j=/^[0-9a-f]{32}$/,E=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function I(e){return{v:e.v,g:e.g,y:{...e.y??{}}}}function H(e){let o;try{o=JSON.parse(e)}catch{w("invalid-state","The page state is not JSON")}return(!E(o)||o.v!==1)&&w("invalid-state","Expected a version 1 Yjs page value"),{state:I(o),bytes:p(o)}}var S=e=>e==null?"":String(e);async function N({href:e,etag:o,fetch:n=globalThis.fetch,signal:i=null}={}){if(typeof o!="string"||!o)return t("missing-etag","A conditional read needs the accepted ETag");if(typeof e!="string"||!e)return t("no-blockeditor-state","This host names no blockeditor-state resource");if(typeof n!="function")return t("unavailable","This tab cannot read the page state");let s=globalThis.location?.href??"http://localhost/",d;try{d=new URL(e,s).href}catch{return t("no-blockeditor-state","The blockeditor-state resource is not a URL")}let c=b(),a;try{a=await n(d,{method:"GET",credentials:c?"omit":"same-origin",headers:{"If-Match":o,"Document-URL":globalThis.location?.href??s},cache:"no-store",redirect:"manual",signal:i})}catch{return t("unavailable","The blockeditor-state request did not complete")}if(!a||typeof a.status!="number")return t("unavailable","The blockeditor-state request did not answer");if(a.status===412)return t("etag-mismatch","Another version of this document is stored");if(a.status===428)return t("etag-required","The host needs a condition this read cannot send");if(a.status===404)return t("no-blockeditor-state","This host keeps no page state");if(!a.ok)return t("unavailable",`The host answered ${a.status}`);let r;try{r=JSON.parse(await a.text())}catch{return t("invalid-state","The blockeditor-state answer is not JSON")}return!E(r)||r.version!==x?t("unsupported-version","Unknown blockeditor-state version"):typeof r.tag!="string"||!r.tag?t("invalid-state","The blockeditor-state answer carries no page tag"):typeof r.stateHash!="string"||!A.test(r.stateHash)?t("invalid-state","The blockeditor-state answer carries no state digest"):typeof r.generation!="string"||!j.test(r.generation)?t("invalid-state","The blockeditor-state answer carries no generation"):typeof r.etag!="string"||!r.etag?t("invalid-state","The blockeditor-state answer carries no ETag"):Object.hasOwn(r,"documentId")?{ok:!0,version:r.version,documentId:r.documentId,generation:r.generation,etag:r.etag,stateHash:r.stateHash,tag:r.tag}:t("invalid-state","The blockeditor-state answer carries no document identity")}async function _(e,{accepted:o,article:n,etag:i}={}){if(!e||e.ok!==!0)return t(e?.code??"unavailable",e?.message??"The page state was not read");let s=o?.authority;if(!(s?.scope==="path"&&e.documentId==null)&&S(e.documentId)!==S(s?.documentId))return t("foreign-document","The page state belongs to another document");if(typeof o?.lineage?.generation!="string"||e.generation!==o.lineage.generation)return t("foreign-generation","The page state belongs to another generation");if(e.etag!==i)return t("etag-mismatch","The page state belongs to another version of this document");let c,a;try{({state:a,bytes:c}=H(e.tag))}catch(u){return t(u?.code??"invalid-state",u?.message??"The page state does not decode")}if(await h(c)!==e.stateHash)return t("state-digest-mismatch","The page state is not the one the host hashed");if(typeof n!="string")return t("missing-article","A proof names the final outgoing article");let r;try{r=m(a)}catch(u){return t("invalid-state",u?.message??"The page state does not project")}return r!==n?t("article-mismatch","The page state does not project to the accepted article"):{ok:!0,state:a,receipt:{file:e.etag,blockeditorState:e.stateHash}}}async function O(e,o){let n=(o||[]).map(({id:i,revision:s})=>({id:i,revision:s}));try{return{ok:!0,proof:e,covered:await k(e,n)}}catch(i){return t(i?.code??"invalid-proof",i?.message??"The proof does not validate")}}async function R({capture:e,records:o=[],accepted:n,article:i,state:s=null,etag:d=null}={}){if(!s)return t("no-capture-state","No page state was pinned to this capture");if(typeof d!="string"||!d)return t("missing-etag","An accepted save with no ETag proves no stored pair");if(typeof i!="string")return t("missing-article","The accepted bytes hold no article");let c,a;try{c=m(s),a=p(s)}catch(u){return t(u?.code??"invalid-state",u?.message??"The pinned page state does not decode")}if(c!==i)return t("article-mismatch","The pinned page state does not project to the accepted article");let r;try{r=await g({capture:e,records:o,accepted:n,article:i,state:s,receipt:{file:d,blockeditorState:await h(a)}})}catch(u){return t(u?.code??"invalid-proof",u?.message??"The proof could not be built")}return O(r,o)}async function B({read:e,capture:o,records:n=[],accepted:i,article:s,etag:d=null}={}){let c=await _(e,{accepted:i,article:s,etag:d});if(!c.ok)return c;let a;try{a=await g({capture:o,records:n,accepted:i,article:s,state:c.state,receipt:c.receipt})}catch(r){return t(r?.code??"invalid-proof",r?.message??"The proof could not be built")}return O(a,n)}async function G({channel:e,records:o=[],capture:n,accepted:i,article:s,state:d=null,etag:c=null,href:a=null,read:r=N,fetch:u}={}){if(!e||typeof e.checkpoint!="function")return{ok:!1,code:"no-channel",retired:[],proof:null};let l=await R({capture:n,records:o,accepted:i,article:s,state:d,etag:c});if(!l.ok){let P=await r({href:a,etag:c,fetch:u});l=await B({read:P,capture:n,records:o,accepted:i,article:s,etag:c})}if(!l.ok)return{ok:!1,code:l.code,retired:[],proof:null};let f=await e.checkpoint({records:l.covered,proof:l.proof});return!f||f.ok!==!0?{ok:!1,code:f?.code??"checkpoint-failed",retired:[],proof:l.proof}:{ok:!0,retired:f.retired??[],proof:l.proof}}export{x as PAGE_STATE_VERSION,y as PageCheckpointError,R as captureProof,G as checkpointAccepted,N as readPageState,B as refetchedProof,_ as verifyPageState};
|
package/dist/m/c-MLMJUNRV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f}from"./c-NW4ZFKCY.js";import{g as a}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-3Y234AUB.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-VHNSBD2M.js";export{e as ChartView,d as chartFromSlash,a as chartTables,b as insertChartAfterTable,f as refreshCharts,c as tableLabel};
|
package/dist/m/c-V5L6HWVL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as g,f as h}from"./c-TRS6TM6O.js";import{d as m}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import{b as f}from"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as g,z as E}from"../c-FC5RUFPR.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-P73XPAOA.js";import"../c-ZPI7M5U5.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as m}from"../c-MZCOGNZL.js";import{e as S}from"../c-EHAR4RJJ.js";import{a as v}from"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-KU3PX7LL.js";import"../c-EQ5NBOGA.js";import"../c-IJUK2GPW.js";import"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var T="Site-Data",M='script[data-rules-name~="api"]',R=/(?:^|[{,])\s*["']?site["']?\s*:/,h={html:null,now:null,keys:[]},l=null,a=null,u=h,b=null,y=new Set,f=new Map;function k(){let t=E();if(typeof t!="string"||!t)return!1;if(t===b)return!0;let e=d(w(t));if(!a)a=e;else for(let[n,o]of Object.entries(e)){if(y.has(n))continue;let s=f.get(n);a[n]=s&&s.sent===o?s.value:o}return f.clear(),b=t,u=h,!0}function j(t){let e=l.engine.findRulesIn(t,"api")?.rules?.site;return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function d(t){let e=j(t);if(!e)return{};let n=l.extractData(t,{site:e}).site??{};return Object.fromEntries(Object.entries(n).map(([o,s])=>[o,JSON.stringify(s)]))}var w=t=>new DOMParser().parseFromString(t,"text/html").documentElement;function O(t){if(u.html!==t){let e=d(w(t));u={html:t,now:e,keys:Object.keys(e).filter(n=>e[n]!==a[n])}}return u}function x(t){return!l||typeof t!="string"||!k()?null:{[T]:`keys=${O(t).keys.map(encodeURIComponent).join(",")}`}}function H(t,e,n){let o=document.documentElement,s=j(o),c=d(o),p=[];for(let[r,A]of Object.entries(t)){if(n.has(r)||!s||!Object.hasOwn(s,r)||c[r]!==e[r])continue;let C=new Map([...o.querySelectorAll("[editable]")].map(i=>[i,i.innerHTML]));m.pause();try{l.applyData(o,{site:{[r]:A}},{site:{[r]:s[r]}}),a[r]=d(o)[r],f.set(r,{sent:e[r],value:a[r]}),p.push(r)}catch(i){console.error(`clayjs: the shared value "${r}" could not be refreshed on this page`,i)}finally{m.resume()}for(let[i,D]of C)i.isConnected&&i.innerHTML!==D&&i.dispatchEvent(new CustomEvent("clay:external-write"))}return p.length&&g(),p}function L(t,e){if(!l||!k())return;f.clear();let n=O(t).now,o=new Set((e?.refused??[]).filter(c=>c.code!=="stale").map(c=>c.key));for(let c of Object.keys(n))o.has(c)?y.add(c):(a[c]=n[c],y.delete(c));if(u=h,!e)return;let s=e.current?H(e.current,n,o):[];document.dispatchEvent(new CustomEvent("clay:site-data",{detail:{written:e.written??[],refused:e.refused??[],applied:s}}))}var U=R.test(document.querySelector(M)?.textContent??"")?(()=>{let t=import("../c-VGG3UR7I.js");return S(x),v((e,n)=>L(e,n.siteData??null)),t.then(e=>{l=e}).catch(e=>console.error("clayjs: shared site edits are not tracked on this page",e))})():Promise.resolve();export{T as SITE_DATA_HEADER,U as ready};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as X}from"./c-NL4I4KNG.js";import"./c-7SWMYKAI.js";import{f as V}from"./c-46XYM55L.js";import{b as J}from"./c-FILLTJA7.js";import{a as F}from"./c-VKEDWYDF.js";import"./c-UGHH4MB3.js";import"./c-MZCOGNZL.js";import"./c-IJUK2GPW.js";import{b as G}from"./c-CYWLPPUS.js";import{i as z}from"./c-MOP5KBWZ.js";import{a as W}from"./c-2YYDMLNZ.js";import{c as H,l as $}from"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var K={always:["lib/mutation.js","core/preserve-authored.js","core/edit-mode.js","core/mode-key.js","core/stale-host-notice.js","core/page-data.js"],editOnly:["core/snapshot.js","core/persist.js","core/admin-attrs.js","core/save-core.js","core/save.js","core/conflict-notice.js","core/recovery.js","core/unsaved-warning.js","core/autosave.js","attrs/save-freeze.js","attrs/onaftersave.js","attrs/refetch-on-save.js","attrs/add-from.js","lib/cache-bust.js"]},O={richclay:{path:"plugins/richclay.js",editOnly:!0,default:!0},indicator:{path:"plugins/indicator.js",editOnly:!0,default:!1},sync:{path:"sync/live-sync.js",editOnly:!1,default:!1},live:{path:"plugins/live.js",editOnly:!1,default:!1},blockeditor:{path:"plugins/page.js",editOnly:!0,default:!1},"blockeditor-view":{path:"plugins/page-view.js",editOnly:!1,default:!1,internal:!0},sortable:{path:"plugins/sortable.js",editOnly:!0,default:!1},undo:{path:"plugins/undo.js",editOnly:!0,default:!1},unsent:{path:"plugins/unsent.js",editOnly:!0,default:!1},cms:{path:"plugins/cms.js",editOnly:!1,default:!1},quickcrop:{path:"plugins/quickcrop.js",editOnly:!1,default:!1},upload:{path:"plugins/upload.js",editOnly:!0,default:!1},people:{path:"plugins/people.js",editOnly:!1,default:!1},menu:{path:"plugins/menu.js",editOnly:!1,default:!1},wire:{path:"plugins/wire.js",editOnly:!1,default:!1},message:{path:"plugins/message.js",editOnly:!1,default:!1},like:{path:"plugins/like.js",editOnly:!1,default:!1},"ai-edit":{path:"plugins/ai-edit.js",editOnly:!0,default:!1},demo:{path:"plugins/demo.js",editOnly:!1,default:!1},source:{path:"plugins/source.js",editOnly:!0,default:!0},"visitor-drafts":{path:"plugins/visitor-drafts.js",ownerPath:"plugins/visitor-drafts-owner.js",editOnly:!1,default:!1},"visitor-menu":{path:"plugins/visitor-menu.js",editOnly:!0,draft:!0},"bind-text":{path:"plugins/bind-text.js",editOnly:!0,default:!1},derive:{path:"plugins/derive.js",editOnly:!1,default:!1},upgrade:{path:"plugins/upgrade.js",editOnly:!1,default:!1}},S={"core/is-edit-mode.js":()=>import("./core/is-edit-mode-73OXKK5H.js"),"core/draft-mode.js":()=>import("./core/draft-mode-M5XNYBMY.js"),"lib/region-policy.js":()=>import("./lib/region-policy-KWBPROWF.js"),"lib/mutation.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["lib/mutation.js"]),"core/edit-mode.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["core/edit-mode.js"]),"core/mode-key.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["core/mode-key.js"]),"core/stale-host-notice.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["core/stale-host-notice.js"]),"core/page-data.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["core/page-data.js"]),"core/preserve-authored.js":()=>import("./reader-core-AHOAP5DH.js").then(t=>t.core["core/preserve-authored.js"]),"core/snapshot.js":()=>import("./core/snapshot-N5MKDGNI.js"),"core/save-core.js":()=>import("./core/save-core-I4N6S4ED.js"),"core/save.js":()=>import("./core/save-JZ7R4ET2.js"),"core/site-edits.js":()=>import("./core/site-edits-TIJDPG6H.js"),"core/conflict-notice.js":()=>import("./core/conflict-notice-Y2NTMDGJ.js"),"core/recovery.js":()=>import("./core/recovery-VZF7RJZF.js"),"core/unsaved-warning.js":()=>import("./core/unsaved-warning-BP6ZY3PG.js"),"core/persist.js":()=>import("./core/persist-MX3VYVBN.js"),"core/admin-attrs.js":()=>import("./core/admin-attrs-43JBA6JB.js"),"core/autosave.js":()=>import("./core/autosave-HD7Y7UNV.js"),"attrs/save-freeze.js":()=>import("./attrs/save-freeze-PUYX32AK.js"),"attrs/onaftersave.js":()=>import("./attrs/onaftersave-OKSWEJQF.js"),"attrs/refetch-on-save.js":()=>import("./attrs/refetch-on-save-5CBFUJUF.js"),"attrs/add-from.js":()=>import("./attrs/add-from-T5LJXFFI.js"),"lib/cache-bust.js":()=>import("./lib/cache-bust-BL4KUQAJ.js"),"plugins/richclay.js":()=>import("./plugins/richclay-V6WKJTUF.js"),"plugins/indicator.js":()=>import("./plugins/indicator-OLPZ4WFI.js"),"sync/live-sync.js":()=>import("./sync/live-sync-DX4K5GDB.js"),"plugins/live.js":()=>import("./plugins/live-CO4VJS46.js"),"plugins/page.js":()=>import("./plugins/page-L3VKIQU2.js"),"plugins/page-view.js":()=>import("./plugins/page-view-6KNTXABH.js"),"plugins/sortable.js":()=>import("./plugins/sortable-BAG3MSWS.js"),"plugins/undo.js":()=>import("./plugins/undo-WUK2NLBA.js"),"plugins/unsent.js":()=>import("./plugins/unsent-OA4RGBUT.js"),"plugins/cms.js":()=>import("./plugins/cms-4KET6RZT.js"),"plugins/quickcrop.js":()=>import("./plugins/quickcrop-VNRXGRPC.js"),"plugins/upload.js":()=>import("./plugins/upload-NZET3DNQ.js"),"plugins/people.js":()=>import("./plugins/people-EBWE337I.js"),"plugins/menu.js":()=>import("./plugins/menu-ESEFQARM.js"),"plugins/wire.js":()=>import("./plugins/wire-S5ATC4QI.js"),"plugins/message.js":()=>import("./plugins/message-LQ6EDH4V.js"),"plugins/like.js":()=>import("./plugins/like-EV7MTZ56.js"),"plugins/ai-edit.js":()=>import("./plugins/ai-edit-WDV2GLDU.js"),"plugins/demo.js":()=>import("./plugins/demo-LMCMBILC.js"),"plugins/visitor-drafts.js":()=>import("./plugins/visitor-drafts-ZE6PCAFP.js"),"plugins/visitor-drafts-owner.js":()=>import("./plugins/visitor-drafts-owner-TLECTYWS.js"),"plugins/visitor-menu.js":()=>import("./plugins/visitor-menu-5XY57JQA.js"),"plugins/bind-text.js":()=>import("./plugins/bind-text-NX46N5UV.js"),"plugins/source.js":()=>import("./plugins/source-OYHDXKTB.js"),"plugins/derive.js":()=>import("./plugins/derive-R4USHZ7P.js"),"plugins/upgrade.js":()=>import("./plugins/upgrade-SZQJYEQQ.js")},re=["visitor-drafts","visitor-menu","richclay","indicator","sortable","undo","unsent","quickcrop","upload","people","menu","upgrade","cms","blockeditor-view","sync","live","blockeditor","message","like","wire","ai-edit","demo","derive","bind-text","source"],ae={cms:["quickcrop","upload","menu"],"ai-edit":["wire"],blockeditor:["live","sync","upload","wire","ai-edit"]},ce={blockeditor:["richclay"]},le={blockeditor:["undo"]},ue=new Set(["source","sortable","menu","upgrade"]),de=new Set(["wire","ai-edit"]);function Q(t,e,o,s){let u=t.get(e);if(u)for(let i of u.split(",")){let a=i.trim();if(a){if(!O[a]||O[a].internal){console.warn(`clayjs: unknown plugin "${a}"`);continue}s(o,a)}}}var pe=["sync","live","blockeditor","upload","quickcrop","cms","people","menu","upgrade","wire","ai-edit","demo","source"],fe="core/site-edits.js",me=["attrs/refetch-on-save.js","core/conflict-notice.js"],ge="https://hyperclay.com/templates/";function P(t,e,{isDraftMode:o=!1,hasSap:s=!1,hasVariants:u=!1,hasSite:i=!1,canEdit:a=!1,templateSource:h=null}={}){let d=[...K.always];e&&d.push(...K.editOnly),e&&!o&&i&&d.splice(d.indexOf("core/save.js")+1,0,fe);let p=new Set;Q(t,"plugins",p,(r,c)=>r.add(c));let j=new Set;Q(t,"exclude",j,(r,c)=>r.add(c));let n=new Set(p);for(let[r,c]of Object.entries(O))c.default&&n.add(r);s&&n.add("derive"),u&&(e||a)&&n.add("menu"),!e&&!o&&n.has("blockeditor")&&n.add("blockeditor-view");for(let r of[...n])if(!j.has(r)&&!(O[r].editOnly&&!e))for(let c of ae[r]||[])n.add(c);j.has("wire")&&n.delete("ai-edit");for(let r of j)n.delete(r);if(o){let r=n.has("blockeditor");for(let c of pe)r&&(c==="blockeditor"||c==="live")||n.delete(c);for(let c of me){let y=d.indexOf(c);y>-1&&d.splice(y,1)}n.add("visitor-drafts")}!o&&a&&!j.has("upgrade")&&h&&h.startsWith(ge)&&n.add("upgrade");for(let[r,c]of Object.entries(ce))if(n.has(r))for(let y of c)p.has(y)||n.delete(y);for(let[r,c]of Object.entries(le))if(n.has(r))for(let y of c)n.has(y)&&(n.delete(y),console.warn(`clayjs: plugin "${y}" cannot run with "${r}" and was left out`));let g=[],w=[];for(let r of re){if(!n.has(r))continue;let c=O[r];if(c.editOnly&&!e||c.draft&&!o)continue;(ue.has(r)||de.has(r)&&n.has("blockeditor")?w:g).push(c.ownerPath&&!o?c.ownerPath:c.path)}return{core:d,plugins:g,late:w}}var _="data-deleted-at",I=(t,e)=>window.clay?.undo?.commit?window.clay.undo.commit(t,e):e(),Y=(t,e)=>t.dispatchEvent(new CustomEvent(e,{bubbles:!0})),R=Object.assign((t,{at:e=new Date().toISOString()}={})=>(I("Move to Trash",()=>t.setAttribute(_,e)),Y(t,"clay:trashed"),{undo:()=>R.restore(t)}),{is:t=>!!t.getAttribute(_),restore(t){I("Restore",()=>t.removeAttribute(_)),Y(t,"clay:restored")},purge(t){I("Delete forever",()=>t.remove())}});var Z=50,he=1e3,ye='[clay~="no-snapshot"], [no-snapshot], [snapshot-remove]',L=0,je=t=>{let e=t.nodeType===1?t:t.parentElement;if(!e)return"a detached node";let o=e.localName;return e.id?o+="#"+e.id:e.classList.length&&(o+="."+[...e.classList].slice(0,2).join(".")),"<"+o+">"};function ve(t){let e=window.clay?.region?.resolveRegionPolicy;if(!e)return null;let o=s=>!!s&&!s.closest(ye)&&e(s).dirtyTracked;for(let s of t){if(s.type==="attributes"&&$(s.attributeName,s.target))continue;let u=s.target.nodeType===1?s.target:s.target.parentElement;if(o(u)&&!(s.type==="childList"&&![...s.addedNodes,...s.removedNodes].some(i=>i.nodeType!==1||o(i))))return s.target}return null}function q(t){let e=window.clay,o=e.Mutation,s=new Set,u=(m,f)=>{s.has(m)||(s.add(m),console.warn("clay.effect: "+f))},i=!1,a=!1,h=0,d=0;L&&e.isEditMode&&console.warn("clay.effect: an effect was created inside another effect, so a new one starts on every run. Create effects once, in clay.start.");let p=()=>{let m=Date.now();m-h>he&&(h=m,d=0),++d>Z&&u("loop",`this effect ran more than ${Z} times in a second. Something keeps changing the document, often a timer or async callback the effect started.`)},j=()=>{if(i=!1,a)return;let m=null;o.pause(),L++;try{e.isEditMode===!0&&(p(),s.has("saved")||(m=new MutationObserver(()=>{}),m.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0})));let f=t();f&&typeof f.then=="function"&&(y(),console.error("clay.effect: fn returned a promise. It must be synchronous, so this effect was stopped."))}catch(f){console.error("clay.effect:",f)}finally{L--,o.resume();let f=m?m.takeRecords():[];if(m?.disconnect(),f.length){let E=ve(f);E&&u("saved",`this effect changed ${je(E)}, which is saved with the file. Effect writes never mark the page unsaved, so a merge can leave it dirty with no save scheduled. Draw derived values inside clay="no-dirty" or clay="editor-ui".`)}}},n=()=>{i||a||(i=!0,queueMicrotask(j))},g=["undo","redo"],w=()=>{for(let m of g)e.undo?.on?.(m,n)},r=m=>{m.detail?.applied?.length&&n()},c=o.onAnyChange({debounce:0,require:"observed"},n);document.addEventListener("clay:sync-applied",n),document.addEventListener("clay:site-data",r),document.addEventListener("clay:modechange",w),w();let y=()=>{a=!0,c(),document.removeEventListener("clay:sync-applied",n),document.removeEventListener("clay:site-data",r),document.removeEventListener("clay:modechange",w);for(let m of g)e.undo?.off?.(m,n)};return n(),y}Object.defineProperty(q,"running",{get:()=>L>0});var we={overtype:()=>import("./c-PQ5LK6QE.js"),marked:()=>import("./c-XN6MBKI6.js"),highlight:()=>import("./c-33JJ6CBX.js"),"highlight/bash":()=>import("./c-KI7M4AY3.js"),"highlight/css":()=>import("./c-H4LG442Q.js"),"highlight/javascript":()=>import("./c-VDSS4K3Z.js"),"highlight/json":()=>import("./c-NRPJEVJS.js"),"highlight/python":()=>import("./c-5YIHJ3TJ.js"),"highlight/xml":()=>import("./c-WN5AY3OZ.js"),uimotion:()=>import("./c-B5CS55WR.js")};function be(t){let e=new Map;function o(s){return Object.hasOwn(t,s)?(e.has(s)||e.set(s,t[s]().catch(u=>{throw e.delete(s),u})),e.get(s)):Promise.reject(new Error(`clay.assets: no asset named "${s}"`))}return{load:o,names:()=>Object.keys(t)}}var ee=be(we);function T(t,e){if(!t||!e)return t;let o={...e,...t};for(let s of["entries","imports","bootImports"])o[s]={...e[s],...t[s]};return o}var Oe="plugins/page.js";function M(t,e,{isEditMode:o=!1,isDraftMode:s=!1,hasSapJs:u=!1}={},i=document){if(!t?.entries)return 0;let a=[...e];for(let n of e)for(let g of t.bootImports?.[n]??[])u&&g==="vendor/sap-core.vendor.js"||a.push(g);o&&!s&&a.push(...t.editBootImports??[]),o&&!s&&e.includes(Oe)&&a.push(...t.editorBootImports??[]);let h=new Set,d=n=>{if(!(!n||h.has(n))){h.add(n);for(let g of t.imports?.[n]??[])d(g)}};for(let n of a)d(t.entries[n]);let p=new Set([...i.querySelectorAll('link[rel="modulepreload"]')].map(n=>n.href)),j=0;for(let n of h){let g=new URL(n,t.base).href;if(p.has(g))continue;let w=i.createElement("link");w.rel="modulepreload",w.href=g,w.setAttribute("clay","no-save"),i.head.append(w),j++}return j}var k=Object.fromEntries(Object.entries(O).flatMap(([t,e])=>e.ownerPath?[[e.path,t],[e.ownerPath,t]]:[[e.path,t]])),v={},te=new Set;function oe(t){te.has(t)||(te.add(t),document.dispatchEvent(new CustomEvent("clay:plugin-ready",{detail:{plugin:k[t]}})))}var Se=(t,e,o,s)=>()=>t().then(u=>(M(T(e,u),[...o.core,...o.plugins,...o.late],{isEditMode:!0,hasSapJs:s}),u));function Ee(){return new Promise(t=>F(t))}function A(){let t=document.querySelector('meta[name="hyper-source"]');return t?t.getAttribute("content"):null}async function Je(t,e,o,s=null,u=null,i=null){V(),(await S["core/draft-mode.js"]()).noteBootParams(e),await Ee();let h=await S["core/is-edit-mode.js"](),{isEditMode:d,isDraftMode:p,isOwner:j,siteVisibility:n,canEdit:g}=h;d&&!p&&import("./core/host-permission-5BYP24GC.js").then(l=>l.checkHostPermission()).catch(()=>{}),window.__hyperclayEditMode=d;let w=await S["lib/region-policy.js"](),r=!!document.querySelector("[sap]"),c=document.querySelectorAll("head style[clay-variant]").length>=2,y=/(?:^|[{,])\s*["']?site["']?\s*:/.test(document.querySelector('script[data-rules-name~="api"]')?.textContent??""),m=!!document.querySelector('script[src*="sap.js"]');W.holdSettle=r&&d;let f=P(e,d,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});f.plugins.includes("plugins/demo.js")&&h.commitModeFacts({destination:"demo"}),M(T(s,u),[...f.core,...f.plugins],{isEditMode:d,isDraftMode:p,hasSapJs:m}),(d||p)&&!u&&i&&i().then(l=>M(T(s,l),[...f.core,...f.plugins],{isEditMode:d,isDraftMode:p,hasSapJs:m})).catch(()=>{});let E,ne=new Promise(l=>{E=l}),ie={sync:f.plugins.includes("sync/live-sync.js")};for(let l of f.core)v[l]=await S[l](),v[l].install?.();if(Le(v,{isDraftMode:p,isOwner:j,siteVisibility:n},w),se(v),document.documentElement.getAttribute("clay-mode-switch")==="live"){let l=P(e,!0,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});v["core/edit-mode.js"].noteLiveSwitch({edit:l,view:P(e,!1,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()}),loaded:v,modules:S,attach:(b,x)=>{U(b,x);let D=k[b],C=window.clay.plugins;D&&Array.isArray(C)&&!C.includes(D)&&(window.clay.plugins=Object.freeze([...C,D]))},attachEditCore:se,announce:oe,loadEditHints:i?Se(i,s,l,m):null,late:ne})}await v["core/edit-mode.js"].activateInitialMode(),window.clay.plugins=Object.freeze([...f.plugins,...f.late].map(l=>k[l]));let B=d?f:P(e,!0,{isDraftMode:p,hasSap:r,hasVariants:c,hasSite:y,canEdit:g,templateSource:A()});window.clay.editPlugins=Object.freeze([...B.plugins,...B.late].map(l=>k[l]));for(let l of f.plugins){let b;try{b=await S[l]()}catch(x){console.error(`clayjs: plugin "${l}" failed to load, continuing without it:`,x);continue}v[l]=b,l==="plugins/visitor-drafts.js"&&await b.restoring,l==="plugins/page-view.js"&&b.start(ie),U(l,b,v)}await Promise.allSettled(f.plugins.map(l=>v[l]?.ready).filter(Boolean)),r&&Pe(v),Te(h),o(window.clay),document.dispatchEvent(new CustomEvent("clay:ready",{detail:{clay:window.clay}})),f.late.length?ke(f.late,h).then(E,E):E()}var N=(t,e)=>O[k[t]]?.editOnly&&!e.startsAtImport();async function ke(t,e){try{await window.clay.blockeditor?.ready}catch{}for(let o of t)if(!N(o,e))try{let s=await S[o]();if(N(o,e)||(v[o]=s,U(o,s,v),await s.ready,N(o,e)))continue;oe(o)}catch(s){console.error(`clayjs: plugin "${o}" failed to load, continuing without it:`,s),document.dispatchEvent(new CustomEvent("clay:plugin-failed",{detail:{plugin:k[o]}}))}}function Pe(t){let e=t["core/save.js"],o=null;try{o=e?e.currentPaintSignature():null}catch(s){console.error("clayjs: could not read the page's painted values:",s)}try{window.Sap&&typeof window.Sap.mount=="function"&&window.Sap.mount()}catch(s){console.error("clayjs: the derive engine failed to mount:",s)}finally{e?.releaseBootSettle()}e&&o!=null&&e.schedulePaintHeal(o)}function Le(t,{isDraftMode:e,isOwner:o,siteVisibility:s},u){let i=window.clay,a=t["lib/mutation.js"],h=t["core/edit-mode.js"];Object.assign(i,{toggleEditMode:h.toggleEditMode,setMode:h.setMode,modeLifecycle:h.modeLifecycle,isDraftMode:e,isOwner:o,siteVisibility:s,Mutation:a.default,region:u.windowRegionShape});for(let p of["mode","isEditMode","canEdit"])Object.defineProperty(i,p,{get:()=>h[p],enumerable:!0,configurable:!0});i.assets=ee;let d=t["core/page-data.js"];i.readData=d.readData,i.writeData=d.writeData,i.ephemeral=H,i.storage=G,i.host={get versions(){return import("./c-Q2CB57UG.js").then(p=>p.hostVersions())}},i.trash=R,i.derived=z,i.effect=q,i.style=X,i.morph=(p,j,n)=>J().then(({morph:g})=>g(p,j,n))}function se(t){let e=window.clay,o=t["core/save.js"];if(o){let a=o.savePage||o.default;a.force=o.savePageForce,a.overwrite=o.saveOverwritingConflict,a.flush=o.flushSave,a.soon=o.savePageSoon,a.limits=o.saveLimits,a.inspect=o.inspectSaveSize,e.save!==a&&typeof e.save?.replace=="function"&&(a.replace=e.save.replace),e.save!==a&&(e.save=a)}e.hasUnsavedChanges=t["core/unsaved-warning.js"]?.hasUnsavedChanges??e.hasUnsavedChanges??(()=>!1);let s=t["core/snapshot.js"];s&&(e.getHTML||(e.getHTML=s.getPageContents),e.addDocumentTransform||(e.addDocumentTransform=s.addDocumentTransform),e.onSnapshot||(e.onSnapshot=s.onSnapshot));let u=t["lib/cache-bust.js"];u&&!e.cacheBust&&(e.cacheBust=u.default);let i=t["core/recovery.js"];i&&!e.recovery&&(e.recovery=i.recovery)}function U(t,e,o=v){let s=window.clay;t==="plugins/undo.js"?s.undo=e.undo||e.default:t==="plugins/unsent.js"?s.unsent=e.unsent:t==="sync/live-sync.js"?(s.morph=e.morph,s.conflicts=e.conflicts,o["core/page-data.js"].setPageDataLiveSync(e.liveSync)):t==="plugins/live.js"?s.live=e.live:t==="plugins/page.js"?s.blockeditor=e.page:t==="plugins/upgrade.js"?(s.save=s.save||{},s.save.replace=e.replace):t==="plugins/cms.js"?s.cms=e.cms||e.default:t==="plugins/upload.js"?s.upload=e.upload||e.default:t==="plugins/people.js"?(s.people=e.people,s.author=e.author,Object.defineProperty(s,"me",{get:e.currentMe,configurable:!0,enumerable:!0})):t==="plugins/message.js"?s.message=e.message:t==="plugins/like.js"?s.like=e.like:t==="plugins/wire.js"?s.wire=e.wire||e.default:t==="plugins/ai-edit.js"?s.aiEdit=e.aiEdit||e.default:t==="plugins/demo.js"?s.demo=e.demo:t==="plugins/richclay.js"?s.RichClay=e.RichClay||e.default:t==="plugins/quickcrop.js"?s.quickcrop=e.quickcrop||e.default:t==="plugins/sortable.js"?s.sortable=e.sortable:t==="plugins/source.js"?s.source=e.source||e.default:t==="plugins/visitor-drafts.js"||t==="plugins/visitor-drafts-owner.js"?s.visitorDrafts=e.visitorDrafts:t==="plugins/bind-text.js"&&(s.bindText=e.bindText)}function Te(t){t.isEditMode||document.addEventListener("click",e=>{e.target.closest?.("[trigger-save]")&&(t.isEditMode||(console.info("clayjs: you're not the owner of this page; changes stay local"),document.dispatchEvent(new CustomEvent("clay:view-save-attempt"))))})}export{Je as boot,Pe as mountDerivedEngine};
|