grooph 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -31
- package/THIRD-PARTY-NOTICES.md +5 -1
- package/dist/app/assets/App-CT9KxzfQ.css +1 -0
- package/dist/app/assets/App-D1pDFbEY.js +5 -0
- package/dist/app/assets/EmbedApp-CTausQWY.js +1 -0
- package/dist/app/assets/ExportPanel-CbRH4C69.js +8 -0
- package/dist/app/assets/Import-DF0XLxRI.js +1 -0
- package/dist/app/assets/SketchView-BjeUHG4X.js +143 -0
- package/dist/app/assets/{brakes-BJPDrrJT.js → brakes-B9b3hDX8.js} +1 -1
- package/dist/app/assets/{builtins-D_22fKRF.js → builtins-DzyPaYdd.js} +1 -1
- package/dist/app/assets/{compile-BAvi-rd0.js → compile-DL2budwP.js} +8 -8
- package/dist/app/assets/{front-BRl7rl-u.js → front-OxfL-OaD.js} +1 -1
- package/dist/app/assets/full-C0asYORc.js +1 -0
- package/dist/app/assets/graph-more-Dn_hNa20.js +2 -0
- package/dist/app/assets/graph-stage-CwNePnN4.js +4 -0
- package/dist/app/assets/graph-views-CmkQ41zC.js +2 -0
- package/dist/app/assets/{index-CeaKwKuU.js → index-B5ZkSF4L.js} +2 -2
- package/dist/app/assets/mermaid-read-cyqJ32v-.js +17 -0
- package/dist/app/assets/{plan-templates-BQu8G2sX.js → plan-templates-u2fF3GnS.js} +1 -1
- package/dist/app/assets/runs-BA5HKtsx.js +1 -0
- package/dist/app/assets/screens-CMMuexid.js +16 -0
- package/dist/app/assets/share-DV3wsAsJ.js +8 -0
- package/dist/app/assets/site-looks.v1.css +223 -0
- package/dist/app/assets/space-Cuy4YqyZ.js +1 -0
- package/dist/app/assets/styles-Dlp-yYlE.css +1 -0
- package/dist/app/assets/templates-DbAhWvP6.js +2 -0
- package/dist/app/assets/{themes-DtOBrLk0.js → themes-C34TrvOJ.js} +1 -1
- package/dist/app/assets/{units-DOIUgOIU.js → units-DlniUjfH.js} +1 -1
- package/dist/app/assets/{views-CLwg5VNv.js → views-CFqRShXD.js} +2 -1
- package/dist/app/grooph-app.json +1 -1
- package/dist/app/index.html +14 -11
- package/dist/app/llms.txt +6 -7
- package/dist/app/manifest.webmanifest +1 -1
- package/dist/app/og.png +0 -0
- package/dist/app/routes.json +42 -33
- package/dist/app/sw.js +7 -2
- package/dist/browser/grooph.d.ts +44 -0
- package/dist/browser/grooph.global.js +7 -0
- package/dist/browser/grooph.js +7 -0
- package/dist/bundle/grooph.js +6734 -2536
- package/hooks/grooph-event.mjs +163 -14
- package/package.json +14 -6
- package/dist/app/assets/App-48y1Ec5B.js +0 -5
- package/dist/app/assets/App-Cv1auMeh.css +0 -1
- package/dist/app/assets/EmbedApp-390Z2d4x.js +0 -1
- package/dist/app/assets/ExportPanel-Ca3wBB38.js +0 -8
- package/dist/app/assets/Import-ByMI7Uz9.js +0 -1
- package/dist/app/assets/graph-more-393HTgQE.js +0 -2
- package/dist/app/assets/graph-stage-BkrQGQ-z.js +0 -4
- package/dist/app/assets/graph-views-COQF_QTQ.js +0 -2
- package/dist/app/assets/runs-DcjRi7S6.js +0 -1
- package/dist/app/assets/screens-aIjMSzZg.js +0 -16
- package/dist/app/assets/share-BzIzB4EY.js +0 -8
- package/dist/app/assets/space-DWgrlnfB.js +0 -1
- package/dist/app/assets/styles-BA1aVO9R.css +0 -1
- package/dist/app/assets/templates-CoNTzuuz.js +0 -2
- package/dist/app/demo/run.txt +0 -1
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,t as n}from"./index-CeaKwKuU.js";import{C as r,Gt as i,Ht as a,S as o,T as s,Vt as c,Wt as l,Xt as u,en as d,x as f}from"./share-BzIzB4EY.js";var p=t(e(),1),m=`.s3{grid-template-rows:auto minmax(var(--s3-tall,180px), 1fr);min-height:100%;font:13px/1.4 var(--font);color:var(--ink);grid-auto-rows:min-content;gap:10px;padding:0 12px;display:grid}.s3-bar,.s3-steps{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.s3-bar span{color:var(--ink-3);text-wrap:pretty;flex:8rem;font-size:12.5px}.s3 button:not(.s3-card){border:1px solid var(--line-strong);background:var(--surface);min-width:40px;min-height:40px;color:var(--ink);font:600 13px/1 var(--font);cursor:pointer;border-radius:10px;padding:0 12px}.s3 button.is-on{border-color:var(--accent);background:var(--accent-soft)}.s3-steps input{min-width:0;height:40px;accent-color:var(--accent);flex:8rem}.s3-frame{border:1px solid var(--line);background:var(--bg);touch-action:none;cursor:grab;-webkit-user-select:none;user-select:none;border-radius:14px;min-height:0;position:relative;overflow:hidden}.s3-frame:active{cursor:grabbing}.s3-frame:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.s3-frame canvas{width:100%;height:100%;position:absolute;inset:0}.s3-card{transform-origin:0 0;border:1px solid var(--line-strong);border-left:4px solid var(--kind-stop);background:var(--surface);width:106px;color:var(--ink);font:inherit;text-align:left;cursor:pointer;border-radius:7px;padding:4px 6px 5px 9px;position:absolute;top:0;left:0}.s3-card[data-kind=agent]{border-left-color:var(--kind-agent)}.s3-card[data-kind=check]{border-left-color:var(--kind-check)}.s3-card[data-kind=person],.s3-card[data-kind=gate]{border-left-color:var(--kind-human-gate)}.s3-card b,.s3-card span{white-space:nowrap;text-overflow:ellipsis;display:block;overflow:hidden}.s3-card b{-webkit-line-clamp:2;white-space:normal;overflow-wrap:anywhere;-webkit-box-orient:vertical;display:-webkit-box}.s3-bar .s3-tight,.s3[data-tight] .s3-bar span:first-child{display:none}.s3[data-tight] .s3-bar .s3-tight{color:var(--ink);display:block}.s3-card b{font-size:11.5px;font-weight:600;line-height:1.25}.s3-card span{color:var(--ink-3);font-size:9.5px;line-height:1.3}.s3-card.is-small{width:max-content;min-width:56px;max-width:150px;padding-block:3px}.s3-card.is-small span{display:none}.s3-card.is-small[data-kind=person] span{display:block}.s3-card.is-small b{white-space:nowrap;display:block}.s3-card.is-lit{border-color:var(--accent);background:var(--accent-soft);box-shadow:0 0 0 1px var(--accent)}.s3-token{z-index:100000;box-sizing:border-box;border:3px solid var(--accent);pointer-events:none;border-radius:50%;position:absolute;top:0;left:0}.s3-card.is-dim{opacity:.62}.s3-card:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.s3-says{text-wrap:pretty;min-height:2.8em;display:block}.s3[data-kind=spiral]{grid-template-rows:auto minmax(max(330px, var(--s3-tall,0px)), 1fr)}.s3-key{color:var(--ink-2);text-wrap:pretty;gap:4px;margin:0;padding:0;font-size:12.5px;list-style:none;display:grid}.s3-note{color:var(--ink-3);text-wrap:pretty;margin:0;font-size:12.5px}`,h=Math.PI*2,g=(e,t,n)=>Math.max(t,Math.min(n,e)),_={ink:`--ink`,"ink-2":`--ink-2`,"ink-3":`--ink-3`,line:`--line`,"line-strong":`--line-strong`,card:`--surface`,ground:`--bg`,floor:`--surface-2`,accent:`--accent`,"accent-soft":`--accent-soft`,"loop-0":`--loop-0`,"loop-1":`--loop-1`,"loop-2":`--loop-2`,"loop-3":`--loop-3`,"k-agent":`--kind-agent`,"k-check":`--kind-check`,"k-gate":`--kind-human-gate`,"k-stop":`--kind-stop`,ok:`--ok`,bad:`--warning`,brake:`--error`},v=.8,y=.9;function b(e,t,n,r,i=0){let a=t.getContext(`2d`);if(!a)throw Error(`no 2D context`);let o=a,s={...r,zoom:1},c=[],l=1,u=[0,0,0],d=[0,0],f={},p=`system-ui, sans-serif`,[m,b]=[0,0],x=0,S=0,C=!1,w=``,T=!1,E=new Map,D=0,O=!1,k=e.appendChild(document.createElement(`i`));k.className=`s3-token`,k.hidden=!0;let A=e=>`pts`in e?e.pts:[e.at],j=e=>{let[t,n,r]=[e[0]-u[0],e[1]-u[1],e[2]-u[2]],[i,a,o,c]=[Math.cos(s.yaw),Math.sin(s.yaw),Math.cos(s.pitch),Math.sin(s.pitch)],[l,d]=[t*i+r*a,-t*a+r*i];return[l,n*o-d*c,n*c+d*o]},M=(e,t)=>t*2600/(2600-e*t),N=e=>{let[t,n,r]=j(e),i=M(r,l*s.zoom);return[m/2+(t-d[0])*i,b/2-(n-d[1])*i,r,i]},P=(e,t=1)=>{let n=f[e]??e;return t>=1?n:`color-mix(in srgb, ${n} ${Math.round(t*100)}%, transparent)`},F=e=>n.querySelector(`[data-node="${CSS.escape(e)}"]`),I=(e,t,n,r,i)=>{let a=g(i,.72,1.15),[o,s]=[t.offsetWidth*a,t.offsetHeight*a];return[e.side?n+9:n-o/2,e.stand&&!e.side?r-s-13:r-s/2,o,s,a]};function L(){if(!c.length||!m||!b)return;let n=c.flatMap(A);u=[0,1,2].map(e=>(Math.min(...n.map(t=>t[e]))+Math.max(...n.map(t=>t[e])))/2);let a={...s};Object.assign(s,r,{zoom:1});let o=e=>{let t=(e.t===`card`&&e.small?F(e.id)?.offsetWidth??88:106)/2+5;return e.t===`card`?e.side?e.small?[8,t*2,14,14]:[8,128,22,22]:e.stand?[t,t,Math.max(60,(F(e.id)?.offsetHeight??0)*1.15+14),8]:[58,58,24,24]:e.t===`text`?[8,8,e.up?16*e.text.split(`
|
|
2
|
-
`).length*1.6:12,12]:[3,3,3,3]},f=c.flatMap(e=>A(e).map(t=>[j(t),o(e)])),p=e=>[Math.min(...f.map(([t,n])=>t[0]*M(t[2],e)-n[0])),Math.max(...f.map(([t,n])=>t[0]*M(t[2],e)+n[1])),Math.min(...f.map(([t,n])=>-t[1]*M(t[2],e)-n[2])),Math.max(...f.map(([t,n])=>-t[1]*M(t[2],e)+n[3]))],h=(e,t)=>{let[n,r]=[.05,1.5];for(let i=0;i<18;i+=1){let i=(n+r)/2,[a,o,s,c]=p(i);o-a<=e-16&&c-s<=t-16?n=i:r=i}return n},g=e.parentElement,_=g?.parentElement;if(i&&g&&_){let n=c.flatMap(e=>e.t===`card`&&F(e.id)?[[e,F(e.id),j(e.at)]]:[]),r=()=>`${m}|${_.clientHeight}|${g.style.getPropertyValue(`--s3-tall`)?`held`:b}|${n.map(([e,t,n])=>`${e.id}:${t.offsetHeight}:${n.map(Math.round).join(`,`)}`).join(`|`)}`;if(r()!==w&&O)D||=requestAnimationFrame(()=>(D=0,L(),V()));else if(r()!==w){let a=(e,t=i)=>{let[r,a,o,s]=p(e),[c,l]=[(r+a)/2/e,-(o+s)/2/e],u=n.map(([t,n,r])=>I(t,n,(r[0]-c)*M(r[2],e),-(r[1]-l)*M(r[2],e),M(r[2],e)));return u.every((e,n)=>u.every((r,i)=>i<=n||e[0]>=r[0]+r[2]+t||r[0]>=e[0]+e[2]+t||e[1]>=r[1]+r[3]+t||r[1]>=e[1]+e[3]+t))},o=()=>(b=Math.round(t.getBoundingClientRect().height),t.height=b*x,h(m,b)),s=_.scrollTop;g.style.removeProperty(`--s3-tall`),delete g.dataset.tight;let c=o();if(b&&(!a(c)||c<y)){let t=h(m,1e6),n=a(c)?c:t;for(let e=1;e<=24&&!a(c);e+=1){let[r,i]=[c+(t-c)*(e-1)/24,c+(t-c)*e/24];if(a(i)){for(let e=0;e<10;e+=1)a((r+i)/2)?i=(r+i)/2:r=(r+i)/2;n=i;break}}let r=e=>Math.ceil(p(e)[3]-p(e)[2])+18,i=(e,t)=>t&&e instanceof HTMLElement?e.offsetHeight+10+i(e.nextElementSibling,t-1):0,s=_.clientHeight-e.offsetTop-i(e.nextElementSibling,2)-parseFloat(getComputedStyle(_).paddingBottom),l=a(c)?b:r(n),u=Math.min(Math.max(l,Math.min(r(Math.max(n,Math.min(t,y))),s)),Math.round(_.clientHeight*v));u>b?(g.style.setProperty(`--s3-tall`,`${u}px`),a(o(),0)||(g.dataset.tight=``)):a(c,0)||(g.dataset.tight=``)}`tight`in g.dataset&&o(),T=`tight`in g.dataset,_.scrollTop=s,w=r()}}l=h(m,b);let[S,C,E,k]=p(l);d=[(S+C)/2/l,-(E+k)/2/l],Object.assign(s,a)}function R(e,t,n){let r=(e,t)=>{let n=[...e],r=t;for(;n.length>2&&r>0;){let e=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]);if(e>r)break;r-=e,n.shift()}let i=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]);return i>r+1&&(n[0]=[n[0][0]+(n[1][0]-n[0][0])*r/i,n[0][1]+(n[1][1]-n[0][1])*r/i]),n};return r(r(e,t).reverse(),n).reverse()}let z=(e,[t,n,r,i])=>{let a=e=>e[0]>t&&e[0]<t+r&&e[1]>n&&e[1]<n+i;if(e.length<2||!a(e[e.length-1]))return null;let o=e.length-1;for(;o>0&&a(e[o-1]);)--o;if(o===0)return null;let[s,c]=[e[o-1],e[o]],[l,u]=[0,1];for(let e=0;e<12;e+=1)a([s[0]+(c[0]-s[0])*((l+u)/2),s[1]+(c[1]-s[1])*((l+u)/2)])?u=(l+u)/2:l=(l+u)/2;return[...e.slice(0,o),[s[0]+(c[0]-s[0])*l,s[1]+(c[1]-s[1])*l]]},B=e=>{o.beginPath(),e.forEach((e,t)=>t?o.lineTo(e[0],e[1]):o.moveTo(e[0],e[1]))};function V(){if(e.parentElement?.toggleAttribute(`data-tight`,T&&s.zoom<=1),cancelAnimationFrame(S),S=0,!m||!b)return;let t=getComputedStyle(e);for(let[e,n]of Object.entries(_))f[e]=t.getPropertyValue(n).trim();p=t.fontFamily,o.setTransform(x,0,0,x,0,0),o.clearRect(0,0,m,b);let r=Q.lit,i=e=>r&&e.key&&!r.has(e.key)?.42:1,a=Q.grown,l=c.filter(e=>!e.hide&&!(e.grow&&a<=0)).map(e=>{let t=A(e).map(N);return{p:e,pts:t,depth:t.reduce((e,t)=>e+t[2],0)/t.length+(e.t===`poly`?-90:e.t===`line`?-20:e.t===`dot`?4e3:e.t===`text`?60:0)+(e.lift??0)}}).sort((e,t)=>e.depth-t.depth),u=new Map;k.hidden=!0,l.forEach(({p:e,pts:t},n)=>{if(e.t!==`card`)return;let i=F(e.id);if(!i)return;let a=!!(r&&e.key&&r.has(e.key)),[o,s,c,l,d]=I(e,i,t[0][0],t[0][1],t[0][3]);u.set(e.id,[o,s,c,l]),i.style.transform=`translate(${o.toFixed(1)}px,${s.toFixed(1)}px) scale(${d.toFixed(3)})`,i.style.zIndex=String(n),i.hidden=!1,i.classList.toggle(`is-lit`,a),i.classList.toggle(`is-dim`,!!r&&!a)});let d=[],v=(e,t)=>Math.max(0,Math.min(e[0]+e[2],t[0]+t[2])-Math.max(e[0],t[0]))*Math.max(0,Math.min(e[1]+e[3],t[1]+t[3])-Math.max(e[1],t[1]));l.forEach(({p:e,pts:t})=>{if(e.t===`card`)return;let n=!!(r&&e.key&&r.has(e.key)),s=t;if(o.globalAlpha=i(e)*(e.alpha??1)*(e.grow&&e.t!==`line`?a:1),o.setLineDash(`dash`in e&&e.dash?e.dash:[]),o.lineJoin=o.lineCap=`round`,e.t===`poly`)B(s),o.closePath(),e.fill&&(o.fillStyle=P(e.fill,n?Math.min(1,(e.fa??1)*1.8):e.fa??1),o.fill()),e.stroke&&(o.strokeStyle=P(n?`accent`:e.stroke),o.lineWidth=(e.w??1)*(n?2:1),o.stroke());else if(e.t===`line`){let[t,r]=[e.from?u.get(e.from):void 0,e.to?u.get(e.to):void 0],i=[r?z(s,r):null,t?z([...s].reverse(),t):null];if(i[0]&&(s=i[0]),i[1]&&(s=z([...s].reverse(),t)?.reverse()??s),e.inset&&(s=R(s,i[1]?2:e.inset[0],i[0]?1:e.inset[1])),e.grow&&a<1&&(s=s.slice(0,Math.max(2,Math.ceil(s.length*a)))),B(s),o.strokeStyle=P(e.stroke??`ink-2`),o.lineWidth=(e.w??1.4)*(n?2.1:1),o.stroke(),e.arrow&&s.length>1&&!(e.grow&&a<1)){let[t,n]=[s[s.length-2],s[s.length-1]],r=Math.atan2(n[1]-t[1],n[0]-t[0]);o.setLineDash([]),o.beginPath(),o.moveTo(n[0],n[1]),o.lineTo(n[0]-9*Math.cos(r-.42),n[1]-9*Math.sin(r-.42)),o.lineTo(n[0]-9*Math.cos(r+.42),n[1]-9*Math.sin(r+.42)),o.closePath(),o.fillStyle=P(e.stroke??`ink-2`),o.fill()}}else if(e.t===`dot`&&e.over){let t=e.r??5;k.style.cssText=`width:${t*2}px;height:${t*2}px;transform:translate(${(s[0][0]-t).toFixed(1)}px,${(s[0][1]-t).toFixed(1)}px)`,k.hidden=!1}else if(e.t===`dot`)o.beginPath(),o.arc(s[0][0],s[0][1],e.r??5,0,h),e.fill&&(o.fillStyle=P(e.fill),o.fill()),e.stroke&&(o.strokeStyle=P(e.stroke),o.lineWidth=e.w??2,o.stroke());else{let t=e.size??11;o.font=`${e.bold?600:400} ${t}px ${p}`,o.textBaseline=`middle`,o.textAlign=`left`;let n=Math.min(e.max??220,m-12),r=e.text.split(`
|
|
3
|
-
`).flatMap((t,r)=>{let i=[``];for(let e of t.split(` `)){let t=i[i.length-1]?`${i[i.length-1]} ${e}`:e;o.measureText(t).width>n&&i[i.length-1]?i.push(e):i[i.length-1]=t}return i.map(t=>({text:t,head:r<(e.heads??0)}))}),i=Math.max(...r.map(({text:e})=>o.measureText(e).width)),a=[{at:s[0],align:e.align},...(e.or??[]).map(e=>({at:N(e.at),align:e.align}))].map(n=>{let a=g(n.at[0]-(n.align===`center`?i/2:n.align===`right`?i:0),4,Math.max(4,m-4-i)),o=r.length*(t+3),s=[a,n.at[1]-(e.up?o-(t+3)/2:o/2),i,o];return{...n,box:s,under:[...u.values(),...d].reduce((e,t)=>e+v(s,t),0)}}),c=a[E.get(e.text)??-1],l=e.or?c&&c.under<=.1*c.box[2]*c.box[3]?c:a.find(e=>e.under===0)??[...a].sort((e,t)=>e.under-t.under)[0]:a[0];e.or&&(d.push(l.box),E.set(e.text,a.indexOf(l))),r.forEach(({text:n,head:i},a)=>{let s=o.measureText(n).width,c=g(l.at[0]-(l.align===`center`?s/2:l.align===`right`?s:0),4,Math.max(4,m-4-s)),u=l.at[1]+(e.up?a-(r.length-1):a-(r.length-1)/2)*(t+3);o.strokeStyle=P(`ground`,.9),o.lineWidth=3.5,o.setLineDash([]),o.strokeText(n,c,u),o.fillStyle=P(i&&e.headFill?e.headFill:e.fill??`ink-2`),o.fillText(n,c,u)})}}),o.globalAlpha=1,o.setLineDash([]);for(let e of n.querySelectorAll(`[data-node]`))u.has(e.dataset.node)||(e.hidden=!0)}let H=()=>{S||=requestAnimationFrame(V)};function U(){let e=t.getBoundingClientRect(),[n,r]=[Math.round(e.width),Math.round(e.height)];(n!==m||r!==b||x!==(devicePixelRatio||1))&&([m,b]=[n,r],x=devicePixelRatio||1,t.width=m*x,t.height=b*x,L())}let W=[],G=(t,n,r)=>{e.addEventListener(t,n,r),W.push(()=>e.removeEventListener(t,n,r))},K=new Map,q=0,J=[0,0];G(`pointerdown`,e=>{(e.pointerType!==`mouse`||e.button===0)&&(K.set(e.pointerId,[e.clientX,e.clientY]),J=[e.clientX,e.clientY],q=0,C=!1)}),G(`pointermove`,t=>{let n=K.get(t.pointerId);if(!n||t.pointerType===`mouse`&&!(t.buttons&1))return void K.delete(t.pointerId);if(!(!C&&K.size===1&&Math.hypot(t.clientX-J[0],t.clientY-J[1])<6)){if(C||e.setPointerCapture(t.pointerId),C=!0,K.set(t.pointerId,[t.clientX,t.clientY]),K.size===1)s.yaw=g(s.yaw+(t.clientX-n[0])*.009,-1.9,1.9),s.pitch=g(s.pitch+(t.clientY-n[1])*.007,-.15,1.45);else if(K.size===2){let[e,t]=[...K.values()],n=Math.hypot(e[0]-t[0],e[1]-t[1]);q&&(s.zoom=g(s.zoom*n/q,.5,3.2)),q=n}H()}});let Y=e=>void(K.delete(e.pointerId),q=0);if(G(`pointerup`,Y),G(`pointercancel`,Y),G(`wheel`,e=>{e.ctrlKey&&(e.preventDefault(),s.zoom=g(s.zoom*Math.exp(-e.deltaY*.01),.5,3.2),H())},{passive:!1}),G(`keydown`,t=>{if(t.target!==e||t.altKey||t.ctrlKey||t.metaKey)return;let n={ArrowLeft:[-.12,0],ArrowRight:[.12,0],ArrowUp:[0,-.1],ArrowDown:[0,.1]}[t.key];if(n)s.yaw=g(s.yaw+n[0],-1.9,1.9),s.pitch=g(s.pitch+n[1],-.15,1.45);else if(t.key===`+`||t.key===`=`)s.zoom=g(s.zoom*1.2,.5,3.2);else if(t.key===`-`)s.zoom=g(s.zoom/1.2,.5,3.2);else if(t.key===`0`||t.key===`Home`)Object.assign(s,r,{zoom:1});else return;t.preventDefault(),H()}),typeof ResizeObserver==`function`){let n=new ResizeObserver(()=>{O=!0,U(),i&&L(),O=!1,V()});n.observe(t),i&&e.parentElement?.parentElement&&n.observe(e.parentElement.parentElement),W.push(()=>n.disconnect())}let X=matchMedia(`(prefers-color-scheme: dark)`);X.addEventListener(`change`,H);let Z=new MutationObserver(H);Z.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),W.push(()=>X.removeEventListener(`change`,H),()=>Z.disconnect(),()=>cancelAnimationFrame(S),()=>cancelAnimationFrame(D),()=>k.remove());let Q={lit:null,grown:1,set(e){c=e;for(let e of c)e.t===`card`&&F(e.id)?.classList.toggle(`is-small`,!!e.small);U(),L()},draw(){U(),V()},ask:H,reset:()=>(Object.assign(s,r,{zoom:1}),H()),zoom:e=>(s.zoom=g(s.zoom*e,.5,3.2),H()),dragged:()=>C,off:()=>W.forEach(e=>e())};return Q}var x={agent:[`agent`,`Agent`],check:[`check`,`Check`],"human-gate":[`gate`,`Human gate`],merge:[`gate`,`Merge`],stop:[`stop`,`Stop`]};function S(e){let t=e.groups??[],n=(e,r,i=new Set)=>!i.has(e.id)&&(i.add(e.id),t.some(t=>t.id!==e.id&&e.members.includes(t.id)&&(t.id===r||n(t,r,i)))),r=e=>{let r=t.filter(t=>t.id!==e&&t.members.includes(e));return(r.find(e=>!r.some(t=>t.id!==e.id&&n(e,t.id)))??r[0])?.id??null},i=(n,a)=>a.has(n)?[]:(a.add(n),[...e.nodes.filter(e=>r(e.id)===n).map(e=>e.id),...t.filter(e=>r(e.id)===n).flatMap(e=>i(e.id,a))]);return t.map(e=>({id:e.id,name:e.name||e.id,from:e.from??null,nodes:i(e.id,new Set),inside:r(e.id)}))}var C=e=>e<640?2:4;function w(e,t,n,r=!1){let f=o(e),p=new Map(f.flat().map((e,t)=>[e,t])),m=t,h=t=>e.nodes.some(e=>e.id===t),g=t=>e.nodes.find(e=>e.id===t)?.name||t,_=e=>e.members.filter(h),v=t=>e.loops.filter(e=>e.id!==t.id&&_(e).length>_(t).length&&_(t).every(t=>e.members.includes(t))).sort((e,t)=>_(e).length-_(t).length)[0]?.id??null,y=e.loops.map(t=>{let n=e=>t.stops.find(t=>t.kind===e),r=n(`budget`),i=t.stops.flatMap(e=>e.kind===`max-iterations`?[e.n]:[]),o=t.stops.flatMap(e=>e.kind===`budget`&&e.measure===`dispatches`?[e.limit]:[]);return{id:t.id,name:t.name||t.id,inside:v(t),members:_(t).sort((e,t)=>(p.get(e)??0)-(p.get(t)??0)),own:[],back:t.back,stops:t.stops.map(a),brakes:t.stops.flatMap(e=>e.kind===`max-iterations`?[{kind:e.kind,n:e.n}]:e.kind===`budget`?[{kind:e.kind,measure:e.measure,limit:e.limit}]:e.kind===`human`?[{kind:e.kind,every:e.every??null}]:[]),cap:i.length?Math.min(...i):null,budget:r?{measure:r.measure,limit:r.limit}:null,dispatches:o.length?Math.min(...o):null,human:n(`human`)?.every??null,perRound:t.members.map(t=>e.nodes.find(e=>e.id===t)).filter(e=>e?.kind===`check`||e?.kind===`agent`&&e.role!==`lead`&&!u(e)).length}}),b=e=>y.filter(t=>t.members.includes(e)).sort((e,t)=>e.members.length-t.members.length)[0]?.id??null;for(let e of y)e.own=e.members.filter(t=>b(t)===e.id);let C=new Map(e.loops.flatMap(e=>e.back.map(t=>[t,e.id]))),w=e.edges.filter(e=>h(e.from)&&h(e.to)),T=w.filter(e=>!C.has(e.id)&&p.has(e.from)&&p.has(e.to)).sort((e,t)=>p.get(e.from)-p.get(t.from)||p.get(e.to)-p.get(t.to)),D=[...C].flatMap(([e,t])=>w.filter(t=>t.id===e&&p.has(t.from)&&p.has(t.to)).map(e=>({e,loop:t}))),O={narrow:r,id:e.id,name:e.name||e.id,rows:f,nodes:e.nodes.map(e=>({id:e.id,name:e.name||e.id,kind:u(e)?`person`:x[e.kind][0],word:u(e)?c.person:x[e.kind][1],line:e.kind===`agent`?u(e)?`${c.person} · ${d(e)}`:[d(e),e.model?.tier??`session default`,e.effort].filter(Boolean).join(` · `):x[e.kind][1],tier:e.kind===`agent`&&!u(e)?e.model?.tier??`unset`:null,loop:b(e.id),at:[m[e.id]?.x??0,m[e.id]?.y??0]})),edges:w.map(e=>({id:e.id,from:e.from,to:e.to,when:l(e)?i(e):``,back:C.get(e.id)??null,on:e.when})),loops:y,groups:S(e),pass:[...T.map(e=>({e,loop:null})),...D].map(({e,loop:t})=>({edge:e.id,loop:t,says:`${e.from===e.to?`${g(e.from)} to itself`:`${g(e.from)} to ${g(e.to)}`}${l(e)===`always`?``:` · when ${i(e)}`}${t?` · back into ${y.find(e=>e.id===t).name}: another round, until ${y.find(e=>e.id===t).stops.join(`; `)}`:``}`}))};if(n?.length){let t=s(n,e),r=new Map,i=[],a=e=>!!y.find(t=>t.id===e)?.inside,o=(e,t)=>{for(let n=y.find(t=>t.id===e)?.inside;n;n=y.find(e=>e.id===n)?.inside)if(n===t)return!0;return!1},c={},l={},d=E(O.edges),f=!1;for(let{focus:e,note:n}of t.steps.slice(1))if(e&&n){if(e.kind===`node`&&h(e.id)){let t=b(e.id),r=d.into(e.id).flatMap(e=>e.back?[e.back]:[]);for(let e of y)r.some(t=>o(e.id,t))&&delete l[e.id];t&&a(t)&&n.round!==void 0&&(f||=r.some(e=>o(t,e))?n.round!==0:r.includes(t)&&n.round<=(l[t]??-1),c[t]=l[t]=n.round),d.at(e.id,{round:null,outcome:n.outcome??null,verdict:n.verdict??null,open:n.outcome===`started`})}else e.kind===`loop`&&(n.round!==void 0&&(f||=n.round>(c[e.id]??n.round),c[e.id]=void 0),n.stop!==void 0&&d.stopped(e.id,n.stop===`human`))}let p={},m={},g=E(O.edges),_=t.steps.slice(1).map(t=>{let n=t.note,s=t.focus??{kind:`graph`},c=s.kind===`graph`||(s.kind===`node`?h(s.id):s.kind===`edge`?w.some(e=>e.id===s.id):y.some(e=>e.id===s.id))?s:{kind:`graph`},l=n.proposal?.summary??n.amendment?.summary??n.text??``,d=c.kind===`node`?e.nodes.find(e=>e.id===c.id):void 0,_=d?b(d.id):c.kind===`loop`?c.id:null,v=f&&d&&a(_)?void 0:n.round;for(let e of new Set(d?g.into(d.id).flatMap(e=>e.back?[e.back]:[]):[])){(e!==_||v===void 0)&&(p[e]=(p[e]??0)+1);for(let t of y)o(t.id,e)&&(p[t.id]=0)}let x=_?p[_]=v??p[_]??0:null;d&&g.at(d.id,{round:x,outcome:n.outcome??null,verdict:n.verdict??null,open:n.outcome===`started`}),c.kind===`loop`&&n.stop!==void 0&&g.stopped(c.id,n.stop===`human`);for(let e in p)m[e]=Math.max(m[e]??0,p[e]);let S={says:t.caption,about:c.kind,id:`id`in c?c.id:null,round:x,outcome:n.outcome??null,verdict:n.verdict??null,what:n.proposal?`proposal`:n.amendment?`amendment`:null,open:n.outcome===`started`,stop:c.kind===`loop`?n.stop??null:null,words:l.length>150?`${l.slice(0,l.lastIndexOf(` `,150))} …`:l};if(d&&(d.kind===`agent`||d.kind===`check`)&&!u(d)&&n.outcome&&n.outcome!==`started`){let e=e=>(Date.parse(n.ended??``)-Date.parse(e??``))/6e4,t=e(n.started)>=0?e(n.started):e(r.get(d.id));S.dispatch=i.push({node:d.id,loop:_,round:x,outcome:n.outcome??null,minutes:t>=0?t:null})-1,r.delete(d.id)}else d&&n.outcome===`started`&&n.started&&r.set(d.id,n.started);return S});O.run={end:t.end.line,at:t.end.at&&h(t.end.at.id)?t.end.at.id:null,dispatches:i,most:m,notes:_,rounds:Object.fromEntries(t.end.loops.map(e=>[e.loop,e.round??-1]))}}return O}function T(e,t,n){for(let r=e.find(e=>e.id===t)?.inside??null,i=0;r&&i<=e.length;r=e.find(e=>e.id===r)?.inside??null,i+=1)if(r===n)return!0;return!1}function E(e){let t=new Map,n=new Map,[r,i,a,o]=[0,null,null,null];return{into(r,s){if(a===r)return[];let c=n.get(r)??-1;return[...t].filter(([e,t])=>!t.open&&(e===r||t.k>c)).sort(([e,t],[n,r])=>Number(n===i)-Number(e===i)||r.k-t.k).flatMap(([t,n])=>{let i=e.filter(e=>e.from===t&&e.to===r&&!(e.back&&n.not.has(e.back)&&(s||e.back!==o))),a=i.find(e=>typeof e.on==`object`&&e.on.verdict===n.verdict)??i.find(e=>typeof e.on==`string`&&e.on===n.routes)??i.find(e=>e.on===void 0||e.on===`always`);return a?[{...a,r0:n.round??0}]:[]})},at(e,s){r+=1;let c=t.get(e);(s.open?!c||c.open:(s.outcome??s.verdict)!==null)&&t.set(e,{...s,k:r,routes:s.outcome===`invalid-evidence`&&c?.outcome===`invalid-evidence`&&!c.open&&c.round===s.round?`fail`:s.outcome,not:new Set}),n.set(e,r),[i,a,o]=[e,s.open?e:null,s.open||(s.outcome??s.verdict)!==null?null:o]},stopped(e,n){for(let n of t.values())n.not.add(e);(n||o===e)&&(o=n?e:null)}}}function D(e){let t=t=>e.edges.find(e=>e.id===t);if(!e.run)return e.pass.length?[{says:e.pass.length===1?`The graph's one edge is lit.`:`All ${e.pass.length} steps are lit. Move the slider or press Play to follow a first pass, one edge at a time.`},...e.pass.map((n,r)=>{let i=t(n.edge);return{says:`Step ${r+1} of ${e.pass.length}: ${n.says}`,edge:i.id,nodes:[i.from,i.to],from:i.from,to:i.to,r0:0,r1:+!!n.loop,...n.loop?{loops:[]}:{}}})]:[{says:`This graph has no edges to step through.`}];let{notes:n,dispatches:r,end:i}=e.run,a=e.loops.flatMap(e=>{let t=[...new Set(r.flatMap(t=>t.loop===e.id&&t.round!==null?[t.round]:[]))];return t.length?[`round${t.length===1?``:`s`} ${t.length>2?`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`:t.join(` and `)} of ${e.name}`]:[]}),o=[{says:`The whole run: ${r.length} dispatch${r.length===1?``:`es`}${a.length?`, in ${a.join(`; `)}`:``}. ${i} Move the slider or press Play to follow its ${n.length} notes.`}],s=E(e.edges),c=0,l=null;n.forEach((t,r)=>{let i=`Note ${r+1} of ${n.length}`,a={says:``,...t.dispatch===void 0?{}:{dispatch:t.dispatch}};if(t.about===`node`&&t.id){let e=t.round??0,[n,...r]=s.into(t.id);Object.assign(a,{says:`${i}: ${t.says}`,nodes:[t.id],to:t.id,r1:e},n?{edge:n.id,from:n.from,r0:n.r0}:{},r.length?{also:r.map(e=>({edge:e.id,r0:e.r0}))}:{}),s.at(t.id,{round:t.round,outcome:t.outcome,verdict:t.verdict,open:t.open}),[c,l]=[e,t.id]}else if(t.about===`loop`&&t.id)Object.assign(a,{says:`${i}: ${t.says}`,loops:[t.id]}),t.stop&&s.stopped(t.id,t.stop===`human`);else if(t.about===`edge`&&t.id){let n=e.edges.find(e=>e.id===t.id);Object.assign(a,{says:t.what?`${i}, a ${t.what} about the edge ${t.says}, not a move along it: ${t.words}`:`${i}, at the edge ${t.says}: ${t.words}`},n?{edge:n.id,nodes:[n.from,n.to],about:!0,r0:c}:{})}else a.says=`${i}, ${t.what?`an ${t.what}`:`about the run`}: ${t.words}`;o.push(a)});let u=o[n.findLastIndex(e=>e.about===`graph`&&e.outcome!==null)+1],d=e.run.at;if(d&&d!==l&&u!==o[0]&&!u.nodes&&!u.edge&&!u.loops){let[e,...t]=s.into(d,!0);e&&Object.assign(u,{nodes:[d],to:d,edge:e.id,from:e.from,r0:e.r0,r1:0},t.length?{also:t.map(e=>({edge:e.id,r0:e.r0}))}:{})}return o}var O=Math.PI*2,k=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n],A=(e,t)=>e.find(e=>e.id===t),j=(e,t)=>`loop-${e.loops.findIndex(e=>e.id===t)%4}`,M=(e,t,n={stand:!0})=>({t:`card`,at:t,id:e.id,key:`node:${e.id}`,...n}),N=(e,t,n,r=40,i=0,a=O)=>Array.from({length:r+1},(o,s)=>[e[0]+t*Math.cos(i+(a-i)*s/r),n,e[2]+t*Math.sin(i+(a-i)*s/r)]),P=e=>{let t=new Map(e.rows.flat().map((e,t)=>[e,t]));return n=>t.get(n)??e.rows.flat().length};function F(e,t){let n=P(e),r=e.loops.filter(e=>e.inside===t.id),i=t.members.filter(e=>!t.own.includes(e)&&!r.some(t=>t.members.includes(e)));return[...t.own.map(e=>({node:e,first:n(e)})),...r.map(e=>({loop:e,first:Math.min(...e.members.map(n))})),...i.map(e=>({away:e,first:n(e)}))].sort((e,t)=>e.first-t.first)}var I=(e,t)=>e.findIndex(e=>e.node===t||e.away===t||!!e.loop?.members.includes(t));function L(e){let t=P(e);return[...e.nodes.filter(e=>!e.loop).map(e=>({node:e.id,first:t(e.id)})),...e.loops.filter(e=>!e.inside).map(e=>({loop:e,first:Math.min(...e.members.map(t))}))].sort((e,t)=>e.first-t.first)}var R=(e,t,n,r=16)=>Array.from({length:r+1},(i,a)=>{let o=k(e,t,a/r);return[o[0],o[1]+n*4*(a/r)*(1-a/r),o[2]]}),z=(e,t,n,r={})=>({t:`line`,pts:n,stroke:t.back?j(e,t.back):`ink-2`,...t.back?{dash:[6,4]}:{},w:t.back?1.8:1.4,arrow:!0,key:`edge:${t.id}`,inset:[2,1],from:t.from,to:t.to,...r}),B=(e,t)=>{let n=Math.max(0,Math.min(1,t))*(e.length-1),r=Math.min(e.length-2,Math.floor(n));return e.length<2?e[0]:k(e[r],e[r+1],n-r)};function V(e,t,n){let[r,i]=[{},{}];for(let a of t.slice(1,n+1)){let t=a.to;if(!t)continue;let n=new Set(a.about?[]:[a.edge,...(a.also??[]).map(e=>e.edge)].flatMap(t=>e.edges.find(e=>e.id===t)?.back??[]));for(let t of n)for(let n of e.loops)T(e.loops,n.id,t)&&(i[n.id]=0);for(let o of e.loops){if(!o.members.includes(t))continue;o.own.includes(t)?i[o.id]=a.r1??0:i[o.id]=(i[o.id]??0)+ +!!n.has(o.id);let s=F(e,o),c=i[o.id]+Math.max(0,I(s,t))/s.length;r[o.id]={now:c,most:Math.max(c,r[o.id]?.most??0)}}}return r}function H(e,t,n){let r=t[n],i=e=>e.edge&&!e.about?[{edge:e.edge,r0:e.r0??0},...e.also??[]].map(t=>({...t,r1:e.r1??0})):[],a=r.about&&r.edge?[`edge:${r.edge}`]:i(r).flatMap(e=>[`edge:${e.edge}`,`edge:${e.edge}@${e.r0}>${e.r1}`]),o=[...(r.nodes??[]).map(e=>`node:${e}`),...a,...(r.loops??[]).map(e=>`loop:${e}`)],s={k:n,lit:o.length?new Set(o):null,took:e.run?t.flatMap((e,t)=>i(e).map(e=>({...e,step:t}))):[]};return r.about&&r.edge&&(s.about={edge:r.edge,r0:r.r0??0}),e.run&&n>0&&(s.dispatches=t.slice(1,n+1).filter(e=>e.dispatch!==void 0).length),e.run&&(s.until=V(e,t,n||t.length-1)),s}var U=84,[W,G]=[.8,.4];function K(e,t){let n=[...e.map(e=>({loop:e,name:e.name,ids:e.members,sub:`loop`,depth:0})),...t.filter(e=>e.from).map(e=>({group:e,name:e.name,ids:e.nodes,sub:`subgrooph, from ${e.from}`,depth:0}))].filter(e=>e.ids.length>0),r=(e,t,n)=>{for(let r=t.inside,i=0;r&&i<=e.length;r=e.find(e=>e.id===r)?.inside??null,i+=1)if(r===n.id)return!0;return!1},i=(e,t)=>e.ids.every(e=>t.ids.includes(e)),a=(n,a)=>n!==a&&(n.loop&&a.loop?r(e,a.loop,n.loop):n.group&&a.group?r(t,a.group,n.group):n.group?i(a,n):i(a,n)&&n.ids.length>a.ids.length);for(let e of n)e.depth=n.filter(t=>a(t,e)).length+1;return n}var q=e=>{let t=[],n={},r=K(e.loops,e.groups),i=e=>Math.max(0,...r.filter(t=>t.ids.includes(e)).map(e=>e.depth));for(let t of e.nodes)n[t.id]=[t.at[0]*W,-t.at[1]*G,i(t.id)*U];for(let r of e.nodes)t.push(M(r,n[r.id],{}));let a=(e,t)=>{let r=e.map(e=>n[e]);return[Math.min(...r.map(e=>e[0]))-58-t,Math.max(...r.map(e=>e[0]))+58+t,Math.min(...r.map(e=>e[1]))-22-t,Math.max(...r.map(e=>e[1]))+22+t]},[o,s,c,l]=a(e.nodes.map(e=>e.id),42);t.push({t:`poly`,pts:[[o,c,-8],[s,c,-8],[s,l,-8],[o,l,-8]],fill:`floor`,fa:.7,stroke:`line-strong`,lift:-600}),t.push({t:`text`,at:[o+4,l+10,-8],text:`the picture`,fill:`ink-3`,size:10});for(let n of r){let[r,i,o,s]=a(n.ids,8+(4-Math.min(4,n.depth))*9),c=n.depth*U-12,l=n.loop?j(e,n.loop.id):`ink-3`;t.push({t:`poly`,pts:[[r,o,c],[i,o,c],[i,s,c],[r,s,c]],fill:l,fa:n.loop?.15:.08,stroke:l,...n.loop?{key:`loop:${n.loop.id}`}:{dash:[5,4]},w:1.3,lift:n.depth*30-80});let[u,d]=[[[r+4,s+10,c],[i-4,s+10,c]],[[r+4,o-10,c],[i-4,o-10,c]]],[f,p]=n.depth%2?[u,d]:[d,u];t.push({t:`text`,at:f[0],text:`${n.name} · ${n.sub}`,fill:l,size:10.5,bold:!0,max:200,or:[{at:f[1],align:`right`},{at:p[0]},{at:p[1],align:`right`},{at:[r-6,(o+s)/2,c],align:`right`},{at:[i+6,(o+s)/2,c]}]}),t.push({t:`line`,pts:[[r,o,-8],[i,o,-8],[i,s,-8],[r,s,-8],[r,o,-8]],stroke:l,w:1,dash:[2,4],alpha:.6})}let u={};return e.edges.forEach((r,i)=>{let[a,o]=[n[r.from],n[r.to]],s=e.edges.slice(0,i).filter(e=>e.from===r.from&&e.to===r.to||e.from===r.to&&e.to===r.from).length,c=r.back||r.from===r.to,l=(c?70+Math.abs(a[1]-o[1])*.2:0)+22*s,d=c?50:0,[f,p]=r.from===r.to?[1,0]:[o[1]-a[1],a[0]-o[0]],m=(f<0||!f&&p>0?-l:l)/(Math.hypot(f,p)||1);u[r.id]=l?Array.from({length:19},(e,t)=>(e=>[e[0]+m*f*4*(t/18)*(1-t/18),e[1]+m*p*4*(t/18)*(1-t/18),e[2]])(k([a[0]+d,a[1],a[2]],[o[0]+d,o[1],o[2]],t/18))):[a,o],t.push(z(e,r,u[r.id],{inset:[4,8]}))}),{prims:t,node:e=>n[e],path:e=>u[e]}},J=54,Y=(e,t)=>t.cap??Math.max(e.run?(e.run.most[t.id]??-1)+1:1,1)+2;function X(e,t){let n=e.cap,r=e.brakes.findIndex(e=>e.kind===`max-iterations`&&e.n===n),i=e.brakes.map((e,i)=>{if(e.kind!==`human`||!e.every)return null;let a=Array.from({length:Math.floor(t/e.every)},(t,n)=>(n+1)*e.every);return{within:a,drawn:a.filter(e=>n===null||e<n||e===n&&i<r)}}),a=[...new Set(i.flatMap(e=>e?.drawn??[]))].sort((e,t)=>e-t),o=e.dispatches!==null&&e.perRound?e.dispatches/e.perRound:null,s=o!==null&&o<=t+1.5?o:null,c=e.brakes.map((t,r)=>{if(t.kind===`max-iterations`)return`max iterations: ${t.n}${t.n===n?` (the lid, over round ${t.n-1})`:` (a looser cap: the lid stops the loop first)`}`;if(t.kind===`human`){let e=i[r];if(!e)return`human halt (no place on the way up)`;let n=e.drawn.length?`the amber ring${e.drawn.length===1?``:`s`}`:e.within.length?`no ring: only at the lid, where the cap is looked at first`:`not within the rounds drawn`;return`a person is asked every ${t.every===1?`round`:`${t.every} rounds`} (${n})`}if(t.measure!==`dispatches`||!e.perRound)return`budget: ${t.limit} ${t.measure} (no place on the way up)`;let[a,o]=[Math.floor(t.limit/e.perRound),t.limit%e.perRound];return`budget: ${t.limit} dispatches, at most ${a} full round${a===1?``:`s`}${o?` and ${o} more`:``}${t.limit===e.dispatches?s===null?` (not drawn: above the rounds shown)`:` (the dashed ring, a reading)`:` (a looser budget)`}`});return n===null&&c.unshift(`no lid: no cap on rounds`),{words:c,lid:n,asked:a,budget:s}}var Z=e=>e===`pass`?`ok`:e===`fail`?`bad`:`ink-3`,Q=(e,t)=>{let n=[],r={},i={},a=t=>Math.max(e.narrow?76:64,F(e,t).length*(e.narrow?31:27)),o=(e,t,n=0)=>[e.c[0]-(e.r+n)*Math.cos(O*t),e.c[1]+t*J,e.c[2]+(e.r+n)*Math.sin(O*t)],s=(e,t,n)=>{let r=Math.max(1,Math.ceil(Math.abs(n-t)*36));return Array.from({length:r+1},(i,a)=>o(e,t+(n-t)*a/r))};function c(c,l){let u=F(e,c),d=Math.max(1,u.length),f=i[c.id]={c:l,r:a(c),stops:u,k:d},p=j(e,c.id),m=e.run?t.until?.[c.id]??null:null,h=e.run?m?.most??null:(d-1)/d,g=Y(e,c);n.push({t:`poly`,pts:N(l,f.r+12,l[1]),fill:`floor`,fa:.8,stroke:`line`,lift:-400}),n.push({t:`line`,pts:[[l[0],l[1],l[2]],[l[0],l[1]+g*J,l[2]]],stroke:`line-strong`,w:1}),n.push({t:`line`,pts:s(f,0,g),stroke:p,w:1.3,alpha:.5,dash:[3,4]}),h!==null&&h>0&&n.push({t:`line`,pts:s(f,0,Math.min(h,g)),stroke:p,w:3.2,key:`loop:${c.id}`});let _=X(c,g);_.lid!==null&&n.push({t:`poly`,pts:N(l,f.r+18,l[1]+_.lid*J),fill:`brake`,fa:.24,stroke:`brake`,w:1.8,lift:300});for(let e of _.asked)n.push({t:`line`,pts:N(l,f.r+(e===_.lid?9:18),l[1]+e*J),stroke:`k-gate`,w:2.2,lift:320});_.budget!==null&&n.push({t:`line`,pts:N(l,f.r+18,l[1]+_.budget*J),stroke:`brake`,w:1.2,dash:[4,4],alpha:.85});let v=Math.max(g,_.budget??0),y=e.run?m===null?`
|
|
4
|
-
not entered`:`\nround ${Math.floor(m.now)}${c.cap?`, lid over round ${c.cap-1}`:``}`:``;n.push({t:`text`,at:[l[0],l[1]+v*J+46,l[2]],text:`${c.name}${y}`,align:`center`,up:!0,fill:p,size:11,bold:!0,max:Math.max(120,2*f.r+30)}),u.forEach((t,i)=>{if(t.node){let a=o(f,i/d,46);r[t.node]=[a[0],a[1]-30,a[2]],n.push(M(A(e.nodes,t.node),r[t.node],{stand:!0,small:e.narrow}),{t:`line`,pts:[o(f,i/d),o(f,i/d,30)],stroke:p,w:1,alpha:.7})}else t.loop?n.push({t:`text`,at:o(f,i/d,e.narrow?84:34),text:`${t.loop.name}: the spiral ${e.narrow?`above`:`beside`}`,align:`center`,fill:j(e,t.loop.id),size:10.5,bold:!0,max:96}):t.away&&n.push({t:`text`,at:o(f,i/d,34),text:`${A(e.nodes,t.away).name}: on ${A(e.loops,A(e.nodes,t.away).loop).name}`,align:`center`,fill:`ink-3`,size:10.5,max:96})});let b=(e.run?.dispatches??[]).flatMap((e,n)=>{let r=u.findIndex(t=>t.node===e.node);return r<0||e.round===null?[]:[{d:e,i:r,round:e.round,shown:t.dispatches===void 0||n<t.dispatches}]}),x={};for(let{d:e,i:t,round:r,shown:i}of b){let a=`${r}:${t}`,s=x[a]=(x[a]??-1)+1,c=Math.min(13,(f.r-10)/Math.max(1,b.filter(e=>`${e.round}:${e.i}`===a).length-1));i&&n.push({t:`dot`,at:o(f,r+t/d,-c*s),r:6,fill:Z(e.outcome),stroke:`card`})}}let l=[],u=t=>(e.loops.filter(e=>e.inside===t.id).forEach(u),void l.push({loop:t,first:0}));for(let t of L(e))t.loop?u(t.loop):l.push(t);let d=l.findIndex(e=>e.loop),f=l.length-1-[...l].reverse().findIndex(e=>e.loop),p=0;if(e.narrow&&d>=0){let t=0;for(let n of l){let i=n.loop?Y(e,n.loop):0,[o,s]=n.loop?[Math.max(i,X(n.loop,i).budget??0)*J+96,.3*(a(n.loop)+50)+56]:[23,23];t+=o,n.loop?c(n.loop,[0,-t,0]):r[n.node]=[-60,-t,0],t+=s}}else l.forEach((e,t)=>{if(e.loop){let t=a(e.loop)+40;c(e.loop,[p+t,0,0]),p+=2*t+56}else d>=0&&t>d&&t<f&&(r[e.node]=[p+20,0,130],p+=190)});e.narrow&&d>=0||(d>=0?(l.slice(0,d).reverse().forEach((e,t)=>r[e.node]=[-170-t*56,0,-230-t*124]),l.slice(f+1).forEach((e,t)=>r[e.node]=[p-6+t*20,0,130+t*124])):(l.forEach((t,n)=>r[t.node]=e.narrow?[0,(l.length-1-n)*52,0]:[n*20,0,(n-(l.length-1)/2)*150]),n.push({t:`text`,at:e.narrow?[60,l.length*52+10,0]:[10*l.length,60,-75*l.length],text:`No loop in this graph: nothing goes round, and there is no spiral to draw.`,align:`center`,up:!0,fill:`ink-3`,size:11,max:220})));for(let t of l)t.node&&n.push(M(A(e.nodes,t.node),r[t.node],{stand:!0,side:!0,small:d>=0}),{t:`dot`,at:r[t.node],r:3,fill:`ink-2`,lift:-3990});let m=(t,n=0)=>{let a=e.loops.find(n=>n.id===A(e.nodes,t).loop),s=a&&i[a.id],c=s?s.stops.findIndex(e=>e.node===t):-1;return s&&c>=0?o(s,n+c/s.k):r[t]},h=t=>e.loops.find(e=>e.own.includes(t.from)&&e.own.includes(t.to)),g=(t,n=0,r=0)=>{let a=A(e.edges,t),c=e.edges.slice(0,e.edges.indexOf(a)).filter(e=>e.from===a.from&&e.to===a.to).length,u=h(a);if(u){let t=i[u.id],[l,d]=[t.stops.findIndex(e=>e.node===a.from),t.stops.findIndex(e=>e.node===a.to)],f=a.back===u.id;if(!a.back&&d===l+1||f&&l===t.k-1&&d===0)return s(t,n+l/t.k,(f?n+1:r)+d/t.k);let p=!a.back||f?r:T(e.loops,u.id,a.back)?0:e.run?r:n;return R(o(t,n+l/t.k),o(t,p+d/t.k),26+14*c,18)}let d=(t,n)=>A(e.nodes,t).loop?n:0,f=A(e.nodes,a.to).loop,p=a.back?f&&T(e.loops,f,a.back)?0:f===a.back||e.run?d(a.to,r):0:d(a.to,r),g=e=>l.findIndex(t=>t.node===e||!!t.loop?.own.includes(e)),[_,v]=[g(a.from),g(a.to)].sort((e,t)=>e-t),y=A(e.nodes,a.from).loop&&f?0:26*l.slice(_+1,v).filter(e=>e.node).length,[b,x]=[m(a.from,d(a.from,n)),m(a.to,p)];if(!e.narrow)return R(b,x,(a.back?40:y)+14*c,18);let S=e=>e.own.includes(a.from)||e.own.includes(a.to),C=e.loops.flatMap(t=>[i[t.id].c[1]+Y(e,t)*J,...S(t)&&Math.abs((t.own.includes(a.from)?b:x)[1]-i[t.id].c[1])>=J?[i[t.id].c[1]]:[]].map(e=>({loop:t,u:(e-b[1])/(x[1]-b[1]||1)}))).filter(e=>e.u>0&&e.u<1),w=C.find(e=>S(e.loop))?.loop,E=!y&&(w?(w.own.includes(a.from)?b:x)[0]>0:b[0]>0&&x[0]>0)?1:-1,D=a.back?40:y*1.3;for(let{loop:e,u:t}of C)D=Math.max(D,(i[e.id].r+30-E*(b[0]+(x[0]-b[0])*t))/Math.max(.36,4*t*(1-t)));return D+=26*c+12*n+10*r,R(b,x,0,18).map((e,t)=>[e[0]+E*D*4*(t/18)*(1-t/18),e[1],e[2]])},_=new Set,v=(r,a,o,s={})=>{let c=`edge:${r.id}@${a}>${o}`;if(_.has(c))return;_.add(c);let l=r.back?void 0:h(r),u=l&&i[l.id],d=!!u&&u.stops.findIndex(e=>e.node===r.to)===u.stops.findIndex(e=>e.node===r.from)+1;n.push(z(e,r,g(r.id,a,o),{key:c,...d&&l?{hide:!t.lit?.has(c),stroke:j(e,l.id),w:3.2}:{},...s}))};for(let n of e.edges){let r=t.took.filter(e=>e.edge===n.id&&(t.k===0||e.step<=t.k));if(!e.run)v(n,0,+!!n.back);else if(r.length)for(let e of r)v(n,e.r0,e.r1);else t.took.some(e=>e.edge===n.id)||v(n,0,+!!n.back,{alpha:.3})}if(t.about){let r=A(e.edges,t.about.edge);n.some(e=>e.key?.startsWith(`edge:${r.id}@`))||v(r,0,+!!r.back,{alpha:.3});for(let e of n)e.key?.startsWith(`edge:${r.id}@`)&&(e.hide=!1,t.lit?.add(e.key))}for(let e of n)e.t!==`card`&&(e.grow=!0);return{prims:n,node:m,path:g}},$=n(),ee={arch:R,by:A,card:M,circle:N,edgeLine:z,ground:L,hue:j,lerp:k,stations:F,TAU:O,under:T},te={panes:{view:q,start:{yaw:-.86,pitch:.16},as:`panes`,apart:2,says:`Every node is where the picture has it, one pane toward you for each loop or subgrooph around it; loops that only share a node are panes at one depth. An edge that changes depth is entering or leaving a loop or a subgrooph.`},spiral:{view:Q,start:{yaw:-.42,pitch:.3},as:`a spiral for each loop`,apart:7,says:`A round of a loop is one turn upward, and a brake that counts rounds is a place on the way up. A loop inside another is a spiral of its own, where its rounds start afresh; a node two loops share stands on one of them.`,brakes:!0}},ne=!1,re=()=>matchMedia(`(prefers-reduced-motion: reduce)`).matches;function ie({doc:e,kind:t,its:n,wide:i,of:a,drawn:o}){if(!ne){let e=document.createElement(`style`);e.textContent=m,document.head.append(e),ne=!0}let s=n??te[t],[c,l]=(0,p.useState)(i<640),u=(0,p.useMemo)(()=>w(e,r(e,C(i),f).positions,a.notes,c),[e,i,a.notes,c]),d=e=>[...u.loops.filter(t=>t.members.includes(e)).sort((e,t)=>e.members.length-t.members.length).map(e=>`in the loop ${e.name}`),...u.groups.filter(t=>t.nodes.includes(e)).sort((e,t)=>e.nodes.length-t.nodes.length).map(e=>`in the ${e.from?`subgrooph`:`group`} ${e.name}`)].join(`, `),h=(0,p.useMemo)(()=>D(u),[u]),[g,_]=(0,p.useState)(0),[v,y]=(0,p.useState)(!1),x=Math.min(g,h.length-1),S=h[x],T=(0,p.useRef)(null),E=(0,p.useRef)(null),O=(0,p.useRef)(null),k=(0,p.useRef)(void 0),A=(0,p.useRef)(0),j=(0,p.useRef)(!1),M=(0,p.useRef)(0);(0,p.useLayoutEffect)(()=>{let e=()=>l(T.current.clientWidth<640);e();let t=new ResizeObserver(e);return t.observe(T.current),()=>t.disconnect()},[]),(0,p.useLayoutEffect)(()=>{let e=k.current=b(T.current,E.current,O.current,s.start,s.apart),t=0,n;return re()||(e.grown=0,n=setTimeout(()=>{let n=performance.now(),r=i=>{e.grown=Math.min(1,(i-n)/700),e.draw(),e.grown<1&&(t=requestAnimationFrame(r))};t=requestAnimationFrame(r)},330)),()=>(clearTimeout(n),cancelAnimationFrame(t),cancelAnimationFrame(A.current),e.off())},[t]),(0,p.useLayoutEffect)(()=>{let e=k.current,t=H(u,h,x),n=s.view(u,t);e.lit=t.lit,cancelAnimationFrame(A.current);let r=S.edge&&!S.about?n.path(S.edge,S.r0,S.r1):null;if(r&&r.length>1&&x===M.current+1&&!re()){let t={t:`dot`,at:r[0],r:9.5,over:!0};e.set([...n.prims,t]);let i=performance.now(),a=n=>{let o=Math.min(1,(n-i)/620);t.at=B(r,1-(1-o)**3),t.hide=o===1,e.draw(),o<1&&(A.current=requestAnimationFrame(a))};A.current=requestAnimationFrame(a)}else e.set(n.prims);M.current=x,e.draw(),j.current||(j.current=!0,o?.())},[u,t,x]),(0,p.useEffect)(()=>{if(!v)return;if(x>=h.length-1)return y(!1);let e=setTimeout(()=>_(x+1),x===0?150:1150);return()=>clearTimeout(e)},[v,x,h.length]);let N=e=>(y(!1),_(Math.max(0,Math.min(h.length-1,e)))),P=u.run?`note`:`step`;return(0,$.jsxs)(`div`,{className:`s3`,"data-picture":`space`,"data-kind":t,children:[(0,$.jsxs)(`div`,{className:`s3-bar`,children:[(0,$.jsx)(`span`,{children:`Drag to turn. Pinch to move in and out.`}),(0,$.jsx)(`span`,{className:`s3-tight`,children:`Not every card has room here. Move in to read them, or close the details if they are open under this view.`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Move out`,onClick:()=>k.current?.zoom(.8),children:`−`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Move in`,onClick:()=>k.current?.zoom(1.25),children:`+`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>k.current?.reset(),children:`Starting view`})]}),(0,$.jsxs)(`div`,{ref:T,className:`s3-frame`,tabIndex:0,role:`group`,"aria-label":`${u.name} as ${s.as}: ${u.nodes.length} card${u.nodes.length===1?``:`s`}, ${u.edges.length} edge${u.edges.length===1?``:`s`}${u.loops.length?`, and ${u.loops.length===1?`the loop`:`the loops`} ${u.loops.map(e=>e.name).join(`, `)}`:``}. Drag to turn it; the arrow keys turn it too, and plus and minus move in and out.`,children:[(0,$.jsx)(`canvas`,{ref:E,"aria-hidden":`true`}),(0,$.jsx)(`div`,{ref:O,children:u.nodes.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`s3-card`,"data-node":e.id,"data-kind":e.kind,"aria-label":`${e.word} ${e.name}`,...d(e.id)?{"aria-description":d(e.id)}:{},onClick:t=>(t.detail===0||!k.current?.dragged())&&a.onNodeTap?.(e.id),children:[(0,$.jsx)(`b`,{children:e.name}),(0,$.jsx)(`span`,{children:e.line})]},e.id))})]}),(0,$.jsxs)(`div`,{className:`s3-steps`,children:[(0,$.jsx)(`button`,{type:`button`,className:v?`is-on`:void 0,onClick:()=>v?y(!1):(x>=h.length-1&&_(0),y(!0)),children:v?`Pause`:`Play`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Previous ${P}`,onClick:()=>N(x-1),children:`‹`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Next ${P}`,onClick:()=>N(x+1),children:`›`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:h.length-1,step:1,value:x,"aria-label":u.run?`Note, in the order the run wrote them`:`Step, in the order a first pass takes them`,onChange:e=>N(Number(e.target.value))})]}),(0,$.jsx)(`output`,{className:`s3-says`,"aria-live":`polite`,children:S.says}),s.brakes&&u.loops.length?(0,$.jsx)(`ul`,{className:`s3-key`,"aria-label":`Each loop's brakes`,children:u.loops.map((e,t)=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`b`,{style:{color:`var(--loop-${t%4})`},children:e.name}),` `,X(e,Y(u,e)).words.join(`; `)]},e.id))}):null,s.under?.(u,H(u,h,x)),(0,$.jsxs)(`p`,{className:`s3-note`,children:[s.says,t===`panes`&&!u.loops.length&&!u.groups.some(e=>e.from)?` This graph has no loop and no subgrooph, so nothing is lifted.`:``]})]})}export{ie as Stage3,ee as tools};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-stage-BkrQGQ-z.js","assets/index-CeaKwKuU.js","assets/share-BzIzB4EY.js","assets/graph-more-393HTgQE.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,c as t,n,r,t as i}from"./index-CeaKwKuU.js";import{Gt as a,Ht as o,S as s,T as c,Wt as l,en as u,l as d}from"./share-BzIzB4EY.js";var f=t(e(),1),p=()=>typeof document.startViewTransition!=`function`||matchMedia(`(prefers-reduced-motion: reduce)`).matches,m=[],h=0;function g(e,t){if(p())return t(()=>{},()=>{});let n=[],r=++h,i=e=>{if(r===h){for(let e of m)for(let t of[`name`,`class`])e.style.removeProperty(`view-transition-${t}`);m=[];for(let[t,r]of e)t.style.setProperty(`view-transition-name`,`gv${n.includes(r)?n.indexOf(r):n.push(r)-1}`),t.style.setProperty(`view-transition-class`,`gv`),m.push(t)}};i(e());let a=document.startViewTransition(()=>new Promise(n=>t(()=>(i(e()),n()),()=>a.skipTransition())));a.ready.catch(()=>{});let o=()=>i([]);a.finished.then(o,o)}var _=`.graph-views{z-index:6;pointer-events:none;position:absolute;inset:0}.stage:has(>.graph-views)>.loop-legend{right:196px}.stage:has(>.graph-views.is-space)>.loop-legend{display:none}.graph-switch{z-index:2;pointer-events:auto;box-shadow:var(--shadow);flex-wrap:nowrap;position:absolute;top:26px;right:10px}.graph-switch .seg{min-width:78px;min-height:36px}.graph-views-note{z-index:2;border:1px solid var(--line-strong);background:var(--surface);text-align:center;pointer-events:auto;border-radius:10px;width:min(92%,44ch);margin:0;padding:8px 12px;font-size:13px;position:absolute;top:74px;left:50%;transform:translate(-50%)}.graph-space{z-index:1;background:var(--bg);pointer-events:auto;padding:118px 0 104px;position:absolute;inset:0;overflow:auto}.graph-space .map-picture{padding:0}@media (max-width:899px){.run-view:has(>.run-stage>.graph-views.is-space){grid-template-rows:auto minmax(220px,82dvh) minmax(0,1fr)}}.run-stage .graph-space{padding-bottom:16px}.run-stage:has(>.graph-views.is-space)>.canvas-size{display:none}@media (min-width:1100px){.graph-space{padding:118px 28px 104px}}@media (max-width:899px){[data-space-folds] .sheet-body{display:none}[data-space-folds] .sheet-toggle{visibility:hidden}}.graph-kinds{z-index:2;pointer-events:auto;box-shadow:var(--shadow);flex-wrap:nowrap;position:absolute;top:74px;right:10px}.graph-kinds .seg{min-width:62px;min-height:36px}.graph-views.is-space .graph-views-note{top:118px}.graph-views.is-space:has(>.graph-views-note)>.graph-space{padding-top:188px}::view-transition-group(.gv){animation-duration:.3s}::view-transition-old(root){animation-duration:.3s}::view-transition-new(root){animation-duration:.3s}::view-transition-old(.gv){animation:.3s both gv-goes}::view-transition-new(.gv){animation:.3s both gv-comes}@keyframes gv-goes{35%{opacity:1}65%,to{opacity:0}}@keyframes gv-comes{0%,35%{opacity:0}65%{opacity:1}}`,v=i(),y,b,x,S=!1,C=[[`stairs`,`Stairs`,`Each loop is a floor with its own nodes standing on it; a loop inside it has a floor of its own.`],[`panes`,`Panes`,`The picture as it is, with each loop and each subgrooph lifted toward you on a pane of its own.`],[`spiral`,`Spiral`,`Each loop is a spiral: a round is one turn upward, and the brakes that count rounds are places on the way up, the lid where max iterations stops it.`],[`rings`,`Rings`,`Each loop is a ring, with its own nodes standing around it; a loop inside another is a ring standing on the outer one.`],[`columns`,`Columns`,`Every node where the picture has it, an agent as a column: taller for a higher tier (an order, not a model), and on a run a block for each dispatch, as tall as its own minutes.`]],w=e=>e===`stairs`?`space`:e===`rings`||e===`columns`?`more`:`stage`,T=e=>!!(e===`stairs`?y:b&&(w(e)===`stage`||x)),E,D=()=>{if(E)return E;try{let e=sessionStorage.getItem(`groophSpace`);return C.find(([t])=>t===e)?.[0]??`stairs`}catch{return`stairs`}},O=e=>{E=e;try{sessionStorage.setItem(`groophSpace`,e)}catch{}},k={"human-gate":[`Human gate`,`gate`],check:[`Check`,`check`],merge:[`Merge`,`merge`],stop:[`Stop`,`stop`]},A=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function j(e){let t=new Map(s(e).flat().map((e,t)=>[e,t])),n=e=>!!e&&t.has(e.from)&&t.has(e.to),r=new Map(e.loops.flatMap(e=>e.back.map(t=>[t,e]))),i=e.edges.filter(e=>n(e)&&!r.has(e.id)).sort((e,n)=>t.get(e.from)-t.get(n.from)||t.get(e.to)-t.get(n.to)),a=[...r].map(([t,n])=>({edge:e.edges.find(e=>e.id===t),loop:n})).filter(e=>n(e.edge));return[...i.map(e=>({edge:e})),...a]}function M(e,t,n,r){let[,,,,,,,,,,,,,,,i,,,,,,,f,,,,p,,m]=d,h=i(`auto`),g=t=>e.nodes.find(e=>e.id===t)?.name||t,_=s(e).flat(),v=new Map(_.map((e,t)=>[e,t])),y=e.loops.map((e,t)=>({loop:e,k:t,members:new Set(e.members)})),b=(e.groups??[]).filter(e=>e.from),x=e=>{let t=y.filter(t=>t.members.has(e)).sort((e,t)=>e.members.size-t.members.size)[0];if(t)return`loop ${t.loop.id}`;let n=b.find(t=>t.members.includes(e));return n?`unit ${n.id}`:``},S=new Map;for(let t of _){let n=e.nodes.find(e=>e.id===t);(S.get(x(t))??S.set(x(t),[]).get(x(t))).push(n)}let C=e=>{let t=e.kind===`agent`&&e.by===`person`,[r,i]=e.kind===`agent`?t?[`Person · ${u(e)}`,`gate`]:[u(e),`accent`]:k[e.kind],a=e.kind===`agent`&&!t&&e.model?e.model.tier:``,o=m(e.name||e.id,n-16,12.5,3,`bold`),s=7+o.length*15+13+(a?11.5:0)+6;return{id:e.id,h:s,svg:()=>{let t=e.kind===`human-gate`?{fill:h(`gate-soft`),stroke:h(`gate`),rx:12,width:1.8}:{fill:h(`surface`),stroke:h(e.kind===`agent`?`line-strong`:i),rx:e.kind===`stop`?2:8,width:e.kind===`agent`?1:1.4},c=5,l=o.map(e=>p(8,c+=15,e,{size:12.5,fill:h(`ink`),weight:`bold`}));return`<g data-node="${A(e.id)}" data-kind="${e.kind}">${f(.7,.7,n-1.4,s-1.4,{...t,mark:`card`})}${l.join(``)}${p(8,c+=13,m(r,n-16,9.5,1,`bold`)[0],{size:9.5,fill:h(i),weight:`bold`})}${a?p(8,c+11.5,a,{size:9,fill:h(`ink-3`)}):``}</g>`}}},w=[...S.keys()].filter(e=>e!==``).sort((e,t)=>v.get(S.get(e)[0].id)-v.get(S.get(t)[0].id)),T=[...S.has(``)||w.length===0?[``]:[],...w].map((t,n)=>{let r=(S.get(t)??[]).map(C),i=y.find(e=>`loop ${e.loop.id}`===t),a=b.find(e=>`unit ${e.id}`===t);if(i){let e=y.filter(e=>e!==i&&i.loop.members.every(t=>e.members.has(t))).sort((e,t)=>e.members.size-t.members.size)[0];return{cls:``,mark:`data-loop="${A(i.loop.id)}"`,name:i.loop.name||i.loop.id,place:`loop`,sub:`${e?`inside ${e.loop.name||e.loop.id} · `:``}stops: ${i.loop.stops.map(o).join(`; `)}`,gap:n===0?0:1,items:r}}return a?{cls:``,mark:`data-unit="${A(a.id)}"`,name:a.name||a.id,place:`subgrooph`,sub:`from ${a.from}`,gap:n===0?0:1,items:r}:{cls:` is-people`,mark:`data-outside=""`,name:w.length?`Outside any loop`:e.name||e.id,place:``,sub:w.length?`what a run passes once`:`no loop`,gap:0,items:r}}),E=j(e),D=E.map(({edge:t,loop:n},r)=>({id:t.id,n:r+1,from:t.from,to:t.to,style:n?{color:`loop-${e.loops.indexOf(n)%4}`,dash:`6 4`,width:2.2}:{color:`ink-2`,width:1.6}})),O=E.length,M=[{short:`all steps`,says:O===0?`This graph has no edges to step through.`:O===1?`The graph's one edge is lit.`:`All ${O} steps are lit. Move the slider or press Play to follow a first pass, one edge at a time.`}];E.forEach(({edge:e,loop:t},n)=>{let r=l(e)===`always`?``:` · when ${a(e)}`;M.push({handoff:e.id,short:`step ${n+1} of ${O}`,says:`Step ${n+1} of ${O}: ${e.from===e.to?`${g(e.from)} to itself`:`${g(e.from)} to ${g(e.to)}`}${r}${t?` · back into ${t.name||t.id}: another round, until ${t.stops.map(o).join(`; `)}`:``}`})});let N={title:e.name||e.id,sheets:T,links:D,per:t,link:`edge`,links_:`edges`,none:` · no nodes`,flat:` The picture shows the same graph, flat. <button type="button" data-flat="picture">Picture</button>`};if(r?.length){let t=c(r,e),n=new Set(T.map(e=>e.mark)),i=t=>t?.kind===`edge`?{handoff:t.id}:t?.kind===`node`?{ends:[t.id]}:t?.kind===`loop`?n.has(`data-loop="${A(t.id)}"`)?{sheet:`data-loop="${A(t.id)}"`}:{ends:e.loops.find(e=>e.id===t.id)?.members??[]}:{};return{...N,stops:t.steps.map((e,t)=>t===0?{short:`before the run`,says:`Before the run: ${r.length} note${r.length===1?``:`s`} to follow. Move the slider or press Play.`}:{short:`note ${t} of ${r.length}`,says:`Note ${t} of ${r.length}: ${e.caption}`,alone:!0,...i(e.focus)}),step:`note`,range:`Note, in the order the run wrote them`,note:`The run's own notes, in the order it wrote them. ${t.end.line}`}}return{...N,stops:M,range:`Step, in the order a first pass takes them`,note:`The edges a first pass takes, in order, and then one turn of each loop. An order, not a clock: a graph records no times.`}}var N=class extends f.Component{state={lost:!1};static getDerivedStateFromError(){return{lost:!0}}componentDidCatch(){this.props.lost()}render(){return this.state.lost?null:this.props.children}};function P({doc:e,of:t}){let[i,a]=(0,f.useState)(`picture`),[o,s]=(0,f.useState)(D),[c,l]=(0,f.useState)(`picture`),[u,p]=(0,f.useState)(y),[m,h]=(0,f.useState)(b),[E,A]=(0,f.useState)(x),[j,P]=(0,f.useState)(),F=(0,f.useRef)({}),[I,ee]=(0,f.useState)(3),L=(0,f.useRef)({doc:e,at:innerWidth});L.current.doc!==e&&(L.current={doc:e,at:innerWidth});let R=(0,f.useRef)(null),te=(0,f.useRef)(void 0);if(!S){let e=document.createElement(`style`);e.textContent=_,document.head.append(e),S=!0}let ne=()=>{let t=R.current?.parentElement;if(!t)return[];let n=[...t.querySelectorAll(`.space-card, .s3-card`)].map(e=>[e,e.dataset.node??e.querySelector(`[data-node]`)?.dataset.node??``]),[r,i]=[t,t.querySelector(n.length?`.space-scene, .s3-frame`:`.react-flow`)??t].map(e=>e.getBoundingClientRect());return(n.length?n:[...t.querySelectorAll(`.react-flow__node[data-id]`)].map(e=>[e,e.dataset.id])).filter(([t,n])=>{let a=t.getBoundingClientRect();return e.nodes.some(e=>e.id===n)&&a.left>Math.max(r.left,i.left)-1&&a.right<Math.min(r.right,i.right)+1&&a.top>Math.max(r.top,i.top)-1&&a.bottom<Math.min(r.bottom,i.bottom)+1})},z=(0,f.useRef)(`picture`),B=(0,f.useRef)(c),V=(0,f.useRef)({}),H=(0,f.useRef)([]),U=(0,f.useRef)(`picture`),W=e=>void R.current?.closest(`.editor`)?.toggleAttribute(`data-space-folds`,!!e&&e!==`picture`&&w(e)!==`space`),G=(0,f.useRef)(0),[re,ie]=(0,f.useState)(0),K=(e,t)=>{if(!R.current)return e();g(ne,(n,r)=>{if(!R.current)return n();t()&&r(),H.current.push([++G.current,n]),e(),ie(G.current)})},q=()=>{let e=z.current;e===`picture`?l(e):T(e)&&(l(e),w(e)===`space`&&O(e)),a(e===`picture`?`picture`:`space`),e!==`picture`&&s(e)},J=e=>{if(P(void 0),W(e),e===z.current)return;z.current=e;let t=e===`picture`?void 0:w(e);if(t&&!(t===`space`?u:t===`more`?m&&E:m)){if(a(`space`),s(e),V.current[t])return;V.current[t]=!0;let i=()=>z.current!==`picture`&&w(z.current)===t,o=()=>n(`graph-stage`,()=>r(()=>import(`./graph-stage-BkrQGQ-z.js`),__vite__mapDeps([0,1,2])));(t===`space`?n(`space`,()=>r(()=>import(`./space-DWgrlnfB.js`),[])).then(e=>()=>p(y=e)):t===`stage`?o().then(e=>()=>h(b=e)):Promise.all([o(),n(`graph-more`,()=>r(()=>import(`./graph-more-393HTgQE.js`),__vite__mapDeps([3,1])))]).then(([e,t])=>()=>(h(b=e),A(x=t)))).then(e=>{F.current[t]=!1;let n=()=>(e(),i()?q():void 0);i()?K(n,()=>!i()):n()},()=>{V.current[t]=!1,F.current[t]=!0;let e=i();e&&W(z.current=B.current),z.current===`picture`?(s(t===`space`?`panes`:`stairs`),P(t!==`space`&&!F.current.space?`That view in three dimensions could not be fetched. The picture shows the same graph, and so do the stairs.`:`The view in three dimensions could not be fetched. The picture shows the same graph.`)):P(`That view could not be fetched. This one shows the same graph.`),e&&q()})}else e!==`picture`||B.current!==`picture`?K(q,()=>z.current===B.current):q()},Y=(0,f.useMemo)(()=>c===`stairs`&&u?u.scene(d,M(e,I,u.CARD,t.notes)):void 0,[e,c,u,I,t.notes]),X=c!==`picture`&&c!==`stairs`&&m&&(w(c)===`stage`||E)?c:void 0,Z=(0,f.useMemo)(()=>m&&E?E.MORE(m.tools):{},[m,E]);(0,f.useLayoutEffect)(()=>{let t=R.current?.querySelector(`.space`);if(!t||!u||!Y)return;let n=t=>e.nodes.find(e=>e.id===t)?.name||t;for(let r of t.querySelectorAll(`[data-node]`)){let t=e.nodes.find(e=>e.id===r.dataset.node);r.setAttribute(`tabindex`,`0`),r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,`${t?.kind===`agent`?t.by===`person`?`Person`:`Agent`:k[t?.kind]?.[0]??`Node`} ${n(r.dataset.node)}`)}for(let e of t.querySelectorAll(`[data-edge]`)){let t=Y.arcs.find(t=>t.id===e.dataset.edge);e.setAttribute(`role`,`img`),t&&e.setAttribute(`aria-label`,`Step ${t.n}: ${n(t.from)} to ${n(t.to)}`)}return u.attach(t,Y,te.current??=u.held(),()=>J(`picture`))},[Y]);let Q=e=>void(H.current=H.current.filter(([t,n])=>t>e||(n(),!1)));(0,f.useLayoutEffect)(()=>{B.current=c,(c===`picture`||c===`stairs`)&&(U.current=c),Q(re)}),(0,f.useEffect)(()=>{let e=R.current?.closest(`.editor`),t=()=>e?.querySelector(`.sheet:not(.sheet-rail)`)?.getAttribute(`aria-label`),n=e=>{let n=t();e.target instanceof Element&&e.target.closest(`.topbar,.sheet-head`)?W():requestAnimationFrame(()=>t()!==n&&W())};return e?.addEventListener(`click`,n,!0),()=>(e?.removeEventListener(`click`,n,!0),e?.removeAttribute(`data-space-folds`))},[]),(0,f.useEffect)(()=>()=>Q(1/0),[]),(0,f.useEffect)(()=>{let e=R.current?.parentElement;if(!e||typeof ResizeObserver!=`function`)return;let t=new ResizeObserver(()=>ee(e.clientWidth<640?3:e.clientWidth<900?4:6));return t.observe(e),()=>t.disconnect()},[]);let $=e=>(W(),t.onNodeTap?.(e)),ae=e=>{let t=e instanceof Element?e.closest(`[data-node]`):null;return t&&$(t.dataset.node),!!t},oe=()=>{let e=U.current;W(z.current=e),l(e),a(e===`picture`?`picture`:`space`),s(`stairs`),P(e===`picture`?`That view cannot be drawn in this browser. The picture shows the same graph.`:`That view cannot be drawn in this browser. This one shows the same graph.`)},se=!!Y||!!X;return(0,v.jsxs)(`div`,{ref:R,className:`graph-views${se?` is-space`:``}`,children:[(0,v.jsx)(`div`,{className:`segmented graph-switch`,role:`radiogroup`,"aria-label":`View of the graph`,children:[`picture`,`space`].map(e=>(0,v.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e,className:i===e?`seg seg-on`:`seg`,onClick:()=>J(e===`picture`?`picture`:o),children:e===`picture`?`Picture`:`3D`},e))}),se?(0,v.jsx)(`div`,{className:`segmented graph-kinds`,role:`radiogroup`,"aria-label":`Kind of view in three dimensions`,children:C.map(([e,t,n])=>(0,v.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":o===e,"aria-description":n,title:n,className:o===e?`seg seg-on`:`seg`,onClick:()=>J(e),children:t},e))}):null,j?(0,v.jsx)(`p`,{className:`graph-views-note`,role:`status`,children:j}):null,Y?(0,v.jsx)(`div`,{className:`graph-space map-stage`,"data-keep":t.notes?326:346,children:(0,v.jsx)(`div`,{className:`map-picture`,onClick:e=>void ae(e.target),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&ae(e.target)&&e.preventDefault()},dangerouslySetInnerHTML:{__html:Y.html}})}):X&&m?(0,v.jsx)(`div`,{className:`graph-space`,children:(0,v.jsx)(N,{lost:oe,children:(0,v.jsx)(m.Stage3,{doc:e,kind:X,...Z[X]?{its:Z[X]}:{},wide:L.current.at,of:{...t,onNodeTap:$},drawn:()=>O(X)})},X)}):null]})}export{P as Views,j as firstPass,M as graphScene};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,A as t,Bt as n,I as r,Lt as i,O as a,Tt as o,cn as s,et as c,j as l,k as u,ln as d,pt as f,sn as p,tt as m}from"./share-BzIzB4EY.js";var ee=`grooph`,h=`graphs`,g=`templates`,_=`runs`,v=()=>{};function y(e){v=e}var b=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});function x(){return new Promise((e,t)=>{let n=indexedDB.open(ee,3);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(h)||e.createObjectStore(h,{keyPath:`key`}),e.objectStoreNames.contains(g)||e.createObjectStore(g,{keyPath:`id`}),e.objectStoreNames.contains(_)||e.createObjectStore(_,{keyPath:`key`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error),n.onblocked=()=>t(Error(`IndexedDB upgrade blocked by another tab`))})}var S=class{db;name;constructor(e,t){this.db=e,this.name=t}tx(e){return this.db.transaction(this.name,e).objectStore(this.name)}async list(){return b(this.tx(`readonly`).getAll())}async get(e){return b(this.tx(`readonly`).get(e))}async put(e){await b(this.tx(`readwrite`).put(e)),v()}async delete(e){await b(this.tx(`readwrite`).delete(e))}},te=class extends S{persistent=!0;templates;runs;constructor(e){super(e,h),this.templates=new S(e,g),this.runs=new S(e,_)}},C=class{keyOf;records=new Map;constructor(e){this.keyOf=e}async list(){return[...this.records.values()].map(e=>structuredClone(e))}async get(e){let t=this.records.get(e);return t&&structuredClone(t)}async put(e){this.records.set(this.keyOf(e),structuredClone(e))}async delete(e){this.records.delete(e)}},w=class extends C{persistent=!1;templates=new C(e=>e.id);runs=new C(e=>e.key);constructor(){super(e=>e.key)}},T;function E(){return T??=x().then(e=>new te(e),()=>new w),T}function D(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function O(e){let t=s(e);return t.doc?m(t.doc,{forExport:!0}).filter(e=>!k(e)):t.issues}var k=e=>e.code===`E_NO_TARGET`||e.code===`E_NO_GOAL`||e.code===`E_PERSON_STEP_NOT_COMPILED`;function ne(e){let t=s(e);return t.doc?m(t.doc,{forExport:!0}).filter(k):[]}function re(e){let n=r(e.notes,e.working),i=t(e.source,e.working);return{bundle:e,summary:n,diff:i,why:l(i.changes,n.amendments),adoption:a(e.source,e.working,{run:e.run}),moved:e.source.version!==e.working.version,issues:O(e.working)}}function ie(e){if(e.at===`graph`)return{kind:`graph`};let t=e.at.indexOf(`:`);return{kind:e.at.slice(0,t),id:e.at.slice(t+1)}}function A(e,t){if(e.kind===`graph`)return`The run`;let n=e=>t.nodes.find(t=>t.id===e);if(e.kind===`node`)return n(e.id)?.name||e.id;if(e.kind===`loop`)return`Loop ${t.loops.find(t=>t.id===e.id)?.name||e.id}`;let r=t.edges.find(t=>t.id===e.id);return r?`Edge ${n(r.from)?.name||r.from} → ${n(r.to)?.name||r.to}`:`Edge ${e.id}`}function j(e,t){if(e.kind===`node`)return{nodes:[e.id],edges:[]};if(e.kind===`edge`){let n=t.edges.find(t=>t.id===e.id);return{nodes:n?[n.from,n.to]:[],edges:[e.id]}}if(e.kind===`loop`){let n=t.loops.find(t=>t.id===e.id);return{nodes:n?.members??[],edges:n?.back??[],loop:e.id}}return{nodes:[],edges:[]}}function M(e,t){return e===`passed`&&t&&![`pass`,`fail`,`halt`,`invalid-evidence`,`started`,`ending`].includes(t)?t:e}function N(e){if(e!==void 0){if(e===`started`)return`running`;if(e!==`ending`)return e===`pass`?`passed`:e===`fail`||e===`invalid-evidence`?`failed`:e===`halt`?`halted`:`passed`}}function P(e,t){let n=e=>e===void 0||Array.isArray(e)&&e.every(e=>typeof e==`string`);if(!n(e)||!n(t)||e===void 0&&t===void 0)return;let r=e??[],i=t??[],a=r.filter(e=>!i.includes(e)),o=i.filter(e=>!r.includes(e));return{removed:a,added:o,kept:r.length-a.length,reordered:a.length===0&&o.length===0}}function F(t,n){let r=u(n.proposal?.patch);if(r.kind===`none`)return{ok:!1,message:`This proposal carries no patch, only its summary; make the change by hand if you agree with it.`};if(r.kind===`other`)return{ok:!1,message:r.why};let i=e(t.working,r.ops);if(!i.ok)return{ok:!1,message:`The patch does not apply to the run's working copy: ${c(i.error)}. Nothing was saved.`};let{source:a}=t,{notes:o,...l}=i.doc,d={...l,id:a.id,name:a.name,version:a.version+1,lineage:{...i.doc.lineage,from:`${a.id}@${a.version}`},...a.notes&&a.notes.length>0?{notes:a.notes}:{}},f=JSON.parse(JSON.stringify(d)),p=s(f);return{ok:!0,doc:f,issues:O(f),graph:p.doc!==void 0}}var I=(e,t)=>t&&e.state===`running`?[...e.timeline].reverse():e.timeline,L=e=>`${e.working.id}/${e.run}`,R=e=>`#/run/${encodeURIComponent(e)}`;function z(e,t){if(!e||!t)return;let n=Date.parse(t)-Date.parse(e);if(!Number.isFinite(n)||n<0)return;let r=Math.round(n/6e4);return r<60?`${r} min`:`${Math.floor(r/60)} h ${r%60} min`}async function B(){return(await(await E()).list()).sort((e,t)=>t.updatedAt-e.updatedAt)}async function V(){return new Set((await(await E()).list()).map(e=>e.doc.id))}async function H(e){let t=Date.now(),n={key:D(),doc:e,createdAt:t,updatedAt:t};return await(await E()).put(n),n}async function U(){let e=n(`untitled-graph`,await V()),t=e===`untitled-graph`?`Untitled graph`:`Untitled graph ${e.slice(15)}`;return H(f({name:t,id:e}))}async function W(e){let t=await(await E()).get(e);if(!t)return;let r=n(`${t.doc.id}-copy`,await V());return H({...structuredClone(t.doc),id:r,name:`${t.doc.name} (copy)`})}async function G(e,t,n={}){let r=await E(),i=await r.get(e);if(!i)return;let a=o(i.doc,t);await r.put({...i,doc:n.keepId===void 0?a:K(a,n.keepId),updatedAt:Date.now()})}function K(e,t){if(e.id===t)return e;let n=i(e);return n.delete(e.id),n.has(t)?e:{...e,id:t}}async function q(e){await(await E()).delete(e)}function J(e){let t=d(e);if(t.doc)return{doc:t.doc,issues:[]};let n;try{n=JSON.parse(e)}catch{return{issues:t.issues}}return oe(n)?{doc:n,issues:t.issues}:{issues:t.issues}}async function Y(e){return H(e)}async function ae(e){let t=p(e),n=(await B()).find(n=>n.doc.id===e.id&&p(n.doc)===t);return n?{record:n,existed:!0}:{record:await H(structuredClone(e)),existed:!1}}var X=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z=(e,t)=>Array.isArray(e)&&e.every(e=>X(e)&&t.every(t=>typeof e[t]==`string`));function oe(e){return!X(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Z(e.nodes,[`id`,`kind`])||!Z(e.edges,[`id`,`from`,`to`])||!Array.isArray(e.loops)?!1:e.loops.every(e=>X(e)&&typeof e.id==`string`&&Array.isArray(e.members)&&Array.isArray(e.back)&&Array.isArray(e.stops))}async function se(){return(await(await E()).runs.list()).sort((e,t)=>t.savedAt-e.savedAt)}async function ce(e){return(await E()).runs.get(e)}async function le(e){let t=await E(),n=L(e),r=await t.runs.get(n)!==void 0,i={key:n,graphId:e.working.id,run:e.run,bundle:structuredClone(e),savedAt:Date.now()};return await t.runs.put(i),{record:i,replaced:r}}async function ue(e){await(await E()).runs.delete(e)}async function Q(e){return Y(structuredClone(e))}async function de(e,t){let r=await E(),a=(await B()).find(t=>t.doc.id===e.source.id),o=structuredClone(a?.doc??e.source),s=(o.notes??[]).find(e=>$(e)===$(t));if(s&&a)return{record:a,created:!1,already:!0,id:s.id};let c=i(o).has(t.id)?n(t.id,i(o)):t.id;if(o.notes=[...o.notes??[],{...t,id:c}],a){let e={...a,doc:o,updatedAt:Date.now()};return await r.put(e),{record:e,created:!1,already:!1,id:c}}return{record:await Y(o),created:!0,already:!1,id:c}}function $(e){let t=e=>Array.isArray(e)?e.map(t):typeof e==`object`&&e?Object.fromEntries(Object.keys(e).sort().map(n=>[n,t(e[n])])):e,{id:n,...r}=e;return JSON.stringify(t(r))}export{y as A,L as C,A as D,j as E,O,R as S,M as T,P as _,le as a,N as b,q as c,K as d,B as f,z as g,ae as h,de as i,E as j,ne as k,W as l,G as m,ce as n,Q as o,J as p,se as r,U as s,ue as t,Y as u,ie as v,re as w,F as x,I as y};
|