isorite 0.18.0 → 0.18.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 (32) hide show
  1. package/dist/main.js +37 -7
  2. package/package.json +1 -1
  3. package/web/_app/immutable/assets/0.i592VXJM.css +1 -0
  4. package/web/_app/immutable/chunks/Co7i-dcu.js +1 -0
  5. package/web/_app/immutable/chunks/{CL9QeiGC.js → CqmdC7Q3.js} +2 -2
  6. package/web/_app/immutable/chunks/D4nFtMQC.js +1 -0
  7. package/web/_app/immutable/chunks/{DyZdoKBK.js → DdegnILL.js} +1 -1
  8. package/web/_app/immutable/chunks/DjN194Ef.js +1 -0
  9. package/web/_app/immutable/chunks/{BFOLKM4z.js → lSTs4h6V.js} +1 -1
  10. package/web/_app/immutable/chunks/{D7yT4F_8.js → ufOJrCuz.js} +1 -1
  11. package/web/_app/immutable/entry/{app.CyEmP0i2.js → app.BRzQKhKX.js} +2 -2
  12. package/web/_app/immutable/entry/start.-f1rSSM0.js +1 -0
  13. package/web/_app/immutable/nodes/0.i_AjenOL.js +11 -0
  14. package/web/_app/immutable/nodes/{1.kdx6h8ts.js → 1.D6qHWJUF.js} +1 -1
  15. package/web/_app/immutable/nodes/2.BPWtlg8V.js +1 -0
  16. package/web/_app/immutable/nodes/3.DaRPyiq0.js +1 -0
  17. package/web/_app/immutable/nodes/{4.DzS8oPUH.js → 4.CkZ28L5K.js} +1 -1
  18. package/web/_app/immutable/nodes/5.6ZCfORwJ.js +22 -0
  19. package/web/_app/immutable/nodes/6.B9EIxq5B.js +1 -0
  20. package/web/_app/immutable/nodes/{7.CCNCaItj.js → 7.DGJflKit.js} +1 -1
  21. package/web/_app/version.json +1 -1
  22. package/web/index.html +14 -14
  23. package/web/_app/immutable/assets/0.BGpjfMlq.css +0 -1
  24. package/web/_app/immutable/chunks/Bg-39frG.js +0 -1
  25. package/web/_app/immutable/chunks/BleKqNM1.js +0 -1
  26. package/web/_app/immutable/chunks/DQp-M3XN.js +0 -1
  27. package/web/_app/immutable/entry/start.BxCHvKWL.js +0 -1
  28. package/web/_app/immutable/nodes/0.Bkbiw_sA.js +0 -11
  29. package/web/_app/immutable/nodes/2.CtK7BGB8.js +0 -1
  30. package/web/_app/immutable/nodes/3.D5PZa2kH.js +0 -1
  31. package/web/_app/immutable/nodes/5.B-1BDKsL.js +0 -19
  32. package/web/_app/immutable/nodes/6.DDT1DtCg.js +0 -1
@@ -0,0 +1,11 @@
1
+ import{$ as e,B as t,D as n,E as r,F as i,G as a,H as o,I as s,J as c,K as l,L as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,V as v,W as y,Y as b,Z as x,_ as S,_t as C,at as w,b as T,c as E,ct as D,d as O,dt as k,et as A,f as j,g as M,gt as N,h as P,ht as F,i as I,it as L,j as R,k as z,l as B,mt as V,n as ee,nt as H,ot as U,p as te,q as ne,rt as re,tt as W,u as G,ut as ie,v as K,w as ae,x as oe,y as q,yt as se,z as J}from"../chunks/Cz6kYWmu.js";import{s as ce,t as le}from"../chunks/Co7i-dcu.js";import"../chunks/xihTtKlq.js";import{b as ue,c as de,i as fe,s as Y,t as X,u as pe}from"../chunks/CqmdC7Q3.js";import{_ as me,b as he,g as ge,i as _e,l as ve,m as ye,o as be,s as xe,t as Se,u as Ce,x as we}from"../chunks/ufOJrCuz.js";import{i as Z,n as Te,r as Ee,t as De}from"../chunks/D4nFtMQC.js";import{t as Oe}from"../chunks/DdegnILL.js";import{n as Q}from"../chunks/lSTs4h6V.js";import{n as ke,r as Ae,t as je}from"../chunks/DjN194Ef.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"../chunks/DgI3Vj5v.js";var Le=se({load:()=>Re});async function Re(){return await X.load(),{}}function ze(e,t,n){for(let r=1;;r++){let i=r===1?t:`${t}-${r}`;if(n([e,i].filter(Boolean).join(`/`)))return{slug:i,n:r}}}async function Be(e,t){let n=X.listing.notes.map(e=>e.id),r=t.split(`/`).slice(0,-1).join(`/`),i=ze(r,`untitled-${e}`,e=>!n.includes(e)),a=[r,i.slug].filter(Boolean).join(`/`),o=`Untitled ${e}${i.n===1?``:` ${i.n}`}`;return await X.api.createNote(a,`---\ntype: ${e===`question`?`Question`:`Problem`}\ntitle: ${JSON.stringify(o)}\n${e===`question`?`about`:`uses`}: [${t}]\n---\n\n`),await X.refresh(),Z.fresh=a,await Z.open(a,!0),a}var Ve=()=>Q.sent.map(e=>e.kind===`passage`?{kind:e.kind,id:e.id,text:e.text}:{kind:e.kind,id:e.id});function He(e){let t=e.items.flatMap((t,n)=>t.kind===`text`||t.kind===`question`||t.kind===`offer`?[t]:t.kind===`look`?[{kind:`tool`,id:`${e.id}:${n}`,name:t.step.tool,title:t.step.query??t.step.opened??t.step.said,status:t.step.failed?`failed`:`done`,output:``,...t.step.opened&&!t.step.away?{note:t.step.opened}:{}}]:t.kind===`change`?[{kind:`tool`,id:`${e.id}:${n}`,name:t.why===`create`?`write_note`:`edit_note`,title:t.to??t.note,status:`done`,output:``,...t.why===`delete`?{}:{note:t.to??t.note}}]:t.kind===`point`?[{kind:`text`,text:`Look at [${X.listing.notes.find(e=>e.id===t.note)?.title??t.note}](/${t.note}.md)${t.why?`: ${t.why}`:`.`}`}]:[]);return{id:e.id,asked:e.asked,from:`here`,items:t,state:e.state,given:e.given,at:e.at}}var $=new class{#e=w(null);get view(){return o(this.#e)}set view(e){L(this.#e,e)}#t=w(null);get old(){return o(this.#t)}set old(e){L(this.#t,e)}#n=w(`session`);get shown(){return o(this.#n)}set shown(e){L(this.#n,e,!0)}#r=w([]);get past(){return o(this.#r)}set past(e){L(this.#r,e)}#i=w(!1);get changing(){return o(this.#i)}set changing(e){L(this.#i,e,!0)}#a=w(``);get problem(){return o(this.#a)}set problem(e){L(this.#a,e,!0)}started=!1;get session(){return this.old??this.view}get connected(){return!!this.view?.connected}get running(){return!this.old&&(!!this.view?.busy||this.view?.turns.at(-1)?.state===`running`)}get api(){return X.api?.terminal??null}start(){!this.started&&X.api&&(this.started=!0,X.api.agentNotes().then(({may:e})=>{Z.on.notes=e},()=>void 0),Z.notesFlipped=e=>{X.api.setAgentNotes(e).catch(t=>{Z.on.notes=!e,this.problem=t.message})},this.api?(this.api.view().then(e=>this.show(e),()=>Z.setAttached(!1)),X.on(e=>{e.type===`terminal`&&this.show(e.terminal)})):Z.setAttached(!1))}show(e){let t=this.connected;this.view=e,Z.setAttached(e.connected||!!e.reading);for(let t of e.asking)this.refused.has(t.id)||(/^(shell|bash|execute)$/.test(t.action)?!Z.on.run:/^(edit|write|patch)$/.test(t.action)&&!Z.on.files)&&(this.refused.add(t.id),this.reply(t.id,`reject`));t&&e.connected&&Z.focus!==`iso`&&e.turns.length>(this.seen??e.turns.length)&&Z.unseen++,this.seen=e.turns.length}seen=null;refused=new Set;async send(e){if(this.problem=``,!e.trim()||!this.api)return!1;this.old=null;try{return await this.api.prompt(e.trim(),Ve()),!0}catch(e){return this.problem=e.message,!1}}async steer(e){if(this.problem=``,!e.trim()||!this.api)return!1;try{return await this.api.steer(e.trim(),Ve()),!0}catch(e){return this.problem=e.message,!1}}get canSteer(){return this.running&&!!this.view?.steer}async stop(){try{await this.api?.stop()}catch(e){this.problem=e.message}}async reply(e,t){try{await this.api?.reply(e,t)}catch(e){this.problem=e.message}}async take(e){try{await this.api?.take(e)}catch(e){this.problem=e.message}}get acp(){return!!this.view&&(this.view.connected||!!this.view.reading)}async give(){if(this.acp&&this.api)try{await this.api.give(Ve())}catch(e){this.problem=e.message}}async withdraw(e){if(this.acp&&this.api)try{await this.api.withdraw(e.kind===`passage`?{kind:e.kind,id:e.id,text:e.text}:{kind:e.kind,id:e.id})}catch{}}async fork(e,t){this.problem=``;try{await this.api?.fork(e,t)}catch(e){this.problem=e.message}}async follow(e,t){this.problem=``,this.old=null;try{await this.api?.follow(e,t)}catch(e){this.problem=e.message}}async set(e,t,n){this.problem=``;try{await this.api?.set(e,t,n)}catch(e){this.problem=e.message}}async forgetPast(e){this.problem=``;try{await X.api.deleteConversation(e),this.old?.session===e&&(this.old=null),this.past=await X.api.conversations()}catch(e){this.problem=e.message}}change(){this.changing=!0,this.shown!==`past`&&this.drawer()}async forget(e,t){this.problem=``;try{await this.api?.forget(e,t),this.view?.agentId===e&&this.view.session===t&&(this.old=null)}catch(e){this.problem=e.message}}async fresh(e){this.problem=``,this.old=null;try{await this.api?.fresh(e)}catch(e){this.problem=e.message}}async drawer(){if(this.shown===`past`)this.shown=`session`;else{this.shown=`past`,this.acp&&this.api?.list().catch(()=>void 0);try{this.past=await X.api.conversations()}catch{this.past=[]}}}async read(e){this.problem=``;try{let t=await X.api.conversation(e);t&&(this.old={connected:!1,reading:!0,agent:`Agent`,agentId:`iso`,session:t.id,title:t.turns[0]?.asked??``,busy:!1,turns:t.turns.map(He),asking:[],cost:0,tokens:{input:0,output:0},model:``}),this.shown=`session`}catch(e){this.problem=e.message}}};Q.onRemove=e=>void $.withdraw(e);var Ue=4.5,We=.04;function Ge(e){let t=e.items.map(t=>{let n=[];for(let r=t.parent;r>=0;r=e.items[r].parent)n.push(r);return n}),n=e.items.map(()=>0);e.items.forEach((e,r)=>{if(e.kind===`note`)for(let e of t[r])n[e]++});let r=(t,n)=>{for(;e.items[t].parent!==n;)t=e.items[t].parent;return t},i=new Map(e.trunks.map((e,t)=>[`${e.a}|${e.b}`,t])),a=e.links.some(e=>e.s>=3)?3:2,o=e.trunks.map(()=>!1);for(let t of e.links){let e=t.s>=a?i.get(`${r(t.a,t.level)}|${r(t.b,t.level)}`):void 0;e!==void 0&&(o[e]=!0)}return{up:t,noteCount:n,strong:o,at:new Map(e.items.flatMap((e,t)=>e.kind===`note`?[[e.ref,t]]:[])),trunkAt:i,feederAt:new Map(e.feeders.map((e,t)=>[`${e.trunk}|${e.folder}|${e.item}`,t])),ownPath:new Map(e.trunks.flatMap(e=>e.pts?[[`${e.a}|${e.b}`,e.pts]]:[]))}}var Ke=new WeakMap;function qe(e){let t=Ke.get(e);return t||Ke.set(e,t={...e,trunks:e.highways.trunks,feeders:e.highways.feeders}),t}function Je(e,t){let n=[];return e.items.forEach((r,i)=>{let a=r.parent<0||n[r.parent]===`o`;n[i]=a?r.kind===`folder`&&e.cell*t>=1.2&&Math.max(r.w,r.h)*e.cell*t>=53?`o`:`s`:`-`}),n.join(``)}function Ye(e,t,n){let r=e.up[n];for(let e=r.length-1;e>=0;e--)if(t[r[e]]!==`o`)return r[e];return n}function Xe(e,t,n=[],r=!1){let i=e=>t[e]!==`-`,a=[];return e.trunks.forEach((t,r)=>{let o=e.items[t.a].kind===`folder`&&e.items[t.b].kind===`folder`;t.pts&&!t.implied&&i(t.a)&&i(t.b)&&a.push({key:`t`+r,pts:t.pts,lane:0,count:t.count,feed:!o,strong:n[r]??!0})}),e.feeders.forEach((o,s)=>{let c=e.trunks[o.trunk];(r||!o.leaf)&&!c.implied&&t[o.folder]===`o`&&i(o.item)&&i(c.a)&&i(c.b)&&a.push({key:`f`+s,pts:o.pts,lane:o.lane,count:o.count,feed:!0,strong:n[o.trunk]??!0})}),a}var Ze=(e,t)=>Math.abs(e[0]-t[0])<1e-6&&Math.abs(e[1]-t[1])<1e-6;function Qe(e,t,n,r){let i=new Set(t.up[r]),a=t.up[n].find(e=>i.has(e))??-1,o=e=>{let n=[e];for(let r of t.up[e]){if(r===a)break;n.push(r)}return n},s=o(n),c=o(r),l=t.trunkAt.get(`${s.at(-1)}|${c.at(-1)}`);if(l===void 0||!e.trunks[l].pts||s.length<2&&c.length<2)return null;let u=(t,n=0)=>{let r=e.feeders[t];if(r.via<0||n>40)return r.pts;let i=u(r.via,n+1),a=i.findIndex(e=>Ze(e,r.pts.at(-1)));return a<0?r.pts:[...r.pts,...i.slice(a+1)]},d=e=>{let n=[];for(let r=0;r+1<e.length;r++){let i=t.feederAt.get(`${l}|${e[r+1]}|${e[r]}`);if(i===void 0)return null;n=n.concat(u(i))}return n},f=d(c),p=d(s);if(!f||!p)return null;let m=[...f,...e.trunks[l].pts,...p.reverse()];return m.filter((e,t)=>!t||!Ze(e,m[t-1]))}var $e=[`uses`,`builds`,`requires`,`iso`];function et(e,t=!1){let n=e=>`${Math.round(e[0]*100)},${Math.round(e[1]*100)}`,r=new Map,i=new Map;for(let t of e){let e=$e.indexOf(t.kind??`requires`),a=new Set;for(let o=1;o<t.pts.length;o++){let[s,c]=t.pts[o-1],[l,u]=t.pts[o],d=Math.max(1,Math.round(Math.max(Math.abs(l-s),Math.abs(u-c))*2));for(let o=0;o<d;o++){let f=[s+(l-s)*o/d,c+(u-c)*o/d],p=[s+(l-s)*(o+1)/d,c+(u-c)*(o+1)/d],m=n(f),h=n(p),g=m<h?m+`|`+h:h+`|`+m;if(m===h||a.has(g))continue;a.add(g);let _=r.get(g);if(!_){_=m<h?{a:m,b:h,A:f,B:p,count:0,strong:!1,trunk:!1,kind:0,fwd:[0,0,0,0],back:[0,0,0,0]}:{a:h,b:m,A:p,B:f,count:0,strong:!1,trunk:!1,kind:0,fwd:[0,0,0,0],back:[0,0,0,0]},r.set(g,_);for(let e of[_.a,_.b]){let t=i.get(e);t?t.push(g):i.set(e,[g])}}_.count+=t.count??1,_.strong||=t.strong??!0,_.trunk||=t.feed===!1,_.kind=Math.max(_.kind,e),(m===_.a?_.fwd:_.back)[e]+=1}}}let a=e=>t?`${e.kind}|${e.count}`:`${e.count}|${e.strong}|${e.trunk}`,o=(e,n)=>{let r=e.fwd[e.kind],i=e.back[e.kind];return!t||r&&i?0:(r?1:-1)*(n===e.a?1:-1)},s=(e,t)=>t===e.a?e.b:e.a,c=(e,t)=>t===e.a?e.A:e.B,l=(e,t,n)=>{let r=s(e,t);return a(e)===a(n)&&o(e,t)===o(n,r)},u=new Set,d=[],f=new Set,p=(e,t)=>{let p=e,m=t,h=r.get(m),g=[c(h,p)],_=o(h,p);for(;;){u.add(m);let e=s(h,p);g.push(c(h,e));let t=i.get(e).filter(e=>e!==m);if(t.length!==1||u.has(t[0])||!l(h,p,r.get(t[0])))break;p=e,m=t[0],h=r.get(m)}_<0&&g.reverse();let v=`${n(g[0])}>${n(g.at(-1))}:${a(h)}`;for(let e=2;f.has(v);e++)v=`${v.split(`#`)[0]}#${e}`;f.add(v),d.push({key:v,pts:g,count:h.count,strong:h.strong,trunk:h.trunk,kind:$e[h.kind],flow:+!!_})};for(let[e,t]of i)if(t.length!==2||!l(r.get(t[0]),s(r.get(t[0]),e),r.get(t[1])))for(let n of t)u.has(n)||p(e,n);for(let[e,t]of r)u.has(e)||p(t.a,e);return d}function tt(e,t,n,r){let i=[],a=[],o=new Set;for(let{a:s,b:c,kind:l}of r){let r=Ye(t,n,s),u=Ye(t,n,c),d=`${l}:${r}|${u}`;if(r===u||o.has(d))continue;o.add(d);let f=(n,i)=>r===s&&u===c?t.ownPath.get(`${n}|${i}`)??Qe(e,t,n,i):t.ownPath.get(`${n}|${i}`)??null,p=f(r,u)??f(u,r)?.slice().reverse()??null;p?i.push({key:d,kind:l,pts:p}):a.push({key:d,kind:l,a:r,b:u})}return{fixed:i,asks:a}}function nt(e,t){if(!t)return e;let n=(e,t)=>{let n=t[0]-e[0],r=t[1]-e[1],i=Math.hypot(n,r)||1;return n/=i,r/=i,(n<-1e-6||Math.abs(n)<1e-6&&r<0)&&(n=-n,r=-r),[-r,n]};return e.map((r,i)=>{let a=i>0?n(e[i-1],r):n(r,e[i+1]),o=i<e.length-1?n(r,e[i+1]):a,s=1+a[0]*o[0]+a[1]*o[1];return s<.2?[r[0]+a[0]*t,r[1]+a[1]*t]:[r[0]+(a[0]+o[0])/s*t,r[1]+(a[1]+o[1])/s*t]})}function rt(e,t=0,n=7){let r=nt(e.map(([e,t])=>[e*n,t*n]),t*2.2),i=Math.min(n,10.5)*.9,a=r.filter((e,t)=>t===0||t===r.length-1||Math.abs((e[0]-r[t-1][0])*(r[t+1][1]-e[1])-(e[1]-r[t-1][1])*(r[t+1][0]-e[0]))>.001),o=e=>String(Math.round(e*10)/10),s=`M${o(a[0][0])} ${o(a[0][1])}`;for(let e=1;e<a.length-1;e++){let t=a[e-1],n=a[e],r=a[e+1],c=Math.hypot(n[0]-t[0],n[1]-t[1])||1,l=Math.hypot(r[0]-n[0],r[1]-n[1])||1;if(!(Math.abs((n[0]-t[0])*(r[0]-n[0])+(n[1]-t[1])*(r[1]-n[1]))<.001*c*l)){s+=`L${o(n[0])} ${o(n[1])}`;continue}let u=Math.min(i,c/2,l/2);s+=`L${o(n[0]-(n[0]-t[0])/c*u)} ${o(n[1]-(n[1]-t[1])/c*u)}L${o(n[0]+(r[0]-n[0])/l*u)} ${o(n[1]+(r[1]-n[1])/l*u)}`}let c=a.at(-1);return s+`L${o(c[0])} ${o(c[1])}`}function it(e,t,n,r=3,i=7){let a=Math.max(We,Math.min(r,.96*Math.min(t/((e.w+4)*i),n/((e.h+4)*i))));return{k:a,x:t/2-a*(e.gx+e.w/2)*i,y:n/2-a*(e.gy+e.h/2)*i}}function at(e,t,n,r){let i=Math.max(We,Math.min(3,e.k*t)),a=i/e.k;return{k:i,x:n-(n-e.x)*a,y:r-(r-e.y)*a}}function ot(e,t){if(!t.length)return e;let n=new Map,r=new Map,i=e=>{for(let t of e.children)t.kind===`dir`?i(t):n.set(t.ref,t)};i(e.root);for(let e of t){let t=e.about.find(e=>n.has(e));t&&r.set(t,[...r.get(t)??[],e])}let a=e=>({...e,children:e.children.flatMap(e=>e.kind===`dir`?[a(e)]:[e,...(r.get(e.ref)??[]).map(t=>({kind:`concept`,id:`c:`+t.ref,ref:t.ref,weight:1,rank:e.rank+1,of:`question`}))])}),o=[...e.edges];for(let e of r.values())for(let t of e)for(let e of t.about)n.has(e)&&o.push([t.ref,e,ue.uses]);return{root:a(e.root),edges:o}}function st(e,t){let n=new Set,r=e=>({...e,children:e.children.flatMap(e=>e.kind===`dir`?[r(e)]:t(e.ref)?(n.add(e.ref),[]):[e])}),i=r(e.root);return n.size?{root:i,edges:e.edges.filter(([e,t])=>!n.has(e)&&!n.has(t))}:e}var ct=1;function lt(e,t,n,r=new Set){if(!n.web&&!n.code&&!n.pictures)return[];let i=[];for(let a of e){let e=t[a.ref],o=[...(e?.links??[]).filter(e=>n[e.kind]).map(e=>({kind:e.kind,href:e.href,text:e.text,broken:!!e.broken})),...(n.pictures?e?.pictures??[]:[]).map(e=>({kind:`picture`,href:e.href,text:e.text,broken:!!e.broken,picture:{path:e.path,from:e.from}}))],s=Math.max(1,Math.floor((a.h+ct)/4)),c=Math.max(s*2,6),l=r.has(a.ref);if(o.length>c&&c>1){if(l)o.push({kind:`more`,href:``,text:`fewer`,broken:!1});else{let e=o.length-(c-1);o.splice(c-1,o.length,{kind:`more`,href:``,text:`${e} more`,broken:!1})}}o.forEach((e,t)=>{let n=Math.floor(t/s),r=t%s;i.push({...e,key:`${a.ref} ${e.kind===`picture`?`picture:`:e.kind===`more`?`more:`:``}${e.href}`,note:a.ref,gx:a.gx+a.w+ct+n*4,gy:a.gy+r*4})})}return i}var ut=2;function dt(e){let{W:t,H:n,items:r}=e,i=new Int8Array(t*n),a=new Uint8Array(t*n),o=new Int32Array(t*n).fill(-1),s=new Int32Array(t*n).fill(-1),c=r.map((e,t)=>t).filter(e=>r[e].kind===`folder`).sort((e,t)=>r[e].depth-r[t].depth||e-t);for(let e of c){let n=r[e];for(let r=n.gy;r<n.gy+n.h;r++)for(let a=n.gx;a<n.gx+n.w;a++)i[r*t+a]=n.depth,o[r*t+a]=e}r.forEach((e,n)=>{if(e.kind===`note`)for(let r=e.gy;r<e.gy+e.h;r++)for(let i=e.gx;i<e.gx+e.w;i++)a[r*t+i]=1,s[r*t+i]=n});let l=new Uint8Array(t*n),u=e.keep??ut,d=(e,r,i,a)=>{for(let o=Math.max(0,r);o<Math.min(n,a);o++)for(let n=Math.max(0,e);n<Math.min(t,i);n++)l[o*t+n]=1};for(let e of r)e.kind===`note`?d(e.gx-u,e.gy-u,e.gx+e.w+u,e.gy+e.h+u):(d(e.gx-u,e.gy-u,e.gx+e.w+u,e.gy+u),d(e.gx-u,e.gy+e.h-u,e.gx+e.w+u,e.gy+e.h+u),d(e.gx-u,e.gy-u,e.gx+u,e.gy+e.h+u),d(e.gx+e.w-u,e.gy-u,e.gx+e.w+u,e.gy+e.h+u));return{W:t,H:n,elev:i,blocked:a,owner:o,noteAt:s,close:l}}function ft(e,t){let n=e[t].kind===`folder`?[t]:[];for(let r=e[t].parent;r>=0;r=e[r].parent)n.push(r);return n}var pt={bend:4,flow:1,area:.01,aspect:1,shape:1,effort:1e3,seed:0,cross:20,stay:5};function mt(e,t,n,r,i={}){let{bend:a,flow:o,area:s,aspect:c,shape:l,effort:u,seed:d,cross:f,stay:p}={...pt,...i},m=e.length,h=e.map(e=>e[0]),g=e.map(e=>e[1]);if(!m)return{x:[],y:[],w:0,h:0};let _=Array.from({length:m},(e,t)=>Array.from({length:m},(e,r)=>n(t,r))),v=new Float64Array(m),y=new Float64Array(m),b=[...Array(m).keys()],x=[...b],S=new Int32Array(m),C=new Int32Array(m),w=0,T=0,E=()=>{b.forEach((e,t)=>{S[e]=t}),x.forEach((e,t)=>{C[e]=t}),w=0,T=0;for(let e=0;e<m;e++){let t=b[e],n=0,r=0;for(let i=0;i<e;i++){let e=b[i];C[e]<C[t]?n=Math.max(n,v[e]+h[e]+_[e][t]):r=Math.max(r,y[e]+g[e]+_[e][t])}v[t]=n,y[t]=r,w=Math.max(w,n+h[t]),T=Math.max(T,r+g[t])}},D=e=>[v[e]+h[e]/2,y[e]+g[e]/2],O=()=>{E();let e=0;for(let[n,i,s]of t){let t=Math.max(0,v[i]-v[n]-h[n],v[n]-v[i]-h[i]),c=Math.max(0,y[i]-y[n]-g[n],y[n]-y[i]-g[i]);e+=s*(Math.max(t,c)+.414*Math.min(t,c)+(t>0&&c>0?a:0));let l=r===`right`?v[n]+h[n]/2-(v[i]+h[i]/2):y[i]+g[i]/2-(y[n]+g[n]/2);l>0&&(e+=o*s*l)}if(f)for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let[i,a,o]=t[n],[s,c,l]=t[r];i!==s&&i!==c&&a!==s&&a!==c&&gt(D(i),D(a),D(s),D(c))&&(e+=f*Math.min(o,l))}if(A)for(let t=0;t<m;t++)for(let n=t+1;n<m;n++)(S[t]<S[n]!=A[0][t]<A[0][n]||C[t]<C[n]!=A[1][t]<A[1][n])&&(e+=p);let n=Math.log(w/T/l);return e+s*w*T*(1+c*n*n)},k=ht(m,t);if(b.sort((e,t)=>k[e]-k[t]),x.splice(0,m,...b),r===`up`&&b.reverse(),i.pair)return b.splice(0,m,...i.pair[0]),x.splice(0,m,...i.pair[1]),E(),{x:[...v],y:[...y],w,h:T,pair:i.pair};let A=null;i.start&&(b.splice(0,m,...i.start[0]),x.splice(0,m,...i.start[1]),A=[new Int32Array(m),new Int32Array(m)],b.forEach((e,t)=>{A[0][e]=t}),x.forEach((e,t)=>{A[1][e]=t}));let j=O(),M=j,N=[...b],P=[...x];if(m<2)return E(),{x:[...v],y:[...y],w,h:T,pair:[[...b],[...x]]};let F=vt(_t(e,t)^d),I=u*m,L=i.start?Math.max(.5,j*.002):Math.max(1,j*.05),R=.001**(1/I);for(let e=0;e<I;e++,L*=R){let e=Math.floor(F()*m),t=(e+1+Math.floor(F()*(m-1)))%m,n=F(),r=n=>{let r=n[e];n[e]=n[t],n[t]=r};if(n<.4)r(b);else if(n<.8)r(x);else{let n=b.indexOf(x[e]),i=b.indexOf(x[t]);r(x);let a=b[n];b[n]=b[i],b[i]=a}let i=O();if(i<=j||F()<Math.exp((j-i)/L))j=i,j<M&&(M=j,N=[...b],P=[...x]);else if(n<.4)r(b);else if(n<.8)r(x);else{let n=b.indexOf(x[e]),i=b.indexOf(x[t]);r(x);let a=b[n];b[n]=b[i],b[i]=a}}return b.splice(0,m,...N),x.splice(0,m,...P),E(),{x:[...v],y:[...y],w,h:T,cost:M,pair:[N,P]}}function ht(e,t){let n=Array(e).fill(0);for(let[e,r,i]of t)n[e]+=i,n[r]-=i;let r=[...Array(e).keys()].sort((e,t)=>n[t]-n[e]||e-t),i=Array(e);return r.forEach((e,t)=>{i[e]=t}),i}function gt(e,t,n,r){let i=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return i(e,t,n)*i(e,t,r)<0&&i(n,r,e)*i(n,r,t)<0}function _t(e,t){let n=2166136261;for(let r of[...e.flat(),...t.flat()])n^=r|0,n=Math.imul(n,16777619);return n>>>0}function vt(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var yt={cell:7,note:[18,11],gap:6,gapFolders:8,channel:6,channelFolders:8,pad:6,head:2,margin:8,minFolder:12,slant:8,keep:2},bt={fine:yt,coarse:{cell:14,note:[9,6],gap:3,gapFolders:6,channel:3,channelFolders:6,pad:3,head:1,margin:6,minFolder:6,slant:4,keep:1},coarser:{cell:18,note:[7,4],gap:2,gapFolders:5,channel:2,channelFolders:5,pad:2,head:1,margin:5,minFolder:5,slant:3,keep:1}};yt.pad;var xt=1.4,St=8,Ct=12,wt=yt.note,Tt=0,Et=0,Dt=0,Ot=0,kt=0,At=0,jt=0,Mt=0,Nt=0,Pt=2,Ft=0,It=0;function Lt(e){({note:wt,gap:Tt,gapFolders:Et,channel:Dt,channelFolders:Ot,head:kt,margin:At,minFolder:jt,slant:Mt,pad:Nt,keep:Pt}=e),Ft=wt[0]+Tt,It=3*Ft}function Rt(e,{flow:t=`up`,grain:n=`fine`,plan:r=!1,planCosts:i={},planned:a=null,from:o=null}={}){let s=bt[n]??yt;Lt(s);let c=e=>e.kind===`dir`,l=new Map,u=new Map,d=[e.root];for(let e=0;e<d.length;e++)for(let t of d[e].children||[])l.set(t,d[e]),c(t)?d.push(t):u.set(t.ref,t);let f=e=>{let t=[];for(let n=e;n;n=l.get(n))t.push(n);return t.reverse()},p=new Map(d.map(e=>[e,new Map])),m=new Map;for(let e of d){m.set(e,m.size);for(let t of e.children||[])c(t)||m.set(t,m.size)}let h=new Map(u);if(e.code)for(let t of d)t!==e.root&&!h.has(t.ref)&&h.set(t.ref,t);for(let[t,n,r]of e.edges){if(r<2)continue;let e=h.get(t),i=h.get(n);if(!e||!i||e===i)continue;let a=f(e),o=f(i),s=0;for(;a[s+1]&&a[s+1]===o[s+1];)s++;if(!a[s+1]||!o[s+1])continue;let c=p.get(a[s]),l=o[s+1],u=a[s+1],d=m.get(l)+`|`+m.get(u),g=c.get(d)||{p:l,q:u,weight:0,count:0};g.weight+=r,g.count++,c.set(d,g)}let g=new Map,_=new Map,v={},y=new Map,b=e=>e===`up`?`right`:`up`,x=(t,n)=>{let r=t.children||[];for(let e of r)c(e)?x(e,b(n)):g.set(e,{w:wt[0],h:wt[1]});let i=r.length?S(t,r,n):{w:0,h:0};g.set(t,t===e.root?i:r.length?{w:Math.max(jt,i.w+2*Nt),h:i.h+Nt+kt+Nt}:{w:Math.max(jt,wt[0]+2*Nt),h:wt[1]+kt+2*Nt})};function S(e,t,n){if(r&&t.some(c))return C(e,t,n);let i=new Map(t.map(e=>[e,e])),a=e=>{for(;i.get(e)!==e;)e=i.get(e);return e};for(let t of p.get(e).values()){let e=a(t.p),n=a(t.q);e!==n&&i.set(n,e)}let o=new Map,s=new Set([...p.get(e).values()].flatMap(e=>[e.p,e.q]));for(let e of t){let t=s.has(e)?a(e):null;o.set(t,[...o.get(t)||[],e])}if(o.size<2){let r=w(e,t,n);return y.set(e,r.out),{w:r.w,h:r.h}}let l=[...o].map(([t,r],i)=>({list:r,loose:t===null,k:i,...w(e,r,n)}));l.sort((e,t)=>e.loose-t.loose||t.w*t.h-e.w*e.h||e.k-t.k);let u=t.some(c)?Et:Tt,d=l.reduce((e,t)=>e+(t.w+u)*(t.h+u),0),f=Math.max(Math.ceil(Math.sqrt(d*xt)),...l.map(e=>e.w)),m=0,h=0,_=0,v=0,b=[];for(let e of l){m&&m+e.w>f&&(m=0,h+=_+u,_=0);for(let t of e.list){let e=g.get(t);e.x+=m,e.y+=h}for(let t of e.out)b.push({...t,pts:t.pts&&t.pts.map(([e,t])=>[e+m,t+h])});v=Math.max(v,m+e.w),_=Math.max(_,e.h),m+=e.w+u}return y.set(e,b),{w:v,h:h+_}}function C(t,n,r){let s=new Map(n.map((e,t)=>[e,t])),l=[...p.get(t).values()].filter(e=>s.has(e.p)&&s.has(e.q)),u=t===e.root?``:t.ref,d=a?.get(u),f=(e,t)=>d?.wider.get([n[e].ref,n[t].ref].sort().join(`|`))??0,m=(e,t)=>(c(n[e])||c(n[t])?Et:Tt)+f(e,t),h=n.map(e=>[g.get(e).w,g.get(e).h]),b=t===e.root&&r===`up`?1/pt.shape:pt.shape,x,S=!d&&o?.[u];if(S){let e=new Map(n.map((e,t)=>[e.ref,t])),t=n.map((e,t)=>t).filter(e=>!S[0].includes(n[e].ref));x=S.map(n=>[...n.filter(t=>e.has(t)).map(t=>e.get(t)),...t])}let C=mt(h,l.map(e=>[s.get(e.p),s.get(e.q),e.count]),m,r,{shape:b,...i,pair:d?.pair,start:x});_.set(u,C.pair),v[u]=C.pair.map(e=>e.map(e=>n[e].ref)),n.forEach((e,t)=>Object.assign(g.get(e),{x:C.x[t],y:C.y[t]}));let w=e=>r===`right`?C.x[e]+h[e][0]/2:-(C.y[e]+h[e][1]/2),T=new Map;for(let e of l)T.set(e.p,[...T.get(e.p)||[],e.q]);let E=(e,t)=>{let n=new Set,r=(T.get(e)||[]).filter(e=>e!==t);for(;r.length;){let e=r.pop();if(e===t)return!0;n.has(e)||(n.add(e),r.push(...T.get(e)||[]))}return!1};return y.set(t,l.map(e=>({p:e.p,q:e.q,count:e.count,back:w(s.get(e.p))>w(s.get(e.q)),implied:!c(e.p)&&!c(e.q)&&E(e.p,e.q),pts:null}))),{w:C.w,h:C.h}}function w(e,t,n){let r=t.length,i=new Map(t.map((e,t)=>[e,t])),a=n===`up`,o=t.some(c)?Et:Tt,s=t.map(e=>a?g.get(e).h:g.get(e).w),l=t.map(e=>a?g.get(e).w:g.get(e).h),u=[...p.get(e).values()].filter(e=>i.has(e.p)&&i.has(e.q)).map(e=>({...e,p:i.get(e.p),q:i.get(e.q)})),d=Bt(r,u.map(e=>[e.p,e.q,e.weight]));for(let e of u)e.back=d[e.p]>d[e.q],e.u=e.back?e.q:e.p,e.v=e.back?e.p:e.q;let f=u.filter(e=>!e.back),m=Array(r).fill(0),h=t.map(()=>[]),_=t.map(()=>[]);for(let e of u)h[e.v].push(e.u),_[e.u].push(e.v);let v=t.map(()=>[]);for(let e of f)v[e.p].push(e.q);for(let e of[...Array(r).keys()].sort((e,t)=>d[e]-d[t]))for(let t of h[e])m[e]=Math.max(m[e],m[t]+1);for(let e=0;e<r;e++)!h[e].length&&_[e].length&&(m[e]=Math.min(..._[e].map(e=>m[e]))-1);let y=(e,t,n)=>{let r=new Set,i=v[e].filter(e=>e!==n);for(;i.length;){let e=i.pop();if(e===t)return!0;r.has(e)||(r.add(e),i.push(...v[e]))}return!1};for(let e of f)e.implied=!c(t[e.p])&&!c(t[e.q])&&y(e.p,e.q,e.q);let b=u.filter(e=>!e.implied).sort((e,t)=>t.weight-e.weight||e.p-t.p||e.q-t.q),x=t.reduce((e,t,n)=>e+(l[n]+o)*(s[n]+Dt),0),S=Math.max(Math.ceil(Math.sqrt(a?x*xt:x/xt)),...l),C=[],w=Array(r),T=Array(r).fill(!1);for(let e of u)T[e.p]=!0,T[e.q]=!0;let E=T.some(Boolean)&&T.some(e=>!e),D=e=>{let t=e.reduce((e,t)=>e+l[t]+o,0),n=Math.max(1,Math.ceil((t-o)/S)),r=t/n,i=null,a=0;for(let t of e)(!i||a+l[t]>S||C.length-O<n&&a>=r)&&(i=[],C.push(i),a=0),w[t]=C.length-1,i.push(t),a+=l[t]+o},O=0,k=e=>h[e].length?+!!_[e].length:2,A=e=>e.length?e.reduce((e,t)=>e+d[t],0)/e.length:0;for(let e=0;e<=Math.max(...m);e++){let t=[...Array(r).keys()].filter(t=>m[t]===e&&(T[t]||!E));t.reduce((e,t)=>e+l[t]+o,0)-o>S&&t.sort((e,t)=>k(e)-k(t)||A(h[e])-A(h[t])||e-t),O=C.length,D(t)}E&&(O=C.length,D([...Array(r).keys()].filter(e=>!T[e])));let j=[...l],M=t.map(()=>[]),N=t.map(()=>[]),P=new Map,F=new Map,I=[],L=new Set,R=new Map;for(let e of b){let t=[e.u];for(let n=w[e.u]+1;n<w[e.v];n++){let r=e.u+`|`+n;P.has(r)||(P.set(r,j.length),F.set(j.length,e.u),j.push(1),M.push([]),N.push([]),w.push(n),C[n].push(j.length-1)),t.push(P.get(r))}t.push(e.v);for(let e=1;e<t.length;e++){let n=t[e-1],r=t[e];L.has(n+`|`+r)||(L.add(n+`|`+r),I.push([n,r]),N[n].push(r),M[r].push(n))}R.set(e,t)}let z=e=>e>=r,B=Array(j.length);C.forEach(e=>e.forEach((e,t)=>{B[e]=t}));let V=(e,t)=>{let n=new Map(C[e].map(e=>[e,t[e].length?t[e].reduce((e,t)=>e+B[t],0)/t[e].length:B[e]]));C[e].sort((e,t)=>n.get(e)-n.get(t)||B[e]-B[t]),C[e].forEach((e,t)=>{B[e]=t})},ee=()=>{let e=0;for(let t=0;t<C.length-1;t++){let n=[];for(let e of C[t])for(let t of N[e])n.push([B[e],B[t]]);for(let t=0;t<n.length;t++)for(let r=t+1;r<n.length;r++)(n[t][0]-n[r][0])*(n[t][1]-n[r][1])<0&&e++}return e},H=()=>{let e=(e,t,n)=>{let r=0;for(let i of n[e])for(let e of n[t])r+=B[i]>B[e]?1:B[i]<B[e]?-1:0;return r};for(let t=!0,n=0;t&&n<St;n++){t=!1;for(let n of C)for(let r=0;r+1<n.length;r++){let i=n[r],a=n[r+1];e(i,a,M)+e(i,a,N)>0&&(n[r]=a,n[r+1]=i,B[i]=r+1,B[a]=r,t=!0)}}},U=C.map(e=>[...e]),te=(e,t)=>(z(e)?d[F.get(e)]:d[e])-(z(t)?d[F.get(t)]:d[t])||e-t,ne=null,re=1/0;for(let e of[e=>e,e=>[...e].sort(te),e=>[...e].reverse()]){C.forEach((t,n)=>{t.splice(0,t.length,...e(U[n])),t.forEach((e,t)=>{B[e]=t})});let t=1/0,n=0;for(let e=0;e<24&&n<4&&re>0;e++,n++){if(e%2==0)for(let e=1;e<C.length;e++)V(e,M);else for(let e=C.length-2;e>=0;e--)V(e,N);H();let r=ee();r<t&&(t=r,n=0),r<re&&(re=r,ne=C.map(e=>[...e]))}}ne&&C.forEach((e,t)=>{e.splice(0,e.length,...ne[t]),e.forEach((e,t)=>{B[e]=t})});let W=(e,t)=>z(e)&&z(t)?1:z(e)||z(t)?Pt:o,G=Array(j.length).fill(0);for(let e of C){let t=0;e.forEach((n,r)=>{r&&(t+=W(e[r-1],n)),G[n]=t,t+=j[n]})}let ie=e=>e.length?G[e[e.length-1]]+j[e[e.length-1]]:0,K=Math.max(...C.map(ie));for(let e of C){let t=(K-ie(e))/2;for(let n of e)G[n]+=t}let ae=e=>G[e]+j[e]/2;for(let e=0;e<Ct;e++)for(let t of e%2?[...C].reverse():C){if(!t.length)continue;let e=t.map(e=>{let t=[...M[e],...N[e]];return(t.length?t.reduce((e,t)=>e+ae(t),0)/t.length:ae(e))-j[e]/2}),n=[],r=[];t.forEach((r,i)=>{n[i]=i?Math.max(e[i],n[i-1]+j[t[i-1]]+W(t[i-1],r)):e[i]});for(let n=t.length-1;n>=0;n--)r[n]=n<t.length-1?Math.min(e[n],r[n+1]-j[t[n]]-W(t[n],t[n+1])):e[n];t.forEach((e,t)=>{G[e]=(n[t]+r[t])/2})}let oe=e=>Math.floor((j[e]-1)/2),q=Array(j.length).fill(-1),se=Array(j.length).fill(-1);for(let e of[!0,!1])for(let t=1;t<C.length;t++){let n=C[t].filter(e=>q[e]>=0).map(e=>[B[q[e]],B[e]]);for(let r of C[t]){if(q[r]>=0||!M[r].length)continue;let t=[...M[r]].sort((e,t)=>B[e]-B[t]),i=(t.length-1)/2,a=t.map((e,t)=>[e,Math.abs(t-i)]).filter(([t])=>se[t]<0&&(!e||z(t)&&z(r))&&Math.abs(G[t]+oe(t)-G[r]-oe(r))<=(e?It:Ft)).sort((e,t)=>e[1]-t[1]||B[e[0]]-B[t[0]]);for(let[e]of a)if(!n.some(([t,n])=>t<B[e]!=n<B[r])){q[r]=e,se[e]=r,n.push([B[e],B[r]]);break}}}let J=Array(j.length).fill(-1),ce=0;for(let e=0;e<j.length;e++)if(q[e]<0){for(let t=e;t>=0;t=se[t])J[t]=ce;ce++}let le=Array.from({length:ce},()=>[]);J.forEach((e,t)=>le[e].push(t));let ue=(e,t)=>j[e]-oe(e)+W(e,t)+oe(t),de=Array(j.length).fill(-1),fe=Array(j.length).fill(-1);for(let e of C)e.forEach((t,n)=>{n&&(de[t]=e[n-1],fe[e[n-1]]=t)});let Y=Array(ce).fill(0),X=!1;for(let e=0;e<=ce&&!X;e++){X=!0;for(let e of C)for(let t=1;t<e.length;t++){let n=Y[J[e[t-1]]]+ue(e[t-1],e[t]);Y[J[e[t]]]<n&&(Y[J[e[t]]]=n,X=!1)}}if(X){let e=le.map(e=>Math.round(e.reduce((e,t)=>e+G[t]+oe(t),0)/e.length)),t=Math.min(...e.map((e,t)=>e-Y[t])),n=[...Array(ce).keys()].sort((t,n)=>e[n]-e[t]||t-n);for(let r=0;r<24;r++){let i=!1;for(let a of r%2?[...n].reverse():n){let n=-1/0,r=1/0;for(let e of le[a])de[e]>=0&&(n=Math.max(n,Y[J[de[e]]]+ue(de[e],e))),fe[e]>=0&&(r=Math.min(r,Y[J[fe[e]]]-ue(e,fe[e])));let o=Math.max(n,Math.min(r,e[a]-t));o!==Y[a]&&(Y[a]=o,i=!0)}if(!i)break}for(let e=0;e<j.length;e++)G[e]=Y[J[e]]-oe(e)}else for(let e of C)e.forEach((t,n)=>{G[t]=n?Math.max(Math.round(G[t]),G[e[n-1]]+j[e[n-1]]+W(e[n-1],t)):Math.round(G[t])});let pe=Math.min(...G);for(let e=0;e<G.length;e++)G[e]-=pe;let me=Math.max(...G.map((e,t)=>e+j[t])),he=e=>G[e]+Math.floor((j[e]-1)/2)+.5,ge=new Map;for(let e=0;e<j.length;e++){let t=[...M[e]].sort((e,t)=>he(e)-he(t)),n=G[e]+.5,r=G[e]+j[e]-.5;if(t.length>j[e]){t.forEach((r,i)=>ge.set(r+`|`+e,n+Math.min(j[e]-1,Math.floor(i*j[e]/t.length))));continue}let i=t.map(e=>Math.max(n,Math.min(r,he(e))));for(let e=1;e<i.length;e++)i[e]=Math.max(i[e],i[e-1]+1);for(let e=i.length-1;e>=0;e--)i[e]=Math.min(i[e],e===i.length-1?r:i[e+1]-1);t.forEach((t,n)=>ge.set(t+`|`+e,i[n]))}let _e=(e,t)=>{let n=ge.get(e+`|`+t);return n>=G[e]+.5&&n<=G[e]+j[e]-.5},ve=Array(j.length);for(let e=0;e<j.length;e++){let t=N[e].filter(t=>!_e(e,t)).map(t=>ge.get(e+`|`+t)).sort((e,t)=>e-t);ve[e]=t.length?Math.max(G[e]+.5,Math.min(G[e]+j[e]-.5,t[t.length-1>>1])):he(e)}let ye=(e,t)=>_e(e,t)?ge.get(e+`|`+t):ve[e],be=(e,t)=>{let n=ye(e,t),r=ge.get(e+`|`+t);return[Math.min(n,r),Math.max(n,r)]},xe=new Set,Se=C.map(()=>0);for(let[e,t]of I){if(_e(e,t))continue;let[n,r]=be(e,t),i=ge.get(e+`|`+t)>ve[e];r-n>Mt||I.every(([a,o])=>{if(w[a]!==w[e]||a===e&&o===t)return!0;let[s,c]=be(a,o);return a===e?i?c<=n:s>=r:c<n-1||s>r+1})&&(xe.add(e+`|`+t),Se[w[e]]=Math.max(Se[w[e]],r-n))}let Ce=new Map;for(let[e,t]of I){if(_e(e,t)||xe.has(e+`|`+t))continue;let n=ge.get(e+`|`+t),r=Ce.get(e)||{u:e,lo:ve[e],hi:ve[e],track:0};r.lo=Math.min(r.lo,n),r.hi=Math.max(r.hi,n),Ce.set(e,r)}let we=C.map(()=>0);C.forEach((e,t)=>{let n=[...Ce.values()].filter(e=>w[e.u]===t&&e.hi>e.lo).sort((e,t)=>e.lo-t.lo||e.hi-t.hi||e.u-t.u),r=n.map(e=>N[e.u].filter(t=>!_e(e.u,t)&&!xe.has(e.u+`|`+t)).map(t=>ge.get(e.u+`|`+t))),i=(e,t)=>!(n[e].hi<n[t].lo-1||n[t].hi<n[e].lo-1),a=(e,t)=>+(ve[n[t].u]>n[e].lo&&ve[n[t].u]<n[e].hi)+r[e].filter(e=>e>n[t].lo&&e<n[t].hi).length,o=[];for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){if(!i(e,t))continue;let n=a(t,e)-a(e,t);n>0?o.push([e,t,n]):n<0&&o.push([t,e,-n])}let s=Bt(n.length,o),c=[];for(let e of[...n.keys()].sort((e,t)=>s[e]-s[t]))n[e].track=Math.max(0,...c.filter(t=>i(e,t)).map(e=>n[e].track+1)),c.push(e);we[t]=Math.max(0,...n.map(e=>e.track+1))});let Z=C.map(e=>Math.max(0,...e.filter(e=>!z(e)).map(e=>s[e]))),Te=[],Ee=[],De=[],Oe=0;C.forEach((e,n)=>{Te[n]=Oe,Oe+=Z[n];let r=Math.max(t.some(c)?Ot:Dt,we[n]+2*Pt,Se[n]+2);Ee[n]=Oe+Math.max(Pt,Math.floor((r-we[n])/2));let i=Oe;De[n]=e=>i+Math.floor((r-e)/2),n<C.length-1&&(Oe+=r)});let Q=Oe,ke=e=>Te[w[e]]+Math.floor((Z[w[e]]-s[e])/2),Ae=(e,t)=>a?[t,Q-e]:[e,t];t.forEach((e,t)=>Object.assign(g.get(e),a?{x:G[t],y:Q-ke(t)-s[t]}:{x:ke(t),y:G[t]}));let je=[];for(let e of u){let n=R.get(e),r=null;if(n){r=[Ae(ke(e.u)+s[e.u],ye(e.u,n[1]))];for(let e=1;e<n.length;e++){let t=n[e-1],i=n[e],a=ge.get(t+`|`+i);if(xe.has(t+`|`+i)){let e=Math.abs(a-ve[t]),n=De[w[t]](e);r.push(Ae(n,ve[t]),Ae(n+e,a));continue}let o=Ee[w[t]]+(Ce.get(t)?.track||0)+.5;r.push(Ae(o,ye(t,i)),Ae(o,a))}r.push(Ae(ke(e.v),ge.get(n[n.length-2]+`|`+e.v))),r=r.filter((e,t)=>!t||e[0]!==r[t-1][0]||e[1]!==r[t-1][1]),e.back&&r.reverse()}je.push({p:t[e.p],q:t[e.q],count:e.count,back:e.back,implied:!!e.implied,pts:r})}return a?{w:me,h:Q,out:je}:{w:Q,h:me,out:je}}x(e.root,t);let T=[],E=new Map,D=new Map([[e.root,[At,At]]]);for(let t of d){let[n,r]=D.get(t),i=t===e.root?-1:E.get(t),a=f(t).length;for(let e of t.children||[]){let t=g.get(e);E.set(e,T.length),T.push({id:e.id,ref:e.ref,kind:c(e)?`folder`:`note`,parent:i,depth:a,gx:n+t.x,gy:r+t.y,w:t.w,h:t.h}),c(e)&&D.set(e,[n+t.x+Nt,r+t.y+kt+Nt])}}let O=[],k=new Set;for(let e of d){let[t,n]=D.get(e);for(let r of y.get(e)||[]){let e=E.get(r.q),i=E.get(r.p);r.back&&k.add(e+`|`+i),O.push({a:e,b:i,count:r.count,back:r.back,implied:r.implied,pts:r.pts&&r.pts.map(([e,r])=>[e+t,r+n])})}}let A=zt(T,e.edges,new Map([...u].map(([e,t])=>[e,E.get(t)]))),j=(e,t)=>{for(;T[e].parent!==t;)e=T[e].parent;return e};for(let e of A)e.placed=e.s>=2&&!k.has(j(e.a,e.level)+`|`+j(e.b,e.level));let M=g.get(e.root);return{W:M.w+2*At,H:M.h+2*At,flow:t,cell:s.cell,keep:s.keep,margin:At,items:T,links:A,trunks:O,pairs:_,orders:v}}function zt(e,t,n){let r=t=>{let n=[];for(let r=e[t].parent;r>=0;r=e[r].parent)n.push(r);return n},i=[];for(let[e,a,o]of t){let t=n.get(e),s=n.get(a);if(t===void 0||s===void 0||t===s)continue;let c=new Set(r(s));i.push({a:t,b:s,s:o,level:r(t).find(e=>c.has(e))??-1,placed:!1})}return i}function Bt(e,t){let n=Array.from({length:e},()=>new Map),r=Array.from({length:e},()=>new Map);for(let[e,i,a]of t)e!==i&&(n[e].set(i,(n[e].get(i)||0)+a),r[i].set(e,(r[i].get(e)||0)+a));let i=e=>{let t=0;for(let n of e.values())t+=n;return t},a=new Set([...Array(e).keys()]),o=[],s=[],c=(e,t)=>{a.delete(e),t.push(e);for(let t of n[e].keys())r[t].delete(e);for(let t of r[e].keys())n[t].delete(e)};for(;a.size;){let e=!0;for(;e;){e=!1;for(let t of[...a])r[t].size?n[t].size||(c(t,s),e=!0):(c(t,o),e=!0)}if(!a.size)break;let t=-1,l=-1/0;for(let e of a){let a=i(n[e])-i(r[e]);a>l&&(l=a,t=e)}c(t,o)}let l=Array(e);return[...o,...s.reverse()].forEach((e,t)=>{l[e]=t}),l}var Vt={climb:5,turn45:1.5,turn90:3,foreign:2.5,crowd:.2,near:0,hug:2.5,haste:3.2},Ht=[1,1,0,-1,-1,-1,0,1],Ut=[0,1,1,1,0,-1,-1,-1],Wt=3,Gt=8;function Kt(e,t,n={}){let{climb:r,turn45:i,turn90:a,foreign:o,crowd:s,near:c,hug:l,haste:u}={...Vt,...n},{W:d,H:f,elev:p,blocked:m,owner:h}=t,g=t.close||new Uint8Array(d*f),_=d*f,v=e.items,y=new Uint16Array(_),b=new Uint16Array(_),x=new Float32Array(_*9),S=new Int32Array(_*9),C=new Uint32Array(_*9),w=new Uint32Array(v.length),T=_*9,E=0,D=new Float32Array(4096),O=new Float32Array(4096),k=new Int32Array(4096),A=0,j=(e,t,n)=>{if(A===D.length){let e=(e,t)=>{let n=new t(e.length*2);return n.set(e),n};D=e(D,Float32Array),O=e(O,Float32Array),k=e(k,Int32Array)}let r=A++;for(;r>0;){let t=r-1>>1;if(D[t]<=e)break;D[r]=D[t],O[r]=O[t],k[r]=k[t],r=t}D[r]=e,O[r]=t,k[r]=n},M=()=>{N=O[0],P=k[0];let e=D[--A],t=O[A],n=k[A],r=0;for(;;){let t=2*r+1;if(t>=A||(t+1<A&&D[t+1]<D[t]&&t++,D[t]>=e))break;D[r]=D[t],O[r]=O[t],k[r]=k[t],r=t}D[r]=e,O[r]=t,k[r]=n},N=0,P=0,F=(e,t)=>{y[e]+=t;let n=e%d,r=e/d|0;for(let e=Math.max(0,r-1);e<=Math.min(f-1,r+1);e++)for(let i=Math.max(0,n-1);i<=Math.min(d-1,n+1);i++)(i!==n||e!==r)&&(b[e*d+i]+=t)},I=e=>{let t=[],n=(e,n,r,i)=>{e>=0&&n>=0&&e<d&&n<f&&!m[n*d+e]&&t.push([n*d+e,r,i])};for(let t=e.gx;t<e.gx+e.w;t++)n(t,e.gy-1,t+.5,e.gy),n(t,e.gy+e.h,t+.5,e.gy+e.h);for(let t=e.gy;t<e.gy+e.h;t++)n(e.gx-1,t,e.gx,t+.5),n(e.gx+e.w,t,e.gx+e.w,t+.5);return t};function L(e,t,n,f,_,D,O=null){E++,A=0;for(let t of ft(v,e))w[t]=E;if(O){w[O.folder]=E;for(let e of ft(v,O.folder))w[e]=E}else for(let e of ft(v,t))w[e]=E;let k=v[e],L=O?null:v[t],R=O?O.ends:new Map(I(L).map(e=>[e[0],e])),z,B,V,ee;if(O?.toward!==void 0)z=B=O.toward%d,V=ee=O.toward/d|0;else if(O){z=V=1/0,B=ee=-1/0;for(let e of R.keys()){let t=e%d,n=e/d|0;z=Math.min(z,t),B=Math.max(B,t),V=Math.min(V,n),ee=Math.max(ee,n)}}else z=L.gx-1,B=L.gx+L.w,V=L.gy-1,ee=L.gy+L.h;let H=(e,t)=>{let n=Math.max(z-e,e-B,0),r=Math.max(V-t,t-ee,0);return u*(Math.max(n,r)+.414*Math.min(n,r))},U=new Map;for(let e of I(k)){let t=e[0],n=t*9+Gt,r=Math.fround(1+s*Math.min(y[t],Wt));C[n]===E&&x[n]<=r||(C[n]=E,x[n]=r,S[n]=-1,j(r+H(t%d,t/d|0),r,n),U.set(t,e))}let te=!!O?.strict,ne=-1;for(;A;){M();let e=P,t=N;if(e>=T){ne=e-T;break}if(t!==x[e])continue;let u=e/9|0,v=e%9,k=R.get(u);if(k){if(!k[3]){ne=e;break}j(Math.fround(t+k[3]),Math.fround(t+k[3]),T+e)}let A=u%d,F=u/d|0;for(let T=0;T<8;T++){let k=A+Ht[T],M=F+Ut[T];if(k<n||M<f||k>_||M>D)continue;let N=M*d+k;if(m[N]||te&&h[N]!==O.folder)continue;if(Ht[T]&&Ut[T]){let e=F*d+k,t=M*d+A;if(m[e]||m[t]||p[e]!==p[u]||p[t]!==p[u]||p[N]!==p[u])continue}let P=(Ht[T]&&Ut[T]?1.414:1)*(1+s*Math.min(y[N],Wt)+c*Math.min(b[N],Wt))+r*Math.abs(p[N]-p[u]);if(v!==Gt&&v!==T){let e=Math.min((T-v+8)%8,(v-T+8)%8);P+=e===1?i:a*(e>=3?2:1)}h[N]>=0&&w[h[N]]!==E&&(P+=o),g[N]&&(P+=l);let I=N*9+T,L=Math.fround(t+P);C[I]===E&&x[I]<=L||(C[I]=E,x[I]=L,S[I]=e,j(L+H(k,M),L,I))}}if(ne<0)return null;let re=[];for(let e=ne;e!==-1;e=S[e])re.push(e/9|0);re.reverse();for(let e of re)F(e,1);let W=U.get(re[0]),G=R.get(re[re.length-1]),ie=[[W[1],W[2]]];for(let e of re)ie.push([e%d+.5,(e/d|0)+.5]);return ie.push([G[1],G[2]]),{cells:Int32Array.from(re),pts:ie}}function R(e,t){let n=v[e],r=v[t],i=Math.max(Math.abs(n.gx-r.gx),Math.abs(n.gy-r.gy)),a=Math.max(12,Math.ceil(i*.4)),o=Math.max(0,Math.min(n.gx,r.gx)-a),s=Math.max(0,Math.min(n.gy,r.gy)-a),c=Math.min(d-1,Math.max(n.gx+n.w,r.gx+r.w)+a),l=Math.min(f-1,Math.max(n.gy+n.h,r.gy+r.h)+a);return L(e,t,o,s,c,l)||(o||s||c<d-1||l<f-1?L(e,t,0,0,d-1,f-1):null)}function z(e,t){return v[e],v[t.folder],B(e,{...t,strict:!0})||B(e,t)}function B(e,t){let n=v[e],r=v[t.folder];return L(e,-1,Math.max(0,Math.min(n.gx,r.gx)-2),Math.max(0,Math.min(n.gy,r.gy)-2),Math.min(d-1,Math.max(n.gx+n.w,r.gx+r.w)+2),Math.min(f-1,Math.max(n.gy+n.h,r.gy+r.h)+2),t)}function V(e){let t=new Set;for(let n=1;n<e.length;n++){let[r,i]=e[n-1],[a,o]=e[n],s=Math.max(1,Math.ceil(Math.max(Math.abs(a-r),Math.abs(o-i))*2));for(let e=0;e<=s;e++){let n=Math.floor(r+(a-r)*e/s),c=Math.floor(i+(o-i)*e/s);n<0||c<0||n>=d||c>=f||m[c*d+n]||t.has(c*d+n)||(t.add(c*d+n),F(c*d+n,1))}}}return{route:R,routeTo:z,occupy:V,release:e=>{for(let t of e.cells)F(t,-1)},hold:e=>{for(let t of e.cells)F(t,1)}}}var qt=[0,1,-1,2,-2,3,-3];function Jt(e,t){let n=new Map;e.forEach((e,r)=>{e.edges=new Set;for(let i=1;i<e.cells.length;i++){let a=e.cells[i-1],o=e.cells[i],s=a<o?a*t+o:o*t+a;e.edges.add(s),n.has(s)||n.set(s,[]),n.get(s).push(r)}}),e.forEach((t,r)=>{let i=new Set;for(let a of t.edges)for(let t of n.get(a))t<r&&i.add(e[t].lane);t.lane=qt.find(e=>!i.has(e))??0,delete t.edges})}var Yt=(e,t,n,r)=>{let i=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return i(e,t,n)*i(e,t,r)<0&&i(n,r,e)*i(n,r,t)<0};function Xt(e,t){let n=new Map;e.forEach((e,t)=>{for(let r of e.cells)n.has(r)||n.set(r,new Set),n.get(r).add(t)});let r=0,i=0;e.forEach((e,a)=>{for(let o of e.cells){r++;let e=!1,s=o%t;for(let r=-1;r<=1&&!e;r++)for(let i=-1;i<=1&&!e;i++){if(s+i<0||s+i>=t)continue;let c=n.get(o+r*t+i);if(c){for(let t of c)if(t!==a){e=!0;break}}}e||i++}});let a=e.map((e,t)=>{let n=[t*.618%1*.02-.01,t*.414%1*.02-.01],r=e.pts;return r.filter((e,t)=>t===0||t===r.length-1||Math.abs((e[0]-r[t-1][0])*(r[t+1][1]-e[1])-(e[1]-r[t-1][1])*(r[t+1][0]-e[0]))>1e-6).map(e=>[e[0]+n[0],e[1]+n[1]])}),o=0;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let r=e[t],i=e[n];if(r.a!==i.a&&r.a!==i.b&&r.b!==i.a&&r.b!==i.b)for(let e=1;e<a[t].length;e++)for(let r=1;r<a[n].length;r++)Yt(a[t][e-1],a[t][e],a[n][r-1],a[n][r])&&o++}return{routes:e.length,crossings:o,length:r,beside:r?1-i/r:0}}function Zt(e,t,n,r,i=t.length<=100?2:+(t.length<=300)){let a=t.map(({a:t,b:n})=>{let r=e.route(t,n);return r&&{a:t,b:n,...r}});for(let t=0;t<i;t++)a.forEach((t,n)=>{if(!t)return;e.release(t);let r=e.route(t.a,t.b);r?Object.assign(t,r):e.hold(t)});let o=a.filter(Boolean);Jt(o,n*r);let s={...Xt(o,n),lost:a.length-o.length};for(let t of o)e.release(t);return{routes:a.map(e=>e&&{pts:e.pts,lane:e.lane}),measures:s}}var Qt=[1,1,0,-1,-1,-1,0,1],$t=[0,1,1,1,0,-1,-1,-1],en=8,tn={turn45:1.5,turn90:3,diag:1.3,hug:1,share:.35,centre:.3,gather:224};function nn(e,t=dt(e),n={}){let{turn45:r,turn90:i,diag:a,hug:o,share:s,centre:c,gather:l}={...tn,...n},{items:u,trunks:d}=e,{W:f,H:p,blocked:m,owner:h}=t,g=f*p,_=Math.max(2,Math.round(28/(e.cell??7))),v=pn(t,_),y=_,b=new Uint8Array(g),x=10/(e.cell??7),S=(e,t)=>e>=0&&t>=0&&e<f&&t<p,C=(e,t,n)=>S(e,t)&&!m[t*f+e]&&h[t*f+e]===n;function w(e,t,n){let[r,i]=e,[a,o]=t,s=n?a-r:o-i,c=n?o-i:a-r,l=Math.sign(s),u=Math.sign(c),d=Math.abs(s),f=Math.abs(c),p=[];if(d>=f){let e=Math.floor((d-f)/2);for(let t=0;t<e;t++)p.push([l,0]);for(let e=0;e<f;e++)p.push([l,u]);for(let t=0;t<d-f-e;t++)p.push([l,0])}else{let e=Math.floor(d/2);for(let t=0;t<e;t++)p.push([l,u]);for(let e=0;e<f-d;e++)p.push([0,u]);for(let t=0;t<d-e;t++)p.push([l,u])}let m=[[r,i]],h=r,g=i;for(let[e,t]of p)n?(h+=e,g+=t):(h+=t,g+=e),m.push([h,g]);return m}function T(e,t,n,r,i){let a=Math.max(e.gx-(t.gx+t.w),t.gx-(e.gx+e.w)),o=Math.max(e.gy-(t.gy+t.h),t.gy-(e.gy+e.h)),s=a>=o;if((s?a:o)<1)return null;let[c,l]=s?t.gx<e.gx?[3,2]:[2,3]:t.gy<e.gy?[1,0]:[0,1];if(i&&i.side!==c||r&&r.side!==l)return null;let u=fn(t)[c],d=fn(e)[l],p=s?Math.max(e.gy,t.gy):Math.max(e.gx,t.gx),m=s?Math.min(e.gy+e.h,t.gy+t.h):Math.min(e.gx+e.w,t.gx+t.w),h=e=>Math.floor(e.mid-.5+1e-9),g=e=>e>=p&&e<m,b=r||i?[[i?i.t:g(r.t)?r.t:h(u),r?r.t:g(i.t)?i.t:h(d),0]]:m-p>=1?mn(p,m).map(e=>[e,e,Math.abs(e+.5-(p+m)/2)]):[[h(u),h(d),0]],S=null;for(let[r,i,a]of b){if(rn(t,c,r,x)||rn(e,l,i,x))continue;let o=w(s?[c===3?t.gx+t.w:t.gx-1,r]:[r,c===1?t.gy+t.h:t.gy-1],s?[l===2?e.gx-1:e.gx+e.w,i]:[i,l===0?e.gy-1:e.gy+e.h],s);if(!o.every(([e,t])=>C(e,t,n)))continue;let u=o.slice(_,o.length-_),d=u.length?Math.min(...u.map(([e,t])=>v[t*f+e])):_;d<y||(!S||d>S.least||d===S.least&&a<S.off)&&(S={least:d,off:a,tb:r,ta:i,way:o})}return S?[u.wall(S.tb),...S.way.map(([e,t])=>[e+.5,t+.5]),d.wall(S.ta)]:null}let E=new Float32Array(g+1),D=new Int32Array(g+1),O=new Uint8Array(g+1),k=new Uint32Array(g+1),A=0,j=[],M=(e,t)=>{j.push([e,t]);let n=j.length-1;for(;n>0;){let t=n-1>>1;if(j[t][0]<=e)break;[j[t],j[n]]=[j[n],j[t]],n=t}},N=()=>{let e=j[0],t=j.pop();if(j.length){j[0]=t;let e=0;for(;;){let t=2*e+1;if(t>=j.length||(t+1<j.length&&j[t+1][0]<j[t][0]&&t++,j[t][0]>=j[e][0]))break;[j[t],j[e]]=[j[e],j[t]],e=t}}return e},P=(e,t)=>{if(e===en||e===t)return 0;let n=Math.min((t-e+8)%8,(e-t+8)%8);return n===1?r:i*(n>=3?2:1)};function F(e,t,n,r,i){A++,j.length=0;let l=g,u=new Map,d=(e,t,n)=>!e||e.side===t&&e.t===n;if(fn(e).forEach((t,i)=>t.cells.forEach(([a,o])=>{let s=t.dir===6||t.dir===2?a:o;C(a,o,n)&&d(r,i,s)&&!rn(e,i,s,x)&&u.set(o*f+a,[(t.dir+4)%8,c*Math.abs(s+.5-t.mid),t.wall(s)])})),!r)for(let t of an(e,x))C(...t.out,n)&&u.set(t.out[1]*f+t.out[0],[(t.dir+4)%8,c*Math.min(e.w,e.h)/2,t.pt]);if(!u.size)return null;let p=e.gx-1,m=e.gx+e.w,h=e.gy-1,y=e.gy+e.h,S=(e,t)=>{let n=Math.max(p-e,e-m,0),r=Math.max(h-t,t-y,0);return Math.max(n,r)+.414*Math.min(n,r)},w=new Map,T=(e,t,n,r)=>{k[e]===A&&E[e]<=t||(k[e]=A,E[e]=t,D[e]=-1,O[e]=n,w.set(e,r),M(t+S(e%f,e/f|0),e))};if(fn(t).forEach((e,r)=>e.cells.forEach(([a,o])=>{let s=e.dir===6||e.dir===2?a:o;C(a,o,n)&&d(i,r,s)&&!rn(t,r,s,x)&&T(o*f+a,c*Math.abs(s+.5-e.mid),e.dir,e.wall(s))})),!i)for(let e of an(t,x))C(...e.out,n)&&T(e.out[1]*f+e.out[0],c*Math.min(t.w,t.h)/2,e.dir,e.pt);for(;j.length;){let[e,t]=N();if(t===l)break;let r=E[t];if(e-S(t%f,t/f|0)>r+1e-4)continue;let i=u.get(t);if(i){let e=r+i[1]+P(O[t],i[0]);(k[l]!==A||e<E[l])&&(k[l]=A,E[l]=e,D[l]=t,M(e,l))}let c=t%f,d=t/f|0;for(let e=0;e<8;e++){let i=c+Qt[e],l=d+$t[e];if(!C(i,l,n)||Qt[e]&&$t[e]&&(!C(i,d,n)||!C(c,l,n)))continue;let u=l*f+i,p=r+(Qt[e]&&$t[e]?Math.SQRT2*a:1)*(b[u]?1-s:1)+o*(_-v[u])+P(O[t],e);k[u]===A&&E[u]<=p||(k[u]=A,E[u]=p,D[u]=t,O[u]=e,M(p+S(i,l),u))}}if(k[l]!==A)return null;let F=[];for(let e=D[l];e!==-1;e=D[e])F.push(e);return F.reverse(),[w.get(F[0]),...F.map(e=>[e%f+.5,Math.floor(e/f)+.5]),u.get(F.at(-1))[2]]}let I=d.map((e,t)=>t).sort((e,t)=>d[t].count-d[e].count||e-t),L=d.map(e=>({a:e.a,b:e.b,count:e.count,back:e.back,implied:e.implied})),R=e=>cn(e,(e,t)=>{S(e,t)&&!m[t*f+e]&&(b[t*f+e]=1)}),z=(e,t,n)=>{let r=d[e],i=u[r.a],a=u[r.b];return T(i,a,i.parent,t,n)??F(i,a,i.parent,t,n)};for(let e of I){let t=z(e);t&&(L[e].pts=t,R(t))}let B=l/(e.cell??7),V=new Map;L.forEach((e,t)=>{if(e.pts)for(let[n,r,i]of[[`b`,e.b,e.pts[0]],[`a`,e.a,e.pts.at(-1)]]){let a=u[r];if(a.kind!==`folder`||!on(a,i))continue;let o=sn(a,i),s=`${r}|${o}`;V.set(s,[...V.get(s)||[],{k:t,end:n,t:Math.floor(o<2?i[0]:i[1]),count:e.count}])}});let ee=new Map;for(let[e,t]of V){let[n,r]=e.split(`|`).map(Number),i=u[n];fn(i)[r],r<2?i.gx:i.gy,t.sort((e,t)=>e.t-t.t);for(let e=0;e<t.length;){let n=e+1;for(;n<t.length&&t[n].t-t[n-1].t<=B;)n++;let a=t.slice(e,n);if(e=n,a.length<2||a.every(e=>e.t===a[0].t))continue;let o=new Map;for(let e of a)o.set(e.t,(o.get(e.t)||0)+e.count);let s=(a[0].t+a.at(-1).t)/2,c=[...o].filter(([e])=>!rn(i,r,e,x)).reduce((e,t)=>t[1]>e[1]||t[1]===e[1]&&Math.abs(t[0]-s)<Math.abs(e[0]-s)?t:e)[0];for(let e of a)e.t!==c&&ee.set(e.k,{...ee.get(e.k),[e.end]:{side:r,t:c}})}}if(ee.size){b.fill(0),L.forEach((e,t)=>{e.pts&&!ee.has(t)&&R(e.pts)});for(let e of I){let t=ee.get(e);if(!t)continue;let n=L[e],r=(e,t)=>{if(!on(u[e],t))return;let n=sn(u[e],t);return{side:n,t:Math.floor(n<2?t[0]:t[1])}},i=z(e,t.a??r(n.a,n.pts.at(-1)),t.b??r(n.b,n.pts[0]));i&&(L[e].pts=i),R(L[e].pts)}}return L}function rn(e,t,n,r){if(e.kind!==`folder`)return!1;let i=t<2?e.gx:e.gy,a=i+(t<2?e.w:e.h);return n+.5-i<r||a-(n+.5)<r}function an(e,t){return e.kind===`folder`?[[e.gx,e.gy,1,1,5],[e.gx+e.w,e.gy,-1,1,7],[e.gx+e.w,e.gy+e.h,-1,-1,1],[e.gx,e.gy+e.h,1,-1,3]].map(([e,n,r,i,a])=>({out:[Math.floor(e-r*.5),Math.floor(n-i*.5)],in:[Math.floor(e+r*.5),Math.floor(n+i*.5)],dir:a,pt:[e+r*t/2,n+i*t/2]})):[]}function on(e,[t,n]){let r=(e,t)=>Math.abs(e-t)<1e-6;return(r(t,e.gx)||r(t,e.gx+e.w))&&n>=e.gy-1e-6&&n<=e.gy+e.h+1e-6||(r(n,e.gy)||r(n,e.gy+e.h))&&t>=e.gx-1e-6&&t<=e.gx+e.w+1e-6}function sn(e,[t,n]){let r=(e,t)=>Math.abs(e-t)<1e-6;return r(n,e.gy)?0:r(n,e.gy+e.h)?1:r(t,e.gx)?2:3}function cn(e,t){for(let n=1;n<e.length;n++){let[r,i]=e[n-1],[a,o]=e[n],s=Math.max(1,Math.ceil(Math.max(Math.abs(a-r),Math.abs(o-i))*2));for(let e=0;e<=s;e++)t(Math.floor(r+(a-r)*e/s),Math.floor(i+(o-i)*e/s))}}var ln={turn45:1.5,turn90:3,diag:1.3,hug:1,centre:1,join:.5,cross:1,haste:1.5,hasteNote:4};function un(e,t,n=dt(e),r={}){let{turn45:i,turn90:a,diag:o,hug:s,centre:c,join:l,cross:u,haste:d,hasteNote:f}={...ln,...r},{items:p,links:m}=e,{W:h,H:g,blocked:_,owner:v}=n,y=h*g,b=Math.max(2,Math.round(28/(e.cell??7))),x=pn(n,b),S=10/(e.cell??7),C=new Uint8Array(y);for(let e of t)e.pts&&cn(e.pts,(e,t)=>{e>=0&&t>=0&&e<h&&t<g&&(C[t*h+e]=1)});let w=(e,t)=>e>=0&&t>=0&&e<h&&t<g,T=(e,t)=>{for(;p[e].parent!==t;)e=p[e].parent;return e},E=(e,[t,n])=>{let r=(e,t)=>Math.abs(e-t)<1e-6;if(!on(e,[t,n])){let i=an(e,S).find(e=>r(e.pt[0],t)&&r(e.pt[1],n));if(i)return[...i.in,i.dir]}return r(t,e.gx)?[e.gx,Math.floor(n),4]:r(t,e.gx+e.w)?[e.gx+e.w-1,Math.floor(n),0]:r(n,e.gy)?[Math.floor(t),e.gy,6]:[Math.floor(t),e.gy+e.h-1,2]},D=(e,t)=>(Qt[e]&&$t[e]?Math.SQRT2*o:1)+s*(b-x[t]),O=(e,t)=>{if(e===en||e===t)return 0;let n=Math.min((t-e+8)%8,(e-t+8)%8);return n===1?i:a*(n>=3?2:1)},k=new Float32Array(y*9+1),A=new Int32Array(y*9+1),j=new Uint32Array(y*9+1),M=y*9,N=0,P=new Float64Array(4096),F=new Float64Array(4096),I=new Int32Array(4096),L=0,R=0,z=0,B=(e,t,n)=>{if(L===P.length){let e=(e,t)=>{let n=new t(e.length*2);return n.set(e),n};P=e(P,Float64Array),F=e(F,Float64Array),I=e(I,Int32Array)}let r=L++;for(;r>0;){let t=r-1>>1;if(P[t]<=e)break;P[r]=P[t],F[r]=F[t],I[r]=I[t],r=t}P[r]=e,F[r]=t,I[r]=n},V=()=>{P[0],R=F[0],z=I[0];let e=P[--L],t=F[L],n=I[L],r=0;for(;;){let t=2*r+1;if(t>=L||(t+1<L&&P[t+1]<P[t]&&t++,P[t]>=e))break;P[r]=P[t],F[r]=F[t],I[r]=I[t],r=t}P[r]=e,F[r]=t,I[r]=n};function ee(e,t,n,r,i){N++,L=0;let a=(e,t)=>w(e,t)&&!_[t*h+e]&&v[t*h+e]===n,o=r%h,d=r/h|0,f=(e,t)=>{let n=Math.abs(e-o),r=Math.abs(t-d);return i*(1-l)*(Math.max(n,r)+.414*Math.min(n,r))},p=new Map;if(e.kind===`folder`)for(let t of an(e,S)){let[n,r]=t.out;if(!a(n,r))continue;let i=r*h+n,o=i*9+t.dir,l=Math.fround(c*Math.min(e.w,e.h)/2+s*(b-x[i]));j[o]===N&&k[o]<=l||(j[o]=N,k[o]=l,A[o]=-1,p.set(i,t.pt),B(l+f(n,r),l,o))}for(fn(e).forEach((t,n)=>t.cells.forEach(([r,i])=>{if(!a(r,i)||rn(e,n,t.dir===6||t.dir===2?r:i,S))return;let o=t.dir===6||t.dir===2?r:i,l=i*h+r,u=l*9+t.dir,d=Math.fround(c*Math.abs(o+.5-t.mid)+s*(b-x[l]));j[u]===N&&k[u]<=d||(j[u]=N,k[u]=d,A[u]=-1,p.set(l,t.wall(o)),B(d+f(r,i),d,u))}));L;){V();let e=z,n=R;if(e===M)break;if(n!==k[e])continue;let r=e/9|0,i=e%9,o=r%h,s=r/h|0,c=t.get(r);if(c){let t=n+c.rest+O(i,c.dir);(j[M]!==N||t<k[M])&&(j[M]=N,k[M]=t,A[M]=e,B(t,t,M))}for(let t=0;t<8;t++){let r=o+Qt[t],c=s+$t[t];if(!a(r,c)||Qt[t]&&$t[t]&&(!a(r,s)||!a(o,c)))continue;let l=c*h+r,d=l*9+t,p=Math.fround(n+D(t,l)+(C[l]?u:0)+O(i,t));j[d]===N&&k[d]<=p||(j[d]=N,k[d]=p,A[d]=e,B(p+f(r,c),p,d))}}if(j[M]!==N)return null;let m=[];for(let e=A[M];e!==-1;e=A[e])m.push(e/9|0);return m.reverse(),{cells:m,pts:[p.get(m[0]),...m.map(e=>[e%h+.5,Math.floor(e/h)+.5]),t.get(m.at(-1)).pt]}}let H=[];t.forEach((e,t)=>{if(!e.pts)return;let n=p[e.a].parent,r=m.filter(t=>t.s>=2&&t.level===n&&T(t.a,n)===e.a&&T(t.b,n)===e.b);p[e.a].kind===`folder`&&H.push({folder:e.a,at:e.pts[e.pts.length-1],notes:r.map(e=>e.a),trunk:t}),p[e.b].kind===`folder`&&H.push({folder:e.b,at:e.pts[0],notes:r.map(e=>e.b),trunk:t})});let U=[],te=e=>p[e].kind===`note`,ne=new Map;for(let e=0;e<H.length;e++){let{folder:t,at:n,notes:r,trunk:i}=H[e],[a,c,u]=E(p[t],n);if(!w(a,c)||_[c*h+a])continue;let m=c*h+a,g={dir:u,rest:0,pt:n};ne.has(m)||ne.set(m,{ends:new Map([[m,g]]),endsAny:new Map([[m,g]]),owners:new Map([[m,-1]]),exits:new Map});let{ends:v,endsAny:y,owners:S,exits:C}=ne.get(m),D=new Map;for(let e of r){let n=T(e,t);D.set(n,[...D.get(n)||[],e])}for(let[e,n]of[...D].sort((e,t)=>te(e[0])-te(t[0])||t[1].length-e[1].length||e[0]-t[0])){let r=te(e),a=C.get(e),c=r?y:v,u=a&&c.has(a.cell)?{cells:[a.cell],pts:[a.wall,c.get(a.cell).pt,c.get(a.cell).pt]}:ee(p[e],c,t,m,r?f:d);if(!u)continue;a||C.set(e,{cell:u.cells[0],wall:u.pts[0]});let g=U.length,_=u.cells.at(-1);U.push({item:e,folder:t,trunk:i,count:n.length,pts:u.pts,cells:u.cells,leaf:r,via:S.get(_)??-1});let w=new Float32Array(u.cells.length);w[w.length-1]=y.get(_).rest;for(let e=u.cells.length-2;e>=0;e--){let t=u.cells[e],n=u.cells[e+1],r=t%h!==n%h&&Math.floor(t/h)!==Math.floor(n/h);w[e]=w[e+1]+(1-l)*((r?Math.SQRT2*o:1)+s*(b-x[n]))}for(let[e,t]of u.cells.entries()){if(y.has(t))continue;let n=u.cells[e+1],i={dir:n===void 0?y.get(_).dir:dn(n%h-t%h,Math.floor(n/h)-Math.floor(t/h)),rest:w[e],pt:[t%h+.5,Math.floor(t/h)+.5]};y.set(t,i),S.set(t,g),r||v.set(t,i)}r||H.push({folder:e,at:u.pts[0],notes:n,trunk:i})}}return Jt(U,y),U.map(({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s})=>({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s}))}var dn=(e,t)=>Qt.findIndex((n,r)=>n===Math.sign(e)&&$t[r]===Math.sign(t));function fn(e){return[{dir:6,cells:mn(e.gx,e.gx+e.w).map(t=>[t,e.gy-1]),mid:e.gx+e.w/2,wall:t=>[t+.5,e.gy]},{dir:2,cells:mn(e.gx,e.gx+e.w).map(t=>[t,e.gy+e.h]),mid:e.gx+e.w/2,wall:t=>[t+.5,e.gy+e.h]},{dir:4,cells:mn(e.gy,e.gy+e.h).map(t=>[e.gx-1,t]),mid:e.gy+e.h/2,wall:t=>[e.gx,t+.5]},{dir:0,cells:mn(e.gy,e.gy+e.h).map(t=>[e.gx+e.w,t]),mid:e.gy+e.h/2,wall:t=>[e.gx+e.w,t+.5]}]}function pn({W:e,H:t,blocked:n,owner:r},i){let a=e*t,o=new Uint8Array(a).fill(i),s=new Int32Array(a),c=0,l=0;for(let i=0;i<a;i++){if(n[i]){o[i]=0;continue}let a=i%e,c=i/e|0;for(let u=0;u<8;u++){let d=a+Qt[u],f=c+$t[u];if(d<0||f<0||d>=e||f>=t)continue;let p=f*e+d;if(n[p]||r[p]!==r[i]){o[i]=1,s[l++]=i;break}}}for(;c<l;){let a=s[c++],u=a%e,d=a/e|0;if(!(o[a]+1>=i))for(let i=0;i<8;i++){let c=u+Qt[i],f=d+$t[i];if(c<0||f<0||c>=e||f>=t)continue;let p=f*e+c;o[p]>o[a]+1&&!n[p]&&r[p]===r[a]&&(o[p]=o[a]+1,s[l++]=p)}}return o}var mn=(e,t)=>Array.from({length:Math.max(0,t-e)},(t,n)=>e+n);function hn(e,t){let n=10/(e.cell??7),r=e.items.filter(e=>e.kind===`folder`),i=(e,t)=>Math.abs(e-t)<1e-6,a=(e,t)=>{for(let a of r){let r=i(e[0],a.gx)||i(e[0],a.gx+a.w),o=i(e[1],a.gy)||i(e[1],a.gy+a.h);if(!(r&&e[1]>=a.gy-1e-6&&e[1]<=a.gy+a.h+1e-6)&&!(o&&e[0]>=a.gx-1e-6&&e[0]<=a.gx+a.w+1e-6))continue;let s=e[0]-a.gx<a.w/2?1:-1,c=e[1]-a.gy<a.h/2?1:-1,l=s>0?a.gx:a.gx+a.w,u=c>0?a.gy:a.gy+a.h;if(Math.abs(e[0]-l)+Math.abs(e[1]-u)>=n-1e-6)return null;let d=[l+s*n/2,u+c*n/2],f=t[0]>a.gx&&t[0]<a.gx+a.w&&t[1]>a.gy&&t[1]<a.gy+a.h?[s,c]:[-s,-c],p=t[0]-d[0],m=t[1]-d[1];if(Math.abs(Math.abs(p)-Math.abs(m))<1e-6&&p*f[0]>0)return[d];let h=[p/f[0],m/f[1]].filter(e=>e>1e-6).sort((e,t)=>e-t);return h.length?[d,[d[0]+f[0]*h[0],d[1]+f[1]*h[0]]]:null}return null};for(let e of t){if(!e.pts||e.pts.length<2)continue;let t=a(e.pts[0],e.pts[1]);t&&(e.pts=[...t,...e.pts.slice(1)]);let n=a(e.pts.at(-1),e.pts.at(-2));n&&(e.pts=[...e.pts.slice(0,-1),...n.reverse()])}return t}function gn(e,t=!1){let n=e=>e.kind===`dir`?{kind:`dir`,id:e.id,ref:e.ref,children:e.children.map(n)}:{kind:e.kind,id:e.id,ref:e.ref,weight:e.weight,rank:e.rank||0};if(t){let t=[],r=e=>{e.kind===`dir`?e.children.forEach(r):t.push(n(e))};return r(e.root),{root:{kind:`dir`,id:e.root.id,ref:e.root.ref,children:t},edges:e.edges,code:!1}}return{root:n(e.root),edges:e.edges,code:!!e.code}}function _n(e,t){let n={flow:t.gridFlow===`right`?`right`:`up`,grain:Sn(t),plan:!!t.blocks,from:t.from??null},r=Rt(e,n);if(t.blocks){let t=vn(r,nn(r,dt(r)));[...t.values()].some(e=>e.wider.size)&&(r=Rt(e,{...n,planned:t}))}r.feeders=yn(r);let i=dt(r),a=nn(r,i),o=un(r,a,i);return hn(r,[...a,...o]),r.highways={trunks:a,feeders:o},r}function vn(e,t){let{items:n}=e,r=e.cell>7?2:3,i=new Map;for(let[a,o]of e.pairs??[]){let e=a===``?-1:n.findIndex(e=>e.kind===`folder`&&e.ref===a),s=n.map((e,t)=>t).filter(t=>n[t].parent===e),c=t.filter(t=>t.pts&&n[t.a].parent===e),l=new Map;for(let e of s)for(let t of s){if(e>=t)continue;let i=n[e],a=n[t],[o,s]=i.gx<=a.gx?[i,a]:[a,i],[u,d]=i.gy<=a.gy?[i,a]:[a,i],f=s.gx-(o.gx+o.w),p=d.gy-(u.gy+u.h),m=null,h=!1;if(f>0&&f<=16&&Math.min(i.gy+i.h,a.gy+a.h)-Math.max(i.gy,a.gy)>=4?(m=[o.gx+o.w,Math.max(i.gy,a.gy),s.gx,Math.min(i.gy+i.h,a.gy+a.h)],h=!0):p>0&&p<=16&&Math.min(i.gx+i.w,a.gx+a.w)-Math.max(i.gx,a.gx)>=4&&(m=[Math.max(i.gx,a.gx),u.gy+u.h,Math.min(i.gx+i.w,a.gx+a.w),d.gy]),!m)continue;let g=new Map;for(let e of c)for(let t=1;t<e.pts.length;t++){let[n,r]=e.pts[t-1],[i,a]=e.pts[t],o=Math.max(1,Math.ceil(Math.max(Math.abs(i-n),Math.abs(a-r))));for(let e=0;e<=o;e++){let t=Math.floor(n+(i-n)*e/o),s=Math.floor(r+(a-r)*e/o);if(t<m[0]||t>=m[2]||s<m[1]||s>=m[3])continue;let c=h?t:s;g.has(c)||g.set(c,new Set),g.get(c).add(h?s:t)}}let _=[...g.values()].filter(e=>e.size>=4).length;_>1&&l.set([i.ref,a.ref].sort().join(`|`),r*(_-1))}i.set(a,{pair:o,wider:l})}return i}function yn(e,t=e.trunks){let{items:n,links:r,W:i}=e;if(!t.some(e=>e.pts&&(n[e.a].kind===`folder`||n[e.b].kind===`folder`)))return[];let a=dt(e),o=Kt(e,a,{crowd:1,haste:1.5});for(let e of t)e.pts&&o.occupy(e.pts);let s=(e,t)=>{for(;n[e].parent!==t;)e=n[e].parent;return e},c=(e,[t,r])=>{let i=n[e],a=(e,t)=>Math.abs(e-t)<1e-6;return a(t,i.gx)?[i.gx,Math.floor(r)]:a(t,i.gx+i.w)?[i.gx+i.w-1,Math.floor(r)]:a(r,i.gy)?[Math.floor(t),i.gy]:[Math.floor(t),i.gy+i.h-1]},l=[];t.forEach((e,t)=>{if(!e.pts)return;let i=n[e.a].parent,a=r.filter(t=>t.s>=2&&t.level===i&&s(t.a,i)===e.a&&s(t.b,i)===e.b);n[e.a].kind===`folder`&&l.push({folder:e.a,at:e.pts[e.pts.length-1],notes:a.map(e=>e.a),trunk:t}),n[e.b].kind===`folder`&&l.push({folder:e.b,at:e.pts[0],notes:a.map(e=>e.b),trunk:t})});let u=[];for(let e=0;e<l.length;e++){let{folder:t,at:r,notes:d,trunk:f}=l[e],[p,m]=c(t,r);if(p<0||m<0||p>=i||a.blocked[m*i+p])continue;let h=new Map;for(let e of d){let n=s(e,t);h.set(n,[...h.get(n)||[],e])}let g=m*i+p,_=e=>n[e].kind===`note`,v=new Map([[g,[g,r[0],r[1]]]]),y=new Map(v),b=new Map([[g,-1]]);for(let[e,n]of[...h].sort((e,t)=>_(e[0])-_(t[0])||t[1].length-e[1].length||e[0]-t[0])){let r=_(e),s=o.routeTo(e,{ends:r?y:v,folder:t,toward:g});if(!s)continue;let c=u.length;u.push({item:e,folder:t,trunk:f,count:n.length,pts:s.pts,cells:s.cells,leaf:r,via:b.get(s.cells[s.cells.length-1])??-1});let d=new Float32Array(s.cells.length);d[d.length-1]=y.get(s.cells[s.cells.length-1])?.[3]??0;for(let e=s.cells.length-2;e>=0;e--){let t=s.cells[e],n=s.cells[e+1];d[e]=d[e+1]+(t%i!==n%i&&Math.floor(t/i)!==Math.floor(n/i)?Math.SQRT2:1)+(a.close[n]?Vt.hug:0)}for(let[e,t]of s.cells.entries()){if(y.has(t))continue;let n=[t,t%i+.5,Math.floor(t/i)+.5,d[e]];y.set(t,n),b.set(t,c),r||v.set(t,n)}r||l.push({folder:e,at:s.pts[0],notes:n,trunk:f})}}return Jt(u,a.W*a.H),u.map(({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s})=>({item:e,folder:t,trunk:n,count:r,pts:i,lane:a,leaf:o,via:s}))}function bn(e){let t=dt(e),n=Kt(e,t);return e=>Zt(n,e,t.W,t.H)}function xn(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}var Sn=e=>e.grain===`coarse`||e.grain===`coarser`?e.grain:`fine`;function Cn(e,t={}){return xn(JSON.stringify([14,t.gridFlow===`right`?`right`:`up`,Sn(t),!!t.blocks,e]))}var wn,Tn=1,En=new Map;function Dn(e){if(wn===void 0)try{wn=new Worker(new URL(new URL(`../workers/worker-C_nKscAW.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),wn.onmessage=({data:e})=>{let t=En.get(e.id);En.delete(e.id),e.error===void 0?t?.resolve(e.result):t?.reject(Error(e.error))},wn.onerror=()=>{for(let e of En.values())e.reject(Error(`the layout worker stopped`));En.clear(),wn=null}}catch{wn=null}if(!wn)return Promise.reject(Error(`no worker`));let t=Tn++;return new Promise((n,r)=>{En.set(t,{resolve:n,reject:r}),wn.postMessage({id:t,...e})})}var On=new Map,kn=new Map,An=``;async function jn(e,t){let n=gn(e),r=Cn(n,t),i=On.get(r);return i||(i=await Dn({layout:{model:n,o:t}}).catch(()=>_n(n,t)),On.size>=6&&On.delete(On.keys().next().value),On.set(r,i)),{key:r,layout:i}}async function Mn(e,t,n){if(!n.length)return[];let r=()=>{let r=kn.get(e);return r||(kn.clear(),kn.set(e,r=bn(t))),r(n)},i=An!==e;return An=e,(await Dn({routes:{key:e,layout:i?t:null,asks:n}}).catch(()=>Dn({routes:{key:e,layout:t,asks:n}})).catch(r)).routes.map(e=>e?.pts??null)}var Nn=s(`<path d="M8 2.5L13.5 8L8 13.5L2.5 8Z"></path>`),Pn=s(`<path d="M8 2.5l5.8 10.5H2.2z"></path>`),Fn=s(`<svg class="notch svelte-m50bdg" viewBox="0 0 16 16" aria-hidden="true"><!></svg>`),In=i(` <wbr/> `,1),Ln=i(`<b class="order svelte-m50bdg" aria-hidden="true"> </b>`),Rn=i(`<i class="dia svelte-m50bdg" aria-hidden="true"></i>`),zn=i(`<a data-lustre=""><!><span class="inner svelte-m50bdg"><!><span class="t svelte-m50bdg"><!></span></span><!><!></a>`);function Bn(n,r){k(r,!0);let i=I(r,`kind`,3,``),a=I(r,`file`,3,``),s=I(r,`prospect`,3,!1),l=I(r,`done`,3,!1),f=I(r,`behind`,3,`var(--ground-0)`),p=I(r,`mark`,3,``),m=I(r,`far`,3,0),h=I(r,`iso`,3,``),g=I(r,`dim`,3,!1),_=I(r,`moment`,3,``),v=I(r,`given`,3,!1),y=I(r,`held`,3,``),b=I(r,`changed`,3,!1),x=I(r,`order`,3,0),S=I(r,`here`,3,!1);var C=zn();let w;var T=e(C),E=t=>{var n=Fn(),r=e(n),a=e=>{var t=Nn();c(()=>j(t,`fill`,l()?`currentColor`:`none`)),d(e,t)},o=e=>{var t=Pn();c(()=>j(t,`fill`,l()?`currentColor`:`none`)),d(e,t)};z(r,e=>{i()===`question`?e(a):e(o,-1)}),F(n),d(t,n)};z(T,e=>{i()&&e(E)});var D=H(T),O=e(D),M=e=>{xe(e,{get kind(){return a()},size:11})};z(O,e=>{a()&&e(M)});var N=H(O),P=e(N),L=e=>{var t=In(),n=A(t,!0),i=H(n,2,!0);c((e,t)=>{R(n,e),R(i,t)},[()=>r.title.slice(0,r.title.lastIndexOf(`.`)),()=>r.title.slice(r.title.lastIndexOf(`.`))]),d(e,t)},B=U(()=>a()&&/^[^\s]+\.\w+$/.test(r.title)),V=e=>{var t=u();c(()=>R(t,r.title)),d(e,t)};z(P,e=>{o(B)?e(L):e(V,-1)}),F(N),F(D);var ee=H(D),te=e=>{var t=Ln(),n=W(t,!0);c(()=>R(n,x())),d(e,t)};z(ee,e=>{x()&&e(te)});var ne=H(ee),re=e=>{var t=Rn();d(e,t)};z(ne,e=>{b()&&e(re)}),F(C),c(e=>{w=q(C,1,`n ${_()?`mo-${_()}`:``} ${h()?`p-${h()}`:``} ${p()??``} ${i()??``}`,`svelte-m50bdg`,w,{done:l(),dim:g()&&!h()&&!v(),far:m()>1,given:v(),held:y()===`on`,changed:b(),here:S(),file:!!a(),prospect:s()}),j(C,`aria-current`,S()?`page`:void 0),j(C,`href`,r.href),j(C,`aria-label`,`${s()?`Asked back, not kept: `:i()===`question`?`Question${l()?`, resolved`:``}: `:i()===`problem`?`Problem${l()?`, solved`:``}: `:``}${r.title}${v()?`: in the agent's context`:y()===`on`?`: read by the agent`:``}${b()?`, changed by the agent`:``}`),j(C,`title`,v()?`In the agent's context: shift+click takes it back`:void 0),j(C,`data-note`,r.item.ref),K(C,`--x:${r.item.gx??``};--y:${r.item.gy??``};--w:${r.item.w??``};--h:${r.item.h??``};--lit:${e??``}%;--behind:${f()??``}`)},[()=>Math.max(34,100-(m()-1)*20)]),J(`click`,C,function(...e){r.onpick?.apply(this,e)}),t(`pointerenter`,C,e=>{e.pointerType===`mouse`&&r.onpoint(!0)}),t(`pointerleave`,C,e=>{e.pointerType===`mouse`&&r.onpoint(!1)}),t(`focus`,C,()=>r.onpoint(!0)),t(`blur`,C,()=>r.onpoint(!1)),d(n,C),ie()}h([`click`]);var Vn=i(`<input class="frame-title rename svelte-ywp27z"/>`),Hn=i(`<button class="frame-title svelte-ywp27z" type="button"> </button>`),Un=i(`<span class="frame-title held svelte-ywp27z"> </span>`),Wn=i(`<span class="bare svelte-ywp27z" aria-hidden="true"><i class="svelte-ywp27z"></i><i class="svelte-ywp27z"></i><i class="svelte-ywp27z"></i></span>`),Gn=i(`<div><!> <!> <!></div>`),Kn=i(`<button type="button"><span class="inner svelte-ywp27z"><span class="name svelte-ywp27z"> </span><span class="label svelte-ywp27z"> </span></span></button>`);function qn(n,r){k(r,!0);let i=I(r,`titled`,3,!0),a=I(r,`held`,19,()=>({req:0,bld:0})),s=I(r,`bare`,3,!1),l=I(r,`dim`,3,!1),u=I(r,`given`,3,!1),f=I(r,`here`,3,!1),m=I(r,`moment`,3,``),h=U(()=>r.item.depth%2?`var(--ground-1)`:`var(--ground-0)`),g=U(()=>r.item.depth%2?`var(--ground-0)`:`var(--ground-1)`),_=U(()=>a().req?`req`:a().bld?`bld`:``),v=U(()=>[a().req?`${a().req} required here`:``,a().bld?`${a().bld} ${a().bld===1?`builds`:`build`} on it`:``].filter(Boolean).join(` · `)),y=w(!1),x=w(``);function S(e){r.onrename&&(e.stopPropagation(),L(x,r.name,!0),L(y,!0))}function C(e){let t=o(y);L(y,!1),e&&t&&o(x).trim()&&o(x).trim()!==r.name&&r.onrename?.(o(x).trim())}let T=e=>{e.focus(),e.select()},E=w(void 0);b(()=>{let e=o(_),t=o(E);e&&t&&requestAnimationFrame(()=>{t.isConnected&&me(t,!0,e===`req`?`--requires`:`--builds`)})});let D=U(()=>`--x:${r.item.gx};--y:${r.item.gy};--w:${r.item.w};--h:${r.item.h}`);var M=p(),N=A(M),P=n=>{var a=Gn();let l;var f=e(a),p=e=>{var n=Vn();O(n),ne(()=>G(n,()=>o(x),e=>L(x,e))),oe(n,e=>T?.(e)),c(()=>j(n,`aria-label`,`Rename the folder ${r.name??``}`)),J(`pointerdown`,n,e=>e.stopPropagation()),J(`click`,n,e=>e.stopPropagation()),J(`keydown`,n,e=>{e.stopPropagation(),e.key===`Enter`?C(!0):e.key===`Escape`&&C(!1)}),t(`blur`,n,()=>C(!1)),d(e,n)},b=e=>{var t=Hn(),n=W(t,!0);c(()=>{j(t,`title`,u()?`In the agent's context: shift+click takes it back. Double click renames it.`:r.onrename?`Double click renames it`:void 0),R(n,r.name)}),J(`click`,t,function(...e){r.onpick?.apply(this,e)}),J(`dblclick`,t,S),d(e,t)};z(f,e=>{i()&&o(y)?e(p):i()&&e(b,1)});var w=H(f,2),k=e=>{var t=Un(),n=W(t,!0);c(()=>R(n,o(v))),d(e,t)};z(w,e=>{o(v)&&e(k)});var A=H(w,2),M=e=>{var t=Wn();d(e,t)};z(A,e=>{s()&&e(M)}),F(a),B(a,e=>L(E,e),()=>o(E)),c(()=>{l=q(a,1,`folder frame ${o(_)??``} ${m()?`mo-${m()}`:``}`,`svelte-ywp27z`,l,{given:u()}),j(a,`data-folder`,r.item.ref),K(a,`${o(D)??``};--inside:${o(h)??``};--behind:${o(g)??``};--ground-here:${o(h)??``}`)}),d(n,a)},V=t=>{var n=Kn();let i;var a=e(n),s=e(a),p=W(s,!0),h=H(s),g=W(h,!0);F(a),F(n),B(n,e=>L(E,e),()=>o(E)),c(()=>{i=q(n,1,`folder frame closed ${o(_)??``} ${m()?`mo-${m()}`:``}`,`svelte-ywp27z`,i,{dim:l(),given:u(),here:f()}),j(n,`aria-current`,f()?`page`:void 0),j(n,`data-folder`,r.item.ref),K(n,o(D)),j(n,`title`,u()?`In the agent's context: shift+click takes it back`:void 0),R(p,r.name),R(g,o(v)||`${r.count} ${r.count===1?`note`:`notes`}`)}),J(`click`,n,function(...e){r.onpick?.apply(this,e)}),d(t,n)};z(N,e=>{r.open?e(P):e(V,-1)}),d(n,M),ie()}h([`pointerdown`,`click`,`keydown`,`dblclick`]);var Jn=s(`<path pathLength="1"></path>`),Yn=s(`<path></path>`),Xn=s(`<path class="along touch svelte-k96fgh" pathLength="1"></path><path class="pulse glow blue svelte-k96fgh" pathLength="1"></path><path class="pulse core svelte-k96fgh" pathLength="1"></path>`,1),Zn=s(`<path pathLength="1"></path><path class="pulse core loop svelte-k96fgh" pathLength="1"></path>`,1),Qn=s(`<path></path><!>`,1),$n=s(`<!><!>`,1),er=s(`<path class="pulse glow slow svelte-k96fgh" pathLength="1"></path><path class="pulse core slow svelte-k96fgh" pathLength="1"></path>`,1),tr=s(`<svg class="routes svelte-k96fgh" aria-hidden="true"><g class="svelte-k96fgh"><!><!></g></svg>`);function nr(t,n){k(n,!0);let i=I(n,`pointed`,3,!1),a=I(n,`grown`,19,()=>[]),s=I(n,`beat`,3,``),l=I(n,`retracting`,19,()=>[]),u=e=>`${(e.strong?e.trunk?3:1.5:e.trunk?2:1)/n.k}px`;var f=tr(),m=e(f),h=e(m),g=e=>{var t=p(),n=A(t);r(n,17,l,e=>e.key,(e,t)=>{var n=Jn();let r,i;c(e=>{r=q(n,0,`along retract ${o(t).strong?`base`:`base weak`}`,`svelte-k96fgh`,r,{trunk:o(t).trunk}),j(n,`d`,o(t).d),i=K(n,``,i,{"stroke-width":e})},[()=>u(o(t))]),d(e,n)}),d(e,t)},_=e=>{var t=p(),i=A(t);r(i,17,()=>n.rest,e=>e.key,(e,t)=>{var n=Jn();let r,i;c(e=>{r=q(n,0,`along draw ${o(t).strong?`base`:`base weak`}`,`svelte-k96fgh`,r,{trunk:o(t).trunk}),j(n,`d`,o(t).d),i=K(n,``,i,{"stroke-width":e})},[()=>u(o(t))]),d(e,n)}),d(e,t)},v=e=>{var t=$n(),a=A(t);r(a,17,()=>n.rest,e=>e.key,(e,t)=>{var n=Yn();let r;c(()=>{r=q(n,0,T(o(t).strong?`base`:`base weak`),`svelte-k96fgh`,r,{trunk:o(t).trunk}),j(n,`d`,o(t).d)}),d(e,n)});var s=H(a);r(s,17,()=>n.hot,e=>e.key,(e,t)=>{var r=p(),a=A(r),s=e=>{var r=Xn(),i=A(r);let a;var s=H(i);let l;var u=H(s);let f;c(()=>{j(i,`d`,o(t).d),a=K(i,``,a,{"stroke-width":`${2/n.k}px`}),j(s,`d`,o(t).d),l=K(s,``,l,{"stroke-width":`${4/n.k}px`}),j(u,`d`,o(t).d),f=K(u,``,f,{"stroke-width":`${1.3/n.k}px`})}),d(e,r)},l=e=>{var r=Qn(),i=A(r);let a;var s=H(i),l=e=>{var r=Zn(),i=A(r);let a;var s=H(i);let l;c(()=>{q(i,0,`pulse glow loop pk-${o(t).kind??``}`,`svelte-k96fgh`),j(i,`d`,o(t).d),a=K(i,``,a,{"stroke-width":`${4/n.k}px`}),j(s,`d`,o(t).d),l=K(s,``,l,{"stroke-width":`${1.3/n.k}px`})}),d(e,r)};z(s,e=>{!o(t).still&&o(t).kind!==`uses`&&e(l)}),c(()=>{a=q(i,0,`lit ${o(t).kind??``}`,`svelte-k96fgh`,a,{still:o(t).still}),j(i,`d`,o(t).d)}),d(e,r)};z(a,e=>{i()&&o(t).kind!==`iso`?e(s):e(l,-1)}),d(e,r)}),d(e,t)};z(h,e=>{s()===`retract`?e(g):s()===`draw`?e(_,1):s()===``&&e(v,2)});var y=H(h);r(y,17,a,e=>e.key,(e,t)=>{var r=er(),i=A(r);let a;var s=H(i);let l;c(()=>{j(i,`d`,o(t).d),a=K(i,``,a,{"stroke-width":`${5/n.k}px`}),j(s,`d`,o(t).d),l=K(s,``,l,{"stroke-width":`${1.6/n.k}px`})}),d(e,r)}),F(m),F(f),c(()=>{j(f,`data-requires`,n.counts.requires),j(f,`data-builds`,n.counts.builds),j(f,`data-uses`,n.counts.uses),j(m,`transform`,`scale(${n.k??``})`)}),d(t,f),ie()}var rr=i(`<p class="said svelte-14y1y1z"> </p>`),ir=i(`<p class="said faint svelte-14y1y1z">There are no notes yet. The map draws itself as you write them.</p>`),ar=i(`<a class="sat web svelte-14y1y1z" target="_blank" rel="noopener noreferrer"><svg viewBox="0 0 16 16" aria-hidden="true" class="svelte-14y1y1z"><circle cx="8" cy="8" r="5.5"></circle><path d="M2.5 8h11M8 2.5c-2 2.8-2 8.2 0 11M8 2.5c2 2.8 2 8.2 0 11"></path></svg></a>`),or=i(`<button class="sat more svelte-14y1y1z" type="button"> </button>`),sr=s(`<svg viewBox="0 0 16 16" aria-hidden="true" class="svelte-14y1y1z"><rect x="2.5" y="3" width="11" height="10"></rect><path d="M2.5 11l3.5-3.5 3 3 1.5-1.5 3 3"></path></svg>`),cr=i(`<img alt="" loading="lazy" draggable="false" class="svelte-14y1y1z"/>`),lr=i(`<a><!></a>`),ur=i(`<span role="img"><svg viewBox="0 0 16 16" aria-hidden="true" class="svelte-14y1y1z"><path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5M9 3l-2 10"></path></svg></span>`),dr=s(`<path d="M1.5 5.5h6l2 2.5h9v12.5h-17z" class="svelte-14y1y1z"></path>`),fr=s(`<path d="M3.5 1.5h9l4.5 4.5v16.5h-13.5z M12.5 1.5v4.5h4.5" class="svelte-14y1y1z"></path><path class="ln svelte-14y1y1z" d="M6.5 11h7.5M6.5 14.5h7.5M6.5 18h5"></path>`,1),pr=i(`<div><svg viewBox="0 0 20 24" width="20" height="24" aria-hidden="true" class="svelte-14y1y1z"><!></svg> <span class="svelte-14y1y1z"> </span></div>`),mr=i(`<button type="button"><svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true" class="svelte-14y1y1z"><path d="M2 2l8 4-8 4z" class="svelte-14y1y1z"></path></svg></button>`),hr=i(`<p class="notice svelte-14y1y1z" role="alert"> </p>`),gr=i(`<p class="given svelte-14y1y1z" role="status"> </p>`),_r=i(`<div class="frame asking svelte-14y1y1z" role="alertdialog" aria-label="Delete"><span> </span> <span class="row svelte-14y1y1z"><button class="btn danger" type="button"> </button><button class="btn quiet" type="button">keep it</button></span></div>`),vr=i(`<p class="legend svelte-14y1y1z" aria-hidden="true"><span class="svelte-14y1y1z"><i class="k g svelte-14y1y1z"></i>you gave it</span><span class="svelte-14y1y1z"><i class="k h svelte-14y1y1z"></i>the agent read it</span><span class="svelte-14y1y1z"><i class="k d svelte-14y1y1z"></i>the agent changed it</span><span class="svelte-14y1y1z"><i class="k n svelte-14y1y1z">1</i>read, in order</span></p>`),yr=i(`<button type="button" role="menuitem" class="svelte-14y1y1z"><i aria-hidden="true" class="svelte-14y1y1z">◇</i>Take back from the agent</button>`),br=i(`<button type="button" role="menuitem" class="svelte-14y1y1z"><i aria-hidden="true" class="svelte-14y1y1z">◆</i>Give to the agent</button>`),xr=i(`<div class="offer frame svelte-14y1y1z" role="menu"><!> <button type="button" role="menuitem" class="svelte-14y1y1z"><i aria-hidden="true" class="svelte-14y1y1z">▣</i>Open</button> <button type="button" role="menuitem" class="svelte-14y1y1z"><i class="q svelte-14y1y1z" aria-hidden="true">?</i>A question about it</button> <button type="button" role="menuitem" class="svelte-14y1y1z"><i aria-hidden="true" class="svelte-14y1y1z">△</i>A problem using it</button></div>`),Sr=i(`<div aria-hidden="true"> </div>`),Cr=i(`<!> <div><div class="scaled svelte-14y1y1z"></div> <!> <div class="scaled svelte-14y1y1z"><!> <!></div> <!></div> <!> <!> <!> <!> <!> <!> <!> <!> <!>`,1),wr=i(`<div role="application" aria-label="The atlas: the map of the base" tabindex="0"><div class="ground dots svelte-14y1y1z" aria-hidden="true"></div> <!></div>`);function Tr(n,i){k(i,!0);let s=w(null),l=w(null),u=``,f=w(``),m=w({x:0,y:0,k:1}),h=w(1),g;b(()=>{let e=o(m).k;clearTimeout(g),Math.abs(Math.log(e/o(h)))>.35?L(h,e,!0):e!==o(h)&&(g=setTimeout(()=>L(h,e,!0),150))});let _=w(!1),x;b(()=>(o(m).x,o(m).y,o(m).k,L(_,!0),clearTimeout(x),x=setTimeout(()=>L(_,!1),200),()=>clearTimeout(x)));let S=e=>{L(m,e),L(h,e.k,!0)},C=w({w:0,h:0}),T=w(``),E=w([]),D=U(()=>o(E).at(-1)??``),O=w(void 0),M=[`fine`,`coarse`,`coarser`],N=w(re(M.find(e=>e===te(`isorite.atlas.grain`))??`fine`)),P=w(te(`isorite.atlas.leaves`)===`on`),I=!1,ee=window.innerWidth>=window.innerHeight?`right`:`up`;function te(e){try{return localStorage.getItem(e)}catch{return null}}function ne(){L(N,M[(M.indexOf(o(N))+1)%M.length],!0),I=!1;try{localStorage.setItem(`isorite.atlas.grain`,o(N))}catch{}ce()}function G(e){L(P,e,!0);try{localStorage.setItem(`isorite.atlas.leaves`,e?`on`:`off`)}catch{}}let ae=U(()=>{if(!Z.on.questions)return[];let e=[];for(let t of $.session?.turns??[])for(let n of t.items)n.kind===`question`&&!n.made&&e.push({ref:`?${n.id}`,title:n.title,about:n.about});return e}),se=!1;async function ce(){try{let e=await X.api.map(),t=a(()=>o(ae)),n={...e.notes};for(let e of t)n[e.ref]={title:e.title,tokens:0,kind:`question`};let r={...e,model:ot(e.model,t),notes:n},i={...r,model:st(r.model,e=>{let t=r.files?.[e];if(t)return t.kind===`artifact`?!Z.on.artifacts:!Z.on.pictures;let n=r.notes[e];return n?.kind===`question`?!Z.on.questions:n?.kind===`problem`&&!Z.on.problems})},c=`${ee}|${o(N)}`,d=o(l)&&u===c&&!se?o(l).layout.orders??null:null;se=!1;let p=await jn(i.model,{gridFlow:ee,grain:o(N),blocks:!0,from:d});u=c;let m=!!o(l)&&o(l).key!==p.key,h=o(l)&&o(Y)?{refs:new Set(o(Y).items.map(e=>e.ref)),edges:new Set(o(s).model.edges.map(([e,t])=>`${e}>${t}`))}:null,g=!o(l)||o(l).key!==p.key&&!I,_=++Te,v=matchMedia(`(prefers-reduced-motion: reduce)`).matches,y=!!h&&m&&!v;if(y||(L(Se,``),L(we,[])),y){if(L(we,o(Le)),L(Se,`retract`),await xe(_e),_!==Te)return;L(we,[]),L(Se,`move`)}if(L(s,i),L(l,p),L(f,``),h&&m&&je(h),g&&o(C).w&&S(ge()),y){if(await xe(ve),_!==Te)return;L(Se,`draw`),await xe(be),_===Te&&L(Se,``)}}catch(e){L(f,e.message,!0)}}b(()=>{o(T)&&o(Y)&&!o(Y).items.some(e=>e.ref===o(T))&&L(T,``)});let le=``;b(()=>{let e=o(ae).map(e=>e.ref).join(` `);if(e!==le){let t=le===``&&e===``;le=e,t||ce()}});let de=``;b(()=>{let e=`${Z.on.questions}|${Z.on.problems}|${Z.on.pictures}|${Z.on.artifacts}`;de&&de!==e&&ce(),de=e}),b(()=>{ce();let e,t=X.on(t=>{t.type===`note-changed`&&(clearTimeout(e),e=setTimeout(()=>{ce()},400))});return()=>{t(),clearTimeout(e)}});let Y=U(()=>o(l)?qe(o(l).layout):null),me=U(()=>o(Y)?Ge(o(Y)):null),he=U(()=>o(Y)?Je(o(Y),o(h)):``),ge=()=>{let e=(o(Y)?.margin??0)/2;return it({gx:e,gy:e,w:(o(Y)?.W??1)-2*e,h:(o(Y)?.H??1)-2*e},o(C).w,o(C).h,1,o(Y)?.cell)},_e=220,ve=520,be=340,xe=e=>new Promise(t=>setTimeout(t,e)),Se=w(``),we=w([]),Te=0,Ee=w(!1),De=w([]);async function je(e){if(L(Ee,!0),setTimeout(()=>L(Ee,!1),700),await y(),!o(Y)||!o(me)||!o(s))return;let t=matchMedia(`(prefers-reduced-motion: reduce)`).matches;for(let n of o(Y).items)e.refs.has(n.ref)||n.ref.startsWith(`@`)||(o(O)?.querySelector(n.kind===`folder`?`[data-folder="${CSS.escape(n.ref)}"]`:`[data-note="${CSS.escape(n.ref)}"]`))?.animate([{opacity:0},{opacity:0,offset:t?0:.45},{opacity:1}],{duration:t?200:1e3,easing:`ease-out`});let n=o(s).model.edges.filter(([t,n])=>!e.edges.has(`${t}>${n}`)&&!t.startsWith(`@`)&&!n.startsWith(`@`)&&e.refs.has(t)&&e.refs.has(n));Me?.(),Me=ut(n.map(([e,t])=>({from:e,to:t,kind:`uses`})),e=>{L(De,e.map(e=>({key:e.key,d:e.d})))}),n.length&&(clearTimeout(Ne),Ne=setTimeout(()=>{L(De,[]),Me?.(),Me=void 0},1600))}let Me,Ne;b(()=>{if(!o(O))return;let e=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect,r=!o(C).w,i=o(C);L(C,{w:t,h:n}),r&&o(Y)?S(ge()):!r&&t&&n&&L(m,{...o(m),x:o(m).x+(t-i.w)/2,y:o(m).y+(n-i.h)/2})});return e.observe(o(O)),()=>e.disconnect()});let Pe=U(()=>{let e=(o(Y)?.cell??7)*o(m).k;if(!(e>0))return 24;for(;e<14;)e*=2;for(;e>=28;)e/=2;return e}),Fe=U(()=>o(Y)?o(Y).items.flatMap((e,t)=>e.kind===`folder`&&o(he)[t]!==`-`?[{item:e,i:t,open:o(he)[t]===`o`}]:[]):[]),Ie=U(()=>o(Y)?o(Y).items.flatMap((e,t)=>e.kind===`note`&&o(he)[t]===`s`?[{item:e,i:t}]:[]):[]),Le=U(()=>o(Y)?et(Xe(o(Y),o(he),o(me).strong,o(P))).map(e=>({key:e.key,pts:e.pts,d:rt(e.pts,0,o(Y).cell),count:e.count,strong:e.strong,trunk:e.trunk,...Re(e)})).map((e,t,n)=>({...e,label:e.label&&!n.some((n,r)=>r!==t&&n.label&&n.count===e.count&&Math.hypot(n.mid[0]-e.mid[0],n.mid[1]-e.mid[1])<10&&(n.length>e.length||n.length===e.length&&r<t))})):[]);function Re(e){let t=e.pts[0],n=t,r=0;for(let i=1,a=0;i<e.pts.length;i++){let o=e.pts[i-1],s=e.pts[i],c=e.pts[i+1];if(c&&Math.abs((s[0]-o[0])*(c[1]-s[1])-(s[1]-o[1])*(c[0]-s[0]))<1e-6&&(s[0]-o[0])*(c[0]-s[0])+(s[1]-o[1])*(c[1]-s[1])>0)continue;let l=e.pts[a],u=Math.hypot(s[0]-l[0],s[1]-l[1]);u>r&&(r=u,t=l,n=s),a=i}return{label:e.trunk&&e.count>1&&r>=3,mid:[(t[0]+n[0])/2,(t[1]+n[1])/2],side:Math.abs(t[0]-n[0])<1e-6?`right`:`above`,length:r}}let Ve=U(()=>o(D)||o(T)),He=U(()=>o(Ve)&&o(s)&&o(me)?.at.has(o(Ve))?pe(o(s).model,o(Ve)):null),Ke=U(()=>{let e=new Map;if(!o(He))return e;for(let t of o(He).also)e.set(t,{mark:`also`,far:0});for(let t of o(He).uses)e.set(t,{mark:`use`,far:0});for(let t of o(He).builds)e.set(t,{mark:`bld`,far:0});for(let t of o(He).requires)e.set(t,{mark:`req`,far:o(He).depth[t]??1});for(let t of o(E))e.set(t,{mark:`req`,far:1});return e.set(o(Ve),{mark:`at`,far:0}),e}),Ze=U(()=>{if(!o(He))return[];let e=o(E).slice(1).map((e,t)=>({from:o(E)[t],to:e,kind:`requires`})),t=o(E).at(-2);return[...e,...o(He).links.filter(e=>e.kind===`requires`?e.from===o(Ve):e.kind!==`builds`||e.from!==t)]}),Qe=U(()=>{let e=new Map;if(!o(He)||!o(me))return e;let t=new Set(o(me).up[o(me).at.get(o(Ve))]),n=(n,r)=>{for(let i of n)for(let n of o(me).up[o(me).at.get(i)??-1]??[]){if(t.has(n))break;let i=e.get(n)??{req:0,bld:0};i[r]++,e.set(n,i)}};return n(o(He).requires,`req`),n(o(He).builds,`bld`),e}),$e=(e,t)=>{let n=o(Qe).get(e),r=o(Y).items[e].parent;return n&&(!t||r<0||!o(Qe).has(r))?n:{req:0,bld:0}},nt=w([]),ct=w({requires:0,builds:0,uses:0});function ut(e,t){if(!e.length||!o(Y)||!o(me)||!o(l)){t([],[]);return}let n=e.flatMap(e=>{let t=o(me).at.get(e.from),n=o(me).at.get(e.to);return t===void 0||n===void 0?[]:[{a:t,b:n,kind:e.kind}]}),{fixed:r,asks:i}=tt(o(Y),o(me),o(he),n),a=e=>t(et(e,!0).map(e=>({key:e.key,kind:e.kind,d:rt(e.pts,0,o(Y).cell),count:e.count,still:!e.flow})),e);if(a(r),!i.length)return;let s=!1;return Mn(o(l).key,o(Y),i.map(({a:e,b:t})=>({a:e,b:t}))).then(e=>{s||a([...r,...i.flatMap((t,n)=>e[n]?[{key:t.key,kind:t.kind,pts:[...e[n]].reverse()}]:[])])}).catch(()=>void 0),()=>{s=!0}}b(()=>ut(o(Ze),(e,t)=>{L(nt,e),L(ct,{requires:t.filter(e=>e.kind===`requires`).length,builds:t.filter(e=>e.kind===`builds`).length,uses:t.filter(e=>e.kind===`uses`).length})}));let dt=U(()=>Oe.route.id===`/n/[...id]`?Oe.params.id??``:``);function ft(e,t=!1){if(!o(Y)||!o(me)||!e)return-1;let n=t?o(Y).items.findIndex(t=>t.kind===`folder`&&t.ref.replace(/\/$/,``)===e):o(me).at.get(e)??-1;return n<0?-1:Ye(o(me),o(he),n)}let pt=U(()=>ft(o(dt))),mt=U(()=>Ce.elsewhere),ht=U(()=>o(mt)?ft(o(mt).id,o(mt).folder):-1),gt=U(()=>{if(!o(mt)||o(mt).folder||!o(dt)||o(mt).id===o(dt)||!o(s))return[];let e=o(s).model.edges.find(([e,t])=>e===o(dt)&&t===o(mt).id||e===o(mt).id&&t===o(dt));return e?[{from:e[0],to:e[1],kind:e[2]>=ue.requires?`requires`:`uses`}]:[]}),_t=w([]);b(()=>ut(o(gt),e=>{L(_t,e.map(e=>({...e,key:`there:${e.key}`})))}));let vt=``;b(()=>{let e=o(dt);a(()=>{if(e&&e!==vt&&o(D)&&o(D)===vt&&o(me)?.at.has(e)){let t=[];if(o(He)&&o(He).depth[e])for(let n=e;n&&n!==o(D);n=o(He).via[n])t.unshift(n);L(E,o(E).includes(e)?o(E).slice(0,o(E).indexOf(e)+1):t.length?[...o(E),...t]:[e])}vt=e})});function yt(e){if(!o(Y)||e<0||!o(C).w)return null;let t=o(Y).items[e],n=o(Y).cell*o(m).k,r=o(m).x+t.gx*n,i=o(m).y+t.gy*n,a=r+t.w*n,s=i+t.h*n;if(a>0&&r<o(C).w&&s>0&&i<o(C).h)return null;let c=o(C).w/2,l=o(C).h/2,u=(r+a)/2-c,d=(i+s)/2-l,f=Math.min((c-14)/Math.max(Math.abs(u),1e-6),(l-14)/Math.max(Math.abs(d),1e-6));return{x:c+u*f,y:l+d*f,angle:Math.atan2(d,u)}}let bt=U(()=>yt(o(pt))),xt=U(()=>o(ht)===o(pt)?null:yt(o(ht)));function St(e){if(!o(Y))return;let t=o(Y).items[e],n=o(Y).cell*o(m).k;I=!0,pn({k:o(m).k,x:o(C).w/2-(t.gx+t.w/2)*n,y:o(C).h/2-(t.gy+t.h/2)*n})}let Ct=U(()=>X.iso),wt=U(()=>o(Ct)?.state===`reading`||o(Ct)?.state===`writing`),Tt=U(()=>{let e=new Map;for(let t of o(Ct)?.steps??[])t.opened&&!t.failed&&!e.has(t.opened)&&e.set(t.opened,t.how);return e}),Et=U(()=>Z.on.context),Dt=U(()=>new Set(Q.parts.filter(e=>e.kind===`note`).map(e=>e.id))),Ot=U(()=>new Set(Q.parts.filter(e=>e.kind===`folder`).map(e=>e.id))),kt=/(^|[_:./-])(edit_note|write_note|edit|write|patch)$/,At=U(()=>new Set(($.session?.turns??[]).flatMap(e=>e.items.flatMap(e=>e.kind===`tool`&&e.note&&!e.base&&e.status!==`failed`&&!kt.test(e.name)?[e.note]:[])))),jt=U(()=>new Set(($.session?.turns??[]).flatMap(e=>e.items.flatMap(e=>e.kind===`tool`&&e.note&&!e.base&&e.status!==`failed`&&kt.test(e.name)?[e.note]:[])))),Mt=U(()=>{let e=new Map;for(let t of $.session?.turns.at(-1)?.items??[])t.kind===`tool`&&t.note&&!t.base&&t.status!==`failed`&&!kt.test(t.name)&&!e.has(t.note)&&e.set(t.note,e.size+1);return e}),Nt=U(()=>o(wt)?o(Ct).steps.findLast(e=>e.opened&&!e.failed)?.opened??``:``),Pt=U(()=>(o(Ct)?.steps??[]).flatMap(e=>e.how===`link`&&e.from&&e.opened&&!e.failed?[{from:e.from,to:e.opened,kind:`iso`}]:[])),Ft=w([]);b(()=>ut(o(Pt),e=>{L(Ft,e.map(e=>({...e,key:`iso:${e.key}`})))}));let It=e=>{if(!o(Et))return``;if(e===o(Nt))return`used`;let t=o(Tt).get(e);return t===`keyword`?`key`:t===`meaning`?`sem`:t?`link`:``},Lt=w(null),Rt=null,zt=!1,Bt,Vt,Ht=new Ae({move:(e,t)=>void Gt(e,t),remove:e=>void Kt(e),send:e=>nn(e.id,e.kind)},{drift:`cancel`,scroll:!1,dropAt:(e,t)=>Wt(e,t)}),Ut=w(null);function Wt(e,t){if(!o(Y)||!o(O))return null;let n=o(O).getBoundingClientRect(),r=o(Y).cell*o(m).k,i=(e-n.left-o(m).x)/r,a=(t-n.top-o(m).y)/r,s=Ht.item?.kind===`folder`?Ht.item.id:null,c=null;return o(Y).items.forEach((e,t)=>{if(e.kind!==`folder`||o(he)[t]===`-`||!e.ref||e.ref.startsWith(`@`)||i<e.gx||i>=e.gx+e.w||a<e.gy||a>=e.gy+e.h)return;let n=e.ref.replace(/\/$/,``);(s===null||n!==s&&!n.startsWith(`${s}/`))&&(!c||e.depth>c.depth)&&(c={ref:n,depth:e.depth})}),c?.ref??(e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom?``:null)}async function Gt(e,t){let n=e.id.replace(/\/$/,``),r=n.split(`/`).at(-1),i=t?`${t}/${r}`:r;if(i!==n)try{e.kind===`folder`?await X.api.moveFolder(n,i):await X.api.moveNote(n,i,(await X.api.readNote(n)).version),await X.refresh(),ce()}catch(e){L($t,e.message,!0)}}async function Kt(e){try{if(e.kind===`folder`){let t=X.listing.notes.filter(t=>t.dir===e.id||t.dir.startsWith(`${e.id}/`)).length;if(t){L($t,`${e.id} holds ${t} ${t===1?`note`:`notes`}: move or delete ${t===1?`it`:`them`} first.`);return}L(Ut,{item:e,text:`Delete the empty folder ${e.id}?`});return}let t=await X.api.map(),n=[...new Set(t.model.edges.filter(([t,n])=>n===e.id&&t!==e.id&&!t.startsWith(`@`)).map(([e])=>t.notes[e]?.title||e))];L(Ut,{item:e,text:`Delete “${e.title}”? ${n.length?`${n.length===1?`One note links`:`${n.length} notes link`} to it (${n.join(`, `)}); ${n.length===1?`its link is`:`their links are`} left broken.`:`No note links to it.`} Its history stays.`})}catch(e){L($t,e.message,!0)}}async function qt(){let e=o(Ut);if(L(Ut,null),e)try{e.item.kind===`folder`?await X.api.deleteFolder(e.item.id):await X.api.deleteNote(e.item.id,(await X.api.readNote(e.item.id)).version),await X.refresh(),ce()}catch(e){L($t,e.message,!0)}}b(()=>{let e=Ht.phase,t=Ht.tag,n=Ht.item,r=Ht.over;if(!o(O)||!n||e===`idle`)return;let i=o(O).querySelector(n.kind===`folder`?`[data-folder="${CSS.escape(n.id)}"]`:`[data-note="${CSS.escape(n.id)}"]`),a=e===`moving`&&r?o(O).querySelector(`[data-folder="${CSS.escape(r)}"]`):null,s=e===`moving`?`g-lifted`:t===`delete`?`g-doomed`:t===`send`?`g-sending`:``;return s&&i?.classList.add(s),a?.classList.add(`g-over`),()=>{i?.classList.remove(`g-lifted`,`g-doomed`,`g-sending`),a?.classList.remove(`g-over`)}});function Jt(){Ht.stop(),clearTimeout(Bt),clearTimeout(Vt),Bt=Vt=void 0,Rt=null,zt||L(Lt,null)}function Yt(e,t){let n=null;for(let r of o(Y).items)r.kind===`folder`&&!r.ref.startsWith(`@`)&&e>=r.gx&&e<r.gx+r.w&&t>=r.gy&&t<r.gy+r.h&&(!n||r.depth>n.depth)&&(n={ref:r.ref,depth:r.depth});return n?.ref??``}function Xt(e,t){if(Jt(),o(Qt)&&!(e.target instanceof Element&&e.target.closest(`.offer`))&&L(Qt,null),zt||!o(Y)||!o(me)||!(e.target instanceof Element))return;if(e.pointerType===`mouse`&&!e.target.closest(`input, .dock, .offer`)){let t=xn(e),n=e.target.closest(t?.kind===`folder`?`[data-folder]`:`[data-note]`);if(t&&n&&!t.id.startsWith(`?`)&&!o(s)?.files?.[t.id]){Ht.begin({kind:t.kind,id:t.id.replace(/\/$/,``),title:t.title},e,n);return}}if(e.target.closest(`button, .dock`))return;let n=e.target.closest(`[data-note]`)?.dataset.note??``;if(n.startsWith(`@`))return;if(n){let r=e.pointerType!==`mouse`;Vt=setTimeout(()=>{Vt=void 0,mn=!0,r?L(Qt,{ref:n,x:t.x,y:t.y}):nn(n)},650);return}let r=o(Y).cell*o(m).k,i=Math.round((t.x-o(m).x)/r),a=Math.round((t.y-o(m).y)/r),c={dir:Yt(i,a),gx:i,gy:a,w:0,h:0,folder:!1};Bt=setTimeout(()=>{L(Lt,c)},180),Vt=setTimeout(()=>{Vt=void 0,mn=!0,Rt=t,L(Lt,c),o(O)?.setPointerCapture(e.pointerId)},650)}function Zt(e){Rt&&o(Lt)&&!o(Lt).folder&&Math.hypot(e.x-Rt.x,e.y-Rt.y)>=24&&L(Lt,{...o(Lt),folder:!0})}let Qt=w(null),$t=w(``),en=w(``),tn;function nn(e,t=`note`){let n=Q.add({kind:t,id:e,title:t===`note`?ln(e):dn(e)});L(en,n?`${t===`note`?ln(e):dn(e)} is in the agent's context`:`${t===`note`?ln(e):dn(e)} is in the agent's context already`,!0),clearTimeout(tn),tn=setTimeout(()=>L(en,``),2200)}function rn(e,t=`note`){if(!Q.has(t,e)){nn(e,t);return}let n=t===`note`?ln(e):dn(e);Q.remove({kind:t,id:e,title:n}),L(en,`${n} is out of the agent's context`),clearTimeout(tn),tn=setTimeout(()=>L(en,``),2200)}function an(){Rt&&o(Lt)&&(Rt=null,on(o(Lt)))}async function on(e){zt=!0;let t=X.listing.notes.map(e=>e.id),n=e.dir;if(e.folder){let r=ze(e.dir,`untitled-folder`,e=>!t.some(t=>t.startsWith(`${e}/`)));n=[e.dir,r.slug].filter(Boolean).join(`/`)}let r=ze(n,`untitled-note`,e=>!t.includes(e)),i=[n,r.slug].filter(Boolean).join(`/`),a=r.n===1?`Untitled note`:`Untitled note ${r.n}`;try{await X.api.createNote(i,`---\ntype: Concept\ntitle: ${JSON.stringify(a)}\n---\n\n`),await X.refresh(),Z.fresh=i,await Z.open(i)}catch(e){L($t,e.message,!0)}finally{zt=!1,L(Lt,null)}}async function sn(e,t){try{await Be(e,t)}catch(e){L($t,e.message,!0)}}let cn=e=>e.endsWith(`/`)?e.slice(0,-1):e,ln=e=>o(s)?.notes[e]?.title??o(s)?.files?.[e]?.title??e.split(`/`).at(-1)??e;async function un(e,t){let n=e.replace(/\/$/,``),r=[n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``,t.replace(/^\/+|\/+$/g,``)].filter(Boolean).join(`/`);try{await X.api.moveFolder(n,r),await X.refresh(),ce()}catch(e){L(en,e.message,!0)}}let dn=e=>e.split(`/`).at(-1)||X.session?.name||`the base`,fn=0;function pn(e){if(cancelAnimationFrame(fn),An(),matchMedia(`(prefers-reduced-motion: reduce)`).matches){L(m,e);return}let t=o(m),n=performance.now(),r=i=>{let a=Math.min(1,(i-n)/320),s=1-(1-a)**3,c=t.k*(e.k/t.k)**s,l=o(C).w/2,u=o(C).h/2,d=(l-t.x)/t.k*(1-s)+(l-e.x)/e.k*s,f=(u-t.y)/t.k*(1-s)+(u-e.y)/e.k*s;L(m,a===1?e:{k:c,x:l-d*c,y:u-f*c}),a<1&&(fn=requestAnimationFrame(r))};fn=requestAnimationFrame(r)}let mn=!1,hn=new Map,gn=null;function _n(){let e=[...hn.values()];if(!e.length){gn=null;return}let t=e.reduce((e,t)=>e+t.x,0)/e.length,n=e.reduce((e,t)=>e+t.y,0)/e.length;gn={view:o(m),x:t,y:n,span:e.length>1?Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y):0}}let vn=e=>{let t=o(O).getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},yn=null,bn=w(re({x:0,y:0}));function xn(e){if(!(e.target instanceof Element))return null;let t=e.target.closest(`[data-note]`)?.dataset.note;if(t)return t.startsWith(`@`)?null:{kind:`note`,id:t,title:ln(t)};let n=(e.target.closest(`.frame-title`)?.closest(`[data-folder]`)??e.target.closest(`button[data-folder]`))?.dataset.folder;return n&&!n.startsWith(`@`)?{kind:`folder`,id:n,title:dn(n)}:null}function Sn(e){if(!yn||e.pointerType!==`mouse`)return;L(bn,{x:e.clientX,y:e.clientY},!0);let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-pane="iso"]`)!=null;Q.carrying={part:yn,over:t}}function Cn(e){(e.pointerType!==`mouse`||e.button===0)&&(cancelAnimationFrame(fn),An(),hn.size||(mn=!1,yn=xn(e)),hn.set(e.pointerId,vn(e)),_n(),hn.size===1?Xt(e,vn(e)):Jt())}function wn(e){if(!hn.has(e.pointerId)||!gn||Ht.phase!==`idle`&&Ht.item)return;if(hn.set(e.pointerId,vn(e)),Rt){Zt(vn(e));return}let t=[...hn.values()],n=t.reduce((e,t)=>e+t.x,0)/t.length,r=t.reduce((e,t)=>e+t.y,0)/t.length;if(!mn&&t.length===1&&Math.hypot(n-gn.x,r-gn.y)<5)return;if(mn||(mn=!0,Jt(),o(O).setPointerCapture(e.pointerId)),t.length===1&&yn){Sn(e);return}I=!0;let i=t.length>1?Math.hypot(t[0].x-t[1].x,t[0].y-t[1].y):0,a=gn.span&&i?at(gn.view,i/gn.span,gn.x,gn.y):gn.view;L(m,{k:a.k,x:a.x+n-gn.x,y:a.y+r-gn.y})}function Tn(e){if(hn.delete(e.pointerId)){if(Q.carrying){let{part:e,over:t}=Q.carrying;Q.carrying=null,t&&(e.kind===`note`||e.kind===`folder`)&&nn(e.id,e.kind)}yn=null,Rt?an():Vt!==void 0&&Jt(),_n()}}let En=null,Dn=0;function On(e){e.preventDefault(),cancelAnimationFrame(fn),I=!0;let t=vn(e),n=e.deltaMode===1?16:1,r=Math.exp(-e.deltaY*n*(e.ctrlKey?.01:.0015)),i=Math.min(3,Math.max(We,(En?.k??o(m).k)*r));matchMedia(`(prefers-reduced-motion: reduce)`).matches?L(m,at(o(m),i/o(m).k,t.x,t.y)):(En={k:i,x:t.x,y:t.y},Dn||=requestAnimationFrame(kn))}function kn(){if(Dn=0,!En)return;let e=En.k/o(m).k;Math.abs(Math.log(e))<.004?(L(m,at(o(m),e,En.x,En.y)),En=null):(L(m,at(o(m),e**.3,En.x,En.y)),Dn=requestAnimationFrame(kn))}function An(){cancelAnimationFrame(Dn),Dn=0,En=null}b(()=>{if(!o(O))return;let e=o(O);return e.addEventListener(`wheel`,On,{passive:!1}),()=>e.removeEventListener(`wheel`,On)});function Nn(e,t){if(e.metaKey||e.ctrlKey||(e.preventDefault(),e.stopPropagation(),mn))return;if(t.startsWith(`?`)){Z.to(`iso`);return}if(e.shiftKey){t.startsWith(`@`)||rn(t);return}if(o(D)===t){Z.open(cn(t));return}let n=[];if(o(He)&&o(Ve)===o(D)&&o(He).depth[t])for(let e=t;e&&e!==o(D);e=o(He).via[e])n.unshift(e);L(E,o(E).includes(t)?o(E).slice(0,o(E).indexOf(t)+1):n.length?[...o(E),...n]:[t])}function Pn(e,t){if(mn||!o(Y))return;let n=o(Y).items[e].ref;if(t?.shiftKey){n.startsWith(`@`)||rn(n,`folder`);return}I=!0;let r=it(o(Y).items[e],o(C).w,o(C).h,1.5,o(Y).cell),i=Math.abs(r.k-o(m).k)<.01*r.k&&Math.hypot(r.x-o(m).x,r.y-o(m).y)<4,a=o(Y).items[e].parent;pn(i?a<0?ge():it(o(Y).items[a],o(C).w,o(C).h,1.5,o(Y).cell):r)}function Fn(e){if(mn||!(e.target instanceof Element)||e.target.closest(`.dock, .key`))return;let t=e.target.closest(`[data-folder]`);e.target.closest(`a, button`)||(o(D)?L(E,[]):o(Ct)&&!o(wt)?X.iso=null:t&&o(Y)?Pn(o(Y).items.findIndex(e=>e.kind===`folder`&&e.ref===t.dataset.folder),e):pn(ge()))}function In(e){if(e.key===`Escape`){L(E,[]),L(T,``);return}if(e.key===`c`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){ne();return}if(e.key===`l`&&!e.metaKey&&!e.ctrlKey&&!e.altKey){G(!o(P));return}if(e.target!==o(O))return;let t={x:o(C).w/2,y:o(C).h/2};if(e.key===`+`||e.key===`=`)L(m,at(o(m),1.25,t.x,t.y));else if(e.key===`-`)L(m,at(o(m),.8,t.x,t.y));else if(e.key===`0`)pn(ge());else if(e.key===`ArrowLeft`)L(m,{...o(m),x:o(m).x+80});else if(e.key===`ArrowRight`)L(m,{...o(m),x:o(m).x-80});else if(e.key===`ArrowUp`)L(m,{...o(m),y:o(m).y+80});else if(e.key===`ArrowDown`)L(m,{...o(m),y:o(m).y-80});else return;e.preventDefault(),I=!0}let Ln=U(()=>{if(!o(Y)||!o(C).w||o(m).k<=ge().k*1.05)return-1;let e=o(Y).cell*o(m).k,t=(o(C).w/2-o(m).x)/e,n=(o(C).h/2-o(m).y)/e,r=-1;return o(Y).items.forEach((i,a)=>{i.kind!==`folder`||o(he)[a]!==`o`||t<i.gx||t>i.gx+i.w||n<i.gy||n>i.gy+i.h||(i.w*e>=.6*o(C).w||i.h*e>=.6*o(C).h)&&(r<0||o(Y).items[r].depth<i.depth)&&(r=a)}),r});function Rn(){if(!o(Y))return;I=!0;let e=o(Ln)<0?-1:o(Y).items[o(Ln)].parent;pn(e<0?ge():it(o(Y).items[e],o(C).w,o(C).h,1.5,o(Y).cell))}let zn=U(()=>12*o(h)>=Ue),Vn=w(new Set),Hn=U(()=>o(Y)&&o(s)?lt(o(Ie).map(e=>e.item),o(s).notes,{web:Z.on.web,code:Z.on.code},o(Vn)):[]);function Un(e,t){let n=ye(X.api,t);typeof n==`string`?e.src=n:n.then(t=>{t&&(e.src=t)})}let Wn=e=>e>=0&&o(Y).items[e].depth%2?`var(--ground-1)`:`var(--ground-0)`;b(()=>(X.atlas={chosen:o(D)?ln(o(D)):``,chosenId:o(D),steps:o(E).length-1,here:o(Ln)<0?``:dn(o(Y).items[o(Ln)].ref),out:Rn,fit:()=>{I=!1,pn(ge())},relayout:()=>{se=!0,I=!1,ce()}},()=>{X.atlas=null}));var Gn=wr();let Kn;var Jn=e(Gn),Yn=H(Jn,2),Xn=e=>{var t=rr(),n=W(t);c(()=>R(n,`The map could not be drawn: ${o(f)??``}`)),d(e,t)},Zn=t=>{var n=Cr(),i=A(n),a=e=>{var t=ir();d(e,t)};z(i,e=>{o(Y).items.length||e(a)});var l=H(i,2);let u;var f=e(l);r(f,21,()=>o(Fe),e=>e.item.id,(e,t)=>{{let n=U(()=>dn(o(t).item.ref)),r=U(()=>o(t).item.parent<0||(o(t).item.gy-o(Y).items[o(t).item.parent].gy)*o(Y).cell*o(h)>=18),i=U(()=>$e(o(t).i,o(t).open)),a=U(()=>o(t).open&&!o(Y).items.some(e=>e.parent===o(t).i)),s=U(()=>!!o(He)&&!o(t).open&&!o(Qe).has(o(t).i)),c=U(()=>o(Et)&&o(Ot).has(o(t).item.ref)),l=U(()=>!o(t).open&&o(pt)===o(t).i),u=U(()=>o(ht)===o(t).i?o(mt).who:``),d=U(()=>o(t).item.ref.startsWith(`@`)||!o(t).item.ref?void 0:e=>void un(o(t).item.ref,e));qn(e,{get item(){return o(t).item},get name(){return o(n)},get count(){return o(me).noteCount[o(t).i]},get open(){return o(t).open},get titled(){return o(r)},get held(){return o(i)},get bare(){return o(a)},get dim(){return o(s)},get given(){return o(c)},get here(){return o(l)},get moment(){return o(u)},onpick:e=>Pn(o(t).i,e),get onrename(){return o(d)}})}}),F(f);var g=H(f,2);{let e=U(()=>!o(D)&&!!o(T)),t=U(()=>[...o(Et)?o(Ft):[],...o(nt),...o(_t)]);nr(g,{get k(){return o(h)},get rest(){return o(Le)},get pointed(){return o(e)},get hot(){return o(t)},get counts(){return o(ct)},get grown(){return o(De)},get beat(){return o(Se)},get retracting(){return o(we)}})}var y=H(g,2),b=e(y);r(b,17,()=>o(Ie),e=>e.item.id,(e,t)=>{let n=U(()=>o(Ke).get(o(t).item.ref)),r=U(()=>o(n)?.mark??``);{let i=U(()=>ln(o(t).item.ref)),a=U(()=>o(s).notes[o(t).item.ref]?.kind??``),c=U(()=>!!o(s).notes[o(t).item.ref]?.done),l=U(()=>Wn(o(t).item.parent)),u=U(()=>o(n)?.far??0),d=U(()=>It(o(t).item.ref)),f=U(()=>o(s).files?.[o(t).item.ref]?.kind??``),p=U(()=>o(t).item.ref.startsWith(`?`)),m=U(()=>o(Et)&&o(Dt).has(o(t).item.ref)),h=U(()=>o(Et)&&!o(Dt).has(o(t).item.ref)&&o(At).has(o(t).item.ref)?`on`:``),g=U(()=>o(Et)&&o(jt).has(o(t).item.ref)),_=U(()=>o(Et)?o(Mt).get(o(t).item.ref)??0:0),v=U(()=>o(ht)===o(t).i?o(mt).who:``),y=U(()=>o(pt)===o(t).i),b=U(()=>!!o(He)&&!o(r)),x=U(()=>fe(cn(o(t).item.ref)));Bn(e,{get item(){return o(t).item},get title(){return o(i)},get kind(){return o(a)},get done(){return o(c)},get behind(){return o(l)},get mark(){return o(r)},get far(){return o(u)},get iso(){return o(d)},get file(){return o(f)},get prospect(){return o(p)},get given(){return o(m)},get held(){return o(h)},get changed(){return o(g)},get order(){return o(_)},get moment(){return o(v)},get here(){return o(y)},get dim(){return o(b)},get href(){return o(x)},onpick:e=>Nn(e,o(t).item.ref),onpoint:e=>{L(T,e?o(t).item.ref:o(T)===o(t).item.ref?``:o(T),!0),Ce.onAtlas=o(T)}})}});var x=H(b,2);r(x,17,()=>o(Hn),e=>e.key,(t,n)=>{var r=p(),i=A(r),a=e=>{var t=ar();c(()=>{j(t,`href`,o(n).href),j(t,`title`,`${o(n).text} · ${o(n).href}`),j(t,`aria-label`,o(n).text),j(t,`data-sat`,o(n).key),K(t,`--x:${o(n).gx??``};--y:${o(n).gy??``}`)}),J(`click`,t,e=>{mn&&e.preventDefault(),e.stopPropagation()}),d(e,t)},s=e=>{var t=or(),r=W(t,!0);c(e=>{j(t,`data-sat`,o(n).key),K(t,`--x:${o(n).gx??``};--y:${o(n).gy??``}`),j(t,`title`,o(n).text===`fewer`?`Fold them again`:`${o(n).text}: show them all`),j(t,`aria-label`,o(n).text),j(t,`aria-expanded`,o(n).text===`fewer`),R(r,e)},[()=>o(n).text===`fewer`?`−`:`+${o(n).text.split(` `)[0]}`]),J(`click`,t,()=>{let e=new Set(o(Vn));e.delete(o(n).note)||e.add(o(n).note),L(Vn,e)}),d(e,t)},l=t=>{var r=lr();let i;var a=e(r),s=e=>{var t=sr();d(e,t)},l=e=>{var t=cr();oe(t,(e,t)=>Un?.(e,t),()=>o(n).picture),v(t),d(e,t)};z(a,e=>{o(n).broken?e(s):e(l,-1)}),F(r),c(e=>{i=q(r,1,`sat picture svelte-14y1y1z`,null,i,{broken:o(n).broken}),j(r,`href`,e),j(r,`title`,`${o(n).text} · ${o(n).picture.from===`code`?`code:`:``}${o(n).picture.path}${o(n).broken?o(n).picture.from===`code`?` · not in the repository`:` · not in the notes`:``}`),j(r,`aria-label`,`${o(n).text}${o(n).broken?`, missing`:``}`),j(r,`data-sat`,o(n).key),K(r,`--x:${o(n).gx??``};--y:${o(n).gy??``}`)},[()=>fe(o(n).note)]),J(`click`,r,e=>{mn&&e.preventDefault(),e.stopPropagation()}),d(t,r)},u=e=>{var t=ur();let r;c(e=>{r=q(t,1,`sat code svelte-14y1y1z`,null,r,{broken:o(n).broken}),j(t,`title`,e),j(t,`aria-label`,`${o(n).text}${o(n).broken?`, not in the repository`:``}`),j(t,`data-sat`,o(n).key),K(t,`--x:${o(n).gx??``};--y:${o(n).gy??``}`)},[()=>`${o(n).text} · ${o(n).href.slice(5)}${o(n).broken?` · not in the repository`:``}`]),d(e,t)};z(i,e=>{o(n).kind===`web`?e(a):o(n).kind===`more`?e(s,1):o(n).kind===`picture`?e(l,2):e(u,-1)}),d(t,r)}),F(y);var S=H(y,2),w=t=>{var n=pr();let r;var i=e(n),a=e(i),s=e=>{var t=dr();d(e,t)},l=e=>{var t=fr();V(),d(e,t)};z(a,e=>{o(Lt).folder?e(s):e(l,-1)}),F(i);var u=H(i,2),f=W(u);F(n),c(()=>{r=q(n,1,`grasp svelte-14y1y1z`,null,r,{folder:o(Lt).folder}),K(n,`--x:${o(Lt).gx??``};--y:${o(Lt).gy??``}`),R(f,`${o(Lt).folder?`a new folder`:`a new note`}${o(Lt).dir?` in ${o(Lt).dir}`:``}`)}),d(t,n)};z(S,e=>{o(Lt)&&e(w)}),F(l);var E=H(l,2);r(E,17,()=>[{p:o(bt),i:o(pt),who:`here`},{p:o(xt),i:o(ht),who:o(mt)?.who??`you`}],e=>e.who===`here`?`here`:`there`,(e,t)=>{var n=p(),r=A(n),i=e=>{var n=mr();c((e,r)=>{q(n,1,`pip ${o(t).who??``}`,`svelte-14y1y1z`),K(n,`left:${o(t).p.x??``}px;top:${o(t).p.y??``}px;--a:${o(t).p.angle??``}rad`),j(n,`data-pip`,o(t).who===`here`?`here`:`there`),j(n,`aria-label`,`Bring ${e??``} into view`),j(n,`title`,`${r??``}${o(t).who===`here`?`: open in the Note pane`:``}`)},[()=>ln(o(Y).items[o(t).i].ref),()=>ln(o(Y).items[o(t).i].ref)]),J(`click`,n,e=>{e.stopPropagation(),St(o(t).i)}),d(e,n)};z(r,e=>{o(t).p&&e(i)}),d(e,n)});var k=H(E,2),M=e=>{var t=hr(),n=W(t,!0);c(()=>R(n,o($t))),d(e,t)};z(k,e=>{o($t)&&e(M)});var N=H(k,2),P=e=>{var t=gr(),n=W(t);c(()=>R(n,`◆ ${o(en)??``}`)),d(e,t)};z(N,e=>{o(en)&&e(P)});var I=H(N,2);{let e=U(()=>o(O)?.getBoundingClientRect()??null);ke(I,{get g(){return Ht},mode:`point`,get bounds(){return o(e)}})}var B=H(I,2);ke(B,{get g(){return Ht},mode:`ghost`});var ee=H(B,2),te=t=>{var n=_r(),r=e(n),i=W(r,!0),a=H(r,2),s=e(a),l=W(s,!0),u=H(s);F(a),F(n),c(()=>{R(i,o(Ut).text),R(l,o(Ut).item.kind===`folder`?`delete ${o(Ut).item.id}`:`delete`)}),J(`click`,s,()=>void qt()),J(`click`,u,()=>L(Ut,null)),d(t,n)};z(ee,e=>{o(Ut)&&e(te)});var ne=H(ee,2),re=e=>{var t=vr();d(e,t)};z(ne,e=>{Z.on.context&&!o(en)&&Z.settings===`atlas`&&e(re)});var G=H(ne,2),ie=t=>{let n=U(()=>o(Qt));var r=xr(),i=e(r),a=e=>{var t=yr();J(`click`,t,e=>{e.stopPropagation(),rn(o(n).ref),L(Qt,null)}),d(e,t)},s=U(()=>Q.has(`note`,o(n).ref)),l=e=>{var t=br();J(`click`,t,e=>{e.stopPropagation(),nn(o(n).ref),L(Qt,null)}),d(e,t)};z(i,e=>{o(s)?e(a):e(l,-1)});var u=H(i,2),f=H(u,2),p=H(f,2);F(r),c((e,t)=>{j(r,`aria-label`,e),K(r,`left:${t??``}px;top:${o(n).y+14}px`)},[()=>ln(o(n).ref),()=>Math.min(o(n).x,o(C).w-170)]),J(`click`,u,e=>{e.stopPropagation(),L(Qt,null),Z.open(o(n).ref,!0)}),J(`click`,f,e=>{e.stopPropagation(),L(Qt,null),sn(`question`,o(n).ref)}),J(`click`,p,e=>{e.stopPropagation(),L(Qt,null),sn(`problem`,o(n).ref)}),d(t,r)};z(G,e=>{o(Qt)&&e(ie)});var ae=H(G,2),se=e=>{var t=Sr();let n;var r=W(t);c(()=>{n=q(t,1,`carried svelte-14y1y1z`,null,n,{over:Q.carrying.over}),K(t,`left:${o(bn).x??``}px;top:${o(bn).y??``}px`),R(r,`${Q.carrying.part.kind===`folder`?`▭`:`▣`} ${Q.carrying.part.title??``}`)}),d(e,t)};z(ae,e=>{Q.carrying&&e(se)}),c((e,t)=>{u=q(l,1,`atlas-world svelte-14y1y1z`,null,u,{labels:o(zn),shifting:o(Ee),moving:o(_)}),j(l,`data-open`,o(he)),K(l,`transform: translate(${e??``}px, ${t??``}px) scale(${o(m).k/o(h)}); --u: ${(o(Y)?.cell??7)*o(h)}px; --k: ${o(h)??``}`),K(f,`transform: scale(${o(h)??``}); --u: ${o(Y).cell??``}px; --px: ${1/o(h)}px; --ik: ${1/o(h)}`),K(y,`transform: scale(${o(h)??``}); --u: ${o(Y).cell??``}px; --px: ${1/o(h)}px; --ik: ${1/o(h)}`)},[()=>o(_)?o(m).x:Math.round(o(m).x),()=>o(_)?o(m).y:Math.round(o(m).y)]),d(t,n)};z(Yn,e=>{o(f)?e(Xn):o(Y)&&o(s)&&e(Zn,1)}),F(Gn),B(Gn,e=>L(O,e),()=>o(O)),c(()=>{Kn=q(Gn,1,`atlas svelte-14y1y1z`,null,Kn,{lit:!!o(He)}),K(Jn,`background-size: ${o(Pe)??``}px ${o(Pe)??``}px; transform: translate(${((o(m).x+56+o(Pe)/2)%o(Pe)+o(Pe))%o(Pe)}px, ${((o(m).y+56+o(Pe)/2)%o(Pe)+o(Pe))%o(Pe)}px)`)}),J(`pointerdown`,Gn,Cn),J(`pointermove`,Gn,wn),J(`pointerup`,Gn,Tn),t(`pointercancel`,Gn,Tn),J(`click`,Gn,Fn),J(`keydown`,Gn,In),t(`dragstart`,Gn,e=>e.preventDefault()),J(`contextmenu`,Gn,e=>{(o(Lt)||Bt!==void 0||Vt!==void 0||o(Qt))&&e.preventDefault()}),d(n,Gn),ie()}h([`pointerdown`,`pointermove`,`pointerup`,`click`,`keydown`,`contextmenu`]);var Er=i(`<div class="map svelte-nwxyyl"><!> <div class="side svelte-nwxyyl"><button class="icon svelte-nwxyyl" type="button" aria-label="this session's timeline" title="this session's timeline"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 1v14" stroke="currentColor" stroke-width="1.2" fill="none"></path><rect x="5.5" y="2" width="5" height="3.2" fill="currentColor"></rect><path d="M8 6.3l2.3 2.3L8 10.9 5.7 8.6z" fill="currentColor"></path><rect x="5.5" y="12" width="5" height="3" fill="none" stroke="currentColor" stroke-width="1.2"></rect></svg></button> <!></div></div>`);function Dr(t,n){k(n,!0);let r=w(re((()=>{try{return localStorage.getItem(`isorite.timeline`)===`1`}catch{return!1}})())),i=w([]),a=w(null),s=e=>X.listing.notes.find(t=>t.id===e)?.title??e.split(`/`).at(-1),l=e=>e.who.startsWith(`iso:`)||e.who.startsWith(`agent:`);async function u(){try{L(i,(await X.api.timeline()).filter(e=>!e.note.startsWith(`@`)))}catch{}}b(()=>{if(!o(r))return;u();let e,t=X.on(t=>{t.type===`journal`&&(clearTimeout(e),e=setTimeout(()=>{u()},300))});return()=>{t(),clearTimeout(e)}});function f(e){le(`${fe(e.note)}?at=${encodeURIComponent(he(e))}`)}b(()=>{let e=o(a);Ce.set(`timeline`,e?{id:e.note,folder:!1,who:l(e)?`iso`:`you`}:null)});function p(){L(r,!o(r)),L(a,null);try{localStorage.setItem(`isorite.timeline`,o(r)?`1`:`0`)}catch{}}var m=Er(),h=e(m);Tr(h,{});var g=H(h,2),_=e(g),v=H(_,2),y=e=>{be(e,{get moments(){return o(i)},at:null,get pointed(){return o(a)},leftward:!0,name:`This session's timeline`,label:e=>s(e.note),point:e=>L(a,e),pick:e=>f(e)})};z(v,e=>{o(r)&&e(y)}),F(g),F(m),c(()=>j(_,`aria-pressed`,o(r))),J(`click`,_,p),d(t,m),ie()}h([`click`]);var Or=e=>e.trim().split(`
2
+ `).map(e=>`> ${e}`).join(`
3
+ `);function kr(e,t=``){if(!e.length)return``;let n=e.filter(e=>e.kind===`note`),r=e.filter(e=>e.kind===`folder`),i=e.filter(e=>e.kind===`passage`),a=[`From my isorite knowledge base. Read what I name with the isorite tools (read_note, outline_note, search_notes), not from this message alone: the notes may have changed since I chose them.`];return n.length&&a.push(`Notes (read_note by id; outline_note first for a long one):\n${n.map(e=>`- ${e.title} (${e.id})`).join(`
4
+ `)}`),r.length&&a.push(`Folders (search_notes with "under" set to the folder, or brief_base for the whole base):\n${r.map(e=>`- ${e.title} (${e.id})`).join(`
5
+ `)}`),i.length&&a.push(`Passages I selected, quoted as they were when I chose them. Read the note for the current text before relying on a quote:\n\n${i.map(e=>`From ${e.title} (${e.id}):\n${Or(e.text)}`).join(`
6
+
7
+ `)}`),t.trim()&&a.push(t.trim()),a.join(`
8
+
9
+ `)}var Ar=i(`<p class="svelte-1n9iqy5">In a repository of their own, <code class="svelte-1n9iqy5"> </code> </p> <pre class="svelte-1n9iqy5"> </pre> <p class="svelte-1n9iqy5"><button type="button" class="more svelte-1n9iqy5"> </button> <span class="faint">isorite runs none of this itself.</span></p>`,1),jr=i(`<p class="svelte-1n9iqy5"> <code class="svelte-1n9iqy5"> </code>.</p>`),Mr=i(`<p class="choices svelte-1n9iqy5"><button type="button" class="btn">with the project</button> <button type="button" class="btn">apart</button></p>`),Nr=i(`<p class="faint svelte-1n9iqy5">Kept with the project. <button type="button" class="more svelte-1n9iqy5">show how to keep them apart</button></p>`),Pr=i(`<p class="svelte-1n9iqy5">To keep them apart, run these in a terminal (isorite runs none of it):</p> <pre class="svelte-1n9iqy5"> </pre> <p class="svelte-1n9iqy5"><button type="button" class="more svelte-1n9iqy5"> </button></p>`,1),Fr=i(`<p class="svelte-1n9iqy5"><!> <!></p> <!> <!>`,1),Ir=i(`<p class="bad svelte-1n9iqy5" role="alert"> </p>`),Lr=i(`<details class="own svelte-1n9iqy5"><summary class="label svelte-1n9iqy5">where isorite's files are kept</summary> <div class="body svelte-1n9iqy5"><!> <!></div></details>`);function Rr(t,n){k(n,!0);let r=X.api?.own??null,i=w(null),a=w(!1),s=w(``);b(()=>{r&&r.repo().then(e=>L(i,e),()=>void 0)});let l=U(()=>o(i)?.commands.join(`
10
+ `)??``),f=w(!1),m=U(()=>o(i)?.choice===`separate`||o(f));async function h(e){L(s,``);try{L(i,await r?.choose(e)??o(i))}catch(e){L(s,e.message,!0)}}async function g(){try{await navigator.clipboard.writeText(o(l)),L(a,!0),setTimeout(()=>L(a,!1),1500)}catch{L(s,`The browser would not copy: select the lines and copy them.`)}}var _=p(),v=A(_),y=t=>{var n=Lr(),r=H(e(n),2),p=e(r),_=t=>{var n=Ar(),r=A(n),s=H(e(r)),u=W(s,!0),f=H(s);F(r);var p=H(r,2),m=W(p,!0),h=H(p,2),_=e(h),v=W(_,!0);V(2),F(h),c(e=>{R(u,o(i).path),R(f,`. ${e??``}`),R(m,o(l)),R(v,o(a)?`copied`:`copy`)},[()=>o(i).remotes.length?`Remote: ${o(i).remotes.join(`, `)}. To push:`:`To keep them elsewhere, add a remote and push:`]),J(`click`,_,()=>void g()),d(t,n)},v=t=>{var n=jr(),r=e(n),a=H(r),s=W(a,!0);V(),F(n),c(()=>{R(r,`Git didn't answer: ${o(i).problem??``}. isorite's files are plain files in `),R(s,o(i).path)}),d(t,n)},y=t=>{var n=Fr(),r=A(n),s=e(r),p=e=>{var t=u(`The project's repository tracks them, so everyone sharing the project has your journals and kept sessions.`);d(e,t)},_=e=>{var t=u(`They are in the project's folder, to be committed with it.`);d(e,t)};z(s,e=>{o(i).state===`tracked`?e(p):e(_,-1)});var v=H(s,2),y=e=>{var t=u(`Keep them with the project, or apart from it, in a repository of their own?`);d(e,t)};z(v,e=>{o(i).ask&&e(y)}),F(r);var b=H(r,2),x=t=>{var n=Mr(),r=e(n),i=H(r,2);F(n),J(`click`,r,()=>void h(`project`)),J(`click`,i,()=>void h(`separate`)),d(t,n)},S=t=>{var n=Nr(),r=H(e(n));F(n),J(`click`,r,()=>L(f,!0)),d(t,n)};z(b,e=>{o(i).ask?e(x):o(i).choice===`project`&&!o(f)&&e(S,1)});var C=H(b,2),w=t=>{var n=Pr(),r=H(A(n),2),i=W(r,!0),s=H(r,2),u=e(s),f=W(u,!0);F(s),c(()=>{R(i,o(l)),R(f,o(a)?`copied`:`copy`)}),J(`click`,u,()=>void g()),d(t,n)};z(C,e=>{o(m)&&e(w)}),d(t,n)};z(p,e=>{o(i).state===`own`?e(_):o(i).state===`unavailable`?e(v,1):e(y,-1)});var b=H(p,2),x=e=>{var t=Ir(),n=W(t,!0);c(()=>R(n,o(s))),d(e,t)};z(b,e=>{o(s)&&e(x)}),F(r),F(n),c(()=>n.open=o(i).ask),d(t,n)};z(v,e=>{o(i)&&o(i).state!==`none`&&e(y)}),d(t,_),ie()}h([`click`]);var zr=i(`<h2 class="label svelte-6livgy">choose your agent</h2> <p class="soft svelte-6livgy">The agent you already use. In this pane its conversations show here, with the notes it reads lit on the Atlas. In its own terminal it has the same tools, and the pane isn't its conversation.</p>`,1),Br=i(`<p class="faint svelte-6livgy">Looking for agents on this machine…</p>`),Vr=i(`<p class="faint note svelte-6livgy"> </p>`),Hr=i(`<button type="button" class="more svelte-6livgy">start it again</button> · <button type="button" class="more svelte-6livgy">stop</button>`,1),Ur=i(`<button type="button" class="btn svelte-6livgy"> </button>`),Wr=i(`<div class="steps svelte-6livgy"><p class="svelte-6livgy"><b class="svelte-6livgy">1.</b> </p> <p class="line svelte-6livgy"><code class="svelte-6livgy"> </code> <button type="button" class="more svelte-6livgy"> </button></p> <p class="svelte-6livgy"><b class="svelte-6livgy">2.</b> <span class="faint">The pane won't show that conversation.</span></p> <p class="svelte-6livgy"><b class="svelte-6livgy">Live in both places?</b> Run it from an ACP front end such as Toad or Zed with this as its agent, and the same session shows here as it happens:</p> <p class="line svelte-6livgy"><code class="svelte-6livgy"> </code> <button type="button" class="more svelte-6livgy"> </button></p></div>`),Gr=i(`<li data-lustre=""><div class="head svelte-6livgy"><b class="svelte-6livgy"> </b><span class="state svelte-6livgy"> </span></div> <!> <div class="acts svelte-6livgy"><!> <button type="button" class="more svelte-6livgy">in my terminal</button></div> <!></li>`),Kr=i(`· <span class="faint">in this pane: <span class="chosen svelte-6livgy"> </span> <button type="button" class="more svelte-6livgy">stop</button></span>`,1),qr=i(`<p class="bad svelte-6livgy" role="alert"> </p>`),Jr=i(`<p class="faint svelte-6livgy">Reading the ACP registry…</p>`),Yr=i(`<option> </option>`),Xr=i(`<label class="hidden-label" for="agent-pick">An agent of the ACP registry</label> <select id="agent-pick" class="field svelte-6livgy"><option>An agent of the ACP registry…</option><!></select>`,1),Zr=i(`<form class="pick svelte-6livgy"><!> <label class="hidden-label" for="agent-command">Or the command of an ACP agent</label> <input id="agent-command" class="field svelte-6livgy" placeholder="or its command: hermes acp" autocomplete="off" spellcheck="false"/> <p class="faint svelte-6livgy">It runs on this machine, in the base's repository, with the server's environment: its key and model are set up as for its own terminal.</p> <p class="svelte-6livgy"><button type="submit" class="btn svelte-6livgy"> </button></p></form>`),Qr=i(`<pre class="svelte-6livgy"> </pre>`),$r=i(`<p class="faint svelte-6livgy"> </p> <!>`,1),ei=i(`<p class="svelte-6livgy"><button type="button" class="btn svelte-6livgy"> </button></p>`),ti=i(`<p class="faint svelte-6livgy"> </p>`),ni=i(`<!> <!> <!>`,1),ri=i(`<p class="faint svelte-6livgy">With no agent, the notes, the Atlas and search by meaning work as they are. Nothing to set up.</p>`),ii=i(`<!> <ul class="cards svelte-6livgy"></ul> <p class="more-row svelte-6livgy"><button type="button" class="more svelte-6livgy">another agent</button> · <button type="button" class="more svelte-6livgy">the project's config</button> <!></p> <!> <!> <!> <!> <!>`,1),ai=i(`<p class="faint svelte-6livgy">An agent is chosen from the machine isorite runs on. In the agent's own terminal, give it isorite's MCP: <code class="svelte-6livgy"> </code>.</p>`),oi=i(`<section aria-label="Choose your agent"><!> <!> <!></section>`);function si(n,i){k(i,!0);let a=I(i,`compact`,3,!1),s=X.api?.terminal??null,l=new URL(Y()?`b/${encodeURIComponent(Y())}/mcp`:`mcp`,document.baseURI).href,u=[`localhost`,`127.0.0.1`,`[::1]`].includes(location.hostname),f=w(``),m=w(null),h=w(null),g=w(``),_=w(``),v=w(!1),y=w(``);b(()=>{s&&u&&(s.chosen().then(e=>L(m,e),()=>void 0),s.detected().then(e=>L(h,e),()=>L(h,[])))});let x=(e,t)=>!!e&&(`id`in e?`id`in t&&e.id===t.id:`command`in t&&e.command===t.command),S=e=>x(o(m)?.choice,{command:e.command}),C=e=>e?o(h)?.find(t=>`command`in e&&e.command===t.command)?.name??(`command`in e?e.command:e.id):``,T=e=>`isorite acp ${e.id}`;async function E(e,t=``){if(L(f,``),s){L(g,t||`none`,!0);try{L(m,await s.choose(e))}catch(e){L(f,e.message,!0)}finally{L(g,``)}}}async function D(e,t){try{await navigator.clipboard.writeText(e),L(y,t,!0),setTimeout(()=>{o(y)===t&&L(y,``)},1500)}catch{L(f,`The browser would not copy: select the line and copy it.`)}}let N=w(null),B=w(``),ee=w(``);async function te(){if(L(v,!o(v)),o(v)&&!o(N)&&s)try{L(N,(await s.registry()).filter(e=>e.how))}catch(e){L(f,e.message,!0),L(N,[])}}function ne(e){e.preventDefault(),o(ee).trim()?E({command:o(ee).trim()},`other`):o(B)&&E({id:o(B)},`other`)}let K=w(null),ae=w(re([])),oe=w(!1);async function se(){if(L(oe,!o(oe)),o(oe)&&!o(K)&&s)try{L(K,await s.project())}catch(e){L(f,e.message,!0)}}async function ce(){if(L(f,``),s)try{L(ae,await s.writeProject(),!0),L(K,o(K)&&{...o(K),files:o(K).files.map(e=>({...e,current:!0}))})}catch(e){L(f,e.message,!0)}}let le=U(()=>o(K)?.files.filter(e=>!e.current)??[]);var ue=p(),de=A(ue),fe=n=>{var i=oi();let s;var p=e(i),b=e=>{var t=zr();V(2),d(e,t)};z(p,e=>{a()||e(b)});var x=H(p,2),w=n=>{var i=ii(),s=A(i),u=e=>{var t=Br();d(e,t)};z(s,e=>{o(h)===null&&e(u)});var f=H(s,2);r(f,21,()=>o(h)??[],e=>e.id,(t,n)=>{var r=Gr();let i;var a=e(r),s=e(a),u=W(s,!0),f=H(s),p=W(f,!0);F(a);var h=H(a,2),v=e=>{var t=Vr(),r=W(t,!0);c(()=>R(r,o(n).note)),d(e,t)};z(h,e=>{o(n).found&&e(v)});var b=H(h,2),x=e(b),C=e=>{var t=Hr(),r=A(t),i=H(r,2);c(()=>{r.disabled=!!o(g),i.disabled=!!o(g)}),J(`click`,r,()=>void E({command:o(n).command},o(n).id)),J(`click`,i,()=>void E(null)),d(e,t)},w=U(()=>S(o(n))),O=e=>{var t=Ur(),r=W(t,!0);c(()=>{t.disabled=!!o(g)||!o(n).found||!o(n).ready,j(t,`title`,o(n).found?o(n).ready?void 0:o(n).note:`${o(n).name} isn't on this machine's PATH`),R(r,o(g)===o(n).id?`starting…`:`use in this pane`)}),J(`click`,t,()=>void E({command:o(n).command},o(n).id)),d(e,t)};z(x,e=>{o(w)?e(C):e(O,-1)});var k=H(x,2);F(b);var M=H(b,2),N=t=>{var r=Wr(),i=e(r),a=H(e(i));F(i);var s=H(i,2),u=e(s),f=W(u,!0),p=H(u,2),m=W(p,!0);F(s);var h=H(s,2),g=H(e(h));V(),F(h);var _=H(h,4),v=e(_),b=W(v,!0),x=H(v,2),S=W(x,!0);F(_),F(r),c(e=>{R(a,` Give ${o(n).name??``} isorite's tools. Add this MCP address to its config, or write the project's config:`),R(f,l),R(m,o(y)===`${o(n).id}-mcp`?`copied`:`copy`),R(g,` Then run ${o(n).name??``} as you do. It reads and cites the notes, and the Atlas shows what it read. `),R(b,e),R(S,o(y)===`${o(n).id}-acp`?`copied`:`copy`)},[()=>T(o(n))]),J(`click`,p,()=>void D(l,`${o(n).id}-mcp`)),J(`click`,x,()=>void D(T(o(n)),`${o(n).id}-acp`)),d(t,r)};z(M,e=>{o(_)===o(n).id&&e(N)}),F(r),c((e,t)=>{i=q(r,1,`card frame svelte-6livgy`,null,i,{on:e,absent:!o(n).found}),R(u,o(n).name),R(p,t),j(k,`aria-expanded`,o(_)===o(n).id)},[()=>S(o(n)),()=>S(o(n))?o(m)?.running?`in this pane · running`:`in this pane`:o(n).found?`found`:`not found`]),J(`click`,k,()=>L(_,o(_)===o(n).id?``:o(n).id,!0)),d(t,r)}),F(f);var p=H(f,2),b=e(p),x=H(b,2),w=H(x,2),k=t=>{var n=Kr(),r=H(A(n)),i=H(e(r)),a=W(i,!0),s=H(i,2);F(r),c(e=>R(a,e),[()=>C(o(m).choice)]),J(`click`,s,()=>void E(null)),d(t,n)},I=U(()=>o(m)?.choice&&!o(h)?.some(S));z(w,e=>{o(I)&&e(k)}),F(p);var re=H(p,2),ie=e=>{var t=qr(),n=W(t);c(e=>R(n,`${o(m).problem??``}${e??``}`),[()=>o(m).hint?`: ${o(m).hint}`:o(m).said?`: ${o(m).said.trim().split(`
11
+ `).at(-1)}`:``]),d(e,t)};z(re,e=>{o(m)?.problem&&e(ie)});var ue=H(re,2),de=n=>{var i=Zr(),a=e(i),s=e=>{var t=Jr();d(e,t)},l=t=>{var n=Xr(),i=H(A(n),2),a=e(i);a.value=a.__value=``;var s=H(a);r(s,17,()=>o(N),e=>e.id,(e,t)=>{var n=Yr(),r=W(n),i={};c(()=>{j(n,`title`,o(t).description),R(r,`${o(t).name??``} ${o(t).version??``}`),i!==(i=o(t).id)&&(n.value=(n.__value=i)??``)}),d(e,n)}),F(i),M(i),J(`change`,i,()=>L(ee,``)),P(i,()=>o(B),e=>L(B,e)),d(t,n)};z(a,e=>{o(N)===null?e(s):o(N).length&&e(l,1)});var u=H(a,4);O(u);var f=H(u,4),p=e(f),m=W(p,!0);F(f),F(i),c(e=>{p.disabled=e,R(m,o(g)===`other`?`starting…`:`use in this pane`)},[()=>!!o(g)||!o(B)&&!o(ee).trim()]),t(`submit`,i,ne),J(`input`,u,()=>L(B,``)),G(u,()=>o(ee),e=>L(ee,e)),d(n,i)};z(ue,e=>{o(v)&&e(de)});var fe=H(ue,2),Y=t=>{var n=ni(),i=A(n);r(i,17,()=>o(K).files,e=>e.file,(e,t)=>{var n=$r(),r=A(n),i=W(r),a=H(r,2),s=e=>{var n=Qr(),r=W(n,!0);c(()=>R(r,o(t).after)),d(e,n)};z(a,e=>{o(t).current||e(s)}),c(()=>R(i,`${o(t).file??``} (${o(t).harness??``})${o(t).current?`: has it`:``}`)),d(e,n)});var a=H(i,2),s=t=>{var n=ei(),r=e(n),i=W(r);F(n),c(e=>R(i,`write ${e??``}`),[()=>o(le).map(e=>e.file).join(` and `)]),J(`click`,r,()=>void ce()),d(t,n)};z(a,e=>{o(le).length&&e(s)});var l=H(a,2),u=e=>{var t=ti(),n=W(t);c(e=>R(n,`Written: ${e??``}. Commit them with the project.`),[()=>o(ae).join(`, `)]),d(e,t)};z(l,e=>{o(ae).length&&e(u)}),d(t,n)};z(fe,e=>{o(oe)&&o(K)&&e(Y)});var X=H(fe,2),pe=e=>{Rr(e,{})};z(X,e=>{a()||e(pe)});var me=H(X,2),he=e=>{var t=ri();d(e,t)};z(me,e=>{a()||e(he)}),c(()=>{j(b,`aria-expanded`,o(v)),j(x,`aria-expanded`,o(oe))}),J(`click`,b,()=>void te()),J(`click`,x,()=>void se()),d(n,i)},k=t=>{var n=ai(),r=H(e(n)),i=W(r,!0);V(),F(n),c(()=>R(i,l)),d(t,n)};z(x,e=>{u?e(w):e(k,-1)});var I=H(x,2),re=e=>{var t=qr(),n=W(t,!0);c(()=>R(n,o(f))),d(e,t)};z(I,e=>{o(f)&&e(re)}),F(i),c(()=>s=q(i,1,`attach svelte-6livgy`,null,s,{compact:a()})),d(n,i)};z(de,e=>{s&&e(fe)}),d(n,ue),ie()}h([`click`,`change`,`input`]);var ci=i(`<p class="faint none svelte-19hl4w"> </p>`),li=i(`<button type="button" class="more drop fork svelte-19hl4w" title="A new session that begins where this one is">fork</button>`),ui=i(`<p class="sure svelte-19hl4w" role="group" aria-label="Remove the kept copy">Remove what isorite kept of this?<span class="faint">The agent's own history stays.</span> <button type="button" class="more bad svelte-19hl4w">remove</button> · <button type="button" class="more svelte-19hl4w">keep</button></p>`),di=i(`<button type="button" class="more drop svelte-19hl4w">remove</button>`),fi=i(`<div role="listitem" class="svelte-19hl4w"><button type="button" data-lustre=""><!> <span class="m svelte-19hl4w"> </span> <span class="q svelte-19hl4w"> </span> <span class="m svelte-19hl4w"> </span></button> <!> <!></div>`),pi=i(`<p class="sure svelte-19hl4w" role="group" aria-label="Remove this conversation">Remove this conversation with the agent? <button type="button" class="more bad svelte-19hl4w">remove</button> · <button type="button" class="more svelte-19hl4w">keep</button></p>`),mi=i(`<div role="listitem" class="svelte-19hl4w"><button type="button" data-lustre=""><!> <span class="m svelte-19hl4w"> </span> <span class="q svelte-19hl4w"> </span> <span class="m svelte-19hl4w"> </span></button> <!></div>`),hi=i(`<h2 class="label none svelte-19hl4w">earlier, with the agent</h2> <!>`,1),gi=i(`<p class="faint none svelte-19hl4w">Started for this pane: <code class="svelte-19hl4w"> </code> · <button type="button" class="more svelte-19hl4w">stop it</button></p>`),_i=i(`<p class="bad none svelte-19hl4w" role="alert"> </p>`),vi=i(`<div class="drawer svelte-19hl4w" role="list" aria-label="The agents' sessions"><!> <!> <!> <!> <!> <details class="change none svelte-19hl4w"><summary class="label svelte-19hl4w">change agent</summary><!></details> <!></div>`);function yi(t,n){k(n,!0);let i=864e5;function a(e){let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return Number.isNaN(t.getTime())?``:t.getTime()>=r?`today · ${t.toTimeString().slice(0,5)}`:t.getTime()>=r-i?`yesterday`:t.getTime()>=r-6*i?t.toLocaleDateString(void 0,{weekday:`short`}):t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,...t.getFullYear()===n.getFullYear()?{}:{year:`numeric`}})}let s=(e,t)=>`${e} ${t}${e===1?``:`s`}`,l=U(()=>$.view?.sessions??[]),u=e=>!$.old&&e.session===$.view?.session&&e.agent===$.view?.agentId,f=e=>e.busy?`at work`:e.live?`live`:e.kept?e.open?`kept`:`kept · to read`:e.open?`from its terminal`:`the agent's own`,m=X.api?.terminal??null,h=w(null);b(()=>{m&&[`localhost`,`127.0.0.1`,`[::1]`].includes(location.hostname)&&m.chosen().then(e=>L(h,e),()=>void 0)});async function g(){try{L(h,await m?.choose(null)??null)}catch(e){$.problem=e.message}}let _=w(``),v=e=>`${e.agent}/${e.session}`;async function y(e){L(_,``),await $.forgetPast(e)}async function x(e){L(_,``),await $.forget(e.agent,e.session)}async function S(e){await $.fork(e.agent,e.session),$.problem||($.shown=`session`)}async function C(e){await $.follow(e.agent,e.session),$.problem||($.shown=`session`)}var T=vi(),D=e(T),O=e=>{var t=ci(),n=W(t);c(()=>R(n,`No sessions yet${$.acp?`: those you start in the agent's own terminal show here too, to carry on`:`: attach an agent, and its sessions are kept here`}.`)),d(e,t)};z(D,e=>{o(l).length||e(O)});var M=H(D,2);r(M,17,()=>o(l),e=>`${e.agent}/${e.session}`,(t,n)=>{var r=fi(),i=e(r);let l;var m=e(i);Me(m,{get id(){return o(n).session},size:44,get growing(){return o(n).busy}});var h=H(m,2),g=W(h),y=H(h,2),b=W(y,!0),w=H(y,2),T=W(w,!0);F(i);var E=H(i,2),D=e=>{var t=li();c(()=>j(t,`aria-label`,`Fork ${(o(n).title||o(n).asked||`this session`)??``}: a new session from here`)),J(`click`,t,()=>void S(o(n))),d(e,t)};z(E,e=>{$.view?.fork&&o(n).kept&&e(D)});var O=H(E,2),k=t=>{var r=p(),i=A(r),a=t=>{var r=ui(),i=H(e(r),3),a=H(i,2);F(r),J(`click`,i,()=>void x(o(n))),J(`click`,a,()=>L(_,``)),d(t,r)},s=U(()=>o(_)===v(o(n))),l=e=>{var t=di();c(()=>j(t,`aria-label`,`Remove the kept copy of ${(o(n).title||o(n).asked||`this session`)??``}`)),J(`click`,t,()=>L(_,v(o(n)),!0)),d(e,t)};z(i,e=>{o(s)?e(a):e(l,-1)}),d(t,r)};z(O,e=>{o(n).kept&&!o(n).live&&e(k)}),F(r),c((e,t,r,a,s)=>{l=q(i,1,`spec frame svelte-19hl4w`,null,l,{on:e,live:o(n).live}),j(i,`aria-current`,t),i.disabled=!o(n).open&&!o(n).kept,j(i,`title`,!o(n).open&&!o(n).kept?`${o(n).name} isn't attached to carry it on`:!o(n).live&&!o(n).kept?`Carry on here what you did in ${o(n).name}'s own terminal`:void 0),R(g,`${o(n).name??``} · ${r??``}${a??``}`),R(b,o(n).title||o(n).asked||`A session`),R(T,s)},[()=>u(o(n)),()=>u(o(n))?`true`:void 0,()=>f(o(n)),()=>a(o(n).last)?` · ${a(o(n).last)}`:``,()=>o(n).turns?`${s(o(n).notes,`note`)} · ${s(o(n).turns,`turn`)}`:`not carried here yet`]),J(`click`,i,()=>void C(o(n))),d(t,r)});var N=H(M,2),P=t=>{var n=hi(),i=H(A(n),2);r(i,17,()=>$.past,e=>e.id,(t,n)=>{var r=mi(),i=e(r);let l;var u=e(i);Me(u,{get id(){return o(n).id},size:44});var f=H(u,2),p=W(f),m=H(f,2),h=W(m,!0),g=H(m,2),v=W(g);F(i);var b=H(i,2),x=t=>{var r=pi(),i=H(e(r)),a=H(i,2);F(r),J(`click`,i,()=>void y(o(n).id)),J(`click`,a,()=>L(_,``)),d(t,r)},S=e=>{var t=di();c(()=>j(t,`aria-label`,`Remove the conversation ${o(n).asked??``}`)),J(`click`,t,()=>L(_,`iso/${o(n).id}`)),d(e,t)};z(b,e=>{o(_)===`iso/${o(n).id}`?e(x):e(S,-1)}),F(r),c((e,t,r)=>{l=q(i,1,`spec frame svelte-19hl4w`,null,l,{on:$.old?.session===o(n).id}),j(i,`aria-current`,$.old?.session===o(n).id?`true`:void 0),R(p,`Agent · to read${e??``}`),R(h,o(n).asked),R(v,`${t??``} · ${r??``}`)},[()=>a(o(n).last)?` · ${a(o(n).last)}`:``,()=>s(o(n).notes,`note`),()=>s(o(n).turns,`turn`)]),J(`click`,i,()=>void $.read(o(n).id)),d(t,r)}),d(t,n)};z(N,e=>{$.past.length&&e(P)});var I=H(N,2),B=t=>{var n=gi(),r=H(e(n)),i=W(r,!0),a=H(r,2);F(n),c(()=>R(i,o(h).choice&&`id`in o(h).choice?o(h).choice.id:o(h).command)),J(`click`,a,()=>void g()),d(t,n)};z(I,e=>{o(h)?.running&&e(B)});var V=H(I,2),ee=e=>{var t=_i(),n=W(t,!0);c(()=>R(n,$.problem)),d(e,t)};z(V,e=>{$.problem&&e(ee)});var te=H(V,2);si(H(e(te)),{compact:!0}),F(te),Rr(H(te,2),{}),F(T),E(`open`,`toggle`,te,e=>$.changing=e,()=>$.changing),d(t,T),ie()}h([`click`]);var bi=i(`<i></i>`),xi=i(`<span> </span>`),Si=i(`<span> </span><span class="faint"> </span>`,1),Ci=i(`<span class="faint"> </span>`),wi=i(`<div class="strata svelte-po8nwq" role="img"></div> <p class="total svelte-po8nwq"><!><!></p>`,1),Ti=i(`<p class="faint"> </p>`),Ei=i(`<span class="num svelte-po8nwq"> </span>`),Di=i(`<li class="row svelte-po8nwq"><span class="r svelte-po8nwq"><span aria-hidden="true"> </span><span class="t svelte-po8nwq"> </span><span class="d svelte-po8nwq"> </span><!></span></li>`),Oi=i(`<div class="column svelte-po8nwq"><!> <p class="faint"> </p></div> <h2 class="label svelte-po8nwq">notes</h2> <ul class="rows svelte-po8nwq" aria-label="The notes in the session"></ul>`,1),ki=i(`<p class="faint">With an agent attached, what it has in hand shows here: isorite's part, the notes it was given and read, and the room left.</p>`),Ai=i(`<li class="row svelte-po8nwq"><span class="r svelte-po8nwq"><span class="mk svelte-po8nwq" aria-hidden="true">◆</span><span class="t svelte-po8nwq"> </span></span> <button type="button" class="x svelte-po8nwq"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M4 4l8 8M12 4l-8 8"></path></svg></button></li>`),ji=i(`<div class="context svelte-po8nwq" role="region" aria-label="What the agent has in hand"><!> <h2 class="label svelte-po8nwq">in the tray</h2> <ul class="rows svelte-po8nwq" aria-label="What you gave the agent" title="Given to the session before its next prompt, asked here or in its front end, unless given already"></ul></div>`);function Mi(n,i){k(i,!0);let a=e=>e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1)}k`:String(e),s=w(null),l=w({});b(()=>{$.session&&X.api.map().then(e=>L(l,Object.fromEntries(Object.entries(e.notes).map(([e,t])=>[e,t.tokens]))),()=>void 0)});let u=U(()=>{let e=new Set,t=new Set;for(let n of $.session?.turns??[]){for(let t of n.given??[])t.kind===`note`&&e.add(t.id);for(let e of n.items)e.kind===`tool`&&e.note&&!e.base&&e.status===`done`&&t.add(e.note)}let n=e=>X.listing.notes.find(t=>t.id===e)?.title??e;return[...[...e].map(e=>({id:e,how:`given`})),...[...t].filter(t=>!e.has(t)).map(e=>({id:e,how:`read`}))].map(e=>({...e,title:n(e.id),tokens:o(l)[e.id]??0}))}),f=U(()=>{let e=$.session;if(!e?.size||!e.tokens.input)return[];let t=Math.min(e.ours??0,e.tokens.input),n=Math.min(o(u).reduce((e,t)=>e+t.tokens,0),e.tokens.input-t);return[{k:`instructions`,name:`isorite's`,tokens:t},{k:`notes`,name:`notes`,tokens:n},{k:`conversation`,name:`the rest`,tokens:e.tokens.input-t-n},{k:`room`,name:`room`,tokens:Math.max(0,e.size-e.tokens.input)}].filter(e=>e.tokens>0).map(t=>({...t,w:100*t.tokens/e.size}))}),p=U(()=>o(f).find(e=>e.k===o(s)));var m=ji(),h=e(m),g=n=>{let i=U(()=>$.session);var l=Oi(),m=A(l),h=e(m),g=n=>{var l=wi(),u=A(l);r(u,21,()=>o(f),e=>e.k,(e,t)=>{var n=bi();let r;c(e=>{q(n,1,`s ${o(t).k??``}`,`svelte-po8nwq`),j(n,`data-k`,o(t).k),r=K(n,``,r,{width:e})},[()=>`${o(t).w.toFixed(2)??``}%`]),d(e,n)}),F(u);var m=H(u,2),h=e(m),g=e=>{var t=xi(),n=W(t);c(e=>R(n,`${o(p).name??``} · ${e??``}`),[()=>a(o(p).tokens)]),d(e,t)},_=e=>{var t=Si(),n=A(t),r=W(n,!0),s=H(n),l=W(s);c((e,t)=>{R(r,e),R(l,`of ${t??``}`)},[()=>a(o(i).tokens.input),()=>a(o(i).size??0)]),d(e,t)};z(h,e=>{o(p)?e(g):e(_,-1)});var v=H(h),y=e=>{var t=Ci(),n=W(t);c(e=>R(n,`· $${e??``}`),[()=>o(i).cost.toFixed(2)]),d(e,t)};z(v,e=>{o(i).cost&&e(y)}),F(m),c(e=>{j(u,`aria-label`,e),j(m,`title`,`As ${o(i).agent??``} counts it`)},[()=>o(f).map(e=>`${e.name} ${a(e.tokens)}`).join(`, `)]),J(`pointerover`,u,e=>L(s,e.target.dataset.k??null,!0)),t(`pointerleave`,u,()=>L(s,null)),d(n,l)},_=e=>{var t=Ti(),n=W(t);c(()=>R(n,`${(o(i).agent||`The agent`)??``} hasn't said how full its context is${o(i).turns.length?``:` yet`}.`)),d(e,t)};z(h,e=>{o(f).length?e(g):e(_,-1)});var v=H(h,2),y=W(v);F(m);var b=H(m,4);r(b,21,()=>o(u),e=>e.id,(t,n)=>{var r=Di(),s=e(r),l=e(s);let u;var f=W(l,!0),p=H(l),m=W(p,!0),h=H(p),g=W(h,!0),_=H(h),v=e=>{var t=Ei(),r=W(t,!0);c(e=>R(r,e),[()=>a(o(n).tokens)]),d(e,t)};z(_,e=>{o(n).tokens&&e(v)}),F(s),F(r),c(()=>{j(s,`title`,o(n).how===`given`?`Given from here`:`Read by ${o(i).agent}`),u=q(l,1,`mk svelte-po8nwq`,null,u,{iso:o(n).how===`read`}),R(f,o(n).how===`given`?`◆`:`◇`),R(m,o(n).title),R(g,o(n).how)}),d(t,r)}),F(b),c(()=>R(y,`What ${(o(i).agent||`the agent`)??``} dropped when it compacted can't be seen from here.`)),d(n,l)},_=e=>{var t=ki();d(e,t)};z(h,e=>{$.session?e(g):e(_,-1)});var v=H(h,4);r(v,21,()=>Q.sent,e=>Q.keyOf(e),(t,n)=>{var r=Ai(),i=e(r),a=H(e(i)),s=W(a,!0);F(i);var l=H(i,2);F(r),c(()=>{R(s,o(n).kind===`passage`?`“${o(n).text}”`:o(n).title),j(l,`aria-label`,`Take ${o(n).title??``} out of the agent's context`)}),J(`click`,l,()=>Q.remove(o(n))),d(t,r)}),F(v),F(m),d(n,m),ie()}h([`pointerover`,`click`]);var Ni=i(`<div class="permit svelte-17377q0" role="group" aria-label="The agent asks before it does this"><p> <code class="svelte-17377q0"> </code>.</p> <p class="acts svelte-17377q0"><button type="button" class="svelte-17377q0">Allow once</button><button type="button" class="svelte-17377q0">Always allow this</button><button type="button" class="no svelte-17377q0">Don't allow</button></p></div>`),Pi=i(`<div class="said prose svelte-17377q0"></div>`),Fi=i(`<details class="think svelte-17377q0"><summary class="svelte-17377q0">thinking</summary><p class="svelte-17377q0"> </p></details>`),Ii=i(`<p class="svelte-17377q0"> </p>`),Li=i(`<details class="squeeze svelte-17377q0"><summary class="svelte-17377q0"><!></summary> <!></details>`),Ri=i(`<p class="mid svelte-17377q0"><span class="how svelte-17377q0"> </span> </p>`),zi=i(`<button type="button" class="note-link svelte-17377q0"> </button>`),Bi=i(`<span class="qt svelte-17377q0"> </span> <button class="keep svelte-17377q0" type="button" data-lustre="">keep</button>`,1),Vi=i(`<p class="qb svelte-17377q0"> </p>`),Hi=i(`<div class="asks svelte-17377q0"><p class="svelte-17377q0"><svg class="qm svelte-17377q0" viewBox="0 0 16 16" width="13" height="13" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M8 2.5L13.5 8L8 13.5L2.5 8Z"></path></svg><!></p> <!></div>`),Ui=i(`<span>AGENTS.md</span>`),Wi=i(`<span class="in svelte-17377q0">inserted</span>`),Gi=i(`<button class="insert svelte-17377q0" type="button">insert</button>`),Ki=i(`<div class="offer svelte-17377q0"><div class="prose yours svelte-17377q0"></div> <p class="for svelte-17377q0"><!> <!></p></div>`),qi=i(`<a class="note-link svelte-17377q0" data-sveltekit-reload="" target="_blank" rel="noopener"><span class="in svelte-17377q0"> </span> </a>`),Ji=i(`<code class="q svelte-17377q0"> </code>`),Yi=i(`<span class="n svelte-17377q0"><span class="add svelte-17377q0"> </span> <span class="del svelte-17377q0"> </span></span>`),Xi=i(`<span> </span>`),Zi=i(`<pre class="diff svelte-17377q0"></pre>`),Qi=i(`<pre class="out svelte-17377q0"> </pre>`),$i=i(`<details><summary class="svelte-17377q0"><span class="v svelte-17377q0"> </span><!><!></summary> <!></details>`),ea=i(`<p class="line svelte-17377q0"><span class="v svelte-17377q0"> </span><!></p>`),ta=i(`<div class="tool svelte-17377q0"><!> <!></div>`),na=i(`<span><span class="k svelte-17377q0" aria-hidden="true"> </span><span class="t svelte-17377q0"> </span></span>`),ra=i(`<span class="gave svelte-17377q0"></span>`),ia=i(`<button type="button" data-lustre=""><s aria-hidden="true" class="svelte-17377q0"></s><b class="svelte-17377q0"> </b> </button>`),aa=i(`<div class="parts svelte-17377q0" role="group"></div>`),oa=i(`<p class="doing svelte-17377q0" role="status"><!> </p>`),sa=i(`<p class="faint end svelte-17377q0">stopped</p>`),ca=i(`<p class="bad svelte-17377q0" role="alert"> </p>`),la=i(`<article class="turn svelte-17377q0"><div class="you svelte-17377q0"><p class="asked svelte-17377q0"> </p> <!> <span class="from svelte-17377q0"> </span></div> <!> <!> <!></article>`),ua=i(`<p class="title faint svelte-17377q0"> </p>`),da=i(`<p class="faint"> </p>`),fa=i(`<p class="faint">A conversation with the agent, from before isorite attached your own agent: kept to read.</p>`),pa=i(`<div class="chat svelte-17377q0" role="log" aria-label="The agent's session" aria-live="polite"><!> <!> <!> <!> <!> <!></div>`);function ma(i,a){k(a,!0);let s=(t,n=N)=>{var r=Ni(),i=e(r),a=e(i),s=H(a),l=W(s,!0);V(),F(i);var u=H(i,2),f=e(u),p=H(f),m=H(p);F(u),F(r),c(e=>{R(a,`${(o(h)?.agent||`The agent`)??``} wants to `),R(l,e)},[()=>M(n())]),J(`click`,f,()=>void $.reply(n().id,`once`)),J(`click`,p,()=>void $.reply(n().id,`always`)),J(`click`,m,()=>void $.reply(n().id,`reject`)),d(t,r)},l=(t,i=N)=>{var a=p(),l=A(a),f=e=>{var t=Pi();_(t,()=>_e(i().text),!0),F(t),oe(t,(e,t)=>Se?.(e,t),()=>({given:i().text,copy:!0})),d(e,t)},m=t=>{var n=Fi(),r=H(e(n)),a=W(r,!0);F(n),c(()=>R(a,i().text)),d(t,n)},h=t=>{var n=Li(),r=e(n),a=e(r),o=e=>{var t=u(`Summarising the earlier conversation to make room…`);d(e,t)},s=e=>{var t=u();c(()=>R(t,`Could not summarise the earlier conversation${i().error?` (${i().error})`:``}; carrying on with all of it`)),d(e,t)},l=e=>{var t=u();c((e,n)=>R(t,`Earlier conversation summarised: ${e??``} → ${n??``} tokens`),[()=>E(i().before),()=>E(i().after??0)]),d(e,t)};z(a,e=>{i().state===`running`?e(o):i().state===`failed`?e(s,1):e(l,-1)}),F(r);var f=H(r,2),p=e=>{var t=Ii(),n=W(t,!0);c(()=>R(n,i().summary)),d(e,t)};z(f,e=>{i().summary&&e(p)}),F(n),c(()=>j(n,`data-state`,i().state)),d(t,n)},v=t=>{var n=Ri(),r=e(n),a=W(r),o=H(r);F(n),c(()=>{j(n,`data-state`,i().state),j(n,`data-mode`,i().mode),R(a,`${i().mode===`steer`?`steer`:`next`}${i().state===`queued`?` · waiting`:i().state===`dropped`?` · not taken up`:``}`),R(o,` ${i().text??``}`)}),d(t,n)},y=t=>{var n=Hi(),r=e(n),a=H(e(r)),o=e=>{var t=zi(),n=W(t,!0);c(()=>{j(t,`data-to`,i().made),R(n,i().title)}),J(`click`,t,()=>S(`read`,i().made)),d(e,t)},s=e=>{var t=Bi(),n=A(t),r=W(n,!0),a=H(n,2);c(e=>{R(r,i().title),j(a,`aria-label`,`Keep “${i().title??``}” as an open question`),j(a,`title`,`Keep as an open question about ${e??``}`)},[()=>i().about.map(g).join(`, `)]),J(`click`,a,()=>void $.take(i().id)),d(e,t)};z(a,e=>{i().made?e(o):e(s,-1)}),F(r);var l=H(r,2),u=e=>{var t=Vi(),n=W(t,!0);c(()=>R(n,i().text)),d(e,t)};z(l,e=>{i().text&&e(u)}),F(n),c(()=>{j(n,`data-question`,i().id),j(n,`data-to`,i().made??`?${i().id}`)}),d(t,n)},b=t=>{var n=Ki(),r=e(n);_(r,()=>_e(i().text),!0),F(r),oe(r,(e,t)=>Se?.(e,t),()=>i().text);var a=H(r,2),o=e(a),s=e=>{var t=Ui();d(e,t)},l=e=>{var t=zi(),n=W(t,!0);c(e=>{j(t,`data-to`,i().note),R(n,e)},[()=>g(i().note)]),J(`click`,t,()=>S(`read`,i().note)),d(e,t)};z(o,e=>{i().note===`AGENTS.md`?e(s):e(l,-1)});var u=H(o,2),f=e=>{var t=Wi();d(e,t)},p=e=>{var t=Gi();c(e=>j(t,`aria-label`,`Insert into ${e??``} as yours`),[()=>g(i().note)]),J(`click`,t,()=>void $.take(i().id)),d(e,t)};z(u,e=>{i().taken?e(f):e(p,-1)}),F(a),F(n),c(()=>j(n,`data-offer`,i().id)),d(t,n)},x=t=>{var a=ta(),l=e(a),u=t=>{var a=$i(),s=e(a),l=e(s),u=W(l,!0),f=H(l),p=t=>{var n=qi(),r=e(n),a=W(r),o=H(r);F(n),c(e=>{j(n,`href`,e),j(n,`title`,`In ${i().base??``}, in a tab of its own`),R(a,`${i().base??``}:`),R(o,` ${i().note??``}`)},[()=>de(i().base,`#/n/${i().note}`)]),d(t,n)},m=e=>{var t=zi(),n=W(t,!0);c(e=>{j(t,`data-to`,i().note),R(n,e)},[()=>g(i().note)]),J(`click`,t,e=>{e.preventDefault(),S(i().name,i().note)}),d(e,t)},h=e=>{var t=Ji(),n=W(t,!0);c(()=>R(n,i().title)),d(e,t)};z(f,e=>{i().note&&i().base?e(p):i().note?e(m,1):e(h,-1)});var _=H(f),v=t=>{var n=Yi(),r=e(n),a=W(r),o=H(r,2),s=W(o);F(n),c((e,t)=>{R(a,`+${e??``}`),R(s,`−${t??``}`)},[()=>i().diff.filter(e=>e.startsWith(`+`)).length,()=>i().diff.filter(e=>e.startsWith(`-`)).length]),d(t,n)};z(_,e=>{i().diff&&e(v)}),F(s);var y=H(s,2),b=e=>{var t=Zi();r(t,21,()=>i().diff,n,(e,t)=>{var n=Xi();let r;var i=W(n,!0);c((e,a)=>{r=q(n,1,`svelte-17377q0`,null,r,{add:e,del:a}),R(i,o(t))},[()=>o(t).startsWith(`+`),()=>o(t).startsWith(`-`)]),d(e,n)}),F(t),d(e,t)},x=e=>{var t=Qi(),n=W(t,!0);c(()=>R(n,i().output)),d(e,t)};z(y,e=>{i().diff?e(b):e(x,-1)}),F(a),c(e=>R(u,e),[()=>T(i().name)]),d(t,a)},f=t=>{var n=ea(),r=e(n),a=W(r,!0),o=H(r),s=t=>{var n=qi(),r=e(n),a=W(r),o=H(r);F(n),c(e=>{j(n,`href`,e),j(n,`title`,`In ${i().base??``}, in a tab of its own`),R(a,`${i().base??``}:`),R(o,` ${i().note??``}`)},[()=>de(i().base,`#/n/${i().note}`)]),d(t,n)},l=e=>{var t=zi(),n=W(t,!0);c(e=>{j(t,`data-to`,i().note),R(n,e)},[()=>g(i().note)]),J(`click`,t,()=>S(i().name,i().note)),d(e,t)},u=e=>{var t=Ji(),n=W(t,!0);c(()=>R(n,i().title)),d(e,t)};z(o,e=>{i().note&&i().base?e(s):i().note?e(l,1):e(u,-1)}),F(n),c(e=>R(a,e),[()=>T(i().name)]),d(t,n)};z(l,e=>{i().output||i().diff?e(u):e(f,-1)});var p=H(l,2);r(p,17,()=>P(i().id),e=>e.id,(e,t)=>{s(e,()=>o(t))}),F(a),c(()=>j(a,`data-status`,i().status)),d(t,a)};z(l,e=>{i().kind===`text`?e(f):i().kind===`thinking`?e(m,1):i().kind===`compaction`?e(h,2):i().kind===`message`?e(v,3):i().kind===`question`?e(y,4):i().kind===`offer`?e(b,5):e(x,-1)}),d(t,a)},f=(t,i=N)=>{var a=la(),s=e(a),u=e(s),f=W(u,!0),m=H(u,2),_=t=>{var a=ra();r(a,21,()=>i().given,n,(t,n,r)=>{var a=na();let s;var l=e(a),u=W(l,!0),f=H(l),p=W(f,!0);F(a),c((e,t,r)=>{s=q(a,1,`chip svelte-17377q0`,null,s,{out:e}),j(a,`title`,t),j(a,`data-to`,o(n).kind===`note`?o(n).id:void 0),R(u,se[o(n).kind]),R(p,r)},[()=>i().withdrawn?.includes(r),()=>i().withdrawn?.includes(r)?`Taken out of the conversation afterwards: the agent is no longer sent it`:void 0,()=>o(n).kind===`passage`?o(n).text:o(n).kind===`folder`?o(n).id||`the base`:g(o(n).id)]),d(t,a)}),F(a),d(t,a)};z(m,e=>{i().given?.length&&e(_)});var v=H(m,2),y=W(v,!0);F(s);var b=H(s,2);r(b,17,()=>i().items,n,(e,t)=>{var n=p(),r=A(n),a=e=>{l(e,()=>o(t))},s=U(()=>!D(o(t))&&!K(i(),o(t)));z(r,e=>{o(s)&&e(a)}),d(e,n)});var x=H(b,2),S=t=>{var n=aa();r(n,20,()=>re(i()),e=>e,(t,n)=>{var r=ia();let i;var a=H(e(r)),s=W(a,!0),l=H(a,1,!0);F(r),c((e,t)=>{i=q(r,1,`part svelte-17377q0`,null,i,{lit:o(ae)===n}),j(r,`data-to`,n),R(s,e),R(l,t)},[()=>g(n),()=>G(n)]),J(`click`,r,()=>void Z.open(n,!0)),d(t,r)}),F(n),c(()=>j(n,`aria-label`,`What ${(o(h)?.agent||`the agent`)??``} drew on`)),d(t,n)},C=U(()=>i().state!==`running`&&re(i()).length);z(x,e=>{o(C)&&e(S)});var w=H(x,2),T=t=>{var n=oa(),r=e(n),i=e=>{Me(e,{get id(){return o(h).session},size:28,growing:!0})};z(r,e=>{o(h)?.session&&e(i)});var a=H(r);F(n),c(()=>R(a,`${(o(h)?.agent||`The agent`)??``} is at work`)),d(t,n)},E=e=>{var t=sa();d(e,t)},O=e=>{var t=ca(),n=W(t);c(()=>R(n,`The turn failed${$.old?``:`; ${o(h)?.agent||`the agent`} says why in its front end`}.`)),d(e,t)};z(w,e=>{i().state===`running`?e(T):i().state===`stopped`?e(E,1):i().state===`failed`&&e(O,2)}),F(a),c(()=>{j(a,`data-state`,i().state),R(f,i().asked),R(y,$.old?``:i().from===`here`?`from here`:`in its front end`)}),d(t,a)},m=w(void 0),h=U(()=>$.session),g=e=>X.listing.notes.find(t=>t.id===e)?.title??e.split(`/`).at(-1)??e,v={shell:`ran`,bash:`ran`,read:`read`,write:`wrote`,edit:`edited`,glob:`found`,grep:`searched`,webfetch:`fetched`,websearch:`searched the web`,search_notes:`searched`,find_similar:`by meaning`,outline_note:`outlined`,read_note:`read`,brief_base:`looked over`,edit_note:`changed`,write_note:`wrote`},x=new Set([`edit_note`,`write_note`]);function S(e,t){x.has(C(e))&&Z.flip(`provenance`,!0),Z.open(t,!0)}let C=e=>e.replace(/^(mcp_+)?isorite[_:]+/,``),T=e=>v[C(e)]??C(e).replaceAll(`_`,` `),E=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),D=e=>e.kind===`tool`&&/^(ask_question|offer_text)$/.test(C(e.name)),O={shell:`run`,edit:`edit`,write:`write`,read:`read`,webfetch:`fetch`,external_directory:`reach outside the project`},M=e=>`${O[e.action]??e.action} ${e.resources.join(`, `)}`.trim(),P=e=>o(h)?.asking.filter(t=>t.tool===e)??[],I=U(()=>o(h)?.asking.filter(e=>!e.tool||!o(h).turns.some(t=>t.items.some(t=>t.kind===`tool`&&t.id===e.tool)))??[]);b(()=>{o(h),y().then(()=>{o(m)&&(o(m).scrollTop=o(m).scrollHeight)})});function ee(e){if(e.pointerType!==`mouse`||!(e.target instanceof Element))return;let t=e.target.closest(`[data-to], a[href]`),n=t?.dataset.to?{id:t.dataset.to,folder:!1}:t instanceof HTMLAnchorElement?ve(t.getAttribute(`href`)??``):null;Ce.set(`iso`,n?{...n,who:`you`}:null)}let te=/\]\(\/([^)\s]+?)\.md(?:#[^)\s]*)?(?:\s+"[^"]*")?\)/g,ne=e=>X.listing.notes.some(t=>t.id===e);function re(e){let t=new Set;for(let n of e.items)if(n.kind===`text`)for(let e of n.text.matchAll(te))t.add(decodeURI(e[1]));for(let n of e.items)n.kind===`tool`&&n.note&&!n.base&&n.status!==`failed`&&t.add(n.note);return[...t].filter(ne)}let G=e=>X.listing.notes.find(t=>t.id===e)?.dir.split(`/`).at(-1)||`notes`,K=(e,t)=>e.state!==`running`&&t.kind===`tool`&&!!t.note&&!t.base&&!t.diff&&t.status===`done`&&!x.has(C(t.name))&&ne(t.note),ae=U(()=>Ce.elsewhere?.from===`iso`&&!Ce.elsewhere.folder?Ce.elsewhere.id:Ce.onAtlas);b(()=>{let e=o(ae);if(o(h),o(m))for(let t of o(m).querySelectorAll(`.said a.vein`))t.classList.toggle(`lit`,!!e&&ve(t.getAttribute(`href`)??``)?.id===e)});let se={note:`▣`,folder:`▭`,passage:`“`};var ce=pa(),le=e(ce),ue=e=>{var t=ua(),n=W(t,!0);c(()=>R(n,o(h).title)),d(e,t)};z(le,e=>{o(h)?.title&&e(ue)});var fe=H(le,2);r(fe,17,()=>o(h)?.turns??[],e=>e.id,(e,t)=>{f(e,()=>o(t))});var Y=H(fe,2);r(Y,17,()=>o(I),e=>e.id,(e,t)=>{s(e,()=>o(t))});var pe=H(Y,2),me=e=>{var t=da(),n=W(t);c(()=>R(n,`${(o(h)?.agent||`The agent`)??``}'s session shows here: what is asked in its front end or here, what it does, and what it asks before doing. Notes put in the tray go before the next prompt.`)),d(e,t)};z(pe,e=>{o(h)?.turns.length||e(me)});var he=H(pe,2),ge=e=>{var t=fa();d(e,t)},ye=e=>{var t=da(),n=W(t);c(()=>R(n,`Kept here; ${o(h).agent??``} isn't attached to carry it on.`)),d(e,t)};z(he,e=>{$.old?e(ge):o(h)?.reading&&e(ye,1)});var be=H(he,2),xe=e=>{si(e,{})};z(be,e=>{$.connected||e(xe)}),F(ce),B(ce,e=>L(m,e),()=>o(m)),J(`pointerover`,ce,ee),t(`pointerleave`,ce,()=>Ce.set(`iso`,null)),d(i,ce),ie()}h([`click`,`pointerover`]);var ha=i(`<div class="chat svelte-d2jxoz"><!></div>`),ga=i(`<option> </option>`),_a=i(`<label class="set svelte-d2jxoz"><span class="hidden-label"> </span> <select class="field svelte-d2jxoz"></select></label>`),va=i(`<div class="settings svelte-d2jxoz"></div>`),ya=i(`<span class="faint"> </span>`),ba=i(`<li role="option"><button type="button" tabindex="-1"><b class="svelte-d2jxoz"> </b><!> <span class="d svelte-d2jxoz"> </span></button></li>`),xa=i(`<ul class="slash svelte-d2jxoz" role="listbox" aria-label="Slash commands"></ul>`),Sa=i(`<li><span class="g svelte-d2jxoz" aria-hidden="true"> </span> <span class="t svelte-d2jxoz"> </span> <button type="button" class="x svelte-d2jxoz"><svg viewBox="0 0 16 16" width="10" height="10" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M4 4l8 8M12 4l-8 8"></path></svg></button></li>`),Ca=i(`<span class="bad svelte-d2jxoz" role="alert"> </span>`),wa=i(`<ul class="chips svelte-d2jxoz" aria-label="Going with your message"></ul> <p class="handoff svelte-d2jxoz"><button type="button" class="more svelte-d2jxoz" title="Text that names these for an agent running in your own terminal, to paste there. It reads them through isorite's tools."> </button> <!></p>`,1),Ta=i(`<button class="corner stop svelte-d2jxoz" type="button" aria-label="Stop the agent" title="Stop (Escape)"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><rect x="4" y="4" width="8" height="8" fill="currentColor"></rect></svg></button>`),Ea=i(`<button class="corner send svelte-d2jxoz" type="button" aria-label="Send" title="Send (Enter)"><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M3 8h10M9 4l4 4-4 4"></path></svg></button>`),Da=i(`<button type="button" class="more svelte-d2jxoz" title="Put it in after the step running now (Ctrl+Enter)">Steer now</button>`),Oa=i(`<p class="mid svelte-d2jxoz">Enter adds it for when the agent stops.<!></p>`),ka=i(`<p class="bad svelte-d2jxoz" role="alert"> </p>`),Aa=i(`<div><!> <div class="composer svelte-d2jxoz"><!> <!> <!> <div class="box svelte-d2jxoz"><label class="hidden-label" for="iso-box">Message the agent</label> <textarea id="iso-box" rows="2" class="svelte-d2jxoz"></textarea> <!></div> <!> <!></div></div>`);function ja(t,n){k(n,!0);let i=w(``),a=w(re(new Set)),s=U(()=>$.view?.session??null);b(()=>{o(s),L(a,new Set,!0)});let l=U(()=>$.old?[]:Q.sent),u=w(!1),f=w(``);async function p(){L(f,``);try{await navigator.clipboard.writeText(kr(Q.sent,o(i))),L(u,!0),setTimeout(()=>{L(u,!1)},1500)}catch{L(f,`The browser would not copy.`)}}let m=(e,t=44)=>e.length>t?`${e.slice(0,t).trimEnd()}…`:e,h=U(()=>$.running),g=U(()=>!!$.old||$.acp);ee(()=>{$.start()}),b(()=>{Q.sent,$.view?.session,$.acp&&$.give()});let _=U(()=>$.view?.commands??[]),v=U(()=>$.view?.settings??[]),y=U(()=>/^\/(\S*)$/.exec(o(i))),x=U(()=>o(y)&&!$.old?o(_).filter(e=>e.name.startsWith(o(y)[1]??``)):[]),C=w(0);b(()=>{o(x).length,L(C,0)});function T(e=o(C)){let t=o(x)[e];t&&L(i,`/${t.name} `)}async function E(){let e=Q.sent.map(Q.keyOf);await $.steer(o(i))&&(L(i,``),L(a,new Set([...o(a),...e]),!0))}async function O(){let e=Q.sent.map(Q.keyOf);await $.send(o(i))&&(L(i,``),L(a,new Set([...o(a),...e]),!0))}function N(e){if(o(x).length&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),L(C,(o(C)+(e.key===`ArrowDown`?1:o(x).length-1))%o(x).length);return}if(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey&&o(i)!==`/${o(x)[o(C)]?.name}`){e.preventDefault(),T();return}if(e.key===`Escape`){e.preventDefault(),L(i,``);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&$.canSteer&&!e.isComposing?(e.preventDefault(),E()):e.key===`Enter`&&!e.shiftKey&&!e.isComposing?(e.preventDefault(),O()):e.key===`Escape`&&o(h)&&(e.preventDefault(),$.stop())}var P=Aa();let I;var B=e(P),V=e=>{Mi(e,{})},te=e=>{yi(e,{})},ne=e=>{ma(e,{})},K=t=>{var n=ha();si(e(n),{}),F(n),d(t,n)};z(B,e=>{$.shown===`context`?e(V):$.shown===`past`?e(te,1):o(g)?e(ne,2):e(K,-1)});var ae=H(B,2),oe=e(ae),se=t=>{var n=va();r(n,21,()=>o(v),e=>`${e.kind}:${e.id}`,(t,n)=>{var i=_a(),a=e(i),s=W(a,!0),l=H(a,2);r(l,21,()=>o(n).options,e=>e.value,(e,t)=>{var r=ga(),i=W(r),a={};c(()=>{j(r,`title`,o(t).description),R(i,`${o(n).kind===`mode`?``:`${o(n).name}: `}${o(t).name??``}`),a!==(a=o(t).value)&&(r.value=(r.__value=a)??``)}),d(e,r)}),F(l);var u;M(l),F(i),c(()=>{R(s,o(n).name),j(l,`aria-label`,o(n).name),j(l,`title`,o(n).name),u!==(u=o(n).current)&&(l.value=(l.__value=u)??``,S(l,u))}),J(`change`,l,e=>void $.set(o(n).kind,o(n).id,e.currentTarget.value)),d(t,i)}),F(n),d(t,n)};z(oe,e=>{o(v).length&&$.connected&&!$.old&&e(se)});var ce=H(oe,2),le=t=>{var n=xa();r(n,23,()=>o(x),e=>e.name,(t,n,r)=>{var i=ba(),a=e(i);let s;var l=e(a),u=W(l),f=H(l),p=e=>{var t=ya(),r=W(t,!0);c(()=>R(r,o(n).hint)),d(e,t)};z(f,e=>{o(n).hint&&e(p)});var m=H(f,2),h=W(m,!0);F(a),F(i),c(()=>{j(i,`aria-selected`,o(r)===o(C)),s=q(a,1,`svelte-d2jxoz`,null,s,{on:o(r)===o(C)}),R(u,`/${o(n).name??``}`),R(h,o(n).description)}),J(`mousedown`,a,e=>{e.preventDefault(),T(o(r))}),d(t,i)}),F(n),d(t,n)};z(ce,e=>{o(x).length&&e(le)});var ue=H(ce,2),de=t=>{var n=wa(),i=A(n);r(i,21,()=>o(l),e=>Q.keyOf(e),(t,n)=>{var r=Sa();let i;var s=e(r),l=W(s,!0),u=H(s,2),f=W(u,!0),p=H(u,2);F(r),c((e,t,a)=>{i=q(r,1,`chip svelte-d2jxoz`,null,i,{given:e}),j(r,`data-kind`,o(n).kind),j(r,`title`,t),R(l,o(n).kind===`passage`?`❝`:o(n).kind===`folder`?`▤`:`◆`),R(f,a),j(p,`aria-label`,`Remove ${(o(n).kind===`passage`?`the passage from ${o(n).title}`:o(n).title)??``} from the message`)},[()=>o(a).has(Q.keyOf(o(n))),()=>o(a).has(Q.keyOf(o(n)))?`Already given to this session`:`Goes before your next message`,()=>o(n).kind===`passage`?`${o(n).title}: “${m(o(n).text)}”`:o(n).title]),J(`click`,p,()=>Q.remove(o(n))),d(t,r)}),F(i);var s=H(i,2),h=e(s),g=W(h,!0),_=H(h,2),v=e=>{var t=Ca(),n=W(t,!0);c(()=>R(n,o(f))),d(e,t)};z(_,e=>{o(f)&&e(v)}),F(s),c(()=>R(g,o(u)?`Copied`:`Copy for your agent`)),J(`click`,h,()=>void p()),d(t,n)};z(ue,e=>{o(l).length&&e(de)});var fe=H(ue,2),Y=H(e(fe),2);D(Y);var X=H(Y,2),pe=e=>{var t=Ta();J(`click`,t,()=>void $.stop()),d(e,t)},me=e=>{var t=Ea();J(`click`,t,()=>void O()),d(e,t)},he=U(()=>o(i).trim());z(X,e=>{o(h)?e(pe):o(he)&&e(me,1)}),F(fe);var ge=H(fe,2),_e=t=>{var n=Oa(),r=H(e(n)),i=e=>{var t=Da();J(`click`,t,()=>void E()),d(e,t)};z(r,e=>{$.canSteer&&e(i)}),F(n),d(t,n)},ve=U(()=>o(h)&&o(i).trim());z(ge,e=>{o(ve)&&e(_e)});var ye=H(ge,2),be=e=>{var t=ka(),n=W(t,!0);c(()=>R(n,$.problem||$.view?.problem)),d(e,t)};z(ye,e=>{($.problem||$.view?.problem)&&e(be)}),F(ae),F(P),c(()=>{I=q(P,1,`iso svelte-d2jxoz`,null,I,{drop:Q.carrying?.over}),j(Y,`placeholder`,$.connected?`Ask ${$.view?.agent||`the agent`}`:`Attach an agent to ask it here`)}),J(`keydown`,Y,N),G(Y,()=>o(i),e=>L(i,e)),d(t,P),ie()}h([`change`,`mousedown`,`click`,`keydown`]);var Ma=i(`<input class="field name svelte-1wk2ip3" maxlength="60"/>`),Na=i(`<a data-sveltekit-reload="" class="svelte-1wk2ip3"> </a>`),Pa=i(`<li><i class="tick svelte-1wk2ip3" aria-hidden="true"> </i> <!> <button class="lend rename svelte-1wk2ip3" type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"><path d="M3 13l.6-2.8L11 2.8l2.2 2.2-7.4 7.4z"></path></svg></button> <button class="lend svelte-1wk2ip3" type="button" aria-label="Lent to every session"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"><rect x="2.5" y="5.5" width="7" height="8"></rect><path d="M6.5 5.5V2.5h7v8h-4"></path></svg></button></li>`),Fa=i(`<p class="bad svelte-1wk2ip3" role="alert"> </p>`),Ia=i(`<div class="frame bases svelte-1wk2ip3" role="dialog" aria-label="Knowledge bases" tabindex="-1"><span class="frame-title">bases</span> <ul class="svelte-1wk2ip3"></ul> <!></div>`),La=i(`<button class="base svelte-1wk2ip3" type="button" aria-haspopup="true" title="The knowledge bases: switch to another"> </button> <span class="slash svelte-1wk2ip3" aria-hidden="true">/</span> <!>`,1);function Ra(n,i){k(i,!0);let a=X.api?.bases??null,s=w(!1),l=w([]),u=w(``),f=w(!1),h=w(``),g=w(void 0),_=w(void 0),v=w(re({top:0,left:0}));async function y(){if(a)try{await(async e=>{L(l,e.bases),L(u,e.here,!0),L(f,e.local,!0)})(await a.list()),L(h,``)}catch(e){L(h,e.message,!0)}}y();async function b(){if(L(s,!o(s)),o(s)&&o(_)){let e=o(_).getBoundingClientRect();L(v,{top:e.bottom+14,left:Math.max(8,e.left-8)},!0)}o(s)&&(await y(),o(g)?.querySelector(`a`)?.focus())}let x=w(``),S=w(``);async function C(e){let t=e.name;L(x,``);try{L(l,await a.title(t,o(S))),L(h,``)}catch(e){L(h,e.message,!0)}}let T=U(()=>o(l).find(e=>e.name===(o(u)||X.session?.name))?.title||X.session?.name||``);async function E(e){try{L(l,await a.lend(e.name,!e.lend)),L(h,``)}catch(e){L(h,e.message,!0)}}function D(e){o(s)&&e.target instanceof Node&&!o(g)?.contains(e.target)&&!o(_)?.contains(e.target)&&L(s,!1)}function M(e){o(s)&&e.key===`Escape`&&(L(s,!1),o(_)?.focus())}var N=p();t(`pointerdown`,m,D),t(`keydown`,m,M);var P=A(N),I=t=>{var n=La(),i=A(n),a=W(i,!0);B(i,e=>L(_,e),()=>o(_));var p=H(i,4),m=t=>{var n=Ia();let i;var a=H(e(n),2);r(a,21,()=>o(l),e=>e.name,(t,n)=>{let r=U(()=>o(n).name===(o(u)||X.session.name));var i=Pa();let a;var s=e(i),l=W(s,!0),p=H(s,2),m=e=>{var t=Ma();O(t),c(()=>{j(t,`aria-label`,`A title for ${o(n).name??``}`),j(t,`placeholder`,o(n).name)}),J(`keydown`,t,e=>{e.key===`Enter`?C(o(n)):e.key===`Escape`&&(e.stopPropagation(),L(x,``))}),G(t,()=>o(S),e=>L(S,e)),d(e,t)},h=e=>{var t=Na(),i=W(t,!0);c(e=>{j(t,`href`,e),j(t,`title`,o(n).title===o(n).name?o(n).path:`${o(n).name}: ${o(n).path}`),j(t,`aria-current`,o(r)?`page`:void 0),R(i,o(n).title)},[()=>de(o(n).name)]),d(e,t)};z(p,e=>{o(x)===o(n).name?e(m):e(h,-1)});var g=H(p,2),_=H(g,2);F(i),c(()=>{a=q(i,1,`svelte-1wk2ip3`,null,a,{here:o(r)}),R(l,o(r)?`✓`:``),g.disabled=!o(f),j(g,`aria-label`,`Rename ${o(n).title??``}`),j(g,`title`,o(f)?`Show it by another title: its address stays the same`:`Renamed only from this machine`),j(_,`aria-pressed`,o(n).lend),_.disabled=!o(f),j(_,`title`,o(f)?o(n).lend?`Lent to every session's agent: press to keep it to itself`:`Lend it to every session's agent, as the agent's memory is`:`Lent or not is changed only from this machine`)}),J(`click`,g,()=>{o(x)===o(n).name?C(o(n)):(L(S,o(n).title===o(n).name?``:o(n).title,!0),L(x,o(n).name,!0))}),J(`click`,_,()=>E(o(n))),d(t,i)}),F(a);var s=H(a,2),p=e=>{var t=Fa(),n=W(t,!0);c(()=>R(n,o(h))),d(e,t)};z(s,e=>{o(h)&&e(p)}),F(n),B(n,e=>L(g,e),()=>o(g)),c(()=>i=K(n,``,i,{top:`${o(v).top??``}px`,left:`${o(v).left??``}px`})),d(t,n)};z(p,e=>{o(s)&&e(m)}),c(()=>{j(i,`aria-expanded`,o(s)),R(a,o(T))}),J(`click`,i,b),d(t,n)};z(P,e=>{a&&X.session&&e(I)}),d(n,N),ie()}h([`click`,`keydown`]);var za=s(`<rect x="2.5" y="2.5" width="11" height="11"></rect><path d="M8 2.5v11"></path><rect x="8.6" y="3.1" width="4.3" height="9.8" fill="currentColor" stroke="none"></rect>`,1),Ba=s(`<path d="M8 1v14" stroke-width="1.2"></path><rect x="5.5" y="2" width="5" height="3.2" fill="currentColor" stroke="none"></rect><path d="M8 6.3l2.3 2.3L8 10.9 5.7 8.6z" fill="currentColor" stroke="none"></path><rect x="5.5" y="12" width="5" height="3" stroke-width="1.2"></rect>`,1),Va=s(`<rect x="2.5" y="2.5" width="11" height="2.5" fill="currentColor" stroke="none"></rect><rect x="2.5" y="6.75" width="7" height="2.5" fill="currentColor" stroke="none"></rect><rect x="2.5" y="11" width="9" height="2.5" fill="currentColor" stroke="none"></rect>`,1),Ha=s(`<path d="M2.5 13.5l2.5-2.5M5 11c.6-4.2 3.6-7.4 8.5-8.5C12.6 7.2 9.4 10.4 5 11zM7.2 8.8l2.6-.3M8.8 6.6l2.4-.4"></path>`),Ua=s(`<path d="M3.5 2.5h5.5l3.5 3.5v7.5h-9z"></path><path d="M9 2.5V6h3.5"></path>`,1),Wa=s(`<path d="M3 4.5l3 3.5-3 3.5M7.5 12h5.5"></path>`),Ga=s(`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square" stroke-linejoin="miter"><!></svg>`),Ka=i(`<span class="lbl svelte-ubc5lw" aria-hidden="true"> </span>`),qa=i(`<button type="button" class="sw svelte-ubc5lw"><!> <!></button>`),Ja=i(`<button class="icon gear svelte-ubc5lw" type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3"><path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"></path><rect x="9" y="3" width="2.5" height="3" fill="var(--ground-0)"></rect><rect x="4.5" y="6.5" width="2.5" height="3" fill="var(--ground-0)"></rect><rect x="10" y="10" width="2.5" height="3" fill="var(--ground-0)"></rect></svg></button>`),Ya=i(`<div class="frame settings svelte-ubc5lw" role="dialog" tabindex="-1"><span class="frame-title"> </span> <div class="inner svelte-ubc5lw"><!></div></div>`),Xa=i(`<header><!> <span class="pname svelte-ubc5lw"> </span> <span class="switches svelte-ubc5lw" role="group"></span> <span class="grow svelte-ubc5lw"></span> <!> <!></header> <!>`,1);function Za(n,i){k(i,!0);let a={questions:`question`,problems:`problem`,web:`web`,code:`code`,pictures:`image`,artifacts:`artifact`},s=I(i,`first`,3,!1),l={provenance:`Provenance: whose words are whose (Alt+P)`,timeline:`Timeline (Alt+T)`,context:`The agent's context: what it was given, what it read and changed (Alt+C)`,questions:`Open questions (Alt+Q)`,problems:`Problems (Alt+B)`,web:`Links to the web (Alt+W)`,code:`Links to code (Alt+K)`,pictures:`Pictures, data and other files beside the notes (Alt+I)`,artifacts:`Artifacts beside the notes (Alt+A)`,notes:`Agents may edit the notes (Alt+N)`,files:`The agent may edit the project's files (Alt+F)`,run:`The agent may run commands (Alt+R)`},u={questions:`questions`,problems:`problems`,web:`web`,code:`code`,pictures:`files`,artifacts:`artifacts`,context:`context`},f={provenance:`growth`,timeline:`lattice`,questions:`rose`,problems:`text`,web:`lattice`,code:`lattice`,pictures:`lattice`,artifacts:`lattice`,context:`growth`,notes:`growth`,files:`growth`,run:`growth`},p=U(()=>Ee[i.pane].filter(e=>e!==`files`&&e!==`run`||Z.attached)),h=U(()=>Z.settings===i.pane),g=w(void 0);b(()=>{o(h)&&o(g)?.focus()});function _(e){o(h)&&e.target instanceof Element&&(o(g)?.contains(e.target)||e.target.closest(`[data-settings="${i.pane}"]`)||(Z.settings=null))}var v=Xa();t(`pointerdown`,m,_),t(`keydown`,m,e=>{o(h)&&e.key===`Escape`&&(Z.settings=null)});var y=A(v);let x;var S=e(y),C=e=>{Ra(e,{})};z(S,e=>{s()&&e(C)});var T=H(S,2),E=W(T,!0),D=H(T,2);r(D,20,()=>o(p),e=>e,(t,n)=>{var r=qa();let i;var o=e(r),s=e=>{xe(e,{get kind(){return a[n]},size:16})},p=t=>{var r=Ga(),i=e(r),a=e=>{var t=za();V(2),d(e,t)},o=e=>{var t=Ba();V(3),d(e,t)},s=e=>{var t=Va();V(2),d(e,t)},c=e=>{var t=Ha();d(e,t)},l=e=>{var t=Ua();V(),d(e,t)},u=e=>{var t=Wa();d(e,t)};z(i,e=>{n===`provenance`?e(a):n===`timeline`?e(o,1):n===`context`?e(s,2):n===`notes`?e(c,3):n===`files`?e(l,4):e(u,-1)}),F(r),d(t,r)};z(o,e=>{a[n]?e(s):e(p,-1)});var m=H(o,2),h=e=>{var t=Ka(),r=W(t,!0);c(()=>R(r,u[n])),d(e,t)};z(m,e=>{u[n]&&e(h)}),F(r),c(e=>{j(r,`data-switch`,n),j(r,`aria-pressed`,Z.on[n]),j(r,`aria-label`,e),j(r,`title`,l[n]),i=K(r,``,i,{"--c":`var(--${f[n]??``})`})},[()=>l[n].replace(/ \(Alt\+.\)$/,``)]),J(`click`,r,()=>Z.flip(n)),d(t,r)}),F(D);var O=H(D,4);ae(O,()=>i.tools??N);var M=H(O,2),P=e=>{var t=Ja();c(()=>{j(t,`data-settings`,i.pane),j(t,`aria-label`,`${i.name??``} settings`),j(t,`aria-expanded`,o(h)),j(t,`title`,`${i.name??``} settings`)}),J(`click`,t,()=>Z.settings=o(h)?null:i.pane),d(e,t)};z(M,e=>{i.settings&&e(P)}),F(y);var ee=H(y,2),te=t=>{var n=Ya(),r=e(n),a=W(r,!0),s=H(r,2),l=e(s);ae(l,()=>i.settings),F(s),F(n),B(n,e=>L(g,e),()=>o(g)),c(e=>{j(n,`aria-label`,`${i.name??``} settings`),R(a,e)},[()=>i.name.toLowerCase()]),d(t,n)};z(ee,e=>{i.settings&&o(h)&&e(te)}),c(()=>{x=q(y,1,`phead svelte-ubc5lw`,null,x,{named:i.pane===`atlas`}),R(E,i.name),j(D,`aria-label`,`${i.name??``}'s switches`)}),d(n,v),ie()}h([`click`]);var Qa=i(`<button type="button" class="gauge svelte-1cyuk5c"><i></i></button>`);function $a(t,n){k(n,!0);let r=e=>e>=1e3?`${(e/1e3).toFixed(e>=1e5?0:1)}k`:String(e),i=e=>`$${e.toFixed(e>0&&e<.1?3:2)}`,a=U(()=>$.session),s=U(()=>o(a)?.size?{tokens:o(a).tokens.input,limit:o(a).size}:null),l=U(()=>o(s)?Math.min(1,o(s).tokens/o(s).limit):0),u=U(()=>!!o(s)&&o(s).tokens>=Math.min(1e5,o(s).limit/2)),f=U(()=>!!o(s)&&o(s).tokens>o(s).limit),p=U(()=>o(a)?o(a).size?`${o(a).agent}: ${r(o(a).tokens.input)} of ${r(o(a).size)} tokens${o(a).cost?`, ${i(o(a).cost)}`:``}${o(u)?`: long enough to drift`:``}`:`${o(a).agent||`The agent`} hasn't said how full its context is`:`Context: no agent attached`);var m=Qa(),h=e(m);let g,_;F(m),c(()=>{j(m,`aria-label`,o(p)),j(m,`title`,o(p)),g=q(h,1,`bar ctx svelte-1cyuk5c`,null,g,{long:o(u),full:o(f)}),_=K(h,``,_,{"--fill":o(l)})}),J(`click`,m,()=>$.shown=$.shown===`context`?`session`:`context`),d(t,m),ie()}h([`click`]);var eo=i(`<h2 class="label svelte-1c4xnzk">AGENTS.md</h2> <label class="hidden-label" for="agents">AGENTS.md: your instructions for this base</label> <textarea id="agents" class="agents svelte-1c4xnzk" rows="6" spellcheck="true" placeholder="notation, level, language, how notes are named" title="Your instructions for this base, read by the agents you attach. Kept at the top of your notes, as AGENTS.md."></textarea>`,1),to=i(`<p class="note svelte-1c4xnzk"> </p>`),no=i(`<option> </option>`),ro=i(`<p class="note svelte-1c4xnzk" role="status"> </p>`),io=i(`<h2 class="label svelte-1c4xnzk">Model for isorite's own agent</h2> <p class="note svelte-1c4xnzk">Used when the pane runs isorite's own agent rather than one of yours. Keys are kept in isorite's data folder, readable only by you, never in your notes or repository.</p> <!> <label class="hidden-label" for="pi-provider">Provider</label> <select id="pi-provider" class="svelte-1c4xnzk"></select> <p class="note svelte-1c4xnzk" data-testid="pi-key-state"><!></p> <label class="hidden-label" for="pi-key">Key for this provider</label> <input id="pi-key" type="password" autocomplete="off" spellcheck="false" placeholder="paste a key" class="svelte-1c4xnzk"/> <div class="row svelte-1c4xnzk"><button type="button">Keep key</button> <button type="button">Remove key</button></div> <label class="hidden-label" for="pi-model">Model</label> <input id="pi-model" type="text" spellcheck="false" class="svelte-1c4xnzk"/> <div class="row svelte-1c4xnzk"><button type="button">Use this model</button></div> <h2 class="label svelte-1c4xnzk">What it may do in your project</h2> <p class="note svelte-1c4xnzk">Its tools for your notes are always on. These are for the project's files, which it does not need to manage the knowledge base.<!></p> <fieldset class="svelte-1c4xnzk"><legend class="hidden-label">Project files</legend> <label><input type="radio" name="pi-files" class="svelte-1c4xnzk"/> No project files</label> <label><input type="radio" name="pi-files" class="svelte-1c4xnzk"/> Read files</label> <p class="note svelte-1c4xnzk">Reads, searches and lists files inside the project folder. It can see everything there that you can, including files that hold secrets. It cannot change anything.</p> <label><input type="radio" name="pi-files" class="svelte-1c4xnzk"/> Read and write files</label> <p class="note svelte-1c4xnzk">Also edits and creates files inside the project folder, never in .git. It changes your files directly: keep the project in version control.</p> <label><input type="checkbox" class="svelte-1c4xnzk"/> Run shell commands</label> <p class="note warn svelte-1c4xnzk">A shell is not confined. A command runs as you and can read or change any file you can, use the network, and reach outside the project folder; the checks on file paths do not apply to it. To confine it, run isorite inside a container or a disposable virtual machine, or under a separate user account that has only the project; or leave it off.</p></fieldset> <!>`,1),ao=i(`<p class="bad svelte-1c4xnzk" role="alert"> </p>`),oo=i(`<section class="svelte-1c4xnzk"><!> <!> <!></section>`);function so(n,i){k(i,!0);let a=w(``),s=w(null),l=``;b(()=>{X.api.agents().then(e=>{L(s,e.text??``,!0),l=o(s)},()=>void 0)});async function f(){if(o(s)!==null&&o(s)!==l){L(a,``);try{await X.api.saveAgents(o(s)),l=o(s)}catch(e){L(a,e.message,!0)}}}let p=X.api?.pi??null,m=[`localhost`,`127.0.0.1`,`[::1]`].includes(location.hostname),h=w(null),g=w(`openrouter`),_=w(``),v=w(``),y=w(``);async function x(){if(p&&m)try{L(h,await p.state())}catch{L(h,null)}}b(()=>{x()}),b(()=>{o(h)?.choice&&(L(g,o(h).choice.provider,!0),L(_,o(h).choice.model,!0))});async function S(e,t){L(a,``),L(y,``);try{await e(),L(y,t,!0),await x()}catch(e){L(a,e.message,!0)}}let C=()=>S(async()=>{await p.setKey(o(g),o(v)),L(v,``)},`Key kept. The next turn uses it.`),T=()=>S(()=>p.removeKey(o(g)),`Key removed.`),E=(e,t)=>S(()=>p.setReach(e,t),`Saved. The next question uses it.`),N=()=>S(()=>p.choose(o(g),o(_)),o(h)?.active?`Model chosen. The next turn uses it.`:`Model chosen. Restart isorite for the pane to use it.`);var I=oo(),B=e(I),ee=e=>{var n=eo(),r=H(A(n),4);D(r),t(`blur`,r,()=>void f()),G(r,()=>o(s),e=>L(s,e)),d(e,n)};z(B,e=>{o(s)!==null&&e(ee)});var U=H(B,2),ne=t=>{var n=io(),i=H(A(n),4),a=e=>{var t=to(),n=W(t);c(()=>R(n,`ISORITE_PI names the model (${o(h).choice?.provider??``}/${o(h).choice?.model??``}) and wins while it is set.`)),d(e,t)};z(i,e=>{o(h).source===`environment`&&e(a)});var s=H(i,4);r(s,21,()=>o(h).providers,e=>e.id,(e,t)=>{var n=no(),r=W(n),i={};c(()=>{R(r,`${o(t).name??``}${o(h).keys[o(t).id]?` ✓`:``}`),i!==(i=o(t).id)&&(n.value=(n.__value=i)??``)}),d(e,n)}),F(s),M(s);var l=H(s,2),f=e(l),p=e=>{var t=u(`A key is saved.`);d(e,t)},m=e=>{var t=u();c(e=>R(t,`Using the key in ${e??``}.`),[()=>o(h).providers.find(e=>e.id===o(g))?.env]),d(e,t)},b=e=>{var t=u(`No key is set.`);d(e,t)};z(f,e=>{o(h).keys[o(g)]===`saved`?e(p):o(h).keys[o(g)]===`environment`?e(m,1):e(b,-1)}),F(l);var x=H(l,4);O(x);var S=H(x,2),w=e(S),D=H(w,2);F(S);var k=H(S,4);O(k);var I=H(k,2),B=W(I),ee=H(I,4),U=H(e(ee)),ne=e=>{var t=u(`ISORITE_PI_FILES or ISORITE_PI_SHELL sets this and wins while it is set.`);d(e,t)};z(U,e=>{o(h).reachFromEnvironment&&e(ne)}),F(ee);var re=H(ee,2),ie=H(e(re),2),K=e(ie);O(K),V(),F(ie);var ae=H(ie,2),oe=e(ae);O(oe),V(),F(ae);var q=H(ae,4),se=e(q);O(se),V(),F(q);var ce=H(q,4),le=e(ce);O(le),V(),F(ce),V(2),F(re);var ue=H(re,2),de=e=>{var t=ro(),n=W(t,!0);c(()=>R(n,o(y))),d(e,t)};z(ue,e=>{o(y)&&e(de)}),c((e,t)=>{w.disabled=e,D.disabled=o(h).keys[o(g)]!==`saved`,j(k,`placeholder`,o(g)===`openrouter`?`anthropic/claude-haiku-5.5`:`model name`),B.disabled=t,re.disabled=o(h).reachFromEnvironment,te(K,o(h).reach.files===`off`),te(oe,o(h).reach.files===`read`),te(se,o(h).reach.files===`write`),te(le,o(h).reach.shell)},[()=>!o(v).trim(),()=>!o(_).trim()]),P(s,()=>o(g),e=>L(g,e)),G(x,()=>o(v),e=>L(v,e)),J(`click`,w,()=>void C()),J(`click`,D,()=>void T()),G(k,()=>o(_),e=>L(_,e)),J(`click`,B,()=>void N()),J(`change`,K,()=>void E(`off`,o(h).reach.shell)),J(`change`,oe,()=>void E(`read`,o(h).reach.shell)),J(`change`,se,()=>void E(`write`,o(h).reach.shell)),J(`change`,le,e=>void E(o(h).reach.files,e.currentTarget.checked)),d(t,n)};z(U,e=>{o(h)&&e(ne)});var re=H(U,2),K=e=>{var t=ao(),n=W(t,!0);c(()=>R(n,o(a))),d(e,t)};z(re,e=>{o(a)&&e(K)}),F(I),d(n,I),ie()}h([`click`,`change`]);var co=i(`<button class="btn quiet danger-text svelte-1h9x2hz" type="button">Delete it</button>`),lo=i(`<div class="ask svelte-1h9x2hz" role="alertdialog" aria-label="delete this note"><span>Delete this note? <!> Its history stays.</span> <div class="row svelte-1h9x2hz"><button class="btn danger" type="button">delete</button> <button class="btn quiet" type="button">keep it</button></div></div>`),uo=i(`<p class="problem svelte-1h9x2hz" role="alert"> </p>`),fo=i(`<section class="svelte-1h9x2hz"><h2 class="label svelte-1h9x2hz">this note</h2> <div class="row svelte-1h9x2hz"><button class="btn" type="button">A question about it</button> <button class="btn" type="button">A problem using it</button> <!></div> <!> <!></section>`),po=i(`<section class="svelte-1h9x2hz"><h2 class="label svelte-1h9x2hz">the base</h2> <p><span class="name svelte-1h9x2hz"> </span> <span class="faint"> </span></p> <!></section>`),mo=i(`<button type="button" role="radio"> </button>`),ho=i(`<button type="button">fullscreen</button>`),go=s(`<path d="M5.8 2.5v11M10.2 2.5v11"></path>`),_o=s(`<path d="M8 2.5v11M8 8h6.5"></path>`),vo=i(`<button class="icon svelte-1h9x2hz" type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3"><rect x="1.5" y="2.5" width="13" height="11"></rect><!></svg></button>`),yo=s(`<path d="M4 2.5h6l2.5 2.5v8.5H4zM6 7h5M6 9.5h5"></path>`),bo=s(`<rect x="2" y="2.5" width="5" height="4"></rect><rect x="9" y="9.5" width="5" height="4"></rect><path d="M4.5 6.5v5H9"></path>`,1),xo=s(`<path d="M8 2.5l5.5 5.5L8 13.5 2.5 8z"></path>`),So=i(`<button type="button"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3"><!></svg></button>`),Co=i(`<span class="icons svelte-1h9x2hz" role="group" aria-label="Layout"></span> <span class="icons svelte-1h9x2hz" role="group" aria-label="Panes shown"></span>`,1),wo=i(`<section class="svelte-1h9x2hz"><h2 class="label svelte-1h9x2hz">the screen</h2> <div class="row svelte-1h9x2hz"><!> <!></div></section>`),To=i(`<!> <!> <section class="svelte-1h9x2hz"><h2 class="label svelte-1h9x2hz">the ground</h2> <div class="row svelte-1h9x2hz" role="radiogroup" aria-label="Ground"></div></section> <section class="svelte-1h9x2hz"><h2 class="label svelte-1h9x2hz">the code</h2> <div class="row svelte-1h9x2hz" role="radiogroup" aria-label="Code"></div></section> <!> <p class="foot svelte-1h9x2hz"><a>the parts</a></p>`,1);function Eo(t,n){k(n,!0);let i={note:`Note`,atlas:`Atlas`,iso:`Agent`},a={cols:`Three columns`,stack:`The note beside the Atlas over the agent`,one:`One pane: the one in focus`},s=w(!1),l=w(!1);ee(()=>{L(s,!!document.fullscreenEnabled&&!matchMedia(`(display-mode: standalone)`).matches,!0);let e=()=>{L(l,document.fullscreenElement!==null)};return e(),document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)}),w(!1);let f=w(null),p=w(``);async function m(e){L(p,``);try{let t=await X.api.map();L(f,[...new Set(t.model.edges.filter(([t,n])=>n===e&&t!==e&&!t.startsWith(`@`)).map(([e])=>t.notes[e]?.title||e))],!0)}catch(e){L(p,e.message,!0)}}async function h(e){try{await X.api.deleteNote(e,(await X.api.readNote(e)).version),L(f,null),Z.settings=null,await X.refresh(),await le(ce(`/notes`),{replaceState:!0})}catch(e){L(p,e.message,!0),L(f,null)}}function g(){document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen().catch(()=>void 0)}var _=To(),v=A(_),y=t=>{let n=U(()=>X.open);var r=fo(),i=H(e(r),2),a=e(i),s=H(a,2),l=H(s,2),g=e=>{var t=co();J(`click`,t,()=>void m(o(n))),d(e,t)},_=U(()=>o(f)===null&&X.listing.notes.some(e=>e.id===o(n)));z(l,e=>{o(_)&&e(g)}),F(i);var v=H(i,2),y=t=>{var r=lo(),i=e(r),a=H(e(i)),s=e=>{var t=u();c(e=>R(t,`${o(f).length===1?`One note links`:`${o(f).length} notes link`} to it (${e??``}); ${o(f).length===1?`its link is`:`their links are`} left broken.`),[()=>o(f).join(`, `)]),d(e,t)},l=e=>{var t=u(`No note links to it.`);d(e,t)};z(a,e=>{o(f).length?e(s):e(l,-1)}),V(),F(i);var p=H(i,2),m=e(p),g=H(m,2);F(p),F(r),J(`click`,m,()=>void h(o(n))),J(`click`,g,()=>{L(f,null)}),d(t,r)};z(v,e=>{o(f)!==null&&e(y)});var b=H(v,2),x=e=>{var t=uo(),n=W(t,!0);c(()=>R(n,o(p))),d(e,t)};z(b,e=>{o(p)&&e(x)}),F(r),J(`click`,a,()=>{Z.settings=null,Be(`question`,o(n))}),J(`click`,s,()=>{Z.settings=null,Be(`problem`,o(n))}),d(t,r)},b=U(()=>X.open&&!X.open.startsWith(`@`));z(v,e=>{o(b)&&e(y)});var x=H(v,2),S=t=>{var n=po(),r=H(e(n),2),i=e(r),a=W(i,!0),o=H(i,2),s=W(o);F(r);var l=H(r,2);z(l,e=>{}),F(n),c(()=>{R(a,X.session.name),R(s,`· ${X.listing.notes.length??``} ${X.listing.notes.length===1?`note`:`notes`}`)}),d(t,n)};z(x,e=>{X.session&&e(S)});var T=H(x,2),E=H(e(T),2);r(E,21,()=>Pe,([e,t])=>e,(e,t)=>{var n=U(()=>C(o(t),2));let r=()=>o(n)[0],i=()=>o(n)[1];var a=mo();let s;var l=W(a,!0);c(()=>{s=q(a,1,`btn svelte-1h9x2hz`,null,s,{on:Ne.chosen===r()}),j(a,`aria-checked`,Ne.chosen===r()),R(l,i())}),J(`click`,a,()=>Ne.choose(r())),d(e,a)}),F(E),F(T);var D=H(T,2),O=H(e(D),2);r(O,21,()=>Ie,([e,t])=>e,(e,t)=>{var n=U(()=>C(o(t),2));let r=()=>o(n)[0],i=()=>o(n)[1];var a=mo();let s;var l=W(a,!0);c(()=>{s=q(a,1,`btn svelte-1h9x2hz`,null,s,{on:Fe.chosen===r()}),j(a,`aria-checked`,Fe.chosen===r()),j(a,`title`,r()?`keywords bold, comments faint, as in print`:`coloured by what each word is`),R(l,i())}),J(`click`,a,()=>Fe.choose(r())),d(e,a)}),F(O),F(D);var M=H(D,2),N=t=>{var n=wo(),u=H(e(n),2),f=e(u),p=e=>{var t=ho();let n;c(()=>{n=q(t,1,`btn svelte-1h9x2hz`,null,n,{on:o(l)}),j(t,`aria-pressed`,o(l))}),J(`click`,t,g),d(e,t)};z(f,e=>{o(s)&&e(p)});var m=H(f,2),h=t=>{var n=Co(),o=A(n);r(o,20,()=>De,e=>e,(t,n)=>{var r=vo(),i=e(r),o=H(e(i)),s=e=>{var t=go();d(e,t)},l=e=>{var t=_o();d(e,t)};z(o,e=>{n===`cols`?e(s):n===`stack`&&e(l,1)}),F(i),F(r),c(()=>{j(r,`aria-pressed`,Z.layout===n),j(r,`aria-label`,a[n]),j(r,`title`,`${a[n]??``} (Alt+L)`)}),J(`click`,r,()=>Z.setLayout(n)),d(t,r)}),F(o);var s=H(o,2);r(s,20,()=>Te,e=>e,(t,n)=>{var r=So();let a;var o=e(r),s=e(o),l=e=>{var t=yo();d(e,t)},u=e=>{var t=bo();V(2),d(e,t)},f=e=>{var t=xo();d(e,t)};z(s,e=>{n===`note`?e(l):n===`atlas`?e(u,1):e(f,-1)}),F(o),F(r),c(e=>{a=q(r,1,`icon svelte-1h9x2hz`,null,a,{off:!Z.show[n]}),j(r,`aria-pressed`,Z.show[n]),j(r,`aria-label`,`Show ${i[n]??``}`),j(r,`title`,`Show or hide ${i[n]??``} (Alt+${e??``} brings it back)${n===`iso`?` · hide it when your terminal has the session`:``}`)},[()=>Te.indexOf(n)+1]),J(`click`,r,()=>Z.toggle(n)),d(t,r)}),F(s),d(t,n)};z(m,e=>{Z.narrow||e(h)}),F(u),F(n),d(t,n)};z(M,e=>{(o(s)||!Z.narrow)&&e(N)});var P=H(M,2),I=W(P);c(e=>j(I,`href`,e),[()=>ce(`/parts`)]),J(`click`,I,()=>Z.settings=null),d(t,_),ie()}h([`click`]);var Do=e=>{Eo(e,{})},Oo=e=>{so(e,{})},ko=t=>{var n=jo(),r=H(e(n),2),i=e=>{var t=Ao(),n=W(t);c(()=>R(n,`${X.listing.notes.length??``} ${X.listing.notes.length===1?`note`:`notes`}`)),d(e,t)};z(r,e=>{X.atlas&&e(i)}),F(n),d(t,n)},Ao=i(`<p class="soft svelte-12qhfyh"> </p>`),jo=i(`<section class="set svelte-12qhfyh"><h2 class="label svelte-12qhfyh">the map</h2> <!></section>`),Mo=i(`<p class="stopped svelte-12qhfyh"> </p>`),No=i(`<div class="divider svelte-12qhfyh" role="separator" aria-orientation="vertical" tabindex="0"></div>`),Po=i(`<span role="status"><i aria-hidden="true" class="svelte-12qhfyh"></i><span class="hidden-label svelte-12qhfyh"> </span></span>`),Fo=i(`<button class="icon svelte-12qhfyh" type="button" aria-label="Back to the note before" title="Back to the note before"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" class="svelte-12qhfyh"><path d="M10 3L5 8l5 5" class="svelte-12qhfyh"></path></svg></button> <button class="icon svelte-12qhfyh" type="button" aria-label="Forward to the note after" title="Forward to the note after"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" class="svelte-12qhfyh"><path d="M6 3l5 5-5 5" class="svelte-12qhfyh"></path></svg></button> <!> <button class="icon svelte-12qhfyh" type="button" aria-label="All notes" title="All notes, and search"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M2.5 3h4M4.5 3v9.5h3M4.5 7.5h3" class="svelte-12qhfyh"></path><rect x="8" y="5.5" width="5.5" height="3.5" class="svelte-12qhfyh"></rect><rect x="8" y="10.5" width="5.5" height="3.5" class="svelte-12qhfyh"></rect></svg></button>`,1),Io=i(`<div class="tree svelte-12qhfyh"><!></div>`),Lo=i(`<!> <div class="pbody note-body svelte-12qhfyh"><!></div> <!>`,1),Ro=i(`<span class="says svelte-12qhfyh"> </span>`),zo=i(`<span class="where soft svelte-12qhfyh"> </span><button class="btn out svelte-12qhfyh" type="button">↑ out</button>`,1),Bo=i(`<button class="icon svelte-12qhfyh" type="button" aria-label="The whole map" title="The whole map (0)"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10" class="svelte-12qhfyh"></path></svg></button><button class="icon svelte-12qhfyh" type="button" aria-label="Lay the map out again" title="Lay the map out again"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M13 8a5 5 0 1 1-1.5-3.6M13 2.5v3h-3" class="svelte-12qhfyh"></path></svg></button>`,1),Vo=i(`<!> <!> <!>`,1),Ho=i(`<!> <div class="pbody atlas-body svelte-12qhfyh"><!></div>`,1),Uo=i(`<button class="chip svelte-12qhfyh" type="button" aria-label="Change agent"> <span aria-hidden="true" class="svelte-12qhfyh">▾</span></button>`),Wo=s(`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M2.5 4.5h11v8h-11zM2.5 7.5h11M6.5 10h3" class="svelte-12qhfyh"></path></svg>`),Go=i(`<span> </span>`),Ko=i(`<button class="icon svelte-12qhfyh" type="button" aria-label="A new session"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M8 3.5v9M3.5 8h9" class="svelte-12qhfyh"></path></svg></button>`),qo=i(`<!> <!> <!> <button class="icon past svelte-12qhfyh" type="button" aria-label="Sessions" title="The agents' sessions, and earlier conversations"><!></button> <button class="icon ctx svelte-12qhfyh" type="button" aria-label="Context" title="What the agent has in hand, and what the tray gives it"><svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.3" class="svelte-12qhfyh"><path d="M3 3.5h10M3 6.5h10M3 9.5h6M3 12.5h6" class="svelte-12qhfyh"></path></svg> <!></button> <!>`,1),Jo=i(`<!> <div class="pbody iso-body svelte-12qhfyh"><!></div>`,1),Yo=i(`<section><!> <!></section>`),Xo=i(`<span class="badge svelte-12qhfyh"> </span>`),Zo=i(`<button type="button" class="svelte-12qhfyh"> <!></button>`),Qo=i(`<div class="shell svelte-12qhfyh"><main class="panes svelte-12qhfyh"><!></main> <nav class="tabs svelte-12qhfyh" aria-label="Panes"></nav></div>`);function $o(n,i){k(i,!0);let s=U(()=>Z.standing);b(()=>{if(Oe.route.id===`/n/[...id]`&&Oe.params.id){let e=Oe.params.id;Z.setLast(e),a(()=>Z.visit(e))}}),b(()=>{Oe.url.href,Z.tree=!1}),ee(ge),ee(()=>{let e=matchMedia(`(max-width: 760px)`);Z.narrow=e.matches;let t=()=>{Z.narrow=e.matches,Z.narrow&&requestAnimationFrame(()=>Z.scroll?.(Z.focus))};return e.addEventListener(`change`,t),Z.scroll=e=>{if(!Z.narrow||!o(u))return;let t=o(u).querySelector(`[data-pane="${e}"]`);t&&o(u).scrollTo({left:t.offsetLeft,behavior:matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})},()=>{e.removeEventListener(`change`,t),Z.scroll=null}});let u=w(void 0),h=U(()=>{if(Z.layout===`stack`&&o(s).length===3){let[e,t]=o(s);return{template:`"a b" minmax(0, 1fr) "a c" minmax(0, 1fr) / minmax(0, ${Z.widths[e]}fr) minmax(0, ${Z.widths[t]}fr)`,areas:Object.fromEntries(o(s).map((e,t)=>[e,`abc`[t]]))}}return{template:`minmax(0, 1fr) / ${o(s).map(e=>`minmax(0, ${Z.widths[e]}fr)`).join(` `)}`,areas:{}}});function _(e,t){let n=e.currentTarget,r=o(s)[o(s).indexOf(t)-1];if(!r||!o(u))return;n.setPointerCapture(e.pointerId);let i=o(s).reduce((e,t)=>e+(Z.layout===`stack`&&t===o(s)[2]?0:Z.widths[t]),0),a=o(u).getBoundingClientRect().width/i,c=e.clientX,l=e=>{let n=(e.clientX-c)/a,i=Z.widths[r]+n,o=Z.widths[t]-n;i<.4||o<.4||(Z.setWidth(r,i),Z.setWidth(t,o),c=e.clientX)},d=()=>{n.removeEventListener(`pointermove`,l),n.removeEventListener(`pointerup`,d)};n.addEventListener(`pointermove`,l),n.addEventListener(`pointerup`,d)}function v(e,t){let n=o(s)[o(s).indexOf(t)-1];if(!n||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let r=e.key===`ArrowLeft`?-.1:.1;Z.widths[n]+r>=.4&&Z.widths[t]-r>=.4&&(Z.setWidth(n,Z.widths[n]+r),Z.setWidth(t,Z.widths[t]-r)),e.preventDefault()}function y(){Z.narrow&&o(u)&&(clearTimeout(S),S=setTimeout(()=>{let e=Te[Math.round(o(u).scrollLeft/o(u).clientWidth)];e&&e!==Z.focus&&(Z.focus=e,e===`iso`&&(Z.unseen=0))},60))}let S;function C(e){if(e.key===`Escape`&&Z.tree){Z.tree=!1;return}if(!e.altKey||e.ctrlKey||e.metaKey||e.defaultPrevented)return;let t=e.target?.closest?.(`.cm-editor, input, textarea`)!=null,n=e.key;if(n===`1`||n===`2`||n===`3`)Z.to(Te[n-1]);else if(n.toLowerCase()===`l`&&!Z.narrow)Z.nextLayout();else if(t)return;else if(n===`ArrowLeft`||n===`ArrowRight`)Z.step(n===`ArrowRight`?1:-1);else if(E[n.toLowerCase()])Z.flip(E[n.toLowerCase()]);else return;e.preventDefault()}let T={note:`Note`,atlas:`Atlas`,iso:`Agent`},E={p:`provenance`,t:`timeline`,q:`questions`,b:`problems`,w:`web`,k:`code`,i:`pictures`,a:`artifacts`,c:`context`,n:`notes`,f:`files`,r:`run`},D=U(()=>Oe.route.id===`/n/[...id]`),O=U(()=>X.atlas?X.iso:null),M=U(()=>o(O)?.state===`reading`||o(O)?.state===`writing`),N=U(()=>we(o(O)?.agent)),P=U(()=>{let e=o(O)?.steps.findLast(e=>e.opened&&!e.failed)?.opened;return e?X.listing.notes.find(t=>t.id===e)?.title??e:``});var I=Qo();g(`12qhfyh`,e=>{l(()=>{x.title=o(D)&&X.here?`${X.here} · isorite`:`isorite`})}),t(`keydown`,m,C);var te=e(I);let ne;var re=e(te),G=e=>{var t=Mo(),n=W(t);c(()=>R(n,`isorite could not open the base: ${X.error??``}`)),d(e,t)},oe=n=>{var a=p(),l=A(a);r(l,16,()=>Te,e=>e,(n,r)=>{var a=Yo();let l,u;var m=e(a),g=e=>{var t=No();c(()=>j(t,`aria-label`,`Resize ${T[r]??``}`)),J(`pointerdown`,t,e=>_(e,r)),J(`keydown`,t,e=>v(e,r)),d(e,t)};z(m,e=>{!Z.narrow&&o(s)[0]!==r&&(Z.layout!==`stack`||o(s)[2]!==r)&&e(g)});var y=H(m,2),b=t=>{var n=Lo(),r=A(n);{let t=t=>{var n=Fo(),r=A(n),i=H(r,2),a=H(i,2),s=t=>{var n=Po();let r;var i=H(e(n)),a=W(i,!0);F(n),c(e=>{r=q(n,1,`saved svelte-12qhfyh`,null,r,{bad:X.saving.bad,busy:e}),j(n,`title`,X.saving.text),R(a,X.saving.text)},[()=>!X.saving.text.startsWith(`saved`)]),d(t,n)};z(a,e=>{o(D)&&X.saving&&e(s)});var l=H(a,2);c(()=>{r.disabled=!Z.canBack,i.disabled=!Z.canForward,j(l,`aria-pressed`,Oe.route.id===`/notes`||Z.tree)}),J(`click`,r,()=>void Z.walk(-1)),J(`click`,i,()=>void Z.walk(1)),J(`click`,l,()=>{Oe.route.id!==`/notes`&&(Z.tree=!Z.tree)}),d(t,n)},n=U(()=>Z.narrow||o(s)[0]===`note`);Za(r,{pane:`note`,get first(){return o(n)},name:`Note`,get settings(){return Do},tools:t,$$slots:{tools:!0}})}var a=H(r,2),l=e(a);ae(l,()=>i.children),F(a);var u=H(a,2),f=t=>{var n=Io(),r=e(n);je(r,{}),F(n),d(t,n)};z(u,e=>{Z.tree&&Oe.route.id!==`/notes`&&e(f)}),d(t,n)},x=t=>{var n=Ho(),r=A(n);{let e=e=>{var t=Vo(),n=A(t),r=e=>{var t=Ro(),n=W(t);c(()=>R(n,`${X.atlas.steps??``} ${X.atlas.steps===1?`step`:`steps`} back`)),d(e,t)};z(n,e=>{X.atlas?.chosen&&X.atlas.steps&&e(r)});var i=H(n,2),a=e=>{var t=zo(),n=A(t),r=W(n,!0),i=H(n);c(()=>R(r,X.atlas.here)),J(`click`,i,function(...e){X.atlas.out?.apply(this,e)}),d(e,t)};z(i,e=>{X.atlas?.here&&e(a)});var o=H(i,2),s=e=>{var t=Bo(),n=A(t),r=H(n);J(`click`,n,function(...e){X.atlas.fit?.apply(this,e)}),J(`click`,r,function(...e){X.atlas.relayout?.apply(this,e)}),d(e,t)};z(o,e=>{X.atlas&&e(s)}),d(e,t)},t=U(()=>Z.narrow||o(s)[0]===`atlas`);Za(r,{pane:`atlas`,get first(){return o(t)},name:`Atlas`,get settings(){return ko},tools:e,$$slots:{tools:!0}})}var i=H(r,2);Dr(e(i),{}),F(i),d(t,n)},S=t=>{var n=Jo(),r=A(n);{let t=t=>{let n=U(()=>$.session?.session);var r=qo(),i=A(r),a=e=>{var t=Ro(),n=W(t,!0);c(()=>{j(t,`title`,o(M)?``:`click open ground on the Atlas to let its path go`),R(n,o(M)?`${o(N)} is ${o(P)?`reading ${o(P)}`:`at work`} in its own terminal`:`${o(N)}'s turn is done`)}),d(e,t)};z(i,e=>{o(O)?.agent&&!$.acp&&e(a)});var s=H(i,2),l=t=>{var n=Uo(),r=e(n);V(),F(n),c(()=>{j(n,`title`,`${$.view.agent??``} is attached: change agent`),R(r,`${$.view.agent??``} `)}),J(`click`,n,()=>$.change()),d(t,n)};z(s,e=>{$.view?.connected&&$.view.agent&&e(l)});var u=H(s,2);$a(u,{});var m=H(u,2),h=e(m),g=e=>{Me(e,{get id(){return o(n)},size:20})},_=e=>{var t=Wo();d(e,t)};z(h,e=>{o(n)?e(g):e(_,-1)}),F(m);var v=H(m,2),y=H(e(v),2),b=e=>{var t=p(),n=A(t);f(n,()=>Q.fresh,e=>{var t=Go();let n;var r=W(t,!0);c(()=>{n=q(t,1,`n svelte-12qhfyh`,null,n,{pulse:$.shown===`session`&&Q.fresh!==``}),R(r,Q.sent.length)}),d(e,t)}),d(e,t)};z(y,e=>{Q.sent.length&&e(b)}),F(v);var x=H(v,2),S=e=>{var t=Ko();c(()=>j(t,`title`,`A new session with ${$.view.agent??``}, from here`)),J(`click`,t,()=>{$.fresh($.view?.agentId??``),$.shown=`session`}),d(e,t)};z(x,e=>{$.view?.connected&&e(S)}),c(()=>{j(m,`aria-pressed`,$.shown===`past`),j(v,`aria-pressed`,$.shown===`context`)}),J(`click`,m,()=>void $.drawer()),J(`click`,v,()=>$.shown=$.shown===`context`?`session`:`context`),d(t,r)},n=U(()=>Z.narrow||o(s)[0]===`iso`);Za(r,{pane:`iso`,get first(){return o(n)},name:`Agent`,get settings(){return Oo},tools:t,$$slots:{tools:!0}})}var i=H(r,2);ja(e(i),{}),F(i),d(t,n)};z(y,e=>{r===`note`?e(b):r===`atlas`?e(x,1):e(S,-1)}),F(a),c(e=>{l=q(a,1,`pane svelte-12qhfyh`,null,l,{focus:Z.focus===r,first:o(s)[0]===r,top:Z.layout===`stack`&&o(s)[1]===r&&o(s).length===3}),j(a,`data-pane`,r),j(a,`aria-label`,T[r]),j(a,`hidden`,e),u=K(a,``,u,{"grid-area":o(h).areas[r]})},[()=>!o(s).includes(r)]),t(`pointerdown`,a,()=>{Z.narrow||(Z.focus=r)},!0),d(n,a)}),d(n,a)};z(re,e=>{X.error?e(G):e(oe,-1)}),F(te),B(te,e=>L(u,e),()=>o(u));var se=H(te,2);r(se,20,()=>Te,e=>e,(t,n)=>{var r=Zo(),i=e(r),a=H(i),o=e=>{var t=Xo(),n=W(t,!0);c(()=>R(n,Z.unseen)),d(e,t)};z(a,e=>{n===`iso`&&Z.unseen&&e(o)}),F(r),c(()=>{j(r,`aria-current`,Z.focus===n),j(r,`aria-label`,T[n]),R(i,`${T[n]??``} `)}),J(`click`,r,()=>Z.to(n)),d(t,r)}),F(se),F(I),c(()=>{j(te,`data-layout`,Z.layout),ne=K(te,``,ne,{"grid-template":o(h).template})}),t(`scroll`,te,y),d(n,I),ie()}h([`pointerdown`,`keydown`,`click`]);export{$o as component,Le as universal};
@@ -1 +1 @@
1
- import{F as e,J as t,N as n,dt as r,et as i,j as a,nt as o,tt as s,ut as c}from"../chunks/Cz6kYWmu.js";import"../chunks/xihTtKlq.js";import{t as l}from"../chunks/DyZdoKBK.js";var u=e(`<h1> </h1> <p> </p>`,1);function d(e,d){r(d,!0);var f=u(),p=i(f),m=s(p,!0),h=o(p,2),g=s(h,!0);t(()=>{a(m,l.status),a(g,l.error?.message)}),n(e,f),c()}export{d as component};
1
+ import{F as e,J as t,N as n,dt as r,et as i,j as a,nt as o,tt as s,ut as c}from"../chunks/Cz6kYWmu.js";import"../chunks/xihTtKlq.js";import{t as l}from"../chunks/DdegnILL.js";var u=e(`<h1> </h1> <p> </p>`,1);function d(e,d){r(d,!0);var f=u(),p=i(f),m=s(p,!0),h=o(p,2),g=s(h,!0);t(()=>{a(m,l.status),a(g,l.error?.message)}),n(e,f),c()}export{d as component};
@@ -0,0 +1 @@
1
+ import{dt as e,n as t,s as n,ut as r}from"../chunks/Cz6kYWmu.js";import{s as i,t as a}from"../chunks/Co7i-dcu.js";import"../chunks/xihTtKlq.js";import{i as o,t as s}from"../chunks/CqmdC7Q3.js";import{i as c}from"../chunks/D4nFtMQC.js";import"../chunks/0qd6IUbO.js";function l(l,u){e(u,!1),t(()=>{let e=s.listing.notes.some(e=>e.id===c.last)?c.last:``;a(e?o(e):i(`/notes`),{replaceState:!0})}),n(),r()}export{l as component};
@@ -0,0 +1 @@
1
+ import{dt as e,n as t,s as n,ut as r}from"../chunks/Cz6kYWmu.js";import{s as i,t as a}from"../chunks/Co7i-dcu.js";import"../chunks/xihTtKlq.js";import{i as o,t as s}from"../chunks/CqmdC7Q3.js";import{i as c}from"../chunks/D4nFtMQC.js";import{t as l}from"../chunks/DdegnILL.js";import"../chunks/0qd6IUbO.js";function u(u,d){e(d,!1),t(()=>{let e=s.listing.notes.some(e=>e.id===c.last)?c.last:``,t=new URLSearchParams(l.url.search);t.delete(`base`);let n=t.size?`?${t}`:``;a((e?o(e):i(`/notes`))+n,{replaceState:!0}).then(()=>c.to(`atlas`))}),n(),r()}export{u as component};
@@ -1,3 +1,3 @@
1
- import{$ as e,D as t,E as n,F as r,H as i,J as a,N as o,O as s,P as c,R as l,T as u,W as d,Y as f,at as p,dt as m,et as h,f as g,ht as _,i as v,it as y,j as b,k as x,l as S,nt as C,ot as w,tt as T,ut as E,y as D,z as O}from"../chunks/Cz6kYWmu.js";import"../chunks/xihTtKlq.js";import{t as k}from"../chunks/CL9QeiGC.js";import{t as A}from"../chunks/DyZdoKBK.js";import{r as j}from"../chunks/CkSjC-iE.js";var M=r(`<span class="sym svelte-17avqta"> </span>`),N=r(`<span> </span>`),ee=r(`<span> </span> <!> <!> <span class="tools svelte-17avqta"><code class="link svelte-17avqta"> </code><button class="btn quiet" type="button"> </button></span>`,1),te=r(`<p class="why svelte-17avqta"> </p>`),ne=r(`<p class="why broken svelte-17avqta"> </p>`),re=r(`<div><button type="button" class="num svelte-17avqta"></button><span class="code svelte-17avqta"></span></div>`),ie=r(`<div class="pre svelte-17avqta" role="region"></div>`),ae=r(`<p class="why svelte-17avqta">Reading…</p>`),oe=r(`<div class="reader svelte-17avqta"><header><h1 class="svelte-17avqta"><span class="dir svelte-17avqta"> </span> </h1> <p class="meta svelte-17avqta"><!></p></header> <!></div>`);function P(r,s){m(s,!0);let c=v(s,`at`,3,``),l=w(()=>`code:${s.path}${c()?`#${c()}`:``}`),A=p(null),P=p([]),F=p(``),I=p(null),L=p(!1),R=p(void 0);async function z(){try{let e=await k.api.code(i(l),!0);if(y(A,e),y(F,``),e.state!==`ok`){y(P,[]);return}let t=e.text.split(`
1
+ import{$ as e,D as t,E as n,F as r,H as i,J as a,N as o,O as s,P as c,R as l,T as u,W as d,Y as f,at as p,dt as m,et as h,f as g,ht as _,i as v,it as y,j as b,k as x,l as S,nt as C,ot as w,tt as T,ut as E,y as D,z as O}from"../chunks/Cz6kYWmu.js";import"../chunks/xihTtKlq.js";import{t as k}from"../chunks/CqmdC7Q3.js";import{t as A}from"../chunks/DdegnILL.js";import{r as j}from"../chunks/CkSjC-iE.js";var M=r(`<span class="sym svelte-17avqta"> </span>`),N=r(`<span> </span>`),ee=r(`<span> </span> <!> <!> <span class="tools svelte-17avqta"><code class="link svelte-17avqta"> </code><button class="btn quiet" type="button"> </button></span>`,1),te=r(`<p class="why svelte-17avqta"> </p>`),ne=r(`<p class="why broken svelte-17avqta"> </p>`),re=r(`<div><button type="button" class="num svelte-17avqta"></button><span class="code svelte-17avqta"></span></div>`),ie=r(`<div class="pre svelte-17avqta" role="region"></div>`),ae=r(`<p class="why svelte-17avqta">Reading…</p>`),oe=r(`<div class="reader svelte-17avqta"><header><h1 class="svelte-17avqta"><span class="dir svelte-17avqta"> </span> </h1> <p class="meta svelte-17avqta"><!></p></header> <!></div>`);function P(r,s){m(s,!0);let c=v(s,`at`,3,``),l=w(()=>`code:${s.path}${c()?`#${c()}`:``}`),A=p(null),P=p([]),F=p(``),I=p(null),L=p(!1),R=p(void 0);async function z(){try{let e=await k.api.code(i(l),!0);if(y(A,e),y(F,``),e.state!==`ok`){y(P,[]);return}let t=e.text.split(`
2
2
  `);y(P,t.map(e=>B(e))),y(I,e.mark??null,!0),await d(),V();let n=await j(e.text,e.path);n&&i(A)===e&&y(P,n.split(`
3
3
  `))}catch(e){y(F,e.message,!0)}}let B=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`);f(()=>{i(l),z()});function V(){i(I)&&i(R)&&i(R).querySelector(`[data-n="${i(I).start}"]`)?.scrollIntoView({block:`center`})}function H(e,t){y(I,t.shiftKey&&i(I)?{start:Math.min(i(I).start,e),end:Math.max(i(I).end,e)}:{start:e,end:e},!0)}let U=e=>!!i(I)&&e>=i(I).start&&e<=i(I).end,W=w(()=>i(I)?`code:${s.path}#L${i(I).start}${i(I).end>i(I).start?`-L${i(I).end}`:``}`:`code:${s.path}`);async function G(){try{await navigator.clipboard.writeText(i(W)),y(L,!0),setTimeout(()=>y(L,!1),1500)}catch{}}let K={"no-repository":`no repository is named for this base's code links`,"no-file":`not in the repository`,"too-large":`too large to show`},se=w(()=>s.path.split(`/`).at(-1)??s.path),q=w(()=>s.path.split(`/`).slice(0,-1).join(`/`));var J=oe(),Y=e(J),X=e(Y),Z=e(X),ce=T(Z,!0),le=C(Z,1,!0);_(X);var Q=C(X,2),$=e(Q),ue=t=>{var n=ee(),r=h(n),s=T(r),c=C(r,2),l=e=>{var t=M(),n=T(t);a(()=>b(n,`${i(A).symbol??``}${i(I)&&i(A).mark?``:` (not found in the file)`}`)),o(e,t)};x(c,e=>{i(A).symbol&&e(l)});var u=C(c,2),d=e=>{var t=N(),n=T(t);a(()=>b(n,`${i(A).count??``} declarations of this name: the first is marked`)),o(e,t)};x(u,e=>{i(A).count&&e(d)});var f=C(u,2),p=e(f),m=T(p,!0),g=C(p),v=T(g,!0);_(f),a(()=>{b(s,`${i(A).total??``} lines`),b(m,i(W)),b(v,i(L)?`copied`:`copy link`)}),O(`click`,g,()=>void G()),o(t,n)};x($,e=>{i(A)?.state===`ok`&&e(ue)}),_(Q),_(Y);var de=C(Y,2),fe=e=>{var t=te(),n=T(t,!0);a(()=>b(n,i(F))),o(e,t)},pe=e=>{var t=ne(),n=T(t);a(()=>b(n,`${s.path??``}: ${K[i(A).state]??i(A).state??``}`)),o(e,t)},me=r=>{var c=ie();n(c,21,()=>i(P),t,(t,n,r)=>{var s=re();let c;g(s,`data-n`,r+1);var l=e(s);g(l,`aria-label`,`Line ${r+1}`),l.textContent=r+1;var d=C(l);u(d,()=>i(n)||` `,!0),_(d),_(s),a(e=>c=D(s,1,`row svelte-17avqta`,null,c,{on:e}),[()=>U(r+1)]),O(`click`,l,e=>H(r+1,e)),o(t,s)}),_(c),S(c,e=>y(R,e),()=>i(R)),a(()=>g(c,`aria-label`,`The file ${s.path??``}`)),o(r,c)},he=e=>{var t=ae();o(e,t)};x(de,e=>{i(F)?e(fe):i(A)&&i(A).state!==`ok`?e(pe,1):i(A)?e(me,2):e(he,-1)}),_(J),a(()=>{b(ce,i(q)?`${i(q)}/`:``),b(le,i(se))}),o(r,J),E()}l([`click`]);function F(e,t){m(t,!0);let n=w(()=>A.params.path??``),r=w(()=>new URLSearchParams(A.url.href.split(`?`)[1]?.split(`#`)[0]??``).get(`at`)??``);var a=c(),l=h(a);s(l,()=>`${i(n)}#${i(r)}`,e=>{P(e,{get path(){return i(n)},get at(){return i(r)}})}),o(e,a),E()}export{F as component};