isorite 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/dist/main.js +684 -116
  3. package/docs/setup-for-agents.md +4 -0
  4. package/docs/setup.md +20 -0
  5. package/docs/terminal.md +15 -0
  6. package/package.json +1 -1
  7. package/plugin/server.ts +4 -2
  8. package/web/_app/immutable/assets/{0.BKnIhFWM.css → 0.CTbO0owi.css} +1 -1
  9. package/web/_app/immutable/chunks/B2TCcw-P.js +6 -0
  10. package/web/_app/immutable/chunks/{BoNMG-YE.js → B4sg4e8i.js} +1 -1
  11. package/web/_app/immutable/chunks/BAkGB2fM.js +1 -0
  12. package/web/_app/immutable/chunks/{Cn-vtDpV.js → C1hqerMA.js} +1 -1
  13. package/web/_app/immutable/chunks/{CVbgxz8Y.js → CMTjeXEe.js} +1 -1
  14. package/web/_app/immutable/chunks/{WBFggAXs.js → C_ER1Any.js} +1 -1
  15. package/web/_app/immutable/chunks/{B7GA1FFB.js → Cgml88Pl.js} +1 -1
  16. package/web/_app/immutable/chunks/CurmVJyp.js +1 -0
  17. package/web/_app/immutable/chunks/{DHfKGggc.js → D29fKEzc.js} +1 -1
  18. package/web/_app/immutable/chunks/{62dhNtvj.js → D3BEa5-_.js} +3 -3
  19. package/web/_app/immutable/chunks/{CYNZ4aV_.js → DPnfDiTn.js} +1 -1
  20. package/web/_app/immutable/chunks/{DsBJWNWe.js → DsIcKd8x.js} +1 -1
  21. package/web/_app/immutable/chunks/DtPULAe0.js +1 -0
  22. package/web/_app/immutable/chunks/{CWmfjLLv.js → yXUzBjUq.js} +1 -1
  23. package/web/_app/immutable/entry/{app.Dt52eXt2.js → app.idRgnoYp.js} +2 -2
  24. package/web/_app/immutable/entry/start.CEx_UQO6.js +1 -0
  25. package/web/_app/immutable/nodes/0.BUd_gY_8.js +26 -0
  26. package/web/_app/immutable/nodes/{1.B5qkcrvB.js → 1.DHK7VmG0.js} +1 -1
  27. package/web/_app/immutable/nodes/2.CDAt-6SJ.js +1 -0
  28. package/web/_app/immutable/nodes/3.4Wv5nmaw.js +1 -0
  29. package/web/_app/immutable/nodes/{4.BhNJiqT-.js → 4.Ceb5g4Ps.js} +1 -1
  30. package/web/_app/immutable/nodes/{5.DXTbGemS.js → 5.DioYOANs.js} +1 -1
  31. package/web/_app/immutable/nodes/6.CzYfNb6g.js +1 -0
  32. package/web/_app/version.json +1 -1
  33. package/web/index.html +15 -15
  34. package/web/_app/immutable/chunks/B3dCo0od.js +0 -1
  35. package/web/_app/immutable/chunks/BNjH_DUx.js +0 -1
  36. package/web/_app/immutable/chunks/D6Vzg2HD.js +0 -6
  37. package/web/_app/immutable/chunks/DkvLWnSd.js +0 -1
  38. package/web/_app/immutable/entry/start.mjqIl2PI.js +0 -1
  39. package/web/_app/immutable/nodes/0.DIhIOwuo.js +0 -26
  40. package/web/_app/immutable/nodes/2.CK3q7brK.js +0 -1
  41. package/web/_app/immutable/nodes/3.CrUewa31.js +0 -1
  42. package/web/_app/immutable/nodes/6.BZWaFgFP.js +0 -1
@@ -1,4 +1,4 @@
1
- import{$ as e,A as t,D as n,F as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,P as d,Q as f,S as p,T as m,U as h,X as g,Y as _,Z as v,_ as y,at as b,d as x,dt as S,f as C,h as w,j as T,k as E,m as ee,n as te,ot as D,p as O,pt as k,q as A,rt as j,s as M,tt as N,ut as P,w as F,x as I,z as L}from"../chunks/nMarIA7J.js";import{o as ne,t as R}from"../chunks/BNjH_DUx.js";import"../chunks/xihTtKlq.js";import{A as z,E as B,M as re,N as V,P as ie,T as H,h as ae,i as U,j as oe,m as se,t as W,w as ce,x as le}from"../chunks/62dhNtvj.js";import{i as ue,n as de,r as fe,t as pe}from"../chunks/CVbgxz8Y.js";import{i as G,r as me,t as K}from"../chunks/DkvLWnSd.js";import{i as q}from"../chunks/B3dCo0od.js";import{t as he}from"../chunks/DsBJWNWe.js";import{t as ge}from"../chunks/DHfKGggc.js";import{a as _e,i as J,n as Y,o as ve,r as ye,t as be}from"../chunks/D6Vzg2HD.js";var xe=T(`<button class="link svelte-1khbtcu" type="button">delete</button>`),Se=T(`<label class="wide svelte-1khbtcu" for="note-folder"><span>folder</span></label> <span class="wide svelte-1khbtcu"><!></span> <label class="svelte-1khbtcu"><span>name</span><input class="mono svelte-1khbtcu" spellcheck="false" autocomplete="off" aria-label="name: change it to rename the file"/></label> <!>`,1),X=T(`<div class="full ask svelte-1khbtcu" role="alertdialog" aria-label="delete this note"><span class="svelte-1khbtcu">Delete this note? <!> Its history stays.</span> <button class="btn danger svelte-1khbtcu" type="button">delete</button> <button class="btn quiet svelte-1khbtcu" type="button">keep it</button></div>`),Ce=T(`<p class="full problem svelte-1khbtcu" role="alert"> </p>`),we=T(`<option></option>`),Te=T(`<div class="details svelte-1khbtcu"><label class="svelte-1khbtcu"><span>type</span><input list="types" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="wide svelte-1khbtcu"><span>tags</span><input placeholder="none" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="full svelte-1khbtcu"><span>description</span><input placeholder="one line on what this note says" autocomplete="off" class="svelte-1khbtcu"/></label> <!> <!> <!> <datalist id="types"></datalist></div>`);function Ee(t,a){D(a,!0);let s=N(()=>[...new Set(K.listing.notes.map(e=>e.type).filter(Boolean))].sort()),l=N(()=>!a.note.id.startsWith(`@`)),d=e(``),h=e(null),v=e=>e.split(`/`).slice(0,-1).join(`/`),y=e=>e.split(`/`).at(-1),w=N(()=>v(a.note.id));async function T(e,t){let n=e=>e.trim().replace(/^\/+|\/+$/g,``).replace(/\.md$/,``),r=[n(e),n(t)].filter(Boolean).join(`/`);if(!n(t)||r===a.note.id)f(w,v(a.note.id));else{f(d,``);try{let e=await a.note.move(r);await K.refresh(),await R(me(e),{replaceState:!0})}catch(e){f(d,e.message,!0),f(w,v(a.note.id))}}}async function ee(){f(d,``);try{let e=await K.api.map();f(h,[...new Set(e.model.edges.filter(([e,t])=>t===a.note.id&&e!==a.note.id&&!e.startsWith(`@`)).map(([t])=>e.notes[t]?.title||t))],!0)}catch(e){f(d,e.message,!0)}}async function te(){try{await a.note.remove(),await K.refresh(),await R(ne(`/notes`),{replaceState:!0})}catch(e){f(d,e.message,!0),f(h,null)}}var k=Te(),j=A(k),M=g(A(j));x(M),S(j);var F=g(j,2),I=g(A(F));x(I),S(F);var L=g(F,2),z=g(A(L));x(z),S(L);var B=g(L,2),re=e=>{var t=Se(),n=g(o(t),2),s=A(n);ge(s,{id:`note-folder`,quiet:!0,label:`folder: change it to move the note`,placeholder:`the top of the base`,onpick:e=>void T(e,y(a.note.id)),onkeydown:e=>{e.key===`Escape`&&(f(w,v(a.note.id)),e.currentTarget.blur())},get value(){return c(w)},set value(e){f(w,e)}}),S(n);var l=g(n,2),u=g(A(l));x(u),S(l);var d=g(l,2),p=e=>{var t=xe();r(`click`,t,()=>void ee()),E(e,t)};m(d,e=>{c(h)===null&&e(p)}),i((e,t)=>{O(u,e),C(u,`size`,t)},[()=>y(a.note.id),()=>Math.max(8,y(a.note.id).length)]),r(`change`,u,e=>void T(c(w),e.currentTarget.value)),r(`keydown`,u,e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(e.currentTarget.value=y(a.note.id),e.currentTarget.blur())}),E(e,t)};m(B,e=>{c(l)&&e(re)});var V=g(B,2),ie=e=>{var t=X(),a=A(t),o=g(A(a)),s=e=>{var t=u();i(e=>n(t,`${c(h).length===1?`One note links`:`${c(h).length} notes link`} to it (${e??``}); ${c(h).length===1?`its link is`:`their links are`} left broken.`),[()=>c(h).join(`, `)]),E(e,t)},l=e=>{var t=u(`No note links to it.`);E(e,t)};m(o,e=>{c(h).length?e(s):e(l,-1)}),P(),S(a);var d=g(a,2),p=g(d,2);S(t),r(`click`,d,()=>void te()),r(`click`,p,()=>{f(h,null)}),E(e,t)};m(V,e=>{c(h)!==null&&e(ie)});var H=g(V,2),ae=e=>{var t=Ce(),r=_(t,!0);i(()=>n(r,c(d))),E(e,t)};m(H,e=>{c(d)&&e(ae)});var U=g(H,2);p(U,20,()=>c(s),e=>e,(e,t)=>{var n=we(),r={};i(()=>{r!==(r=t)&&(n.value=(n.__value=r)??``)}),E(e,n)}),S(U),S(k),i(e=>{O(M,a.note.fields.type),C(M,`size`,e),O(I,a.note.fields.tags),O(z,a.note.fields.description)},[()=>Math.max(7,a.note.fields.type.length)]),r(`input`,M,e=>a.note.setFields({type:e.currentTarget.value})),r(`change`,I,e=>a.note.setFields({tags:e.currentTarget.value})),r(`input`,z,e=>a.note.setFields({description:e.currentTarget.value})),E(t,k),b()}d([`input`,`change`,`keydown`,`click`]);var De=T(`<h1 class="serif title svelte-130pv1o"> </h1>`),Oe=T(`<p class="asked svelte-130pv1o"><i class="dia svelte-130pv1o" aria-hidden="true"></i><span> </span></p>`),ke=T(`<div class="offered svelte-130pv1o" aria-label="What Iso offered"><p class="serif svelte-130pv1o"> </p></div>`),Ae=T(`<div class="version svelte-130pv1o"><!> <!> <div class="text svelte-130pv1o"></div> <!></div>`);function je(t,r){D(r,!0);let a=N(()=>{try{let[e,t,n]=z(r.text);return{title:/^title:\s*(.*)$/m.exec(t??``)?.[1]?.trim().replace(/^["']|["']$/g,``)??``,body:n,lines:e.split(`
1
+ import{$ as e,A as t,D as n,F as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,P as d,Q as f,S as p,T as m,U as h,X as g,Y as _,Z as v,_ as y,at as b,d as x,dt as S,f as C,h as w,j as T,k as E,m as ee,n as te,ot as D,p as O,pt as k,q as A,rt as j,s as M,tt as N,ut as P,w as F,x as I,z as L}from"../chunks/nMarIA7J.js";import{o as ne,t as R}from"../chunks/DtPULAe0.js";import"../chunks/xihTtKlq.js";import{A as z,E as B,M as re,N as V,P as ie,T as H,h as ae,i as U,j as oe,m as se,t as W,w as ce,x as le}from"../chunks/D3BEa5-_.js";import{i as ue,n as de,r as fe,t as pe}from"../chunks/CMTjeXEe.js";import{i as G,r as me,t as K}from"../chunks/CurmVJyp.js";import{i as q}from"../chunks/BAkGB2fM.js";import{t as he}from"../chunks/DsIcKd8x.js";import{t as ge}from"../chunks/D29fKEzc.js";import{a as _e,i as J,n as Y,o as ve,r as ye,t as be}from"../chunks/B2TCcw-P.js";var xe=T(`<button class="link svelte-1khbtcu" type="button">delete</button>`),Se=T(`<label class="wide svelte-1khbtcu" for="note-folder"><span>folder</span></label> <span class="wide svelte-1khbtcu"><!></span> <label class="svelte-1khbtcu"><span>name</span><input class="mono svelte-1khbtcu" spellcheck="false" autocomplete="off" aria-label="name: change it to rename the file"/></label> <!>`,1),X=T(`<div class="full ask svelte-1khbtcu" role="alertdialog" aria-label="delete this note"><span class="svelte-1khbtcu">Delete this note? <!> Its history stays.</span> <button class="btn danger svelte-1khbtcu" type="button">delete</button> <button class="btn quiet svelte-1khbtcu" type="button">keep it</button></div>`),Ce=T(`<p class="full problem svelte-1khbtcu" role="alert"> </p>`),we=T(`<option></option>`),Te=T(`<div class="details svelte-1khbtcu"><label class="svelte-1khbtcu"><span>type</span><input list="types" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="wide svelte-1khbtcu"><span>tags</span><input placeholder="none" autocomplete="off" class="svelte-1khbtcu"/></label> <label class="full svelte-1khbtcu"><span>description</span><input placeholder="one line on what this note says" autocomplete="off" class="svelte-1khbtcu"/></label> <!> <!> <!> <datalist id="types"></datalist></div>`);function Ee(t,a){D(a,!0);let s=N(()=>[...new Set(K.listing.notes.map(e=>e.type).filter(Boolean))].sort()),l=N(()=>!a.note.id.startsWith(`@`)),d=e(``),h=e(null),v=e=>e.split(`/`).slice(0,-1).join(`/`),y=e=>e.split(`/`).at(-1),w=N(()=>v(a.note.id));async function T(e,t){let n=e=>e.trim().replace(/^\/+|\/+$/g,``).replace(/\.md$/,``),r=[n(e),n(t)].filter(Boolean).join(`/`);if(!n(t)||r===a.note.id)f(w,v(a.note.id));else{f(d,``);try{let e=await a.note.move(r);await K.refresh(),await R(me(e),{replaceState:!0})}catch(e){f(d,e.message,!0),f(w,v(a.note.id))}}}async function ee(){f(d,``);try{let e=await K.api.map();f(h,[...new Set(e.model.edges.filter(([e,t])=>t===a.note.id&&e!==a.note.id&&!e.startsWith(`@`)).map(([t])=>e.notes[t]?.title||t))],!0)}catch(e){f(d,e.message,!0)}}async function te(){try{await a.note.remove(),await K.refresh(),await R(ne(`/notes`),{replaceState:!0})}catch(e){f(d,e.message,!0),f(h,null)}}var k=Te(),j=A(k),M=g(A(j));x(M),S(j);var F=g(j,2),I=g(A(F));x(I),S(F);var L=g(F,2),z=g(A(L));x(z),S(L);var B=g(L,2),re=e=>{var t=Se(),n=g(o(t),2),s=A(n);ge(s,{id:`note-folder`,quiet:!0,label:`folder: change it to move the note`,placeholder:`the top of the base`,onpick:e=>void T(e,y(a.note.id)),onkeydown:e=>{e.key===`Escape`&&(f(w,v(a.note.id)),e.currentTarget.blur())},get value(){return c(w)},set value(e){f(w,e)}}),S(n);var l=g(n,2),u=g(A(l));x(u),S(l);var d=g(l,2),p=e=>{var t=xe();r(`click`,t,()=>void ee()),E(e,t)};m(d,e=>{c(h)===null&&e(p)}),i((e,t)=>{O(u,e),C(u,`size`,t)},[()=>y(a.note.id),()=>Math.max(8,y(a.note.id).length)]),r(`change`,u,e=>void T(c(w),e.currentTarget.value)),r(`keydown`,u,e=>{e.key===`Enter`?e.currentTarget.blur():e.key===`Escape`&&(e.currentTarget.value=y(a.note.id),e.currentTarget.blur())}),E(e,t)};m(B,e=>{c(l)&&e(re)});var V=g(B,2),ie=e=>{var t=X(),a=A(t),o=g(A(a)),s=e=>{var t=u();i(e=>n(t,`${c(h).length===1?`One note links`:`${c(h).length} notes link`} to it (${e??``}); ${c(h).length===1?`its link is`:`their links are`} left broken.`),[()=>c(h).join(`, `)]),E(e,t)},l=e=>{var t=u(`No note links to it.`);E(e,t)};m(o,e=>{c(h).length?e(s):e(l,-1)}),P(),S(a);var d=g(a,2),p=g(d,2);S(t),r(`click`,d,()=>void te()),r(`click`,p,()=>{f(h,null)}),E(e,t)};m(V,e=>{c(h)!==null&&e(ie)});var H=g(V,2),ae=e=>{var t=Ce(),r=_(t,!0);i(()=>n(r,c(d))),E(e,t)};m(H,e=>{c(d)&&e(ae)});var U=g(H,2);p(U,20,()=>c(s),e=>e,(e,t)=>{var n=we(),r={};i(()=>{r!==(r=t)&&(n.value=(n.__value=r)??``)}),E(e,n)}),S(U),S(k),i(e=>{O(M,a.note.fields.type),C(M,`size`,e),O(I,a.note.fields.tags),O(z,a.note.fields.description)},[()=>Math.max(7,a.note.fields.type.length)]),r(`input`,M,e=>a.note.setFields({type:e.currentTarget.value})),r(`change`,I,e=>a.note.setFields({tags:e.currentTarget.value})),r(`input`,z,e=>a.note.setFields({description:e.currentTarget.value})),E(t,k),b()}d([`input`,`change`,`keydown`,`click`]);var De=T(`<h1 class="serif title svelte-130pv1o"> </h1>`),Oe=T(`<p class="asked svelte-130pv1o"><i class="dia svelte-130pv1o" aria-hidden="true"></i><span> </span></p>`),ke=T(`<div class="offered svelte-130pv1o" aria-label="What Iso offered"><p class="serif svelte-130pv1o"> </p></div>`),Ae=T(`<div class="version svelte-130pv1o"><!> <!> <div class="text svelte-130pv1o"></div> <!></div>`);function je(t,r){D(r,!0);let a=N(()=>{try{let[e,t,n]=z(r.text);return{title:/^title:\s*(.*)$/m.exec(t??``)?.[1]?.trim().replace(/^["']|["']$/g,``)??``,body:n,lines:e.split(`
2
2
  `).length-1}}catch{return{title:``,body:r.text,lines:0}}}),o,s=e(void 0);te(()=>(f(s,Y(o,{doc:c(a).body,onChange:()=>void 0,onSave:()=>void 0,label:`The note as it was`,notes:()=>[],readOnly:!0})),()=>c(s)?.destroy())),h(()=>{let e=r.touched,t=c(a).lines;c(s)?.dispatch({effects:J.of(e?{who:e.who,lines:e.lines.map(e=>e-t)}:null)})});var l=Ae(),u=A(l),d=e=>{var t=De(),r=_(t,!0);i(()=>n(r,c(a).title)),E(e,t)};m(u,e=>{c(a).title&&c(a).title!==r.title&&e(d)});var p=g(u,2),v=e=>{var t=Oe(),a=g(A(t)),o=_(a,!0);S(t),i(()=>n(o,r.asked)),E(e,t)};m(p,e=>{r.asked!==void 0&&e(v)});var y=g(p,2);M(y,e=>o=e,()=>o);var x=g(y,2),C=e=>{var t=ke(),a=A(t),o=_(a,!0);S(t),i(()=>n(o,r.offered)),E(e,t)};m(x,e=>{r.offered!==void 0&&e(C)}),S(l),E(t,l),b()}var Me=(e,t=k,n=k)=>{var r=Fe();let a;var o=A(r),s=e=>{var t=Ne();P(),E(e,t)},c=e=>{var t=Pe();i(()=>C(t,`fill`,n()?`currentColor`:`none`)),E(e,t)};m(o,e=>{t()===`question`?e(s):e(c,-1)}),S(r),i(()=>a=w(r,0,`glyph ${t()??``}`,`svelte-18ltlst`,a,{solved:n()})),E(e,r)},Ne=l(`<path d="M5.6 5.6a2.4 2.4 0 1 1 3.4 2.2c-.6.3-1 .8-1 1.5v.9"></path><path d="M8 12v1.2"></path>`,1),Pe=l(`<path d="M8 2.5l5.8 10.5H2.2z"></path>`),Fe=l(`<svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4"><!></svg>`),Ie=T(`<p class="faint">opening…</p>`),Le=T(`<p class="soft">There is no note at <span class="faint"> </span>.</p> <p><a>all notes</a></p>`,1),Re=T(`<p class="bad svelte-18ltlst"> </p>`),ze=T(`<button class="btn" type="button">take theirs</button>`),Be=T(`<div class="frame choice svelte-18ltlst" role="alert"><span class="frame-title">changed elsewhere</span> <p> </p> <div class="row svelte-18ltlst"><button class="btn primary" type="button">keep mine</button> <!></div> <p class="faint">Whichever you keep, the other stays in the note's journal.</p></div>`),Ve=T(`<button class="done-tg svelte-18ltlst" type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8.5l3 3 7-7"></path></svg></button>`),He=T(`<div class="titlerow svelte-18ltlst"><!> <label class="hidden-label" for="title">Title</label> <textarea id="title" class="serif title svelte-18ltlst" rows="1" autocomplete="off"></textarea> <!></div>`),Ue=T(`<span class="grow faint"> </span>`),We=T(`<button class="btn quiet svelte-18ltlst" type="button">details</button>`),Ge=T(` <a class="svelte-18ltlst"> </a>`,1),Ke=T(`<p class="about svelte-18ltlst"></p>`),qe=T(`<div class="tl-col svelte-18ltlst"><!></div>`),Je=T(`<span class="bad svelte-18ltlst" role="alert"> </span>`),Ye=T(`<div class="atbar svelte-18ltlst" role="status"><span class="label"> </span> <span class="grow"></span> <!> <button class="icon svelte-18ltlst" type="button" aria-label="restore to here" title="restore to here"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M3.2 9.5A5 5 0 1 0 4.6 4.3" stroke="currentColor" stroke-width="1.3" fill="none"></path><path d="M3 1.8v3.4h3.4" stroke="currentColor" stroke-width="1.3" fill="none"></path></svg></button> <button class="icon svelte-18ltlst" type="button" aria-label="back to now" title="back to now"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M2 8h9M8 4.8 11.2 8 8 11.2" stroke="currentColor" stroke-width="1.3" fill="none"></path><path d="M13.5 3v10" stroke="currentColor" stroke-width="1.3"></path></svg></button></div> <!>`,1),Xe=T(`<button class="toiso svelte-18ltlst" type="button"><i class="dia svelte-18ltlst" aria-hidden="true">◆</i>send to Iso</button>`),Ze=l(`<svg class="ok svelte-18ltlst" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8.5l3 3 7-7"></path></svg>`),Qe=T(`<li><a><!><span class="svelte-18ltlst"> </span><!></a></li>`),$e=T(`<ul class="attached svelte-18ltlst"></ul>`),et=T(`<div class="changes svelte-18ltlst" role="status"><i class="dia svelte-18ltlst" aria-hidden="true"></i> <span class="soft"> </span> <span class="grow"></span> <button class="link svelte-18ltlst" type="button">keep all</button> <button class="link svelte-18ltlst" type="button">remove all</button></div>`),tt=T(`<!> <div class="head svelte-18ltlst"><!> <div class="side svelte-18ltlst"><div class="tools svelte-18ltlst"><!> <button class="btn quiet svelte-18ltlst" type="button">source</button></div></div></div> <!> <!> <!> <!> <!> <div class="live"><!></div> <!> <!>`,1),nt=T(`<article><!></article>`);function rt(t,l){D(l,!0);let u=new _e(l.id),d=new ve(u),y=e=>{try{return localStorage.getItem(e)===`1`}catch{return!1}},x=(e,t)=>{try{localStorage.setItem(e,t?`1`:`0`)}catch{}},T=e(v(y(`isorite.details`))),k=e(!1),I=N(()=>c(k)||u.meta===null),z=N(()=>q.on.timeline),U=e(null),W=e(null),ge=e(!1),J=e(``),Y=N(()=>le(d.entries)),ye=e=>e.who.startsWith(`iso:`)||e.who.startsWith(`agent:`),xe=e=>e.flatMap(e=>Array.from({length:e.to-e.from},(t,n)=>e.from+n)),Se=N(()=>{if(!c(z)||c(W)||c(I))return null;let e=c(U)??(c(Te)?void 0:c(Y).findLast(e=>ye(e)&&(e.what===`kept`||e.what===`edited`)));if(!e)return null;let t=xe(H(d.entries,e.ids).runs);return t.length?{who:ye(e)?`iso`:`you`,lines:t}:null}),X=N(()=>{if(!c(W))return null;let e=ue(c(W)),t=ce(d.entries,e);if(t===null)return null;let n=d.entries.filter(t=>t.id<=e),r=d.entries.find(e=>e.id===c(W).ids[0]),i=(c(W).what===`offered`||c(W).what===`discarded`)&&r?.kind===`proposal`?r.form===`insert`?r.text:r.regions.map(e=>e.new).join(`
3
3
 
4
4
  `):void 0;return{text:t,touched:{who:ye(c(W))?`iso`:`you`,lines:xe(H(n,c(W).ids).runs)},asked:c(W).asked,offered:i}}),Ce=()=>he.url.searchParams.get(`at`)??new URLSearchParams(location.hash.split(`?`)[1]??``).get(`at`),we=e(v(Ce()));h(()=>{let e=Ce();e&&f(we,e,!0)}),h(()=>{if(!c(we))return;let e=c(Y).find(e=>e.ids.includes(c(we)));e&&(f(we,null),q.flip(`timeline`,!0),f(W,e))});let Te=N(()=>q.on.provenance);h(()=>{c(z)||(f(W,null),f(U,null))});let De=N(()=>{if(!c(Te)||u.loaded!==`ready`)return[];let e=[],t=B(d.entries),n=u.text.split(`
@@ -0,0 +1 @@
1
+ import"../chunks/nMarIA7J.js";import"../chunks/xihTtKlq.js";import{t as e}from"../chunks/DPnfDiTn.js";import"../chunks/D_19S_Iu.js";function t(t){e(t,{})}export{t as component};
@@ -1 +1 @@
1
- {"version":"1793005904466"}
1
+ {"version":"1793066465938"}
package/web/index.html CHANGED
@@ -36,42 +36,42 @@
36
36
  history.replaceState(history.state, "", location.pathname.slice(0, -1) + location.search + location.hash);
37
37
  }
38
38
  </script>
39
- <link href="/_app/immutable/entry/start.mjqIl2PI.js" rel="modulepreload">
40
- <link href="/_app/immutable/chunks/BNjH_DUx.js" rel="modulepreload">
39
+ <link href="/_app/immutable/entry/start.CEx_UQO6.js" rel="modulepreload">
40
+ <link href="/_app/immutable/chunks/DtPULAe0.js" rel="modulepreload">
41
41
  <link href="/_app/immutable/chunks/nMarIA7J.js" rel="modulepreload">
42
- <link href="/_app/immutable/entry/app.Dt52eXt2.js" rel="modulepreload">
42
+ <link href="/_app/immutable/entry/app.idRgnoYp.js" rel="modulepreload">
43
43
  <link href="/_app/immutable/chunks/CRzLMJPS.js" rel="modulepreload">
44
44
  <link href="/_app/immutable/chunks/xihTtKlq.js" rel="modulepreload">
45
- <link href="/_app/immutable/nodes/0.DIhIOwuo.js" rel="modulepreload">
46
- <link href="/_app/immutable/chunks/62dhNtvj.js" rel="modulepreload">
47
- <link href="/_app/immutable/chunks/DkvLWnSd.js" rel="modulepreload">
48
- <link href="/_app/immutable/chunks/B3dCo0od.js" rel="modulepreload">
45
+ <link href="/_app/immutable/nodes/0.BUd_gY_8.js" rel="modulepreload">
46
+ <link href="/_app/immutable/chunks/D3BEa5-_.js" rel="modulepreload">
47
+ <link href="/_app/immutable/chunks/CurmVJyp.js" rel="modulepreload">
48
+ <link href="/_app/immutable/chunks/BAkGB2fM.js" rel="modulepreload">
49
49
  <link href="/_app/immutable/chunks/BxTFtVqu.js" rel="modulepreload">
50
50
  <link href="/_app/immutable/chunks/yxd8jSz3.js" rel="modulepreload">
51
- <link href="/_app/immutable/chunks/CVbgxz8Y.js" rel="modulepreload">
52
- <link href="/_app/immutable/chunks/DsBJWNWe.js" rel="modulepreload">
53
- <link href="/_app/immutable/chunks/CYNZ4aV_.js" rel="modulepreload">
54
- <link href="/_app/immutable/chunks/DHfKGggc.js" rel="modulepreload">
51
+ <link href="/_app/immutable/chunks/CMTjeXEe.js" rel="modulepreload">
52
+ <link href="/_app/immutable/chunks/DsIcKd8x.js" rel="modulepreload">
53
+ <link href="/_app/immutable/chunks/DPnfDiTn.js" rel="modulepreload">
54
+ <link href="/_app/immutable/chunks/D29fKEzc.js" rel="modulepreload">
55
55
  <link href="/_app/immutable/chunks/DZYaqCwi.js" rel="modulepreload">
56
56
 
57
57
  <link href="/_app/immutable/assets/Timeline.KTc3LKuK.css" rel="stylesheet">
58
58
  <link href="/_app/immutable/assets/FolderField._A4_sc1Z.css" rel="stylesheet">
59
59
  <link href="/_app/immutable/assets/NoteList.F579Zvj_.css" rel="stylesheet">
60
- <link href="/_app/immutable/assets/0.BKnIhFWM.css" rel="stylesheet">
60
+ <link href="/_app/immutable/assets/0.CTbO0owi.css" rel="stylesheet">
61
61
  </head>
62
62
  <body>
63
63
  <div style="display: contents">
64
64
  <script>
65
65
  {
66
- __sveltekit_101t0vp = {
66
+ __sveltekit_jizr8c = {
67
67
  base: new URL('.', location).pathname.slice(0, -1)
68
68
  };
69
69
 
70
70
  const element = document.currentScript.parentElement;
71
71
 
72
72
  Promise.all([
73
- import("/_app/immutable/entry/start.mjqIl2PI.js"),
74
- import("/_app/immutable/entry/app.Dt52eXt2.js")
73
+ import("/_app/immutable/entry/start.CEx_UQO6.js"),
74
+ import("/_app/immutable/entry/app.idRgnoYp.js")
75
75
  ]).then(([kit, app]) => {
76
76
  kit.start(app, element);
77
77
  });
@@ -1 +0,0 @@
1
- import{$ as e,L as t,Q as n,Z as r}from"./nMarIA7J.js";import{o as i,t as a}from"./BNjH_DUx.js";import{r as o}from"./DkvLWnSd.js";var s=(e,t)=>{try{return localStorage.getItem(e)??t}catch{return t}},c=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},l=(e,t)=>{try{return{...t,...JSON.parse(s(e,`{}`))}}catch{return t}},u=[`note`,`atlas`,`iso`],d=[`cols`,`stack`,`one`],f={note:[`provenance`,`timeline`],atlas:[`questions`,`problems`,`web`,`code`,`context`],iso:[`notes`,`files`,`run`]},p={provenance:!1,timeline:!1,questions:!0,problems:!0,web:!1,code:!1,context:!1,notes:!1,files:!1,run:!1},m={note:1.25,atlas:1,iso:1.05},h={min:.4,max:3},g=new class{#e=e(r(d.includes(s(`isorite.layout`,``))?s(`isorite.layout`,``):`cols`));get layout(){return t(this.#e)}set layout(e){n(this.#e,e,!0)}#t=e(r(l(`isorite.show`,{note:!0,atlas:!0,iso:!0})));get show(){return t(this.#t)}set show(e){n(this.#t,e,!0)}#n=e(r(l(`isorite.widths`,m)));get widths(){return t(this.#n)}set widths(e){n(this.#n,e,!0)}#r=e(r(l(`isorite.switches`,p)));get on(){return t(this.#r)}set on(e){n(this.#r,e,!0)}#i=e(s(`isorite.understanding`,``)===`1`);get understanding(){return t(this.#i)}set understanding(e){n(this.#i,e,!0)}#a=e(`note`);get focus(){return t(this.#a)}set focus(e){n(this.#a,e,!0)}#o=e(!1);get narrow(){return t(this.#o)}set narrow(e){n(this.#o,e,!0)}#s=e(0);get unseen(){return t(this.#s)}set unseen(e){n(this.#s,e,!0)}#c=e(!1);get tree(){return t(this.#c)}set tree(e){n(this.#c,e,!0)}#l=e(``);get fresh(){return t(this.#l)}set fresh(e){n(this.#l,e,!0)}#u=e(null);get settings(){return t(this.#u)}set settings(e){n(this.#u,e,!0)}#d=e(r(s(`isorite.last`,``)));get last(){return t(this.#d)}set last(e){n(this.#d,e,!0)}get standing(){if(this.narrow)return[...u];let e=u.filter(e=>this.show[e]);return this.layout===`one`?[e.includes(this.focus)?this.focus:e[0]??`note`]:e}setLayout(e){this.layout=e,c(`isorite.layout`,e)}nextLayout(){this.setLayout(d[(d.indexOf(this.layout)+1)%d.length])}toggle(e){this.show[e]&&u.filter(e=>this.show[e]).length===1||(this.show[e]=!this.show[e],c(`isorite.show`,JSON.stringify(this.show)),!this.show[e]&&this.focus===e&&(this.focus=u.find(e=>this.show[e])))}setWidth(e,t){this.widths[e]=Math.min(h.max,Math.max(h.min,t)),c(`isorite.widths`,JSON.stringify(this.widths))}to(e){!this.narrow&&!this.show[e]&&this.toggle(e),this.focus=e,e===`iso`&&(this.unseen=0),this.scroll?.(e)}scroll=null;step(e){let t=this.narrow?[...u]:u.filter(e=>this.show[e]),n=t.indexOf(this.focus);this.to(t[(n+e+t.length)%t.length])}flip(e,t=!this.on[e]){this.on[e]=t,c(`isorite.switches`,JSON.stringify(this.on)),(e===`notes`||e===`files`||e===`run`)&&this.onMode?.()}showUnderstanding(e=!this.understanding){this.understanding=e,c(`isorite.understanding`,e?`1`:``),this.onMode?.()}busy(e){let t=typeof document>`u`?null:document.activeElement;return!!t&&!!t.closest(`[data-pane="${e}"]`)&&(t.matches(`input, textarea, [contenteditable=true]`)||!!t.closest(`.cm-editor`))}#f=e(!1);get terminal(){return t(this.#f)}set terminal(e){n(this.#f,e,!0)}setTerminal(e){this.terminal=e}get mode(){return this.terminal&&(this.on.files||this.on.run)?`build`:this.on.notes?`write`:`ask`}onMode=null;setLast(e){e&&!e.startsWith(`@`)&&(this.last=e,c(`isorite.last`,e))}async open(e,t=this.narrow){await a(o(e)),t&&this.to(`note`)}async home(){await a(i(`/notes`))}};export{g as i,u as n,f as r,d as t};
@@ -1 +0,0 @@
1
- import{$ as e,L as t,Q as n,R as r,a as i,n as a,t as o,z as s}from"./nMarIA7J.js";var c=class{constructor(e,t){this.status=e,this.body=typeof t==`string`?{message:t}:t||{message:`Error: ${e}`}}toString(){return JSON.stringify(this.body)}},l=class{constructor(e,t){try{new Headers({location:t})}catch{throw Error(`Invalid redirect location ${JSON.stringify(t)}: this string contains characters that cannot be used in HTTP headers`)}this.status=e,this.location=t}},u=class extends Error{constructor(e,t,n){super(n),this.status=e,this.text=t}};new URL(`sveltekit-internal://`);function d(e,t){return e===`/`||t===`ignore`?e:t===`never`?e.endsWith(`/`)?e.slice(0,-1):e:t===`always`&&!e.endsWith(`/`)?e+`/`:e}function f(e){return e.split(`%25`).map(decodeURI).join(`%25`)}function p(e){for(let t in e)e[t]=decodeURIComponent(e[t]);return e}function m({href:e}){return e.split(`#`)[0]}function ee(e,t,n,r=!1){let i=new URL(e);Object.defineProperty(i,"searchParams",{value:new Proxy(i.searchParams,{get(e,r){if(r===`get`||r===`getAll`||r===`has`)return(t,...i)=>(n(t),e[r](t,...i));t();let i=Reflect.get(e,r);return typeof i==`function`?i.bind(e):i}}),enumerable:!0,configurable:!0});let a=[`href`,`pathname`,`search`,`toString`,`toJSON`];r&&a.push(`hash`);for(let n of a)Object.defineProperty(i,n,{get(){return t(),e[n]},enumerable:!0,configurable:!0});return i}function h(){}function g(...e){let t=5381;for(let n of e)if(typeof n==`string`){let e=n.length;for(;e;)t=t*33^n.charCodeAt(--e)}else if(ArrayBuffer.isView(n)){let e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r=e.length;for(;r;)t=t*33^e[--r]}else throw TypeError(`value must be a string or TypedArray`);return(t>>>0).toString(36)}new TextEncoder;function _(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var te=window.fetch;window.fetch=(e,t)=>((e instanceof Request?e.method:t?.method||`GET`)!==`GET`&&v.delete(b(e)),te(e,t));var v=new Map;function y(e,t){let n=b(e,t),r=document.querySelector(n);if(r?.textContent){r.remove();let{body:e,...t}=JSON.parse(r.textContent);r.getAttribute(`data-b64`)!==null&&(e=_(e));let i=r.getAttribute(`data-ttl`);return i&&v.set(n,{body:e,init:t,ttl:1e3*Number(i)}),Promise.resolve(new Response(e,t))}return window.fetch(e,t)}function ne(e,t,n){if(v.size>0){let t=b(e,n),r=v.get(t);if(r){if(performance.now()<r.ttl&&[`default`,`force-cache`,`only-if-cached`,void 0].includes(n?.cache))return new Response(r.body,r.init);v.delete(t)}}return window.fetch(t,n)}function b(e,t){let n=`script[data-sveltekit-fetched][data-url=${JSON.stringify(e instanceof Request?e.url:e)}]`;if(t?.headers||t?.body){let e=[];t.headers&&e.push([...new Headers(t.headers)].join(`,`)),t.body&&(typeof t.body==`string`||ArrayBuffer.isView(t.body))&&e.push(t.body),n+=`[data-hash="${g(...e)}"]`}return n}var re=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/,ie=/^\/\((?:[^)]+)\)$/;function ae(e){let t=[];return{pattern:e===`/`||ie.test(e)?/^\/$/:RegExp(`^${se(e).map(e=>{let n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(e);if(n)return t.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),`(?:/([^]*))?`;let r=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(e);if(r)return t.push({name:r[1],matcher:r[2],optional:!0,rest:!1,chained:!0}),`(?:/([^/]+))?`;if(!e)return;let i=e.split(/\[(.+?)\](?!\])/);return`/`+i.map((e,n)=>{if(n%2){if(e.startsWith(`x+`))return le(String.fromCharCode(parseInt(e.slice(2),16)));if(e.startsWith(`u+`))return le(String.fromCharCode(...e.slice(2).split(`-`).map(e=>parseInt(e,16))));let[,r,a,o,s]=re.exec(e);return t.push({name:o,matcher:s,optional:!!r,rest:!!a,chained:a?n===1&&i[0]===``:!1}),a?`([^]*?)`:r?`([^/]*)?`:`([^/]+?)`}return le(e)}).join(``)}).join(``)}/?$`),params:t}}function oe(e){return e!==``&&!/^\([^)]+\)$/.test(e)}function se(e){return e.slice(1).split(`/`).filter(oe)}function ce(e,t,n){let r={},i=e.slice(1),a=i.filter(e=>e!==void 0),o=0;for(let e=0;e<t.length;e+=1){let s=t[e],c=i[e-o];if(s.chained&&s.rest&&o&&(c=i.slice(e-o,e+1).filter(e=>e).join(`/`),o=0),c===void 0){if(s.rest)c=``;else continue}if(!s.matcher||n[s.matcher](c)){r[s.name]=c;let n=t[e+1],l=i[e+1];n&&!n.rest&&n.optional&&l&&s.chained&&(o=0),!n&&!l&&Object.keys(r).length===a.length&&(o=0)}else if(s.optional&&s.chained)o++;else return}if(!o)return r}function le(e){return e.normalize().replace(/[[\]]/g,`\\$&`).replace(/%/g,`%25`).replace(/\//g,`%2[Ff]`).replace(/\?/g,`%3[Ff]`).replace(/#/g,`%23`).replace(/[.*+?^${}()|\\]/g,`\\$&`)}var ue=/\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;function de(e,t){let n=se(e),r=e!=`/`&&e.endsWith(`/`);return`/`+n.map(n=>n.replace(ue,(n,r,i,a)=>{let o=t[a];if(!o){if(r||i&&o!==void 0)return``;throw Error(`Missing parameter '${a}' in route ${e}`)}if(o.startsWith(`/`)||o.endsWith(`/`))throw Error(`Parameter '${a}' in route ${e} cannot start or end with a slash -- this would cause an invalid route like foo//bar`);return o})).filter(Boolean).join(`/`)+(r?`/`:``)}function fe({nodes:e,server_loads:t,dictionary:n,matchers:r}){let i=new Set(t);return Object.entries(n).map(([t,[n,i,s]])=>{let{pattern:c,params:l}=ae(t),u={id:t,exec:e=>{let t=c.exec(e);if(t)return ce(t,l,r)},errors:[1,...s||[]].map(t=>e[t]),layouts:[0,...i||[]].map(o),leaf:a(n)};return u.errors.length=u.layouts.length=Math.max(u.errors.length,u.layouts.length),u});function a(t){let n=t<0;return n&&(t=~t),[n,e[t]]}function o(t){return t===void 0?t:[i.has(t),e[t]]}}function pe(e,t=JSON.parse){try{return t(sessionStorage[e])}catch{}}function me(e,t,n=JSON.stringify){let r=n(t);try{sessionStorage[e]=r}catch{}}var x=globalThis.__sveltekit_101t0vp?.base??``,he=globalThis.__sveltekit_101t0vp?.assets??x??``,ge=`#`;function _e(...e){if(!e[0].startsWith(`/`))throw Error(`Cannot use \`resolve(...)\` with a non-absolute pathname or route ID (got "${e[0]}"). \`resolve\` is only for internal pathnames and route IDs; external URLs should be used directly.`);return x+ge+de(e[0],e[1])}var ve=`1793005904466`,ye=`sveltekit:snapshot`,be=`sveltekit:scroll`,xe=`sveltekit:states`,S=`sveltekit:history`,C=`sveltekit:navigation`,w={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},Se=location.origin;function Ce(e){if(e instanceof URL)return e;let t=document.baseURI;if(!t){let e=document.getElementsByTagName(`base`);t=e.length?e[0].href:document.URL}return new URL(e,t)}function T(){return{x:pageXOffset,y:pageYOffset}}function E(e,t){return e.getAttribute(`data-sveltekit-${t}`)}var we={...w,"":w.hover};function Te(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11&&(t=t.host),t}function Ee(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()===`A`&&e.hasAttribute(`href`))return e;e=Te(e)}}function De(e,t,n){let r;try{if(r=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){let e=location.hash.split(`#`)[1]||`/`;r.hash=`#${e}${r.hash}`}}catch{}let i=e instanceof SVGAElement?e.target.baseVal:e.target,a=!r||!!i||D(r,t,n)||(e.getAttribute(`rel`)||``).split(/\s+/).includes(`external`),o=r?.origin===Se&&e.hasAttribute(`download`);return{url:r,external:a,target:i,download:o}}function Oe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=e;for(;s&&s!==document.documentElement;)r===null&&(r=E(s,`preload-code`)),i===null&&(i=E(s,`preload-data`)),t===null&&(t=E(s,`keepfocus`)),n===null&&(n=E(s,`noscroll`)),a===null&&(a=E(s,`reload`)),o===null&&(o=E(s,`replacestate`)),s=Te(s);function c(e){switch(e){case``:case`true`:return!0;case`off`:case`false`:return!1;default:return}}return{preload_code:we[r??`off`],preload_data:we[i??`off`],keepfocus:c(t),noscroll:c(n),reload:c(a),replace_state:c(o)}}function ke(e){let t=i(e),n=!0;function r(){n=!0,t.update(e=>e)}function a(e){n=!1,t.set(e)}function o(e){let r;return t.subscribe(t=>{(r===void 0||n&&t!==r)&&e(r=t)})}return{notify:r,set:a,subscribe:o}}var Ae={v:h};function je(){let{set:e,subscribe:t}=i(!1),n;async function r(){clearTimeout(n);try{let t=await fetch(`${he}/_app/version.json`,{headers:{pragma:`no-cache`,"cache-control":`no-cache`}});if(!t.ok)return!1;let r=(await t.json()).version!==ve;return r&&(e(!0),Ae.v(),clearTimeout(n)),r}catch{return!1}}return{subscribe:t,check:r}}function D(e,t,n){return e.origin!==Se||!e.pathname.startsWith(t)?!0:n?e.pathname!==location.pathname:!1}function Me(e){}var Ne=new Set([`load`,`prerender`,`csr`,`ssr`,`trailingSlash`,`config`]);[...Ne],[...new Set([...Ne])];function Pe(e){return e.filter(e=>e!=null)}function O(e,t){return e+`/`+t}function Fe(e){return e instanceof c||e instanceof u?e.status:500}function Ie(e){return e instanceof u?e.text:`Internal Error`}var k,A,Le,Re=a.toString().includes(`$$`)||/function \w+\(\) \{\}/.test(a.toString()),ze=`a:`;Re?(k={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL(ze)},A={current:null},Le={current:!1}):(k=new class{#e=e({});get data(){return t(this.#e)}set data(e){n(this.#e,e)}#t=e(null);get form(){return t(this.#t)}set form(e){n(this.#t,e)}#n=e(null);get error(){return t(this.#n)}set error(e){n(this.#n,e)}#r=e({});get params(){return t(this.#r)}set params(e){n(this.#r,e)}#i=e({id:null});get route(){return t(this.#i)}set route(e){n(this.#i,e)}#a=e({});get state(){return t(this.#a)}set state(e){n(this.#a,e)}#o=e(-1);get status(){return t(this.#o)}set status(e){n(this.#o,e)}#s=e(new URL(ze));get url(){return t(this.#s)}set url(e){n(this.#s,e)}},A=new class{#e=e(null);get current(){return t(this.#e)}set current(e){n(this.#e,e)}},Le=new class{#e=e(!1);get current(){return t(this.#e)}set current(e){n(this.#e,e)}},Ae.v=()=>Le.current=!0);function Be(e){Object.assign(k,e)}var Ve={spanContext(){return He},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this},addLink(){return this},addLinks(){return this}},He={traceId:``,spanId:``,traceFlags:0},{onMount:Ue,tick:We}=o,Ge=new Set([`icon`,`shortcut icon`,`apple-touch-icon`]),j=null,M=pe(`sveltekit:scroll`)??{},N=pe(`sveltekit:snapshot`)??{},P={url:ke({}),page:ke({}),navigating:i(null),updated:je()};function Ke(e){M[e]=T()}function qe(e,t){let n=e+1;for(;M[n];)delete M[n],n+=1;for(n=t+1;N[n];)delete N[n],n+=1}function F(e,t=!1){return t?location.replace(e.href):location.href=e.href,new Promise(h)}async function Je(){if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistration(x||`/`);e&&await e.update()}}var Ye,Xe,I,L,Ze,R,Qe={},$e={},z=[],B=[],V=null;function H(){V?.fork?.then(e=>e?.discard()),V=null,Q={element:void 0,href:void 0}}var et=new Map,tt=new Set,nt=new Set,U=new Set,W={branch:[],error:null,url:null,nav:null},rt=!1,it=!1,at=!0,G=!1,K=!1,ot=!1,st=!1,ct,q,J,Y,lt=new Set,ut=new Map,dt=new Map;async function ft(e,t,n){if(globalThis.__sveltekit_101t0vp.data){let{q:e={},p:t={},l:n={},f:r={}}=globalThis.__sveltekit_101t0vp.data;for(let t in e)Qe[t]=e[t];for(let e in n)Qe[e]=n[e];for(let e in r)Qe[e]=r[e];for(let e in t)$e[e]=t[e]}document.URL!==location.href&&(location.href=location.href),R=e,await e.hooks.init?.(),Ye=fe(e),L=document.documentElement,Ze=t,Xe=e.nodes[0],I=e.nodes[1],Xe(),I(),q=history.state?.[S],J=history.state?.[C],q||(q=J=Date.now(),history.replaceState({...history.state,[S]:q,[C]:J},``));let r=M[q];function i(){r&&(history.scrollRestoration=`manual`,scrollTo(r.x,r.y))}n?(i(),await Bt(Ze,n)):(await Z({type:`enter`,url:Ce(R.hash?Kt(new URL(location.href)):location.href),replace_state:!0}),i()),zt()}function pt(){z.length=0,st=!1}function mt(e){B.some(e=>e?.snapshot)&&(N[e]=B.map(e=>e?.snapshot?.capture()))}function ht(e){N[e]?.forEach((e,t)=>{B[t]?.snapshot?.restore(e)})}function gt(){Ke(q),me(be,M),mt(J),me(ye,N)}async function _t(e,t,n,r){let i,a;t.invalidateAll&&H(),await Z({type:`goto`,url:Ce(e),keepfocus:t.keepFocus,noscroll:t.noScroll,replace_state:t.replaceState,state:t.state,redirect_count:n,nav_token:r,accept:()=>{if(t.invalidateAll){st=!0,i=new Set;for(let[e,t]of ut)for(let[n,r]of t)r.resource?.reset(),i.add(O(e,n));a=new Set;for(let[e,t]of dt)for(let n of t.keys())a.add(O(e,n))}t.invalidate&&t.invalidate.forEach(Rt)}}),t.invalidateAll&&s().then(s).then(()=>{for(let[e,t]of ut)for(let[n,{resource:r}]of t)i?.has(O(e,n))&&r.start();for(let[e,t]of dt)for(let[n,{resource:r}]of t)a?.has(O(e,n))&&r.reconnect()})}async function vt(e){if(e.id!==V?.id){H();let t={};lt.add(t),V={id:e.id,token:t,promise:Ot({...e,preload:t}).then(e=>(lt.delete(t),e.type===`loaded`&&e.state.error&&H(),e)),fork:null}}return V.promise}async function yt(e){let t=(await X(e,!1))?.route;t&&await Promise.all([...t.layouts,t.leaf].filter(Boolean).map(e=>e[1]()))}async function bt(e,t,n){let r={params:W.params,route:{id:W.route?.id??null},url:new URL(location.href)};if(W={...e.state,nav:r},Be(e.props.page),ct=new R.root({target:t,props:{...e.props,stores:P,components:B},hydrate:n,sync:!1,transformError:void 0}),await Promise.resolve(),n){let e={from:null,to:{...r,scroll:M[q]??T()},willUnload:!1,type:`enter`,complete:Promise.resolve()};U.forEach(t=>t(e))}ht(J),it=!0}async function xt({url:e,params:t,branch:n,errors:r,status:i,error:a,route:o,form:s}){let c=`never`;if(x&&(e.pathname===x||e.pathname===x+`/`))c=`always`;else for(let e of n)e?.slash!==void 0&&(c=e.slash);e.pathname=d(e.pathname,c),e.search=e.search;let l={type:`loaded`,state:{url:e,params:t,branch:n,error:a,route:o},props:{constructors:Pe(n).map(e=>e.node.component),page:Gt(k)}};s!==void 0&&(l.props.form=s);let u={},f=!k,p=0;for(let e=0;e<Math.max(n.length,W.branch.length);e+=1){let t=n[e],r=W.branch[e];t?.data!==r?.data&&(f=!0),t&&(u={...u,...t.data},f&&(l.props[`data_${p}`]=u),p+=1)}return(!W.url||e.href!==W.url.href||W.error!==a||s!==void 0&&s!==k.form||f)&&(l.props.page={error:a,params:t,route:{id:o?.id??null},state:{},status:i,url:new URL(e),form:s??null,data:f?u:k.data}),l}async function St({loader:e,parent:t,url:n,params:r,route:i,server_data_node:a}){let o=null,s=!0,c={dependencies:new Set,params:new Set,parent:!1,route:!1,url:!1,search_params:new Set},l=await e();if(l.universal?.load){function e(...e){for(let t of e){let{href:e}=new URL(t,n);c.dependencies.add(e)}}let u={tracing:{enabled:!1,root:Ve,current:Ve},route:new Proxy(i,{get:(e,t)=>(s&&(c.route=!0),e[t])}),params:new Proxy(r,{get:(e,t)=>(s&&c.params.add(t),e[t])}),data:a?.data??null,url:ee(n,()=>{s&&(c.url=!0)},e=>{s&&c.search_params.add(e)},R.hash),async fetch(t,r){t instanceof Request&&(r={body:t.method===`GET`||t.method===`HEAD`?void 0:await t.blob(),cache:t.cache,credentials:t.credentials,headers:[...t.headers].length>0?t?.headers:void 0,integrity:t.integrity,keepalive:t.keepalive,method:t.method,mode:t.mode,redirect:t.redirect,referrer:t.referrer,referrerPolicy:t.referrerPolicy,signal:t.signal,...r});let{resolved:i,promise:a}=Ct(t,r,n);return s&&e(i.href),a},setHeaders:h,depends:e,parent(){return s&&(c.parent=!0),t()},untrack(e){s=!1;try{return e()}finally{s=!0}}};o=await l.universal.load.call(null,u)??null}return{node:l,loader:e,server:a,universal:l.universal?.load?{type:`data`,data:o,uses:c}:null,data:o??a?.data??null,slash:l.universal?.trailingSlash??a?.slash}}function Ct(e,t,n){let r=e instanceof Request?e.url:e,i=new URL(r,n);return i.origin===n.origin&&(r=i.href.slice(n.origin.length)),{resolved:i,promise:it?ne(r,i.href,t):y(r,t)}}function wt(e,t,n,r,i,a){if(st)return!0;if(!i)return!1;if(i.parent&&e||i.route&&t||i.url&&n)return!0;for(let e of i.search_params)if(r.has(e))return!0;for(let e of i.params)if(a[e]!==W.params[e])return!0;for(let e of i.dependencies)if(z.some(t=>t(new URL(e))))return!0;return!1}function Tt(e,t){return e?.type===`data`?e:e?.type===`skip`?t??null:null}function Et(e,t){if(!e)return new Set(t.searchParams.keys());let n=new Set([...e.searchParams.keys(),...t.searchParams.keys()]);for(let r of n){let i=e.searchParams.getAll(r),a=t.searchParams.getAll(r);i.every(e=>a.includes(e))&&a.every(e=>i.includes(e))&&n.delete(r)}return n}function Dt({error:e,url:t,route:n,params:r}){return{type:`loaded`,state:{error:e,url:t,route:n,params:r,branch:[]},props:{page:Gt(k),constructors:[]}}}async function Ot({id:e,invalidating:t,url:n,params:r,route:i,preload:a}){if(V?.id===e)return lt.delete(V.token),V.promise;let{errors:o,layouts:s,leaf:u}=i,d=[...s,u];o.forEach(e=>e?.().catch(h)),d.forEach(e=>e?.[1]().catch(h));let f=W.url?e!==Nt(W.url):!1,p=W.route?i.id!==W.route.id:!1,m=Et(W.url,n),ee=!1,g=d.map(async(e,t)=>{if(!e)return;let a=W.branch[t];return e[1]===a?.loader&&!wt(ee,p,f,m,a.universal?.uses,r)?a:(ee=!0,St({loader:e[1],url:n,params:r,route:i,parent:async()=>{let e={};for(let n=0;n<t;n+=1)Object.assign(e,(await g[n])?.data);return e},server_data_node:Tt(e[0]?{type:`skip`}:null,e[0]?a?.server:void 0)}))});for(let e of g)e.catch(h);let _=[];for(let e=0;e<d.length;e+=1)if(d[e])try{_.push(await g[e])}catch(t){if(t instanceof l)return{type:`redirect`,location:t.location};if(a&&lt.has(a))return Dt({error:await $(t,{params:r,url:n,route:{id:i.id}}),url:n,params:r,route:i});let s=Fe(t),u;if(t instanceof c)u=t.body;else{if(await P.updated.check())return await Je(),await F(n);u=await $(t,{params:r,url:n,route:{id:i.id}})}let d=await kt(e,_,o);return d?xt({url:n,params:r,branch:_.slice(0,d.idx).concat(d.node),errors:o,status:s,error:u,route:i}):await Ft(n,{id:i.id},u,s)}else _.push(void 0);return xt({url:n,params:r,branch:_,errors:o,status:200,error:null,route:i,form:t?void 0:null})}async function kt(e,t,n){for(;e--;)if(n[e]){let r=e;for(;!t[r];)--r;try{return{idx:r+1,node:{node:await n[e](),loader:n[e],data:{},server:null,universal:null}}}catch{continue}}}async function At({status:e,error:t,url:n,route:r}){let i={};try{return xt({url:n,params:i,branch:[await St({loader:Xe,url:n,params:i,route:r,parent:()=>Promise.resolve({}),server_data_node:Tt(null)}),{node:await I(),loader:I,universal:null,server:null,data:null}],status:e,error:t,errors:[],route:null})}catch(t){if(t instanceof l){await _t(new URL(t.location,location.href),{},0);return}let a=await R.get_error_template(),o=await $(t,{url:n,params:i,route:r}),s=a({status:e,message:String(o?.message??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}),c=new DOMParser().parseFromString(s,`text/html`);throw document.documentElement.replaceChild(document.adoptNode(c.head),document.head),document.documentElement.replaceChild(document.adoptNode(c.body),document.body),t}}async function jt(e){let t=e.href;if(et.has(t))return et.get(t);let n;try{let r=(async()=>{let t=await R.hooks.reroute({url:new URL(e),fetch:async(t,n)=>Ct(t,n,e).promise})??e;if(typeof t==`string`){let n=new URL(e);R.hash?n.hash=t:n.pathname=t,t=n}return t})();et.set(t,r),n=await r}catch{et.delete(t);return}return n}async function X(e,t){if(e&&!D(e,x,R.hash)){let n=await jt(e);if(!n)return;let r=Mt(n);for(let n of Ye){let i=n.exec(r);if(i)return{id:Nt(e),invalidating:t,route:n,params:p(i),url:e}}}}function Mt(e){return f(R.hash?e.hash.replace(/^#/,``).replace(/[?#].+/,``):e.pathname.slice(x.length))||`/`}function Nt(e){return(R.hash?e.hash.replace(/^#/,``):e.pathname)+e.search}function Pt({url:e,type:t,intent:n,delta:r,event:i,scroll:a}){let o=!1,s=Wt(W,n,e,t,a??null);r!==void 0&&(s.navigation.delta=r),i!==void 0&&(s.navigation.event=i);let c={...s.navigation,cancel:()=>{o=!0,s.reject(Error(`navigation cancelled`))}};return G||tt.forEach(e=>e(c)),o?null:s}async function Z({type:e,url:t,popped:n,keepfocus:i,noscroll:a,replace_state:o,state:c={},redirect_count:l=0,nav_token:d={},accept:f=h,block:p=h,event:m}){let ee=Y;Y=d;let g=await X(t,!1),_=e===`enter`?Wt(W,g,t,e):Pt({url:t,type:e,delta:n?.delta,intent:g,scroll:n?.scroll,event:m});if(!_){p(),Y===d&&(Y=ee);return}let te=q,v=J;f(),G=!0,it&&_.navigation.type!==`enter`&&P.navigating.set(A.current=_.navigation);let y=g&&await Ot(g);if(!y){if(D(t,x,R.hash))return await F(t,o);y=await Ft(t,{id:null},await $(new u(404,`Not Found`,`Not found: ${t.pathname}`),{url:t,params:{},route:{id:null}}),404,o)}if(t=g?.url||t,Y!==d){_.reject(Error(`navigation aborted`));return}if(!y)return;if(y.type===`redirect`){if(l<20){await Z({type:e,url:new URL(y.location,t),popped:n,keepfocus:i,noscroll:a,replace_state:o,state:c,redirect_count:l+1,nav_token:d}),_.fulfil(void 0);return}if(y=await At({status:500,error:await $(Error(`Redirect loop`),{url:t,params:{},route:{id:null}}),url:t,route:{id:null}}),!y)return}else if(y.props.page.status>=400&&await P.updated.check())return await Je(),await F(t,o);if(pt(),Ke(te),mt(v),y.props.page.url.pathname!==t.pathname&&(t.pathname=y.props.page.url.pathname),c=n?n.state:c,!n){let e=+!o,n={[S]:q+=e,[C]:J+=e,[xe]:c};(o?history.replaceState:history.pushState).call(history,n,``,t),o||qe(q,J)}let ne=g&&V?.id===g.id?V.fork:null;V?.fork&&!ne?H():(V=null,Q={element:void 0,href:void 0}),y.props.page.state=c;let b;if(it){let e=(await Promise.all(Array.from(nt,e=>e(_.navigation)))).filter(e=>typeof e==`function`);if(e.length>0){function t(){e.forEach(e=>{U.delete(e)})}e.push(t),e.forEach(e=>{U.add(e)})}let n=_.navigation.to;W={...y.state,nav:{params:n.params,route:n.route,url:n.url}},y.props.page&&(y.props.page.url=t),!i&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur();let a=ne&&await ne;a?b=a.commit():(j=null,ct.$set(y.props),j&&Object.assign(y.props.page,j),Be(y.props.page),b=r?.()),ot=!0}else await bt(y,Ze,!1);let{activeElement:re}=document;if(await b,await s(),await s(),Y!==d){_.reject(Error(`navigation aborted`));return}y.props.page&&j&&Object.assign(y.props.page,j);let ie=null;if(at){let e=n?n.scroll:a?T():null;e?scrollTo(e.x,e.y):(ie=t.hash&&document.getElementById(qt(t)))?ie.scrollIntoView():scrollTo(0,0)}let ae=document.activeElement!==re&&document.activeElement!==document.body;!i&&!ae&&Ut(t,!ie),at=!0,G=!1,_.fulfil(void 0),_.navigation.to&&(_.navigation.to.scroll=T()),U.forEach(e=>e(_.navigation)),e===`popstate`&&ht(J),P.navigating.set(A.current=null)}async function Ft(e,t,n,r,i){return e.origin===Se&&e.pathname===location.pathname&&!rt?await At({status:r,error:n,url:e,route:t}):await F(e,i)}var Q={element:void 0,href:void 0};function It(){let e,t;L.addEventListener(`mousemove`,t=>{let n=t.target;clearTimeout(e),e=setTimeout(()=>{i(n,w.hover)},20)});function n(e){e.defaultPrevented||i(e.composedPath()[0],w.tap)}L.addEventListener(`mousedown`,n),L.addEventListener(`touchstart`,n,{passive:!0});let r=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(yt(new URL(t.target.href)),r.unobserve(t.target))},{threshold:0});async function i(e,n){let r=Ee(e,L),i=r===Q.element&&r?.href===Q.href&&n>=t;if(!r||i)return;let{url:a,external:o,download:s}=De(r,x,R.hash);if(o||s)return;let c=Oe(r),l=a&&Nt(W.url)===Nt(a);if(!(c.reload||l)){if(n<=c.preload_data){Q={element:r,href:r.href},t=w.tap;let e=await X(a,!1);if(!e)return;vt(e)}else n<=c.preload_code&&(Q={element:r,href:r.href},t=n,yt(a))}}function a(){r.disconnect();for(let e of L.querySelectorAll(`a`)){let{url:t,external:n,download:i}=De(e,x,R.hash);if(n||i)continue;let a=Oe(e);a.reload||(a.preload_code===w.viewport&&r.observe(e),a.preload_code===w.eager&&yt(t))}}U.add(a),a()}function $(e,t){if(e instanceof c)return e.body;let n=Fe(e),r=Ie(e);return R.hooks.handleError({error:e,event:t,status:n,message:r})??{message:r}}function Lt(e,t={}){return e=new URL(Ce(e)),e.origin===Se?_t(e,t,0):Promise.reject(Error(`goto: invalid URL`))}function Rt(e){if(typeof e==`function`)z.push(e);else{let{href:t}=new URL(e,location.href);z.push(e=>e.href===t)}}function zt(){history.scrollRestoration=`manual`,addEventListener(`beforeunload`,e=>{let t=!1;if(gt(),!G){let e=Wt(W,void 0,null,`leave`),n={...e.navigation,cancel:()=>{t=!0,e.reject(Error(`navigation cancelled`))}};tt.forEach(e=>e(n))}t?(e.preventDefault(),e.returnValue=``):history.scrollRestoration=`auto`}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&gt()}),navigator.connection?.saveData||It(),L.addEventListener(`click`,async t=>{if(t.button||t.which!==1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.defaultPrevented)return;let n=Ee(t.composedPath()[0],L);if(!n)return;let{url:r,external:i,target:a,download:o}=De(n,x,R.hash);if(!r)return;if(a===`_parent`||a===`_top`){if(window.parent!==window)return}else if(a&&a!==`_self`)return;let s=Oe(n);if(!(n instanceof SVGAElement)&&r.protocol!==location.protocol&&r.protocol!==`https:`&&r.protocol!==`http:`||o)return;let[c,l]=(R.hash?r.hash.replace(/^#/,``):r.href).split(`#`),u=c===m(location);if(i||s.reload&&(!u||!l))Pt({url:r,type:`link`,event:t})?G=!0:t.preventDefault();else{if(l!==void 0&&u){let[,i]=W.url.href.split(`#`);if(i===l){if(t.preventDefault(),l===``||l===`top`&&n.ownerDocument.getElementById(`top`)===null)scrollTo({top:0});else{let e=n.ownerDocument.getElementById(decodeURIComponent(l));e&&(e.scrollIntoView(),e.focus())}return}if(K=!0,Ke(q),e(r),!s.replace_state)return;K=!1}t.preventDefault(),await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,0)}),setTimeout(e,100)}),await Z({type:`link`,url:r,keepfocus:s.keepfocus,noscroll:s.noscroll,replace_state:s.replace_state??r.href===location.href,event:t})}}),L.addEventListener(`submit`,e=>{if(e.defaultPrevented)return;let t=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if((n?.formTarget||t.target)===`_blank`||(n?.formMethod||t.method)!==`get`)return;let r=new URL(n?.hasAttribute(`formaction`)&&n?.formAction||t.action);if(D(r,x,!1))return;let i=e.target,a=Oe(i);if(a.reload)return;e.preventDefault(),e.stopPropagation();let o=new FormData(i,n);r.search=new URLSearchParams(o).toString(),Z({type:`form`,url:r,keepfocus:a.keepfocus,noscroll:a.noscroll,replace_state:a.replace_state??r.href===location.href,event:e})}),addEventListener(`popstate`,async t=>{if(!Ht){if(t.state?.[`sveltekit:history`]){let n=t.state[S];if(Y={},n===q)return;let r=M[n],i=t.state[`sveltekit:states`]??{},a=new URL(t.state[`sveltekit:pageurl`]??location.href),o=t.state[C],s=W.url?m(location)===m(W.url):!1;if(o===J&&(ot||s)){i!==k.state&&(k.state=i),e(a),M[q]=T(),r&&scrollTo(r.x,r.y),q=n;return}let c=n-q;await Z({type:`popstate`,url:a,popped:{state:i,scroll:r,delta:c},accept:()=>{q=n,J=o},block:()=>{history.go(-c)},nav_token:Y,event:t})}else K||(e(new URL(location.href)),R.hash&&location.reload())}}),addEventListener(`hashchange`,()=>{K&&(K=!1,history.replaceState({...history.state,[S]:++q,[C]:J},``,location.href))});for(let e of document.querySelectorAll(`link`))Ge.has(e.rel)&&(e.href=e.href);addEventListener(`pageshow`,e=>{e.persisted&&P.navigating.set(A.current=null)});function e(e){W.url=k.url=e,P.page.set(Gt(k)),P.page.notify()}}async function Bt(e,{status:t=200,error:n,node_ids:r,params:i,route:a,server_route:o,data:s,form:c}){rt=!0;let u=new URL(location.href),d;({params:i={},route:a={id:null}}=await X(u,!1)||{}),d=Ye.find(({id:e})=>e===a.id);let f,p=!0;try{let e=r.map(async(t,n)=>{let r=s[n];return r?.uses&&(r.uses=Vt(r.uses)),St({loader:R.nodes[t],url:u,params:i,route:a,parent:async()=>{let t={};for(let r=0;r<n;r+=1)Object.assign(t,(await e[r]).data);return t},server_data_node:Tt(r)})}),o=await Promise.all(e);if(d){let e=d.layouts;for(let t=0;t<e.length;t++)e[t]||o.splice(t,0,void 0)}f=await xt({url:u,params:i,branch:o,status:t,error:n,errors:d?.errors,form:c,route:d??null})}catch(t){if(t instanceof l)return await F(new URL(t.location,location.href));f=await At({status:Fe(t),error:await $(t,{url:u,params:i,route:a}),url:u,route:a}),e.textContent=``,p=!1}f&&(f.props.page&&(f.props.page.state={}),await bt(f,e,p))}function Vt(e){return{dependencies:new Set(e?.dependencies??[]),params:new Set(e?.params??[]),parent:!!e?.parent,route:!!e?.route,url:!!e?.url,search_params:new Set(e?.search_params??[])}}var Ht=!1;function Ut(e,t=!0){let n=document.querySelector(`[autofocus]`);if(n)n.focus();else{let n=qt(e);if(n&&document.getElementById(n)){let{x:r,y:i}=T();setTimeout(()=>{let a=history.state;Ht=!0,location.replace(new URL(`#${n}`,location.href)),history.replaceState(a,``,e),t&&scrollTo(r,i),Ht=!1})}else{let e=document.body,t=e.getAttribute(`tabindex`);e.tabIndex=-1,e.focus({preventScroll:!0,focusVisible:!1}),t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t)}let r=getSelection();if(r&&r.type!==`None`){let e=[];for(let t=0;t<r.rangeCount;t+=1)e.push(r.getRangeAt(t));setTimeout(()=>{if(r.rangeCount===e.length){for(let t=0;t<r.rangeCount;t+=1){let n=e[t],i=r.getRangeAt(t);if(n.commonAncestorContainer!==i.commonAncestorContainer||n.startContainer!==i.startContainer||n.endContainer!==i.endContainer||n.startOffset!==i.startOffset||n.endOffset!==i.endOffset)return}r.removeAllRanges()}})}}}function Wt(e,t,n,r,i=null){let a,o,s=new Promise((e,t)=>{a=e,o=t});return s.catch(h),{navigation:{from:{params:e.params,route:{id:e.route?.id??null},url:e.url,scroll:T()},to:n&&{params:t?.params??null,route:{id:t?.route?.id??null},url:n,scroll:i},willUnload:!t,type:r,complete:s},fulfil:a,reject:o}}function Gt(e){return{data:e.data,error:e.error,form:e.form,params:e.params,route:e.route,state:e.state,status:e.status,url:e.url}}function Kt(e){let t=new URL(e);return t.hash=decodeURIComponent(e.hash),t}function qt(e){let t;if(R.hash){let[,,n]=e.hash.split(`#`,3);t=n??``}else t=e.hash.slice(1);return decodeURIComponent(t)}export{Me as a,k as i,ft as n,_e as o,A as r,Lt as t};
@@ -1,6 +0,0 @@
1
- import{$ as e,A as t,B as n,D as r,E as i,F as a,H as o,J as s,L as c,O as l,P as u,Q as d,S as f,T as p,U as m,X as h,Y as g,_,at as v,dt as y,f as b,h as x,i as S,j as C,k as w,n as T,ot as E,q as D,rt as ee,s as te,tt as O,u as ne,x as re,z as ie}from"./nMarIA7J.js";import{t as k}from"./BNjH_DUx.js";import"./xihTtKlq.js";import{A,C as ae,D as oe,F as se,S as ce,_ as le,a as ue,b as de,c as fe,f as pe,h as me,i as he,k as ge,m as _e,n as ve,o as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./62dhNtvj.js";import{a as De,n as Oe,r as ke,t as j}from"./DkvLWnSd.js";import{i as Ae}from"./B3dCo0od.js";import{B as je,D as M,E as Me,F as N,G as Ne,H as Pe,I as Fe,J as P,K as Ie,L as F,M as I,N as L,P as Le,R as Re,S as ze,W as Be,X as Ve,Y as He,at as Ue,ct as We,et as Ge,it as Ke,lt as qe,mt as Je,n as Ye,nt as Xe,rt as R,t as Ze,ut as Qe,v as $e,w as et,x as tt,y as nt}from"./BxTFtVqu.js";import{i as rt,l as it,n as at,o as ot,r as st}from"./yxd8jSz3.js";var ct=class{note;#e=e([]);get entries(){return c(this.#e)}set entries(e){d(this.#e,e)}#t=e(null);get prompt(){return c(this.#t)}set prompt(e){d(this.#t,e)}#n=e(null);get asking(){return c(this.#n)}set asking(e){d(this.#n,e)}#r=e(null);get failed(){return c(this.#r)}set failed(e){d(this.#r,e)}get tier(){return be.tier}#i=e(null);get cursor(){return c(this.#i)}set cursor(e){d(this.#i,e)}#a=e(``);get busy(){return c(this.#a)}set busy(e){d(this.#a,e,!0)}#o=e(null);get editing(){return c(this.#o)}set editing(e){d(this.#o,e,!0)}stop=null;constructor(e){this.note=e}#s=O(()=>ae(this.entries));get waiting(){return c(this.#s)}set waiting(e){d(this.#s,e)}#c=O(()=>this.waiting.filter(e=>e.form===`insert`));get proposals(){return c(this.#c)}set proposals(e){d(this.#c,e)}#l=O(()=>{let e=[],t=oe(this.note.text);for(let n of this.waiting)if(n.form===`rewrite`)for(let r of n.open??[]){let i=n.regions[r],a=le(this.note.text,i.old),o=a?this.note.text.slice(0,a.from).split(`
2
- `).length-1:-1,s=t.find(e=>e.from<=o&&o<e.to);e.push({key:`r:${n.id}:${r}`,proposal:n,k:r,at:a,block:/\n/.test(i.old.text.trim())||/\n/.test(i.new.trim()),code:!!(s&&/^\s*(```|~~~)/.test(s.text))})}return e.sort((e,t)=>(e.at?.from??1/0)-(t.at?.from??1/0))});get changes(){return c(this.#l)}set changes(e){d(this.#l,e)}#u=O(()=>{try{let e=A(this.note.text)[0];return{lines:e.split(`
3
- `).length-1,chars:e.length}}catch{return{lines:0,chars:0}}});get head(){return c(this.#u)}set head(e){d(this.#u,e)}get foot(){return this.note.text.split(`
4
- `).length}spans(e){return e.flatMap(e=>{let t=le(this.note.text,e);return t?[t]:[]})}placed(e){return de(this.note.text,e)!==null}#d=O(()=>{let e=[];for(let t of this.proposals){let n=de(this.note.text,t);e.push({key:`p:${t.id}`,line:n?.form===`insert`?n.line:this.foot})}this.changes.some(e=>!e.at)&&e.push({key:`lost`,line:this.foot}),this.asking&&e.push({key:`asking`,line:this.asking.line}),this.failed&&e.push({key:`failed`,line:this.failed.line}),this.prompt&&e.push({key:`prompt`,line:this.prompt.line});let t=this.changes.filter(e=>e.at);for(let n of t)n.block&&e.push({key:n.key,line:this.note.text.slice(0,n.at.to).split(`
5
- `).length});return{blocks:e,picked:this.spans(this.prompt?.regions??this.asking?.regions??[]),old:t.map(e=>e.at),inline:t.filter(e=>!e.block).map(e=>({key:e.key,at:e.at.to}))}});get layout(){return c(this.#d)}set layout(e){d(this.#d,e)}async open(){this.stop=j.on(e=>this.hear(e));let e=j.iso;e?.start&&e.note===this.note.id&&(e.state===`reading`||e.state===`writing`)&&(this.hear(e.start),this.asking&&={...this.asking,text:e.text??``,steps:e.steps});try{this.entries=await j.api.journal(this.note.id)}catch{}}close(){this.stop?.()}hear(e){if(e.type===`journal`){if(e.id!==this.note.id||this.entries.some(t=>t.id===e.entry.id))return;this.entries=[...this.entries,e.entry];let t=e.entry.kind===`discard`||e.entry.kind===`change`?e.entry.proposal:void 0;t&&this.editing?.id===t&&(this.editing=null);return}if(e.type===`note-changed`||e.type===`record`||e.type===`agent-sent`||!(`note`in e)||e.note!==this.note.id)return;if(e.type===`iso-start`){if(this.asking&&!this.asking.request){this.asking={...this.asking,request:e.request};return}let t=this.foot;if(e.place.form===`insert`||e.place.form===`rewrite`){let n=de(this.note.text,{form:`insert`,after:e.place.after,before:e.place.before});n?.form===`insert`&&(t=n.line)}this.asking={request:e.request,asked:e.asked,line:t,regions:e.place.form===`rewrite`?e.place.regions:[],text:``,steps:[]},this.failed=null,this.prompt=null;return}let t=this.asking;t&&t.request===e.request&&(e.type===`iso-text`?this.asking={...t,text:e.again?e.delta:t.text+e.delta}:e.type===`iso-step`?this.asking={...t,text:``,steps:[...t.steps,e.step]}:(e.type===`iso-failed`&&(this.failed={line:t.line,message:e.message}),this.asking=null))}promptAt(e,t){let n=oe(this.note.text).find(t=>t.from<=e&&e<t.to);this.failed=null,this.prompt={line:n?n.to:e,mode:`insert`,regions:[]},t&&t.to>t.from&&(this.setMode(`rewrite`),this.pick([t]))}promptHere(){let e=this.cursor;e?this.promptAt(e.line,e):this.promptAt(this.foot)}askAt(e,t){if(t&&t.to>t.from){this.promptAt(e,t);return}let n=oe(this.note.text).find(t=>t.from<=e&&e<t.to),r=n?.text.trim()??``;!n||!r||/^(```|~~~|\$\$|\|)/.test(r)?this.promptAt(e):(this.failed=null,this.prompt={line:n.to,mode:`insert`,regions:[]},this.ask(r))}askHere(){let e=this.cursor;e?this.askAt(e.line,e):this.promptAt(this.foot)}setMode(e){this.prompt&&={...this.prompt,mode:e}}get picking(){return this.prompt?.mode===`rewrite`}pick(e){let t=this.prompt;if(!t)return;let n=this.note.text,r=this.spans(t.regions);for(let t of e){let{from:e,to:i}=t;for(;e<i&&/\s/.test(n[e]);)e++;for(;i>e&&/\s/.test(n[i-1]);)i--;if(i<=e||e<this.head.chars)continue;let a=r.filter(t=>t.from<=i&&e<=t.to);r=[...r.filter(e=>!a.includes(e)),{from:Math.min(e,...a.map(e=>e.from)),to:Math.max(i,...a.map(e=>e.to))}]}r.sort((e,t)=>e.from-t.from),this.prompt={...t,regions:r.map(e=>ce(n,e.from,e.to))}}unpick(e){let t=this.prompt;if(!t)return;let n=t.regions.filter(t=>{let n=le(this.note.text,t);return!n||e<n.from||e>=n.to});n.length!==t.regions.length&&(this.prompt={...t,regions:n})}clearPicked(){this.prompt&&={...this.prompt,regions:[]}}setTier(e){be.setTier(e)}async ask(e){let t=this.prompt;if(!t||!e.trim()||this.asking||t.mode===`rewrite`&&!t.regions.length)return;let n=t.mode===`rewrite`?t.regions:[];this.prompt=null,this.failed=null,this.asking={request:``,asked:e,line:t.line,regions:n,text:``,steps:[]};try{await this.note.save();let r=Ee(this.note.text,t.line),i=be.of(this.note.id),a=Object.keys(i).length?{choice:i}:{},{request:o}=await j.api.ask(n.length?{note:this.note.id,form:`rewrite`,regions:n,after:r.after,before:r.before,asked:e,tier:this.tier,...a}:{note:this.note.id,...r,asked:e,tier:this.tier,...a});this.asking&&!this.asking.request&&(this.asking={...this.asking,request:o})}catch(e){this.asking=null,this.failed={line:t.line,message:e.message}}}async send(){if(this.asking)return``;this.failed=null,this.asking={request:``,asked:``,line:this.foot,regions:[],text:``,steps:[]};try{await this.note.save();let{request:e}=await j.api.ask({note:this.note.id,form:`note`,tier:this.tier});return this.asking&&!this.asking.request&&(this.asking={...this.asking,request:e}),e}catch(e){return this.asking=null,this.failed={line:this.foot,message:e.message},``}}halt(){let e=this.asking;if(!e)return;if(e.request){j.api.stop(e.request);return}let t=j.on(e=>{e.type===`iso-start`&&e.note===this.note.id&&(t(),j.api.stop(e.request))})}say(e,t){this.failed={line:e??this.foot,message:t.message}}lineOf(e){return this.layout.blocks.find(t=>t.key===`p:${e.id}`)?.line}edit(e){this.editing={id:e.id,text:e.text}}async done(e){let t=this.editing;if(t?.id===e.id)try{await j.api.revise(this.note.id,e.id,t.text),this.editing=null}catch(t){this.say(this.lineOf(e),t)}}async keep(e){this.busy=e.id;try{await this.note.save(),this.editing?.id===e.id&&await this.done(e),this.note.adopt(await j.api.keep(this.note.id,e.id))}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async discard(e){this.busy=e.id;try{await j.api.discard(this.note.id,e.id)}catch(t){this.say(this.lineOf(e),t)}finally{this.busy=``}}async keepChange(e){this.busy=e.key;try{await this.note.save(),this.note.adopt(await j.api.keep(this.note.id,e.proposal.id,e.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}async discardChange(e){this.busy=e.key;try{await j.api.discard(this.note.id,e.proposal.id,e.k)}catch(e){this.say(void 0,e)}finally{this.busy=``}}async settleAll(e){this.busy=`all`;try{e&&await this.note.save();for(let t of[...this.changes].reverse())(!e||t.at)&&(e?this.note.adopt(await j.api.keep(this.note.id,t.proposal.id,t.k)):await j.api.discard(this.note.id,t.proposal.id,t.k))}catch(e){this.say(void 0,e)}finally{this.busy=``}}},lt=1500,ut=e=>`isorite.draft.${e}`;function dt(e,t){try{if(t===void 0)return JSON.parse(localStorage.getItem(ut(e))??`null`);t?localStorage.setItem(ut(e),JSON.stringify(t)):localStorage.removeItem(ut(e))}catch{}return null}var ft=e=>typeof e==`string`?e:e==null?``:String(e),pt=class{id;#e=e(`loading`);get loaded(){return c(this.#e)}set loaded(e){d(this.#e,e,!0)}#t=e(`saved`);get saving(){return c(this.#t)}set saving(e){d(this.#t,e,!0)}#n=e(``);get message(){return c(this.#n)}set message(e){d(this.#n,e,!0)}#r=e(``);get text(){return c(this.#r)}set text(e){d(this.#r,e,!0)}#i=e(void 0);get theirs(){return c(this.#i)}set theirs(e){d(this.#i,e)}#a=e(0);get revision(){return c(this.#a)}set revision(e){d(this.#a,e,!0)}base=``;saved=``;timer=null;inFlight=null;stop=null;constructor(e){this.id=e}#o=O(()=>{try{return se(this.text)[0]??{}}catch{return null}});get meta(){return c(this.#o)}set meta(e){d(this.#o,e)}#s=O(()=>{let e=this.meta??{};return{title:ft(e.title),type:ft(e.type),description:ft(e.description),tags:Array.isArray(e.tags)?e.tags.map(String).join(`, `):ft(e.tags)}});get fields(){return c(this.#s)}set fields(e){d(this.#s,e)}#c=O(()=>{try{return A(this.text)[2]}catch{return this.text}});get body(){return c(this.#c)}set body(e){d(this.#c,e)}async open(){try{let e=await j.api.readNote(this.id),t=dt(this.id);this.take(e),t&&t.text!==e.text&&(this.text=t.text,t.base===e.version?this.changed():(this.theirs=e,this.saving=`conflict`,dt(this.id,t))),this.loaded=`ready`,this.stop=j.on(e=>this.hear(e))}catch(e){this.loaded=e instanceof De&&e.status===404?`missing`:`error`,this.message=e.message}}async close(){this.stop?.(),await this.save()}adopt(e){this.take(e)}async restore(e){await this.settle(),this.take(await j.api.restore(this.id,e,this.base))}async move(e){await this.settle();let t=await j.api.moveNote(this.id,e,this.base);return this.stop?.(),t.id}async setDone(e){await this.settle(),this.take(await j.api.setDone(this.id,e,this.base)),await j.refresh()}async remove(){await this.settle(),await j.api.deleteNote(this.id,this.base),this.stop?.()}async settle(){if(this.saving!==`saved`&&await this.save(),this.saving!==`saved`)throw Error(this.message||`the note could not be saved first`)}take(e){this.text=this.saved=e.text,this.base=e.version,this.theirs=void 0,this.saving=`saved`,this.message=``,dt(this.id,null),this.revision++}setText(e){e!==this.text&&(this.text=e,this.changed())}setBody(e){e!==this.body&&this.setText(ge(this.text,{},e))}setFields(e){let t={};for(let[n,r]of Object.entries(e)){let e=r.trim();t[n]=n===`tags`?e?e.split(`,`).map(e=>e.trim()).filter(Boolean):null:e||null}this.setMeta(t)}setMeta(e){try{this.setText(ge(this.text,e,null))}catch{}}changed(){dt(this.id,{base:this.base,text:this.text}),this.saving!==`conflict`&&(this.saving=`unsaved`,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.save()},lt))}save(){return this.timer&&=(clearTimeout(this.timer),null),this.inFlight=(this.inFlight??Promise.resolve()).then(()=>this.send()),this.inFlight}async send(){if(this.loaded!==`ready`||this.saving===`conflict`||this.text===this.saved)return;let e=this.text;this.saving=`saving`;try{let t=await j.api.saveNote(this.id,{base:this.base,text:e});this.base=t.version,this.saved=e,this.message=``,this.text===e?(this.saving=`saved`,dt(this.id,null)):this.changed()}catch(t){if(t instanceof De&&t.status===409&&t.current!==void 0){if(t.current?.text===e)return this.take(t.current);this.theirs=t.current,this.saving=`conflict`}else this.saving=`failed`,this.message=t.message,this.timer=setTimeout(()=>{this.save()},5e3)}}hear(e){e.type===`note-changed`&&e.id===this.id&&e.version!==this.base&&e.version!==Te(this.text)&&this.saving===`saved`&&j.api.readNote(this.id).then(e=>{this.saving===`saved`&&e.version!==this.base&&this.take(e)},()=>void 0)}keepMine(){let e=this.theirs;return e===void 0?Promise.resolve():(this.theirs=void 0,this.saving=`unsaved`,e===null?j.api.createNote(this.id,this.text).then(e=>this.take(e),e=>{this.saving=`failed`,this.message=e.message}):(this.base=e.version,this.saved=e.text,this.save()))}keepTheirs(){this.theirs&&this.take(this.theirs)}},mt=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=yt(e.state,n.from);return r.line?gt(e):r.block?vt(e):!1};function ht(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var gt=ht(wt,0),_t=ht(Ct,0),vt=ht((e,t)=>Ct(e,t,St(t)),0);function yt(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var bt=50;function xt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-bt,r),o=e.sliceDoc(i,i+bt),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+bt),d=e.sliceDoc(i-bt,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function St(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ct(e,t,n=t.selection.ranges){let r=n.map(e=>yt(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function wt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=yt(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Tt=Be.define(),Et=Be.define(),Dt=Ve.define(),Ot=Ve.define({combine(e){return We(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),kt=R.define({create(){return Kt.empty},update(e,t){let n=t.state.facet(Ot),r=t.annotation(Tt);if(r){let i=z.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?It(o,o.length,n.minDepth,i):Vt(o,t.startState.selection),new Kt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Ue.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=z.fromTransaction(t),o=t.annotation(Ue.time),s=t.annotation(Ue.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Kt(e.done.map(z.fromJSON),e.undone.map(z.fromJSON))}});function At(e={}){return[kt,Ot.of(e),N.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Mt:e.inputType==`historyRedo`?Nt:null;return n?(e.preventDefault(),n(t)):!1}})]}function jt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(kt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Mt=jt(0,!1),Nt=jt(1,!1),Pt=jt(0,!0),Ft=jt(1,!0),z=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Ie.fromJSON(t.changes),[],t.mapped&&Ne.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=B;for(let e of t.startState.facet(Dt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,B)}static selection(t){return new e(void 0,B,void 0,void 0,t)}};function It(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Lt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Rt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function zt(e,t){return e.length?t.length?e.concat(t):e:t}var B=[],Bt=200;function Vt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),It(e,e.length-1,1e9,n.setSelAfter(r)))}return[z.selection([t])]}function Ht(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ut(e,t){if(!e.length)return e;let n=e.length,r=B;for(;n;){let i=Wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[z.selection(r)]:B}function Wt(e,t,n){let r=zt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):B,n);if(!e.changes)return z.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new z(i,Xe.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Gt=/^(input\.type|delete)($|\.)/,Kt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Gt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Lt(s.changes,t.changes))||r==`input.type.compose`)?It(o,o.length-1,i.minDepth,new z(t.changes.compose(s.changes),zt(Xe.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,B)):It(o,o.length,i.minDepth,t),new e(o,B,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:B;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Rt(a[a.length-1],t)?this:new e(Vt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ut(this.done,t),Ut(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Tt.of({side:e,rest:Ht(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?B:r.slice(0,r.length-1);return i.mapped&&(n=Ut(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Tt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Kt.empty=new Kt(B,B);var qt=[{key:`Mod-z`,run:Mt,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Nt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Nt,preventDefault:!0},{key:`Mod-u`,run:Pt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Ft,preventDefault:!0}];function V(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function H(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function U({state:e,dispatch:t},n){let r=V(e.selection,n);return!r.eq(e.selection,!0)&&(t(H(e,r)),!0)}function Jt(e,t){return P.cursor(t?e.to:e.from)}function Yt(e,t){return U(e,n=>n.empty?e.moveByChar(n,t):Jt(n,t))}function W(e){return e.textDirectionAt(e.state.selection.main.head)==Le.LTR}var Xt=e=>Yt(e,!W(e)),Zt=e=>Yt(e,W(e));function Qt(e,t){return U(e,n=>n.empty?e.moveByGroup(n,t):Jt(n,t))}var $t=e=>Qt(e,!W(e)),en=e=>Qt(e,W(e));typeof Intl<`u`&&Intl.Segmenter;function tn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function nn(e,t,n){let r=M(e).resolveInner(t.head),i=n?Je.closedBy:Je.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;tn(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?et(e,r.from,1):et(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var rn=e=>U(e,t=>nn(e.state,t,!W(e))),an=e=>U(e,t=>nn(e.state,t,W(e)));function on(e,t){return U(e,n=>{if(!n.empty)return Jt(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var sn=e=>on(e,!1),cn=e=>on(e,!0);function ln(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(N.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function un(e,t){let n=ln(e),{state:r}=e,i=V(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Jt(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=N.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(H(r,i),{effects:a}),!0}var dn=e=>un(e,!1),fn=e=>un(e,!0);function G(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var pn=e=>U(e,t=>G(e,t,!0)),mn=e=>U(e,t=>G(e,t,!1)),hn=e=>U(e,t=>G(e,t,!W(e))),gn=e=>U(e,t=>G(e,t,W(e))),_n=e=>U(e,t=>e.moveToLineBoundary(t,!1,!1)),vn=e=>U(e,t=>e.moveToLineBoundary(t,!0,!1));function yn(e,t,n){let r=!1,i=V(e.selection,t=>{let i=et(e,t.head,-1)||et(e,t.head,1)||t.head>0&&et(e,t.head-1,1)||t.head<e.doc.length&&et(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(H(e,i)),!0):!1}var bn=({state:e,dispatch:t})=>yn(e,t,!1);function K(e,t,n){let r=V(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=P.range(e.head,e.anchor));let r=n(e);return P.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(H(e.state,r)),!0)}function xn(e,t){return K(e,t,n=>e.moveByChar(n,t))}var Sn=e=>xn(e,!W(e)),Cn=e=>xn(e,W(e));function wn(e,t){return K(e,t,n=>e.moveByGroup(n,t))}var Tn=e=>wn(e,!W(e)),En=e=>wn(e,W(e)),Dn=e=>{let t=!W(e);return K(e,t,n=>nn(e.state,n,t))},On=e=>{let t=W(e);return K(e,t,n=>nn(e.state,n,t))};function kn(e,t){return K(e,t,n=>e.moveVertically(n,t))}var An=e=>kn(e,!1),jn=e=>kn(e,!0);function Mn(e,t){return K(e,t,n=>e.moveVertically(n,t,ln(e).height))}var Nn=e=>Mn(e,!1),Pn=e=>Mn(e,!0),Fn=e=>K(e,!0,t=>G(e,t,!0)),In=e=>K(e,!1,t=>G(e,t,!1)),Ln=e=>{let t=!W(e);return K(e,t,n=>G(e,n,t))},Rn=e=>{let t=W(e);return K(e,t,n=>G(e,n,t))},zn=e=>K(e,!1,t=>P.cursor(e.lineBlockAt(t.head).from)),Bn=e=>K(e,!0,t=>P.cursor(e.lineBlockAt(t.head).to)),Vn=({state:e,dispatch:t})=>(t(H(e,{anchor:0})),!0),Hn=({state:e,dispatch:t})=>(t(H(e,{anchor:e.doc.length})),!0),Un=({state:e,dispatch:t})=>(t(H(e,{anchor:e.selection.main.anchor,head:0})),!0),Wn=({state:e,dispatch:t})=>(t(H(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Gn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Kn=({state:e,dispatch:t})=>{let n=dr(e).map(({from:t,to:n})=>P.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},qn=({state:e,dispatch:t})=>{let n=V(e.selection,t=>{let n=M(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(H(e,n)),!0)};function Jn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(H(n,P.create(i,i.length-1))),!0)}var Yn=e=>Jn(e,!1),Xn=e=>Jn(e,!0),Zn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(H(e,r)),!0):!1};function Qn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=$n(e,o,!1)):o>i&&(n=`delete.forward`,o=$n(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=$n(e,i,!1),a=$n(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?N.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function $n(e,t,n){if(e instanceof N)for(let r of e.state.facet(N.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var er=(e,t,n)=>Qn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=qe(s,a.tabSize)%$e(a)||$e(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=Qe(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=Qe(o.text,c-o.from,!1,!1)+o.from);return c}),tr=e=>er(e,!1,!0),nr=e=>er(e,!0,!1),rr=(e,t)=>Qn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=Qe(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),ir=e=>rr(e,!1),ar=e=>rr(e,!0),or=e=>Qn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),sr=e=>Qn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),cr=e=>Qn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),lr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Ke.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:Qe(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:Qe(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function dr(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function fr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of dr(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var pr=({state:e,dispatch:t})=>fr(e,t,!1),mr=({state:e,dispatch:t})=>fr(e,t,!0);function hr(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of dr(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var gr=({state:e,dispatch:t})=>hr(e,t,!1),_r=({state:e,dispatch:t})=>hr(e,t,!0),vr=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(dr(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=V(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function yr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=M(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Je.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var br=Sr(!1),xr=Sr(!0);function Sr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&yr(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Ye(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=nt(s,r);for(c??=qe(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,tt(t,c)];return o&&l.push(tt(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:Ke.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Cr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var wr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ye(e,{overrideIndentation:e=>n[e]??-1}),i=Cr(e,(t,i,a)=>{let o=nt(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=tt(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},Tr=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Cr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ze)})}),{userEvent:`input.indent`})),!0),Er=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Cr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=qe(r,e.tabSize),a=0,o=tt(e,Math.max(0,i-$e(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Dr=e=>(e.setTabFocusMode(),!0),Or=[{key:`Ctrl-b`,run:Xt,shift:Sn,preventDefault:!0},{key:`Ctrl-f`,run:Zt,shift:Cn},{key:`Ctrl-p`,run:sn,shift:An},{key:`Ctrl-n`,run:cn,shift:jn},{key:`Ctrl-a`,run:_n,shift:zn},{key:`Ctrl-e`,run:vn,shift:Bn},{key:`Ctrl-d`,run:nr},{key:`Ctrl-h`,run:tr},{key:`Ctrl-k`,run:or},{key:`Ctrl-Alt-h`,run:ir},{key:`Ctrl-o`,run:lr},{key:`Ctrl-t`,run:ur},{key:`Ctrl-v`,run:fn}],kr=[{key:`ArrowLeft`,run:Xt,shift:Sn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:$t,shift:Tn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:hn,shift:Ln,preventDefault:!0},{key:`ArrowRight`,run:Zt,shift:Cn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:en,shift:En,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:gn,shift:Rn,preventDefault:!0},{key:`ArrowUp`,run:sn,shift:An,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Vn,shift:Un},{mac:`Ctrl-ArrowUp`,run:dn,shift:Nn},{key:`ArrowDown`,run:cn,shift:jn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Hn,shift:Wn},{mac:`Ctrl-ArrowDown`,run:fn,shift:Pn},{key:`PageUp`,run:dn,shift:Nn},{key:`PageDown`,run:fn,shift:Pn},{key:`Home`,run:mn,shift:In,preventDefault:!0},{key:`Mod-Home`,run:Vn,shift:Un},{key:`End`,run:pn,shift:Fn,preventDefault:!0},{key:`Mod-End`,run:Hn,shift:Wn},{key:`Enter`,run:br,shift:br},{key:`Mod-a`,run:Gn},{key:`Backspace`,run:tr,shift:tr,preventDefault:!0},{key:`Delete`,run:nr,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:ir,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:ar,preventDefault:!0},{mac:`Mod-Backspace`,run:sr,preventDefault:!0},{mac:`Mod-Delete`,run:cr,preventDefault:!0}].concat(Or.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Ar=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:rn,shift:Dn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:an,shift:On},{key:`Alt-ArrowUp`,run:pr},{key:`Shift-Alt-ArrowUp`,run:gr},{key:`Alt-ArrowDown`,run:mr},{key:`Shift-Alt-ArrowDown`,run:_r},{key:`Mod-Alt-ArrowUp`,run:Yn},{key:`Mod-Alt-ArrowDown`,run:Xn},{key:`Escape`,run:Zn},{key:`Mod-Enter`,run:xr},{key:`Alt-l`,mac:`Ctrl-l`,run:Kn},{key:`Mod-i`,run:qn,preventDefault:!0},{key:`Mod-[`,run:Er},{key:`Mod-]`,run:Tr},{key:`Mod-Alt-\\`,run:wr},{key:`Shift-Mod-k`,run:vr},{key:`Shift-Mod-\\`,run:bn},{key:`Mod-/`,run:mt},{key:`Alt-A`,mac:`Ctrl-A`,run:_t},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Dr}].concat(kr),jr={key:`Tab`,run:Tr,shift:Er},Mr=Ve.define({combine:e=>e[0]??null}),Nr=/^[ \t]*\[\[!([^\]\n]+)\]\][ \t]*$/,Pr={question:`<path d="M5.6 5.6a2.4 2.4 0 1 1 3.4 2.2c-.6.3-1 .8-1 1.5v.9"/><path d="M8 12v1.2"/>`,problem:`<path d="M8 2.5l5.8 10.5H2.2z"/>`,note:`<rect x="3.5" y="2.5" width="9" height="11"/>`},Fr=`<path d="M3 8.5l3 3 7-7"/>`,Ir=class extends F{ref;found;at;constructor(e,t,n){super(),this.ref=e,this.found=t,this.at=n}eq(e){return e.ref===this.ref&&JSON.stringify(e.found)===JSON.stringify(this.found)&&e.at===this.at}toDOM(e){let t=this.found,n=document.createElement(`div`);n.className=`cm-lp-embed${t?` cm-lp-embed-${t.kind}`:` cm-lp-embed-broken`}${t?.done?` cm-lp-embed-done`:``}`,n.title=`[[!${this.ref}]]`;let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`viewBox`,`0 0 16 16`),r.setAttribute(`width`,`16`),r.setAttribute(`height`,`16`),r.setAttribute(`aria-hidden`,`true`),r.innerHTML=t?.done?Fr:Pr[t?.kind??`question`];let i=document.createElement(`span`);return i.textContent=t?t.title:this.ref,n.append(r,i),n.addEventListener(`mousedown`,n=>{n.preventDefault(),t&&!n.altKey?e.state.facet(Mr)?.open(t.id):(e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus())}),n}ignoreEvent(){return!0}get estimatedHeight(){return 44}},Lr=class extends F{kind;source;at;beneath;constructor(e,t,n,r){super(),this.kind=e,this.source=t,this.at=n,this.beneath=r}eq(e){return e.kind===this.kind&&e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-${this.kind}${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`div`);return n.className=`prose`,t.append(n),n.innerHTML=he(this.source),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}ignoreEvent(){return!0}get estimatedHeight(){return this.kind===`maths`?60:120}},Rr=new WeakMap,zr=class extends F{source;at;beneath;constructor(e,t,n){super(),this.source=e,this.at=t,this.beneath=n}eq(e){return e.source===this.source&&e.at===this.at&&e.beneath===this.beneath}toDOM(e){let t=document.createElement(`div`);t.className=`cm-lp-block cm-lp-diagram${this.beneath?` cm-lp-beneath`:``}`;let n=document.createElement(`pre`);n.className=`cm-lp-diagram-src`,n.textContent=this.source;let r=document.createElement(`div`);return r.className=`diagram`,t.append(n,r),Rr.set(t,{mounted:ve(r,this.source,()=>t.classList.add(`cm-lp-broken-diagram`)),source:this.source}),this.beneath||(t.title=`Click to edit`,t.addEventListener(`mousedown`,t=>{t.preventDefault(),e.dispatch({selection:{anchor:this.at},scrollIntoView:!0}),e.focus()})),t}updateDOM(e){let t=Rr.get(e);return!t||!this.beneath||!e.classList.contains(`cm-lp-beneath`)?!1:(t.source!==this.source&&(t.source=this.source,e.classList.remove(`cm-lp-broken-diagram`),e.querySelector(`.cm-lp-diagram-src`).textContent=this.source,t.mounted.then(e=>xe(e,this.source))),!0)}ignoreEvent(){return!0}get estimatedHeight(){return 160}},Br=(e,t)=>t!==null&&e.sliceDoc(t.from,t.to).trim().split(/\s/)[0].toLowerCase()===`mermaid`;function Vr(e){let t=[],n=e.selection.ranges;M(e).iterate({enter:r=>{let i=null,a=``;if(r.name===`BlockMath`)i=`maths`,a=e.sliceDoc(r.from,r.to);else if(r.name===`Table`)i=`table`,a=e.sliceDoc(r.from,r.to);else if(r.name===`FencedCode`&&Br(e,r.node.getChild(`CodeInfo`))){let i=r.node.getChild(`CodeText`),a=i?e.sliceDoc(i.from,i.to):``,o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?a.trim()&&t.push(L.widget({widget:new zr(a,r.from,!0),block:!0,side:1}).range(s)):t.push(L.replace({widget:new zr(a,r.from,!1),block:!0}).range(o,s)),!1}else if(r.name===`Document`||r.name===`Blockquote`||/List|ListItem/.test(r.name))return;if(!i)return!1;let o=e.doc.lineAt(r.from).from,s=e.doc.lineAt(r.to).to;return n.some(e=>e.to>=o&&e.from<=s)?i!==`table`&&a.trim()&&t.push(L.widget({widget:new Lr(i,a,r.from,!0),block:!0,side:1}).range(s)):t.push(L.replace({widget:new Lr(i,a,r.from,!1),block:!0}).range(o,s)),!1}});let r=e.facet(Mr);if(r){let i=!1;for(let a=1;a<=e.doc.lines;a++){let o=e.doc.line(a);if(/^\s*(```|~~~)/.test(o.text)){i=!i;continue}let s=i?null:Nr.exec(o.text);if(!s||n.some(e=>e.to>=o.from&&e.from<=o.to))continue;let c=s[1].trim();t.push(L.replace({widget:new Ir(c,r.find(c),o.from),block:!0}).range(o.from,o.to))}}return L.set(t,!0)}var Hr=R.define({create:Vr,update(e,t){return t.docChanged||t.selection||M(t.startState)!==M(t.state)?Vr(t.state):e},provide:e=>N.decorations.from(e)}),Ur=N.theme({".cm-lp-block":{padding:`0`,cursor:`text`},".cm-lp-block .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-block .prose":{maxWidth:`none`},".cm-lp-block .prose > :last-child, .cm-lp-block .table-wrap":{marginBottom:`0`},".cm-lp-block .katex-display":{margin:`0`},".cm-lp-diagram .diagram":{overflowX:`auto`,overflowY:`hidden`},".cm-lp-diagram-src":{display:`none`,margin:`0`,font:`13px/20px var(--font-mono)`,whiteSpace:`pre-wrap`,color:`var(--text-soft)`},".cm-lp-diagram.cm-lp-broken-diagram:not(.cm-lp-beneath) .cm-lp-diagram-src":{display:`block`},".cm-lp-beneath":{borderLeft:`2px solid var(--line)`,paddingLeft:`12px`,marginTop:`4px`,opacity:`.9`},".cm-lp-block:not(.cm-lp-beneath):hover":{outline:`1px dashed var(--line)`,outlineOffset:`2px`},".cm-lp-embed":{display:`flex`,alignItems:`center`,gap:`10px`,padding:`9px 12px`,border:`1px solid var(--rose)`,borderLeftWidth:`3px`,background:`var(--rose-soft)`,fontFamily:`var(--font-text)`,fontSize:`16px`,lineHeight:`1.45`,cursor:`pointer`},".cm-lp-embed svg":{flex:`none`,fill:`none`,stroke:`var(--rose)`,strokeWidth:`1.4`},".cm-lp-embed-problem":{borderColor:`var(--line-strong)`,background:`var(--ground-1)`},".cm-lp-embed-problem svg":{stroke:`var(--text-soft)`},".cm-lp-embed-done":{borderColor:`var(--malachite)`,background:`var(--malachite-soft)`},".cm-lp-embed-done svg":{stroke:`var(--malachite)`},".cm-lp-embed-broken":{borderStyle:`dashed`,borderColor:`var(--line-strong)`,background:`none`,color:`var(--text-faint)`},".cm-lp-embed-broken svg":{stroke:`var(--text-faint)`},".cm-lp-embed:hover":{borderColor:`var(--text-soft)`}});function Wr(e,t){let{state:n}=e,r=t.length;return e.dispatch(n.changeByRange(e=>{let i=n.sliceDoc(e.from-r,e.from),a=n.sliceDoc(e.to,e.to+r);return i===t&&a===t?{changes:[{from:e.from-r,to:e.from},{from:e.to,to:e.to+r}],range:P.range(e.from-r,e.to-r)}:{changes:[{from:e.from,insert:t},{from:e.to,insert:t}],range:P.range(e.from+r,e.to+r)}}),{scrollIntoView:!0,userEvent:`input`}),!0}function Gr(e){let{state:t}=e,n=new Map;for(let e of t.selection.ranges)for(let r=e.from;r<=e.to;){let e=t.doc.lineAt(r);n.set(e.number,{from:e.from,text:e.text}),r=e.to+1}return[...n.values()]}function Kr(e){let t=Gr(e).map(({from:e,text:t})=>{let n=/^(#{1,6}) /.exec(t),r=n?n[1].length:0,i=r>=3?``:`#`.repeat(r+1)+` `;return{from:e,to:e+(n?n[0].length:0),insert:i}});return e.dispatch({changes:t,scrollIntoView:!0,userEvent:`input`}),!0}function qr(e){let t=Gr(e),n=t.every(({text:e})=>/^\s*[-*+] /.test(e)),r=t.map(({from:e,text:t})=>{if(n){let n=/^(\s*)[-*+] /.exec(t);return{from:e+n[1].length,to:e+n[0].length}}return{from:e+/^\s*/.exec(t)[0].length,insert:`- `}});return e.dispatch({changes:r,scrollIntoView:!0,userEvent:`input`}),!0}function Jr(e){let{state:t}=e,n=t.selection.main;if(n.empty)e.dispatch({changes:{from:n.from,insert:`[[]]`},selection:{anchor:n.from+2},userEvent:`input`});else{let r=t.sliceDoc(n.from,n.to);e.dispatch({changes:{from:n.from,to:n.to,insert:`[${r}]()`},selection:{anchor:n.from+r.length+3},userEvent:`input`})}return it(e),!0}function q(e,t){switch(t){case`bold`:return Wr(e,`**`);case`italic`:return Wr(e,`*`);case`maths`:return Wr(e,`$`);case`heading`:return Kr(e);case`list`:return qr(e);case`link`:return Jr(e);case`undo`:return Mt(e);case`redo`:return Nt(e)}}var Yr=[{key:`Mod-b`,preventDefault:!0,run:e=>q(e,`bold`)},{key:`Mod-i`,preventDefault:!0,run:e=>q(e,`italic`)},{key:`Mod-k`,preventDefault:!0,run:e=>q(e,`link`)},{key:`Mod-Shift-m`,preventDefault:!0,run:e=>q(e,`maths`)},{key:`Mod-Shift-h`,preventDefault:!0,run:e=>q(e,`heading`)},{key:`Mod-Shift-8`,preventDefault:!0,run:e=>q(e,`list`)}],Xr=[`requires`,`uses`,`see also`];function Zr(e){if(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`#`))return null;let t=e.split(`#`)[0].split(`?`)[0];return/\.html?$/i.test(t)?`artifact`:/\.(png|jpe?g|gif|svg|webp|avif)$/i.test(t)?`image`:/\.md$/i.test(t)||t.endsWith(`/`)?`note`:null}function J(e,t){let n=M(e);for(let r of[-1,1])for(let i=n.resolveInner(t,r);i;i=i.parent){if(i.name!==`Link`&&i.name!==`Image`)continue;let t=i.getChild(`URL`);if(!t)break;let n=e.sliceDoc(t.from,t.to),r=Zr(n);if(!r)return null;let a=i.getChild(`LinkTitle`),o=a?e.sliceDoc(a.from,a.to):null;return{from:i.from,to:i.to,embed:i.name===`Image`,url:n,urlTo:t.to,title:o===null?null:o.replace(/^["'(]|["')]$/g,``),titleFrom:a?a.from:t.to,titleTo:a?a.to:t.to,kind:r}}return null}var Qr=e=>e.kind===`note`||e.kind===`artifact`&&!e.embed;function $r(e,t,n){let r=[];return M(e).iterate({from:t,to:n,enter:i=>{if(i.name!==`Link`&&i.name!==`Image`)return;if(i.from<t||i.to>n)return!1;let a=J(e,i.from+1);return a&&a.from===i.from&&Qr(a)&&r.push(a),!1}}),r}var ei=(e,t)=>e.filter(e=>Y(e)!==t).map(e=>X(e,t)),ti=e=>(e??``).trim().toLowerCase().replace(/[-_]/g,` `),Y=e=>Xr.includes(ti(e.title))?ti(e.title):ti(e.title)===`seealso`?`see also`:null,ni=e=>ti(e.title)===`left`?`left`:`center`;function X(e,t){return t===null?{from:e.urlTo,to:e.titleTo,insert:``}:e.titleFrom===e.titleTo?{from:e.urlTo,insert:` "${t}"`}:{from:e.titleFrom,to:e.titleTo,insert:`"${t}"`}}function ri(e,t){if(e.embed===t)return[];let n=[t?{from:e.from,insert:`!`}:{from:e.from,to:e.from+1,insert:``}];return e.title!==null&&(e.kind===`image`||Y(e)!==null)&&n.push(X(e,null)),n}var Z=(e,t)=>e.dispatch({changes:t,userEvent:`input.link`});function ii(e){let t=[...Xr.map(t=>({label:t[0].toUpperCase()+t.slice(1),on:Y(e)===t,run:(e,n)=>Z(e,X(n,t)),hint:t===`requires`?`This note cannot be followed without it: it shapes the Atlas and the study order`:t===`uses`?`It draws on it: it shapes the Atlas`:`Related reading: shown, but it does not shape the Atlas`})),{label:`Unrated`,on:Y(e)===null,run:(e,t)=>Z(e,X(t,null)),hint:`No rating: counted as uses`}];if(e.kind===`note`)return t;let n=[{label:`Shown here`,on:e.embed,run:(e,t)=>Z(e,ri(t,!0)),hint:e.kind===`image`?`The picture is shown in the note`:`The artifact is shown in the note, working`},{label:`Link`,on:!e.embed,run:(e,t)=>Z(e,ri(t,!1)),hint:`A link to it; it opens on its own`}];return e.kind===`image`?e.embed?[...n,{label:`Centre`,on:ni(e)===`center`,run:(e,t)=>Z(e,X(t,null)),hint:`In the middle, 80% of the text's width`},{label:`Left`,on:ni(e)===`left`,run:(e,t)=>Z(e,X(t,`left`)),hint:`At the left, 80% of the text's width`}]:n:e.embed?n:[...n,...t]}function ai(e){let t=t=>e.every(e=>Y(e)===t),n=e.length;return[...Xr.map(e=>({label:e[0].toUpperCase()+e.slice(1),on:t(e),run:t=>Z(t,ei($r(t.state,t.state.selection.main.from,t.state.selection.main.to),e)),hint:`Rate all ${n} links ${e}`})),{label:`Unrated`,on:t(null),run:e=>Z(e,ei($r(e.state,e.state.selection.main.from,e.state.selection.main.to),null)),hint:`Take the rating from all ${n} links`}]}function oi(e){let t=Y(e[0]),n=e.every(e=>Y(e)===t);return`${e.length} links, ${n?t??`unrated`:`mixed`}`}function si(e){return e.kind===`note`?Y(e)?Y(e)[0].toUpperCase()+Y(e).slice(1):`Unrated`:e.embed?e.kind===`image`?ni(e)===`left`?`Shown, left`:`Shown, centre`:`Shown here`:Y(e)?`Link, ${Y(e)}`:`Link`}var ci=(e,t)=>e===t||!!e&&!!t&&e.from===t.from&&e.to===t.to&&e.title===t.title&&e.embed===t.embed,li=class{view;layer;button;menu;leader;path;link=null;hover=null;many=[];open=!1;at=0;constructor(e){this.view=e,this.layer=document.createElement(`div`),this.layer.className=`cm-link-control`,this.layer.hidden=!0,this.leader=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this.leader.setAttribute(`class`,`cm-link-leader`),this.leader.setAttribute(`aria-hidden`,`true`),this.path=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),this.leader.append(this.path),this.button=document.createElement(`button`),this.button.type=`button`,this.button.className=`cm-link-button`,this.button.setAttribute(`aria-haspopup`,`menu`),this.button.addEventListener(`mousedown`,e=>e.preventDefault()),this.button.addEventListener(`click`,()=>this.toggle(!this.open,!1)),this.menu=document.createElement(`div`),this.menu.className=`cm-link-menu`,this.menu.setAttribute(`role`,`menu`),this.menu.hidden=!0,this.menu.tabIndex=-1,this.menu.addEventListener(`keydown`,e=>this.keys(e)),this.layer.append(this.leader,this.button,this.menu),e.dom.append(this.layer),e.dom.addEventListener(`mousemove`,this.onMove),e.dom.addEventListener(`mouseleave`,this.onLeave)}onMove=e=>{if(this.open||this.layer.contains(e.target))return;let t=this.view.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t===null?null:J(this.view.state,t);ci(n,this.hover)||(this.hover=n,this.view.requestMeasure(this.measure))};onLeave=e=>{this.open||this.layer.contains(e.relatedTarget)||this.hover&&(this.hover=null,this.view.requestMeasure(this.measure))};selected(){let e=this.view.state.selection.main;if(e.empty)return[];let t=$r(this.view.state,e.from,e.to);return t.length>=2?t:[]}current(){let e=this.view.state.selection.main,t=this.selected();return t.length?t[0]:J(this.view.state,e.head)??(e.empty?this.hover:null)}update(e){e.docChanged&&(this.hover=null),(e.docChanged||e.selectionSet||e.geometryChanged||e.viewportChanged||e.focusChanged)&&this.view.requestMeasure(this.measure)}measure={key:`link-control`,read:e=>{let t=this.current();if(!t)return null;let n=this.selected(),r=e.dom.getBoundingClientRect(),i=e.contentDOM.getBoundingClientRect(),a=e.coordsAtPos(Math.max(t.from,t.to-1),1)??e.coordsAtPos(t.to,-1);if(n.length){let t=Math.max(r.top,0),i=Math.min(r.bottom,window.innerHeight);a=null;for(let r=n.length-1;r>=0&&!a;r--){let o=e.coordsAtPos(Math.max(n[r].from,n[r].to-1),1);o&&o.top>=t&&o.bottom<=i-34&&(a=o)}a??=e.coordsAtPos(Math.max(n[0].from,n[0].to-1),1)}return a?{l:t,many:n,x:a.right-r.left,y:(a.top+a.bottom)/2-r.top,right:i.right-r.left,width:r.width}:null},write:e=>{if(!e){this.link=null,this.many=[],this.layer.hidden=!0,this.toggle(!1,!1);return}let t=e.many.length?oi(e.many):si(e.l),n=!ci(e.l,this.link)||e.many.length!==this.many.length||t!==this.button.textContent;this.link=e.l,this.many=e.many,this.layer.hidden=!1,this.button.textContent=t,this.button.title=e.many.length?`Rate all the selected links (Alt+L)`:`What this link is (Alt+L)`,this.button.setAttribute(`aria-label`,e.many.length?`${t}. Rate them all`:`This link: ${t}. Change it`);let r=this.button.offsetWidth||90,i=e.width-e.right>=r+20,a=i?e.right+14:Math.max(0,e.width-r-2),o=i?e.y-13:e.y+12;this.button.style.transform=`translate(${Math.round(a)}px, ${Math.round(o)}px)`,this.menu.style.transform=`translate(${Math.round(Math.min(a,e.width-250))}px, ${Math.round(o+30)}px)`;let s=a,c=o+13;this.path.setAttribute(`d`,i?`M${e.x+3} ${e.y} H${Math.max(e.x+3,s-3)}`:`M${e.x+3} ${e.y} V${c} H${s-3}`),n&&this.open&&(this.fill(),this.mark(this.at))}};fill(){let e=this.link;e&&this.menu.replaceChildren(...(this.many.length?ai(this.many):ii(e)).map((t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.tabIndex=-1,r.id=`cm-link-choice-${n}`,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`mousemove`,()=>this.mark(n)),r.setAttribute(`role`,`menuitemradio`),r.setAttribute(`aria-checked`,String(t.on)),r.title=t.hint,r.innerHTML=`<b></b><span></span>`,r.querySelector(`b`).textContent=t.label,r.querySelector(`span`).textContent=t.hint,r.addEventListener(`click`,()=>{let n=this.current()??e;t.run(this.view,n),this.toggle(!1,!0)}),r}))}toggle(e,t){if(e&&(this.link=this.current()??this.link,this.many=this.selected()),!e||this.link){if(this.open=e,this.menu.hidden=!e,this.layer.classList.toggle(`open`,e),this.button.setAttribute(`aria-expanded`,String(e)),e){this.fill();let e=[...this.menu.querySelectorAll(`button`)];this.mark(Math.max(0,e.findIndex(e=>e.getAttribute(`aria-checked`)===`true`))),this.menu.focus()}else t&&this.view.focus()}}mark(e){let t=[...this.menu.querySelectorAll(`button`)];this.at=t.length?(e+t.length)%t.length:0,t.forEach((e,t)=>e.classList.toggle(`on`,t===this.at)),this.menu.setAttribute(`aria-activedescendant`,t[this.at]?.id??``)}keys(e){let t=[...this.menu.querySelectorAll(`button`)],n=!0;if(e.key===`Escape`)this.toggle(!1,!0);else if(e.key===`Enter`||e.key===` `)t[this.at]?.click();else if(e.key===`ArrowDown`)this.mark(this.at+1);else if(e.key===`ArrowUp`)this.mark(this.at-1);else if(e.key===`Home`)this.mark(0);else if(e.key===`End`)this.mark(t.length-1);else if(e.key===`Tab`)this.toggle(!1,!0);else if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let r=t.findIndex(t=>t.textContent.toLowerCase().startsWith(e.key.toLowerCase()));r>=0?this.mark(r):n=!1}else n=!1;n&&(e.preventDefault(),e.stopPropagation())}destroy(){this.view.dom.removeEventListener(`mousemove`,this.onMove),this.view.dom.removeEventListener(`mouseleave`,this.onLeave),this.layer.remove()}},ui=Fe.fromClass(li),di=e=>t=>{let n=J(t.state,t.state.selection.main.head);return n?(e(t,n),!0):!1},fi=e=>t=>{let n=t.state.selection.main,r=n.empty?[]:$r(t.state,n.from,n.to);return r.length>=2?(Z(t,ei(r,e)),!0):di((t,n)=>{Qr(n)&&Z(t,X(n,e))})(t)},pi=[{key:`Alt-l`,run:e=>{let t=e.plugin(ui);return!t||!t.current()?!1:(t.toggle(!0,!1),!0)}},{key:`Alt-1`,run:fi(`requires`)},{key:`Alt-2`,run:fi(`uses`)},{key:`Alt-3`,run:fi(`see also`)},{key:`Alt-0`,run:fi(null)},{key:`Alt-e`,run:di((e,t)=>{t.kind!==`note`&&Z(e,ri(t,!t.embed))})}],mi=[ui,N.baseTheme({"&":{position:`relative`},".cm-link-control":{position:`absolute`,inset:`0`,pointerEvents:`none`,zIndex:`4`,overflow:`visible`},".cm-link-control[hidden]":{display:`none`},".cm-link-leader":{position:`absolute`,left:`0`,top:`0`,width:`100%`,height:`100%`,overflow:`visible`},".cm-link-leader path":{fill:`none`,stroke:`var(--lattice)`,strokeWidth:`1.75`,strokeDasharray:`.1 5`,strokeLinecap:`round`,opacity:`.7`},".cm-link-control:hover .cm-link-leader path, .cm-link-control:focus-within .cm-link-leader path, .cm-link-control.open .cm-link-leader path":{opacity:`1`,animation:`cm-link-run .6s linear infinite`},"@keyframes cm-link-run":{to:{strokeDashoffset:`-5.1`}},"@media (prefers-reduced-motion: reduce)":{".cm-link-leader path":{animation:`none !important`}},".cm-link-button":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,height:`26px`,padding:`0 9px`,font:`12.5px var(--font-ui)`,whiteSpace:`nowrap`,color:`var(--text)`,background:`var(--ground-1)`,border:`1px solid var(--lattice)`,cursor:`pointer`},".cm-link-button:hover, .cm-link-button[aria-expanded=true]":{background:`var(--lattice-soft)`},".cm-link-button:focus-visible":{outline:`2px solid var(--focus-ring)`,outlineOffset:`2px`},".cm-link-menu":{position:`absolute`,left:`0`,top:`0`,pointerEvents:`auto`,width:`248px`,padding:`4px`,background:`var(--ground-1)`,border:`1px solid var(--line)`,display:`grid`,gap:`1px`},".cm-link-menu[hidden]":{display:`none`},".cm-link-menu button":{display:`grid`,gap:`1px`,textAlign:`left`,padding:`6px 8px 6px 24px`,background:`none`,border:`0`,color:`var(--text)`,font:`13.5px var(--font-ui)`,cursor:`pointer`,position:`relative`},".cm-link-menu button b":{fontWeight:`600`},".cm-link-menu button span":{fontSize:`12px`,color:`var(--text-faint)`,lineHeight:`1.3`},".cm-link-menu button[aria-checked=true]::before":{content:`"●"`,position:`absolute`,left:`8px`,top:`7px`,fontSize:`10px`,color:`var(--lattice)`},".cm-link-menu:focus":{outline:`none`},".cm-link-menu button.on":{background:`var(--lattice-soft)`},".cm-link-menu:focus-visible button.on":{outline:`2px solid var(--focus-ring)`,outlineOffset:`-2px`}}),je.of(pi)];function hi(e){return t=>{let n=t.matchBefore(/\[\[[^\]\n]*$/);if(!n)return null;let r=e().map(e=>({label:e.title,detail:e.folder,apply:(t,n,r,i)=>{let a=`[${e.title}](/${e.id}.md)`,o=r-2,s=t.state.sliceDoc(i,i+2)===`]]`?i+2:i;t.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}})}}));return{from:n.from+2,options:r,filter:!0,validFor:/^[^\]\n]*$/}}}function gi(e){return t=>{let n=t.matchBefore(/\]\([^)\s]*$/);return n?{from:n.from+2,options:e().map(e=>({label:`/${e.id}.md`,detail:e.title})),validFor:/^[^)\s]*$/}:null}}function _i(e){return at({override:[hi(e),gi(e)],icons:!1,activateOnTyping:!0})}var vi=36,yi=92,bi=40,xi=/^\$\$([^$]*?[^\\])\$\$/,Si=/^\$((?:[^\s\\])|(?:\S.*?[^\s\\]))\$(?!\d)/,Ci=/^\\\((.+?)\\\)/,wi=/^\$\$([^$]*?[^\\])\$\$(?:[ \t]*\([^)\s]+?\))?(?=[ \t]*(?:\n|$))/,Ti=/^\\\[([\s\S]+?)\\\](?:[ \t]*\([^)$\r\n]+?\))?(?=[ \t]*(?:\n|$))/;function Ei(e,t,n){if(t===vi){if(n>e.offset&&e.char(n-1)===yi)return-1;let t=e.slice(n,e.end),r=(t.charCodeAt(1)===vi?xi:Si).exec(t);return r?e.addElement(e.elt(`InlineMath`,n,n+r[0].length,[e.elt(`MathMark`,n,n+(r[0].startsWith(`$$`)?2:1)),e.elt(`MathMark`,n+r[0].length-(r[0].startsWith(`$$`)?2:1),n+r[0].length)])):-1}if(t===yi&&e.char(n+1)===bi){let t=Ci.exec(e.slice(n,e.end));if(!t)return-1;let r=n+t[0].length;return e.addElement(e.elt(`InlineMath`,n,r,[e.elt(`MathMark`,n,n+2),e.elt(`MathMark`,r-2,r)]))}return-1}var Di=2e4;function Oi(e,t){let n=t.text.slice(t.pos),r=n.startsWith(`$$`)?wi:n.startsWith(`\\[`)?Ti:null;if(!r)return!1;let i=e.lineStart+t.pos,a=e.input,o=r.exec(a.read(i,Math.min(a.length,i+Di)));if(!o)return!1;let s=i+o[0].length;for(;e.lineStart+t.text.length<s&&e.nextLine(););return e.addElement(e.elt(`BlockMath`,i,s)),e.nextLine(),!0}var ki={defineNodes:[{name:`InlineMath`,style:I.special(I.content)},{name:`BlockMath`,block:!0,style:I.special(I.content)},{name:`MathMark`,style:I.processingInstruction}],parseInline:[{name:`InlineMath`,parse:Ei,before:`Escape`}],parseBlock:[{name:`BlockMath`,parse:Oi,before:`FencedCode`}]};function Ai(e){let t;return(t=/^\$\$([\s\S]*?)\$\$/.exec(e))||(t=/^\\\[([\s\S]*?)\\\]/.exec(e))?{tex:t[1],display:!0}:(t=/^\\\(([\s\S]*?)\\\)$/.exec(e))||(t=/^\$([\s\S]*?)\$$/.exec(e))?{tex:t[1],display:!1}:{tex:e,display:!1}}var ji=class extends F{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-bullet`,e.textContent=`•`,e}},Mi=class extends F{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-hr`,e}},Ni=class extends F{name;constructor(e){super(),this.name=e}eq(e){return e.name===this.name}toDOM(){let e=document.createElement(`span`);return e.className=`cm-lp-lang`,e.textContent=this.name,e}},Pi=class extends F{source;constructor(e){super(),this.source=e}eq(e){return e.source===this.source}toDOM(){let e=document.createElement(`span`);e.className=`cm-lp-imaths`;let{tex:t,display:n}=Ai(this.source);return e.innerHTML=we.renderToString(t,{displayMode:n,throwOnError:!1}),e}},Q=L.replace({}),Fi=L.replace({widget:new ji}),Ii=L.replace({widget:new Mi}),$=e=>L.mark({class:e}),Li=e=>L.line({class:e});function Ri(e,t){let n=new Set;if(!t)return n;for(let t of e.selection.ranges){let r=e.doc.lineAt(t.from).number,i=e.doc.lineAt(t.to).number;for(let e=r;e<=i;e++)n.add(e)}return n}function zi(e){let{state:t}=e,n=Ri(t,e.hasFocus),r=e=>n.has(t.doc.lineAt(e).number),i=[],a=(e,n,r)=>{for(let a=t.doc.lineAt(e).number,o=t.doc.lineAt(n).number;a<=o;a++)i.push(Li(r).range(t.doc.line(a).from))},o=e.visibleRanges;if(o.length){let e=o[0].from,s=o[o.length-1].to,c=/^ {0,3}([-*_])(?: *\1){2,} *$/,l=t.doc.lineAt(e).number,u=t.doc.lineAt(s).number,d=e=>e>=1&&e<=t.doc.lines?t.doc.line(e).text:``;for(let e=l;e<=u;e++){let r=t.doc.line(e);if(r.length!==0||/Code|Math|HTML|Comment/.test(M(t).resolveInner(r.from,1).name))continue;let a=e>1&&t.doc.line(e-1).length===0&&!n.has(e),o=c.test(d(e-1))||c.test(d(e+1));i.push(Li(a?`cm-lp-gap cm-lp-gap-more`:o?`cm-lp-gap cm-lp-gap-rule`:`cm-lp-gap`).range(r.from))}M(t).iterate({from:e,to:s,enter:e=>{let n=e.name,o=/^(?:ATX|Setext)Heading(\d)$/.exec(n);if(o)a(e.from,e.to,`cm-lp-h${o[1]}`);else switch(n){case`HeaderMark`:{if(r(e.from))break;if((e.node.parent?.name??``).startsWith(`SetextHeading`)){i.push(Q.range(t.doc.lineAt(e.from).from,e.to));break}let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;n>e.from&&i.push(Q.range(e.from,n));break}case`EmphasisMark`:case`StrikethroughMark`:r(e.from)||i.push(Q.range(e.from,e.to));break;case`Emphasis`:i.push($(`cm-lp-em`).range(e.from,e.to));break;case`StrongEmphasis`:i.push($(`cm-lp-strong`).range(e.from,e.to));break;case`Strikethrough`:i.push($(`cm-lp-strike`).range(e.from,e.to));break;case`InlineCode`:if(i.push($(`cm-lp-code`).range(e.from,e.to)),!r(e.from)){let t=e.node;for(let e=t.firstChild;e;e=e.nextSibling)e.name===`CodeMark`&&i.push(Q.range(e.from,e.to))}return!1;case`InlineMath`:return r(e.from)?i.push($(`cm-lp-mathsrc`).range(e.from,e.to)):i.push(L.replace({widget:new Pi(t.sliceDoc(e.from,e.to))}).range(e.from,e.to)),!1;case`BlockMath`:case`Table`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`Link`:{let n=e.node,a=[],o=!1;for(let e=n.firstChild;e;e=e.nextSibling)e.name===`LinkMark`&&a.push(e),e.name===`URL`&&(o=!0);let s=a[0],c=a[1],l=n.getChild(`URL`),u=l?t.sliceDoc(l.from,l.to):``,d=u.startsWith(`code:`),f=/^https?:/i.test(u),p=d?t.facet(Bi)(u)?`cm-lp-link cm-lp-codelink cm-lp-broken`:`cm-lp-link cm-lp-codelink`:f?`cm-lp-link cm-lp-weblink`:`cm-lp-link`;s&&c&&c.from>s.to&&i.push((d?L.mark({class:p,attributes:{title:t.facet(Bi)(u)?`${u.slice(5)}: not in the repository`:u.slice(5)}}):$(p)).range(s.to,c.from)),!r(e.from)&&o&&s&&c&&(i.push(Q.range(s.from,s.to)),i.push(Q.range(c.from,e.to)));break}case`ListMark`:{let n=t.sliceDoc(e.from,e.to);!r(e.from)&&/^[-*+]$/.test(n)?i.push(Fi.range(e.from,e.to)):i.push($(`cm-lp-listmark`).range(e.from,e.to));break}case`TaskMarker`:i.push($(`cm-lp-task`).range(e.from,e.to));break;case`Blockquote`:a(e.from,e.to,`cm-lp-quote`);break;case`QuoteMark`:if(!r(e.from)){let n=t.sliceDoc(e.to,e.to+1)===` `?e.to+1:e.to;i.push(Q.range(e.from,n))}break;case`HorizontalRule`:r(e.from)||(i.push(Ii.range(e.from,e.to)),a(e.from,e.to,`cm-lp-ruleline`));break;case`FencedCode`:{a(e.from,e.to,`cm-lp-codeblock`);let n=e.node,o=t.doc.lineAt(e.from),s=t.doc.lineAt(e.to),c=n.getChild(`CodeInfo`),l=n.lastChild?.name===`CodeMark`&&n.lastChild.from>=s.from?n.lastChild:null;if(!r(o.from)){i.push(Li(`cm-lp-fence`).range(o.from));let e=c?t.sliceDoc(c.from,c.to).trim().split(/\s/)[0]:``;i.push((e?L.replace({widget:new Ni(e)}):Q).range(o.from,o.to))}return l&&s.number>o.number&&!r(s.from)&&(i.push(Li(`cm-lp-fence`).range(s.from)),s.to>s.from&&i.push(Q.range(s.from,s.to))),!1}case`CodeBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1;case`HTMLBlock`:case`CommentBlock`:return a(e.from,e.to,`cm-lp-codeblock`),!1}}})}i.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide);let s=new Ge;for(let e of i)s.add(e.from,e.to,e.value);return s.finish()}var Bi=Ve.define({combine:e=>e[0]??(()=>!1)}),Vi=Fe.fromClass(class{decorations;constructor(e){this.decorations=zi(e)}update(e){(e.docChanged||e.viewportChanged||e.selectionSet||e.focusChanged||M(e.startState)!==M(e.state))&&(this.decorations=zi(e.view))}},{decorations:e=>e.decorations}),Hi=N.theme({".cm-scroller":{fontFamily:`var(--font-text)`,fontSize:`var(--text-size)`,lineHeight:`1.55`},".cm-lp-gap":{lineHeight:`20px`},".cm-lp-gap-rule":{lineHeight:`10px`},".cm-lp-gap-more":{lineHeight:`4px`},".cm-lp-ruleline":{lineHeight:`12px`},".cm-content":{fontVariationSettings:`"opsz" 18`},".cm-lp-h1, .cm-lp-h2, .cm-lp-h3, .cm-lp-h4, .cm-lp-h5, .cm-lp-h6":{fontWeight:`600`,lineHeight:`1.3`,fontVariationSettings:`"opsz" 36`,paddingTop:`.5em !important`},".cm-lp-h1":{fontSize:`26px`},".cm-lp-h2":{fontSize:`22px`},".cm-lp-h3":{fontSize:`19px`},".cm-lp-h4":{fontSize:`17px`,fontWeight:`700`},".cm-lp-em":{fontStyle:`italic`},".cm-lp-strong":{fontWeight:`700`},".cm-lp-strike":{textDecoration:`line-through`},".cm-lp-code":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,background:`color-mix(in srgb, var(--text) 8%, transparent)`,padding:`.1em .2em`},".cm-lp-link":{color:`var(--lattice)`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-lp-weblink":{textDecorationStyle:`dotted`},".cm-lp-codelink":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,textDecoration:`none`,borderBottom:`1px solid color-mix(in srgb, var(--lattice) 50%, transparent)`},".cm-lp-broken":{color:`var(--rose)`,textDecoration:`line-through`,borderBottomColor:`transparent`},".cm-lp-bullet":{color:`var(--text-faint)`,display:`inline-block`,minWidth:`1ch`},".cm-lp-listmark, .cm-lp-task":{color:`var(--text-faint)`,fontFamily:`var(--font-mono)`},".cm-lp-quote":{borderLeft:`3px solid var(--lattice)`,paddingLeft:`14px !important`,color:`var(--text-soft)`},".cm-lp-codeblock":{fontFamily:`var(--font-mono)`,fontSize:`13px`,lineHeight:`20px`,background:`color-mix(in srgb, var(--line) 38%, transparent)`,borderLeft:`2px solid var(--line-strong)`,padding:`0 16px !important`},".cm-lp-codeblock.cm-lp-fence":{lineHeight:`12px`,position:`relative`},".cm-lp-lang":{position:`absolute`,top:`8px`,right:`12px`,fontFamily:`var(--font-ui)`,fontSize:`12px`,lineHeight:`16px`,color:`var(--text-faint)`,pointerEvents:`none`},".cm-lp-mathsrc":{fontFamily:`var(--font-mono)`,fontSize:`.86em`,color:`var(--text-soft)`},".cm-lp-imaths .katex":{fontSize:`1.05em`},".cm-lp-imaths .katex-display":{margin:`0`,padding:`6px 0`},".cm-lp-imaths .katex-display > .katex":{fontSize:`1.17em`},".cm-lp-hr":{display:`inline-block`,width:`100%`,borderTop:`1px solid var(--line)`,verticalAlign:`middle`}});function Ui(e){let t=e.split(`#`)[0];return t.startsWith(`/`)&&t.endsWith(`.md`)?t.slice(1,-3):null}var Wi=Xe.define(),Gi=Xe.define(),Ki=[R.define({create:()=>L.none,update(e,t){for(let e of t.effects){if(!e.is(Gi))continue;let n=t.state.doc,r=e.value;if(!r)return L.none;let i=L.line({class:`cm-touched cm-touched-${r.who}`});return L.set([...new Set(r.lines)].filter(e=>e>=0&&e<n.lines&&n.line(e+1).text.trim()!==``).sort((e,t)=>e-t).map(e=>i.range(n.line(e+1).from)))}return t.docChanged?e.map(t.changes):e},provide:e=>N.decorations.from(e)}),N.theme({".cm-line.cm-touched-you":{background:`var(--lattice-soft)`,boxShadow:`-10px 0 0 var(--lattice-soft), -13px 0 0 var(--lattice), 10px 0 0 var(--lattice-soft)`},".cm-line.cm-touched-iso":{background:`var(--growth-soft)`,boxShadow:`-10px 0 0 var(--growth-soft), -13px 0 0 var(--growth), 10px 0 0 var(--growth-soft)`}})],qi=Xe.define(),Ji=class extends F{key;mount;block;down=null;watch=null;constructor(e,t,n){super(),this.key=e,this.mount=t,this.block=n}eq(e){return e.key===this.key&&e.block===this.block}toDOM(e){let t=document.createElement(this.block?`div`:`span`);return t.className=this.block?`cm-overlay`:`cm-iso-change`,t.contentEditable=`false`,this.down=this.mount(t,this.key),this.watch=new ResizeObserver(()=>e.requestMeasure()),this.watch.observe(t),t}destroy(){this.watch?.disconnect(),this.watch=null,this.down?.(),this.down=null}ignoreEvent(){return!0}get estimatedHeight(){return this.block?120:-1}};function Yi(e){return[R.define({create:()=>L.none,update(t,n){for(let t of n.effects){if(!t.is(Wi))continue;let r=n.state.doc;return L.set(t.value.map(t=>{let n=t.line>=r.lines,i=n?r.length:r.line(Math.max(1,t.line+1)).from;return L.widget({widget:new Ji(t.key,e,!0),block:!0,side:n?1:-1}).range(i)}),!0)}return n.docChanged?t.map(n.changes):t},provide:e=>N.decorations.from(e)}),R.define({create:()=>L.none,update(t,n){for(let t of n.effects){if(!t.is(qi))continue;let r=n.state.doc.length,i=[];for(let e of t.value.marks){let t=Math.max(0,Math.min(r,e.from)),n=Math.max(0,Math.min(r,e.to));n>t&&i.push(L.mark({class:`cm-iso-${e.kind}`}).range(t,n))}for(let n of t.value.inline)i.push(L.widget({widget:new Ji(n.key,e,!1),side:1}).range(Math.max(0,Math.min(r,n.at))));return L.set(i,!0)}return n.docChanged?t.map(n.changes):t},provide:e=>N.decorations.from(e)}),N.theme({".cm-overlay":{cursor:`default`,userSelect:`text`,padding:`10px 0`,display:`flow-root`,whiteSpace:`normal`},".cm-iso-picked":{background:`var(--lattice-soft)`,boxShadow:`inset 0 -2px 0 var(--lattice)`,cursor:`pointer`},".cm-iso-old":{textDecoration:`line-through`,textDecorationColor:`var(--text-faint)`,color:`var(--text-faint)`},".cm-iso-old *":{color:`var(--text-faint) !important`},".cm-iso-change":{cursor:`default`},".cm-iso-by-iso":{background:`var(--growth-soft)`,boxShadow:`inset 0 -1.5px 0 var(--growth)`},".cm-iso-given":{textDecoration:`underline dashed var(--growth)`,textUnderlineOffset:`4px`,textDecorationThickness:`1.5px`}})]}function Xi(e){let t=e.split(`#`)[0].split(`?`)[0];return!t.startsWith(`/`)||t.startsWith(`//`)?null:t.endsWith(`.md`)?{id:decodeURIComponent(t.slice(1,-3)),folder:!1}:t.endsWith(`/`)&&t.length>1?{id:decodeURIComponent(t.slice(1,-1)),folder:!0}:null}var Zi=Xe.define(),Qi=L.mark({class:`cm-pointed`});function $i(e,t){if(!t)return L.none;let n=[];return M(e).iterate({enter:r=>{if(r.name!==`Link`)return;let i=J(e,r.from+1);return i&&!i.embed&&i.from===r.from&&Xi(i.url)?.id===t&&n.push(Qi.range(i.from,i.to)),!1}}),L.set(n)}var ea=R.define({create:()=>({id:``,marks:L.none}),update(e,t){let n=e.id;for(let e of t.effects)e.is(Zi)&&(n=e.value);return n!==e.id||n&&t.docChanged?{id:n,marks:$i(t.state,n)}:e},provide:e=>N.decorations.from(e,e=>e.marks)}),ta=N.theme({".cm-pointed":{backgroundColor:`var(--lattice-soft)`,boxShadow:`0 2px 0 var(--lattice)`}});function na(e){if(!e)return[ea,ta];let t=``,n=n=>{let r=n?`${n.folder?`d`:`n`}:${n.id}`:``;r!==t&&(t=r,e(n))};return[ea,ta,N.domEventHandlers({pointermove(e,t){if(e.pointerType!==`mouse`)return!1;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:J(t.state,r);return n(i&&!i.embed?Xi(i.url):null),!1},pointerleave(){return n(null),!1}})]}var ra=N.theme({".cm-scroller":{fontFamily:`var(--font-mono)`,fontSize:`14px`,lineHeight:`1.6`}}),ia=N.theme({"&":{color:`var(--text)`,backgroundColor:`transparent`,fontSize:`16px`},"&.cm-focused":{outline:`none`},".cm-scroller":{overflow:`visible`},".cm-content":{padding:`12px 0 40vh`,caretColor:`var(--lattice)`},".cm-line":{padding:`0 2px`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--lattice)`,borderLeftWidth:`2px`},".cm-selectionBackground":{backgroundColor:`color-mix(in srgb, var(--lattice) 22%, transparent) !important`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`color-mix(in srgb, var(--lattice) 40%, transparent) !important`},".cm-placeholder":{color:`var(--text-faint)`},".cm-tooltip-autocomplete":{background:`var(--ground-1)`,border:`1px solid var(--line-strong)`,fontFamily:`var(--font-ui)`,fontSize:`13px`},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:`var(--font-ui)`,maxHeight:`16em`},".cm-tooltip-autocomplete > ul > li":{padding:`6px 10px !important`,lineHeight:`1.3`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{background:`var(--lattice-soft)`,color:`var(--text)`},".cm-completionDetail":{color:`var(--text-faint)`,fontStyle:`normal`,marginLeft:`10px`}}),aa=Ze.define([{tag:I.heading,fontWeight:`700`,color:`var(--text)`},{tag:I.strong,fontWeight:`700`},{tag:I.emphasis,fontStyle:`italic`},{tag:I.strikethrough,textDecoration:`line-through`},{tag:[I.link,I.url],color:`var(--lattice)`},{tag:[I.processingInstruction,I.punctuation,I.contentSeparator],color:`var(--text-faint)`},{tag:I.monospace,color:`var(--text-soft)`},{tag:I.quote,color:`var(--text-soft)`,fontStyle:`italic`}]);function oa(e){let t=e.selection.main;return{line:e.doc.lineAt(t.to).number-1,from:t.from,to:t.to}}function sa(e,t){let n=He.create({doc:t.doc,extensions:[At(),Re(),N.lineWrapping,Se({base:fe,extensions:[ki],completeHTMLTags:!1,codeLanguages:ye}),Me(aa),Me(ue),ia,...t.source?[ra]:[Vi,Hi,Hr,Ur,mi,...t.embeds?[Mr.of(t.embeds)]:[],...t.codeBroken?[Bi.of(t.codeBroken)]:[]],st(),He.languageData.of(()=>[{closeBrackets:{brackets:[`(`,`[`]}}]),...t.mountOverlay?[Yi(t.mountOverlay)]:[],Ki,na(t.onPoint),...t.readOnly?[He.readOnly.of(!0),N.editable.of(!1)]:[],_i(t.notes),Pe(t.placeholder??`Write the note here. # for a heading, [[ to link to another note, $x$ for maths.`),N.contentAttributes.of({"aria-label":t.label,spellcheck:`true`,autocapitalize:`sentences`,autocorrect:`on`}),je.of([{key:`Mod-s`,preventDefault:!0,run:()=>(t.onSave(),!0)},{key:`Mod-Enter`,preventDefault:!0,run:e=>(t.onAsk?.(oa(e.state)),!!t.onAsk)},...Yr,...rt,...ot,jr,...Ar,...qt]),N.domEventHandlers((()=>{let e=(e,n)=>{if(!t.picking?.())return;let r=e.state.selection,i=r.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to}));i.length?(t.onPick?.(i),setTimeout(()=>e.dispatch({selection:{anchor:Math.min(r.main.head,e.state.doc.length)}}),0)):n&&t.onUnpick?.(r.main.head)};return{mouseup:(t,n)=>(e(n,t.detail===1),!1),touchend:(t,n)=>(e(n,!1),!1),keyup:(t,n)=>(t.key===`Shift`&&e(n,!1),!1)}})()),N.domEventHandlers({mousedown(e,n){if(!t.onFollow||!(e.ctrlKey||e.metaKey)||e.button!==0)return!1;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=r===null?null:J(n.state,r),a=i&&!i.embed?Ui(i.url):null;return a!==null&&(e.preventDefault(),t.onFollow(a),!0)}}),N.updateListener.of(e=>{e.docChanged&&t.onChange(e.state.doc.toString()),t.onCursor&&(e.selectionSet||e.docChanged)&&t.onCursor(oa(e.state))})]});return new N({state:n,parent:e})}function ca(e,t){if(t===e.state.doc.toString())return;let n=Math.min(e.state.selection.main.head,t.length);e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},selection:{anchor:n}})}var la=C(`<span class="soft picked svelte-192cp36" role="status"> </span>`),ua=C(`<div class="between svelte-192cp36"><!> <div class="ask svelte-192cp36"><i class="dia open svelte-192cp36" aria-hidden="true"></i> <textarea rows="1" aria-label="Ask Iso" class="svelte-192cp36"></textarea></div> <div class="foot svelte-192cp36"><span class="grow"></span> <button class="link faint svelte-192cp36" type="button">cancel</button> <button class="btn primary" type="button">ask Iso</button></div></div>`),da=C(`<div class="prose said svelte-192cp36"></div>`),fa=C(`<span class="faint"> </span>`),pa=C(`<div class="between working svelte-192cp36" aria-live="polite"><!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="soft doing svelte-192cp36"> <!></span> <span class="grow"></span> <button class="link svelte-192cp36" type="button">stop</button></div></div>`),ma=C(`<div class="between stopped svelte-192cp36" role="alert"><p class="bad svelte-192cp36"> </p> <div class="foot svelte-192cp36"><span class="grow"></span><button class="link svelte-192cp36" type="button">dismiss</button></div></div>`),ha=C(`<p class="soft lost svelte-192cp36"><span class="strike svelte-192cp36"> </span> </p>`),ga=C(`<div class="between stopped svelte-192cp36"><p class="label"> </p> <!> <div class="foot svelte-192cp36"><span class="grow"></span><button class="btn remove" type="button">remove</button></div></div>`),_a=C(`<p class="label">The place this was written for is no longer in the note, so it is shown here. Keeping it adds it at the end.</p>`),va=C(`<textarea class="revision svelte-192cp36" aria-label="Iso's text, to edit"></textarea>`),ya=C(`<p class="label"> </p>`),ba=C(`<button class="btn edit" type="button">done</button>`),xa=C(`<button class="btn edit" type="button">edit</button>`),Sa=C(`<div class="between svelte-192cp36"><!> <!> <!> <div class="foot svelte-192cp36"><i class="dia svelte-192cp36" aria-hidden="true"></i> <span class="grow"></span> <button class="btn keep" type="button">keep</button> <!> <button class="btn remove" type="button">remove</button></div></div>`);function Ca(n,i){E(i,!0);let l=S(i,`iso`,7),u=O(()=>i.key.startsWith(`p:`)?l().proposals.find(e=>e.id===i.key.slice(2)):void 0),x=O(()=>c(u)&&l().editing?.id===c(u).id?l().editing:null),C=O(()=>!!c(u)&&l().busy===c(u)?.id),T=O(()=>l().changes.filter(e=>!e.at)),k=e(``),A=e(void 0);m(()=>{i.key===`prompt`&&ie().then(()=>c(A)?.focus())});let ae=O(()=>l().asking?.steps.at(-1)?.said??``),oe=O(()=>(l().asking?.regions.length??0)>0),se=O(()=>l().prompt?.mode===`rewrite`),ce=O(()=>l().prompt?.regions.length??0),le=O(()=>!!c(k).trim()&&(!c(se)||c(ce)>0));function ue(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),l().ask(c(k))):e.key===`Escape`&&(e.preventDefault(),l().prompt=null)}var de=t(),fe=s(de),pe=e=>{var t=ua(),n=D(t),i=e=>{var t=la(),n=g(t,!0);o(()=>r(n,c(ce)===0?`select text in the note to rewrite`:`rewriting ${c(ce)} ${c(ce)===1?`passage`:`passages`} · select more, or click one to drop it`)),w(e,t)};p(n,e=>{c(se)&&e(i)});var s=h(n,2),u=h(D(s),2);ee(u),te(u,e=>d(A,e),()=>c(A)),y(s);var f=h(s,2),m=h(D(f),2),_=h(m,2);y(f),y(t),o(()=>{b(u,`placeholder`,c(se)?`how should Iso rewrite it?`:`what should Iso write here?`),_.disabled=!c(le)}),a(`keydown`,u,ue),ne(u,()=>c(k),e=>d(k,e)),a(`click`,m,()=>l().prompt=null),a(`click`,_,()=>l().ask(c(k))),w(e,t)},me=e=>{var t=pa(),n=D(t),i=e=>{var t=da();re(t,()=>he(l().asking.text),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>l().asking.text),w(e,t)};p(n,e=>{l().asking.text&&!c(oe)&&e(i)});var s=h(n,2),u=h(D(s),2),d=D(u,!0),f=h(d),m=e=>{var t=fa(),n=g(t);o(()=>r(n,`· ${c(ae)??``}`)),w(e,t)};p(f,e=>{c(ae)&&e(m)}),y(u);var v=h(u,4);y(s),y(t),o(()=>r(d,l().asking.text?c(oe)?`Iso is rewriting`:`Iso is writing`:`Iso is thinking`)),a(`click`,v,()=>l().halt()),w(e,t)},ge=e=>{var t=ma(),n=D(t),i=g(n,!0),s=h(n,2),c=h(D(s));y(s),y(t),o(()=>r(i,l().failed.message)),a(`click`,c,()=>l().failed=null),w(e,t)},_e=e=>{var t=ga(),n=D(t),i=g(n),s=h(n,2);f(s,17,()=>c(T),e=>e.key,(e,t)=>{var n=ha(),i=D(n),a=g(i,!0),s=h(i);y(n),o((e,t)=>{r(a,e),r(s,` → ${t??``}`)},[()=>c(t).proposal.regions[c(t).k].old.text.trim(),()=>c(t).proposal.regions[c(t).k].new.trim()||`(taken out)`]),w(e,n)});var u=h(s,2),d=h(D(u));y(u),y(t),o(()=>r(i,`${c(T).length===1?`One change Iso offered is`:`${c(T).length} changes Iso offered are`} for text that is no longer in the note as it was, so ${c(T).length===1?`it`:`they`} cannot be kept.`)),a(`click`,d,()=>{for(let e of c(T))l().discardChange(e)}),w(e,t)},ve=e=>{var t=Sa(),n=D(t),i=e=>{var t=_a();w(e,t)},s=O(()=>!l().placed(c(u)));p(n,e=>{c(s)&&e(i)});var d=h(n,2),f=e=>{var t=va();ee(t),o(e=>b(t,`rows`,e),[()=>Math.max(3,c(x).text.split(`
6
- `).length+1)]),ne(t,()=>c(x).text,e=>c(x).text=e),w(e,t)},m=e=>{var t=da();re(t,()=>he(c(u).text),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>({given:c(u).text,copy:!0})),w(e,t)};p(d,e=>{c(x)?e(f):e(m,-1)});var v=h(d,2),S=e=>{var t=ya(),n=g(t,!0);o(()=>r(n,c(u).notice)),w(e,t)};p(v,e=>{c(u).notice&&e(S)});var T=h(v,2),E=h(D(T),4),te=h(E,2),ie=e=>{var t=ba();a(`click`,t,()=>l().done(c(u))),w(e,t)},k=e=>{var t=xa();o(()=>t.disabled=c(C)),a(`click`,t,()=>l().edit(c(u))),w(e,t)};p(te,e=>{c(x)?e(ie):e(k,-1)});var A=h(te,2);y(T),y(t),o(()=>{b(t,`data-proposal`,c(u).id),E.disabled=c(C),A.disabled=c(C)}),a(`click`,E,()=>l().keep(c(u))),a(`click`,A,()=>l().discard(c(u))),w(e,t)};p(fe,e=>{i.key===`prompt`?e(pe):i.key===`asking`&&l().asking?e(me,1):i.key===`failed`&&l().failed?e(ge,2):i.key===`lost`&&c(T).length?e(_e,3):c(u)&&e(ve,4)}),w(n,de),v()}u([`keydown`,`click`]);var wa=C(`<span class="label who svelte-1o10yjh"> </span>`),Ta=C(`<!> <span class="act svelte-1o10yjh"><button class="keep svelte-1o10yjh" type="button" aria-label="Keep this change">keep</button><button class="remove svelte-1o10yjh" type="button" aria-label="Remove this change">remove</button></span>`,1),Ea=C(`<span class="gone svelte-1o10yjh">the passage above is taken out</span>`),Da=C(`<pre class="new svelte-1o10yjh"> </pre>`),Oa=C(`<div class="new prose svelte-1o10yjh"></div>`),ka=C(`<div><!> <div class="foot svelte-1o10yjh"><i class="dia svelte-1o10yjh" aria-hidden="true"></i><span class="label">in place of the lines struck through above</span><span class="grow"></span><!></div></div>`),Aa=C(`<span class="new svelte-1o10yjh"></span>`),ja=C(`<span class="gone svelte-1o10yjh">taken out</span>`),Ma=C(`<span class="change svelte-1o10yjh"><!> <!></span>`);function Na(e,n){E(n,!0);let i=e=>{var t=Ta(),i=s(t),u=e=>{var t=wa(),n=g(t,!0);o(()=>{b(t,`title`,c(l)?.proposal.asked),r(n,c(S))}),w(e,t)};p(i,e=>{c(S)&&e(u)});var f=h(i,2),m=D(f),_=h(m);y(f),o(()=>{m.disabled=c(d),_.disabled=c(d)}),a(`click`,m,()=>c(l)&&n.iso.keepChange(c(l))),a(`click`,_,()=>c(l)&&n.iso.discardChange(c(l))),w(e,t)},l=O(()=>n.iso.changes.find(e=>e.key===n.key)),u=O(()=>c(l)?c(l).proposal.regions[c(l).k].new:``),d=O(()=>n.iso.busy===n.key||n.iso.busy===`all`),f=O(()=>he(c(u).trim())),m=O(()=>c(f).replace(/^<p>([\s\S]*)<\/p>\s*$/,`$1`)),S=O(()=>c(l)?me(c(l).proposal.who):``);var C=t(),T=s(C),ee=e=>{var t=ka();let a;var s=D(t),d=e=>{var t=Ea();w(e,t)},m=O(()=>!c(u).trim()),v=e=>{var t=Da(),n=g(t,!0);o(e=>r(n,e),[()=>c(u).replace(/^\n+|\s+$/g,``)]),w(e,t)},S=e=>{var t=Oa();re(t,()=>c(f),!0),y(t),_(t,(e,t)=>Ce?.(e,t),()=>c(f)),w(e,t)};p(s,e=>{c(m)?e(d):c(l).code?e(v,1):e(S,-1)});var C=h(s,2),T=h(D(C),3);i(T),y(C),y(t),o(()=>{a=x(t,1,`change block svelte-1o10yjh`,null,a,{code:c(l).code}),b(t,`data-change`,n.key)}),w(e,t)},te=e=>{var t=Ma(),r=D(t),a=e=>{var t=Aa();re(t,()=>c(m),!0),y(t),w(e,t)},s=O(()=>c(u).trim()),l=e=>{var t=ja();w(e,t)};p(r,e=>{c(s)?e(a):e(l,-1)});var d=h(r,2);i(d),y(t),o(()=>b(t,`data-change`,n.key)),w(e,t)};p(T,e=>{c(l)?.block?e(ee):c(l)&&e(te,1)}),w(e,C),v()}u([`click`]);var Pa=C(`<div></div>`);function Fa(t,r){E(r,!0);let a=S(r,`iso`,7),s=S(r,`touched`,3,null),u=S(r,`lens`,19,()=>[]),f,p=e(void 0),h=O(()=>r.source||!a()?{lines:0,chars:0}:a().head),g=O(()=>{if(!a())return{blocks:[],marks:[],inline:[]};let e=e=>t=>({kind:e,from:t.from-c(h).chars,to:t.to-c(h).chars});return{blocks:a().layout.blocks.map(e=>({key:e.key,line:Math.max(0,e.line-c(h).lines)})).sort((e,t)=>e.line-t.line),marks:[...a().layout.picked.map(e(`picked`)),...a().layout.old.map(e(`old`)),...u().map(t=>e(t.kind)(t))].filter(e=>e.to>0),inline:a().layout.inline.map(e=>({key:e.key,at:e.at-c(h).chars})).filter(e=>e.at>=0)}});T(()=>{let e=sa(f,{doc:r.source?r.note.text:r.note.body,source:r.source,label:r.source?`The note's file`:`The note`,notes:()=>j.listing.notes.filter(e=>e.id!==r.note.id).map(e=>({id:e.id,title:e.title,folder:e.dir})),onChange:e=>r.source?r.note.setText(e):r.note.setBody(e),onSave:()=>{r.note.save()},onFollow:e=>{k(ke(e))},embeds:{find:Oe,open:e=>{k(ke(e))}},onPoint:e=>pe.set(`note`,e?{...e,who:`you`}:null),codeBroken:e=>j.listing.notes.find(e=>e.id===r.note.id)?.broken?.includes(e)??!1,...a()?{onAsk:e=>{let t=r.note.text.slice(e.from+c(h).chars,e.to+c(h).chars).trim();t&&_e.add({kind:`passage`,id:r.note.id,title:r.note.fields.title||r.note.id,text:t}),Ae.to(`iso`),requestAnimationFrame(()=>document.getElementById(`iso-box`)?.focus())},onCursor:e=>{a().cursor={line:e.line+c(h).lines,from:e.from+c(h).chars,to:e.to+c(h).chars}},picking:()=>a().picking,onPick:e=>a().pick(e.map(e=>({from:e.from+c(h).chars,to:e.to+c(h).chars}))),onUnpick:e=>a().unpick(e+c(h).chars),mountOverlay:(e,t)=>{let n=i(t.startsWith(`r:`)?Na:Ca,{target:e,props:{iso:a(),key:t}});return()=>{l(n)}}}:{placeholder:n(()=>r.placeholder)??`Write what you understand, what you do not, and what you want from Iso. [[ links a note it should rest on.`}});return d(p,e),()=>{e.destroy(),pe.set(`note`,null)}}),m(()=>{r.note.revision,n(()=>{c(p)&&ca(c(p),r.source?r.note.text:r.note.body)})}),m(()=>{let e=s(),t=c(h).lines;c(p)&&c(p).dispatch({effects:Gi.of(e?{who:e.who,lines:e.lines.map(e=>e-t)}:null)})}),m(()=>{let e=pe.onAtlas;c(p)&&c(p).dispatch({effects:Zi.of(e)})}),m(()=>{let{blocks:e,marks:t,inline:n}=c(g);c(p)&&c(p).dispatch({effects:[Wi.of(e),qi.of({marks:t,inline:n})]})});var _=Pa();let y;te(_,e=>f=e,()=>f),o(()=>y=x(_,1,`editor svelte-hrl8lz`,null,y,{source:r.source})),w(t,_),v()}export{pt as a,Gi as i,sa as n,ct as o,ca as r,Fa as t};
@@ -1 +0,0 @@
1
- import{$ as e,L as t,Q as n}from"./nMarIA7J.js";import{o as r}from"./BNjH_DUx.js";var i=class extends Error{status;current;constructor(e,t,n){super(e),this.status=t,this.current=n}};function a(e=new URL(`api/`,document.baseURI).href){let t=null,n=async(t,n)=>{let r;try{r=await fetch(e+t,n)}catch{throw new i(`isorite is not answering`,0)}let a=await r.json().catch(()=>({}));if(!r.ok)throw new i(a.error??r.statusText,r.status,a.current);return a},r=()=>n(`session`),a=async(e,i,a)=>{t??=r().then(e=>e.token);let o={"Content-Type":`application/json`,"x-isorite-token":await t};return n(i,{method:e,headers:o,body:JSON.stringify(a)})},o=e=>`?id=${encodeURIComponent(e)}`;return{session:async()=>{let{token:e,...n}=await r();return t=Promise.resolve(e),n},notes:()=>n(`notes`),readNote:e=>n(`note`+o(e)),saveNote:(e,t)=>a(`PUT`,`note`+o(e),t),createNote:(e,t)=>a(`POST`,`note`+o(e),{text:t}),journal:e=>n(`journal`+o(e)),version:async(e,t)=>(await n(`version`+o(e)+`&entry=`+encodeURIComponent(t))).text,moveNote:(e,t,n)=>a(`POST`,`note/move`+o(e),{to:t,base:n}),deleteNote:async(e,t)=>{await a(`POST`,`note/delete`+o(e),{base:t})},restore:(e,t,n)=>a(`POST`,`note/restore`+o(e),{entry:t,base:n}),map:()=>n(`map`),timeline:()=>n(`timeline`),search:e=>n(`search?q=${encodeURIComponent(e)}`),ask:e=>a(`POST`,`iso/ask`,e),converse:e=>a(`POST`,`iso/converse`,e),understanding:e=>n(`understanding`+o(e)),saveScratchpad:(e,t,n)=>a(`POST`,`understanding/scratchpad`+o(e),{scratchpad:t,base:n}),undoTurn:(e,t)=>a(`POST`,`iso/undo`,{conversation:e,turn:t}),setContext:(e,t,n)=>a(`POST`,`iso/context`,{conversation:e,part:t,on:n}),compact:(e,t)=>a(`POST`,`iso/compact`,{conversation:e,...t===void 0?{}:{keep:t}}),branch:e=>a(`POST`,`iso/branch`,{conversation:e}),agents:()=>n(`agents`),saveAgents:e=>a(`POST`,`agents`,{text:e}),takeItem:(e,t,n)=>a(`POST`,`iso/take`,{conversation:e,turn:t,item:n}),nameRepository:async()=>!1,brokenNews:async()=>[],answer:async(e,t,n)=>{await a(`POST`,`iso/answer`,{turn:e,permission:t,decision:n})},conversation:async e=>{let t=await n(`conversation`+(e?o(e):``));return t.id?t:null},turnContext:e=>n(`turn/context?turn=${encodeURIComponent(JSON.stringify(e))}`),stop:async e=>{await a(`POST`,`iso/stop`,{request:e})},keep:(e,t,n)=>a(`POST`,`proposal/keep`+o(e),{proposal:t,...n===void 0?{}:{region:n}}),revise:async(e,t,n)=>{await a(`POST`,`proposal/revise`+o(e),{proposal:t,text:n})},discard:async(e,t,n)=>{await a(`POST`,`proposal/discard`+o(e),{proposal:t,...n===void 0?{}:{region:n}})},drafts:()=>n(`drafts`),createDraft:()=>a(`POST`,`drafts`,{}),keepDraft:(e,t,n)=>a(`POST`,`draft/keep`+o(e),{proposal:t,folder:n}),discardDraft:async e=>{await a(`POST`,`draft/discard`+o(e),{})},setDone:(e,t,n)=>a(`POST`,`note/done`+o(e),{done:t,base:n}),context:(e,t)=>n(`context`+(e?o(e):``)+(t?`${e?`&`:`?`}choice=${encodeURIComponent(JSON.stringify(t))}`:``)),clearConversation:async()=>{await a(`POST`,`context/clear`,{})},settings:()=>n(`settings`),setKey:e=>a(`PUT`,`settings/key`,{key:e}),spend:()=>n(`spend`),setSpendCap:e=>a(`PUT`,`settings/spend-cap`,{usd:e}),connect:e=>a(`POST`,`settings/connect`,{callback:e}),connected:(e,t)=>a(`POST`,`settings/connected`,{code:e,state:t}),agentTools:()=>n(`agent/tools`),agentLook:e=>a(`POST`,`agent/look`,e),agentWrite:e=>a(`POST`,`agent/write`,e),agentSend:e=>a(`POST`,`agent/send`,e),agentReceived:async(e,t)=>{await a(`POST`,`agent/received`,{id:e,agent:t})},agentStatus:async(e,t,n)=>{await a(`POST`,`agent/status`,{agent:e,session:t,busy:n})},setup:{view:()=>n(`settings/provider`),keep:e=>a(`PUT`,`settings/provider`,e),check:e=>a(`POST`,`settings/provider/check`,{draft:e}),models:async e=>(await a(`POST`,`settings/provider/models`,{draft:e})).models,report:async()=>(await a(`POST`,`settings/report`,{})).text},terminal:{view:()=>n(`terminal`),prompt:async(e,t)=>{await a(`POST`,`terminal/prompt`,{asked:e,given:t})},stop:async()=>{await a(`POST`,`terminal/stop`,{})},reply:async(e,t)=>{await a(`POST`,`terminal/permission`,{id:e,decision:t})}},events(t){let n=new EventSource(e+`events`),r=e=>{try{t(JSON.parse(e.data))}catch{}};for(let e of[`note-changed`,`journal`,`record`,`iso-start`,`iso-step`,`iso-text`,`iso-item`,`iso-answer`,`iso-taken`,`iso-done`,`iso-stopped`,`iso-failed`,`iso-retry`,`context`,`agent-start`,`agent-step`,`agent-done`,`agent-sent`,`agent-received`,`terminal`])n.addEventListener(e,r);return()=>n.close()}}}var o=class{api;#e=e(null);get session(){return t(this.#e)}set session(e){n(this.#e,e)}#t=e({notes:[],dirs:[]});get listing(){return t(this.#t)}set listing(e){n(this.#t,e)}#n=e(``);get error(){return t(this.#n)}set error(e){n(this.#n,e,!0)}#r=e(``);get open(){return t(this.#r)}set open(e){n(this.#r,e,!0)}#i=e(``);get here(){return t(this.#i)}set here(e){n(this.#i,e,!0)}#a=e(null);get saving(){return t(this.#a)}set saving(e){n(this.#a,e,!0)}#o=e(null);get atlas(){return t(this.#o)}set atlas(e){n(this.#o,e)}#s=e(null);get signIn(){return t(this.#s)}set signIn(e){n(this.#s,e)}#c=e(null);get iso(){return t(this.#c)}set iso(e){n(this.#c,e)}watching=``;listeners=new Set;relist=null;async load(e=a()){this.api=e;try{[this.session,this.listing]=await Promise.all([e.session(),e.notes()])}catch(e){this.error=e.message;return}await this.signedIn(),e.events(e=>{this.follow(e);for(let t of this.listeners)t(e);e.type===`note-changed`&&(this.relist&&clearTimeout(this.relist),this.relist=setTimeout(()=>{this.refresh()},300))})}async startSignIn(){let{url:e}=await this.api.connect(location.origin+location.pathname);try{sessionStorage.setItem(s,location.hash)}catch{}location.assign(e)}async signedIn(){let e=new URLSearchParams(location.search),t,n;try{if(e.has(`code`)||e.has(`state`)||e.has(`error`)){let t=sessionStorage.getItem(s)??location.hash;return sessionStorage.removeItem(s),sessionStorage.setItem(c,JSON.stringify({code:e.get(`code`),state:e.get(`state`)})),location.replace(location.pathname+t),new Promise(()=>void 0)}let r=sessionStorage.getItem(c);if(r===null)return;sessionStorage.removeItem(c),{code:t,state:n}=JSON.parse(r)}catch{if({code:t,state:n}={code:e.get(`code`),state:e.get(`state`)},!t&&!n)return}if(!t||!n)this.signIn={ok:!1,message:`No key was made: the sign-in was left or refused.`};else try{let e=await this.api.connected(t,n);this.signIn={ok:!0,message:`Signed in at ${e.provider}: a key was made for isorite, and is held on this device.`}}catch(e){this.signIn={ok:!1,message:e.message}}}async refresh(){try{this.listing=await this.api.notes()}catch{}}follow(e){if(e.type===`iso-start`){this.iso={request:e.request,note:e.note,agent:null,state:`reading`,steps:[],message:``,start:e,text:``};return}if((e.type===`agent-start`||e.type===`agent-step`)&&this.iso?.request!==e.request){if(this.iso&&!this.iso.agent&&(this.iso.state===`reading`||this.iso.state===`writing`))return;this.iso={request:e.request,note:``,agent:e.agent,state:`reading`,steps:[],message:``}}let t=this.iso;t&&`request`in e&&e.request===t.request&&(e.type===`iso-step`||e.type===`agent-step`?this.iso={...t,state:`reading`,steps:[...t.steps,e.step]}:e.type===`iso-text`?this.iso={...t,state:`writing`,text:e.again?e.delta:(t.text??``)+e.delta}:e.type===`iso-done`||e.type===`agent-done`?this.iso={...t,state:`done`}:e.type===`iso-stopped`?this.iso={...t,state:`stopped`}:e.type===`iso-failed`&&(this.iso={...t,state:`failed`,message:e.message}))}on(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}},s=`isorite.sign-in.back`,c=`isorite.sign-in.code`,l=new o,u=e=>r(`/n/[...id]`,{id:e});function d(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``)}function f(e){let t=e.trim().replace(/^\/+/,``).replace(/\.md$/,``),n=t.includes(`/`)?l.listing.notes.filter(e=>e.id===t):l.listing.notes.filter(e=>e.id.split(`/`).at(-1)===t),r=n.length===1?n[0]:null;return r?{id:r.id,title:r.title,kind:r.kind??`note`,done:!!r.done}:null}export{i as a,d as i,f as n,u as r,l as t};
@@ -1 +0,0 @@
1
- export{a as load_css,n as start}from"../chunks/BNjH_DUx.js";