dev-process-kit 0.3.0 → 0.3.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 (28) hide show
  1. package/dist/boards.js +1 -1
  2. package/dist/chunks/{shared-B_Tiv_T3.js → shared-2OsWmhrI.js} +1 -1
  3. package/dist/chunks/{shared-DNsl9DK1.js → shared-B57TT0rn.js} +1 -1
  4. package/dist/chunks/{shared-DYDJzB79.js → shared-B8ZhyjWv.js} +140 -137
  5. package/dist/chunks/{shared-BfByEotW.js → shared-BXywwm1a.js} +740 -366
  6. package/dist/chunks/shared-Be43xweD.js +43 -0
  7. package/dist/chunks/{shared-FMBoDqPg.js → shared-C0M3Ib7z.js} +1 -1
  8. package/dist/chunks/{shared-Ln6ei2B2.js → shared-C89fKgKG.js} +98 -94
  9. package/dist/chunks/{shared-Bs2YYFvO.js → shared-CF2_VP2x.js} +1 -1
  10. package/dist/chunks/{shared-DegJ_tfw.js → shared-CeCpFPDQ.js} +1 -1
  11. package/dist/chunks/{shared-BYbcHniE.js → shared-DIEJ9E2G.js} +1 -1
  12. package/dist/chunks/{shared-RvLH2Fqp.js → shared-DJtGS7Ct.js} +1 -1
  13. package/dist/chunks/{shared-epAjO2d1.js → shared-Dd8JfvQe.js} +1 -1
  14. package/dist/chunks/{shared-TtB-p2Zh.js → shared-Dn92ukYW.js} +1 -1
  15. package/dist/chunks/{shared-WtWbdwp_.js → shared-Dql0ZVdC.js} +1 -1
  16. package/dist/chunks/shared-LHG2FbnK.js +1 -0
  17. package/dist/chunks/{shared-BFraiskj.js → shared-egtdNQhY.js} +264 -281
  18. package/dist/chunks/{shared-DqlTHpRQ.js → shared-ubG0-RQ-.js} +1 -1
  19. package/dist/components.js +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/views/delegation-poker.js +1 -1
  22. package/dist/views/plain.js +1 -1
  23. package/dist/views/prototype.js +1 -1
  24. package/dist/views/slides.js +1 -1
  25. package/dist/views/task-board.js +1 -1
  26. package/dist/views/usm.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunks/shared-DMksNmni.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab as pe,ac as y,ad as le,ae as Td,af as Sd,X as Md,j as ri,ag as ai,ah as ae,ai as M,aj as Y,ak as di,al as li,am as Id,an as Cd,D as Ld,ao as _d,U as Rd,ap as Fn,aq as Ad,ar as ci,as as v,C as Od,at as Nd,au as he,av as P,aw as C,ax as I,ay as _,az as X,aA as Ge,aB as ft,aC as Bn,aD as Dd,aE as pi,aF as hi,aG as zd,aH as Te,aI as ui,B as mi,aJ as Pd,G as gi,H as Un,I as Ft,aK as qd,aL as W,aM as oe,aN as Ze,p as z,t as Se,aO as ue,aP as Hn,z as Yn,aQ as bt,aR as Fd,N as Bt,e as Xn,P as B,aS as Ut,aT as Bd,l as xe,aU as Ht,aV as fi,aW as bi,aX as Ud,aY as xi,aZ as Hd,a_ as yi,a$ as Yt,b0 as Me,b1 as Yd,b2 as Xd,b3 as Gd}from"./shared-DYDJzB79.js";import{Q as Kd,A as jd,H as Wd,R as Vd,S as Qd,T as ye,U as Ie,V as vi,W as Zd,X as ve,Y as Jd,Z as Gn,_ as ki,$ as el}from"./shared-BYbcHniE.js";import{o as tl}from"./shared-D4PPk0Dk.js";import{E as nl,t as Ce,u as ol,v as Ne,B as Xt,w as Gt,x as il}from"./shared-epAjO2d1.js";import{a as sl,c as rl}from"./shared-TtB-p2Zh.js";import{o as Kt}from"./shared-DMksNmni.js";const al=[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2"}]],dl=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"}]],ll=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"}]],cl=[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1"}]],pl=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}],["path",{d:"M5 17A12 12 0 0 1 17 5"}]];function hl(t,e){let n=0;for(let o=0;o<t.length;o++)n+=e(t[o],o);return n}function wi(t){if(t.length===0)return NaN;const e=t.slice().sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?(e[n-1]+e[n])/2:e[n]}const $i={},Ei=t=>{const e={kind:"board",name:t.name,label:t.label,addable:t.addable??!1,parseBase:()=>$i,emptyBase:()=>$i,actions:{},apply:()=>null,hasTarget:()=>!1,describe:i=>({title:i.type,targetLabel:qn(i.target),tone:"meta"}),serialize:i=>`${i.type} ${qn(i.target)} ${JSON.stringify(i.payload)}`,resolveNavigation:()=>({}),commentTargets:()=>[],title:()=>t.label},n=t.commentTargets?.()??[],o=new Map((t.elementActionResults?.()??[]).map(i=>[i.id,i]));return wd(e,n,o)},xt={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6,groupSpacing:34,superGroupSpacing:34,superGroupRowGap:0,superGroupColumnGap:0,superGroupRowCount:0},yt=t=>{const e=[...t].sort((o,i)=>o-i);if(e.length===0)return 0;const n=Math.floor(e.length/2);return e.length%2===1?e[n]??0:((e[n-1]??0)+(e[n]??0))/2},Kn=(t,e)=>{const n=new Map;for(const r of t)n.set(r.id,[]);for(const r of e)n.get(r.from)?.push(r);const o=new Map,i=new Set,s=r=>{o.set(r,"open");for(const a of n.get(r)??[]){const d=o.get(a.to)??"new";d==="open"?i.add(a.id):d==="new"&&s(a.to)}o.set(r,"done")};for(const r of t)(o.get(r.id)??"new")==="new"&&s(r.id);return{reversed:i,forward:e.filter(r=>!i.has(r.id))}},Ti=(t,e)=>{const n=new Map,o=new Map;for(const a of t)n.set(a.id,[]),o.set(a.id,[]);for(const a of e)o.get(a.from)?.push(a),n.get(a.to)?.push(a);const i=new Map(t.map(a=>[a.id,0])),s=new Map(t.map(a=>[a.id,(n.get(a.id)??[]).length])),r=t.filter(a=>(s.get(a.id)??0)===0).map(a=>a.id);for(const a of r)for(const d of o.get(a)??[]){const l=i.get(d.to)??0;i.set(d.to,Math.max(l,(i.get(a)??0)+1));const c=(s.get(d.to)??0)-1;s.set(d.to,c),c===0&&r.push(d.to)}return i},Si=(t,e,n,o)=>{const i=[...t.keys()].sort((s,r)=>s-r);for(let s=0;s<o;s++){const r=s%2===0;for(const a of r?i:[...i].reverse()){const d=t.get(a)??[],l=new Map(d.map((p,u)=>[p,u])),c=p=>{const u=l.get(p);return u===void 0?null:u},h=d.map(p=>{const u=(e.get(p)??[]).filter(g=>(n.get(g)??a)===a+(r?-1:1)).map(c).filter(g=>g!==null);return{id:p,want:u.length>0?yt(u):l.get(p)??0}});h.sort((p,u)=>p.want-u.want||(l.get(p.id)??0)-(l.get(u.id)??0)),t.set(a,h.map(p=>p.id))}}},Mi=(t,e,n,o)=>{const i=t.map((r,a)=>({id:r,want:n.get(r)??a*100,index:a}));i.sort((r,a)=>r.want-a.want||r.index-a.index);let s=0;for(const r of i){const a=e.get(r.id);a&&(a.y=s,s+=a.spec.height+o)}return{height:Math.max(0,s-o)}},ul=(t,e,n,o,i)=>{const s=[...t.keys()].sort((l,c)=>l-c),r=new Map;for(const l of s)r.set(l,Mi(t.get(l)??[],e,new Map,i.nodeSpacing).height);const a=Math.max(0,...r.values());for(const l of s){const c=(a-(r.get(l)??0))/2;for(const h of t.get(l)??[]){const p=e.get(h);p&&(p.y+=c)}}const d=(l,c)=>{const h=(n.get(l)??[]).filter(p=>o.get(p)===c).flatMap(p=>{const u=e.get(p);return u?[u.y+u.spec.height/2]:[]});return h.length>0?yt(h):null};for(let l=0;l<i.coordinatePasses;l++){const c=l%2===0;for(const h of c?s:[...s].reverse()){const p=t.get(h)??[],u=new Map;for(const m of p){const x=d(m,h+(c?-1:1)),k=e.get(m);k!==void 0&&u.set(m,x===null?k.y+k.spec.height/2:x)}const g=p.map(m=>e.get(m)?.y??0);Mi(p,e,u,i.nodeSpacing);const b=p.map(m=>e.get(m)?.y??0),f=yt(g)-yt(b);for(const m of p){const x=e.get(m);x&&(x.y+=f)}}}},Ii=(t,e,n,o,i,s,r)=>{for(const a of i){const d=t.filter(h=>o.get(h)===a);if(d.length===0)continue;const l=d.map((h,p)=>({id:h,want:n.get(h)??p,index:p})).sort((h,p)=>h.want-p.want||h.index-p.index);let c=s.get(a)??0;for(const h of l){const p=e.get(h.id);p&&(p.y=c,c+=p.spec.height+r)}}},ml=(t,e,n,o,i)=>{let s=0;for(const r of t.values()){const a=r.filter(l=>n.get(l)===o);if(a.length===0)continue;const d=a.reduce((l,c)=>l+(e.get(c)?.spec.height??0),0)+i*(a.length-1);d>s&&(s=d)}return s},gl=(t,e,n,o,i,s,r)=>{const a=new Map(t.map(T=>[T.id,T.group??T.id])),d=new Set(t.flatMap(T=>T.group===void 0?[]:[T.group])),l=t.some(T=>T.superGroup!==void 0),c=new Map;for(const T of t){const E=a.get(T.id)??T.id;T.superGroup!==void 0&&!c.has(E)&&c.set(E,T.superGroup)}const h=T=>c.get(T)??T,p=[...e.keys()].sort((T,E)=>T-E),u=T=>{const E=i.get(T)??0,R=(e.get(E)??[]).length,A=s.get(T)??0;return R<=1?0:A/(R-1)},g=[...new Set(a.values())],b=T=>{const E=t.filter(R=>(a.get(R.id)??R.id)===T).map(R=>R.id);return E.length===0?0:E.reduce((R,A)=>R+u(A),0)/E.length},f=[...new Set(g.map(h))],m=T=>{const E=t.filter(R=>h(a.get(R.id)??R.id)===T).map(R=>R.id);return E.length===0?0:E.reduce((R,A)=>R+u(A),0)/E.length},k=f.sort((T,E)=>m(T)-m(E)).flatMap(T=>g.filter(E=>h(E)===T).sort((E,R)=>b(E)-b(R))),w=new Map(k.map(T=>[T,ml(e,n,a,T,r.nodeSpacing)])),$=new Map;let L=0;for(const[T,E]of k.entries()){$.set(E,L),L+=w.get(E)??0;const R=k[T+1];if(R!==void 0){const A=l&&h(E)!==h(R);L+=A?r.superGroupSpacing:d.has(E)||d.has(R)?r.groupSpacing:r.nodeSpacing}}for(const T of p){const E=e.get(T)??[];Ii(E,n,new Map(E.map(R=>[R,s.get(R)??0])),a,k,$,r.nodeSpacing)}const S=(T,E)=>{const R=(o.get(T)??[]).filter(A=>i.get(A)===E).flatMap(A=>{const N=n.get(A);return N?[N.y+N.spec.height/2]:[]});return R.length>0?yt(R):null};for(let T=0;T<r.coordinatePasses;T++){const E=T%2===0;for(const R of E?p:[...p].reverse()){const A=e.get(R)??[],N=new Map;for(const U of A){const H=S(U,R+(E?-1:1)),q=n.get(U);q!==void 0&&N.set(U,H===null?q.y+q.spec.height/2:H)}Ii(A,n,N,a,k,$,r.nodeSpacing)}}},Ci=(t,e,n)=>{const o=e===void 0?void 0:t.spec.ports?.[e];return o?{x:t.x+o.x,y:t.y+o.y}:n==="out"?{x:t.x+t.spec.width,y:t.y+t.spec.height/2}:{x:t.x,y:t.y+t.spec.height/2}},jt=(t,e,n)=>{let o=0;const i=[];for(const s of t){const r=n.byId.get(s.from),a=n.byId.get(s.to);if(!r||!a)continue;const d=Ci(r,s.fromPort,"out"),l=Ci(a,s.toPort,"in");if(s.from===s.to){const g=r.x+r.spec.width,b=r.y+r.spec.height,f=Math.max(n.padding/2,b+18);i.push({id:s.id,points:[d,{x:g+20,y:d.y},{x:g+20,y:f},{x:r.x-20,y:f},{x:r.x-20,y:l.y},l]});continue}if(!e.has(s.id)&&(r.layer<a.layer||r.layer===a.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){i.push({id:s.id,points:[d,l]});continue}const b=r.layer<a.layer?Math.max(d.x+14,a.x-Math.max(12,n.layerSpacing/2)):(d.x+l.x)/2;i.push({id:s.id,points:[d,{x:b,y:d.y},{x:b,y:l.y},l]});continue}const c=s.fromPort===void 0?{x:r.x+r.spec.width/2,y:r.y+r.spec.height}:d,h=s.toPort===void 0?{x:a.x+a.spec.width/2,y:a.y+a.spec.height}:l,p=Math.max(c.y,h.y)+18+o*14;o+=1;const u=[d,c,{x:c.x,y:p},{x:h.x,y:p},h,l].filter((g,b,f)=>b===0||g.x!==f[b-1]?.x||g.y!==f[b-1]?.y);i.push({id:s.id,points:u})}return i},jn=(t,e,n)=>{const o=e.flatMap(p=>[...p.points]),i=[...t.map(p=>p.x),...t.map(p=>p.x+p.spec.width),...o.map(p=>p.x)],s=[...t.map(p=>p.y),...t.map(p=>p.y+p.spec.height),...o.map(p=>p.y)],r=Math.min(0,...i),a=Math.min(0,...s),d=Math.max(0,...i),l=Math.max(0,...s),c=n-r,h=n-a;return{width:d-r+n*2,height:l-a+n*2,nodes:t.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+h,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(u=>({x:u.x+c,y:u.y+h}))}))}},Wt=(t,e)=>{const n=new Map(t.map(o=>[o.id,[]]));for(const o of e)o.from!==o.to&&(n.get(o.from)?.push(o.to),n.get(o.to)?.push(o.from));return n},Li=(t,e,n,o)=>t.map(i=>({spec:i,layer:e.get(i.id)??0,order:n.get(i.id)??0,...o(i)})),_i=(t,e)=>{const n=new Map;for(const o of t){const i=e.get(o.id)??0,s=n.get(i);s?s.push(o.id):n.set(i,[o.id])}return n},Ri=(t,e,n={})=>{if(t.some(b=>b.superGroup!==void 0))return Il(t,e,n);const o={...xt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(b=>b.id)),s=e.filter(b=>i.has(b.from)&&i.has(b.to)),{forward:r,reversed:a}=Kn(t,s),d=Ti(t,r),l=_i(t,d);Si(l,Wt(t,s),d,o.sweeps);const c=new Map;for(const b of l.values())b.forEach((f,m)=>c.set(f,m));const h=Li(t,d,c,()=>({x:0,y:0})),p=new Map(h.map(b=>[b.spec.id,b]));t.some(b=>b.group!==void 0||b.superGroup!==void 0)?gl(t,l,p,Wt(t,s),d,c,o):ul(l,p,Wt(t,s),d,o);const u=[...l.keys()].sort((b,f)=>b-f);let g=0;for(const b of u){const f=Math.max(...(l.get(b)??[]).map(m=>p.get(m)?.spec.width??0));for(const m of l.get(b)??[]){const x=p.get(m);x&&(x.x=g)}g+=f+o.layerSpacing}return jn(h,jt(s,a,{byId:p,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},Je=12,Ai=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Oi=(t,e)=>{const n=Ai(t),o=Ai(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},Ni=(t,e,n)=>Math.min(n,Math.max(e,t)),Di=(t,e,n)=>{const o=Ni(n.y-t.y,Je,Math.max(Je,t.height-Je)),i=t.height<=0?.5:o/t.height,s=t.x+Ni(i*t.width,Je,Math.max(Je,t.width-Je));switch(e){case"left":return{x:t.x,y:t.y+o};case"right":return{x:t.x+t.width,y:t.y+o};case"top":return{x:s,y:t.y};case"bottom":return{x:s,y:t.y+t.height};default:return{x:t.x+t.width,y:t.y+o}}},fl=(t,e,n)=>{if(t.length<=1)return t.map(c=>c.id);const o=t.map(c=>({id:c.id,width:c.width,height:c.height})),i=new Set(o.map(c=>c.id)),s=e.filter(c=>i.has(c.from)&&i.has(c.to)&&c.from!==c.to),{forward:r}=Kn(o,s),a=Ti(o,r),d=_i(o,a);return Si(d,Wt(o,s),a,n),[...d.keys()].sort((c,h)=>c-h).flatMap(c=>d.get(c)??[])},bl=(t,e,n,o)=>{let i=0;for(let s=e;s<n;s++)i+=t[s].width;return i+o*Math.max(0,n-e-1)},Wn=(t,e,n)=>{const o=t.length,i=Math.max(1,Math.min(n,o)),s=Number.POSITIVE_INFINITY,r=Array.from({length:o+1},()=>Array.from({length:i+1},()=>s)),a=Array.from({length:o+1},()=>Array.from({length:i+1},()=>0));r[0][0]=0;for(let u=1;u<=i;u++)for(let g=u;g<=o;g++)for(let b=u-1;b<g;b++){const f=r[b][u-1];if(f===s)continue;const m=Math.max(f,bl(t,b,g,e));m<r[g][u]&&(r[g][u]=m,a[g][u]=b)}const d=[];let l=o;for(let u=i;u>0;u--){const g=a[l][u];d.unshift(t.slice(g,l)),l=g}const c=new Map;let h=0,p=0;for(const u of d){let g=0;const b=Math.max(...u.map(f=>f.height));for(const f of u)c.set(f.id,{x:g,y:h}),g+=f.width+e;p=Math.max(p,g-e),h+=b+e}return{positions:c,width:p,height:Math.max(0,h-e)}},Ke=1e-6,Vt=(t,e)=>Math.abs(t.x-e.x)<Ke&&Math.abs(t.y-e.y)<Ke,Qt=(t,e,n)=>{const o=(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y);return Math.abs(o)<Ke?0:o>0?1:-1},Zt=(t,e,n)=>Math.min(t.x,n.x)-Ke<=e.x&&e.x<=Math.max(t.x,n.x)+Ke&&Math.min(t.y,n.y)-Ke<=e.y&&e.y<=Math.max(t.y,n.y)+Ke,zi=(t,e)=>{const[n,o]=t,[i,s]=e;if(Vt(n,i)||Vt(n,s)||Vt(o,i)||Vt(o,s))return!1;const r=Qt(n,o,i),a=Qt(n,o,s),d=Qt(i,s,n),l=Qt(i,s,o);return r!==a&&d!==l||r===0&&Zt(n,i,o)||a===0&&Zt(n,s,o)||d===0&&Zt(i,n,s)?!0:l===0&&Zt(i,o,s)},Pi=(t,e)=>{const n=t.x+t.width/2,o=t.y+t.height/2,i=e.x+e.width/2,s=e.y+e.height/2,r=i-n,a=s-o;return Math.abs(r)>=Math.abs(a)?{x:r>=0?t.x+t.width:t.x,y:o}:{x:n,y:a>=0?t.y+t.height:t.y}},xl=(t,e,n)=>{const o=r=>{const a=t.positions.get(r),d=e.get(r);return!a||!d?null:{id:r,x:a.x,y:a.y,width:d.width,height:d.height}},i=[];let s=0;for(const r of n){if(r.from===r.to)continue;const a=o(r.from),d=o(r.to);if(!a||!d)continue;const l=Pi(a,d),c=Pi(d,a);if(l.x===c.x||l.y===c.y){const g=[l,c];s+=i.filter(b=>zi(g,b)).length,i.push(g);continue}const h=[[[l,{x:c.x,y:l.y}],[{x:c.x,y:l.y},c]],[[l,{x:l.x,y:c.y}],[{x:l.x,y:c.y},c]]];let p=h[0],u=Number.POSITIVE_INFINITY;for(const g of h){const b=g.reduce((f,m)=>f+i.filter(x=>zi(m,x)).length,0);b<u&&(u=b,p=g)}s+=u,i.push(...p)}return s},yl=(t,e,n)=>{const o=s=>{const r=t.positions.get(s),a=e.get(s);return!r||!a?null:{x:r.x+a.width/2,y:r.y+a.height/2}};let i=0;for(const s of n){if(s.from===s.to)continue;const r=o(s.from),a=o(s.to);r&&a&&(i+=Math.hypot(r.x-a.x,r.y-a.y))}return i},qi=(t,e)=>{const n=t[0].x===t[1].x,o=e[0].x===e[1].x;if(n===o)return!1;const[i,s,r,a]=n?[t[0],t[1],e[0],e[1]]:[e[0],e[1],t[0],t[1]],d=i.x,l=r.y;return d>Math.min(r.x,a.x)&&d<Math.max(r.x,a.x)&&l>Math.min(i.y,s.y)&&l<Math.max(i.y,s.y)},Fi=(t,e,n,o)=>{const i=n===void 0?void 0:t.ports?.[n];return i!==void 0?{x:e.x+i.x,y:e.y+i.y}:o==="out"?{x:e.x+t.width,y:e.y+t.height/2}:{x:e.x,y:e.y+t.height/2}},vl=(t,e,n)=>{const o=new Map(t.map(r=>[r.id,r])),i=[];let s=0;for(const r of e){if(r.from===r.to)continue;const a=o.get(r.from),d=o.get(r.to),l=n.get(r.from),c=n.get(r.to);if(a===void 0||d===void 0||l===void 0||c===void 0)continue;const h={x:l.x,y:l.y,width:a.width,height:a.height},p={x:c.x,y:c.y,width:d.width,height:d.height},u=Di(h,Oi(h,p),Fi(a,l,r.fromPort,"out")),g=Di(p,Oi(p,h),Fi(d,c,r.toPort,"in")),b=k=>k.slice(1).map((w,$)=>[k[$],w]);if(u.x===g.x||u.y===g.y){const k=[u,g];s+=i.filter(w=>qi(k,w)).length,i.push(k);continue}const f=[[u,{x:g.x,y:u.y},g],[u,{x:u.x,y:g.y},g]];let m=f[0],x=Number.POSITIVE_INFINITY;for(const k of f){const w=b(k).reduce(($,L)=>$+i.filter(S=>qi(L,S)).length,0);w<x&&(m=k,x=w)}s+=x,i.push(...b(m))}return s},Jt={crossings:1e4,edgeLength:1,aspectDeviation:50},Bi=50,kl=Jt.aspectDeviation,Vn=(t,e,n,o,i)=>{const s=t.width<=0||t.height<=0?0:Math.abs(Math.log(t.width/t.height/o));return xl(t,e,n)*Jt.crossings+yl(t,e,n)*Jt.edgeLength+s*i},wl=function*(t){const e=[...t],n=e.length;if(yield[...e],n<=1)return;const o=Array.from({length:n}).fill(0);let i=0;for(;i<n;)if(o[i]<i){const s=i%2===0?0:o[i],r=e[s];e[s]=e[i],e[i]=r,yield[...e],o[i]=o[i]+1,i=0}else o[i]=0,i++},$l=7,El=400,Tl=1e-6,Qn=(t,e,n,o,i=xt.sweeps,s=0,r=Jt.aspectDeviation,a=El)=>{if(t.length===0)return{positions:new Map,width:0,height:0};if(t.length===1){const $=t[0];return{positions:new Map([[$.id,{x:0,y:0}]]),width:$.width,height:$.height}}const d=new Map(t.map($=>[$.id,{width:$.width,height:$.height}])),l=e.filter($=>d.has($.from)&&d.has($.to)&&$.from!==$.to),c=$=>{const L=$.map(N=>({id:N,...d.get(N)}));let S=Wn(L,n,1),T=Number.POSITIVE_INFINITY,E=1;const R=s>0?Math.min(s,L.length):1,A=s>0?R:L.length;for(let N=R;N<=A;N++){const U=Wn(L,n,N);if(U.width<=0||U.height<=0)continue;const H=Vn(U,d,l,o,r);H<T&&(T=H,S=U,E=N)}return{packed:S,cost:T,rowCount:E}},h=($,L)=>Wn($.map(S=>({id:S,...d.get(S)})),n,L),p=t.map($=>$.id);if(p.length<=$l){let $=c(p);for(const L of wl(p)){const S=c(L);S.cost<$.cost&&($=S)}return $.packed}const u=s>0?Math.min(a,50):a;let g=fl(t,l,i);const b=c(g),f=s>0?Math.min(s,g.length):b.rowCount;let m=s>0?h(g,f):b.packed,x=s>0?Vn(m,d,l,o,r):b.cost,k=0,w=!0;for(;w&&k<u;){w=!1;for(let $=0;$<g.length-1&&k<u;$++){k++;const L=[...g],S=L[$];L[$]=L[$+1],L[$+1]=S;const T=h(L,f);if(T.width<=0||T.height<=0)continue;const E=Vn(T,d,l,o,r);E<x-Tl&&(x=E,m=T,g=L,w=!0)}}return m},Sl=(t,e,n,o,i)=>{if(n<=0&&o<=0||t.positions.size<=1)return t;const s=new Map;for(const[p,u]of t.positions){const g=s.get(u.y);g?g.push(p):s.set(u.y,[p])}const a=[...s.keys()].sort((p,u)=>p-u).map(p=>[...s.get(p)??[]].sort((u,g)=>(t.positions.get(u)?.x??0)-(t.positions.get(g)?.x??0))),d=new Map;let l=0,c=0,h=0;return a.forEach((p,u)=>{const g=a[u-1];if(g!==void 0){const f=p.some(i)||g.some(i);h+=f?n:0}let b=0;p.forEach((f,m)=>{const x=p[m-1];x!==void 0&&(b+=i(x)||i(f)?o:0);const k=t.positions.get(f),w=e.get(f);if(!k||!w)return;const $={x:k.x+b,y:k.y+h};d.set(f,$),l=Math.max(l,$.x+w.width),c=Math.max(c,$.y+w.height)})}),{positions:d,width:l,height:c}},Ui=1.3,Ml=1.45,Il=(t,e,n={})=>{const o={...xt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(E=>E.id)),s=e.filter(E=>i.has(E.from)&&i.has(E.to)),r=E=>E.group??`__loose:${E.id}`,a=E=>E.superGroup??`__top:${E.id}`,d=new Map(t.map(E=>[E.id,r(E)])),l=new Map(t.map(E=>[E.id,a(E)])),c=new Map;for(const E of t){const R=r(E),A=c.get(R);A?A.push(E):c.set(R,[E])}const h=new Map;for(const[E,R]of c){const A=R[0];if(R.length===1&&A!==void 0){h.set(E,{size:{width:A.width,height:A.height},relative:new Map([[A.id,{x:0,y:0}]])});continue}const N=new Set(R.map(q=>q.id)),U=s.filter(q=>N.has(q.from)&&N.has(q.to)),H=Qn(R.map(q=>({id:q.id,width:q.width,height:q.height})),U,o.nodeSpacing,Ui,o.sweeps,0,Bi);h.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const p=new Map;for(const[E,R]of c){const A=R[0];A!==void 0&&p.set(E,a(A))}const u=new Map;for(const[E,R]of p){const A=u.get(R);A?A.push(E):u.set(R,[E])}const g=new Map;for(const[E,R]of u){const A=R[0];if(R.length===1&&A!==void 0){const q=h.get(A);q&&g.set(E,{size:q.size,relative:new Map([[A,{x:0,y:0}]])});continue}const N=new Map(R.flatMap(q=>h.has(q)?[[q,h.get(q).size]]:[])),U=s.flatMap(q=>{const ee=d.get(q.from),Q=d.get(q.to);return ee===void 0||Q===void 0||ee===Q?[]:!R.includes(ee)||!R.includes(Q)?[]:[{id:q.id,from:ee,to:Q}]}),H=Qn(R.flatMap(q=>N.has(q)?[{id:q,...N.get(q)}]:[]),U,o.groupSpacing,Ui,o.sweeps,0,Bi);g.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const b=new Map([...g].map(([E,R])=>[E,R.size])),f=[...g.keys()],m=new Set(t.flatMap(E=>E.superGroup===void 0?[]:[E.superGroup])),x=E=>{const R=new Map;for(const[A,N]of u){const U=E.get(A)??{x:0,y:0},H=g.get(A);for(const q of N){const ee=H?.relative.get(q)??{x:0,y:0},Q=h.get(q);if(Q)for(const[G,Z]of Q.relative)R.set(G,{x:U.x+ee.x+Z.x,y:U.y+ee.y+Z.y})}}return R};let k=new Map;if(f.length<=1)for(const E of f)k.set(E,{x:0,y:0});else{const E=s.flatMap(G=>{const Z=l.get(G.from),ne=l.get(G.to);return Z===void 0||ne===void 0||Z===ne?[]:[{id:G.id,from:Z,to:ne}]}),R=G=>Qn(f.map(Z=>({id:Z,...b.get(Z)})),E,o.superGroupSpacing,Ml,o.sweeps,G,kl),A=R(o.superGroupRowCount),N=o.superGroupRowCount>0?[]:[1,2,3,4].filter(G=>G<=f.length),U=[A,...N.map(G=>R(G))],H=G=>{const Z=Sl(G,b,o.superGroupRowGap,o.superGroupColumnGap,K=>m.has(K)),ne=vl(t,s,x(Z.positions)),D=Math.min(1180/Math.max(1,Z.width),900/Math.max(1,Z.height),1);return{offsets:Z.positions,crossings:ne,fit:D}},q=U.map(H),ee=q[0];let Q=ee;for(const G of q.slice(1))G.crossings>ee.crossings*.8||G.fit<ee.fit*.9||(G.crossings<Q.crossings||G.crossings===Q.crossings&&G.fit>Q.fit)&&(Q=G);k=new Map(Q.offsets)}const w=x(k),$=Kn(t,s).reversed,L=t.map((E,R)=>{const A=w.get(E.id)??{x:0,y:0};return{spec:E,layer:0,order:R,x:A.x,y:A.y}}),S=new Map(L.map(E=>[E.spec.id,E])),T=jt(s,$,{byId:S,layerSpacing:o.layerSpacing,padding:o.padding});return jn(L,T,o.padding)},Cl=(t,e,n,o,i={})=>{if(e.size===0)return t;const s={...xt,...i},r=new Map(n.map(f=>[f.id,f])),a=t.nodes.map(f=>{const m=e.get(f.id);return m===void 0?f:{...f,x:m.x,y:m.y}}),d=new Map(a.map(f=>[f.id,{spec:r.get(f.id)??{id:f.id,width:f.width,height:f.height},layer:f.layer,order:f.order,x:f.x,y:f.y}])),l=new Set(a.map(f=>f.id)),c=o.filter(f=>l.has(f.from)&&l.has(f.to)),h=jt(c,new Set,{byId:d,layerSpacing:s.layerSpacing,padding:s.padding}),p=[...a.map(f=>f.x+f.width),...h.flatMap(f=>f.points.map(m=>m.x))],u=[...a.map(f=>f.y+f.height),...h.flatMap(f=>f.points.map(m=>m.y))],g=Math.max(t.width,Math.max(0,...p)+s.padding),b=Math.max(t.height,Math.max(0,...u)+s.padding);return{width:g,height:b,nodes:a,routes:h}},Hi=(t,e,n={})=>{const o={...xt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(d=>d.id)),s=e.filter(d=>i.has(d.from)&&i.has(d.to)),r=Li(t,new Map,new Map,d=>d.position??{x:0,y:0}),a=new Map(r.map(d=>[d.spec.id,d]));return jn(r,jt(s,new Set,{byId:a,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},Yi={kind:"idle"},Ll=t=>({kind:"node",...t,moved:!1,preview:null}),_l=t=>({kind:"group",...t,moved:!1,preview:null}),Rl=(t,e,n,o)=>{if(t.kind==="idle")return t;const i=e.screenX-t.origin.screenX,s=e.screenY-t.origin.screenY;if(!t.moved&&Math.hypot(i,s)<=o)return t;const r=i/n,a=s/n;if(t.kind==="node"){const l={x:Math.max(0,t.start.x+r),y:Math.max(0,t.start.y+a)};return{...t,moved:!0,preview:l}}const d=new Map;for(const[l,c]of t.starts)d.set(l,{x:Math.max(0,c.x+r),y:Math.max(0,c.y+a)});return{...t,moved:!0,preview:d}},Xi=ce({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:t=>`Comment on ${t}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the data.",nodes:"elements",edges:"relations",change:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:t=>`${t}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`}}),Gi={v:1,overrides:[]},Zn="dpk-layout-change",Al=(t,e)=>t.board===e.board&&t.diagram===e.diagram&&t.node===e.node,Ki=(t,e,n)=>({...t,overrides:[...t.overrides.filter(o=>!Al(o,e)),{...e,position:n}]}),Ol=(t,e)=>e.reduce((n,o)=>Ki(n,o,o.position),t),Nl=(t,e,n)=>new Map(t.overrides.filter(o=>o.board===e&&o.diagram===n).map(o=>[o.node,o.position])),Dl=(t,e,n)=>t.overrides.some(o=>o.board===e&&o.diagram===n),zl=(t,e,n)=>{const o=t.overrides.filter(i=>!(i.board===e&&i.diagram===n));return o.length===t.overrides.length?t:{...t,overrides:o}},Pl=(t,e,n,o)=>{const i=t.overrides.filter(s=>!(s.board===e&&s.diagram===n)||o.has(s.node));return i.length===t.overrides.length?t:{...t,overrides:i}},ql=O({x:le(),y:le()}),Fl=O({board:y(),diagram:y(),node:y(),position:ql}),Bl=O({v:pe(1),overrides:F(Fl)}),ji=t=>{const e=Oe(Bl,t);return e.success?e.output:null},Ul=t=>`dev-process-kit:layout-positions:${t}`,Hl=()=>{const t=typeof location>"u"?"local":`${location.pathname}${location.search}`;return Ul(t)},Yl=()=>Ed(ji),Xl=()=>$d(ji),Gl=t=>t.closest(Td)?.getAttribute(Sd)??"";class Kl{#o;#i;#e=null;#n="";#t=Gi;#a=()=>this.#c();constructor(e,n){this.#o=e,this.#i=n,e.addController(this)}hostConnected(){this.#e=this.#i.persist===!1?Xl():Yl(),this.#n=Hl(),this.#t=this.#e.read(this.#n)??Gi,window.addEventListener(Zn,this.#a)}hostDisconnected(){window.removeEventListener(Zn,this.#a)}get#r(){return Gl(this.#i.host())}get#s(){return this.#i.diagram()}overrides(){return Nl(this.#t,this.#r,this.#s)}hasOverrides(){return Dl(this.#t,this.#r,this.#s)}commit(e,n){this.#t=Ki(this.#t,{board:this.#r,diagram:this.#s,node:e},n),this.#d()}commitMany(e){if(e.size===0)return;const n=[...e].map(([o,i])=>({board:this.#r,diagram:this.#s,node:o,position:i}));this.#t=Ol(this.#t,n),this.#d()}prune(e){const n=Pl(this.#t,this.#r,this.#s,e);n!==this.#t&&(this.#t=n,this.#d())}reset(){const e=zl(this.#t,this.#r,this.#s);e!==this.#t&&(this.#t=e,this.#d())}#d(){this.#e?.write(this.#n,this.#t),this.#o.requestUpdate(),window.dispatchEvent(new CustomEvent(Zn))}#c(){this.#t=this.#e?.read(this.#n)??this.#t,this.#o.requestUpdate()}}const jl=(t,e,n)=>`${t} ${n.node} \xB7 ${e} ${n.edge}`,et=[Md,ri,ai,ae`
1
+ import{a4 as Od,S as Bn,a5 as pe,a6 as Nd,a7 as zd,a8 as re,a9 as _,aa as F,ab as he,ac as x,ad as ce,ae as Pd,af as qd,X as Fd,j as pi,ag as hi,ah as de,ai as T,aj as Y,ak as ui,al as mi,am as Ud,an as Bd,D as Hd,ao as Yd,U as Gd,ap as Hn,aq as Xd,ar as gi,as as k,C as Kd,at as jd,au as ue,av as P,aw as L,ax as S,ay as I,az as G,aA as ye,aB as yt,aC as Yn,aD as Wd,aE as fi,aF as bi,aG as Vd,aH as Me,aI as xi,B as yi,aJ as Qd,G as ki,H as Gn,I as Bt,aK as Zd,aL as j,aM as oe,aN as tt,p as z,t as Ce,aO as me,aP as nt,z as Xn,aQ as kt,aR as Jd,N as Ht,e as Kn,P as U,aS as Yt,aT as el,l as ke,aU as Gt,aV as vi,aW as wi,y as jn,aX as tl,aY as $i,aZ as nl,a_ as Ei,a$ as Xt,b0 as Le,b1 as ol,b2 as il,b3 as sl}from"./shared-B8ZhyjWv.js";import{Q as rl,A as al,H as dl,R as ll,S as cl,T as ve,U as Ie,V as Ti,W as pl,X as we,Y as hl,Z as Wn,_ as Si,$ as ul}from"./shared-DIEJ9E2G.js";import{o as ml}from"./shared-D4PPk0Dk.js";import{E as gl,t as Ae,u as fl,v as Ne,B as Kt,w as jt,x as bl}from"./shared-Dd8JfvQe.js";import{a as xl,c as yl}from"./shared-Dn92ukYW.js";import{o as Wt}from"./shared-LHG2FbnK.js";import{h as Mi,l as kl,d as Vn,a as Ci}from"./shared-Be43xweD.js";const vl=[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2"}]],wl=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"}]],$l=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"}]],El=[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1"}]],Tl=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}],["path",{d:"M5 17A12 12 0 0 1 17 5"}]];function Sl(t,e){let n=0;for(let o=0;o<t.length;o++)n+=e(t[o],o);return n}function Li(t){if(t.length===0)return NaN;const e=t.slice().sort((o,i)=>o-i),n=Math.floor(e.length/2);return e.length%2===0?(e[n-1]+e[n])/2:e[n]}const Ii={},Ai=t=>{const e={kind:"board",name:t.name,label:t.label,addable:t.addable??!1,parseBase:()=>Ii,emptyBase:()=>Ii,actions:{},apply:()=>null,hasTarget:()=>!1,describe:i=>({title:i.type,targetLabel:Bn(i.target),tone:"meta"}),serialize:i=>`${i.type} ${Bn(i.target)} ${JSON.stringify(i.payload)}`,resolveNavigation:()=>({}),commentTargets:()=>[],title:()=>t.label},n=t.commentTargets?.()??[],o=new Map((t.elementActionResults?.()??[]).map(i=>[i.id,i]));return Od(e,n,o)},vt={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6,groupSpacing:34,superGroupSpacing:34,superGroupRowGap:0,superGroupColumnGap:0,superGroupRowCount:0},wt=t=>{const e=[...t].sort((o,i)=>o-i);if(e.length===0)return 0;const n=Math.floor(e.length/2);return e.length%2===1?e[n]??0:((e[n-1]??0)+(e[n]??0))/2},Qn=(t,e)=>{const n=new Map;for(const r of t)n.set(r.id,[]);for(const r of e)n.get(r.from)?.push(r);const o=new Map,i=new Set,s=r=>{o.set(r,"open");for(const a of n.get(r)??[]){const d=o.get(a.to)??"new";d==="open"?i.add(a.id):d==="new"&&s(a.to)}o.set(r,"done")};for(const r of t)(o.get(r.id)??"new")==="new"&&s(r.id);return{reversed:i,forward:e.filter(r=>!i.has(r.id))}},Ri=(t,e)=>{const n=new Map,o=new Map;for(const a of t)n.set(a.id,[]),o.set(a.id,[]);for(const a of e)o.get(a.from)?.push(a),n.get(a.to)?.push(a);const i=new Map(t.map(a=>[a.id,0])),s=new Map(t.map(a=>[a.id,(n.get(a.id)??[]).length])),r=t.filter(a=>(s.get(a.id)??0)===0).map(a=>a.id);for(const a of r)for(const d of o.get(a)??[]){const l=i.get(d.to)??0;i.set(d.to,Math.max(l,(i.get(a)??0)+1));const c=(s.get(d.to)??0)-1;s.set(d.to,c),c===0&&r.push(d.to)}return i},_i=(t,e,n,o)=>{const i=[...t.keys()].sort((s,r)=>s-r);for(let s=0;s<o;s++){const r=s%2===0;for(const a of r?i:[...i].reverse()){const d=t.get(a)??[],l=new Map(d.map((p,u)=>[p,u])),c=p=>{const u=l.get(p);return u===void 0?null:u},h=d.map(p=>{const u=(e.get(p)??[]).filter(g=>(n.get(g)??a)===a+(r?-1:1)).map(c).filter(g=>g!==null);return{id:p,want:u.length>0?wt(u):l.get(p)??0}});h.sort((p,u)=>p.want-u.want||(l.get(p.id)??0)-(l.get(u.id)??0)),t.set(a,h.map(p=>p.id))}}},Di=(t,e,n,o)=>{const i=t.map((r,a)=>({id:r,want:n.get(r)??a*100,index:a}));i.sort((r,a)=>r.want-a.want||r.index-a.index);let s=0;for(const r of i){const a=e.get(r.id);a&&(a.y=s,s+=a.spec.height+o)}return{height:Math.max(0,s-o)}},Ml=(t,e,n,o,i)=>{const s=[...t.keys()].sort((l,c)=>l-c),r=new Map;for(const l of s)r.set(l,Di(t.get(l)??[],e,new Map,i.nodeSpacing).height);const a=Math.max(0,...r.values());for(const l of s){const c=(a-(r.get(l)??0))/2;for(const h of t.get(l)??[]){const p=e.get(h);p&&(p.y+=c)}}const d=(l,c)=>{const h=(n.get(l)??[]).filter(p=>o.get(p)===c).flatMap(p=>{const u=e.get(p);return u?[u.y+u.spec.height/2]:[]});return h.length>0?wt(h):null};for(let l=0;l<i.coordinatePasses;l++){const c=l%2===0;for(const h of c?s:[...s].reverse()){const p=t.get(h)??[],u=new Map;for(const m of p){const y=d(m,h+(c?-1:1)),v=e.get(m);v!==void 0&&u.set(m,y===null?v.y+v.spec.height/2:y)}const g=p.map(m=>e.get(m)?.y??0);Di(p,e,u,i.nodeSpacing);const b=p.map(m=>e.get(m)?.y??0),f=wt(g)-wt(b);for(const m of p){const y=e.get(m);y&&(y.y+=f)}}}},Oi=(t,e,n,o,i,s,r)=>{for(const a of i){const d=t.filter(h=>o.get(h)===a);if(d.length===0)continue;const l=d.map((h,p)=>({id:h,want:n.get(h)??p,index:p})).sort((h,p)=>h.want-p.want||h.index-p.index);let c=s.get(a)??0;for(const h of l){const p=e.get(h.id);p&&(p.y=c,c+=p.spec.height+r)}}},Cl=(t,e,n,o,i)=>{let s=0;for(const r of t.values()){const a=r.filter(l=>n.get(l)===o);if(a.length===0)continue;const d=a.reduce((l,c)=>l+(e.get(c)?.spec.height??0),0)+i*(a.length-1);d>s&&(s=d)}return s},Ll=(t,e,n,o,i,s,r)=>{const a=new Map(t.map(M=>[M.id,M.group??M.id])),d=new Set(t.flatMap(M=>M.group===void 0?[]:[M.group])),l=t.some(M=>M.superGroup!==void 0),c=new Map;for(const M of t){const E=a.get(M.id)??M.id;M.superGroup!==void 0&&!c.has(E)&&c.set(E,M.superGroup)}const h=M=>c.get(M)??M,p=[...e.keys()].sort((M,E)=>M-E),u=M=>{const E=i.get(M)??0,R=(e.get(E)??[]).length,D=s.get(M)??0;return R<=1?0:D/(R-1)},g=[...new Set(a.values())],b=M=>{const E=t.filter(R=>(a.get(R.id)??R.id)===M).map(R=>R.id);return E.length===0?0:E.reduce((R,D)=>R+u(D),0)/E.length},f=[...new Set(g.map(h))],m=M=>{const E=t.filter(R=>h(a.get(R.id)??R.id)===M).map(R=>R.id);return E.length===0?0:E.reduce((R,D)=>R+u(D),0)/E.length},v=f.sort((M,E)=>m(M)-m(E)).flatMap(M=>g.filter(E=>h(E)===M).sort((E,R)=>b(E)-b(R))),w=new Map(v.map(M=>[M,Cl(e,n,a,M,r.nodeSpacing)])),$=new Map;let A=0;for(const[M,E]of v.entries()){$.set(E,A),A+=w.get(E)??0;const R=v[M+1];if(R!==void 0){const D=l&&h(E)!==h(R);A+=D?r.superGroupSpacing:d.has(E)||d.has(R)?r.groupSpacing:r.nodeSpacing}}for(const M of p){const E=e.get(M)??[];Oi(E,n,new Map(E.map(R=>[R,s.get(R)??0])),a,v,$,r.nodeSpacing)}const C=(M,E)=>{const R=(o.get(M)??[]).filter(D=>i.get(D)===E).flatMap(D=>{const O=n.get(D);return O?[O.y+O.spec.height/2]:[]});return R.length>0?wt(R):null};for(let M=0;M<r.coordinatePasses;M++){const E=M%2===0;for(const R of E?p:[...p].reverse()){const D=e.get(R)??[],O=new Map;for(const B of D){const H=C(B,R+(E?-1:1)),q=n.get(B);q!==void 0&&O.set(B,H===null?q.y+q.spec.height/2:H)}Oi(D,n,O,a,v,$,r.nodeSpacing)}}},Ni=(t,e,n)=>{const o=e===void 0?void 0:t.spec.ports?.[e];return o?{x:t.x+o.x,y:t.y+o.y}:n==="out"?{x:t.x+t.spec.width,y:t.y+t.spec.height/2}:{x:t.x,y:t.y+t.spec.height/2}},Vt=(t,e,n)=>{let o=0;const i=[];for(const s of t){const r=n.byId.get(s.from),a=n.byId.get(s.to);if(!r||!a)continue;const d=Ni(r,s.fromPort,"out"),l=Ni(a,s.toPort,"in");if(s.from===s.to){const g=r.x+r.spec.width,b=r.y+r.spec.height,f=Math.max(n.padding/2,b+18);i.push({id:s.id,points:[d,{x:g+20,y:d.y},{x:g+20,y:f},{x:r.x-20,y:f},{x:r.x-20,y:l.y},l]});continue}if(!e.has(s.id)&&(r.layer<a.layer||r.layer===a.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){i.push({id:s.id,points:[d,l]});continue}const b=r.layer<a.layer?Math.max(d.x+14,a.x-Math.max(12,n.layerSpacing/2)):(d.x+l.x)/2;i.push({id:s.id,points:[d,{x:b,y:d.y},{x:b,y:l.y},l]});continue}const c=s.fromPort===void 0?{x:r.x+r.spec.width/2,y:r.y+r.spec.height}:d,h=s.toPort===void 0?{x:a.x+a.spec.width/2,y:a.y+a.spec.height}:l,p=Math.max(c.y,h.y)+18+o*14;o+=1;const u=[d,c,{x:c.x,y:p},{x:h.x,y:p},h,l].filter((g,b,f)=>b===0||g.x!==f[b-1]?.x||g.y!==f[b-1]?.y);i.push({id:s.id,points:u})}return i},Zn=(t,e,n)=>{const o=e.flatMap(p=>[...p.points]),i=[...t.map(p=>p.x),...t.map(p=>p.x+p.spec.width),...o.map(p=>p.x)],s=[...t.map(p=>p.y),...t.map(p=>p.y+p.spec.height),...o.map(p=>p.y)],r=Math.min(0,...i),a=Math.min(0,...s),d=Math.max(0,...i),l=Math.max(0,...s),c=n-r,h=n-a;return{width:d-r+n*2,height:l-a+n*2,nodes:t.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+h,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(u=>({x:u.x+c,y:u.y+h}))}))}},Qt=(t,e)=>{const n=new Map(t.map(o=>[o.id,[]]));for(const o of e)o.from!==o.to&&(n.get(o.from)?.push(o.to),n.get(o.to)?.push(o.from));return n},zi=(t,e,n,o)=>t.map(i=>({spec:i,layer:e.get(i.id)??0,order:n.get(i.id)??0,...o(i)})),Pi=(t,e)=>{const n=new Map;for(const o of t){const i=e.get(o.id)??0,s=n.get(i);s?s.push(o.id):n.set(i,[o.id])}return n},qi=(t,e,n={})=>{if(t.some(b=>b.superGroup!==void 0))return Bl(t,e,n);const o={...vt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(b=>b.id)),s=e.filter(b=>i.has(b.from)&&i.has(b.to)),{forward:r,reversed:a}=Qn(t,s),d=Ri(t,r),l=Pi(t,d);_i(l,Qt(t,s),d,o.sweeps);const c=new Map;for(const b of l.values())b.forEach((f,m)=>c.set(f,m));const h=zi(t,d,c,()=>({x:0,y:0})),p=new Map(h.map(b=>[b.spec.id,b]));t.some(b=>b.group!==void 0||b.superGroup!==void 0)?Ll(t,l,p,Qt(t,s),d,c,o):Ml(l,p,Qt(t,s),d,o);const u=[...l.keys()].sort((b,f)=>b-f);let g=0;for(const b of u){const f=Math.max(...(l.get(b)??[]).map(m=>p.get(m)?.spec.width??0));for(const m of l.get(b)??[]){const y=p.get(m);y&&(y.x=g)}g+=f+o.layerSpacing}return Zn(h,Vt(s,a,{byId:p,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},ot=12,Fi=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Ui=(t,e)=>{const n=Fi(t),o=Fi(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},Bi=(t,e,n)=>Math.min(n,Math.max(e,t)),Hi=(t,e,n)=>{const o=Bi(n.y-t.y,ot,Math.max(ot,t.height-ot)),i=t.height<=0?.5:o/t.height,s=t.x+Bi(i*t.width,ot,Math.max(ot,t.width-ot));switch(e){case"left":return{x:t.x,y:t.y+o};case"right":return{x:t.x+t.width,y:t.y+o};case"top":return{x:s,y:t.y};case"bottom":return{x:s,y:t.y+t.height};default:return{x:t.x+t.width,y:t.y+o}}},Il=(t,e,n)=>{if(t.length<=1)return t.map(c=>c.id);const o=t.map(c=>({id:c.id,width:c.width,height:c.height})),i=new Set(o.map(c=>c.id)),s=e.filter(c=>i.has(c.from)&&i.has(c.to)&&c.from!==c.to),{forward:r}=Qn(o,s),a=Ri(o,r),d=Pi(o,a);return _i(d,Qt(o,s),a,n),[...d.keys()].sort((c,h)=>c-h).flatMap(c=>d.get(c)??[])},Al=(t,e,n,o)=>{let i=0;for(let s=e;s<n;s++)i+=t[s].width;return i+o*Math.max(0,n-e-1)},Jn=(t,e,n)=>{const o=t.length,i=Math.max(1,Math.min(n,o)),s=Number.POSITIVE_INFINITY,r=Array.from({length:o+1},()=>Array.from({length:i+1},()=>s)),a=Array.from({length:o+1},()=>Array.from({length:i+1},()=>0));r[0][0]=0;for(let u=1;u<=i;u++)for(let g=u;g<=o;g++)for(let b=u-1;b<g;b++){const f=r[b][u-1];if(f===s)continue;const m=Math.max(f,Al(t,b,g,e));m<r[g][u]&&(r[g][u]=m,a[g][u]=b)}const d=[];let l=o;for(let u=i;u>0;u--){const g=a[l][u];d.unshift(t.slice(g,l)),l=g}const c=new Map;let h=0,p=0;for(const u of d){let g=0;const b=Math.max(...u.map(f=>f.height));for(const f of u)c.set(f.id,{x:g,y:h}),g+=f.width+e;p=Math.max(p,g-e),h+=b+e}return{positions:c,width:p,height:Math.max(0,h-e)}},je=1e-6,Zt=(t,e)=>Math.abs(t.x-e.x)<je&&Math.abs(t.y-e.y)<je,Jt=(t,e,n)=>{const o=(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y);return Math.abs(o)<je?0:o>0?1:-1},en=(t,e,n)=>Math.min(t.x,n.x)-je<=e.x&&e.x<=Math.max(t.x,n.x)+je&&Math.min(t.y,n.y)-je<=e.y&&e.y<=Math.max(t.y,n.y)+je,Yi=(t,e)=>{const[n,o]=t,[i,s]=e;if(Zt(n,i)||Zt(n,s)||Zt(o,i)||Zt(o,s))return!1;const r=Jt(n,o,i),a=Jt(n,o,s),d=Jt(i,s,n),l=Jt(i,s,o);return r!==a&&d!==l||r===0&&en(n,i,o)||a===0&&en(n,s,o)||d===0&&en(i,n,s)?!0:l===0&&en(i,o,s)},Gi=(t,e)=>{const n=t.x+t.width/2,o=t.y+t.height/2,i=e.x+e.width/2,s=e.y+e.height/2,r=i-n,a=s-o;return Math.abs(r)>=Math.abs(a)?{x:r>=0?t.x+t.width:t.x,y:o}:{x:n,y:a>=0?t.y+t.height:t.y}},Rl=(t,e,n)=>{const o=r=>{const a=t.positions.get(r),d=e.get(r);return!a||!d?null:{id:r,x:a.x,y:a.y,width:d.width,height:d.height}},i=[];let s=0;for(const r of n){if(r.from===r.to)continue;const a=o(r.from),d=o(r.to);if(!a||!d)continue;const l=Gi(a,d),c=Gi(d,a);if(l.x===c.x||l.y===c.y){const g=[l,c];s+=i.filter(b=>Yi(g,b)).length,i.push(g);continue}const h=[[[l,{x:c.x,y:l.y}],[{x:c.x,y:l.y},c]],[[l,{x:l.x,y:c.y}],[{x:l.x,y:c.y},c]]];let p=h[0],u=Number.POSITIVE_INFINITY;for(const g of h){const b=g.reduce((f,m)=>f+i.filter(y=>Yi(m,y)).length,0);b<u&&(u=b,p=g)}s+=u,i.push(...p)}return s},_l=(t,e,n)=>{const o=s=>{const r=t.positions.get(s),a=e.get(s);return!r||!a?null:{x:r.x+a.width/2,y:r.y+a.height/2}};let i=0;for(const s of n){if(s.from===s.to)continue;const r=o(s.from),a=o(s.to);r&&a&&(i+=Math.hypot(r.x-a.x,r.y-a.y))}return i},Xi=(t,e)=>{const n=t[0].x===t[1].x,o=e[0].x===e[1].x;if(n===o)return!1;const[i,s,r,a]=n?[t[0],t[1],e[0],e[1]]:[e[0],e[1],t[0],t[1]],d=i.x,l=r.y;return d>Math.min(r.x,a.x)&&d<Math.max(r.x,a.x)&&l>Math.min(i.y,s.y)&&l<Math.max(i.y,s.y)},Ki=(t,e,n,o)=>{const i=n===void 0?void 0:t.ports?.[n];return i!==void 0?{x:e.x+i.x,y:e.y+i.y}:o==="out"?{x:e.x+t.width,y:e.y+t.height/2}:{x:e.x,y:e.y+t.height/2}},Dl=(t,e,n)=>{const o=new Map(t.map(r=>[r.id,r])),i=[];let s=0;for(const r of e){if(r.from===r.to)continue;const a=o.get(r.from),d=o.get(r.to),l=n.get(r.from),c=n.get(r.to);if(a===void 0||d===void 0||l===void 0||c===void 0)continue;const h={x:l.x,y:l.y,width:a.width,height:a.height},p={x:c.x,y:c.y,width:d.width,height:d.height},u=Hi(h,Ui(h,p),Ki(a,l,r.fromPort,"out")),g=Hi(p,Ui(p,h),Ki(d,c,r.toPort,"in")),b=v=>v.slice(1).map((w,$)=>[v[$],w]);if(u.x===g.x||u.y===g.y){const v=[u,g];s+=i.filter(w=>Xi(v,w)).length,i.push(v);continue}const f=[[u,{x:g.x,y:u.y},g],[u,{x:u.x,y:g.y},g]];let m=f[0],y=Number.POSITIVE_INFINITY;for(const v of f){const w=b(v).reduce(($,A)=>$+i.filter(C=>Xi(A,C)).length,0);w<y&&(m=v,y=w)}s+=y,i.push(...b(m))}return s},tn={crossings:1e4,edgeLength:1,aspectDeviation:50},ji=50,Ol=tn.aspectDeviation,eo=(t,e,n,o,i)=>{const s=t.width<=0||t.height<=0?0:Math.abs(Math.log(t.width/t.height/o));return Rl(t,e,n)*tn.crossings+_l(t,e,n)*tn.edgeLength+s*i},Nl=function*(t){const e=[...t],n=e.length;if(yield[...e],n<=1)return;const o=Array.from({length:n}).fill(0);let i=0;for(;i<n;)if(o[i]<i){const s=i%2===0?0:o[i],r=e[s];e[s]=e[i],e[i]=r,yield[...e],o[i]=o[i]+1,i=0}else o[i]=0,i++},zl=7,Pl=400,ql=1e-6,to=(t,e,n,o,i=vt.sweeps,s=0,r=tn.aspectDeviation,a=Pl)=>{if(t.length===0)return{positions:new Map,width:0,height:0};if(t.length===1){const $=t[0];return{positions:new Map([[$.id,{x:0,y:0}]]),width:$.width,height:$.height}}const d=new Map(t.map($=>[$.id,{width:$.width,height:$.height}])),l=e.filter($=>d.has($.from)&&d.has($.to)&&$.from!==$.to),c=$=>{const A=$.map(O=>({id:O,...d.get(O)}));let C=Jn(A,n,1),M=Number.POSITIVE_INFINITY,E=1;const R=s>0?Math.min(s,A.length):1,D=s>0?R:A.length;for(let O=R;O<=D;O++){const B=Jn(A,n,O);if(B.width<=0||B.height<=0)continue;const H=eo(B,d,l,o,r);H<M&&(M=H,C=B,E=O)}return{packed:C,cost:M,rowCount:E}},h=($,A)=>Jn($.map(C=>({id:C,...d.get(C)})),n,A),p=t.map($=>$.id);if(p.length<=zl){let $=c(p);for(const A of Nl(p)){const C=c(A);C.cost<$.cost&&($=C)}return $.packed}const u=s>0?Math.min(a,50):a;let g=Il(t,l,i);const b=c(g),f=s>0?Math.min(s,g.length):b.rowCount;let m=s>0?h(g,f):b.packed,y=s>0?eo(m,d,l,o,r):b.cost,v=0,w=!0;for(;w&&v<u;){w=!1;for(let $=0;$<g.length-1&&v<u;$++){v++;const A=[...g],C=A[$];A[$]=A[$+1],A[$+1]=C;const M=h(A,f);if(M.width<=0||M.height<=0)continue;const E=eo(M,d,l,o,r);E<y-ql&&(y=E,m=M,g=A,w=!0)}}return m},Fl=(t,e,n,o,i)=>{if(n<=0&&o<=0||t.positions.size<=1)return t;const s=new Map;for(const[p,u]of t.positions){const g=s.get(u.y);g?g.push(p):s.set(u.y,[p])}const a=[...s.keys()].sort((p,u)=>p-u).map(p=>[...s.get(p)??[]].sort((u,g)=>(t.positions.get(u)?.x??0)-(t.positions.get(g)?.x??0))),d=new Map;let l=0,c=0,h=0;return a.forEach((p,u)=>{const g=a[u-1];if(g!==void 0){const f=p.some(i)||g.some(i);h+=f?n:0}let b=0;p.forEach((f,m)=>{const y=p[m-1];y!==void 0&&(b+=i(y)||i(f)?o:0);const v=t.positions.get(f),w=e.get(f);if(!v||!w)return;const $={x:v.x+b,y:v.y+h};d.set(f,$),l=Math.max(l,$.x+w.width),c=Math.max(c,$.y+w.height)})}),{positions:d,width:l,height:c}},Wi=1.3,Ul=1.45,Bl=(t,e,n={})=>{const o={...vt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(E=>E.id)),s=e.filter(E=>i.has(E.from)&&i.has(E.to)),r=E=>E.group??`__loose:${E.id}`,a=E=>E.superGroup??`__top:${E.id}`,d=new Map(t.map(E=>[E.id,r(E)])),l=new Map(t.map(E=>[E.id,a(E)])),c=new Map;for(const E of t){const R=r(E),D=c.get(R);D?D.push(E):c.set(R,[E])}const h=new Map;for(const[E,R]of c){const D=R[0];if(R.length===1&&D!==void 0){h.set(E,{size:{width:D.width,height:D.height},relative:new Map([[D.id,{x:0,y:0}]])});continue}const O=new Set(R.map(q=>q.id)),B=s.filter(q=>O.has(q.from)&&O.has(q.to)),H=to(R.map(q=>({id:q.id,width:q.width,height:q.height})),B,o.nodeSpacing,Wi,o.sweeps,0,ji);h.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const p=new Map;for(const[E,R]of c){const D=R[0];D!==void 0&&p.set(E,a(D))}const u=new Map;for(const[E,R]of p){const D=u.get(R);D?D.push(E):u.set(R,[E])}const g=new Map;for(const[E,R]of u){const D=R[0];if(R.length===1&&D!==void 0){const q=h.get(D);q&&g.set(E,{size:q.size,relative:new Map([[D,{x:0,y:0}]])});continue}const O=new Map(R.flatMap(q=>h.has(q)?[[q,h.get(q).size]]:[])),B=s.flatMap(q=>{const ee=d.get(q.from),Q=d.get(q.to);return ee===void 0||Q===void 0||ee===Q?[]:!R.includes(ee)||!R.includes(Q)?[]:[{id:q.id,from:ee,to:Q}]}),H=to(R.flatMap(q=>O.has(q)?[{id:q,...O.get(q)}]:[]),B,o.groupSpacing,Wi,o.sweeps,0,ji);g.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const b=new Map([...g].map(([E,R])=>[E,R.size])),f=[...g.keys()],m=new Set(t.flatMap(E=>E.superGroup===void 0?[]:[E.superGroup])),y=E=>{const R=new Map;for(const[D,O]of u){const B=E.get(D)??{x:0,y:0},H=g.get(D);for(const q of O){const ee=H?.relative.get(q)??{x:0,y:0},Q=h.get(q);if(Q)for(const[X,Z]of Q.relative)R.set(X,{x:B.x+ee.x+Z.x,y:B.y+ee.y+Z.y})}}return R};let v=new Map;if(f.length<=1)for(const E of f)v.set(E,{x:0,y:0});else{const E=s.flatMap(X=>{const Z=l.get(X.from),ne=l.get(X.to);return Z===void 0||ne===void 0||Z===ne?[]:[{id:X.id,from:Z,to:ne}]}),R=X=>to(f.map(Z=>({id:Z,...b.get(Z)})),E,o.superGroupSpacing,Ul,o.sweeps,X,Ol),D=R(o.superGroupRowCount),O=o.superGroupRowCount>0?[]:[1,2,3,4].filter(X=>X<=f.length),B=[D,...O.map(X=>R(X))],H=X=>{const Z=Fl(X,b,o.superGroupRowGap,o.superGroupColumnGap,K=>m.has(K)),ne=Dl(t,s,y(Z.positions)),N=Math.min(1180/Math.max(1,Z.width),900/Math.max(1,Z.height),1);return{offsets:Z.positions,crossings:ne,fit:N}},q=B.map(H),ee=q[0];let Q=ee;for(const X of q.slice(1))X.crossings>ee.crossings*.8||X.fit<ee.fit*.9||(X.crossings<Q.crossings||X.crossings===Q.crossings&&X.fit>Q.fit)&&(Q=X);v=new Map(Q.offsets)}const w=y(v),$=Qn(t,s).reversed,A=t.map((E,R)=>{const D=w.get(E.id)??{x:0,y:0};return{spec:E,layer:0,order:R,x:D.x,y:D.y}}),C=new Map(A.map(E=>[E.spec.id,E])),M=Vt(s,$,{byId:C,layerSpacing:o.layerSpacing,padding:o.padding});return Zn(A,M,o.padding)},Hl=(t,e,n,o,i={})=>{if(e.size===0)return t;const s={...vt,...i},r=new Map(n.map(f=>[f.id,f])),a=t.nodes.map(f=>{const m=e.get(f.id);return m===void 0?f:{...f,x:m.x,y:m.y}}),d=new Map(a.map(f=>[f.id,{spec:r.get(f.id)??{id:f.id,width:f.width,height:f.height},layer:f.layer,order:f.order,x:f.x,y:f.y}])),l=new Set(a.map(f=>f.id)),c=o.filter(f=>l.has(f.from)&&l.has(f.to)),h=Vt(c,new Set,{byId:d,layerSpacing:s.layerSpacing,padding:s.padding}),p=[...a.map(f=>f.x+f.width),...h.flatMap(f=>f.points.map(m=>m.x))],u=[...a.map(f=>f.y+f.height),...h.flatMap(f=>f.points.map(m=>m.y))],g=Math.max(t.width,Math.max(0,...p)+s.padding),b=Math.max(t.height,Math.max(0,...u)+s.padding);return{width:g,height:b,nodes:a,routes:h}},Vi=(t,e,n={})=>{const o={...vt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(d=>d.id)),s=e.filter(d=>i.has(d.from)&&i.has(d.to)),r=zi(t,new Map,new Map,d=>d.position??{x:0,y:0}),a=new Map(r.map(d=>[d.spec.id,d]));return Zn(r,Vt(s,new Set,{byId:a,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},Qi={kind:"idle"},Yl=t=>({kind:"node",...t,moved:!1,preview:null}),Gl=t=>({kind:"group",...t,moved:!1,preview:null}),Xl=(t,e,n,o)=>{if(t.kind==="idle")return t;const i=e.screenX-t.origin.screenX,s=e.screenY-t.origin.screenY;if(!t.moved&&Math.hypot(i,s)<=o)return t;const r=i/n,a=s/n;if(t.kind==="node"){const l={x:Math.max(0,t.start.x+r),y:Math.max(0,t.start.y+a)};return{...t,moved:!0,preview:l}}const d=new Map;for(const[l,c]of t.starts)d.set(l,{x:Math.max(0,c.x+r),y:Math.max(0,c.y+a)});return{...t,moved:!0,preview:d}},Zi=pe({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:t=>`Comment on ${t}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the data.",nodes:"elements",edges:"relations",change:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:t=>`${t}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`}}),Ji={v:1,overrides:[]},no="dpk-layout-change",Kl=(t,e)=>t.board===e.board&&t.diagram===e.diagram&&t.node===e.node,es=(t,e,n)=>({...t,overrides:[...t.overrides.filter(o=>!Kl(o,e)),{...e,position:n}]}),jl=(t,e)=>e.reduce((n,o)=>es(n,o,o.position),t),Wl=(t,e,n)=>new Map(t.overrides.filter(o=>o.board===e&&o.diagram===n).map(o=>[o.node,o.position])),Vl=(t,e,n)=>t.overrides.some(o=>o.board===e&&o.diagram===n),Ql=(t,e,n)=>{const o=t.overrides.filter(i=>!(i.board===e&&i.diagram===n));return o.length===t.overrides.length?t:{...t,overrides:o}},Zl=(t,e,n,o)=>{const i=t.overrides.filter(s=>!(s.board===e&&s.diagram===n)||o.has(s.node));return i.length===t.overrides.length?t:{...t,overrides:i}},Jl=_({x:ce(),y:ce()}),ec=_({board:x(),diagram:x(),node:x(),position:Jl}),tc=_({v:he(1),overrides:F(ec)}),ts=t=>{const e=re(tc,t);return e.success?e.output:null},nc=t=>`dev-process-kit:layout-positions:${t}`,oc=()=>{const t=typeof location>"u"?"local":`${location.pathname}${location.search}`;return nc(t)},ic=()=>zd(ts),sc=()=>Nd(ts),rc=t=>t.closest(Pd)?.getAttribute(qd)??"";class ac{#o;#i;#e=null;#t="";#n=Ji;#a=()=>this.#c();constructor(e,n){this.#o=e,this.#i=n,e.addController(this)}hostConnected(){this.#e=this.#i.persist===!1?sc():ic(),this.#t=oc(),this.#n=this.#e.read(this.#t)??Ji,window.addEventListener(no,this.#a)}hostDisconnected(){window.removeEventListener(no,this.#a)}get#r(){return rc(this.#i.host())}get#s(){return this.#i.diagram()}overrides(){return Wl(this.#n,this.#r,this.#s)}hasOverrides(){return Vl(this.#n,this.#r,this.#s)}commit(e,n){this.#n=es(this.#n,{board:this.#r,diagram:this.#s,node:e},n),this.#d()}commitMany(e){if(e.size===0)return;const n=[...e].map(([o,i])=>({board:this.#r,diagram:this.#s,node:o,position:i}));this.#n=jl(this.#n,n),this.#d()}prune(e){const n=Zl(this.#n,this.#r,this.#s,e);n!==this.#n&&(this.#n=n,this.#d())}reset(){const e=Ql(this.#n,this.#r,this.#s);e!==this.#n&&(this.#n=e,this.#d())}#d(){this.#e?.write(this.#t,this.#n),this.#o.requestUpdate(),window.dispatchEvent(new CustomEvent(no))}#c(){this.#n=this.#e?.read(this.#t)??this.#n,this.#o.requestUpdate()}}const dc=(t,e,n)=>`${t} ${n.node} \xB7 ${e} ${n.edge}`,it=[Fd,pi,hi,de`
2
2
  :host {
3
3
  display: block;
4
4
  container-type: inline-size;
@@ -139,7 +139,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
139
139
  font-size: 11px;
140
140
  color: var(--dpk-accent);
141
141
  }
142
- `],Wl=ae`
142
+ `],lc=de`
143
143
  /*
144
144
  * The shell is a panel: header, tag row, viewport. The sizing knob is
145
145
  * --diagram-height; the panel may be resized vertically, and the canvas
@@ -346,7 +346,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
346
346
  .d-edge-label.is-dimmed {
347
347
  opacity: 0.3;
348
348
  }
349
- `,De=[...et,Wl],en=t=>t.map((e,n)=>`${n===0?"M":"L"}${e.x} ${e.y}`).join(" "),Wi=t=>Y`
349
+ `,ze=[...it,lc],nn=t=>t.map((e,n)=>`${n===0?"M":"L"}${e.x} ${e.y}`).join(" "),ns=t=>Y`
350
350
  <defs>
351
351
  ${t.map(e=>Y`
352
352
  <marker
@@ -361,27 +361,27 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
361
361
  <path
362
362
  class="diagram-arrow"
363
363
  d=${e.open===!0?"M1 1 L9 5 L1 9":"M1 1 L9 5 L1 9 Z"}
364
- fill=${e.open===!0||e.color===void 0?M:e.color}
365
- stroke=${e.color??M}
364
+ fill=${e.open===!0||e.color===void 0?T:e.color}
365
+ stroke=${e.color??T}
366
366
  stroke-width="1.3"
367
367
  ></path>
368
368
  </marker>
369
369
  `)}
370
370
  </defs>
371
- `,Vi={fromAttribute:t=>t==="board"?"board":"embedded",toAttribute:t=>t},Jn=t=>typeof t=="object"&&t!==null;class tt extends di{static{this.styles=et}static{this.properties={data:{attribute:!1},id:{type:String,reflect:!0},heading:{type:String},subject:{type:String},variant:{type:String,reflect:!0,converter:Vi}}}#o=null;#i=null;#e=[];#n=[];#t=null;#a=nl;#r=null;#s=null;#d="";#c=new Kd(this);#p=new li(this,()=>{this.#d=""});#u=null;#h=null;constructor(){super(),this.id=this.getAttribute("id")??"",this.data=null,this.heading=null,this.subject=null,this.variant=Vi.fromAttribute(this.getAttribute("variant"))}connectedCallback(){jd(),Wd(),super.connectedCallback(),this.#d="",this.requestUpdate(),this.#s=tl(this,e=>this.parseData(e),e=>{e.ok?this.#b(e.value):this.#$(e.error)}),this.board!==null&&this.#g()}disconnectedCallback(){super.disconnectedCallback(),this.#s?.(),this.#s=null}willUpdate(e){e.has("data")&&this.data!==null&&this.#b(this.data)}updated(){this.#l(),this.#c.sync(this.renderRoot.querySelector(".comment-pop"))}#l(){const e=JSON.stringify([this.commentTargets,this.#n]);e!==this.#d&&(this.#d=e,this.dispatchEvent(new CustomEvent("dpk-comment-targets-change",{bubbles:!0,composed:!0})))}get commentTargets(){if(!this.id||this.#t!==null)return[];const e=`${this.subject??this.heading??this.defaultHeading()} \xB7 ${this.id}`;return this.commentItems().map(n=>({...n,group:e}))}commentItems(){return[]}#m(){return this.id!==""?this.id:this.board??this.tagName.toLowerCase()}commentRef(e,...n){return`element:${[this.#m(),e,...n].map(o=>encodeURIComponent(o)).join("/")}`}get elementActions(){return this.#e}set elementActions(e){this.#e=e,this.#w()}get elementActionResults(){return this.#n}get board(){return Id(this)}boardName(){const e=this.tagName.toLowerCase();return e.startsWith("dpk-board-")?e.slice(10):e}boardLabel(){return this.heading??this.defaultHeading()}boardAddable(){return!1}get definition(){return Ei({name:this.boardName(),label:this.boardLabel(),addable:this.boardAddable(),commentTargets:()=>this.commentTargets,elementActionResults:()=>this.elementActionResults})}get controller(){return this.#g()}get api(){return this.#h??=Cd(this.#y(),this),this.#h}#g(){if(this.#u)return this.#u;const e=this.board!==null,n=Ei({name:this.boardName(),label:this.boardLabel(),addable:this.boardAddable()}),o=new Ld(e?{definition:n,base:{},storage:null}:{definition:n,base:{}});return this.#u=o,e&&(this.dataset.template=n.name),o.subscribe(()=>this.#f()),this.#f(),o}#f(){const e=this.#u;if(!e)return;const n=this.#m();this.elementActions=_d(e.actions,n),e.setComponentSnapshot({targets:this.commentTargets,providers:[{id:n,results:this.elementActionResults}]})}#y(){const e=()=>this.#g(),n={definition:this.definition,controller:e,derivation:()=>e().derivation,ready:Promise.resolve(),navigation:()=>({}),issues:()=>e().lastIssues,dispatch:o=>this.#k(o),dispatchBatch:o=>this.#v(o),subscribe:o=>e().subscribe(()=>o(Nd(n))),editComment:(o,i)=>e().editComment(o,i),removeAction:o=>e().removeAction(o),clearActions:()=>e().clearActions(),navigate:()=>{},hashFor:()=>"",requestComment:()=>{}};return n}#C(e){const o=this.#g().descriptorFor(e.type)?.targetType??"element",i=Rd(e.target,o),s=this.board;if(s===null)return{...e,target:i};const r=Fn(this)?.pageNames()??new Set;return{...e,target:Ad(i,s,r)}}#k(e){const n=this.board!==null?Fn(this):null;return n===null?this.#g().dispatch(e):n.dispatch(this.#C(e))}#v(e){const n=this.board!==null?Fn(this):null;return n===null?this.#g().dispatchBatch(e):n.dispatchBatch(e.map(o=>this.#C(o)))}reduceElementActions(e,n){return{data:e,results:n.map(o=>({id:o.id,title:o.type,stale:"unsupported-action-type"}))}}dispatchElementAction(e,n,o){const i=this.commentRef(...n);if(this.board!==null)return this.#k({type:e,target:i,payload:o}).ok;const s=new CustomEvent("dpk-element-action",{detail:{type:e,target:i,payload:o},bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(s),s.defaultPrevented}get selection(){return this.#r}select(e){this.#L(e)}get tagFilter(){return this.#a}set tagFilter(e){this.#a=e,this.requestUpdate()}get dataError(){return this.#t}closeComposer(){this.#c.close()}openComment(e){const n=this.commentTargets.find(o=>o.value===e)?.label;this.#M(e,n??e)}get locale(){return this.#p.locale}get chromeMessages(){return Xi(this.#p.locale)}renderSelection(){return this.#c.render({locale:this.#p.locale,errorMessage:this.chromeMessages.sendFailed,submit:(e,n)=>this.#T(e,n)})}getContextMenuItems(e){const n=Vd(e.target,this.commentTargets,ci(this.locale),(o,i)=>this.#M(o,i));return n===null?null:[n]}#M(e,n){const o=this.renderRoot.querySelector(`[data-dpk-target="${CSS.escape(e)}"]`);o!==null&&this.#c.open(e,o,n)}questionsOf(e){const n=e.questions?.trim();return n===void 0||n===""?M:n}statsText(){return""}tagItems(){return[]}isEmpty(){return!1}shellClass(){return""}get frameControls(){return this.board===null}defaultHeading(){return""}defaultSubject(){return""}emptyMessage(){return this.chromeMessages.noMatches}renderToolbarActions(){return M}items(){return this.#i??this.emptyData()}authoredItems(){return this.#o??this.emptyData()}renderToolbarActionsSlot(){return v`<div slot="actions" class="diagram-toolbar-actions">
371
+ `,os={fromAttribute:t=>t==="board"?"board":"embedded",toAttribute:t=>t},oo=t=>typeof t=="object"&&t!==null;class st extends ui{static{this.styles=it}static{this.properties={data:{attribute:!1},id:{type:String,reflect:!0},heading:{type:String},subject:{type:String},variant:{type:String,reflect:!0,converter:os}}}#o=null;#i=null;#e=[];#t=[];#n=null;#a=gl;#r=null;#s=null;#d="";#c=new rl(this);#h=new mi(this,()=>{this.#d=""});#p=null;#u=null;constructor(){super(),this.id=this.getAttribute("id")??"",this.data=null,this.heading=null,this.subject=null,this.variant=os.fromAttribute(this.getAttribute("variant"))}connectedCallback(){al(),dl(),super.connectedCallback(),this.#d="",this.requestUpdate(),this.#s=ml(this,e=>this.parseData(e),e=>{e.ok?this.#b(e.value):this.#w(e.error)}),this.board!==null&&this.#g()}disconnectedCallback(){super.disconnectedCallback(),this.#s?.(),this.#s=null}willUpdate(e){e.has("data")&&this.data!==null&&this.#b(this.data)}updated(){this.#l(),this.#c.sync(this.renderRoot.querySelector(".comment-pop"))}#l(){const e=JSON.stringify([this.commentTargets,this.#t]);e!==this.#d&&(this.#d=e,this.dispatchEvent(new CustomEvent("dpk-comment-targets-change",{bubbles:!0,composed:!0})))}get commentTargets(){if(!this.id||this.#n!==null)return[];const e=`${this.subject??this.heading??this.defaultHeading()} \xB7 ${this.id}`;return this.commentItems().map(n=>({...n,group:e}))}commentItems(){return[]}#m(){return this.id!==""?this.id:this.board??this.tagName.toLowerCase()}commentRef(e,...n){return`element:${[this.#m(),e,...n].map(o=>encodeURIComponent(o)).join("/")}`}get elementActions(){return this.#e}set elementActions(e){this.#e=e,this.#v()}get elementActionResults(){return this.#t}get board(){return Ud(this)}boardName(){const e=this.tagName.toLowerCase();return e.startsWith("dpk-board-")?e.slice(10):e}boardLabel(){return this.heading??this.defaultHeading()}boardAddable(){return!1}get definition(){return Ai({name:this.boardName(),label:this.boardLabel(),addable:this.boardAddable(),commentTargets:()=>this.commentTargets,elementActionResults:()=>this.elementActionResults})}get controller(){return this.#g()}get componentSnapshot(){return this.#p?.componentSnapshot??null}get api(){return this.#u??=Bd(this.#x(),this),this.#u}#g(){if(this.#p)return this.#p;const e=this.board!==null,n=Ai({name:this.boardName(),label:this.boardLabel(),addable:this.boardAddable()}),o=new Hd(e?{definition:n,base:{},storage:null}:{definition:n,base:{}});return this.#p=o,e&&(this.dataset.template=n.name),o.subscribe(()=>this.#f()),this.#f(),o}#f(){const e=this.#p;if(!e)return;const n=this.#m();this.elementActions=Yd(e.actions,n),e.setComponentSnapshot({targets:this.commentTargets,providers:[{id:n,results:this.elementActionResults}]})}#x(){const e=()=>this.#g(),n={definition:this.definition,controller:e,derivation:()=>e().derivation,ready:Promise.resolve(),navigation:()=>({}),issues:()=>e().lastIssues,dispatch:o=>this.#E(o),dispatchBatch:o=>this.#k(o),subscribe:o=>e().subscribe(()=>o(jd(n))),editComment:(o,i)=>e().editComment(o,i),removeAction:o=>e().removeAction(o),clearActions:()=>e().clearActions(),navigate:()=>{},hashFor:()=>"",requestComment:()=>{}};return n}#A(e){const o=this.#g().descriptorFor(e.type)?.targetType??"element",i=Gd(e.target,o),s=this.board;if(s===null)return{...e,target:i};const r=Hn(this)?.pageNames()??new Set;return{...e,target:Xd(i,s,r)}}#E(e){const n=this.board!==null?Hn(this):null;return n===null?this.#g().dispatch(e):n.dispatch(this.#A(e))}#k(e){const n=this.board!==null?Hn(this):null;return n===null?this.#g().dispatchBatch(e):n.dispatchBatch(e.map(o=>this.#A(o)))}reduceElementActions(e,n){return{data:e,results:n.map(o=>({id:o.id,title:o.type,stale:"unsupported-action-type"}))}}dispatchElementAction(e,n,o){const i=this.commentRef(...n);if(this.board!==null)return this.#E({type:e,target:i,payload:o}).ok;const s=new CustomEvent("dpk-element-action",{detail:{type:e,target:i,payload:o},bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(s),s.defaultPrevented}get selection(){return this.#r}select(e){this.#C(e)}get tagFilter(){return this.#a}set tagFilter(e){this.#a=e,this.requestUpdate()}get dataError(){return this.#n}closeComposer(){this.#c.close()}openComment(e){const n=this.commentTargets.find(o=>o.value===e)?.label;this.#I(e,n??e)}get locale(){return this.#h.locale}get chromeMessages(){return Zi(this.#h.locale)}renderSelection(){return this.#c.render({locale:this.#h.locale,errorMessage:this.chromeMessages.sendFailed,submit:(e,n)=>this.#T(e,n)})}getContextMenuItems(e){const n=ll(e.target,this.commentTargets,gi(this.locale),(o,i)=>this.#I(o,i));return n===null?null:[n]}#I(e,n){const o=this.renderRoot.querySelector(`[data-dpk-target="${CSS.escape(e)}"]`);o!==null&&this.#c.open(e,o,n)}questionsOf(e){const n=e.questions?.trim();return n===void 0||n===""?T:n}statsText(){return""}tagItems(){return[]}isEmpty(){return!1}shellClass(){return""}get frameControls(){return this.board===null}defaultHeading(){return""}defaultSubject(){return""}emptyMessage(){return this.chromeMessages.noMatches}renderToolbarActions(){return T}items(){return this.#i??this.emptyData()}authoredItems(){return this.#o??this.emptyData()}renderToolbarActionsSlot(){return k`<div slot="actions" class="diagram-toolbar-actions">
372
372
  ${this.renderToolbarActions()}
373
373
  <span class="diagram-stats">${this.statsText()}</span>
374
- </div>`}renderTagFilterRow(e=M){return v`<div slot="toolbar" class="diagram-toolbar-rows">
374
+ </div>`}renderTagFilterRow(e=T){return k`<div slot="toolbar" class="diagram-toolbar-rows">
375
375
  <dpk-tag-filter
376
- .tags=${Qd(this.tagItems())}
376
+ .tags=${cl(this.tagItems())}
377
377
  .active=${this.#a.active}
378
378
  .match=${this.#a.match}
379
379
  @dpk-tag-filter-change=${n=>{n.stopPropagation(),this.#a={active:n.detail.active,match:n.detail.match},this.requestUpdate()}}
380
380
  ></dpk-tag-filter>
381
381
  ${e}
382
- </div>`}#b(e){this.#t=null,this.#o=e,this.#w()}#w(){if(this.#o===null){this.#n=this.#e.map(n=>({id:n.id,title:n.type,stale:"target-missing"})),this.requestUpdate();return}const e=this.reduceElementActions(this.#o,this.#e);this.#i=e.data,this.#n=e.results,this.#r!==null&&(this.hasSelection(this.#r)||(this.#r=null)),this.requestUpdate()}#T(e,n){return this.board!==null?this.#k({type:Od,target:e,payload:{body:n}}).ok:!this.dispatchEvent(new CustomEvent("dpk-comment-submit",{detail:{target:e,body:n},bubbles:!0,composed:!0,cancelable:!0}))}#$(e){this.#t=e,this.#o=null,this.#i=null,this.#w(),console.error("[dev-process-kit] invalid element data:",e),this.requestUpdate()}hasSelection(e){return!0}#L(e){(e===null?this.#r===null:this.#r!==null&&this.#r.kind===e.kind&&this.#r.id===e.id)||(this.#r=e,this.dispatchEvent(new CustomEvent("dpk-diagram-select",{detail:{selection:e},bubbles:!0,composed:!0})),this.requestUpdate())}refreshContent(){}prepareRender(){this.refreshContent()}}class eo extends tt{static{this.styles=De}#o=-1;#i=null;constructor(){super(),this.addEventListener("keydown",this.#t,{capture:!0})}updated(){super.updated(),this.#e()}async#e(){const e=this.#n();if(!e)return;const n=this.contentSize();if(e.contentWidth=n?.width??0,e.contentHeight=n?.height??0,await e.updateComplete,n===null)return;const o=this.layoutVersion();o!==this.#o&&(this.#o=o,this.initialView());const i=this.focusBounds(),s=this.focusKey();s!==this.#i&&(this.#i=s,i!==null?this.viewport?.fitTo(i):this.fitViewport())}#n(){return this.renderRoot.querySelector("dpk-dialog-panel")}resetView(){this.fitViewport()}#t=e=>{e.key==="Escape"&&this.selection!==null&&e.preventDefault()};layoutVersion(){return 0}fitViewport(){this.fitMode()==="width"?this.viewport?.fitWidth():this.viewport?.fit()}fitMode(){return"all"}initialView(){this.viewport?.reset()}viewAlign(){return"center"}focusBounds(){return null}focusKey(){const e=this.focusBounds();return e===null?null:JSON.stringify(e)}onViewChange(e){}onMaximizeChange(e){}isEmpty(){return this.contentSize()===null}renderLegend(){return M}renderAboveCanvas(){return M}renderControls(){return M}get viewport(){const e=this.#n();return e===null?null:{apply:()=>e.apply(),fit:()=>e.fit(),fitTo:n=>e.fitTo(n),fitWidth:()=>e.fitWidth(),reset:n=>e.reset(n),zoom:n=>e.zoom(n),view:()=>e.view}}elementClass(e,...n){return ye(...n,e.selected&&"is-selected",e.related&&"is-related",e.dimmed&&"is-dimmed")}render(){this.prepareRender();const e=this.chromeMessages,n=this.subject??this.defaultSubject(),o=this.renderControls();return v`
382
+ </div>`}#b(e){this.#n=null,this.#o=e,this.#v()}#v(){if(this.#o===null){this.#t=this.#e.map(n=>({id:n.id,title:n.type,stale:"target-missing"})),this.requestUpdate();return}const e=this.reduceElementActions(this.#o,this.#e);this.#i=e.data,this.#t=e.results,this.#r!==null&&(this.hasSelection(this.#r)||(this.#r=null)),this.requestUpdate()}#T(e,n){return this.board!==null?this.#E({type:Kd,target:e,payload:{body:n}}).ok:!this.dispatchEvent(new CustomEvent("dpk-comment-submit",{detail:{target:e,body:n},bubbles:!0,composed:!0,cancelable:!0}))}#w(e){this.#n=e,this.#o=null,this.#i=null,this.#v(),console.error("[dev-process-kit] invalid element data:",e),this.requestUpdate()}hasSelection(e){return!0}#C(e){(e===null?this.#r===null:this.#r!==null&&this.#r.kind===e.kind&&this.#r.id===e.id)||(this.#r=e,this.dispatchEvent(new CustomEvent("dpk-diagram-select",{detail:{selection:e},bubbles:!0,composed:!0})),this.requestUpdate())}refreshContent(){}prepareRender(){this.refreshContent()}}class io extends st{static{this.styles=ze}#o=-1;#i=null;constructor(){super(),this.addEventListener("keydown",this.#n,{capture:!0})}updated(){super.updated(),this.#e()}async#e(){const e=this.#t();if(!e)return;const n=this.contentSize();if(e.contentWidth=n?.width??0,e.contentHeight=n?.height??0,await e.updateComplete,n===null)return;const o=this.layoutVersion();o!==this.#o&&(this.#o=o,this.initialView());const i=this.focusBounds(),s=this.focusKey();s!==this.#i&&(this.#i=s,i!==null?this.viewport?.fitTo(i):this.fitViewport())}#t(){return this.renderRoot.querySelector("dpk-dialog-panel")}resetView(){this.fitViewport()}#n=e=>{e.key==="Escape"&&this.selection!==null&&e.preventDefault()};layoutVersion(){return 0}fitViewport(){this.fitMode()==="width"?this.viewport?.fitWidth():this.viewport?.fit()}fitMode(){return"all"}initialView(){this.viewport?.reset()}viewAlign(){return"center"}focusBounds(){return null}focusKey(){const e=this.focusBounds();return e===null?null:JSON.stringify(e)}onViewChange(e){}onMaximizeChange(e){}isEmpty(){return this.contentSize()===null}renderLegend(){return T}renderAboveCanvas(){return T}renderControls(){return T}get viewport(){const e=this.#t();return e===null?null:{apply:()=>e.apply(),fit:()=>e.fit(),fitTo:n=>e.fitTo(n),fitWidth:()=>e.fitWidth(),reset:n=>e.reset(n),zoom:n=>e.zoom(n),view:()=>e.view}}elementClass(e,...n){return ve(...n,e.selected&&"is-selected",e.related&&"is-related",e.dimmed&&"is-dimmed")}render(){this.prepareRender();const e=this.chromeMessages,n=this.subject??this.defaultSubject(),o=this.renderControls();return k`
383
383
  <dpk-dialog-panel
384
- class=${ye("diagram",this.shellClass())}
384
+ class=${ve("diagram",this.shellClass())}
385
385
  flush
386
386
  ?maximizable=${this.frameControls}
387
387
  ?resizable=${this.frameControls}
@@ -391,24 +391,24 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
391
391
  align=${this.viewAlign()}
392
392
  label=${e.canvas}
393
393
  heading=${this.heading??this.defaultHeading()}
394
- subject=${n===""?M:n}
394
+ subject=${n===""?T:n}
395
395
  @dpk-maximize-change=${i=>{this.closeComposer(),this.onMaximizeChange(i.detail.maximized)}}
396
396
  @dpk-canvas-change=${i=>{i.stopPropagation();const{view:s}=i.detail;this.dispatchEvent(new CustomEvent("dpk-diagram-view",{detail:{view:s},bubbles:!0,composed:!0})),this.onViewChange(s)}}
397
397
  @dpk-canvas-dismiss=${i=>{i.stopPropagation(),this.selection!==null&&(i.preventDefault(),this.select(null))}}
398
398
  >
399
399
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow(this.renderAboveCanvas())}
400
400
  <div class="diagram-world">${this.renderCanvas()}</div>
401
- ${o===M?M:v`<div slot="controls">${o}</div>`}
401
+ ${o===T?T:k`<div slot="controls">${o}</div>`}
402
402
  <div slot="overlay" class="diagram-overlay">
403
- ${this.isEmpty()?v`<p class="diagram-empty">${this.emptyMessage()}</p>`:M}
404
- ${this.dataError===null?M:v`<p class="diagram-notice" role="alert">${e.dataError}<br />${this.dataError}</p>`}
403
+ ${this.isEmpty()?k`<p class="diagram-empty">${this.emptyMessage()}</p>`:T}
404
+ ${this.dataError===null?T:k`<p class="diagram-notice" role="alert">${e.dataError}<br />${this.dataError}</p>`}
405
405
  ${this.renderLegend()}
406
406
  </div>
407
407
  </dpk-dialog-panel>
408
408
  ${this.renderSelection()}
409
- `}}const Vl=4,Ql=new Set,Zl='button,[role="button"],a,input,textarea,select';class nt extends eo{#o=null;#i="";#e=null;#n="";#t=0;#a=Ie;#r=new Kl(this,{host:()=>this,diagram:()=>this.id});#s=Yi;#d=!1;commentItems(){const e=this.items();return[...e.nodes.map(n=>({value:this.commentRef("node",n.id),label:n.id})),...e.edges.map(n=>({value:this.commentRef("edge",n.id),label:`${n.from} \u2192 ${n.to} (${n.id})`}))]}get visible(){const e=this.filtered();return{nodes:e.nodes,edges:e.edges}}get layout(){return this.#e}get layoutMode(){return"layered"}get tagDimension(){return"node"}layoutOptions(){return{}}matchesFilter(e){return!0}layoutSignature(){return""}statsLabels(){return{node:this.chromeMessages.nodes,edge:this.chromeMessages.edges}}statsText(){const e=this.filtered();return jl(e.nodes.length,e.edges.length,this.statsLabels())}tagItems(){const e=this.items();return(this.tagDimension==="edge"?e.edges:e.nodes).map(n=>n.tags)}contentSize(){const e=this.#e;return e===null||e.nodes.length===0?null:{width:e.width,height:e.height}}layoutVersion(){return this.#t}hasSelection(e){const n=this.items();return e.kind==="node"?n.nodes.some(o=>o.id===e.id):n.edges.some(o=>o.id===e.id)}placedNode(e){return this.#e?.nodes.find(n=>n.id===e)}routeOf(e){return this.#e?.routes.find(n=>n.id===e)?.points??[]}nodeState(e){return vi(e,this.selection,"node",this.#a)}edgeState(e){return vi(e,this.selection,"edge",this.#a)}renderEdges(e,n){const o=this.#e?.width??0,i=this.#e?.height??0;return v`<svg class="diagram-edges" width=${o} height=${i}>
410
- ${Wi(n)}${e}
411
- </svg>`}filtered(){const e=this.items();if(this.tagDimension==="edge"){const i=e.edges.filter(r=>Ce(r.tags,this.tagFilter)&&this.matchesFilter(r)),s=new Set(i.flatMap(r=>[r.from,r.to]));return{...e,edges:i,nodes:e.nodes.filter(r=>s.has(r.id))}}const n=e.nodes.filter(i=>Ce(i.tags,this.tagFilter)&&this.matchesFilter(i)),o=new Set(n.map(i=>i.id));return{...e,nodes:n,edges:e.edges.filter(i=>o.has(i.from)&&o.has(i.to))}}refreshContent(){const e=this.filtered(),n=[this.layoutMode,e.nodes.map(i=>`${i.id}:${i.width}x${i.height}`).join(","),e.edges.map(i=>`${i.id}:${i.from}>${i.to}`).join(","),this.layoutSignature()].join("|");n!==this.#i&&(this.#i=n,this.#o=this.routePlacement(this.computePlacement(e),e));const o=[this.layoutMode,e.nodes.map(i=>i.id).join(","),e.edges.map(i=>i.id).join(",")].join("|");o!==this.#n&&(this.#n=o,this.#t+=1),this.#a=this.relations(this.selection,e),this.#u(e)}computePlacement(e){const n=this.#c(e),o=this.#p(e),i=this.layoutOptions();return this.layoutMode==="fixed"?Hi(n,o,i):Ri(n,o,i)}routePlacement(e,n){return e}#c(e){return e.nodes.map(n=>({id:n.id,width:n.width,height:n.height,...n.ports===void 0?{}:{ports:n.ports},...n.position===void 0?{}:{position:n.position},...n.group===void 0?{}:{group:n.group}}))}#p(e){return e.edges.map(n=>({id:n.id,from:n.from,to:n.to,...n.fromPort===void 0?{}:{fromPort:n.fromPort},...n.toPort===void 0?{}:{toPort:n.toPort}}))}#u(e){this.#r.prune(new Set(e.nodes.map(s=>s.id)));let n=this.#r.overrides();const o=this.#s;if(o.kind==="node"&&o.preview!==null)n=new Map(n).set(o.id,o.preview);else if(o.kind==="group"&&o.preview!==null){const s=new Map(n);for(const[r,a]of o.preview)s.set(r,a);n=s}const i=this.#o;this.#e=i===null?null:n.size===0?i:this.routePlacement(Cl(i,n,this.#c(e),this.#p(e),this.layoutOptions()),e)}hasPositionOverrides(){return this.#r.hasOverrides()}resetPositions(){this.#r.reset()}getContextMenuItems(e){const n=super.getContextMenuItems(e);if(!this.hasPositionOverrides())return n;const i={id:"diagram-reset-positions",entries:[{kind:"item",id:"reset-positions",label:ci(this.locale).resetPositions,run:()=>this.resetPositions()}]};return[...n??[],i]}isDraggingNode(e){return this.#s.kind==="node"&&this.#s.moved&&this.#s.id===e}consumeDragClick(){return this.#d?(this.#d=!1,!0):!1}onNodeDragStart(e,n){if(e.button!==0||this.#s.kind!=="idle")return;const o=e.target instanceof Element?e.target.closest(Zl):null;if(o!==null&&o!==e.currentTarget)return;const i=this.placedNode(n),s=e.currentTarget;!i||!(s instanceof HTMLElement)||(e.stopPropagation(),this.#h(Ll({id:n,pointerId:e.pointerId,target:s,start:{x:i.x,y:i.y},origin:{screenX:e.clientX,screenY:e.clientY}}),s,e.pointerId))}isDraggingGroup(e){return this.#s.kind==="group"&&this.#s.moved&&this.#s.key===e}draggedNodeIds(){const e=this.#s;return e.kind==="node"&&e.moved?new Set([e.id]):e.kind==="group"&&e.moved?new Set(e.starts.keys()):Ql}onGroupDragStart(e,n,o){if(e.button!==0||this.#s.kind!=="idle")return;const i=e.currentTarget;if(!(i instanceof HTMLElement)||o.length===0)return;const s=new Map;for(const r of o){const a=this.placedNode(r);a&&s.set(r,{x:a.x,y:a.y})}s.size!==0&&(e.stopPropagation(),this.#h(_l({key:n,pointerId:e.pointerId,target:i,starts:s,origin:{screenX:e.clientX,screenY:e.clientY}}),i,e.pointerId))}#h(e,n,o){this.#s=e,n.setPointerCapture(o),n.addEventListener("pointermove",this.#l),n.addEventListener("pointerup",this.#m),n.addEventListener("pointercancel",this.#g),n.addEventListener("lostpointercapture",this.#f)}#l=e=>{const n=this.#s;if(n.kind==="idle"||e.pointerId!==n.pointerId)return;e.stopPropagation();const o=this.viewport?.view().scale??1,i=Rl(n,{screenX:e.clientX,screenY:e.clientY},o,Vl);i.kind==="idle"||i===n||(!n.moved&&i.moved&&(i.target.style.userSelect="none"),this.#s=i,this.requestUpdate())};#m=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||(e.stopPropagation(),this.#y(!0))};#g=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||(e.stopPropagation(),this.#y(!1))};#f=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||this.#y(!1)};#y(e){const n=this.#s;if(n.kind==="idle")return;const{target:o}=n;o.removeEventListener("pointermove",this.#l),o.removeEventListener("pointerup",this.#m),o.removeEventListener("pointercancel",this.#g),o.removeEventListener("lostpointercapture",this.#f),o.style.userSelect="",this.#s=Yi,e&&n.moved&&(n.kind==="node"&&n.preview!==null?(this.#r.commit(n.id,n.preview),this.#d=!0):n.kind==="group"&&n.preview!==null&&this.#r.commitMany(n.preview)),this.requestUpdate()}}const vt=ce({en:{heading:"Architecture map",node:"Service",edge:"Connection",empty:"No matching services.",boundaries:"Boundaries",edgeLabel:(t,e)=>`Connection from ${t} to ${e}`,artworkCredit:t=>`Icon credit: ${t}`},ja:{heading:"\u30A2\u30FC\u30AD\u30C6\u30AF\u30C1\u30E3\u30DE\u30C3\u30D7",node:"\u30B5\u30FC\u30D3\u30B9",edge:"\u63A5\u7D9A",empty:"\u8A72\u5F53\u3059\u308B\u30B5\u30FC\u30D3\u30B9\u306F\u3042\u308A\u307E\u305B\u3093\u3002",boundaries:"\u5883\u754C",edgeLabel:(t,e)=>`${t} \u304B\u3089 ${e} \u3078\u306E\u63A5\u7D9A`,artworkCredit:t=>`\u30A2\u30A4\u30B3\u30F3\u51FA\u5178: ${t}`}}),Qi={width:220,height:112},tn=26,Jl=P({src:I(y(),_(1)),alt:I(y(),_(1)),license:C(y())}),ec=P({id:I(y(),_(1)),name:I(y(),_(1)),description:C(y()),boundary:C(y()),symbol:C(y()),tags:C(F(y()),[]),artwork:C(Jl),position:P({x:le(),y:le()}),questions:C(y())}),tc=P({id:I(y(),_(1)),label:I(y(),_(1)),kind:C(X(["internal","external"]),"internal")}),nc=P({id:I(y(),_(1)),from:I(y(),_(1)),to:I(y(),_(1)),label:C(y())}),oc=P({boundaries:C(F(tc),[]),services:F(ec),links:C(F(nc),[])}),ic=()=>({nodes:[],edges:[],boundaries:[]}),sc=t=>{const e=he(oc,t),n=new Set;for(const a of e.boundaries){if(n.has(a.id))throw new Error(`duplicate boundary id: ${a.id}`);n.add(a.id)}const o=new Set,i=e.services.map(a=>{if(o.has(a.id))throw new Error(`duplicate service id: ${a.id}`);if(o.add(a.id),a.boundary!==void 0&&!n.has(a.boundary))throw new Error(`unknown boundary: ${a.boundary}`);return{id:a.id,name:a.name,description:a.description??null,boundary:a.boundary??null,symbol:a.symbol??null,artwork:a.artwork?{src:a.artwork.src,alt:a.artwork.alt,license:a.artwork.license??null}:null,tags:a.tags,width:Qi.width,height:Qi.height,position:a.position,...a.questions===void 0?{}:{questions:a.questions}}}),s=new Set,r=e.links.map(a=>{if(s.has(a.id))throw new Error(`duplicate link id: ${a.id}`);if(s.add(a.id),!o.has(a.from))throw new Error(`unknown link source: ${a.from}`);if(!o.has(a.to))throw new Error(`unknown link target: ${a.to}`);return{id:a.id,from:a.from,to:a.to,label:a.label??null,tags:[]}});return{nodes:i,edges:r,boundaries:e.boundaries.map(a=>({id:a.id,label:a.label,kind:a.kind}))}},to={left:tn,top:tn*1.6,right:tn,bottom:tn},rc={left:0,top:0,right:0,bottom:0},ac=12,Zi=t=>({left:Math.min(...t.map(e=>e.position?.x??0)),top:Math.min(...t.map(e=>e.position?.y??0)),right:Math.max(...t.map(e=>(e.position?.x??0)+e.width)),bottom:Math.max(...t.map(e=>(e.position?.y??0)+e.height))}),dc=(t,e,n,o)=>{const i=t.left-e.left<n.right+o.right&&n.left-o.left<t.right+e.right,s=t.top-e.top<n.bottom+o.bottom&&n.top-o.top<t.bottom+e.bottom;if(!i||!s)return e;const r=Math.max(n.left-t.right,t.left-n.right),a=Math.max(n.top-t.bottom,t.top-n.bottom);if(r<0&&a<0)return e;const d=(l,c,h)=>l===0?0:Math.max(0,h-ac)*l/(l+c);return r>=a?n.left>=t.right?{...e,right:Math.min(e.right,d(e.right,o.left,r))}:{...e,left:Math.min(e.left,d(e.left,o.right,r))}:n.top>=t.bottom?{...e,bottom:Math.min(e.bottom,d(e.bottom,o.top,a))}:{...e,top:Math.min(e.top,d(e.top,o.bottom,a))}},lc=(t,e)=>{const n=e.flatMap(i=>{const s=t.filter(r=>r.boundary===i.id);return s.length===0?[]:[{boundary:i,bounds:Zi(s)}]}),o=[...n.map(i=>({id:i.boundary.id,bounds:i.bounds,padding:to})),...t.filter(i=>i.boundary===null||!n.some(s=>s.boundary.id===i.boundary)).map(i=>({id:null,bounds:Zi([i]),padding:rc}))];return n.map(({boundary:i,bounds:s})=>{const r=o.filter(l=>l.id!==i.id).map(l=>dc(s,to,l.bounds,l.padding)).reduce((l,c)=>({left:Math.min(l.left,c.left),top:Math.min(l.top,c.top),right:Math.min(l.right,c.right),bottom:Math.min(l.bottom,c.bottom)}),to),a=s.left-r.left,d=s.top-r.top;return{boundary:i,x:a,y:d,width:s.right+r.right-a,height:s.bottom+r.bottom-d}})},Ji=6,es=12,cc=t=>t.slice(1).map((e,n)=>[t[n],e]),pc=(t,e,n)=>{const[o,i]=t,[s,r]=e,a=o.x===i.x,d=s.x===r.x;if(a!==d)return 0;if(a){if(Math.abs(o.x-s.x)>n)return 0;const u=Math.min(o.y,i.y),g=Math.max(o.y,i.y),b=Math.min(s.y,r.y),f=Math.max(s.y,r.y);return Math.max(0,Math.min(g,f)-Math.max(u,b))}if(Math.abs(o.y-s.y)>n)return 0;const l=Math.min(o.x,i.x),c=Math.max(o.x,i.x),h=Math.min(s.x,r.x),p=Math.max(s.x,r.x);return Math.max(0,Math.min(c,p)-Math.max(l,h))},hc=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],ts=(t,e)=>e.some(n=>hc(n).some(o=>cc(t).some(i=>pc(i,o,Ji)>es))),me=(t,e,n,o)=>o.some(i=>t>i.x&&t<i.x+i.width&&Math.max(i.y,e)<Math.min(i.y+i.height,n)-1e-6),ge=(t,e,n,o)=>o.some(i=>t>i.y&&t<i.y+i.height&&Math.max(i.x,e)<Math.min(i.x+i.width,n)-1e-6),ot=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},kt=t=>t.slice(1).map((e,n)=>[t[n],e]),ns=(t,e)=>{const[n,o]=t,[i,s]=e,r=n.x===o.x,a=i.x===s.x;if(r===a)return!1;const[d,l,c,h]=r?[n,o,i,s]:[i,s,n,o],p=d.x,u=c.y,g=Math.min(d.y,l.y),b=Math.max(d.y,l.y),f=Math.min(c.x,h.x),m=Math.max(c.x,h.x);return p>f&&p<m&&u>g&&u<b},no=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of kt(t))for(const i of e)ns(o,i)&&n++;return n},uc=4,os=8,oo=(t,e,n)=>{const[o,i]=t,[s,r]=e,a=o.x===i.x;return a!==(s.x===r.x)?0:a?Math.abs(o.x-s.x)>n?0:Math.max(0,Math.min(Math.max(o.y,i.y),Math.max(s.y,r.y))-Math.max(Math.min(o.y,i.y),Math.min(s.y,r.y))):Math.abs(o.y-s.y)>n?0:Math.max(0,Math.min(Math.max(o.x,i.x),Math.max(s.x,r.x))-Math.max(Math.min(o.x,i.x),Math.min(s.x,r.x)))},is=(t,e)=>oo(t,e,uc),ss=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of kt(t))for(const i of e){const s=is(o,i);s>os&&(n+=s)}return n},rs=([t,e])=>({minX:Math.min(t.x,e.x),maxX:Math.max(t.x,e.x),minY:Math.min(t.y,e.y),maxY:Math.max(t.y,e.y)}),mc=(t,e)=>t.maxX>=e.minX&&e.maxX>=t.minX&&t.maxY>=e.minY&&e.maxY>=t.minY,gc=(t,e,n)=>{if(e.length===0)return{crossings:0,parallel:0};let o=0,i=0;for(const s of kt(t)){const r=rs(s);for(let a=0;a<e.length;a++){if(!mc(r,n[a]))continue;const d=e[a];ns(s,d)&&o++;const l=is(s,d);l>os&&(i+=l)}}return{crossings:o,parallel:i}},fc=(t,e,n,o)=>{const i=new Set;for(const s of n)(o==="x"?s.y<e&&s.y+s.height>t:s.x<e&&s.x+s.width>t)&&(o==="x"?(i.add(s.x),i.add(s.x+s.width)):(i.add(s.y),i.add(s.y+s.height)));return[...i]},bc=(t,e,n,o,i)=>{const s=new Set;for(const r of n)(o==="x"?r.y<e&&r.y+r.height>t:r.x<e&&r.x+r.width>t)&&(o==="x"?(s.add(r.x-i),s.add(r.x+r.width+i)):(s.add(r.y-i),s.add(r.y+r.height+i)));return[...s]},xc=14,as=(t,e,n,o,i)=>[...new Set([...fc(t,e,n,i),...bc(t,e,o,i,xc)])],yc=1.5,vc=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],kc=(t,e)=>{let n=!1,o=!1;for(const i of e)for(const s of vc(i))for(const r of kt(t)){const a=oo(r,s,Ji);if(a>es&&(n=!0),a>1&&oo(r,s,yc)>1&&(o=!0),n&&o)return{hugs:n,contact:o}}return{hugs:n,contact:o}},wc=(t,e,n,o)=>{const i=gc(t.points,e,n),{hugs:s,contact:r}=kc(t.points,o);return{...t,crossings:i.crossings,parallel:i.parallel,hugs:s,contact:r}},ds=(t,e)=>t.contact!==e.contact?!t.contact:t.crossings!==e.crossings?t.crossings<e.crossings:t.parallel!==e.parallel?t.parallel<e.parallel:t.hugs!==e.hugs?!t.hugs:t.length<e.length,io=t=>kt(t).reduce((e,[n,o])=>e+Math.abs(n.x-o.x)+Math.abs(n.y-o.y),0),$c=(t,e,n,o,i)=>{const s=as(Math.min(t.y,e.y),Math.max(t.y,e.y),n,i,"x"),r=[];for(const a of s){const d=!ge(t.y,Math.min(t.x,a),Math.max(t.x,a),o),l=!me(a,Math.min(t.y,e.y),Math.max(t.y,e.y),o),c=!ge(e.y,Math.min(a,e.x),Math.max(a,e.x),o);if(!d||!l||!c)continue;const h=ot([t,{x:a,y:t.y},{x:a,y:e.y},e]);r.push({points:h,length:io(h)})}return r},Ec=(t,e,n,o,i)=>{const s=as(Math.min(t.x,e.x),Math.max(t.x,e.x),n,i,"y"),r=[];for(const a of s){const d=!me(t.x,Math.min(t.y,a),Math.max(t.y,a),o),l=!ge(a,Math.min(t.x,e.x),Math.max(t.x,e.x),o),c=!me(e.x,Math.min(a,e.y),Math.max(a,e.y),o);if(!d||!l||!c)continue;const h=ot([t,{x:t.x,y:a},{x:e.x,y:a},e]);r.push({points:h,length:io(h)})}return r},ls=(t,e,n)=>{const o=e.map(rs);let i=null;for(const s of t){const r=wc(s,e,o,n);(i===null||ds(r,i))&&(i=r)}return i},Tc=(t,e,n,o,i,s)=>ls([...$c(t,e,n,o,s),...Ec(t,e,n,o,s)],i,s),nn=(t,e,n)=>Math.min(n,Math.max(e,t)),Sc=(t,e,n,o)=>{const i=Math.max(o*4,160),s=Math.min(t.x,e.x)-i,r=Math.max(t.x,e.x)+i,a=Math.min(t.y,e.y)-i,d=Math.max(t.y,e.y)+i,l=n.filter(D=>D.x<r&&D.x+D.width>s&&D.y<d&&D.y+D.height>a),c=Math.max(o,40),h=Math.min(s,...l.map(D=>D.x-c)),p=Math.max(r,...l.map(D=>D.x+D.width+c)),u=Math.min(a,...l.map(D=>D.y-c)),g=Math.max(d,...l.map(D=>D.y+D.height+c)),b=n.filter(D=>D.x<p&&D.x+D.width>h&&D.y<g&&D.y+D.height>u);if(b.length>120)return null;const f=new Set([t.x,e.x,h,p]),m=new Set([t.y,e.y,u,g]);for(const D of b)f.add(nn(D.x,h,p)),f.add(nn(D.x+D.width,h,p)),m.add(nn(D.y,u,g)),m.add(nn(D.y+D.height,u,g));const x=[...f].sort((D,K)=>D-K),k=[...m].sort((D,K)=>D-K),w=x.length,$=k.length,L=x.indexOf(t.x),S=k.indexOf(t.y),T=x.indexOf(e.x),E=k.indexOf(e.y);if(L<0||S<0||T<0||E<0)return null;const R=Array.from({length:w-1},(D,K)=>Array.from({length:$},(de,Ee)=>!ge(k[Ee],x[K],x[K+1],b))),A=Array.from({length:w},(D,K)=>Array.from({length:$-1},(de,Ee)=>!me(x[K],k[Ee],k[Ee+1],b))),N=(D,K)=>D*$+K,U=w*$,H=new Int32Array(U).fill(-1),q=new Uint8Array(U),ee=N(L,S),Q=N(T,E);q[ee]=1;const G=[ee];for(const D of G){if(D===Q)break;const K=D%$,de=(D-K)/$,Ee=(vd,kd)=>{const qt=N(vd,kd);q[qt]||(q[qt]=1,H[qt]=D,G.push(qt))};de>0&&R[de-1]?.[K]&&Ee(de-1,K),de<w-1&&R[de]?.[K]&&Ee(de+1,K),K>0&&A[de]?.[K-1]&&Ee(de,K-1),K<$-1&&A[de]?.[K]&&Ee(de,K+1)}if(!q[Q])return null;const Z=[];let ne=Q;for(;;){const D=ne%$,K=(ne-D)/$;if(Z.push({x:x[K],y:k[D]}),ne===ee)break;ne=H[ne]}return Z.reverse(),ot(Z)},so=(t,e,n,o,i=[],s=[],r=[])=>{if(t.x===e.x&&t.y===e.y)return[t,e];const a=n.map(f=>({x:f.x-o,y:f.y-o,width:f.width+o*2,height:f.height+o*2})),d=r.length===0?a:[...a,...r];if(t.x===e.x){if(!me(t.x,Math.min(t.y,e.y),Math.max(t.y,e.y),d)&&!ts([t,e],s))return[t,e]}else if(t.y===e.y&&!ge(t.y,Math.min(t.x,e.x),Math.max(t.x,e.x),d)&&!ts([t,e],s))return[t,e];const l={x:e.x,y:t.y},c={x:t.x,y:e.y},h=f=>{const m=f.y===t.y?!ge(t.y,Math.min(t.x,f.x),Math.max(t.x,f.x),d):!me(t.x,Math.min(t.y,f.y),Math.max(t.y,f.y),d),x=f.y===e.y?!ge(e.y,Math.min(f.x,e.x),Math.max(f.x,e.x),d):!me(e.x,Math.min(f.y,e.y),Math.max(f.y,e.y),d);return m&&x},p=[],u=f=>{p.push({points:f,length:io(f)})};t.x===e.x?me(t.x,Math.min(t.y,e.y),Math.max(t.y,e.y),d)||u([t,e]):t.y===e.y&&(ge(t.y,Math.min(t.x,e.x),Math.max(t.x,e.x),d)||u([t,e])),h(c)&&u(ot([t,c,e])),h(l)&&u(ot([t,l,e]));const g=ls(p,i,s);if(g!==null&&!g.contact&&!g.hugs)return g.points;const b=Tc(t,e,a,d,i,s);return b!==null&&(g===null||ds(b,g))?b.points:g!==null?g.points:Sc(t,e,d,o)??ot([t,l,e])},Mc=12,Ic=16,on=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),cs=(t,e)=>{const n=on(t),o=on(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},ro=t=>t==="left"||t==="right"?"y":"x",ps=(t,e,n,o,i)=>{const s=(t+e)/2;if(n<=1)return s;const r=Math.min(i,Math.max(0,e-t)/(n-1));return s+(o-(n-1)/2)*r},Cc=(t,e,n)=>{const o=ro(e)==="y"?t.height:t.width,i=ro(e)==="y"?t.y:t.x;return{low:i+Math.min(n,o/2),high:i+Math.max(o-n,o/2)}},Lc=(t,e,n)=>{switch(e){case"left":return{x:t.x,y:n};case"right":return{x:t.x+t.width,y:n};case"top":return{x:n,y:t.y};case"bottom":return{x:n,y:t.y+t.height};default:return{x:t.x+t.width,y:n}}},hs=(t,e,n={})=>{const o=new Map(t.map(h=>[h.id,h])),i=n.inset??Mc,s=n.gap??Ic,r=n.sideOf??(h=>cs(h.node,h.other)),a=new Map,d=(h,p)=>{const u=on(h.node),g=on(p),b=ro(h.side)==="y"?g.y:g.x,f=`${h.node.id}\0${h.side}`,m=a.get(f),x={...h,order:b,distance:Math.abs(g.x-u.x)+Math.abs(g.y-u.y)};m?m.push(x):a.set(f,[x])};for(const h of e){const p=o.get(h.from),u=o.get(h.to);p===void 0||u===void 0||(d({edgeId:h.id,end:"from",node:p,side:r({node:p,other:u,edge:h,end:"from"})},u),d({edgeId:h.id,end:"to",node:u,side:r({node:u,other:p,edge:h,end:"to"})},p))}const l=new Map;for(const h of a.values()){const p=h[0];if(p===void 0)continue;const{low:u,high:g}=Cc(p.node,p.side,i),b=[...h].sort((f,m)=>f.order-m.order||m.distance-f.distance||f.edgeId.localeCompare(m.edgeId)||f.end.localeCompare(m.end));b.forEach((f,m)=>{const x=Lc(f.node,f.side,ps(u,g,b.length,m,s)),k=l.get(f.edgeId)??{};f.end==="from"?k.from={point:x,side:f.side}:k.to={point:x,side:f.side},l.set(f.edgeId,k)})}const c=new Map;for(const[h,p]of l)p.from!==void 0&&p.to!==void 0&&c.set(h,{from:p.from,to:p.to});return c},us={trackSpacing:6,frameClearance:6},_c=t=>{if(t.length<4)return null;let e=null;for(let n=1;n<=t.length-3;n++){const o=t[n],i=t[n+1],s=o.x===i.x?"vertical":"horizontal",r=Math.abs(s==="vertical"?i.y-o.y:i.x-o.x);(e===null||r>e.length)&&(e={segIndex:n,orientation:s,length:r})}return e},wt=(t,e,n,o)=>e>=n&&o>=t,Rc=(t,e,n,o)=>{let i=t.coord;for(const s of e){const r=t.orientation==="vertical"?wt(t.rangeMin,t.rangeMax,s.y,s.y+s.height)?[s.x,s.x+s.width]:[]:wt(t.rangeMin,t.rangeMax,s.x,s.x+s.width)?[s.y,s.y+s.height]:[];for(const a of r){const d=Math.abs(i-a);if(d<n){const l=i>=a?1:-1;i=i+l*(n-d)}}}return i},Ac=(t,e)=>t.orientation==="vertical"?me(e,t.rangeMin,t.rangeMax,t.obstacles):ge(e,t.rangeMin,t.rangeMax,t.obstacles),Oc=(t,e,n,o)=>n.some(i=>(t.orientation==="vertical"?wt(t.rangeMin,t.rangeMax,i.y,i.y+i.height)?[i.x,i.x+i.width]:[]:wt(t.rangeMin,t.rangeMax,i.x,i.x+i.width)?[i.y,i.y+i.height]:[]).some(r=>Math.abs(e-r)<o)),Nc=(t,e,n,o=[],i=0)=>{const s=d=>Ac(t,d)||o.length>0&&Oc(t,d,o,i);let r=n,a=0;for(;s(r)&&a<8;)r=(r+e)/2,a++;return s(r)?e:r},Dc=(t,e,n,o)=>{const i=n==="vertical"?"x":"y";let s=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;const a=(l,c)=>{const h=Math.sign(c[i]-l[i]);if(h===0)return;const p=l[i]+h*o;h>0?s=Math.max(s,p):r=Math.min(r,p)},d=t.length-1;return e===1&&a(t[0],t[1]),e+1===d-1&&a(t[d],t[d-1]),{low:s,high:r}},zc=(t,e)=>{const n=t.map((s,r)=>r),o=s=>{for(;n[s]!==s;)n[s]=n[n[s]],s=n[s];return s},i=(s,r)=>{const a=o(s),d=o(r);a!==d&&(n[a]=d)};for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++){const a=t[s],d=t[r];Math.abs(a.coord-d.coord)<=e&&wt(a.rangeMin,a.rangeMax,d.rangeMin,d.rangeMax)&&i(s,r)}return t.map((s,r)=>o(r))},ao=(t,e={})=>{const n=e.trackSpacing??us.trackSpacing,o=e.frameClearance??us.frameClearance,i=e.minPortRun??0,s=[],r=new Map;for(const c of t){const h=_c(c.points);if(h===null)continue;const p=c.points[h.segIndex],u=c.points[h.segIndex+1],g=h.orientation==="vertical"?p.x:p.y,[b,f]=h.orientation==="vertical"?[Math.min(p.y,u.y),Math.max(p.y,u.y)]:[Math.min(p.x,u.x),Math.max(p.x,u.x)];s.push({edgeId:c.id,segIndex:h.segIndex,orientation:h.orientation,coord:g,rangeMin:b,rangeMax:f,obstacles:c.obstacles}),c.ownFrames!==void 0&&r.set(c.id,c.ownFrames)}for(const c of s){const h=r.get(c.edgeId);h!==void 0&&h.length>0&&(c.coord=Rc(c,h,o))}const a=new Map,d=new Map(t.map(c=>[c.id,c])),l=new Set;for(const c of["vertical","horizontal"]){const h=s.filter(g=>g.orientation===c);if(h.length===0)continue;const p=zc(h,n),u=new Map;for(let g=0;g<h.length;g++){const b=p[g],f=u.get(b);f?f.push(h[g]):u.set(b,[h[g]])}for(const g of u.values()){const b=[...g].sort((m,x)=>m.edgeId.localeCompare(x.edgeId)),f=b.reduce((m,x)=>m+x.coord,0)/b.length;b.forEach((m,x)=>{const k=b.length===1?m.coord:f+(x-(b.length-1)/2)*n,w=d.get(m.edgeId),$=w.points[m.segIndex][c==="vertical"?"x":"y"],{low:L,high:S}=Dc(w.points,m.segIndex,c,i),T=i>0?L>S?$:Math.min(S,Math.max(L,k)):k,E=Nc(m,$,T,r.get(m.edgeId)??[],o),R=(a.get(m.edgeId)??w.points).map((A,N)=>N!==m.segIndex&&N!==m.segIndex+1?A:c==="vertical"?{x:E,y:A.y}:{x:A.x,y:E});a.set(m.edgeId,R),l.add(m.edgeId)})}}for(const c of t)l.has(c.id)||a.set(c.id,c.points);return a},Pc={margin:16,portGap:16},qc=12,sn=16,ms=11,lo=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),gs=(t,e)=>t.slice(1).some((n,o)=>{const i=t[o];if(i===void 0)return!1;const s=Math.min(i.x,n.x),r=Math.max(i.x,n.x),a=Math.min(i.y,n.y),d=Math.max(i.y,n.y);return e.some(l=>i.x===n.x?i.x>l.x&&i.x<l.x+l.width&&a<l.y+l.height&&d>l.y:i.y>l.y&&i.y<l.y+l.height&&s<l.x+l.width&&r>l.x)}),Fc=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},fs=t=>t.slice(1).map((e,n)=>[t[n],e]),bs=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},xs=(t,e)=>e.x>=t.x+t.width?{from:"right",to:"left"}:t.x>=e.x+e.width?{from:"left",to:"right"}:e.y>=t.y+t.height?{from:"bottom",to:"top"}:t.y>=e.y+e.height?{from:"top",to:"bottom"}:null,Bc=(t,e,n)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0)return{x:0,y:0};if(t.length<=2)return{x:(o.x+i.x)/2,y:(o.y+i.y)/2};const s=Hc(n),r=c=>({x:c.x,y:c.y-6-ms+2,width:s,height:ms}),a=c=>{const h=r(c);return!e.some(p=>h.x<p.x+p.width&&p.x<h.x+h.width&&h.y<p.y+p.height&&p.y<h.y+h.height)},d=t.length===4?{x:(t[1].x+t[2].x)/2,y:(t[1].y+t[2].y)/2}:Uc(t);return a(d)?d:t.slice(1).map((c,h)=>{const p=t[h];return{point:{x:(p.x+c.x)/2,y:(p.y+c.y)/2},length:Math.abs(c.x-p.x)+Math.abs(c.y-p.y)}}).sort((c,h)=>h.length-c.length).find(c=>a(c.point))?.point??d},Uc=t=>{let e={point:{x:t[0].x,y:t[0].y},length:-1};for(let n=0;n+1<t.length;n++){const o=t[n],i=t[n+1],s=Math.abs(i.x-o.x)+Math.abs(i.y-o.y);s>e.length&&(e={point:{x:(o.x+i.x)/2,y:(o.y+i.y)/2},length:s})}return e.point},Hc=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:5.6;return Math.ceil(e+4)},Yc=(t,e,n={})=>{const o={...Pc,...n},i=new Map(t.nodes.map(m=>[m.id,m])),s=e.filter(m=>i.has(m.from)&&i.has(m.to));if(s.length===0)return t;const r=new Map(t.nodes.map(m=>[m.id,lo(m)])),a=hs(t.nodes,s,{inset:qc,gap:o.portGap,sideOf:({node:m,other:x,edge:k,end:w})=>{const $=i.get(k.from),L=i.get(k.to),S=$!==void 0&&L!==void 0?xs($,L):null;return S===null?cs(m,x):w==="from"?S.from:S.to}}),d=new Map(t.routes.map(m=>[m.id,m.points])),l=m=>{const x=i.get(m.from),k=i.get(m.to);return x===void 0||k===void 0?0:Math.abs(k.x-x.x)+Math.abs(k.y-x.y)},c=[...s].sort((m,x)=>l(m)-l(x)||m.id.localeCompare(x.id)),h=[],p=new Map;for(const m of c){const x=i.get(m.from),k=i.get(m.to),w=a.get(m.id),$=d.get(m.id)??[],L=x!==void 0&&k!==void 0?xs(x,k):null;if(x===void 0||k===void 0||w===void 0||L===null||x.id===k.id){p.set(m.id,$),h.push(...fs($));continue}const S=[r.get(x.id),r.get(k.id)],T=t.nodes.filter(H=>H.id!==x.id&&H.id!==k.id).map(lo),E=bs(w.from.side),R=bs(w.to.side),A=so({x:w.from.point.x+E.x*sn,y:w.from.point.y+E.y*sn},{x:w.to.point.x+R.x*sn,y:w.to.point.y+R.y*sn},T,o.margin,h,[...S,...T],S),N=Fc([w.from.point,...A,w.to.point]),U=gs(N,T)&&!gs($,T)?$:N;p.set(m.id,U),h.push(...fs(U))}const u=s.map(m=>{const x=i.get(m.from),k=i.get(m.to),w=x!==void 0&&k!==void 0?[r.get(x.id),r.get(k.id)]:[];return{id:m.id,points:p.get(m.id)??[],obstacles:t.nodes.filter($=>$.id!==m.from&&$.id!==m.to).map(lo),ownFrames:w}}),g=ao(u,{minPortRun:0}),b=s.map(m=>({id:m.id,points:g.get(m.id)??p.get(m.id)??[]})),f=[...b.flatMap(m=>m.points),...t.nodes.map(m=>({x:m.x+m.width,y:m.y+m.height}))];return{...t,width:Math.max(t.width,...f.map(m=>m.x)),height:Math.max(t.height,...f.map(m=>m.y)),routes:[...t.routes.filter(m=>!s.some(x=>x.id===m.id)),...b]}},Xc=ae`
409
+ `}}const cc=4,pc=new Set,hc='button,[role="button"],a,input,textarea,select';class rt extends io{#o=null;#i="";#e=null;#t="";#n=0;#a=Ie;#r=new ac(this,{host:()=>this,diagram:()=>this.id});#s=Qi;#d=!1;commentItems(){const e=this.items();return[...e.nodes.map(n=>({value:this.commentRef("node",n.id),label:n.id})),...e.edges.map(n=>({value:this.commentRef("edge",n.id),label:`${n.from} \u2192 ${n.to} (${n.id})`}))]}get visible(){const e=this.filtered();return{nodes:e.nodes,edges:e.edges}}get layout(){return this.#e}get layoutMode(){return"layered"}get tagDimension(){return"node"}layoutOptions(){return{}}matchesFilter(e){return!0}layoutSignature(){return""}statsLabels(){return{node:this.chromeMessages.nodes,edge:this.chromeMessages.edges}}statsText(){const e=this.filtered();return dc(e.nodes.length,e.edges.length,this.statsLabels())}tagItems(){const e=this.items();return(this.tagDimension==="edge"?e.edges:e.nodes).map(n=>n.tags)}contentSize(){const e=this.#e;return e===null||e.nodes.length===0?null:{width:e.width,height:e.height}}layoutVersion(){return this.#n}hasSelection(e){const n=this.items();return e.kind==="node"?n.nodes.some(o=>o.id===e.id):n.edges.some(o=>o.id===e.id)}placedNode(e){return this.#e?.nodes.find(n=>n.id===e)}routeOf(e){return this.#e?.routes.find(n=>n.id===e)?.points??[]}nodeState(e){return Ti(e,this.selection,"node",this.#a)}edgeState(e){return Ti(e,this.selection,"edge",this.#a)}renderEdges(e,n){const o=this.#e?.width??0,i=this.#e?.height??0;return k`<svg class="diagram-edges" width=${o} height=${i}>
410
+ ${ns(n)}${e}
411
+ </svg>`}filtered(){const e=this.items();if(this.tagDimension==="edge"){const i=e.edges.filter(r=>Ae(r.tags,this.tagFilter)&&this.matchesFilter(r)),s=new Set(i.flatMap(r=>[r.from,r.to]));return{...e,edges:i,nodes:e.nodes.filter(r=>s.has(r.id))}}const n=e.nodes.filter(i=>Ae(i.tags,this.tagFilter)&&this.matchesFilter(i)),o=new Set(n.map(i=>i.id));return{...e,nodes:n,edges:e.edges.filter(i=>o.has(i.from)&&o.has(i.to))}}refreshContent(){const e=this.filtered(),n=[this.layoutMode,e.nodes.map(i=>`${i.id}:${i.width}x${i.height}`).join(","),e.edges.map(i=>`${i.id}:${i.from}>${i.to}`).join(","),this.layoutSignature()].join("|");n!==this.#i&&(this.#i=n,this.#o=this.routePlacement(this.computePlacement(e),e));const o=[this.layoutMode,e.nodes.map(i=>i.id).join(","),e.edges.map(i=>i.id).join(",")].join("|");o!==this.#t&&(this.#t=o,this.#n+=1),this.#a=this.relations(this.selection,e),this.#p(e)}computePlacement(e){const n=this.#c(e),o=this.#h(e),i=this.layoutOptions();return this.layoutMode==="fixed"?Vi(n,o,i):qi(n,o,i)}routePlacement(e,n){return e}#c(e){return e.nodes.map(n=>({id:n.id,width:n.width,height:n.height,...n.ports===void 0?{}:{ports:n.ports},...n.position===void 0?{}:{position:n.position},...n.group===void 0?{}:{group:n.group}}))}#h(e){return e.edges.map(n=>({id:n.id,from:n.from,to:n.to,...n.fromPort===void 0?{}:{fromPort:n.fromPort},...n.toPort===void 0?{}:{toPort:n.toPort}}))}#p(e){this.#r.prune(new Set(e.nodes.map(s=>s.id)));let n=this.#r.overrides();const o=this.#s;if(o.kind==="node"&&o.preview!==null)n=new Map(n).set(o.id,o.preview);else if(o.kind==="group"&&o.preview!==null){const s=new Map(n);for(const[r,a]of o.preview)s.set(r,a);n=s}const i=this.#o;this.#e=i===null?null:n.size===0?i:this.routePlacement(Hl(i,n,this.#c(e),this.#h(e),this.layoutOptions()),e)}hasPositionOverrides(){return this.#r.hasOverrides()}resetPositions(){this.#r.reset()}getContextMenuItems(e){const n=super.getContextMenuItems(e);if(!this.hasPositionOverrides())return n;const i={id:"diagram-reset-positions",entries:[{kind:"item",id:"reset-positions",label:gi(this.locale).resetPositions,run:()=>this.resetPositions()}]};return[...n??[],i]}isDraggingNode(e){return this.#s.kind==="node"&&this.#s.moved&&this.#s.id===e}consumeDragClick(){return this.#d?(this.#d=!1,!0):!1}onNodeDragStart(e,n){if(e.button!==0||this.#s.kind!=="idle")return;const o=e.target instanceof Element?e.target.closest(hc):null;if(o!==null&&o!==e.currentTarget)return;const i=this.placedNode(n),s=e.currentTarget;!i||!(s instanceof HTMLElement)||(e.stopPropagation(),this.#u(Yl({id:n,pointerId:e.pointerId,target:s,start:{x:i.x,y:i.y},origin:{screenX:e.clientX,screenY:e.clientY}}),s,e.pointerId))}isDraggingGroup(e){return this.#s.kind==="group"&&this.#s.moved&&this.#s.key===e}draggedNodeIds(){const e=this.#s;return e.kind==="node"&&e.moved?new Set([e.id]):e.kind==="group"&&e.moved?new Set(e.starts.keys()):pc}onGroupDragStart(e,n,o){if(e.button!==0||this.#s.kind!=="idle")return;const i=e.currentTarget;if(!(i instanceof HTMLElement)||o.length===0)return;const s=new Map;for(const r of o){const a=this.placedNode(r);a&&s.set(r,{x:a.x,y:a.y})}s.size!==0&&(e.stopPropagation(),this.#u(Gl({key:n,pointerId:e.pointerId,target:i,starts:s,origin:{screenX:e.clientX,screenY:e.clientY}}),i,e.pointerId))}#u(e,n,o){this.#s=e,n.setPointerCapture(o),n.addEventListener("pointermove",this.#l),n.addEventListener("pointerup",this.#m),n.addEventListener("pointercancel",this.#g),n.addEventListener("lostpointercapture",this.#f)}#l=e=>{const n=this.#s;if(n.kind==="idle"||e.pointerId!==n.pointerId)return;e.stopPropagation();const o=this.viewport?.view().scale??1,i=Xl(n,{screenX:e.clientX,screenY:e.clientY},o,cc);i.kind==="idle"||i===n||(!n.moved&&i.moved&&(i.target.style.userSelect="none"),this.#s=i,this.requestUpdate())};#m=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||(e.stopPropagation(),this.#x(!0))};#g=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||(e.stopPropagation(),this.#x(!1))};#f=e=>{const n=this.#s;n.kind==="idle"||e.pointerId!==n.pointerId||this.#x(!1)};#x(e){const n=this.#s;if(n.kind==="idle")return;const{target:o}=n;o.removeEventListener("pointermove",this.#l),o.removeEventListener("pointerup",this.#m),o.removeEventListener("pointercancel",this.#g),o.removeEventListener("lostpointercapture",this.#f),o.style.userSelect="",this.#s=Qi,e&&n.moved&&(n.kind==="node"&&n.preview!==null?(this.#r.commit(n.id,n.preview),this.#d=!0):n.kind==="group"&&n.preview!==null&&this.#r.commitMany(n.preview)),this.requestUpdate()}}const $t=pe({en:{heading:"Architecture map",node:"Service",edge:"Connection",empty:"No matching services.",boundaries:"Boundaries",edgeLabel:(t,e)=>`Connection from ${t} to ${e}`,artworkCredit:t=>`Icon credit: ${t}`},ja:{heading:"\u30A2\u30FC\u30AD\u30C6\u30AF\u30C1\u30E3\u30DE\u30C3\u30D7",node:"\u30B5\u30FC\u30D3\u30B9",edge:"\u63A5\u7D9A",empty:"\u8A72\u5F53\u3059\u308B\u30B5\u30FC\u30D3\u30B9\u306F\u3042\u308A\u307E\u305B\u3093\u3002",boundaries:"\u5883\u754C",edgeLabel:(t,e)=>`${t} \u304B\u3089 ${e} \u3078\u306E\u63A5\u7D9A`,artworkCredit:t=>`\u30A2\u30A4\u30B3\u30F3\u51FA\u5178: ${t}`}}),is={width:220,height:112},on=26,uc=P({src:S(x(),I(1)),alt:S(x(),I(1)),license:L(x())}),mc=P({id:S(x(),I(1)),name:S(x(),I(1)),description:L(x()),boundary:L(x()),symbol:L(x()),tags:L(F(x()),[]),artwork:L(uc),position:P({x:ce(),y:ce()}),questions:L(x())}),gc=P({id:S(x(),I(1)),label:S(x(),I(1)),kind:L(G(["internal","external"]),"internal")}),fc=P({id:S(x(),I(1)),from:S(x(),I(1)),to:S(x(),I(1)),label:L(x())}),bc=P({boundaries:L(F(gc),[]),services:F(mc),links:L(F(fc),[])}),xc=()=>({nodes:[],edges:[],boundaries:[]}),yc=t=>{const e=ue(bc,t),n=new Set;for(const a of e.boundaries){if(n.has(a.id))throw new Error(`duplicate boundary id: ${a.id}`);n.add(a.id)}const o=new Set,i=e.services.map(a=>{if(o.has(a.id))throw new Error(`duplicate service id: ${a.id}`);if(o.add(a.id),a.boundary!==void 0&&!n.has(a.boundary))throw new Error(`unknown boundary: ${a.boundary}`);return{id:a.id,name:a.name,description:a.description??null,boundary:a.boundary??null,symbol:a.symbol??null,artwork:a.artwork?{src:a.artwork.src,alt:a.artwork.alt,license:a.artwork.license??null}:null,tags:a.tags,width:is.width,height:is.height,position:a.position,...a.questions===void 0?{}:{questions:a.questions}}}),s=new Set,r=e.links.map(a=>{if(s.has(a.id))throw new Error(`duplicate link id: ${a.id}`);if(s.add(a.id),!o.has(a.from))throw new Error(`unknown link source: ${a.from}`);if(!o.has(a.to))throw new Error(`unknown link target: ${a.to}`);return{id:a.id,from:a.from,to:a.to,label:a.label??null,tags:[]}});return{nodes:i,edges:r,boundaries:e.boundaries.map(a=>({id:a.id,label:a.label,kind:a.kind}))}},so={left:on,top:on*1.6,right:on,bottom:on},kc={left:0,top:0,right:0,bottom:0},vc=12,ss=t=>({left:Math.min(...t.map(e=>e.position?.x??0)),top:Math.min(...t.map(e=>e.position?.y??0)),right:Math.max(...t.map(e=>(e.position?.x??0)+e.width)),bottom:Math.max(...t.map(e=>(e.position?.y??0)+e.height))}),wc=(t,e,n,o)=>{const i=t.left-e.left<n.right+o.right&&n.left-o.left<t.right+e.right,s=t.top-e.top<n.bottom+o.bottom&&n.top-o.top<t.bottom+e.bottom;if(!i||!s)return e;const r=Math.max(n.left-t.right,t.left-n.right),a=Math.max(n.top-t.bottom,t.top-n.bottom);if(r<0&&a<0)return e;const d=(l,c,h)=>l===0?0:Math.max(0,h-vc)*l/(l+c);return r>=a?n.left>=t.right?{...e,right:Math.min(e.right,d(e.right,o.left,r))}:{...e,left:Math.min(e.left,d(e.left,o.right,r))}:n.top>=t.bottom?{...e,bottom:Math.min(e.bottom,d(e.bottom,o.top,a))}:{...e,top:Math.min(e.top,d(e.top,o.bottom,a))}},$c=(t,e)=>{const n=e.flatMap(i=>{const s=t.filter(r=>r.boundary===i.id);return s.length===0?[]:[{boundary:i,bounds:ss(s)}]}),o=[...n.map(i=>({id:i.boundary.id,bounds:i.bounds,padding:so})),...t.filter(i=>i.boundary===null||!n.some(s=>s.boundary.id===i.boundary)).map(i=>({id:null,bounds:ss([i]),padding:kc}))];return n.map(({boundary:i,bounds:s})=>{const r=o.filter(l=>l.id!==i.id).map(l=>wc(s,so,l.bounds,l.padding)).reduce((l,c)=>({left:Math.min(l.left,c.left),top:Math.min(l.top,c.top),right:Math.min(l.right,c.right),bottom:Math.min(l.bottom,c.bottom)}),so),a=s.left-r.left,d=s.top-r.top;return{boundary:i,x:a,y:d,width:s.right+r.right-a,height:s.bottom+r.bottom-d}})},rs=6,as=12,Ec=t=>t.slice(1).map((e,n)=>[t[n],e]),Tc=(t,e,n)=>{const[o,i]=t,[s,r]=e,a=o.x===i.x,d=s.x===r.x;if(a!==d)return 0;if(a){if(Math.abs(o.x-s.x)>n)return 0;const u=Math.min(o.y,i.y),g=Math.max(o.y,i.y),b=Math.min(s.y,r.y),f=Math.max(s.y,r.y);return Math.max(0,Math.min(g,f)-Math.max(u,b))}if(Math.abs(o.y-s.y)>n)return 0;const l=Math.min(o.x,i.x),c=Math.max(o.x,i.x),h=Math.min(s.x,r.x),p=Math.max(s.x,r.x);return Math.max(0,Math.min(c,p)-Math.max(l,h))},Sc=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],ds=(t,e)=>e.some(n=>Sc(n).some(o=>Ec(t).some(i=>Tc(i,o,rs)>as))),ge=(t,e,n,o)=>o.some(i=>t>i.x&&t<i.x+i.width&&Math.max(i.y,e)<Math.min(i.y+i.height,n)-1e-6),fe=(t,e,n,o)=>o.some(i=>t>i.y&&t<i.y+i.height&&Math.max(i.x,e)<Math.min(i.x+i.width,n)-1e-6),at=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},Et=t=>t.slice(1).map((e,n)=>[t[n],e]),ls=(t,e)=>{const[n,o]=t,[i,s]=e,r=n.x===o.x,a=i.x===s.x;if(r===a)return!1;const[d,l,c,h]=r?[n,o,i,s]:[i,s,n,o],p=d.x,u=c.y,g=Math.min(d.y,l.y),b=Math.max(d.y,l.y),f=Math.min(c.x,h.x),m=Math.max(c.x,h.x);return p>f&&p<m&&u>g&&u<b},ro=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of Et(t))for(const i of e)ls(o,i)&&n++;return n},Mc=4,cs=8,ao=(t,e,n)=>{const[o,i]=t,[s,r]=e,a=o.x===i.x;return a!==(s.x===r.x)?0:a?Math.abs(o.x-s.x)>n?0:Math.max(0,Math.min(Math.max(o.y,i.y),Math.max(s.y,r.y))-Math.max(Math.min(o.y,i.y),Math.min(s.y,r.y))):Math.abs(o.y-s.y)>n?0:Math.max(0,Math.min(Math.max(o.x,i.x),Math.max(s.x,r.x))-Math.max(Math.min(o.x,i.x),Math.min(s.x,r.x)))},ps=(t,e)=>ao(t,e,Mc),hs=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of Et(t))for(const i of e){const s=ps(o,i);s>cs&&(n+=s)}return n},us=([t,e])=>({minX:Math.min(t.x,e.x),maxX:Math.max(t.x,e.x),minY:Math.min(t.y,e.y),maxY:Math.max(t.y,e.y)}),Cc=(t,e)=>t.maxX>=e.minX&&e.maxX>=t.minX&&t.maxY>=e.minY&&e.maxY>=t.minY,Lc=(t,e,n)=>{if(e.length===0)return{crossings:0,parallel:0};let o=0,i=0;for(const s of Et(t)){const r=us(s);for(let a=0;a<e.length;a++){if(!Cc(r,n[a]))continue;const d=e[a];ls(s,d)&&o++;const l=ps(s,d);l>cs&&(i+=l)}}return{crossings:o,parallel:i}},Ic=(t,e,n,o)=>{const i=new Set;for(const s of n)(o==="x"?s.y<e&&s.y+s.height>t:s.x<e&&s.x+s.width>t)&&(o==="x"?(i.add(s.x),i.add(s.x+s.width)):(i.add(s.y),i.add(s.y+s.height)));return[...i]},Ac=(t,e,n,o,i)=>{const s=new Set;for(const r of n)(o==="x"?r.y<e&&r.y+r.height>t:r.x<e&&r.x+r.width>t)&&(o==="x"?(s.add(r.x-i),s.add(r.x+r.width+i)):(s.add(r.y-i),s.add(r.y+r.height+i)));return[...s]},Rc=14,ms=(t,e,n,o,i)=>[...new Set([...Ic(t,e,n,i),...Ac(t,e,o,i,Rc)])],_c=1.5,Dc=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],Oc=(t,e)=>{let n=!1,o=!1;for(const i of e)for(const s of Dc(i))for(const r of Et(t)){const a=ao(r,s,rs);if(a>as&&(n=!0),a>1&&ao(r,s,_c)>1&&(o=!0),n&&o)return{hugs:n,contact:o}}return{hugs:n,contact:o}},Nc=(t,e,n,o)=>{const i=Lc(t.points,e,n),{hugs:s,contact:r}=Oc(t.points,o);return{...t,crossings:i.crossings,parallel:i.parallel,hugs:s,contact:r}},gs=(t,e)=>t.contact!==e.contact?!t.contact:t.crossings!==e.crossings?t.crossings<e.crossings:t.parallel!==e.parallel?t.parallel<e.parallel:t.hugs!==e.hugs?!t.hugs:t.length<e.length,lo=t=>Et(t).reduce((e,[n,o])=>e+Math.abs(n.x-o.x)+Math.abs(n.y-o.y),0),zc=(t,e,n,o,i)=>{const s=ms(Math.min(t.y,e.y),Math.max(t.y,e.y),n,i,"x"),r=[];for(const a of s){const d=!fe(t.y,Math.min(t.x,a),Math.max(t.x,a),o),l=!ge(a,Math.min(t.y,e.y),Math.max(t.y,e.y),o),c=!fe(e.y,Math.min(a,e.x),Math.max(a,e.x),o);if(!d||!l||!c)continue;const h=at([t,{x:a,y:t.y},{x:a,y:e.y},e]);r.push({points:h,length:lo(h)})}return r},Pc=(t,e,n,o,i)=>{const s=ms(Math.min(t.x,e.x),Math.max(t.x,e.x),n,i,"y"),r=[];for(const a of s){const d=!ge(t.x,Math.min(t.y,a),Math.max(t.y,a),o),l=!fe(a,Math.min(t.x,e.x),Math.max(t.x,e.x),o),c=!ge(e.x,Math.min(a,e.y),Math.max(a,e.y),o);if(!d||!l||!c)continue;const h=at([t,{x:t.x,y:a},{x:e.x,y:a},e]);r.push({points:h,length:lo(h)})}return r},fs=(t,e,n)=>{const o=e.map(us);let i=null;for(const s of t){const r=Nc(s,e,o,n);(i===null||gs(r,i))&&(i=r)}return i},qc=(t,e,n,o,i,s)=>fs([...zc(t,e,n,o,s),...Pc(t,e,n,o,s)],i,s),sn=(t,e,n)=>Math.min(n,Math.max(e,t)),Fc=(t,e,n,o)=>{const i=Math.max(o*4,160),s=Math.min(t.x,e.x)-i,r=Math.max(t.x,e.x)+i,a=Math.min(t.y,e.y)-i,d=Math.max(t.y,e.y)+i,l=n.filter(N=>N.x<r&&N.x+N.width>s&&N.y<d&&N.y+N.height>a),c=Math.max(o,40),h=Math.min(s,...l.map(N=>N.x-c)),p=Math.max(r,...l.map(N=>N.x+N.width+c)),u=Math.min(a,...l.map(N=>N.y-c)),g=Math.max(d,...l.map(N=>N.y+N.height+c)),b=n.filter(N=>N.x<p&&N.x+N.width>h&&N.y<g&&N.y+N.height>u);if(b.length>120)return null;const f=new Set([t.x,e.x,h,p]),m=new Set([t.y,e.y,u,g]);for(const N of b)f.add(sn(N.x,h,p)),f.add(sn(N.x+N.width,h,p)),m.add(sn(N.y,u,g)),m.add(sn(N.y+N.height,u,g));const y=[...f].sort((N,K)=>N-K),v=[...m].sort((N,K)=>N-K),w=y.length,$=v.length,A=y.indexOf(t.x),C=v.indexOf(t.y),M=y.indexOf(e.x),E=v.indexOf(e.y);if(A<0||C<0||M<0||E<0)return null;const R=Array.from({length:w-1},(N,K)=>Array.from({length:$},(le,Se)=>!fe(v[Se],y[K],y[K+1],b))),D=Array.from({length:w},(N,K)=>Array.from({length:$-1},(le,Se)=>!ge(y[K],v[Se],v[Se+1],b))),O=(N,K)=>N*$+K,B=w*$,H=new Int32Array(B).fill(-1),q=new Uint8Array(B),ee=O(A,C),Q=O(M,E);q[ee]=1;const X=[ee];for(const N of X){if(N===Q)break;const K=N%$,le=(N-K)/$,Se=(_d,Dd)=>{const Ut=O(_d,Dd);q[Ut]||(q[Ut]=1,H[Ut]=N,X.push(Ut))};le>0&&R[le-1]?.[K]&&Se(le-1,K),le<w-1&&R[le]?.[K]&&Se(le+1,K),K>0&&D[le]?.[K-1]&&Se(le,K-1),K<$-1&&D[le]?.[K]&&Se(le,K+1)}if(!q[Q])return null;const Z=[];let ne=Q;for(;;){const N=ne%$,K=(ne-N)/$;if(Z.push({x:y[K],y:v[N]}),ne===ee)break;ne=H[ne]}return Z.reverse(),at(Z)},co=(t,e,n,o,i=[],s=[],r=[])=>{if(t.x===e.x&&t.y===e.y)return[t,e];const a=n.map(f=>({x:f.x-o,y:f.y-o,width:f.width+o*2,height:f.height+o*2})),d=r.length===0?a:[...a,...r];if(t.x===e.x){if(!ge(t.x,Math.min(t.y,e.y),Math.max(t.y,e.y),d)&&!ds([t,e],s))return[t,e]}else if(t.y===e.y&&!fe(t.y,Math.min(t.x,e.x),Math.max(t.x,e.x),d)&&!ds([t,e],s))return[t,e];const l={x:e.x,y:t.y},c={x:t.x,y:e.y},h=f=>{const m=f.y===t.y?!fe(t.y,Math.min(t.x,f.x),Math.max(t.x,f.x),d):!ge(t.x,Math.min(t.y,f.y),Math.max(t.y,f.y),d),y=f.y===e.y?!fe(e.y,Math.min(f.x,e.x),Math.max(f.x,e.x),d):!ge(e.x,Math.min(f.y,e.y),Math.max(f.y,e.y),d);return m&&y},p=[],u=f=>{p.push({points:f,length:lo(f)})};t.x===e.x?ge(t.x,Math.min(t.y,e.y),Math.max(t.y,e.y),d)||u([t,e]):t.y===e.y&&(fe(t.y,Math.min(t.x,e.x),Math.max(t.x,e.x),d)||u([t,e])),h(c)&&u(at([t,c,e])),h(l)&&u(at([t,l,e]));const g=fs(p,i,s);if(g!==null&&!g.contact&&!g.hugs)return g.points;const b=qc(t,e,a,d,i,s);return b!==null&&(g===null||gs(b,g))?b.points:g!==null?g.points:Fc(t,e,d,o)??at([t,l,e])},Uc=12,Bc=16,rn=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),bs=(t,e)=>{const n=rn(t),o=rn(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},po=t=>t==="left"||t==="right"?"y":"x",xs=(t,e,n,o,i)=>{const s=(t+e)/2;if(n<=1)return s;const r=Math.min(i,Math.max(0,e-t)/(n-1));return s+(o-(n-1)/2)*r},Hc=(t,e,n)=>{const o=po(e)==="y"?t.height:t.width,i=po(e)==="y"?t.y:t.x;return{low:i+Math.min(n,o/2),high:i+Math.max(o-n,o/2)}},Yc=(t,e,n)=>{switch(e){case"left":return{x:t.x,y:n};case"right":return{x:t.x+t.width,y:n};case"top":return{x:n,y:t.y};case"bottom":return{x:n,y:t.y+t.height};default:return{x:t.x+t.width,y:n}}},ys=(t,e,n={})=>{const o=new Map(t.map(h=>[h.id,h])),i=n.inset??Uc,s=n.gap??Bc,r=n.sideOf??(h=>bs(h.node,h.other)),a=new Map,d=(h,p)=>{const u=rn(h.node),g=rn(p),b=po(h.side)==="y"?g.y:g.x,f=`${h.node.id}\0${h.side}`,m=a.get(f),y={...h,order:b,distance:Math.abs(g.x-u.x)+Math.abs(g.y-u.y)};m?m.push(y):a.set(f,[y])};for(const h of e){const p=o.get(h.from),u=o.get(h.to);p===void 0||u===void 0||(d({edgeId:h.id,end:"from",node:p,side:r({node:p,other:u,edge:h,end:"from"})},u),d({edgeId:h.id,end:"to",node:u,side:r({node:u,other:p,edge:h,end:"to"})},p))}const l=new Map;for(const h of a.values()){const p=h[0];if(p===void 0)continue;const{low:u,high:g}=Hc(p.node,p.side,i),b=[...h].sort((f,m)=>f.order-m.order||m.distance-f.distance||f.edgeId.localeCompare(m.edgeId)||f.end.localeCompare(m.end));b.forEach((f,m)=>{const y=Yc(f.node,f.side,xs(u,g,b.length,m,s)),v=l.get(f.edgeId)??{};f.end==="from"?v.from={point:y,side:f.side}:v.to={point:y,side:f.side},l.set(f.edgeId,v)})}const c=new Map;for(const[h,p]of l)p.from!==void 0&&p.to!==void 0&&c.set(h,{from:p.from,to:p.to});return c},ks={trackSpacing:6,frameClearance:6},Gc=t=>{if(t.length<4)return null;let e=null;for(let n=1;n<=t.length-3;n++){const o=t[n],i=t[n+1],s=o.x===i.x?"vertical":"horizontal",r=Math.abs(s==="vertical"?i.y-o.y:i.x-o.x);(e===null||r>e.length)&&(e={segIndex:n,orientation:s,length:r})}return e},Tt=(t,e,n,o)=>e>=n&&o>=t,Xc=(t,e,n,o)=>{let i=t.coord;for(const s of e){const r=t.orientation==="vertical"?Tt(t.rangeMin,t.rangeMax,s.y,s.y+s.height)?[s.x,s.x+s.width]:[]:Tt(t.rangeMin,t.rangeMax,s.x,s.x+s.width)?[s.y,s.y+s.height]:[];for(const a of r){const d=Math.abs(i-a);if(d<n){const l=i>=a?1:-1;i=i+l*(n-d)}}}return i},Kc=(t,e)=>t.orientation==="vertical"?ge(e,t.rangeMin,t.rangeMax,t.obstacles):fe(e,t.rangeMin,t.rangeMax,t.obstacles),jc=(t,e,n,o)=>n.some(i=>(t.orientation==="vertical"?Tt(t.rangeMin,t.rangeMax,i.y,i.y+i.height)?[i.x,i.x+i.width]:[]:Tt(t.rangeMin,t.rangeMax,i.x,i.x+i.width)?[i.y,i.y+i.height]:[]).some(r=>Math.abs(e-r)<o)),Wc=(t,e,n,o=[],i=0)=>{const s=d=>Kc(t,d)||o.length>0&&jc(t,d,o,i);let r=n,a=0;for(;s(r)&&a<8;)r=(r+e)/2,a++;return s(r)?e:r},Vc=(t,e,n,o)=>{const i=n==="vertical"?"x":"y";let s=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;const a=(l,c)=>{const h=Math.sign(c[i]-l[i]);if(h===0)return;const p=l[i]+h*o;h>0?s=Math.max(s,p):r=Math.min(r,p)},d=t.length-1;return e===1&&a(t[0],t[1]),e+1===d-1&&a(t[d],t[d-1]),{low:s,high:r}},Qc=(t,e)=>{const n=t.map((s,r)=>r),o=s=>{for(;n[s]!==s;)n[s]=n[n[s]],s=n[s];return s},i=(s,r)=>{const a=o(s),d=o(r);a!==d&&(n[a]=d)};for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++){const a=t[s],d=t[r];Math.abs(a.coord-d.coord)<=e&&Tt(a.rangeMin,a.rangeMax,d.rangeMin,d.rangeMax)&&i(s,r)}return t.map((s,r)=>o(r))},ho=(t,e={})=>{const n=e.trackSpacing??ks.trackSpacing,o=e.frameClearance??ks.frameClearance,i=e.minPortRun??0,s=[],r=new Map;for(const c of t){const h=Gc(c.points);if(h===null)continue;const p=c.points[h.segIndex],u=c.points[h.segIndex+1],g=h.orientation==="vertical"?p.x:p.y,[b,f]=h.orientation==="vertical"?[Math.min(p.y,u.y),Math.max(p.y,u.y)]:[Math.min(p.x,u.x),Math.max(p.x,u.x)];s.push({edgeId:c.id,segIndex:h.segIndex,orientation:h.orientation,coord:g,rangeMin:b,rangeMax:f,obstacles:c.obstacles}),c.ownFrames!==void 0&&r.set(c.id,c.ownFrames)}for(const c of s){const h=r.get(c.edgeId);h!==void 0&&h.length>0&&(c.coord=Xc(c,h,o))}const a=new Map,d=new Map(t.map(c=>[c.id,c])),l=new Set;for(const c of["vertical","horizontal"]){const h=s.filter(g=>g.orientation===c);if(h.length===0)continue;const p=Qc(h,n),u=new Map;for(let g=0;g<h.length;g++){const b=p[g],f=u.get(b);f?f.push(h[g]):u.set(b,[h[g]])}for(const g of u.values()){const b=[...g].sort((m,y)=>m.edgeId.localeCompare(y.edgeId)),f=b.reduce((m,y)=>m+y.coord,0)/b.length;b.forEach((m,y)=>{const v=b.length===1?m.coord:f+(y-(b.length-1)/2)*n,w=d.get(m.edgeId),$=w.points[m.segIndex][c==="vertical"?"x":"y"],{low:A,high:C}=Vc(w.points,m.segIndex,c,i),M=i>0?A>C?$:Math.min(C,Math.max(A,v)):v,E=Wc(m,$,M,r.get(m.edgeId)??[],o),R=(a.get(m.edgeId)??w.points).map((D,O)=>O!==m.segIndex&&O!==m.segIndex+1?D:c==="vertical"?{x:E,y:D.y}:{x:D.x,y:E});a.set(m.edgeId,R),l.add(m.edgeId)})}}for(const c of t)l.has(c.id)||a.set(c.id,c.points);return a},Zc={margin:16,portGap:16},Jc=12,an=16,vs=11,uo=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),ws=(t,e)=>t.slice(1).some((n,o)=>{const i=t[o];if(i===void 0)return!1;const s=Math.min(i.x,n.x),r=Math.max(i.x,n.x),a=Math.min(i.y,n.y),d=Math.max(i.y,n.y);return e.some(l=>i.x===n.x?i.x>l.x&&i.x<l.x+l.width&&a<l.y+l.height&&d>l.y:i.y>l.y&&i.y<l.y+l.height&&s<l.x+l.width&&r>l.x)}),ep=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},$s=t=>t.slice(1).map((e,n)=>[t[n],e]),Es=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},Ts=(t,e)=>e.x>=t.x+t.width?{from:"right",to:"left"}:t.x>=e.x+e.width?{from:"left",to:"right"}:e.y>=t.y+t.height?{from:"bottom",to:"top"}:t.y>=e.y+e.height?{from:"top",to:"bottom"}:null,tp=(t,e,n)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0)return{x:0,y:0};if(t.length<=2)return{x:(o.x+i.x)/2,y:(o.y+i.y)/2};const s=op(n),r=c=>({x:c.x,y:c.y-6-vs+2,width:s,height:vs}),a=c=>{const h=r(c);return!e.some(p=>h.x<p.x+p.width&&p.x<h.x+h.width&&h.y<p.y+p.height&&p.y<h.y+h.height)},d=t.length===4?{x:(t[1].x+t[2].x)/2,y:(t[1].y+t[2].y)/2}:np(t);return a(d)?d:t.slice(1).map((c,h)=>{const p=t[h];return{point:{x:(p.x+c.x)/2,y:(p.y+c.y)/2},length:Math.abs(c.x-p.x)+Math.abs(c.y-p.y)}}).sort((c,h)=>h.length-c.length).find(c=>a(c.point))?.point??d},np=t=>{let e={point:{x:t[0].x,y:t[0].y},length:-1};for(let n=0;n+1<t.length;n++){const o=t[n],i=t[n+1],s=Math.abs(i.x-o.x)+Math.abs(i.y-o.y);s>e.length&&(e={point:{x:(o.x+i.x)/2,y:(o.y+i.y)/2},length:s})}return e.point},op=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:5.6;return Math.ceil(e+4)},ip=(t,e,n={})=>{const o={...Zc,...n},i=new Map(t.nodes.map(m=>[m.id,m])),s=e.filter(m=>i.has(m.from)&&i.has(m.to));if(s.length===0)return t;const r=new Map(t.nodes.map(m=>[m.id,uo(m)])),a=ys(t.nodes,s,{inset:Jc,gap:o.portGap,sideOf:({node:m,other:y,edge:v,end:w})=>{const $=i.get(v.from),A=i.get(v.to),C=$!==void 0&&A!==void 0?Ts($,A):null;return C===null?bs(m,y):w==="from"?C.from:C.to}}),d=new Map(t.routes.map(m=>[m.id,m.points])),l=m=>{const y=i.get(m.from),v=i.get(m.to);return y===void 0||v===void 0?0:Math.abs(v.x-y.x)+Math.abs(v.y-y.y)},c=[...s].sort((m,y)=>l(m)-l(y)||m.id.localeCompare(y.id)),h=[],p=new Map;for(const m of c){const y=i.get(m.from),v=i.get(m.to),w=a.get(m.id),$=d.get(m.id)??[],A=y!==void 0&&v!==void 0?Ts(y,v):null;if(y===void 0||v===void 0||w===void 0||A===null||y.id===v.id){p.set(m.id,$),h.push(...$s($));continue}const C=[r.get(y.id),r.get(v.id)],M=t.nodes.filter(H=>H.id!==y.id&&H.id!==v.id).map(uo),E=Es(w.from.side),R=Es(w.to.side),D=co({x:w.from.point.x+E.x*an,y:w.from.point.y+E.y*an},{x:w.to.point.x+R.x*an,y:w.to.point.y+R.y*an},M,o.margin,h,[...C,...M],C),O=ep([w.from.point,...D,w.to.point]),B=ws(O,M)&&!ws($,M)?$:O;p.set(m.id,B),h.push(...$s(B))}const u=s.map(m=>{const y=i.get(m.from),v=i.get(m.to),w=y!==void 0&&v!==void 0?[r.get(y.id),r.get(v.id)]:[];return{id:m.id,points:p.get(m.id)??[],obstacles:t.nodes.filter($=>$.id!==m.from&&$.id!==m.to).map(uo),ownFrames:w}}),g=ho(u,{minPortRun:0}),b=s.map(m=>({id:m.id,points:g.get(m.id)??p.get(m.id)??[]})),f=[...b.flatMap(m=>m.points),...t.nodes.map(m=>({x:m.x+m.width,y:m.y+m.height}))];return{...t,width:Math.max(t.width,...f.map(m=>m.x)),height:Math.max(t.height,...f.map(m=>m.y)),routes:[...t.routes.filter(m=>!s.some(y=>y.id===m.id)),...b]}},sp=de`
412
412
  .arch-toggle {
413
413
  min-height: 26px;
414
414
  padding: 0 9px;
@@ -570,7 +570,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
570
570
  fill: var(--dpk-blue);
571
571
  stroke: var(--dpk-blue);
572
572
  }
573
- `,Gc=[{id:"arch-neutral"},{id:"arch-selected"}];class ys extends nt{static{this.styles=[De,Xc]}#o=!0;parseData(e){return sc(e)}emptyData(){return ic()}defaultHeading(){return vt(this.locale).heading}statsLabels(){const e=vt(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return vt(this.locale).empty}get layoutMode(){return"fixed"}layoutOptions(){return{padding:40}}routePlacement(e,n){return Yc(e,n.edges)}#i(){return this.visible.nodes.flatMap(e=>{const n=this.placedNode(e.id);return n?[{x:n.x,y:n.y,width:n.width,height:n.height}]:[]})}isEmpty(){return this.visible.nodes.length===0}contentSize(){const e=super.contentSize();if(e===null)return null;const n=this.#e();return n.length===0?e:{width:Math.max(e.width,...n.map(o=>o.x+o.width)),height:Math.max(e.height,...n.map(o=>o.y+o.height))}}initialView(){const e=this.visible.nodes.flatMap(i=>{const s=this.placedNode(i.id);return s?[s]:[]}),n=this.renderRoot.querySelector("dpk-dialog-panel")?.shadowRoot?.querySelector('[part~="canvas"]'),o=Zd([...e,...this.#e()],n?.clientHeight??0);this.viewport?.reset(o??void 0)}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)}${o.label===null?"":` \xB7 ${o.label}`}`}))]}renderToolbarActions(){const e=vt(this.locale);return v`
573
+ `,rp=[{id:"arch-neutral"},{id:"arch-selected"}];class Ss extends rt{static{this.styles=[ze,sp]}#o=!0;parseData(e){return yc(e)}emptyData(){return xc()}defaultHeading(){return $t(this.locale).heading}statsLabels(){const e=$t(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return $t(this.locale).empty}get layoutMode(){return"fixed"}layoutOptions(){return{padding:40}}routePlacement(e,n){return ip(e,n.edges)}#i(){return this.visible.nodes.flatMap(e=>{const n=this.placedNode(e.id);return n?[{x:n.x,y:n.y,width:n.width,height:n.height}]:[]})}isEmpty(){return this.visible.nodes.length===0}contentSize(){const e=super.contentSize();if(e===null)return null;const n=this.#e();return n.length===0?e:{width:Math.max(e.width,...n.map(o=>o.x+o.width)),height:Math.max(e.height,...n.map(o=>o.y+o.height))}}initialView(){const e=this.visible.nodes.flatMap(i=>{const s=this.placedNode(i.id);return s?[s]:[]}),n=this.renderRoot.querySelector("dpk-dialog-panel")?.shadowRoot?.querySelector('[part~="canvas"]'),o=pl([...e,...this.#e()],n?.clientHeight??0);this.viewport?.reset(o??void 0)}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=we(n.edges,e.id,"outgoing",!1),i=we(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)}${o.label===null?"":` \xB7 ${o.label}`}`}))]}renderToolbarActions(){const e=$t(this.locale);return k`
574
574
  <button
575
575
  type="button"
576
576
  class="dpk-btn dpk-btn--ghost arch-toggle"
@@ -580,7 +580,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
580
580
  >
581
581
  ${e.boundaries}
582
582
  </button>
583
- `}#e(){const e=this.visible.nodes.flatMap(n=>{const o=this.placedNode(n.id);return o?[{...n,position:{x:o.x,y:o.y}}]:[]});return lc(e,this.items().boundaries)}renderCanvas(){const e=vt(this.locale),n=this.visible,o=s=>n.nodes.find(r=>r.id===s)?.name??s,i=n.edges.map(s=>{const r=this.edgeState(s.id),a=this.routeOf(s.id),d=en(a),l=()=>this.select({kind:"edge",id:s.id});return Y`
583
+ `}#e(){const e=this.visible.nodes.flatMap(n=>{const o=this.placedNode(n.id);return o?[{...n,position:{x:o.x,y:o.y}}]:[]});return $c(e,this.items().boundaries)}renderCanvas(){const e=$t(this.locale),n=this.visible,o=s=>n.nodes.find(r=>r.id===s)?.name??s,i=n.edges.map(s=>{const r=this.edgeState(s.id),a=this.routeOf(s.id),d=nn(a),l=()=>this.select({kind:"edge",id:s.id});return Y`
584
584
  <g
585
585
  class=${this.elementClass(r,"d-edge","arch-link")}
586
586
  data-link=${s.id}
@@ -602,18 +602,18 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
602
602
  @click=${l}
603
603
  @keydown=${c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),l())}}
604
604
  ></path>
605
- ${s.label===null||a.length===0?M:this.#n(s.label,a)}
605
+ ${s.label===null||a.length===0?T:this.#t(s.label,a)}
606
606
  </g>
607
- `});return v`
608
- ${this.#o?this.#e().map(s=>v`<div
607
+ `});return k`
608
+ ${this.#o?this.#e().map(s=>k`<div
609
609
  class=${`arch-boundary ${s.boundary.kind==="external"?"is-external":""}`}
610
610
  data-boundary=${s.boundary.id}
611
611
  style="left:${s.x}px; top:${s.y}px; width:${s.width}px; height:${s.height}px"
612
612
  >
613
613
  <span>${s.boundary.label}</span>
614
- </div>`):M}
615
- ${this.renderEdges(i,Gc)} ${n.nodes.map(s=>this.#t(s,e))}
616
- `}#n(e,n){const o=Bc(n,this.#i(),e);return Y`<text class="arch-link-label" x=${o.x} y=${o.y-6}>${e}</text>`}#t(e,n){const o=this.placedNode(e.id);if(!o)return M;const i=this.nodeState(e.id);return v`
614
+ </div>`):T}
615
+ ${this.renderEdges(i,rp)} ${n.nodes.map(s=>this.#n(s,e))}
616
+ `}#t(e,n){const o=tp(n,this.#i(),e);return Y`<text class="arch-link-label" x=${o.x} y=${o.y-6}>${e}</text>`}#n(e,n){const o=this.placedNode(e.id);if(!o)return T;const i=this.nodeState(e.id);return k`
617
617
  <button
618
618
  type="button"
619
619
  class=${this.elementClass(i,"d-node","arch-service",this.isDraggingNode(e.id)&&"is-dragging")}
@@ -626,18 +626,18 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
626
626
  @pointerdown=${s=>this.onNodeDragStart(s,e.id)}
627
627
  @click=${()=>{this.consumeDragClick()||this.select({kind:"node",id:e.id})}}
628
628
  >
629
- ${e.artwork===null?v`<span class="arch-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>`:v`<img
629
+ ${e.artwork===null?k`<span class="arch-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>`:k`<img
630
630
  class="arch-artwork"
631
631
  src=${e.artwork.src}
632
632
  alt=${e.artwork.alt}
633
- title=${e.artwork.license===null?M:n.artworkCredit(e.artwork.license)}
633
+ title=${e.artwork.license===null?T:n.artworkCredit(e.artwork.license)}
634
634
  />`}
635
635
  <span class="arch-body">
636
636
  <span class="arch-name">${e.name}</span>
637
- ${e.description===null?M:v`<span class="arch-description">${e.description}</span>`}
637
+ ${e.description===null?T:k`<span class="arch-description">${e.description}</span>`}
638
638
  </span>
639
639
  </button>
640
- `}}const vs=()=>{customElements.get("dpk-board-architecture-map")||customElements.define("dpk-board-architecture-map",ys)},it=ce({en:{heading:"Dependency graph",node:"Module",edge:"Dependency",emptyCycles:"No matching cycles.",emptyModules:"No matching modules.",directionGroup:"Direction to follow from the selected module",directionOutgoing:"Depends on",directionIncoming:"Depended on by",directionBoth:"Both",transitive:"Include indirect",cyclesToggleLabel:t=>`Show only ${t} cycle group(s)`,cyclesCount:t=>`Cycles ${t}`,legendOutgoing:"Depends on",legendIncoming:"Depended on by",legendCycle:"Cycle",edgeLabel:(t,e)=>`${t} depends on ${e}`,cyclicSuffix:t=>`${t}, part of a cycle`,cycleBadge:"Cycle"},ja:{heading:"\u4F9D\u5B58\u95A2\u4FC2\u30B0\u30E9\u30D5",node:"\u30E2\u30B8\u30E5\u30FC\u30EB",edge:"\u4F9D\u5B58",emptyCycles:"\u8A72\u5F53\u3059\u308B\u5FAA\u74B0\u4F9D\u5B58\u306F\u3042\u308A\u307E\u305B\u3093\u3002",emptyModules:"\u8A72\u5F53\u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",directionGroup:"\u9078\u629E\u3057\u305F\u30E2\u30B8\u30E5\u30FC\u30EB\u304B\u3089\u8FFD\u3046\u65B9\u5411",directionOutgoing:"\u4F9D\u5B58\u5148",directionIncoming:"\u4F9D\u5B58\u5143",directionBoth:"\u4E21\u65B9",transitive:"\u9593\u63A5\u3082\u542B\u3080",cyclesToggleLabel:t=>`\u5FAA\u74B0\u4F9D\u5B58 ${t} \u30B0\u30EB\u30FC\u30D7\u3060\u3051\u8868\u793A`,cyclesCount:t=>`\u5FAA\u74B0 ${t}`,legendOutgoing:"\u4F9D\u5B58\u5148",legendIncoming:"\u4F9D\u5B58\u5143",legendCycle:"\u5FAA\u74B0",edgeLabel:(t,e)=>`${t} \u304C ${e} \u306B\u4F9D\u5B58`,cyclicSuffix:t=>`${t}\u30FB\u5FAA\u74B0\u4F9D\u5B58\u3042\u308A`,cycleBadge:"\u5FAA\u74B0"}}),ks={width:176,height:84},Kc=P({id:I(y(),_(1)),name:I(y(),_(1)),path:C(y()),layer:C(y()),tags:C(F(y()),[]),description:C(y()),questions:C(y())}),jc=P({id:I(y(),_(1)),from:I(y(),_(1)),to:I(y(),_(1)),contract:C(y()),description:C(y()),questions:C(y())}),Wc=P({modules:F(Kc),dependencies:C(F(jc),[])}),Vc=()=>({nodes:[],edges:[]}),Qc=t=>{const e=he(Wc,t),n=new Set;for(const r of e.modules){if(n.has(r.id))throw new Error(`duplicate module id: ${r.id}`);n.add(r.id)}const o=new Set,i=e.dependencies.map(r=>{if(o.has(r.id))throw new Error(`duplicate dependency id: ${r.id}`);if(o.add(r.id),!n.has(r.from))throw new Error(`unknown dependency source: ${r.from}`);if(!n.has(r.to))throw new Error(`unknown dependency target: ${r.to}`);return{id:r.id,from:r.from,to:r.to,tags:[],contract:r.contract??null,description:r.description??null}});return{nodes:e.modules.map(r=>({id:r.id,name:r.name,path:r.path??null,layer:r.layer??null,description:r.description??null,tags:r.tags,width:ks.width,height:ks.height,...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},Zc=ae`
640
+ `}}const Ms=()=>{customElements.get("dpk-board-architecture-map")||customElements.define("dpk-board-architecture-map",Ss)},dt=pe({en:{heading:"Dependency graph",node:"Module",edge:"Dependency",emptyCycles:"No matching cycles.",emptyModules:"No matching modules.",directionGroup:"Direction to follow from the selected module",directionOutgoing:"Depends on",directionIncoming:"Depended on by",directionBoth:"Both",transitive:"Include indirect",cyclesToggleLabel:t=>`Show only ${t} cycle group(s)`,cyclesCount:t=>`Cycles ${t}`,legendOutgoing:"Depends on",legendIncoming:"Depended on by",legendCycle:"Cycle",edgeLabel:(t,e)=>`${t} depends on ${e}`,cyclicSuffix:t=>`${t}, part of a cycle`,cycleBadge:"Cycle"},ja:{heading:"\u4F9D\u5B58\u95A2\u4FC2\u30B0\u30E9\u30D5",node:"\u30E2\u30B8\u30E5\u30FC\u30EB",edge:"\u4F9D\u5B58",emptyCycles:"\u8A72\u5F53\u3059\u308B\u5FAA\u74B0\u4F9D\u5B58\u306F\u3042\u308A\u307E\u305B\u3093\u3002",emptyModules:"\u8A72\u5F53\u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",directionGroup:"\u9078\u629E\u3057\u305F\u30E2\u30B8\u30E5\u30FC\u30EB\u304B\u3089\u8FFD\u3046\u65B9\u5411",directionOutgoing:"\u4F9D\u5B58\u5148",directionIncoming:"\u4F9D\u5B58\u5143",directionBoth:"\u4E21\u65B9",transitive:"\u9593\u63A5\u3082\u542B\u3080",cyclesToggleLabel:t=>`\u5FAA\u74B0\u4F9D\u5B58 ${t} \u30B0\u30EB\u30FC\u30D7\u3060\u3051\u8868\u793A`,cyclesCount:t=>`\u5FAA\u74B0 ${t}`,legendOutgoing:"\u4F9D\u5B58\u5148",legendIncoming:"\u4F9D\u5B58\u5143",legendCycle:"\u5FAA\u74B0",edgeLabel:(t,e)=>`${t} \u304C ${e} \u306B\u4F9D\u5B58`,cyclicSuffix:t=>`${t}\u30FB\u5FAA\u74B0\u4F9D\u5B58\u3042\u308A`,cycleBadge:"\u5FAA\u74B0"}}),Cs={width:176,height:84},ap=P({id:S(x(),I(1)),name:S(x(),I(1)),path:L(x()),layer:L(x()),tags:L(F(x()),[]),description:L(x()),questions:L(x())}),dp=P({id:S(x(),I(1)),from:S(x(),I(1)),to:S(x(),I(1)),contract:L(x()),description:L(x()),questions:L(x())}),lp=P({modules:F(ap),dependencies:L(F(dp),[])}),cp=()=>({nodes:[],edges:[]}),pp=t=>{const e=ue(lp,t),n=new Set;for(const r of e.modules){if(n.has(r.id))throw new Error(`duplicate module id: ${r.id}`);n.add(r.id)}const o=new Set,i=e.dependencies.map(r=>{if(o.has(r.id))throw new Error(`duplicate dependency id: ${r.id}`);if(o.add(r.id),!n.has(r.from))throw new Error(`unknown dependency source: ${r.from}`);if(!n.has(r.to))throw new Error(`unknown dependency target: ${r.to}`);return{id:r.id,from:r.from,to:r.to,tags:[],contract:r.contract??null,description:r.description??null}});return{nodes:e.modules.map(r=>({id:r.id,name:r.name,path:r.path??null,layer:r.layer??null,description:r.description??null,tags:r.tags,width:Cs.width,height:Cs.height,...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},hp=de`
641
641
  .dep-direction {
642
642
  display: flex;
643
643
  gap: 2px;
@@ -831,9 +831,9 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
831
831
  fill: var(--dpk-blue);
832
832
  stroke: var(--dpk-blue);
833
833
  }
834
- `,Jc=[{id:"dep-neutral"},{id:"dep-outgoing"},{id:"dep-incoming"},{id:"dep-cycle"},{id:"dep-selected"}];class ws extends nt{static{this.styles=[De,Zc]}#o="both";#i=!1;#e=!1;#n=[];#t=Ie;#a=Ie;parseData(e){return Qc(e)}emptyData(){return Vc()}defaultHeading(){return it(this.locale).heading}statsLabels(){const e=it(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){const e=it(this.locale);return this.#e?e.emptyCycles:e.emptyModules}layoutOptions(){return{nodeSpacing:40,layerSpacing:96,padding:32}}relations(e,n){return e===null||e.kind!=="node"?Ie:{nodes:new Map([...this.#t.nodes,...this.#a.nodes]),edges:new Set([...this.#t.edges,...this.#a.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)}`}))]}refreshContent(){const e=this.items(),n=this.tagFilter,o=e.nodes.filter(a=>Ce(a.tags,n)),i=new Set(o.map(a=>a.id)),s=e.edges.filter(a=>i.has(a.from)&&i.has(a.to));this.#n=Jd(o.map(a=>a.id),s);const r=this.selection;this.#t=r!==null&&r.kind==="node"&&this.#o!=="incoming"?ve(s,r.id,"outgoing",this.#i):Ie,this.#a=r!==null&&r.kind==="node"&&this.#o!=="outgoing"?ve(s,r.id,"incoming",this.#i):Ie,super.refreshContent()}matchesFilter(e){return this.#e?Gn(this.#n).has(e.id):!0}filtered(){const e=super.filtered();if(!this.#e)return e;const n=Gn(this.#n),o=e.edges.filter(s=>ki(s,n)),i=new Set(o.flatMap(s=>[s.from,s.to]));return{nodes:e.nodes.filter(s=>i.has(s.id)),edges:o}}renderToolbarActions(){const e=it(this.locale),n=this.#n.length;return v`
834
+ `,up=[{id:"dep-neutral"},{id:"dep-outgoing"},{id:"dep-incoming"},{id:"dep-cycle"},{id:"dep-selected"}];class Ls extends rt{static{this.styles=[ze,hp]}#o="both";#i=!1;#e=!1;#t=[];#n=Ie;#a=Ie;parseData(e){return pp(e)}emptyData(){return cp()}defaultHeading(){return dt(this.locale).heading}statsLabels(){const e=dt(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){const e=dt(this.locale);return this.#e?e.emptyCycles:e.emptyModules}layoutOptions(){return{nodeSpacing:40,layerSpacing:96,padding:32}}relations(e,n){return e===null||e.kind!=="node"?Ie:{nodes:new Map([...this.#n.nodes,...this.#a.nodes]),edges:new Set([...this.#n.edges,...this.#a.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)}`}))]}refreshContent(){const e=this.items(),n=this.tagFilter,o=e.nodes.filter(a=>Ae(a.tags,n)),i=new Set(o.map(a=>a.id)),s=e.edges.filter(a=>i.has(a.from)&&i.has(a.to));this.#t=hl(o.map(a=>a.id),s);const r=this.selection;this.#n=r!==null&&r.kind==="node"&&this.#o!=="incoming"?we(s,r.id,"outgoing",this.#i):Ie,this.#a=r!==null&&r.kind==="node"&&this.#o!=="outgoing"?we(s,r.id,"incoming",this.#i):Ie,super.refreshContent()}matchesFilter(e){return this.#e?Wn(this.#t).has(e.id):!0}filtered(){const e=super.filtered();if(!this.#e)return e;const n=Wn(this.#t),o=e.edges.filter(s=>Si(s,n)),i=new Set(o.flatMap(s=>[s.from,s.to]));return{nodes:e.nodes.filter(s=>i.has(s.id)),edges:o}}renderToolbarActions(){const e=dt(this.locale),n=this.#t.length;return k`
835
835
  <div class="dep-direction" role="group" aria-label=${e.directionGroup}>
836
- ${[["outgoing",e.directionOutgoing],["incoming",e.directionIncoming],["both",e.directionBoth]].map(([o,i])=>v`
836
+ ${[["outgoing",e.directionOutgoing],["incoming",e.directionIncoming],["both",e.directionBoth]].map(([o,i])=>k`
837
837
  <button
838
838
  type="button"
839
839
  data-direction=${o}
@@ -864,11 +864,11 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
864
864
  >
865
865
  ${e.cyclesCount(n)}
866
866
  </button>
867
- `}renderLegend(){const e=it(this.locale);return v`<div class="diagram-legend">
867
+ `}renderLegend(){const e=dt(this.locale);return k`<div class="diagram-legend">
868
868
  <span><i class="dep-swatch-outgoing"></i>${e.legendOutgoing}</span>
869
869
  <span><i class="dep-swatch-incoming"></i>${e.legendIncoming}</span>
870
870
  <span><i class="dep-swatch-cycle"></i>${e.legendCycle}</span>
871
- </div>`}#r(e){this.#o=e,this.requestUpdate()}#s(e,n){const o=this.selection;return o!==null&&o.kind==="edge"&&o.id===e.id?"dep-selected":ki(e,n)?"dep-cycle":this.#t.edges.has(e.id)?"dep-outgoing":this.#a.edges.has(e.id)?"dep-incoming":"dep-neutral"}renderCanvas(){const e=it(this.locale),n=this.visible,o=Gn(this.#n),i=a=>n.nodes.find(d=>d.id===a)?.name??a,s=n.edges.map(a=>{const d=this.edgeState(a.id),l=this.routeOf(a.id),c=en(l),h=()=>this.select({kind:"edge",id:a.id});return Y`
871
+ </div>`}#r(e){this.#o=e,this.requestUpdate()}#s(e,n){const o=this.selection;return o!==null&&o.kind==="edge"&&o.id===e.id?"dep-selected":Si(e,n)?"dep-cycle":this.#n.edges.has(e.id)?"dep-outgoing":this.#a.edges.has(e.id)?"dep-incoming":"dep-neutral"}renderCanvas(){const e=dt(this.locale),n=this.visible,o=Wn(this.#t),i=a=>n.nodes.find(d=>d.id===a)?.name??a,s=n.edges.map(a=>{const d=this.edgeState(a.id),l=this.routeOf(a.id),c=nn(l),h=()=>this.select({kind:"edge",id:a.id});return Y`
872
872
  <g
873
873
  class=${this.elementClass(d,"d-edge","dep-edge")}
874
874
  data-dependency=${a.id}
@@ -888,7 +888,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
888
888
  @keydown=${p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),h())}}
889
889
  ></path>
890
890
  </g>
891
- `}),r=n.nodes.map(a=>{const d=this.placedNode(a.id);if(!d)return M;const l=this.nodeState(a.id),c=o.has(a.id),h=this.#t.nodes.has(a.id),p=this.#a.nodes.has(a.id);return v`
891
+ `}),r=n.nodes.map(a=>{const d=this.placedNode(a.id);if(!d)return T;const l=this.nodeState(a.id),c=o.has(a.id),h=this.#n.nodes.has(a.id),p=this.#a.nodes.has(a.id);return k`
892
892
  <button
893
893
  type="button"
894
894
  class=${this.elementClass(l,"d-node","dep-module",c&&"is-cyclic",h&&"is-dependency",p&&"is-dependent",this.isDraggingNode(a.id)&&"is-dragging")}
@@ -905,12 +905,12 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
905
905
  >
906
906
  <span class="dep-head">
907
907
  <span class="dep-layer">${a.layer??""}</span>
908
- ${c?v`<span class="dep-cycle-badge">${e.cycleBadge}</span>`:M}
908
+ ${c?k`<span class="dep-cycle-badge">${e.cycleBadge}</span>`:T}
909
909
  </span>
910
910
  <span class="dep-name">${a.name}</span>
911
911
  <span class="dep-path">${a.path??""}</span>
912
912
  </button>
913
- `});return v`${this.renderEdges(s,Jc)}${r}`}}const $s=()=>{customElements.get("dpk-board-dependency-graph")||customElements.define("dpk-board-dependency-graph",ws)},ep=t=>{switch(t){case"1":return{min:"one",max:"one"};case"0..1":return{min:"zero",max:"one"};case"1..N":return{min:"one",max:"many"};case"0..N":return{min:"zero",max:"many"}}},$t=4,Es=6,tp=12,Ts=7,np=7,co=13,po=14,op=6,rn=t=>t+$t-2,ip=Math.max(co,po,rn(po)+$t,rn(co)+$t),Ss=(t,e)=>{const n=e==="start"?t:[...t].reverse(),[o]=n,i=n.find(r=>o!==void 0&&(r.x!==o.x||r.y!==o.y));if(o===void 0||i===void 0)return{x:e==="start"?1:-1,y:0};const s=Math.hypot(i.x-o.x,i.y-o.y);return{x:(i.x-o.x)/s,y:(i.y-o.y)/s}},sp=(t,e)=>Ss(t,e),Ms=t=>Math.round(t*100)/100||0,rp=(t,e,n)=>{const o=(e==="start"?t[0]:t.at(-1))??{x:0,y:0},i=Ss(t,e),s={x:-i.y,y:i.x},r=(b,f=0)=>({x:Ms(o.x+i.x*b+s.x*f),y:Ms(o.y+i.y*b+s.y*f)}),a=b=>[r(b,-Es),r(b,Es)],d=ep(n),l=d.max==="many"?[-Ts,0,Ts].map(b=>[r(tp),r(0,b)]):[a(np)],c=d.max==="many"?po:co,h=d.min==="one"?[...l,a(c)]:l,p=d.min==="zero"?r(rn(c)):null,u=(d.min==="zero"?rn(c)+$t:c)+op,g=r(u);return{segments:h,circle:p,label:{...g,anchor:i.x>=0?"start":"end"}}},an=10,ap=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:6.2;return Math.ceil(e+2)},ho=(t,e)=>e!=null&&e!==t?`${e} ${t}`:t,Is=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height,Cs=(t,e,n)=>t.x===e.x?t.x<=n.x||t.x>=n.x+n.width?0:Math.max(0,Math.min(Math.max(t.y,e.y),n.y+n.height)-Math.max(Math.min(t.y,e.y),n.y)):t.y<=n.y||t.y>=n.y+n.height?0:Math.max(0,Math.min(Math.max(t.x,e.x),n.x+n.width)-Math.max(Math.min(t.x,e.x),n.x)),dp=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],uo=(t,e,n,o)=>{const i=e==="relation"?"end":e,s=i==="start"?t[0]:t.at(-1);if(s===void 0)return[];const r=sp(t,i),a={x:-r.y,y:r.x},d=Math.abs(r.x)>=Math.abs(r.y),l=ap(n),c=e==="start"?[14,20,26]:e==="end"?[4,8,12]:[14,20,26],h=[16,-16,24,-24];o&&(c.push(...c.map(u=>u+36)),h.push(32,-32));const p=[];for(const u of c)for(const g of h){const b=s.x+r.x*u+a.x*g,f=s.y+r.y*u+a.y*g;let m,x;if(d){const k=r.x>0;m=k?"start":"end",x={x:k?b:b-l,y:f-an/2,width:l,height:an}}else{const k=a.x*g>0;m=k?"start":"end",x={x:k?b:b-l,y:f-an/2,width:l,height:an}}p.push({x:b,y:f,anchor:m,box:x,along:u,across:g})}return p},lp=(t,e,n)=>{const{box:o}=t;let i=0;(o.x<0||o.y<0||o.x+o.width>e.width||o.y+o.height>e.height)&&(i+=1e7);for(const s of e.nodes)Is(o,s.box)&&(i+=1e6);for(const s of e.frames)for(const[r,a]of dp(s.box))if(Cs(r,a,o)>0){i+=1e5;break}for(const s of n)Is(o,s)&&(i+=1e5);for(const s of e.edges??[])for(let r=1;r<s.length;r++)if(Cs(s[r-1],s[r],o)>.5){i+=1e4;break}return Math.abs(t.across)<14&&(i+=1e3),i+=t.along*.1+Math.abs(t.across)*.5,i},mo=(t,e,n,o,i,s,r)=>{let a=uo(n,e,i,!1)[0],d=Number.POSITIVE_INFINITY;const l=c=>{for(const h of c){const p=lp(h,s,r);p<d&&(a=h,d=p)}};return l(uo(n,e,i,!1)),d>=1e4&&l(uo(n,e,i,!0)),{id:`${t.id}:${e}`,edge:t.id,end:e,kind:e==="relation"?"relation":"cardinality",text:o,x:a.x,y:a.y,anchor:a.anchor,box:a.box}},cp=(t,e,n)=>{const o=[],i=new Map;for(const s of[...t].sort((r,a)=>r.id.localeCompare(a.id))){const r=e.get(s.id);if(r===void 0||r.length<2)continue;const a=s.cardinality.parent,d=s.cardinality.child,l=mo(s,"start",r,a,ho(a,s.before?.cardinality.parent),n,o);o.push(l.box);const c=mo(s,"end",r,d,ho(d,s.before?.cardinality.child),n,o);o.push(c.box);const h=s.label===null?null:mo(s,"relation",r,s.label,ho(s.label,s.before?.label),n,o);h!==null&&o.push(h.box),i.set(s.id,{start:l,end:c,relation:h})}return i},Ls=(t,e)=>e?{same:"Unchanged",added:"Added",removed:"Removed",changed:"Changed"}[t]:{same:"\u5909\u66F4\u306A\u3057",added:"\u8FFD\u52A0",removed:"\u524A\u9664",changed:"\u5909\u66F4"}[t],ke=ce({en:{heading:"ER diagram",node:"Table",edge:"Relation",empty:"No matching tables.",search:"Search",legendAdded:"Added",legendRemoved:"Removed",legendChanged:"Changed",statusLabel:t=>Ls(t,!0),edgeLabel:(t,e,n)=>`${t} and ${e}, related ${n}`,was:t=>`was ${t}`,nullable:"nullable",notNull:"not null",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",addFieldButton:"Add column",addFieldTitle:"Add column",addFieldName:"Column name",addFieldType:"Type",columnNameLabel:"Name",columnNamePlaceholder:"column_name",columnTypePlaceholder:"e.g. text",columnTypeChoices:"Types in this schema",columnTypeNew:"New type",columnNullable:"Allow NULL",columnNameTaken:"This table already has a column with this name.",columnDescriptionLabel:"Description",columnDescriptionPlaceholder:"optional note",cancel:"Cancel",columnAdd:"Add",columnSave:"Save",columnKeys:"Enter to confirm \xB7 Esc to cancel",addFieldSummary:(t,e,n)=>`${t}.${e} (${n})`,editFieldButton:t=>`Edit ${t}`,editFieldTitle:"Edit column",editFieldSummary:(t,e,n)=>`${t}.${e} \u2192 ${n}`,columnRole:t=>({primary:"Primary key",foreign:"Foreign key","not-null":"NOT NULL",nullable:"Nullable"})[t],changesLabel:"Changes",attributeLabel:t=>({type:"type",keys:"keys",ref:"ref",nullable:"null",cardinality:"card.",label:"label"})[t],deleteFieldButton:t=>`Delete ${t}`,deleteFieldTitle:"Delete column",deleteFieldSummary:(t,e)=>`${t}.${e}`,deleteFieldRelationsNote:t=>`Also removes ${t} relation${t===1?"":"s"}.`,editCardinalityTitle:"Edit cardinality",editCardinalityButton:"Edit cardinality",editCardinalitySummary:(t,e,n)=>`${t} \u2013 ${e}: ${n}`,cardinalityLabel:"Cardinality",patternLabel:t=>({immutable:"Immutable",mutable:"Mutable",sti:"STI",cti:"CTI","value-object":"Value Object"})[t],aggregateLabel:"Aggregate",columnFilterLabel:"Columns shown",columnFilterAll:"All",columnFilterKeys:"Keys",columnFilterTablesOnly:"Tables only",tableConstraintsLabel:"Table-level constraints",groupingLabel:"Grouping",boundedContextLabel:"Bounded Context"},ja:{heading:"ER\u56F3",node:"\u30C6\u30FC\u30D6\u30EB",edge:"\u95A2\u9023",empty:"\u8A72\u5F53\u3059\u308B\u30C6\u30FC\u30D6\u30EB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",search:"\u691C\u7D22",legendAdded:"\u8FFD\u52A0",legendRemoved:"\u524A\u9664",legendChanged:"\u5909\u66F4",statusLabel:t=>Ls(t,!1),edgeLabel:(t,e,n)=>`${t} \u3068 ${e} \u306E\u95A2\u9023 (${n})`,was:t=>`\u5909\u66F4\u524D ${t}`,nullable:"NULL \u53EF",notNull:"NOT NULL",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",addFieldButton:"\u30AB\u30E9\u30E0\u3092\u8FFD\u52A0",addFieldTitle:"\u30AB\u30E9\u30E0\u3092\u8FFD\u52A0",addFieldName:"\u30AB\u30E9\u30E0\u540D",addFieldType:"\u578B",columnNameLabel:"\u540D\u524D",columnNamePlaceholder:"column_name",columnTypePlaceholder:"\u4F8B: text",columnTypeChoices:"\u3053\u306E\u30B9\u30AD\u30FC\u30DE\u306E\u578B",columnTypeNew:"\u65B0\u3057\u3044\u578B",columnNullable:"NULL \u3092\u8A31\u53EF",columnNameTaken:"\u540C\u3058\u540D\u524D\u306E\u30AB\u30E9\u30E0\u304C\u3059\u3067\u306B\u3042\u308A\u307E\u3059\u3002",columnDescriptionLabel:"\u8AAC\u660E",columnDescriptionPlaceholder:"\u88DC\u8DB3\uFF08\u4EFB\u610F\uFF09",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",columnAdd:"\u8FFD\u52A0",columnSave:"\u4FDD\u5B58",columnKeys:"Enter \u3067\u78BA\u5B9A \xB7 Esc \u3067\u9589\u3058\u308B",addFieldSummary:(t,e,n)=>`${t}.${e} (${n})`,editFieldButton:t=>`${t} \u3092\u7DE8\u96C6`,editFieldTitle:"\u30AB\u30E9\u30E0\u3092\u7DE8\u96C6",editFieldSummary:(t,e,n)=>`${t}.${e} \u2192 ${n}`,columnRole:t=>({primary:"\u4E3B\u30AD\u30FC",foreign:"\u5916\u90E8\u30AD\u30FC","not-null":"NOT NULL",nullable:"NULL \u53EF"})[t],changesLabel:"\u5909\u66F4\u70B9",attributeLabel:t=>({type:"\u578B",keys:"\u30AD\u30FC",ref:"\u53C2\u7167",nullable:"NULL",cardinality:"\u591A\u91CD\u5EA6",label:"\u30E9\u30D9\u30EB"})[t],deleteFieldButton:t=>`${t} \u3092\u524A\u9664`,deleteFieldTitle:"\u30AB\u30E9\u30E0\u3092\u524A\u9664",deleteFieldSummary:(t,e)=>`${t}.${e}`,deleteFieldRelationsNote:t=>`\u95A2\u9023 ${t} \u672C\u3082\u524A\u9664\u3055\u308C\u307E\u3059`,editCardinalityTitle:"\u591A\u91CD\u5EA6\u3092\u7DE8\u96C6",editCardinalityButton:"\u591A\u91CD\u5EA6\u3092\u7DE8\u96C6",editCardinalitySummary:(t,e,n)=>`${t} \u2013 ${e}: ${n}`,cardinalityLabel:"\u591A\u91CD\u5EA6",patternLabel:t=>({immutable:"Immutable",mutable:"Mutable",sti:"STI",cti:"CTI","value-object":"Value Object"})[t],aggregateLabel:"\u96C6\u7D04",columnFilterLabel:"\u8868\u793A\u3059\u308B\u30AB\u30E9\u30E0",columnFilterAll:"\u3059\u3079\u3066",columnFilterKeys:"\u30AD\u30FC\u306E\u307F",columnFilterTablesOnly:"\u30C6\u30FC\u30D6\u30EB\u306E\u307F",tableConstraintsLabel:"\u30C6\u30FC\u30D6\u30EB\u5236\u7D04",groupingLabel:"\u30B0\u30EB\u30FC\u30D4\u30F3\u30B0",boundedContextLabel:"\u5883\u754C\u3065\u3051\u3089\u308C\u305F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8"}}),pp=280,go=48,hp=32,up=52,mp=16,gp=18,fp=10,bp=440,_s=["1","0..1"],Rs=["1","0..1","1..N","0..N"],fo=_s.flatMap(t=>Rs.map(e=>`${t}:${e}`)),xp=["immutable","mutable","sti","cti","value-object"],yp=X(xp),As=X(["PK","FK","UQ"]),vp=P({id:I(y(),_(1)),type:I(y(),_(1)),key:C(Dd([As,I(F(As),_(1))])),ref:C(y()),nullable:C(ft(),!1),cardinality:C(X(fo)),label:C(I(y(),_(1))),description:C(y()),questions:C(y())}),kp=Bn("kind",[P({kind:pe("unique"),columns:I(F(I(y(),_(1))),_(1))}),P({kind:pe("primary-key"),columns:I(F(I(y(),_(1))),_(1))}),P({kind:pe("check"),expression:I(y(),_(1))}),P({kind:pe("exclude"),using:C(I(y(),_(1))),elements:I(F(I(y(),_(1))),_(1))})]),wp=P({id:I(y(),_(1)),name:I(y(),_(1)),tags:C(F(y()),[]),boundedContext:C(y()),aggregate:C(y()),pattern:C(yp),fields:F(vp),constraints:C(F(kp),[]),questions:C(y())}),Os=P({tables:F(wp)}),$p=P({before:C(Os),after:Os}),Ep=()=>({nodes:[],edges:[]}),Tp=t=>({nodes:t.nodes.map(e=>({id:e.id,width:e.width,height:e.height,...e.ports===void 0?{}:{ports:e.ports},...e.position===void 0?{}:{position:e.position},...e.group===void 0?{}:{group:e.group},...e.boundedContext===null?{}:{superGroup:e.boundedContext}})),edges:t.edges.map(e=>({id:e.id,from:e.from,to:e.to,...e.fromPort===void 0?{}:{fromPort:e.fromPort},...e.toPort===void 0?{}:{toPort:e.toPort}}))}),bo=t=>t.key===void 0?[]:[...new Set(typeof t.key=="string"?[t.key]:t.key)],Ns=t=>({id:t.id,type:t.type,keys:bo(t),ref:t.ref??null,nullable:t.nullable,cardinality:t.cardinality??null,label:t.label??null,description:t.description??null,questions:t.questions??null}),xo=(t,e)=>t.type===e.type&&t.keys.join()===e.keys.join()&&t.ref===e.ref&&t.nullable===e.nullable&&t.cardinality===e.cardinality&&t.label===e.label,Sp=t=>t.kind==="exclude"?{...t,using:t.using??null}:t,Ds=t=>{switch(t.kind){case"unique":return`UNIQUE (${t.columns.join(", ")})`;case"primary-key":return`PRIMARY KEY (${t.columns.join(", ")})`;case"check":return`CHECK (${t.expression})`;case"exclude":return`EXCLUDE${t.using===null?"":` USING ${t.using}`} (${t.elements.join(", ")})`}},Et=t=>`${t.parent} : ${t.child}`,zs=(t,e)=>Et(t.cardinality)===Et(e.cardinality)&&t.label===e.label,Mp=(t,e)=>{const n=bo(e);return n.includes("UQ")?!0:n.includes("PK")&&t.fields.filter(o=>bo(o).includes("PK")).length===1},Ps=new Map(_s.map(t=>[t,t])),qs=new Map(Rs.map(t=>[t,t])),Ip=(t,e)=>{const n=Mp(t,e),o={parent:e.nullable?"0..1":"1",child:n?"0..1":"0..N"};if(e.cardinality===void 0)return o;const[i="",s=""]=e.cardinality.split(":"),r=Ps.get(i),a=qs.get(s),d=`${t.id}.${e.id}`;if(r===void 0||a===void 0)throw new Error(`invalid cardinality on ${d}`);if(r!==o.parent)throw new Error(`cardinality "${e.cardinality}" on ${d} needs the parent end ${o.parent}: the FK is ${e.nullable?"":"not "}nullable`);if(n&&(a==="1..N"||a==="0..N"))throw new Error(`cardinality "${e.cardinality}" on ${d} allows many rows, but the column is unique`);return{parent:r,child:a}},yo=t=>(t.status==="changed"?up:hp)+(t.description===null?0:mp),Cp=t=>t.length===0?0:fp+t.length*gp,Fs=(t,e=[])=>go+t.reduce((n,o)=>n+yo(o),0)+Cp(e),Bs=(t,e)=>{let n=go;for(const o of t){if(o.id===e)return n+yo(o)/2;n+=yo(o)}return go/2},Lp=14,_p=(t,e)=>(t-(e-1)/2)*Lp,Us=t=>{const e=new Map;for(const n of t){const o=`${n.from}.${n.sourceField}`;e.set(o,[...e.get(o)??[],n.id])}return new Map([...e.values()].flatMap(n=>n.map((o,i)=>[o,_p(i,n.length)])))},Hs=t=>t.flatMap(e=>e.fields.flatMap(n=>{if(n.ref===void 0){if(n.cardinality!==void 0||n.label!==void 0)throw new Error(`cardinality and label on ${e.id}.${n.id} describe a relation; add its ref`);return[]}const[o,i]=n.ref.split(".");if(o===void 0||i===void 0)throw new Error(`invalid ref "${n.ref}" on ${e.id}.${n.id}; expected table.field`);return[{id:`${o}:${i}>${e.id}:${n.id}`,from:o,to:e.id,sourceField:i,targetField:n.id,cardinality:Ip(e,n),label:n.label??null}]})),Rp=(t,e)=>[...new Set([...t,...e].map(o=>o.id))].flatMap(o=>{const i=t.find(l=>l.id===o),s=e.find(l=>l.id===o),r=s??i;if(!r)return[];const a=Ns(r);if(!i)return[{...a,status:"added",before:null}];if(!s)return[{...a,status:"removed",before:null}];const d=Ns(i);return[{...a,status:xo(d,a)?"same":"changed",before:xo(d,a)?null:d}]}),Ys=(t,e)=>{const n=Us(e),o={};for(const i of e)i.from===t.id&&(o[`${i.id}:out`]={x:t.width,y:Bs(t.fields,i.sourceField)+(n.get(i.id)??0)}),i.to===t.id&&(o[`${i.id}:in`]={x:0,y:Bs(t.fields,i.targetField)});return{...t,ports:o}},Tt=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},Ap=70,Op=20,Np=168,Dp=t=>{const e=Tt(t.type,11),n=t.before===null||t.before.type===t.type?0:Tt(t.before.type,11)+5;return Math.min(Np,Math.ceil(n+e))},Xs=(t,e,n=[])=>{const o=Tt(t,13)/2+100,i=Math.max(0,...e.map(r=>Tt(r.id,12)/2+Ap+Op+Dp(r))),s=Math.max(0,...n.map(r=>Tt(Ds(r),11)+24));return Math.min(bp,Math.max(pp,Math.ceil(Math.max(o,i,s))))},zp=t=>{const e=he($p,t),n=e.before?.tables??e.after.tables,o=e.after.tables,i=[...new Set([...n,...o].map(b=>b.id))],s=new Map,r=new Map,a=new Map,d=new Map;for(const b of[...n,...o])s.set(b.id,b.tags),r.set(b.id,b.boundedContext??null),a.set(b.id,b.aggregate??null),d.set(b.id,b.pattern??null);const l=i.flatMap(b=>{const f=n.find(T=>T.id===b),m=o.find(T=>T.id===b),x=m??f;if(!x)return[];const k=Rp(f?.fields??[],m?.fields??[]),w=f?m?k.some(T=>T.status!=="same")?"changed":"same":"removed":"added",$=r.get(b)??null,L=a.get(b)??null,S=x.constraints.map(Sp);return[{id:b,name:x.name,status:w,fields:k,tags:[...s.get(b)??[],...$===null?[]:[ol($)]],boundedContext:$,aggregate:L,...L===null?{}:{group:L},pattern:d.get(b)??null,constraints:S,width:Xs(b,k,S),height:Fs(k,S),...x.questions===void 0?{}:{questions:x.questions}}]}),c=new Map(l.map(b=>[b.id,b])),h=Hs(n),p=Hs(o),g=[...new Set([...h,...p].map(b=>b.id))].flatMap(b=>{const f=h.find(S=>S.id===b),m=p.find(S=>S.id===b),x=m??f;if(!x)return[];const k=c.get(x.from),w=c.get(x.to);if(!k||!w)return[];const $=f&&m&&!zs(f,m)?f:null,L=f?m?$?"changed":"same":"removed":"added";return[{id:b,from:x.from,to:x.to,sourceField:x.sourceField,targetField:x.targetField,cardinality:x.cardinality,label:x.label,before:$&&{cardinality:$.cardinality,label:$.label},status:L,tags:[],fromPort:`${b}:out`,toPort:`${b}:in`}]});return{nodes:l.map(b=>Ys(b,g)),edges:g}},Gs="ADD_FIELD",Ks="EDIT_FIELD",js="DELETE_FIELD",Ws="EDIT_CARDINALITY",Pp=O({id:I(y(),Ge(),_(1)),type:I(y(),Ge(),_(1)),nullable:C(ft(),!1),description:C(I(y(),Ge()))}),qp=O({field:I(y(),_(1)),type:I(y(),Ge(),_(1)),nullable:ft(),description:C(I(y(),Ge()))}),Fp=O({field:I(y(),_(1))}),Bp=O({cardinality:X(fo)}),vo=t=>{const e=Ne(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},Up=t=>{const e=Ne(t);return e?.length===3&&e[1]==="edge"?e[2]??null:null},Vs=(t,e,n)=>t.edges.filter(o=>o.from===e&&o.sourceField===n||o.to===e&&o.targetField===n),ko=(t,e,n)=>{const o=t.nodes.map(i=>{if(i.id!==e)return i;const s=i.status==="added"||i.status==="removed"?i.status:n.some(r=>r.status!=="same")?"changed":"same";return Ys({...i,status:s,fields:n,width:Xs(i.id,n,i.constraints),height:Fs(n,i.constraints)},t.edges)});return{...t,nodes:o}},Hp=(t,e,n)=>{const o=t.addFieldTitle,i=e.nodes.find(a=>a.id===vo(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=Oe(Pp,n.payload);if(!s.success||i.fields.some(a=>a.id===s.output.id))return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const r={id:s.output.id,type:s.output.type,keys:[],ref:null,nullable:s.output.nullable,cardinality:null,label:null,description:s.output.description===void 0||s.output.description===""?null:s.output.description,questions:null,status:"added",before:null};return{data:ko(e,i.id,[...i.fields,r]),result:{id:n.id,title:o,summary:t.addFieldSummary(i.id,r.id,r.type),tone:"create"}}},Yp=(t,e,n)=>{const o=t.editFieldTitle,i=e.nodes.find(g=>g.id===vo(n.target.id)),s=Oe(qp,n.payload),r=s.success?i?.fields.find(g=>g.id===s.output.field):void 0;if(i===void 0||s.success&&r===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};if(!s.success||r===void 0||r.ref!==null||r.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const{before:a,status:d,...l}=r,c={...l,type:s.output.type,nullable:s.output.nullable,description:s.output.description===void 0?l.description:s.output.description===""?null:s.output.description},h=r.before??l,p=r.status==="added"?"added":xo(h,c)?"same":"changed",u={...c,status:p,before:p==="changed"?h:null};return{data:ko(e,i.id,i.fields.map(g=>g.id===r.id?u:g)),result:{id:n.id,title:o,summary:t.editFieldSummary(i.id,r.id,c.type),tone:"update"}}},Xp=(t,e,n)=>{const o=t.deleteFieldTitle,i=e.nodes.find(c=>c.id===vo(n.target.id)),s=Oe(Fp,n.payload),r=s.success?i?.fields.find(c=>c.id===s.output.field):void 0;if(i===void 0||s.success&&r===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};if(!s.success||r===void 0||r.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const a=r.status==="added"?i.fields.filter(c=>c.id!==r.id):i.fields.map(c=>c.id===r.id?{...r,status:"removed",before:null}:c),d=Vs(e,i.id,r.id),l=d.length===0?e.edges:e.edges.filter(c=>!d.includes(c));return{data:ko({...e,edges:l},i.id,a),result:{id:n.id,title:o,summary:t.deleteFieldSummary(i.id,r.id),tone:"delete"}}},Gp=(t,e,n)=>{const o=t.editCardinalityTitle,i=e.edges.find(b=>b.id===Up(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=Oe(Bp,n.payload);if(!s.success||i.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const[r="",a=""]=s.output.cardinality.split(":"),d=Ps.get(r),l=qs.get(a);if(d===void 0||l===void 0)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const c={parent:d,child:l},h={cardinality:c,label:i.label},p=i.before??{cardinality:i.cardinality,label:i.label},u=i.status==="added"?"added":zs(p,h)?"same":"changed",g={...i,cardinality:c,status:u,before:u==="changed"?p:null};return{data:{...e,edges:e.edges.map(b=>b.id===i.id?g:b)},result:{id:n.id,title:o,summary:t.editCardinalitySummary(i.from,i.to,Et(c)),tone:"update"}}},Kp=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===Gs?Hp(t,o,s):s.type===Ks?Yp(t,o,s):s.type===js?Xp(t,o,s):s.type===Ws?Gp(t,o,s):{data:o,result:{id:s.id,title:s.type,stale:"unsupported-action-type"}};o=r.data,i.push(r.result)}return{data:o,results:i}},jp=ae`
913
+ `});return k`${this.renderEdges(s,up)}${r}`}}const Is=()=>{customElements.get("dpk-board-dependency-graph")||customElements.define("dpk-board-dependency-graph",Ls)},mp=t=>{switch(t){case"1":return{min:"one",max:"one"};case"0..1":return{min:"zero",max:"one"};case"1..N":return{min:"one",max:"many"};case"0..N":return{min:"zero",max:"many"}}},St=4,As=6,gp=12,Rs=7,fp=7,mo=13,go=14,bp=6,dn=t=>t+St-2,xp=Math.max(mo,go,dn(go)+St,dn(mo)+St),_s=(t,e)=>{const n=e==="start"?t:[...t].reverse(),[o]=n,i=n.find(r=>o!==void 0&&(r.x!==o.x||r.y!==o.y));if(o===void 0||i===void 0)return{x:e==="start"?1:-1,y:0};const s=Math.hypot(i.x-o.x,i.y-o.y);return{x:(i.x-o.x)/s,y:(i.y-o.y)/s}},yp=(t,e)=>_s(t,e),Ds=t=>Math.round(t*100)/100||0,kp=(t,e,n)=>{const o=(e==="start"?t[0]:t.at(-1))??{x:0,y:0},i=_s(t,e),s={x:-i.y,y:i.x},r=(b,f=0)=>({x:Ds(o.x+i.x*b+s.x*f),y:Ds(o.y+i.y*b+s.y*f)}),a=b=>[r(b,-As),r(b,As)],d=mp(n),l=d.max==="many"?[-Rs,0,Rs].map(b=>[r(gp),r(0,b)]):[a(fp)],c=d.max==="many"?go:mo,h=d.min==="one"?[...l,a(c)]:l,p=d.min==="zero"?r(dn(c)):null,u=(d.min==="zero"?dn(c)+St:c)+bp,g=r(u);return{segments:h,circle:p,label:{...g,anchor:i.x>=0?"start":"end"}}},ln=10,vp=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:6.2;return Math.ceil(e+2)},fo=(t,e)=>e!=null&&e!==t?`${e} ${t}`:t,Os=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height,Ns=(t,e,n)=>t.x===e.x?t.x<=n.x||t.x>=n.x+n.width?0:Math.max(0,Math.min(Math.max(t.y,e.y),n.y+n.height)-Math.max(Math.min(t.y,e.y),n.y)):t.y<=n.y||t.y>=n.y+n.height?0:Math.max(0,Math.min(Math.max(t.x,e.x),n.x+n.width)-Math.max(Math.min(t.x,e.x),n.x)),wp=t=>[[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y}],[{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],[{x:t.x,y:t.y},{x:t.x,y:t.y+t.height}],[{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height}]],bo=(t,e,n,o)=>{const i=e==="relation"?"end":e,s=i==="start"?t[0]:t.at(-1);if(s===void 0)return[];const r=yp(t,i),a={x:-r.y,y:r.x},d=Math.abs(r.x)>=Math.abs(r.y),l=vp(n),c=e==="start"?[14,20,26]:e==="end"?[4,8,12]:[14,20,26],h=[16,-16,24,-24];o&&(c.push(...c.map(u=>u+36)),h.push(32,-32));const p=[];for(const u of c)for(const g of h){const b=s.x+r.x*u+a.x*g,f=s.y+r.y*u+a.y*g;let m,y;if(d){const v=r.x>0;m=v?"start":"end",y={x:v?b:b-l,y:f-ln/2,width:l,height:ln}}else{const v=a.x*g>0;m=v?"start":"end",y={x:v?b:b-l,y:f-ln/2,width:l,height:ln}}p.push({x:b,y:f,anchor:m,box:y,along:u,across:g})}return p},$p=(t,e,n)=>{const{box:o}=t;let i=0;(o.x<0||o.y<0||o.x+o.width>e.width||o.y+o.height>e.height)&&(i+=1e7);for(const s of e.nodes)Os(o,s.box)&&(i+=1e6);for(const s of e.frames)for(const[r,a]of wp(s.box))if(Ns(r,a,o)>0){i+=1e5;break}for(const s of n)Os(o,s)&&(i+=1e5);for(const s of e.edges??[])for(let r=1;r<s.length;r++)if(Ns(s[r-1],s[r],o)>.5){i+=1e4;break}return Math.abs(t.across)<14&&(i+=1e3),i+=t.along*.1+Math.abs(t.across)*.5,i},xo=(t,e,n,o,i,s,r)=>{let a=bo(n,e,i,!1)[0],d=Number.POSITIVE_INFINITY;const l=c=>{for(const h of c){const p=$p(h,s,r);p<d&&(a=h,d=p)}};return l(bo(n,e,i,!1)),d>=1e4&&l(bo(n,e,i,!0)),{id:`${t.id}:${e}`,edge:t.id,end:e,kind:e==="relation"?"relation":"cardinality",text:o,x:a.x,y:a.y,anchor:a.anchor,box:a.box}},Ep=(t,e,n)=>{const o=[],i=new Map;for(const s of[...t].sort((r,a)=>r.id.localeCompare(a.id))){const r=e.get(s.id);if(r===void 0||r.length<2)continue;const a=s.cardinality.parent,d=s.cardinality.child,l=xo(s,"start",r,a,fo(a,s.before?.cardinality.parent),n,o);o.push(l.box);const c=xo(s,"end",r,d,fo(d,s.before?.cardinality.child),n,o);o.push(c.box);const h=s.label===null?null:xo(s,"relation",r,s.label,fo(s.label,s.before?.label),n,o);h!==null&&o.push(h.box),i.set(s.id,{start:l,end:c,relation:h})}return i},zs=(t,e)=>e?{same:"Unchanged",added:"Added",removed:"Removed",changed:"Changed"}[t]:{same:"\u5909\u66F4\u306A\u3057",added:"\u8FFD\u52A0",removed:"\u524A\u9664",changed:"\u5909\u66F4"}[t],$e=pe({en:{heading:"ER diagram",node:"Table",edge:"Relation",empty:"No matching tables.",search:"Search",legendAdded:"Added",legendRemoved:"Removed",legendChanged:"Changed",statusLabel:t=>zs(t,!0),edgeLabel:(t,e,n)=>`${t} and ${e}, related ${n}`,was:t=>`was ${t}`,nullable:"nullable",notNull:"not null",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",addFieldButton:"Add column",addFieldTitle:"Add column",addFieldName:"Column name",addFieldType:"Type",columnNameLabel:"Name",columnNamePlaceholder:"column_name",columnTypePlaceholder:"e.g. text",columnTypeChoices:"Types in this schema",columnTypeNew:"New type",columnNullable:"Allow NULL",columnNameTaken:"This table already has a column with this name.",columnDescriptionLabel:"Description",columnDescriptionPlaceholder:"optional note",cancel:"Cancel",columnAdd:"Add",columnSave:"Save",columnKeys:"Enter to confirm \xB7 Esc to cancel",addFieldSummary:(t,e,n)=>`${t}.${e} (${n})`,editFieldButton:t=>`Edit ${t}`,editFieldTitle:"Edit column",editFieldSummary:(t,e,n)=>`${t}.${e} \u2192 ${n}`,columnRole:t=>({primary:"Primary key",foreign:"Foreign key","not-null":"NOT NULL",nullable:"Nullable"})[t],changesLabel:"Changes",attributeLabel:t=>({type:"type",keys:"keys",ref:"ref",nullable:"null",cardinality:"card.",label:"label"})[t],deleteFieldButton:t=>`Delete ${t}`,deleteFieldTitle:"Delete column",deleteFieldSummary:(t,e)=>`${t}.${e}`,deleteFieldRelationsNote:t=>`Also removes ${t} relation${t===1?"":"s"}.`,editCardinalityTitle:"Edit cardinality",editCardinalityButton:"Edit cardinality",editCardinalitySummary:(t,e,n)=>`${t} \u2013 ${e}: ${n}`,cardinalityLabel:"Cardinality",patternLabel:t=>({immutable:"Immutable",mutable:"Mutable",sti:"STI",cti:"CTI","value-object":"Value Object"})[t],aggregateLabel:"Aggregate",columnFilterLabel:"Columns shown",columnFilterAll:"All",columnFilterKeys:"Keys",columnFilterTablesOnly:"Tables only",tableConstraintsLabel:"Table-level constraints",groupingLabel:"Grouping",boundedContextLabel:"Bounded Context"},ja:{heading:"ER\u56F3",node:"\u30C6\u30FC\u30D6\u30EB",edge:"\u95A2\u9023",empty:"\u8A72\u5F53\u3059\u308B\u30C6\u30FC\u30D6\u30EB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",search:"\u691C\u7D22",legendAdded:"\u8FFD\u52A0",legendRemoved:"\u524A\u9664",legendChanged:"\u5909\u66F4",statusLabel:t=>zs(t,!1),edgeLabel:(t,e,n)=>`${t} \u3068 ${e} \u306E\u95A2\u9023 (${n})`,was:t=>`\u5909\u66F4\u524D ${t}`,nullable:"NULL \u53EF",notNull:"NOT NULL",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",addFieldButton:"\u30AB\u30E9\u30E0\u3092\u8FFD\u52A0",addFieldTitle:"\u30AB\u30E9\u30E0\u3092\u8FFD\u52A0",addFieldName:"\u30AB\u30E9\u30E0\u540D",addFieldType:"\u578B",columnNameLabel:"\u540D\u524D",columnNamePlaceholder:"column_name",columnTypePlaceholder:"\u4F8B: text",columnTypeChoices:"\u3053\u306E\u30B9\u30AD\u30FC\u30DE\u306E\u578B",columnTypeNew:"\u65B0\u3057\u3044\u578B",columnNullable:"NULL \u3092\u8A31\u53EF",columnNameTaken:"\u540C\u3058\u540D\u524D\u306E\u30AB\u30E9\u30E0\u304C\u3059\u3067\u306B\u3042\u308A\u307E\u3059\u3002",columnDescriptionLabel:"\u8AAC\u660E",columnDescriptionPlaceholder:"\u88DC\u8DB3\uFF08\u4EFB\u610F\uFF09",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",columnAdd:"\u8FFD\u52A0",columnSave:"\u4FDD\u5B58",columnKeys:"Enter \u3067\u78BA\u5B9A \xB7 Esc \u3067\u9589\u3058\u308B",addFieldSummary:(t,e,n)=>`${t}.${e} (${n})`,editFieldButton:t=>`${t} \u3092\u7DE8\u96C6`,editFieldTitle:"\u30AB\u30E9\u30E0\u3092\u7DE8\u96C6",editFieldSummary:(t,e,n)=>`${t}.${e} \u2192 ${n}`,columnRole:t=>({primary:"\u4E3B\u30AD\u30FC",foreign:"\u5916\u90E8\u30AD\u30FC","not-null":"NOT NULL",nullable:"NULL \u53EF"})[t],changesLabel:"\u5909\u66F4\u70B9",attributeLabel:t=>({type:"\u578B",keys:"\u30AD\u30FC",ref:"\u53C2\u7167",nullable:"NULL",cardinality:"\u591A\u91CD\u5EA6",label:"\u30E9\u30D9\u30EB"})[t],deleteFieldButton:t=>`${t} \u3092\u524A\u9664`,deleteFieldTitle:"\u30AB\u30E9\u30E0\u3092\u524A\u9664",deleteFieldSummary:(t,e)=>`${t}.${e}`,deleteFieldRelationsNote:t=>`\u95A2\u9023 ${t} \u672C\u3082\u524A\u9664\u3055\u308C\u307E\u3059`,editCardinalityTitle:"\u591A\u91CD\u5EA6\u3092\u7DE8\u96C6",editCardinalityButton:"\u591A\u91CD\u5EA6\u3092\u7DE8\u96C6",editCardinalitySummary:(t,e,n)=>`${t} \u2013 ${e}: ${n}`,cardinalityLabel:"\u591A\u91CD\u5EA6",patternLabel:t=>({immutable:"Immutable",mutable:"Mutable",sti:"STI",cti:"CTI","value-object":"Value Object"})[t],aggregateLabel:"\u96C6\u7D04",columnFilterLabel:"\u8868\u793A\u3059\u308B\u30AB\u30E9\u30E0",columnFilterAll:"\u3059\u3079\u3066",columnFilterKeys:"\u30AD\u30FC\u306E\u307F",columnFilterTablesOnly:"\u30C6\u30FC\u30D6\u30EB\u306E\u307F",tableConstraintsLabel:"\u30C6\u30FC\u30D6\u30EB\u5236\u7D04",groupingLabel:"\u30B0\u30EB\u30FC\u30D4\u30F3\u30B0",boundedContextLabel:"\u5883\u754C\u3065\u3051\u3089\u308C\u305F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8"}}),Tp=280,yo=48,Sp=32,Mp=52,Cp=16,Lp=18,Ip=10,Ap=440,Ps=["1","0..1"],qs=["1","0..1","1..N","0..N"],ko=Ps.flatMap(t=>qs.map(e=>`${t}:${e}`)),Rp=["immutable","mutable","sti","cti","value-object"],_p=G(Rp),Fs=G(["PK","FK","UQ"]),Dp=P({id:S(x(),I(1)),type:S(x(),I(1)),key:L(Wd([Fs,S(F(Fs),I(1))])),ref:L(x()),nullable:L(yt(),!1),cardinality:L(G(ko)),label:L(S(x(),I(1))),description:L(x()),questions:L(x())}),Op=Yn("kind",[P({kind:he("unique"),columns:S(F(S(x(),I(1))),I(1))}),P({kind:he("primary-key"),columns:S(F(S(x(),I(1))),I(1))}),P({kind:he("check"),expression:S(x(),I(1))}),P({kind:he("exclude"),using:L(S(x(),I(1))),elements:S(F(S(x(),I(1))),I(1))})]),Np=P({id:S(x(),I(1)),name:S(x(),I(1)),tags:L(F(x()),[]),boundedContext:L(x()),aggregate:L(x()),pattern:L(_p),fields:F(Dp),constraints:L(F(Op),[]),questions:L(x())}),Us=P({tables:F(Np)}),zp=P({before:L(Us),after:Us}),Pp=()=>({nodes:[],edges:[]}),qp=t=>({nodes:t.nodes.map(e=>({id:e.id,width:e.width,height:e.height,...e.ports===void 0?{}:{ports:e.ports},...e.position===void 0?{}:{position:e.position},...e.group===void 0?{}:{group:e.group},...e.boundedContext===null?{}:{superGroup:e.boundedContext}})),edges:t.edges.map(e=>({id:e.id,from:e.from,to:e.to,...e.fromPort===void 0?{}:{fromPort:e.fromPort},...e.toPort===void 0?{}:{toPort:e.toPort}}))}),vo=t=>t.key===void 0?[]:[...new Set(typeof t.key=="string"?[t.key]:t.key)],Bs=t=>({id:t.id,type:t.type,keys:vo(t),ref:t.ref??null,nullable:t.nullable,cardinality:t.cardinality??null,label:t.label??null,description:t.description??null,questions:t.questions??null}),wo=(t,e)=>t.type===e.type&&t.keys.join()===e.keys.join()&&t.ref===e.ref&&t.nullable===e.nullable&&t.cardinality===e.cardinality&&t.label===e.label,Fp=t=>t.kind==="exclude"?{...t,using:t.using??null}:t,Hs=t=>{switch(t.kind){case"unique":return`UNIQUE (${t.columns.join(", ")})`;case"primary-key":return`PRIMARY KEY (${t.columns.join(", ")})`;case"check":return`CHECK (${t.expression})`;case"exclude":return`EXCLUDE${t.using===null?"":` USING ${t.using}`} (${t.elements.join(", ")})`}},Mt=t=>`${t.parent} : ${t.child}`,Ys=(t,e)=>Mt(t.cardinality)===Mt(e.cardinality)&&t.label===e.label,Up=(t,e)=>{const n=vo(e);return n.includes("UQ")?!0:n.includes("PK")&&t.fields.filter(o=>vo(o).includes("PK")).length===1},Gs=new Map(Ps.map(t=>[t,t])),Xs=new Map(qs.map(t=>[t,t])),Bp=(t,e)=>{const n=Up(t,e),o={parent:e.nullable?"0..1":"1",child:n?"0..1":"0..N"};if(e.cardinality===void 0)return o;const[i="",s=""]=e.cardinality.split(":"),r=Gs.get(i),a=Xs.get(s),d=`${t.id}.${e.id}`;if(r===void 0||a===void 0)throw new Error(`invalid cardinality on ${d}`);if(r!==o.parent)throw new Error(`cardinality "${e.cardinality}" on ${d} needs the parent end ${o.parent}: the FK is ${e.nullable?"":"not "}nullable`);if(n&&(a==="1..N"||a==="0..N"))throw new Error(`cardinality "${e.cardinality}" on ${d} allows many rows, but the column is unique`);return{parent:r,child:a}},$o=t=>(t.status==="changed"?Mp:Sp)+(t.description===null?0:Cp),Hp=t=>t.length===0?0:Ip+t.length*Lp,Ks=(t,e=[])=>yo+t.reduce((n,o)=>n+$o(o),0)+Hp(e),js=(t,e)=>{let n=yo;for(const o of t){if(o.id===e)return n+$o(o)/2;n+=$o(o)}return yo/2},Yp=14,Gp=(t,e)=>(t-(e-1)/2)*Yp,Ws=t=>{const e=new Map;for(const n of t){const o=`${n.from}.${n.sourceField}`;e.set(o,[...e.get(o)??[],n.id])}return new Map([...e.values()].flatMap(n=>n.map((o,i)=>[o,Gp(i,n.length)])))},Vs=t=>t.flatMap(e=>e.fields.flatMap(n=>{if(n.ref===void 0){if(n.cardinality!==void 0||n.label!==void 0)throw new Error(`cardinality and label on ${e.id}.${n.id} describe a relation; add its ref`);return[]}const[o,i]=n.ref.split(".");if(o===void 0||i===void 0)throw new Error(`invalid ref "${n.ref}" on ${e.id}.${n.id}; expected table.field`);return[{id:`${o}:${i}>${e.id}:${n.id}`,from:o,to:e.id,sourceField:i,targetField:n.id,cardinality:Bp(e,n),label:n.label??null}]})),Xp=(t,e)=>[...new Set([...t,...e].map(o=>o.id))].flatMap(o=>{const i=t.find(l=>l.id===o),s=e.find(l=>l.id===o),r=s??i;if(!r)return[];const a=Bs(r);if(!i)return[{...a,status:"added",before:null}];if(!s)return[{...a,status:"removed",before:null}];const d=Bs(i);return[{...a,status:wo(d,a)?"same":"changed",before:wo(d,a)?null:d}]}),Qs=(t,e)=>{const n=Ws(e),o={};for(const i of e)i.from===t.id&&(o[`${i.id}:out`]={x:t.width,y:js(t.fields,i.sourceField)+(n.get(i.id)??0)}),i.to===t.id&&(o[`${i.id}:in`]={x:0,y:js(t.fields,i.targetField)});return{...t,ports:o}},Ct=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},Kp=70,jp=20,Wp=168,Vp=t=>{const e=Ct(t.type,11),n=t.before===null||t.before.type===t.type?0:Ct(t.before.type,11)+5;return Math.min(Wp,Math.ceil(n+e))},Zs=(t,e,n=[])=>{const o=Ct(t,13)/2+100,i=Math.max(0,...e.map(r=>Ct(r.id,12)/2+Kp+jp+Vp(r))),s=Math.max(0,...n.map(r=>Ct(Hs(r),11)+24));return Math.min(Ap,Math.max(Tp,Math.ceil(Math.max(o,i,s))))},Qp=t=>{const e=ue(zp,t),n=e.before?.tables??e.after.tables,o=e.after.tables,i=[...new Set([...n,...o].map(b=>b.id))],s=new Map,r=new Map,a=new Map,d=new Map;for(const b of[...n,...o])s.set(b.id,b.tags),r.set(b.id,b.boundedContext??null),a.set(b.id,b.aggregate??null),d.set(b.id,b.pattern??null);const l=i.flatMap(b=>{const f=n.find(M=>M.id===b),m=o.find(M=>M.id===b),y=m??f;if(!y)return[];const v=Xp(f?.fields??[],m?.fields??[]),w=f?m?v.some(M=>M.status!=="same")?"changed":"same":"removed":"added",$=r.get(b)??null,A=a.get(b)??null,C=y.constraints.map(Fp);return[{id:b,name:y.name,status:w,fields:v,tags:[...s.get(b)??[],...$===null?[]:[fl($)]],boundedContext:$,aggregate:A,...A===null?{}:{group:A},pattern:d.get(b)??null,constraints:C,width:Zs(b,v,C),height:Ks(v,C),...y.questions===void 0?{}:{questions:y.questions}}]}),c=new Map(l.map(b=>[b.id,b])),h=Vs(n),p=Vs(o),g=[...new Set([...h,...p].map(b=>b.id))].flatMap(b=>{const f=h.find(C=>C.id===b),m=p.find(C=>C.id===b),y=m??f;if(!y)return[];const v=c.get(y.from),w=c.get(y.to);if(!v||!w)return[];const $=f&&m&&!Ys(f,m)?f:null,A=f?m?$?"changed":"same":"removed":"added";return[{id:b,from:y.from,to:y.to,sourceField:y.sourceField,targetField:y.targetField,cardinality:y.cardinality,label:y.label,before:$&&{cardinality:$.cardinality,label:$.label},status:A,tags:[],fromPort:`${b}:out`,toPort:`${b}:in`}]});return{nodes:l.map(b=>Qs(b,g)),edges:g}},Js="ADD_FIELD",er="EDIT_FIELD",tr="DELETE_FIELD",nr="EDIT_CARDINALITY",Zp=_({id:S(x(),ye(),I(1)),type:S(x(),ye(),I(1)),nullable:L(yt(),!1),description:L(S(x(),ye()))}),Jp=_({field:S(x(),I(1)),type:S(x(),ye(),I(1)),nullable:yt(),description:L(S(x(),ye()))}),eh=_({field:S(x(),I(1))}),th=_({cardinality:G(ko)}),Eo=t=>{const e=Ne(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},nh=t=>{const e=Ne(t);return e?.length===3&&e[1]==="edge"?e[2]??null:null},or=(t,e,n)=>t.edges.filter(o=>o.from===e&&o.sourceField===n||o.to===e&&o.targetField===n),To=(t,e,n)=>{const o=t.nodes.map(i=>{if(i.id!==e)return i;const s=i.status==="added"||i.status==="removed"?i.status:n.some(r=>r.status!=="same")?"changed":"same";return Qs({...i,status:s,fields:n,width:Zs(i.id,n,i.constraints),height:Ks(n,i.constraints)},t.edges)});return{...t,nodes:o}},oh=(t,e,n)=>{const o=t.addFieldTitle,i=e.nodes.find(a=>a.id===Eo(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=re(Zp,n.payload);if(!s.success||i.fields.some(a=>a.id===s.output.id))return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const r={id:s.output.id,type:s.output.type,keys:[],ref:null,nullable:s.output.nullable,cardinality:null,label:null,description:s.output.description===void 0||s.output.description===""?null:s.output.description,questions:null,status:"added",before:null};return{data:To(e,i.id,[...i.fields,r]),result:{id:n.id,title:o,summary:t.addFieldSummary(i.id,r.id,r.type),tone:"create"}}},ih=(t,e,n)=>{const o=t.editFieldTitle,i=e.nodes.find(g=>g.id===Eo(n.target.id)),s=re(Jp,n.payload),r=s.success?i?.fields.find(g=>g.id===s.output.field):void 0;if(i===void 0||s.success&&r===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};if(!s.success||r===void 0||r.ref!==null||r.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const{before:a,status:d,...l}=r,c={...l,type:s.output.type,nullable:s.output.nullable,description:s.output.description===void 0?l.description:s.output.description===""?null:s.output.description},h=r.before??l,p=r.status==="added"?"added":wo(h,c)?"same":"changed",u={...c,status:p,before:p==="changed"?h:null};return{data:To(e,i.id,i.fields.map(g=>g.id===r.id?u:g)),result:{id:n.id,title:o,summary:t.editFieldSummary(i.id,r.id,c.type),tone:"update"}}},sh=(t,e,n)=>{const o=t.deleteFieldTitle,i=e.nodes.find(c=>c.id===Eo(n.target.id)),s=re(eh,n.payload),r=s.success?i?.fields.find(c=>c.id===s.output.field):void 0;if(i===void 0||s.success&&r===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};if(!s.success||r===void 0||r.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const a=r.status==="added"?i.fields.filter(c=>c.id!==r.id):i.fields.map(c=>c.id===r.id?{...r,status:"removed",before:null}:c),d=or(e,i.id,r.id),l=d.length===0?e.edges:e.edges.filter(c=>!d.includes(c));return{data:To({...e,edges:l},i.id,a),result:{id:n.id,title:o,summary:t.deleteFieldSummary(i.id,r.id),tone:"delete"}}},rh=(t,e,n)=>{const o=t.editCardinalityTitle,i=e.edges.find(b=>b.id===nh(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=re(th,n.payload);if(!s.success||i.status==="removed")return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const[r="",a=""]=s.output.cardinality.split(":"),d=Gs.get(r),l=Xs.get(a);if(d===void 0||l===void 0)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const c={parent:d,child:l},h={cardinality:c,label:i.label},p=i.before??{cardinality:i.cardinality,label:i.label},u=i.status==="added"?"added":Ys(p,h)?"same":"changed",g={...i,cardinality:c,status:u,before:u==="changed"?p:null};return{data:{...e,edges:e.edges.map(b=>b.id===i.id?g:b)},result:{id:n.id,title:o,summary:t.editCardinalitySummary(i.from,i.to,Mt(c)),tone:"update"}}},ah=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===Js?oh(t,o,s):s.type===er?ih(t,o,s):s.type===tr?sh(t,o,s):s.type===nr?rh(t,o,s):{data:o,result:{id:s.id,title:s.type,stale:"unsupported-action-type"}};o=r.data,i.push(r.result)}return{data:o,results:i}},dh=de`
914
914
  .er-search {
915
915
  display: flex;
916
916
  align-items: center;
@@ -1935,7 +1935,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
1935
1935
  padding: 0 10px;
1936
1936
  font-size: 10.5px;
1937
1937
  }
1938
- `,Wp=(t,e,n=!1)=>[[t.type,t.ref===null?null:`\u2192 ${t.ref}`].filter(Boolean).join(" "),n&&t.keys.length>0?t.keys.join("+"):null,t.cardinality,t.label===null?null:`\u201C${t.label}\u201D`,t.nullable?e.nullable:null].filter(Boolean).join(" \xB7 "),dn="\u2014",Vp=(t,e)=>{const n=t.before;return n===null?[]:[["type",i=>i.type],["keys",i=>i.keys.length===0?dn:i.keys.join("+")],["ref",i=>i.ref??dn],["nullable",i=>i.nullable?e.nullable:e.notNull],["cardinality",i=>i.cardinality??dn],["label",i=>i.label===null?dn:`\u201C${i.label}\u201D`]].flatMap(([i,s])=>s(n)===s(t)?[]:[{attribute:i,before:s(n),after:s(t)}])},Qp=(t,e)=>t!==void 0&&JSON.stringify(t.base)===JSON.stringify(e)?t.draft:e,Qs=t=>[...new Set(t.nodes.flatMap(e=>e.fields.map(n=>n.type)))].sort(),Zs=(t,e,n)=>{const o=e.trim(),i=o.toLowerCase(),s=t.findIndex(d=>d.toLowerCase()===i),r=i===""||s!==-1?t.map(d=>({kind:"schema",type:d})):[...t.filter(d=>d.toLowerCase().startsWith(i)),...t.filter(d=>!d.toLowerCase().startsWith(i)&&d.toLowerCase().includes(i))].map(d=>({kind:"schema",type:d})).concat({kind:"new",type:o});if(r.length===0)return{options:r,active:-1};const a=n??Math.max(0,s);return{options:r,active:(a%r.length+r.length)%r.length}},Js=(t,e)=>{const n=t.type.trim();if(t.kind==="add"){const r=t.name.trim();return e.fields.some(a=>a.id===r)?{ready:!1,issue:"name-taken"}:{ready:r!==""&&n!=="",issue:null}}const o=e.fields.find(r=>r.id===t.field);if(o!==void 0&&o.ref!==null)return{ready:!1,issue:null};const i=t.description.trim(),s=o===void 0||n!==o.type||t.nullable!==o.nullable||i!==(o.description??"");return{ready:n!==""&&s,issue:null}},Zp=t=>t.keys.includes("PK")?"primary":t.keys.includes("FK")||t.ref!==null?"foreign":t.nullable?"nullable":"not-null",er=(t,e)=>e.kind==="relation"?t.id===e.id:e.kind==="table"?t.from===e.id||t.to===e.id:t.from===e.table&&t.sourceField===e.field||t.to===e.table&&t.targetField===e.field,Jp=(t,e)=>{const n=e.map(r=>r.kind==="column"&&!t.some(a=>er(a,r))?{kind:"table",id:r.table}:r),o=new Set(n.flatMap(r=>r.kind==="relation"?[]:[r.kind==="table"?r.id:r.table])),i=new Set,s=new Set;for(const r of t)n.some(a=>er(r,a))&&(i.add(r.id),o.add(r.from).add(r.to),s.add(`${r.from}.${r.sourceField}`).add(`${r.to}.${r.targetField}`));return{tables:o,edges:i,columns:s}},eh=t=>`${t.parent}:${t.child}`,tr=18,nr=22,wo=30,$o=46,th=160,nh=120,oh=(t,e,n)=>{const o=Math.min(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:o-e,y:i-e-n,width:s-o+e*2,height:r-i+e*2+n}},or=(t,e,n,o)=>{const i=new Map;for(const s of t){const r=e(s);r===null||s.box===null||i.set(r,[...i.get(r)??[],{id:s.id,box:s.box}])}return[...i].map(([s,r])=>({key:s,tables:r.map(a=>a.id),box:oh(r.map(a=>a.box),n,o)}))},Eo=t=>or(t,e=>e.aggregate,tr,nr).map(e=>({aggregate:e.key,box:e.box,tables:e.tables})),ln=t=>or(t,e=>e.boundedContext,wo,$o).map(e=>({boundedContext:e.key,box:e.box,tables:e.tables})),ir=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),st=(t,e,n)=>Math.min(n,Math.max(e,t)),sr=(t,e)=>{const n=ir(t),o=ir(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},te=12,rr=(t,e,n)=>{const o=st(n.y-t.y,te,Math.max(te,t.height-te)),i=t.height<=0?.5:o/t.height,s=t.x+st(i*t.width,te,Math.max(te,t.width-te));switch(e){case"left":return{x:t.x,y:t.y+o};case"right":return{x:t.x+t.width,y:t.y+o};case"top":return{x:s,y:t.y};case"bottom":return{x:s,y:t.y+t.height};default:return{x:t.x+t.width,y:t.y+o}}},ih=(t,e,n)=>{const o=e[0],i=e.at(-1);if(o===void 0||i===void 0||t.from===t.to)return null;const s=n.find(l=>l.id===t.from)?.box,r=n.find(l=>l.id===t.to)?.box;if(s===void 0||r===void 0)return null;const a=sr(s,r),d=sr(r,s);return{start:rr(s,a,o),end:rr(r,d,i),startSide:a,endSide:d,source:s,target:r}},ze=ip,ar=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},sh=(t,e,n,o,i=[],s=[],r=[])=>so(t,e,n,o,i,s,r),St=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},rh=(t,e,n,o,i)=>{const s=n.find(f=>f.id===t.from)?.box,r=e[0],a=e.at(-1);if(s===void 0||r===void 0||a===void 0)return e;const d=st(r.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),l=st(a.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),c=st(r.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),h=st(a.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),p=n.filter(f=>f.id!==t.from).map(f=>f.box),u=o+ze,g=[St([{x:s.x+s.width,y:d},{x:s.x+s.width+u,y:d},{x:s.x+s.width+u,y:l},{x:s.x+s.width,y:l}]),St([{x:s.x,y:d},{x:s.x-u,y:d},{x:s.x-u,y:l},{x:s.x,y:l}]),St([{x:c,y:s.y+s.height},{x:c,y:s.y+s.height+u},{x:h,y:s.y+s.height+u},{x:h,y:s.y+s.height}]),St([{x:c,y:s.y},{x:c,y:s.y-u},{x:h,y:s.y-u},{x:h,y:s.y}])].filter(f=>f.slice(1).map((x,k)=>[f[k],x]).every(([x,k])=>x.x===k.x?!me(x.x,Math.min(x.y,k.y),Math.max(x.y,k.y),p):!ge(x.y,Math.min(x.x,k.x),Math.max(x.x,k.x),p)));return g.length===0?e:g.reduce((f,m)=>{const x=no(f,i),k=no(m,i);if(x!==k)return k<x?m:f;const w=ss(f,i),$=ss(m,i);return w!==$?$<w?m:f:m.length<f.length?m:f})},dr=(t,e,n,o,i=[],s=[])=>{if(t.from===t.to)return rh(t,e,n,o,s);const r=ih(t,e,n);if(r===null)return e;const a=n.filter(L=>L.id!==t.from&&L.id!==t.to).map(L=>L.box),d=n.filter(L=>L.id===t.from||L.id===t.to).map(L=>L.box),l=i.filter(L=>L.members.includes(t.from)||L.members.includes(t.to)).map(L=>L.box),c=o*12,h=Math.min(r.start.x,r.end.x)-c,p=Math.max(r.start.x,r.end.x)+c,u=Math.min(r.start.y,r.end.y)-c,g=Math.max(r.start.y,r.end.y)+c,b=i.filter(L=>L.box.x<p&&L.box.x+L.box.width>h&&L.box.y<g&&L.box.y+L.box.height>u).map(L=>L.box),f=[...new Set([...d,...l,...b])],m=ar(r.startSide),x=ar(r.endSide),k={x:r.start.x+m.x*ze,y:r.start.y+m.y*ze},w={x:r.end.x+x.x*ze,y:r.end.y+x.y*ze},$=sh(k,w,a,o,s,f,d);return St([r.start,...$,r.end])},ah=t=>t.slice(1).map((e,n)=>[t[n],e]),dh=t=>{const e=t[0],n=t.at(-1);return e===void 0||n===void 0?0:Math.abs(n.x-e.x)+Math.abs(n.y-e.y)},lh=(t,e,n,o,i=[])=>{const s=p=>dh(e.get(p.id)??[]),r=new Map;for(const p of t){const u=r.get(p.from);(u===void 0||s(p)<u)&&r.set(p.from,s(p))}const a=[...t].sort((p,u)=>(r.get(p.from)??0)-(r.get(u.from)??0)||p.from.localeCompare(u.from)||s(u)-s(p)||p.id.localeCompare(u.id)),d=(p,u)=>dr(p,e.get(p.id)??[],n,o,i,u),l=new Map,c=[];for(const p of a){const u=d(p,c);l.set(p.id,u),c.push(...ah(u))}const h=t.map(p=>{const u=n.filter(f=>f.id!==p.from&&f.id!==p.to).map(f=>f.box),g=n.filter(f=>f.id===p.from||f.id===p.to).map(f=>f.box),b=[];for(const f of i)(f.members.includes(p.from)||f.members.includes(p.to)?g:b).push(f.box);return{id:p.id,points:l.get(p.id)??[],obstacles:[...u,...b],ownFrames:g}});return ao(h,{minPortRun:ze})},ch=10,ph=(t,e,n=ze)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0||!hh(t))return uh(t,ch,n);const s=[`M${we(o)}`];let r=o;const a=d=>{(d.x!==r.x||d.y!==r.y)&&s.push(`L${we(d)}`),r=d};for(let d=1;d+1<t.length;d+=2){const l=t[d],c=t[d+1];if(l===void 0||c===void 0)continue;const h=(x,k)=>k?x/2:x,p=d===1,u=d+2===t.length-1,g=(x,k)=>k?Math.max(0,x-n):x,b=g(h(l.x-(t[d-1]?.x??l.x),d-1>0),p),f=g(h((t[d+2]?.x??c.x)-c.x,d+2<t.length-1),u),m=rt(Math.min(e,b,f));if(m===0){a(l),a(c);continue}a({x:rt(l.x-m),y:l.y}),s.push(`C${we(l)} ${we(c)} ${rt(c.x+m)} ${c.y}`),r={x:rt(c.x+m),y:c.y}}return a(i),s.join(" ")},hh=t=>t.length>=2&&t.length%2===0&&t.every((e,n)=>{const o=t[n-1];return o===void 0?!0:n%2===1?e.y===o.y&&e.x>=o.x:e.x===o.x})&&(t.at(-1)?.x??0)>(t[0]?.x??0),we=t=>`${t.x} ${t.y}`,uh=(t,e,n=ze)=>{const[o,...i]=t;if(o===void 0)return"";const s=[`M${we(o)}`];return i.forEach((r,a)=>{const d=t[a]??r,l=i[a+1];if(l===void 0){s.push(`L${we(r)}`);return}const c=Math.hypot(r.x-d.x,r.y-d.y),h=Math.hypot(l.x-r.x,l.y-r.y),p=a===0?c-n:c,u=i[a+2]===void 0?h-n:h,g=Math.min(e,c/2,h/2,p,u);if(g<=0){s.push(`L${we(r)}`);return}const b=(f,m,x)=>({x:rt(f.x+(m.x-f.x)/x*g),y:rt(f.y+(m.y-f.y)/x*g)});s.push(`L${we(b(r,d,c))}`,`Q${we(r)} ${we(b(r,l,h))}`)}),s.join(" ")},rt=t=>Math.round(t*100)/100||0,To={nodeSpacing:40,layerSpacing:136,padding:wo+$o+4,groupSpacing:tr*2+nr+12,superGroupSpacing:wo*2+$o+12,superGroupRowGap:th,superGroupColumnGap:nh},lr=To.nodeSpacing/2,mh=To.layerSpacing/2,gh='[data-action="add-field"], [data-action="edit-field"]',cr={same:"",added:"+",removed:"\u2212",changed:"~"},fh={primary:Pd,foreign:mi,"not-null":ui,nullable:ui},bh=(t,e)=>t.keys.filter(n=>!(e==="primary"&&n==="PK")&&!(e==="foreign"&&n==="FK")),xh=.5,yh=(t,e,n)=>{if(t===void 0||Math.abs(t.height-e.height)>n||Math.abs(t.head-e.head)>n)return!1;const o=Object.keys(t.rows),i=Object.keys(e.rows);return o.length!==i.length?!1:i.every(s=>{const r=t.rows[s];return r!==void 0&&Math.abs(r-e.rows[s])<=n})};class pr extends nt{static{this.styles=[De,jp,sl]}#o="";#i=null;#e=null;#n=null;#t=new Map;#a=null;#r=new Map;#s=!1;#d=null;#c=new Set;#p=new pi(this);#u=new hi(this);#h=null;#l="all";#m=!0;#g=!0;#f=null;#y=null;constructor(){super(),new zd(this,{open:()=>this.#e!==null,closesOn:e=>!e.some(n=>n instanceof Element&&n.matches(`.er-editor, ${gh}`)),ownsEscape:()=>!1,dismiss:()=>this.#D(!1,!1)})}disconnectedCallback(){this.#d?.disconnect(),this.#d=null,this.#c.clear(),super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),this.#i!==null&&!this.#b(this.#i)&&(this.#i=null);const n=this.selection;if(n!==null&&n.kind==="edge"&&this.#I){if(this.#h===null||this.#h.edge!==n.id){const o=this.visible.edges.find(i=>i.id===n.id);this.#h=o===void 0?null:{edge:o.id,cardinality:eh(o.cardinality),failed:!1}}}else this.#h!==null&&(this.#h=null)}updated(){super.updated(),this.#q(),this.#B(),typeof ResizeObserver<"u"&&(this.#d??=new ResizeObserver(()=>this.#k())),this.#C(),this.#k()}#C(){if(this.#d===null)return;const e=new Set;for(const n of this.renderRoot.querySelectorAll(".er-table")){e.add(n);for(const o of n.querySelectorAll(".er-field"))e.add(o)}for(const n of this.#c)e.has(n)||(this.#d.unobserve(n),this.#c.delete(n));for(const n of e)this.#c.has(n)||(this.#d.observe(n),this.#c.add(n))}#k(){let e=!1;for(const n of this.renderRoot.querySelectorAll(".er-table")){const o=n.dataset.erTable,i=n.getBoundingClientRect();if(o===void 0||i.width===0)continue;const s=i.width/n.offsetWidth,r=c=>Math.round(c*64)/64,a=c=>{const h=c?.getBoundingClientRect();return h===void 0?0:r((h.top+h.height/2-i.top)/s)},d={};for(const c of n.querySelectorAll(".er-field[data-field]")){const h=c.dataset.field;h!==void 0&&(d[h]=a(c.querySelector(".er-field-line")??c))}const l={height:r(i.height/s),head:a(n.querySelector(".er-head")),rows:d};yh(this.#r.get(o),l,xh)||(this.#r.set(o,l),e=!0)}e&&(this.requestUpdate(),!this.#s&&(this.#s=!0,this.updateComplete.then(()=>this.fitViewport())))}layoutSignature(){return JSON.stringify([...this.#r])}#v(){const e=this.tagFilter.active.filter(n=>n.startsWith(Xt));return e.length===0?null:{...this.tagFilter,active:e}}filtered(){const e=this.items(),o=this.#v()===null?this.tagFilter:{...this.tagFilter,active:this.tagFilter.active.filter(d=>!d.startsWith(Xt))},i=e.nodes.filter(d=>Ce(d.tags,o)&&this.matchesFilter(d)),s=new Set(i.map(d=>d.id)),r={...e,nodes:i,edges:e.edges.filter(d=>s.has(d.from)&&s.has(d.to))},a=Us(r.edges);return{...r,nodes:r.nodes.map(d=>{const l=this.#r.get(d.id);if(!l)return d;const c={...d.ports};for(const h of r.edges){if(h.from===d.id&&h.fromPort!==void 0){const p=l.rows[h.sourceField]??l.head;c[h.fromPort]={x:d.width,y:p+(a.get(h.id)??0)}}h.to===d.id&&h.toPort!==void 0&&(c[h.toPort]={x:0,y:l.rows[h.targetField]??l.head})}return{...d,height:l.height,ports:c}})}}parseData(e){return zp(e)}reduceElementActions(e,n){return Kp(ke(this.locale),e,n)}emptyData(){return Ep()}defaultHeading(){return ke(this.locale).heading}statsLabels(){const e=ke(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return ke(this.locale).empty}layoutOptions(){return To}computePlacement(e){const{nodes:n,edges:o}=Tp(e),i=this.layoutOptions();return this.layoutMode==="fixed"?Hi(n,o,i):Ri(n,o,i)}focusBounds(){const e=this.#v();if(e===null)return null;const n=new Set(e.active.map(d=>d.slice(Xt.length))),o=ln(this.visible.nodes.map(d=>({id:d.id,boundedContext:d.boundedContext,box:this.placedNode(d.id)??null}))).filter(d=>n.has(d.boundedContext)).map(d=>d.box);if(o.length===0)return null;const i=Math.min(...o.map(d=>d.x)),s=Math.min(...o.map(d=>d.y)),r=Math.max(...o.map(d=>d.x+d.width)),a=Math.max(...o.map(d=>d.y+d.height));return{x:i,y:s,width:r-i,height:a-s}}focusKey(){return this.#v()?.active.join(",")??null}initialView(){this.fitViewport()}onMaximizeChange(){(this.renderRoot.querySelector("dpk-dialog-panel")?.updateComplete??Promise.resolve(!0)).then(()=>this.fitViewport())}matchesFilter(e){return this.#o===""?!0:[e.id,e.name,...e.fields.map(n=>n.id)].some(n=>n.toLowerCase().includes(this.#o))}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items();return[...e.nodes.map(n=>({value:this.commentRef("node",n.id),label:`${n.id} \xB7 ${n.name}`})),...e.edges.map(n=>({value:this.commentRef("edge",n.id),label:`${n.from}.${n.sourceField} \u2192 ${n.to}.${n.targetField}`}))]}renderToolbarActions(){const e=ke(this.locale);return v`
1938
+ `,lh=(t,e,n=!1)=>[[t.type,t.ref===null?null:`\u2192 ${t.ref}`].filter(Boolean).join(" "),n&&t.keys.length>0?t.keys.join("+"):null,t.cardinality,t.label===null?null:`\u201C${t.label}\u201D`,t.nullable?e.nullable:null].filter(Boolean).join(" \xB7 "),cn="\u2014",ch=(t,e)=>{const n=t.before;return n===null?[]:[["type",i=>i.type],["keys",i=>i.keys.length===0?cn:i.keys.join("+")],["ref",i=>i.ref??cn],["nullable",i=>i.nullable?e.nullable:e.notNull],["cardinality",i=>i.cardinality??cn],["label",i=>i.label===null?cn:`\u201C${i.label}\u201D`]].flatMap(([i,s])=>s(n)===s(t)?[]:[{attribute:i,before:s(n),after:s(t)}])},ph=(t,e)=>t!==void 0&&JSON.stringify(t.base)===JSON.stringify(e)?t.draft:e,ir=t=>[...new Set(t.nodes.flatMap(e=>e.fields.map(n=>n.type)))].sort(),sr=(t,e,n)=>{const o=e.trim(),i=o.toLowerCase(),s=t.findIndex(d=>d.toLowerCase()===i),r=i===""||s!==-1?t.map(d=>({kind:"schema",type:d})):[...t.filter(d=>d.toLowerCase().startsWith(i)),...t.filter(d=>!d.toLowerCase().startsWith(i)&&d.toLowerCase().includes(i))].map(d=>({kind:"schema",type:d})).concat({kind:"new",type:o});if(r.length===0)return{options:r,active:-1};const a=n??Math.max(0,s);return{options:r,active:(a%r.length+r.length)%r.length}},rr=(t,e)=>{const n=t.type.trim();if(t.kind==="add"){const r=t.name.trim();return e.fields.some(a=>a.id===r)?{ready:!1,issue:"name-taken"}:{ready:r!==""&&n!=="",issue:null}}const o=e.fields.find(r=>r.id===t.field);if(o!==void 0&&o.ref!==null)return{ready:!1,issue:null};const i=t.description.trim(),s=o===void 0||n!==o.type||t.nullable!==o.nullable||i!==(o.description??"");return{ready:n!==""&&s,issue:null}},hh=t=>t.keys.includes("PK")?"primary":t.keys.includes("FK")||t.ref!==null?"foreign":t.nullable?"nullable":"not-null",ar=(t,e)=>e.kind==="relation"?t.id===e.id:e.kind==="table"?t.from===e.id||t.to===e.id:t.from===e.table&&t.sourceField===e.field||t.to===e.table&&t.targetField===e.field,uh=(t,e)=>{const n=e.map(r=>r.kind==="column"&&!t.some(a=>ar(a,r))?{kind:"table",id:r.table}:r),o=new Set(n.flatMap(r=>r.kind==="relation"?[]:[r.kind==="table"?r.id:r.table])),i=new Set,s=new Set;for(const r of t)n.some(a=>ar(r,a))&&(i.add(r.id),o.add(r.from).add(r.to),s.add(`${r.from}.${r.sourceField}`).add(`${r.to}.${r.targetField}`));return{tables:o,edges:i,columns:s}},mh=t=>`${t.parent}:${t.child}`,dr=18,lr=22,So=30,Mo=46,gh=160,fh=120,bh=(t,e,n)=>{const o=Math.min(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:o-e,y:i-e-n,width:s-o+e*2,height:r-i+e*2+n}},cr=(t,e,n,o)=>{const i=new Map;for(const s of t){const r=e(s);r===null||s.box===null||i.set(r,[...i.get(r)??[],{id:s.id,box:s.box}])}return[...i].map(([s,r])=>({key:s,tables:r.map(a=>a.id),box:bh(r.map(a=>a.box),n,o)}))},Co=t=>cr(t,e=>e.aggregate,dr,lr).map(e=>({aggregate:e.key,box:e.box,tables:e.tables})),pn=t=>cr(t,e=>e.boundedContext,So,Mo).map(e=>({boundedContext:e.key,box:e.box,tables:e.tables})),pr=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),lt=(t,e,n)=>Math.min(n,Math.max(e,t)),hr=(t,e)=>{const n=pr(t),o=pr(e),i=o.x-n.x,s=o.y-n.y;return Math.abs(i)>=Math.abs(s)?i>=0?"right":"left":s>=0?"bottom":"top"},te=12,ur=(t,e,n)=>{const o=lt(n.y-t.y,te,Math.max(te,t.height-te)),i=t.height<=0?.5:o/t.height,s=t.x+lt(i*t.width,te,Math.max(te,t.width-te));switch(e){case"left":return{x:t.x,y:t.y+o};case"right":return{x:t.x+t.width,y:t.y+o};case"top":return{x:s,y:t.y};case"bottom":return{x:s,y:t.y+t.height};default:return{x:t.x+t.width,y:t.y+o}}},xh=(t,e,n)=>{const o=e[0],i=e.at(-1);if(o===void 0||i===void 0||t.from===t.to)return null;const s=n.find(l=>l.id===t.from)?.box,r=n.find(l=>l.id===t.to)?.box;if(s===void 0||r===void 0)return null;const a=hr(s,r),d=hr(r,s);return{start:ur(s,a,o),end:ur(r,d,i),startSide:a,endSide:d,source:s,target:r}},Pe=xp,mr=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},yh=(t,e,n,o,i=[],s=[],r=[])=>co(t,e,n,o,i,s,r),Lt=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},kh=(t,e,n,o,i)=>{const s=n.find(f=>f.id===t.from)?.box,r=e[0],a=e.at(-1);if(s===void 0||r===void 0||a===void 0)return e;const d=lt(r.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),l=lt(a.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),c=lt(r.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),h=lt(a.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),p=n.filter(f=>f.id!==t.from).map(f=>f.box),u=o+Pe,g=[Lt([{x:s.x+s.width,y:d},{x:s.x+s.width+u,y:d},{x:s.x+s.width+u,y:l},{x:s.x+s.width,y:l}]),Lt([{x:s.x,y:d},{x:s.x-u,y:d},{x:s.x-u,y:l},{x:s.x,y:l}]),Lt([{x:c,y:s.y+s.height},{x:c,y:s.y+s.height+u},{x:h,y:s.y+s.height+u},{x:h,y:s.y+s.height}]),Lt([{x:c,y:s.y},{x:c,y:s.y-u},{x:h,y:s.y-u},{x:h,y:s.y}])].filter(f=>f.slice(1).map((y,v)=>[f[v],y]).every(([y,v])=>y.x===v.x?!ge(y.x,Math.min(y.y,v.y),Math.max(y.y,v.y),p):!fe(y.y,Math.min(y.x,v.x),Math.max(y.x,v.x),p)));return g.length===0?e:g.reduce((f,m)=>{const y=ro(f,i),v=ro(m,i);if(y!==v)return v<y?m:f;const w=hs(f,i),$=hs(m,i);return w!==$?$<w?m:f:m.length<f.length?m:f})},gr=(t,e,n,o,i=[],s=[])=>{if(t.from===t.to)return kh(t,e,n,o,s);const r=xh(t,e,n);if(r===null)return e;const a=n.filter(A=>A.id!==t.from&&A.id!==t.to).map(A=>A.box),d=n.filter(A=>A.id===t.from||A.id===t.to).map(A=>A.box),l=i.filter(A=>A.members.includes(t.from)||A.members.includes(t.to)).map(A=>A.box),c=o*12,h=Math.min(r.start.x,r.end.x)-c,p=Math.max(r.start.x,r.end.x)+c,u=Math.min(r.start.y,r.end.y)-c,g=Math.max(r.start.y,r.end.y)+c,b=i.filter(A=>A.box.x<p&&A.box.x+A.box.width>h&&A.box.y<g&&A.box.y+A.box.height>u).map(A=>A.box),f=[...new Set([...d,...l,...b])],m=mr(r.startSide),y=mr(r.endSide),v={x:r.start.x+m.x*Pe,y:r.start.y+m.y*Pe},w={x:r.end.x+y.x*Pe,y:r.end.y+y.y*Pe},$=yh(v,w,a,o,s,f,d);return Lt([r.start,...$,r.end])},vh=t=>t.slice(1).map((e,n)=>[t[n],e]),wh=t=>{const e=t[0],n=t.at(-1);return e===void 0||n===void 0?0:Math.abs(n.x-e.x)+Math.abs(n.y-e.y)},$h=(t,e,n,o,i=[])=>{const s=p=>wh(e.get(p.id)??[]),r=new Map;for(const p of t){const u=r.get(p.from);(u===void 0||s(p)<u)&&r.set(p.from,s(p))}const a=[...t].sort((p,u)=>(r.get(p.from)??0)-(r.get(u.from)??0)||p.from.localeCompare(u.from)||s(u)-s(p)||p.id.localeCompare(u.id)),d=(p,u)=>gr(p,e.get(p.id)??[],n,o,i,u),l=new Map,c=[];for(const p of a){const u=d(p,c);l.set(p.id,u),c.push(...vh(u))}const h=t.map(p=>{const u=n.filter(f=>f.id!==p.from&&f.id!==p.to).map(f=>f.box),g=n.filter(f=>f.id===p.from||f.id===p.to).map(f=>f.box),b=[];for(const f of i)(f.members.includes(p.from)||f.members.includes(p.to)?g:b).push(f.box);return{id:p.id,points:l.get(p.id)??[],obstacles:[...u,...b],ownFrames:g}});return ho(h,{minPortRun:Pe})},Eh=10,Th=(t,e,n=Pe)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0||!Sh(t))return Mh(t,Eh,n);const s=[`M${Ee(o)}`];let r=o;const a=d=>{(d.x!==r.x||d.y!==r.y)&&s.push(`L${Ee(d)}`),r=d};for(let d=1;d+1<t.length;d+=2){const l=t[d],c=t[d+1];if(l===void 0||c===void 0)continue;const h=(y,v)=>v?y/2:y,p=d===1,u=d+2===t.length-1,g=(y,v)=>v?Math.max(0,y-n):y,b=g(h(l.x-(t[d-1]?.x??l.x),d-1>0),p),f=g(h((t[d+2]?.x??c.x)-c.x,d+2<t.length-1),u),m=ct(Math.min(e,b,f));if(m===0){a(l),a(c);continue}a({x:ct(l.x-m),y:l.y}),s.push(`C${Ee(l)} ${Ee(c)} ${ct(c.x+m)} ${c.y}`),r={x:ct(c.x+m),y:c.y}}return a(i),s.join(" ")},Sh=t=>t.length>=2&&t.length%2===0&&t.every((e,n)=>{const o=t[n-1];return o===void 0?!0:n%2===1?e.y===o.y&&e.x>=o.x:e.x===o.x})&&(t.at(-1)?.x??0)>(t[0]?.x??0),Ee=t=>`${t.x} ${t.y}`,Mh=(t,e,n=Pe)=>{const[o,...i]=t;if(o===void 0)return"";const s=[`M${Ee(o)}`];return i.forEach((r,a)=>{const d=t[a]??r,l=i[a+1];if(l===void 0){s.push(`L${Ee(r)}`);return}const c=Math.hypot(r.x-d.x,r.y-d.y),h=Math.hypot(l.x-r.x,l.y-r.y),p=a===0?c-n:c,u=i[a+2]===void 0?h-n:h,g=Math.min(e,c/2,h/2,p,u);if(g<=0){s.push(`L${Ee(r)}`);return}const b=(f,m,y)=>({x:ct(f.x+(m.x-f.x)/y*g),y:ct(f.y+(m.y-f.y)/y*g)});s.push(`L${Ee(b(r,d,c))}`,`Q${Ee(r)} ${Ee(b(r,l,h))}`)}),s.join(" ")},ct=t=>Math.round(t*100)/100||0,Lo={nodeSpacing:40,layerSpacing:136,padding:So+Mo+4,groupSpacing:dr*2+lr+12,superGroupSpacing:So*2+Mo+12,superGroupRowGap:gh,superGroupColumnGap:fh},fr=Lo.nodeSpacing/2,Ch=Lo.layerSpacing/2,Lh='[data-action="add-field"], [data-action="edit-field"]',br={same:"",added:"+",removed:"\u2212",changed:"~"},Ih={primary:Qd,foreign:yi,"not-null":xi,nullable:xi},Ah=(t,e)=>t.keys.filter(n=>!(e==="primary"&&n==="PK")&&!(e==="foreign"&&n==="FK")),Rh=.5,_h=(t,e,n)=>{if(t===void 0||Math.abs(t.height-e.height)>n||Math.abs(t.head-e.head)>n)return!1;const o=Object.keys(t.rows),i=Object.keys(e.rows);return o.length!==i.length?!1:i.every(s=>{const r=t.rows[s];return r!==void 0&&Math.abs(r-e.rows[s])<=n})};class xr extends rt{static{this.styles=[ze,dh,xl]}#o="";#i=null;#e=null;#t=null;#n=new Map;#a=null;#r=new Map;#s=!1;#d=null;#c=new Set;#h=new fi(this);#p=new bi(this);#u=null;#l="all";#m=!0;#g=!0;#f=null;#x=null;constructor(){super(),new Vd(this,{open:()=>this.#e!==null,closesOn:e=>!e.some(n=>n instanceof Element&&n.matches(`.er-editor, ${Lh}`)),ownsEscape:()=>!1,dismiss:()=>this.#q(!1,!1)})}disconnectedCallback(){this.#d?.disconnect(),this.#d=null,this.#c.clear(),super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),this.#i!==null&&!this.#b(this.#i)&&(this.#i=null);const n=this.selection;if(n!==null&&n.kind==="edge"&&this.#S){if(this.#u===null||this.#u.edge!==n.id){const o=this.visible.edges.find(i=>i.id===n.id);this.#u=o===void 0?null:{edge:o.id,cardinality:mh(o.cardinality),failed:!1}}}else this.#u!==null&&(this.#u=null)}updated(){super.updated(),this.#U(),this.#H(),typeof ResizeObserver<"u"&&(this.#d??=new ResizeObserver(()=>this.#E())),this.#A(),this.#E()}#A(){if(this.#d===null)return;const e=new Set;for(const n of this.renderRoot.querySelectorAll(".er-table")){e.add(n);for(const o of n.querySelectorAll(".er-field"))e.add(o)}for(const n of this.#c)e.has(n)||(this.#d.unobserve(n),this.#c.delete(n));for(const n of e)this.#c.has(n)||(this.#d.observe(n),this.#c.add(n))}#E(){let e=!1;for(const n of this.renderRoot.querySelectorAll(".er-table")){const o=n.dataset.erTable,i=n.getBoundingClientRect();if(o===void 0||i.width===0)continue;const s=i.width/n.offsetWidth,r=c=>Math.round(c*64)/64,a=c=>{const h=c?.getBoundingClientRect();return h===void 0?0:r((h.top+h.height/2-i.top)/s)},d={};for(const c of n.querySelectorAll(".er-field[data-field]")){const h=c.dataset.field;h!==void 0&&(d[h]=a(c.querySelector(".er-field-line")??c))}const l={height:r(i.height/s),head:a(n.querySelector(".er-head")),rows:d};_h(this.#r.get(o),l,Rh)||(this.#r.set(o,l),e=!0)}e&&(this.requestUpdate(),!this.#s&&(this.#s=!0,this.updateComplete.then(()=>this.fitViewport())))}layoutSignature(){return JSON.stringify([...this.#r])}#k(){const e=this.tagFilter.active.filter(n=>n.startsWith(Kt));return e.length===0?null:{...this.tagFilter,active:e}}filtered(){const e=this.items(),o=this.#k()===null?this.tagFilter:{...this.tagFilter,active:this.tagFilter.active.filter(d=>!d.startsWith(Kt))},i=e.nodes.filter(d=>Ae(d.tags,o)&&this.matchesFilter(d)),s=new Set(i.map(d=>d.id)),r={...e,nodes:i,edges:e.edges.filter(d=>s.has(d.from)&&s.has(d.to))},a=Ws(r.edges);return{...r,nodes:r.nodes.map(d=>{const l=this.#r.get(d.id);if(!l)return d;const c={...d.ports};for(const h of r.edges){if(h.from===d.id&&h.fromPort!==void 0){const p=l.rows[h.sourceField]??l.head;c[h.fromPort]={x:d.width,y:p+(a.get(h.id)??0)}}h.to===d.id&&h.toPort!==void 0&&(c[h.toPort]={x:0,y:l.rows[h.targetField]??l.head})}return{...d,height:l.height,ports:c}})}}parseData(e){return Qp(e)}reduceElementActions(e,n){return ah($e(this.locale),e,n)}emptyData(){return Pp()}defaultHeading(){return $e(this.locale).heading}statsLabels(){const e=$e(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return $e(this.locale).empty}layoutOptions(){return Lo}computePlacement(e){const{nodes:n,edges:o}=qp(e),i=this.layoutOptions();return this.layoutMode==="fixed"?Vi(n,o,i):qi(n,o,i)}focusBounds(){const e=this.#k();if(e===null)return null;const n=new Set(e.active.map(d=>d.slice(Kt.length))),o=pn(this.visible.nodes.map(d=>({id:d.id,boundedContext:d.boundedContext,box:this.placedNode(d.id)??null}))).filter(d=>n.has(d.boundedContext)).map(d=>d.box);if(o.length===0)return null;const i=Math.min(...o.map(d=>d.x)),s=Math.min(...o.map(d=>d.y)),r=Math.max(...o.map(d=>d.x+d.width)),a=Math.max(...o.map(d=>d.y+d.height));return{x:i,y:s,width:r-i,height:a-s}}focusKey(){return this.#k()?.active.join(",")??null}initialView(){this.fitViewport()}onMaximizeChange(){(this.renderRoot.querySelector("dpk-dialog-panel")?.updateComplete??Promise.resolve(!0)).then(()=>this.fitViewport())}matchesFilter(e){return this.#o===""?!0:[e.id,e.name,...e.fields.map(n=>n.id)].some(n=>n.toLowerCase().includes(this.#o))}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=we(n.edges,e.id,"outgoing",!1),i=we(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items();return[...e.nodes.map(n=>({value:this.commentRef("node",n.id),label:`${n.id} \xB7 ${n.name}`})),...e.edges.map(n=>({value:this.commentRef("edge",n.id),label:`${n.from}.${n.sourceField} \u2192 ${n.to}.${n.targetField}`}))]}renderToolbarActions(){const e=$e(this.locale);return k`
1939
1939
  <label class="er-search">
1940
1940
  <span class="dpk-label">${e.search}</span>
1941
1941
  <input
@@ -1946,13 +1946,13 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
1946
1946
  @input=${n=>{const o=n.currentTarget;o instanceof HTMLInputElement&&(this.#o=o.value.trim().toLowerCase(),this.requestUpdate())}}
1947
1947
  />
1948
1948
  </label>
1949
- `}renderLegend(){const e=ke(this.locale);return v`<div class="diagram-legend">
1949
+ `}renderLegend(){const e=$e(this.locale);return k`<div class="diagram-legend">
1950
1950
  <span><i class="er-swatch-added"></i>${e.legendAdded}</span>
1951
1951
  <span><i class="er-swatch-removed"></i>${e.legendRemoved}</span>
1952
1952
  <span><i class="er-swatch-changed"></i>${e.legendChanged}</span>
1953
- </div>`}renderControls(){const e=ke(this.locale),n=[{value:"all",label:e.columnFilterAll},{value:"keys",label:e.columnFilterKeys},{value:"tables-only",label:e.columnFilterTablesOnly}],o=[{pressed:this.#m,label:e.boundedContextLabel,onClick:()=>{this.#m=!this.#m,this.requestUpdate()}},{pressed:this.#g,label:e.aggregateLabel,onClick:()=>{this.#g=!this.#g,this.requestUpdate()}}];return v`<div class="er-controls-row">
1953
+ </div>`}renderControls(){const e=$e(this.locale),n=[{value:"all",label:e.columnFilterAll},{value:"keys",label:e.columnFilterKeys},{value:"tables-only",label:e.columnFilterTablesOnly}],o=[{pressed:this.#m,label:e.boundedContextLabel,onClick:()=>{this.#m=!this.#m,this.requestUpdate()}},{pressed:this.#g,label:e.aggregateLabel,onClick:()=>{this.#g=!this.#g,this.requestUpdate()}}];return k`<div class="er-controls-row">
1954
1954
  <div class="dpk-segmented er-column-filter" role="group" aria-label=${e.columnFilterLabel}>
1955
- ${n.map(i=>v`<button
1955
+ ${n.map(i=>k`<button
1956
1956
  type="button"
1957
1957
  aria-pressed=${this.#l===i.value?"true":"false"}
1958
1958
  @click=${()=>{this.#l=i.value,this.requestUpdate()}}
@@ -1961,7 +1961,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
1961
1961
  </button>`)}
1962
1962
  </div>
1963
1963
  <div class="dpk-segmented er-grouping-filter" role="group" aria-label=${e.groupingLabel}>
1964
- ${o.map(i=>v`<button
1964
+ ${o.map(i=>k`<button
1965
1965
  type="button"
1966
1966
  aria-pressed=${i.pressed?"true":"false"}
1967
1967
  @click=${i.onClick}
@@ -1969,16 +1969,16 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
1969
1969
  ${i.label}
1970
1970
  </button>`)}
1971
1971
  </div>
1972
- </div>`}#M(e){const n=this.selection,o=n===null?null:n.kind==="node"?{kind:"table",id:n.id}:{kind:"relation",id:n.id};return Jp(e.edges,[this.#i,o].filter(i=>i!==null))}#b(e){const n=this.visible;if(e.kind==="relation")return n.edges.some(i=>i.id===e.id);const o=e.kind==="table"?e.id:e.table;return n.nodes.some(i=>i.id===o)}#w(e){const n=e.nodes.flatMap(h=>{const p=this.placedNode(h.id);return p===void 0?[]:[{id:h.id,box:p}]}),o=e.nodes.map(h=>({id:h.id,aggregate:h.aggregate,boundedContext:h.boundedContext,box:this.placedNode(h.id)??null})),i=[...Eo(o).map(h=>({box:h.box,members:h.tables})),...ln(o).map(h=>({box:h.box,members:h.tables}))],s=new Map(e.edges.map(h=>[h.id,this.routeOf(h.id)])),r=h=>{const p=this.placedNode(h);return p===void 0?"":`${p.x},${p.y},${p.width},${p.height}`},a=[e.nodes.map(h=>`${h.id}:${r(h.id)}`).join(","),e.edges.map(h=>`${h.id}:${h.from}>${h.to}`).join(",")].join("|"),d=this.draggedNodeIds(),l=this.#f;if(d.size>0&&l!==null){const h=e.edges.filter(u=>d.has(u.from)||d.has(u.to));if(h.length===0)return l.result;const p=new Map(l.result);for(const u of h)p.set(u.id,dr(u,s.get(u.id)??[],n,lr,i));return p}if(l!==null&&l.signature===a)return l.result;const c=lh(e.edges,s,n,lr,i);return this.#f={signature:a,result:c},c}renderCanvas(){const e=ke(this.locale),n=this.visible,o=this.#M(n),i=this.#v(),s=new Set(i===null?[]:n.nodes.filter(m=>!Ce(m.tags,i)).map(m=>m.id)),r=[...n.edges].sort((m,x)=>Number(o.edges.has(m.id))-Number(o.edges.has(x.id))),a=this.#w(n),d=n.nodes.flatMap(m=>{const x=this.placedNode(m.id);return x===void 0?[]:[{id:m.id,box:x}]}),l=n.nodes.map(m=>({id:m.id,aggregate:m.aggregate,boundedContext:m.boundedContext,box:this.placedNode(m.id)??null})),c=[...Eo(l).map(m=>({box:m.box})),...ln(l).map(m=>({box:m.box}))],h=`${this.#f?.signature??""}|${this.layout?.width??0}x${this.layout?.height??0}`,p=this.draggedNodeIds().size>0;let u=!p&&this.#y?.signature===h?this.#y.result:null;u===null&&(u=cp(n.edges,a,{nodes:d,frames:c,edges:[...a.values()],width:this.layout?.width??0,height:this.layout?.height??0}),p||(this.#y={signature:h,result:u}));const g=r.map(m=>{const x=this.edgeState(m.id),k=a.get(m.id)??[],w=ph(k,mh),$=()=>this.select({kind:"edge",id:m.id}),L=[Et(m.cardinality),m.label].filter(Boolean).join(" \xB7 "),S=m.before===null?null:[Et(m.before.cardinality),m.before.label].filter(Boolean).join(" \xB7 ");return Y`
1972
+ </div>`}#I(e){const n=this.selection,o=n===null?null:n.kind==="node"?{kind:"table",id:n.id}:{kind:"relation",id:n.id};return uh(e.edges,[this.#i,o].filter(i=>i!==null))}#b(e){const n=this.visible;if(e.kind==="relation")return n.edges.some(i=>i.id===e.id);const o=e.kind==="table"?e.id:e.table;return n.nodes.some(i=>i.id===o)}#v(e){const n=e.nodes.flatMap(h=>{const p=this.placedNode(h.id);return p===void 0?[]:[{id:h.id,box:p}]}),o=e.nodes.map(h=>({id:h.id,aggregate:h.aggregate,boundedContext:h.boundedContext,box:this.placedNode(h.id)??null})),i=[...Co(o).map(h=>({box:h.box,members:h.tables})),...pn(o).map(h=>({box:h.box,members:h.tables}))],s=new Map(e.edges.map(h=>[h.id,this.routeOf(h.id)])),r=h=>{const p=this.placedNode(h);return p===void 0?"":`${p.x},${p.y},${p.width},${p.height}`},a=[e.nodes.map(h=>`${h.id}:${r(h.id)}`).join(","),e.edges.map(h=>`${h.id}:${h.from}>${h.to}`).join(",")].join("|"),d=this.draggedNodeIds(),l=this.#f;if(d.size>0&&l!==null){const h=e.edges.filter(u=>d.has(u.from)||d.has(u.to));if(h.length===0)return l.result;const p=new Map(l.result);for(const u of h)p.set(u.id,gr(u,s.get(u.id)??[],n,fr,i));return p}if(l!==null&&l.signature===a)return l.result;const c=$h(e.edges,s,n,fr,i);return this.#f={signature:a,result:c},c}renderCanvas(){const e=$e(this.locale),n=this.visible,o=this.#I(n),i=this.#k(),s=new Set(i===null?[]:n.nodes.filter(m=>!Ae(m.tags,i)).map(m=>m.id)),r=[...n.edges].sort((m,y)=>Number(o.edges.has(m.id))-Number(o.edges.has(y.id))),a=this.#v(n),d=n.nodes.flatMap(m=>{const y=this.placedNode(m.id);return y===void 0?[]:[{id:m.id,box:y}]}),l=n.nodes.map(m=>({id:m.id,aggregate:m.aggregate,boundedContext:m.boundedContext,box:this.placedNode(m.id)??null})),c=[...Co(l).map(m=>({box:m.box})),...pn(l).map(m=>({box:m.box}))],h=`${this.#f?.signature??""}|${this.layout?.width??0}x${this.layout?.height??0}`,p=this.draggedNodeIds().size>0;let u=!p&&this.#x?.signature===h?this.#x.result:null;u===null&&(u=Ep(n.edges,a,{nodes:d,frames:c,edges:[...a.values()],width:this.layout?.width??0,height:this.layout?.height??0}),p||(this.#x={signature:h,result:u}));const g=r.map(m=>{const y=this.edgeState(m.id),v=a.get(m.id)??[],w=Th(v,Ch),$=()=>this.select({kind:"edge",id:m.id}),A=[Mt(m.cardinality),m.label].filter(Boolean).join(" \xB7 "),C=m.before===null?null:[Mt(m.before.cardinality),m.before.label].filter(Boolean).join(" \xB7 ");return Y`
1973
1973
  <g
1974
- class=${this.elementClass({...x,dimmed:!1},"d-edge","er-edge",`is-${m.status}`,o.edges.has(m.id)&&"is-lit",o.edges.size>0&&!o.edges.has(m.id)&&"is-faded",(s.has(m.from)||s.has(m.to))&&"is-bc-dimmed")}
1974
+ class=${this.elementClass({...y,dimmed:!1},"d-edge","er-edge",`is-${m.status}`,o.edges.has(m.id)&&"is-lit",o.edges.size>0&&!o.edges.has(m.id)&&"is-faded",(s.has(m.from)||s.has(m.to))&&"is-bc-dimmed")}
1975
1975
  data-relation=${m.id}
1976
1976
  data-dpk-target=${this.commentRef("edge",m.id)}
1977
1977
  data-dpk-check="off"
1978
- @pointerenter=${()=>this.#x({kind:"relation",id:m.id})}
1979
- @pointerleave=${()=>this.#x(null)}
1978
+ @pointerenter=${()=>this.#y({kind:"relation",id:m.id})}
1979
+ @pointerleave=${()=>this.#y(null)}
1980
1980
  >
1981
- <title>${[`${m.from}.${m.sourceField} \u2192 ${m.to}.${m.targetField}`,L,S===null?null:`(${e.was(S)})`].filter(Boolean).join(" \xB7 ")}</title>
1981
+ <title>${[`${m.from}.${m.sourceField} \u2192 ${m.to}.${m.targetField}`,A,C===null?null:`(${e.was(C)})`].filter(Boolean).join(" \xB7 ")}</title>
1982
1982
  <path class="d-edge-path" d=${w}></path>
1983
1983
  <path class="er-edge-flow" d=${w}></path>
1984
1984
  <path
@@ -1986,27 +1986,27 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
1986
1986
  d=${w}
1987
1987
  role="button"
1988
1988
  tabindex="0"
1989
- aria-label=${e.edgeLabel(m.from,m.to,L)}
1989
+ aria-label=${e.edgeLabel(m.from,m.to,A)}
1990
1990
  @click=${$}
1991
- @keydown=${T=>{T.key!=="Enter"&&T.key!==" "||(T.preventDefault(),$())}}
1991
+ @keydown=${M=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),$())}}
1992
1992
  ></path>
1993
- ${k.length>0?this.#T(k,m,u.get(m.id)):M}
1993
+ ${v.length>0?this.#T(v,m,u.get(m.id)):T}
1994
1994
  </g>
1995
- `}),b=this.#m?ln(n.nodes.map(m=>({id:m.id,boundedContext:m.boundedContext,box:this.placedNode(m.id)??null}))):[],f=this.#g?Eo(n.nodes.map(m=>({id:m.id,aggregate:m.aggregate,box:this.placedNode(m.id)??null}))):[];return v`${b.map(m=>v`<div
1996
- class=${ye("er-bc",i!==null&&!Ce([`${Xt}${m.boundedContext}`],i)&&"is-bc-dimmed")}
1995
+ `}),b=this.#m?pn(n.nodes.map(m=>({id:m.id,boundedContext:m.boundedContext,box:this.placedNode(m.id)??null}))):[],f=this.#g?Co(n.nodes.map(m=>({id:m.id,aggregate:m.aggregate,box:this.placedNode(m.id)??null}))):[];return k`${b.map(m=>k`<div
1996
+ class=${ve("er-bc",i!==null&&!Ae([`${Kt}${m.boundedContext}`],i)&&"is-bc-dimmed")}
1997
1997
  style="left:${m.box.x}px; top:${m.box.y}px; width:${m.box.width}px; height:${m.box.height}px"
1998
1998
  >
1999
1999
  <span class="er-bc-label">${m.boundedContext}</span>
2000
- </div>`)}${f.map(m=>v`<div
2001
- class=${ye("er-aggregate",this.isDraggingGroup(m.aggregate)&&"is-dragging")}
2000
+ </div>`)}${f.map(m=>k`<div
2001
+ class=${ve("er-aggregate",this.isDraggingGroup(m.aggregate)&&"is-dragging")}
2002
2002
  style="left:${m.box.x}px; top:${m.box.y}px; width:${m.box.width}px; height:${m.box.height}px"
2003
- @pointerdown=${x=>{x.composedPath().some(k=>k instanceof Element&&k.matches(".d-node"))||this.onGroupDragStart(x,m.aggregate,m.tables)}}
2003
+ @pointerdown=${y=>{y.composedPath().some(v=>v instanceof Element&&v.matches(".d-node"))||this.onGroupDragStart(y,m.aggregate,m.tables)}}
2004
2004
  >
2005
2005
  <span class="er-aggregate-label">${m.aggregate}</span>
2006
- </div>`)}${this.renderEdges(Te(g,(m,x)=>r[x]?.id,m=>m),[])}${n.nodes.map(m=>this.#$(m,o,e,s.has(m.id)))}`}#T(e,n,o){const i=n.before,s=(h,p)=>Y`${p!=null&&p!==h?Y`<tspan class="er-was">${p}</tspan> `:M}${h??M}`,r=h=>{const p=h==="start"?n.cardinality.parent:n.cardinality.child,u=i&&(h==="start"?i.cardinality.parent:i.cardinality.child),g=rp(e,h,p),b=o?.[h];return{glyph:g,content:Y`
2006
+ </div>`)}${this.renderEdges(Me(g,(m,y)=>r[y]?.id,m=>m),[])}${n.nodes.map(m=>this.#w(m,o,e,s.has(m.id)))}`}#T(e,n,o){const i=n.before,s=(h,p)=>Y`${p!=null&&p!==h?Y`<tspan class="er-was">${p}</tspan> `:T}${h??T}`,r=h=>{const p=h==="start"?n.cardinality.parent:n.cardinality.child,u=i&&(h==="start"?i.cardinality.parent:i.cardinality.child),g=kp(e,h,p),b=o?.[h];return{glyph:g,content:Y`
2007
2007
  <g class="er-end" data-end=${h} data-multiplicity=${p}>
2008
2008
  ${g.segments.map(([f,m])=>Y`<line x1=${f.x} y1=${f.y} x2=${m.x} y2=${m.y}></line>`)}
2009
- ${g.circle===null?M:Y`<circle cx=${g.circle.x} cy=${g.circle.y} r=${$t}></circle>`}
2009
+ ${g.circle===null?T:Y`<circle cx=${g.circle.x} cy=${g.circle.y} r=${St}></circle>`}
2010
2010
  </g>
2011
2011
  <text
2012
2012
  class="er-cardinality is-${n.status}"
@@ -2018,14 +2018,14 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2018
2018
  >${s(p,u)}</text>
2019
2019
  `}},a=r("start"),d=r("end"),l=n.label??i?.label??null,c=o?.relation;return Y`
2020
2020
  ${a.content}${d.content}
2021
- ${l===null?M:Y`<text
2021
+ ${l===null?T:Y`<text
2022
2022
  class="er-relation-label is-${n.status}"
2023
2023
  text-anchor=${c?.anchor??d.glyph.label.anchor}
2024
2024
  x=${c?.x??d.glyph.label.x}
2025
2025
  dominant-baseline="central"
2026
2026
  y=${c?.y??d.glyph.label.y}
2027
2027
  >${s(n.label,i?.label)}</text>`}
2028
- `}#$(e,n,o,i){const s=this.placedNode(e.id);if(!s)return M;const r=this.nodeState(e.id),a=this.#l==="tables-only"?[]:this.#l==="keys"?e.fields.filter(d=>d.keys.length>0||d.ref!==null):e.fields;return v`
2028
+ `}#w(e,n,o,i){const s=this.placedNode(e.id);if(!s)return T;const r=this.nodeState(e.id),a=this.#l==="tables-only"?[]:this.#l==="keys"?e.fields.filter(d=>d.keys.length>0||d.ref!==null):e.fields;return k`
2029
2029
  <div
2030
2030
  class=${this.elementClass({...r,dimmed:!1},"d-node","er-table",`is-${e.status}`,n.tables.has(e.id)&&"is-lit",e.fields.some(d=>d.status!=="same")&&"has-diff",this.isDraggingNode(e.id)&&"is-dragging",i&&"is-bc-dimmed")}
2031
2031
  data-er-table=${e.id}
@@ -2033,8 +2033,8 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2033
2033
  data-dpk-target=${this.commentRef("node",e.id)}
2034
2034
  style="left:${s.x}px; top:${s.y}px; width:${e.width}px"
2035
2035
  @pointerdown=${d=>this.onNodeDragStart(d,e.id)}
2036
- @pointerenter=${()=>this.#x({kind:"table",id:e.id})}
2037
- @pointerleave=${()=>this.#x(null)}
2036
+ @pointerenter=${()=>this.#y({kind:"table",id:e.id})}
2037
+ @pointerleave=${()=>this.#y(null)}
2038
2038
  >
2039
2039
  <div class="er-head">
2040
2040
  <button
@@ -2049,7 +2049,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2049
2049
  <span class="er-title">
2050
2050
  <span class="er-title-top">
2051
2051
  <span class="er-name">${e.id}</span>
2052
- ${e.pattern===null?M:v`<span
2052
+ ${e.pattern===null?T:k`<span
2053
2053
  class="er-pattern-badge"
2054
2054
  data-pattern=${e.pattern}
2055
2055
  title=${o.patternLabel(e.pattern)}
@@ -2058,38 +2058,38 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2058
2058
  </span>
2059
2059
  <span class="er-label">${e.name}</span>
2060
2060
  </span>
2061
- ${e.status==="same"?M:v`<span class="er-status"
2062
- ><span aria-hidden="true">${cr[e.status]}</span>${o.statusLabel(e.status)}</span
2061
+ ${e.status==="same"?T:k`<span class="er-status"
2062
+ ><span aria-hidden="true">${br[e.status]}</span>${o.statusLabel(e.status)}</span
2063
2063
  >`}
2064
2064
  </button>
2065
2065
  </div>
2066
- ${a.length===0?M:v`<div class="er-fields">${a.map(d=>this.#H(e,d,n,o))}</div>`}
2067
- ${this.#L(e,o)} ${this.#z(e,o)}
2066
+ ${a.length===0?T:k`<div class="er-fields">${a.map(d=>this.#F(e,d,n,o))}</div>`}
2067
+ ${this.#C(e,o)} ${this.#N(e,o)}
2068
2068
  </div>
2069
- `}#L(e,n){return e.constraints.length===0?M:v`<ul class="er-constraints" aria-label=${n.tableConstraintsLabel}>
2070
- ${e.constraints.map(o=>v`<li class="er-constraint">${Ds(o)}</li>`)}
2071
- </ul>`}#E(e,n){return v`<span class="er-icon" data-icon=${e} role="img" aria-label=${n.columnRole(e)}
2072
- >${fh[e]()}</span
2073
- >`}#H(e,n,o,i){const s=this.#e,r=s?.kind==="edit"&&s.table===e.id&&s.field===n.id,a=this.#I&&n.status!=="removed",d=this.#o!==""&&n.id.toLowerCase().includes(this.#o),l=Zp(n),c=Vp(n,i),h=c.find(u=>u.attribute==="type"),p=c.filter(u=>u.attribute!=="type");return v`
2069
+ `}#C(e,n){return e.constraints.length===0?T:k`<ul class="er-constraints" aria-label=${n.tableConstraintsLabel}>
2070
+ ${e.constraints.map(o=>k`<li class="er-constraint">${Hs(o)}</li>`)}
2071
+ </ul>`}#$(e,n){return k`<span class="er-icon" data-icon=${e} role="img" aria-label=${n.columnRole(e)}
2072
+ >${Ih[e]()}</span
2073
+ >`}#F(e,n,o,i){const s=this.#e,r=s?.kind==="edit"&&s.table===e.id&&s.field===n.id,a=this.#S&&n.status!=="removed",d=this.#o!==""&&n.id.toLowerCase().includes(this.#o),l=hh(n),c=ch(n,i),h=c.find(u=>u.attribute==="type"),p=c.filter(u=>u.attribute!=="type");return k`
2074
2074
  <div
2075
- class=${ye("er-field",`is-${n.status}`,d&&"is-match",o.columns.has(`${e.id}.${n.id}`)&&"is-lit",r&&"is-editing")}
2075
+ class=${ve("er-field",`is-${n.status}`,d&&"is-match",o.columns.has(`${e.id}.${n.id}`)&&"is-lit",r&&"is-editing")}
2076
2076
  data-field=${n.id}
2077
2077
  data-grill-questions=${this.questionsOf(n)}
2078
- title=${[i.statusLabel(n.status),n.id,Wp(n,i,!0)].join(" / ")}
2079
- @pointerenter=${()=>this.#x({kind:"column",table:e.id,field:n.id})}
2080
- @pointerleave=${()=>this.#x({kind:"table",id:e.id})}
2078
+ title=${[i.statusLabel(n.status),n.id,lh(n,i,!0)].join(" / ")}
2079
+ @pointerenter=${()=>this.#y({kind:"column",table:e.id,field:n.id})}
2080
+ @pointerleave=${()=>this.#y({kind:"table",id:e.id})}
2081
2081
  >
2082
2082
  <div class="er-field-line">
2083
- <span class="er-field-mark" aria-hidden="true">${cr[n.status]}</span>
2084
- ${this.#E(l,i)}
2083
+ <span class="er-field-mark" aria-hidden="true">${br[n.status]}</span>
2084
+ ${this.#$(l,i)}
2085
2085
  <span class="er-field-name"
2086
- >${n.id}${bh(n,l).map(u=>v`<span class="er-key">${u}</span>`)}</span
2086
+ >${n.id}${Ah(n,l).map(u=>k`<span class="er-key">${u}</span>`)}</span
2087
2087
  >
2088
2088
  <span class="er-field-type">
2089
- ${h===void 0?n.type:v`<del>${h.before}</del><ins>${h.after}</ins>`}
2089
+ ${h===void 0?n.type:k`<del>${h.before}</del><ins>${h.after}</ins>`}
2090
2090
  </span>
2091
2091
  <span class="er-field-action">
2092
- ${a?v`<button
2092
+ ${a?k`<button
2093
2093
  type="button"
2094
2094
  class="dpk-icon-btn er-field-edit"
2095
2095
  data-action="edit-field"
@@ -2098,32 +2098,32 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2098
2098
  aria-haspopup="dialog"
2099
2099
  aria-expanded=${r?"true":"false"}
2100
2100
  title=${i.editFieldButton(n.id)}
2101
- @click=${()=>this.#A({kind:"edit",table:e.id,field:n.id,type:n.type,nullable:n.nullable,description:n.description??"",failed:!1})}
2101
+ @click=${()=>this.#_({kind:"edit",table:e.id,field:n.id,type:n.type,nullable:n.nullable,description:n.description??"",failed:!1})}
2102
2102
  >
2103
- ${gi()}
2104
- </button>`:M}
2103
+ ${ki()}
2104
+ </button>`:T}
2105
2105
  </span>
2106
2106
  </div>
2107
- ${n.description===null?M:v`<p class="er-field-description">${n.description}</p>`}
2108
- ${p.length===0?M:v`<ul class="er-deltas" aria-label=${i.changesLabel}>
2109
- ${p.map(u=>v`<li class="er-delta" data-attribute=${u.attribute}>
2107
+ ${n.description===null?T:k`<p class="er-field-description">${n.description}</p>`}
2108
+ ${p.length===0?T:k`<ul class="er-deltas" aria-label=${i.changesLabel}>
2109
+ ${p.map(u=>k`<li class="er-delta" data-attribute=${u.attribute}>
2110
2110
  <span class="er-delta-name">${i.attributeLabel(u.attribute)}</span>
2111
2111
  <del>${u.before}</del><span aria-hidden="true">→</span><ins>${u.after}</ins>
2112
2112
  </li>`)}
2113
2113
  </ul>`}
2114
2114
  </div>
2115
- `}get#I(){return this.id!==""}#_(e){return this.#I&&e.status!=="removed"}#Y(e,n){if(!this.dispatchElementAction(js,["node",e],{field:n})){this.#e!==null&&(this.#e={...this.#e,failed:!0}),this.requestUpdate();return}this.#D(!0)}#z(e,n){if(!this.#I||e.status==="removed")return M;const o=this.#e?.kind==="add"&&this.#e.table===e.id;return v`<div class="er-add">
2115
+ `}get#S(){return this.id!==""}#M(e){return this.#S&&e.status!=="removed"}#O(e,n){if(!this.dispatchElementAction(tr,["node",e],{field:n})){this.#e!==null&&(this.#e={...this.#e,failed:!0}),this.requestUpdate();return}this.#q(!0)}#N(e,n){if(!this.#S||e.status==="removed")return T;const o=this.#e?.kind==="add"&&this.#e.table===e.id;return k`<div class="er-add">
2116
2116
  <button
2117
2117
  type="button"
2118
- class=${ye("er-add-button",o&&"is-open")}
2118
+ class=${ve("er-add-button",o&&"is-open")}
2119
2119
  data-action="add-field"
2120
2120
  aria-haspopup="dialog"
2121
2121
  aria-expanded=${o?"true":"false"}
2122
- @click=${()=>this.#A({kind:"add",table:e.id,name:"",type:"",nullable:!1,description:"",failed:!1})}
2122
+ @click=${()=>this.#_({kind:"add",table:e.id,name:"",type:"",nullable:!1,description:"",failed:!1})}
2123
2123
  >
2124
- <span class="er-icon" aria-hidden="true">${Un()}</span><span>${n.addFieldButton}</span>
2124
+ <span class="er-icon" aria-hidden="true">${Gn()}</span><span>${n.addFieldButton}</span>
2125
2125
  </button>
2126
- </div>`}renderSelection(){const e=this.#e,n=e===null?void 0:this.visible.nodes.find(r=>r.id===e.table),o=super.renderSelection(),i=e===null||n===void 0?M:this.#P(n,e,ke(this.locale)),s=this.#F();return v`${o}${i}${s}`}#P(e,n,o){const i=Js(n,e),s=n.kind==="edit"?e.fields.find(h=>h.id===n.field):void 0,r=s!==void 0&&s.keys.includes("PK")?"primary":n.nullable?"nullable":"not-null",a=n.kind==="add"?o.addFieldTitle:o.editFieldTitle,d=n.kind==="add"?e.id:`${e.id}.${n.field}`,l=n.kind==="edit"&&s!==void 0&&this.#_(s)?{table:e.id,field:n.field}:null,c=l===null?[]:Vs(this.items(),e.id,l.field);return v`<div
2126
+ </div>`}renderSelection(){const e=this.#e,n=e===null?void 0:this.visible.nodes.find(r=>r.id===e.table),o=super.renderSelection(),i=e===null||n===void 0?T:this.#z(n,e,$e(this.locale)),s=this.#B();return k`${o}${i}${s}`}#z(e,n,o){const i=rr(n,e),s=n.kind==="edit"?e.fields.find(h=>h.id===n.field):void 0,r=s!==void 0&&s.keys.includes("PK")?"primary":n.nullable?"nullable":"not-null",a=n.kind==="add"?o.addFieldTitle:o.editFieldTitle,d=n.kind==="add"?e.id:`${e.id}.${n.field}`,l=n.kind==="edit"&&s!==void 0&&this.#M(s)?{table:e.id,field:n.field}:null,c=l===null?[]:or(this.items(),e.id,l.field);return k`<div
2127
2127
  class="er-editor"
2128
2128
  popover="manual"
2129
2129
  role="dialog"
@@ -2132,12 +2132,12 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2132
2132
  @keydown=${h=>this.#Z(h)}
2133
2133
  >
2134
2134
  <div class="er-editor-head">
2135
- ${this.#E(r,o)}
2135
+ ${this.#$(r,o)}
2136
2136
  <span class="er-editor-title">${a}</span>
2137
2137
  <code class="er-editor-target">${d}</code>
2138
2138
  </div>
2139
2139
  <div class="er-editor-fields">
2140
- ${n.kind==="add"?v`<label class="er-editor-field">
2140
+ ${n.kind==="add"?k`<label class="er-editor-field">
2141
2141
  <span class="dpk-label">${o.columnNameLabel}</span>
2142
2142
  <input
2143
2143
  class="dpk-input"
@@ -2147,9 +2147,9 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2147
2147
  aria-invalid=${i.issue==="name-taken"?"true":"false"}
2148
2148
  placeholder=${o.columnNamePlaceholder}
2149
2149
  .value=${n.name}
2150
- @input=${h=>{const p=h.currentTarget;this.#e?.kind==="add"&&p instanceof HTMLInputElement&&this.#N({...this.#e,name:p.value})}}
2150
+ @input=${h=>{const p=h.currentTarget;this.#e?.kind==="add"&&p instanceof HTMLInputElement&&this.#P({...this.#e,name:p.value})}}
2151
2151
  />
2152
- </label>`:M}
2152
+ </label>`:T}
2153
2153
  ${this.#V(n,o)}
2154
2154
  </div>
2155
2155
  <label class="er-editor-field">
@@ -2161,33 +2161,33 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2161
2161
  spellcheck="false"
2162
2162
  placeholder=${o.columnDescriptionPlaceholder}
2163
2163
  .value=${n.description}
2164
- @input=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#N({...this.#e,description:p.value})}}
2164
+ @input=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#P({...this.#e,description:p.value})}}
2165
2165
  />
2166
2166
  </label>
2167
- ${i.issue==="name-taken"?v`<p class="er-editor-note" role="status">${o.columnNameTaken}</p>`:M}
2168
- ${n.failed?v`<p class="er-error" role="alert">${o.notRecorded}</p>`:M}
2167
+ ${i.issue==="name-taken"?k`<p class="er-editor-note" role="status">${o.columnNameTaken}</p>`:T}
2168
+ ${n.failed?k`<p class="er-error" role="alert">${o.notRecorded}</p>`:T}
2169
2169
  <label class="er-editor-check">
2170
2170
  <input
2171
2171
  type="checkbox"
2172
2172
  data-input="nullable"
2173
2173
  .checked=${n.nullable}
2174
- @change=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#N({...this.#e,nullable:p.checked})}}
2174
+ @change=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#P({...this.#e,nullable:p.checked})}}
2175
2175
  />
2176
2176
  <span>${o.columnNullable}</span>
2177
2177
  </label>
2178
2178
  <div class="er-editor-foot">
2179
2179
  <span class="er-editor-keys">${o.columnKeys}</span>
2180
- ${l===null||c.length===0?M:v`<span class="er-editor-note" role="status"
2180
+ ${l===null||c.length===0?T:k`<span class="er-editor-note" role="status"
2181
2181
  >${o.deleteFieldRelationsNote(c.length)}</span
2182
2182
  >`}
2183
2183
  <div class="er-editor-actions">
2184
- ${l===null?M:v`<button
2184
+ ${l===null?T:k`<button
2185
2185
  type="button"
2186
2186
  class="dpk-btn dpk-btn--danger"
2187
2187
  data-action="delete-column"
2188
- @click=${()=>this.#Y(l.table,l.field)}
2188
+ @click=${()=>this.#O(l.table,l.field)}
2189
2189
  >
2190
- ${Ft()}<span>${o.deleteFieldTitle}</span>
2190
+ ${Bt()}<span>${o.deleteFieldTitle}</span>
2191
2191
  </button>`}
2192
2192
  <div class="er-editor-actions-right">
2193
2193
  <button
@@ -2195,7 +2195,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2195
2195
  class="dpk-btn dpk-btn--ghost"
2196
2196
  data-action="cancel-column"
2197
2197
  data-dpk-text-discard
2198
- @click=${()=>this.#D(!0)}
2198
+ @click=${()=>this.#q(!0)}
2199
2199
  >
2200
2200
  ${o.cancel}
2201
2201
  </button>
@@ -2211,24 +2211,24 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2211
2211
  </div>
2212
2212
  </div>
2213
2213
  </div>
2214
- </div>`}#q(){const e=this.#e,n=this.renderRoot.querySelector(".er-editor");if(e===null||n===null)return;const o=this.renderRoot.querySelector(`[data-er-table="${CSS.escape(e.table)}"] ${hr(e)}`),i=e.kind==="edit"?o?.closest(".er-field"):o;if(!i)return;const s=this.renderRoot.querySelector("dpk-dialog-panel"),r=s===null?{}:{boundary:s};this.#p.open(n,i,{width:300,height:400},{placement:"bottom-start",trackTransform:!0,...r});const a=n.querySelector(".er-type-options"),d=n.querySelector(".er-editor-type");a===null||d===null||this.#p.open(a,d,{width:Math.max(d.offsetWidth,200),height:220},{placement:"bottom-start",trackTransform:!0,...r})}#F(){const e=this.#h;if(e===null)return M;const n=this.visible.edges.find(i=>i.id===e.edge);if(n===void 0)return M;const o=ke(this.locale);return v`<div
2214
+ </div>`}#U(){const e=this.#e,n=this.renderRoot.querySelector(".er-editor");if(e===null||n===null)return;const o=this.renderRoot.querySelector(`[data-er-table="${CSS.escape(e.table)}"] ${yr(e)}`),i=e.kind==="edit"?o?.closest(".er-field"):o;if(!i)return;const s=this.renderRoot.querySelector("dpk-dialog-panel"),r=s===null?{}:{boundary:s};this.#h.open(n,i,{width:300,height:400},{placement:"bottom-start",trackTransform:!0,...r});const a=n.querySelector(".er-type-options"),d=n.querySelector(".er-editor-type");a===null||d===null||this.#h.open(a,d,{width:Math.max(d.offsetWidth,200),height:220},{placement:"bottom-start",trackTransform:!0,...r})}#B(){const e=this.#u;if(e===null)return T;const n=this.visible.edges.find(i=>i.id===e.edge);if(n===void 0)return T;const o=$e(this.locale);return k`<div
2215
2215
  class="er-editor er-cardinality-editor"
2216
2216
  popover="manual"
2217
2217
  role="dialog"
2218
2218
  aria-label=${`${o.editCardinalityTitle} ${n.from}.${n.sourceField} \u2192 ${n.to}.${n.targetField}`}
2219
- @keydown=${i=>this.#G(i)}
2219
+ @keydown=${i=>this.#X(i)}
2220
2220
  >
2221
2221
  <div class="er-editor-head">
2222
- <span class="er-icon" aria-hidden="true">${mi()}</span>
2222
+ <span class="er-icon" aria-hidden="true">${yi()}</span>
2223
2223
  <span class="er-editor-title">${o.editCardinalityTitle}</span>
2224
2224
  <code class="er-editor-target">${n.from} → ${n.to}</code>
2225
2225
  </div>
2226
2226
  <label class="er-editor-field">
2227
2227
  <span class="dpk-label">${o.cardinalityLabel}</span>
2228
- ${this.#u.render({options:fo.map(i=>({value:i,label:i.replace(":"," : ")})),value:e.cardinality,ariaLabel:o.cardinalityLabel,onChange:i=>this.#X(i)})}
2228
+ ${this.#p.render({options:ko.map(i=>({value:i,label:i.replace(":"," : ")})),value:e.cardinality,ariaLabel:o.cardinalityLabel,onChange:i=>this.#G(i)})}
2229
2229
  </label>
2230
- ${e.failed?v`<p class="er-error" role="alert">${o.notRecorded}</p>`:M}
2231
- </div>`}#X(e){const n=this.#h;if(n===null)return;const o=this.dispatchElementAction(Ws,["edge",n.edge],{cardinality:e});this.#h={...n,cardinality:e,failed:!o},this.requestUpdate()}#B(){const e=this.#h,n=this.renderRoot.querySelector(".er-cardinality-editor");if(e===null||n===null)return;const o=this.renderRoot.querySelector(`[data-relation="${CSS.escape(e.edge)}"]`);o&&this.#p.open(n,o,{width:240,height:170},{placement:"bottom-start",trackTransform:!0})}#G(e){e.isComposing||e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.select(null))}#S(){this.#e===null||this.#n===null||this.#t.set(Mt(this.#e),{draft:this.#e,base:this.#n})}#x(e){JSON.stringify(this.#i)!==JSON.stringify(e)&&(this.#i=e,this.#W())}#W(){const e=this.#M(this.visible),n=this.renderRoot;for(const o of n.querySelectorAll(".er-edge")){const i=o.getAttribute("data-relation")??"";o.classList.toggle("is-lit",e.edges.has(i)),o.classList.toggle("is-faded",e.edges.size>0&&!e.edges.has(i))}for(const o of n.querySelectorAll(".er-table")){const i=o.getAttribute("data-er-table")??"";o.classList.toggle("is-lit",e.tables.has(i));for(const s of o.querySelectorAll(".er-field")){const r=s.getAttribute("data-field")??"";s.classList.toggle("is-lit",e.columns.has(`${i}.${r}`))}}}#A(e){if(this.#e!==null&&Mt(this.#e)===Mt(e)){this.#D(!1);return}this.#O(e)}#O(e){this.#S(),this.#e=Qp(this.#t.get(Mt(e)),e),this.#n=e,this.#t.delete(Mt(e)),this.#a=null,this.requestUpdate();const n=e.kind==="add"?"add-name":"edit-type";this.updateComplete.then(()=>{const o=this.renderRoot.querySelector(`.er-editor [data-input="${n}"]`);o?.focus({preventScroll:!0}),o?.select()})}#V(e,n){const o=this.#a,i=o===null?null:Zs(Qs(this.items()),e.type,o.moved),s=i!==null&&i.options.length>0,r=d=>`er-type-option-${d}`,a=()=>{this.#a===null&&(this.#a={moved:null},this.requestUpdate())};return v`<div class="er-editor-combo">
2230
+ ${e.failed?k`<p class="er-error" role="alert">${o.notRecorded}</p>`:T}
2231
+ </div>`}#G(e){const n=this.#u;if(n===null)return;const o=this.dispatchElementAction(nr,["edge",n.edge],{cardinality:e});this.#u={...n,cardinality:e,failed:!o},this.requestUpdate()}#H(){const e=this.#u,n=this.renderRoot.querySelector(".er-cardinality-editor");if(e===null||n===null)return;const o=this.renderRoot.querySelector(`[data-relation="${CSS.escape(e.edge)}"]`);o&&this.#h.open(n,o,{width:240,height:170},{placement:"bottom-start",trackTransform:!0})}#X(e){e.isComposing||e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.select(null))}#L(){this.#e===null||this.#t===null||this.#n.set(It(this.#e),{draft:this.#e,base:this.#t})}#y(e){JSON.stringify(this.#i)!==JSON.stringify(e)&&(this.#i=e,this.#W())}#W(){const e=this.#I(this.visible),n=this.renderRoot;for(const o of n.querySelectorAll(".er-edge")){const i=o.getAttribute("data-relation")??"";o.classList.toggle("is-lit",e.edges.has(i)),o.classList.toggle("is-faded",e.edges.size>0&&!e.edges.has(i))}for(const o of n.querySelectorAll(".er-table")){const i=o.getAttribute("data-er-table")??"";o.classList.toggle("is-lit",e.tables.has(i));for(const s of o.querySelectorAll(".er-field")){const r=s.getAttribute("data-field")??"";s.classList.toggle("is-lit",e.columns.has(`${i}.${r}`))}}}#_(e){if(this.#e!==null&&It(this.#e)===It(e)){this.#q(!1);return}this.#D(e)}#D(e){this.#L(),this.#e=ph(this.#n.get(It(e)),e),this.#t=e,this.#n.delete(It(e)),this.#a=null,this.requestUpdate();const n=e.kind==="add"?"add-name":"edit-type";this.updateComplete.then(()=>{const o=this.renderRoot.querySelector(`.er-editor [data-input="${n}"]`);o?.focus({preventScroll:!0}),o?.select()})}#V(e,n){const o=this.#a,i=o===null?null:sr(ir(this.items()),e.type,o.moved),s=i!==null&&i.options.length>0,r=d=>`er-type-option-${d}`,a=()=>{this.#a===null&&(this.#a={moved:null},this.requestUpdate())};return k`<div class="er-editor-combo">
2232
2232
  <label class="er-editor-field">
2233
2233
  <span class="dpk-label">${n.addFieldType}</span>
2234
2234
  <input
@@ -2238,25 +2238,25 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2238
2238
  aria-autocomplete="list"
2239
2239
  aria-controls="er-type-options"
2240
2240
  aria-expanded=${String(s)}
2241
- aria-activedescendant=${s?r(i.active):M}
2241
+ aria-activedescendant=${s?r(i.active):T}
2242
2242
  autocomplete="off"
2243
2243
  spellcheck="false"
2244
2244
  placeholder=${n.columnTypePlaceholder}
2245
2245
  .value=${e.type}
2246
2246
  @click=${a}
2247
- @blur=${()=>this.#U()}
2248
- @input=${d=>{const l=d.currentTarget;this.#e===null||!(l instanceof HTMLInputElement)||(this.#a={moved:null},this.#N({...this.#e,type:l.value}))}}
2247
+ @blur=${()=>this.#Y()}
2248
+ @input=${d=>{const l=d.currentTarget;this.#e===null||!(l instanceof HTMLInputElement)||(this.#a={moved:null},this.#P({...this.#e,type:l.value}))}}
2249
2249
  @keydown=${d=>this.#Q(d)}
2250
2250
  />
2251
2251
  </label>
2252
- ${s?v`<ul
2252
+ ${s?k`<ul
2253
2253
  id="er-type-options"
2254
2254
  class="er-type-options"
2255
2255
  popover="manual"
2256
2256
  role="listbox"
2257
2257
  aria-label=${n.columnTypeChoices}
2258
2258
  >
2259
- ${i.options.map((d,l)=>v`<li
2259
+ ${i.options.map((d,l)=>k`<li
2260
2260
  id=${r(l)}
2261
2261
  role="option"
2262
2262
  data-type=${d.type}
@@ -2265,12 +2265,12 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2265
2265
  @pointerdown=${c=>c.preventDefault()}
2266
2266
  @click=${()=>this.#K(d.type)}
2267
2267
  >
2268
- ${d.kind==="new"?v`<span class="er-icon" aria-hidden="true">${Un()}</span>`:M}
2268
+ ${d.kind==="new"?k`<span class="er-icon" aria-hidden="true">${Gn()}</span>`:T}
2269
2269
  <code>${d.type}</code>
2270
- ${d.kind==="new"?v`<span class="er-type-option-hint">${n.columnTypeNew}</span>`:M}
2270
+ ${d.kind==="new"?k`<span class="er-type-option-hint">${n.columnTypeNew}</span>`:T}
2271
2271
  </li>`)}
2272
- </ul>`:M}
2273
- </div>`}#Q(e){const n=this.#e,o=this.#a;if(e.isComposing||n===null)return;const i=o===null?null:Zs(Qs(this.items()),n.type,o.moved);switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),this.#a=i===null||i.options.length===0?{moved:null}:{moved:i.active+(e.key==="ArrowDown"?1:-1)},this.requestUpdate(),this.updateComplete.then(()=>{const s=this.renderRoot.querySelector(".er-type-options"),r=s?.querySelector('[aria-selected="true"]');s&&r&&qd(s,r)});return;case"Enter":{const s=i?.options[i.active];if(s===void 0||s.type===n.type.trim()){this.#U();return}e.preventDefault(),e.stopPropagation(),this.#K(s.type);return}case"Escape":if(o===null)return;e.preventDefault(),e.stopPropagation(),this.#U();return}}#K(e){this.#e!==null&&(this.#a=null,this.#N({...this.#e,type:e}))}#U(){this.#a!==null&&(this.#a=null,this.requestUpdate())}#N(e){this.#e={...e,failed:!1},this.requestUpdate()}#D(e,n=!0){const o=this.#e;o!==null&&(e||this.#S(),this.#e=null,this.#a=null,this.requestUpdate(),n&&this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-er-table="${CSS.escape(o.table)}"] ${hr(o)}`)?.focus({preventScroll:!0})))}#Z(e){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.#D(!1);return}if(e.key!=="Enter"||!(e.target instanceof HTMLInputElement)||e.target.type==="checkbox")return;e.preventDefault();const n=this.#e;if(n?.kind==="add"&&e.target.dataset.input==="add-name"&&n.type.trim()===""){e.target.closest(".er-editor")?.querySelector('[data-input="add-type"]')?.focus();return}this.#R()}#R(){const e=this.#e,n=e===null?void 0:this.visible.nodes.find(r=>r.id===e.table);if(e===null||n===void 0||!Js(e,n).ready)return;const o=e.type.trim(),i=e.description.trim();if(!(e.kind==="add"?this.dispatchElementAction(Gs,["node",e.table],{id:e.name.trim(),type:o,nullable:e.nullable,description:i}):this.dispatchElementAction(Ks,["node",e.table],{field:e.field,type:o,nullable:e.nullable,description:i}))){this.#e={...e,failed:!0},this.requestUpdate();return}this.#D(!0)}}const hr=t=>t.kind==="add"?'[data-action="add-field"]':`[data-action="edit-field"][data-field="${CSS.escape(t.field)}"]`,Mt=t=>t.kind==="add"?`add:${t.table}`:`edit:${t.table}:${t.field}`,ur=()=>{customElements.get("dpk-board-er-diagram")||customElements.define("dpk-board-er-diagram",pr)},So=["actor","command","aggregate","event","policy","readmodel","external","hotspot"],vh=P({id:oe,name:I(y(),_(1)),description:W(y()),questions:Ze}),kh=P({id:oe,type:X(So),name:I(y(),_(1)),description:W(y()),contextId:W(y()),questions:Ze}),wh=P({id:oe,from:I(y(),_(1)),to:I(y(),_(1)),label:W(y()),kind:W(X(["member","flow"]))}),$h=P({title:W(y()),contexts:C(F(vh),[]),elements:C(F(kh),[]),links:C(F(wh),[])}),Eh=t=>{const e=he($h,t),n=new Set(e.elements.map(i=>i.id)),o=new Set(e.contexts.map(i=>i.id));for(const i of e.elements)if(i.contextId!==void 0&&!o.has(i.contextId))throw new Error(`unknown context "${i.contextId}" for note "${i.id}"`);for(const i of e.links){if(!n.has(i.from))throw new Error(`unknown note "${i.from}" in link "${i.id}"`);if(!n.has(i.to))throw new Error(`unknown note "${i.to}" in link "${i.id}"`)}return e},Th=()=>({contexts:[],elements:[],links:[]}),at=(t,e)=>{if(e!==void 0)return t.elements.find(n=>n.id===e)},Mo=(t,e)=>{if(e!==void 0)return t.contexts.find(n=>n.id===e)},Sh=(t,e)=>{if(e!==void 0)return t.links.find(n=>n.id===e)},cn=t=>t.elements.map(e=>e.id),ie={SET_ELEMENT_NAME:z("SET_ELEMENT_NAME","element",O({name:I(y(),_(1))})),SET_ELEMENT_DESCRIPTION:z("SET_ELEMENT_DESCRIPTION","element",O({description:y()})),SET_ELEMENT_TYPE:z("SET_ELEMENT_TYPE","element",O({type:X(So)})),SET_ELEMENT_CONTEXT:z("SET_ELEMENT_CONTEXT","element",O({contextId:ue(y())})),MOVE_ELEMENT:z("MOVE_ELEMENT","element",O({after:ue(y())}),{mode:"sequence"}),ADD_ELEMENT:z("ADD_ELEMENT","page",O({id:oe,type:X(So),name:I(y(),_(1)),description:W(y()),contextId:W(y())}),{dedupeKey:Se}),DELETE_ELEMENT:z("DELETE_ELEMENT","element",O({})),LINK_ELEMENTS:z("LINK_ELEMENTS","page",O({id:oe,from:I(y(),_(1)),to:I(y(),_(1)),label:W(y()),kind:W(X(["member","flow"]))}),{dedupeKey:Se}),SET_LINK_LABEL:z("SET_LINK_LABEL","link",O({label:y()})),UNLINK_ELEMENTS:z("UNLINK_ELEMENTS","page",O({from:I(y(),_(1)),to:I(y(),_(1))}),{mode:"sequence"}),ADD_CONTEXT:z("ADD_CONTEXT","page",O({id:oe,name:I(y(),_(1)),description:W(y())}),{dedupeKey:Se}),SET_CONTEXT_NAME:z("SET_CONTEXT_NAME","context",O({name:I(y(),_(1))})),DELETE_CONTEXT:z("DELETE_CONTEXT","context",O({}))},J={setElementName:(t,e)=>({type:"SET_ELEMENT_NAME",target:{type:"element",id:t},payload:{name:e}}),setElementDescription:(t,e)=>({type:"SET_ELEMENT_DESCRIPTION",target:{type:"element",id:t},payload:{description:e}}),setElementType:(t,e)=>({type:"SET_ELEMENT_TYPE",target:{type:"element",id:t},payload:{type:e}}),setElementContext:(t,e)=>({type:"SET_ELEMENT_CONTEXT",target:{type:"element",id:t},payload:{contextId:e}}),moveElement:(t,e)=>({type:"MOVE_ELEMENT",target:{type:"element",id:t},payload:{after:e}}),addElement:(t,e,n)=>({type:"ADD_ELEMENT",target:{type:"page",id:"event-storming"},payload:{id:t,type:e,name:n}}),deleteElement:t=>({type:"DELETE_ELEMENT",target:{type:"element",id:t},payload:{}}),linkElements:(t,e,n,o)=>({type:"LINK_ELEMENTS",target:{type:"page",id:"event-storming"},payload:{id:t,from:e,to:n,...o?.label===void 0?{}:{label:o.label},...o?.kind===void 0?{}:{kind:o.kind}}}),setLinkLabel:(t,e)=>({type:"SET_LINK_LABEL",target:{type:"link",id:t},payload:{label:e}}),unlinkElements:(t,e)=>({type:"UNLINK_ELEMENTS",target:{type:"page",id:"event-storming"},payload:{from:t,to:e}}),addContext:(t,e)=>({type:"ADD_CONTEXT",target:{type:"page",id:"event-storming"},payload:{id:t,name:e}}),setContextName:(t,e)=>({type:"SET_CONTEXT_NAME",target:{type:"context",id:t},payload:{name:e}}),deleteContext:t=>({type:"DELETE_CONTEXT",target:{type:"context",id:t},payload:{}})},mr={actor:"Actor",command:"Command",aggregate:"Aggregate",event:"Domain Event",policy:"Policy",readmodel:"Read Model",external:"External System",hotspot:"Hotspot"},gr={actor:"\u30A2\u30AF\u30BF\u30FC",command:"\u30B3\u30DE\u30F3\u30C9",aggregate:"\u96C6\u7D04",event:"\u30A4\u30D9\u30F3\u30C8",policy:"\u30DD\u30EA\u30B7\u30FC",readmodel:"\u30EA\u30FC\u30C9\u30E2\u30C7\u30EB",external:"\u5916\u90E8\u30B7\u30B9\u30C6\u30E0",hotspot:"\u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8"},fe=ce({en:{heading:"Event Storming",wholeBoard:"Whole board",renameElementTitle:"Rename element",updateDescriptionTitle:"Update element description",changeTypeTitle:"Change element type",changeContextTitle:"Change the element\u2019s context",moveTitle:"Change timeline position",addElementTitle:"Add element",deleteElementTitle:"Delete element",linkTitle:"Link elements",renameLinkTitle:"Change link label",unlinkTitle:"Remove link",addContextTitle:"Add bounded context",renameContextTitle:"Rename bounded context",deleteContextTitle:"Delete bounded context",renamed:(t,e)=>`"${t}" \u2192 "${e}"`,noContext:"No context",moveToFront:"\u2192 To the front",moveAfter:t=>`\u2192 Right after "${t}"`,elementLabel:t=>`Element \xB7 ${t}`,contextLabel:t=>`Bounded context \xB7 ${t}`,linkLabel:(t,e)=>`Link \xB7 ${t}\u2192${e}`,linkGroup:"Link",pageLabel:t=>`Page \xB7 ${t}`,elementGroup:"Element",contextGroup:"Bounded context",noteTypeLabel:t=>mr[t],addTypeLabel:t=>`+ ${mr[t]}`,addHotspot:"+ Hotspot",pinHotspotTitle:"Pin a hotspot on this note",commentNote:"Comment",deleteNote:"Delete",noteNameLabel:"Note name",newContextTitle:"New bounded context",contextNamePlaceholder:"Context name",cancel:"Cancel",create:"Create",save:"Save",appendMenuNext:"Note to add next",appendMenuAfter:t=>`Continue after \u201C${t}\u201D`,emptyTitle:"No notes yet",emptyBody:"Start Event Storming by placing domain events on the timeline.",addFirstEvent:"+ First event",portAriaLabel:"Add what comes next (pick a type, or drag to connect to another slice)",portTitle:"Click: pick a note to continue / Drag: connect to another slice",renameContextHint:"Click to rename",dissolveContextAria:t=>`Dissolve bounded context "${t}"`,dissolveContextTitle:"Dissolve the bounded context (notes stay)",noteCount:t=>`${t} notes`,sliceCount:t=>`${t} slices`,contextCount:t=>`${t} bounded contexts`,hudHint:"Wheel: pan \xB7 Pinch: zoom \xB7 Drag background: select area",zoomOut:"Zoom out",zoomReset:"Reset to 100%",zoomIn:"Zoom in",zoomFit:"Fit to view",selectedLinks:t=>`${t} links selected`,deleteLinks:"Delete links",deleteHint:"Delete works too",clearSelection:"Clear selection",selectedSlices:t=>`${t} slices selected`,groupIntoContext:"Group into a bounded context",addToExistingAria:"Add to an existing bounded context",addToExistingOption:"Add to existing\u2026",removeFromContext:"Remove from context",deleteButton:"Delete"},ja:{heading:"\u30A4\u30D9\u30F3\u30C8\u30B9\u30C8\u30FC\u30DF\u30F3\u30B0",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",renameElementTitle:"\u8981\u7D20\u540D\u3092\u5909\u66F4",updateDescriptionTitle:"\u8981\u7D20\u306E\u8AAC\u660E\u3092\u66F4\u65B0",changeTypeTitle:"\u8981\u7D20\u306E\u7A2E\u5225\u3092\u5909\u66F4",changeContextTitle:"\u6240\u5C5E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4",moveTitle:"\u30BF\u30A4\u30E0\u30E9\u30A4\u30F3\u4F4D\u7F6E\u3092\u5909\u66F4",addElementTitle:"\u8981\u7D20\u3092\u8FFD\u52A0",deleteElementTitle:"\u8981\u7D20\u3092\u524A\u9664",linkTitle:"\u8981\u7D20\u3092\u9023\u7D50",renameLinkTitle:"\u30EA\u30F3\u30AF\u540D\u3092\u5909\u66F4",unlinkTitle:"\u30EA\u30F3\u30AF\u3092\u524A\u9664",addContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u8FFD\u52A0",renameContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u540D\u3092\u5909\u66F4",deleteContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u524A\u9664",renamed:(t,e)=>`"${t}" \u2192 "${e}"`,noContext:"\u672A\u6240\u5C5E",moveToFront:"\u2192 \u5148\u982D\u3078",moveAfter:t=>`\u2192 "${t}" \u306E\u76F4\u5F8C\u3078`,elementLabel:t=>`\u8981\u7D20 \xB7 ${t}`,contextLabel:t=>`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8 \xB7 ${t}`,linkLabel:(t,e)=>`\u30EA\u30F3\u30AF \xB7 ${t}\u2192${e}`,linkGroup:"\u30EA\u30F3\u30AF",pageLabel:t=>`\u30DA\u30FC\u30B8 \xB7 ${t}`,elementGroup:"\u8981\u7D20",contextGroup:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",noteTypeLabel:t=>gr[t],addTypeLabel:t=>`+ ${gr[t]}`,addHotspot:"+ \u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8",pinHotspotTitle:"\u3053\u306E\u4ED8\u7B8B\u306B\u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8\u3092\u7ACB\u3066\u308B",commentNote:"\u30B3\u30E1\u30F3\u30C8",deleteNote:"\u524A\u9664",noteNameLabel:"\u4ED8\u7B8B\u540D",newContextTitle:"\u65B0\u3057\u3044\u5883\u754C\u3065\u3051\u3089\u308C\u305F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",contextNamePlaceholder:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u540D",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",create:"\u4F5C\u6210",save:"\u4FDD\u5B58",appendMenuNext:"\u7D9A\u304D\u306B\u8FFD\u52A0\u3059\u308B\u4ED8\u7B8B",appendMenuAfter:t=>`\u300C${t}\u300D\u306E\u7D9A\u304D\u306B\u8FFD\u52A0`,emptyTitle:"\u4ED8\u7B8B\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",emptyBody:"\u30A4\u30D9\u30F3\u30C8\u30B9\u30C8\u30FC\u30DF\u30F3\u30B0\u3092\u958B\u59CB\u3057\u307E\u3057\u3087\u3046\u3002\u30C9\u30E1\u30A4\u30F3\u30A4\u30D9\u30F3\u30C8\u3092\u6642\u7CFB\u5217\u306B\u8CBC\u308B\u3068\u3053\u308D\u304B\u3089\u59CB\u3081\u307E\u3059\u3002",addFirstEvent:"+ \u6700\u521D\u306E\u30A4\u30D9\u30F3\u30C8",portAriaLabel:"\u7D9A\u304D\u3092\u8FFD\u52A0\uFF08\u7A2E\u985E\u3092\u9078\u3093\u3067\u8FFD\u52A0 / \u30C9\u30E9\u30C3\u30B0\u3067\u4ED6\u306E\u30B9\u30E9\u30A4\u30B9\u3078\u63A5\u7D9A\uFF09",portTitle:"\u30AF\u30EA\u30C3\u30AF: \u7D9A\u304D\u306E\u4ED8\u7B8B\u3092\u9078\u3093\u3067\u8FFD\u52A0 / \u30C9\u30E9\u30C3\u30B0: \u4ED6\u306E\u30B9\u30E9\u30A4\u30B9\u3078\u63A5\u7D9A",renameContextHint:"\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u540D\u524D\u3092\u5909\u66F4",dissolveContextAria:t=>`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u300C${t}\u300D\u3092\u89E3\u4F53`,dissolveContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u89E3\u4F53\uFF08\u4ED8\u7B8B\u306F\u6B8B\u308A\u307E\u3059\uFF09",noteCount:t=>`${t} \u4ED8\u7B8B`,sliceCount:t=>`${t} \u30B9\u30E9\u30A4\u30B9`,contextCount:t=>`${t} \u30B3\u30F3\u30C6\u30AD\u30B9\u30C8`,hudHint:"\u30DB\u30A4\u30FC\u30EB: \u79FB\u52D5 \xB7 \u30D4\u30F3\u30C1: \u30BA\u30FC\u30E0 \xB7 \u80CC\u666F\u30C9\u30E9\u30C3\u30B0: \u7BC4\u56F2\u9078\u629E",zoomOut:"\u7E2E\u5C0F",zoomReset:"100% \u306B\u623B\u3059",zoomIn:"\u62E1\u5927",zoomFit:"\u5168\u4F53\u3092\u8868\u793A",selectedLinks:t=>`${t} \u672C\u306E\u30EA\u30F3\u30AF\u3092\u9078\u629E\u4E2D`,deleteLinks:"\u30EA\u30F3\u30AF\u3092\u524A\u9664",deleteHint:"Delete \u3067\u3082\u524A\u9664\u3067\u304D\u307E\u3059",clearSelection:"\u9078\u629E\u89E3\u9664",selectedSlices:t=>`${t} \u30B9\u30E9\u30A4\u30B9\u3092\u9078\u629E\u4E2D`,groupIntoContext:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u307E\u3068\u3081\u308B",addToExistingAria:"\u65E2\u5B58\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3078\u8FFD\u52A0",addToExistingOption:"\u65E2\u5B58\u3078\u8FFD\u52A0\u2026",removeFromContext:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u89E3\u9664",deleteButton:"\u524A\u9664"}}),Mh={event:{bg:"linear-gradient(178deg, #ffbc55, #f8a52e)",ink:"#402703"},command:{bg:"linear-gradient(178deg, #93c9f2, #74b4e8)",ink:"#0e2c4b"},aggregate:{bg:"linear-gradient(178deg, #fff3a6, #fdea7e)",ink:"#4a3a06"},actor:{bg:"linear-gradient(178deg, #ffdf63, #fdd23e)",ink:"#423204"},policy:{bg:"linear-gradient(178deg, #dcc2f7, #c9a6f0)",ink:"#32195c"},readmodel:{bg:"linear-gradient(178deg, #c0e788, #a8dc63)",ink:"#22380a"},external:{bg:"linear-gradient(178deg, #f9bcd3, #f4a0c0)",ink:"#4b1029"},hotspot:{bg:"linear-gradient(178deg, #d63550, #b81c33)",ink:"#ffffff"}},Io=t=>{const{bg:e,ink:n}=Mh[t];return`--es-note-bg:${e};--es-note-ink:${n}`},Ih=ae`
2272
+ </ul>`:T}
2273
+ </div>`}#Q(e){const n=this.#e,o=this.#a;if(e.isComposing||n===null)return;const i=o===null?null:sr(ir(this.items()),n.type,o.moved);switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),this.#a=i===null||i.options.length===0?{moved:null}:{moved:i.active+(e.key==="ArrowDown"?1:-1)},this.requestUpdate(),this.updateComplete.then(()=>{const s=this.renderRoot.querySelector(".er-type-options"),r=s?.querySelector('[aria-selected="true"]');s&&r&&Zd(s,r)});return;case"Enter":{const s=i?.options[i.active];if(s===void 0||s.type===n.type.trim()){this.#Y();return}e.preventDefault(),e.stopPropagation(),this.#K(s.type);return}case"Escape":if(o===null)return;e.preventDefault(),e.stopPropagation(),this.#Y();return}}#K(e){this.#e!==null&&(this.#a=null,this.#P({...this.#e,type:e}))}#Y(){this.#a!==null&&(this.#a=null,this.requestUpdate())}#P(e){this.#e={...e,failed:!1},this.requestUpdate()}#q(e,n=!0){const o=this.#e;o!==null&&(e||this.#L(),this.#e=null,this.#a=null,this.requestUpdate(),n&&this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-er-table="${CSS.escape(o.table)}"] ${yr(o)}`)?.focus({preventScroll:!0})))}#Z(e){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.#q(!1);return}if(e.key!=="Enter"||!(e.target instanceof HTMLInputElement)||e.target.type==="checkbox")return;e.preventDefault();const n=this.#e;if(n?.kind==="add"&&e.target.dataset.input==="add-name"&&n.type.trim()===""){e.target.closest(".er-editor")?.querySelector('[data-input="add-type"]')?.focus();return}this.#R()}#R(){const e=this.#e,n=e===null?void 0:this.visible.nodes.find(r=>r.id===e.table);if(e===null||n===void 0||!rr(e,n).ready)return;const o=e.type.trim(),i=e.description.trim();if(!(e.kind==="add"?this.dispatchElementAction(Js,["node",e.table],{id:e.name.trim(),type:o,nullable:e.nullable,description:i}):this.dispatchElementAction(er,["node",e.table],{field:e.field,type:o,nullable:e.nullable,description:i}))){this.#e={...e,failed:!0},this.requestUpdate();return}this.#q(!0)}}const yr=t=>t.kind==="add"?'[data-action="add-field"]':`[data-action="edit-field"][data-field="${CSS.escape(t.field)}"]`,It=t=>t.kind==="add"?`add:${t.table}`:`edit:${t.table}:${t.field}`,kr=()=>{customElements.get("dpk-board-er-diagram")||customElements.define("dpk-board-er-diagram",xr)},Io=["actor","command","aggregate","event","policy","readmodel","external","hotspot"],Dh=P({id:oe,name:S(x(),I(1)),description:j(x()),questions:tt}),Oh=P({id:oe,type:G(Io),name:S(x(),I(1)),description:j(x()),contextId:j(x()),questions:tt}),Nh=P({id:oe,from:S(x(),I(1)),to:S(x(),I(1)),label:j(x()),kind:j(G(["member","flow"]))}),zh=P({title:j(x()),contexts:L(F(Dh),[]),elements:L(F(Oh),[]),links:L(F(Nh),[])}),Ph=t=>{const e=ue(zh,t),n=new Set(e.elements.map(i=>i.id)),o=new Set(e.contexts.map(i=>i.id));for(const i of e.elements)if(i.contextId!==void 0&&!o.has(i.contextId))throw new Error(`unknown context "${i.contextId}" for note "${i.id}"`);for(const i of e.links){if(!n.has(i.from))throw new Error(`unknown note "${i.from}" in link "${i.id}"`);if(!n.has(i.to))throw new Error(`unknown note "${i.to}" in link "${i.id}"`)}return e},qh=()=>({contexts:[],elements:[],links:[]}),pt=(t,e)=>{if(e!==void 0)return t.elements.find(n=>n.id===e)},Ao=(t,e)=>{if(e!==void 0)return t.contexts.find(n=>n.id===e)},Fh=(t,e)=>{if(e!==void 0)return t.links.find(n=>n.id===e)},hn=t=>t.elements.map(e=>e.id),ie={SET_ELEMENT_NAME:z("SET_ELEMENT_NAME","element",_({name:S(x(),I(1))})),SET_ELEMENT_DESCRIPTION:z("SET_ELEMENT_DESCRIPTION","element",_({description:x()})),SET_ELEMENT_TYPE:z("SET_ELEMENT_TYPE","element",_({type:G(Io)})),SET_ELEMENT_CONTEXT:z("SET_ELEMENT_CONTEXT","element",_({contextId:me(x())})),MOVE_ELEMENT:z("MOVE_ELEMENT","element",_({after:me(x())}),{mode:"sequence"}),ADD_ELEMENT:z("ADD_ELEMENT","page",_({id:oe,type:G(Io),name:S(x(),I(1)),description:j(x()),contextId:j(x())}),{dedupeKey:Ce}),DELETE_ELEMENT:z("DELETE_ELEMENT","element",_({})),LINK_ELEMENTS:z("LINK_ELEMENTS","page",_({id:oe,from:S(x(),I(1)),to:S(x(),I(1)),label:j(x()),kind:j(G(["member","flow"]))}),{dedupeKey:Ce}),SET_LINK_LABEL:z("SET_LINK_LABEL","link",_({label:x()})),UNLINK_ELEMENTS:z("UNLINK_ELEMENTS","page",_({from:S(x(),I(1)),to:S(x(),I(1))}),{mode:"sequence"}),ADD_CONTEXT:z("ADD_CONTEXT","page",_({id:oe,name:S(x(),I(1)),description:j(x())}),{dedupeKey:Ce}),SET_CONTEXT_NAME:z("SET_CONTEXT_NAME","context",_({name:S(x(),I(1))})),DELETE_CONTEXT:z("DELETE_CONTEXT","context",_({}))},J={setElementName:(t,e)=>({type:"SET_ELEMENT_NAME",target:{type:"element",id:t},payload:{name:e}}),setElementDescription:(t,e)=>({type:"SET_ELEMENT_DESCRIPTION",target:{type:"element",id:t},payload:{description:e}}),setElementType:(t,e)=>({type:"SET_ELEMENT_TYPE",target:{type:"element",id:t},payload:{type:e}}),setElementContext:(t,e)=>({type:"SET_ELEMENT_CONTEXT",target:{type:"element",id:t},payload:{contextId:e}}),moveElement:(t,e)=>({type:"MOVE_ELEMENT",target:{type:"element",id:t},payload:{after:e}}),addElement:(t,e,n)=>({type:"ADD_ELEMENT",target:{type:"page",id:"event-storming"},payload:{id:t,type:e,name:n}}),deleteElement:t=>({type:"DELETE_ELEMENT",target:{type:"element",id:t},payload:{}}),linkElements:(t,e,n,o)=>({type:"LINK_ELEMENTS",target:{type:"page",id:"event-storming"},payload:{id:t,from:e,to:n,...o?.label===void 0?{}:{label:o.label},...o?.kind===void 0?{}:{kind:o.kind}}}),setLinkLabel:(t,e)=>({type:"SET_LINK_LABEL",target:{type:"link",id:t},payload:{label:e}}),unlinkElements:(t,e)=>({type:"UNLINK_ELEMENTS",target:{type:"page",id:"event-storming"},payload:{from:t,to:e}}),addContext:(t,e)=>({type:"ADD_CONTEXT",target:{type:"page",id:"event-storming"},payload:{id:t,name:e}}),setContextName:(t,e)=>({type:"SET_CONTEXT_NAME",target:{type:"context",id:t},payload:{name:e}}),deleteContext:t=>({type:"DELETE_CONTEXT",target:{type:"context",id:t},payload:{}})},vr={actor:"Actor",command:"Command",aggregate:"Aggregate",event:"Domain Event",policy:"Policy",readmodel:"Read Model",external:"External System",hotspot:"Hotspot"},wr={actor:"\u30A2\u30AF\u30BF\u30FC",command:"\u30B3\u30DE\u30F3\u30C9",aggregate:"\u96C6\u7D04",event:"\u30A4\u30D9\u30F3\u30C8",policy:"\u30DD\u30EA\u30B7\u30FC",readmodel:"\u30EA\u30FC\u30C9\u30E2\u30C7\u30EB",external:"\u5916\u90E8\u30B7\u30B9\u30C6\u30E0",hotspot:"\u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8"},be=pe({en:{heading:"Event Storming",wholeBoard:"Whole board",renameElementTitle:"Rename element",updateDescriptionTitle:"Update element description",changeTypeTitle:"Change element type",changeContextTitle:"Change the element\u2019s context",moveTitle:"Change timeline position",addElementTitle:"Add element",deleteElementTitle:"Delete element",linkTitle:"Link elements",renameLinkTitle:"Change link label",unlinkTitle:"Remove link",addContextTitle:"Add bounded context",renameContextTitle:"Rename bounded context",deleteContextTitle:"Delete bounded context",renamed:(t,e)=>`"${t}" \u2192 "${e}"`,noContext:"No context",moveToFront:"\u2192 To the front",moveAfter:t=>`\u2192 Right after "${t}"`,elementLabel:t=>`Element \xB7 ${t}`,contextLabel:t=>`Bounded context \xB7 ${t}`,linkLabel:(t,e)=>`Link \xB7 ${t}\u2192${e}`,linkGroup:"Link",pageLabel:t=>`Page \xB7 ${t}`,elementGroup:"Element",contextGroup:"Bounded context",noteTypeLabel:t=>vr[t],addTypeLabel:t=>`+ ${vr[t]}`,addHotspot:"+ Hotspot",pinHotspotTitle:"Pin a hotspot on this note",commentNote:"Comment",deleteNote:"Delete",noteNameLabel:"Note name",newContextTitle:"New bounded context",contextNamePlaceholder:"Context name",cancel:"Cancel",create:"Create",save:"Save",appendMenuNext:"Note to add next",appendMenuAfter:t=>`Continue after \u201C${t}\u201D`,emptyTitle:"No notes yet",emptyBody:"Start Event Storming by placing domain events on the timeline.",addFirstEvent:"+ First event",portAriaLabel:"Add what comes next (pick a type, or drag to connect to another slice)",portTitle:"Click: pick a note to continue / Drag: connect to another slice",renameContextHint:"Click to rename",dissolveContextAria:t=>`Dissolve bounded context "${t}"`,dissolveContextTitle:"Dissolve the bounded context (notes stay)",noteCount:t=>`${t} notes`,sliceCount:t=>`${t} slices`,contextCount:t=>`${t} bounded contexts`,hudHint:"Wheel: pan \xB7 Pinch: zoom \xB7 Drag background: select area",zoomOut:"Zoom out",zoomReset:"Reset to 100%",zoomIn:"Zoom in",zoomFit:"Fit to view",selectedLinks:t=>`${t} links selected`,deleteLinks:"Delete links",deleteHint:"Delete works too",clearSelection:"Clear selection",selectedSlices:t=>`${t} slices selected`,groupIntoContext:"Group into a bounded context",addToExistingAria:"Add to an existing bounded context",addToExistingOption:"Add to existing\u2026",removeFromContext:"Remove from context",deleteButton:"Delete"},ja:{heading:"\u30A4\u30D9\u30F3\u30C8\u30B9\u30C8\u30FC\u30DF\u30F3\u30B0",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",renameElementTitle:"\u8981\u7D20\u540D\u3092\u5909\u66F4",updateDescriptionTitle:"\u8981\u7D20\u306E\u8AAC\u660E\u3092\u66F4\u65B0",changeTypeTitle:"\u8981\u7D20\u306E\u7A2E\u5225\u3092\u5909\u66F4",changeContextTitle:"\u6240\u5C5E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4",moveTitle:"\u30BF\u30A4\u30E0\u30E9\u30A4\u30F3\u4F4D\u7F6E\u3092\u5909\u66F4",addElementTitle:"\u8981\u7D20\u3092\u8FFD\u52A0",deleteElementTitle:"\u8981\u7D20\u3092\u524A\u9664",linkTitle:"\u8981\u7D20\u3092\u9023\u7D50",renameLinkTitle:"\u30EA\u30F3\u30AF\u540D\u3092\u5909\u66F4",unlinkTitle:"\u30EA\u30F3\u30AF\u3092\u524A\u9664",addContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u8FFD\u52A0",renameContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u540D\u3092\u5909\u66F4",deleteContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u524A\u9664",renamed:(t,e)=>`"${t}" \u2192 "${e}"`,noContext:"\u672A\u6240\u5C5E",moveToFront:"\u2192 \u5148\u982D\u3078",moveAfter:t=>`\u2192 "${t}" \u306E\u76F4\u5F8C\u3078`,elementLabel:t=>`\u8981\u7D20 \xB7 ${t}`,contextLabel:t=>`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8 \xB7 ${t}`,linkLabel:(t,e)=>`\u30EA\u30F3\u30AF \xB7 ${t}\u2192${e}`,linkGroup:"\u30EA\u30F3\u30AF",pageLabel:t=>`\u30DA\u30FC\u30B8 \xB7 ${t}`,elementGroup:"\u8981\u7D20",contextGroup:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",noteTypeLabel:t=>wr[t],addTypeLabel:t=>`+ ${wr[t]}`,addHotspot:"+ \u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8",pinHotspotTitle:"\u3053\u306E\u4ED8\u7B8B\u306B\u30DB\u30C3\u30C8\u30B9\u30DD\u30C3\u30C8\u3092\u7ACB\u3066\u308B",commentNote:"\u30B3\u30E1\u30F3\u30C8",deleteNote:"\u524A\u9664",noteNameLabel:"\u4ED8\u7B8B\u540D",newContextTitle:"\u65B0\u3057\u3044\u5883\u754C\u3065\u3051\u3089\u308C\u305F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",contextNamePlaceholder:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u540D",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",create:"\u4F5C\u6210",save:"\u4FDD\u5B58",appendMenuNext:"\u7D9A\u304D\u306B\u8FFD\u52A0\u3059\u308B\u4ED8\u7B8B",appendMenuAfter:t=>`\u300C${t}\u300D\u306E\u7D9A\u304D\u306B\u8FFD\u52A0`,emptyTitle:"\u4ED8\u7B8B\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",emptyBody:"\u30A4\u30D9\u30F3\u30C8\u30B9\u30C8\u30FC\u30DF\u30F3\u30B0\u3092\u958B\u59CB\u3057\u307E\u3057\u3087\u3046\u3002\u30C9\u30E1\u30A4\u30F3\u30A4\u30D9\u30F3\u30C8\u3092\u6642\u7CFB\u5217\u306B\u8CBC\u308B\u3068\u3053\u308D\u304B\u3089\u59CB\u3081\u307E\u3059\u3002",addFirstEvent:"+ \u6700\u521D\u306E\u30A4\u30D9\u30F3\u30C8",portAriaLabel:"\u7D9A\u304D\u3092\u8FFD\u52A0\uFF08\u7A2E\u985E\u3092\u9078\u3093\u3067\u8FFD\u52A0 / \u30C9\u30E9\u30C3\u30B0\u3067\u4ED6\u306E\u30B9\u30E9\u30A4\u30B9\u3078\u63A5\u7D9A\uFF09",portTitle:"\u30AF\u30EA\u30C3\u30AF: \u7D9A\u304D\u306E\u4ED8\u7B8B\u3092\u9078\u3093\u3067\u8FFD\u52A0 / \u30C9\u30E9\u30C3\u30B0: \u4ED6\u306E\u30B9\u30E9\u30A4\u30B9\u3078\u63A5\u7D9A",renameContextHint:"\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u540D\u524D\u3092\u5909\u66F4",dissolveContextAria:t=>`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u300C${t}\u300D\u3092\u89E3\u4F53`,dissolveContextTitle:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u89E3\u4F53\uFF08\u4ED8\u7B8B\u306F\u6B8B\u308A\u307E\u3059\uFF09",noteCount:t=>`${t} \u4ED8\u7B8B`,sliceCount:t=>`${t} \u30B9\u30E9\u30A4\u30B9`,contextCount:t=>`${t} \u30B3\u30F3\u30C6\u30AD\u30B9\u30C8`,hudHint:"\u30DB\u30A4\u30FC\u30EB: \u79FB\u52D5 \xB7 \u30D4\u30F3\u30C1: \u30BA\u30FC\u30E0 \xB7 \u80CC\u666F\u30C9\u30E9\u30C3\u30B0: \u7BC4\u56F2\u9078\u629E",zoomOut:"\u7E2E\u5C0F",zoomReset:"100% \u306B\u623B\u3059",zoomIn:"\u62E1\u5927",zoomFit:"\u5168\u4F53\u3092\u8868\u793A",selectedLinks:t=>`${t} \u672C\u306E\u30EA\u30F3\u30AF\u3092\u9078\u629E\u4E2D`,deleteLinks:"\u30EA\u30F3\u30AF\u3092\u524A\u9664",deleteHint:"Delete \u3067\u3082\u524A\u9664\u3067\u304D\u307E\u3059",clearSelection:"\u9078\u629E\u89E3\u9664",selectedSlices:t=>`${t} \u30B9\u30E9\u30A4\u30B9\u3092\u9078\u629E\u4E2D`,groupIntoContext:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u307E\u3068\u3081\u308B",addToExistingAria:"\u65E2\u5B58\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3078\u8FFD\u52A0",addToExistingOption:"\u65E2\u5B58\u3078\u8FFD\u52A0\u2026",removeFromContext:"\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u89E3\u9664",deleteButton:"\u524A\u9664"}}),Uh={event:{bg:"linear-gradient(178deg, #ffbc55, #f8a52e)",ink:"#402703"},command:{bg:"linear-gradient(178deg, #93c9f2, #74b4e8)",ink:"#0e2c4b"},aggregate:{bg:"linear-gradient(178deg, #fff3a6, #fdea7e)",ink:"#4a3a06"},actor:{bg:"linear-gradient(178deg, #ffdf63, #fdd23e)",ink:"#423204"},policy:{bg:"linear-gradient(178deg, #dcc2f7, #c9a6f0)",ink:"#32195c"},readmodel:{bg:"linear-gradient(178deg, #c0e788, #a8dc63)",ink:"#22380a"},external:{bg:"linear-gradient(178deg, #f9bcd3, #f4a0c0)",ink:"#4b1029"},hotspot:{bg:"linear-gradient(178deg, #d63550, #b81c33)",ink:"#ffffff"}},Ro=t=>{const{bg:e,ink:n}=Uh[t];return`--es-note-bg:${e};--es-note-ink:${n}`},Bh=de`
2274
2274
  /*
2275
2275
  * The host is the note's box and its ink. It is never rotated, scaled or
2276
2276
  * filtered: any transform here promotes the note to a composited layer that
@@ -2534,10 +2534,10 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2534
2534
  backdrop-filter: blur(4px);
2535
2535
  box-shadow: var(--dpk-bevel), var(--dpk-shadow-xs);
2536
2536
  }
2537
- `;class Ch extends di{static{this.styles=[ri,Ih,ai]}static{this.properties={note:{attribute:!1},mode:{type:String,reflect:!0,attribute:"data-mode"},focused:{type:Boolean,reflect:!0},compact:{type:Boolean,reflect:!0},onIntent:{attribute:!1}}}#o=new li(this);#i=new MutationObserver(()=>this.#n());constructor(){super(),this.note=null,this.mode="view",this.focused=!1,this.compact=!1,this.onIntent=null,this.addEventListener("click",()=>this.#a({kind:"select"}))}connectedCallback(){super.connectedCallback(),this.#e(),this.#n()}disconnectedCallback(){super.disconnectedCallback(),this.#i.disconnect()}updated(e){e.has("note")&&this.note&&(this.setAttribute("data-type",this.note.type),this.note.description===void 0?this.removeAttribute("title"):this.setAttribute("title",this.note.description)),e.has("mode")&&this.mode==="editing"&&this.renderRoot.querySelector("dpk-inline-edit")?.startEditing(),this.#e(),this.#n()}#e(){const e=this.renderRoot.querySelector("dpk-inline-edit");e&&this.#i.observe(e,{attributes:!0,attributeFilter:["data-editing"]})}#n(){const e=this.renderRoot.querySelector("dpk-inline-edit")?.hasAttribute("data-editing")??!1;this.toggleAttribute("data-editing",e)}render(){const e=this.note;if(!e)return M;const n=fe(this.#o.locale);return v`
2537
+ `;class Hh extends ui{static{this.styles=[pi,Bh,hi]}static{this.properties={note:{attribute:!1},mode:{type:String,reflect:!0,attribute:"data-mode"},focused:{type:Boolean,reflect:!0},compact:{type:Boolean,reflect:!0},onIntent:{attribute:!1}}}#o=new mi(this);#i=new MutationObserver(()=>this.#t());constructor(){super(),this.note=null,this.mode="view",this.focused=!1,this.compact=!1,this.onIntent=null,this.addEventListener("click",()=>this.#a({kind:"select"}))}connectedCallback(){super.connectedCallback(),this.#e(),this.#t()}disconnectedCallback(){super.disconnectedCallback(),this.#i.disconnect()}updated(e){e.has("note")&&this.note&&(this.setAttribute("data-type",this.note.type),this.note.description===void 0?this.removeAttribute("title"):this.setAttribute("title",this.note.description)),e.has("mode")&&this.mode==="editing"&&this.renderRoot.querySelector("dpk-inline-edit")?.startEditing(),this.#e(),this.#t()}#e(){const e=this.renderRoot.querySelector("dpk-inline-edit");e&&this.#i.observe(e,{attributes:!0,attributeFilter:["data-editing"]})}#t(){const e=this.renderRoot.querySelector("dpk-inline-edit")?.hasAttribute("data-editing")??!1;this.toggleAttribute("data-editing",e)}render(){const e=this.note;if(!e)return T;const n=be(this.#o.locale);return k`
2538
2538
  <div class="paper" aria-hidden="true"></div>
2539
2539
  <div class="note-type">${n.noteTypeLabel(e.type)}</div>
2540
- <div class="note-editing" aria-hidden="true">${gi()}</div>
2540
+ <div class="note-editing" aria-hidden="true">${ki()}</div>
2541
2541
  <dpk-inline-edit
2542
2542
  class="note-name"
2543
2543
  ?wrap=${!0}
@@ -2545,14 +2545,14 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2545
2545
  ?seamless=${!0}
2546
2546
  .value=${e.name}
2547
2547
  .label=${n.noteNameLabel}
2548
- @dpk-commit=${Hn(o=>this.#a({kind:"rename",name:o}))}
2548
+ @dpk-commit=${nt(o=>this.#a({kind:"rename",name:o}))}
2549
2549
  ></dpk-inline-edit>
2550
- ${e.type==="hotspot"?M:v`<button
2550
+ ${e.type==="hotspot"?T:k`<button
2551
2551
  class="note-hotspot"
2552
2552
  type="button"
2553
2553
  data-role="hotspot"
2554
2554
  title=${n.pinHotspotTitle}
2555
- @click=${this.#t(()=>({kind:"add-hotspot"}))}
2555
+ @click=${this.#n(()=>({kind:"add-hotspot"}))}
2556
2556
  >
2557
2557
  ${n.addHotspot}
2558
2558
  </button>`}
@@ -2562,21 +2562,21 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2562
2562
  type="button"
2563
2563
  data-role="comment"
2564
2564
  aria-label=${n.commentNote}
2565
- @click=${this.#t(()=>({kind:"comment"}))}
2565
+ @click=${this.#n(()=>({kind:"comment"}))}
2566
2566
  >
2567
- ${Yn()}
2567
+ ${Xn()}
2568
2568
  </button>
2569
2569
  <button
2570
2570
  class="dpk-icon-btn"
2571
2571
  type="button"
2572
2572
  data-role="delete"
2573
2573
  aria-label=${n.deleteNote}
2574
- @click=${this.#t(()=>({kind:"delete"}))}
2574
+ @click=${this.#n(()=>({kind:"delete"}))}
2575
2575
  >
2576
- ${Ft()}
2576
+ ${Bt()}
2577
2577
  </button>
2578
2578
  </div>
2579
- `}#t(e){return n=>{n.stopPropagation(),this.#a(e(n))}}#a(e){this.onIntent?.(e)}}const Lh=()=>{customElements.get("dpk-internal-event-storming-note")||customElements.define("dpk-internal-event-storming-note",Ch)},fr=.25,_h=2,Rh=(t,e,n)=>({...t,panX:t.panX+e,panY:t.panY+n}),br=(t,e,n,o)=>{const i=bt(t.zoom*o,fr,_h),s=(e-t.panX)/t.zoom,r=(n-t.panY)/t.zoom;return{panX:e-s*i,panY:n-r*i,zoom:i}},Ah=(t,e,n)=>{const o=Math.max(1,e.width-n*2),i=Math.max(1,e.height-n*2),s=Math.max(fr,Math.min(1,o/Math.max(1,t.width),i/Math.max(1,t.height)));return{panX:(e.width-t.width*s)/2,panY:(e.height-t.height*s)/2,zoom:s}},Oh=(t,e,n,o)=>{const i=(s,r,a,d)=>{const l=a*t.zoom;return l<=d?(d-l)/2-r*t.zoom:Math.min(-r*t.zoom,Math.max(d-(r+a)*t.zoom,s))};return{zoom:t.zoom,panX:i(t.panX,-o,e.width+o*2,n.width),panY:i(t.panY,-o,e.height+o*2,n.height)}},Nh=(t,e,n)=>e>=t.left&&e<=t.left+t.width&&n>=t.top&&n<=t.top+t.height,xr=(t,e,n)=>{for(let o=t.length-1;o>=0;o-=1){const i=t[o];if(i!==void 0&&Nh(i.rect,e,n))return i.id}},Dh=(t,e)=>e<t.left+t.width/2?"before":"after",zh=(t,e)=>t.filter(({rect:n})=>n.left<e.left+e.width&&e.left<n.left+n.width&&n.top<e.top+e.height&&e.top<n.top+n.height).map(({id:n})=>n),yr=(t,e,n,o)=>{const i=new Set(e);if(n.some(c=>i.has(c)))return[];const s=t.filter(c=>!i.has(c)),r=n.map(c=>s.indexOf(c)).filter(c=>c>=0);if(r.length===0)return[];const a=o==="before"?Math.min(...r):Math.max(...r)+1,d=[];let l=s[a-1]??null;for(const c of t)i.has(c)&&(d.push({id:c,after:l}),l=c);return d},Ph=(t,e,n,o)=>{const i=yr(t,e,n,o);if(i.length===0)return i;const s=[...t];for(const r of i){const a=s.indexOf(r.id),d=a<0?void 0:s[a];d!==void 0&&(s.splice(a,1),s.splice(r.after===null?0:s.indexOf(r.after)+1,0,d))}return Fd(s,t)?[]:i},vr=(t,e,n,o=4)=>{if(e.pointerId!==t.pointerId)return t;const{point:i}=e,s={pointerId:t.pointerId,start:t.start,current:i,moved:t.moved||Math.hypot(i.x-t.start.x,i.y-t.start.y)>o},r=xr(n,i.x,i.y);switch(t.kind){case"connect":return{...s,kind:"connect",fromSliceId:t.fromSliceId,...r!==void 0&&r!==t.fromSliceId?{targetSliceId:r}:{}};case"move-slice":{const a=n.find(d=>d.id===r)?.rect;return{...s,kind:"move-slice",sliceId:t.sliceId,...r!==void 0&&r!==t.sliceId&&a!==void 0?{drop:{sliceId:r,side:Dh(a,i.x)}}:{}}}case"select":return{...s,kind:"select"}}},qh=new Set(["actor>command","command>aggregate","aggregate>event","command>event","policy>command","external>event"]),Co=(t,e)=>qh.has(`${t}>${e}`),Fh=(t,e,n)=>t.kind!==void 0?t.kind==="member":Co(e,n),Bh=["readmodel","actor","policy","command","aggregate","external","event","hotspot"],Uh=(t,e)=>{const n=new Map;for(const o of t.links){const i=e.get(o.from),s=e.get(o.to);if(i===void 0||s===void 0||i==="hotspot"==(s==="hotspot")||o.kind!==void 0&&o.kind!=="member")continue;const r=i==="hotspot"?o.from:o.to;n.has(r)||n.set(r,i==="hotspot"?o.to:o.from)}return n},Hh=(t,e,n)=>{const o=new Map(t.map(a=>[a.id,a.id])),i=a=>{let d=a;for(;o.get(d)!==d;)d=o.get(d)??d;let l=a;for(;l!==d;){const c=o.get(l)??d;o.set(l,d),l=c}return d};for(const a of e){if(!o.has(a.from)||!o.has(a.to))continue;const d=n.get(a.from),l=n.get(a.to);d===void 0||l===void 0||Fh(a,d,l)&&o.set(i(a.from),i(a.to))}const s=new Map,r=new Map;for(const a of t){const d=i(a.id);r.set(a.id,d);const l=s.get(d);l?l.push(a):s.set(d,[a])}return{groups:s,rootOf:r}},dt=t=>{const e=new Map(t.elements.map(l=>[l.id,l.type])),n=Uh(t,e),o=t.elements.filter(l=>!n.has(l.id)),{groups:i,rootOf:s}=Hh(o,t.links,e),r=new Map;for(const[l,c]of n){const h=at(t,l),p=s.get(c);if(h===void 0||p===void 0)continue;const u=r.get(p);u?u.push({note:h,targetId:c}):r.set(p,[{note:h,targetId:c}])}const a=new Map(Bh.map((l,c)=>[l,c])),d=new Map(t.elements.map((l,c)=>[l.id,c]));return[...i].map(([l,c])=>{const h=[...c].sort((p,u)=>(a.get(p.type)??0)-(a.get(u.type)??0)||(d.get(p.id)??0)-(d.get(u.id)??0));return{id:c[0]?.id??"",notes:h,pins:r.get(l)??[],contextId:c.find(p=>p.contextId!==void 0)?.contextId}})},Yh=(t,e)=>{const n=[...t.notes,...t.pins.map(r=>r.note)],o=n.find(r=>Co(e,r.type));if(o!==void 0)return{anchorId:o.id,incoming:!0};const i=n.find(r=>Co(r.type,e));if(i!==void 0)return{anchorId:i.id,incoming:!1};const s=n[0];return s===void 0?void 0:{anchorId:s.id,incoming:!0}},Xh=(t,e)=>{const n=new Map(e.flatMap(o=>o.notes.map(i=>[i.id,o.id])));return t.links.flatMap(o=>{const i=n.get(o.from),s=n.get(o.to);return i===void 0||s===void 0||i===s?[]:[{id:o.id,from:i,to:s,...o.label!==void 0?{label:o.label}:{}}]})},Lo=(t,e)=>`${t}\0${e}`,Gh=(t,e,n)=>{const{widthOf:o,gapX:i,padX:s,maxWidth:r}=n,a=new Map;for(const g of e)a.set(Lo(g.from,g.to),g),a.set(Lo(g.to,g.from),g);const d=(g,b)=>g===void 0||b===void 0?void 0:a.get(Lo(g,b)),l=g=>hl(g,b=>o(b))+i*Math.max(0,g.length-1)+s*2<=r,c=[];let h=[],p;const u=()=>{h.length!==0&&(c.push({sliceIds:h,...p===void 0?{}:{cutFrom:p}}),h=[],p=void 0)};for(const g of t.map(b=>b.id)){if(h.length>0&&!l([...h,g])){let b=h.length;for(;d(h[b-1],b===h.length?g:h[b])!==void 0&&(b-=1,b!==0););const f=b===0?[]:h.splice(b),m=b===0?d(h.at(-1),g):d(h.at(-1),f[0]);u(),h=f,p=m}h.push(g)}return u(),c},pn=t=>[...t.notes].reverse().find(e=>e.type==="event")??t.notes.at(-1),Kh=(t,e)=>{const n=pn(t),o=e.notes[0];if(!(n===void 0||o===void 0))return{from:n.id,to:o.id}},_o="data-pin";class jh{#o;#i=new Set;#e;#n=new Map;constructor(e){this.#o=e,e.addController(this)}get heights(){return this.#n}hostConnected(){typeof ResizeObserver>"u"||(this.#e=new ResizeObserver(e=>this.#t(e)))}hostUpdated(){const e=this.#e;if(e===void 0)return;const n=new Set(this.#o.renderRoot.querySelectorAll(`[${_o}]`));for(const i of this.#i)n.has(i)||(e.unobserve(i),this.#i.delete(i));for(const i of n)this.#i.has(i)||(e.observe(i),this.#i.add(i));const o=new Set([...n].map(i=>i.getAttribute(_o)));[...this.#n.keys()].some(i=>!o.has(i))&&(this.#n=new Map([...this.#n].filter(([i])=>o.has(i))))}hostDisconnected(){this.#e?.disconnect(),this.#e=void 0,this.#i.clear()}#t(e){const n=new Map(this.#n);for(const o of e){const i=o.target.getAttribute(_o),s=o.borderBoxSize[0]?.blockSize;i===null||s===void 0||s===0||n.set(i,s)}[...n].every(([o,i])=>this.#n.get(o)===i)||(this.#n=n,this.#o.requestUpdate())}}const Wh=(t,e)=>{const n=Bt(ie,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_ELEMENT_NAME":return hn(t,o,i=>({...i,name:n.payload.name}));case"SET_ELEMENT_DESCRIPTION":return hn(t,o,i=>({...i,description:n.payload.description}));case"SET_ELEMENT_TYPE":return hn(t,o,i=>({...i,type:n.payload.type}));case"SET_ELEMENT_CONTEXT":{const{contextId:i}=n.payload;return i!==null&&!t.contexts.some(s=>s.id===i)?null:hn(t,o,s=>i===null?kr(s):{...s,contextId:i})}case"MOVE_ELEMENT":{const{after:i}=n.payload,s=Vh(t.elements,o,i);return s===null?null:{...t,elements:s}}case"ADD_ELEMENT":{const i=n.payload;if(t.elements.some(r=>r.id===i.id))return t;if(i.contextId!==void 0&&!t.contexts.some(r=>r.id===i.contextId))return null;const s={id:i.id,type:i.type,name:i.name,...i.description===void 0?{}:{description:i.description},...i.contextId===void 0?{}:{contextId:i.contextId}};return{...t,elements:[...t.elements,s]}}case"DELETE_ELEMENT":return t.elements.some(i=>i.id===o)?{...t,elements:t.elements.filter(i=>i.id!==o),links:t.links.filter(i=>i.from!==o&&i.to!==o)}:null;case"LINK_ELEMENTS":{const i=n.payload;return t.links.some(s=>s.id===i.id)?t:!t.elements.some(s=>s.id===i.from)||!t.elements.some(s=>s.id===i.to)?null:{...t,links:[...t.links,{id:i.id,from:i.from,to:i.to,...i.label===void 0?{}:{label:i.label},...i.kind===void 0?{}:{kind:i.kind}}]}}case"SET_LINK_LABEL":return t.links.some(i=>i.id===o)?{...t,links:t.links.map(i=>i.id===o?{...i,label:n.payload.label}:i)}:null;case"UNLINK_ELEMENTS":{const i=n.payload;return t.links.some(s=>s.from===i.from&&s.to===i.to)?{...t,links:t.links.filter(s=>!(s.from===i.from&&s.to===i.to))}:null}case"ADD_CONTEXT":{const i=n.payload;if(t.contexts.some(r=>r.id===i.id))return t;const s={id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}};return{...t,contexts:[...t.contexts,s]}}case"SET_CONTEXT_NAME":return t.contexts.some(i=>i.id===o)?{...t,contexts:t.contexts.map(i=>i.id===o?{...i,name:n.payload.name}:i)}:null;case"DELETE_CONTEXT":return t.contexts.some(i=>i.id===o)?{...t,contexts:t.contexts.filter(i=>i.id!==o),elements:t.elements.map(i=>i.contextId===o?kr(i):i)}:null;default:return Xn(n)}},kr=t=>{const e={...t};return delete e.contextId,e},hn=(t,e,n)=>t.elements.some(o=>o.id===e)?{...t,elements:t.elements.map(o=>o.id===e?n(o):o)}:null,Vh=(t,e,n)=>{const o=t.findIndex(a=>a.id===e);if(o<0||n!==null&&!t.some(a=>a.id===n))return null;const i=t[o];if(i===void 0)return null;const r=[...t.filter(a=>a.id!==e)];return r.splice(n===null?0:r.findIndex(a=>a.id===n)+1,0,i),r},Qh={SET_ELEMENT_NAME:(t,e,n)=>({title:t.renameElementTitle,tone:"update",body:t.renamed(at(n,e.target.id)?.name??"?",B(ie.SET_ELEMENT_NAME,e).name)}),SET_ELEMENT_DESCRIPTION:(t,e)=>({title:t.updateDescriptionTitle,tone:"update",body:`\u2192 "${B(ie.SET_ELEMENT_DESCRIPTION,e).description.slice(0,60)}"`}),SET_ELEMENT_TYPE:(t,e)=>({title:t.changeTypeTitle,tone:"update",body:`\u2192 ${B(ie.SET_ELEMENT_TYPE,e).type}`}),SET_ELEMENT_CONTEXT:(t,e)=>({title:t.changeContextTitle,tone:"move",body:`\u2192 ${B(ie.SET_ELEMENT_CONTEXT,e).contextId??t.noContext}`}),MOVE_ELEMENT:(t,e)=>({title:t.moveTitle,tone:"move",body:B(ie.MOVE_ELEMENT,e).after===null?t.moveToFront:t.moveAfter(B(ie.MOVE_ELEMENT,e).after??"")}),ADD_ELEMENT:(t,e)=>({title:t.addElementTitle,tone:"create",body:`+ "${B(ie.ADD_ELEMENT,e).name}"`}),DELETE_ELEMENT:(t,e,n)=>({title:t.deleteElementTitle,tone:"delete",body:`\u2212 "${at(n,e.target.id)?.name??e.target.id}"`}),LINK_ELEMENTS:(t,e)=>({title:t.linkTitle,tone:"create",body:`${B(ie.LINK_ELEMENTS,e).from} \u2192 ${B(ie.LINK_ELEMENTS,e).to}`}),SET_LINK_LABEL:(t,e)=>({title:t.renameLinkTitle,tone:"update",body:`\u2192 "${B(ie.SET_LINK_LABEL,e).label}"`}),UNLINK_ELEMENTS:(t,e)=>({title:t.unlinkTitle,tone:"delete",body:`${B(ie.UNLINK_ELEMENTS,e).from} \u2192 ${B(ie.UNLINK_ELEMENTS,e).to}`}),ADD_CONTEXT:(t,e)=>({title:t.addContextTitle,tone:"create",body:`+ "${B(ie.ADD_CONTEXT,e).name}"`}),SET_CONTEXT_NAME:(t,e)=>({title:t.renameContextTitle,tone:"update",body:`\u2192 "${B(ie.SET_CONTEXT_NAME,e).name}"`}),DELETE_CONTEXT:(t,e,n)=>({title:t.deleteContextTitle,tone:"delete",body:`\u2212 "${Mo(n,e.target.id)?.name??e.target.id}"`})},wr=(t,e,n,o)=>{const i=Qh[e.type],r=i?i(t,e,o??n):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:Zh(t,n,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},Zh=(t,e,n)=>{switch(n.type){case"element":{const o=at(e,n.id);return o?t.elementLabel(o.name):`${t.elementLabel(n.id)} (missing)`}case"context":{const o=Mo(e,n.id);return o?t.contextLabel(o.name):`${t.contextLabel(n.id)} (missing)`}case"link":{const o=Sh(e,n.id);return o?t.linkLabel(o.from,o.to):`${t.linkGroup} \xB7 ${n.id} (missing)`}case"page":return t.pageLabel(e.title??"Event Storming");default:return`${n.type} \xB7 ${n.id}`}},Jh=t=>t==="comment"?"meta":t,eu=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},tu=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=wr(t,s,o).title;if(!(s.type in ie)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=eu(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Wh(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=wr(t,d,l,o);i.push({id:s.id,title:c.title,tone:Jh(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Le={kind:"idle"},nu=(t,e)=>t.kind==="editing"&&t.noteId===e?"editing":"view",ou=(t,e,n)=>{switch(n.kind){case"delete":return Le;case"select":case"add-hotspot":return t;case"rename":return t.kind==="editing"&&t.noteId===e?Le:t}},iu=6,su=10,$r="\u2026",ru=[[4352,4447],[11904,42191],[44032,55203],[63744,64255],[65072,65103],[65280,65376],[65504,65510],[127744,129791],[131072,262141]],Ro=t=>{const e=t.codePointAt(0)??0;return ru.some(([n,o])=>e>=n&&e<=o)?su:iu},au=(t,e)=>{const n=Array.from(t);if(n.reduce((s,r)=>s+Ro(r),0)<=e)return t;let o=Ro($r),i="";for(const s of n){if(o+=Ro(s),o>e)break;i+=s}return`${i}${$r}`},Er=92,Ao=54,du=18,Tr=4,Sr=t=>{const e=[];let n=du;for(const o of t)e.push(n),n+=o+Tr;return{lifts:e,extent:t.length===0?0:n-Tr}},Mr=240,It=132,Ir=96,Oo=10,un=24,mn=12,_e=Ir+mn*2,gn=46,fn=16,Cr=44,Lr=40,No=16,_r=13,lt=8,lu=6,cu=26,pu=(t,e)=>Math.max(Cr,t-mn+(e?cu:0)),hu=Sr([Ao]).extent,uu=["actor","command","aggregate","event","policy","readmodel","external"],Rr=t=>un*2+t*It+(t-1)*Oo,mu=(t,e)=>{const n=new Map;let o=0;for(const i of t.notes){const s=t.pins.filter(a=>a.targetId===i.id),r=Sr(s.map(a=>e(a.note.id)));s.forEach((a,d)=>n.set(a.note.id,r.lifts[d]??0)),o=Math.max(o,r.extent)}return{liftOf:n,extent:o}},gu=(t,e,n,o)=>{const i=new Map(e.map(f=>[f.id,Rr(f.notes.length)])),s=Xh(t,e),r=Gh(e,s,{widthOf:f=>i.get(f)??0,gapX:gn,padX:fn,maxWidth:Math.max(n,Rr(1))}),a=new Map,d=new Map,l=new Map,c=new Map,h=new Map,p=new Map(e.map(f=>[f.id,f.contextId]));for(const f of e){const m=mu(f,x=>o.get(x)??Ao);for(const[x,k]of m.liftOf)c.set(x,k);h.set(f.id,m.extent)}let u=lt;const g=r.map((f,m)=>{const x=f.cutFrom===void 0?void 0:d.get(f.cutFrom.from),k=x===void 0?0:Math.max(0,x-fn);let w=k+fn;const $=pu(Math.max(hu,...f.sliceIds.map(T=>h.get(T)??0)),f.sliceIds.some(T=>p.get(T)!==void 0));for(const T of f.sliceIds)a.set(T,w-k),d.set(T,w),l.set(T,m),w+=(i.get(T)??0)+gn;const L=$+_e+Lr,S={sliceIds:f.sliceIds,x:k,width:w-gn+fn-k,height:L,y:u,head:$,cutFrom:f.cutFrom};return u+=L+lu,S}),b=g.at(-1);return{slices:e,bands:g,xOf:a,absXOf:d,bandOf:l,widthOf:i,pinLiftOf:c,arrows:s,width:Math.max(0,...g.map(f=>f.x+f.width))+lt*2,height:b===void 0?lt*2:b.y+b.height+lt}},fu=t=>{const{m:e,state:n,maxRowWidth:o,pinHeights:i,viewport:s,handlers:r}=t,a=24*s.zoom,d=`background-size:${a}px ${a}px;background-position:${s.panX}px ${s.panY}px`;if(n.elements.length===0)return v`<div class="board-viewport board-viewport--empty" style=${d}>
2579
+ `}#n(e){return n=>{n.stopPropagation(),this.#a(e(n))}}#a(e){this.onIntent?.(e)}}const Yh=()=>{customElements.get("dpk-internal-event-storming-note")||customElements.define("dpk-internal-event-storming-note",Hh)},$r=.25,Gh=2,Xh=(t,e,n)=>({...t,panX:t.panX+e,panY:t.panY+n}),Er=(t,e,n,o)=>{const i=kt(t.zoom*o,$r,Gh),s=(e-t.panX)/t.zoom,r=(n-t.panY)/t.zoom;return{panX:e-s*i,panY:n-r*i,zoom:i}},Kh=(t,e,n)=>{const o=Math.max(1,e.width-n*2),i=Math.max(1,e.height-n*2),s=Math.max($r,Math.min(1,o/Math.max(1,t.width),i/Math.max(1,t.height)));return{panX:(e.width-t.width*s)/2,panY:(e.height-t.height*s)/2,zoom:s}},jh=(t,e,n,o)=>{const i=(s,r,a,d)=>{const l=a*t.zoom;return l<=d?(d-l)/2-r*t.zoom:Math.min(-r*t.zoom,Math.max(d-(r+a)*t.zoom,s))};return{zoom:t.zoom,panX:i(t.panX,-o,e.width+o*2,n.width),panY:i(t.panY,-o,e.height+o*2,n.height)}},Wh=(t,e,n)=>e>=t.left&&e<=t.left+t.width&&n>=t.top&&n<=t.top+t.height,Tr=(t,e,n)=>{for(let o=t.length-1;o>=0;o-=1){const i=t[o];if(i!==void 0&&Wh(i.rect,e,n))return i.id}},Vh=(t,e)=>e<t.left+t.width/2?"before":"after",Qh=(t,e)=>t.filter(({rect:n})=>n.left<e.left+e.width&&e.left<n.left+n.width&&n.top<e.top+e.height&&e.top<n.top+n.height).map(({id:n})=>n),Sr=(t,e,n,o)=>{const i=new Set(e);if(n.some(c=>i.has(c)))return[];const s=t.filter(c=>!i.has(c)),r=n.map(c=>s.indexOf(c)).filter(c=>c>=0);if(r.length===0)return[];const a=o==="before"?Math.min(...r):Math.max(...r)+1,d=[];let l=s[a-1]??null;for(const c of t)i.has(c)&&(d.push({id:c,after:l}),l=c);return d},Zh=(t,e,n,o)=>{const i=Sr(t,e,n,o);if(i.length===0)return i;const s=[...t];for(const r of i){const a=s.indexOf(r.id),d=a<0?void 0:s[a];d!==void 0&&(s.splice(a,1),s.splice(r.after===null?0:s.indexOf(r.after)+1,0,d))}return Jd(s,t)?[]:i},Mr=(t,e,n,o=4)=>{if(e.pointerId!==t.pointerId)return t;const{point:i}=e,s={pointerId:t.pointerId,start:t.start,current:i,moved:t.moved||Math.hypot(i.x-t.start.x,i.y-t.start.y)>o},r=Tr(n,i.x,i.y);switch(t.kind){case"connect":return{...s,kind:"connect",fromSliceId:t.fromSliceId,...r!==void 0&&r!==t.fromSliceId?{targetSliceId:r}:{}};case"move-slice":{const a=n.find(d=>d.id===r)?.rect;return{...s,kind:"move-slice",sliceId:t.sliceId,...r!==void 0&&r!==t.sliceId&&a!==void 0?{drop:{sliceId:r,side:Vh(a,i.x)}}:{}}}case"select":return{...s,kind:"select"}}},Jh=new Set(["actor>command","command>aggregate","aggregate>event","command>event","policy>command","external>event"]),_o=(t,e)=>Jh.has(`${t}>${e}`),eu=(t,e,n)=>t.kind!==void 0?t.kind==="member":_o(e,n),tu=["readmodel","actor","policy","command","aggregate","external","event","hotspot"],nu=(t,e)=>{const n=new Map;for(const o of t.links){const i=e.get(o.from),s=e.get(o.to);if(i===void 0||s===void 0||i==="hotspot"==(s==="hotspot")||o.kind!==void 0&&o.kind!=="member")continue;const r=i==="hotspot"?o.from:o.to;n.has(r)||n.set(r,i==="hotspot"?o.to:o.from)}return n},ou=(t,e,n)=>{const o=new Map(t.map(a=>[a.id,a.id])),i=a=>{let d=a;for(;o.get(d)!==d;)d=o.get(d)??d;let l=a;for(;l!==d;){const c=o.get(l)??d;o.set(l,d),l=c}return d};for(const a of e){if(!o.has(a.from)||!o.has(a.to))continue;const d=n.get(a.from),l=n.get(a.to);d===void 0||l===void 0||eu(a,d,l)&&o.set(i(a.from),i(a.to))}const s=new Map,r=new Map;for(const a of t){const d=i(a.id);r.set(a.id,d);const l=s.get(d);l?l.push(a):s.set(d,[a])}return{groups:s,rootOf:r}},ht=t=>{const e=new Map(t.elements.map(l=>[l.id,l.type])),n=nu(t,e),o=t.elements.filter(l=>!n.has(l.id)),{groups:i,rootOf:s}=ou(o,t.links,e),r=new Map;for(const[l,c]of n){const h=pt(t,l),p=s.get(c);if(h===void 0||p===void 0)continue;const u=r.get(p);u?u.push({note:h,targetId:c}):r.set(p,[{note:h,targetId:c}])}const a=new Map(tu.map((l,c)=>[l,c])),d=new Map(t.elements.map((l,c)=>[l.id,c]));return[...i].map(([l,c])=>{const h=[...c].sort((p,u)=>(a.get(p.type)??0)-(a.get(u.type)??0)||(d.get(p.id)??0)-(d.get(u.id)??0));return{id:c[0]?.id??"",notes:h,pins:r.get(l)??[],contextId:c.find(p=>p.contextId!==void 0)?.contextId}})},iu=(t,e)=>{const n=[...t.notes,...t.pins.map(r=>r.note)],o=n.find(r=>_o(e,r.type));if(o!==void 0)return{anchorId:o.id,incoming:!0};const i=n.find(r=>_o(r.type,e));if(i!==void 0)return{anchorId:i.id,incoming:!1};const s=n[0];return s===void 0?void 0:{anchorId:s.id,incoming:!0}},su=(t,e)=>{const n=new Map(e.flatMap(o=>o.notes.map(i=>[i.id,o.id])));return t.links.flatMap(o=>{const i=n.get(o.from),s=n.get(o.to);return i===void 0||s===void 0||i===s?[]:[{id:o.id,from:i,to:s,...o.label!==void 0?{label:o.label}:{}}]})},Do=(t,e)=>`${t}\0${e}`,ru=(t,e,n)=>{const{widthOf:o,gapX:i,padX:s,maxWidth:r}=n,a=new Map;for(const g of e)a.set(Do(g.from,g.to),g),a.set(Do(g.to,g.from),g);const d=(g,b)=>g===void 0||b===void 0?void 0:a.get(Do(g,b)),l=g=>Sl(g,b=>o(b))+i*Math.max(0,g.length-1)+s*2<=r,c=[];let h=[],p;const u=()=>{h.length!==0&&(c.push({sliceIds:h,...p===void 0?{}:{cutFrom:p}}),h=[],p=void 0)};for(const g of t.map(b=>b.id)){if(h.length>0&&!l([...h,g])){let b=h.length;for(;d(h[b-1],b===h.length?g:h[b])!==void 0&&(b-=1,b!==0););const f=b===0?[]:h.splice(b),m=b===0?d(h.at(-1),g):d(h.at(-1),f[0]);u(),h=f,p=m}h.push(g)}return u(),c},un=t=>[...t.notes].reverse().find(e=>e.type==="event")??t.notes.at(-1),au=(t,e)=>{const n=un(t),o=e.notes[0];if(!(n===void 0||o===void 0))return{from:n.id,to:o.id}},Oo="data-pin";class du{#o;#i=new Set;#e;#t=new Map;constructor(e){this.#o=e,e.addController(this)}get heights(){return this.#t}hostConnected(){typeof ResizeObserver>"u"||(this.#e=new ResizeObserver(e=>this.#n(e)))}hostUpdated(){const e=this.#e;if(e===void 0)return;const n=new Set(this.#o.renderRoot.querySelectorAll(`[${Oo}]`));for(const i of this.#i)n.has(i)||(e.unobserve(i),this.#i.delete(i));for(const i of n)this.#i.has(i)||(e.observe(i),this.#i.add(i));const o=new Set([...n].map(i=>i.getAttribute(Oo)));[...this.#t.keys()].some(i=>!o.has(i))&&(this.#t=new Map([...this.#t].filter(([i])=>o.has(i))))}hostDisconnected(){this.#e?.disconnect(),this.#e=void 0,this.#i.clear()}#n(e){const n=new Map(this.#t);for(const o of e){const i=o.target.getAttribute(Oo),s=o.borderBoxSize[0]?.blockSize;i===null||s===void 0||s===0||n.set(i,s)}[...n].every(([o,i])=>this.#t.get(o)===i)||(this.#t=n,this.#o.requestUpdate())}}const lu=(t,e)=>{const n=Ht(ie,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_ELEMENT_NAME":return mn(t,o,i=>({...i,name:n.payload.name}));case"SET_ELEMENT_DESCRIPTION":return mn(t,o,i=>({...i,description:n.payload.description}));case"SET_ELEMENT_TYPE":return mn(t,o,i=>({...i,type:n.payload.type}));case"SET_ELEMENT_CONTEXT":{const{contextId:i}=n.payload;return i!==null&&!t.contexts.some(s=>s.id===i)?null:mn(t,o,s=>i===null?Cr(s):{...s,contextId:i})}case"MOVE_ELEMENT":{const{after:i}=n.payload,s=cu(t.elements,o,i);return s===null?null:{...t,elements:s}}case"ADD_ELEMENT":{const i=n.payload;if(t.elements.some(r=>r.id===i.id))return t;if(i.contextId!==void 0&&!t.contexts.some(r=>r.id===i.contextId))return null;const s={id:i.id,type:i.type,name:i.name,...i.description===void 0?{}:{description:i.description},...i.contextId===void 0?{}:{contextId:i.contextId}};return{...t,elements:[...t.elements,s]}}case"DELETE_ELEMENT":return t.elements.some(i=>i.id===o)?{...t,elements:t.elements.filter(i=>i.id!==o),links:t.links.filter(i=>i.from!==o&&i.to!==o)}:null;case"LINK_ELEMENTS":{const i=n.payload;return t.links.some(s=>s.id===i.id)?t:!t.elements.some(s=>s.id===i.from)||!t.elements.some(s=>s.id===i.to)?null:{...t,links:[...t.links,{id:i.id,from:i.from,to:i.to,...i.label===void 0?{}:{label:i.label},...i.kind===void 0?{}:{kind:i.kind}}]}}case"SET_LINK_LABEL":return t.links.some(i=>i.id===o)?{...t,links:t.links.map(i=>i.id===o?{...i,label:n.payload.label}:i)}:null;case"UNLINK_ELEMENTS":{const i=n.payload;return t.links.some(s=>s.from===i.from&&s.to===i.to)?{...t,links:t.links.filter(s=>!(s.from===i.from&&s.to===i.to))}:null}case"ADD_CONTEXT":{const i=n.payload;if(t.contexts.some(r=>r.id===i.id))return t;const s={id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}};return{...t,contexts:[...t.contexts,s]}}case"SET_CONTEXT_NAME":return t.contexts.some(i=>i.id===o)?{...t,contexts:t.contexts.map(i=>i.id===o?{...i,name:n.payload.name}:i)}:null;case"DELETE_CONTEXT":return t.contexts.some(i=>i.id===o)?{...t,contexts:t.contexts.filter(i=>i.id!==o),elements:t.elements.map(i=>i.contextId===o?Cr(i):i)}:null;default:return Kn(n)}},Cr=t=>{const e={...t};return delete e.contextId,e},mn=(t,e,n)=>t.elements.some(o=>o.id===e)?{...t,elements:t.elements.map(o=>o.id===e?n(o):o)}:null,cu=(t,e,n)=>{const o=t.findIndex(a=>a.id===e);if(o<0||n!==null&&!t.some(a=>a.id===n))return null;const i=t[o];if(i===void 0)return null;const r=[...t.filter(a=>a.id!==e)];return r.splice(n===null?0:r.findIndex(a=>a.id===n)+1,0,i),r},pu={SET_ELEMENT_NAME:(t,e,n)=>({title:t.renameElementTitle,tone:"update",body:t.renamed(pt(n,e.target.id)?.name??"?",U(ie.SET_ELEMENT_NAME,e).name)}),SET_ELEMENT_DESCRIPTION:(t,e)=>({title:t.updateDescriptionTitle,tone:"update",body:`\u2192 "${U(ie.SET_ELEMENT_DESCRIPTION,e).description.slice(0,60)}"`}),SET_ELEMENT_TYPE:(t,e)=>({title:t.changeTypeTitle,tone:"update",body:`\u2192 ${U(ie.SET_ELEMENT_TYPE,e).type}`}),SET_ELEMENT_CONTEXT:(t,e)=>({title:t.changeContextTitle,tone:"move",body:`\u2192 ${U(ie.SET_ELEMENT_CONTEXT,e).contextId??t.noContext}`}),MOVE_ELEMENT:(t,e)=>({title:t.moveTitle,tone:"move",body:U(ie.MOVE_ELEMENT,e).after===null?t.moveToFront:t.moveAfter(U(ie.MOVE_ELEMENT,e).after??"")}),ADD_ELEMENT:(t,e)=>({title:t.addElementTitle,tone:"create",body:`+ "${U(ie.ADD_ELEMENT,e).name}"`}),DELETE_ELEMENT:(t,e,n)=>({title:t.deleteElementTitle,tone:"delete",body:`\u2212 "${pt(n,e.target.id)?.name??e.target.id}"`}),LINK_ELEMENTS:(t,e)=>({title:t.linkTitle,tone:"create",body:`${U(ie.LINK_ELEMENTS,e).from} \u2192 ${U(ie.LINK_ELEMENTS,e).to}`}),SET_LINK_LABEL:(t,e)=>({title:t.renameLinkTitle,tone:"update",body:`\u2192 "${U(ie.SET_LINK_LABEL,e).label}"`}),UNLINK_ELEMENTS:(t,e)=>({title:t.unlinkTitle,tone:"delete",body:`${U(ie.UNLINK_ELEMENTS,e).from} \u2192 ${U(ie.UNLINK_ELEMENTS,e).to}`}),ADD_CONTEXT:(t,e)=>({title:t.addContextTitle,tone:"create",body:`+ "${U(ie.ADD_CONTEXT,e).name}"`}),SET_CONTEXT_NAME:(t,e)=>({title:t.renameContextTitle,tone:"update",body:`\u2192 "${U(ie.SET_CONTEXT_NAME,e).name}"`}),DELETE_CONTEXT:(t,e,n)=>({title:t.deleteContextTitle,tone:"delete",body:`\u2212 "${Ao(n,e.target.id)?.name??e.target.id}"`})},Lr=(t,e,n,o)=>{const i=pu[e.type],r=i?i(t,e,o??n):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:hu(t,n,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},hu=(t,e,n)=>{switch(n.type){case"element":{const o=pt(e,n.id);return o?t.elementLabel(o.name):`${t.elementLabel(n.id)} (missing)`}case"context":{const o=Ao(e,n.id);return o?t.contextLabel(o.name):`${t.contextLabel(n.id)} (missing)`}case"link":{const o=Fh(e,n.id);return o?t.linkLabel(o.from,o.to):`${t.linkGroup} \xB7 ${n.id} (missing)`}case"page":return t.pageLabel(e.title??"Event Storming");default:return`${n.type} \xB7 ${n.id}`}},uu=t=>t==="comment"?"meta":t,mu=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},gu=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=Lr(t,s,o).title;if(!(s.type in ie)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=mu(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=lu(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=Lr(t,d,l,o);i.push({id:s.id,title:c.title,tone:uu(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Re={kind:"idle"},fu=(t,e)=>t.kind==="editing"&&t.noteId===e?"editing":"view",bu=(t,e,n)=>{switch(n.kind){case"delete":return Re;case"select":case"add-hotspot":return t;case"rename":return t.kind==="editing"&&t.noteId===e?Re:t}},xu=6,yu=10,Ir="\u2026",ku=[[4352,4447],[11904,42191],[44032,55203],[63744,64255],[65072,65103],[65280,65376],[65504,65510],[127744,129791],[131072,262141]],No=t=>{const e=t.codePointAt(0)??0;return ku.some(([n,o])=>e>=n&&e<=o)?yu:xu},vu=(t,e)=>{const n=Array.from(t);if(n.reduce((s,r)=>s+No(r),0)<=e)return t;let o=No(Ir),i="";for(const s of n){if(o+=No(s),o>e)break;i+=s}return`${i}${Ir}`},Ar=92,zo=54,wu=18,Rr=4,_r=t=>{const e=[];let n=wu;for(const o of t)e.push(n),n+=o+Rr;return{lifts:e,extent:t.length===0?0:n-Rr}},Dr=240,At=132,Or=96,Po=10,gn=24,fn=12,_e=Or+fn*2,bn=46,xn=16,Nr=44,zr=40,qo=16,Pr=13,ut=8,$u=6,Eu=26,Tu=(t,e)=>Math.max(Nr,t-fn+(e?Eu:0)),Su=_r([zo]).extent,Mu=["actor","command","aggregate","event","policy","readmodel","external"],qr=t=>gn*2+t*At+(t-1)*Po,Cu=(t,e)=>{const n=new Map;let o=0;for(const i of t.notes){const s=t.pins.filter(a=>a.targetId===i.id),r=_r(s.map(a=>e(a.note.id)));s.forEach((a,d)=>n.set(a.note.id,r.lifts[d]??0)),o=Math.max(o,r.extent)}return{liftOf:n,extent:o}},Lu=(t,e,n,o)=>{const i=new Map(e.map(f=>[f.id,qr(f.notes.length)])),s=su(t,e),r=ru(e,s,{widthOf:f=>i.get(f)??0,gapX:bn,padX:xn,maxWidth:Math.max(n,qr(1))}),a=new Map,d=new Map,l=new Map,c=new Map,h=new Map,p=new Map(e.map(f=>[f.id,f.contextId]));for(const f of e){const m=Cu(f,y=>o.get(y)??zo);for(const[y,v]of m.liftOf)c.set(y,v);h.set(f.id,m.extent)}let u=ut;const g=r.map((f,m)=>{const y=f.cutFrom===void 0?void 0:d.get(f.cutFrom.from),v=y===void 0?0:Math.max(0,y-xn);let w=v+xn;const $=Tu(Math.max(Su,...f.sliceIds.map(M=>h.get(M)??0)),f.sliceIds.some(M=>p.get(M)!==void 0));for(const M of f.sliceIds)a.set(M,w-v),d.set(M,w),l.set(M,m),w+=(i.get(M)??0)+bn;const A=$+_e+zr,C={sliceIds:f.sliceIds,x:v,width:w-bn+xn-v,height:A,y:u,head:$,cutFrom:f.cutFrom};return u+=A+$u,C}),b=g.at(-1);return{slices:e,bands:g,xOf:a,absXOf:d,bandOf:l,widthOf:i,pinLiftOf:c,arrows:s,width:Math.max(0,...g.map(f=>f.x+f.width))+ut*2,height:b===void 0?ut*2:b.y+b.height+ut}},Iu=t=>{const{m:e,state:n,maxRowWidth:o,pinHeights:i,viewport:s,handlers:r}=t,a=24*s.zoom,d=`background-size:${a}px ${a}px;background-position:${s.panX}px ${s.panY}px`;if(n.elements.length===0)return k`<div class="board-viewport board-viewport--empty" style=${d}>
2580
2580
  <div class="empty">
2581
2581
  <h2>${e.emptyTitle}</h2>
2582
2582
  <p>${e.emptyBody}</p>
@@ -2584,7 +2584,7 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2584
2584
  ${e.addFirstEvent}
2585
2585
  </button>
2586
2586
  </div>
2587
- </div>`;const l=dt(n),c=gu(n,l,o,i);return v`
2587
+ </div>`;const l=ht(n),c=Lu(n,l,o,i);return k`
2588
2588
  <div
2589
2589
  class="board-viewport${t.gesture!==void 0?" board-viewport--gesturing":""}"
2590
2590
  data-testid="es-viewport"
@@ -2603,76 +2603,76 @@ import{a4 as wd,S as qn,a5 as ce,a6 as $d,a7 as Ed,a8 as Oe,a9 as O,aa as F,ab a
2603
2603
  style=${`transform:translate(${s.panX}px, ${s.panY}px) scale(${s.zoom})`}
2604
2604
  >
2605
2605
  <div class="wall" data-testid="es-wall" style=${`width:${c.width}px;height:${c.height}px`}>
2606
- ${Tu(t,c)}
2607
- ${c.bands.map((h,p)=>xu(t,c,h,p))}
2606
+ ${qu(t,c)}
2607
+ ${c.bands.map((h,p)=>Ru(t,c,h,p))}
2608
2608
  </div>
2609
2609
  </div>
2610
- ${vu(t.gesture)} ${ku(e,n,l)} ${wu(t)}
2611
- ${$u(t)}
2610
+ ${Du(t.gesture)} ${Ou(e,n,l)} ${Nu(t)}
2611
+ ${zu(t)}
2612
2612
  </div>
2613
- `},bu=(t,e)=>{const n=["slice"];t.selectedSliceIds.includes(e.id)&&n.push("slice--selected");const o=t.gesture;return o?.kind==="connect"&&o.moved&&(o.fromSliceId!==e.id&&n.push("slice--candidate"),o.targetSliceId===e.id&&n.push("slice--target")),o?.kind==="move-slice"&&o.moved&&(o.sliceId===e.id&&n.push("slice--lifted"),o.drop?.sliceId===e.id&&n.push(o.drop.side==="before"?"slice--insert-before":"slice--insert-after")),n.join(" ")},xu=(t,e,n,o)=>{const{m:i,mode:s,gesture:r,hoverSliceId:a,selectedNoteId:d,handlers:l}=t,c=n.sliceIds.flatMap(u=>e.slices.filter(g=>g.id===u)),h=u=>({x:e.xOf.get(u.id)??0,y:n.head,w:e.widthOf.get(u.id)??0}),p=(u,g,b=!1)=>v`<dpk-internal-event-storming-note
2613
+ `},Au=(t,e)=>{const n=["slice"];t.selectedSliceIds.includes(e.id)&&n.push("slice--selected");const o=t.gesture;return o?.kind==="connect"&&o.moved&&(o.fromSliceId!==e.id&&n.push("slice--candidate"),o.targetSliceId===e.id&&n.push("slice--target")),o?.kind==="move-slice"&&o.moved&&(o.sliceId===e.id&&n.push("slice--lifted"),o.drop?.sliceId===e.id&&n.push(o.drop.side==="before"?"slice--insert-before":"slice--insert-after")),n.join(" ")},Ru=(t,e,n,o)=>{const{m:i,mode:s,gesture:r,hoverSliceId:a,selectedNoteId:d,handlers:l}=t,c=n.sliceIds.flatMap(u=>e.slices.filter(g=>g.id===u)),h=u=>({x:e.xOf.get(u.id)??0,y:n.head,w:e.widthOf.get(u.id)??0}),p=(u,g,b=!1)=>k`<dpk-internal-event-storming-note
2614
2614
  style=${g}
2615
2615
  .note=${u}
2616
- .mode=${nu(s,u.id)}
2616
+ .mode=${fu(s,u.id)}
2617
2617
  ?focused=${d===u.id}
2618
2618
  ?compact=${b}
2619
- data-pin=${b?u.id:M}
2619
+ data-pin=${b?u.id:T}
2620
2620
  data-dpk-target=${t.commentRef("note",u.id)}
2621
- data-grill-questions=${Kt(Ut(u.questions))}
2621
+ data-grill-questions=${Wt(Yt(u.questions))}
2622
2622
  .onIntent=${f=>l.noteIntent(u.id,f)}
2623
- ></dpk-internal-event-storming-note>`;return v`
2624
- <section class="band" data-band=${o} style=${`left:${lt+n.x}px;top:${n.y}px`}>
2623
+ ></dpk-internal-event-storming-note>`;return k`
2624
+ <section class="band" data-band=${o} style=${`left:${ut+n.x}px;top:${n.y}px`}>
2625
2625
  <div class="band-canvas" style=${`width:${n.width}px;height:${n.height}px`}>
2626
- ${yu(t,e,o)}
2627
- ${c.map(u=>{const{x:g,y:b,w:f}=h(u);return v`<div
2628
- class=${bu(t,u)}
2626
+ ${_u(t,e,o)}
2627
+ ${c.map(u=>{const{x:g,y:b,w:f}=h(u);return k`<div
2628
+ class=${Au(t,u)}
2629
2629
  data-slice-id=${u.id}
2630
2630
  style=${`left:${g}px;top:${b}px;width:${f}px;height:${_e}px`}
2631
2631
  @pointerdown=${m=>l.slicePointerDown(u.id,m)}
2632
2632
  ></div>`})}
2633
- ${Te(c.flatMap(u=>u.notes.map((g,b)=>({slice:u,note:g,slot:b}))),({note:u})=>u.id,({slice:u,note:g,slot:b})=>{const{x:f,y:m}=h(u),x=f+un+b*(It+Oo),k=m+mn;return p(g,`${Io(g.type)};position:absolute;left:${x}px;top:${k}px;width:${It}px;height:${Ir}px;--es-tilt:${Iu(g.id)}deg;z-index:2`)})}
2634
- ${Te(c.flatMap(u=>{const g=h(u);return u.notes.flatMap((b,f)=>u.pins.filter(x=>x.targetId===b.id).map((x,k)=>({pin:x,slot:f,index:k,at:g})))}),({pin:u})=>u.note.id,({pin:u,slot:g,index:b,at:f})=>{const m=f.x+un+g*(It+Oo),x=f.y+mn,k=e.pinLiftOf.get(u.note.id)??0;return p(u.note,`${Io(u.note.type)};position:absolute;left:${m+It-Er-6-b*10}px;bottom:${n.height-(x-k)}px;width:${Er}px;min-height:${Ao}px;--es-tilt:-2.4deg;z-index:3`,!0)})}
2635
- ${c.map(u=>{const{x:g,y:b,w:f}=h(u),m=a===u.id||r?.kind==="connect"&&r.fromSliceId===u.id;return v`<button
2633
+ ${Me(c.flatMap(u=>u.notes.map((g,b)=>({slice:u,note:g,slot:b}))),({note:u})=>u.id,({slice:u,note:g,slot:b})=>{const{x:f,y:m}=h(u),y=f+gn+b*(At+Po),v=m+fn;return p(g,`${Ro(g.type)};position:absolute;left:${y}px;top:${v}px;width:${At}px;height:${Or}px;--es-tilt:${Bu(g.id)}deg;z-index:2`)})}
2634
+ ${Me(c.flatMap(u=>{const g=h(u);return u.notes.flatMap((b,f)=>u.pins.filter(y=>y.targetId===b.id).map((y,v)=>({pin:y,slot:f,index:v,at:g})))}),({pin:u})=>u.note.id,({pin:u,slot:g,index:b,at:f})=>{const m=f.x+gn+g*(At+Po),y=f.y+fn,v=e.pinLiftOf.get(u.note.id)??0;return p(u.note,`${Ro(u.note.type)};position:absolute;left:${m+At-Ar-6-b*10}px;bottom:${n.height-(y-v)}px;width:${Ar}px;min-height:${zo}px;--es-tilt:-2.4deg;z-index:3`,!0)})}
2635
+ ${c.map(u=>{const{x:g,y:b,w:f}=h(u),m=a===u.id||r?.kind==="connect"&&r.fromSliceId===u.id;return k`<button
2636
2636
  class="slice-port${m?" slice-port--on":""}"
2637
2637
  type="button"
2638
- style=${`left:${g+f-_r}px;top:${b+_e/2-_r}px`}
2638
+ style=${`left:${g+f-Pr}px;top:${b+_e/2-Pr}px`}
2639
2639
  aria-label=${i.portAriaLabel}
2640
2640
  title=${i.portTitle}
2641
- @pointerdown=${x=>l.portPointerDown(u.id,x)}
2641
+ @pointerdown=${y=>l.portPointerDown(u.id,y)}
2642
2642
  >
2643
2643
  →
2644
2644
  </button>`})}
2645
- ${c.map(u=>{if(a!==u.id||r!==void 0)return M;const{x:g,y:b}=h(u),f=new Set(u.notes.map(x=>x.type)),m=uu.filter(x=>!f.has(x));return v`<div
2645
+ ${c.map(u=>{if(a!==u.id||r!==void 0)return T;const{x:g,y:b}=h(u),f=new Set(u.notes.map(y=>y.type)),m=Mu.filter(y=>!f.has(y));return k`<div
2646
2646
  class="slice-chips"
2647
2647
  style=${`left:${g}px;top:${b+_e+6}px`}
2648
- @pointerdown=${x=>x.stopPropagation()}
2648
+ @pointerdown=${y=>y.stopPropagation()}
2649
2649
  >
2650
- ${m.map(x=>v`<button class="slice-chip" type="button" @click=${()=>l.attachNote(u.id,x)}>
2651
- ${i.addTypeLabel(x)}
2650
+ ${m.map(y=>k`<button class="slice-chip" type="button" @click=${()=>l.attachNote(u.id,y)}>
2651
+ ${i.addTypeLabel(y)}
2652
2652
  </button>`)}
2653
2653
  </div>`})}
2654
2654
  </div>
2655
2655
  </section>
2656
- `},yu=(t,e,n)=>{const{m:o,state:i,handlers:s}=t,r=i.contexts.flatMap((a,d)=>{const c=e.slices.filter(k=>k.contextId===a.id).flatMap(k=>{const w=e.xOf.get(k.id),$=e.bandOf.get(k.id);return w===void 0||$===void 0?[]:[{x:w,band:$,width:e.widthOf.get(k.id)??0}]}),h=c.filter(k=>k.band===n);if(h.length===0)return[];const p=Math.min(...h.map(k=>k.x))-10,u=Math.max(...h.map(k=>k.x+k.width))+10,g=14,b=(e.bands[n]?.head??Cr)+_e+12,f=c.some(k=>k.band<n)?"\u2026 ":"",m=c.some(k=>k.band>n)?" \u2026":"",x=String(d%5);return[v`<div
2656
+ `},_u=(t,e,n)=>{const{m:o,state:i,handlers:s}=t,r=i.contexts.flatMap((a,d)=>{const c=e.slices.filter(v=>v.contextId===a.id).flatMap(v=>{const w=e.xOf.get(v.id),$=e.bandOf.get(v.id);return w===void 0||$===void 0?[]:[{x:w,band:$,width:e.widthOf.get(v.id)??0}]}),h=c.filter(v=>v.band===n);if(h.length===0)return[];const p=Math.min(...h.map(v=>v.x))-10,u=Math.max(...h.map(v=>v.x+v.width))+10,g=14,b=(e.bands[n]?.head??Nr)+_e+12,f=c.some(v=>v.band<n)?"\u2026 ":"",m=c.some(v=>v.band>n)?" \u2026":"",y=String(d%5);return[k`<div
2657
2657
  class="context-region"
2658
- data-hue=${x}
2658
+ data-hue=${y}
2659
2659
  data-dpk-target=${t.commentRef("context",a.id)}
2660
- data-grill-questions=${Kt(Ut(a.questions))}
2660
+ data-grill-questions=${Wt(Yt(a.questions))}
2661
2661
  style=${`left:${p}px;top:${g}px;width:${u-p}px;height:${b-g}px`}
2662
2662
  title=${a.description??a.name}
2663
2663
  ></div>
2664
2664
  <div
2665
2665
  class="context-label"
2666
- data-hue=${x}
2666
+ data-hue=${y}
2667
2667
  style=${`left:${p+10}px;top:${g}px;max-width:${u-p-20}px`}
2668
- @pointerdown=${k=>k.stopPropagation()}
2668
+ @pointerdown=${v=>v.stopPropagation()}
2669
2669
  >
2670
2670
  <button
2671
2671
  class="context-label-name"
2672
2672
  type="button"
2673
2673
  title=${`${a.name}
2674
2674
  ${o.renameContextHint}`}
2675
- @click=${k=>s.renameContext(a.id,{x:k.clientX,y:k.clientY})}
2675
+ @click=${v=>s.renameContext(a.id,{x:v.clientX,y:v.clientY})}
2676
2676
  >
2677
2677
  ${f}${a.name}${m}
2678
2678
  </button>
@@ -2685,25 +2685,25 @@ ${o.renameContextHint}`}
2685
2685
  >
2686
2686
  ✕
2687
2687
  </button>
2688
- </div>`]});return r.length>0?v`${r}`:M},vu=t=>{if(t===void 0||!t.moved)return M;if(t.kind==="connect")return v`<svg class="gesture-layer" aria-hidden="true">
2688
+ </div>`]});return r.length>0?k`${r}`:T},Du=t=>{if(t===void 0||!t.moved)return T;if(t.kind==="connect")return k`<svg class="gesture-layer" aria-hidden="true">
2689
2689
  ${Y`<path class="connect-line" d=${`M ${t.start.x} ${t.start.y} L ${t.current.x} ${t.current.y}`}></path>
2690
2690
  <circle class="connect-tip" cx=${t.current.x} cy=${t.current.y} r="5"></circle>`}
2691
- </svg>`;if(t.kind==="select"){const e=Math.min(t.start.x,t.current.x),n=Math.min(t.start.y,t.current.y),o=Math.abs(t.current.x-t.start.x),i=Math.abs(t.current.y-t.start.y);return v`<div
2691
+ </svg>`;if(t.kind==="select"){const e=Math.min(t.start.x,t.current.x),n=Math.min(t.start.y,t.current.y),o=Math.abs(t.current.x-t.start.x),i=Math.abs(t.current.y-t.start.y);return k`<div
2692
2692
  class="select-rect"
2693
2693
  style=${`left:${e}px;top:${n}px;width:${o}px;height:${i}px`}
2694
- ></div>`}return M},ku=(t,e,n)=>v`<div class="board-hud">
2694
+ ></div>`}return T},Ou=(t,e,n)=>k`<div class="board-hud">
2695
2695
  <span class="board-hud-stat">${t.noteCount(e.elements.length)}</span>
2696
2696
  <span class="board-hud-stat">${t.sliceCount(n.length)}</span>
2697
2697
  <span class="board-hud-stat">${t.contextCount(e.contexts.length)}</span>
2698
2698
  <span class="board-hint">${t.hudHint}</span>
2699
- </div>`,wu=t=>{const{m:e,viewport:n,handlers:o}=t;return v`<div class="board-zoom" @pointerdown=${i=>i.stopPropagation()}>
2699
+ </div>`,Nu=t=>{const{m:e,viewport:n,handlers:o}=t;return k`<div class="board-zoom" @pointerdown=${i=>i.stopPropagation()}>
2700
2700
  <button type="button" aria-label=${e.zoomOut} @click=${()=>o.zoomStep(-1)}>−</button>
2701
2701
  <button type="button" class="board-zoom-pct" title=${e.zoomReset} @click=${()=>o.zoomReset()}>
2702
2702
  ${Math.round(n.zoom*100)}%
2703
2703
  </button>
2704
2704
  <button type="button" aria-label=${e.zoomIn} @click=${()=>o.zoomStep(1)}>+</button>
2705
2705
  <button type="button" aria-label=${e.zoomFit} title=${e.zoomFit} @click=${()=>o.zoomFit()}>⛶</button>
2706
- </div>`},$u=t=>{const{m:e,state:n,selectedSliceIds:o,selectedLinkIds:i,assignSelect:s,handlers:r}=t;if(i.length===0&&o.length===0)return M;const a=n.contexts;return i.length>0?v`<dpk-selection-bar
2706
+ </div>`},zu=t=>{const{m:e,state:n,selectedSliceIds:o,selectedLinkIds:i,assignSelect:s,handlers:r}=t;if(i.length===0&&o.length===0)return T;const a=n.contexts;return i.length>0?k`<dpk-selection-bar
2707
2707
  label=${e.selectedLinks(i.length)}
2708
2708
  @pointerdown=${d=>d.stopPropagation()}
2709
2709
  @dpk-selection-clear=${()=>r.clearSelection()}
@@ -2721,7 +2721,7 @@ ${o.renameContextHint}`}
2721
2721
  >
2722
2722
  ✕
2723
2723
  </button>
2724
- </dpk-selection-bar>`:v`<dpk-selection-bar
2724
+ </dpk-selection-bar>`:k`<dpk-selection-bar
2725
2725
  label=${e.selectedSlices(o.length)}
2726
2726
  @pointerdown=${d=>d.stopPropagation()}
2727
2727
  @dpk-selection-clear=${()=>r.clearSelection()}
@@ -2734,7 +2734,7 @@ ${o.renameContextHint}`}
2734
2734
  >
2735
2735
  ${e.groupIntoContext}
2736
2736
  </button>
2737
- ${a.length>0?s.render({options:a.map(d=>({value:d.id,label:d.name})),value:"",onChange:d=>{d!==""&&r.assignSelection(d)},ariaLabel:e.addToExistingAria,placeholder:e.addToExistingOption}):M}
2737
+ ${a.length>0?s.render({options:a.map(d=>({value:d.id,label:d.name})),value:"",onChange:d=>{d!==""&&r.assignSelection(d)},ariaLabel:e.addToExistingAria,placeholder:e.addToExistingOption}):T}
2738
2738
  <button class="dpk-btn" type="button" @click=${()=>r.stripSelectionContext()}>
2739
2739
  ${e.removeFromContext}
2740
2740
  </button>
@@ -2742,16 +2742,16 @@ ${o.renameContextHint}`}
2742
2742
  <button class="dpk-icon-btn" type="button" aria-label=${e.clearSelection} @click=${()=>r.clearSelection()}>
2743
2743
  ✕
2744
2744
  </button>
2745
- </dpk-selection-bar>`},Ar=(t,e,n,o)=>({d:`M ${t.x} ${t.y} C ${e.x} ${e.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`,mid:{x:(t.x+3*e.x+3*n.x+o.x)/8,y:(t.y+3*e.y+3*n.y+o.y)/8}}),Eu=()=>Y`<marker id="es-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
2745
+ </dpk-selection-bar>`},Fr=(t,e,n,o)=>({d:`M ${t.x} ${t.y} C ${e.x} ${e.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`,mid:{x:(t.x+3*e.x+3*n.x+o.x)/8,y:(t.y+3*e.y+3*n.y+o.y)/8}}),Pu=()=>Y`<marker id="es-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
2746
2746
  <path d="M0,0 L8,4 L0,8 z"></path>
2747
- </marker>`,Tu=(t,e)=>{const n="url(#es-arrow)",o=[],i=a=>{const d=e.absXOf.get(a),l=e.bandOf.get(a),c=l===void 0?void 0:e.bands[l];if(!(d===void 0||l===void 0||c===void 0))return{x:lt+d,y:c.y+c.head,w:e.widthOf.get(a)??0,band:l}},s=a=>{const d=e.bands[a];return d===void 0?0:d.y+d.height},r=(a,d,l,c,h)=>{const p=t.selectedLinkIds.includes(a.id)?" is-selected":"",u={start:6,end:-6,middle:0}[c];o.push(Y`<g data-link-id=${a.id} data-dpk-target=${`link:${a.id}`} data-dpk-check="off">
2747
+ </marker>`,qu=(t,e)=>{const n="url(#es-arrow)",o=[],i=a=>{const d=e.absXOf.get(a),l=e.bandOf.get(a),c=l===void 0?void 0:e.bands[l];if(!(d===void 0||l===void 0||c===void 0))return{x:ut+d,y:c.y+c.head,w:e.widthOf.get(a)??0,band:l}},s=a=>{const d=e.bands[a];return d===void 0?0:d.y+d.height},r=(a,d,l,c,h)=>{const p=t.selectedLinkIds.includes(a.id)?" is-selected":"",u={start:6,end:-6,middle:0}[c];o.push(Y`<g data-link-id=${a.id} data-dpk-target=${`link:${a.id}`} data-dpk-check="off">
2748
2748
  <path class="link-hit" d=${d} @pointerdown=${g=>g.stopPropagation()} @click=${g=>t.handlers.linkClick(a.id,g.shiftKey||g.metaKey||g.ctrlKey)}></path>
2749
2749
  <path class=${`link-path${p}`} d=${d} marker-end=${n}></path>
2750
- ${a.label===void 0?M:Y`<text class="link-label" x=${l.x+u} y=${l.y-6} text-anchor=${c}><title>${a.label}</title>${au(a.label,Math.min(h,Mr))}</text>`}
2751
- </g>`)};for(const a of e.arrows){const d=i(a.from),l=i(a.to);if(d===void 0||l===void 0)continue;if(d.band===l.band){const f=l.x>=d.x+d.w,m=f?l.x-(d.x+d.w):d.x-(l.x+l.w);if(m<=gn+2){const k=d.y+_e/2,w=f?d.x+d.w:d.x,$=f?l.x:l.x+l.w;r(a,`M ${w} ${k} L ${$} ${k}`,{x:(w+$)/2,y:k},"middle",Math.abs($-w)-4);continue}const x=Su(d,l,s(d.band)-Lr/2);r(a,x.d,x.mid,"middle",m+2*un);continue}const c=d.y<l.y,h=d.x+No,p=bt(h,l.x+No,l.x+l.w-No),u={x:h,y:c?d.y+_e:d.y},g={x:p,y:c?l.y:l.y+_e},b=c?(s(d.band)+(e.bands[l.band]?.y??0))/2:(s(l.band)+(e.bands[d.band]?.y??0))/2;r(a,Mu([u,{x:u.x,y:b},{x:g.x,y:b},g]),{x:g.x-6,y:b},"end",Mr)}return Y`<svg class="links-layer" width=${e.width} height=${e.height}>
2752
- <defs>${Eu()}</defs>
2750
+ ${a.label===void 0?T:Y`<text class="link-label" x=${l.x+u} y=${l.y-6} text-anchor=${c}><title>${a.label}</title>${vu(a.label,Math.min(h,Dr))}</text>`}
2751
+ </g>`)};for(const a of e.arrows){const d=i(a.from),l=i(a.to);if(d===void 0||l===void 0)continue;if(d.band===l.band){const f=l.x>=d.x+d.w,m=f?l.x-(d.x+d.w):d.x-(l.x+l.w);if(m<=bn+2){const v=d.y+_e/2,w=f?d.x+d.w:d.x,$=f?l.x:l.x+l.w;r(a,`M ${w} ${v} L ${$} ${v}`,{x:(w+$)/2,y:v},"middle",Math.abs($-w)-4);continue}const y=Fu(d,l,s(d.band)-zr/2);r(a,y.d,y.mid,"middle",m+2*gn);continue}const c=d.y<l.y,h=d.x+qo,p=kt(h,l.x+qo,l.x+l.w-qo),u={x:h,y:c?d.y+_e:d.y},g={x:p,y:c?l.y:l.y+_e},b=c?(s(d.band)+(e.bands[l.band]?.y??0))/2:(s(l.band)+(e.bands[d.band]?.y??0))/2;r(a,Uu([u,{x:u.x,y:b},{x:g.x,y:b},g]),{x:g.x-6,y:b},"end",Dr)}return Y`<svg class="links-layer" width=${e.width} height=${e.height}>
2752
+ <defs>${Pu()}</defs>
2753
2753
  ${o}
2754
- </svg>`},Su=(t,e,n)=>{const o=t.y+_e;if(e.x>=t.x+t.w){const r={x:t.x+t.w-18,y:o},a={x:e.x+18,y:o};return Ar(r,{x:r.x+48,y:n},{x:a.x-48,y:n},a)}const i={x:t.x+18,y:o},s={x:e.x+e.w-18,y:o};return Ar(i,{x:i.x-48,y:n},{x:s.x+48,y:n},s)},Mu=(t,e=10)=>{let n=`M ${t[0]?.x??0} ${t[0]?.y??0}`;for(let i=1;i<t.length-1;i+=1){const s=t[i-1],r=t[i],a=t[i+1];if(s===void 0||r===void 0||a===void 0)continue;const d=Math.sign(r.x-s.x),l=Math.sign(r.y-s.y),c=Math.sign(a.x-r.x),h=Math.sign(a.y-r.y),p=Math.hypot(r.x-s.x,r.y-s.y),u=Math.hypot(a.x-r.x,a.y-r.y),g=Math.max(0,Math.min(e,p/2,u/2));n+=` L ${r.x-d*g} ${r.y-l*g} Q ${r.x} ${r.y} ${r.x+c*g} ${r.y+h*g}`}const o=t.at(-1);return o===void 0?n:`${n} L ${o.x} ${o.y}`},Iu=t=>{let e=0;for(const n of t)e=(e*31+n.charCodeAt(0))%997;return(e%17-8)*.09},Cu=ae`
2754
+ </svg>`},Fu=(t,e,n)=>{const o=t.y+_e;if(e.x>=t.x+t.w){const r={x:t.x+t.w-18,y:o},a={x:e.x+18,y:o};return Fr(r,{x:r.x+48,y:n},{x:a.x-48,y:n},a)}const i={x:t.x+18,y:o},s={x:e.x+e.w-18,y:o};return Fr(i,{x:i.x-48,y:n},{x:s.x+48,y:n},s)},Uu=(t,e=10)=>{let n=`M ${t[0]?.x??0} ${t[0]?.y??0}`;for(let i=1;i<t.length-1;i+=1){const s=t[i-1],r=t[i],a=t[i+1];if(s===void 0||r===void 0||a===void 0)continue;const d=Math.sign(r.x-s.x),l=Math.sign(r.y-s.y),c=Math.sign(a.x-r.x),h=Math.sign(a.y-r.y),p=Math.hypot(r.x-s.x,r.y-s.y),u=Math.hypot(a.x-r.x,a.y-r.y),g=Math.max(0,Math.min(e,p/2,u/2));n+=` L ${r.x-d*g} ${r.y-l*g} Q ${r.x} ${r.y} ${r.x+c*g} ${r.y+h*g}`}const o=t.at(-1);return o===void 0?n:`${n} L ${o.x} ${o.y}`},Bu=t=>{let e=0;for(const n of t)e=(e*31+n.charCodeAt(0))%997;return(e%17-8)*.09},Hu=de`
2755
2755
  /*
2756
2756
  * The shell (\`<dpk-dialog-panel class="event-storming">\`) is a panel: header, tag
2757
2757
  * row, viewport; \`--dpk-dialog-panel-height\` is the knob it reads for its own
@@ -3349,23 +3349,23 @@ ${o.renameContextHint}`}
3349
3349
  flex: 1 1 auto;
3350
3350
  min-width: 0;
3351
3351
  }
3352
- `,Lu={width:260,height:150},_u={width:236,height:210},Ru=64,Au=["event","command","aggregate","actor","policy","readmodel","external"],Ou=1200,Or=5,Nu={x:20,top:46,bottom:40},Du=264,zu="event-storming";class Nr extends tt{constructor(){super(...arguments),this.mode=Le,this.boardWidth=Ou,this.viewport={panX:24,panY:16,zoom:1},this.gesture=void 0,this.hoverSliceId=void 0,this.selectedSliceIds=[],this.selectedLinkIds=[],this.naming=void 0,this.#i=new pi(this),this.#e=new jh(this),this.#n=new hi(this)}boardAddable(){return!0}static{this.styles=[et,Cu]}#o;#i;#e;#n;parseData(e){return Eh(e)}emptyData(){return Th()}reduceElementActions(e,n){return tu(fe(this.locale),e,n)}defaultHeading(){return fe(this.locale).heading}shellClass(){return"event-storming"}commentItems(){const e=this.items(),n=fe(this.locale);return[{value:this.commentRef("page",zu),label:n.wholeBoard},...e.elements.map(o=>({value:this.commentRef("note",o.id),label:o.name})),...e.contexts.map(o=>({value:this.commentRef("context",o.id),label:o.name}))]}hasSelection(e){return at(this.items(),e.id)!==void 0}disconnectedCallback(){super.disconnectedCallback(),this.#o?.disconnect(),this.#o=void 0}firstUpdated(){typeof ResizeObserver>"u"||(this.#o=new ResizeObserver(e=>{const n=e[0]?.contentRect.width;n!==void 0&&n>0&&(this.boardWidth=n,this.requestUpdate())}),this.#o.observe(this))}updated(){super.updated(),this.#v(this.viewport),this.mode.kind==="append"&&this.#t("#append-menu",this.mode.point,_u),this.naming!==void 0&&this.#t("#context-pop",this.naming.point,Lu,"#context-name")}#t(e,n,o,i){const s=this.renderRoot.querySelector(e);if(!s||s.matches(":popover-open")||(this.#i.open(s,Bd(n.x,n.y),o),i===void 0))return;const r=this.renderRoot.querySelector(i);r?.focus(),r instanceof HTMLInputElement&&r.select()}#a(){return Math.max(Du,this.boardWidth-96)}render(){this.prepareRender();const e=fe(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return v`
3352
+ `,Yu={width:260,height:150},Gu={width:236,height:210},Xu=64,Ku=["event","command","aggregate","actor","policy","readmodel","external"],ju=1200,Ur=5,Wu={x:20,top:46,bottom:40},Vu=264,Qu="event-storming";class Br extends st{constructor(){super(...arguments),this.mode=Re,this.boardWidth=ju,this.viewport={panX:24,panY:16,zoom:1},this.gesture=void 0,this.hoverSliceId=void 0,this.selectedSliceIds=[],this.selectedLinkIds=[],this.naming=void 0,this.#i=new fi(this),this.#e=new du(this),this.#t=new bi(this)}boardAddable(){return!0}static{this.styles=[it,Hu]}#o;#i;#e;#t;parseData(e){return Ph(e)}emptyData(){return qh()}reduceElementActions(e,n){return gu(be(this.locale),e,n)}defaultHeading(){return be(this.locale).heading}shellClass(){return"event-storming"}commentItems(){const e=this.items(),n=be(this.locale);return[{value:this.commentRef("page",Qu),label:n.wholeBoard},...e.elements.map(o=>({value:this.commentRef("note",o.id),label:o.name})),...e.contexts.map(o=>({value:this.commentRef("context",o.id),label:o.name}))]}hasSelection(e){return pt(this.items(),e.id)!==void 0}disconnectedCallback(){super.disconnectedCallback(),this.#o?.disconnect(),this.#o=void 0}firstUpdated(){typeof ResizeObserver>"u"||(this.#o=new ResizeObserver(e=>{const n=e[0]?.contentRect.width;n!==void 0&&n>0&&(this.boardWidth=n,this.requestUpdate())}),this.#o.observe(this))}updated(){super.updated(),this.#k(this.viewport),this.mode.kind==="append"&&this.#n("#append-menu",this.mode.point,Gu),this.naming!==void 0&&this.#n("#context-pop",this.naming.point,Yu,"#context-name")}#n(e,n,o,i){const s=this.renderRoot.querySelector(e);if(!s||s.matches(":popover-open")||(this.#i.open(s,el(n.x,n.y),o),i===void 0))return;const r=this.renderRoot.querySelector(i);r?.focus(),r instanceof HTMLInputElement&&r.select()}#a(){return Math.max(Vu,this.boardWidth-96)}render(){this.prepareRender();const e=be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return k`
3353
3353
  <dpk-dialog-panel
3354
3354
  class=${this.shellClass()}
3355
3355
  flush
3356
3356
  ?maximizable=${this.frameControls}
3357
3357
  ?resizable=${this.frameControls}
3358
3358
  heading=${this.heading??this.defaultHeading()}
3359
- subject=${o===""?M:o}
3359
+ subject=${o===""?T:o}
3360
3360
  @dpk-maximize-change=${()=>this.closeComposer()}
3361
3361
  >
3362
3362
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
3363
- ${this.dataError!==null?v`<p class="es-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:v`${fu({m:e,state:this.items(),mode:this.mode,maxRowWidth:this.#a(),pinHeights:this.#e.heights,viewport:this.viewport,gesture:this.gesture,hoverSliceId:this.hoverSliceId,selectedSliceIds:this.selectedSliceIds,selectedLinkIds:this.selectedLinkIds,selectedNoteId:this.selection?.kind==="note"?this.selection.id:void 0,assignSelect:this.#n,commentRef:(i,s)=>this.commentRef(i,s),handlers:{noteIntent:(i,s)=>this.#M(i,s),addFirst:()=>this.#G(),attachNote:(i,s)=>this.#I(i,s),viewportPointerDown:i=>this.#h(i),viewportPointerMove:i=>this.#l(i),viewportPointerUp:i=>this.#m(i),viewportPointerCancel:()=>{this.gesture=void 0,this.requestUpdate()},viewportPointerLeave:()=>{this.gesture===void 0&&(this.hoverSliceId=void 0,this.requestUpdate())},viewportWheel:i=>this.#g(i),portPointerDown:(i,s)=>this.#p(i,s),slicePointerDown:(i,s)=>this.#u(i,s),zoomStep:i=>this.#y(i),zoomFit:()=>this.#C(),zoomReset:()=>this.#f(1/this.viewport.zoom),groupSelection:i=>{this.selectedSliceIds.length>0&&(this.naming={kind:"create-context",sliceIds:this.selectedSliceIds,point:i},this.requestUpdate())},assignSelection:i=>this.#q(i),stripSelectionContext:()=>this.#q(null),clearSelection:()=>{this.selectedSliceIds=[],this.selectedLinkIds=[],this.requestUpdate()},linkClick:(i,s)=>this.#Y(i,s),deleteSelection:()=>this.#z(),keyDown:i=>this.#P(i),renameContext:(i,s)=>{this.naming={kind:"rename-context",contextId:i,point:s},this.requestUpdate()},dissolveContext:i=>this.#S(J.deleteContext(i))}})}
3364
- ${this.mode.kind==="append"?this.#B(this.mode.sliceId):M}
3365
- ${this.naming!==void 0?this.#X(this.naming):M} `}
3363
+ ${this.dataError!==null?k`<p class="es-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:k`${Iu({m:e,state:this.items(),mode:this.mode,maxRowWidth:this.#a(),pinHeights:this.#e.heights,viewport:this.viewport,gesture:this.gesture,hoverSliceId:this.hoverSliceId,selectedSliceIds:this.selectedSliceIds,selectedLinkIds:this.selectedLinkIds,selectedNoteId:this.selection?.kind==="note"?this.selection.id:void 0,assignSelect:this.#t,commentRef:(i,s)=>this.commentRef(i,s),handlers:{noteIntent:(i,s)=>this.#I(i,s),addFirst:()=>this.#X(),attachNote:(i,s)=>this.#S(i,s),viewportPointerDown:i=>this.#u(i),viewportPointerMove:i=>this.#l(i),viewportPointerUp:i=>this.#m(i),viewportPointerCancel:()=>{this.gesture=void 0,this.requestUpdate()},viewportPointerLeave:()=>{this.gesture===void 0&&(this.hoverSliceId=void 0,this.requestUpdate())},viewportWheel:i=>this.#g(i),portPointerDown:(i,s)=>this.#h(i,s),slicePointerDown:(i,s)=>this.#p(i,s),zoomStep:i=>this.#x(i),zoomFit:()=>this.#A(),zoomReset:()=>this.#f(1/this.viewport.zoom),groupSelection:i=>{this.selectedSliceIds.length>0&&(this.naming={kind:"create-context",sliceIds:this.selectedSliceIds,point:i},this.requestUpdate())},assignSelection:i=>this.#U(i),stripSelectionContext:()=>this.#U(null),clearSelection:()=>{this.selectedSliceIds=[],this.selectedLinkIds=[],this.requestUpdate()},linkClick:(i,s)=>this.#O(i,s),deleteSelection:()=>this.#N(),keyDown:i=>this.#z(i),renameContext:(i,s)=>{this.naming={kind:"rename-context",contextId:i,point:s},this.requestUpdate()},dissolveContext:i=>this.#L(J.deleteContext(i))}})}
3364
+ ${this.mode.kind==="append"?this.#H(this.mode.sliceId):T}
3365
+ ${this.naming!==void 0?this.#G(this.naming):T} `}
3366
3366
  </dpk-dialog-panel>
3367
3367
  ${this.renderSelection()}
3368
- `}#r(){return this.renderRoot.querySelector(".board-viewport")}#s(e){const n=this.#r()?.getBoundingClientRect();return n===void 0?{x:e.clientX,y:e.clientY}:{x:e.clientX-n.left,y:e.clientY-n.top}}#d(e){const n=this.#r();if(n===null)return[];const o=n.getBoundingClientRect();return[...this.renderRoot.querySelectorAll("[data-slice-id]")].map(i=>{const s=i.getBoundingClientRect();return{id:i.dataset.sliceId??"",rect:{left:s.left-o.left-(e?.x??0),top:s.top-o.top-(e?.top??0),width:s.width+(e?.x??0)*2,height:s.height+(e?.top??0)+(e?.bottom??0)}}})}#c(e,n){const o=this.#r();o!==null&&(o.setPointerCapture(e.pointerId),this.gesture=n,this.requestUpdate())}#p(e,n){if(n.button!==0)return;n.stopPropagation(),n.preventDefault();const o=this.#s(n);this.#c(n,{kind:"connect",pointerId:n.pointerId,fromSliceId:e,start:o,current:o,moved:!1})}#u(e,n){if(n.button!==0)return;n.stopPropagation(),n.preventDefault();const o=this.#s(n);this.#c(n,{kind:"move-slice",pointerId:n.pointerId,sliceId:e,start:o,current:o,moved:!1})}#h(e){if(e.button!==0||this.gesture!==void 0)return;for(const o of e.composedPath()){if(o===e.currentTarget)break;if(o instanceof Element&&(o.tagName.toLowerCase()==="dpk-internal-event-storming-note"||o.matches("button, select, textarea, input, a")))return}const n=this.#s(e);(this.mode.kind==="editing"||this.mode.kind==="append")&&(this.mode=Le),this.selectedLinkIds=[],this.#c(e,{kind:"select",pointerId:e.pointerId,start:n,current:n,moved:!1})}#l(e){const n=this.gesture,o=this.#s(e);if(n===void 0){const i=xr(this.#d(Nu),o.x,o.y);i!==this.hoverSliceId&&(this.hoverSliceId=i,this.requestUpdate());return}this.gesture=vr(n,{pointerId:e.pointerId,point:o},this.#d(),Or),this.requestUpdate()}#m(e){const n=this.gesture;if(n===void 0||e.pointerId!==n.pointerId)return;const o=vr(n,{pointerId:e.pointerId,point:this.#s(e)},this.#d(),Or);if(this.gesture=void 0,o.kind==="connect"){o.moved?o.targetSliceId!==void 0&&this.#T(o.fromSliceId,o.targetSliceId):this.#L(o.fromSliceId),this.requestUpdate();return}if(o.kind==="move-slice"){if(!o.moved){this.selectedSliceIds=this.selectedSliceIds.includes(o.sliceId)?this.selectedSliceIds.filter(s=>s!==o.sliceId):[...this.selectedSliceIds,o.sliceId],this.requestUpdate();return}o.drop!==void 0&&this.#_(o.sliceId,o.drop.sliceId,o.drop.side),this.requestUpdate();return}if(!o.moved){this.selectedSliceIds=[],this.requestUpdate();return}const i={left:Math.min(o.start.x,o.current.x),top:Math.min(o.start.y,o.current.y),width:Math.abs(o.current.x-o.start.x),height:Math.abs(o.current.y-o.start.y)};this.selectedSliceIds=[...zh(this.#d(),i)],this.requestUpdate()}#g(e){e.preventDefault();const n=this.#s(e);this.#v(e.ctrlKey||e.metaKey?br(this.viewport,n.x,n.y,Math.exp(-e.deltaY*.01)):Rh(this.viewport,-e.deltaX,-e.deltaY))}#f(e){const n=this.#r()?.getBoundingClientRect();this.#v(br(this.viewport,(n?.width??0)/2,(n?.height??0)/2,e))}#y(e){this.#f(e===1?1.2:1/1.2)}#C(){const e=this.#r()?.getBoundingClientRect(),n=this.#k();e===void 0||n===void 0||this.#v(Ah(n,{width:e.width,height:e.height},48))}#k(){const e=this.renderRoot.querySelector(".wall");return e===null?void 0:{width:e.offsetWidth,height:e.offsetHeight}}#v(e){const n=this.#r()?.getBoundingClientRect(),o=this.#k(),i=n===void 0||o===void 0||o.width===0||n.width===0?e:Oh(e,o,{width:n.width,height:n.height},Ru),s=this.viewport;i.panX===s.panX&&i.panY===s.panY&&i.zoom===s.zoom||(this.viewport=i,this.requestUpdate())}#M(e,n){if(n.kind==="comment"){this.openComment(this.commentRef("note",e));return}switch(n.kind){case"select":this.select({kind:"note",id:e});break;case"rename":this.#S(J.setElementName(e,n.name));break;case"delete":this.#S(J.deleteElement(e)),this.selection?.kind==="note"&&this.selection.id===e&&this.select(null);break;case"add-hotspot":this.#H(e);break}this.mode=ou(this.mode,e,n),this.requestUpdate()}#b(e){return dt(this.items()).find(n=>n.id===e)}#w(e){return e===void 0?[]:[...e.notes,...e.pins.map(n=>n.note)].map(n=>n.id)}#T(e,n){if(e===n)return;const o=this.items(),i=dt(o),s=i.find(p=>p.id===e),r=i.find(p=>p.id===n),a=s&&r?Kh(s,r):void 0;if(s===void 0||r===void 0||a===void 0||o.links.some(p=>p.from===a.from&&p.to===a.to))return;const d=o.links.map(p=>p.id),l=o.elements.map(p=>p.id),c=pn(s)?.id,h=c!==void 0&&i.indexOf(r)>i.indexOf(s)?Ph(l,this.#w(r),[c],"after"):[];this.#x([J.linkElements(xn(`link-${a.from}`,d),a.from,a.to,{kind:"flow"}),...h.map(p=>J.moveElement(p.id,p.after))])}#$(e){const n=this.#r(),o=this.#d().find(s=>s.id===e)?.rect;if(n===null||o===void 0)return;const i=n.getBoundingClientRect();return{x:i.left+o.left+o.width,y:i.top+o.top+o.height/2}}#L(e){const n=this.#$(e);n!==void 0&&(this.mode={kind:"append",sliceId:e,point:n},this.requestUpdate())}#E(e,n){const o=this.items(),i=this.#b(e),s=i?pn(i):void 0;if(s===void 0){this.mode=Le,this.requestUpdate();return}const r=bn(`new-${n}`,cn(o)),a=o.links.map(l=>l.id);if(!this.#x([J.addElement(r,n,fe(this.locale).noteTypeLabel(n)),J.linkElements(xn(`link-${s.id}`,a),s.id,r,{kind:"flow"})])){this.mode=Le,this.requestUpdate();return}this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate()}#H(e){const n=this.items(),o=bn("new-hotspot",cn(n)),i=n.links.map(r=>r.id);this.#x([J.addElement(o,"hotspot",fe(this.locale).noteTypeLabel("hotspot")),J.linkElements(xn(`link-${o}`,i),o,e,{kind:"member"})])&&(this.select({kind:"note",id:o}),this.mode={kind:"editing",noteId:o},this.requestUpdate())}#I(e,n){const o=this.#b(e),i=o===void 0?void 0:Yh(o,n);if(i===void 0)return;const s=this.items(),r=bn(`new-${n}`,cn(s)),[a,d]=i.incoming?[r,i.anchorId]:[i.anchorId,r],l=s.links.map(h=>h.id);this.#x([J.addElement(r,n,fe(this.locale).noteTypeLabel(n)),J.linkElements(xn(`link-${a}`,l),a,d,{kind:"member"})])&&(this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate())}#_(e,n,o){const i=this.items(),s=yr(i.elements.map(r=>r.id),this.#w(this.#b(e)),this.#w(this.#b(n)),o);this.#x(s.map(r=>J.moveElement(r.id,r.after)))}#Y(e,n){this.mode.kind==="editing"&&(this.mode=Le),this.selectedSliceIds=[],this.selectedLinkIds=n?this.selectedLinkIds.includes(e)?this.selectedLinkIds.filter(o=>o!==e):[...this.selectedLinkIds,e]:[e],this.requestUpdate(),this.#r()?.focus()}#z(){const e=this.items();if(this.selectedLinkIds.length>0){const i=e.links.filter(s=>this.selectedLinkIds.includes(s.id));this.#x(i.map(s=>J.unlinkElements(s.from,s.to))),this.selectedLinkIds=[],this.requestUpdate();return}if(this.selectedSliceIds.length===0)return;const n=dt(e),o=this.selectedSliceIds.flatMap(i=>this.#w(n.find(s=>s.id===i)));this.#x(o.map(i=>J.deleteElement(i))),this.selectedSliceIds=[],this.requestUpdate()}#P(e){if(e.target!==e.currentTarget)return;if(e.key==="Escape"){this.selectedSliceIds=[],this.selectedLinkIds=[],this.requestUpdate();return}if(e.key!=="Delete"&&e.key!=="Backspace"||this.mode.kind!=="idle"||this.naming!==void 0)return;if(e.preventDefault(),this.selectedLinkIds.length>0||this.selectedSliceIds.length>0){this.#z();return}const n=this.selection?.kind==="note"?this.selection.id:void 0;n===void 0||at(this.items(),n)===void 0||(this.#S(J.deleteElement(n)),this.select(null))}#q(e){const n=this.items(),o=dt(n),i=this.selectedSliceIds.flatMap(r=>this.#w(o.find(a=>a.id===r)));this.#x(i.map(r=>J.setElementContext(r,e)))&&(this.selectedSliceIds=[],this.requestUpdate())}#F(e){const o=this.renderRoot.querySelector("#context-name")?.value.trim()??"";if(o==="")return;if(e.kind==="rename-context"){this.#S(J.setContextName(e.contextId,o))&&(this.naming=void 0,this.requestUpdate());return}const i=this.items(),s=Pu("context",i.contexts.map(l=>l.id)),r=dt(i),a=e.sliceIds.flatMap(l=>this.#w(r.find(c=>c.id===l)));this.#x([J.addContext(s,o),...a.map(l=>J.setElementContext(l,s))])&&(this.selectedSliceIds=[],this.naming=void 0,this.requestUpdate())}#X(e){const n=fe(this.locale),o=e.kind==="rename-context"?Mo(this.items(),e.contextId)?.name??"":"";return v`<div id="context-pop" class="comment-pop context-pop" popover="manual">
3368
+ `}#r(){return this.renderRoot.querySelector(".board-viewport")}#s(e){const n=this.#r()?.getBoundingClientRect();return n===void 0?{x:e.clientX,y:e.clientY}:{x:e.clientX-n.left,y:e.clientY-n.top}}#d(e){const n=this.#r();if(n===null)return[];const o=n.getBoundingClientRect();return[...this.renderRoot.querySelectorAll("[data-slice-id]")].map(i=>{const s=i.getBoundingClientRect();return{id:i.dataset.sliceId??"",rect:{left:s.left-o.left-(e?.x??0),top:s.top-o.top-(e?.top??0),width:s.width+(e?.x??0)*2,height:s.height+(e?.top??0)+(e?.bottom??0)}}})}#c(e,n){const o=this.#r();o!==null&&(o.setPointerCapture(e.pointerId),this.gesture=n,this.requestUpdate())}#h(e,n){if(n.button!==0)return;n.stopPropagation(),n.preventDefault();const o=this.#s(n);this.#c(n,{kind:"connect",pointerId:n.pointerId,fromSliceId:e,start:o,current:o,moved:!1})}#p(e,n){if(n.button!==0)return;n.stopPropagation(),n.preventDefault();const o=this.#s(n);this.#c(n,{kind:"move-slice",pointerId:n.pointerId,sliceId:e,start:o,current:o,moved:!1})}#u(e){if(e.button!==0||this.gesture!==void 0)return;for(const o of e.composedPath()){if(o===e.currentTarget)break;if(o instanceof Element&&(o.tagName.toLowerCase()==="dpk-internal-event-storming-note"||o.matches("button, select, textarea, input, a")))return}const n=this.#s(e);(this.mode.kind==="editing"||this.mode.kind==="append")&&(this.mode=Re),this.selectedLinkIds=[],this.#c(e,{kind:"select",pointerId:e.pointerId,start:n,current:n,moved:!1})}#l(e){const n=this.gesture,o=this.#s(e);if(n===void 0){const i=Tr(this.#d(Wu),o.x,o.y);i!==this.hoverSliceId&&(this.hoverSliceId=i,this.requestUpdate());return}this.gesture=Mr(n,{pointerId:e.pointerId,point:o},this.#d(),Ur),this.requestUpdate()}#m(e){const n=this.gesture;if(n===void 0||e.pointerId!==n.pointerId)return;const o=Mr(n,{pointerId:e.pointerId,point:this.#s(e)},this.#d(),Ur);if(this.gesture=void 0,o.kind==="connect"){o.moved?o.targetSliceId!==void 0&&this.#T(o.fromSliceId,o.targetSliceId):this.#C(o.fromSliceId),this.requestUpdate();return}if(o.kind==="move-slice"){if(!o.moved){this.selectedSliceIds=this.selectedSliceIds.includes(o.sliceId)?this.selectedSliceIds.filter(s=>s!==o.sliceId):[...this.selectedSliceIds,o.sliceId],this.requestUpdate();return}o.drop!==void 0&&this.#M(o.sliceId,o.drop.sliceId,o.drop.side),this.requestUpdate();return}if(!o.moved){this.selectedSliceIds=[],this.requestUpdate();return}const i={left:Math.min(o.start.x,o.current.x),top:Math.min(o.start.y,o.current.y),width:Math.abs(o.current.x-o.start.x),height:Math.abs(o.current.y-o.start.y)};this.selectedSliceIds=[...Qh(this.#d(),i)],this.requestUpdate()}#g(e){e.preventDefault();const n=this.#s(e);this.#k(e.ctrlKey||e.metaKey?Er(this.viewport,n.x,n.y,Math.exp(-e.deltaY*.01)):Xh(this.viewport,-e.deltaX,-e.deltaY))}#f(e){const n=this.#r()?.getBoundingClientRect();this.#k(Er(this.viewport,(n?.width??0)/2,(n?.height??0)/2,e))}#x(e){this.#f(e===1?1.2:1/1.2)}#A(){const e=this.#r()?.getBoundingClientRect(),n=this.#E();e===void 0||n===void 0||this.#k(Kh(n,{width:e.width,height:e.height},48))}#E(){const e=this.renderRoot.querySelector(".wall");return e===null?void 0:{width:e.offsetWidth,height:e.offsetHeight}}#k(e){const n=this.#r()?.getBoundingClientRect(),o=this.#E(),i=n===void 0||o===void 0||o.width===0||n.width===0?e:jh(e,o,{width:n.width,height:n.height},Xu),s=this.viewport;i.panX===s.panX&&i.panY===s.panY&&i.zoom===s.zoom||(this.viewport=i,this.requestUpdate())}#I(e,n){if(n.kind==="comment"){this.openComment(this.commentRef("note",e));return}switch(n.kind){case"select":this.select({kind:"note",id:e});break;case"rename":this.#L(J.setElementName(e,n.name));break;case"delete":this.#L(J.deleteElement(e)),this.selection?.kind==="note"&&this.selection.id===e&&this.select(null);break;case"add-hotspot":this.#F(e);break}this.mode=bu(this.mode,e,n),this.requestUpdate()}#b(e){return ht(this.items()).find(n=>n.id===e)}#v(e){return e===void 0?[]:[...e.notes,...e.pins.map(n=>n.note)].map(n=>n.id)}#T(e,n){if(e===n)return;const o=this.items(),i=ht(o),s=i.find(p=>p.id===e),r=i.find(p=>p.id===n),a=s&&r?au(s,r):void 0;if(s===void 0||r===void 0||a===void 0||o.links.some(p=>p.from===a.from&&p.to===a.to))return;const d=o.links.map(p=>p.id),l=o.elements.map(p=>p.id),c=un(s)?.id,h=c!==void 0&&i.indexOf(r)>i.indexOf(s)?Zh(l,this.#v(r),[c],"after"):[];this.#y([J.linkElements(kn(`link-${a.from}`,d),a.from,a.to,{kind:"flow"}),...h.map(p=>J.moveElement(p.id,p.after))])}#w(e){const n=this.#r(),o=this.#d().find(s=>s.id===e)?.rect;if(n===null||o===void 0)return;const i=n.getBoundingClientRect();return{x:i.left+o.left+o.width,y:i.top+o.top+o.height/2}}#C(e){const n=this.#w(e);n!==void 0&&(this.mode={kind:"append",sliceId:e,point:n},this.requestUpdate())}#$(e,n){const o=this.items(),i=this.#b(e),s=i?un(i):void 0;if(s===void 0){this.mode=Re,this.requestUpdate();return}const r=yn(`new-${n}`,hn(o)),a=o.links.map(l=>l.id);if(!this.#y([J.addElement(r,n,be(this.locale).noteTypeLabel(n)),J.linkElements(kn(`link-${s.id}`,a),s.id,r,{kind:"flow"})])){this.mode=Re,this.requestUpdate();return}this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate()}#F(e){const n=this.items(),o=yn("new-hotspot",hn(n)),i=n.links.map(r=>r.id);this.#y([J.addElement(o,"hotspot",be(this.locale).noteTypeLabel("hotspot")),J.linkElements(kn(`link-${o}`,i),o,e,{kind:"member"})])&&(this.select({kind:"note",id:o}),this.mode={kind:"editing",noteId:o},this.requestUpdate())}#S(e,n){const o=this.#b(e),i=o===void 0?void 0:iu(o,n);if(i===void 0)return;const s=this.items(),r=yn(`new-${n}`,hn(s)),[a,d]=i.incoming?[r,i.anchorId]:[i.anchorId,r],l=s.links.map(h=>h.id);this.#y([J.addElement(r,n,be(this.locale).noteTypeLabel(n)),J.linkElements(kn(`link-${a}`,l),a,d,{kind:"member"})])&&(this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate())}#M(e,n,o){const i=this.items(),s=Sr(i.elements.map(r=>r.id),this.#v(this.#b(e)),this.#v(this.#b(n)),o);this.#y(s.map(r=>J.moveElement(r.id,r.after)))}#O(e,n){this.mode.kind==="editing"&&(this.mode=Re),this.selectedSliceIds=[],this.selectedLinkIds=n?this.selectedLinkIds.includes(e)?this.selectedLinkIds.filter(o=>o!==e):[...this.selectedLinkIds,e]:[e],this.requestUpdate(),this.#r()?.focus()}#N(){const e=this.items();if(this.selectedLinkIds.length>0){const i=e.links.filter(s=>this.selectedLinkIds.includes(s.id));this.#y(i.map(s=>J.unlinkElements(s.from,s.to))),this.selectedLinkIds=[],this.requestUpdate();return}if(this.selectedSliceIds.length===0)return;const n=ht(e),o=this.selectedSliceIds.flatMap(i=>this.#v(n.find(s=>s.id===i)));this.#y(o.map(i=>J.deleteElement(i))),this.selectedSliceIds=[],this.requestUpdate()}#z(e){if(e.target!==e.currentTarget)return;if(e.key==="Escape"){this.selectedSliceIds=[],this.selectedLinkIds=[],this.requestUpdate();return}if(e.key!=="Delete"&&e.key!=="Backspace"||this.mode.kind!=="idle"||this.naming!==void 0)return;if(e.preventDefault(),this.selectedLinkIds.length>0||this.selectedSliceIds.length>0){this.#N();return}const n=this.selection?.kind==="note"?this.selection.id:void 0;n===void 0||pt(this.items(),n)===void 0||(this.#L(J.deleteElement(n)),this.select(null))}#U(e){const n=this.items(),o=ht(n),i=this.selectedSliceIds.flatMap(r=>this.#v(o.find(a=>a.id===r)));this.#y(i.map(r=>J.setElementContext(r,e)))&&(this.selectedSliceIds=[],this.requestUpdate())}#B(e){const o=this.renderRoot.querySelector("#context-name")?.value.trim()??"";if(o==="")return;if(e.kind==="rename-context"){this.#L(J.setContextName(e.contextId,o))&&(this.naming=void 0,this.requestUpdate());return}const i=this.items(),s=Zu("context",i.contexts.map(l=>l.id)),r=ht(i),a=e.sliceIds.flatMap(l=>this.#v(r.find(c=>c.id===l)));this.#y([J.addContext(s,o),...a.map(l=>J.setElementContext(l,s))])&&(this.selectedSliceIds=[],this.naming=void 0,this.requestUpdate())}#G(e){const n=be(this.locale),o=e.kind==="rename-context"?Ao(this.items(),e.contextId)?.name??"":"";return k`<div id="context-pop" class="comment-pop context-pop" popover="manual">
3369
3369
  <span class="dpk-label"> ${e.kind==="create-context"?n.newContextTitle:n.renameContextTitle} </span>
3370
3370
  <input
3371
3371
  id="context-name"
@@ -3373,7 +3373,7 @@ ${o.renameContextHint}`}
3373
3373
  type="text"
3374
3374
  placeholder=${n.contextNamePlaceholder}
3375
3375
  .value=${o}
3376
- @keydown=${i=>{i.key==="Enter"&&this.#F(e),i.key==="Escape"&&(this.naming=void 0,this.requestUpdate())}}
3376
+ @keydown=${i=>{i.key==="Enter"&&this.#B(e),i.key==="Escape"&&(this.naming=void 0,this.requestUpdate())}}
3377
3377
  />
3378
3378
  <div class="pop-actions">
3379
3379
  <button
@@ -3384,19 +3384,19 @@ ${o.renameContextHint}`}
3384
3384
  >
3385
3385
  ${n.cancel}
3386
3386
  </button>
3387
- <button class="dpk-btn dpk-btn--accent" type="button" @click=${()=>this.#F(e)}>
3387
+ <button class="dpk-btn dpk-btn--accent" type="button" @click=${()=>this.#B(e)}>
3388
3388
  ${e.kind==="create-context"?n.create:n.save}
3389
3389
  </button>
3390
3390
  </div>
3391
- </div>`}#B(e){const n=fe(this.locale),o=this.#b(e),i=o===void 0?void 0:pn(o);return v`<div id="append-menu" class="comment-pop append-menu" popover="manual">
3391
+ </div>`}#H(e){const n=be(this.locale),o=this.#b(e),i=o===void 0?void 0:un(o);return k`<div id="append-menu" class="comment-pop append-menu" popover="manual">
3392
3392
  <span class="dpk-label">${i===void 0?n.appendMenuNext:n.appendMenuAfter(i.name)}</span>
3393
3393
  <div class="type-options">
3394
- ${Au.map(s=>v`<button
3394
+ ${Ku.map(s=>k`<button
3395
3395
  class="type-chip"
3396
3396
  type="button"
3397
3397
  data-type=${s}
3398
- style=${Io(s)}
3399
- @click=${()=>this.#E(e,s)}
3398
+ style=${Ro(s)}
3399
+ @click=${()=>this.#$(e,s)}
3400
3400
  >
3401
3401
  ${n.noteTypeLabel(s)}
3402
3402
  </button>`)}
@@ -3405,24 +3405,24 @@ ${o.renameContextHint}`}
3405
3405
  <button
3406
3406
  class="dpk-btn"
3407
3407
  type="button"
3408
- @click=${()=>{this.mode=Le,this.requestUpdate()}}
3408
+ @click=${()=>{this.mode=Re,this.requestUpdate()}}
3409
3409
  >
3410
3410
  ${n.cancel}
3411
3411
  </button>
3412
3412
  </div>
3413
- </div>`}#G(){const e=this.items(),n=bn("new-event",cn(e));if(!this.#S(J.addElement(n,"event",fe(this.locale).noteTypeLabel("event")))){this.mode=Le,this.requestUpdate();return}this.select({kind:"note",id:n}),this.mode={kind:"editing",noteId:n},this.requestUpdate()}#S(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],Jn(o)?o:{})}#x(e){let n=!0;for(const o of e)this.#S(o)||(n=!1);return n}}const bn=(t,e)=>Do(t,e),xn=(t,e)=>Do(t,e),Pu=(t,e)=>Do(t,e),Do=(t,e)=>{const n=new Set(e);if(!n.has(t))return t;let o=2;for(;n.has(`${t}-${o}`);)o+=1;return`${t}-${o}`},Dr=()=>{Lh(),customElements.get("dpk-board-event-storming")||customElements.define("dpk-board-event-storming",Nr)},qu=P({id:oe,name:I(y(),_(1)),description:W(y()),questions:Ze}),Fu=P({id:oe,storyId:I(y(),_(1)),name:I(y(),_(1)),description:W(y()),questions:Ze}),zr=P({id:oe,ruleId:I(y(),_(1)),name:I(y(),_(1)),description:W(y()),questions:Ze}),Bu=P({title:W(y()),stories:C(F(qu),[]),rules:C(F(Fu),[]),examples:C(F(zr),[]),questions:C(F(zr),[])}),Uu=t=>{const e=he(Bu,t),n=new Set,o=(r,a)=>{if(n.has(a))throw new Error(`duplicate id "${a}" in ${r}`);n.add(a)},i=new Set(e.stories.map(r=>r.id));for(const r of e.stories)o("stories",r.id);for(const r of e.rules)if(o("rules",r.id),!i.has(r.storyId))throw new Error(`rule "${r.id}" references unknown storyId "${r.storyId}"`);const s=new Map(e.rules.map(r=>[r.id,r]));for(const r of e.examples)if(o("examples",r.id),!s.has(r.ruleId))throw new Error(`example "${r.id}" references unknown ruleId "${r.ruleId}"`);for(const r of e.questions)if(o("questions",r.id),!s.has(r.ruleId))throw new Error(`question "${r.id}" references unknown ruleId "${r.ruleId}"`);return e},Hu=()=>({stories:[],rules:[],examples:[],questions:[]}),Pe=(t,e)=>{if(e!==void 0)return t.stories.find(n=>n.id===e)},se=(t,e)=>{if(e!==void 0)return t.rules.find(n=>n.id===e)},qe=(t,e)=>{if(e!==void 0)return t.examples.find(n=>n.id===e)},Fe=(t,e)=>{if(e!==void 0)return t.questions.find(n=>n.id===e)},Pr=(t,e)=>{if(e===void 0)return;const n=Pe(t,e);if(n)return{kind:"story",id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}};const o=se(t,e);if(o)return{kind:"rule",id:o.id,name:o.name,...o.description===void 0?{}:{description:o.description}};const i=qe(t,e);if(i)return{kind:"example",id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}};const s=Fe(t,e);if(s)return{kind:"question",id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description}}},Yu=(t,e)=>t.rules.filter(n=>n.storyId===e),Xu=(t,e)=>t.examples.filter(n=>n.ruleId===e),Gu=(t,e)=>t.questions.filter(n=>n.ruleId===e),yn=t=>[...t.stories.map(e=>e.id),...t.rules.map(e=>e.id),...t.examples.map(e=>e.id),...t.questions.map(e=>e.id)],Ku=(t,e,n,o)=>{if(!Pe(t,e))return null;const i=t.stories.map(s=>s.id);return{type:"REORDER_STORY",target:{type:"story",id:e},payload:{after:Gt(i,e,n,o)}}},ju=(t,e,n,o,i)=>{if(!Pe(t,e)||!se(t,n))return null;const s=t.rules.filter(r=>r.storyId===e).map(r=>r.id);return{type:"MOVE_RULE",target:{type:"rule",id:n},payload:{storyId:e,after:Gt(s,n,o,i)}}},Wu=(t,e,n,o,i)=>{if(!se(t,e)||!qe(t,n))return null;const s=t.examples.filter(r=>r.ruleId===e).map(r=>r.id);return{type:"MOVE_EXAMPLE",target:{type:"example",id:n},payload:{ruleId:e,after:Gt(s,n,o,i)}}},Vu=(t,e,n,o,i)=>{if(!se(t,e)||!Fe(t,n))return null;const s=t.questions.filter(r=>r.ruleId===e).map(r=>r.id);return{type:"MOVE_QUESTION",target:{type:"question",id:n},payload:{ruleId:e,after:Gt(s,n,o,i)}}},Qu={story:"Story",rule:"Rule",example:"Example",question:"Question"},Zu={story:"\u30B9\u30C8\u30FC\u30EA\u30FC",rule:"\u30EB\u30FC\u30EB",example:"\u5177\u4F53\u4F8B",question:"\u8CEA\u554F"},Ju={empty:"No rules yet","open-questions":"Open questions","too-big":"Consider splitting",thin:"A rule has no example",ready:"Looks ready"},em={empty:"\u30EB\u30FC\u30EB\u672A\u6574\u7406","open-questions":"\u672A\u89E3\u6C7A\u306E\u8CEA\u554F\u3042\u308A","too-big":"\u5206\u5272\u3092\u691C\u8A0E",thin:"\u5177\u4F53\u4F8B\u306E\u7121\u3044\u30EB\u30FC\u30EB\u3042\u308A",ready:"\u5408\u610F\u3067\u304D\u305D\u3046"},Be=ce({en:{heading:"Example Mapping",kindLabel:t=>Qu[t],readinessLabel:t=>Ju[t],map:"Map",noStoriesTitle:"No stories yet",noStoriesBody:"Place one story (yellow), then line up the rules (blue) that accept it beneath it. For each rule, stack examples (green) in the top area and open questions (red) in the bottom area.",firstStory:"+ First story",addStoryButton:"+ Story",noExamples:"No examples yet",noQuestions:"No open questions",deleteButton:"Delete",commentCard:"Comment",nameField:t=>`${t} name`,newStory:"New story",newRule:"New rule",newExample:"New example",newQuestion:"New question",storyRenamedTitle:"Renamed the story",storyDescriptionUpdatedTitle:"Updated the story\u2019s description",storyReorderedTitle:"Reordered the story",storyAddedTitle:"Added a story",storyDeletedTitle:"Deleted the story",ruleRenamedTitle:"Renamed the rule",ruleDescriptionUpdatedTitle:"Updated the rule\u2019s description",ruleMovedTitle:"Moved the rule",ruleReorderedTitle:"Reordered the rule",ruleAddedTitle:"Added a rule",ruleDeletedTitle:"Deleted the rule",exampleRenamedTitle:"Renamed the example",exampleDescriptionUpdatedTitle:"Updated the example\u2019s description",exampleMovedTitle:"Moved the example",exampleReorderedTitle:"Reordered the example",exampleAddedTitle:"Added an example",exampleDeletedTitle:"Deleted the example",questionRenamedTitle:"Renamed the question",questionDescriptionUpdatedTitle:"Updated the question\u2019s description",questionMovedTitle:"Moved the question",questionReorderedTitle:"Reordered the question",questionAddedTitle:"Added a question",questionDeletedTitle:"Deleted the question",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,toTop:"\u2192 To the top",afterPlacement:t=>`\u2192 After \u201C${t}\u201D`,wholeMap:"Whole map"},ja:{heading:"Example Mapping",kindLabel:t=>Zu[t],readinessLabel:t=>em[t],map:"\u30DE\u30C3\u30D7",noStoriesTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",noStoriesBody:"\u30B9\u30C8\u30FC\u30EA\u30FC\uFF08\u9EC4\uFF09\u30921\u679A\u7F6E\u304D\u3001\u305D\u306E\u4E0B\u306B\u53D7\u3051\u5165\u308C\u6761\u4EF6\u3068\u306A\u308B\u30EB\u30FC\u30EB\uFF08\u9752\uFF09\u3092\u4E26\u3079\u307E\u3059\u3002\u30EB\u30FC\u30EB\u3054\u3068\u306B\u3001\u4E0A\u306E\u6B04\u3078\u5177\u4F53\u4F8B\uFF08\u7DD1\uFF09\u3092\u3001\u4E0B\u306E\u6B04\u3078\u7B54\u3048\u306E\u51FA\u306A\u3044\u8AD6\u70B9\u3092\u8CEA\u554F\uFF08\u8D64\uFF09\u3068\u3057\u3066\u7A4D\u307F\u307E\u3059\u3002",firstStory:"+ \u6700\u521D\u306E\u30B9\u30C8\u30FC\u30EA\u30FC",addStoryButton:"+ \u30B9\u30C8\u30FC\u30EA\u30FC",noExamples:"\u5177\u4F53\u4F8B\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",noQuestions:"\u672A\u89E3\u6C7A\u306E\u8CEA\u554F\u306F\u3042\u308A\u307E\u305B\u3093",deleteButton:"\u524A\u9664",commentCard:"\u30B3\u30E1\u30F3\u30C8",nameField:t=>`${t}\u540D`,newStory:"\u65B0\u3057\u3044\u30B9\u30C8\u30FC\u30EA\u30FC",newRule:"\u65B0\u3057\u3044\u30EB\u30FC\u30EB",newExample:"\u65B0\u3057\u3044\u5177\u4F53\u4F8B",newQuestion:"\u65B0\u3057\u3044\u8CEA\u554F",storyRenamedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u540D\u3092\u5909\u66F4",storyDescriptionUpdatedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u306E\u8AAC\u660E\u3092\u66F4\u65B0",storyReorderedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u306E\u9806\u5E8F\u3092\u5909\u66F4",storyAddedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u3092\u8FFD\u52A0",storyDeletedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u3092\u524A\u9664",ruleRenamedTitle:"\u30EB\u30FC\u30EB\u540D\u3092\u5909\u66F4",ruleDescriptionUpdatedTitle:"\u30EB\u30FC\u30EB\u306E\u8AAC\u660E\u3092\u66F4\u65B0",ruleMovedTitle:"\u30EB\u30FC\u30EB\u3092\u79FB\u52D5",ruleReorderedTitle:"\u30EB\u30FC\u30EB\u306E\u9806\u5E8F\u3092\u5909\u66F4",ruleAddedTitle:"\u30EB\u30FC\u30EB\u3092\u8FFD\u52A0",ruleDeletedTitle:"\u30EB\u30FC\u30EB\u3092\u524A\u9664",exampleRenamedTitle:"\u5177\u4F53\u4F8B\u540D\u3092\u5909\u66F4",exampleDescriptionUpdatedTitle:"\u5177\u4F53\u4F8B\u306E\u8AAC\u660E\u3092\u66F4\u65B0",exampleMovedTitle:"\u5177\u4F53\u4F8B\u3092\u79FB\u52D5",exampleReorderedTitle:"\u5177\u4F53\u4F8B\u306E\u9806\u5E8F\u3092\u5909\u66F4",exampleAddedTitle:"\u5177\u4F53\u4F8B\u3092\u8FFD\u52A0",exampleDeletedTitle:"\u5177\u4F53\u4F8B\u3092\u524A\u9664",questionRenamedTitle:"\u8CEA\u554F\u540D\u3092\u5909\u66F4",questionDescriptionUpdatedTitle:"\u8CEA\u554F\u306E\u8AAC\u660E\u3092\u66F4\u65B0",questionMovedTitle:"\u8CEA\u554F\u3092\u79FB\u52D5",questionReorderedTitle:"\u8CEA\u554F\u306E\u9806\u5E8F\u3092\u5909\u66F4",questionAddedTitle:"\u8CEA\u554F\u3092\u8FFD\u52A0",questionDeletedTitle:"\u8CEA\u554F\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,toTop:"\u2192 \u5148\u982D\u3078",afterPlacement:t=>`\u2192 \u300C${t}\u300D\u306E\u76F4\u5F8C\u3078`,wholeMap:"\u30DE\u30C3\u30D7\u5168\u4F53"}}),V={SET_STORY_NAME:z("SET_STORY_NAME","story",O({name:I(y(),_(1))})),SET_STORY_DESCRIPTION:z("SET_STORY_DESCRIPTION","story",O({description:y()})),REORDER_STORY:z("REORDER_STORY","story",O({after:ue(y())}),{mode:"sequence"}),ADD_STORY:z("ADD_STORY","page",O({id:oe,name:I(y(),_(1)),description:W(y())}),{dedupeKey:Se}),DELETE_STORY:z("DELETE_STORY","story",O({})),SET_RULE_NAME:z("SET_RULE_NAME","rule",O({name:I(y(),_(1))})),SET_RULE_DESCRIPTION:z("SET_RULE_DESCRIPTION","rule",O({description:y()})),MOVE_RULE:z("MOVE_RULE","rule",O({storyId:I(y(),_(1)),after:ue(y())}),{mode:"sequence"}),REORDER_RULE:z("REORDER_RULE","rule",O({after:ue(y())}),{mode:"sequence"}),ADD_RULE:z("ADD_RULE","story",O({id:oe,name:I(y(),_(1)),description:W(y())}),{dedupeKey:Se}),DELETE_RULE:z("DELETE_RULE","rule",O({})),SET_EXAMPLE_NAME:z("SET_EXAMPLE_NAME","example",O({name:I(y(),_(1))})),SET_EXAMPLE_DESCRIPTION:z("SET_EXAMPLE_DESCRIPTION","example",O({description:y()})),MOVE_EXAMPLE:z("MOVE_EXAMPLE","example",O({ruleId:I(y(),_(1)),after:ue(y())}),{mode:"sequence"}),REORDER_EXAMPLE:z("REORDER_EXAMPLE","example",O({after:ue(y())}),{mode:"sequence"}),ADD_EXAMPLE:z("ADD_EXAMPLE","rule",O({id:oe,name:I(y(),_(1)),description:W(y())}),{dedupeKey:Se}),DELETE_EXAMPLE:z("DELETE_EXAMPLE","example",O({})),SET_QUESTION_NAME:z("SET_QUESTION_NAME","question",O({name:I(y(),_(1))})),SET_QUESTION_DESCRIPTION:z("SET_QUESTION_DESCRIPTION","question",O({description:y()})),MOVE_QUESTION:z("MOVE_QUESTION","question",O({ruleId:I(y(),_(1)),after:ue(y())}),{mode:"sequence"}),REORDER_QUESTION:z("REORDER_QUESTION","question",O({after:ue(y())}),{mode:"sequence"}),ADD_QUESTION:z("ADD_QUESTION","rule",O({id:oe,name:I(y(),_(1)),description:W(y())}),{dedupeKey:Se}),DELETE_QUESTION:z("DELETE_QUESTION","question",O({}))},tm=(t,e)=>{const n=Bt(V,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_STORY_NAME":return qr(t,o,i=>({...i,name:n.payload.name}));case"SET_STORY_DESCRIPTION":return qr(t,o,i=>({...i,description:n.payload.description}));case"REORDER_STORY":{const i=nm(t.stories,o,n.payload.after);return i===null?null:{...t,stories:i}}case"ADD_STORY":{const i=n.payload;return t.stories.some(s=>s.id===i.id)?t:vn(t,i.id)?null:{...t,stories:[...t.stories,{id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}}case"DELETE_STORY":{if(!t.stories.some(s=>s.id===o))return null;const i=new Set(t.rules.filter(s=>s.storyId===o).map(s=>s.id));return{...t,stories:t.stories.filter(s=>s.id!==o),rules:t.rules.filter(s=>s.storyId!==o),examples:t.examples.filter(s=>!i.has(s.ruleId)),questions:t.questions.filter(s=>!i.has(s.ruleId))}}case"SET_RULE_NAME":return Fr(t,o,i=>({...i,name:n.payload.name}));case"SET_RULE_DESCRIPTION":return Fr(t,o,i=>({...i,description:n.payload.description}));case"MOVE_RULE":{const i=n.payload,s=se(t,o);if(!s||!t.stories.some(a=>a.id===i.storyId))return null;const r=t.rules.filter(a=>a.storyId===i.storyId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,rules:Hr(t.rules,{...s,storyId:i.storyId},i.after)}}case"REORDER_RULE":{const i=se(t,o);if(!i)return null;const s=t.rules.filter(r=>r.storyId===i.storyId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,rules:Hr(t.rules,i,n.payload.after)}}case"ADD_RULE":{const i=n.payload,s=Pe(t,o);return s?t.rules.some(r=>r.id===i.id)?t:vn(t,i.id)?null:{...t,rules:[...t.rules,{id:i.id,storyId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_RULE":return se(t,o)?{...t,rules:t.rules.filter(i=>i.id!==o),examples:t.examples.filter(i=>i.ruleId!==o),questions:t.questions.filter(i=>i.ruleId!==o)}:null;case"SET_EXAMPLE_NAME":return Br(t,o,i=>({...i,name:n.payload.name}));case"SET_EXAMPLE_DESCRIPTION":return Br(t,o,i=>({...i,description:n.payload.description}));case"MOVE_EXAMPLE":{const i=n.payload,s=qe(t,o);if(!s||!se(t,i.ruleId))return null;const r=t.examples.filter(a=>a.ruleId===i.ruleId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,examples:kn(t.examples,{...s,ruleId:i.ruleId},i.after)}}case"REORDER_EXAMPLE":{const i=qe(t,o);if(!i)return null;const s=t.examples.filter(r=>r.ruleId===i.ruleId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,examples:kn(t.examples,i,n.payload.after)}}case"ADD_EXAMPLE":{const i=n.payload,s=se(t,o);return s?t.examples.some(r=>r.id===i.id)?t:vn(t,i.id)?null:{...t,examples:[...t.examples,{id:i.id,ruleId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_EXAMPLE":return qe(t,o)?{...t,examples:t.examples.filter(i=>i.id!==o)}:null;case"SET_QUESTION_NAME":return Ur(t,o,i=>({...i,name:n.payload.name}));case"SET_QUESTION_DESCRIPTION":return Ur(t,o,i=>({...i,description:n.payload.description}));case"MOVE_QUESTION":{const i=n.payload,s=Fe(t,o);if(!s||!se(t,i.ruleId))return null;const r=t.questions.filter(a=>a.ruleId===i.ruleId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,questions:kn(t.questions,{...s,ruleId:i.ruleId},i.after)}}case"REORDER_QUESTION":{const i=Fe(t,o);if(!i)return null;const s=t.questions.filter(r=>r.ruleId===i.ruleId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,questions:kn(t.questions,i,n.payload.after)}}case"ADD_QUESTION":{const i=n.payload,s=se(t,o);return s?t.questions.some(r=>r.id===i.id)?t:vn(t,i.id)?null:{...t,questions:[...t.questions,{id:i.id,ruleId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_QUESTION":return Fe(t,o)?{...t,questions:t.questions.filter(i=>i.id!==o)}:null;default:return Xn(n)}},vn=(t,e)=>t.stories.some(n=>n.id===e)||t.rules.some(n=>n.id===e)||t.examples.some(n=>n.id===e)||t.questions.some(n=>n.id===e),qr=(t,e,n)=>t.stories.some(o=>o.id===e)?{...t,stories:t.stories.map(o=>o.id===e?n(o):o)}:null,Fr=(t,e,n)=>t.rules.some(o=>o.id===e)?{...t,rules:t.rules.map(o=>o.id===e?n(o):o)}:null,Br=(t,e,n)=>t.examples.some(o=>o.id===e)?{...t,examples:t.examples.map(o=>o.id===e?n(o):o)}:null,Ur=(t,e,n)=>t.questions.some(o=>o.id===e)?{...t,questions:t.questions.map(o=>o.id===e?n(o):o)}:null,Hr=(t,e,n)=>{const o=t.filter(c=>c.id!==e.id),i=o.filter(c=>c.storyId===e.storyId),s=n===null?[e,...i]:zo(i,e,n),r=o.findIndex(c=>c.storyId===e.storyId),a=new Set(i.map(c=>c.id)),d=o.filter(c=>!a.has(c.id)),l=r<0?d.length:Math.min(r,d.length);return[...d.slice(0,l),...s,...d.slice(l)]},kn=(t,e,n)=>{const o=t.filter(c=>c.id!==e.id),i=o.filter(c=>c.ruleId===e.ruleId),s=n===null?[e,...i]:zo(i,e,n),r=o.findIndex(c=>c.ruleId===e.ruleId),a=new Set(i.map(c=>c.id)),d=o.filter(c=>!a.has(c.id)),l=r<0?d.length:Math.min(r,d.length);return[...d.slice(0,l),...s,...d.slice(l)]},nm=(t,e,n)=>{if(!t.some(s=>s.id===e)||n!==null&&!t.some(s=>s.id===n))return null;if(n===e)return[...t];const o=t.find(s=>s.id===e);if(o===void 0)return null;const i=t.filter(s=>s.id!==e);return zo(i,o,n)},zo=(t,e,n)=>{const o=[...t],i=n===null?-1:o.findIndex(s=>s.id===n);return o.splice(i+1,0,e),o},wn=(t,e,n)=>{const o=typeof n=="string"?n:"",i=typeof e=="string"?e:void 0;return i===void 0?t.arrowTo(o):t.arrowFrom(i,o)},om={SET_STORY_NAME:(t,e,n)=>({title:t.storyRenamedTitle,tone:"update",body:wn(t,Pe(n,e.target.id)?.name,B(V.SET_STORY_NAME,e).name??"")}),SET_STORY_DESCRIPTION:(t,e)=>({title:t.storyDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(B(V.SET_STORY_DESCRIPTION,e).description??"").slice(0,90))}),REORDER_STORY:(t,e)=>({title:t.storyReorderedTitle,tone:"move",body:$n(t,B(V.REORDER_STORY,e).after)}),ADD_STORY:(t,e)=>({title:t.storyAddedTitle,tone:"create",body:t.added(String(B(V.ADD_STORY,e).name??""))}),DELETE_STORY:(t,e,n)=>({title:t.storyDeletedTitle,tone:"delete",body:t.deleted(Pe(n,e.target.id)?.name??e.target.id)}),SET_RULE_NAME:(t,e,n)=>({title:t.ruleRenamedTitle,tone:"update",body:wn(t,se(n,e.target.id)?.name,B(V.SET_RULE_NAME,e).name??"")}),SET_RULE_DESCRIPTION:(t,e)=>({title:t.ruleDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(B(V.SET_RULE_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_RULE:(t,e,n)=>({title:t.ruleMovedTitle,tone:"move",body:t.arrowTo(Pe(n,String(B(V.MOVE_RULE,e).storyId))?.name??String(B(V.MOVE_RULE,e).storyId??""))}),REORDER_RULE:(t,e)=>({title:t.ruleReorderedTitle,tone:"move",body:$n(t,B(V.REORDER_RULE,e).after)}),ADD_RULE:(t,e)=>({title:t.ruleAddedTitle,tone:"create",body:t.added(String(B(V.ADD_RULE,e).name??""))}),DELETE_RULE:(t,e,n)=>({title:t.ruleDeletedTitle,tone:"delete",body:t.deleted(se(n,e.target.id)?.name??e.target.id)}),SET_EXAMPLE_NAME:(t,e,n)=>({title:t.exampleRenamedTitle,tone:"update",body:wn(t,qe(n,e.target.id)?.name,B(V.SET_EXAMPLE_NAME,e).name??"")}),SET_EXAMPLE_DESCRIPTION:(t,e)=>({title:t.exampleDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(B(V.SET_EXAMPLE_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_EXAMPLE:(t,e,n)=>({title:t.exampleMovedTitle,tone:"move",body:t.arrowTo(se(n,String(B(V.MOVE_EXAMPLE,e).ruleId))?.name??String(B(V.MOVE_EXAMPLE,e).ruleId??""))}),REORDER_EXAMPLE:(t,e)=>({title:t.exampleReorderedTitle,tone:"move",body:$n(t,B(V.REORDER_EXAMPLE,e).after)}),ADD_EXAMPLE:(t,e)=>({title:t.exampleAddedTitle,tone:"create",body:t.added(String(B(V.ADD_EXAMPLE,e).name??""))}),DELETE_EXAMPLE:(t,e,n)=>({title:t.exampleDeletedTitle,tone:"delete",body:t.deleted(qe(n,e.target.id)?.name??e.target.id)}),SET_QUESTION_NAME:(t,e,n)=>({title:t.questionRenamedTitle,tone:"update",body:wn(t,Fe(n,e.target.id)?.name,B(V.SET_QUESTION_NAME,e).name??"")}),SET_QUESTION_DESCRIPTION:(t,e)=>({title:t.questionDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(B(V.SET_QUESTION_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_QUESTION:(t,e,n)=>({title:t.questionMovedTitle,tone:"move",body:t.arrowTo(se(n,String(B(V.MOVE_QUESTION,e).ruleId))?.name??String(B(V.MOVE_QUESTION,e).ruleId??""))}),REORDER_QUESTION:(t,e)=>({title:t.questionReorderedTitle,tone:"move",body:$n(t,B(V.REORDER_QUESTION,e).after)}),ADD_QUESTION:(t,e)=>({title:t.questionAddedTitle,tone:"create",body:t.added(String(B(V.ADD_QUESTION,e).name??""))}),DELETE_QUESTION:(t,e,n)=>({title:t.questionDeletedTitle,tone:"delete",body:t.deleted(Fe(n,e.target.id)?.name??e.target.id)})},$n=(t,e)=>e==null?t.toTop:t.afterPlacement(e),Yr=(t,e,n,o)=>{let i;try{const s=om[e.type];i=s?s(t,e,o??n):{title:e.type,tone:"meta"}}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:im(t,n,e.target),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},im=(t,e,n)=>{try{switch(n.type){case"story":{const o=Pe(e,n.id);return o?`${t.kindLabel("story")} \xB7 ${o.name}`:`${t.kindLabel("story")} \xB7 ${n.id} (missing)`}case"rule":{const o=se(e,n.id);return o?`${t.kindLabel("rule")} \xB7 ${o.name}`:`${t.kindLabel("rule")} \xB7 ${n.id} (missing)`}case"example":{const o=qe(e,n.id);return o?`${t.kindLabel("example")} \xB7 ${o.name}`:`${t.kindLabel("example")} \xB7 ${n.id} (missing)`}case"question":{const o=Fe(e,n.id);return o?`${t.kindLabel("question")} \xB7 ${o.name}`:`${t.kindLabel("question")} \xB7 ${n.id} (missing)`}case"page":return`${t.map} \xB7 ${am(e)}`;default:return`${n.type} \xB7 ${n.id}`}}catch{return`${n.type} \xB7 ${n.id}`}},sm=4,rm=(t,e,n)=>{const o=e.rules.filter(l=>l.storyId===n),i=new Set(o.map(l=>l.id)),s=e.examples.filter(l=>i.has(l.ruleId)),r=e.questions.filter(l=>i.has(l.ruleId)).length,a=o.some(l=>!s.some(c=>c.ruleId===l.id)),d=o.length===0?"empty":r>0?"open-questions":o.length>sm?"too-big":a?"thin":"ready";return{rules:o.length,examples:s.length,questions:r,readiness:d,label:t.readinessLabel(d)}},am=t=>t.title??"Example Mapping",dm=t=>t==="comment"?"meta":t,lm=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},cm=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=Yr(t,s,o).title;if(!(s.type in V)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=lm(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=tm(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=Yr(t,d,l,o);i.push({id:s.id,title:c.title,tone:dm(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},pm={story:{bg:"linear-gradient(178deg, #fff3a6, #fde77a)",ink:"#4a3a06"},rule:{bg:"linear-gradient(178deg, #a3d1f5, #7cb8ea)",ink:"#0e2c4b"},example:{bg:"linear-gradient(178deg, #c9eb95, #a8dc63)",ink:"#22380a"},question:{bg:"linear-gradient(178deg, #fbc6d9, #f4a0c0)",ink:"#4b1029"}},Ct=t=>{const{bg:e,ink:n}=pm[t];return`--em-card-bg:${e};--em-card-ink:${n}`},Xr=t=>{const e=t.currentTarget;e instanceof HTMLElement&&(e.draggable=t.type==="focusout")},hm=t=>{const{kind:e,card:n,tilt:o,mode:i,focused:s,dragging:r,m:a,dpkTarget:d,grillQuestions:l,onIntent:c,onComment:h,onDragStart:p,onDragEnd:u}=t,g=a.kindLabel(e);return v`
3413
+ </div>`}#X(){const e=this.items(),n=yn("new-event",hn(e));if(!this.#L(J.addElement(n,"event",be(this.locale).noteTypeLabel("event")))){this.mode=Re,this.requestUpdate();return}this.select({kind:"note",id:n}),this.mode={kind:"editing",noteId:n},this.requestUpdate()}#L(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],oo(o)?o:{})}#y(e){let n=!0;for(const o of e)this.#L(o)||(n=!1);return n}}const yn=(t,e)=>Fo(t,e),kn=(t,e)=>Fo(t,e),Zu=(t,e)=>Fo(t,e),Fo=(t,e)=>{const n=new Set(e);if(!n.has(t))return t;let o=2;for(;n.has(`${t}-${o}`);)o+=1;return`${t}-${o}`},Hr=()=>{Yh(),customElements.get("dpk-board-event-storming")||customElements.define("dpk-board-event-storming",Br)},Ju=P({id:oe,name:S(x(),I(1)),description:j(x()),questions:tt}),em=P({id:oe,storyId:S(x(),I(1)),name:S(x(),I(1)),description:j(x()),questions:tt}),Yr=P({id:oe,ruleId:S(x(),I(1)),name:S(x(),I(1)),description:j(x()),questions:tt}),tm=P({title:j(x()),stories:L(F(Ju),[]),rules:L(F(em),[]),examples:L(F(Yr),[]),questions:L(F(Yr),[])}),nm=t=>{const e=ue(tm,t),n=new Set,o=(r,a)=>{if(n.has(a))throw new Error(`duplicate id "${a}" in ${r}`);n.add(a)},i=new Set(e.stories.map(r=>r.id));for(const r of e.stories)o("stories",r.id);for(const r of e.rules)if(o("rules",r.id),!i.has(r.storyId))throw new Error(`rule "${r.id}" references unknown storyId "${r.storyId}"`);const s=new Map(e.rules.map(r=>[r.id,r]));for(const r of e.examples)if(o("examples",r.id),!s.has(r.ruleId))throw new Error(`example "${r.id}" references unknown ruleId "${r.ruleId}"`);for(const r of e.questions)if(o("questions",r.id),!s.has(r.ruleId))throw new Error(`question "${r.id}" references unknown ruleId "${r.ruleId}"`);return e},om=()=>({stories:[],rules:[],examples:[],questions:[]}),qe=(t,e)=>{if(e!==void 0)return t.stories.find(n=>n.id===e)},se=(t,e)=>{if(e!==void 0)return t.rules.find(n=>n.id===e)},Fe=(t,e)=>{if(e!==void 0)return t.examples.find(n=>n.id===e)},Ue=(t,e)=>{if(e!==void 0)return t.questions.find(n=>n.id===e)},Gr=(t,e)=>{if(e===void 0)return;const n=qe(t,e);if(n)return{kind:"story",id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}};const o=se(t,e);if(o)return{kind:"rule",id:o.id,name:o.name,...o.description===void 0?{}:{description:o.description}};const i=Fe(t,e);if(i)return{kind:"example",id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}};const s=Ue(t,e);if(s)return{kind:"question",id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description}}},im=(t,e)=>t.rules.filter(n=>n.storyId===e),sm=(t,e)=>t.examples.filter(n=>n.ruleId===e),rm=(t,e)=>t.questions.filter(n=>n.ruleId===e),vn=t=>[...t.stories.map(e=>e.id),...t.rules.map(e=>e.id),...t.examples.map(e=>e.id),...t.questions.map(e=>e.id)],am=(t,e,n,o)=>{if(!qe(t,e))return null;const i=t.stories.map(s=>s.id);return{type:"REORDER_STORY",target:{type:"story",id:e},payload:{after:jt(i,e,n,o)}}},dm=(t,e,n,o,i)=>{if(!qe(t,e)||!se(t,n))return null;const s=t.rules.filter(r=>r.storyId===e).map(r=>r.id);return{type:"MOVE_RULE",target:{type:"rule",id:n},payload:{storyId:e,after:jt(s,n,o,i)}}},lm=(t,e,n,o,i)=>{if(!se(t,e)||!Fe(t,n))return null;const s=t.examples.filter(r=>r.ruleId===e).map(r=>r.id);return{type:"MOVE_EXAMPLE",target:{type:"example",id:n},payload:{ruleId:e,after:jt(s,n,o,i)}}},cm=(t,e,n,o,i)=>{if(!se(t,e)||!Ue(t,n))return null;const s=t.questions.filter(r=>r.ruleId===e).map(r=>r.id);return{type:"MOVE_QUESTION",target:{type:"question",id:n},payload:{ruleId:e,after:jt(s,n,o,i)}}},pm={story:"Story",rule:"Rule",example:"Example",question:"Question"},hm={story:"\u30B9\u30C8\u30FC\u30EA\u30FC",rule:"\u30EB\u30FC\u30EB",example:"\u5177\u4F53\u4F8B",question:"\u8CEA\u554F"},um={empty:"No rules yet","open-questions":"Open questions","too-big":"Consider splitting",thin:"A rule has no example",ready:"Looks ready"},mm={empty:"\u30EB\u30FC\u30EB\u672A\u6574\u7406","open-questions":"\u672A\u89E3\u6C7A\u306E\u8CEA\u554F\u3042\u308A","too-big":"\u5206\u5272\u3092\u691C\u8A0E",thin:"\u5177\u4F53\u4F8B\u306E\u7121\u3044\u30EB\u30FC\u30EB\u3042\u308A",ready:"\u5408\u610F\u3067\u304D\u305D\u3046"},Be=pe({en:{heading:"Example Mapping",kindLabel:t=>pm[t],readinessLabel:t=>um[t],map:"Map",noStoriesTitle:"No stories yet",noStoriesBody:"Place one story (yellow), then line up the rules (blue) that accept it beneath it. For each rule, stack examples (green) in the top area and open questions (red) in the bottom area.",firstStory:"+ First story",addStoryButton:"+ Story",noExamples:"No examples yet",noQuestions:"No open questions",deleteButton:"Delete",commentCard:"Comment",nameField:t=>`${t} name`,newStory:"New story",newRule:"New rule",newExample:"New example",newQuestion:"New question",storyRenamedTitle:"Renamed the story",storyDescriptionUpdatedTitle:"Updated the story\u2019s description",storyReorderedTitle:"Reordered the story",storyAddedTitle:"Added a story",storyDeletedTitle:"Deleted the story",ruleRenamedTitle:"Renamed the rule",ruleDescriptionUpdatedTitle:"Updated the rule\u2019s description",ruleMovedTitle:"Moved the rule",ruleReorderedTitle:"Reordered the rule",ruleAddedTitle:"Added a rule",ruleDeletedTitle:"Deleted the rule",exampleRenamedTitle:"Renamed the example",exampleDescriptionUpdatedTitle:"Updated the example\u2019s description",exampleMovedTitle:"Moved the example",exampleReorderedTitle:"Reordered the example",exampleAddedTitle:"Added an example",exampleDeletedTitle:"Deleted the example",questionRenamedTitle:"Renamed the question",questionDescriptionUpdatedTitle:"Updated the question\u2019s description",questionMovedTitle:"Moved the question",questionReorderedTitle:"Reordered the question",questionAddedTitle:"Added a question",questionDeletedTitle:"Deleted the question",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,toTop:"\u2192 To the top",afterPlacement:t=>`\u2192 After \u201C${t}\u201D`,wholeMap:"Whole map"},ja:{heading:"Example Mapping",kindLabel:t=>hm[t],readinessLabel:t=>mm[t],map:"\u30DE\u30C3\u30D7",noStoriesTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",noStoriesBody:"\u30B9\u30C8\u30FC\u30EA\u30FC\uFF08\u9EC4\uFF09\u30921\u679A\u7F6E\u304D\u3001\u305D\u306E\u4E0B\u306B\u53D7\u3051\u5165\u308C\u6761\u4EF6\u3068\u306A\u308B\u30EB\u30FC\u30EB\uFF08\u9752\uFF09\u3092\u4E26\u3079\u307E\u3059\u3002\u30EB\u30FC\u30EB\u3054\u3068\u306B\u3001\u4E0A\u306E\u6B04\u3078\u5177\u4F53\u4F8B\uFF08\u7DD1\uFF09\u3092\u3001\u4E0B\u306E\u6B04\u3078\u7B54\u3048\u306E\u51FA\u306A\u3044\u8AD6\u70B9\u3092\u8CEA\u554F\uFF08\u8D64\uFF09\u3068\u3057\u3066\u7A4D\u307F\u307E\u3059\u3002",firstStory:"+ \u6700\u521D\u306E\u30B9\u30C8\u30FC\u30EA\u30FC",addStoryButton:"+ \u30B9\u30C8\u30FC\u30EA\u30FC",noExamples:"\u5177\u4F53\u4F8B\u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093",noQuestions:"\u672A\u89E3\u6C7A\u306E\u8CEA\u554F\u306F\u3042\u308A\u307E\u305B\u3093",deleteButton:"\u524A\u9664",commentCard:"\u30B3\u30E1\u30F3\u30C8",nameField:t=>`${t}\u540D`,newStory:"\u65B0\u3057\u3044\u30B9\u30C8\u30FC\u30EA\u30FC",newRule:"\u65B0\u3057\u3044\u30EB\u30FC\u30EB",newExample:"\u65B0\u3057\u3044\u5177\u4F53\u4F8B",newQuestion:"\u65B0\u3057\u3044\u8CEA\u554F",storyRenamedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u540D\u3092\u5909\u66F4",storyDescriptionUpdatedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u306E\u8AAC\u660E\u3092\u66F4\u65B0",storyReorderedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u306E\u9806\u5E8F\u3092\u5909\u66F4",storyAddedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u3092\u8FFD\u52A0",storyDeletedTitle:"\u30B9\u30C8\u30FC\u30EA\u30FC\u3092\u524A\u9664",ruleRenamedTitle:"\u30EB\u30FC\u30EB\u540D\u3092\u5909\u66F4",ruleDescriptionUpdatedTitle:"\u30EB\u30FC\u30EB\u306E\u8AAC\u660E\u3092\u66F4\u65B0",ruleMovedTitle:"\u30EB\u30FC\u30EB\u3092\u79FB\u52D5",ruleReorderedTitle:"\u30EB\u30FC\u30EB\u306E\u9806\u5E8F\u3092\u5909\u66F4",ruleAddedTitle:"\u30EB\u30FC\u30EB\u3092\u8FFD\u52A0",ruleDeletedTitle:"\u30EB\u30FC\u30EB\u3092\u524A\u9664",exampleRenamedTitle:"\u5177\u4F53\u4F8B\u540D\u3092\u5909\u66F4",exampleDescriptionUpdatedTitle:"\u5177\u4F53\u4F8B\u306E\u8AAC\u660E\u3092\u66F4\u65B0",exampleMovedTitle:"\u5177\u4F53\u4F8B\u3092\u79FB\u52D5",exampleReorderedTitle:"\u5177\u4F53\u4F8B\u306E\u9806\u5E8F\u3092\u5909\u66F4",exampleAddedTitle:"\u5177\u4F53\u4F8B\u3092\u8FFD\u52A0",exampleDeletedTitle:"\u5177\u4F53\u4F8B\u3092\u524A\u9664",questionRenamedTitle:"\u8CEA\u554F\u540D\u3092\u5909\u66F4",questionDescriptionUpdatedTitle:"\u8CEA\u554F\u306E\u8AAC\u660E\u3092\u66F4\u65B0",questionMovedTitle:"\u8CEA\u554F\u3092\u79FB\u52D5",questionReorderedTitle:"\u8CEA\u554F\u306E\u9806\u5E8F\u3092\u5909\u66F4",questionAddedTitle:"\u8CEA\u554F\u3092\u8FFD\u52A0",questionDeletedTitle:"\u8CEA\u554F\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,toTop:"\u2192 \u5148\u982D\u3078",afterPlacement:t=>`\u2192 \u300C${t}\u300D\u306E\u76F4\u5F8C\u3078`,wholeMap:"\u30DE\u30C3\u30D7\u5168\u4F53"}}),V={SET_STORY_NAME:z("SET_STORY_NAME","story",_({name:S(x(),I(1))})),SET_STORY_DESCRIPTION:z("SET_STORY_DESCRIPTION","story",_({description:x()})),REORDER_STORY:z("REORDER_STORY","story",_({after:me(x())}),{mode:"sequence"}),ADD_STORY:z("ADD_STORY","page",_({id:oe,name:S(x(),I(1)),description:j(x())}),{dedupeKey:Ce}),DELETE_STORY:z("DELETE_STORY","story",_({})),SET_RULE_NAME:z("SET_RULE_NAME","rule",_({name:S(x(),I(1))})),SET_RULE_DESCRIPTION:z("SET_RULE_DESCRIPTION","rule",_({description:x()})),MOVE_RULE:z("MOVE_RULE","rule",_({storyId:S(x(),I(1)),after:me(x())}),{mode:"sequence"}),REORDER_RULE:z("REORDER_RULE","rule",_({after:me(x())}),{mode:"sequence"}),ADD_RULE:z("ADD_RULE","story",_({id:oe,name:S(x(),I(1)),description:j(x())}),{dedupeKey:Ce}),DELETE_RULE:z("DELETE_RULE","rule",_({})),SET_EXAMPLE_NAME:z("SET_EXAMPLE_NAME","example",_({name:S(x(),I(1))})),SET_EXAMPLE_DESCRIPTION:z("SET_EXAMPLE_DESCRIPTION","example",_({description:x()})),MOVE_EXAMPLE:z("MOVE_EXAMPLE","example",_({ruleId:S(x(),I(1)),after:me(x())}),{mode:"sequence"}),REORDER_EXAMPLE:z("REORDER_EXAMPLE","example",_({after:me(x())}),{mode:"sequence"}),ADD_EXAMPLE:z("ADD_EXAMPLE","rule",_({id:oe,name:S(x(),I(1)),description:j(x())}),{dedupeKey:Ce}),DELETE_EXAMPLE:z("DELETE_EXAMPLE","example",_({})),SET_QUESTION_NAME:z("SET_QUESTION_NAME","question",_({name:S(x(),I(1))})),SET_QUESTION_DESCRIPTION:z("SET_QUESTION_DESCRIPTION","question",_({description:x()})),MOVE_QUESTION:z("MOVE_QUESTION","question",_({ruleId:S(x(),I(1)),after:me(x())}),{mode:"sequence"}),REORDER_QUESTION:z("REORDER_QUESTION","question",_({after:me(x())}),{mode:"sequence"}),ADD_QUESTION:z("ADD_QUESTION","rule",_({id:oe,name:S(x(),I(1)),description:j(x())}),{dedupeKey:Ce}),DELETE_QUESTION:z("DELETE_QUESTION","question",_({}))},gm=(t,e)=>{const n=Ht(V,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_STORY_NAME":return Xr(t,o,i=>({...i,name:n.payload.name}));case"SET_STORY_DESCRIPTION":return Xr(t,o,i=>({...i,description:n.payload.description}));case"REORDER_STORY":{const i=fm(t.stories,o,n.payload.after);return i===null?null:{...t,stories:i}}case"ADD_STORY":{const i=n.payload;return t.stories.some(s=>s.id===i.id)?t:wn(t,i.id)?null:{...t,stories:[...t.stories,{id:i.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}}case"DELETE_STORY":{if(!t.stories.some(s=>s.id===o))return null;const i=new Set(t.rules.filter(s=>s.storyId===o).map(s=>s.id));return{...t,stories:t.stories.filter(s=>s.id!==o),rules:t.rules.filter(s=>s.storyId!==o),examples:t.examples.filter(s=>!i.has(s.ruleId)),questions:t.questions.filter(s=>!i.has(s.ruleId))}}case"SET_RULE_NAME":return Kr(t,o,i=>({...i,name:n.payload.name}));case"SET_RULE_DESCRIPTION":return Kr(t,o,i=>({...i,description:n.payload.description}));case"MOVE_RULE":{const i=n.payload,s=se(t,o);if(!s||!t.stories.some(a=>a.id===i.storyId))return null;const r=t.rules.filter(a=>a.storyId===i.storyId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,rules:Vr(t.rules,{...s,storyId:i.storyId},i.after)}}case"REORDER_RULE":{const i=se(t,o);if(!i)return null;const s=t.rules.filter(r=>r.storyId===i.storyId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,rules:Vr(t.rules,i,n.payload.after)}}case"ADD_RULE":{const i=n.payload,s=qe(t,o);return s?t.rules.some(r=>r.id===i.id)?t:wn(t,i.id)?null:{...t,rules:[...t.rules,{id:i.id,storyId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_RULE":return se(t,o)?{...t,rules:t.rules.filter(i=>i.id!==o),examples:t.examples.filter(i=>i.ruleId!==o),questions:t.questions.filter(i=>i.ruleId!==o)}:null;case"SET_EXAMPLE_NAME":return jr(t,o,i=>({...i,name:n.payload.name}));case"SET_EXAMPLE_DESCRIPTION":return jr(t,o,i=>({...i,description:n.payload.description}));case"MOVE_EXAMPLE":{const i=n.payload,s=Fe(t,o);if(!s||!se(t,i.ruleId))return null;const r=t.examples.filter(a=>a.ruleId===i.ruleId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,examples:$n(t.examples,{...s,ruleId:i.ruleId},i.after)}}case"REORDER_EXAMPLE":{const i=Fe(t,o);if(!i)return null;const s=t.examples.filter(r=>r.ruleId===i.ruleId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,examples:$n(t.examples,i,n.payload.after)}}case"ADD_EXAMPLE":{const i=n.payload,s=se(t,o);return s?t.examples.some(r=>r.id===i.id)?t:wn(t,i.id)?null:{...t,examples:[...t.examples,{id:i.id,ruleId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_EXAMPLE":return Fe(t,o)?{...t,examples:t.examples.filter(i=>i.id!==o)}:null;case"SET_QUESTION_NAME":return Wr(t,o,i=>({...i,name:n.payload.name}));case"SET_QUESTION_DESCRIPTION":return Wr(t,o,i=>({...i,description:n.payload.description}));case"MOVE_QUESTION":{const i=n.payload,s=Ue(t,o);if(!s||!se(t,i.ruleId))return null;const r=t.questions.filter(a=>a.ruleId===i.ruleId&&a.id!==o);return i.after!==null&&!r.some(a=>a.id===i.after)?null:{...t,questions:$n(t.questions,{...s,ruleId:i.ruleId},i.after)}}case"REORDER_QUESTION":{const i=Ue(t,o);if(!i)return null;const s=t.questions.filter(r=>r.ruleId===i.ruleId);return n.payload.after!==null&&!s.some(r=>r.id===n.payload.after)?null:{...t,questions:$n(t.questions,i,n.payload.after)}}case"ADD_QUESTION":{const i=n.payload,s=se(t,o);return s?t.questions.some(r=>r.id===i.id)?t:wn(t,i.id)?null:{...t,questions:[...t.questions,{id:i.id,ruleId:s.id,name:i.name,...i.description===void 0?{}:{description:i.description}}]}:null}case"DELETE_QUESTION":return Ue(t,o)?{...t,questions:t.questions.filter(i=>i.id!==o)}:null;default:return Kn(n)}},wn=(t,e)=>t.stories.some(n=>n.id===e)||t.rules.some(n=>n.id===e)||t.examples.some(n=>n.id===e)||t.questions.some(n=>n.id===e),Xr=(t,e,n)=>t.stories.some(o=>o.id===e)?{...t,stories:t.stories.map(o=>o.id===e?n(o):o)}:null,Kr=(t,e,n)=>t.rules.some(o=>o.id===e)?{...t,rules:t.rules.map(o=>o.id===e?n(o):o)}:null,jr=(t,e,n)=>t.examples.some(o=>o.id===e)?{...t,examples:t.examples.map(o=>o.id===e?n(o):o)}:null,Wr=(t,e,n)=>t.questions.some(o=>o.id===e)?{...t,questions:t.questions.map(o=>o.id===e?n(o):o)}:null,Vr=(t,e,n)=>{const o=t.filter(c=>c.id!==e.id),i=o.filter(c=>c.storyId===e.storyId),s=n===null?[e,...i]:Uo(i,e,n),r=o.findIndex(c=>c.storyId===e.storyId),a=new Set(i.map(c=>c.id)),d=o.filter(c=>!a.has(c.id)),l=r<0?d.length:Math.min(r,d.length);return[...d.slice(0,l),...s,...d.slice(l)]},$n=(t,e,n)=>{const o=t.filter(c=>c.id!==e.id),i=o.filter(c=>c.ruleId===e.ruleId),s=n===null?[e,...i]:Uo(i,e,n),r=o.findIndex(c=>c.ruleId===e.ruleId),a=new Set(i.map(c=>c.id)),d=o.filter(c=>!a.has(c.id)),l=r<0?d.length:Math.min(r,d.length);return[...d.slice(0,l),...s,...d.slice(l)]},fm=(t,e,n)=>{if(!t.some(s=>s.id===e)||n!==null&&!t.some(s=>s.id===n))return null;if(n===e)return[...t];const o=t.find(s=>s.id===e);if(o===void 0)return null;const i=t.filter(s=>s.id!==e);return Uo(i,o,n)},Uo=(t,e,n)=>{const o=[...t],i=n===null?-1:o.findIndex(s=>s.id===n);return o.splice(i+1,0,e),o},En=(t,e,n)=>{const o=typeof n=="string"?n:"",i=typeof e=="string"?e:void 0;return i===void 0?t.arrowTo(o):t.arrowFrom(i,o)},bm={SET_STORY_NAME:(t,e,n)=>({title:t.storyRenamedTitle,tone:"update",body:En(t,qe(n,e.target.id)?.name,U(V.SET_STORY_NAME,e).name??"")}),SET_STORY_DESCRIPTION:(t,e)=>({title:t.storyDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(U(V.SET_STORY_DESCRIPTION,e).description??"").slice(0,90))}),REORDER_STORY:(t,e)=>({title:t.storyReorderedTitle,tone:"move",body:Tn(t,U(V.REORDER_STORY,e).after)}),ADD_STORY:(t,e)=>({title:t.storyAddedTitle,tone:"create",body:t.added(String(U(V.ADD_STORY,e).name??""))}),DELETE_STORY:(t,e,n)=>({title:t.storyDeletedTitle,tone:"delete",body:t.deleted(qe(n,e.target.id)?.name??e.target.id)}),SET_RULE_NAME:(t,e,n)=>({title:t.ruleRenamedTitle,tone:"update",body:En(t,se(n,e.target.id)?.name,U(V.SET_RULE_NAME,e).name??"")}),SET_RULE_DESCRIPTION:(t,e)=>({title:t.ruleDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(U(V.SET_RULE_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_RULE:(t,e,n)=>({title:t.ruleMovedTitle,tone:"move",body:t.arrowTo(qe(n,String(U(V.MOVE_RULE,e).storyId))?.name??String(U(V.MOVE_RULE,e).storyId??""))}),REORDER_RULE:(t,e)=>({title:t.ruleReorderedTitle,tone:"move",body:Tn(t,U(V.REORDER_RULE,e).after)}),ADD_RULE:(t,e)=>({title:t.ruleAddedTitle,tone:"create",body:t.added(String(U(V.ADD_RULE,e).name??""))}),DELETE_RULE:(t,e,n)=>({title:t.ruleDeletedTitle,tone:"delete",body:t.deleted(se(n,e.target.id)?.name??e.target.id)}),SET_EXAMPLE_NAME:(t,e,n)=>({title:t.exampleRenamedTitle,tone:"update",body:En(t,Fe(n,e.target.id)?.name,U(V.SET_EXAMPLE_NAME,e).name??"")}),SET_EXAMPLE_DESCRIPTION:(t,e)=>({title:t.exampleDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(U(V.SET_EXAMPLE_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_EXAMPLE:(t,e,n)=>({title:t.exampleMovedTitle,tone:"move",body:t.arrowTo(se(n,String(U(V.MOVE_EXAMPLE,e).ruleId))?.name??String(U(V.MOVE_EXAMPLE,e).ruleId??""))}),REORDER_EXAMPLE:(t,e)=>({title:t.exampleReorderedTitle,tone:"move",body:Tn(t,U(V.REORDER_EXAMPLE,e).after)}),ADD_EXAMPLE:(t,e)=>({title:t.exampleAddedTitle,tone:"create",body:t.added(String(U(V.ADD_EXAMPLE,e).name??""))}),DELETE_EXAMPLE:(t,e,n)=>({title:t.exampleDeletedTitle,tone:"delete",body:t.deleted(Fe(n,e.target.id)?.name??e.target.id)}),SET_QUESTION_NAME:(t,e,n)=>({title:t.questionRenamedTitle,tone:"update",body:En(t,Ue(n,e.target.id)?.name,U(V.SET_QUESTION_NAME,e).name??"")}),SET_QUESTION_DESCRIPTION:(t,e)=>({title:t.questionDescriptionUpdatedTitle,tone:"update",body:t.arrowTo(String(U(V.SET_QUESTION_DESCRIPTION,e).description??"").slice(0,90))}),MOVE_QUESTION:(t,e,n)=>({title:t.questionMovedTitle,tone:"move",body:t.arrowTo(se(n,String(U(V.MOVE_QUESTION,e).ruleId))?.name??String(U(V.MOVE_QUESTION,e).ruleId??""))}),REORDER_QUESTION:(t,e)=>({title:t.questionReorderedTitle,tone:"move",body:Tn(t,U(V.REORDER_QUESTION,e).after)}),ADD_QUESTION:(t,e)=>({title:t.questionAddedTitle,tone:"create",body:t.added(String(U(V.ADD_QUESTION,e).name??""))}),DELETE_QUESTION:(t,e,n)=>({title:t.questionDeletedTitle,tone:"delete",body:t.deleted(Ue(n,e.target.id)?.name??e.target.id)})},Tn=(t,e)=>e==null?t.toTop:t.afterPlacement(e),Qr=(t,e,n,o)=>{let i;try{const s=bm[e.type];i=s?s(t,e,o??n):{title:e.type,tone:"meta"}}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:xm(t,n,e.target),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},xm=(t,e,n)=>{try{switch(n.type){case"story":{const o=qe(e,n.id);return o?`${t.kindLabel("story")} \xB7 ${o.name}`:`${t.kindLabel("story")} \xB7 ${n.id} (missing)`}case"rule":{const o=se(e,n.id);return o?`${t.kindLabel("rule")} \xB7 ${o.name}`:`${t.kindLabel("rule")} \xB7 ${n.id} (missing)`}case"example":{const o=Fe(e,n.id);return o?`${t.kindLabel("example")} \xB7 ${o.name}`:`${t.kindLabel("example")} \xB7 ${n.id} (missing)`}case"question":{const o=Ue(e,n.id);return o?`${t.kindLabel("question")} \xB7 ${o.name}`:`${t.kindLabel("question")} \xB7 ${n.id} (missing)`}case"page":return`${t.map} \xB7 ${vm(e)}`;default:return`${n.type} \xB7 ${n.id}`}}catch{return`${n.type} \xB7 ${n.id}`}},ym=4,km=(t,e,n)=>{const o=e.rules.filter(l=>l.storyId===n),i=new Set(o.map(l=>l.id)),s=e.examples.filter(l=>i.has(l.ruleId)),r=e.questions.filter(l=>i.has(l.ruleId)).length,a=o.some(l=>!s.some(c=>c.ruleId===l.id)),d=o.length===0?"empty":r>0?"open-questions":o.length>ym?"too-big":a?"thin":"ready";return{rules:o.length,examples:s.length,questions:r,readiness:d,label:t.readinessLabel(d)}},vm=t=>t.title??"Example Mapping",wm=t=>t==="comment"?"meta":t,$m=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},Em=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=Qr(t,s,o).title;if(!(s.type in V)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=$m(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=gm(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=Qr(t,d,l,o);i.push({id:s.id,title:c.title,tone:wm(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Tm={story:{bg:"linear-gradient(178deg, #fff3a6, #fde77a)",ink:"#4a3a06"},rule:{bg:"linear-gradient(178deg, #a3d1f5, #7cb8ea)",ink:"#0e2c4b"},example:{bg:"linear-gradient(178deg, #c9eb95, #a8dc63)",ink:"#22380a"},question:{bg:"linear-gradient(178deg, #fbc6d9, #f4a0c0)",ink:"#4b1029"}},Rt=t=>{const{bg:e,ink:n}=Tm[t];return`--em-card-bg:${e};--em-card-ink:${n}`},Zr=t=>{const e=t.currentTarget;e instanceof HTMLElement&&(e.draggable=t.type==="focusout")},Sm=t=>{const{kind:e,card:n,tilt:o,mode:i,focused:s,dragging:r,m:a,dpkTarget:d,grillQuestions:l,onIntent:c,onComment:h,onDragStart:p,onDragEnd:u}=t,g=a.kindLabel(e);return k`
3414
3414
  <div
3415
- class=${ye("em-card",s&&"is-focused",r&&"is-dragging")}
3415
+ class=${ve("em-card",s&&"is-focused",r&&"is-dragging")}
3416
3416
  data-card=${n.id}
3417
3417
  data-card-kind=${e}
3418
3418
  data-mode=${i}
3419
3419
  data-dpk-target=${d}
3420
- data-grill-questions=${Kt(l)}
3421
- style=${`${Ct(e)};--em-tilt:${o}deg`}
3420
+ data-grill-questions=${Wt(l)}
3421
+ style=${`${Rt(e)};--em-tilt:${o}deg`}
3422
3422
  draggable="true"
3423
3423
  @click=${()=>c({kind:"select"})}
3424
- @focusin=${Xr}
3425
- @focusout=${Xr}
3424
+ @focusin=${Zr}
3425
+ @focusout=${Zr}
3426
3426
  @dragstart=${p}
3427
3427
  @dragend=${u}
3428
3428
  >
@@ -3433,9 +3433,9 @@ ${o.renameContextHint}`}
3433
3433
  ?seamless=${!0}
3434
3434
  .value=${n.name}
3435
3435
  .label=${a.nameField(g)}
3436
- @dpk-commit=${Hn(b=>c({kind:"rename",name:b}))}
3436
+ @dpk-commit=${nt(b=>c({kind:"rename",name:b}))}
3437
3437
  ></dpk-inline-edit>
3438
- ${n.description?v`<div class="card-text">${n.description}</div>`:M}
3438
+ ${n.description?k`<div class="card-text">${n.description}</div>`:T}
3439
3439
  <div class="card-tools">
3440
3440
  <button
3441
3441
  class="dpk-icon-btn"
@@ -3444,7 +3444,7 @@ ${o.renameContextHint}`}
3444
3444
  aria-label=${a.commentCard}
3445
3445
  @click=${b=>{b.stopPropagation(),h(e,n.id)}}
3446
3446
  >
3447
- ${Yn()}
3447
+ ${Xn()}
3448
3448
  </button>
3449
3449
  <button
3450
3450
  class="dpk-icon-btn"
@@ -3453,24 +3453,24 @@ ${o.renameContextHint}`}
3453
3453
  aria-label=${a.deleteButton}
3454
3454
  @click=${b=>{b.stopPropagation(),c({kind:"delete"})}}
3455
3455
  >
3456
- ${Ft()}
3456
+ ${Bt()}
3457
3457
  </button>
3458
3458
  </div>
3459
3459
  </div>
3460
- `},Po={kind:"idle"},Gr=(t,e)=>t.kind!=="idle"&&t.cardId===e,um=(t,e)=>Gr(t,e)&&t.kind==="editing"?"editing":"view",mm=(t,e,n)=>{switch(n.kind){case"rename":case"delete":return Gr(t,e)?Po:t;case"select":return t}},gm=(t,e)=>{if(t==="story")return 0;let n=0;for(const o of e)n=n*31+o.charCodeAt(0)|0;return(Math.abs(n)%5-2)*.45},fm=t=>{const{state:e,handlers:n,m:o}=t;return e.stories.length===0?v`
3460
+ `},Bo={kind:"idle"},Jr=(t,e)=>t.kind!=="idle"&&t.cardId===e,Mm=(t,e)=>Jr(t,e)&&t.kind==="editing"?"editing":"view",Cm=(t,e,n)=>{switch(n.kind){case"rename":case"delete":return Jr(t,e)?Bo:t;case"select":return t}},Lm=(t,e)=>{if(t==="story")return 0;let n=0;for(const o of e)n=n*31+o.charCodeAt(0)|0;return(Math.abs(n)%5-2)*.45},Im=t=>{const{state:e,handlers:n,m:o}=t;return e.stories.length===0?k`
3461
3461
  <div class="empty">
3462
3462
  <h2>${o.noStoriesTitle}</h2>
3463
3463
  <p>${o.noStoriesBody}</p>
3464
3464
  <button class="dpk-btn dpk-btn--accent" type="button" @click=${n.addStory}>${o.firstStory}</button>
3465
3465
  </div>
3466
- `:v`
3466
+ `:k`
3467
3467
  <div class="board" data-testid="example-mapping-board">
3468
- ${Te(e.stories,i=>i.id,i=>bm(t,i))}
3468
+ ${Me(e.stories,i=>i.id,i=>Am(t,i))}
3469
3469
  <button class="add-story" type="button" @click=${n.addStory}>${o.addStoryButton}</button>
3470
3470
  </div>
3471
- `},qo=(t,e,n)=>{const{mode:o,drag:i,handlers:s,m:r}=t,a=i.source({type:e,id:n.id}),d=Ut(n.questions);return v`<span class="card-slot">
3472
- ${hm({kind:e,card:{id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}},tilt:gm(e,n.id),mode:um(o,n.id),focused:s.isSelected(e,n.id),dragging:i.isDragging(e,n.id),m:r,dpkTarget:t.commentRef(e,n.id),...d===void 0?{}:{grillQuestions:d},onIntent:l=>s.cardIntent(n.id,e,l),onComment:t.onComment,onDragStart:a.dragstart,onDragEnd:a.dragend})}
3473
- </span>`},bm=(t,e)=>{const{state:n,drag:o,handlers:i,m:s}=t,r=rm(s,n,e.id),a=`story:${e.id}`,d=o.target({key:a,accepts:"story",hovered:Wr(".story-section","story"),onDrop:i.dropStory}),l=`rules:${e.id}`,c=o.target({key:l,accepts:"rule",hovered:Wr(".rule-col","rule"),onDrop:h=>i.dropRule(e.id,h)});return v`
3471
+ `},Ho=(t,e,n)=>{const{mode:o,drag:i,handlers:s,m:r}=t,a=i.source({type:e,id:n.id}),d=Yt(n.questions);return k`<span class="card-slot">
3472
+ ${Sm({kind:e,card:{id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}},tilt:Lm(e,n.id),mode:Mm(o,n.id),focused:s.isSelected(e,n.id),dragging:i.isDragging(e,n.id),m:r,dpkTarget:t.commentRef(e,n.id),...d===void 0?{}:{grillQuestions:d},onIntent:l=>s.cardIntent(n.id,e,l),onComment:t.onComment,onDragStart:a.dragstart,onDragEnd:a.dragend})}
3473
+ </span>`},Am=(t,e)=>{const{state:n,drag:o,handlers:i,m:s}=t,r=km(s,n,e.id),a=`story:${e.id}`,d=o.target({key:a,accepts:"story",hovered:na(".story-section","story"),onDrop:i.dropStory}),l=`rules:${e.id}`,c=o.target({key:l,accepts:"rule",hovered:na(".rule-col","rule"),onDrop:h=>i.dropRule(e.id,h)});return k`
3474
3474
  <section
3475
3475
  class="story-section"
3476
3476
  data-story=${e.id}
@@ -3481,18 +3481,18 @@ ${o.renameContextHint}`}
3481
3481
  @drop=${d.drop}
3482
3482
  >
3483
3483
  <header class="story-row">
3484
- <div class="story-slot">${qo(t,"story",e)}</div>
3484
+ <div class="story-slot">${Ho(t,"story",e)}</div>
3485
3485
  <div class="story-meta">
3486
3486
  <span class="readiness" data-readiness=${r.readiness}>${r.label}</span>
3487
3487
  <span class="tally"
3488
- ><i class="tally-dot" style=${Ct("rule")}></i>${s.kindLabel("rule")} ${r.rules}</span
3488
+ ><i class="tally-dot" style=${Rt("rule")}></i>${s.kindLabel("rule")} ${r.rules}</span
3489
3489
  >
3490
3490
  <span class="tally"
3491
- ><i class="tally-dot" style=${Ct("example")}></i>${s.kindLabel("example")}
3491
+ ><i class="tally-dot" style=${Rt("example")}></i>${s.kindLabel("example")}
3492
3492
  ${r.examples}</span
3493
3493
  >
3494
3494
  <span class="tally"
3495
- ><i class="tally-dot" style=${Ct("question")}></i>${s.kindLabel("question")}
3495
+ ><i class="tally-dot" style=${Rt("question")}></i>${s.kindLabel("question")}
3496
3496
  ${r.questions}</span
3497
3497
  >
3498
3498
  </div>
@@ -3506,18 +3506,18 @@ ${o.renameContextHint}`}
3506
3506
  @dragleave=${c.dragleave}
3507
3507
  @drop=${c.drop}
3508
3508
  >
3509
- ${Te(Yu(n,e.id),h=>h.id,h=>xm(t,h))}
3509
+ ${Me(im(n,e.id),h=>h.id,h=>Rm(t,h))}
3510
3510
  <button class="add-rule" type="button" @click=${()=>i.addRule(e.id)}>
3511
3511
  <span class="add-plus">+</span>${s.kindLabel("rule")}
3512
3512
  </button>
3513
3513
  </div>
3514
3514
  </section>
3515
- `},xm=(t,e)=>{const{drag:n}=t;return v`
3515
+ `},Rm=(t,e)=>{const{drag:n}=t;return k`
3516
3516
  <div class="rule-col" data-rule=${e.id} ?data-dragging=${n.isDragging("rule",e.id)}>
3517
- ${qo(t,"rule",e)} ${Kr(t,e.id,"example")}
3518
- ${Kr(t,e.id,"question")}
3517
+ ${Ho(t,"rule",e)} ${ea(t,e.id,"example")}
3518
+ ${ea(t,e.id,"question")}
3519
3519
  </div>
3520
- `},ym={example:"examples",question:"questions"},vm=(t,e)=>({testid:ym[e],label:t.kindLabel(e),empty:e==="example"?t.noExamples:t.noQuestions,add:`+ ${t.kindLabel(e)}`}),Kr=(t,e,n)=>{const{state:o,drag:i,handlers:s,m:r}=t,a=vm(r,n),d=`${a.testid}:${e}`,l=n==="example"?i.target({key:d,accepts:"example",hovered:jr("example"),onDrop:p=>s.dropExample(e,p)}):i.target({key:d,accepts:"question",hovered:jr("question"),onDrop:p=>s.dropQuestion(e,p)}),c=n==="example"?Xu(o,e):Gu(o,e),h=n==="example"?s.addExample:s.addQuestion;return v`<div
3520
+ `},_m={example:"examples",question:"questions"},Dm=(t,e)=>({testid:_m[e],label:t.kindLabel(e),empty:e==="example"?t.noExamples:t.noQuestions,add:`+ ${t.kindLabel(e)}`}),ea=(t,e,n)=>{const{state:o,drag:i,handlers:s,m:r}=t,a=Dm(r,n),d=`${a.testid}:${e}`,l=n==="example"?i.target({key:d,accepts:"example",hovered:ta("example"),onDrop:p=>s.dropExample(e,p)}):i.target({key:d,accepts:"question",hovered:ta("question"),onDrop:p=>s.dropQuestion(e,p)}),c=n==="example"?sm(o,e):rm(o,e),h=n==="example"?s.addExample:s.addQuestion;return k`<div
3521
3521
  class="card-area card-area--${n}"
3522
3522
  data-testid=${`${a.testid}-${e}`}
3523
3523
  data-drop=${String(i.isOver(d))}
@@ -3526,11 +3526,11 @@ ${o.renameContextHint}`}
3526
3526
  @dragleave=${l.dragleave}
3527
3527
  @drop=${l.drop}
3528
3528
  >
3529
- <h3 class="area-label"><i class="tally-dot" style=${Ct(n)}></i>${a.label}</h3>
3530
- ${Te(c,p=>p.id,p=>qo(t,n,p))}
3531
- ${c.length===0?v`<p class="stack-hint">${a.empty}</p>`:M}
3529
+ <h3 class="area-label"><i class="tally-dot" style=${Rt(n)}></i>${a.label}</h3>
3530
+ ${Me(c,p=>p.id,p=>Ho(t,n,p))}
3531
+ ${c.length===0?k`<p class="stack-hint">${a.empty}</p>`:T}
3532
3532
  <button class="add-card add-${n}" type="button" @click=${()=>h(e)}>${a.add}</button>
3533
- </div>`},jr=t=>e=>{const n=e.target instanceof Element?e.target.closest(".em-card"):null;return!n||n.getAttribute("data-card-kind")!==t?null:{id:n.getAttribute("data-card"),element:n}},Wr=(t,e)=>n=>{const o=n.target instanceof Element?n.target.closest(t):null;return o?{id:o.getAttribute(`data-${e}`),element:o}:null},km=ae`
3533
+ </div>`},ta=t=>e=>{const n=e.target instanceof Element?e.target.closest(".em-card"):null;return!n||n.getAttribute("data-card-kind")!==t?null:{id:n.getAttribute("data-card"),element:n}},na=(t,e)=>n=>{const o=n.target instanceof Element?n.target.closest(t):null;return o?{id:o.getAttribute(`data-${e}`),element:o}:null},Om=de`
3534
3534
  /* ------------------------------------------------------------- board */
3535
3535
 
3536
3536
  .board {
@@ -3917,21 +3917,31 @@ ${o.renameContextHint}`}
3917
3917
  background: color-mix(in srgb, var(--dpk-paper-raised) 94%, transparent);
3918
3918
  box-shadow: var(--dpk-shadow-xs);
3919
3919
  }
3920
- `,wm={story:"SET_STORY_NAME",rule:"SET_RULE_NAME",example:"SET_EXAMPLE_NAME",question:"SET_QUESTION_NAME"},$m={story:"DELETE_STORY",rule:"DELETE_RULE",example:"DELETE_EXAMPLE",question:"DELETE_QUESTION"},Em="example-mapping";class Vr extends tt{boardAddable(){return!0}static{this.styles=[et,km]}#o=new il(this);#i=null;#e=Po;parseData(e){return Uu(e)}emptyData(){return Hu()}reduceElementActions(e,n){return cm(Be(this.locale),e,n)}defaultHeading(){return Be(this.locale).heading}shellClass(){return"example-mapping"}emptyMessage(){return Be(this.locale).noStoriesTitle}commentItems(){const e=this.items();return[...e.stories.map(n=>({value:this.commentRef("story",n.id),label:n.name})),...e.rules.map(n=>({value:this.commentRef("rule",n.id),label:n.name})),...e.examples.map(n=>({value:this.commentRef("example",n.id),label:n.name})),...e.questions.map(n=>({value:this.commentRef("question",n.id),label:n.name}))]}hasSelection(e){return Pr(this.items(),e.id)?.kind===e.kind}isEmpty(){return this.items().stories.length===0}refreshContent(){const e=this.authoredItems();e!==this.#i&&(this.#i=e,this.#e=Po)}render(){this.prepareRender();const e=Be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return v`
3920
+ `,Nm={story:"SET_STORY_NAME",rule:"SET_RULE_NAME",example:"SET_EXAMPLE_NAME",question:"SET_QUESTION_NAME"},zm={story:"DELETE_STORY",rule:"DELETE_RULE",example:"DELETE_EXAMPLE",question:"DELETE_QUESTION"},Pm="example-mapping";class oa extends st{boardAddable(){return!0}static{this.styles=[it,Om]}#o=new bl(this);#i=null;#e=Bo;parseData(e){return nm(e)}emptyData(){return om()}reduceElementActions(e,n){return Em(Be(this.locale),e,n)}defaultHeading(){return Be(this.locale).heading}shellClass(){return"example-mapping"}emptyMessage(){return Be(this.locale).noStoriesTitle}commentItems(){const e=this.items();return[...e.stories.map(n=>({value:this.commentRef("story",n.id),label:n.name})),...e.rules.map(n=>({value:this.commentRef("rule",n.id),label:n.name})),...e.examples.map(n=>({value:this.commentRef("example",n.id),label:n.name})),...e.questions.map(n=>({value:this.commentRef("question",n.id),label:n.name}))]}hasSelection(e){return Gr(this.items(),e.id)?.kind===e.kind}isEmpty(){return this.items().stories.length===0}refreshContent(){const e=this.authoredItems();e!==this.#i&&(this.#i=e,this.#e=Bo)}render(){this.prepareRender();const e=Be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return k`
3921
3921
  <dpk-dialog-panel
3922
3922
  class=${this.shellClass()}
3923
3923
  ?maximizable=${this.frameControls}
3924
3924
  ?resizable=${this.frameControls}
3925
3925
  heading=${this.heading??this.defaultHeading()}
3926
- subject=${o===""?M:o}
3926
+ subject=${o===""?T:o}
3927
3927
  @dpk-maximize-change=${()=>this.closeComposer()}
3928
3928
  >
3929
3929
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
3930
- ${this.dataError!==null?v`<p class="em-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:fm({state:this.items(),mode:this.#e,drag:this.#o,m:e,handlers:{cardIntent:(i,s,r)=>this.#c(i,s,r),addStory:()=>this.#a(),addRule:i=>this.#r(i),addExample:i=>this.#s(i),addQuestion:i=>this.#d(i),dropStory:i=>this.#p(i),dropRule:(i,s)=>this.#u(i,s),dropExample:(i,s)=>this.#l(i,s),dropQuestion:(i,s)=>this.#m(i,s),isSelected:(i,s)=>this.#n(i,s)},commentRef:(i,s)=>this.commentRef(i,s),onComment:(i,s)=>this.openComment(this.commentRef(i,s))})}
3930
+ ${this.dataError!==null?k`<p class="em-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:Im({state:this.items(),mode:this.#e,drag:this.#o,m:e,handlers:{cardIntent:(i,s,r)=>this.#c(i,s,r),addStory:()=>this.#a(),addRule:i=>this.#r(i),addExample:i=>this.#s(i),addQuestion:i=>this.#d(i),dropStory:i=>this.#h(i),dropRule:(i,s)=>this.#p(i,s),dropExample:(i,s)=>this.#l(i,s),dropQuestion:(i,s)=>this.#m(i,s),isSelected:(i,s)=>this.#t(i,s)},commentRef:(i,s)=>this.commentRef(i,s),onComment:(i,s)=>this.openComment(this.commentRef(i,s))})}
3931
3931
  </dpk-dialog-panel>
3932
3932
  ${this.renderSelection()}
3933
- `}#n(e,n){const o=this.selection;return o!==null&&o.kind===e&&o.id===n}#t(e){e!==null&&(this.#e={kind:"editing",cardId:e},this.select({kind:Pr(this.items(),e)?.kind??"story",id:e}),this.requestUpdate(),this.updateComplete.then(()=>{this.renderRoot.querySelector(`[data-card="${CSS.escape(e)}"] dpk-inline-edit`)?.startEditing()}))}#a(){const e=yn(this.items()),n=Be(this.locale).newStory,o=xe(`story ${n}`,e);this.#t(this.dispatchElementAction("ADD_STORY",["page",Em],{id:o,name:n})?o:null)}#r(e){const n=yn(this.items()),o=Be(this.locale).newRule,i=xe(`rule ${o}`,n);this.#t(this.dispatchElementAction("ADD_RULE",["story",e],{id:i,name:o})?i:null)}#s(e){const n=yn(this.items()),o=Be(this.locale).newExample,i=xe(`example ${o}`,n);this.#t(this.dispatchElementAction("ADD_EXAMPLE",["rule",e],{id:i,name:o})?i:null)}#d(e){const n=yn(this.items()),o=Be(this.locale).newQuestion,i=xe(`question ${o}`,n);this.#t(this.dispatchElementAction("ADD_QUESTION",["rule",e],{id:i,name:o})?i:null)}#c(e,n,o){switch(o.kind){case"select":this.select({kind:n,id:e});break;case"rename":this.dispatchElementAction(wm[n],[n,e],{name:o.name});break;case"delete":this.dispatchElementAction($m[n],[n,e],{}),this.selection?.id===e&&this.select(null);break}this.#e=mm(this.#e,e,o),this.requestUpdate()}#p(e){const n=Ku(this.items(),e.item.id,e.hoveredId,e.place);n&&this.dispatchElementAction(n.type,[n.target.type,n.target.id],n.payload)}#u(e,n){const o=this.#h(n.hoveredId,n.event.clientX,n.place),i=ju(this.items(),e,n.item.id,n.hoveredId,o);i&&this.dispatchElementAction(i.type,[i.target.type,i.target.id],i.payload)}#h(e,n,o){if(e===null)return o;const i=this.renderRoot.querySelector(`.rule-col[data-rule="${CSS.escape(e)}"]`);if(!i)return o;const s=i.getBoundingClientRect();return n<=s.left+s.width/2?"before":"after"}#l(e,n){const o=Wu(this.items(),e,n.item.id,n.hoveredId,n.place);o&&this.dispatchElementAction(o.type,[o.target.type,o.target.id],o.payload)}#m(e,n){const o=Vu(this.items(),e,n.item.id,n.hoveredId,n.place);o&&this.dispatchElementAction(o.type,[o.target.type,o.target.id],o.payload)}}const Qr=()=>{customElements.get("dpk-board-example-mapping")||customElements.define("dpk-board-example-mapping",Vr)},ct=ce({en:{heading:"Kanban",empty:"No columns.",cards:"Card",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",wipLimit:t=>`WIP limit ${t}`,addCardButton:"+ Card",addCardAriaLabel:t=>`Card to add to ${t}`,addCardPlaceholder:"Card title (Enter to add)",addCardTitle:"Add card",moveCardTitle:"Move card",addSummary:(t,e)=>`${t} \u203A ${e}`,moveSummarySame:(t,e)=>`${t}: reorder within ${e}`,moveSummaryAcross:(t,e,n)=>`${t}: ${e} \u2192 ${n}`,copyKey:"Copy ID",copyKeyTitle:"Copy ID and title"},ja:{heading:"\u30AB\u30F3\u30D0\u30F3",empty:"\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002",cards:"\u30AB\u30FC\u30C9",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",wipLimit:t=>`WIP \u4E0A\u9650 ${t}`,addCardButton:"\uFF0B \u30AB\u30FC\u30C9",addCardAriaLabel:t=>`${t} \u306B\u8FFD\u52A0\u3059\u308B\u30AB\u30FC\u30C9`,addCardPlaceholder:"\u30AB\u30FC\u30C9\u540D\uFF08Enter \u3067\u8FFD\u52A0\uFF09",addCardTitle:"\u30AB\u30FC\u30C9\u3092\u8FFD\u52A0",moveCardTitle:"\u30AB\u30FC\u30C9\u3092\u79FB\u52D5",addSummary:(t,e)=>`${t} \u203A ${e}`,moveSummarySame:(t,e)=>`${t}: ${e} \u5185\u3067\u4E26\u3079\u66FF\u3048`,moveSummaryAcross:(t,e,n)=>`${t}: ${e} \u2192 ${n}`,copyKey:"ID\u3092\u30B3\u30D4\u30FC",copyKeyTitle:"ID\u3068\u30BF\u30A4\u30C8\u30EB\u3092\u30B3\u30D4\u30FC"}}),Zr=I(le(),fi(),Ht(1)),Tm=P({id:I(y(),_(1)),number:C(Zr),title:I(y(),_(1)),description:C(y()),tags:C(F(y())),assignee:C(y()),questions:C(y())}),Sm=["gray","blue","green","amber","violet","red"],Mm=P({id:I(y(),_(1)),label:I(y(),_(1)),description:C(y()),color:C(X(Sm)),limit:C(I(le(),fi(),Ht(1))),cards:C(F(Tm))}),Im=P({columns:F(Mm)}),Cm=()=>({columns:[]}),Lm=t=>{const e=he(Im,t),n=new Set,o=new Set,i=e.columns.flatMap(d=>(d.cards??[]).flatMap(l=>l.number===void 0?[]:[l.number])),s=i.find((d,l)=>i.indexOf(d)!==l);if(s!==void 0)throw new Error(`duplicate card number: ${s}`);let r=Math.max(0,...i);return{columns:e.columns.map(d=>{if(n.has(d.id))throw new Error(`duplicate column id: ${d.id}`);return n.add(d.id),{id:d.id,label:d.label,description:d.description??null,color:d.color??null,limit:d.limit??null,cards:(d.cards??[]).map(l=>{if(o.has(l.id))throw new Error(`duplicate card id: ${l.id}`);return o.add(l.id),{id:l.id,number:l.number??++r,title:l.title,description:l.description??null,tags:l.tags??[],assignee:l.assignee??null,...l.questions===void 0?{}:{questions:l.questions},column:d.id,change:null}})}})}},Lt=(t,e)=>t.columns.flatMap(n=>n.cards).find(n=>n.id===e),je=t=>t.columns.flatMap(e=>e.cards),_m=(t,e)=>e===null?t:{columns:t.columns.map(n=>({...n,cards:n.cards.filter(e)}))},Rm=(t,e,n,o)=>{const i=Lt(t,e);if(i===void 0||i.column!==n)return!1;if(o===e)return!0;const s=t.columns.find(a=>a.id===n)?.cards??[],r=s.findIndex(a=>a.id===e);return(s[r+1]?.id??null)===o},Jr=t=>`TASK-${t.number}`,Am=t=>Math.max(0,...je(t).map(e=>e.number))+1,ea="ADD_CARD",ta="MOVE_CARD",Om=O({id:I(y(),_(1)),title:I(y(),Ge(),_(1)),number:C(Zr)}),Nm=O({column:I(y(),_(1)),before:ue(I(y(),_(1)))}),na=(t,e)=>{const n=Ne(t);return n?.length===3&&n[1]===e?n[2]??null:null},Dm=(t,e)=>({columns:t.columns.map(n=>n.cards.some(o=>o.id===e)?{...n,cards:n.cards.filter(o=>o.id!==e)}:n)}),oa=(t,e,n)=>({columns:t.columns.map(o=>{if(o.id!==n.column)return o;const i={...e,column:o.id},s=n.before===null?-1:o.cards.findIndex(r=>r.id===n.before);return{...o,cards:s<0?[...o.cards,i]:[...o.cards.slice(0,s),i,...o.cards.slice(s)]}})}),zm=(t,e,n)=>{const o=t.addCardTitle,i=na(n.target.id,"column"),s=e.columns.find(l=>l.id===i);if(s===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const r=Oe(Om,n.payload);if(!r.success||Lt(e,r.output.id)!==void 0)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const a=r.output.number??Am(e);if(je(e).some(l=>l.number===a))return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const d={id:r.output.id,number:a,title:r.output.title,description:null,tags:[],assignee:null,column:s.id,change:"added"};return{data:oa(e,d,{column:s.id,before:null}),result:{id:n.id,title:o,summary:t.addSummary(s.label,d.title),tone:"create"}}},Pm=(t,e,n)=>{const o=t.moveCardTitle,i=na(n.target.id,"card"),s=i===null?void 0:Lt(e,i);if(s===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const r=Oe(Nm,n.payload),a=e.columns.find(u=>u.id===s.column),d=r.success?e.columns.find(u=>u.id===r.output.column):void 0,l=r.success?r.output.before:null,c=l===null||l!==s.id&&d?.cards.some(u=>u.id===l)===!0;if(!r.success||a===void 0||d===void 0||!c)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const h={...s,change:s.change??"moved"},p=a.id===d.id?t.moveSummarySame(s.title,d.label):t.moveSummaryAcross(s.title,a.label,d.label);return{data:oa(Dm(e,s.id),h,{column:d.id,before:l}),result:{id:n.id,title:o,summary:p,tone:"move"}}},qm=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===ea?zm(t,o,s):s.type===ta?Pm(t,o,s):{data:o,result:{id:s.id,title:s.type,stale:"unsupported-action-type"}};o=r.data,i.push(r.result)}return{data:o,results:i}},Fm=ae`
3933
+ `}#t(e,n){const o=this.selection;return o!==null&&o.kind===e&&o.id===n}#n(e){e!==null&&(this.#e={kind:"editing",cardId:e},this.select({kind:Gr(this.items(),e)?.kind??"story",id:e}),this.requestUpdate(),this.updateComplete.then(()=>{this.renderRoot.querySelector(`[data-card="${CSS.escape(e)}"] dpk-inline-edit`)?.startEditing()}))}#a(){const e=vn(this.items()),n=Be(this.locale).newStory,o=ke(`story ${n}`,e);this.#n(this.dispatchElementAction("ADD_STORY",["page",Pm],{id:o,name:n})?o:null)}#r(e){const n=vn(this.items()),o=Be(this.locale).newRule,i=ke(`rule ${o}`,n);this.#n(this.dispatchElementAction("ADD_RULE",["story",e],{id:i,name:o})?i:null)}#s(e){const n=vn(this.items()),o=Be(this.locale).newExample,i=ke(`example ${o}`,n);this.#n(this.dispatchElementAction("ADD_EXAMPLE",["rule",e],{id:i,name:o})?i:null)}#d(e){const n=vn(this.items()),o=Be(this.locale).newQuestion,i=ke(`question ${o}`,n);this.#n(this.dispatchElementAction("ADD_QUESTION",["rule",e],{id:i,name:o})?i:null)}#c(e,n,o){switch(o.kind){case"select":this.select({kind:n,id:e});break;case"rename":this.dispatchElementAction(Nm[n],[n,e],{name:o.name});break;case"delete":this.dispatchElementAction(zm[n],[n,e],{}),this.selection?.id===e&&this.select(null);break}this.#e=Cm(this.#e,e,o),this.requestUpdate()}#h(e){const n=am(this.items(),e.item.id,e.hoveredId,e.place);n&&this.dispatchElementAction(n.type,[n.target.type,n.target.id],n.payload)}#p(e,n){const o=this.#u(n.hoveredId,n.event.clientX,n.place),i=dm(this.items(),e,n.item.id,n.hoveredId,o);i&&this.dispatchElementAction(i.type,[i.target.type,i.target.id],i.payload)}#u(e,n,o){if(e===null)return o;const i=this.renderRoot.querySelector(`.rule-col[data-rule="${CSS.escape(e)}"]`);if(!i)return o;const s=i.getBoundingClientRect();return n<=s.left+s.width/2?"before":"after"}#l(e,n){const o=lm(this.items(),e,n.item.id,n.hoveredId,n.place);o&&this.dispatchElementAction(o.type,[o.target.type,o.target.id],o.payload)}#m(e,n){const o=cm(this.items(),e,n.item.id,n.hoveredId,n.place);o&&this.dispatchElementAction(o.type,[o.target.type,o.target.id],o.payload)}}const ia=()=>{customElements.get("dpk-board-example-mapping")||customElements.define("dpk-board-example-mapping",oa)},We=pe({en:{heading:"Kanban",empty:"No columns.",cards:"Card",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",wipLimit:t=>`WIP limit ${t}`,addCardButton:"+ Card",addCardAriaLabel:t=>`Card to add to ${t}`,addCardPlaceholder:"Card title (Enter to add)",addCardTitle:"Add card",moveCardTitle:"Move card",addSummary:(t,e)=>`${t} \u203A ${e}`,moveSummarySame:(t,e)=>`${t}: reorder within ${e}`,moveSummaryAcross:(t,e,n)=>`${t}: ${e} \u2192 ${n}`,editSummary:(t,e)=>`${t} ${e}: edited`,cardTitleLabel:"Card title",setTitleTitle:"Set card title",setDescriptionTitle:"Set card description",setAssigneeTitle:"Set card assignee",addTagTitle:"Add tag",removeTagTitle:"Remove tag",addLinkTitle:"Add link",removeLinkTitle:"Remove link",cardDetailAria:t=>`Card ${t}`,closeCardDetail:"Close the card",cardStatusLabel:"Status",cardAssigneeLabel:"Assignee",cardAssigneePlaceholder:"Unassigned",cardTagsLabel:"Tags",cardTagsPlaceholder:"Tag (Enter to add)",removeTagAria:t=>`Remove the tag ${t}`,cardDescriptionLabel:"Description",cardDescriptionPlaceholder:"Notes, acceptance criteria, \u2026",cardLinksLabel:"Links",cardLinkUrlPlaceholder:"https://\u2026",cardLinkLabelPlaceholder:"Label (optional)",addLinkButton:"Add",removeLinkAria:t=>`Remove the link ${t}`,copyKey:"Copy ID",copyKeyTitle:"Copy ID and title"},ja:{heading:"\u30AB\u30F3\u30D0\u30F3",empty:"\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002",cards:"\u30AB\u30FC\u30C9",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",wipLimit:t=>`WIP \u4E0A\u9650 ${t}`,addCardButton:"\uFF0B \u30AB\u30FC\u30C9",addCardAriaLabel:t=>`${t} \u306B\u8FFD\u52A0\u3059\u308B\u30AB\u30FC\u30C9`,addCardPlaceholder:"\u30AB\u30FC\u30C9\u540D\uFF08Enter \u3067\u8FFD\u52A0\uFF09",addCardTitle:"\u30AB\u30FC\u30C9\u3092\u8FFD\u52A0",moveCardTitle:"\u30AB\u30FC\u30C9\u3092\u79FB\u52D5",addSummary:(t,e)=>`${t} \u203A ${e}`,moveSummarySame:(t,e)=>`${t}: ${e} \u5185\u3067\u4E26\u3079\u66FF\u3048`,moveSummaryAcross:(t,e,n)=>`${t}: ${e} \u2192 ${n}`,editSummary:(t,e)=>`${t} ${e}: edited`,cardTitleLabel:"Card title",setTitleTitle:"Set card title",setDescriptionTitle:"Set card description",setAssigneeTitle:"Set card assignee",addTagTitle:"Add tag",removeTagTitle:"Remove tag",addLinkTitle:"Add link",removeLinkTitle:"Remove link",cardDetailAria:t=>`Card ${t}`,closeCardDetail:"Close the card",cardStatusLabel:"Status",cardAssigneeLabel:"Assignee",cardAssigneePlaceholder:"Unassigned",cardTagsLabel:"Tags",cardTagsPlaceholder:"Tag (Enter to add)",removeTagAria:t=>`Remove the tag ${t}`,cardDescriptionLabel:"Description",cardDescriptionPlaceholder:"Notes, acceptance criteria, \u2026",cardLinksLabel:"Links",cardLinkUrlPlaceholder:"https://\u2026",cardLinkLabelPlaceholder:"Label (optional)",addLinkButton:"Add",removeLinkAria:t=>`Remove the link ${t}`,copyKey:"ID\u3092\u30B3\u30D4\u30FC",copyKeyTitle:"ID\u3068\u30BF\u30A4\u30C8\u30EB\u3092\u30B3\u30D4\u30FC"}}),sa=S(ce(),vi(),Gt(1)),qm=P({url:Mi,label:j(S(x(),I(1)))}),Fm=P({id:S(x(),I(1)),number:L(sa),title:S(x(),I(1)),description:L(x()),tags:L(F(x())),assignee:L(x()),links:L(F(qm)),questions:L(x())}),Um=["gray","blue","green","amber","violet","red"],Bm=P({id:S(x(),I(1)),label:S(x(),I(1)),description:L(x()),color:L(G(Um)),limit:L(S(ce(),vi(),Gt(1))),cards:L(F(Fm))}),Hm=P({columns:F(Bm)}),Ym=()=>({columns:[]}),Gm=t=>{const e=ue(Hm,t),n=new Set,o=new Set,i=e.columns.flatMap(d=>(d.cards??[]).flatMap(l=>l.number===void 0?[]:[l.number])),s=i.find((d,l)=>i.indexOf(d)!==l);if(s!==void 0)throw new Error(`duplicate card number: ${s}`);let r=Math.max(0,...i);return{columns:e.columns.map(d=>{if(n.has(d.id))throw new Error(`duplicate column id: ${d.id}`);return n.add(d.id),{id:d.id,label:d.label,description:d.description??null,color:d.color??null,limit:d.limit??null,cards:(d.cards??[]).map(l=>{if(o.has(l.id))throw new Error(`duplicate card id: ${l.id}`);o.add(l.id);const c=(l.links??[]).map(p=>({url:p.url,label:p.label??null})),h=c.map(p=>p.url);if(new Set(h).size!==h.length)throw new Error(`card "${l.id}" links the same URL twice`);return{id:l.id,number:l.number??++r,title:l.title,description:l.description??null,tags:l.tags??[],assignee:l.assignee??null,links:c,...l.questions===void 0?{}:{questions:l.questions},column:d.id,change:null}})}})}},He=(t,e)=>t.columns.flatMap(n=>n.cards).find(n=>n.id===e),Ve=t=>t.columns.flatMap(e=>e.cards),Xm=(t,e)=>e===null?t:{columns:t.columns.map(n=>({...n,cards:n.cards.filter(e)}))},Km=(t,e,n,o)=>{const i=He(t,e);if(i===void 0||i.column!==n)return!1;if(o===e)return!0;const s=t.columns.find(a=>a.id===n)?.cards??[],r=s.findIndex(a=>a.id===e);return(s[r+1]?.id??null)===o},Sn=t=>`TASK-${t.number}`,jm=t=>Math.max(0,...Ve(t).map(e=>e.number))+1,ra="ADD_CARD",aa="MOVE_CARD",da="SET_CARD_TITLE",la="SET_CARD_DESCRIPTION",ca="SET_CARD_ASSIGNEE",pa="ADD_CARD_TAG",ha="REMOVE_CARD_TAG",ua="ADD_CARD_LINK",ma="REMOVE_CARD_LINK",Wm=_({id:S(x(),I(1)),title:S(x(),ye(),I(1)),number:L(sa)}),Vm=_({column:S(x(),I(1)),before:me(S(x(),I(1)))}),Yo=(t,e)=>{const n=Ne(t);return n?.length===3&&n[1]===e?n[2]??null:null},Qm=(t,e)=>({columns:t.columns.map(n=>n.cards.some(o=>o.id===e)?{...n,cards:n.cards.filter(o=>o.id!==e)}:n)}),ga=(t,e,n)=>({columns:t.columns.map(o=>{if(o.id!==n.column)return o;const i={...e,column:o.id},s=n.before===null?-1:o.cards.findIndex(r=>r.id===n.before);return{...o,cards:s<0?[...o.cards,i]:[...o.cards.slice(0,s),i,...o.cards.slice(s)]}})}),Zm=(t,e,n)=>{const o=t.addCardTitle,i=Yo(n.target.id,"column"),s=e.columns.find(l=>l.id===i);if(s===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const r=re(Wm,n.payload);if(!r.success||He(e,r.output.id)!==void 0)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const a=r.output.number??jm(e);if(Ve(e).some(l=>l.number===a))return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const d={id:r.output.id,number:a,title:r.output.title,description:null,tags:[],assignee:null,links:[],column:s.id,change:"added"};return{data:ga(e,d,{column:s.id,before:null}),result:{id:n.id,title:o,summary:t.addSummary(s.label,d.title),tone:"create"}}},Jm=(t,e,n)=>{const o=t.moveCardTitle,i=Yo(n.target.id,"card"),s=i===null?void 0:He(e,i);if(s===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const r=re(Vm,n.payload),a=e.columns.find(u=>u.id===s.column),d=r.success?e.columns.find(u=>u.id===r.output.column):void 0,l=r.success?r.output.before:null,c=l===null||l!==s.id&&d?.cards.some(u=>u.id===l)===!0;if(!r.success||a===void 0||d===void 0||!c)return{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}};const h={...s,change:s.change??"moved"},p=a.id===d.id?t.moveSummarySame(s.title,d.label):t.moveSummaryAcross(s.title,a.label,d.label);return{data:ga(Qm(e,s.id),h,{column:d.id,before:l}),result:{id:n.id,title:o,summary:p,tone:"move"}}},eg=(t,e)=>({columns:t.columns.map(n=>n.cards.some(o=>o.id===e.id)?{...n,cards:n.cards.map(o=>o.id===e.id?e:o)}:n)}),Qe=(t,e,n,o,i)=>{const s=Yo(n.target.id,"card"),r=s===null?void 0:He(e,s);if(r===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const a=i(r);return a===null?{data:e,result:{id:n.id,title:o,stale:"constraint-violated"}}:{data:eg(e,a),result:{id:n.id,title:o,summary:t.editSummary(Sn(r),r.title),tone:"update"}}},tg=_({title:S(x(),ye(),I(1))}),ng=_({description:x()}),og=_({assignee:x()}),fa=_({tag:S(x(),ye(),I(1))}),ig=_({url:Mi,label:j(S(x(),ye(),I(1)))}),sg=_({url:S(x(),I(1))}),rg=(t,e,n)=>{const o=re(tg,n.payload);return o.success?Qe(t,e,n,t.setTitleTitle,i=>({...i,title:o.output.title})):{data:e,result:{id:n.id,title:t.setTitleTitle,stale:"constraint-violated"}}},ag=(t,e,n)=>{const o=re(ng,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.setDescriptionTitle,stale:"constraint-violated"}};const i=o.output.description.trim()===""?null:o.output.description;return Qe(t,e,n,t.setDescriptionTitle,s=>({...s,description:i}))},dg=(t,e,n)=>{const o=re(og,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.setAssigneeTitle,stale:"constraint-violated"}};const i=o.output.assignee.trim()===""?null:o.output.assignee.trim();return Qe(t,e,n,t.setAssigneeTitle,s=>({...s,assignee:i}))},lg=(t,e,n)=>{const o=re(fa,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.addTagTitle,stale:"constraint-violated"}};const i=o.output.tag;return Qe(t,e,n,t.addTagTitle,s=>s.tags.includes(i)?null:{...s,tags:[...s.tags,i]})},cg=(t,e,n)=>{const o=re(fa,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.removeTagTitle,stale:"constraint-violated"}};const i=o.output.tag;return Qe(t,e,n,t.removeTagTitle,s=>s.tags.includes(i)?{...s,tags:s.tags.filter(r=>r!==i)}:null)},pg=(t,e,n)=>{const o=re(ig,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.addLinkTitle,stale:"constraint-violated"}};const i={url:o.output.url,label:o.output.label??null};return Qe(t,e,n,t.addLinkTitle,s=>s.links.some(r=>r.url===i.url)?null:{...s,links:[...s.links,i]})},hg=(t,e,n)=>{const o=re(sg,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.removeLinkTitle,stale:"constraint-violated"}};const i=o.output.url;return Qe(t,e,n,t.removeLinkTitle,s=>s.links.some(r=>r.url===i)?{...s,links:s.links.filter(r=>r.url!==i)}:null)},ug=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===ra?Zm(t,o,s):s.type===aa?Jm(t,o,s):s.type===da?rg(t,o,s):s.type===la?ag(t,o,s):s.type===ca?dg(t,o,s):s.type===pa?lg(t,o,s):s.type===ha?cg(t,o,s):s.type===ua?pg(t,o,s):s.type===ma?hg(t,o,s):{data:o,result:{id:s.id,title:s.type,stale:"unsupported-action-type"}};o=r.data,i.push(r.result)}return{data:o,results:i}},mg=de`
3934
+ /* The columns and, while a card is open, its detail beside them. */
3935
+ .kanban-stage {
3936
+ display: flex;
3937
+ align-items: flex-start;
3938
+ gap: 14px;
3939
+ min-width: 0;
3940
+ }
3941
+
3934
3942
  .kanban-board {
3943
+ flex: 1 1 auto;
3944
+ min-width: 0;
3935
3945
  display: flex;
3936
3946
  align-items: flex-start;
3937
3947
  gap: 14px;
@@ -4219,108 +4229,472 @@ ${o.renameContextHint}`}
4219
4229
  color: var(--dpk-ink-soft);
4220
4230
  font-size: 12px;
4221
4231
  }
4222
- `;class ia extends tt{boardAddable(){return!0}static{this.styles=[et,rl,Fm]}#o=null;#i=null;#e=null;#n=null;#t=null;parseData(e){return Lm(e)}emptyData(){return Cm()}reduceElementActions(e,n){return qm(ct(this.locale),e,n)}defaultHeading(){return ct(this.locale).heading}shellClass(){return"kanban"}emptyMessage(){return ct(this.locale).empty}commentItems(){const e=this.items();return[...e.columns.map(n=>({value:this.commentRef("column",n.id),label:n.label})),...je(e).map(n=>({value:this.commentRef("card",n.id),label:n.title}))]}getContextMenuItems(e){const n=super.getContextMenuItems(e),o=this.#a(e.target);if(o===void 0)return n;const i=ct(this.locale),s=Jr(o);return[{id:"kanban-card",entries:[{kind:"item",id:"copy-card-key",label:i.copyKey,run:()=>{bi(s)}},{kind:"item",id:"copy-card-key-title",label:i.copyKeyTitle,run:()=>{bi(`${s} ${o.title}`)}}]},...n??[]]}#a(e){if(e===null||e.type!=="element")return;const n=Ne(e.id);if(n===null||n.length!==3||n[1]!=="card")return;const o=n[2],i=o===void 0?void 0:Lt(this.items(),o);return i!==void 0&&this.commentRef("card",i.id)===qn(e)?i:void 0}hasSelection(e){const n=this.items();return e.kind==="column"?n.columns.some(o=>o.id===e.id):Lt(n,e.id)!==void 0}tagItems(){return je(this.items()).map(e=>e.tags)}statsText(){const e=ct(this.locale),n=je(this.items()).length,o=je(this.#s()).length;return o===n?`${n} ${e.cards}`:`${o} / ${n} ${e.cards}`}isEmpty(){return this.items().columns.length===0}refreshContent(){const e=this.authoredItems();e!==this.#o&&(this.#o=e,this.#i=null,this.#e=null)}render(){this.prepareRender();const e=this.chromeMessages,n=this.subject??this.defaultSubject();return v`
4232
+
4233
+ /* ------------------------------------------------------------ card detail */
4234
+
4235
+ /* A panel beside the columns, not over them: the board narrows instead of
4236
+ hiding what the reader was comparing. Sticky within the panel body, so it
4237
+ stays in view while a tall column scrolls. */
4238
+ .kanban-detail {
4239
+ flex: none;
4240
+ position: sticky;
4241
+ top: 0;
4242
+ display: grid;
4243
+ grid-template-rows: auto minmax(0, 1fr);
4244
+ width: min(380px, 100%);
4245
+ max-height: calc(100vh - var(--dpk-header-height, 0px) - 96px);
4246
+ border: 1px solid var(--dpk-rule-strong);
4247
+ border-radius: var(--dpk-radius-lg);
4248
+ background: var(--dpk-paper-raised);
4249
+ box-shadow: var(--dpk-shadow-lg);
4250
+ overflow: hidden;
4251
+ }
4252
+ .kanban-detail:focus {
4253
+ outline: none;
4254
+ }
4255
+ .kanban-detail-head {
4256
+ display: flex;
4257
+ align-items: center;
4258
+ gap: 8px;
4259
+ padding: 10px 10px 10px 14px;
4260
+ border-bottom: 1px solid var(--dpk-rule);
4261
+ /* The close button keeps clear of a floating menu docked at the right edge. */
4262
+ padding-inline-end: calc(10px + var(--dpk-floating-menu-clearance, 0px));
4263
+ }
4264
+ .kanban-detail-key {
4265
+ color: var(--dpk-ink-faint);
4266
+ font-family: var(--dpk-mono);
4267
+ font-size: 11px;
4268
+ font-weight: 650;
4269
+ font-variant-numeric: tabular-nums;
4270
+ }
4271
+ .kanban-detail-column {
4272
+ padding: 1px 8px;
4273
+ border-radius: 999px;
4274
+ background: color-mix(in srgb, var(--kanban-tone, var(--dpk-ink-faint)) 12%, var(--dpk-paper-sunken));
4275
+ color: var(--kanban-tone, var(--dpk-ink-soft));
4276
+ font-size: 11px;
4277
+ font-weight: 650;
4278
+ }
4279
+ .kanban-detail-close {
4280
+ margin-left: auto;
4281
+ }
4282
+ .kanban-detail-body {
4283
+ display: grid;
4284
+ align-content: start;
4285
+ gap: 18px;
4286
+ min-height: 0;
4287
+ padding: 14px 16px 20px;
4288
+ overflow: auto;
4289
+ }
4290
+ .kanban-detail-title {
4291
+ margin: 0;
4292
+ font-size: 17px;
4293
+ font-weight: 700;
4294
+ line-height: 1.35;
4295
+ letter-spacing: -0.01em;
4296
+ }
4297
+ .kanban-detail-title dpk-inline-edit,
4298
+ .kanban-detail-field > dpk-inline-edit {
4299
+ display: block;
4300
+ margin: 0 -4px;
4301
+ }
4302
+ .kanban-detail-field {
4303
+ display: grid;
4304
+ gap: 7px;
4305
+ min-width: 0;
4306
+ }
4307
+ .kanban-statuses {
4308
+ display: flex;
4309
+ flex-wrap: wrap;
4310
+ gap: 6px;
4311
+ }
4312
+ .kanban-status {
4313
+ padding: 4px 11px;
4314
+ border: 1px solid var(--dpk-rule-strong);
4315
+ border-radius: 999px;
4316
+ background: var(--dpk-paper-raised);
4317
+ color: var(--dpk-ink-soft);
4318
+ font: inherit;
4319
+ font-size: 12px;
4320
+ font-weight: 600;
4321
+ cursor: pointer;
4322
+ }
4323
+ .kanban-status[aria-pressed='true'] {
4324
+ border-color: color-mix(in srgb, var(--dpk-blue) 55%, transparent);
4325
+ background: var(--dpk-blue-soft);
4326
+ color: var(--dpk-blue);
4327
+ }
4328
+ .kanban-status:focus-visible {
4329
+ outline: none;
4330
+ box-shadow: var(--dpk-focus);
4331
+ }
4332
+ .kanban-tag-row {
4333
+ display: flex;
4334
+ flex-wrap: wrap;
4335
+ align-items: center;
4336
+ gap: 6px;
4337
+ }
4338
+ .kanban-tag {
4339
+ gap: 2px;
4340
+ padding-right: 2px;
4341
+ }
4342
+ .kanban-tag-remove {
4343
+ display: inline-flex;
4344
+ align-items: center;
4345
+ justify-content: center;
4346
+ width: 18px;
4347
+ height: 18px;
4348
+ border: 0;
4349
+ border-radius: 999px;
4350
+ background: none;
4351
+ color: inherit;
4352
+ cursor: pointer;
4353
+ opacity: 0.7;
4354
+ }
4355
+ .kanban-tag-remove:hover,
4356
+ .kanban-tag-remove:focus-visible {
4357
+ background: color-mix(in srgb, var(--dpk-ink) 8%, transparent);
4358
+ opacity: 1;
4359
+ outline: none;
4360
+ }
4361
+ .kanban-tag-remove svg {
4362
+ width: 11px;
4363
+ height: 11px;
4364
+ }
4365
+ .kanban-tag-add {
4366
+ flex: 1 1 110px;
4367
+ min-width: 90px;
4368
+ font-size: 12px;
4369
+ }
4370
+ .kanban-link-list {
4371
+ display: grid;
4372
+ gap: 4px;
4373
+ margin: 0;
4374
+ padding: 0;
4375
+ list-style: none;
4376
+ }
4377
+ .kanban-link-list li {
4378
+ display: flex;
4379
+ align-items: center;
4380
+ gap: 4px;
4381
+ min-width: 0;
4382
+ border: 1px solid var(--dpk-rule);
4383
+ border-radius: var(--dpk-radius-sm);
4384
+ background: var(--dpk-paper-sunken);
4385
+ }
4386
+ .kanban-link {
4387
+ display: flex;
4388
+ flex: 1 1 auto;
4389
+ align-items: center;
4390
+ gap: 6px;
4391
+ min-width: 0;
4392
+ padding: 6px 8px;
4393
+ color: var(--dpk-ink-soft);
4394
+ font-family: var(--dpk-mono);
4395
+ font-size: 11.5px;
4396
+ font-weight: 600;
4397
+ text-decoration: none;
4398
+ }
4399
+ .kanban-link span {
4400
+ overflow: hidden;
4401
+ text-overflow: ellipsis;
4402
+ white-space: nowrap;
4403
+ }
4404
+ .kanban-link:hover span {
4405
+ text-decoration: underline;
4406
+ }
4407
+ .kanban-link svg {
4408
+ flex: none;
4409
+ width: 12px;
4410
+ height: 12px;
4411
+ }
4412
+ .kanban-link-remove {
4413
+ flex: none;
4414
+ width: 24px;
4415
+ height: 24px;
4416
+ margin-right: 4px;
4417
+ }
4418
+ .kanban-link-add {
4419
+ display: flex;
4420
+ flex-wrap: wrap;
4421
+ gap: 6px;
4422
+ }
4423
+ .kanban-link-add [data-role='link-url'] {
4424
+ flex: 1 1 100%;
4425
+ font-size: 12px;
4426
+ }
4427
+ .kanban-link-add [data-role='link-label'] {
4428
+ flex: 1 1 120px;
4429
+ font-size: 12px;
4430
+ }
4431
+ .kanban-link-add .dpk-btn {
4432
+ flex: none;
4433
+ }
4434
+ .kanban-card-links .link-chip {
4435
+ max-width: 100%;
4436
+ }
4437
+ .kanban-card-links .link-chip span {
4438
+ overflow: hidden;
4439
+ text-overflow: ellipsis;
4440
+ white-space: nowrap;
4441
+ }
4442
+
4443
+ /* A narrow screen stacks the panel under the board instead of squeezing both. */
4444
+ @media (max-width: 860px) {
4445
+ .kanban-stage {
4446
+ flex-direction: column;
4447
+ }
4448
+ .kanban-detail {
4449
+ position: static;
4450
+ width: 100%;
4451
+ max-height: none;
4452
+ }
4453
+ }
4454
+ `,gg=3;class ba extends st{boardAddable(){return!0}static{this.styles=[it,yl,kl,mg]}#o=null;#i=null;#e=null;#t=null;#n=!1;#a=!1;#r=null;#s=null;parseData(e){return Gm(e)}emptyData(){return Ym()}reduceElementActions(e,n){return ug(We(this.locale),e,n)}defaultHeading(){return We(this.locale).heading}shellClass(){return"kanban"}emptyMessage(){return We(this.locale).empty}commentItems(){const e=this.items();return[...e.columns.map(n=>({value:this.commentRef("column",n.id),label:n.label})),...Ve(e).map(n=>({value:this.commentRef("card",n.id),label:n.title}))]}getContextMenuItems(e){const n=super.getContextMenuItems(e),o=this.#d(e.target);if(o===void 0)return n;const i=We(this.locale),s=Sn(o);return[{id:"kanban-card",entries:[{kind:"item",id:"copy-card-key",label:i.copyKey,run:()=>{wi(s)}},{kind:"item",id:"copy-card-key-title",label:i.copyKeyTitle,run:()=>{wi(`${s} ${o.title}`)}}]},...n??[]]}#d(e){if(e===null||e.type!=="element")return;const n=Ne(e.id);if(n===null||n.length!==3||n[1]!=="card")return;const o=n[2],i=o===void 0?void 0:He(this.items(),o);return i!==void 0&&this.commentRef("card",i.id)===Bn(e)?i:void 0}hasSelection(e){const n=this.items();return e.kind==="column"?n.columns.some(o=>o.id===e.id):He(n,e.id)!==void 0}tagItems(){return Ve(this.items()).map(e=>e.tags)}statsText(){const e=We(this.locale),n=Ve(this.items()).length,o=Ve(this.#h()).length;return o===n?`${n} ${e.cards}`:`${o} / ${n} ${e.cards}`}isEmpty(){return this.items().columns.length===0}refreshContent(){const e=this.authoredItems();e!==this.#o&&(this.#o=e,this.#i=null,this.#e=null),this.#t!==null&&He(this.items(),this.#t)===void 0&&(this.#t=null,this.#n=!1)}render(){this.prepareRender();const e=this.chromeMessages,n=this.subject??this.defaultSubject();return k`
4223
4455
  <dpk-dialog-panel
4224
4456
  class=${this.shellClass()}
4225
4457
  ?maximizable=${this.frameControls}
4226
4458
  ?resizable=${this.frameControls}
4227
4459
  heading=${this.heading??this.defaultHeading()}
4228
- subject=${n===""?M:n}
4460
+ subject=${n===""?T:n}
4229
4461
  @dpk-maximize-change=${()=>this.closeComposer()}
4230
4462
  >
4231
4463
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
4232
- ${this.dataError!==null?v`<p class="kanban-notice" role="alert">${e.dataError}<br />${this.dataError}</p>`:this.isEmpty()?v`<p class="kanban-empty">${this.emptyMessage()}</p>`:this.#r()}
4464
+ ${this.dataError!==null?k`<p class="kanban-notice" role="alert">${e.dataError}<br />${this.dataError}</p>`:this.isEmpty()?k`<p class="kanban-empty">${this.emptyMessage()}</p>`:this.#c()}
4233
4465
  </dpk-dialog-panel>
4234
4466
  ${this.renderSelection()}
4235
- `}#r(){const e=this.#s(),n=new Map(this.items().columns.map(o=>[o.id,o.cards.length]));return v`<div class="kanban-board">
4236
- ${Te(e.columns,o=>o.id,o=>this.#c(o,n.get(o.id)??0))}
4237
- </div>`}#s(){const e=this.tagFilter;return _m(this.items(),e.active.length===0?null:n=>Ce(n.tags,e))}#d(e,n){const o=this.selection;return o!==null&&o.kind===e&&o.id===n}#c(e,n){const o=ct(this.locale),i=e.limit!==null&&n>e.limit,s=this.#t?.column===e.id?this.#t:null;return v`
4467
+ `}#c(){const e=this.#h(),n=new Map(this.items().columns.map(s=>[s.id,s.cards.length])),o=this.#t===null?void 0:He(this.items(),this.#t),i=o===void 0?void 0:this.items().columns.find(s=>s.id===o.column);return k`<div class="kanban-stage">
4468
+ <div class="kanban-board">
4469
+ ${Me(e.columns,s=>s.id,s=>this.#u(s,n.get(s.id)??0))}
4470
+ </div>
4471
+ ${o===void 0?T:this.#b(o,i,We(this.locale))}
4472
+ </div>`}#h(){const e=this.tagFilter;return Xm(this.items(),e.active.length===0?null:n=>Ae(n.tags,e))}#p(e,n){const o=this.selection;return o!==null&&o.kind===e&&o.id===n}#u(e,n){const o=We(this.locale),i=e.limit!==null&&n>e.limit,s=this.#s?.column===e.id?this.#s:null;return k`
4238
4473
  <section
4239
- class=${ye("kanban-column",i&&"is-over",this.#d("column",e.id)&&"is-selected",s!==null&&"is-drop-target")}
4474
+ class=${ve("kanban-column",i&&"is-over",this.#p("column",e.id)&&"is-selected",s!==null&&"is-drop-target")}
4240
4475
  data-column=${e.id}
4241
- data-color=${e.color??M}
4476
+ data-color=${e.color??T}
4242
4477
  aria-label=${e.label}
4243
4478
  >
4244
4479
  <div class="kanban-column-head">
4245
4480
  <button
4246
4481
  type="button"
4247
4482
  class="kanban-column-title"
4248
- aria-pressed=${this.#d("column",e.id)?"true":"false"}
4483
+ aria-pressed=${this.#p("column",e.id)?"true":"false"}
4249
4484
  data-dpk-target=${this.commentRef("column",e.id)}
4250
4485
  title=${e.description??e.label}
4251
4486
  @click=${()=>this.select({kind:"column",id:e.id})}
4252
4487
  >
4253
4488
  <span class="kanban-column-label">${e.label}</span>
4254
- <span class="kanban-count" title=${e.limit===null?M:o.wipLimit(e.limit)}>
4489
+ <span class="kanban-count" title=${e.limit===null?T:o.wipLimit(e.limit)}>
4255
4490
  ${e.limit===null?n:`${n} / ${e.limit}`}
4256
4491
  </span>
4257
4492
  </button>
4258
4493
  </div>
4259
- ${e.description===null?M:v`<p class="kanban-column-description">${e.description}</p>`}
4494
+ ${e.description===null?T:k`<p class="kanban-column-description">${e.description}</p>`}
4260
4495
  <div
4261
4496
  class="kanban-cards"
4262
- @dragover=${r=>this.#f(r,e.id)}
4263
- @dragleave=${r=>this.#y(r)}
4264
- @drop=${r=>this.#C(r,e.id)}
4497
+ @dragover=${r=>this.#$(r,e.id)}
4498
+ @dragleave=${r=>this.#F(r)}
4499
+ @drop=${r=>this.#S(r,e.id)}
4265
4500
  >
4266
- ${Te(e.cards,r=>r.id,r=>v`${s?.before===r.id?this.#p():M}${this.#u(r,o)}`)}
4267
- ${s!==null&&s.before===null?this.#p():M}
4501
+ ${Me(e.cards,r=>r.id,r=>k`${s?.before===r.id?this.#l():T}${this.#m(r,o)}`)}
4502
+ ${s!==null&&s.before===null?this.#l():T}
4268
4503
  </div>
4269
- ${this.#h(e,o)}
4504
+ ${this.#v(e,o)}
4270
4505
  </section>
4271
- `}#p(){return v`<div class="kanban-drop-marker" aria-hidden="true"></div>`}#u(e,n){const o=this.#d("card",e.id);return v`
4506
+ `}#l(){return k`<div class="kanban-drop-marker" aria-hidden="true"></div>`}#m(e,n){const o=this.#p("card",e.id);return k`
4272
4507
  <div class="kanban-card-slot">
4273
4508
  <div
4274
4509
  role="button"
4275
4510
  tabindex="0"
4276
4511
  draggable="true"
4277
- class=${ye("dpk-card","kanban-card",e.change==="added"&&"is-added",e.change==="moved"&&"is-moved")}
4278
- data-state=${this.#n===e.id?"dragging":M}
4512
+ class=${ve("dpk-card","kanban-card",e.change==="added"&&"is-added",e.change==="moved"&&"is-moved")}
4513
+ data-state=${this.#r===e.id?"dragging":T}
4279
4514
  data-card=${e.id}
4280
4515
  data-grill-questions=${this.questionsOf(e)}
4281
4516
  data-dpk-target=${this.commentRef("card",e.id)}
4282
4517
  title=${e.description??e.title}
4283
4518
  aria-pressed=${o?"true":"false"}
4284
- @click=${()=>this.select({kind:"card",id:e.id})}
4285
- @keydown=${i=>this.#l(i,e.id)}
4286
- @dragstart=${i=>this.#g(i,e.id)}
4287
- @dragend=${()=>this.#k()}
4519
+ @click=${()=>this.#f(e.id)}
4520
+ @keydown=${i=>this.#T(i,e.id)}
4521
+ @dragstart=${i=>this.#C(i,e.id)}
4522
+ @dragend=${()=>this.#M()}
4288
4523
  >
4289
4524
  <div class="dpk-card-head">
4290
4525
  <div class="dpk-card-title">${e.title}</div>
4291
- <span class="dpk-card-key">${Jr(e)}</span>
4526
+ <span class="dpk-card-key">${Sn(e)}</span>
4292
4527
  </div>
4293
- ${e.description===null?M:v`<div class="dpk-card-text">${e.description}</div>`}
4294
- ${e.tags.length===0&&e.assignee===null?M:v`<div class="dpk-card-row kanban-card-meta">
4295
- ${e.tags.map(i=>v`<span class="dpk-pill">${i}</span>`)}
4296
- ${e.assignee===null?M:v`<span class="kanban-assignee"
4528
+ ${e.description===null?T:k`<div class="dpk-card-text">${e.description}</div>`}
4529
+ ${e.tags.length===0&&e.assignee===null?T:k`<div class="dpk-card-row kanban-card-meta">
4530
+ ${e.tags.map(i=>k`<span class="dpk-pill">${i}</span>`)}
4531
+ ${e.assignee===null?T:k`<span class="kanban-assignee"
4297
4532
  ><span class="dpk-avatar" aria-hidden="true">${Array.from(e.assignee)[0]??""}</span
4298
4533
  >${e.assignee}</span
4299
4534
  >`}
4300
4535
  </div>`}
4536
+ ${e.links.length===0?T:this.#g(e)}
4301
4537
  </div>
4302
- ${this.#e===e.id?v`<p class="kanban-error" role="alert">${n.notRecorded}</p>`:M}
4538
+ ${this.#e===e.id?k`<p class="kanban-error" role="alert">${n.notRecorded}</p>`:T}
4539
+ </div>
4540
+ `}#g(e){const n=e.links.slice(0,gg);return k`<div class="dpk-card-row kanban-card-links">
4541
+ ${n.map(o=>{const i=Vn(o.url);return k`<a
4542
+ class="link-chip"
4543
+ data-kind=${i.kind}
4544
+ href=${o.url}
4545
+ target="_blank"
4546
+ rel="noopener noreferrer"
4547
+ title=${o.label??i.title}
4548
+ draggable="false"
4549
+ tabindex="-1"
4550
+ @click=${s=>s.stopPropagation()}
4551
+ >${Ci(i.kind)}<span>${o.label??i.text}</span></a
4552
+ >`})}
4553
+ ${e.links.length>n.length?k`<span class="link-chip">+${e.links.length-n.length}</span>`:T}
4554
+ </div>`}#f(e){this.select({kind:"card",id:e}),this.#t!==e&&(this.#t=e,this.#n=!1,this.#a=!0,this.requestUpdate())}#x(){const e=this.#t;e!==null&&(this.#t=null,this.#n=!1,this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-card="${CSS.escape(e)}"]`)?.focus({preventScroll:!0})))}#A(e,n,o){const i=this.dispatchElementAction(e,["card",n],o);this.#n=!i,this.requestUpdate()}#E(e){e.key==="Escape"&&(e.composedPath().some(n=>n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)||(e.preventDefault(),this.#x()))}#k(e,n){if(e.key!=="Enter"||e.isComposing)return;e.preventDefault();const o=e.currentTarget;if(!(o instanceof HTMLInputElement))return;const i=o.value.trim();if(i==="")return;const s=this.dispatchElementAction(pa,["card",n],{tag:i});this.#n=!s,s&&(o.value=""),this.requestUpdate()}#I(e,n){e.preventDefault();const o=e.currentTarget;if(!(o instanceof HTMLFormElement))return;const i=o.querySelector('[data-role="link-url"]')?.value.trim()??"",s=o.querySelector('[data-role="link-label"]')?.value.trim()??"";if(i==="")return;const r=this.dispatchElementAction(ua,["card",n],s===""?{url:i}:{url:i,label:s});this.#n=!r,r&&o.reset(),this.requestUpdate()}#b(e,n,o){const i=(s,r)=>this.#A(s,e.id,r);return k`<aside
4555
+ class="kanban-detail"
4556
+ role="dialog"
4557
+ aria-label=${o.cardDetailAria(e.title)}
4558
+ data-card=${e.id}
4559
+ tabindex="-1"
4560
+ @keydown=${s=>this.#E(s)}
4561
+ >
4562
+ <header class="kanban-detail-head">
4563
+ <span class="kanban-detail-key">${Sn(e)}</span>
4564
+ ${n===void 0?T:k`<span class="kanban-detail-column" data-color=${n.color??T}>${n.label}</span>`}
4565
+ <button
4566
+ class="dpk-icon-btn kanban-detail-close"
4567
+ type="button"
4568
+ aria-label=${o.closeCardDetail}
4569
+ @click=${()=>this.#x()}
4570
+ >
4571
+ ${jn()}
4572
+ </button>
4573
+ </header>
4574
+ <div class="kanban-detail-body">
4575
+ <h3 class="kanban-detail-title">
4576
+ <dpk-inline-edit
4577
+ wrap
4578
+ .value=${e.title}
4579
+ .label=${o.cardTitleLabel}
4580
+ @dpk-commit=${nt(s=>i(da,{title:s}))}
4581
+ ></dpk-inline-edit>
4582
+ </h3>
4583
+ <section class="kanban-detail-field">
4584
+ <span class="dpk-label">${o.cardStatusLabel}</span>
4585
+ <div class="kanban-statuses">
4586
+ ${this.items().columns.map(s=>k`<button
4587
+ class="kanban-status"
4588
+ type="button"
4589
+ aria-pressed=${String(s.id===e.column)}
4590
+ @click=${()=>this.#w(e.id,{column:s.id,before:null})}
4591
+ >
4592
+ ${s.label}
4593
+ </button>`)}
4594
+ </div>
4595
+ </section>
4596
+ <section class="kanban-detail-field">
4597
+ <span class="dpk-label">${o.cardAssigneeLabel}</span>
4598
+ <dpk-inline-edit
4599
+ .value=${e.assignee??""}
4600
+ .label=${o.cardAssigneeLabel}
4601
+ .placeholder=${o.cardAssigneePlaceholder}
4602
+ @dpk-commit=${nt(s=>i(ca,{assignee:s}))}
4603
+ ></dpk-inline-edit>
4604
+ </section>
4605
+ <section class="kanban-detail-field">
4606
+ <span class="dpk-label">${o.cardTagsLabel}</span>
4607
+ <div class="kanban-tag-row">
4608
+ ${e.tags.map(s=>k`<span class="dpk-pill kanban-tag"
4609
+ >${s}<button
4610
+ type="button"
4611
+ class="kanban-tag-remove"
4612
+ aria-label=${o.removeTagAria(s)}
4613
+ @click=${()=>i(ha,{tag:s})}
4614
+ >
4615
+ ${jn()}
4616
+ </button></span
4617
+ >`)}
4618
+ <input
4619
+ class="dpk-input kanban-tag-add"
4620
+ aria-label=${o.cardTagsPlaceholder}
4621
+ placeholder=${o.cardTagsPlaceholder}
4622
+ @keydown=${s=>this.#k(s,e.id)}
4623
+ />
4624
+ </div>
4625
+ </section>
4626
+ <section class="kanban-detail-field">
4627
+ <span class="dpk-label">${o.cardDescriptionLabel}</span>
4628
+ <dpk-inline-edit
4629
+ multiline
4630
+ markdown
4631
+ .value=${e.description??""}
4632
+ .label=${o.cardDescriptionLabel}
4633
+ .placeholder=${o.cardDescriptionPlaceholder}
4634
+ @dpk-commit=${nt(s=>i(la,{description:s}))}
4635
+ ></dpk-inline-edit>
4636
+ </section>
4637
+ <section class="kanban-detail-field">
4638
+ <span class="dpk-label">${o.cardLinksLabel}</span>
4639
+ ${e.links.length===0?T:k`<ul class="kanban-link-list">
4640
+ ${e.links.map(s=>k`<li>
4641
+ <a class="kanban-link" href=${s.url} target="_blank" rel="noopener noreferrer"
4642
+ >${Ci(Vn(s.url).kind)}<span
4643
+ >${s.label??Vn(s.url).text}</span
4644
+ ></a
4645
+ >
4646
+ <button
4647
+ type="button"
4648
+ class="dpk-icon-btn kanban-link-remove"
4649
+ aria-label=${o.removeLinkAria(s.url)}
4650
+ @click=${()=>i(ma,{url:s.url})}
4651
+ >
4652
+ ${jn()}
4653
+ </button>
4654
+ </li>`)}
4655
+ </ul>`}
4656
+ <form class="kanban-link-add" @submit=${s=>this.#I(s,e.id)}>
4657
+ <input
4658
+ class="dpk-input"
4659
+ data-role="link-url"
4660
+ type="url"
4661
+ inputmode="url"
4662
+ autocomplete="off"
4663
+ aria-label=${o.cardLinkUrlPlaceholder}
4664
+ placeholder=${o.cardLinkUrlPlaceholder}
4665
+ />
4666
+ <input
4667
+ class="dpk-input"
4668
+ data-role="link-label"
4669
+ autocomplete="off"
4670
+ aria-label=${o.cardLinkLabelPlaceholder}
4671
+ placeholder=${o.cardLinkLabelPlaceholder}
4672
+ />
4673
+ <button class="dpk-btn" type="submit">${o.addLinkButton}</button>
4674
+ </form>
4675
+ </section>
4676
+ ${this.#n?k`<p class="kanban-error" role="alert">${o.notRecorded}</p>`:T}
4303
4677
  </div>
4304
- `}#h(e,n){const o=this.#i?.column===e.id?this.#i:null;return v`<div class="kanban-add">
4305
- ${o===null?v`<button
4678
+ </aside>`}updated(){super.updated(),this.#a&&(this.#a=!1,this.renderRoot.querySelector(".kanban-detail")?.focus({preventScroll:!0}))}#v(e,n){const o=this.#i?.column===e.id?this.#i:null;return k`<div class="kanban-add">
4679
+ ${o===null?k`<button
4306
4680
  type="button"
4307
4681
  class="kanban-add-button"
4308
4682
  data-action="add"
4309
- @click=${()=>this.#M(e.id)}
4683
+ @click=${()=>this.#N(e.id)}
4310
4684
  >
4311
4685
  ${n.addCardButton}
4312
- </button>`:v`
4686
+ </button>`:k`
4313
4687
  <input
4314
4688
  class="dpk-input"
4315
4689
  aria-label="${n.addCardAriaLabel(e.label)}"
4316
4690
  placeholder="${n.addCardPlaceholder}"
4317
4691
  .value=${o.title}
4318
4692
  @input=${i=>{const s=i.currentTarget;s instanceof HTMLInputElement&&(this.#i={...o,title:s.value,failed:!1})}}
4319
- @keydown=${i=>this.#b(i,e.id)}
4693
+ @keydown=${i=>this.#z(i,e.id)}
4320
4694
  />
4321
- ${o.failed?v`<span class="kanban-error" role="alert">${n.notRecorded}</span>`:M}
4695
+ ${o.failed?k`<span class="kanban-error" role="alert">${n.notRecorded}</span>`:T}
4322
4696
  `}
4323
- </div>`}#l(e,n){e.target!==e.currentTarget||e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.select({kind:"card",id:n}))}#m(e,n){const o=this.dispatchElementAction(ta,["card",e],{column:n.column,before:n.before});this.#e=o?null:e,this.select({kind:"card",id:e}),this.requestUpdate()}#g(e,n){this.#n=n,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",n)),this.requestUpdate()}#f(e,n){if(this.#n===null)return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move");const o=this.#v(e,n);this.#t?.column===o.column&&this.#t.before===o.before||(this.#t=o,this.requestUpdate())}#y(e){const n=e.currentTarget;!(n instanceof HTMLElement)||e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||(this.#t=null,this.requestUpdate())}#C(e,n){const o=this.#n;if(o===null)return;e.preventDefault();const i=this.#v(e,n);this.#k(),Rm(this.items(),o,i.column,i.before)||this.#m(o,i)}#k(){this.#n===null&&this.#t===null||(this.#n=null,this.#t=null,this.requestUpdate())}#v(e,n){const o=e.currentTarget,s=(o instanceof HTMLElement?[...o.querySelectorAll("[data-card]")]:[]).find(r=>{if(r.dataset.card===this.#n)return!1;const a=r.getBoundingClientRect();return a.top+a.height/2>e.clientY});return{column:n,before:s?.dataset.card??null}}#M(e){this.#i={column:e,title:"",failed:!1},this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-column="${CSS.escape(e)}"] .kanban-add input`)?.focus({preventScroll:!0}))}#b(e,n){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),this.#i=null,this.requestUpdate();return}if(e.key!=="Enter")return;e.preventDefault();const o=this.#i?.title.trim()??"";if(o.length===0)return;if(!this.id){const r=[...document.querySelectorAll("[id]")].map(a=>a.id);this.id=xe("kanban",r)}const i=[...this.items().columns.map(r=>r.id),...je(this.items()).map(r=>r.id)],s=xe(`card ${o}`,i);if(!this.dispatchElementAction(ea,["column",n],{id:s,title:o})){this.#i={column:n,title:o,failed:!0},this.requestUpdate();return}this.#i=null,this.select({kind:"card",id:s}),this.requestUpdate()}}const sa=()=>{customElements.get("dpk-board-kanban")||customElements.define("dpk-board-kanban",ia)},ra=[72,52,40],aa=[0,22,10,8],Bm=t=>ra[Math.min(t,ra.length-1)]??40,da=t=>aa[Math.min(t,aa.length-1)]??8,Um=(t,e={})=>{const n=e.padding??40,o=t.nodes.find(S=>S.parent===null);if(o===void 0)return{width:0,height:0,nodes:[],routes:[]};const i=new Map(t.nodes.map(S=>[S.id,S])),s=S=>S.children.flatMap(T=>{const E=i.get(T);return E===void 0?[]:[E]}),r=new Map,a=S=>S.reduce((T,E,R)=>T+d(E)+(R===0?0:da(E.depth)),0),d=S=>{const T=r.get(S.id);if(T!==void 0)return T;const E=Math.max(S.height,a(s(S)));return r.set(S.id,E),E},l=[],c=(S,T,E)=>{if(T.length===0)return;const R=Bm(S.node.depth);let A=S.y+S.node.height/2-a(T)/2;for(const N of T){const U=d(N),q={x:E==="right"?S.x+S.node.width+R:S.x-R-N.width,y:A+U/2-N.height/2,node:N};l.push(q),c(q,s(N),E),A+=U+da(N.depth)}},h={x:-o.width/2,y:-o.height/2,node:o};l.push(h);const p=s(o);c(h,p.filter(S=>S.side!=="left"),"right"),c(h,p.filter(S=>S.side==="left"),"left");const u=Math.min(...l.map(S=>S.x)),g=Math.min(...l.map(S=>S.y)),b=Math.max(...l.map(S=>S.x+S.node.width)),f=Math.max(...l.map(S=>S.y+S.node.height)),m=n-u,x=n-g,k=new Map,w=l.map(S=>{const T=k.get(S.node.depth)??0;return k.set(S.node.depth,T+1),{id:S.node.id,x:S.x+m,y:S.y+x,width:S.node.width,height:S.node.height,layer:S.node.depth,order:T}}),$=new Map(w.map(S=>[S.id,S])),L=t.edges.flatMap(S=>{const T=$.get(S.from),E=$.get(S.to),R=i.get(S.to);if(T===void 0||E===void 0||R===void 0)return[];const A=R.side==="left",N={x:A?T.x:T.x+T.width,y:T.y+T.height/2},U={x:A?E.x+E.width:E.x,y:E.y+E.height/2};return[{id:S.id,points:[N,U]}]});return{width:b-u+n*2,height:f-g+n*2,nodes:w,routes:L}},Hm=t=>{const e=t[0],n=t.at(-1);if(e===void 0||n===void 0)return"";const o=(n.x-e.x)/2;return`M${e.x} ${e.y} C${e.x+o} ${e.y} ${n.x-o} ${n.y} ${n.x} ${n.y}`},_t=ce({en:{heading:"Mind map",empty:"No matching topics.",topics:"Topic",toggleOpen:(t,e)=>`Open ${e} subtopics of ${t}`,toggleClose:t=>`Collapse subtopics of ${t}`,addSubtopicButton:"+ Subtopic",addSubtopicAriaLabel:t=>`Subtopic of ${t}`,addSubtopicPlaceholder:"Subtopic title (Enter to add)",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",addTopicTitle:"Add topic",addSummary:(t,e)=>`${t} \u203A ${e}`},ja:{heading:"\u30DE\u30A4\u30F3\u30C9\u30DE\u30C3\u30D7",empty:"\u8A72\u5F53\u3059\u308B\u30C8\u30D4\u30C3\u30AF\u306F\u3042\u308A\u307E\u305B\u3093\u3002",topics:"\u30C8\u30D4\u30C3\u30AF",toggleOpen:(t,e)=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF ${e} \u4EF6\u3092\u3072\u3089\u304F`,toggleClose:t=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF\u3092\u305F\u305F\u3080`,addSubtopicButton:"\uFF0B \u30B5\u30D6\u30C8\u30D4\u30C3\u30AF",addSubtopicAriaLabel:t=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF`,addSubtopicPlaceholder:"\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF\u540D\uFF08Enter \u3067\u8FFD\u52A0\uFF09",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",addTopicTitle:"\u30C8\u30D4\u30C3\u30AF\u3092\u8FFD\u52A0",addSummary:(t,e)=>`${t} \u203A ${e}`}}),la=Ud(()=>P({id:I(y(),_(1)),label:I(y(),_(1)),description:C(y()),tags:C(F(y())),questions:C(y()),collapsed:C(ft()),side:C(X(["left","right"])),children:C(F(la))})),Ym=P({root:la}),ca=()=>({root:null,nodes:[],edges:[]}),pa=[{fontSize:16,padding:22,height:48,min:120,max:280},{fontSize:13.5,padding:15,height:34,min:80,max:240},{fontSize:12.5,padding:12,height:28,min:56,max:220}],Xm=t=>pa[Math.min(t,pa.length-1)]??{fontSize:12.5,padding:12,height:28,min:56,max:220},Gm=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},Km=(t,e)=>{const n=Xm(e),o=Math.ceil(Gm(t,n.fontSize)+n.padding*2+4);return{width:Math.min(n.max,Math.max(n.min,o)),height:n.height}},jm=t=>({left:{x:0,y:t.height/2},right:{x:t.width,y:t.height/2}}),Wm=t=>t==="left"?{fromPort:"left",toPort:"right"}:{fromPort:"right",toPort:"left"},Fo=t=>t.children===void 0||t.children.length===0?1:t.children.reduce((e,n)=>e+Fo(n),0),ha=t=>{const e={left:0,right:0};for(const n of t)n.side!==void 0&&(e[n.side]+=Fo(n));return t.map(n=>{if(n.side!==void 0)return n.side;const o=e.right<=e.left?"right":"left";return e[o]+=Fo(n),o})},Vm=t=>ua(he(Ym,t).root),ua=(t,e=new Set)=>{const n=[],o=[],i=new Set,s=(r,a,d,l,c)=>{if(i.has(r.id))throw new Error(`duplicate topic id: ${r.id}`);if(i.add(r.id),r.side!==void 0&&d!==1)throw new Error(`side is only allowed on a main topic (a child of the root): ${r.id}`);const h=r.children??[],p=Km(r.label,d);n.push({id:r.id,label:r.label,description:r.description??null,parent:a,depth:d,branch:l,side:c,children:h.map(g=>g.id),collapsed:r.collapsed??!1,added:e.has(r.id),tags:r.tags??[],...p,ports:jm(p),...r.questions===void 0?{}:{questions:r.questions}}),a!==null&&c!==null&&o.push({id:r.id,from:a,to:r.id,tags:[],...Wm(c)});const u=d===0?ha(h):[];h.forEach((g,b)=>s(g,r.id,d+1,d===0?b:l,d===0?u[b]??"right":c))};return s(t,null,0,-1,null),{root:t,nodes:n,edges:o}},ma="ADD_TOPIC",Qm=O({id:I(y(),_(1)),label:I(y(),Ge(),_(1))}),Zm=t=>{const e=Ne(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},ga=(t,e,n)=>t.id===e?{...t,children:[...t.children??[],n]}:t.children===void 0?t:{...t,children:t.children.map(o=>ga(o,e,n))},Jm=t=>{if(t.children===void 0)return t;const e=ha(t.children);return{...t,children:t.children.map((n,o)=>({...n,side:e[o]??"right"}))}},eg=(t,e,n)=>{const o=t.addTopicTitle,i=new Map(e.nodes.map(d=>[d.id,d.label])),s=new Set,r=[];let a=e.root===null?null:Jm(e.root);for(const d of n){if(d.type!==ma){r.push({id:d.id,title:d.type,stale:"unsupported-action-type"});continue}const l=Zm(d.target.id),c=l===null?void 0:i.get(l),h=Oe(Qm,d.payload);if(a===null||l===null||c===void 0){r.push({id:d.id,title:o,stale:"target-missing"});continue}if(!h.success||i.has(h.output.id)){r.push({id:d.id,title:o,stale:"constraint-violated"});continue}const{id:p,label:u}=h.output;a=ga(a,l,{id:p,label:u}),i.set(p,u),s.add(p),r.push({id:d.id,title:o,summary:t.addSummary(c,u),tone:"create"})}return{data:a===null||s.size===0?e:ua(a,s),results:r}},Bo=(t,e)=>{const n=new Map(t.nodes.map(s=>[s.id,s])),o=[];let i=n.get(e)?.parent??null;for(;i!==null&&!o.includes(i);)o.push(i),i=n.get(i)?.parent??null;return o},tg=(t,e)=>{const n=new Map(t.nodes.map(s=>[s.id,s]));let o=0;const i=[...n.get(e)?.children??[]];for(let s=i.pop();s!==void 0;s=i.pop())o+=1,i.push(...n.get(s)?.children??[]);return o},ng=(t,e,n)=>{let o=null;if(e!==null){const r=t.nodes.filter(e);if(r.length===0)return ca();const a=new Map(t.nodes.map(l=>[l.id,l])),d=new Set;for(const l of r){d.add(l.id);for(const h of Bo(t,l.id))d.add(h);const c=[...l.children];for(let h=c.pop();h!==void 0;h=c.pop())d.add(h),c.push(...a.get(h)?.children??[])}o=d}const i=t.nodes.filter(r=>(o===null||o.has(r.id))&&!Bo(t,r.id).some(a=>n.has(a))),s=new Set(i.map(r=>r.id));return{...t,nodes:i,edges:t.edges.filter(r=>s.has(r.from)&&s.has(r.to))}},og=ae`
4697
+ </div>`}#T(e,n){e.target!==e.currentTarget||e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.#f(n))}#w(e,n){const o=this.dispatchElementAction(aa,["card",e],{column:n.column,before:n.before});this.#e=o?null:e,this.select({kind:"card",id:e}),this.requestUpdate()}#C(e,n){this.#r=n,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",n)),this.requestUpdate()}#$(e,n){if(this.#r===null)return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move");const o=this.#O(e,n);this.#s?.column===o.column&&this.#s.before===o.before||(this.#s=o,this.requestUpdate())}#F(e){const n=e.currentTarget;!(n instanceof HTMLElement)||e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||(this.#s=null,this.requestUpdate())}#S(e,n){const o=this.#r;if(o===null)return;e.preventDefault();const i=this.#O(e,n);this.#M(),Km(this.items(),o,i.column,i.before)||this.#w(o,i)}#M(){this.#r===null&&this.#s===null||(this.#r=null,this.#s=null,this.requestUpdate())}#O(e,n){const o=e.currentTarget,s=(o instanceof HTMLElement?[...o.querySelectorAll("[data-card]")]:[]).find(r=>{if(r.dataset.card===this.#r)return!1;const a=r.getBoundingClientRect();return a.top+a.height/2>e.clientY});return{column:n,before:s?.dataset.card??null}}#N(e){this.#i={column:e,title:"",failed:!1},this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-column="${CSS.escape(e)}"] .kanban-add input`)?.focus({preventScroll:!0}))}#z(e,n){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),this.#i=null,this.requestUpdate();return}if(e.key!=="Enter")return;e.preventDefault();const o=this.#i?.title.trim()??"";if(o.length===0)return;if(!this.id){const r=[...document.querySelectorAll("[id]")].map(a=>a.id);this.id=ke("kanban",r)}const i=[...this.items().columns.map(r=>r.id),...Ve(this.items()).map(r=>r.id)],s=ke(`card ${o}`,i);if(!this.dispatchElementAction(ra,["column",n],{id:s,title:o})){this.#i={column:n,title:o,failed:!0},this.requestUpdate();return}this.#i=null,this.select({kind:"card",id:s}),this.requestUpdate()}}const xa=()=>{customElements.get("dpk-board-kanban")||customElements.define("dpk-board-kanban",ba)},ya=[72,52,40],ka=[0,22,10,8],fg=t=>ya[Math.min(t,ya.length-1)]??40,va=t=>ka[Math.min(t,ka.length-1)]??8,bg=(t,e={})=>{const n=e.padding??40,o=t.nodes.find(C=>C.parent===null);if(o===void 0)return{width:0,height:0,nodes:[],routes:[]};const i=new Map(t.nodes.map(C=>[C.id,C])),s=C=>C.children.flatMap(M=>{const E=i.get(M);return E===void 0?[]:[E]}),r=new Map,a=C=>C.reduce((M,E,R)=>M+d(E)+(R===0?0:va(E.depth)),0),d=C=>{const M=r.get(C.id);if(M!==void 0)return M;const E=Math.max(C.height,a(s(C)));return r.set(C.id,E),E},l=[],c=(C,M,E)=>{if(M.length===0)return;const R=fg(C.node.depth);let D=C.y+C.node.height/2-a(M)/2;for(const O of M){const B=d(O),q={x:E==="right"?C.x+C.node.width+R:C.x-R-O.width,y:D+B/2-O.height/2,node:O};l.push(q),c(q,s(O),E),D+=B+va(O.depth)}},h={x:-o.width/2,y:-o.height/2,node:o};l.push(h);const p=s(o);c(h,p.filter(C=>C.side!=="left"),"right"),c(h,p.filter(C=>C.side==="left"),"left");const u=Math.min(...l.map(C=>C.x)),g=Math.min(...l.map(C=>C.y)),b=Math.max(...l.map(C=>C.x+C.node.width)),f=Math.max(...l.map(C=>C.y+C.node.height)),m=n-u,y=n-g,v=new Map,w=l.map(C=>{const M=v.get(C.node.depth)??0;return v.set(C.node.depth,M+1),{id:C.node.id,x:C.x+m,y:C.y+y,width:C.node.width,height:C.node.height,layer:C.node.depth,order:M}}),$=new Map(w.map(C=>[C.id,C])),A=t.edges.flatMap(C=>{const M=$.get(C.from),E=$.get(C.to),R=i.get(C.to);if(M===void 0||E===void 0||R===void 0)return[];const D=R.side==="left",O={x:D?M.x:M.x+M.width,y:M.y+M.height/2},B={x:D?E.x+E.width:E.x,y:E.y+E.height/2};return[{id:C.id,points:[O,B]}]});return{width:b-u+n*2,height:f-g+n*2,nodes:w,routes:A}},xg=t=>{const e=t[0],n=t.at(-1);if(e===void 0||n===void 0)return"";const o=(n.x-e.x)/2;return`M${e.x} ${e.y} C${e.x+o} ${e.y} ${n.x-o} ${n.y} ${n.x} ${n.y}`},_t=pe({en:{heading:"Mind map",empty:"No matching topics.",topics:"Topic",toggleOpen:(t,e)=>`Open ${e} subtopics of ${t}`,toggleClose:t=>`Collapse subtopics of ${t}`,addSubtopicButton:"+ Subtopic",addSubtopicAriaLabel:t=>`Subtopic of ${t}`,addSubtopicPlaceholder:"Subtopic title (Enter to add)",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",addTopicTitle:"Add topic",addSummary:(t,e)=>`${t} \u203A ${e}`},ja:{heading:"\u30DE\u30A4\u30F3\u30C9\u30DE\u30C3\u30D7",empty:"\u8A72\u5F53\u3059\u308B\u30C8\u30D4\u30C3\u30AF\u306F\u3042\u308A\u307E\u305B\u3093\u3002",topics:"\u30C8\u30D4\u30C3\u30AF",toggleOpen:(t,e)=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF ${e} \u4EF6\u3092\u3072\u3089\u304F`,toggleClose:t=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF\u3092\u305F\u305F\u3080`,addSubtopicButton:"\uFF0B \u30B5\u30D6\u30C8\u30D4\u30C3\u30AF",addSubtopicAriaLabel:t=>`${t} \u306E\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF`,addSubtopicPlaceholder:"\u30B5\u30D6\u30C8\u30D4\u30C3\u30AF\u540D\uFF08Enter \u3067\u8FFD\u52A0\uFF09",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",addTopicTitle:"\u30C8\u30D4\u30C3\u30AF\u3092\u8FFD\u52A0",addSummary:(t,e)=>`${t} \u203A ${e}`}}),wa=tl(()=>P({id:S(x(),I(1)),label:S(x(),I(1)),description:L(x()),tags:L(F(x())),questions:L(x()),collapsed:L(yt()),side:L(G(["left","right"])),children:L(F(wa))})),yg=P({root:wa}),$a=()=>({root:null,nodes:[],edges:[]}),Ea=[{fontSize:16,padding:22,height:48,min:120,max:280},{fontSize:13.5,padding:15,height:34,min:80,max:240},{fontSize:12.5,padding:12,height:28,min:56,max:220}],kg=t=>Ea[Math.min(t,Ea.length-1)]??{fontSize:12.5,padding:12,height:28,min:56,max:220},vg=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},wg=(t,e)=>{const n=kg(e),o=Math.ceil(vg(t,n.fontSize)+n.padding*2+4);return{width:Math.min(n.max,Math.max(n.min,o)),height:n.height}},$g=t=>({left:{x:0,y:t.height/2},right:{x:t.width,y:t.height/2}}),Eg=t=>t==="left"?{fromPort:"left",toPort:"right"}:{fromPort:"right",toPort:"left"},Go=t=>t.children===void 0||t.children.length===0?1:t.children.reduce((e,n)=>e+Go(n),0),Ta=t=>{const e={left:0,right:0};for(const n of t)n.side!==void 0&&(e[n.side]+=Go(n));return t.map(n=>{if(n.side!==void 0)return n.side;const o=e.right<=e.left?"right":"left";return e[o]+=Go(n),o})},Tg=t=>Sa(ue(yg,t).root),Sa=(t,e=new Set)=>{const n=[],o=[],i=new Set,s=(r,a,d,l,c)=>{if(i.has(r.id))throw new Error(`duplicate topic id: ${r.id}`);if(i.add(r.id),r.side!==void 0&&d!==1)throw new Error(`side is only allowed on a main topic (a child of the root): ${r.id}`);const h=r.children??[],p=wg(r.label,d);n.push({id:r.id,label:r.label,description:r.description??null,parent:a,depth:d,branch:l,side:c,children:h.map(g=>g.id),collapsed:r.collapsed??!1,added:e.has(r.id),tags:r.tags??[],...p,ports:$g(p),...r.questions===void 0?{}:{questions:r.questions}}),a!==null&&c!==null&&o.push({id:r.id,from:a,to:r.id,tags:[],...Eg(c)});const u=d===0?Ta(h):[];h.forEach((g,b)=>s(g,r.id,d+1,d===0?b:l,d===0?u[b]??"right":c))};return s(t,null,0,-1,null),{root:t,nodes:n,edges:o}},Ma="ADD_TOPIC",Sg=_({id:S(x(),I(1)),label:S(x(),ye(),I(1))}),Mg=t=>{const e=Ne(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},Ca=(t,e,n)=>t.id===e?{...t,children:[...t.children??[],n]}:t.children===void 0?t:{...t,children:t.children.map(o=>Ca(o,e,n))},Cg=t=>{if(t.children===void 0)return t;const e=Ta(t.children);return{...t,children:t.children.map((n,o)=>({...n,side:e[o]??"right"}))}},Lg=(t,e,n)=>{const o=t.addTopicTitle,i=new Map(e.nodes.map(d=>[d.id,d.label])),s=new Set,r=[];let a=e.root===null?null:Cg(e.root);for(const d of n){if(d.type!==Ma){r.push({id:d.id,title:d.type,stale:"unsupported-action-type"});continue}const l=Mg(d.target.id),c=l===null?void 0:i.get(l),h=re(Sg,d.payload);if(a===null||l===null||c===void 0){r.push({id:d.id,title:o,stale:"target-missing"});continue}if(!h.success||i.has(h.output.id)){r.push({id:d.id,title:o,stale:"constraint-violated"});continue}const{id:p,label:u}=h.output;a=Ca(a,l,{id:p,label:u}),i.set(p,u),s.add(p),r.push({id:d.id,title:o,summary:t.addSummary(c,u),tone:"create"})}return{data:a===null||s.size===0?e:Sa(a,s),results:r}},Xo=(t,e)=>{const n=new Map(t.nodes.map(s=>[s.id,s])),o=[];let i=n.get(e)?.parent??null;for(;i!==null&&!o.includes(i);)o.push(i),i=n.get(i)?.parent??null;return o},Ig=(t,e)=>{const n=new Map(t.nodes.map(s=>[s.id,s]));let o=0;const i=[...n.get(e)?.children??[]];for(let s=i.pop();s!==void 0;s=i.pop())o+=1,i.push(...n.get(s)?.children??[]);return o},Ag=(t,e,n)=>{let o=null;if(e!==null){const r=t.nodes.filter(e);if(r.length===0)return $a();const a=new Map(t.nodes.map(l=>[l.id,l])),d=new Set;for(const l of r){d.add(l.id);for(const h of Xo(t,l.id))d.add(h);const c=[...l.children];for(let h=c.pop();h!==void 0;h=c.pop())d.add(h),c.push(...a.get(h)?.children??[])}o=d}const i=t.nodes.filter(r=>(o===null||o.has(r.id))&&!Xo(t,r.id).some(a=>n.has(a))),s=new Set(i.map(r=>r.id));return{...t,nodes:i,edges:t.edges.filter(r=>s.has(r.from)&&s.has(r.to))}},Rg=de`
4324
4698
  .branch-root {
4325
4699
  --mind-color: var(--dpk-ink);
4326
4700
  --mind-soft: var(--dpk-paper-sunken);
@@ -4537,19 +4911,19 @@ ${o.renameContextHint}`}
4537
4911
  opacity: 1;
4538
4912
  }
4539
4913
  }
4540
- `,ig=5,fa=.6;class ba extends nt{static{this.styles=[De,og]}#o=new Set;#i=null;#e=!1;#n=null;toggle(e,n){const o=this.items().nodes.find(s=>s.id===e);if(o===void 0||o.children.length===0)return;const i=n??!this.#o.has(e);if(i!==this.#o.has(e)){if(i){this.#o.add(e);const s=this.selection;s!==null&&Bo(this.items(),s.id).includes(e)&&this.select(null)}else this.#o.delete(e);this.requestUpdate()}}get collapsed(){return[...this.#o]}parseData(e){return Vm(e)}emptyData(){return ca()}reduceElementActions(e,n){return eg(_t(this.locale),e,n)}defaultHeading(){return _t(this.locale).heading}emptyMessage(){return _t(this.locale).empty}statsText(){const e=_t(this.locale),n=this.items().nodes.length,o=this.filtered().nodes.length;return o===n?`${n} ${e.topics}`:`${o} / ${n} ${e.topics}`}filtered(){const e=this.tagFilter,n=e.active.length===0?null:o=>Ce(o.tags,e);return ng(this.items(),n,this.#o)}layoutSignature(){return this.filtered().nodes.map(e=>`${e.id}<${e.parent??""}:${e.side??""}`).join(",")}computePlacement(e){return Um(e)}refreshContent(){const e=this.authoredItems();e!==this.#i&&(this.#i=e,this.#o=new Set(e.nodes.filter(n=>n.collapsed).map(n=>n.id)),this.#e=!1,this.#n=null),super.refreshContent()}initialView(){const e=this.viewport;if(e===null)return;if(this.#e){e.apply();return}this.#e=!0,e.fit();const{scale:n}=e.view();n<fa&&e.zoom(fa/n)}commentItems(){return this.items().nodes.map(e=>({value:this.commentRef("node",e.id),label:e.label}))}hasSelection(e){return e.kind==="node"&&this.items().nodes.some(n=>n.id===e.id)}relations(e,n){if(e===null||e.kind!=="node")return{nodes:new Map,edges:new Set};const o=ve(n.edges,e.id,"outgoing",!0),i=ve(n.edges,e.id,"incoming",!0);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}renderCanvas(){const e=this.filtered(),n=_t(this.locale);return v`
4914
+ `,_g=5,La=.6;class Ia extends rt{static{this.styles=[ze,Rg]}#o=new Set;#i=null;#e=!1;#t=null;toggle(e,n){const o=this.items().nodes.find(s=>s.id===e);if(o===void 0||o.children.length===0)return;const i=n??!this.#o.has(e);if(i!==this.#o.has(e)){if(i){this.#o.add(e);const s=this.selection;s!==null&&Xo(this.items(),s.id).includes(e)&&this.select(null)}else this.#o.delete(e);this.requestUpdate()}}get collapsed(){return[...this.#o]}parseData(e){return Tg(e)}emptyData(){return $a()}reduceElementActions(e,n){return Lg(_t(this.locale),e,n)}defaultHeading(){return _t(this.locale).heading}emptyMessage(){return _t(this.locale).empty}statsText(){const e=_t(this.locale),n=this.items().nodes.length,o=this.filtered().nodes.length;return o===n?`${n} ${e.topics}`:`${o} / ${n} ${e.topics}`}filtered(){const e=this.tagFilter,n=e.active.length===0?null:o=>Ae(o.tags,e);return Ag(this.items(),n,this.#o)}layoutSignature(){return this.filtered().nodes.map(e=>`${e.id}<${e.parent??""}:${e.side??""}`).join(",")}computePlacement(e){return bg(e)}refreshContent(){const e=this.authoredItems();e!==this.#i&&(this.#i=e,this.#o=new Set(e.nodes.filter(n=>n.collapsed).map(n=>n.id)),this.#e=!1,this.#t=null),super.refreshContent()}initialView(){const e=this.viewport;if(e===null)return;if(this.#e){e.apply();return}this.#e=!0,e.fit();const{scale:n}=e.view();n<La&&e.zoom(La/n)}commentItems(){return this.items().nodes.map(e=>({value:this.commentRef("node",e.id),label:e.label}))}hasSelection(e){return e.kind==="node"&&this.items().nodes.some(n=>n.id===e.id)}relations(e,n){if(e===null||e.kind!=="node")return{nodes:new Map,edges:new Set};const o=we(n.edges,e.id,"outgoing",!0),i=we(n.edges,e.id,"incoming",!0);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}renderCanvas(){const e=this.filtered(),n=_t(this.locale);return k`
4541
4915
  ${this.renderEdges(e.edges.map(o=>this.#a(o)),[])}
4542
4916
  ${e.nodes.map(o=>this.#r(o,n))} ${this.#d(n)}
4543
- `}#t(e){return e===void 0||e.branch<0?"branch-root":`branch-${e.branch%ig}`}#a(e){const n=this.items().nodes.find(i=>i.id===e.to),o=this.edgeState(e.id);return Y`
4917
+ `}#n(e){return e===void 0||e.branch<0?"branch-root":`branch-${e.branch%_g}`}#a(e){const n=this.items().nodes.find(i=>i.id===e.to),o=this.edgeState(e.id);return Y`
4544
4918
  <path
4545
- class=${this.elementClass(o,"d-edge","mind-branch",this.#t(n),`depth-${Math.min(n?.depth??1,3)}`)}
4919
+ class=${this.elementClass(o,"d-edge","mind-branch",this.#n(n),`depth-${Math.min(n?.depth??1,3)}`)}
4546
4920
  data-branch=${e.id}
4547
- d=${Hm(this.routeOf(e.id))}
4921
+ d=${xg(this.routeOf(e.id))}
4548
4922
  ></path>
4549
- `}#r(e,n){const o=this.placedNode(e.id);if(!o)return M;const i=this.nodeState(e.id),s=this.#o.has(e.id),r=`depth-${Math.min(e.depth,3)}`;return v`
4923
+ `}#r(e,n){const o=this.placedNode(e.id);if(!o)return T;const i=this.nodeState(e.id),s=this.#o.has(e.id),r=`depth-${Math.min(e.depth,3)}`;return k`
4550
4924
  <button
4551
4925
  type="button"
4552
- class=${this.elementClass(i,"d-node","mind-topic",r,this.#t(e),s&&"is-folded",e.added&&"is-added",this.isDraggingNode(e.id)&&"is-dragging")}
4926
+ class=${this.elementClass(i,"d-node","mind-topic",r,this.#n(e),s&&"is-folded",e.added&&"is-added",this.isDraggingNode(e.id)&&"is-dragging")}
4553
4927
  data-topic=${e.id}
4554
4928
  data-grill-questions=${this.questionsOf(e)}
4555
4929
  data-dpk-target=${this.commentRef("node",e.id)}
@@ -4561,11 +4935,11 @@ ${o.renameContextHint}`}
4561
4935
  >
4562
4936
  <span class="mind-label">${e.label}</span>
4563
4937
  </button>
4564
- ${e.depth===0||e.children.length===0?M:this.#s(e,o,s,i.dimmed,n)}
4565
- `}#s(e,n,o,i,s){const r=o?tg(this.items(),e.id):0,a=e.side==="left"?n.x:n.x+n.width,d=o?s.toggleOpen(e.label,r):s.toggleClose(e.label);return v`
4938
+ ${e.depth===0||e.children.length===0?T:this.#s(e,o,s,i.dimmed,n)}
4939
+ `}#s(e,n,o,i,s){const r=o?Ig(this.items(),e.id):0,a=e.side==="left"?n.x:n.x+n.width,d=o?s.toggleOpen(e.label,r):s.toggleClose(e.label);return k`
4566
4940
  <button
4567
4941
  type="button"
4568
- class=${this.elementClass({selected:!1,related:!1,dimmed:i,depth:null},"mind-toggle",this.#t(e),o&&"is-folded")}
4942
+ class=${this.elementClass({selected:!1,related:!1,dimmed:i,depth:null},"mind-toggle",this.#n(e),o&&"is-folded")}
4569
4943
  data-toggle=${e.id}
4570
4944
  style="left:${a}px; top:${n.y+n.height/2}px"
4571
4945
  aria-expanded=${o?"false":"true"}
@@ -4575,30 +4949,30 @@ ${o.renameContextHint}`}
4575
4949
  >
4576
4950
  ${o?r:"\u2212"}
4577
4951
  </button>
4578
- `}#d(e){const n=this.selection;if(n===null||n.kind!=="node")return M;const o=this.items().nodes.find(r=>r.id===n.id),i=this.placedNode(n.id);if(o===void 0||i===void 0)return M;const s=this.#n?.parent===o.id?this.#n:null;return v`
4952
+ `}#d(e){const n=this.selection;if(n===null||n.kind!=="node")return T;const o=this.items().nodes.find(r=>r.id===n.id),i=this.placedNode(n.id);if(o===void 0||i===void 0)return T;const s=this.#t?.parent===o.id?this.#t:null;return k`
4579
4953
  <div
4580
4954
  class="mind-actions"
4581
4955
  data-for=${o.id}
4582
4956
  style="left:${this.#c(o,i)}px; top:${i.y+i.height+8}px"
4583
4957
  @click=${r=>r.stopPropagation()}
4584
4958
  >
4585
- ${s===null?v`
4586
- <button type="button" class="dpk-btn" data-action="add" @click=${()=>this.#p(o.id)}>
4959
+ ${s===null?k`
4960
+ <button type="button" class="dpk-btn" data-action="add" @click=${()=>this.#h(o.id)}>
4587
4961
  ${e.addSubtopicButton}
4588
4962
  </button>
4589
- `:v`
4963
+ `:k`
4590
4964
  <input
4591
4965
  class="dpk-input"
4592
4966
  aria-label="${e.addSubtopicAriaLabel(o.label)}"
4593
4967
  placeholder="${e.addSubtopicPlaceholder}"
4594
4968
  .value=${s.label}
4595
- @input=${r=>{const a=r.currentTarget;a instanceof HTMLInputElement&&(this.#n={...s,label:a.value,failed:!1})}}
4596
- @keydown=${r=>this.#u(r,o.id)}
4969
+ @input=${r=>{const a=r.currentTarget;a instanceof HTMLInputElement&&(this.#t={...s,label:a.value,failed:!1})}}
4970
+ @keydown=${r=>this.#p(r,o.id)}
4597
4971
  />
4598
- ${s.failed?v`<span class="mind-actions-error" role="alert">${e.notRecorded}</span>`:M}
4972
+ ${s.failed?k`<span class="mind-actions-error" role="alert">${e.notRecorded}</span>`:T}
4599
4973
  `}
4600
4974
  </div>
4601
- `}#c(e,n){return e.side==="left"?n.x+n.width-220:n.x}#p(e){this.#n={parent:e,label:"",failed:!1},this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(".mind-actions input")?.focus())}#u(e,n){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),this.#n=null,this.requestUpdate();return}if(e.key!=="Enter")return;e.preventDefault();const o=this.#n?.label.trim()??"";if(o.length===0)return;const i=xe(`topic ${o}`,this.items().nodes.map(r=>r.id));if(!this.dispatchElementAction(ma,["node",n],{id:i,label:o})){this.#n={parent:n,label:o,failed:!0},this.requestUpdate();return}this.#n=null,this.#o.delete(n),this.select({kind:"node",id:i}),this.requestUpdate()}}const xa=()=>{customElements.get("dpk-board-mind-map")||customElements.define("dpk-board-mind-map",ba)},ya=(t,e)=>e?{request:"Process / guarantee",response:"Response / guarantee",async:"Async / guarantee"}[t]:{request:"\u51E6\u7406 / \u4FDD\u8A3C",response:"\u5FDC\u7B54 / \u4FDD\u8A3C",async:"\u975E\u540C\u671F\u51E6\u7406 / \u4FDD\u8A3C"}[t],Rt=ce({en:{heading:"Sequence diagram",empty:"No matching messages.",participants:"Participants",stats:(t,e)=>`${t} / ${e} messages`,detailLabel:t=>ya(t,!0),selectMessage:t=>`Select ${t}`,frameHeaderLabel:(t,e,n)=>`${t} \xB7 ${n?`Expand ${e}`:`Collapse ${e}`}`,frameCount:t=>`${t} message${t===1?"":"s"}`},ja:{heading:"\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3",empty:"\u8A72\u5F53\u3059\u308B\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",participants:"\u53C2\u52A0\u8005",stats:(t,e)=>`${t} / ${e} \u30E1\u30C3\u30BB\u30FC\u30B8`,detailLabel:t=>ya(t,!1),selectMessage:t=>`${t}\u3092\u9078\u629E`,frameHeaderLabel:(t,e,n)=>`${t} \xB7 ${e}\u3092${n?"\u5C55\u958B":"\u6298\u308A\u305F\u305F\u3080"}`,frameCount:t=>`${t} \u30E1\u30C3\u30BB\u30FC\u30B8`}}),sg=P({kind:pe("message"),id:I(y(),_(1)),from:I(y(),_(1)),to:I(y(),_(1)),title:I(y(),_(1)),style:C(X(["request","response","async"]),"request"),tags:C(F(y()),[]),guard:C(y()),detail:C(y()),questions:C(y())}),rg=P({label:I(y(),_(1)),items:F(xi())}),ag=P({kind:pe("fragment"),id:I(y(),_(1)),operator:X(["alt","opt","loop","par"]),title:I(y(),_(1)),collapsed:C(ft(),!1),branches:I(F(rg),_(1))}),dg=Bn("kind",[sg,ag]),lg=P({id:I(y(),_(1)),name:I(y(),_(1)),role:C(y()),symbol:C(y()),kind:C(X(["internal","external"]),"internal"),description:C(y()),questions:C(y())}),cg=P({participants:I(F(lg),_(1)),items:C(F(xi()),[])}),va=240,Uo=(t,e,n)=>{if(t.has(e))throw new Error(`duplicate ${n} id: ${e}`);t.add(e)},ka=(t,e,n)=>t.map(o=>{const i=he(dg,o);if(i.kind==="message"){if(Uo(n,i.id,"message"),!e.has(i.from))throw new Error(`unknown sender: ${i.from}`);if(!e.has(i.to))throw new Error(`unknown receiver: ${i.to}`);return{kind:"message",id:i.id,from:i.from,to:i.to,title:i.title,style:i.style,tags:i.tags,guard:i.guard??null,detail:i.detail??null,questions:i.questions??null}}return Uo(n,i.id,"fragment"),{kind:"fragment",id:i.id,operator:i.operator,title:i.title,collapsed:i.collapsed,branches:i.branches.map(r=>({label:r.label,items:ka(r.items,e,n)}))}}),pg=t=>{const e=he(cg,t),n=new Set;for(const o of e.participants)Uo(n,o.id,"participant");return{participants:e.participants.map(o=>({id:o.id,name:o.name,role:o.role??null,symbol:o.symbol??null,external:o.kind==="external",description:o.description??null,questions:o.questions??null})),items:ka(e.items,n,new Set)}},hg=()=>({participants:[],items:[]}),wa=(t,e)=>{for(const n of t)if(n.kind==="message")e.push(n);else for(const o of n.branches)wa(o.items,e)},Ue=t=>{const e=[];return wa(t,e),e},$a=t=>new Map(Ue(t.items).map((e,n)=>[e.id,String(n+1).padStart(2,"0")])),ug=t=>Ue(t).length,Ea=(t,e)=>{const n=[];for(const o of t){if(o.kind==="message"){e(o)&&n.push(o);continue}const i=o.branches.map(s=>({label:s.label,items:Ea(s.items,e)})).filter(s=>s.items.length>0);i.length>0&&n.push({...o,branches:i})}return n},mg=64,gg=86,fg=31,bg=32,xg=40,yg=(t,e)=>{const n=Ea(t.items,e),o=new Set;for(const g of Ue(n))o.add(g.from),o.add(g.to);const i=t.participants.filter(g=>o.has(g.id)),s=new Map(i.map((g,b)=>[g.id,120+b*va])),r=Math.max(360,i.length*va),a=[],d=[],l=[],c=[],h=[];let p=25;const u=(g,b)=>{for(const f of g){if(f.kind==="message"){a.push({message:f,y:p+29,depth:b}),p+=f.from===f.to?gg:mg;continue}const m=22+b*13,x=p,k=r-44-b*26;p+=fg,f.collapsed?(h.push({fragment:f,x:m,y:p+6,width:k}),p+=xg):f.branches.forEach((w,$)=>{$>0&&(c.push({x:m,y:p,width:k}),p+=8),l.push({label:w.label,x:m+12,y:p,width:k-24}),p+=bg,u(w.items,b+1),p+=8}),d.push({fragment:f,x:m,y:x,width:k,height:p-x,count:ug([f])}),p+=14}};return u(n,0),{width:r,height:p+24,participants:i,rows:a,frames:d,branches:l,dividers:c,folds:h,x:s}},vg=ae`
4975
+ `}#c(e,n){return e.side==="left"?n.x+n.width-220:n.x}#h(e){this.#t={parent:e,label:"",failed:!1},this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(".mind-actions input")?.focus())}#p(e,n){if(e.isComposing)return;if(e.key==="Escape"){e.preventDefault(),this.#t=null,this.requestUpdate();return}if(e.key!=="Enter")return;e.preventDefault();const o=this.#t?.label.trim()??"";if(o.length===0)return;const i=ke(`topic ${o}`,this.items().nodes.map(r=>r.id));if(!this.dispatchElementAction(Ma,["node",n],{id:i,label:o})){this.#t={parent:n,label:o,failed:!0},this.requestUpdate();return}this.#t=null,this.#o.delete(n),this.select({kind:"node",id:i}),this.requestUpdate()}}const Aa=()=>{customElements.get("dpk-board-mind-map")||customElements.define("dpk-board-mind-map",Ia)},Ra=(t,e)=>e?{request:"Process / guarantee",response:"Response / guarantee",async:"Async / guarantee"}[t]:{request:"\u51E6\u7406 / \u4FDD\u8A3C",response:"\u5FDC\u7B54 / \u4FDD\u8A3C",async:"\u975E\u540C\u671F\u51E6\u7406 / \u4FDD\u8A3C"}[t],Dt=pe({en:{heading:"Sequence diagram",empty:"No matching messages.",participants:"Participants",stats:(t,e)=>`${t} / ${e} messages`,detailLabel:t=>Ra(t,!0),selectMessage:t=>`Select ${t}`,frameHeaderLabel:(t,e,n)=>`${t} \xB7 ${n?`Expand ${e}`:`Collapse ${e}`}`,frameCount:t=>`${t} message${t===1?"":"s"}`},ja:{heading:"\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3",empty:"\u8A72\u5F53\u3059\u308B\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",participants:"\u53C2\u52A0\u8005",stats:(t,e)=>`${t} / ${e} \u30E1\u30C3\u30BB\u30FC\u30B8`,detailLabel:t=>Ra(t,!1),selectMessage:t=>`${t}\u3092\u9078\u629E`,frameHeaderLabel:(t,e,n)=>`${t} \xB7 ${e}\u3092${n?"\u5C55\u958B":"\u6298\u308A\u305F\u305F\u3080"}`,frameCount:t=>`${t} \u30E1\u30C3\u30BB\u30FC\u30B8`}}),Dg=P({kind:he("message"),id:S(x(),I(1)),from:S(x(),I(1)),to:S(x(),I(1)),title:S(x(),I(1)),style:L(G(["request","response","async"]),"request"),tags:L(F(x()),[]),guard:L(x()),detail:L(x()),questions:L(x())}),Og=P({label:S(x(),I(1)),items:F($i())}),Ng=P({kind:he("fragment"),id:S(x(),I(1)),operator:G(["alt","opt","loop","par"]),title:S(x(),I(1)),collapsed:L(yt(),!1),branches:S(F(Og),I(1))}),zg=Yn("kind",[Dg,Ng]),Pg=P({id:S(x(),I(1)),name:S(x(),I(1)),role:L(x()),symbol:L(x()),kind:L(G(["internal","external"]),"internal"),description:L(x()),questions:L(x())}),qg=P({participants:S(F(Pg),I(1)),items:L(F($i()),[])}),_a=240,Ko=(t,e,n)=>{if(t.has(e))throw new Error(`duplicate ${n} id: ${e}`);t.add(e)},Da=(t,e,n)=>t.map(o=>{const i=ue(zg,o);if(i.kind==="message"){if(Ko(n,i.id,"message"),!e.has(i.from))throw new Error(`unknown sender: ${i.from}`);if(!e.has(i.to))throw new Error(`unknown receiver: ${i.to}`);return{kind:"message",id:i.id,from:i.from,to:i.to,title:i.title,style:i.style,tags:i.tags,guard:i.guard??null,detail:i.detail??null,questions:i.questions??null}}return Ko(n,i.id,"fragment"),{kind:"fragment",id:i.id,operator:i.operator,title:i.title,collapsed:i.collapsed,branches:i.branches.map(r=>({label:r.label,items:Da(r.items,e,n)}))}}),Fg=t=>{const e=ue(qg,t),n=new Set;for(const o of e.participants)Ko(n,o.id,"participant");return{participants:e.participants.map(o=>({id:o.id,name:o.name,role:o.role??null,symbol:o.symbol??null,external:o.kind==="external",description:o.description??null,questions:o.questions??null})),items:Da(e.items,n,new Set)}},Ug=()=>({participants:[],items:[]}),Oa=(t,e)=>{for(const n of t)if(n.kind==="message")e.push(n);else for(const o of n.branches)Oa(o.items,e)},Ye=t=>{const e=[];return Oa(t,e),e},Na=t=>new Map(Ye(t.items).map((e,n)=>[e.id,String(n+1).padStart(2,"0")])),Bg=t=>Ye(t).length,za=(t,e)=>{const n=[];for(const o of t){if(o.kind==="message"){e(o)&&n.push(o);continue}const i=o.branches.map(s=>({label:s.label,items:za(s.items,e)})).filter(s=>s.items.length>0);i.length>0&&n.push({...o,branches:i})}return n},Hg=64,Yg=86,Gg=31,Xg=32,Kg=40,jg=(t,e)=>{const n=za(t.items,e),o=new Set;for(const g of Ye(n))o.add(g.from),o.add(g.to);const i=t.participants.filter(g=>o.has(g.id)),s=new Map(i.map((g,b)=>[g.id,120+b*_a])),r=Math.max(360,i.length*_a),a=[],d=[],l=[],c=[],h=[];let p=25;const u=(g,b)=>{for(const f of g){if(f.kind==="message"){a.push({message:f,y:p+29,depth:b}),p+=f.from===f.to?Yg:Hg;continue}const m=22+b*13,y=p,v=r-44-b*26;p+=Gg,f.collapsed?(h.push({fragment:f,x:m,y:p+6,width:v}),p+=Kg):f.branches.forEach((w,$)=>{$>0&&(c.push({x:m,y:p,width:v}),p+=8),l.push({label:w.label,x:m+12,y:p,width:v-24}),p+=Xg,u(w.items,b+1),p+=8}),d.push({fragment:f,x:m,y,width:v,height:p-y,count:Bg([f])}),p+=14}};return u(n,0),{width:r,height:p+24,participants:i,rows:a,frames:d,branches:l,dividers:c,folds:h,x:s}},Wg=de`
4602
4976
  .sequence::part(canvas) {
4603
4977
  background-image: none;
4604
4978
  }
@@ -4900,14 +5274,14 @@ ${o.renameContextHint}`}
4900
5274
  fill: var(--dpk-ink);
4901
5275
  stroke: var(--dpk-ink);
4902
5276
  }
4903
- `,kg=[{id:"seq-request"},{id:"seq-response"},{id:"seq-async"},{id:"seq-related"},{id:"seq-selected"}];class Ta extends eo{static{this.styles=[De,vg]}#o=null;#i=new Map;#e=new Map;#n=new Set;#t=new Set;#a="";#r=0;commentItems(){const e=this.items(),n=$a(e);return[...e.participants.map(o=>({value:this.commentRef("participant",o.id),label:o.name})),...Ue(e.items).map(o=>({value:this.commentRef("message",o.id),label:`${n.get(o.id)??""} ${o.title}`.trim()}))]}parseData(e){return this.#e.clear(),pg(e)}emptyData(){return hg()}defaultHeading(){return Rt(this.locale).heading}shellClass(){return"sequence"}emptyMessage(){return Rt(this.locale).empty}fitMode(){return"width"}onViewChange(e){const n=this.renderRoot.querySelector(".sequence-rail-world");n&&(n.style.transform=`translateX(${e.x}px) scale(${e.scale})`)}hasSelection(e){const n=this.items();return e.kind==="participant"?n.participants.some(o=>o.id===e.id):Ue(n.items).some(o=>o.id===e.id)}tagItems(){return Ue(this.items().items).map(e=>e.tags)}statsText(){const e=this.#o,n=Ue(this.items().items).length;return e===null?"":Rt(this.locale).stats(e.rows.length,n)}contentSize(){const e=this.#o;return e===null||e.rows.length===0?null:{width:e.width,height:e.height}}isEmpty(){return this.contentSize()===null}layoutVersion(){return this.#r}refreshContent(){const e=this.#d(),n=this.tagFilter,o=[n.match,[...n.active].join(","),[...this.#e].map(([r,a])=>`${r}:${a}`).join(","),Ue(e.items).map(r=>r.id).join(",")].join("|");o!==this.#a&&(this.#a=o,this.#r+=1,this.#i=$a(this.items()),this.#o=yg(e,r=>Ce(r.tags,n))),this.#n=new Set,this.#t=new Set;const i=this.selection,s=this.#o;if(i!==null&&s!==null)if(i.kind==="message"){const r=s.rows.find(a=>a.message.id===i.id);this.#n.add(i.id),r&&(this.#t.add(r.message.from),this.#t.add(r.message.to))}else for(const r of s.rows)r.message.from!==i.id&&r.message.to!==i.id||this.#n.add(r.message.id)}#s(e,n){const o=e.detail===null?null:`${n.detailLabel(e.style)}: ${e.detail}`;return[e.guard,o].filter(i=>i!==null).join(`
4904
- `)||e.title}#d(){const e=this.items(),n=o=>o.map(i=>i.kind==="message"?i:{...i,collapsed:this.#e.get(i.id)??i.collapsed,branches:i.branches.map(s=>({label:s.label,items:n(s.items)}))});return{participants:e.participants,items:n(e.items)}}#c(e){return this.#o?.frames.find(n=>n.fragment.id===e.id)?.fragment.collapsed??e.collapsed}#p(e){this.#e.set(e.id,!this.#c(e)),this.requestUpdate()}#u(e){const n=this.selection?.kind==="message"&&this.selection.id===e,o=!n&&this.#n.has(e);return{selected:n,related:o,dimmed:this.selection!==null&&!n&&!o,depth:null}}#h(e){const n=this.selection?.kind==="participant"&&this.selection.id===e,o=!n&&this.#t.has(e);return{selected:n,related:o,dimmed:this.selection!==null&&!n&&!o,depth:null}}renderAboveCanvas(){const e=this.#o;if(e===null)return M;const n=Rt(this.locale);return v`
5277
+ `,Vg=[{id:"seq-request"},{id:"seq-response"},{id:"seq-async"},{id:"seq-related"},{id:"seq-selected"}];class Pa extends io{static{this.styles=[ze,Wg]}#o=null;#i=new Map;#e=new Map;#t=new Set;#n=new Set;#a="";#r=0;commentItems(){const e=this.items(),n=Na(e);return[...e.participants.map(o=>({value:this.commentRef("participant",o.id),label:o.name})),...Ye(e.items).map(o=>({value:this.commentRef("message",o.id),label:`${n.get(o.id)??""} ${o.title}`.trim()}))]}parseData(e){return this.#e.clear(),Fg(e)}emptyData(){return Ug()}defaultHeading(){return Dt(this.locale).heading}shellClass(){return"sequence"}emptyMessage(){return Dt(this.locale).empty}fitMode(){return"width"}onViewChange(e){const n=this.renderRoot.querySelector(".sequence-rail-world");n&&(n.style.transform=`translateX(${e.x}px) scale(${e.scale})`)}hasSelection(e){const n=this.items();return e.kind==="participant"?n.participants.some(o=>o.id===e.id):Ye(n.items).some(o=>o.id===e.id)}tagItems(){return Ye(this.items().items).map(e=>e.tags)}statsText(){const e=this.#o,n=Ye(this.items().items).length;return e===null?"":Dt(this.locale).stats(e.rows.length,n)}contentSize(){const e=this.#o;return e===null||e.rows.length===0?null:{width:e.width,height:e.height}}isEmpty(){return this.contentSize()===null}layoutVersion(){return this.#r}refreshContent(){const e=this.#d(),n=this.tagFilter,o=[n.match,[...n.active].join(","),[...this.#e].map(([r,a])=>`${r}:${a}`).join(","),Ye(e.items).map(r=>r.id).join(",")].join("|");o!==this.#a&&(this.#a=o,this.#r+=1,this.#i=Na(this.items()),this.#o=jg(e,r=>Ae(r.tags,n))),this.#t=new Set,this.#n=new Set;const i=this.selection,s=this.#o;if(i!==null&&s!==null)if(i.kind==="message"){const r=s.rows.find(a=>a.message.id===i.id);this.#t.add(i.id),r&&(this.#n.add(r.message.from),this.#n.add(r.message.to))}else for(const r of s.rows)r.message.from!==i.id&&r.message.to!==i.id||this.#t.add(r.message.id)}#s(e,n){const o=e.detail===null?null:`${n.detailLabel(e.style)}: ${e.detail}`;return[e.guard,o].filter(i=>i!==null).join(`
5278
+ `)||e.title}#d(){const e=this.items(),n=o=>o.map(i=>i.kind==="message"?i:{...i,collapsed:this.#e.get(i.id)??i.collapsed,branches:i.branches.map(s=>({label:s.label,items:n(s.items)}))});return{participants:e.participants,items:n(e.items)}}#c(e){return this.#o?.frames.find(n=>n.fragment.id===e.id)?.fragment.collapsed??e.collapsed}#h(e){this.#e.set(e.id,!this.#c(e)),this.requestUpdate()}#p(e){const n=this.selection?.kind==="message"&&this.selection.id===e,o=!n&&this.#t.has(e);return{selected:n,related:o,dimmed:this.selection!==null&&!n&&!o,depth:null}}#u(e){const n=this.selection?.kind==="participant"&&this.selection.id===e,o=!n&&this.#n.has(e);return{selected:n,related:o,dimmed:this.selection!==null&&!n&&!o,depth:null}}renderAboveCanvas(){const e=this.#o;if(e===null)return T;const n=Dt(this.locale);return k`
4905
5279
  <div class="sequence-rail" role="group" aria-label=${n.participants}>
4906
5280
  <div class="sequence-rail-world">
4907
5281
  ${e.participants.map(o=>this.#l(o,e))}
4908
5282
  </div>
4909
5283
  </div>
4910
- `}#l(e,n){const o=n.x.get(e.id)??0,i=this.#h(e.id);return v`
5284
+ `}#l(e,n){const o=n.x.get(e.id)??0,i=this.#u(e.id);return k`
4911
5285
  <button
4912
5286
  type="button"
4913
5287
  class=${this.elementClass(i,"sequence-participant",e.external&&"is-external")}
@@ -4922,23 +5296,23 @@ ${o.renameContextHint}`}
4922
5296
  <span class="sequence-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>
4923
5297
  <span class="sequence-names">
4924
5298
  <span class="sequence-name">${e.name}</span>
4925
- ${e.role===null?M:v`<span class="sequence-role">${e.role}</span>`}
5299
+ ${e.role===null?T:k`<span class="sequence-role">${e.role}</span>`}
4926
5300
  </span>
4927
5301
  </button>
4928
- `}renderCanvas(){const e=this.#o;if(e===null)return v``;const n=Rt(this.locale);return v`
5302
+ `}renderCanvas(){const e=this.#o;if(e===null)return k``;const n=Dt(this.locale);return k`
4929
5303
  ${this.#m(e,n)}
4930
- ${e.frames.map(o=>v`<div
5304
+ ${e.frames.map(o=>k`<div
4931
5305
  class="sequence-frame"
4932
5306
  style="left:${o.x}px; top:${o.y}px; width:${o.width}px; height:${o.height}px"
4933
5307
  ></div>`)}
4934
5308
  ${e.frames.map(o=>this.#g(o.fragment,o.x,o.y,o.width,o.count,n))}
4935
- ${e.branches.map(o=>v`<span
5309
+ ${e.branches.map(o=>k`<span
4936
5310
  class="sequence-branch"
4937
5311
  style="left:${o.x}px; top:${o.y}px; max-width:${o.width}px"
4938
5312
  title=${o.label}
4939
5313
  >[${o.label}]</span
4940
5314
  >`)}
4941
- ${e.folds.map(o=>{const i=o.fragment.branches.map(s=>`[${s.label}]`).join(" / ");return v`<span
5315
+ ${e.folds.map(o=>{const i=o.fragment.branches.map(s=>`[${s.label}]`).join(" / ");return k`<span
4942
5316
  class="sequence-fold"
4943
5317
  style="left:${o.x}px; top:${o.y}px; max-width:${o.width}px"
4944
5318
  title=${i}
@@ -4948,7 +5322,7 @@ ${o.renameContextHint}`}
4948
5322
  `}#m(e,n){const o=e.participants.map(r=>Y`<path
4949
5323
  class="sequence-lifeline"
4950
5324
  d=${`M${e.x.get(r.id)??0} 0 V${e.height}`}
4951
- ></path>`),i=e.dividers.map(r=>Y`<path class="sequence-divider" d=${`M${r.x} ${r.y} h${r.width}`}></path>`),s=e.rows.map(r=>{const a=e.x.get(r.message.from)??0,d=e.x.get(r.message.to)??0,l=a===d?`M${a} ${r.y} h42 v25 H${a}`:`M${a} ${r.y} H${d}`,c=this.#u(r.message.id),h=c.selected?"seq-selected":c.related?"seq-related":r.message.style==="async"?"seq-async":r.message.style==="response"?"seq-response":"seq-request",p=()=>this.select({kind:"message",id:r.message.id});return Y`
5325
+ ></path>`),i=e.dividers.map(r=>Y`<path class="sequence-divider" d=${`M${r.x} ${r.y} h${r.width}`}></path>`),s=e.rows.map(r=>{const a=e.x.get(r.message.from)??0,d=e.x.get(r.message.to)??0,l=a===d?`M${a} ${r.y} h42 v25 H${a}`:`M${a} ${r.y} H${d}`,c=this.#p(r.message.id),h=c.selected?"seq-selected":c.related?"seq-related":r.message.style==="async"?"seq-async":r.message.style==="response"?"seq-response":"seq-request",p=()=>this.select({kind:"message",id:r.message.id});return Y`
4952
5326
  <g
4953
5327
  class=${this.elementClass(c,"sequence-message-row","d-edge",`is-${r.message.style}`)}
4954
5328
  data-message=${r.message.id}
@@ -4960,9 +5334,9 @@ ${o.renameContextHint}`}
4960
5334
  @keydown=${u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),p())}}></path>
4961
5335
  <path class="sequence-message is-${r.message.style}" d=${l} marker-end=${`url(#${h})`}></path>
4962
5336
  </g>
4963
- `});return v`<svg class="diagram-edges" width=${e.width} height=${e.height}>
4964
- ${Wi(kg)} ${o} ${i} ${s}
4965
- </svg>`}#g(e,n,o,i,s,r){const a=this.#c(e);return v`
5337
+ `});return k`<svg class="diagram-edges" width=${e.width} height=${e.height}>
5338
+ ${ns(Vg)} ${o} ${i} ${s}
5339
+ </svg>`}#g(e,n,o,i,s,r){const a=this.#c(e);return k`
4966
5340
  <button
4967
5341
  type="button"
4968
5342
  class="sequence-frame-header"
@@ -4970,14 +5344,14 @@ ${o.renameContextHint}`}
4970
5344
  style="left:${n}px; top:${o}px; width:${i}px"
4971
5345
  aria-expanded=${a?"false":"true"}
4972
5346
  aria-label=${r.frameHeaderLabel(e.operator,e.title,a)}
4973
- @click=${()=>this.#p(e)}
5347
+ @click=${()=>this.#h(e)}
4974
5348
  >
4975
- <span class="sequence-frame-chevron">${a?Hd():yi()}</span>
5349
+ <span class="sequence-frame-chevron">${a?nl():Ei()}</span>
4976
5350
  <span class="sequence-operator">${e.operator}</span>
4977
5351
  <span class="sequence-text">${e.title}</span>
4978
5352
  <span class="sequence-frame-count">${r.frameCount(s)}</span>
4979
5353
  </button>
4980
- `}#f(e,n,o,i){const s=o.x.get(n.from)??0,r=o.x.get(n.to)??0,a=s===r,d=this.#u(n.id),l=a?s+12:Math.min(s,r)+14,c=a?175:Math.abs(r-s)-28;return v`
5354
+ `}#f(e,n,o,i){const s=o.x.get(n.from)??0,r=o.x.get(n.to)??0,a=s===r,d=this.#p(n.id),l=a?s+12:Math.min(s,r)+14,c=a?175:Math.abs(r-s)-28;return k`
4981
5355
  <button
4982
5356
  type="button"
4983
5357
  class=${this.elementClass(d,"sequence-label")}
@@ -4992,7 +5366,7 @@ ${o.renameContextHint}`}
4992
5366
  <span class="sequence-number">${this.#i.get(n.id)??""}</span>
4993
5367
  <span class="sequence-text">${n.title}</span>
4994
5368
  </button>
4995
- `}}const Sa=()=>{customElements.get("dpk-board-sequence-diagram")||customElements.define("dpk-board-sequence-diagram",Ta)},En=ce({en:{heading:"State diagram",node:"State",edge:"Transition",empty:"No matching transitions.",transitionLabel:(t,e,n)=>`${n} from ${t} to ${e}`},ja:{heading:"\u30B9\u30C6\u30FC\u30C8\u56F3",node:"\u72B6\u614B",edge:"\u9077\u79FB",empty:"\u8A72\u5F53\u3059\u308B\u9077\u79FB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",transitionLabel:(t,e,n)=>`${t} \u304B\u3089 ${e} \u3078\u306E ${n}`}}),wg=P({x:le(),y:le()}),$g=P({id:I(y(),_(1)),name:I(y(),_(1)),code:C(y()),kind:C(X(["normal","initial","terminal","compensation"]),"normal"),description:C(y()),position:C(wg),questions:C(y())}),Eg=P({id:I(y(),_(1)),from:I(y(),_(1)),to:I(y(),_(1)),title:I(y(),_(1)),kind:C(X(["normal","exception"]),"normal"),tags:C(F(y()),[]),guard:C(y()),effect:C(y()),questions:C(y())}),Ma={width:178,height:86},Tg=()=>({nodes:[],edges:[]}),Sg=P({states:F($g),transitions:C(F(Eg),[])}),Mg=t=>{const e=he(Sg,t),n=new Set;for(const r of e.states){if(n.has(r.id))throw new Error(`duplicate state id: ${r.id}`);n.add(r.id)}const o=new Set,i=e.transitions.map(r=>{if(o.has(r.id))throw new Error(`duplicate transition id: ${r.id}`);if(o.add(r.id),!n.has(r.from))throw new Error(`unknown transition source: ${r.from}`);if(!n.has(r.to))throw new Error(`unknown transition target: ${r.to}`);return{id:r.id,from:r.from,to:r.to,title:r.title,kind:r.kind,tags:r.tags,guard:r.guard??null,effect:r.effect??null,...r.questions===void 0?{}:{questions:r.questions}}});return{nodes:e.states.map(r=>({id:r.id,name:r.name,code:r.code??null,kind:r.kind,description:r.description??null,width:Ma.width,height:Ma.height,tags:[],...r.position===void 0?{}:{position:r.position},...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},Ig=t=>t.length>0&&t.every(e=>e.position!==void 0),Cg={portGap:16,laneGap:10,margin:12},Lg=12,_g=14,Rg=18,Ag=14,Tn=22,Sn=18,Og=4,Ng=10,Ia=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},Ca=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),Ho=(t,e)=>t.slice(1).some((n,o)=>{const i=t[o];return i===void 0?!1:i.x===n.x?me(i.x,Math.min(i.y,n.y),Math.max(i.y,n.y),e):ge(i.y,Math.min(i.x,n.x),Math.max(i.x,n.x),e)}),At=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},Yo=t=>t.slice(1).map((e,n)=>[t[n],e]),Dg=(t,e,n)=>t.id===e.id?n==="from"?"right":"bottom":t.layer<e.layer||t.layer===e.layer&&e.x>t.x+12?n==="from"?"right":"left":"bottom",zg=(t,e,n,o)=>{const i=new Map;for(const r of t){const a=e.get(r.from),d=e.get(r.to),l=n.get(r.id);if(a===void 0||d===void 0||l===void 0||a.id===d.id||l.from.side!=="right"||!(a.layer<d.layer))continue;const c=a.x+a.width,h=d.x,p=`${Math.round(c*2)}|${Math.round(h*2)}`,u=i.get(p)??{low:c,high:h,members:[]};u.members.push({id:r.id,point:l.from.point,end:l.to.point}),i.set(p,u)}const s=new Map;for(const r of i.values()){const a=Math.min(_g,(r.high-r.low)/2),d=r.low+a,l=r.high-a,c=[...r.members].sort((m,x)=>m.point.y-x.point.y||m.id.localeCompare(x.id)),h=m=>m.map((x,k)=>ps(d,l,m.length,k,o.laneGap)),p=(m,x)=>At([m.point,{x,y:m.point.y},{x,y:m.end.y},m.end]),u=m=>{const x=h(m);let k=0;for(let w=0;w<m.length;w++){const $=p(m[w],x[w]);for(let L=w+1;L<m.length;L++)k+=no($,Yo(p(m[L],x[L])))}return k};let g=[...c],b=g.length>Ng?Number.POSITIVE_INFINITY:u(g);if(Number.isFinite(b))for(let m=0;m<Og&&b>0;m++)for(let x=0;x+1<g.length;x++){const k=[...g],w=k[x];k[x]=k[x+1],k[x+1]=w;const $=u(k);$<b&&(b=$,g=k)}const f=h(g);g.forEach((m,x)=>s.set(m.id,f[x]))}return s},Pg=(t,e,n={})=>{const o={...Cg,...n},i=new Map(t.nodes.map(w=>[w.id,w])),s=e.filter(w=>i.has(w.from)&&i.has(w.to));if(s.length===0)return t;const r=hs(t.nodes,s,{inset:Lg,gap:o.portGap,sideOf:({edge:w,end:$})=>{const L=i.get(w.from),S=i.get(w.to);return L!==void 0&&S!==void 0?Dg(L,S,$):"right"}}),a=zg(s,i,r,o),d=new Map(t.routes.map(w=>[w.id,w.points])),l=new Map(t.nodes.map(w=>[w.id,Ca(w)])),c=(w,$)=>t.nodes.filter(L=>L.id!==w.id&&L.id!==$.id).map(Ca),h=w=>{const $=i.get(w.from),L=i.get(w.to);return $===void 0||L===void 0?0:Math.abs(L.x-$.x)+Math.abs(L.y-$.y)},p=[...s].sort((w,$)=>h(w)-h($)||w.id.localeCompare($.id));let u=0;const g=[],b=new Map;for(const w of p){const $=i.get(w.from),L=i.get(w.to),S=r.get(w.id),T=d.get(w.id)??[];if($===void 0||L===void 0||S===void 0){b.set(w.id,T),g.push(...Yo(T));continue}const E=S.from.point,R=S.to.point,A=[l.get($.id),l.get(L.id)],N=c($,L),U=(()=>{if($.id===L.id){const ne=$.x+$.width;return At([E,{x:ne+Tn,y:E.y},{x:ne+Tn,y:R.y+Tn},{x:R.x,y:R.y+Tn},R])}if(S.from.side==="bottom"){const ne=Math.max(E.y,R.y)+Rg+u*Ag;return u+=1,At([E,{x:E.x,y:ne},{x:R.x,y:ne},R])}const q=a.get(w.id)??(E.x+R.x)/2,ee=At([E,{x:q,y:E.y},{x:q,y:R.y},R]);if(!Ho(ee,N))return ee;const Q=Ia(S.from.side),G=Ia(S.to.side),Z=so({x:E.x+Q.x*Sn,y:E.y+Q.y*Sn},{x:R.x+G.x*Sn,y:R.y+G.y*Sn},N,o.margin,g,[...A,...N],A);return At([E,...Z,R])})(),H=Ho(U,N)&&!Ho(T,N)?T:U;b.set(w.id,H),g.push(...Yo(H))}const f=s.map(w=>{const $=i.get(w.from),L=i.get(w.to),S=$!==void 0&&L!==void 0?[l.get($.id),l.get(L.id)]:[];return{id:w.id,points:b.get(w.id)??[],obstacles:$!==void 0&&L!==void 0?c($,L):[],ownFrames:S}}),m=ao(f,{minPortRun:0}),x=s.map(w=>({id:w.id,points:m.get(w.id)??b.get(w.id)??[]})),k=[...x.flatMap(w=>w.points),...t.nodes.map(w=>({x:w.x+w.width,y:w.y+w.height}))];return{...t,width:Math.max(t.width,...k.map(w=>w.x)),height:Math.max(t.height,...k.map(w=>w.y)),routes:[...t.routes.filter(w=>!s.some($=>$.id===w.id)),...x]}},qg=ae`
5369
+ `}}const qa=()=>{customElements.get("dpk-board-sequence-diagram")||customElements.define("dpk-board-sequence-diagram",Pa)},Mn=pe({en:{heading:"State diagram",node:"State",edge:"Transition",empty:"No matching transitions.",transitionLabel:(t,e,n)=>`${n} from ${t} to ${e}`},ja:{heading:"\u30B9\u30C6\u30FC\u30C8\u56F3",node:"\u72B6\u614B",edge:"\u9077\u79FB",empty:"\u8A72\u5F53\u3059\u308B\u9077\u79FB\u306F\u3042\u308A\u307E\u305B\u3093\u3002",transitionLabel:(t,e,n)=>`${t} \u304B\u3089 ${e} \u3078\u306E ${n}`}}),Qg=P({x:ce(),y:ce()}),Zg=P({id:S(x(),I(1)),name:S(x(),I(1)),code:L(x()),kind:L(G(["normal","initial","terminal","compensation"]),"normal"),description:L(x()),position:L(Qg),questions:L(x())}),Jg=P({id:S(x(),I(1)),from:S(x(),I(1)),to:S(x(),I(1)),title:S(x(),I(1)),kind:L(G(["normal","exception"]),"normal"),tags:L(F(x()),[]),guard:L(x()),effect:L(x()),questions:L(x())}),Fa={width:178,height:86},ef=()=>({nodes:[],edges:[]}),tf=P({states:F(Zg),transitions:L(F(Jg),[])}),nf=t=>{const e=ue(tf,t),n=new Set;for(const r of e.states){if(n.has(r.id))throw new Error(`duplicate state id: ${r.id}`);n.add(r.id)}const o=new Set,i=e.transitions.map(r=>{if(o.has(r.id))throw new Error(`duplicate transition id: ${r.id}`);if(o.add(r.id),!n.has(r.from))throw new Error(`unknown transition source: ${r.from}`);if(!n.has(r.to))throw new Error(`unknown transition target: ${r.to}`);return{id:r.id,from:r.from,to:r.to,title:r.title,kind:r.kind,tags:r.tags,guard:r.guard??null,effect:r.effect??null,...r.questions===void 0?{}:{questions:r.questions}}});return{nodes:e.states.map(r=>({id:r.id,name:r.name,code:r.code??null,kind:r.kind,description:r.description??null,width:Fa.width,height:Fa.height,tags:[],...r.position===void 0?{}:{position:r.position},...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},of=t=>t.length>0&&t.every(e=>e.position!==void 0),sf={portGap:16,laneGap:10,margin:12},rf=12,af=14,df=18,lf=14,Cn=22,Ln=18,cf=4,pf=10,Ua=t=>{switch(t){case"left":return{x:-1,y:0};case"right":return{x:1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}},Ba=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),jo=(t,e)=>t.slice(1).some((n,o)=>{const i=t[o];return i===void 0?!1:i.x===n.x?ge(i.x,Math.min(i.y,n.y),Math.max(i.y,n.y),e):fe(i.y,Math.min(i.x,n.x),Math.max(i.x,n.x),e)}),Ot=t=>{const e=[];for(const n of t){const o=e.at(-2),i=e.at(-1);if(o!==void 0&&i!==void 0&&o.x===i.x&&i.x===n.x){e[e.length-1]=n;continue}if(o!==void 0&&i!==void 0&&o.y===i.y&&i.y===n.y){e[e.length-1]=n;continue}i!==void 0&&i.x===n.x&&i.y===n.y||e.push(n)}return e},Wo=t=>t.slice(1).map((e,n)=>[t[n],e]),hf=(t,e,n)=>t.id===e.id?n==="from"?"right":"bottom":t.layer<e.layer||t.layer===e.layer&&e.x>t.x+12?n==="from"?"right":"left":"bottom",uf=(t,e,n,o)=>{const i=new Map;for(const r of t){const a=e.get(r.from),d=e.get(r.to),l=n.get(r.id);if(a===void 0||d===void 0||l===void 0||a.id===d.id||l.from.side!=="right"||!(a.layer<d.layer))continue;const c=a.x+a.width,h=d.x,p=`${Math.round(c*2)}|${Math.round(h*2)}`,u=i.get(p)??{low:c,high:h,members:[]};u.members.push({id:r.id,point:l.from.point,end:l.to.point}),i.set(p,u)}const s=new Map;for(const r of i.values()){const a=Math.min(af,(r.high-r.low)/2),d=r.low+a,l=r.high-a,c=[...r.members].sort((m,y)=>m.point.y-y.point.y||m.id.localeCompare(y.id)),h=m=>m.map((y,v)=>xs(d,l,m.length,v,o.laneGap)),p=(m,y)=>Ot([m.point,{x:y,y:m.point.y},{x:y,y:m.end.y},m.end]),u=m=>{const y=h(m);let v=0;for(let w=0;w<m.length;w++){const $=p(m[w],y[w]);for(let A=w+1;A<m.length;A++)v+=ro($,Wo(p(m[A],y[A])))}return v};let g=[...c],b=g.length>pf?Number.POSITIVE_INFINITY:u(g);if(Number.isFinite(b))for(let m=0;m<cf&&b>0;m++)for(let y=0;y+1<g.length;y++){const v=[...g],w=v[y];v[y]=v[y+1],v[y+1]=w;const $=u(v);$<b&&(b=$,g=v)}const f=h(g);g.forEach((m,y)=>s.set(m.id,f[y]))}return s},mf=(t,e,n={})=>{const o={...sf,...n},i=new Map(t.nodes.map(w=>[w.id,w])),s=e.filter(w=>i.has(w.from)&&i.has(w.to));if(s.length===0)return t;const r=ys(t.nodes,s,{inset:rf,gap:o.portGap,sideOf:({edge:w,end:$})=>{const A=i.get(w.from),C=i.get(w.to);return A!==void 0&&C!==void 0?hf(A,C,$):"right"}}),a=uf(s,i,r,o),d=new Map(t.routes.map(w=>[w.id,w.points])),l=new Map(t.nodes.map(w=>[w.id,Ba(w)])),c=(w,$)=>t.nodes.filter(A=>A.id!==w.id&&A.id!==$.id).map(Ba),h=w=>{const $=i.get(w.from),A=i.get(w.to);return $===void 0||A===void 0?0:Math.abs(A.x-$.x)+Math.abs(A.y-$.y)},p=[...s].sort((w,$)=>h(w)-h($)||w.id.localeCompare($.id));let u=0;const g=[],b=new Map;for(const w of p){const $=i.get(w.from),A=i.get(w.to),C=r.get(w.id),M=d.get(w.id)??[];if($===void 0||A===void 0||C===void 0){b.set(w.id,M),g.push(...Wo(M));continue}const E=C.from.point,R=C.to.point,D=[l.get($.id),l.get(A.id)],O=c($,A),B=(()=>{if($.id===A.id){const ne=$.x+$.width;return Ot([E,{x:ne+Cn,y:E.y},{x:ne+Cn,y:R.y+Cn},{x:R.x,y:R.y+Cn},R])}if(C.from.side==="bottom"){const ne=Math.max(E.y,R.y)+df+u*lf;return u+=1,Ot([E,{x:E.x,y:ne},{x:R.x,y:ne},R])}const q=a.get(w.id)??(E.x+R.x)/2,ee=Ot([E,{x:q,y:E.y},{x:q,y:R.y},R]);if(!jo(ee,O))return ee;const Q=Ua(C.from.side),X=Ua(C.to.side),Z=co({x:E.x+Q.x*Ln,y:E.y+Q.y*Ln},{x:R.x+X.x*Ln,y:R.y+X.y*Ln},O,o.margin,g,[...D,...O],D);return Ot([E,...Z,R])})(),H=jo(B,O)&&!jo(M,O)?M:B;b.set(w.id,H),g.push(...Wo(H))}const f=s.map(w=>{const $=i.get(w.from),A=i.get(w.to),C=$!==void 0&&A!==void 0?[l.get($.id),l.get(A.id)]:[];return{id:w.id,points:b.get(w.id)??[],obstacles:$!==void 0&&A!==void 0?c($,A):[],ownFrames:C}}),m=ho(f,{minPortRun:0}),y=s.map(w=>({id:w.id,points:m.get(w.id)??b.get(w.id)??[]})),v=[...y.flatMap(w=>w.points),...t.nodes.map(w=>({x:w.x+w.width,y:w.y+w.height}))];return{...t,width:Math.max(t.width,...v.map(w=>w.x)),height:Math.max(t.height,...v.map(w=>w.y)),routes:[...t.routes.filter(w=>!s.some($=>$.id===w.id)),...y]}},gf=de`
4996
5370
  .state-node {
4997
5371
  display: flex;
4998
5372
  flex-direction: column;
@@ -5150,19 +5524,19 @@ ${o.renameContextHint}`}
5150
5524
  fill: var(--dpk-amber);
5151
5525
  stroke: var(--dpk-amber);
5152
5526
  }
5153
- `,Fg=[{id:"state-arrow"},{id:"state-arrow-active"},{id:"state-arrow-exception"}];class La extends nt{static{this.styles=[De,qg]}parseData(e){return Mg(e)}emptyData(){return Tg()}defaultHeading(){return En(this.locale).heading}statsLabels(){const e=En(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return En(this.locale).empty}get tagDimension(){return"edge"}get layoutMode(){return Ig(this.filtered().nodes)?"fixed":"layered"}layoutOptions(){return this.layoutMode==="fixed"?{padding:44}:{nodeSpacing:40,layerSpacing:110,padding:44}}routePlacement(e,n){return Pg(e,n.edges)}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)} \xB7 ${o.title}`}))]}renderCanvas(){const e=this.visible.nodes,n=e.filter(o=>o.kind==="initial").map(o=>this.#e(o));return v`
5154
- ${this.renderEdges([...n,...this.visible.edges.map(o=>this.#n(o))],Fg)}
5155
- ${e.map(o=>this.#t(o))} ${this.visible.edges.map(o=>this.#a(o))}
5527
+ `,ff=[{id:"state-arrow"},{id:"state-arrow-active"},{id:"state-arrow-exception"}];class Ha extends rt{static{this.styles=[ze,gf]}parseData(e){return nf(e)}emptyData(){return ef()}defaultHeading(){return Mn(this.locale).heading}statsLabels(){const e=Mn(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return Mn(this.locale).empty}get tagDimension(){return"edge"}get layoutMode(){return of(this.filtered().nodes)?"fixed":"layered"}layoutOptions(){return this.layoutMode==="fixed"?{padding:44}:{nodeSpacing:40,layerSpacing:110,padding:44}}routePlacement(e,n){return mf(e,n.edges)}relations(e,n){if(e===null||e.kind!=="node")return Ie;const o=we(n.edges,e.id,"outgoing",!1),i=we(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)} \xB7 ${o.title}`}))]}renderCanvas(){const e=this.visible.nodes,n=e.filter(o=>o.kind==="initial").map(o=>this.#e(o));return k`
5528
+ ${this.renderEdges([...n,...this.visible.edges.map(o=>this.#t(o))],ff)}
5529
+ ${e.map(o=>this.#n(o))} ${this.visible.edges.map(o=>this.#a(o))}
5156
5530
  `}#o(e){return this.filtered().nodes.find(n=>n.id===e)?.name??e}#i(e){return[e.guard,e.effect].filter(n=>n!==null).join(`
5157
- `)||e.title}#e(e){const n=this.placedNode(e.id);if(!n)return M;const o=n.y+n.height/2,i=this.nodeState(e.id);return Y`
5158
- <g class=${ye("state-initial-mark",i.dimmed&&"is-dimmed")}>
5531
+ `)||e.title}#e(e){const n=this.placedNode(e.id);if(!n)return T;const o=n.y+n.height/2,i=this.nodeState(e.id);return Y`
5532
+ <g class=${ve("state-initial-mark",i.dimmed&&"is-dimmed")}>
5159
5533
  <circle cx=${n.x-22} cy=${o} r="5"></circle>
5160
5534
  <path
5161
- d=${en([{x:n.x-17,y:o},{x:n.x-1,y:o}])}
5535
+ d=${nn([{x:n.x-17,y:o},{x:n.x-1,y:o}])}
5162
5536
  stroke-width="1.6"
5163
5537
  ></path>
5164
5538
  </g>
5165
- `}#n(e){const n=En(this.locale),o=this.edgeState(e.id),i=this.routeOf(e.id),s=en(i),a=o.selected||o.related?"state-arrow-active":e.kind==="exception"?"state-arrow-exception":"state-arrow",d=()=>this.select({kind:"edge",id:e.id});return Y`
5539
+ `}#t(e){const n=Mn(this.locale),o=this.edgeState(e.id),i=this.routeOf(e.id),s=nn(i),a=o.selected||o.related?"state-arrow-active":e.kind==="exception"?"state-arrow-exception":"state-arrow",d=()=>this.select({kind:"edge",id:e.id});return Y`
5166
5540
  <g
5167
5541
  class=${this.elementClass(o,"d-edge","state-edge",e.kind==="exception"&&"is-exception")}
5168
5542
  data-transition=${e.id}
@@ -5179,7 +5553,7 @@ ${o.renameContextHint}`}
5179
5553
  @keydown=${l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),d())}}
5180
5554
  ></path>
5181
5555
  </g>
5182
- `}#t(e){const n=this.placedNode(e.id);if(!n)return M;const o=this.nodeState(e.id);return v`
5556
+ `}#n(e){const n=this.placedNode(e.id);if(!n)return T;const o=this.nodeState(e.id);return k`
5183
5557
  <button
5184
5558
  type="button"
5185
5559
  class=${this.elementClass(o,"d-node","state-node",`is-${e.kind}`,this.isDraggingNode(e.id)&&"is-dragging")}
@@ -5193,9 +5567,9 @@ ${o.renameContextHint}`}
5193
5567
  @click=${()=>{this.consumeDragClick()||this.select({kind:"node",id:e.id})}}
5194
5568
  >
5195
5569
  <span class="state-name">${e.name}</span>
5196
- ${e.code===null?M:v`<span class="state-code">${e.code}</span>`}
5570
+ ${e.code===null?T:k`<span class="state-code">${e.code}</span>`}
5197
5571
  </button>
5198
- `}#a(e){const n=this.edgeState(e.id),o=el(this.routeOf(e.id));return v`
5572
+ `}#a(e){const n=this.edgeState(e.id),o=ul(this.routeOf(e.id));return k`
5199
5573
  <span class="state-label-slot" style="left:${o.x}px; top:${o.y}px">
5200
5574
  <button
5201
5575
  type="button"
@@ -5210,13 +5584,13 @@ ${o.renameContextHint}`}
5210
5584
  ${e.title}
5211
5585
  </button>
5212
5586
  </span>
5213
- `}}const _a=()=>{customElements.get("dpk-board-state-diagram")||customElements.define("dpk-board-state-diagram",La)},Xo=["yellow","orange","pink","purple","blue","green","gray"],Bg=["rect","ellipse"],Go=["small","medium","large","xlarge"],Mn="medium",Ra=["arrow","line"],In=["straight","elbow","curve"],Cn=24,He={sticky:{w:160,h:160},text:{w:240,h:48},shape:{w:180,h:110},frame:{w:640,h:420}},pt={sticky:"yellow",shape:"blue",frame:"gray"},Aa=I(le(),Yt()),Ye=I(le(),Yt(),Ht(Cn)),Ko=X(Xo),jo=C(X(Go),Mn),Ln={id:oe,x:Aa,y:Aa,questions:Ze},Ug=P({...Ln,kind:pe("sticky"),w:C(Ye,He.sticky.w),h:C(Ye,He.sticky.h),text:C(y(),""),color:C(Ko,pt.sticky),fontSize:jo}),Hg=P({...Ln,kind:pe("text"),w:C(Ye,He.text.w),h:C(Ye,He.text.h),text:C(y(),""),fontSize:jo}),Yg=P({...Ln,kind:pe("shape"),shape:C(X(Bg),"rect"),w:C(Ye,He.shape.w),h:C(Ye,He.shape.h),text:C(y(),""),color:C(Ko,pt.shape),fontSize:jo}),Xg=P({...Ln,kind:pe("frame"),w:Ye,h:Ye,title:I(y(),_(1)),color:C(Ko,pt.frame)}),Oa=Bn("kind",[Ug,Hg,Yg,Xg]),Gg=P({id:oe,from:I(y(),_(1)),to:I(y(),_(1)),label:W(y()),style:C(X(Ra),"arrow"),route:C(X(In),"straight")}),Kg=P({title:W(y()),items:C(F(Oa),[]),connectors:C(F(Gg),[])}),jg=t=>{const e=he(Kg,t),n=new Set;for(const{id:i}of[...e.items,...e.connectors]){if(n.has(i))throw new Error(`duplicate id "${i}" (items and connectors share one id space)`);n.add(i)}const o=new Set(e.items.map(i=>i.id));for(const i of e.connectors){if(!o.has(i.from))throw new Error(`unknown item "${i.from}" in connector "${i.id}"`);if(!o.has(i.to))throw new Error(`unknown item "${i.to}" in connector "${i.id}"`);if(i.from===i.to)throw new Error(`connector "${i.id}" connects an item to itself`)}return e},Wg=()=>({items:[],connectors:[]}),j=(t,e)=>{if(e!==void 0)return t.items.find(n=>n.id===e)},be=(t,e)=>{if(e!==void 0)return t.connectors.find(n=>n.id===e)},Wo=t=>[...t.items.map(e=>e.id),...t.connectors.map(e=>e.id)],We=t=>t.kind==="frame"?t.title:t.text,_n=t=>t.kind!=="text",Ot=t=>t.kind!=="frame",Rn=t=>t.w*t.h,Vg=(t,e,n)=>e>=t.x&&e<=t.x+t.w&&n>=t.y&&n<=t.y+t.h,Nt=(t,e)=>{const n=e.x+e.w/2,o=e.y+e.h/2;let i;for(const s of t.items)s.kind!=="frame"||s.id===e.id||e.kind==="frame"&&Rn(s)<=Rn(e)||Vg(s,n,o)&&(i===void 0||Rn(s)<Rn(i))&&(i=s);return i},Qg=(t,e)=>{const n=[],o=i=>{let s=Nt(t,i);for(;s!==void 0;){if(s.id===e.id)return!0;s=Nt(t,s)}return!1};for(const i of t.items)i.id!==e.id&&o(i)&&n.push(i);return n},Na=I(le(),Yt()),Da=I(le(),Yt(),Ht(Cn)),za={type:"page",id:"whiteboard"},Vo={ADD_ITEM:z("ADD_ITEM","page",Oa,{dedupeKey:Se}),SET_ITEM_TEXT:z("SET_ITEM_TEXT","item",O({text:y()})),MOVE_ITEM:z("MOVE_ITEM","item",O({x:Na,y:Na})),RESIZE_ITEM:z("RESIZE_ITEM","item",O({w:Da,h:Da})),SET_ITEM_COLOR:z("SET_ITEM_COLOR","item",O({color:X(Xo)})),SET_ITEM_FONT_SIZE:z("SET_ITEM_FONT_SIZE","item",O({fontSize:X(Go)})),REORDER_ITEM:z("REORDER_ITEM","item",O({after:ue(I(y(),_(1)))})),DELETE_ITEM:z("DELETE_ITEM","item",O({})),CONNECT_ITEMS:z("CONNECT_ITEMS","page",O({id:oe,from:I(y(),_(1)),to:I(y(),_(1)),label:W(y()),style:W(X(Ra)),route:W(X(In))}),{dedupeKey:Se}),SET_CONNECTOR_LABEL:z("SET_CONNECTOR_LABEL","connector",O({label:y()})),SET_CONNECTOR_ROUTE:z("SET_CONNECTOR_ROUTE","connector",O({route:X(In)})),DELETE_CONNECTOR:z("DELETE_CONNECTOR","connector",O({}))},Ve=t=>({type:"item",id:t}),re={addItem:t=>({type:"ADD_ITEM",target:za,payload:t}),setText:(t,e)=>({type:"SET_ITEM_TEXT",target:Ve(t),payload:{text:e}}),move:(t,e,n)=>({type:"MOVE_ITEM",target:Ve(t),payload:{x:e,y:n}}),resize:(t,e,n)=>({type:"RESIZE_ITEM",target:Ve(t),payload:{w:e,h:n}}),setColor:(t,e)=>({type:"SET_ITEM_COLOR",target:Ve(t),payload:{color:e}}),setFontSize:(t,e)=>({type:"SET_ITEM_FONT_SIZE",target:Ve(t),payload:{fontSize:e}}),reorder:(t,e)=>({type:"REORDER_ITEM",target:Ve(t),payload:{after:e}}),deleteItem:t=>({type:"DELETE_ITEM",target:Ve(t),payload:{}}),connect:(t,e,n,o)=>({type:"CONNECT_ITEMS",target:za,payload:{id:t,from:e,to:n,...o===void 0?{}:{label:o}}}),setConnectorLabel:(t,e)=>({type:"SET_CONNECTOR_LABEL",target:{type:"connector",id:t},payload:{label:e}}),setConnectorRoute:(t,e)=>({type:"SET_CONNECTOR_ROUTE",target:{type:"connector",id:t},payload:{route:e}}),deleteConnector:t=>({type:"DELETE_CONNECTOR",target:{type:"connector",id:t},payload:{}})},An=t=>{if(t.length===0)return null;const e=Math.min(...t.map(s=>s.x)),n=Math.min(...t.map(s=>s.y)),o=Math.max(...t.map(s=>s.x+s.w)),i=Math.max(...t.map(s=>s.y+s.h));return{x:e,y:n,w:o-e,h:i-n}},Pa=t=>[...t.items.filter(e=>e.kind==="frame"),...t.items.filter(e=>e.kind!=="frame")],Zg=t=>t.kind==="shape"&&t.shape==="ellipse",On=(t,e)=>{const n=t.x+t.w/2,o=t.y+t.h/2,i=e.x-n,s=e.y-o;if(i===0&&s===0)return{x:n,y:o};const r=t.w/2,a=t.h/2,d=Zg(t)?1/Math.sqrt((i/r)**2+(s/a)**2):Math.min(i===0?1/0:r/Math.abs(i),s===0?1/0:a/Math.abs(s));return{x:n+i*d,y:o+s*d}},ht=t=>({x:t.x+t.w/2,y:t.y+t.h/2}),Jg=(t,e)=>{const n=On(t,ht(e)),o=On(e,ht(t));return{start:n,end:o,mid:{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}},$e=t=>`${t.x} ${t.y}`,Qo=(t,e,n)=>{if(n==="straight"){const{start:g,end:b,mid:f}=Jg(t,e);return{d:`M ${$e(g)} L ${$e(b)}`,mid:f}}const o=ht(t),i=ht(e),s=Math.abs(i.x-o.x)>=Math.abs(i.y-o.y),r=s?i.x>=o.x:i.y>=o.y,a=(g,b)=>{const f=ht(g);return s?{x:b?g.x+g.w:g.x,y:f.y}:{x:f.x,y:b?g.y+g.h:g.y}},d=a(t,r),l=a(e,!r),c={x:(d.x+l.x)/2,y:(d.y+l.y)/2},h=s?{x:c.x,y:d.y}:{x:d.x,y:c.y},p=s?{x:c.x,y:l.y}:{x:l.x,y:c.y};return{d:n==="elbow"?`M ${$e(d)} L ${$e(h)} L ${$e(p)} L ${$e(l)}`:`M ${$e(d)} C ${$e(h)} ${$e(p)} ${$e(l)}`,mid:c}},Zo=(t,e)=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h,ef=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,tf=(t,e)=>t.items.filter(n=>n.kind==="frame"&&Zo(n,e)).sort((n,o)=>n.w*n.h-o.w*o.h),qa=(t,e,n)=>{const o=Pa(t);for(let s=o.length-1;s>=0;s-=1){const r=o[s];if(!(r===void 0||r.id===n||r.kind==="frame")&&Zo(r,e))return r}let i;for(const s of o)s.kind!=="frame"||s.id===n||!Zo(s,e)||(i===void 0||s.w*s.h<i.w*i.h)&&(i=s);return i},nf=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}),of=(t,e)=>e.x>=t.x&&e.y>=t.y&&e.x+e.w<=t.x+t.w&&e.y+e.h<=t.y+t.h,sf=(t,e)=>t.items.filter(n=>n.kind==="frame"?of(e,n):Nn(e,n,0)),Nn=(t,e,n)=>t.x<e.x+e.w+n&&e.x<t.x+t.w+n&&t.y<e.y+e.h+n&&e.y<t.y+t.h+n,rf=(t,e,n=!1,o=16,i=6)=>{const s=n?t.items:t.items.filter(l=>l.kind!=="frame"),r=l=>!s.some(c=>Nn(l,c,o));if(r(e))return{x:e.x,y:e.y};const a=e.w+o,d=e.h+o;for(let l=1;l<=i;l+=1){const c=[];for(let p=-l;p<=l;p+=1)for(let u=-l;u<=l;u+=1)Math.max(Math.abs(u),Math.abs(p))===l&&c.push({x:e.x+u*a,y:e.y+p*d});c.sort((p,u)=>Math.hypot(p.x-e.x,p.y-e.y)-Math.hypot(u.x-e.x,u.y-e.y));const h=c.find(p=>r({...e,...p}));if(h!==void 0)return h}return{x:e.x,y:e.y}},Fa=["front","forward","backward","back"],Ba=t=>t.items.filter(e=>e.kind!=="frame"),Ua=(t,e,n,o)=>{const i=t.indexOf(e),s=(o?t.slice(i+1):t.slice(0,i).reverse()).filter(l=>!n.has(l.id)),r=s.find(l=>Nn(e,l,0))??s[0];if(r===void 0)return t;const a=t.filter(l=>l!==e),d=a.indexOf(r)+(o?1:0);return[...a.slice(0,d),e,...a.slice(d)]},Ha=(t,e,n)=>{const o=t.filter(s=>e.has(s.id)),i=t.filter(s=>!e.has(s.id));switch(n){case"front":return[...i,...o];case"back":return[...o,...i];case"forward":return[...o].reverse().reduce((s,r)=>Ua(s,r,e,!0),[...t]);case"backward":return o.reduce((s,r)=>Ua(s,r,e,!1),[...t])}},af=(t,e,n)=>{let o=t.map(s=>s.id);const i=[];return e.forEach((s,r)=>{if(!n.has(s.id))return;const a=e[r-1]?.id??null,d=o.indexOf(s.id);(o[d-1]??null)!==a&&(o=o.filter(l=>l!==s.id),o.splice(a===null?0:o.indexOf(a)+1,0,s.id),i.push(re.reorder(s.id,a)))}),i},df=(t,e,n)=>{const o=Ba(t),i=new Set(e.filter(s=>o.some(r=>r.id===s)));return i.size===0?[]:af(o,Ha(o,i,n),i)},lf=(t,e)=>{const n=Ba(t),o=new Set(e.filter(r=>n.some(a=>a.id===r))),i=n.flatMap(r=>o.has(r.id)?n.filter(a=>!o.has(a.id)&&Nn(r,a,0)).map(a=>[r,a]):[]),s=(r,[a,d])=>r.indexOf(a)>r.indexOf(d);return new Set(Fa.filter(r=>{const a=Ha(n,o,r);return i.some(d=>s(n,d)!==s(a,d))}))},Ya=(t,e,n)=>{if(!t.contains(e)||e.nodeType!==Node.TEXT_NODE)return;let o=0;const i=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let s=i.nextNode();s!==null;s=i.nextNode()){if(s===e)return o+n;o+=s.textContent?.length??0}},cf=(t,e,n)=>{const o=t.getRootNode(),i=t.ownerDocument;if(typeof i.caretPositionFromPoint=="function"){const s=o instanceof ShadowRoot?[o]:[],r=i.caretPositionFromPoint(e,n,{shadowRoots:s});if(r!==null)return Ya(t,r.offsetNode,r.offset)}if(typeof i.caretRangeFromPoint=="function"){const s=i.caretRangeFromPoint(e,n);if(s!==null)return Ya(t,s.startContainer,s.startOffset)}},pf=["sticky","text","rect","ellipse","frame"],hf=t=>t==="rect"||t==="ellipse"?He.shape:He[t],uf=(t,e,n,o)=>{const{w:i,h:s}=hf(n),r={x:Math.round(o.x-i/2),y:Math.round(o.y-s/2)},a=rf(t,{...r,w:i,h:s},n==="frame"),c={id:xe(`new-${n==="rect"||n==="ellipse"?"shape":n}`,Wo(t)),x:a.x,y:a.y,w:i,h:s};switch(n){case"sticky":return{...c,kind:"sticky",text:"",color:pt.sticky,fontSize:Mn};case"text":return{...c,kind:"text",text:"",fontSize:Mn};case"rect":case"ellipse":return{...c,kind:"shape",shape:n,text:"",color:pt.shape,fontSize:Mn};case"frame":return{...c,kind:"frame",title:e.newFrameTitle,color:pt.frame}}},mf=(t,e,n)=>xe(`${e}-to-${n}`,Wo(t)),gf=24,ff=(t,e,n)=>{const o=new Set(Wo(t));return e.map(i=>{const s=i.kind==="shape"?"shape":i.kind,r=xe(`new-${s}`,o);return o.add(r),{...i,id:r,x:i.x+n,y:i.y+n}})},bf=(t,e)=>{const n=(t.kind==="frame"?e.replace(/\r?\n/g," "):e).trim();if(!(t.kind==="frame"&&n===""))return n===We(t)?void 0:n},Dn=4,xf={n:{x:0,y:-1},s:{x:0,y:1},e:{x:1,y:0},w:{x:-1,y:0},ne:{x:1,y:-1},se:{x:1,y:1},sw:{x:-1,y:1},nw:{x:-1,y:-1}},Jo=(t,e,n,o,i=[e])=>{if(j(t,e)===void 0)return;const s=new Map;for(const r of i.includes(e)?i:[e,...i]){const a=j(t,r);if(a!==void 0)for(const d of a.kind==="frame"?[a,...Qg(t,a)]:[a])s.set(d.id,d)}return{kind:"move",pointerId:n,itemId:e,origins:[...s.values()].map(({id:r,x:a,y:d})=>({id:r,x:a,y:d})),start:o,current:o,moved:!1}},yf=(t,e,n,o,i="se")=>{const s=j(t,e);if(s!==void 0)return{kind:"resize",pointerId:n,itemId:e,origin:{x:s.x,y:s.y,w:s.w,h:s.h},edge:i,start:o,current:o,moved:!1,keepRatio:!1}},vf=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),kf=(t,e)=>({gesture:{...t,last:e,moved:t.moved||Math.hypot(e.x-t.start.x,e.y-t.start.y)>Dn},dx:e.x-t.last.x,dy:e.y-t.last.y}),Xa=(t,e,n)=>({kind:"marquee",pointerId:t,base:n,start:e,current:e,moved:!1}),wf=(t,e,n,o,i)=>{const s=tf(t,o).find(a=>e.includes(a.id));return(s===void 0?void 0:Jo(t,s.id,n,o,e))??Xa(n,o,i)},Ga=t=>t?.kind==="marquee"&&t.moved?nf(t.start,t.current):void 0,Ka=(t,e)=>{const n=Ga(e);if(e.kind!=="marquee"||n===void 0)return[];const o=sf(t,n).map(i=>i.id);return[...new Set([...e.base,...o])]},$f=(t,e,n)=>({kind:"connect",pointerId:e,fromId:t,start:n,current:n,moved:!1}),ei=(t,e,n,o,i,s=!1)=>{if(e.pointerId!==n)return e;switch(e.kind){case"pan":return e;case"marquee":case"move":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>Dn;return{...e,current:o,moved:r}}case"resize":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>Dn;return{...e,current:o,moved:r,keepRatio:s}}case"connect":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>Dn,a=qa(t,o,e.fromId),{targetId:d,...l}=e;return a===void 0?{...l,current:o,moved:r}:{...l,current:o,moved:r,targetId:a.id}}}},Dt=t=>Math.round(t),ja=(t,e)=>{if(e===void 0||!e.moved)return t;if(e.kind==="move"){const n=e.current.x-e.start.x,o=e.current.y-e.start.y,i=new Map(e.origins.map(s=>[s.id,s]));return{...t,items:t.items.map(s=>{const r=i.get(s.id);return r===void 0?s:{...s,x:Dt(r.x+n),y:Dt(r.y+o)}})}}if(e.kind==="resize"){const n=Va(e);return{...t,items:t.items.map(o=>o.id===e.itemId?{...o,...n}:o)}}return t},Wa=t=>Math.max(Cn,Dt(t)),Ef=(t,e,n)=>{const o=Math.max(e===void 0?0:e/t.w,n===void 0?0:n/t.h,Cn/Math.min(t.w,t.h));return{w:Dt(t.w*o),h:Dt(t.h*o)}},Va=t=>{const{origin:e,edge:n}=t,o=xf[n],i=(t.current.x-t.start.x)*o.x,s=(t.current.y-t.start.y)*o.y,r=o.x===0?void 0:e.w+i,a=o.y===0?void 0:e.h+s,d=t.keepRatio?Ef(e,r,a):{w:r===void 0?e.w:Wa(r),h:a===void 0?e.h:Wa(a)};return{...d,x:o.x<0?e.x+e.w-d.w:e.x,y:o.y<0?e.y+e.h-d.h:e.y}},Tf=(t,e,n,o)=>{const[i]=e;if(i===void 0)return[];const s=Jo(t,i,0,{x:0,y:0},e);if(s?.kind!=="move")return[];const r=Qa(t,{...s,current:{x:n,y:o},moved:!0});return r.kind==="dispatch"?r.inputs:[]},Qa=(t,e)=>{switch(e.kind){case"pan":return e.moved?{kind:"none"}:{kind:"click"};case"marquee":{if(e.moved)return{kind:"select",ids:Ka(t,e)};const n=qa(t,e.start);return n===void 0?{kind:"click"}:{kind:"click",itemId:n.id}}case"move":{if(!e.moved)return{kind:"click",itemId:e.itemId};const n=ja(t,e),o=e.origins.flatMap(i=>{const s=j(n,i.id);return s===void 0||s.x===i.x&&s.y===i.y?[]:[re.move(i.id,s.x,s.y)]});return o.length===0?{kind:"none"}:{kind:"dispatch",inputs:o}}case"resize":{if(!e.moved)return{kind:"click",itemId:e.itemId};const n=j(t,e.itemId);if(n===void 0)return{kind:"none"};const o=Va(e),i=[];return(o.x!==n.x||o.y!==n.y)&&i.push(re.move(n.id,o.x,o.y)),(o.w!==n.w||o.h!==n.h)&&i.push(re.resize(n.id,o.w,o.h)),i.length===0?{kind:"none"}:{kind:"dispatch",inputs:i}}case"connect":return e.moved?e.targetId===void 0?{kind:"none"}:{kind:"connect",from:e.fromId,to:e.targetId}:{kind:"click",itemId:e.fromId}}},zn=.1,Sf=2.5,Mf={x:0,y:0,zoom:1},If=96,ti=(t,e)=>({x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}),ni=(t,e)=>({x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}),oi=(t,e,n)=>({...t,x:t.x+e,y:t.y+n}),Za=(t,e,n)=>{const o=bt(t.zoom*n,zn,Sf),i=ti(t,e);return{zoom:o,x:e.x-i.x*o,y:e.y-i.y*o}},Cf=(t,e,n=48,o=1)=>{const i=Math.max(1,e.width-n*2),s=Math.max(1,e.height-n*2),r=bt(Math.min(i/Math.max(1,t.w),s/Math.max(1,t.h)),zn,o);return{zoom:r,x:e.width/2-(t.x+t.w/2)*r,y:e.height/2-(t.y+t.h/2)*r}},Lf=(t,e,n=48)=>{const o=An(t);if(o===null)return null;const i=Math.max(1,e.width-n*2)/zn,s=Math.max(1,e.height-n*2)/zn;if(o.w<=i&&o.h<=s)return o;const r=wi(t.map(l=>l.x+l.w/2)),a=wi(t.map(l=>l.y+l.h/2)),d=t.filter(l=>l.x<r+i/2&&l.x+l.w>r-i/2&&l.y<a+s/2&&l.y+l.h>a-s/2);return An(d)??o},_f=(t,e,n)=>{if(e===null||n.width<=0||n.height<=0)return t;const o=(i,s,r,a)=>{const d=Math.min(If,a/2),l=d-(s+r)*t.zoom,c=a-d-s*t.zoom;return bt(i,Math.min(l,c),Math.max(l,c))};return{zoom:t.zoom,x:o(t.x,e.x,e.w,n.width),y:o(t.y,e.y,e.h,n.height)}},Rf=(t,e,n,o=24)=>{const i=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,r=i+e.w*t.zoom,a=s+e.h*t.zoom;return i>=o&&s>=o&&r<=n.width-o&&a<=n.height-o?t:{zoom:t.zoom,x:n.width/2-(e.x+e.w/2)*t.zoom,y:n.height/2-(e.y+e.h/2)*t.zoom}},Ja=(t,e,n,o,i=0)=>{const s=t+e-(n-o),r=s>0?-s:0;return t+r<i+o?i+o-t:r},Af=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,Of={sticky:"Sticky note",text:"Text",shape:"Shape",frame:"Frame"},Re={sticky:"\u4ED8\u7B8B",text:"\u30C6\u30AD\u30B9\u30C8",shape:"\u56F3\u5F62",frame:"\u30D5\u30EC\u30FC\u30E0"},Xe={sticky:"sticky note",text:"text box",shape:"shape",frame:"frame"},Nf={rect:"Rectangle",ellipse:"Ellipse"},Df={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},zf={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},Pf={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},qf={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},Ff={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},Bf={straight:"Straight",elbow:"Elbow",curve:"Curved"},Uf={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},ed={small:"S",medium:"M",large:"L",xlarge:"XL"},zt=ce({en:{kindLabel:t=>Of[t],shapeLabel:t=>Nf[t],colorLabel:t=>zf[t],fontSizeLabel:t=>qf[t],fontSizeShort:t=>ed[t],routeLabel:t=>Bf[t],heading:"Whiteboard",connector:"Connector",board:"Board",wholeBoard:"Whole board",canvasLabel:"Whiteboard canvas",emptyHint:"Double-click anywhere to add a sticky note, or pick something from the toolbar.",toolsLabel:"Add to the board",addSticky:"Sticky note",addText:"Text",addRect:"Rectangle",addEllipse:"Ellipse",addFrame:"Frame",newFrameTitle:"New frame",textPlaceholder:"Type something",selectionLabel:"Selected item",selectionCount:t=>`${t} items selected`,editText:"Edit text",renameFrame:"Rename frame",comment:"Comment",delete:"Delete",colorLabelPrefix:"Color",fontSizeLabelPrefix:"Text size",arrangeLabel:"Stacking order",bringToFront:"Bring to front",bringForward:"Bring forward",sendBackward:"Send backward",sendToBack:"Send to back",routeLabelPrefix:"Line",labelField:"Connector label",labelPlaceholder:"Add a label",resizeHandle:"Resize",connectHandle:"Drag to connect",commentCount:t=>`${t} comment${t===1?"":"s"}`,zoomIn:"Zoom in",zoomOut:"Zoom out",zoomFit:"Fit the board",zoomReset:"Reset to 100%",addedTitle:t=>`Added a ${Xe[t]}`,textEditedTitle:t=>t==="frame"?"Renamed the frame":`Edited the ${Xe[t]}`,movedTitle:t=>`Moved the ${Xe[t]}`,resizedTitle:t=>`Resized the ${Xe[t]}`,recoloredTitle:t=>`Changed the color of the ${Xe[t]}`,resizedTextTitle:t=>`Changed the text size of the ${Xe[t]}`,restackedTitle:t=>`Changed the stacking order of the ${Xe[t]}`,deletedTitle:t=>`Deleted the ${Xe[t]}`,connectedTitle:"Connected two items",relabeledTitle:"Relabeled the connector",reroutedTitle:"Changed the connector line",disconnectedTitle:"Removed the connector",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,inFrame:t=>`in frame \u201C${t}\u201D`,intoFrame:t=>`into frame \u201C${t}\u201D`,outOfFrame:t=>`out of frame \u201C${t}\u201D`,betweenFrames:(t,e)=>`frame \u201C${t}\u201D \u2192 frame \u201C${e}\u201D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,labeled:t=>`labeled \u201C${t}\u201D`,inFrontOf:t=>`in front of \u201C${t}\u201D`,toBack:"to the very back",empty:"(empty)",noLabel:"(no label)"},ja:{kindLabel:t=>Re[t],shapeLabel:t=>Df[t],colorLabel:t=>Pf[t],fontSizeLabel:t=>Ff[t],fontSizeShort:t=>ed[t],routeLabel:t=>Uf[t],heading:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",connector:"\u30B3\u30CD\u30AF\u30BF",board:"\u30DC\u30FC\u30C9",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",canvasLabel:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",emptyHint:"\u30C0\u30D6\u30EB\u30AF\u30EA\u30C3\u30AF\u3067\u4ED8\u7B8B\u3092\u7F6E\u304F\u304B\u3001\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u8FFD\u52A0\u3057\u307E\u3059\u3002",toolsLabel:"\u30DC\u30FC\u30C9\u306B\u8FFD\u52A0",addSticky:"\u4ED8\u7B8B",addText:"\u30C6\u30AD\u30B9\u30C8",addRect:"\u56DB\u89D2\u5F62",addEllipse:"\u6955\u5186",addFrame:"\u30D5\u30EC\u30FC\u30E0",newFrameTitle:"\u65B0\u3057\u3044\u30D5\u30EC\u30FC\u30E0",textPlaceholder:"\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",selectionLabel:"\u9078\u629E\u4E2D\u306E\u8981\u7D20",selectionCount:t=>`${t} \u4EF6\u3092\u9078\u629E\u4E2D`,editText:"\u30C6\u30AD\u30B9\u30C8\u3092\u7DE8\u96C6",renameFrame:"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4",comment:"\u30B3\u30E1\u30F3\u30C8",delete:"\u524A\u9664",colorLabelPrefix:"\u8272",fontSizeLabelPrefix:"\u6587\u5B57\u30B5\u30A4\u30BA",arrangeLabel:"\u91CD\u306A\u308A\u9806",bringToFront:"\u6700\u524D\u9762\u3078",bringForward:"\u524D\u9762\u3078",sendBackward:"\u80CC\u9762\u3078",sendToBack:"\u6700\u80CC\u9762\u3078",routeLabelPrefix:"\u7DDA\u306E\u5F62",labelField:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB",labelPlaceholder:"\u30E9\u30D9\u30EB\u3092\u8FFD\u52A0",resizeHandle:"\u30B5\u30A4\u30BA\u3092\u5909\u66F4",connectHandle:"\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u3064\u306A\u3050",commentCount:t=>`\u30B3\u30E1\u30F3\u30C8 ${t} \u4EF6`,zoomIn:"\u62E1\u5927",zoomOut:"\u7E2E\u5C0F",zoomFit:"\u30DC\u30FC\u30C9\u5168\u4F53\u3092\u8868\u793A",zoomReset:"100% \u306B\u623B\u3059",addedTitle:t=>`${Re[t]}\u3092\u8FFD\u52A0`,textEditedTitle:t=>t==="frame"?"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4":`${Re[t]}\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4`,movedTitle:t=>`${Re[t]}\u3092\u79FB\u52D5`,resizedTitle:t=>`${Re[t]}\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,recoloredTitle:t=>`${Re[t]}\u306E\u8272\u3092\u5909\u66F4`,resizedTextTitle:t=>`${Re[t]}\u306E\u6587\u5B57\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,restackedTitle:t=>`${Re[t]}\u306E\u91CD\u306A\u308A\u9806\u3092\u5909\u66F4`,deletedTitle:t=>`${Re[t]}\u3092\u524A\u9664`,connectedTitle:"\u8981\u7D20\u3092\u3064\u306A\u3044\u3060",relabeledTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",reroutedTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u7DDA\u306E\u5F62\u3092\u5909\u66F4",disconnectedTitle:"\u30B3\u30CD\u30AF\u30BF\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,inFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u5185`,intoFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u3078`,outOfFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u306E\u5916\u3078`,betweenFrames:(t,e)=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u2192\u300C${e}\u300D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,labeled:t=>`\u30E9\u30D9\u30EB\u300C${t}\u300D`,inFrontOf:t=>`\u300C${t}\u300D\u306E\u524D\u9762\u3078`,toBack:"\u6700\u80CC\u9762\u3078",empty:"\uFF08\u7A7A\uFF09",noLabel:"\uFF08\u30E9\u30D9\u30EB\u306A\u3057\uFF09"}}),td=40,ut=(t,e)=>{const n=e.replace(/\s+/g," ").trim();return n===""?t.empty:n.length>td?`${n.slice(0,td-1)}\u2026`:n},nd=(t,e)=>`${e.kind==="shape"?t.shapeLabel(e.shape):t.kindLabel(e.kind)} \xB7 ${ut(t,We(e))}`,Qe=(t,e,n,o)=>{const i=j(e,o)??j(n,o);return i===void 0?o:ut(t,We(i))},od=(t,e,n,o=e)=>`${t.connector} \xB7 ${t.connection(Qe(t,e,o,n.from),Qe(t,e,o,n.to))}`,Hf=(t,e,n,o,i)=>{const s=n===void 0?void 0:Nt(i,n),r=Nt(e,o),a=t.position(Math.round(o.x),Math.round(o.y));if(s?.id!==r?.id){if(s!==void 0&&r!==void 0)return`${t.betweenFrames(s.title,r.title)} ${a}`;if(r!==void 0)return`${t.intoFrame(r.title)} ${a}`;if(s!==void 0)return`${t.outOfFrame(s.title)} ${a}`}return n===void 0?`\u2192 ${a}`:t.plain(t.position(Math.round(n.x),Math.round(n.y)),a)},Yf=(t,e,n,o)=>{const i=e.target.id,s=j(o,i),r=j(n,i)??s,a=r?.kind??"sticky";switch(e.type){case"ADD_ITEM":{const d=j(n,e.payload.id)??e.payload,l=Nt(n,d),c=t.added(ut(t,We(d)));return{title:t.addedTitle(d.kind),tone:"create",body:l===void 0?c:`${c} ${t.inFrame(l.title)}`}}case"SET_ITEM_TEXT":{const d=ut(t,e.payload.text);return{title:t.textEditedTitle(a),tone:"update",body:s===void 0?t.arrowTo(d):t.arrowFrom(ut(t,We(s)),d)}}case"MOVE_ITEM":{if(r===void 0)return{title:t.movedTitle(a),tone:"move"};const d={...r,x:e.payload.x,y:e.payload.y};return{title:t.movedTitle(a),tone:"move",body:Hf(t,n,s,d,o)}}case"RESIZE_ITEM":{const d=t.size(Math.round(e.payload.w),Math.round(e.payload.h));return{title:t.resizedTitle(a),tone:"update",body:s===void 0?`\u2192 ${d}`:t.plain(t.size(Math.round(s.w),Math.round(s.h)),d)}}case"SET_ITEM_COLOR":{const d=t.colorLabel(e.payload.color);return{title:t.recoloredTitle(a),tone:"update",body:s!==void 0&&_n(s)?t.plain(t.colorLabel(s.color),d):`\u2192 ${d}`}}case"SET_ITEM_FONT_SIZE":{const d=t.fontSizeLabel(e.payload.fontSize);return{title:t.resizedTextTitle(a),tone:"update",body:s!==void 0&&Ot(s)?t.plain(t.fontSizeLabel(s.fontSize),d):`\u2192 ${d}`}}case"REORDER_ITEM":{const d=e.payload.after;return{title:t.restackedTitle(a),tone:"move",body:d===null?t.toBack:t.inFrontOf(Qe(t,n,o,d))}}case"DELETE_ITEM":return{title:t.deletedTitle(a),tone:"delete",body:t.deleted(r===void 0?i:ut(t,We(r)))};case"CONNECT_ITEMS":{const d=e.payload,l=t.connection(Qe(t,n,o,d.from),Qe(t,n,o,d.to));return{title:t.connectedTitle,tone:"create",body:d.label===void 0||d.label===""?l:`${l} \xB7 ${t.labeled(d.label)}`}}case"SET_CONNECTOR_LABEL":{const d=be(o,i)?.label,l=e.payload.label===""?t.noLabel:e.payload.label;return{title:t.relabeledTitle,tone:"update",body:d===void 0?t.arrowTo(l):t.arrowFrom(d,l)}}case"SET_CONNECTOR_ROUTE":{const d=be(o,i)?.route,l=t.routeLabel(e.payload.route);return{title:t.reroutedTitle,tone:"update",body:d===void 0?`\u2192 ${l}`:t.plain(t.routeLabel(d),l)}}case"DELETE_CONNECTOR":{const d=be(o,i)??be(n,i);return{title:t.disconnectedTitle,tone:"delete",...d===void 0?{}:{body:t.connection(Qe(t,n,o,d.from),Qe(t,n,o,d.to))}}}}},id=(t,e,n,o=n)=>{let i;try{const s=Bt(Vo,e);i=s===null?{title:e.type,tone:"meta"}:Yf(t,s,n,o)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:Xf(t,n,e.target,o),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},Xf=(t,e,n,o=e)=>{switch(n.type){case"item":{const i=j(e,n.id)??j(o,n.id);return i===void 0?`${n.type} \xB7 ${n.id} (missing)`:nd(t,i)}case"connector":{const i=be(e,n.id)??be(o,n.id);return i===void 0?`${t.connector} \xB7 ${n.id} (missing)`:od(t,e,i,o)}case"page":return`${t.board} \xB7 ${e.title??"Whiteboard"}`;default:return`${n.type} \xB7 ${n.id}`}},Gf=(t,e)=>{const n=Bt(Vo,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"ADD_ITEM":{const i=n.payload,s=t.items.find(r=>r.id===i.id);return s!==void 0?s.kind===i.kind?t:null:t.connectors.some(r=>r.id===i.id)?null:{...t,items:[...t.items,i]}}case"SET_ITEM_TEXT":return Pt(t,o,i=>i.kind==="frame"?n.payload.text.trim()===""?null:{...i,title:n.payload.text}:{...i,text:n.payload.text});case"MOVE_ITEM":return Pt(t,o,i=>({...i,x:n.payload.x,y:n.payload.y}));case"RESIZE_ITEM":return Pt(t,o,i=>({...i,w:n.payload.w,h:n.payload.h}));case"SET_ITEM_COLOR":return Pt(t,o,i=>i.kind==="text"?null:{...i,color:n.payload.color});case"SET_ITEM_FONT_SIZE":return Pt(t,o,i=>i.kind==="frame"?null:{...i,fontSize:n.payload.fontSize});case"REORDER_ITEM":return Kf(t,o,n.payload.after);case"DELETE_ITEM":return t.items.some(i=>i.id===o)?{...t,items:t.items.filter(i=>i.id!==o),connectors:t.connectors.filter(i=>i.from!==o&&i.to!==o)}:null;case"CONNECT_ITEMS":{const i=n.payload;if(t.connectors.some(r=>r.id===i.id))return t;if(t.items.some(r=>r.id===i.id)||i.from===i.to||!t.items.some(r=>r.id===i.from)||!t.items.some(r=>r.id===i.to))return null;const s={id:i.id,from:i.from,to:i.to,style:i.style??"arrow",route:i.route??"straight",...i.label===void 0||i.label===""?{}:{label:i.label}};return{...t,connectors:[...t.connectors,s]}}case"SET_CONNECTOR_LABEL":return sd(t,o,i=>{const{label:s,...r}=i;return n.payload.label===""?r:{...r,label:n.payload.label}});case"SET_CONNECTOR_ROUTE":return sd(t,o,i=>({...i,route:n.payload.route}));case"DELETE_CONNECTOR":return t.connectors.some(i=>i.id===o)?{...t,connectors:t.connectors.filter(i=>i.id!==o)}:null;default:return Xn(n)}},Pt=(t,e,n)=>{const o=t.items.find(s=>s.id===e);if(o===void 0)return null;const i=n(o);return i===null?null:{...t,items:t.items.map(s=>s.id===e?i:s)}},Kf=(t,e,n)=>{const o=t.items.find(r=>r.id===e);if(o===void 0||n===e)return null;const i=t.items.filter(r=>r.id!==e),s=n===null?0:i.findIndex(r=>r.id===n)+1;return s===0&&n!==null?null:{...t,items:[...i.slice(0,s),o,...i.slice(s)]}},sd=(t,e,n)=>{const o=t.connectors.find(s=>s.id===e);if(o===void 0)return null;const i=n(o);return{...t,connectors:t.connectors.map(s=>s.id===e?i:s)}},jf=t=>t==="comment"?"meta":t,Wf=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},Vf=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=id(t,s,o).title;if(!(s.type in Vo)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=Wf(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Gf(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=id(t,d,l,o);i.push({id:s.id,title:c.title,tone:jf(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Ae={kind:"idle"},mt=(t,e)=>t.kind==="editing"&&t.itemId===e,Qf={front:Me(al),forward:Me(Xd),backward:Me(Yd),back:Me(cl)},rd=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}]],Zf={straight:Me([...rd,["path",{d:"M6.5 17.5 17.5 6.5"}]]),elbow:Me([...rd,["path",{d:"M7 19h5V5h5"}]]),curve:Me(pl)},Jf=t=>Qf[t](),eb=t=>Zf[t](),tb=Me(dl),nb=Me(ll),ob={yellow:{paper:"#fff0a3",ink:"#4a3a06",stroke:"#d9a900"},orange:{paper:"#ffd1a0",ink:"#4a2503",stroke:"#ec7f1d"},pink:{paper:"#ffc9dd",ink:"#4b1029",stroke:"#de4479"},purple:{paper:"#ddcbf8",ink:"#32195c",stroke:"#8a5bd6"},blue:{paper:"#c0ddf7",ink:"#0e2c4b",stroke:"#3a80d4"},green:{paper:"#cdeba5",ink:"#22380a",stroke:"#55a42c"},gray:{paper:"#e3e6eb",ink:"#2a2f38",stroke:"#868d99"}},ad=t=>{const{paper:e,ink:n,stroke:o}=ob[t];return`--wb-paper:${e};--wb-ink:${n};--wb-stroke:${o}`},dd={sticky:"addSticky",text:"addText",rect:"addRect",ellipse:"addEllipse",frame:"addFrame"},ld={small:.8,medium:1,large:1.4,xlarge:2},ib=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},sb=t=>{const{m:e,state:n,viewport:o,gesture:i,handlers:s}=t,r=["wb-canvas"];i?.moved===!0&&r.push("wb-canvas--gesturing"),i?.kind==="pan"&&i.moved&&r.push("wb-canvas--panning"),i?.kind==="connect"&&r.push("wb-canvas--connecting"),(t.panReady||i?.kind==="pan")&&r.push("wb-canvas--pan-ready");const a=Pa(n);return v`<div
5587
+ `}}const Ya=()=>{customElements.get("dpk-board-state-diagram")||customElements.define("dpk-board-state-diagram",Ha)},Vo=["yellow","orange","pink","purple","blue","green","gray"],bf=["rect","ellipse"],Qo=["small","medium","large","xlarge"],In="medium",Ga=["arrow","line"],An=["straight","elbow","curve"],Rn=24,Ge={sticky:{w:160,h:160},text:{w:240,h:48},shape:{w:180,h:110},frame:{w:640,h:420}},mt={sticky:"yellow",shape:"blue",frame:"gray"},Xa=S(ce(),Xt()),Xe=S(ce(),Xt(),Gt(Rn)),Zo=G(Vo),Jo=L(G(Qo),In),_n={id:oe,x:Xa,y:Xa,questions:tt},xf=P({..._n,kind:he("sticky"),w:L(Xe,Ge.sticky.w),h:L(Xe,Ge.sticky.h),text:L(x(),""),color:L(Zo,mt.sticky),fontSize:Jo}),yf=P({..._n,kind:he("text"),w:L(Xe,Ge.text.w),h:L(Xe,Ge.text.h),text:L(x(),""),fontSize:Jo}),kf=P({..._n,kind:he("shape"),shape:L(G(bf),"rect"),w:L(Xe,Ge.shape.w),h:L(Xe,Ge.shape.h),text:L(x(),""),color:L(Zo,mt.shape),fontSize:Jo}),vf=P({..._n,kind:he("frame"),w:Xe,h:Xe,title:S(x(),I(1)),color:L(Zo,mt.frame)}),Ka=Yn("kind",[xf,yf,kf,vf]),wf=P({id:oe,from:S(x(),I(1)),to:S(x(),I(1)),label:j(x()),style:L(G(Ga),"arrow"),route:L(G(An),"straight")}),$f=P({title:j(x()),items:L(F(Ka),[]),connectors:L(F(wf),[])}),Ef=t=>{const e=ue($f,t),n=new Set;for(const{id:i}of[...e.items,...e.connectors]){if(n.has(i))throw new Error(`duplicate id "${i}" (items and connectors share one id space)`);n.add(i)}const o=new Set(e.items.map(i=>i.id));for(const i of e.connectors){if(!o.has(i.from))throw new Error(`unknown item "${i.from}" in connector "${i.id}"`);if(!o.has(i.to))throw new Error(`unknown item "${i.to}" in connector "${i.id}"`);if(i.from===i.to)throw new Error(`connector "${i.id}" connects an item to itself`)}return e},Tf=()=>({items:[],connectors:[]}),W=(t,e)=>{if(e!==void 0)return t.items.find(n=>n.id===e)},xe=(t,e)=>{if(e!==void 0)return t.connectors.find(n=>n.id===e)},ei=t=>[...t.items.map(e=>e.id),...t.connectors.map(e=>e.id)],Ze=t=>t.kind==="frame"?t.title:t.text,Dn=t=>t.kind!=="text",Nt=t=>t.kind!=="frame",On=t=>t.w*t.h,Sf=(t,e,n)=>e>=t.x&&e<=t.x+t.w&&n>=t.y&&n<=t.y+t.h,zt=(t,e)=>{const n=e.x+e.w/2,o=e.y+e.h/2;let i;for(const s of t.items)s.kind!=="frame"||s.id===e.id||e.kind==="frame"&&On(s)<=On(e)||Sf(s,n,o)&&(i===void 0||On(s)<On(i))&&(i=s);return i},Mf=(t,e)=>{const n=[],o=i=>{let s=zt(t,i);for(;s!==void 0;){if(s.id===e.id)return!0;s=zt(t,s)}return!1};for(const i of t.items)i.id!==e.id&&o(i)&&n.push(i);return n},ja=S(ce(),Xt()),Wa=S(ce(),Xt(),Gt(Rn)),Va={type:"page",id:"whiteboard"},ti={ADD_ITEM:z("ADD_ITEM","page",Ka,{dedupeKey:Ce}),SET_ITEM_TEXT:z("SET_ITEM_TEXT","item",_({text:x()})),MOVE_ITEM:z("MOVE_ITEM","item",_({x:ja,y:ja})),RESIZE_ITEM:z("RESIZE_ITEM","item",_({w:Wa,h:Wa})),SET_ITEM_COLOR:z("SET_ITEM_COLOR","item",_({color:G(Vo)})),SET_ITEM_FONT_SIZE:z("SET_ITEM_FONT_SIZE","item",_({fontSize:G(Qo)})),REORDER_ITEM:z("REORDER_ITEM","item",_({after:me(S(x(),I(1)))})),DELETE_ITEM:z("DELETE_ITEM","item",_({})),CONNECT_ITEMS:z("CONNECT_ITEMS","page",_({id:oe,from:S(x(),I(1)),to:S(x(),I(1)),label:j(x()),style:j(G(Ga)),route:j(G(An))}),{dedupeKey:Ce}),SET_CONNECTOR_LABEL:z("SET_CONNECTOR_LABEL","connector",_({label:x()})),SET_CONNECTOR_ROUTE:z("SET_CONNECTOR_ROUTE","connector",_({route:G(An)})),DELETE_CONNECTOR:z("DELETE_CONNECTOR","connector",_({}))},Je=t=>({type:"item",id:t}),ae={addItem:t=>({type:"ADD_ITEM",target:Va,payload:t}),setText:(t,e)=>({type:"SET_ITEM_TEXT",target:Je(t),payload:{text:e}}),move:(t,e,n)=>({type:"MOVE_ITEM",target:Je(t),payload:{x:e,y:n}}),resize:(t,e,n)=>({type:"RESIZE_ITEM",target:Je(t),payload:{w:e,h:n}}),setColor:(t,e)=>({type:"SET_ITEM_COLOR",target:Je(t),payload:{color:e}}),setFontSize:(t,e)=>({type:"SET_ITEM_FONT_SIZE",target:Je(t),payload:{fontSize:e}}),reorder:(t,e)=>({type:"REORDER_ITEM",target:Je(t),payload:{after:e}}),deleteItem:t=>({type:"DELETE_ITEM",target:Je(t),payload:{}}),connect:(t,e,n,o)=>({type:"CONNECT_ITEMS",target:Va,payload:{id:t,from:e,to:n,...o===void 0?{}:{label:o}}}),setConnectorLabel:(t,e)=>({type:"SET_CONNECTOR_LABEL",target:{type:"connector",id:t},payload:{label:e}}),setConnectorRoute:(t,e)=>({type:"SET_CONNECTOR_ROUTE",target:{type:"connector",id:t},payload:{route:e}}),deleteConnector:t=>({type:"DELETE_CONNECTOR",target:{type:"connector",id:t},payload:{}})},Nn=t=>{if(t.length===0)return null;const e=Math.min(...t.map(s=>s.x)),n=Math.min(...t.map(s=>s.y)),o=Math.max(...t.map(s=>s.x+s.w)),i=Math.max(...t.map(s=>s.y+s.h));return{x:e,y:n,w:o-e,h:i-n}},Qa=t=>[...t.items.filter(e=>e.kind==="frame"),...t.items.filter(e=>e.kind!=="frame")],Cf=t=>t.kind==="shape"&&t.shape==="ellipse",zn=(t,e)=>{const n=t.x+t.w/2,o=t.y+t.h/2,i=e.x-n,s=e.y-o;if(i===0&&s===0)return{x:n,y:o};const r=t.w/2,a=t.h/2,d=Cf(t)?1/Math.sqrt((i/r)**2+(s/a)**2):Math.min(i===0?1/0:r/Math.abs(i),s===0?1/0:a/Math.abs(s));return{x:n+i*d,y:o+s*d}},gt=t=>({x:t.x+t.w/2,y:t.y+t.h/2}),Lf=(t,e)=>{const n=zn(t,gt(e)),o=zn(e,gt(t));return{start:n,end:o,mid:{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}},Te=t=>`${t.x} ${t.y}`,ni=(t,e,n)=>{if(n==="straight"){const{start:g,end:b,mid:f}=Lf(t,e);return{d:`M ${Te(g)} L ${Te(b)}`,mid:f}}const o=gt(t),i=gt(e),s=Math.abs(i.x-o.x)>=Math.abs(i.y-o.y),r=s?i.x>=o.x:i.y>=o.y,a=(g,b)=>{const f=gt(g);return s?{x:b?g.x+g.w:g.x,y:f.y}:{x:f.x,y:b?g.y+g.h:g.y}},d=a(t,r),l=a(e,!r),c={x:(d.x+l.x)/2,y:(d.y+l.y)/2},h=s?{x:c.x,y:d.y}:{x:d.x,y:c.y},p=s?{x:c.x,y:l.y}:{x:l.x,y:c.y};return{d:n==="elbow"?`M ${Te(d)} L ${Te(h)} L ${Te(p)} L ${Te(l)}`:`M ${Te(d)} C ${Te(h)} ${Te(p)} ${Te(l)}`,mid:c}},oi=(t,e)=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h,If=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,Af=(t,e)=>t.items.filter(n=>n.kind==="frame"&&oi(n,e)).sort((n,o)=>n.w*n.h-o.w*o.h),Za=(t,e,n)=>{const o=Qa(t);for(let s=o.length-1;s>=0;s-=1){const r=o[s];if(!(r===void 0||r.id===n||r.kind==="frame")&&oi(r,e))return r}let i;for(const s of o)s.kind!=="frame"||s.id===n||!oi(s,e)||(i===void 0||s.w*s.h<i.w*i.h)&&(i=s);return i},Rf=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}),_f=(t,e)=>e.x>=t.x&&e.y>=t.y&&e.x+e.w<=t.x+t.w&&e.y+e.h<=t.y+t.h,Df=(t,e)=>t.items.filter(n=>n.kind==="frame"?_f(e,n):Pn(e,n,0)),Pn=(t,e,n)=>t.x<e.x+e.w+n&&e.x<t.x+t.w+n&&t.y<e.y+e.h+n&&e.y<t.y+t.h+n,Of=(t,e,n=!1,o=16,i=6)=>{const s=n?t.items:t.items.filter(l=>l.kind!=="frame"),r=l=>!s.some(c=>Pn(l,c,o));if(r(e))return{x:e.x,y:e.y};const a=e.w+o,d=e.h+o;for(let l=1;l<=i;l+=1){const c=[];for(let p=-l;p<=l;p+=1)for(let u=-l;u<=l;u+=1)Math.max(Math.abs(u),Math.abs(p))===l&&c.push({x:e.x+u*a,y:e.y+p*d});c.sort((p,u)=>Math.hypot(p.x-e.x,p.y-e.y)-Math.hypot(u.x-e.x,u.y-e.y));const h=c.find(p=>r({...e,...p}));if(h!==void 0)return h}return{x:e.x,y:e.y}},Ja=["front","forward","backward","back"],ed=t=>t.items.filter(e=>e.kind!=="frame"),td=(t,e,n,o)=>{const i=t.indexOf(e),s=(o?t.slice(i+1):t.slice(0,i).reverse()).filter(l=>!n.has(l.id)),r=s.find(l=>Pn(e,l,0))??s[0];if(r===void 0)return t;const a=t.filter(l=>l!==e),d=a.indexOf(r)+(o?1:0);return[...a.slice(0,d),e,...a.slice(d)]},nd=(t,e,n)=>{const o=t.filter(s=>e.has(s.id)),i=t.filter(s=>!e.has(s.id));switch(n){case"front":return[...i,...o];case"back":return[...o,...i];case"forward":return[...o].reverse().reduce((s,r)=>td(s,r,e,!0),[...t]);case"backward":return o.reduce((s,r)=>td(s,r,e,!1),[...t])}},Nf=(t,e,n)=>{let o=t.map(s=>s.id);const i=[];return e.forEach((s,r)=>{if(!n.has(s.id))return;const a=e[r-1]?.id??null,d=o.indexOf(s.id);(o[d-1]??null)!==a&&(o=o.filter(l=>l!==s.id),o.splice(a===null?0:o.indexOf(a)+1,0,s.id),i.push(ae.reorder(s.id,a)))}),i},zf=(t,e,n)=>{const o=ed(t),i=new Set(e.filter(s=>o.some(r=>r.id===s)));return i.size===0?[]:Nf(o,nd(o,i,n),i)},Pf=(t,e)=>{const n=ed(t),o=new Set(e.filter(r=>n.some(a=>a.id===r))),i=n.flatMap(r=>o.has(r.id)?n.filter(a=>!o.has(a.id)&&Pn(r,a,0)).map(a=>[r,a]):[]),s=(r,[a,d])=>r.indexOf(a)>r.indexOf(d);return new Set(Ja.filter(r=>{const a=nd(n,o,r);return i.some(d=>s(n,d)!==s(a,d))}))},od=(t,e,n)=>{if(!t.contains(e)||e.nodeType!==Node.TEXT_NODE)return;let o=0;const i=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let s=i.nextNode();s!==null;s=i.nextNode()){if(s===e)return o+n;o+=s.textContent?.length??0}},qf=(t,e,n)=>{const o=t.getRootNode(),i=t.ownerDocument;if(typeof i.caretPositionFromPoint=="function"){const s=o instanceof ShadowRoot?[o]:[],r=i.caretPositionFromPoint(e,n,{shadowRoots:s});if(r!==null)return od(t,r.offsetNode,r.offset)}if(typeof i.caretRangeFromPoint=="function"){const s=i.caretRangeFromPoint(e,n);if(s!==null)return od(t,s.startContainer,s.startOffset)}},Ff=["sticky","text","rect","ellipse","frame"],Uf=t=>t==="rect"||t==="ellipse"?Ge.shape:Ge[t],Bf=(t,e,n,o)=>{const{w:i,h:s}=Uf(n),r={x:Math.round(o.x-i/2),y:Math.round(o.y-s/2)},a=Of(t,{...r,w:i,h:s},n==="frame"),c={id:ke(`new-${n==="rect"||n==="ellipse"?"shape":n}`,ei(t)),x:a.x,y:a.y,w:i,h:s};switch(n){case"sticky":return{...c,kind:"sticky",text:"",color:mt.sticky,fontSize:In};case"text":return{...c,kind:"text",text:"",fontSize:In};case"rect":case"ellipse":return{...c,kind:"shape",shape:n,text:"",color:mt.shape,fontSize:In};case"frame":return{...c,kind:"frame",title:e.newFrameTitle,color:mt.frame}}},Hf=(t,e,n)=>ke(`${e}-to-${n}`,ei(t)),Yf=24,Gf=(t,e,n)=>{const o=new Set(ei(t));return e.map(i=>{const s=i.kind==="shape"?"shape":i.kind,r=ke(`new-${s}`,o);return o.add(r),{...i,id:r,x:i.x+n,y:i.y+n}})},Xf=(t,e)=>{const n=(t.kind==="frame"?e.replace(/\r?\n/g," "):e).trim();if(!(t.kind==="frame"&&n===""))return n===Ze(t)?void 0:n},qn=4,Kf={n:{x:0,y:-1},s:{x:0,y:1},e:{x:1,y:0},w:{x:-1,y:0},ne:{x:1,y:-1},se:{x:1,y:1},sw:{x:-1,y:1},nw:{x:-1,y:-1}},ii=(t,e,n,o,i=[e])=>{if(W(t,e)===void 0)return;const s=new Map;for(const r of i.includes(e)?i:[e,...i]){const a=W(t,r);if(a!==void 0)for(const d of a.kind==="frame"?[a,...Mf(t,a)]:[a])s.set(d.id,d)}return{kind:"move",pointerId:n,itemId:e,origins:[...s.values()].map(({id:r,x:a,y:d})=>({id:r,x:a,y:d})),start:o,current:o,moved:!1}},jf=(t,e,n,o,i="se")=>{const s=W(t,e);if(s!==void 0)return{kind:"resize",pointerId:n,itemId:e,origin:{x:s.x,y:s.y,w:s.w,h:s.h},edge:i,start:o,current:o,moved:!1,keepRatio:!1}},Wf=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),Vf=(t,e)=>({gesture:{...t,last:e,moved:t.moved||Math.hypot(e.x-t.start.x,e.y-t.start.y)>qn},dx:e.x-t.last.x,dy:e.y-t.last.y}),id=(t,e,n)=>({kind:"marquee",pointerId:t,base:n,start:e,current:e,moved:!1}),Qf=(t,e,n,o,i)=>{const s=Af(t,o).find(a=>e.includes(a.id));return(s===void 0?void 0:ii(t,s.id,n,o,e))??id(n,o,i)},sd=t=>t?.kind==="marquee"&&t.moved?Rf(t.start,t.current):void 0,rd=(t,e)=>{const n=sd(e);if(e.kind!=="marquee"||n===void 0)return[];const o=Df(t,n).map(i=>i.id);return[...new Set([...e.base,...o])]},Zf=(t,e,n)=>({kind:"connect",pointerId:e,fromId:t,start:n,current:n,moved:!1}),si=(t,e,n,o,i,s=!1)=>{if(e.pointerId!==n)return e;switch(e.kind){case"pan":return e;case"marquee":case"move":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>qn;return{...e,current:o,moved:r}}case"resize":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>qn;return{...e,current:o,moved:r,keepRatio:s}}case"connect":{const r=e.moved||Math.hypot(o.x-e.start.x,o.y-e.start.y)*i>qn,a=Za(t,o,e.fromId),{targetId:d,...l}=e;return a===void 0?{...l,current:o,moved:r}:{...l,current:o,moved:r,targetId:a.id}}}},Pt=t=>Math.round(t),ad=(t,e)=>{if(e===void 0||!e.moved)return t;if(e.kind==="move"){const n=e.current.x-e.start.x,o=e.current.y-e.start.y,i=new Map(e.origins.map(s=>[s.id,s]));return{...t,items:t.items.map(s=>{const r=i.get(s.id);return r===void 0?s:{...s,x:Pt(r.x+n),y:Pt(r.y+o)}})}}if(e.kind==="resize"){const n=ld(e);return{...t,items:t.items.map(o=>o.id===e.itemId?{...o,...n}:o)}}return t},dd=t=>Math.max(Rn,Pt(t)),Jf=(t,e,n)=>{const o=Math.max(e===void 0?0:e/t.w,n===void 0?0:n/t.h,Rn/Math.min(t.w,t.h));return{w:Pt(t.w*o),h:Pt(t.h*o)}},ld=t=>{const{origin:e,edge:n}=t,o=Kf[n],i=(t.current.x-t.start.x)*o.x,s=(t.current.y-t.start.y)*o.y,r=o.x===0?void 0:e.w+i,a=o.y===0?void 0:e.h+s,d=t.keepRatio?Jf(e,r,a):{w:r===void 0?e.w:dd(r),h:a===void 0?e.h:dd(a)};return{...d,x:o.x<0?e.x+e.w-d.w:e.x,y:o.y<0?e.y+e.h-d.h:e.y}},eb=(t,e,n,o)=>{const[i]=e;if(i===void 0)return[];const s=ii(t,i,0,{x:0,y:0},e);if(s?.kind!=="move")return[];const r=cd(t,{...s,current:{x:n,y:o},moved:!0});return r.kind==="dispatch"?r.inputs:[]},cd=(t,e)=>{switch(e.kind){case"pan":return e.moved?{kind:"none"}:{kind:"click"};case"marquee":{if(e.moved)return{kind:"select",ids:rd(t,e)};const n=Za(t,e.start);return n===void 0?{kind:"click"}:{kind:"click",itemId:n.id}}case"move":{if(!e.moved)return{kind:"click",itemId:e.itemId};const n=ad(t,e),o=e.origins.flatMap(i=>{const s=W(n,i.id);return s===void 0||s.x===i.x&&s.y===i.y?[]:[ae.move(i.id,s.x,s.y)]});return o.length===0?{kind:"none"}:{kind:"dispatch",inputs:o}}case"resize":{if(!e.moved)return{kind:"click",itemId:e.itemId};const n=W(t,e.itemId);if(n===void 0)return{kind:"none"};const o=ld(e),i=[];return(o.x!==n.x||o.y!==n.y)&&i.push(ae.move(n.id,o.x,o.y)),(o.w!==n.w||o.h!==n.h)&&i.push(ae.resize(n.id,o.w,o.h)),i.length===0?{kind:"none"}:{kind:"dispatch",inputs:i}}case"connect":return e.moved?e.targetId===void 0?{kind:"none"}:{kind:"connect",from:e.fromId,to:e.targetId}:{kind:"click",itemId:e.fromId}}},Fn=.1,tb=2.5,nb={x:0,y:0,zoom:1},ob=96,ri=(t,e)=>({x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}),ai=(t,e)=>({x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}),di=(t,e,n)=>({...t,x:t.x+e,y:t.y+n}),pd=(t,e,n)=>{const o=kt(t.zoom*n,Fn,tb),i=ri(t,e);return{zoom:o,x:e.x-i.x*o,y:e.y-i.y*o}},ib=(t,e,n=48,o=1)=>{const i=Math.max(1,e.width-n*2),s=Math.max(1,e.height-n*2),r=kt(Math.min(i/Math.max(1,t.w),s/Math.max(1,t.h)),Fn,o);return{zoom:r,x:e.width/2-(t.x+t.w/2)*r,y:e.height/2-(t.y+t.h/2)*r}},sb=(t,e,n=48)=>{const o=Nn(t);if(o===null)return null;const i=Math.max(1,e.width-n*2)/Fn,s=Math.max(1,e.height-n*2)/Fn;if(o.w<=i&&o.h<=s)return o;const r=Li(t.map(l=>l.x+l.w/2)),a=Li(t.map(l=>l.y+l.h/2)),d=t.filter(l=>l.x<r+i/2&&l.x+l.w>r-i/2&&l.y<a+s/2&&l.y+l.h>a-s/2);return Nn(d)??o},rb=(t,e,n)=>{if(e===null||n.width<=0||n.height<=0)return t;const o=(i,s,r,a)=>{const d=Math.min(ob,a/2),l=d-(s+r)*t.zoom,c=a-d-s*t.zoom;return kt(i,Math.min(l,c),Math.max(l,c))};return{zoom:t.zoom,x:o(t.x,e.x,e.w,n.width),y:o(t.y,e.y,e.h,n.height)}},ab=(t,e,n,o=24)=>{const i=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,r=i+e.w*t.zoom,a=s+e.h*t.zoom;return i>=o&&s>=o&&r<=n.width-o&&a<=n.height-o?t:{zoom:t.zoom,x:n.width/2-(e.x+e.w/2)*t.zoom,y:n.height/2-(e.y+e.h/2)*t.zoom}},hd=(t,e,n,o,i=0)=>{const s=t+e-(n-o),r=s>0?-s:0;return t+r<i+o?i+o-t:r},db=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,lb={sticky:"Sticky note",text:"Text",shape:"Shape",frame:"Frame"},De={sticky:"\u4ED8\u7B8B",text:"\u30C6\u30AD\u30B9\u30C8",shape:"\u56F3\u5F62",frame:"\u30D5\u30EC\u30FC\u30E0"},Ke={sticky:"sticky note",text:"text box",shape:"shape",frame:"frame"},cb={rect:"Rectangle",ellipse:"Ellipse"},pb={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},hb={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},ub={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},mb={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},gb={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},fb={straight:"Straight",elbow:"Elbow",curve:"Curved"},bb={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},ud={small:"S",medium:"M",large:"L",xlarge:"XL"},qt=pe({en:{kindLabel:t=>lb[t],shapeLabel:t=>cb[t],colorLabel:t=>hb[t],fontSizeLabel:t=>mb[t],fontSizeShort:t=>ud[t],routeLabel:t=>fb[t],heading:"Whiteboard",connector:"Connector",board:"Board",wholeBoard:"Whole board",canvasLabel:"Whiteboard canvas",emptyHint:"Double-click anywhere to add a sticky note, or pick something from the toolbar.",toolsLabel:"Add to the board",addSticky:"Sticky note",addText:"Text",addRect:"Rectangle",addEllipse:"Ellipse",addFrame:"Frame",newFrameTitle:"New frame",textPlaceholder:"Type something",selectionLabel:"Selected item",selectionCount:t=>`${t} items selected`,editText:"Edit text",renameFrame:"Rename frame",comment:"Comment",delete:"Delete",colorLabelPrefix:"Color",fontSizeLabelPrefix:"Text size",arrangeLabel:"Stacking order",bringToFront:"Bring to front",bringForward:"Bring forward",sendBackward:"Send backward",sendToBack:"Send to back",routeLabelPrefix:"Line",labelField:"Connector label",labelPlaceholder:"Add a label",resizeHandle:"Resize",connectHandle:"Drag to connect",commentCount:t=>`${t} comment${t===1?"":"s"}`,zoomIn:"Zoom in",zoomOut:"Zoom out",zoomFit:"Fit the board",zoomReset:"Reset to 100%",addedTitle:t=>`Added a ${Ke[t]}`,textEditedTitle:t=>t==="frame"?"Renamed the frame":`Edited the ${Ke[t]}`,movedTitle:t=>`Moved the ${Ke[t]}`,resizedTitle:t=>`Resized the ${Ke[t]}`,recoloredTitle:t=>`Changed the color of the ${Ke[t]}`,resizedTextTitle:t=>`Changed the text size of the ${Ke[t]}`,restackedTitle:t=>`Changed the stacking order of the ${Ke[t]}`,deletedTitle:t=>`Deleted the ${Ke[t]}`,connectedTitle:"Connected two items",relabeledTitle:"Relabeled the connector",reroutedTitle:"Changed the connector line",disconnectedTitle:"Removed the connector",arrowTo:t=>`\u2192 \u201C${t}\u201D`,arrowFrom:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u201C${t}\u201D`,deleted:t=>`\u2212 \u201C${t}\u201D`,inFrame:t=>`in frame \u201C${t}\u201D`,intoFrame:t=>`into frame \u201C${t}\u201D`,outOfFrame:t=>`out of frame \u201C${t}\u201D`,betweenFrames:(t,e)=>`frame \u201C${t}\u201D \u2192 frame \u201C${e}\u201D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u201C${t}\u201D \u2192 \u201C${e}\u201D`,labeled:t=>`labeled \u201C${t}\u201D`,inFrontOf:t=>`in front of \u201C${t}\u201D`,toBack:"to the very back",empty:"(empty)",noLabel:"(no label)"},ja:{kindLabel:t=>De[t],shapeLabel:t=>pb[t],colorLabel:t=>ub[t],fontSizeLabel:t=>gb[t],fontSizeShort:t=>ud[t],routeLabel:t=>bb[t],heading:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",connector:"\u30B3\u30CD\u30AF\u30BF",board:"\u30DC\u30FC\u30C9",wholeBoard:"\u30DC\u30FC\u30C9\u5168\u4F53",canvasLabel:"\u30DB\u30EF\u30A4\u30C8\u30DC\u30FC\u30C9",emptyHint:"\u30C0\u30D6\u30EB\u30AF\u30EA\u30C3\u30AF\u3067\u4ED8\u7B8B\u3092\u7F6E\u304F\u304B\u3001\u30C4\u30FC\u30EB\u30D0\u30FC\u304B\u3089\u8FFD\u52A0\u3057\u307E\u3059\u3002",toolsLabel:"\u30DC\u30FC\u30C9\u306B\u8FFD\u52A0",addSticky:"\u4ED8\u7B8B",addText:"\u30C6\u30AD\u30B9\u30C8",addRect:"\u56DB\u89D2\u5F62",addEllipse:"\u6955\u5186",addFrame:"\u30D5\u30EC\u30FC\u30E0",newFrameTitle:"\u65B0\u3057\u3044\u30D5\u30EC\u30FC\u30E0",textPlaceholder:"\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",selectionLabel:"\u9078\u629E\u4E2D\u306E\u8981\u7D20",selectionCount:t=>`${t} \u4EF6\u3092\u9078\u629E\u4E2D`,editText:"\u30C6\u30AD\u30B9\u30C8\u3092\u7DE8\u96C6",renameFrame:"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4",comment:"\u30B3\u30E1\u30F3\u30C8",delete:"\u524A\u9664",colorLabelPrefix:"\u8272",fontSizeLabelPrefix:"\u6587\u5B57\u30B5\u30A4\u30BA",arrangeLabel:"\u91CD\u306A\u308A\u9806",bringToFront:"\u6700\u524D\u9762\u3078",bringForward:"\u524D\u9762\u3078",sendBackward:"\u80CC\u9762\u3078",sendToBack:"\u6700\u80CC\u9762\u3078",routeLabelPrefix:"\u7DDA\u306E\u5F62",labelField:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB",labelPlaceholder:"\u30E9\u30D9\u30EB\u3092\u8FFD\u52A0",resizeHandle:"\u30B5\u30A4\u30BA\u3092\u5909\u66F4",connectHandle:"\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u3064\u306A\u3050",commentCount:t=>`\u30B3\u30E1\u30F3\u30C8 ${t} \u4EF6`,zoomIn:"\u62E1\u5927",zoomOut:"\u7E2E\u5C0F",zoomFit:"\u30DC\u30FC\u30C9\u5168\u4F53\u3092\u8868\u793A",zoomReset:"100% \u306B\u623B\u3059",addedTitle:t=>`${De[t]}\u3092\u8FFD\u52A0`,textEditedTitle:t=>t==="frame"?"\u30D5\u30EC\u30FC\u30E0\u540D\u3092\u5909\u66F4":`${De[t]}\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u5909\u66F4`,movedTitle:t=>`${De[t]}\u3092\u79FB\u52D5`,resizedTitle:t=>`${De[t]}\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,recoloredTitle:t=>`${De[t]}\u306E\u8272\u3092\u5909\u66F4`,resizedTextTitle:t=>`${De[t]}\u306E\u6587\u5B57\u30B5\u30A4\u30BA\u3092\u5909\u66F4`,restackedTitle:t=>`${De[t]}\u306E\u91CD\u306A\u308A\u9806\u3092\u5909\u66F4`,deletedTitle:t=>`${De[t]}\u3092\u524A\u9664`,connectedTitle:"\u8981\u7D20\u3092\u3064\u306A\u3044\u3060",relabeledTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",reroutedTitle:"\u30B3\u30CD\u30AF\u30BF\u306E\u7DDA\u306E\u5F62\u3092\u5909\u66F4",disconnectedTitle:"\u30B3\u30CD\u30AF\u30BF\u3092\u524A\u9664",arrowTo:t=>`\u2192 \u300C${t}\u300D`,arrowFrom:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,plain:(t,e)=>`${t} \u2192 ${e}`,added:t=>`+ \u300C${t}\u300D`,deleted:t=>`\u2212 \u300C${t}\u300D`,inFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u5185`,intoFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u3078`,outOfFrame:t=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u306E\u5916\u3078`,betweenFrames:(t,e)=>`\u30D5\u30EC\u30FC\u30E0\u300C${t}\u300D\u2192\u300C${e}\u300D`,position:(t,e)=>`(${t}, ${e})`,size:(t,e)=>`${t}\xD7${e}`,connection:(t,e)=>`\u300C${t}\u300D\u2192\u300C${e}\u300D`,labeled:t=>`\u30E9\u30D9\u30EB\u300C${t}\u300D`,inFrontOf:t=>`\u300C${t}\u300D\u306E\u524D\u9762\u3078`,toBack:"\u6700\u80CC\u9762\u3078",empty:"\uFF08\u7A7A\uFF09",noLabel:"\uFF08\u30E9\u30D9\u30EB\u306A\u3057\uFF09"}}),md=40,ft=(t,e)=>{const n=e.replace(/\s+/g," ").trim();return n===""?t.empty:n.length>md?`${n.slice(0,md-1)}\u2026`:n},gd=(t,e)=>`${e.kind==="shape"?t.shapeLabel(e.shape):t.kindLabel(e.kind)} \xB7 ${ft(t,Ze(e))}`,et=(t,e,n,o)=>{const i=W(e,o)??W(n,o);return i===void 0?o:ft(t,Ze(i))},fd=(t,e,n,o=e)=>`${t.connector} \xB7 ${t.connection(et(t,e,o,n.from),et(t,e,o,n.to))}`,xb=(t,e,n,o,i)=>{const s=n===void 0?void 0:zt(i,n),r=zt(e,o),a=t.position(Math.round(o.x),Math.round(o.y));if(s?.id!==r?.id){if(s!==void 0&&r!==void 0)return`${t.betweenFrames(s.title,r.title)} ${a}`;if(r!==void 0)return`${t.intoFrame(r.title)} ${a}`;if(s!==void 0)return`${t.outOfFrame(s.title)} ${a}`}return n===void 0?`\u2192 ${a}`:t.plain(t.position(Math.round(n.x),Math.round(n.y)),a)},yb=(t,e,n,o)=>{const i=e.target.id,s=W(o,i),r=W(n,i)??s,a=r?.kind??"sticky";switch(e.type){case"ADD_ITEM":{const d=W(n,e.payload.id)??e.payload,l=zt(n,d),c=t.added(ft(t,Ze(d)));return{title:t.addedTitle(d.kind),tone:"create",body:l===void 0?c:`${c} ${t.inFrame(l.title)}`}}case"SET_ITEM_TEXT":{const d=ft(t,e.payload.text);return{title:t.textEditedTitle(a),tone:"update",body:s===void 0?t.arrowTo(d):t.arrowFrom(ft(t,Ze(s)),d)}}case"MOVE_ITEM":{if(r===void 0)return{title:t.movedTitle(a),tone:"move"};const d={...r,x:e.payload.x,y:e.payload.y};return{title:t.movedTitle(a),tone:"move",body:xb(t,n,s,d,o)}}case"RESIZE_ITEM":{const d=t.size(Math.round(e.payload.w),Math.round(e.payload.h));return{title:t.resizedTitle(a),tone:"update",body:s===void 0?`\u2192 ${d}`:t.plain(t.size(Math.round(s.w),Math.round(s.h)),d)}}case"SET_ITEM_COLOR":{const d=t.colorLabel(e.payload.color);return{title:t.recoloredTitle(a),tone:"update",body:s!==void 0&&Dn(s)?t.plain(t.colorLabel(s.color),d):`\u2192 ${d}`}}case"SET_ITEM_FONT_SIZE":{const d=t.fontSizeLabel(e.payload.fontSize);return{title:t.resizedTextTitle(a),tone:"update",body:s!==void 0&&Nt(s)?t.plain(t.fontSizeLabel(s.fontSize),d):`\u2192 ${d}`}}case"REORDER_ITEM":{const d=e.payload.after;return{title:t.restackedTitle(a),tone:"move",body:d===null?t.toBack:t.inFrontOf(et(t,n,o,d))}}case"DELETE_ITEM":return{title:t.deletedTitle(a),tone:"delete",body:t.deleted(r===void 0?i:ft(t,Ze(r)))};case"CONNECT_ITEMS":{const d=e.payload,l=t.connection(et(t,n,o,d.from),et(t,n,o,d.to));return{title:t.connectedTitle,tone:"create",body:d.label===void 0||d.label===""?l:`${l} \xB7 ${t.labeled(d.label)}`}}case"SET_CONNECTOR_LABEL":{const d=xe(o,i)?.label,l=e.payload.label===""?t.noLabel:e.payload.label;return{title:t.relabeledTitle,tone:"update",body:d===void 0?t.arrowTo(l):t.arrowFrom(d,l)}}case"SET_CONNECTOR_ROUTE":{const d=xe(o,i)?.route,l=t.routeLabel(e.payload.route);return{title:t.reroutedTitle,tone:"update",body:d===void 0?`\u2192 ${l}`:t.plain(t.routeLabel(d),l)}}case"DELETE_CONNECTOR":{const d=xe(o,i)??xe(n,i);return{title:t.disconnectedTitle,tone:"delete",...d===void 0?{}:{body:t.connection(et(t,n,o,d.from),et(t,n,o,d.to))}}}}},bd=(t,e,n,o=n)=>{let i;try{const s=Ht(ti,e);i=s===null?{title:e.type,tone:"meta"}:yb(t,s,n,o)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:kb(t,n,e.target,o),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},kb=(t,e,n,o=e)=>{switch(n.type){case"item":{const i=W(e,n.id)??W(o,n.id);return i===void 0?`${n.type} \xB7 ${n.id} (missing)`:gd(t,i)}case"connector":{const i=xe(e,n.id)??xe(o,n.id);return i===void 0?`${t.connector} \xB7 ${n.id} (missing)`:fd(t,e,i,o)}case"page":return`${t.board} \xB7 ${e.title??"Whiteboard"}`;default:return`${n.type} \xB7 ${n.id}`}},vb=(t,e)=>{const n=Ht(ti,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"ADD_ITEM":{const i=n.payload,s=t.items.find(r=>r.id===i.id);return s!==void 0?s.kind===i.kind?t:null:t.connectors.some(r=>r.id===i.id)?null:{...t,items:[...t.items,i]}}case"SET_ITEM_TEXT":return Ft(t,o,i=>i.kind==="frame"?n.payload.text.trim()===""?null:{...i,title:n.payload.text}:{...i,text:n.payload.text});case"MOVE_ITEM":return Ft(t,o,i=>({...i,x:n.payload.x,y:n.payload.y}));case"RESIZE_ITEM":return Ft(t,o,i=>({...i,w:n.payload.w,h:n.payload.h}));case"SET_ITEM_COLOR":return Ft(t,o,i=>i.kind==="text"?null:{...i,color:n.payload.color});case"SET_ITEM_FONT_SIZE":return Ft(t,o,i=>i.kind==="frame"?null:{...i,fontSize:n.payload.fontSize});case"REORDER_ITEM":return wb(t,o,n.payload.after);case"DELETE_ITEM":return t.items.some(i=>i.id===o)?{...t,items:t.items.filter(i=>i.id!==o),connectors:t.connectors.filter(i=>i.from!==o&&i.to!==o)}:null;case"CONNECT_ITEMS":{const i=n.payload;if(t.connectors.some(r=>r.id===i.id))return t;if(t.items.some(r=>r.id===i.id)||i.from===i.to||!t.items.some(r=>r.id===i.from)||!t.items.some(r=>r.id===i.to))return null;const s={id:i.id,from:i.from,to:i.to,style:i.style??"arrow",route:i.route??"straight",...i.label===void 0||i.label===""?{}:{label:i.label}};return{...t,connectors:[...t.connectors,s]}}case"SET_CONNECTOR_LABEL":return xd(t,o,i=>{const{label:s,...r}=i;return n.payload.label===""?r:{...r,label:n.payload.label}});case"SET_CONNECTOR_ROUTE":return xd(t,o,i=>({...i,route:n.payload.route}));case"DELETE_CONNECTOR":return t.connectors.some(i=>i.id===o)?{...t,connectors:t.connectors.filter(i=>i.id!==o)}:null;default:return Kn(n)}},Ft=(t,e,n)=>{const o=t.items.find(s=>s.id===e);if(o===void 0)return null;const i=n(o);return i===null?null:{...t,items:t.items.map(s=>s.id===e?i:s)}},wb=(t,e,n)=>{const o=t.items.find(r=>r.id===e);if(o===void 0||n===e)return null;const i=t.items.filter(r=>r.id!==e),s=n===null?0:i.findIndex(r=>r.id===n)+1;return s===0&&n!==null?null:{...t,items:[...i.slice(0,s),o,...i.slice(s)]}},xd=(t,e,n)=>{const o=t.connectors.find(s=>s.id===e);if(o===void 0)return null;const i=n(o);return{...t,connectors:t.connectors.map(s=>s.id===e?i:s)}},$b=t=>t==="comment"?"meta":t,Eb=t=>{const e=Ne(t);if(e===null||e.length!==3)return null;const[,n,o]=e;return n===void 0||o===void 0||n===""||o===""?null:{type:n,id:o}},Tb=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=bd(t,s,o).title;if(!(s.type in ti)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=Eb(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=vb(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=bd(t,d,l,o);i.push({id:s.id,title:c.title,tone:$b(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Oe={kind:"idle"},bt=(t,e)=>t.kind==="editing"&&t.itemId===e,Sb={front:Le(vl),forward:Le(il),backward:Le(ol),back:Le(El)},yd=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}]],Mb={straight:Le([...yd,["path",{d:"M6.5 17.5 17.5 6.5"}]]),elbow:Le([...yd,["path",{d:"M7 19h5V5h5"}]]),curve:Le(Tl)},Cb=t=>Sb[t](),Lb=t=>Mb[t](),Ib=Le(wl),Ab=Le($l),Rb={yellow:{paper:"#fff0a3",ink:"#4a3a06",stroke:"#d9a900"},orange:{paper:"#ffd1a0",ink:"#4a2503",stroke:"#ec7f1d"},pink:{paper:"#ffc9dd",ink:"#4b1029",stroke:"#de4479"},purple:{paper:"#ddcbf8",ink:"#32195c",stroke:"#8a5bd6"},blue:{paper:"#c0ddf7",ink:"#0e2c4b",stroke:"#3a80d4"},green:{paper:"#cdeba5",ink:"#22380a",stroke:"#55a42c"},gray:{paper:"#e3e6eb",ink:"#2a2f38",stroke:"#868d99"}},kd=t=>{const{paper:e,ink:n,stroke:o}=Rb[t];return`--wb-paper:${e};--wb-ink:${n};--wb-stroke:${o}`},vd={sticky:"addSticky",text:"addText",rect:"addRect",ellipse:"addEllipse",frame:"addFrame"},wd={small:.8,medium:1,large:1.4,xlarge:2},_b=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},Db=t=>{const{m:e,state:n,viewport:o,gesture:i,handlers:s}=t,r=["wb-canvas"];i?.moved===!0&&r.push("wb-canvas--gesturing"),i?.kind==="pan"&&i.moved&&r.push("wb-canvas--panning"),i?.kind==="connect"&&r.push("wb-canvas--connecting"),(t.panReady||i?.kind==="pan")&&r.push("wb-canvas--pan-ready");const a=Qa(n);return k`<div
5214
5588
  class=${r.join(" ")}
5215
5589
  data-testid="wb-canvas"
5216
5590
  tabindex="0"
5217
5591
  role="application"
5218
5592
  aria-label=${e.canvasLabel}
5219
- style=${ib(o)}
5593
+ style=${_b(o)}
5220
5594
  @pointerdown=${s.canvasPointerDown}
5221
5595
  @pointermove=${s.canvasPointerMove}
5222
5596
  @pointerup=${s.canvasPointerUp}
@@ -5231,27 +5605,27 @@ ${o.renameContextHint}`}
5231
5605
  class="wb-world"
5232
5606
  style=${`transform:translate(${o.x}px, ${o.y}px) scale(${o.zoom});--wb-zoom:${o.zoom}`}
5233
5607
  >
5234
- ${Te(a,d=>d.id,d=>db(t,d))}
5235
- ${hb(t)} ${ub(t)}
5608
+ ${Me(a,d=>d.id,d=>zb(t,d))}
5609
+ ${Ub(t)} ${Bb(t)}
5236
5610
  </div>
5237
- ${n.items.length===0?v`<p class="wb-hint wb-hint--empty">${e.emptyHint}</p>`:M}
5238
- ${rb(t)} ${i?.moved===!0?M:t.overlay} ${mb(e,s)}
5239
- ${gb(e,o,s)}
5240
- </div>`},rb=({marquee:t,viewport:e})=>{if(t===void 0)return M;const n=ni(e,t),o=`width:${t.w*e.zoom}px;height:${t.h*e.zoom}px`;return v`<div
5611
+ ${n.items.length===0?k`<p class="wb-hint wb-hint--empty">${e.emptyHint}</p>`:T}
5612
+ ${Ob(t)} ${i?.moved===!0?T:t.overlay} ${Hb(e,s)}
5613
+ ${Yb(e,o,s)}
5614
+ </div>`},Ob=({marquee:t,viewport:e})=>{if(t===void 0)return T;const n=ai(e,t),o=`width:${t.w*e.zoom}px;height:${t.h*e.zoom}px`;return k`<div
5241
5615
  class="wb-marquee"
5242
5616
  aria-hidden="true"
5243
5617
  style=${`left:${n.x}px;top:${n.y}px;${o}`}
5244
- ></div>`},ab=(t,e)=>{const n=["wb-item",`wb-item--${e.kind}`];e.kind==="shape"&&n.push(`wb-item--${e.shape}`),t.selectedIds.has(e.id)&&n.push("is-selected"),mt(t.mode,e.id)&&n.push("is-editing");const o=t.gesture;return o?.kind==="move"&&o.moved&&o.origins.some(i=>i.id===e.id)&&n.push("is-lifted"),o?.kind==="connect"&&o.targetId===e.id&&n.push("is-target"),n.join(" ")},db=(t,e)=>{const{handlers:n}=t,o=`left:${e.x}px;top:${e.y}px;width:${e.w}px;height:${e.h}px`,i=_n(e)?`;${ad(e.color)}`:"",s=Ot(e)?`;--wb-font-scale:${ld[e.fontSize]}`:"",r=t.selectedIds.size===1&&t.selectedIds.has(e.id)&&t.gesture?.moved!==!0,a=r&&!mt(t.mode,e.id),d=l=>n.itemPointerDown(e.id,l);return v`<div
5245
- class=${ab(t,e)}
5618
+ ></div>`},Nb=(t,e)=>{const n=["wb-item",`wb-item--${e.kind}`];e.kind==="shape"&&n.push(`wb-item--${e.shape}`),t.selectedIds.has(e.id)&&n.push("is-selected"),bt(t.mode,e.id)&&n.push("is-editing");const o=t.gesture;return o?.kind==="move"&&o.moved&&o.origins.some(i=>i.id===e.id)&&n.push("is-lifted"),o?.kind==="connect"&&o.targetId===e.id&&n.push("is-target"),n.join(" ")},zb=(t,e)=>{const{handlers:n}=t,o=`left:${e.x}px;top:${e.y}px;width:${e.w}px;height:${e.h}px`,i=Dn(e)?`;${kd(e.color)}`:"",s=Nt(e)?`;--wb-font-scale:${wd[e.fontSize]}`:"",r=t.selectedIds.size===1&&t.selectedIds.has(e.id)&&t.gesture?.moved!==!0,a=r&&!bt(t.mode,e.id),d=l=>n.itemPointerDown(e.id,l);return k`<div
5619
+ class=${Nb(t,e)}
5246
5620
  style=${`${o}${i}${s}`}
5247
5621
  data-item-id=${e.id}
5248
5622
  data-dpk-target=${t.commentRef("item",e.id)}
5249
- data-grill-questions=${Kt(Ut(e.questions))}
5623
+ data-grill-questions=${Wt(Yt(e.questions))}
5250
5624
  data-kind=${e.kind}
5251
- @pointerdown=${e.kind==="frame"?M:d}
5625
+ @pointerdown=${e.kind==="frame"?T:d}
5252
5626
  >
5253
- ${e.kind==="frame"?v`<div class="wb-frame-title" @pointerdown=${d}>${cd(t,e)}</div>`:v`<div class="wb-item-body">${cd(t,e)}</div>`}
5254
- ${e.kind==="frame"?M:v`<div class="wb-item-actions" @pointerdown=${gt} @click=${gt}>
5627
+ ${e.kind==="frame"?k`<div class="wb-frame-title" @pointerdown=${d}>${$d(t,e)}</div>`:k`<div class="wb-item-body">${$d(t,e)}</div>`}
5628
+ ${e.kind==="frame"?T:k`<div class="wb-item-actions" @pointerdown=${xt} @click=${xt}>
5255
5629
  <button
5256
5630
  class="dpk-icon-btn"
5257
5631
  type="button"
@@ -5260,16 +5634,16 @@ ${o.renameContextHint}`}
5260
5634
  aria-label=${t.m.comment}
5261
5635
  @click=${()=>t.onComment(e.id)}
5262
5636
  >
5263
- ${Yn()}
5637
+ ${Xn()}
5264
5638
  </button>
5265
5639
  </div>`}
5266
- ${a?v`${lb.map(l=>v`<span
5640
+ ${a?k`${Pb.map(l=>k`<span
5267
5641
  class=${`wb-edge wb-edge--${l}`}
5268
5642
  role="presentation"
5269
5643
  aria-hidden="true"
5270
5644
  @pointerdown=${c=>n.resizePointerDown(e.id,c,l)}
5271
- ></span>`)}`:M}
5272
- ${r?v`<span
5645
+ ></span>`)}`:T}
5646
+ ${r?k`<span
5273
5647
  class="wb-handle wb-handle--resize"
5274
5648
  role="presentation"
5275
5649
  title=${t.m.resizeHandle}
@@ -5280,8 +5654,8 @@ ${o.renameContextHint}`}
5280
5654
  role="presentation"
5281
5655
  title=${t.m.connectHandle}
5282
5656
  @pointerdown=${l=>n.connectPointerDown(e.id,l)}
5283
- ></span>`:M}
5284
- </div>`},lb=["n","e","s","w","ne","sw","nw"],cb=t=>t.stopPropagation(),cd=(t,e)=>{const{m:n,handlers:o}=t,i=We(e);if(!mt(t.mode,e.id))return v`<span class="wb-text">${i}</span>`;const s=d=>{const l=d.currentTarget;(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement)&&o.editBlur(e.id,l.value)},r=d=>o.editKeyDown(e.id,d),a=d=>{const l=d.currentTarget;l instanceof HTMLInputElement&&l.previousElementSibling?.setAttribute("data-copy",l.value||n.textPlaceholder)};return e.kind==="frame"?v`<span class="wb-title-edit"
5657
+ ></span>`:T}
5658
+ </div>`},Pb=["n","e","s","w","ne","sw","nw"],qb=t=>t.stopPropagation(),$d=(t,e)=>{const{m:n,handlers:o}=t,i=Ze(e);if(!bt(t.mode,e.id))return k`<span class="wb-text">${i}</span>`;const s=d=>{const l=d.currentTarget;(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement)&&o.editBlur(e.id,l.value)},r=d=>o.editKeyDown(e.id,d),a=d=>{const l=d.currentTarget;l instanceof HTMLInputElement&&l.previousElementSibling?.setAttribute("data-copy",l.value||n.textPlaceholder)};return e.kind==="frame"?k`<span class="wb-title-edit"
5285
5659
  ><span class="wb-text" aria-hidden="true" data-copy=${i||n.textPlaceholder}></span
5286
5660
  ><input
5287
5661
  class="wb-editor"
@@ -5292,7 +5666,7 @@ ${o.renameContextHint}`}
5292
5666
  @input=${a}
5293
5667
  @blur=${s}
5294
5668
  @keydown=${r}
5295
- /></span>`:v`<textarea
5669
+ /></span>`:k`<textarea
5296
5670
  class="wb-editor"
5297
5671
  .value=${i}
5298
5672
  placeholder=${n.textPlaceholder}
@@ -5300,54 +5674,54 @@ ${o.renameContextHint}`}
5300
5674
  spellcheck="false"
5301
5675
  @blur=${s}
5302
5676
  @keydown=${r}
5303
- @wheel=${cb}
5304
- ></textarea>`},pb=()=>Y`<marker id="wb-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">
5677
+ @wheel=${qb}
5678
+ ></textarea>`},Fb=()=>Y`<marker id="wb-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">
5305
5679
  <path d="M0,0 L10,5 L0,10 z"></path>
5306
- </marker>`,pd=(t,e)=>{const n=j(t,e.from),o=j(t,e.to);return n===void 0||o===void 0?void 0:[n,o]},hd=t=>t.label!==void 0,ud=(t,e,n)=>hd(e)===n?t.commentRef("connector",e.id):M,hb=t=>{const{state:e,handlers:n,gesture:o}=t,i=e.connectors.map(r=>{const a=pd(e,r);if(a===void 0)return M;const{d}=Qo(...a,r.route),l=t.selectedIds.has(r.id)?" is-selected":"";return Y`<g data-connector-id=${r.id} data-dpk-target=${ud(t,r,!1)} data-dpk-check="off">
5680
+ </marker>`,Ed=(t,e)=>{const n=W(t,e.from),o=W(t,e.to);return n===void 0||o===void 0?void 0:[n,o]},Td=t=>t.label!==void 0,Sd=(t,e,n)=>Td(e)===n?t.commentRef("connector",e.id):T,Ub=t=>{const{state:e,handlers:n,gesture:o}=t,i=e.connectors.map(r=>{const a=Ed(e,r);if(a===void 0)return T;const{d}=ni(...a,r.route),l=t.selectedIds.has(r.id)?" is-selected":"";return Y`<g data-connector-id=${r.id} data-dpk-target=${Sd(t,r,!1)} data-dpk-check="off">
5307
5681
  <path class="wb-link-hit" d=${d} @pointerdown=${c=>n.connectorPointerDown(r.id,c)}></path>
5308
- <path class=${`wb-link${l}`} d=${d} marker-end=${r.style==="arrow"?"url(#wb-arrow)":M}></path>
5309
- </g>`});let s=M;if(o?.kind==="connect"&&o.moved){const r=j(e,o.fromId),a=o.targetId===void 0?void 0:j(e,o.targetId);if(r!==void 0){const d=a===void 0?o.current:On(a,ht(r)),l=On(r,d);s=Y`<path class="wb-link wb-link--draft" d=${`M ${l.x} ${l.y} L ${d.x} ${d.y}`} marker-end="url(#wb-arrow)"></path>`}}return v`<svg class="wb-links" width="1" height="1" aria-hidden="true">
5310
- <defs>${pb()}</defs>
5682
+ <path class=${`wb-link${l}`} d=${d} marker-end=${r.style==="arrow"?"url(#wb-arrow)":T}></path>
5683
+ </g>`});let s=T;if(o?.kind==="connect"&&o.moved){const r=W(e,o.fromId),a=o.targetId===void 0?void 0:W(e,o.targetId);if(r!==void 0){const d=a===void 0?o.current:zn(a,gt(r)),l=zn(r,d);s=Y`<path class="wb-link wb-link--draft" d=${`M ${l.x} ${l.y} L ${d.x} ${d.y}`} marker-end="url(#wb-arrow)"></path>`}}return k`<svg class="wb-links" width="1" height="1" aria-hidden="true">
5684
+ <defs>${Fb()}</defs>
5311
5685
  ${i} ${s}
5312
- </svg>`},ub=t=>{const{state:e,handlers:n}=t;return e.connectors.flatMap(o=>{const i=pd(e,o);if(i===void 0||!hd(o))return[];const{mid:s}=Qo(...i,o.route),r=t.selectedIds.has(o.id)?" is-selected":"";return[v`<div
5686
+ </svg>`},Bb=t=>{const{state:e,handlers:n}=t;return e.connectors.flatMap(o=>{const i=Ed(e,o);if(i===void 0||!Td(o))return[];const{mid:s}=ni(...i,o.route),r=t.selectedIds.has(o.id)?" is-selected":"";return[k`<div
5313
5687
  class=${`wb-link-label${r}`}
5314
5688
  data-connector-label=${o.id}
5315
- data-dpk-target=${ud(t,o,!0)}
5689
+ data-dpk-target=${Sd(t,o,!0)}
5316
5690
  data-dpk-check="off"
5317
5691
  style=${`left:${s.x}px;top:${s.y}px`}
5318
5692
  @pointerdown=${a=>n.connectorPointerDown(o.id,a)}
5319
5693
  >
5320
- ${o.label??M}
5321
- </div>`]})},gt=t=>t.stopPropagation(),mb=(t,e)=>v`<div class="wb-tools" role="toolbar" aria-label=${t.toolsLabel} @pointerdown=${gt} @dblclick=${gt}>
5322
- ${pf.map(n=>v`<button
5694
+ ${o.label??T}
5695
+ </div>`]})},xt=t=>t.stopPropagation(),Hb=(t,e)=>k`<div class="wb-tools" role="toolbar" aria-label=${t.toolsLabel} @pointerdown=${xt} @dblclick=${xt}>
5696
+ ${Ff.map(n=>k`<button
5323
5697
  type="button"
5324
5698
  class="wb-tool"
5325
5699
  data-add=${n}
5326
- title=${t[dd[n]]}
5327
- aria-label=${t[dd[n]]}
5700
+ title=${t[vd[n]]}
5701
+ aria-label=${t[vd[n]]}
5328
5702
  @click=${()=>e.addItem(n)}
5329
5703
  >
5330
5704
  <span class=${`wb-tool-icon wb-tool-icon--${n}`} aria-hidden="true"></span>
5331
5705
  </button>`)}
5332
- </div>`,gb=(t,e,n)=>v`<div class="wb-zoom" @pointerdown=${gt} @dblclick=${gt}>
5333
- <button type="button" aria-label=${t.zoomOut} @click=${()=>n.zoomStep(-1)}>${Gd()}</button>
5706
+ </div>`,Yb=(t,e,n)=>k`<div class="wb-zoom" @pointerdown=${xt} @dblclick=${xt}>
5707
+ <button type="button" aria-label=${t.zoomOut} @click=${()=>n.zoomStep(-1)}>${sl()}</button>
5334
5708
  <button type="button" class="wb-zoom-pct" title=${t.zoomReset} @click=${()=>n.zoomReset()}>
5335
5709
  ${Math.round(e.zoom*100)}%
5336
5710
  </button>
5337
- <button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${Un()}</button>
5711
+ <button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${Gn()}</button>
5338
5712
  <button type="button" aria-label=${t.zoomFit} title=${t.zoomFit} @click=${()=>n.zoomFit()}>
5339
- ${nb()}
5713
+ ${Ab()}
5340
5714
  </button>
5341
- </div>`,ii={item:14,frame:40,connector:18},fb=t=>{const{selection:e,viewport:n,state:o}=t;if(e.kind==="items"){const a=An(e.items);if(a===null)return;const d=e.items.some(c=>c.kind==="frame"&&c.y===a.y),l=ni(n,{x:a.x+a.w/2,y:a.y});return{x:l.x,y:l.y-(d?ii.frame:ii.item)}}const i=j(o,e.connector.from),s=j(o,e.connector.to);if(i===void 0||s===void 0)return;const r=ni(n,Qo(i,s,e.connector.route).mid);return{x:r.x,y:r.y-ii.connector}},si=t=>t.stopPropagation(),Pn=v`<span class="wb-toolbar-sep" aria-hidden="true"></span>`,md=t=>t.length>0&&t.every(e=>e===t[0])?t[0]:void 0,bb=t=>{const e=fb(t);if(e===void 0)return M;const{m:n,selection:o,handlers:i}=t,s=o.kind==="items"&&o.items.length>1?n.selectionCount(o.items.length):n.selectionLabel;return v`<div
5715
+ </div>`,li={item:14,frame:40,connector:18},Gb=t=>{const{selection:e,viewport:n,state:o}=t;if(e.kind==="items"){const a=Nn(e.items);if(a===null)return;const d=e.items.some(c=>c.kind==="frame"&&c.y===a.y),l=ai(n,{x:a.x+a.w/2,y:a.y});return{x:l.x,y:l.y-(d?li.frame:li.item)}}const i=W(o,e.connector.from),s=W(o,e.connector.to);if(i===void 0||s===void 0)return;const r=ai(n,ni(i,s,e.connector.route).mid);return{x:r.x,y:r.y-li.connector}},ci=t=>t.stopPropagation(),Un=k`<span class="wb-toolbar-sep" aria-hidden="true"></span>`,Md=t=>t.length>0&&t.every(e=>e===t[0])?t[0]:void 0,Xb=t=>{const e=Gb(t);if(e===void 0)return T;const{m:n,selection:o,handlers:i}=t,s=o.kind==="items"&&o.items.length>1?n.selectionCount(o.items.length):n.selectionLabel;return k`<div
5342
5716
  class="wb-toolbar"
5343
5717
  role="toolbar"
5344
5718
  aria-label=${s}
5345
5719
  style=${`left:${e.x}px;top:${e.y}px`}
5346
- @pointerdown=${si}
5347
- @dblclick=${si}
5348
- @keydown=${si}
5720
+ @pointerdown=${ci}
5721
+ @dblclick=${ci}
5722
+ @keydown=${ci}
5349
5723
  >
5350
- ${o.kind==="items"?yb(t,o.items):kb(t,o.connector)}
5724
+ ${o.kind==="items"?jb(t,o.items):Vb(t,o.connector)}
5351
5725
  <button
5352
5726
  type="button"
5353
5727
  class="dpk-icon-btn wb-toolbar-btn"
@@ -5356,25 +5730,25 @@ ${o.renameContextHint}`}
5356
5730
  title=${n.delete}
5357
5731
  @click=${()=>i.deleteSelection()}
5358
5732
  >
5359
- ${Ft()}
5733
+ ${Bt()}
5360
5734
  </button>
5361
- </div>`},xb={front:"\u2318/Ctrl ]",forward:"]",backward:"[",back:"\u2318/Ctrl ["},yb=(t,e)=>{const{m:n,handlers:o}=t,i=e.filter(_n).map(d=>d.color),s=e.flatMap(d=>Ot(d)?[d.fontSize]:[]),r=md(i),a=md(s);return v`
5362
- ${i.length>0?v`<div class="wb-swatches" role="radiogroup" aria-label=${n.colorLabelPrefix}>
5363
- ${Xo.map(d=>v`<button
5735
+ </div>`},Kb={front:"\u2318/Ctrl ]",forward:"]",backward:"[",back:"\u2318/Ctrl ["},jb=(t,e)=>{const{m:n,handlers:o}=t,i=e.filter(Dn).map(d=>d.color),s=e.flatMap(d=>Nt(d)?[d.fontSize]:[]),r=Md(i),a=Md(s);return k`
5736
+ ${i.length>0?k`<div class="wb-swatches" role="radiogroup" aria-label=${n.colorLabelPrefix}>
5737
+ ${Vo.map(d=>k`<button
5364
5738
  type="button"
5365
5739
  class="wb-swatch"
5366
5740
  role="radio"
5367
5741
  data-color=${d}
5368
- style=${ad(d)}
5742
+ style=${kd(d)}
5369
5743
  aria-checked=${String(r===d)}
5370
5744
  aria-label=${`${n.colorLabelPrefix}: ${n.colorLabel(d)}`}
5371
5745
  title=${n.colorLabel(d)}
5372
5746
  @click=${()=>o.setColor(d)}
5373
5747
  ></button>`)}
5374
5748
  </div>
5375
- ${Pn}`:M}
5376
- ${s.length>0?v`<div class="wb-choice" role="radiogroup" aria-label=${n.fontSizeLabelPrefix}>
5377
- ${Go.map(d=>v`<button
5749
+ ${Un}`:T}
5750
+ ${s.length>0?k`<div class="wb-choice" role="radiogroup" aria-label=${n.fontSizeLabelPrefix}>
5751
+ ${Qo.map(d=>k`<button
5378
5752
  type="button"
5379
5753
  class="wb-choice-btn"
5380
5754
  role="radio"
@@ -5387,9 +5761,9 @@ ${o.renameContextHint}`}
5387
5761
  ${n.fontSizeShort(d)}
5388
5762
  </button>`)}
5389
5763
  </div>
5390
- ${Pn}`:M}
5391
- ${t.arrange.size>0?v`${vb(t)} ${Pn}`:M}
5392
- `},vb=t=>{const{m:e,handlers:n}=t,o={front:e.bringToFront,forward:e.bringForward,backward:e.sendBackward,back:e.sendToBack};return v`<div class="wb-menu-anchor" @keydown=${s=>{s.key==="Escape"&&n.toggleArrangeMenu()}}>
5764
+ ${Un}`:T}
5765
+ ${t.arrange.size>0?k`${Wb(t)} ${Un}`:T}
5766
+ `},Wb=t=>{const{m:e,handlers:n}=t,o={front:e.bringToFront,forward:e.bringForward,backward:e.sendBackward,back:e.sendToBack};return k`<div class="wb-menu-anchor" @keydown=${s=>{s.key==="Escape"&&n.toggleArrangeMenu()}}>
5393
5767
  <button
5394
5768
  type="button"
5395
5769
  class="wb-menu-btn"
@@ -5400,10 +5774,10 @@ ${o.renameContextHint}`}
5400
5774
  title=${e.arrangeLabel}
5401
5775
  @click=${()=>n.toggleArrangeMenu()}
5402
5776
  >
5403
- ${tb()} ${yi()}
5777
+ ${Ib()} ${Ei()}
5404
5778
  </button>
5405
- ${t.arrangeMenuOpen?v`<div class="wb-menu" role="menu" aria-label=${e.arrangeLabel}>
5406
- ${Fa.map(s=>v`<button
5779
+ ${t.arrangeMenuOpen?k`<div class="wb-menu" role="menu" aria-label=${e.arrangeLabel}>
5780
+ ${Ja.map(s=>k`<button
5407
5781
  type="button"
5408
5782
  class="wb-menu-item"
5409
5783
  role="menuitem"
@@ -5411,13 +5785,13 @@ ${o.renameContextHint}`}
5411
5785
  ?disabled=${!t.arrange.has(s)}
5412
5786
  @click=${()=>n.arrange(s)}
5413
5787
  >
5414
- ${Jf(s)}
5788
+ ${Cb(s)}
5415
5789
  <span class="wb-menu-label">${o[s]}</span>
5416
- <kbd class="wb-menu-key">${xb[s]}</kbd>
5790
+ <kbd class="wb-menu-key">${Kb[s]}</kbd>
5417
5791
  </button>`)}
5418
- </div>`:M}
5419
- </div>`},kb=(t,e)=>{const{m:n,handlers:o}=t;return v`<div class="wb-choice" role="radiogroup" aria-label=${n.routeLabelPrefix}>
5420
- ${In.map(i=>v`<button
5792
+ </div>`:T}
5793
+ </div>`},Vb=(t,e)=>{const{m:n,handlers:o}=t;return k`<div class="wb-choice" role="radiogroup" aria-label=${n.routeLabelPrefix}>
5794
+ ${An.map(i=>k`<button
5421
5795
  type="button"
5422
5796
  class="wb-choice-btn wb-choice-btn--icon"
5423
5797
  role="radio"
@@ -5427,17 +5801,17 @@ ${o.renameContextHint}`}
5427
5801
  title=${n.routeLabel(i)}
5428
5802
  @click=${()=>o.setRoute(e.id,i)}
5429
5803
  >
5430
- ${eb(i)}
5804
+ ${Lb(i)}
5431
5805
  </button>`)}
5432
5806
  </div>
5433
- ${Pn}
5807
+ ${Un}
5434
5808
  <dpk-inline-edit
5435
5809
  class="wb-toolbar-label"
5436
5810
  .value=${e.label??""}
5437
5811
  .placeholder=${n.labelPlaceholder}
5438
5812
  .label=${n.labelField}
5439
- @dpk-commit=${Hn(i=>o.setLabel(e.id,i))}
5440
- ></dpk-inline-edit>`},gd=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],wb=ae`
5813
+ @dpk-commit=${nt(i=>o.setLabel(e.id,i))}
5814
+ ></dpk-inline-edit>`},Cd=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],Qb=de`
5441
5815
  /*
5442
5816
  * The shell (\`<dpk-dialog-panel class="whiteboard">\`) is a panel: header, tag
5443
5817
  * row, canvas; \`--dpk-dialog-panel-height\` is the knob it reads for its own
@@ -6305,18 +6679,18 @@ ${o.renameContextHint}`}
6305
6679
  outline: 2px solid var(--dpk-blue);
6306
6680
  outline-offset: 1px;
6307
6681
  }
6308
- `,$b=10,fd=8,bd=72,Eb=t=>t!==void 0,Tb="whiteboard";class xd extends tt{constructor(){super(...arguments),this.mode=Ae,this.viewport=Mf,this.gesture=void 0,this.panReady=!1,this.arrangeMenu=!1,this.selectedIds=[],this.#o=!1,this.#i=!1,this.#r={on:"other"},this.#s=!1,this.#d=!1,this.#p=[],this.#u=0}boardAddable(){return!0}static{this.styles=[et,wb]}#o;#i;#e;#n;#t;#a;#r;#s;#d;#c;#p;#u;parseData(e){return jg(e)}emptyData(){return Wg()}reduceElementActions(e,n){return Vf(zt(this.locale),e,n)}defaultHeading(){return zt(this.locale).heading}shellClass(){return"whiteboard"}commentItems(){const e=this.items(),n=zt(this.locale);return[{value:this.commentRef("page",Tb),label:n.wholeBoard},...e.items.map(o=>({value:this.commentRef("item",o.id),label:nd(n,o)})),...e.connectors.map(o=>({value:this.commentRef("connector",o.id),label:od(n,e,o)}))]}hasSelection(e){const n=this.items();return e.kind==="item"?j(n,e.id)!==void 0:be(n,e.id)!==void 0}render(){this.prepareRender();const e=zt(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject(),i=ja(this.items(),this.gesture),s=Ga(this.gesture),r=s!==void 0&&this.gesture!==void 0?Ka(this.items(),this.gesture):this.selectedIds;return v`
6682
+ `,Zb=10,Ld=8,Id=72,Jb=t=>t!==void 0,ex="whiteboard";class Ad extends st{constructor(){super(...arguments),this.mode=Oe,this.viewport=nb,this.gesture=void 0,this.panReady=!1,this.arrangeMenu=!1,this.selectedIds=[],this.#o=!1,this.#i=!1,this.#r={on:"other"},this.#s=!1,this.#d=!1,this.#h=[],this.#p=0}boardAddable(){return!0}static{this.styles=[it,Qb]}#o;#i;#e;#t;#n;#a;#r;#s;#d;#c;#h;#p;parseData(e){return Ef(e)}emptyData(){return Tf()}reduceElementActions(e,n){return Tb(qt(this.locale),e,n)}defaultHeading(){return qt(this.locale).heading}shellClass(){return"whiteboard"}commentItems(){const e=this.items(),n=qt(this.locale);return[{value:this.commentRef("page",ex),label:n.wholeBoard},...e.items.map(o=>({value:this.commentRef("item",o.id),label:gd(n,o)})),...e.connectors.map(o=>({value:this.commentRef("connector",o.id),label:fd(n,e,o)}))]}hasSelection(e){const n=this.items();return e.kind==="item"?W(n,e.id)!==void 0:xe(n,e.id)!==void 0}render(){this.prepareRender();const e=qt(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject(),i=ad(this.items(),this.gesture),s=sd(this.gesture),r=s!==void 0&&this.gesture!==void 0?rd(this.items(),this.gesture):this.selectedIds;return k`
6309
6683
  <dpk-dialog-panel
6310
6684
  class=${this.shellClass()}
6311
6685
  flush
6312
6686
  ?maximizable=${this.frameControls}
6313
6687
  ?resizable=${this.frameControls}
6314
6688
  heading=${this.heading??this.defaultHeading()}
6315
- subject=${o===""?M:o}
6689
+ subject=${o===""?T:o}
6316
6690
  @dpk-maximize-change=${()=>this.closeComposer()}
6317
6691
  >
6318
6692
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
6319
- ${this.dataError!==null?v`<p class="wb-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:sb({m:e,state:i,viewport:this.viewport,gesture:this.gesture,mode:this.mode,selectedIds:new Set(r),marquee:s,panReady:this.panReady,overlay:this.#g(i,e),commentRef:(a,d)=>this.commentRef(a,d),onComment:a=>this.openComment(this.commentRef("item",a)),handlers:{canvasPointerDown:a=>this.#Y(a),canvasPointerMove:a=>this.#X(a),canvasPointerUp:a=>this.#G(a),canvasPointerCancel:()=>{this.gesture=void 0,this.requestUpdate()},canvasWheel:a=>this.#S(a),canvasDblClick:a=>this.#x(a),canvasKeyDown:a=>this.#W(a),canvasKeyUp:a=>{a.key===" "&&(this.panReady=!1),a.key==="Shift"&&this.#B(!1),this.requestUpdate()},canvasBlur:()=>{this.panReady=!1,this.requestUpdate()},itemPointerDown:(a,d)=>this.#z(a,d),resizePointerDown:(a,d,l)=>this.#q(a,d,l),connectPointerDown:(a,d)=>this.#P(d,$f(a,d.pointerId,this.#E(d))),connectorPointerDown:(a,d)=>this.#F(a,d),editBlur:(a,d)=>this.#k(a,d),editKeyDown:(a,d)=>this.#w(a,d),addItem:a=>this.#N(a,this.#H()),zoomStep:a=>this.#j(a===1?1.2:1/1.2),zoomFit:()=>this.#te(),zoomReset:()=>this.#j(1/this.viewport.zoom)}})}
6693
+ ${this.dataError!==null?k`<p class="wb-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:Db({m:e,state:i,viewport:this.viewport,gesture:this.gesture,mode:this.mode,selectedIds:new Set(r),marquee:s,panReady:this.panReady,overlay:this.#g(i,e),commentRef:(a,d)=>this.commentRef(a,d),onComment:a=>this.openComment(this.commentRef("item",a)),handlers:{canvasPointerDown:a=>this.#O(a),canvasPointerMove:a=>this.#G(a),canvasPointerUp:a=>this.#X(a),canvasPointerCancel:()=>{this.gesture=void 0,this.requestUpdate()},canvasWheel:a=>this.#L(a),canvasDblClick:a=>this.#y(a),canvasKeyDown:a=>this.#W(a),canvasKeyUp:a=>{a.key===" "&&(this.panReady=!1),a.key==="Shift"&&this.#H(!1),this.requestUpdate()},canvasBlur:()=>{this.panReady=!1,this.requestUpdate()},itemPointerDown:(a,d)=>this.#N(a,d),resizePointerDown:(a,d,l)=>this.#U(a,d,l),connectPointerDown:(a,d)=>this.#z(d,Zf(a,d.pointerId,this.#$(d))),connectorPointerDown:(a,d)=>this.#B(a,d),editBlur:(a,d)=>this.#E(a,d),editKeyDown:(a,d)=>this.#v(a,d),addItem:a=>this.#P(a,this.#F()),zoomStep:a=>this.#j(a===1?1.2:1/1.2),zoomFit:()=>this.#te(),zoomReset:()=>this.#j(1/this.viewport.zoom)}})}
6320
6694
  </dpk-dialog-panel>
6321
6695
  ${this.renderSelection()}
6322
- `}updated(){super.updated();const e=this.#T();e!==null&&(this.#oe(e),this.#ne(),this.#h(),this.#C())}disconnectedCallback(){super.disconnectedCallback(),this.#e?.disconnect(),this.#e=void 0,this.#n=void 0}#h(){const e=this.#T(),n=this.renderRoot.querySelector(".wb-toolbar");if(e===null||n===null)return;const o=u=>Number.parseFloat(n.style.getPropertyValue(`--wb-nudge-${u}`))||0,i=e.getBoundingClientRect(),s=n.getBoundingClientRect(),r=this.renderRoot.querySelector(".wb-tools")?.getBoundingClientRect(),a=s.top-o("y"),l=r!==void 0&&a<r.bottom&&a+s.height>r.top?r.right-i.left:0;n.style.setProperty("--wb-toolbar-floor",`${l}px`);const c=n.getBoundingClientRect(),h=Ja(c.left-o("x")-i.left,c.width,i.width,fd,l),p=Ja(c.top-o("y")-i.top,c.height,i.height,fd);n.style.setProperty("--wb-nudge-x",`${h}px`),n.style.setProperty("--wb-nudge-y",`${p}px`)}#l(e){if(this.arrangeMenu=!1,this.selectedIds=e,e.length===1){const n=e[0];n!==void 0&&this.select({kind:be(this.items(),n)!==void 0?"connector":"item",id:n})}else this.select(null);this.requestUpdate()}#m(e){return this.selectedIds.map(n=>j(e,n)).filter(Eb)}#g(e,n){if(this.mode.kind==="editing")return M;const o=this.selectedIds,i=this.#m(e),s=o.length===1?be(e,o[0]):void 0,r=s!==void 0?{kind:"connector",connector:s}:i.length>0?{kind:"items",items:i}:void 0;return r===void 0?M:bb({m:n,state:e,viewport:this.viewport,selection:r,arrange:lf(e,o),arrangeMenuOpen:this.arrangeMenu,handlers:{setColor:a=>this.#V(a),setFontSize:a=>this.#Q(a),arrange:a=>{this.arrangeMenu=!1,this.#K(a),this.requestUpdate()},toggleArrangeMenu:()=>{this.arrangeMenu=!this.arrangeMenu,this.requestUpdate()},deleteSelection:()=>this.#U(),setLabel:(a,d)=>this.#A(re.setConnectorLabel(a,d)),setRoute:(a,d)=>{be(e,a)?.route!==d&&this.#A(re.setConnectorRoute(a,d))}}})}#f(e){return this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"] .wb-editor`)}#y(e,n){if(mt(this.mode,e))return;this.#b();const o=this.items();if(j(o,e)===void 0)return;const i=n===void 0?null:this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"] .wb-text`);this.#a=i===null||n===void 0?void 0:cf(i,n.clientX,n.clientY);const s=this.selectedIds;(s.length!==1||s[0]!==e)&&this.#l([e]),this.mode={kind:"editing",itemId:e},this.requestUpdate()}#C(){if(this.mode.kind!=="editing"){this.#t=void 0;return}const{itemId:e}=this.mode;if(this.#t===e)return;const n=this.#f(e);if(n===null)return;this.#t=e,n.focus({preventScroll:!0});const o=Math.min(this.#a??n.value.length,n.value.length);n.setSelectionRange(o,o),this.#a=void 0}#k(e,n){if(!mt(this.mode,e))return;this.mode=Ae,this.requestUpdate(),this.#t=void 0;const o=j(this.items(),e),i=o===void 0?void 0:bf(o,n);o===void 0||i===void 0||this.#O([re.setText(e,i),...this.#v(o)])}#v(e,n){if(!Ot(e))return[];const o=ef(e,this.#M(e.id,n));return o===void 0?[]:[re.resize(e.id,o.w,o.h)]}#M(e,n){const o=this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"]`),i=o?.querySelector(".wb-item-body");if(o==null||i===null||i===void 0)return 0;const s=o.getAttribute("style")??"";n!==void 0&&o.style.setProperty("--wb-font-scale",String(ld[n]));const r=i.querySelector(".wb-editor"),d=(r===null?i.querySelector(".wb-text")?.offsetHeight??0:r.scrollHeight)-i.clientHeight;return o.setAttribute("style",s),d}#b(){if(this.mode.kind!=="editing")return;const{itemId:e}=this.mode,n=this.#f(e);if(n===null){this.mode=Ae,this.requestUpdate();return}this.#k(e,n.value)}#w(e,n){if(n.isComposing)return;if(n.key==="Escape"){n.preventDefault(),this.mode=Ae,this.requestUpdate(),this.#_();return}const o=j(this.items(),e)?.kind==="frame";n.key==="Enter"&&(o||n.metaKey||n.ctrlKey)&&(n.preventDefault(),this.#_())}#T(){return this.renderRoot.querySelector(".wb-canvas")}#$(){const e=this.#T();return{width:e?.clientWidth??0,height:e?.clientHeight??0}}#L(e){const n=this.#T()?.getBoundingClientRect();return n===void 0?{x:e.clientX,y:e.clientY}:{x:e.clientX-n.left,y:e.clientY-n.top}}#E(e){return ti(this.viewport,this.#L(e))}#H(){const{width:e,height:n}=this.#$();return ti(this.viewport,{x:e/2,y:n/2})}#I(e,n){if(n===void 0)return;const o=this.#T();if(o!==null&&typeof o.setPointerCapture=="function")try{o.setPointerCapture(e.pointerId)}catch{}this.gesture=n,this.requestUpdate()}#_(){this.#T()?.focus({preventScroll:!0})}#Y(e){if(this.gesture!==void 0)return;const n=e.button===1||e.button===0&&(this.panReady||e.pointerType==="touch");if(!n&&e.button!==0)return;if(this.#b(),this.arrangeMenu=!1,this.#_(),n){e.preventDefault(),this.#r={on:"other"},this.#I(e,vf(e.pointerId,this.#L(e)));return}this.#r={on:"ground"};const o=this.items(),i=this.selectedIds.filter(r=>j(o,r)!==void 0),s=e.shiftKey?Xa(e.pointerId,this.#E(e),i):wf(o,i,e.pointerId,this.#E(e),[]);this.#s=!1,this.#d=s.kind==="move"&&i.length>1,this.#I(e,s)}#z(e,n){if(n.button!==0||this.panReady||this.gesture!==void 0)return;if(n.stopPropagation(),this.#r={on:"item",itemId:e},mt(this.mode,e)){n.target instanceof Element&&n.target.closest(".wb-editor")!==null||n.preventDefault();return}this.#b(),n.preventDefault(),this.#_(),this.arrangeMenu=!1,this.mode.kind!=="idle"&&(this.mode=Ae);const o=this.items(),i=this.selectedIds;if(n.shiftKey){this.#s=!1,this.#d=!1,this.#l(gd(i,e));return}this.#s=i.length===1&&i[0]===e,this.#d=i.length>1&&i.includes(e),this.#c={clientX:n.clientX,clientY:n.clientY},i.includes(e)||this.#l([e]);const s=this.#d?i:[e];this.#I(n,Jo(o,e,n.pointerId,this.#E(n),s))}#P(e,n){e.button===0&&(e.stopPropagation(),e.preventDefault(),this.#r={on:"other"},this.#b(),this.#_(),this.#I(e,n))}#q(e,n,o){o!==void 0&&this.panReady||this.#P(n,yf(this.items(),e,n.pointerId,this.#E(n),o))}#F(e,n){n.button!==0||this.panReady||(n.stopPropagation(),n.preventDefault(),this.#r={on:"other"},this.#b(),this.#_(),this.mode=Ae,this.#l([e]))}#X(e){const n=this.gesture;if(!(n===void 0||n.pointerId!==e.pointerId)){if(n.kind==="pan"){const o=kf(n,this.#L(e));this.gesture=o.gesture,this.#R(oi(this.viewport,o.dx,o.dy)),this.requestUpdate();return}this.gesture=ei(this.items(),n,e.pointerId,this.#E(e),this.viewport.zoom,e.shiftKey),this.requestUpdate()}}#B(e){const n=this.gesture;n?.kind!=="resize"||n.keepRatio===e||(this.gesture=ei(this.items(),n,n.pointerId,n.current,this.viewport.zoom,e),this.requestUpdate())}#G(e){const n=this.gesture;if(n===void 0||n.pointerId!==e.pointerId)return;const o=this.items(),i=n.kind==="pan"?n:ei(o,n,e.pointerId,this.#E(e),this.viewport.zoom,e.shiftKey);this.gesture=void 0,this.requestUpdate();const s=Qa(o,i);switch(s.kind){case"none":return;case"dispatch":this.#O(s.inputs);return;case"connect":this.#Z(s.from,s.to);return;case"select":this.#l(s.ids);return;case"click":if(i.kind==="pan"||i.kind==="marquee"){this.mode=Ae;const r=i.kind==="marquee"?i.base:[];s.itemId!==void 0?this.#l(r.length>0?gd(r,s.itemId):[s.itemId]):r.length===0&&this.#l([]);return}if(i.kind!=="move"||s.itemId===void 0)return;this.#s?this.#y(s.itemId,this.#c):this.#d&&this.#l([s.itemId]);return}}#S(e){e.preventDefault(),e.ctrlKey||e.metaKey?this.#R(Za(this.viewport,this.#L(e),Math.exp(-e.deltaY*.01))):this.#R(oi(this.viewport,-e.deltaX,-e.deltaY))}#x(e){const n=this.#r;n.on==="item"?this.#y(n.itemId,e):n.on==="ground"&&this.#N("sticky",this.#E(e))}#W(e){if(e.key==="Shift"&&this.#B(!0),e.target!==e.currentTarget)return;const n=this.items(),o=this.selectedIds,i=this.#m(n),[s]=i,r=e.metaKey||e.ctrlKey,d={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(e.key===" ")this.panReady=!0;else if(e.key==="Escape")this.mode.kind!=="idle"?this.mode=Ae:o.length>0&&this.#l([]);else if((e.key==="Delete"||e.key==="Backspace")&&o.length>0)this.#U();else if(e.key==="Enter"&&i.length===1&&s!==void 0)this.#y(s.id);else if(r&&e.key.toLowerCase()==="c"&&i.length>0)this.#p=i,this.#u=0;else if(r&&e.key.toLowerCase()==="v"&&this.#p.length>0)this.#D();else if(r&&e.key.toLowerCase()==="a")this.#l(n.items.map(l=>l.id));else if((e.key==="]"||e.key==="[")&&o.length>0){const l=e.key==="]";this.#K(r?l?"front":"back":l?"forward":"backward")}else if(d!==void 0){const l=e.shiftKey?1:$b;i.length>0?this.#O(Tf(n,i.map(c=>c.id),d[0]*l,d[1]*l)):this.#R(oi(this.viewport,-d[0]*40,-d[1]*40))}else if(e.key==="+"||e.key==="=")this.#j(1.2);else if(e.key==="-")this.#j(1/1.2);else if(e.key==="0")this.#te();else return;this.requestUpdate(),e.preventDefault()}#A(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],Jn(o)?o:{})}#O(e){for(const n of e)this.#A(n)}#V(e){const n=this.#m(this.items());this.#O(n.filter(_n).flatMap(o=>o.color===e?[]:[re.setColor(o.id,e)]))}#Q(e){const n=this.#m(this.items());this.#O(n.filter(Ot).flatMap(o=>o.fontSize===e?[]:[re.setFontSize(o.id,e),...this.#v(o,e)]))}#K(e){this.#O(df(this.items(),this.selectedIds,e))}#U(){const e=this.items(),n=this.selectedIds;this.#O([...n.filter(o=>be(e,o)!==void 0).map(o=>re.deleteConnector(o)),...n.filter(o=>j(e,o)!==void 0).map(o=>re.deleteItem(o))]),this.mode=Ae,this.requestUpdate()}#N(e,n){this.#b();const o=this.items(),i=uf(o,zt(this.locale),e,n);if(!this.#A(re.addItem(i)))return;const s=this.#$();s.width>0&&s.height>0&&this.#R(Rf(this.viewport,i,s)),this.#l([i.id]),this.#a=void 0,this.mode={kind:"editing",itemId:i.id}}#D(){this.#u+=1;const e=ff(this.items(),this.#p,gf*this.#u),n=[];for(const o of e)this.#A(re.addItem(o))&&n.push(o.id);n.length>0&&this.#l(n)}#Z(e,n){if(e===n)return;const o=this.items(),i=o.connectors.find(r=>r.from===e&&r.to===n);if(i!==void 0){this.#l([i.id]);return}const s=mf(o,e,n);this.#A(re.connect(s,e,n))&&this.#l([s])}#R(e){this.#i=!1;const n=_f(e,An(this.items().items),this.#$());Af(n,this.viewport)||(this.viewport=n,this.requestUpdate())}#j(e){const{width:n,height:o}=this.#$();this.#R(Za(this.viewport,{x:n/2,y:o/2},e))}#J(e){const n=this.#$();return e===null||n.width<=0||n.height<=0?!1:(this.#R(Cf(e,n,bd)),this.#i=!0,!0)}#ee(){return Lf(this.items().items,this.#$(),bd)}#oe(e){this.#n===e||typeof ResizeObserver>"u"||(this.#e??=new ResizeObserver(()=>this.#ie()),this.#n&&this.#e.unobserve(this.#n),this.#e.observe(e),this.#n=e)}#ie(){if(!this.#o){this.#ne();return}this.#i&&this.#J(this.#ee())}#te(){this.#J(this.#ee())}#ne(){if(this.#o)return;const e=this.#$();if(e.width<=0||e.height<=0)return;const n=this.#ee();n===null?(this.viewport={x:e.width/2,y:e.height/2,zoom:1},this.requestUpdate()):this.#J(n),this.#o=!0}}const yd=()=>{customElements.get("dpk-board-whiteboard")||customElements.define("dpk-board-whiteboard",xd)},Sb=()=>{_a(),Sa(),$s(),ur(),vs(),xa(),sa(),Qr(),yd(),Dr()};export{eo as B,ys as D,nt as a,tt as b,ws as c,pr as d,Nr as e,Vr as f,ia as g,ba as h,Ta as i,La as j,xd as k,vs as l,$s as m,ur as n,Dr as o,Qr as p,sa as q,Sb as r,xa as s,Sa as t,_a as u,yd as v,Xi as w,De as x,Jn as y};
6696
+ `}updated(){super.updated();const e=this.#T();e!==null&&(this.#oe(e),this.#ne(),this.#u(),this.#A())}disconnectedCallback(){super.disconnectedCallback(),this.#e?.disconnect(),this.#e=void 0,this.#t=void 0}#u(){const e=this.#T(),n=this.renderRoot.querySelector(".wb-toolbar");if(e===null||n===null)return;const o=u=>Number.parseFloat(n.style.getPropertyValue(`--wb-nudge-${u}`))||0,i=e.getBoundingClientRect(),s=n.getBoundingClientRect(),r=this.renderRoot.querySelector(".wb-tools")?.getBoundingClientRect(),a=s.top-o("y"),l=r!==void 0&&a<r.bottom&&a+s.height>r.top?r.right-i.left:0;n.style.setProperty("--wb-toolbar-floor",`${l}px`);const c=n.getBoundingClientRect(),h=hd(c.left-o("x")-i.left,c.width,i.width,Ld,l),p=hd(c.top-o("y")-i.top,c.height,i.height,Ld);n.style.setProperty("--wb-nudge-x",`${h}px`),n.style.setProperty("--wb-nudge-y",`${p}px`)}#l(e){if(this.arrangeMenu=!1,this.selectedIds=e,e.length===1){const n=e[0];n!==void 0&&this.select({kind:xe(this.items(),n)!==void 0?"connector":"item",id:n})}else this.select(null);this.requestUpdate()}#m(e){return this.selectedIds.map(n=>W(e,n)).filter(Jb)}#g(e,n){if(this.mode.kind==="editing")return T;const o=this.selectedIds,i=this.#m(e),s=o.length===1?xe(e,o[0]):void 0,r=s!==void 0?{kind:"connector",connector:s}:i.length>0?{kind:"items",items:i}:void 0;return r===void 0?T:Xb({m:n,state:e,viewport:this.viewport,selection:r,arrange:Pf(e,o),arrangeMenuOpen:this.arrangeMenu,handlers:{setColor:a=>this.#V(a),setFontSize:a=>this.#Q(a),arrange:a=>{this.arrangeMenu=!1,this.#K(a),this.requestUpdate()},toggleArrangeMenu:()=>{this.arrangeMenu=!this.arrangeMenu,this.requestUpdate()},deleteSelection:()=>this.#Y(),setLabel:(a,d)=>this.#_(ae.setConnectorLabel(a,d)),setRoute:(a,d)=>{xe(e,a)?.route!==d&&this.#_(ae.setConnectorRoute(a,d))}}})}#f(e){return this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"] .wb-editor`)}#x(e,n){if(bt(this.mode,e))return;this.#b();const o=this.items();if(W(o,e)===void 0)return;const i=n===void 0?null:this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"] .wb-text`);this.#a=i===null||n===void 0?void 0:qf(i,n.clientX,n.clientY);const s=this.selectedIds;(s.length!==1||s[0]!==e)&&this.#l([e]),this.mode={kind:"editing",itemId:e},this.requestUpdate()}#A(){if(this.mode.kind!=="editing"){this.#n=void 0;return}const{itemId:e}=this.mode;if(this.#n===e)return;const n=this.#f(e);if(n===null)return;this.#n=e,n.focus({preventScroll:!0});const o=Math.min(this.#a??n.value.length,n.value.length);n.setSelectionRange(o,o),this.#a=void 0}#E(e,n){if(!bt(this.mode,e))return;this.mode=Oe,this.requestUpdate(),this.#n=void 0;const o=W(this.items(),e),i=o===void 0?void 0:Xf(o,n);o===void 0||i===void 0||this.#D([ae.setText(e,i),...this.#k(o)])}#k(e,n){if(!Nt(e))return[];const o=If(e,this.#I(e.id,n));return o===void 0?[]:[ae.resize(e.id,o.w,o.h)]}#I(e,n){const o=this.renderRoot.querySelector(`.wb-item[data-item-id="${CSS.escape(e)}"]`),i=o?.querySelector(".wb-item-body");if(o==null||i===null||i===void 0)return 0;const s=o.getAttribute("style")??"";n!==void 0&&o.style.setProperty("--wb-font-scale",String(wd[n]));const r=i.querySelector(".wb-editor"),d=(r===null?i.querySelector(".wb-text")?.offsetHeight??0:r.scrollHeight)-i.clientHeight;return o.setAttribute("style",s),d}#b(){if(this.mode.kind!=="editing")return;const{itemId:e}=this.mode,n=this.#f(e);if(n===null){this.mode=Oe,this.requestUpdate();return}this.#E(e,n.value)}#v(e,n){if(n.isComposing)return;if(n.key==="Escape"){n.preventDefault(),this.mode=Oe,this.requestUpdate(),this.#M();return}const o=W(this.items(),e)?.kind==="frame";n.key==="Enter"&&(o||n.metaKey||n.ctrlKey)&&(n.preventDefault(),this.#M())}#T(){return this.renderRoot.querySelector(".wb-canvas")}#w(){const e=this.#T();return{width:e?.clientWidth??0,height:e?.clientHeight??0}}#C(e){const n=this.#T()?.getBoundingClientRect();return n===void 0?{x:e.clientX,y:e.clientY}:{x:e.clientX-n.left,y:e.clientY-n.top}}#$(e){return ri(this.viewport,this.#C(e))}#F(){const{width:e,height:n}=this.#w();return ri(this.viewport,{x:e/2,y:n/2})}#S(e,n){if(n===void 0)return;const o=this.#T();if(o!==null&&typeof o.setPointerCapture=="function")try{o.setPointerCapture(e.pointerId)}catch{}this.gesture=n,this.requestUpdate()}#M(){this.#T()?.focus({preventScroll:!0})}#O(e){if(this.gesture!==void 0)return;const n=e.button===1||e.button===0&&(this.panReady||e.pointerType==="touch");if(!n&&e.button!==0)return;if(this.#b(),this.arrangeMenu=!1,this.#M(),n){e.preventDefault(),this.#r={on:"other"},this.#S(e,Wf(e.pointerId,this.#C(e)));return}this.#r={on:"ground"};const o=this.items(),i=this.selectedIds.filter(r=>W(o,r)!==void 0),s=e.shiftKey?id(e.pointerId,this.#$(e),i):Qf(o,i,e.pointerId,this.#$(e),[]);this.#s=!1,this.#d=s.kind==="move"&&i.length>1,this.#S(e,s)}#N(e,n){if(n.button!==0||this.panReady||this.gesture!==void 0)return;if(n.stopPropagation(),this.#r={on:"item",itemId:e},bt(this.mode,e)){n.target instanceof Element&&n.target.closest(".wb-editor")!==null||n.preventDefault();return}this.#b(),n.preventDefault(),this.#M(),this.arrangeMenu=!1,this.mode.kind!=="idle"&&(this.mode=Oe);const o=this.items(),i=this.selectedIds;if(n.shiftKey){this.#s=!1,this.#d=!1,this.#l(Cd(i,e));return}this.#s=i.length===1&&i[0]===e,this.#d=i.length>1&&i.includes(e),this.#c={clientX:n.clientX,clientY:n.clientY},i.includes(e)||this.#l([e]);const s=this.#d?i:[e];this.#S(n,ii(o,e,n.pointerId,this.#$(n),s))}#z(e,n){e.button===0&&(e.stopPropagation(),e.preventDefault(),this.#r={on:"other"},this.#b(),this.#M(),this.#S(e,n))}#U(e,n,o){o!==void 0&&this.panReady||this.#z(n,jf(this.items(),e,n.pointerId,this.#$(n),o))}#B(e,n){n.button!==0||this.panReady||(n.stopPropagation(),n.preventDefault(),this.#r={on:"other"},this.#b(),this.#M(),this.mode=Oe,this.#l([e]))}#G(e){const n=this.gesture;if(!(n===void 0||n.pointerId!==e.pointerId)){if(n.kind==="pan"){const o=Vf(n,this.#C(e));this.gesture=o.gesture,this.#R(di(this.viewport,o.dx,o.dy)),this.requestUpdate();return}this.gesture=si(this.items(),n,e.pointerId,this.#$(e),this.viewport.zoom,e.shiftKey),this.requestUpdate()}}#H(e){const n=this.gesture;n?.kind!=="resize"||n.keepRatio===e||(this.gesture=si(this.items(),n,n.pointerId,n.current,this.viewport.zoom,e),this.requestUpdate())}#X(e){const n=this.gesture;if(n===void 0||n.pointerId!==e.pointerId)return;const o=this.items(),i=n.kind==="pan"?n:si(o,n,e.pointerId,this.#$(e),this.viewport.zoom,e.shiftKey);this.gesture=void 0,this.requestUpdate();const s=cd(o,i);switch(s.kind){case"none":return;case"dispatch":this.#D(s.inputs);return;case"connect":this.#Z(s.from,s.to);return;case"select":this.#l(s.ids);return;case"click":if(i.kind==="pan"||i.kind==="marquee"){this.mode=Oe;const r=i.kind==="marquee"?i.base:[];s.itemId!==void 0?this.#l(r.length>0?Cd(r,s.itemId):[s.itemId]):r.length===0&&this.#l([]);return}if(i.kind!=="move"||s.itemId===void 0)return;this.#s?this.#x(s.itemId,this.#c):this.#d&&this.#l([s.itemId]);return}}#L(e){e.preventDefault(),e.ctrlKey||e.metaKey?this.#R(pd(this.viewport,this.#C(e),Math.exp(-e.deltaY*.01))):this.#R(di(this.viewport,-e.deltaX,-e.deltaY))}#y(e){const n=this.#r;n.on==="item"?this.#x(n.itemId,e):n.on==="ground"&&this.#P("sticky",this.#$(e))}#W(e){if(e.key==="Shift"&&this.#H(!0),e.target!==e.currentTarget)return;const n=this.items(),o=this.selectedIds,i=this.#m(n),[s]=i,r=e.metaKey||e.ctrlKey,d={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(e.key===" ")this.panReady=!0;else if(e.key==="Escape")this.mode.kind!=="idle"?this.mode=Oe:o.length>0&&this.#l([]);else if((e.key==="Delete"||e.key==="Backspace")&&o.length>0)this.#Y();else if(e.key==="Enter"&&i.length===1&&s!==void 0)this.#x(s.id);else if(r&&e.key.toLowerCase()==="c"&&i.length>0)this.#h=i,this.#p=0;else if(r&&e.key.toLowerCase()==="v"&&this.#h.length>0)this.#q();else if(r&&e.key.toLowerCase()==="a")this.#l(n.items.map(l=>l.id));else if((e.key==="]"||e.key==="[")&&o.length>0){const l=e.key==="]";this.#K(r?l?"front":"back":l?"forward":"backward")}else if(d!==void 0){const l=e.shiftKey?1:Zb;i.length>0?this.#D(eb(n,i.map(c=>c.id),d[0]*l,d[1]*l)):this.#R(di(this.viewport,-d[0]*40,-d[1]*40))}else if(e.key==="+"||e.key==="=")this.#j(1.2);else if(e.key==="-")this.#j(1/1.2);else if(e.key==="0")this.#te();else return;this.requestUpdate(),e.preventDefault()}#_(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],oo(o)?o:{})}#D(e){for(const n of e)this.#_(n)}#V(e){const n=this.#m(this.items());this.#D(n.filter(Dn).flatMap(o=>o.color===e?[]:[ae.setColor(o.id,e)]))}#Q(e){const n=this.#m(this.items());this.#D(n.filter(Nt).flatMap(o=>o.fontSize===e?[]:[ae.setFontSize(o.id,e),...this.#k(o,e)]))}#K(e){this.#D(zf(this.items(),this.selectedIds,e))}#Y(){const e=this.items(),n=this.selectedIds;this.#D([...n.filter(o=>xe(e,o)!==void 0).map(o=>ae.deleteConnector(o)),...n.filter(o=>W(e,o)!==void 0).map(o=>ae.deleteItem(o))]),this.mode=Oe,this.requestUpdate()}#P(e,n){this.#b();const o=this.items(),i=Bf(o,qt(this.locale),e,n);if(!this.#_(ae.addItem(i)))return;const s=this.#w();s.width>0&&s.height>0&&this.#R(ab(this.viewport,i,s)),this.#l([i.id]),this.#a=void 0,this.mode={kind:"editing",itemId:i.id}}#q(){this.#p+=1;const e=Gf(this.items(),this.#h,Yf*this.#p),n=[];for(const o of e)this.#_(ae.addItem(o))&&n.push(o.id);n.length>0&&this.#l(n)}#Z(e,n){if(e===n)return;const o=this.items(),i=o.connectors.find(r=>r.from===e&&r.to===n);if(i!==void 0){this.#l([i.id]);return}const s=Hf(o,e,n);this.#_(ae.connect(s,e,n))&&this.#l([s])}#R(e){this.#i=!1;const n=rb(e,Nn(this.items().items),this.#w());db(n,this.viewport)||(this.viewport=n,this.requestUpdate())}#j(e){const{width:n,height:o}=this.#w();this.#R(pd(this.viewport,{x:n/2,y:o/2},e))}#J(e){const n=this.#w();return e===null||n.width<=0||n.height<=0?!1:(this.#R(ib(e,n,Id)),this.#i=!0,!0)}#ee(){return sb(this.items().items,this.#w(),Id)}#oe(e){this.#t===e||typeof ResizeObserver>"u"||(this.#e??=new ResizeObserver(()=>this.#ie()),this.#t&&this.#e.unobserve(this.#t),this.#e.observe(e),this.#t=e)}#ie(){if(!this.#o){this.#ne();return}this.#i&&this.#J(this.#ee())}#te(){this.#J(this.#ee())}#ne(){if(this.#o)return;const e=this.#w();if(e.width<=0||e.height<=0)return;const n=this.#ee();n===null?(this.viewport={x:e.width/2,y:e.height/2,zoom:1},this.requestUpdate()):this.#J(n),this.#o=!0}}const Rd=()=>{customElements.get("dpk-board-whiteboard")||customElements.define("dpk-board-whiteboard",Ad)},tx=()=>{Ya(),qa(),Is(),kr(),Ms(),Aa(),xa(),ia(),Rd(),Hr()};export{io as B,Ss as D,rt as a,st as b,Ls as c,xr as d,Br as e,oa as f,ba as g,Ia as h,Pa as i,Ha as j,Ad as k,Ms as l,Is as m,kr as n,Hr as o,ia as p,xa as q,tx as r,Aa as s,qa as t,Ya as u,Rd as v,Zi as w,ze as x,oo as y};