dev-process-kit 0.3.1 → 0.3.2

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-CeCpFPDQ.js → shared-7Yki1uKI.js} +1 -1
  3. package/dist/chunks/{shared-CF2_VP2x.js → shared-BBTySCXK.js} +1 -1
  4. package/dist/chunks/{shared-egtdNQhY.js → shared-BPVvO01I.js} +1 -1
  5. package/dist/chunks/{shared-2OsWmhrI.js → shared-BblP0eEY.js} +1 -1
  6. package/dist/chunks/{shared-DJtGS7Ct.js → shared-Bu1HuBxn.js} +1 -1
  7. package/dist/chunks/{shared-C89fKgKG.js → shared-C44CU0VV.js} +1 -1
  8. package/dist/chunks/{shared-Dd8JfvQe.js → shared-C4EqS9Lp.js} +1 -1
  9. package/dist/chunks/{shared-Dn92ukYW.js → shared-C5wXNKl3.js} +1 -1
  10. package/dist/chunks/{shared-DIEJ9E2G.js → shared-Cbm3cQ8l.js} +1 -1
  11. package/dist/chunks/{shared-C0M3Ib7z.js → shared-DPD_tBh8.js} +1 -1
  12. package/dist/chunks/{shared-B8ZhyjWv.js → shared-DlZJHHpN.js} +287 -205
  13. package/dist/chunks/{shared-BXywwm1a.js → shared-UH4xqvj9.js} +395 -371
  14. package/dist/chunks/{shared-Dql0ZVdC.js → shared-bP-1q7ZQ.js} +1 -1
  15. package/dist/chunks/{shared-Be43xweD.js → shared-bQPXht-t.js} +1 -1
  16. package/dist/chunks/shared-hhwSHdS3.js +1 -0
  17. package/dist/chunks/{shared-ubG0-RQ-.js → shared-nrgnwzCU.js} +1 -1
  18. package/dist/chunks/{shared-B57TT0rn.js → shared-pYjptMZ1.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-LHG2FbnK.js +0 -1
@@ -1,4 +1,4 @@
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`
1
+ import{a4 as Hd,S as Hn,a5 as pe,a6 as Yd,a7 as Gd,a8 as re,a9 as R,aa as F,ab as he,ac as k,ad as ce,ae as Xd,af as Kd,X as jd,j as gi,ag as fi,ah as de,ai as T,aj as Y,ak as bi,al as xi,am as Wd,an as Vd,D as Qd,ao as Zd,U as Jd,ap as Yn,aq as el,ar as yi,as as v,C as tl,at as nl,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 Gn,aD as ol,aE as ki,aF as vi,aG as il,aH as Se,aI as wi,B as $i,aJ as sl,G as Ei,H as Xn,I as Ht,aK as rl,aL as j,aM as oe,aN as nt,p as z,t as Me,aO as me,aP as ot,z as Kn,aQ as kt,aR as al,N as Yt,e as jn,P as U,aS as Gt,aT as dl,l as ke,aU as Xt,aV as Ti,aW as Si,y as Wn,aX as ll,aY as Mi,aZ as cl,a_ as Ci,a$ as Kt,b0 as Ce,b1 as pl,b2 as hl,b3 as ul}from"./shared-DlZJHHpN.js";import{Q as ml,A as gl,H as fl,R as bl,S as xl,T as ve,U as Le,V as Li,W as yl,X as we,Y as kl,Z as Vn,_ as Ii,$ as vl}from"./shared-Cbm3cQ8l.js";import{o as wl}from"./shared-D4PPk0Dk.js";import{E as $l,t as Ie,u as El,v as Oe,B as jt,w as Wt,x as Tl}from"./shared-C4EqS9Lp.js";import{a as Sl,c as Ml}from"./shared-C5wXNKl3.js";import{o as Vt}from"./shared-hhwSHdS3.js";import{h as Ai,l as Cl,d as Qn,a as _i}from"./shared-bQPXht-t.js";const Ll=[["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"}]],Il=[["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"}]],Al=[["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"}]],_l=[["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"}]],Rl=[["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 Dl(t,e){let n=0;for(let o=0;o<t.length;o++)n+=e(t[o],o);return n}function Ri(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 Di={},Oi=t=>{const e={kind:"board",name:t.name,label:t.label,addable:t.addable??!1,parseBase:()=>Di,emptyBase:()=>Di,actions:{},apply:()=>null,hasTarget:()=>!1,describe:i=>({title:i.type,targetLabel:Hn(i.target),tone:"meta"}),serialize:i=>`${i.type} ${Hn(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 Hd(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},Zn=(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))}},Ni=(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},zi=(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(m=>(n.get(m)??a)===a+(r?-1:1)).map(c).filter(m=>m!==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))}}},Pi=(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)}},Ol=(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,Pi(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 b of p){const y=d(b,h+(c?-1:1)),x=e.get(b);x!==void 0&&u.set(b,y===null?x.y+x.spec.height/2:y)}const m=p.map(b=>e.get(b)?.y??0);Pi(p,e,u,i.nodeSpacing);const f=p.map(b=>e.get(b)?.y??0),g=wt(m)-wt(f);for(const b of p){const y=e.get(b);y&&(y.y+=g)}}}},qi=(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)}}},Nl=(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},zl=(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,_=(e.get(E)??[]).length,D=s.get(M)??0;return _<=1?0:D/(_-1)},m=[...new Set(a.values())],f=M=>{const E=t.filter(_=>(a.get(_.id)??_.id)===M).map(_=>_.id);return E.length===0?0:E.reduce((_,D)=>_+u(D),0)/E.length},g=[...new Set(m.map(h))],b=M=>{const E=t.filter(_=>h(a.get(_.id)??_.id)===M).map(_=>_.id);return E.length===0?0:E.reduce((_,D)=>_+u(D),0)/E.length},x=g.sort((M,E)=>b(M)-b(E)).flatMap(M=>m.filter(E=>h(E)===M).sort((E,_)=>f(E)-f(_))),w=new Map(x.map(M=>[M,Nl(e,n,a,M,r.nodeSpacing)])),$=new Map;let A=0;for(const[M,E]of x.entries()){$.set(E,A),A+=w.get(E)??0;const _=x[M+1];if(_!==void 0){const D=l&&h(E)!==h(_);A+=D?r.superGroupSpacing:d.has(E)||d.has(_)?r.groupSpacing:r.nodeSpacing}}for(const M of p){const E=e.get(M)??[];qi(E,n,new Map(E.map(_=>[_,s.get(_)??0])),a,x,$,r.nodeSpacing)}const C=(M,E)=>{const _=(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 _.length>0?wt(_):null};for(let M=0;M<r.coordinatePasses;M++){const E=M%2===0;for(const _ of E?p:[...p].reverse()){const D=e.get(_)??[],O=new Map;for(const B of D){const H=C(B,_+(E?-1:1)),q=n.get(B);q!==void 0&&O.set(B,H===null?q.y+q.spec.height/2:H)}qi(D,n,O,a,x,$,r.nodeSpacing)}}},Fi=(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}},Qt=(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=Fi(r,s.fromPort,"out"),l=Fi(a,s.toPort,"in");if(s.from===s.to){const m=r.x+r.spec.width,f=r.y+r.spec.height,g=Math.max(n.padding/2,f+18);i.push({id:s.id,points:[d,{x:m+20,y:d.y},{x:m+20,y:g},{x:r.x-20,y:g},{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 f=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:f,y:d.y},{x:f,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((m,f,g)=>f===0||m.x!==g[f-1]?.x||m.y!==g[f-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}))}))}},Zt=(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},Ui=(t,e,n,o)=>t.map(i=>({spec:i,layer:e.get(i.id)??0,order:n.get(i.id)??0,...o(i)})),Bi=(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},Hi=(t,e,n={})=>{if(t.some(f=>f.superGroup!==void 0))return Vl(t,e,n);const o={...vt,...n};if(t.length===0)return{width:0,height:0,nodes:[],routes:[]};const i=new Set(t.map(f=>f.id)),s=e.filter(f=>i.has(f.from)&&i.has(f.to)),{forward:r,reversed:a}=Zn(t,s),d=Ni(t,r),l=Bi(t,d);zi(l,Zt(t,s),d,o.sweeps);const c=new Map;for(const f of l.values())f.forEach((g,b)=>c.set(g,b));const h=Ui(t,d,c,()=>({x:0,y:0})),p=new Map(h.map(f=>[f.spec.id,f]));t.some(f=>f.group!==void 0||f.superGroup!==void 0)?zl(t,l,p,Zt(t,s),d,c,o):Ol(l,p,Zt(t,s),d,o);const u=[...l.keys()].sort((f,g)=>f-g);let m=0;for(const f of u){const g=Math.max(...(l.get(f)??[]).map(b=>p.get(b)?.spec.width??0));for(const b of l.get(f)??[]){const y=p.get(b);y&&(y.x=m)}m+=g+o.layerSpacing}return Jn(h,Qt(s,a,{byId:p,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},it=12,Yi=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Gi=(t,e)=>{const n=Yi(t),o=Yi(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"},Xi=(t,e,n)=>Math.min(n,Math.max(e,t)),Ki=(t,e,n)=>{const o=Xi(n.y-t.y,it,Math.max(it,t.height-it)),i=t.height<=0?.5:o/t.height,s=t.x+Xi(i*t.width,it,Math.max(it,t.width-it));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}}},Pl=(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}=Zn(o,s),a=Ni(o,r),d=Bi(o,a);return zi(d,Zt(o,s),a,n),[...d.keys()].sort((c,h)=>c-h).flatMap(c=>d.get(c)??[])},ql=(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)},eo=(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 m=u;m<=o;m++)for(let f=u-1;f<m;f++){const g=r[f][u-1];if(g===s)continue;const b=Math.max(g,ql(t,f,m,e));b<r[m][u]&&(r[m][u]=b,a[m][u]=f)}const d=[];let l=o;for(let u=i;u>0;u--){const m=a[l][u];d.unshift(t.slice(m,l)),l=m}const c=new Map;let h=0,p=0;for(const u of d){let m=0;const f=Math.max(...u.map(g=>g.height));for(const g of u)c.set(g.id,{x:m,y:h}),m+=g.width+e;p=Math.max(p,m-e),h+=f+e}return{positions:c,width:p,height:Math.max(0,h-e)}},je=1e-6,Jt=(t,e)=>Math.abs(t.x-e.x)<je&&Math.abs(t.y-e.y)<je,en=(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},tn=(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,ji=(t,e)=>{const[n,o]=t,[i,s]=e;if(Jt(n,i)||Jt(n,s)||Jt(o,i)||Jt(o,s))return!1;const r=en(n,o,i),a=en(n,o,s),d=en(i,s,n),l=en(i,s,o);return r!==a&&d!==l||r===0&&tn(n,i,o)||a===0&&tn(n,s,o)||d===0&&tn(i,n,s)?!0:l===0&&tn(i,o,s)},Wi=(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}},Fl=(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=Wi(a,d),c=Wi(d,a);if(l.x===c.x||l.y===c.y){const m=[l,c];s+=i.filter(f=>ji(m,f)).length,i.push(m);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 m of h){const f=m.reduce((g,b)=>g+i.filter(y=>ji(b,y)).length,0);f<u&&(u=f,p=m)}s+=u,i.push(...p)}return s},Ul=(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},Vi=(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)},Qi=(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}},Bl=(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=Ki(h,Gi(h,p),Qi(a,l,r.fromPort,"out")),m=Ki(p,Gi(p,h),Qi(d,c,r.toPort,"in")),f=x=>x.slice(1).map((w,$)=>[x[$],w]);if(u.x===m.x||u.y===m.y){const x=[u,m];s+=i.filter(w=>Vi(x,w)).length,i.push(x);continue}const g=[[u,{x:m.x,y:u.y},m],[u,{x:u.x,y:m.y},m]];let b=g[0],y=Number.POSITIVE_INFINITY;for(const x of g){const w=f(x).reduce(($,A)=>$+i.filter(C=>Vi(A,C)).length,0);w<y&&(b=x,y=w)}s+=y,i.push(...f(b))}return s},nn={crossings:1e4,edgeLength:1,aspectDeviation:50},Zi=50,Hl=nn.aspectDeviation,to=(t,e,n,o,i)=>{const s=t.width<=0||t.height<=0?0:Math.abs(Math.log(t.width/t.height/o));return Fl(t,e,n)*nn.crossings+Ul(t,e,n)*nn.edgeLength+s*i},Yl=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++},Gl=7,Xl=400,Kl=1e-6,no=(t,e,n,o,i=vt.sweeps,s=0,r=nn.aspectDeviation,a=Xl)=>{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=eo(A,n,1),M=Number.POSITIVE_INFINITY,E=1;const _=s>0?Math.min(s,A.length):1,D=s>0?_:A.length;for(let O=_;O<=D;O++){const B=eo(A,n,O);if(B.width<=0||B.height<=0)continue;const H=to(B,d,l,o,r);H<M&&(M=H,C=B,E=O)}return{packed:C,cost:M,rowCount:E}},h=($,A)=>eo($.map(C=>({id:C,...d.get(C)})),n,A),p=t.map($=>$.id);if(p.length<=Gl){let $=c(p);for(const A of Yl(p)){const C=c(A);C.cost<$.cost&&($=C)}return $.packed}const u=s>0?Math.min(a,50):a;let m=Pl(t,l,i);const f=c(m),g=s>0?Math.min(s,m.length):f.rowCount;let b=s>0?h(m,g):f.packed,y=s>0?to(b,d,l,o,r):f.cost,x=0,w=!0;for(;w&&x<u;){w=!1;for(let $=0;$<m.length-1&&x<u;$++){x++;const A=[...m],C=A[$];A[$]=A[$+1],A[$+1]=C;const M=h(A,g);if(M.width<=0||M.height<=0)continue;const E=to(M,d,l,o,r);E<y-Kl&&(y=E,b=M,m=A,w=!0)}}return b},jl=(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 m=s.get(u.y);m?m.push(p):s.set(u.y,[p])}const a=[...s.keys()].sort((p,u)=>p-u).map(p=>[...s.get(p)??[]].sort((u,m)=>(t.positions.get(u)?.x??0)-(t.positions.get(m)?.x??0))),d=new Map;let l=0,c=0,h=0;return a.forEach((p,u)=>{const m=a[u-1];if(m!==void 0){const g=p.some(i)||m.some(i);h+=g?n:0}let f=0;p.forEach((g,b)=>{const y=p[b-1];y!==void 0&&(f+=i(y)||i(g)?o:0);const x=t.positions.get(g),w=e.get(g);if(!x||!w)return;const $={x:x.x+f,y:x.y+h};d.set(g,$),l=Math.max(l,$.x+w.width),c=Math.max(c,$.y+w.height)})}),{positions:d,width:l,height:c}},Ji=1.3,Wl=1.45,Vl=(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(E),D=c.get(_);D?D.push(E):c.set(_,[E])}const h=new Map;for(const[E,_]of c){const D=_[0];if(_.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(_.map(q=>q.id)),B=s.filter(q=>O.has(q.from)&&O.has(q.to)),H=no(_.map(q=>({id:q.id,width:q.width,height:q.height})),B,o.nodeSpacing,Ji,o.sweeps,0,Zi);h.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const p=new Map;for(const[E,_]of c){const D=_[0];D!==void 0&&p.set(E,a(D))}const u=new Map;for(const[E,_]of p){const D=u.get(_);D?D.push(E):u.set(_,[E])}const m=new Map;for(const[E,_]of u){const D=_[0];if(_.length===1&&D!==void 0){const q=h.get(D);q&&m.set(E,{size:q.size,relative:new Map([[D,{x:0,y:0}]])});continue}const O=new Map(_.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?[]:!_.includes(ee)||!_.includes(Q)?[]:[{id:q.id,from:ee,to:Q}]}),H=no(_.flatMap(q=>O.has(q)?[{id:q,...O.get(q)}]:[]),B,o.groupSpacing,Ji,o.sweeps,0,Zi);m.set(E,{size:{width:H.width,height:H.height},relative:H.positions})}const f=new Map([...m].map(([E,_])=>[E,_.size])),g=[...m.keys()],b=new Set(t.flatMap(E=>E.superGroup===void 0?[]:[E.superGroup])),y=E=>{const _=new Map;for(const[D,O]of u){const B=E.get(D)??{x:0,y:0},H=m.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)_.set(X,{x:B.x+ee.x+Z.x,y:B.y+ee.y+Z.y})}}return _};let x=new Map;if(g.length<=1)for(const E of g)x.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}]}),_=X=>no(g.map(Z=>({id:Z,...f.get(Z)})),E,o.superGroupSpacing,Wl,o.sweeps,X,Hl),D=_(o.superGroupRowCount),O=o.superGroupRowCount>0?[]:[1,2,3,4].filter(X=>X<=g.length),B=[D,...O.map(X=>_(X))],H=X=>{const Z=jl(X,f,o.superGroupRowGap,o.superGroupColumnGap,K=>b.has(K)),ne=Bl(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);x=new Map(Q.offsets)}const w=y(x),$=Zn(t,s).reversed,A=t.map((E,_)=>{const D=w.get(E.id)??{x:0,y:0};return{spec:E,layer:0,order:_,x:D.x,y:D.y}}),C=new Map(A.map(E=>[E.spec.id,E])),M=Qt(s,$,{byId:C,layerSpacing:o.layerSpacing,padding:o.padding});return Jn(A,M,o.padding)},Ql=(t,e,n,o,i={})=>{if(e.size===0)return t;const s={...vt,...i},r=new Map(n.map(g=>[g.id,g])),a=t.nodes.map(g=>{const b=e.get(g.id);return b===void 0?g:{...g,x:b.x,y:b.y}}),d=new Map(a.map(g=>[g.id,{spec:r.get(g.id)??{id:g.id,width:g.width,height:g.height},layer:g.layer,order:g.order,x:g.x,y:g.y}])),l=new Set(a.map(g=>g.id)),c=o.filter(g=>l.has(g.from)&&l.has(g.to)),h=Qt(c,new Set,{byId:d,layerSpacing:s.layerSpacing,padding:s.padding}),p=[...a.map(g=>g.x+g.width),...h.flatMap(g=>g.points.map(b=>b.x))],u=[...a.map(g=>g.y+g.height),...h.flatMap(g=>g.points.map(b=>b.y))],m=Math.max(t.width,Math.max(0,...p)+s.padding),f=Math.max(t.height,Math.max(0,...u)+s.padding);return{width:m,height:f,nodes:a,routes:h}},es=(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=Ui(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,Qt(s,new Set,{byId:a,layerSpacing:o.layerSpacing,padding:o.padding}),o.padding)},ts={kind:"idle"},Zl=t=>({kind:"node",...t,moved:!1,preview:null}),Jl=t=>({kind:"group",...t,moved:!1,preview:null}),ec=(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}},ns=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`}}),os={v:1,overrides:[]},oo="dpk-layout-change",tc=(t,e)=>t.board===e.board&&t.diagram===e.diagram&&t.node===e.node,is=(t,e,n)=>({...t,overrides:[...t.overrides.filter(o=>!tc(o,e)),{...e,position:n}]}),nc=(t,e)=>e.reduce((n,o)=>is(n,o,o.position),t),oc=(t,e,n)=>new Map(t.overrides.filter(o=>o.board===e&&o.diagram===n).map(o=>[o.node,o.position])),ic=(t,e,n)=>t.overrides.some(o=>o.board===e&&o.diagram===n),sc=(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}},rc=(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}},ac=R({x:ce(),y:ce()}),dc=R({board:k(),diagram:k(),node:k(),position:ac}),lc=R({v:he(1),overrides:F(dc)}),ss=t=>{const e=re(lc,t);return e.success?e.output:null},cc=t=>`dev-process-kit:layout-positions:${t}`,pc=()=>{const t=typeof location>"u"?"local":`${location.pathname}${location.search}`;return cc(t)},hc=()=>Gd(ss),uc=()=>Yd(ss),mc=t=>t.closest(Xd)?.getAttribute(Kd)??"";class gc{#o;#i;#e=null;#t="";#n=os;#a=()=>this.#c();constructor(e,n){this.#o=e,this.#i=n,e.addController(this)}hostConnected(){this.#e=this.#i.persist===!1?uc():hc(),this.#t=pc(),this.#n=this.#e.read(this.#t)??os,window.addEventListener(oo,this.#a)}hostDisconnected(){window.removeEventListener(oo,this.#a)}get#r(){return mc(this.#i.host())}get#s(){return this.#i.diagram()}overrides(){return oc(this.#n,this.#r,this.#s)}hasOverrides(){return ic(this.#n,this.#r,this.#s)}commit(e,n){this.#n=is(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=nc(this.#n,n),this.#d()}prune(e){const n=rc(this.#n,this.#r,this.#s,e);n!==this.#n&&(this.#n=n,this.#d())}reset(){const e=sc(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(oo))}#c(){this.#n=this.#e?.read(this.#t)??this.#n,this.#o.requestUpdate()}}const fc=(t,e,n)=>`${t} ${n.node} \xB7 ${e} ${n.edge}`,st=[jd,gi,fi,de`
2
2
  :host {
3
3
  display: block;
4
4
  container-type: inline-size;
@@ -139,7 +139,7 @@ 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 a
139
139
  font-size: 11px;
140
140
  color: var(--dpk-accent);
141
141
  }
142
- `],lc=de`
142
+ `],bc=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 Od,S as Bn,a5 as pe,a6 as Nd,a7 as zd,a8 as re,a9 as _,aa as F,ab a
346
346
  .d-edge-label.is-dimmed {
347
347
  opacity: 0.3;
348
348
  }
349
- `,ze=[...it,lc],nn=t=>t.map((e,n)=>`${n===0?"M":"L"}${e.x} ${e.y}`).join(" "),ns=t=>Y`
349
+ `,Ne=[...st,bc],on=t=>t.map((e,n)=>`${n===0?"M":"L"}${e.x} ${e.y}`).join(" "),rs=t=>Y`
350
350
  <defs>
351
351
  ${t.map(e=>Y`
352
352
  <marker
@@ -368,18 +368,18 @@ 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 a
368
368
  </marker>
369
369
  `)}
370
370
  </defs>
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">
371
+ `,as={fromAttribute:t=>t==="board"?"board":"embedded",toAttribute:t=>t},io=t=>typeof t=="object"&&t!==null;class rt extends bi{static{this.styles=st}static{this.properties={data:{attribute:!1},id:{type:String,reflect:!0},heading:{type:String},subject:{type:String},variant:{type:String,reflect:!0,converter:as}}}#o=null;#i=null;#e=[];#t=[];#n=null;#a=$l;#r=null;#s=null;#d="";#c=new ml(this);#h=new xi(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=as.fromAttribute(this.getAttribute("variant"))}connectedCallback(){gl(),fl(),super.connectedCallback(),this.#d="",this.requestUpdate(),this.#s=wl(this,e=>this.parseData(e),e=>{e.ok?this.#b(e.value):this.#k(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.#y()}get elementActionResults(){return this.#t}get board(){return Wd(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 Oi({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??=Vd(this.#x(),this),this.#u}#g(){if(this.#p)return this.#p;const e=this.board!==null,n=Oi({name:this.boardName(),label:this.boardLabel(),addable:this.boardAddable()}),o=new Qd(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=Zd(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.#S(o),dispatchBatch:o=>this.#w(o),subscribe:o=>e().subscribe(()=>o(nl(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=Jd(e.target,o),s=this.board;if(s===null)return{...e,target:i};const r=Yn(this)?.pageNames()??new Set;return{...e,target:el(i,s,r)}}#S(e){const n=this.board!==null?Yn(this):null;return n===null?this.#g().dispatch(e):n.dispatch(this.#A(e))}#w(e){const n=this.board!==null?Yn(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.#S({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.#M(e,n??e)}get locale(){return this.#h.locale}get chromeMessages(){return ns(this.#h.locale)}renderSelection(){return this.#c.render({locale:this.#h.locale,errorMessage:this.chromeMessages.sendFailed,submit:(e,n)=>this.#v(e,n)})}getContextMenuItems(e){const n=bl(e.target,this.commentTargets,yi(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===""?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 v`<div slot="actions" class="diagram-toolbar-actions">
372
372
  ${this.renderToolbarActions()}
373
373
  <span class="diagram-stats">${this.statsText()}</span>
374
- </div>`}renderTagFilterRow(e=T){return k`<div slot="toolbar" class="diagram-toolbar-rows">
374
+ </div>`}renderTagFilterRow(e=T){return v`<div slot="toolbar" class="diagram-toolbar-rows">
375
375
  <dpk-tag-filter
376
- .tags=${cl(this.tagItems())}
376
+ .tags=${xl(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.#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`
382
+ </div>`}#b(e){this.#n=null,this.#o=e,this.#y()}#y(){if(this.#n!==null){this.#t=this.#e.map(n=>({id:n.id,title:n.type,stale:"target-missing"})),this.requestUpdate();return}const e=this.reduceElementActions(this.authoredItems(),this.#e);this.#i=e.data,this.#t=e.results,this.#r!==null&&(this.hasSelection(this.#r)||(this.#r=null)),this.requestUpdate()}#v(e,n){return this.board!==null?this.#S({type:tl,target:e,payload:{body:n}}).ok:!this.dispatchEvent(new CustomEvent("dpk-comment-submit",{detail:{target:e,body:n},bubbles:!0,composed:!0,cancelable:!0}))}#k(e){this.#n=e,this.#o=null,this.#i=null,this.#y(),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 so extends rt{static{this.styles=Ne}#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 v`
383
383
  <dpk-dialog-panel
384
384
  class=${ve("diagram",this.shellClass())}
385
385
  flush
@@ -398,17 +398,17 @@ 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 a
398
398
  >
399
399
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow(this.renderAboveCanvas())}
400
400
  <div class="diagram-world">${this.renderCanvas()}</div>
401
- ${o===T?T:k`<div slot="controls">${o}</div>`}
401
+ ${o===T?T:v`<div slot="controls">${o}</div>`}
402
402
  <div slot="overlay" class="diagram-overlay">
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>`}
403
+ ${this.isEmpty()?v`<p class="diagram-empty">${this.emptyMessage()}</p>`:T}
404
+ ${this.dataError===null?T:v`<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 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`
409
+ `}}const xc=4,yc=new Set,kc='button,[role="button"],a,input,textarea,select';class at extends so{#o=null;#i="";#e=null;#t="";#n=0;#a=Le;#r=new gc(this,{host:()=>this,diagram:()=>this.id});#s=ts;#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 fc(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 Li(e,this.selection,"node",this.#a)}edgeState(e){return Li(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
+ ${rs(n)}${e}
411
+ </svg>`}filtered(){const e=this.items();if(this.tagDimension==="edge"){const i=e.edges.filter(r=>Ie(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=>Ie(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"?es(n,o,i):Hi(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(Ql(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:yi(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(kc):null;if(o!==null&&o!==e.currentTarget)return;const i=this.placedNode(n),s=e.currentTarget;!i||!(s instanceof HTMLElement)||(e.stopPropagation(),this.#u(Zl({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()):yc}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(Jl({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=ec(n,{screenX:e.clientX,screenY:e.clientY},o,xc);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=ts,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}`}}),ds={width:220,height:112},sn=26,vc=P({src:S(k(),I(1)),alt:S(k(),I(1)),license:L(k())}),wc=P({id:S(k(),I(1)),name:S(k(),I(1)),description:L(k()),boundary:L(k()),symbol:L(k()),tags:L(F(k()),[]),artwork:L(vc),position:P({x:ce(),y:ce()}),questions:L(k())}),$c=P({id:S(k(),I(1)),label:S(k(),I(1)),kind:L(G(["internal","external"]),"internal")}),Ec=P({id:S(k(),I(1)),from:S(k(),I(1)),to:S(k(),I(1)),label:L(k())}),Tc=P({boundaries:L(F($c),[]),services:F(wc),links:L(F(Ec),[])}),Sc=()=>({nodes:[],edges:[],boundaries:[]}),Mc=t=>{const e=ue(Tc,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:ds.width,height:ds.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}))}},ro={left:sn,top:sn*1.6,right:sn,bottom:sn},Cc={left:0,top:0,right:0,bottom:0},Lc=12,ls=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))}),Ic=(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-Lc)*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))}},Ac=(t,e)=>{const n=e.flatMap(i=>{const s=t.filter(r=>r.boundary===i.id);return s.length===0?[]:[{boundary:i,bounds:ls(s)}]}),o=[...n.map(i=>({id:i.boundary.id,bounds:i.bounds,padding:ro})),...t.filter(i=>i.boundary===null||!n.some(s=>s.boundary.id===i.boundary)).map(i=>({id:null,bounds:ls([i]),padding:Cc}))];return n.map(({boundary:i,bounds:s})=>{const r=o.filter(l=>l.id!==i.id).map(l=>Ic(s,ro,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)}),ro),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}})},cs=6,ps=12,_c=t=>t.slice(1).map((e,n)=>[t[n],e]),Rc=(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),m=Math.max(o.y,i.y),f=Math.min(s.y,r.y),g=Math.max(s.y,r.y);return Math.max(0,Math.min(m,g)-Math.max(u,f))}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))},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}]],hs=(t,e)=>e.some(n=>Dc(n).some(o=>_c(t).some(i=>Rc(i,o,cs)>ps))),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),dt=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]),us=(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,m=Math.min(d.y,l.y),f=Math.max(d.y,l.y),g=Math.min(c.x,h.x),b=Math.max(c.x,h.x);return p>g&&p<b&&u>m&&u<f},ao=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of Et(t))for(const i of e)us(o,i)&&n++;return n},Oc=4,ms=8,lo=(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)))},gs=(t,e)=>lo(t,e,Oc),fs=(t,e)=>{if(e.length===0)return 0;let n=0;for(const o of Et(t))for(const i of e){const s=gs(o,i);s>ms&&(n+=s)}return n},bs=([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)}),Nc=(t,e)=>t.maxX>=e.minX&&e.maxX>=t.minX&&t.maxY>=e.minY&&e.maxY>=t.minY,zc=(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=bs(s);for(let a=0;a<e.length;a++){if(!Nc(r,n[a]))continue;const d=e[a];us(s,d)&&o++;const l=gs(s,d);l>ms&&(i+=l)}}return{crossings:o,parallel:i}},Pc=(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]},qc=(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]},Fc=14,xs=(t,e,n,o,i)=>[...new Set([...Pc(t,e,n,i),...qc(t,e,o,i,Fc)])],Uc=1.5,Bc=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}]],Hc=(t,e)=>{let n=!1,o=!1;for(const i of e)for(const s of Bc(i))for(const r of Et(t)){const a=lo(r,s,cs);if(a>ps&&(n=!0),a>1&&lo(r,s,Uc)>1&&(o=!0),n&&o)return{hugs:n,contact:o}}return{hugs:n,contact:o}},Yc=(t,e,n,o)=>{const i=zc(t.points,e,n),{hugs:s,contact:r}=Hc(t.points,o);return{...t,crossings:i.crossings,parallel:i.parallel,hugs:s,contact:r}},ys=(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,co=t=>Et(t).reduce((e,[n,o])=>e+Math.abs(n.x-o.x)+Math.abs(n.y-o.y),0),Gc=(t,e,n,o,i)=>{const s=xs(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=dt([t,{x:a,y:t.y},{x:a,y:e.y},e]);r.push({points:h,length:co(h)})}return r},Xc=(t,e,n,o,i)=>{const s=xs(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=dt([t,{x:t.x,y:a},{x:e.x,y:a},e]);r.push({points:h,length:co(h)})}return r},ks=(t,e,n)=>{const o=e.map(bs);let i=null;for(const s of t){const r=Yc(s,e,o,n);(i===null||ys(r,i))&&(i=r)}return i},Kc=(t,e,n,o,i,s)=>ks([...Gc(t,e,n,o,s),...Xc(t,e,n,o,s)],i,s),rn=(t,e,n)=>Math.min(n,Math.max(e,t)),jc=(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)),m=Math.max(d,...l.map(N=>N.y+N.height+c)),f=n.filter(N=>N.x<p&&N.x+N.width>h&&N.y<m&&N.y+N.height>u);if(f.length>120)return null;const g=new Set([t.x,e.x,h,p]),b=new Set([t.y,e.y,u,m]);for(const N of f)g.add(rn(N.x,h,p)),g.add(rn(N.x+N.width,h,p)),b.add(rn(N.y,u,m)),b.add(rn(N.y+N.height,u,m));const y=[...g].sort((N,K)=>N-K),x=[...b].sort((N,K)=>N-K),w=y.length,$=x.length,A=y.indexOf(t.x),C=x.indexOf(t.y),M=y.indexOf(e.x),E=x.indexOf(e.y);if(A<0||C<0||M<0||E<0)return null;const _=Array.from({length:w-1},(N,K)=>Array.from({length:$},(le,Te)=>!fe(x[Te],y[K],y[K+1],f))),D=Array.from({length:w},(N,K)=>Array.from({length:$-1},(le,Te)=>!ge(y[K],x[Te],x[Te+1],f))),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)/$,Te=(Ud,Bd)=>{const Bt=O(Ud,Bd);q[Bt]||(q[Bt]=1,H[Bt]=N,X.push(Bt))};le>0&&_[le-1]?.[K]&&Te(le-1,K),le<w-1&&_[le]?.[K]&&Te(le+1,K),K>0&&D[le]?.[K-1]&&Te(le,K-1),K<$-1&&D[le]?.[K]&&Te(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:x[N]}),ne===ee)break;ne=H[ne]}return Z.reverse(),dt(Z)},po=(t,e,n,o,i=[],s=[],r=[])=>{if(t.x===e.x&&t.y===e.y)return[t,e];const a=n.map(g=>({x:g.x-o,y:g.y-o,width:g.width+o*2,height:g.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)&&!hs([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)&&!hs([t,e],s))return[t,e];const l={x:e.x,y:t.y},c={x:t.x,y:e.y},h=g=>{const b=g.y===t.y?!fe(t.y,Math.min(t.x,g.x),Math.max(t.x,g.x),d):!ge(t.x,Math.min(t.y,g.y),Math.max(t.y,g.y),d),y=g.y===e.y?!fe(e.y,Math.min(g.x,e.x),Math.max(g.x,e.x),d):!ge(e.x,Math.min(g.y,e.y),Math.max(g.y,e.y),d);return b&&y},p=[],u=g=>{p.push({points:g,length:co(g)})};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(dt([t,c,e])),h(l)&&u(dt([t,l,e]));const m=ks(p,i,s);if(m!==null&&!m.contact&&!m.hugs)return m.points;const f=Kc(t,e,a,d,i,s);return f!==null&&(m===null||ys(f,m))?f.points:m!==null?m.points:jc(t,e,d,o)??dt([t,l,e])},Wc=12,Vc=16,an=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),vs=(t,e)=>{const n=an(t),o=an(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"},ho=t=>t==="left"||t==="right"?"y":"x",ws=(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},Qc=(t,e,n)=>{const o=ho(e)==="y"?t.height:t.width,i=ho(e)==="y"?t.y:t.x;return{low:i+Math.min(n,o/2),high:i+Math.max(o-n,o/2)}},Zc=(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}}},$s=(t,e,n={})=>{const o=new Map(t.map(h=>[h.id,h])),i=n.inset??Wc,s=n.gap??Vc,r=n.sideOf??(h=>vs(h.node,h.other)),a=new Map,d=(h,p)=>{const u=an(h.node),m=an(p),f=ho(h.side)==="y"?m.y:m.x,g=`${h.node.id}\0${h.side}`,b=a.get(g),y={...h,order:f,distance:Math.abs(m.x-u.x)+Math.abs(m.y-u.y)};b?b.push(y):a.set(g,[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:m}=Qc(p.node,p.side,i),f=[...h].sort((g,b)=>g.order-b.order||b.distance-g.distance||g.edgeId.localeCompare(b.edgeId)||g.end.localeCompare(b.end));f.forEach((g,b)=>{const y=Zc(g.node,g.side,ws(u,m,f.length,b,s)),x=l.get(g.edgeId)??{};g.end==="from"?x.from={point:y,side:g.side}:x.to={point:y,side:g.side},l.set(g.edgeId,x)})}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},Es={trackSpacing:6,frameClearance:6},Jc=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,ep=(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},tp=(t,e)=>t.orientation==="vertical"?ge(e,t.rangeMin,t.rangeMax,t.obstacles):fe(e,t.rangeMin,t.rangeMax,t.obstacles),np=(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)),op=(t,e,n,o=[],i=0)=>{const s=d=>tp(t,d)||o.length>0&&np(t,d,o,i);let r=n,a=0;for(;s(r)&&a<8;)r=(r+e)/2,a++;return s(r)?e:r},ip=(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}},sp=(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))},uo=(t,e={})=>{const n=e.trackSpacing??Es.trackSpacing,o=e.frameClearance??Es.frameClearance,i=e.minPortRun??0,s=[],r=new Map;for(const c of t){const h=Jc(c.points);if(h===null)continue;const p=c.points[h.segIndex],u=c.points[h.segIndex+1],m=h.orientation==="vertical"?p.x:p.y,[f,g]=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:m,rangeMin:f,rangeMax:g,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=ep(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(m=>m.orientation===c);if(h.length===0)continue;const p=sp(h,n),u=new Map;for(let m=0;m<h.length;m++){const f=p[m],g=u.get(f);g?g.push(h[m]):u.set(f,[h[m]])}for(const m of u.values()){const f=[...m].sort((b,y)=>b.edgeId.localeCompare(y.edgeId)),g=f.reduce((b,y)=>b+y.coord,0)/f.length;f.forEach((b,y)=>{const x=f.length===1?b.coord:g+(y-(f.length-1)/2)*n,w=d.get(b.edgeId),$=w.points[b.segIndex][c==="vertical"?"x":"y"],{low:A,high:C}=ip(w.points,b.segIndex,c,i),M=i>0?A>C?$:Math.min(C,Math.max(A,x)):x,E=op(b,$,M,r.get(b.edgeId)??[],o),_=(a.get(b.edgeId)??w.points).map((D,O)=>O!==b.segIndex&&O!==b.segIndex+1?D:c==="vertical"?{x:E,y:D.y}:{x:D.x,y:E});a.set(b.edgeId,_),l.add(b.edgeId)})}}for(const c of t)l.has(c.id)||a.set(c.id,c.points);return a},rp={margin:16,portGap:16},ap=12,dn=16,Ts=11,mo=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),Ss=(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)}),dp=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},Ms=t=>t.slice(1).map((e,n)=>[t[n],e]),Cs=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}}},Ls=(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,lp=(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=pp(n),r=c=>({x:c.x,y:c.y-6-Ts+2,width:s,height:Ts}),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}:cp(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},cp=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},pp=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:5.6;return Math.ceil(e+4)},hp=(t,e,n={})=>{const o={...rp,...n},i=new Map(t.nodes.map(b=>[b.id,b])),s=e.filter(b=>i.has(b.from)&&i.has(b.to));if(s.length===0)return t;const r=new Map(t.nodes.map(b=>[b.id,mo(b)])),a=$s(t.nodes,s,{inset:ap,gap:o.portGap,sideOf:({node:b,other:y,edge:x,end:w})=>{const $=i.get(x.from),A=i.get(x.to),C=$!==void 0&&A!==void 0?Ls($,A):null;return C===null?vs(b,y):w==="from"?C.from:C.to}}),d=new Map(t.routes.map(b=>[b.id,b.points])),l=b=>{const y=i.get(b.from),x=i.get(b.to);return y===void 0||x===void 0?0:Math.abs(x.x-y.x)+Math.abs(x.y-y.y)},c=[...s].sort((b,y)=>l(b)-l(y)||b.id.localeCompare(y.id)),h=[],p=new Map;for(const b of c){const y=i.get(b.from),x=i.get(b.to),w=a.get(b.id),$=d.get(b.id)??[],A=y!==void 0&&x!==void 0?Ls(y,x):null;if(y===void 0||x===void 0||w===void 0||A===null||y.id===x.id){p.set(b.id,$),h.push(...Ms($));continue}const C=[r.get(y.id),r.get(x.id)],M=t.nodes.filter(H=>H.id!==y.id&&H.id!==x.id).map(mo),E=Cs(w.from.side),_=Cs(w.to.side),D=po({x:w.from.point.x+E.x*dn,y:w.from.point.y+E.y*dn},{x:w.to.point.x+_.x*dn,y:w.to.point.y+_.y*dn},M,o.margin,h,[...C,...M],C),O=dp([w.from.point,...D,w.to.point]),B=Ss(O,M)&&!Ss($,M)?$:O;p.set(b.id,B),h.push(...Ms(B))}const u=s.map(b=>{const y=i.get(b.from),x=i.get(b.to),w=y!==void 0&&x!==void 0?[r.get(y.id),r.get(x.id)]:[];return{id:b.id,points:p.get(b.id)??[],obstacles:t.nodes.filter($=>$.id!==b.from&&$.id!==b.to).map(mo),ownFrames:w}}),m=uo(u,{minPortRun:0}),f=s.map(b=>({id:b.id,points:m.get(b.id)??p.get(b.id)??[]})),g=[...f.flatMap(b=>b.points),...t.nodes.map(b=>({x:b.x+b.width,y:b.y+b.height}))];return{...t,width:Math.max(t.width,...g.map(b=>b.x)),height:Math.max(t.height,...g.map(b=>b.y)),routes:[...t.routes.filter(b=>!s.some(y=>y.id===b.id)),...f]}},up=de`
412
412
  .arch-toggle {
413
413
  min-height: 26px;
414
414
  padding: 0 9px;
@@ -570,7 +570,7 @@ 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 a
570
570
  fill: var(--dpk-blue);
571
571
  stroke: var(--dpk-blue);
572
572
  }
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`
573
+ `,mp=[{id:"arch-neutral"},{id:"arch-selected"}];class Is extends at{static{this.styles=[Ne,up]}#o=!0;parseData(e){return Mc(e)}emptyData(){return Sc()}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 hp(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=yl([...e,...this.#e()],n?.clientHeight??0);this.viewport?.reset(o??void 0)}relations(e,n){if(e===null||e.kind!=="node")return Le;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 v`
574
574
  <button
575
575
  type="button"
576
576
  class="dpk-btn dpk-btn--ghost arch-toggle"
@@ -580,7 +580,7 @@ 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 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 $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`
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 Ac(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=on(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}
@@ -604,16 +604,16 @@ 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 a
604
604
  ></path>
605
605
  ${s.label===null||a.length===0?T:this.#t(s.label,a)}
606
606
  </g>
607
- `});return k`
608
- ${this.#o?this.#e().map(s=>k`<div
607
+ `});return v`
608
+ ${this.#o?this.#e().map(s=>v`<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
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`
615
+ ${this.renderEdges(i,mp)} ${n.nodes.map(s=>this.#n(s,e))}
616
+ `}#t(e,n){const o=lp(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 v`
617
617
  <button
618
618
  type="button"
619
619
  class=${this.elementClass(i,"d-node","arch-service",this.isDraggingNode(e.id)&&"is-dragging")}
@@ -626,7 +626,7 @@ 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 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?k`<span class="arch-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>`:k`<img
629
+ ${e.artwork===null?v`<span class="arch-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>`:v`<img
630
630
  class="arch-artwork"
631
631
  src=${e.artwork.src}
632
632
  alt=${e.artwork.alt}
@@ -634,10 +634,10 @@ 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 a
634
634
  />`}
635
635
  <span class="arch-body">
636
636
  <span class="arch-name">${e.name}</span>
637
- ${e.description===null?T:k`<span class="arch-description">${e.description}</span>`}
637
+ ${e.description===null?T:v`<span class="arch-description">${e.description}</span>`}
638
638
  </span>
639
639
  </button>
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`
640
+ `}}const As=()=>{customElements.get("dpk-board-architecture-map")||customElements.define("dpk-board-architecture-map",Is)},lt=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"}}),_s={width:176,height:84},gp=P({id:S(k(),I(1)),name:S(k(),I(1)),path:L(k()),layer:L(k()),tags:L(F(k()),[]),description:L(k()),questions:L(k())}),fp=P({id:S(k(),I(1)),from:S(k(),I(1)),to:S(k(),I(1)),contract:L(k()),description:L(k()),questions:L(k())}),bp=P({modules:F(gp),dependencies:L(F(fp),[])}),xp=()=>({nodes:[],edges:[]}),yp=t=>{const e=ue(bp,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:_s.width,height:_s.height,...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},kp=de`
641
641
  .dep-direction {
642
642
  display: flex;
643
643
  gap: 2px;
@@ -831,9 +831,9 @@ 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 a
831
831
  fill: var(--dpk-blue);
832
832
  stroke: var(--dpk-blue);
833
833
  }
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`
834
+ `,vp=[{id:"dep-neutral"},{id:"dep-outgoing"},{id:"dep-incoming"},{id:"dep-cycle"},{id:"dep-selected"}];class Rs extends at{static{this.styles=[Ne,kp]}#o="both";#i=!1;#e=!1;#t=[];#n=Le;#a=Le;parseData(e){return yp(e)}emptyData(){return xp()}defaultHeading(){return lt(this.locale).heading}statsLabels(){const e=lt(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){const e=lt(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"?Le:{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=>Ie(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=kl(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):Le,this.#a=r!==null&&r.kind==="node"&&this.#o!=="outgoing"?we(s,r.id,"incoming",this.#i):Le,super.refreshContent()}matchesFilter(e){return this.#e?Vn(this.#t).has(e.id):!0}filtered(){const e=super.filtered();if(!this.#e)return e;const n=Vn(this.#t),o=e.edges.filter(s=>Ii(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=lt(this.locale),n=this.#t.length;return v`
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])=>k`
836
+ ${[["outgoing",e.directionOutgoing],["incoming",e.directionIncoming],["both",e.directionBoth]].map(([o,i])=>v`
837
837
  <button
838
838
  type="button"
839
839
  data-direction=${o}
@@ -864,11 +864,11 @@ 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 a
864
864
  >
865
865
  ${e.cyclesCount(n)}
866
866
  </button>
867
- `}renderLegend(){const e=dt(this.locale);return k`<div class="diagram-legend">
867
+ `}renderLegend(){const e=lt(this.locale);return v`<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":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`
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":Ii(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=lt(this.locale),n=this.visible,o=Vn(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=on(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 Od,S as Bn,a5 as pe,a6 as Nd,a7 as zd,a8 as re,a9 as _,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 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`
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 v`
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 Od,S as Bn,a5 as pe,a6 as Nd,a7 as zd,a8 as re,a9 as _,aa as F,ab a
905
905
  >
906
906
  <span class="dep-head">
907
907
  <span class="dep-layer">${a.layer??""}</span>
908
- ${c?k`<span class="dep-cycle-badge">${e.cycleBadge}</span>`:T}
908
+ ${c?v`<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 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`
913
+ `});return v`${this.renderEdges(s,vp)}${r}`}}const Ds=()=>{customElements.get("dpk-board-dependency-graph")||customElements.define("dpk-board-dependency-graph",Rs)},wp=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,Os=6,$p=12,Ns=7,Ep=7,go=13,fo=14,Tp=6,ln=t=>t+St-2,zs=Math.max(go,fo,ln(fo)+St,ln(go)+St),Ps=(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)=>Ps(t,e),qs=t=>Math.round(t*100)/100||0,Mp=(t,e,n)=>{const o=(e==="start"?t[0]:t.at(-1))??{x:0,y:0},i=Ps(t,e),s={x:-i.y,y:i.x},r=(f,g=0)=>({x:qs(o.x+i.x*f+s.x*g),y:qs(o.y+i.y*f+s.y*g)}),a=f=>[r(f,-Os),r(f,Os)],d=wp(n),l=d.max==="many"?[-Ns,0,Ns].map(f=>[r($p),r(0,f)]):[a(Ep)],c=d.max==="many"?fo:go,h=d.min==="one"?[...l,a(c)]:l,p=d.min==="zero"?r(ln(c)):null,u=(d.min==="zero"?ln(c)+St:c)+Tp,m=r(u);return{segments:h,circle:p,label:{...m,anchor:i.x>=0?"start":"end"}}},cn=10,Cp=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:6.2;return Math.ceil(e+2)},bo=(t,e)=>e!=null&&e!==t?`${e} ${t}`:t,Fs=(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,Us=(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)),Lp=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}]],xo=(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=Cp(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 m of h){const f=s.x+r.x*u+a.x*m,g=s.y+r.y*u+a.y*m;let b,y;if(d){const x=r.x>0;b=x?"start":"end",y={x:x?f:f-l,y:g-cn/2,width:l,height:cn}}else{const x=a.x*m>0;b=x?"start":"end",y={x:x?f:f-l,y:g-cn/2,width:l,height:cn}}p.push({x:f,y:g,anchor:b,box:y,along:u,across:m})}return p},Ip=(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)Fs(o,s.box)&&(i+=1e6);for(const s of e.frames)for(const[r,a]of Lp(s.box))if(Us(r,a,o)>0){i+=1e5;break}for(const s of n)Fs(o,s)&&(i+=1e5);for(const s of e.edges??[])for(let r=1;r<s.length;r++)if(Us(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},yo=(t,e,n,o,i,s,r)=>{let a=xo(n,e,i,!1)[0],d=Number.POSITIVE_INFINITY;const l=c=>{for(const h of c){const p=Ip(h,s,r);p<d&&(a=h,d=p)}};return l(xo(n,e,i,!1)),d>=1e4&&l(xo(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}},Ap=(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=yo(s,"start",r,a,bo(a,s.before?.cardinality.parent),n,o);o.push(l.box);const c=yo(s,"end",r,d,bo(d,s.before?.cardinality.child),n,o);o.push(c.box);const h=s.label===null?null:yo(s,"relation",r,s.label,bo(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},We=t=>`${t.x} ${t.y}`,ko=t=>Math.round(t*100)/100||0,vo=t=>{switch(t.kind){case"move":return`M${We(t.to)}`;case"line":return`L${We(t.to)}`;case"quad":return`Q${We(t.control)} ${We(t.to)}`;case"cubic":return`C${We(t.control1)} ${We(t.control2)} ${We(t.to)}`}},_p=t=>t.map(vo).join(" "),ze=6,Rp=2*ze+2,Dp=.01,Bs=24,Op=t=>{const e=Np(t),n=e.flatMap(([i,s])=>[i.x,s.x]),o=e.flatMap(([i,s])=>[i.y,s.y]);return{pieces:e,ends:Hs(t),left:Math.min(...n),right:Math.max(...n),top:Math.min(...o),bottom:Math.max(...o)}},Hs=t=>[t[0]?.to,t.at(-1)?.to].filter(e=>e!==void 0),Ys=(t,e)=>t.every(n=>Math.hypot(e.x-n.x,e.y-n.y)>=zs+ze),Gs=t=>Array.from({length:Bs},(e,n)=>t((n+1)/Bs)),Np=t=>{const e=[];let n=null;for(const o of t){if(o.kind==="move"||n===null){n=o.to;continue}const i=n,s=o.kind==="line"?[o.to]:o.kind==="quad"?Gs(a=>({x:(1-a)**2*i.x+2*(1-a)*a*o.control.x+a**2*o.to.x,y:(1-a)**2*i.y+2*(1-a)*a*o.control.y+a**2*o.to.y})):Gs(a=>({x:(1-a)**3*i.x+3*(1-a)**2*a*o.control1.x+3*(1-a)*a**2*o.control2.x+a**3*o.to.x,y:(1-a)**3*i.y+3*(1-a)**2*a*o.control1.y+3*(1-a)*a**2*o.control2.y+a**3*o.to.y}));let r=i;for(const a of s)e.push([r,a]),r=a;n=o.to}return e},zp=(t,e)=>t.flatMap(([n,o],i)=>n.y<e==o.y<e?[]:i===0&&n.y===e||i===t.length-1&&o.y===e?[]:[n.x+(o.x-n.x)*(e-n.y)/(o.y-n.y)]),Pp=(t,e)=>{const n=new Map([...t].filter(([o])=>e.has(o)).map(([o,i])=>[o,Op(i)]));return new Map([...t].map(([o,i])=>{const s=Hs(i),r=[];let a=null;for(const d of i){const l=a;if(a=d.to,d.kind!=="line"||l===null||Math.abs(l.y-d.to.y)>Dp||l.x===d.to.x){r.push(vo(d));continue}const c=l.y,h=Math.sign(d.to.x-l.x),p=Math.min(l.x,d.to.x)+ze+1,u=Math.max(l.x,d.to.x)-ze-1,m=[...n].filter(([b,y])=>b!==o&&y.top<c&&y.bottom>c&&y.left<u&&y.right>p).flatMap(([,b])=>zp(b.pieces,c).filter(y=>Ys(b.ends,{x:y,y:c}))).filter(b=>b>p&&b<u&&Ys(s,{x:b,y:c})).sort((b,y)=>(b-y)*h),f=[];for(const b of m){const y=f.at(-1);y!==void 0&&Math.abs(b-y.last)<Rp?y.last=b:f.push({first:b,last:b})}const g=h>0?1:0;for(const b of f){const y=ko(Math.abs(b.last-b.first)/2+ze);r.push(`L${ko(b.first-ze*h)} ${c}`,`A${y} ${ze} 0 0 ${g} ${ko(b.last+ze*h)} ${c}`)}r.push(vo(d))}return[o,r.join(" ")]}))},Xs=(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=>Xs(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",relationScopeLabel:"Relation lines shown",relationScopeAll:"All lines",relationScopeBoundedContext:"Within BC only",relationScopeAggregate:"Within aggregate 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=>Xs(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",relationScopeLabel:"\u8868\u793A\u3059\u308B\u95A2\u9023\u7DDA",relationScopeAll:"\u3059\u3079\u3066\u306E\u7DDA",relationScopeBoundedContext:"BC \u5185\u306E\u7DDA\u306E\u307F",relationScopeAggregate:"\u96C6\u7D04\u5185\u306E\u7DDA\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"}}),qp=280,wo=48,Fp=32,Up=52,Bp=16,Hp=18,Yp=10,Gp=440,Ks=["1","0..1"],js=["1","0..1","1..N","0..N"],$o=Ks.flatMap(t=>js.map(e=>`${t}:${e}`)),Xp=["immutable","mutable","sti","cti","value-object"],Kp=G(Xp),Ws=G(["PK","FK","UQ"]),jp=P({id:S(k(),I(1)),type:S(k(),I(1)),key:L(ol([Ws,S(F(Ws),I(1))])),ref:L(k()),nullable:L(yt(),!1),cardinality:L(G($o)),label:L(S(k(),I(1))),description:L(k()),questions:L(k())}),Wp=Gn("kind",[P({kind:he("unique"),columns:S(F(S(k(),I(1))),I(1))}),P({kind:he("primary-key"),columns:S(F(S(k(),I(1))),I(1))}),P({kind:he("check"),expression:S(k(),I(1))}),P({kind:he("exclude"),using:L(S(k(),I(1))),elements:S(F(S(k(),I(1))),I(1))})]),Vp=P({id:S(k(),I(1)),name:S(k(),I(1)),tags:L(F(k()),[]),boundedContext:L(k()),aggregate:L(k()),pattern:L(Kp),fields:F(jp),constraints:L(F(Wp),[]),questions:L(k())}),Vs=P({tables:F(Vp)}),Qp=P({before:L(Vs),after:Vs}),Zp=()=>({nodes:[],edges:[]}),Jp=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}}))}),Eo=t=>t.key===void 0?[]:[...new Set(typeof t.key=="string"?[t.key]:t.key)],Qs=t=>({id:t.id,type:t.type,keys:Eo(t),ref:t.ref??null,nullable:t.nullable,cardinality:t.cardinality??null,label:t.label??null,description:t.description??null,questions:t.questions??null}),To=(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,eh=t=>t.kind==="exclude"?{...t,using:t.using??null}:t,Zs=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}`,Js=(t,e)=>Mt(t.cardinality)===Mt(e.cardinality)&&t.label===e.label,th=(t,e)=>{const n=Eo(e);return n.includes("UQ")?!0:n.includes("PK")&&t.fields.filter(o=>Eo(o).includes("PK")).length===1},er=new Map(Ks.map(t=>[t,t])),tr=new Map(js.map(t=>[t,t])),nh=(t,e)=>{const n=th(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=er.get(i),a=tr.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}},So=t=>(t.status==="changed"?Up:Fp)+(t.description===null?0:Bp),oh=t=>t.length===0?0:Yp+t.length*Hp,nr=(t,e=[])=>wo+t.reduce((n,o)=>n+So(o),0)+oh(e),or=(t,e)=>{let n=wo;for(const o of t){if(o.id===e)return n+So(o)/2;n+=So(o)}return wo/2},ih=14,sh=(t,e)=>(t-(e-1)/2)*ih,ir=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,sh(i,n.length)])))},sr=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:nh(e,n),label:n.label??null}]})),rh=(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=Qs(r);if(!i)return[{...a,status:"added",before:null}];if(!s)return[{...a,status:"removed",before:null}];const d=Qs(i);return[{...a,status:To(d,a)?"same":"changed",before:To(d,a)?null:d}]}),rr=(t,e)=>{const n=ir(e),o={};for(const i of e)i.from===t.id&&(o[`${i.id}:out`]={x:t.width,y:or(t.fields,i.sourceField)+(n.get(i.id)??0)}),i.to===t.id&&(o[`${i.id}:in`]={x:0,y:or(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},ah=70,dh=20,lh=168,ch=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(lh,Math.ceil(n+e))},ar=(t,e,n=[])=>{const o=Ct(t,13)/2+100,i=Math.max(0,...e.map(r=>Ct(r.id,12)/2+ah+dh+ch(r))),s=Math.max(0,...n.map(r=>Ct(Zs(r),11)+24));return Math.min(Gp,Math.max(qp,Math.ceil(Math.max(o,i,s))))},ph=t=>{const e=ue(Qp,t),n=e.before?.tables??e.after.tables,o=e.after.tables,i=[...new Set([...n,...o].map(f=>f.id))],s=new Map,r=new Map,a=new Map,d=new Map;for(const f of[...n,...o])s.set(f.id,f.tags),r.set(f.id,f.boundedContext??null),a.set(f.id,f.aggregate??null),d.set(f.id,f.pattern??null);const l=i.flatMap(f=>{const g=n.find(M=>M.id===f),b=o.find(M=>M.id===f),y=b??g;if(!y)return[];const x=rh(g?.fields??[],b?.fields??[]),w=g?b?x.some(M=>M.status!=="same")?"changed":"same":"removed":"added",$=r.get(f)??null,A=a.get(f)??null,C=y.constraints.map(eh);return[{id:f,name:y.name,status:w,fields:x,tags:[...s.get(f)??[],...$===null?[]:[El($)]],boundedContext:$,aggregate:A,...A===null?{}:{group:A},pattern:d.get(f)??null,constraints:C,width:ar(f,x,C),height:nr(x,C),...y.questions===void 0?{}:{questions:y.questions}}]}),c=new Map(l.map(f=>[f.id,f])),h=sr(n),p=sr(o),m=[...new Set([...h,...p].map(f=>f.id))].flatMap(f=>{const g=h.find(C=>C.id===f),b=p.find(C=>C.id===f),y=b??g;if(!y)return[];const x=c.get(y.from),w=c.get(y.to);if(!x||!w)return[];const $=g&&b&&!Js(g,b)?g:null,A=g?b?$?"changed":"same":"removed":"added";return[{id:f,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:`${f}:out`,toPort:`${f}:in`}]});return{nodes:l.map(f=>rr(f,m)),edges:m}},dr="ADD_FIELD",lr="EDIT_FIELD",cr="DELETE_FIELD",pr="EDIT_CARDINALITY",hh=R({id:S(k(),ye(),I(1)),type:S(k(),ye(),I(1)),nullable:L(yt(),!1),description:L(S(k(),ye()))}),uh=R({field:S(k(),I(1)),type:S(k(),ye(),I(1)),nullable:yt(),description:L(S(k(),ye()))}),mh=R({field:S(k(),I(1))}),gh=R({cardinality:G($o)}),Mo=t=>{const e=Oe(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},fh=t=>{const e=Oe(t);return e?.length===3&&e[1]==="edge"?e[2]??null:null},hr=(t,e,n)=>t.edges.filter(o=>o.from===e&&o.sourceField===n||o.to===e&&o.targetField===n),Co=(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 rr({...i,status:s,fields:n,width:ar(i.id,n,i.constraints),height:nr(n,i.constraints)},t.edges)});return{...t,nodes:o}},bh=(t,e,n)=>{const o=t.addFieldTitle,i=e.nodes.find(a=>a.id===Mo(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=re(hh,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:Co(e,i.id,[...i.fields,r]),result:{id:n.id,title:o,summary:t.addFieldSummary(i.id,r.id,r.type),tone:"create"}}},xh=(t,e,n)=>{const o=t.editFieldTitle,i=e.nodes.find(m=>m.id===Mo(n.target.id)),s=re(uh,n.payload),r=s.success?i?.fields.find(m=>m.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":To(h,c)?"same":"changed",u={...c,status:p,before:p==="changed"?h:null};return{data:Co(e,i.id,i.fields.map(m=>m.id===r.id?u:m)),result:{id:n.id,title:o,summary:t.editFieldSummary(i.id,r.id,c.type),tone:"update"}}},yh=(t,e,n)=>{const o=t.deleteFieldTitle,i=e.nodes.find(c=>c.id===Mo(n.target.id)),s=re(mh,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=hr(e,i.id,r.id),l=d.length===0?e.edges:e.edges.filter(c=>!d.includes(c));return{data:Co({...e,edges:l},i.id,a),result:{id:n.id,title:o,summary:t.deleteFieldSummary(i.id,r.id),tone:"delete"}}},kh=(t,e,n)=>{const o=t.editCardinalityTitle,i=e.edges.find(f=>f.id===fh(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=re(gh,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=er.get(r),l=tr.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":Js(p,h)?"same":"changed",m={...i,cardinality:c,status:u,before:u==="changed"?p:null};return{data:{...e,edges:e.edges.map(f=>f.id===i.id?m:f)},result:{id:n.id,title:o,summary:t.editCardinalitySummary(i.from,i.to,Mt(c)),tone:"update"}}},vh=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===dr?bh(t,o,s):s.type===lr?xh(t,o,s):s.type===cr?yh(t,o,s):s.type===pr?kh(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}},wh=de`
914
914
  .er-search {
915
915
  display: flex;
916
916
  align-items: center;
@@ -1494,7 +1494,9 @@ 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 a
1494
1494
 
1495
1495
  /* While something is lit, the relations it does not reach step back. */
1496
1496
  .er-edge {
1497
- transition: opacity 160ms ease;
1497
+ transition:
1498
+ opacity 160ms ease,
1499
+ visibility 160ms;
1498
1500
  }
1499
1501
 
1500
1502
  .er-edge.is-faded {
@@ -1642,6 +1644,17 @@ 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 a
1642
1644
  opacity: 0.12;
1643
1645
  }
1644
1646
 
1647
+ /*
1648
+ * A relation outside the chosen scope (Bounded Context or aggregate) stays undrawn until a
1649
+ * hover or the selection lights it (\`concealedRelations\` in view.ts). Hidden, not just transparent, so its
1650
+ * invisible hit path neither catches the pointer nor takes a tab stop. After
1651
+ * \`.is-bc-dimmed\` so it wins over that opacity.
1652
+ */
1653
+ .er-edge.is-concealed {
1654
+ visibility: hidden;
1655
+ opacity: 0;
1656
+ }
1657
+
1645
1658
  /* ---- Adding and editing columns ---- */
1646
1659
 
1647
1660
  .er-add {
@@ -1915,8 +1928,8 @@ 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 a
1915
1928
  * Slotted into dpk-dialog-panel's own floating controls bar, beside zoom and
1916
1929
  * maximize: the \`.dpk-segmented\` atom (via \`controlAtom\`, composed into
1917
1930
  * this component's own styles) trimmed down to that bar's compact height.
1918
- * \`renderControls\` wraps both segmented groups (columns shown, grouping
1919
- * frames) in \`.er-controls-row\` so they sit side by side as one slotted
1931
+ * \`renderControls\` wraps both segmented groups (relation lines shown,
1932
+ * grouping frames) in \`.er-controls-row\` so they sit side by side as one slotted
1920
1933
  * flex item.
1921
1934
  */
1922
1935
  .er-controls-row {
@@ -1925,17 +1938,17 @@ 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 a
1925
1938
  gap: 6px;
1926
1939
  }
1927
1940
 
1928
- .er-column-filter,
1941
+ .er-relation-scope,
1929
1942
  .er-grouping-filter {
1930
1943
  height: 28px;
1931
1944
  }
1932
1945
 
1933
- .er-column-filter > button,
1946
+ .er-relation-scope > button,
1934
1947
  .er-grouping-filter > button {
1935
1948
  padding: 0 10px;
1936
1949
  font-size: 10.5px;
1937
1950
  }
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`
1951
+ `,$h=(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 "),pn="\u2014",Eh=(t,e)=>{const n=t.before;return n===null?[]:[["type",i=>i.type],["keys",i=>i.keys.length===0?pn:i.keys.join("+")],["ref",i=>i.ref??pn],["nullable",i=>i.nullable?e.nullable:e.notNull],["cardinality",i=>i.cardinality??pn],["label",i=>i.label===null?pn:`\u201C${i.label}\u201D`]].flatMap(([i,s])=>s(n)===s(t)?[]:[{attribute:i,before:s(n),after:s(t)}])},Th=(t,e)=>t!==void 0&&JSON.stringify(t.base)===JSON.stringify(e)?t.draft:e,ur=t=>[...new Set(t.nodes.flatMap(e=>e.fields.map(n=>n.type)))].sort(),mr=(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}},gr=(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}},Sh=t=>t.keys.includes("PK")?"primary":t.keys.includes("FK")||t.ref!==null?"foreign":t.nullable?"nullable":"not-null",fr=(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,Mh=(t,e)=>{const n=e.map(r=>r.kind==="column"&&!t.some(a=>fr(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=>fr(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}},Ch=(t,e,n)=>{const o=new Map(e.map(s=>[s.id,s])),i=s=>{const r=o.get(s.from),a=o.get(s.to);switch(t){case"all":return!1;case"bounded-context":return r?.boundedContext!==a?.boundedContext;case"aggregate":{const d=r?.aggregate??null;return s.from!==s.to&&(d===null||d!==a?.aggregate)}}};return new Set(n.filter(i).map(s=>s.id))},Lh=t=>`${t.parent}:${t.child}`,br=18,xr=22,Lo=30,Io=46,Ih=160,Ah=120,_h=(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}},yr=(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:_h(r.map(a=>a.box),n,o)}))},Ao=t=>yr(t,e=>e.aggregate,br,xr).map(e=>({aggregate:e.key,box:e.box,tables:e.tables})),hn=t=>yr(t,e=>e.boundedContext,Lo,Io).map(e=>({boundedContext:e.key,box:e.box,tables:e.tables})),kr=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),ct=(t,e,n)=>Math.min(n,Math.max(e,t)),vr=(t,e)=>{const n=kr(t),o=kr(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,wr=(t,e,n)=>{const o=ct(n.y-t.y,te,Math.max(te,t.height-te)),i=t.height<=0?.5:o/t.height,s=t.x+ct(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}}},Rh=(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=vr(s,r),d=vr(r,s);return{start:wr(s,a,o),end:wr(r,d,i),startSide:a,endSide:d,source:s,target:r}},Pe=zs,$r=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}}},Dh=(t,e,n,o,i=[],s=[],r=[])=>po(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},Oh=(t,e,n,o,i)=>{const s=n.find(g=>g.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=ct(r.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),l=ct(a.y,s.y+te,Math.max(s.y+te,s.y+s.height-te)),c=ct(r.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),h=ct(a.x,s.x+te,Math.max(s.x+te,s.x+s.width-te)),p=n.filter(g=>g.id!==t.from).map(g=>g.box),u=o+Pe,m=[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(g=>g.slice(1).map((y,x)=>[g[x],y]).every(([y,x])=>y.x===x.x?!ge(y.x,Math.min(y.y,x.y),Math.max(y.y,x.y),p):!fe(y.y,Math.min(y.x,x.x),Math.max(y.x,x.x),p)));return m.length===0?e:m.reduce((g,b)=>{const y=ao(g,i),x=ao(b,i);if(y!==x)return x<y?b:g;const w=fs(g,i),$=fs(b,i);return w!==$?$<w?b:g:b.length<g.length?b:g})},Er=(t,e,n,o,i=[],s=[])=>{if(t.from===t.to)return Oh(t,e,n,o,s);const r=Rh(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,m=Math.max(r.start.y,r.end.y)+c,f=i.filter(A=>A.box.x<p&&A.box.x+A.box.width>h&&A.box.y<m&&A.box.y+A.box.height>u).map(A=>A.box),g=[...new Set([...d,...l,...f])],b=$r(r.startSide),y=$r(r.endSide),x={x:r.start.x+b.x*Pe,y:r.start.y+b.y*Pe},w={x:r.end.x+y.x*Pe,y:r.end.y+y.y*Pe},$=Dh(x,w,a,o,s,g,d);return Lt([r.start,...$,r.end])},Nh=t=>t.slice(1).map((e,n)=>[t[n],e]),zh=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)},Ph=(t,e,n,o,i=[])=>{const s=p=>zh(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)=>Er(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(...Nh(u))}const h=t.map(p=>{const u=n.filter(g=>g.id!==p.from&&g.id!==p.to).map(g=>g.box),m=n.filter(g=>g.id===p.from||g.id===p.to).map(g=>g.box),f=[];for(const g of i)(g.members.includes(p.from)||g.members.includes(p.to)?m:f).push(g.box);return{id:p.id,points:l.get(p.id)??[],obstacles:[...u,...f],ownFrames:m}});return uo(h,{minPortRun:Pe})},qh=10,Fh=(t,e,n=Pe)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0||!Uh(t))return Bh(t,qh,n);const s=[{kind:"move",to:o}];let r=o;const a=d=>{(d.x!==r.x||d.y!==r.y)&&s.push({kind:"line",to: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,x)=>x?y/2:y,p=d===1,u=d+2===t.length-1,m=(y,x)=>x?Math.max(0,y-n):y,f=m(h(l.x-(t[d-1]?.x??l.x),d-1>0),p),g=m(h((t[d+2]?.x??c.x)-c.x,d+2<t.length-1),u),b=It(Math.min(e,f,g));if(b===0){a(l),a(c);continue}a({x:It(l.x-b),y:l.y}),r={x:It(c.x+b),y:c.y},s.push({kind:"cubic",control1:l,control2:c,to:r})}return a(i),s},Uh=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),Bh=(t,e,n=Pe)=>{const[o,...i]=t;if(o===void 0)return[];const s=[{kind:"move",to:o}];return i.forEach((r,a)=>{const d=t[a]??r,l=i[a+1];if(l===void 0){s.push({kind:"line",to: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,m=Math.min(e,c/2,h/2,p,u);if(m<=0){s.push({kind:"line",to:r});return}const f=(g,b,y)=>({x:It(g.x+(b.x-g.x)/y*m),y:It(g.y+(b.y-g.y)/y*m)});s.push({kind:"line",to:f(r,d,c)},{kind:"quad",control:r,to:f(r,l,h)})}),s},It=t=>Math.round(t*100)/100||0,_o={nodeSpacing:64,layerSpacing:136,padding:Lo+Io+4,groupSpacing:br*2+xr+12,superGroupSpacing:Lo*2+Io+12,superGroupRowGap:Ih,superGroupColumnGap:Ah},Tr=_o.nodeSpacing/2,Hh=_o.layerSpacing/2,Yh=16,Gh='[data-action="add-field"], [data-action="edit-field"]',Sr={same:"",added:"+",removed:"\u2212",changed:"~"},Xh={primary:sl,foreign:$i,"not-null":wi,nullable:wi},Kh=(t,e)=>t.keys.filter(n=>!(e==="primary"&&n==="PK")&&!(e==="foreign"&&n==="FK")),jh=.5,Wh=(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 Mr extends at{static{this.styles=[Ne,wh,Sl]}#o="";#i=null;#e=null;#t=null;#n=new Map;#a=null;#r=new Map;#s=!1;#d=null;#c=new Set;#h=new ki(this);#p=new vi(this);#u=null;#l="bounded-context";#m=!0;#g=!0;#f=null;#x=null;#A=null;constructor(){super(),new il(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.#k(this.#i)&&(this.#i=null);const n=this.selection;if(n!==null&&n.kind==="edge"&&this.#_){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:Lh(o.cardinality),failed:!1}}}else this.#u!==null&&(this.#u=null)}updated(){super.updated(),this.#B(),this.#L(),typeof ResizeObserver<"u"&&(this.#d??=new ResizeObserver(()=>this.#w())),this.#S(),this.#w()}#S(){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))}#w(){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};Wh(this.#r.get(o),l,jh)||(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])}#M(){const e=this.tagFilter.active.filter(n=>n.startsWith(jt));return e.length===0?null:{...this.tagFilter,active:e}}filtered(){const e=this.items(),o=this.#M()===null?this.tagFilter:{...this.tagFilter,active:this.tagFilter.active.filter(d=>!d.startsWith(jt))},i=e.nodes.filter(d=>Ie(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=ir(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 ph(e)}reduceElementActions(e,n){return vh($e(this.locale),e,n)}emptyData(){return Zp()}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 _o}computePlacement(e){const{nodes:n,edges:o}=Jp(e),i=this.layoutOptions();return this.layoutMode==="fixed"?es(n,o,i):Hi(n,o,i)}focusBounds(){const e=this.#M();if(e===null)return null;const n=new Set(e.active.map(d=>d.slice(jt.length))),o=hn(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.#M()?.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 Le;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 v`
1939
1952
  <label class="er-search">
1940
1953
  <span class="dpk-label">${e.search}</span>
1941
1954
  <input
@@ -1946,13 +1959,13 @@ 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 a
1946
1959
  @input=${n=>{const o=n.currentTarget;o instanceof HTMLInputElement&&(this.#o=o.value.trim().toLowerCase(),this.requestUpdate())}}
1947
1960
  />
1948
1961
  </label>
1949
- `}renderLegend(){const e=$e(this.locale);return k`<div class="diagram-legend">
1962
+ `}renderLegend(){const e=$e(this.locale);return v`<div class="diagram-legend">
1950
1963
  <span><i class="er-swatch-added"></i>${e.legendAdded}</span>
1951
1964
  <span><i class="er-swatch-removed"></i>${e.legendRemoved}</span>
1952
1965
  <span><i class="er-swatch-changed"></i>${e.legendChanged}</span>
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
- <div class="dpk-segmented er-column-filter" role="group" aria-label=${e.columnFilterLabel}>
1955
- ${n.map(i=>k`<button
1966
+ </div>`}renderControls(){const e=$e(this.locale),n=[{value:"all",label:e.relationScopeAll},{value:"bounded-context",label:e.relationScopeBoundedContext},{value:"aggregate",label:e.relationScopeAggregate}],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">
1967
+ <div class="dpk-segmented er-relation-scope" role="group" aria-label=${e.relationScopeLabel}>
1968
+ ${n.map(i=>v`<button
1956
1969
  type="button"
1957
1970
  aria-pressed=${this.#l===i.value?"true":"false"}
1958
1971
  @click=${()=>{this.#l=i.value,this.requestUpdate()}}
@@ -1961,7 +1974,7 @@ 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 a
1961
1974
  </button>`)}
1962
1975
  </div>
1963
1976
  <div class="dpk-segmented er-grouping-filter" role="group" aria-label=${e.groupingLabel}>
1964
- ${o.map(i=>k`<button
1977
+ ${o.map(i=>v`<button
1965
1978
  type="button"
1966
1979
  aria-pressed=${i.pressed?"true":"false"}
1967
1980
  @click=${i.onClick}
@@ -1969,52 +1982,52 @@ 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 a
1969
1982
  ${i.label}
1970
1983
  </button>`)}
1971
1984
  </div>
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`
1985
+ </div>`}#b(e){const n=this.selection,o=n===null?null:n.kind==="node"?{kind:"table",id:n.id}:{kind:"relation",id:n.id};return Mh(e.edges,[this.#i,o].filter(i=>i!==null))}#y(e){return Ch(this.#l,e.nodes,e.edges)}#v(e,n){const o=this.#C(e),i=()=>new Map(e.edges.map(p=>[p.id,Fh(o.get(p.id)??[],Hh)]));if(this.draggedNodeIds().size>0)return new Map([...i()].map(([p,u])=>[p,_p(u)]));const s=this.#y(e),r=e.edges.map(p=>p.id).filter(p=>!s.has(p)||n.edges.has(p)),a=`${this.#f?.signature??""}|${this.layout?.width??0}x${this.layout?.height??0}`;this.#A?.signature!==a&&(this.#A={signature:a,byDrawn:new Map});const d=this.#A.byDrawn,l=r.join(","),c=d.get(l);if(c!==void 0)return c;const h=Pp(i(),new Set(r));return d.size>=Yh&&d.delete(d.keys().next().value??""),d.set(l,h),h}#k(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)}#C(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=[...Ao(o).map(h=>({box:h.box,members:h.tables})),...hn(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,Er(u,s.get(u.id)??[],n,Tr,i));return p}if(l!==null&&l.signature===a)return l.result;const c=Ph(e.edges,s,n,Tr,i);return this.#f={signature:a,result:c},c}renderCanvas(){const e=$e(this.locale),n=this.visible,o=this.#b(n),i=this.#M(),s=new Set(i===null?[]:n.nodes.filter(x=>!Ie(x.tags,i)).map(x=>x.id)),r=this.#y(n),a=[...n.edges].sort((x,w)=>Number(o.edges.has(x.id))-Number(o.edges.has(w.id))),d=this.#C(n),l=n.nodes.flatMap(x=>{const w=this.placedNode(x.id);return w===void 0?[]:[{id:x.id,box:w}]}),c=n.nodes.map(x=>({id:x.id,aggregate:x.aggregate,boundedContext:x.boundedContext,box:this.placedNode(x.id)??null})),h=[...Ao(c).map(x=>({box:x.box})),...hn(c).map(x=>({box:x.box}))],p=`${this.#f?.signature??""}|${this.layout?.width??0}x${this.layout?.height??0}`,u=this.draggedNodeIds().size>0;let m=!u&&this.#x?.signature===p?this.#x.result:null;m===null&&(m=Ap(n.edges,d,{nodes:l,frames:h,edges:[...d.values()],width:this.layout?.width??0,height:this.layout?.height??0}),u||(this.#x={signature:p,result:m}));const f=this.#v(n,o),g=a.map(x=>{const w=this.edgeState(x.id),$=d.get(x.id)??[],A=f.get(x.id)??"",C=()=>this.select({kind:"edge",id:x.id}),M=[Mt(x.cardinality),x.label].filter(Boolean).join(" \xB7 "),E=x.before===null?null:[Mt(x.before.cardinality),x.before.label].filter(Boolean).join(" \xB7 ");return Y`
1973
1986
  <g
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
- data-relation=${m.id}
1976
- data-dpk-target=${this.commentRef("edge",m.id)}
1987
+ class=${this.elementClass({...w,dimmed:!1},"d-edge","er-edge",`is-${x.status}`,o.edges.has(x.id)&&"is-lit",o.edges.size>0&&!o.edges.has(x.id)&&"is-faded",(s.has(x.from)||s.has(x.to))&&"is-bc-dimmed",r.has(x.id)&&!o.edges.has(x.id)&&"is-concealed")}
1988
+ data-relation=${x.id}
1989
+ data-dpk-target=${this.commentRef("edge",x.id)}
1977
1990
  data-dpk-check="off"
1978
- @pointerenter=${()=>this.#y({kind:"relation",id:m.id})}
1979
- @pointerleave=${()=>this.#y(null)}
1991
+ @pointerenter=${()=>this.#T({kind:"relation",id:x.id})}
1992
+ @pointerleave=${()=>this.#T(null)}
1980
1993
  >
1981
- <title>${[`${m.from}.${m.sourceField} \u2192 ${m.to}.${m.targetField}`,A,C===null?null:`(${e.was(C)})`].filter(Boolean).join(" \xB7 ")}</title>
1982
- <path class="d-edge-path" d=${w}></path>
1983
- <path class="er-edge-flow" d=${w}></path>
1994
+ <title>${[`${x.from}.${x.sourceField} \u2192 ${x.to}.${x.targetField}`,M,E===null?null:`(${e.was(E)})`].filter(Boolean).join(" \xB7 ")}</title>
1995
+ <path class="d-edge-path" d=${A}></path>
1996
+ <path class="er-edge-flow" d=${A}></path>
1984
1997
  <path
1985
1998
  class="d-edge-hit"
1986
- d=${w}
1999
+ d=${A}
1987
2000
  role="button"
1988
2001
  tabindex="0"
1989
- aria-label=${e.edgeLabel(m.from,m.to,A)}
1990
- @click=${$}
1991
- @keydown=${M=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),$())}}
2002
+ aria-label=${e.edgeLabel(x.from,x.to,M)}
2003
+ @click=${C}
2004
+ @keydown=${_=>{_.key!=="Enter"&&_.key!==" "||(_.preventDefault(),C())}}
1992
2005
  ></path>
1993
- ${v.length>0?this.#T(v,m,u.get(m.id)):T}
2006
+ ${$.length>0?this.#$($,x,m.get(x.id)):T}
1994
2007
  </g>
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
- style="left:${m.box.x}px; top:${m.box.y}px; width:${m.box.width}px; height:${m.box.height}px"
2008
+ `}),b=this.#m?hn(n.nodes.map(x=>({id:x.id,boundedContext:x.boundedContext,box:this.placedNode(x.id)??null}))):[],y=this.#g?Ao(n.nodes.map(x=>({id:x.id,aggregate:x.aggregate,box:this.placedNode(x.id)??null}))):[];return v`${b.map(x=>v`<div
2009
+ class=${ve("er-bc",i!==null&&!Ie([`${jt}${x.boundedContext}`],i)&&"is-bc-dimmed")}
2010
+ style="left:${x.box.x}px; top:${x.box.y}px; width:${x.box.width}px; height:${x.box.height}px"
1998
2011
  >
1999
- <span class="er-bc-label">${m.boundedContext}</span>
2000
- </div>`)}${f.map(m=>k`<div
2001
- class=${ve("er-aggregate",this.isDraggingGroup(m.aggregate)&&"is-dragging")}
2002
- style="left:${m.box.x}px; top:${m.box.y}px; width:${m.box.width}px; height:${m.box.height}px"
2003
- @pointerdown=${y=>{y.composedPath().some(v=>v instanceof Element&&v.matches(".d-node"))||this.onGroupDragStart(y,m.aggregate,m.tables)}}
2012
+ <span class="er-bc-label">${x.boundedContext}</span>
2013
+ </div>`)}${y.map(x=>v`<div
2014
+ class=${ve("er-aggregate",this.isDraggingGroup(x.aggregate)&&"is-dragging")}
2015
+ style="left:${x.box.x}px; top:${x.box.y}px; width:${x.box.width}px; height:${x.box.height}px"
2016
+ @pointerdown=${w=>{w.composedPath().some($=>$ instanceof Element&&$.matches(".d-node"))||this.onGroupDragStart(w,x.aggregate,x.tables)}}
2004
2017
  >
2005
- <span class="er-aggregate-label">${m.aggregate}</span>
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`
2018
+ <span class="er-aggregate-label">${x.aggregate}</span>
2019
+ </div>`)}${this.renderEdges(Se(g,(x,w)=>a[w]?.id,x=>x),[])}${n.nodes.map(x=>this.#q(x,o,e,s.has(x.id)))}`}#$(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),m=Mp(e,h,p),f=o?.[h];return{glyph:m,content:Y`
2007
2020
  <g class="er-end" data-end=${h} data-multiplicity=${p}>
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?T:Y`<circle cx=${g.circle.x} cy=${g.circle.y} r=${St}></circle>`}
2021
+ ${m.segments.map(([g,b])=>Y`<line x1=${g.x} y1=${g.y} x2=${b.x} y2=${b.y}></line>`)}
2022
+ ${m.circle===null?T:Y`<circle cx=${m.circle.x} cy=${m.circle.y} r=${St}></circle>`}
2010
2023
  </g>
2011
2024
  <text
2012
2025
  class="er-cardinality is-${n.status}"
2013
2026
  data-end=${h}
2014
- text-anchor=${b?.anchor??g.label.anchor}
2027
+ text-anchor=${f?.anchor??m.label.anchor}
2015
2028
  dominant-baseline="central"
2016
- x=${b?.x??g.label.x}
2017
- y=${b?.y??g.label.y}
2029
+ x=${f?.x??m.label.x}
2030
+ y=${f?.y??m.label.y}
2018
2031
  >${s(p,u)}</text>
2019
2032
  `}},a=r("start"),d=r("end"),l=n.label??i?.label??null,c=o?.relation;return Y`
2020
2033
  ${a.content}${d.content}
@@ -2025,7 +2038,7 @@ 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 a
2025
2038
  dominant-baseline="central"
2026
2039
  y=${c?.y??d.glyph.label.y}
2027
2040
  >${s(n.label,i?.label)}</text>`}
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`
2041
+ `}#q(e,n,o,i){const s=this.placedNode(e.id);if(!s)return T;const r=this.nodeState(e.id),a=e.fields;return v`
2029
2042
  <div
2030
2043
  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
2044
  data-er-table=${e.id}
@@ -2033,8 +2046,8 @@ 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 a
2033
2046
  data-dpk-target=${this.commentRef("node",e.id)}
2034
2047
  style="left:${s.x}px; top:${s.y}px; width:${e.width}px"
2035
2048
  @pointerdown=${d=>this.onNodeDragStart(d,e.id)}
2036
- @pointerenter=${()=>this.#y({kind:"table",id:e.id})}
2037
- @pointerleave=${()=>this.#y(null)}
2049
+ @pointerenter=${()=>this.#T({kind:"table",id:e.id})}
2050
+ @pointerleave=${()=>this.#T(null)}
2038
2051
  >
2039
2052
  <div class="er-head">
2040
2053
  <button
@@ -2049,7 +2062,7 @@ 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 a
2049
2062
  <span class="er-title">
2050
2063
  <span class="er-title-top">
2051
2064
  <span class="er-name">${e.id}</span>
2052
- ${e.pattern===null?T:k`<span
2065
+ ${e.pattern===null?T:v`<span
2053
2066
  class="er-pattern-badge"
2054
2067
  data-pattern=${e.pattern}
2055
2068
  title=${o.patternLabel(e.pattern)}
@@ -2058,38 +2071,38 @@ 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 a
2058
2071
  </span>
2059
2072
  <span class="er-label">${e.name}</span>
2060
2073
  </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
2074
+ ${e.status==="same"?T:v`<span class="er-status"
2075
+ ><span aria-hidden="true">${Sr[e.status]}</span>${o.statusLabel(e.status)}</span
2063
2076
  >`}
2064
2077
  </button>
2065
2078
  </div>
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)}
2079
+ ${a.length===0?T:v`<div class="er-fields">${a.map(d=>this.#z(e,d,n,o))}</div>`}
2080
+ ${this.#O(e,o)} ${this.#U(e,o)}
2068
2081
  </div>
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`
2082
+ `}#O(e,n){return e.constraints.length===0?T:v`<ul class="er-constraints" aria-label=${n.tableConstraintsLabel}>
2083
+ ${e.constraints.map(o=>v`<li class="er-constraint">${Zs(o)}</li>`)}
2084
+ </ul>`}#E(e,n){return v`<span class="er-icon" data-icon=${e} role="img" aria-label=${n.columnRole(e)}
2085
+ >${Xh[e]()}</span
2086
+ >`}#z(e,n,o,i){const s=this.#e,r=s?.kind==="edit"&&s.table===e.id&&s.field===n.id,a=this.#_&&n.status!=="removed",d=this.#o!==""&&n.id.toLowerCase().includes(this.#o),l=Sh(n),c=Eh(n,i),h=c.find(u=>u.attribute==="type"),p=c.filter(u=>u.attribute!=="type");return v`
2074
2087
  <div
2075
2088
  class=${ve("er-field",`is-${n.status}`,d&&"is-match",o.columns.has(`${e.id}.${n.id}`)&&"is-lit",r&&"is-editing")}
2076
2089
  data-field=${n.id}
2077
2090
  data-grill-questions=${this.questionsOf(n)}
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})}
2091
+ title=${[i.statusLabel(n.status),n.id,$h(n,i,!0)].join(" / ")}
2092
+ @pointerenter=${()=>this.#T({kind:"column",table:e.id,field:n.id})}
2093
+ @pointerleave=${()=>this.#T({kind:"table",id:e.id})}
2081
2094
  >
2082
2095
  <div class="er-field-line">
2083
- <span class="er-field-mark" aria-hidden="true">${br[n.status]}</span>
2084
- ${this.#$(l,i)}
2096
+ <span class="er-field-mark" aria-hidden="true">${Sr[n.status]}</span>
2097
+ ${this.#E(l,i)}
2085
2098
  <span class="er-field-name"
2086
- >${n.id}${Ah(n,l).map(u=>k`<span class="er-key">${u}</span>`)}</span
2099
+ >${n.id}${Kh(n,l).map(u=>v`<span class="er-key">${u}</span>`)}</span
2087
2100
  >
2088
2101
  <span class="er-field-type">
2089
- ${h===void 0?n.type:k`<del>${h.before}</del><ins>${h.after}</ins>`}
2102
+ ${h===void 0?n.type:v`<del>${h.before}</del><ins>${h.after}</ins>`}
2090
2103
  </span>
2091
2104
  <span class="er-field-action">
2092
- ${a?k`<button
2105
+ ${a?v`<button
2093
2106
  type="button"
2094
2107
  class="dpk-icon-btn er-field-edit"
2095
2108
  data-action="edit-field"
@@ -2098,46 +2111,46 @@ 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 a
2098
2111
  aria-haspopup="dialog"
2099
2112
  aria-expanded=${r?"true":"false"}
2100
2113
  title=${i.editFieldButton(n.id)}
2101
- @click=${()=>this.#_({kind:"edit",table:e.id,field:n.id,type:n.type,nullable:n.nullable,description:n.description??"",failed:!1})}
2114
+ @click=${()=>this.#j({kind:"edit",table:e.id,field:n.id,type:n.type,nullable:n.nullable,description:n.description??"",failed:!1})}
2102
2115
  >
2103
- ${ki()}
2116
+ ${Ei()}
2104
2117
  </button>`:T}
2105
2118
  </span>
2106
2119
  </div>
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}>
2120
+ ${n.description===null?T:v`<p class="er-field-description">${n.description}</p>`}
2121
+ ${p.length===0?T:v`<ul class="er-deltas" aria-label=${i.changesLabel}>
2122
+ ${p.map(u=>v`<li class="er-delta" data-attribute=${u.attribute}>
2110
2123
  <span class="er-delta-name">${i.attributeLabel(u.attribute)}</span>
2111
2124
  <del>${u.before}</del><span aria-hidden="true">→</span><ins>${u.after}</ins>
2112
2125
  </li>`)}
2113
2126
  </ul>`}
2114
2127
  </div>
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">
2128
+ `}get#_(){return this.id!==""}#P(e){return this.#_&&e.status!=="removed"}#F(e,n){if(!this.dispatchElementAction(cr,["node",e],{field:n})){this.#e!==null&&(this.#e={...this.#e,failed:!0}),this.requestUpdate();return}this.#D(!0)}#U(e,n){if(!this.#_||e.status==="removed")return T;const o=this.#e?.kind==="add"&&this.#e.table===e.id;return v`<div class="er-add">
2116
2129
  <button
2117
2130
  type="button"
2118
2131
  class=${ve("er-add-button",o&&"is-open")}
2119
2132
  data-action="add-field"
2120
2133
  aria-haspopup="dialog"
2121
2134
  aria-expanded=${o?"true":"false"}
2122
- @click=${()=>this.#_({kind:"add",table:e.id,name:"",type:"",nullable:!1,description:"",failed:!1})}
2135
+ @click=${()=>this.#j({kind:"add",table:e.id,name:"",type:"",nullable:!1,description:"",failed:!1})}
2123
2136
  >
2124
- <span class="er-icon" aria-hidden="true">${Gn()}</span><span>${n.addFieldButton}</span>
2137
+ <span class="er-icon" aria-hidden="true">${Xn()}</span><span>${n.addFieldButton}</span>
2125
2138
  </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?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
2139
+ </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.#Y(n,e,$e(this.locale)),s=this.#G();return v`${o}${i}${s}`}#Y(e,n,o){const i=gr(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.#P(s)?{table:e.id,field:n.field}:null,c=l===null?[]:hr(this.items(),e.id,l.field);return v`<div
2127
2140
  class="er-editor"
2128
2141
  popover="manual"
2129
2142
  role="dialog"
2130
2143
  data-kind=${n.kind}
2131
2144
  aria-label=${`${a} ${d}`}
2132
- @keydown=${h=>this.#Z(h)}
2145
+ @keydown=${h=>this.#K(h)}
2133
2146
  >
2134
2147
  <div class="er-editor-head">
2135
- ${this.#$(r,o)}
2148
+ ${this.#E(r,o)}
2136
2149
  <span class="er-editor-title">${a}</span>
2137
2150
  <code class="er-editor-target">${d}</code>
2138
2151
  </div>
2139
2152
  <div class="er-editor-fields">
2140
- ${n.kind==="add"?k`<label class="er-editor-field">
2153
+ ${n.kind==="add"?v`<label class="er-editor-field">
2141
2154
  <span class="dpk-label">${o.columnNameLabel}</span>
2142
2155
  <input
2143
2156
  class="dpk-input"
@@ -2147,7 +2160,7 @@ 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 a
2147
2160
  aria-invalid=${i.issue==="name-taken"?"true":"false"}
2148
2161
  placeholder=${o.columnNamePlaceholder}
2149
2162
  .value=${n.name}
2150
- @input=${h=>{const p=h.currentTarget;this.#e?.kind==="add"&&p instanceof HTMLInputElement&&this.#P({...this.#e,name:p.value})}}
2163
+ @input=${h=>{const p=h.currentTarget;this.#e?.kind==="add"&&p instanceof HTMLInputElement&&this.#I({...this.#e,name:p.value})}}
2151
2164
  />
2152
2165
  </label>`:T}
2153
2166
  ${this.#V(n,o)}
@@ -2161,33 +2174,33 @@ 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 a
2161
2174
  spellcheck="false"
2162
2175
  placeholder=${o.columnDescriptionPlaceholder}
2163
2176
  .value=${n.description}
2164
- @input=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#P({...this.#e,description:p.value})}}
2177
+ @input=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#I({...this.#e,description:p.value})}}
2165
2178
  />
2166
2179
  </label>
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}
2180
+ ${i.issue==="name-taken"?v`<p class="er-editor-note" role="status">${o.columnNameTaken}</p>`:T}
2181
+ ${n.failed?v`<p class="er-error" role="alert">${o.notRecorded}</p>`:T}
2169
2182
  <label class="er-editor-check">
2170
2183
  <input
2171
2184
  type="checkbox"
2172
2185
  data-input="nullable"
2173
2186
  .checked=${n.nullable}
2174
- @change=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#P({...this.#e,nullable:p.checked})}}
2187
+ @change=${h=>{const p=h.currentTarget;this.#e!==null&&p instanceof HTMLInputElement&&this.#I({...this.#e,nullable:p.checked})}}
2175
2188
  />
2176
2189
  <span>${o.columnNullable}</span>
2177
2190
  </label>
2178
2191
  <div class="er-editor-foot">
2179
2192
  <span class="er-editor-keys">${o.columnKeys}</span>
2180
- ${l===null||c.length===0?T:k`<span class="er-editor-note" role="status"
2193
+ ${l===null||c.length===0?T:v`<span class="er-editor-note" role="status"
2181
2194
  >${o.deleteFieldRelationsNote(c.length)}</span
2182
2195
  >`}
2183
2196
  <div class="er-editor-actions">
2184
- ${l===null?T:k`<button
2197
+ ${l===null?T:v`<button
2185
2198
  type="button"
2186
2199
  class="dpk-btn dpk-btn--danger"
2187
2200
  data-action="delete-column"
2188
- @click=${()=>this.#O(l.table,l.field)}
2201
+ @click=${()=>this.#F(l.table,l.field)}
2189
2202
  >
2190
- ${Bt()}<span>${o.deleteFieldTitle}</span>
2203
+ ${Ht()}<span>${o.deleteFieldTitle}</span>
2191
2204
  </button>`}
2192
2205
  <div class="er-editor-actions-right">
2193
2206
  <button
@@ -2195,7 +2208,7 @@ 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 a
2195
2208
  class="dpk-btn dpk-btn--ghost"
2196
2209
  data-action="cancel-column"
2197
2210
  data-dpk-text-discard
2198
- @click=${()=>this.#q(!0)}
2211
+ @click=${()=>this.#D(!0)}
2199
2212
  >
2200
2213
  ${o.cancel}
2201
2214
  </button>
@@ -2204,31 +2217,31 @@ 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 a
2204
2217
  class="dpk-btn dpk-btn--accent"
2205
2218
  data-action="submit-column"
2206
2219
  ?disabled=${!i.ready}
2207
- @click=${()=>this.#R()}
2220
+ @click=${()=>this.#H()}
2208
2221
  >
2209
2222
  ${n.kind==="add"?o.columnAdd:o.columnSave}
2210
2223
  </button>
2211
2224
  </div>
2212
2225
  </div>
2213
2226
  </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
2227
+ </div>`}#B(){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)}"] ${Cr(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})}#G(){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 v`<div
2215
2228
  class="er-editor er-cardinality-editor"
2216
2229
  popover="manual"
2217
2230
  role="dialog"
2218
2231
  aria-label=${`${o.editCardinalityTitle} ${n.from}.${n.sourceField} \u2192 ${n.to}.${n.targetField}`}
2219
- @keydown=${i=>this.#X(i)}
2232
+ @keydown=${i=>this.#J(i)}
2220
2233
  >
2221
2234
  <div class="er-editor-head">
2222
- <span class="er-icon" aria-hidden="true">${yi()}</span>
2235
+ <span class="er-icon" aria-hidden="true">${$i()}</span>
2223
2236
  <span class="er-editor-title">${o.editCardinalityTitle}</span>
2224
2237
  <code class="er-editor-target">${n.from} → ${n.to}</code>
2225
2238
  </div>
2226
2239
  <label class="er-editor-field">
2227
2240
  <span class="dpk-label">${o.cardinalityLabel}</span>
2228
- ${this.#p.render({options:ko.map(i=>({value:i,label:i.replace(":"," : ")})),value:e.cardinality,ariaLabel:o.cardinalityLabel,onChange:i=>this.#G(i)})}
2241
+ ${this.#p.render({options:$o.map(i=>({value:i,label:i.replace(":"," : ")})),value:e.cardinality,ariaLabel:o.cardinalityLabel,onChange:i=>this.#R(i)})}
2229
2242
  </label>
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">
2243
+ ${e.failed?v`<p class="er-error" role="alert">${o.notRecorded}</p>`:T}
2244
+ </div>`}#R(e){const n=this.#u;if(n===null)return;const o=this.dispatchElementAction(pr,["edge",n.edge],{cardinality:e});this.#u={...n,cardinality:e,failed:!o},this.requestUpdate()}#L(){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})}#J(e){e.isComposing||e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.select(null))}#N(){this.#e===null||this.#t===null||this.#n.set(At(this.#e),{draft:this.#e,base:this.#t})}#T(e){JSON.stringify(this.#i)!==JSON.stringify(e)&&(this.#i=e,this.#ee())}#ee(){const e=this.#b(this.visible),n=this.#y(this.visible),o=this.#v(this.visible,e),i=this.renderRoot;for(const s of i.querySelectorAll(".er-edge")){const r=s.getAttribute("data-relation")??"";s.classList.toggle("is-lit",e.edges.has(r)),s.classList.toggle("is-faded",e.edges.size>0&&!e.edges.has(r)),s.classList.toggle("is-concealed",n.has(r)&&!e.edges.has(r));const a=o.get(r);if(a!==void 0)for(const d of s.querySelectorAll(":scope > .d-edge-path, :scope > .er-edge-flow, :scope > .d-edge-hit"))d.getAttribute("d")!==a&&d.setAttribute("d",a)}for(const s of i.querySelectorAll(".er-table")){const r=s.getAttribute("data-er-table")??"";s.classList.toggle("is-lit",e.tables.has(r));for(const a of s.querySelectorAll(".er-field")){const d=a.getAttribute("data-field")??"";a.classList.toggle("is-lit",e.columns.has(`${r}.${d}`))}}}#j(e){if(this.#e!==null&&At(this.#e)===At(e)){this.#D(!1);return}this.#W(e)}#W(e){this.#N(),this.#e=Th(this.#n.get(At(e)),e),this.#t=e,this.#n.delete(At(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:mr(ur(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">
2232
2245
  <label class="er-editor-field">
2233
2246
  <span class="dpk-label">${n.addFieldType}</span>
2234
2247
  <input
@@ -2244,33 +2257,33 @@ 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 a
2244
2257
  placeholder=${n.columnTypePlaceholder}
2245
2258
  .value=${e.type}
2246
2259
  @click=${a}
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}))}}
2260
+ @blur=${()=>this.#X()}
2261
+ @input=${d=>{const l=d.currentTarget;this.#e===null||!(l instanceof HTMLInputElement)||(this.#a={moved:null},this.#I({...this.#e,type:l.value}))}}
2249
2262
  @keydown=${d=>this.#Q(d)}
2250
2263
  />
2251
2264
  </label>
2252
- ${s?k`<ul
2265
+ ${s?v`<ul
2253
2266
  id="er-type-options"
2254
2267
  class="er-type-options"
2255
2268
  popover="manual"
2256
2269
  role="listbox"
2257
2270
  aria-label=${n.columnTypeChoices}
2258
2271
  >
2259
- ${i.options.map((d,l)=>k`<li
2272
+ ${i.options.map((d,l)=>v`<li
2260
2273
  id=${r(l)}
2261
2274
  role="option"
2262
2275
  data-type=${d.type}
2263
2276
  data-kind=${d.kind}
2264
2277
  aria-selected=${String(l===i.active)}
2265
2278
  @pointerdown=${c=>c.preventDefault()}
2266
- @click=${()=>this.#K(d.type)}
2279
+ @click=${()=>this.#Z(d.type)}
2267
2280
  >
2268
- ${d.kind==="new"?k`<span class="er-icon" aria-hidden="true">${Gn()}</span>`:T}
2281
+ ${d.kind==="new"?v`<span class="er-icon" aria-hidden="true">${Xn()}</span>`:T}
2269
2282
  <code>${d.type}</code>
2270
- ${d.kind==="new"?k`<span class="er-type-option-hint">${n.columnTypeNew}</span>`:T}
2283
+ ${d.kind==="new"?v`<span class="er-type-option-hint">${n.columnTypeNew}</span>`:T}
2271
2284
  </li>`)}
2272
2285
  </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`
2286
+ </div>`}#Q(e){const n=this.#e,o=this.#a;if(e.isComposing||n===null)return;const i=o===null?null:mr(ur(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&&rl(s,r)});return;case"Enter":{const s=i?.options[i.active];if(s===void 0||s.type===n.type.trim()){this.#X();return}e.preventDefault(),e.stopPropagation(),this.#Z(s.type);return}case"Escape":if(o===null)return;e.preventDefault(),e.stopPropagation(),this.#X();return}}#Z(e){this.#e!==null&&(this.#a=null,this.#I({...this.#e,type:e}))}#X(){this.#a!==null&&(this.#a=null,this.requestUpdate())}#I(e){this.#e={...e,failed:!1},this.requestUpdate()}#D(e,n=!0){const o=this.#e;o!==null&&(e||this.#N(),this.#e=null,this.#a=null,this.requestUpdate(),n&&this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-er-table="${CSS.escape(o.table)}"] ${Cr(o)}`)?.focus({preventScroll:!0})))}#K(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.#H()}#H(){const e=this.#e,n=e===null?void 0:this.visible.nodes.find(r=>r.id===e.table);if(e===null||n===void 0||!gr(e,n).ready)return;const o=e.type.trim(),i=e.description.trim();if(!(e.kind==="add"?this.dispatchElementAction(dr,["node",e.table],{id:e.name.trim(),type:o,nullable:e.nullable,description:i}):this.dispatchElementAction(lr,["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 Cr=t=>t.kind==="add"?'[data-action="add-field"]':`[data-action="edit-field"][data-field="${CSS.escape(t.field)}"]`,At=t=>t.kind==="add"?`add:${t.table}`:`edit:${t.table}:${t.field}`,Lr=()=>{customElements.get("dpk-board-er-diagram")||customElements.define("dpk-board-er-diagram",Mr)},Ro=["actor","command","aggregate","event","policy","readmodel","external","hotspot"],Vh=P({id:oe,name:S(k(),I(1)),description:j(k()),questions:nt}),Qh=P({id:oe,type:G(Ro),name:S(k(),I(1)),description:j(k()),contextId:j(k()),questions:nt}),Zh=P({id:oe,from:S(k(),I(1)),to:S(k(),I(1)),label:j(k()),kind:j(G(["member","flow"]))}),Jh=P({title:j(k()),contexts:L(F(Vh),[]),elements:L(F(Qh),[]),links:L(F(Zh),[])}),eu=t=>{const e=ue(Jh,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},tu=()=>({contexts:[],elements:[],links:[]}),pt=(t,e)=>{if(e!==void 0)return t.elements.find(n=>n.id===e)},Do=(t,e)=>{if(e!==void 0)return t.contexts.find(n=>n.id===e)},nu=(t,e)=>{if(e!==void 0)return t.links.find(n=>n.id===e)},un=t=>t.elements.map(e=>e.id),ie={SET_ELEMENT_NAME:z("SET_ELEMENT_NAME","element",R({name:S(k(),I(1))})),SET_ELEMENT_DESCRIPTION:z("SET_ELEMENT_DESCRIPTION","element",R({description:k()})),SET_ELEMENT_TYPE:z("SET_ELEMENT_TYPE","element",R({type:G(Ro)})),SET_ELEMENT_CONTEXT:z("SET_ELEMENT_CONTEXT","element",R({contextId:me(k())})),MOVE_ELEMENT:z("MOVE_ELEMENT","element",R({after:me(k())}),{mode:"sequence"}),ADD_ELEMENT:z("ADD_ELEMENT","page",R({id:oe,type:G(Ro),name:S(k(),I(1)),description:j(k()),contextId:j(k())}),{dedupeKey:Me}),DELETE_ELEMENT:z("DELETE_ELEMENT","element",R({})),LINK_ELEMENTS:z("LINK_ELEMENTS","page",R({id:oe,from:S(k(),I(1)),to:S(k(),I(1)),label:j(k()),kind:j(G(["member","flow"]))}),{dedupeKey:Me}),SET_LINK_LABEL:z("SET_LINK_LABEL","link",R({label:k()})),UNLINK_ELEMENTS:z("UNLINK_ELEMENTS","page",R({from:S(k(),I(1)),to:S(k(),I(1))}),{mode:"sequence"}),ADD_CONTEXT:z("ADD_CONTEXT","page",R({id:oe,name:S(k(),I(1)),description:j(k())}),{dedupeKey:Me}),SET_CONTEXT_NAME:z("SET_CONTEXT_NAME","context",R({name:S(k(),I(1))})),DELETE_CONTEXT:z("DELETE_CONTEXT","context",R({}))},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:{}})},Ir={actor:"Actor",command:"Command",aggregate:"Aggregate",event:"Domain Event",policy:"Policy",readmodel:"Read Model",external:"External System",hotspot:"Hotspot"},Ar={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=>Ir[t],addTypeLabel:t=>`+ ${Ir[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=>Ar[t],addTypeLabel:t=>`+ ${Ar[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"}}),ou={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"}},Oo=t=>{const{bg:e,ink:n}=ou[t];return`--es-note-bg:${e};--es-note-ink:${n}`},iu=de`
2274
2287
  /*
2275
2288
  * The host is the note's box and its ink. It is never rotated, scaled or
2276
2289
  * filtered: any transform here promotes the note to a composited layer that
@@ -2534,10 +2547,10 @@ 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 a
2534
2547
  backdrop-filter: blur(4px);
2535
2548
  box-shadow: var(--dpk-bevel), var(--dpk-shadow-xs);
2536
2549
  }
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`
2550
+ `;class su extends bi{static{this.styles=[gi,iu,fi]}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 xi(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 v`
2538
2551
  <div class="paper" aria-hidden="true"></div>
2539
2552
  <div class="note-type">${n.noteTypeLabel(e.type)}</div>
2540
- <div class="note-editing" aria-hidden="true">${ki()}</div>
2553
+ <div class="note-editing" aria-hidden="true">${Ei()}</div>
2541
2554
  <dpk-inline-edit
2542
2555
  class="note-name"
2543
2556
  ?wrap=${!0}
@@ -2545,9 +2558,9 @@ 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 a
2545
2558
  ?seamless=${!0}
2546
2559
  .value=${e.name}
2547
2560
  .label=${n.noteNameLabel}
2548
- @dpk-commit=${nt(o=>this.#a({kind:"rename",name:o}))}
2561
+ @dpk-commit=${ot(o=>this.#a({kind:"rename",name:o}))}
2549
2562
  ></dpk-inline-edit>
2550
- ${e.type==="hotspot"?T:k`<button
2563
+ ${e.type==="hotspot"?T:v`<button
2551
2564
  class="note-hotspot"
2552
2565
  type="button"
2553
2566
  data-role="hotspot"
@@ -2564,7 +2577,7 @@ 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 a
2564
2577
  aria-label=${n.commentNote}
2565
2578
  @click=${this.#n(()=>({kind:"comment"}))}
2566
2579
  >
2567
- ${Xn()}
2580
+ ${Kn()}
2568
2581
  </button>
2569
2582
  <button
2570
2583
  class="dpk-icon-btn"
@@ -2573,10 +2586,10 @@ 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 a
2573
2586
  aria-label=${n.deleteNote}
2574
2587
  @click=${this.#n(()=>({kind:"delete"}))}
2575
2588
  >
2576
- ${Bt()}
2589
+ ${Ht()}
2577
2590
  </button>
2578
2591
  </div>
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}>
2592
+ `}#n(e){return n=>{n.stopPropagation(),this.#a(e(n))}}#a(e){this.onIntent?.(e)}}const ru=()=>{customElements.get("dpk-internal-event-storming-note")||customElements.define("dpk-internal-event-storming-note",su)},_r=.25,au=2,du=(t,e,n)=>({...t,panX:t.panX+e,panY:t.panY+n}),Rr=(t,e,n,o)=>{const i=kt(t.zoom*o,_r,au),s=(e-t.panX)/t.zoom,r=(n-t.panY)/t.zoom;return{panX:e-s*i,panY:n-r*i,zoom:i}},lu=(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}},cu=(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)}},pu=(t,e,n)=>e>=t.left&&e<=t.left+t.width&&n>=t.top&&n<=t.top+t.height,Dr=(t,e,n)=>{for(let o=t.length-1;o>=0;o-=1){const i=t[o];if(i!==void 0&&pu(i.rect,e,n))return i.id}},hu=(t,e)=>e<t.left+t.width/2?"before":"after",uu=(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),Or=(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},mu=(t,e,n,o)=>{const i=Or(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 al(s,t)?[]:i},Nr=(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=Dr(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:hu(a,i.x)}}:{}}}case"select":return{...s,kind:"select"}}},gu=new Set(["actor>command","command>aggregate","aggregate>event","command>event","policy>command","external>event"]),No=(t,e)=>gu.has(`${t}>${e}`),fu=(t,e,n)=>t.kind!==void 0?t.kind==="member":No(e,n),bu=["readmodel","actor","policy","command","aggregate","external","event","hotspot"],xu=(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},yu=(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||fu(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=xu(t,e),o=t.elements.filter(l=>!n.has(l.id)),{groups:i,rootOf:s}=yu(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(bu.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}})},ku=(t,e)=>{const n=[...t.notes,...t.pins.map(r=>r.note)],o=n.find(r=>No(e,r.type));if(o!==void 0)return{anchorId:o.id,incoming:!0};const i=n.find(r=>No(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}},vu=(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}:{}}]})},zo=(t,e)=>`${t}\0${e}`,wu=(t,e,n)=>{const{widthOf:o,gapX:i,padX:s,maxWidth:r}=n,a=new Map;for(const m of e)a.set(zo(m.from,m.to),m),a.set(zo(m.to,m.from),m);const d=(m,f)=>m===void 0||f===void 0?void 0:a.get(zo(m,f)),l=m=>Dl(m,f=>o(f))+i*Math.max(0,m.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 m of t.map(f=>f.id)){if(h.length>0&&!l([...h,m])){let f=h.length;for(;d(h[f-1],f===h.length?m:h[f])!==void 0&&(f-=1,f!==0););const g=f===0?[]:h.splice(f),b=f===0?d(h.at(-1),m):d(h.at(-1),g[0]);u(),h=g,p=b}h.push(m)}return u(),c},mn=t=>[...t.notes].reverse().find(e=>e.type==="event")??t.notes.at(-1),$u=(t,e)=>{const n=mn(t),o=e.notes[0];if(!(n===void 0||o===void 0))return{from:n.id,to:o.id}},Po="data-pin";class Eu{#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(`[${Po}]`));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(Po)));[...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(Po),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 Tu=(t,e)=>{const n=Yt(ie,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_ELEMENT_NAME":return gn(t,o,i=>({...i,name:n.payload.name}));case"SET_ELEMENT_DESCRIPTION":return gn(t,o,i=>({...i,description:n.payload.description}));case"SET_ELEMENT_TYPE":return gn(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:gn(t,o,s=>i===null?zr(s):{...s,contextId:i})}case"MOVE_ELEMENT":{const{after:i}=n.payload,s=Su(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?zr(i):i)}:null;default:return jn(n)}},zr=t=>{const e={...t};return delete e.contextId,e},gn=(t,e,n)=>t.elements.some(o=>o.id===e)?{...t,elements:t.elements.map(o=>o.id===e?n(o):o)}:null,Su=(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},Mu={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 "${Do(n,e.target.id)?.name??e.target.id}"`})},Pr=(t,e,n,o)=>{const i=Mu[e.type],r=i?i(t,e,o??n):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:Cu(t,n,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},Cu=(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=Do(e,n.id);return o?t.contextLabel(o.name):`${t.contextLabel(n.id)} (missing)`}case"link":{const o=nu(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}`}},Lu=t=>t==="comment"?"meta":t,Iu=t=>{const e=Oe(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}},Au=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=Pr(t,s,o).title;if(!(s.type in ie)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=Iu(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Tu(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=Pr(t,d,l,o);i.push({id:s.id,title:c.title,tone:Lu(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Ae={kind:"idle"},_u=(t,e)=>t.kind==="editing"&&t.noteId===e?"editing":"view",Ru=(t,e,n)=>{switch(n.kind){case"delete":return Ae;case"select":case"add-hotspot":return t;case"rename":return t.kind==="editing"&&t.noteId===e?Ae:t}},Du=6,Ou=10,qr="\u2026",Nu=[[4352,4447],[11904,42191],[44032,55203],[63744,64255],[65072,65103],[65280,65376],[65504,65510],[127744,129791],[131072,262141]],qo=t=>{const e=t.codePointAt(0)??0;return Nu.some(([n,o])=>e>=n&&e<=o)?Ou:Du},zu=(t,e)=>{const n=Array.from(t);if(n.reduce((s,r)=>s+qo(r),0)<=e)return t;let o=qo(qr),i="";for(const s of n){if(o+=qo(s),o>e)break;i+=s}return`${i}${qr}`},Fr=92,Fo=54,Pu=18,Ur=4,Br=t=>{const e=[];let n=Pu;for(const o of t)e.push(n),n+=o+Ur;return{lifts:e,extent:t.length===0?0:n-Ur}},Hr=240,_t=132,Yr=96,Uo=10,fn=24,bn=12,_e=Yr+bn*2,xn=46,yn=16,Gr=44,Xr=40,Bo=16,Kr=13,ut=8,qu=6,Fu=26,Uu=(t,e)=>Math.max(Gr,t-bn+(e?Fu:0)),Bu=Br([Fo]).extent,Hu=["actor","command","aggregate","event","policy","readmodel","external"],jr=t=>fn*2+t*_t+(t-1)*Uo,Yu=(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=Br(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(g=>[g.id,jr(g.notes.length)])),s=vu(t,e),r=wu(e,s,{widthOf:g=>i.get(g)??0,gapX:xn,padX:yn,maxWidth:Math.max(n,jr(1))}),a=new Map,d=new Map,l=new Map,c=new Map,h=new Map,p=new Map(e.map(g=>[g.id,g.contextId]));for(const g of e){const b=Yu(g,y=>o.get(y)??Fo);for(const[y,x]of b.liftOf)c.set(y,x);h.set(g.id,b.extent)}let u=ut;const m=r.map((g,b)=>{const y=g.cutFrom===void 0?void 0:d.get(g.cutFrom.from),x=y===void 0?0:Math.max(0,y-yn);let w=x+yn;const $=Uu(Math.max(Bu,...g.sliceIds.map(M=>h.get(M)??0)),g.sliceIds.some(M=>p.get(M)!==void 0));for(const M of g.sliceIds)a.set(M,w-x),d.set(M,w),l.set(M,b),w+=(i.get(M)??0)+xn;const A=$+_e+Xr,C={sliceIds:g.sliceIds,x,width:w-xn+yn-x,height:A,y:u,head:$,cutFrom:g.cutFrom};return u+=A+qu,C}),f=m.at(-1);return{slices:e,bands:m,xOf:a,absXOf:d,bandOf:l,widthOf:i,pinLiftOf:c,arrows:s,width:Math.max(0,...m.map(g=>g.x+g.width))+ut*2,height:f===void 0?ut*2:f.y+f.height+ut}},Xu=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}>
2580
2593
  <div class="empty">
2581
2594
  <h2>${e.emptyTitle}</h2>
2582
2595
  <p>${e.emptyBody}</p>
@@ -2584,7 +2597,7 @@ 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 a
2584
2597
  ${e.addFirstEvent}
2585
2598
  </button>
2586
2599
  </div>
2587
- </div>`;const l=ht(n),c=Lu(n,l,o,i);return k`
2600
+ </div>`;const l=ht(n),c=Gu(n,l,o,i);return v`
2588
2601
  <div
2589
2602
  class="board-viewport${t.gesture!==void 0?" board-viewport--gesturing":""}"
2590
2603
  data-testid="es-viewport"
@@ -2603,78 +2616,78 @@ 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 a
2603
2616
  style=${`transform:translate(${s.panX}px, ${s.panY}px) scale(${s.zoom})`}
2604
2617
  >
2605
2618
  <div class="wall" data-testid="es-wall" style=${`width:${c.width}px;height:${c.height}px`}>
2606
- ${qu(t,c)}
2607
- ${c.bands.map((h,p)=>Ru(t,c,h,p))}
2619
+ ${tm(t,c)}
2620
+ ${c.bands.map((h,p)=>ju(t,c,h,p))}
2608
2621
  </div>
2609
2622
  </div>
2610
- ${Du(t.gesture)} ${Ou(e,n,l)} ${Nu(t)}
2611
- ${zu(t)}
2623
+ ${Vu(t.gesture)} ${Qu(e,n,l)} ${Zu(t)}
2624
+ ${Ju(t)}
2612
2625
  </div>
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
- style=${g}
2626
+ `},Ku=(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(" ")},ju=(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(m=>m.id===u)),h=u=>({x:e.xOf.get(u.id)??0,y:n.head,w:e.widthOf.get(u.id)??0}),p=(u,m,f=!1)=>v`<dpk-internal-event-storming-note
2627
+ style=${m}
2615
2628
  .note=${u}
2616
- .mode=${fu(s,u.id)}
2629
+ .mode=${_u(s,u.id)}
2617
2630
  ?focused=${d===u.id}
2618
- ?compact=${b}
2619
- data-pin=${b?u.id:T}
2631
+ ?compact=${f}
2632
+ data-pin=${f?u.id:T}
2620
2633
  data-dpk-target=${t.commentRef("note",u.id)}
2621
- data-grill-questions=${Wt(Yt(u.questions))}
2622
- .onIntent=${f=>l.noteIntent(u.id,f)}
2623
- ></dpk-internal-event-storming-note>`;return k`
2634
+ data-grill-questions=${Vt(Gt(u.questions))}
2635
+ .onIntent=${g=>l.noteIntent(u.id,g)}
2636
+ ></dpk-internal-event-storming-note>`;return v`
2624
2637
  <section class="band" data-band=${o} style=${`left:${ut+n.x}px;top:${n.y}px`}>
2625
2638
  <div class="band-canvas" style=${`width:${n.width}px;height:${n.height}px`}>
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)}
2639
+ ${Wu(t,e,o)}
2640
+ ${c.map(u=>{const{x:m,y:f,w:g}=h(u);return v`<div
2641
+ class=${Ku(t,u)}
2629
2642
  data-slice-id=${u.id}
2630
- style=${`left:${g}px;top:${b}px;width:${f}px;height:${_e}px`}
2631
- @pointerdown=${m=>l.slicePointerDown(u.id,m)}
2643
+ style=${`left:${m}px;top:${f}px;width:${g}px;height:${_e}px`}
2644
+ @pointerdown=${b=>l.slicePointerDown(u.id,b)}
2632
2645
  ></div>`})}
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
- class="slice-port${m?" slice-port--on":""}"
2646
+ ${Se(c.flatMap(u=>u.notes.map((m,f)=>({slice:u,note:m,slot:f}))),({note:u})=>u.id,({slice:u,note:m,slot:f})=>{const{x:g,y:b}=h(u),y=g+fn+f*(_t+Uo),x=b+bn;return p(m,`${Oo(m.type)};position:absolute;left:${y}px;top:${x}px;width:${_t}px;height:${Yr}px;--es-tilt:${im(m.id)}deg;z-index:2`)})}
2647
+ ${Se(c.flatMap(u=>{const m=h(u);return u.notes.flatMap((f,g)=>u.pins.filter(y=>y.targetId===f.id).map((y,x)=>({pin:y,slot:g,index:x,at:m})))}),({pin:u})=>u.note.id,({pin:u,slot:m,index:f,at:g})=>{const b=g.x+fn+m*(_t+Uo),y=g.y+bn,x=e.pinLiftOf.get(u.note.id)??0;return p(u.note,`${Oo(u.note.type)};position:absolute;left:${b+_t-Fr-6-f*10}px;bottom:${n.height-(y-x)}px;width:${Fr}px;min-height:${Fo}px;--es-tilt:-2.4deg;z-index:3`,!0)})}
2648
+ ${c.map(u=>{const{x:m,y:f,w:g}=h(u),b=a===u.id||r?.kind==="connect"&&r.fromSliceId===u.id;return v`<button
2649
+ class="slice-port${b?" slice-port--on":""}"
2637
2650
  type="button"
2638
- style=${`left:${g+f-Pr}px;top:${b+_e/2-Pr}px`}
2651
+ style=${`left:${m+g-Kr}px;top:${f+_e/2-Kr}px`}
2639
2652
  aria-label=${i.portAriaLabel}
2640
2653
  title=${i.portTitle}
2641
2654
  @pointerdown=${y=>l.portPointerDown(u.id,y)}
2642
2655
  >
2643
2656
  →
2644
2657
  </button>`})}
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
2658
+ ${c.map(u=>{if(a!==u.id||r!==void 0)return T;const{x:m,y:f}=h(u),g=new Set(u.notes.map(y=>y.type)),b=Hu.filter(y=>!g.has(y));return v`<div
2646
2659
  class="slice-chips"
2647
- style=${`left:${g}px;top:${b+_e+6}px`}
2660
+ style=${`left:${m}px;top:${f+_e+6}px`}
2648
2661
  @pointerdown=${y=>y.stopPropagation()}
2649
2662
  >
2650
- ${m.map(y=>k`<button class="slice-chip" type="button" @click=${()=>l.attachNote(u.id,y)}>
2663
+ ${b.map(y=>v`<button class="slice-chip" type="button" @click=${()=>l.attachNote(u.id,y)}>
2651
2664
  ${i.addTypeLabel(y)}
2652
2665
  </button>`)}
2653
2666
  </div>`})}
2654
2667
  </div>
2655
2668
  </section>
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
2669
+ `},Wu=(t,e,n)=>{const{m:o,state:i,handlers:s}=t,r=i.contexts.flatMap((a,d)=>{const c=e.slices.filter(x=>x.contextId===a.id).flatMap(x=>{const w=e.xOf.get(x.id),$=e.bandOf.get(x.id);return w===void 0||$===void 0?[]:[{x:w,band:$,width:e.widthOf.get(x.id)??0}]}),h=c.filter(x=>x.band===n);if(h.length===0)return[];const p=Math.min(...h.map(x=>x.x))-10,u=Math.max(...h.map(x=>x.x+x.width))+10,m=14,f=(e.bands[n]?.head??Gr)+_e+12,g=c.some(x=>x.band<n)?"\u2026 ":"",b=c.some(x=>x.band>n)?" \u2026":"",y=String(d%5);return[v`<div
2657
2670
  class="context-region"
2658
2671
  data-hue=${y}
2659
2672
  data-dpk-target=${t.commentRef("context",a.id)}
2660
- data-grill-questions=${Wt(Yt(a.questions))}
2661
- style=${`left:${p}px;top:${g}px;width:${u-p}px;height:${b-g}px`}
2673
+ data-grill-questions=${Vt(Gt(a.questions))}
2674
+ style=${`left:${p}px;top:${m}px;width:${u-p}px;height:${f-m}px`}
2662
2675
  title=${a.description??a.name}
2663
2676
  ></div>
2664
2677
  <div
2665
2678
  class="context-label"
2666
2679
  data-hue=${y}
2667
- style=${`left:${p+10}px;top:${g}px;max-width:${u-p-20}px`}
2668
- @pointerdown=${v=>v.stopPropagation()}
2680
+ style=${`left:${p+10}px;top:${m}px;max-width:${u-p-20}px`}
2681
+ @pointerdown=${x=>x.stopPropagation()}
2669
2682
  >
2670
2683
  <button
2671
2684
  class="context-label-name"
2672
2685
  type="button"
2673
2686
  title=${`${a.name}
2674
2687
  ${o.renameContextHint}`}
2675
- @click=${v=>s.renameContext(a.id,{x:v.clientX,y:v.clientY})}
2688
+ @click=${x=>s.renameContext(a.id,{x:x.clientX,y:x.clientY})}
2676
2689
  >
2677
- ${f}${a.name}${m}
2690
+ ${g}${a.name}${b}
2678
2691
  </button>
2679
2692
  <button
2680
2693
  class="context-label-x"
@@ -2685,25 +2698,25 @@ ${o.renameContextHint}`}
2685
2698
  >
2686
2699
  ✕
2687
2700
  </button>
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">
2701
+ </div>`]});return r.length>0?v`${r}`:T},Vu=t=>{if(t===void 0||!t.moved)return T;if(t.kind==="connect")return v`<svg class="gesture-layer" aria-hidden="true">
2689
2702
  ${Y`<path class="connect-line" d=${`M ${t.start.x} ${t.start.y} L ${t.current.x} ${t.current.y}`}></path>
2690
2703
  <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 k`<div
2704
+ </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
2692
2705
  class="select-rect"
2693
2706
  style=${`left:${e}px;top:${n}px;width:${o}px;height:${i}px`}
2694
- ></div>`}return T},Ou=(t,e,n)=>k`<div class="board-hud">
2707
+ ></div>`}return T},Qu=(t,e,n)=>v`<div class="board-hud">
2695
2708
  <span class="board-hud-stat">${t.noteCount(e.elements.length)}</span>
2696
2709
  <span class="board-hud-stat">${t.sliceCount(n.length)}</span>
2697
2710
  <span class="board-hud-stat">${t.contextCount(e.contexts.length)}</span>
2698
2711
  <span class="board-hint">${t.hudHint}</span>
2699
- </div>`,Nu=t=>{const{m:e,viewport:n,handlers:o}=t;return k`<div class="board-zoom" @pointerdown=${i=>i.stopPropagation()}>
2712
+ </div>`,Zu=t=>{const{m:e,viewport:n,handlers:o}=t;return v`<div class="board-zoom" @pointerdown=${i=>i.stopPropagation()}>
2700
2713
  <button type="button" aria-label=${e.zoomOut} @click=${()=>o.zoomStep(-1)}>−</button>
2701
2714
  <button type="button" class="board-zoom-pct" title=${e.zoomReset} @click=${()=>o.zoomReset()}>
2702
2715
  ${Math.round(n.zoom*100)}%
2703
2716
  </button>
2704
2717
  <button type="button" aria-label=${e.zoomIn} @click=${()=>o.zoomStep(1)}>+</button>
2705
2718
  <button type="button" aria-label=${e.zoomFit} title=${e.zoomFit} @click=${()=>o.zoomFit()}>⛶</button>
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
2719
+ </div>`},Ju=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?v`<dpk-selection-bar
2707
2720
  label=${e.selectedLinks(i.length)}
2708
2721
  @pointerdown=${d=>d.stopPropagation()}
2709
2722
  @dpk-selection-clear=${()=>r.clearSelection()}
@@ -2721,7 +2734,7 @@ ${o.renameContextHint}`}
2721
2734
  >
2722
2735
  ✕
2723
2736
  </button>
2724
- </dpk-selection-bar>`:k`<dpk-selection-bar
2737
+ </dpk-selection-bar>`:v`<dpk-selection-bar
2725
2738
  label=${e.selectedSlices(o.length)}
2726
2739
  @pointerdown=${d=>d.stopPropagation()}
2727
2740
  @dpk-selection-clear=${()=>r.clearSelection()}
@@ -2742,16 +2755,16 @@ ${o.renameContextHint}`}
2742
2755
  <button class="dpk-icon-btn" type="button" aria-label=${e.clearSelection} @click=${()=>r.clearSelection()}>
2743
2756
  ✕
2744
2757
  </button>
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">
2758
+ </dpk-selection-bar>`},Wr=(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}}),em=()=>Y`<marker id="es-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
2746
2759
  <path d="M0,0 L8,4 L0,8 z"></path>
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
- <path class="link-hit" d=${d} @pointerdown=${g=>g.stopPropagation()} @click=${g=>t.handlers.linkClick(a.id,g.shiftKey||g.metaKey||g.ctrlKey)}></path>
2760
+ </marker>`,tm=(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">
2761
+ <path class="link-hit" d=${d} @pointerdown=${m=>m.stopPropagation()} @click=${m=>t.handlers.linkClick(a.id,m.shiftKey||m.metaKey||m.ctrlKey)}></path>
2749
2762
  <path class=${`link-path${p}`} d=${d} marker-end=${n}></path>
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>
2763
+ ${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>${zu(a.label,Math.min(h,Hr))}</text>`}
2764
+ </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 g=l.x>=d.x+d.w,b=g?l.x-(d.x+d.w):d.x-(l.x+l.w);if(b<=xn+2){const x=d.y+_e/2,w=g?d.x+d.w:d.x,$=g?l.x:l.x+l.w;r(a,`M ${w} ${x} L ${$} ${x}`,{x:(w+$)/2,y:x},"middle",Math.abs($-w)-4);continue}const y=nm(d,l,s(d.band)-Xr/2);r(a,y.d,y.mid,"middle",b+2*fn);continue}const c=d.y<l.y,h=d.x+Bo,p=kt(h,l.x+Bo,l.x+l.w-Bo),u={x:h,y:c?d.y+_e:d.y},m={x:p,y:c?l.y:l.y+_e},f=c?(s(d.band)+(e.bands[l.band]?.y??0))/2:(s(l.band)+(e.bands[d.band]?.y??0))/2;r(a,om([u,{x:u.x,y:f},{x:m.x,y:f},m]),{x:m.x-6,y:f},"end",Hr)}return Y`<svg class="links-layer" width=${e.width} height=${e.height}>
2765
+ <defs>${em()}</defs>
2753
2766
  ${o}
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`
2767
+ </svg>`},nm=(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 Wr(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 Wr(i,{x:i.x-48,y:n},{x:s.x+48,y:n},s)},om=(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),m=Math.max(0,Math.min(e,p/2,u/2));n+=` L ${r.x-d*m} ${r.y-l*m} Q ${r.x} ${r.y} ${r.x+c*m} ${r.y+h*m}`}const o=t.at(-1);return o===void 0?n:`${n} L ${o.x} ${o.y}`},im=t=>{let e=0;for(const n of t)e=(e*31+n.charCodeAt(0))%997;return(e%17-8)*.09},sm=de`
2755
2768
  /*
2756
2769
  * The shell (\`<dpk-dialog-panel class="event-storming">\`) is a panel: header, tag
2757
2770
  * row, viewport; \`--dpk-dialog-panel-height\` is the knob it reads for its own
@@ -3349,7 +3362,7 @@ ${o.renameContextHint}`}
3349
3362
  flex: 1 1 auto;
3350
3363
  min-width: 0;
3351
3364
  }
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`
3365
+ `,rm={width:260,height:150},am={width:236,height:210},dm=64,lm=["event","command","aggregate","actor","policy","readmodel","external"],cm=1200,Vr=5,pm={x:20,top:46,bottom:40},hm=264,um="event-storming";class Qr extends rt{constructor(){super(...arguments),this.mode=Ae,this.boardWidth=cm,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 ki(this),this.#e=new Eu(this),this.#t=new vi(this)}boardAddable(){return!0}static{this.styles=[st,sm]}#o;#i;#e;#t;parseData(e){return eu(e)}emptyData(){return tu()}reduceElementActions(e,n){return Au(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",um),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.#w(this.viewport),this.mode.kind==="append"&&this.#n("#append-menu",this.mode.point,am),this.naming!==void 0&&this.#n("#context-pop",this.naming.point,rm,"#context-name")}#n(e,n,o,i){const s=this.renderRoot.querySelector(e);if(!s||s.matches(":popover-open")||(this.#i.open(s,dl(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(hm,this.boardWidth-96)}render(){this.prepareRender();const e=be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return v`
3353
3366
  <dpk-dialog-panel
3354
3367
  class=${this.shellClass()}
3355
3368
  flush
@@ -3360,12 +3373,12 @@ ${o.renameContextHint}`}
3360
3373
  @dpk-maximize-change=${()=>this.closeComposer()}
3361
3374
  >
3362
3375
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
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} `}
3376
+ ${this.dataError!==null?v`<p class="es-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:v`${Xu({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.#M(i,s),addFirst:()=>this.#G(),attachNote:(i,s)=>this.#O(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.#F(i),stripSelectionContext:()=>this.#F(null),clearSelection:()=>{this.selectedSliceIds=[],this.selectedLinkIds=[],this.requestUpdate()},linkClick:(i,s)=>this.#z(i,s),deleteSelection:()=>this.#_(),keyDown:i=>this.#P(i),renameContext:(i,s)=>{this.naming={kind:"rename-context",contextId:i,point:s},this.requestUpdate()},dissolveContext:i=>this.#R(J.deleteContext(i))}})}
3377
+ ${this.mode.kind==="append"?this.#B(this.mode.sliceId):T}
3378
+ ${this.naming!==void 0?this.#Y(this.naming):T} `}
3366
3379
  </dpk-dialog-panel>
3367
3380
  ${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())}#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">
3381
+ `}#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=Ae),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=Dr(this.#d(pm),o.x,o.y);i!==this.hoverSliceId&&(this.hoverSliceId=i,this.requestUpdate());return}this.gesture=Nr(n,{pointerId:e.pointerId,point:o},this.#d(),Vr),this.requestUpdate()}#m(e){const n=this.gesture;if(n===void 0||e.pointerId!==n.pointerId)return;const o=Nr(n,{pointerId:e.pointerId,point:this.#s(e)},this.#d(),Vr);if(this.gesture=void 0,o.kind==="connect"){o.moved?o.targetSliceId!==void 0&&this.#v(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.#E(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=[...uu(this.#d(),i)],this.requestUpdate()}#g(e){e.preventDefault();const n=this.#s(e);this.#w(e.ctrlKey||e.metaKey?Rr(this.viewport,n.x,n.y,Math.exp(-e.deltaY*.01)):du(this.viewport,-e.deltaX,-e.deltaY))}#f(e){const n=this.#r()?.getBoundingClientRect();this.#w(Rr(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.#S();e===void 0||n===void 0||this.#w(lu(n,{width:e.width,height:e.height},48))}#S(){const e=this.renderRoot.querySelector(".wall");return e===null?void 0:{width:e.offsetWidth,height:e.offsetHeight}}#w(e){const n=this.#r()?.getBoundingClientRect(),o=this.#S(),i=n===void 0||o===void 0||o.width===0||n.width===0?e:cu(e,o,{width:n.width,height:n.height},dm),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.#R(J.setElementName(e,n.name));break;case"delete":this.#R(J.deleteElement(e)),this.selection?.kind==="note"&&this.selection.id===e&&this.select(null);break;case"add-hotspot":this.#q(e);break}this.mode=Ru(this.mode,e,n),this.requestUpdate()}#b(e){return ht(this.items()).find(n=>n.id===e)}#y(e){return e===void 0?[]:[...e.notes,...e.pins.map(n=>n.note)].map(n=>n.id)}#v(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?$u(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=mn(s)?.id,h=c!==void 0&&i.indexOf(r)>i.indexOf(s)?mu(l,this.#y(r),[c],"after"):[];this.#L([J.linkElements(vn(`link-${a.from}`,d),a.from,a.to,{kind:"flow"}),...h.map(p=>J.moveElement(p.id,p.after))])}#k(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.#k(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?mn(i):void 0;if(s===void 0){this.mode=Ae,this.requestUpdate();return}const r=kn(`new-${n}`,un(o)),a=o.links.map(l=>l.id);if(!this.#L([J.addElement(r,n,be(this.locale).noteTypeLabel(n)),J.linkElements(vn(`link-${s.id}`,a),s.id,r,{kind:"flow"})])){this.mode=Ae,this.requestUpdate();return}this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate()}#q(e){const n=this.items(),o=kn("new-hotspot",un(n)),i=n.links.map(r=>r.id);this.#L([J.addElement(o,"hotspot",be(this.locale).noteTypeLabel("hotspot")),J.linkElements(vn(`link-${o}`,i),o,e,{kind:"member"})])&&(this.select({kind:"note",id:o}),this.mode={kind:"editing",noteId:o},this.requestUpdate())}#O(e,n){const o=this.#b(e),i=o===void 0?void 0:ku(o,n);if(i===void 0)return;const s=this.items(),r=kn(`new-${n}`,un(s)),[a,d]=i.incoming?[r,i.anchorId]:[i.anchorId,r],l=s.links.map(h=>h.id);this.#L([J.addElement(r,n,be(this.locale).noteTypeLabel(n)),J.linkElements(vn(`link-${a}`,l),a,d,{kind:"member"})])&&(this.select({kind:"note",id:r}),this.mode={kind:"editing",noteId:r},this.requestUpdate())}#E(e,n,o){const i=this.items(),s=Or(i.elements.map(r=>r.id),this.#y(this.#b(e)),this.#y(this.#b(n)),o);this.#L(s.map(r=>J.moveElement(r.id,r.after)))}#z(e,n){this.mode.kind==="editing"&&(this.mode=Ae),this.selectedSliceIds=[],this.selectedLinkIds=n?this.selectedLinkIds.includes(e)?this.selectedLinkIds.filter(o=>o!==e):[...this.selectedLinkIds,e]:[e],this.requestUpdate(),this.#r()?.focus()}#_(){const e=this.items();if(this.selectedLinkIds.length>0){const i=e.links.filter(s=>this.selectedLinkIds.includes(s.id));this.#L(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.#y(n.find(s=>s.id===i)));this.#L(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.#_();return}const n=this.selection?.kind==="note"?this.selection.id:void 0;n===void 0||pt(this.items(),n)===void 0||(this.#R(J.deleteElement(n)),this.select(null))}#F(e){const n=this.items(),o=ht(n),i=this.selectedSliceIds.flatMap(r=>this.#y(o.find(a=>a.id===r)));this.#L(i.map(r=>J.setElementContext(r,e)))&&(this.selectedSliceIds=[],this.requestUpdate())}#U(e){const o=this.renderRoot.querySelector("#context-name")?.value.trim()??"";if(o==="")return;if(e.kind==="rename-context"){this.#R(J.setContextName(e.contextId,o))&&(this.naming=void 0,this.requestUpdate());return}const i=this.items(),s=mm("context",i.contexts.map(l=>l.id)),r=ht(i),a=e.sliceIds.flatMap(l=>this.#y(r.find(c=>c.id===l)));this.#L([J.addContext(s,o),...a.map(l=>J.setElementContext(l,s))])&&(this.selectedSliceIds=[],this.naming=void 0,this.requestUpdate())}#Y(e){const n=be(this.locale),o=e.kind==="rename-context"?Do(this.items(),e.contextId)?.name??"":"";return v`<div id="context-pop" class="comment-pop context-pop" popover="manual">
3369
3382
  <span class="dpk-label"> ${e.kind==="create-context"?n.newContextTitle:n.renameContextTitle} </span>
3370
3383
  <input
3371
3384
  id="context-name"
@@ -3373,7 +3386,7 @@ ${o.renameContextHint}`}
3373
3386
  type="text"
3374
3387
  placeholder=${n.contextNamePlaceholder}
3375
3388
  .value=${o}
3376
- @keydown=${i=>{i.key==="Enter"&&this.#B(e),i.key==="Escape"&&(this.naming=void 0,this.requestUpdate())}}
3389
+ @keydown=${i=>{i.key==="Enter"&&this.#U(e),i.key==="Escape"&&(this.naming=void 0,this.requestUpdate())}}
3377
3390
  />
3378
3391
  <div class="pop-actions">
3379
3392
  <button
@@ -3384,18 +3397,18 @@ ${o.renameContextHint}`}
3384
3397
  >
3385
3398
  ${n.cancel}
3386
3399
  </button>
3387
- <button class="dpk-btn dpk-btn--accent" type="button" @click=${()=>this.#B(e)}>
3400
+ <button class="dpk-btn dpk-btn--accent" type="button" @click=${()=>this.#U(e)}>
3388
3401
  ${e.kind==="create-context"?n.create:n.save}
3389
3402
  </button>
3390
3403
  </div>
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">
3404
+ </div>`}#B(e){const n=be(this.locale),o=this.#b(e),i=o===void 0?void 0:mn(o);return v`<div id="append-menu" class="comment-pop append-menu" popover="manual">
3392
3405
  <span class="dpk-label">${i===void 0?n.appendMenuNext:n.appendMenuAfter(i.name)}</span>
3393
3406
  <div class="type-options">
3394
- ${Ku.map(s=>k`<button
3407
+ ${lm.map(s=>v`<button
3395
3408
  class="type-chip"
3396
3409
  type="button"
3397
3410
  data-type=${s}
3398
- style=${Ro(s)}
3411
+ style=${Oo(s)}
3399
3412
  @click=${()=>this.#$(e,s)}
3400
3413
  >
3401
3414
  ${n.noteTypeLabel(s)}
@@ -3405,72 +3418,72 @@ ${o.renameContextHint}`}
3405
3418
  <button
3406
3419
  class="dpk-btn"
3407
3420
  type="button"
3408
- @click=${()=>{this.mode=Re,this.requestUpdate()}}
3421
+ @click=${()=>{this.mode=Ae,this.requestUpdate()}}
3409
3422
  >
3410
3423
  ${n.cancel}
3411
3424
  </button>
3412
3425
  </div>
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`
3426
+ </div>`}#G(){const e=this.items(),n=kn("new-event",un(e));if(!this.#R(J.addElement(n,"event",be(this.locale).noteTypeLabel("event")))){this.mode=Ae,this.requestUpdate();return}this.select({kind:"note",id:n}),this.mode={kind:"editing",noteId:n},this.requestUpdate()}#R(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],io(o)?o:{})}#L(e){let n=!0;for(const o of e)this.#R(o)||(n=!1);return n}}const kn=(t,e)=>Ho(t,e),vn=(t,e)=>Ho(t,e),mm=(t,e)=>Ho(t,e),Ho=(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}`},Zr=()=>{ru(),customElements.get("dpk-board-event-storming")||customElements.define("dpk-board-event-storming",Qr)},gm=P({id:oe,name:S(k(),I(1)),description:j(k()),questions:nt}),fm=P({id:oe,storyId:S(k(),I(1)),name:S(k(),I(1)),description:j(k()),questions:nt}),Jr=P({id:oe,ruleId:S(k(),I(1)),name:S(k(),I(1)),description:j(k()),questions:nt}),bm=P({title:j(k()),stories:L(F(gm),[]),rules:L(F(fm),[]),examples:L(F(Jr),[]),questions:L(F(Jr),[])}),xm=t=>{const e=ue(bm,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},ym=()=>({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)},ea=(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}}},km=(t,e)=>t.rules.filter(n=>n.storyId===e),vm=(t,e)=>t.examples.filter(n=>n.ruleId===e),wm=(t,e)=>t.questions.filter(n=>n.ruleId===e),wn=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)],$m=(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:Wt(i,e,n,o)}}},Em=(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:Wt(s,n,o,i)}}},Tm=(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:Wt(s,n,o,i)}}},Sm=(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:Wt(s,n,o,i)}}},Mm={story:"Story",rule:"Rule",example:"Example",question:"Question"},Cm={story:"\u30B9\u30C8\u30FC\u30EA\u30FC",rule:"\u30EB\u30FC\u30EB",example:"\u5177\u4F53\u4F8B",question:"\u8CEA\u554F"},Lm={empty:"No rules yet","open-questions":"Open questions","too-big":"Consider splitting",thin:"A rule has no example",ready:"Looks ready"},Im={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=>Mm[t],readinessLabel:t=>Lm[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=>Cm[t],readinessLabel:t=>Im[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",R({name:S(k(),I(1))})),SET_STORY_DESCRIPTION:z("SET_STORY_DESCRIPTION","story",R({description:k()})),REORDER_STORY:z("REORDER_STORY","story",R({after:me(k())}),{mode:"sequence"}),ADD_STORY:z("ADD_STORY","page",R({id:oe,name:S(k(),I(1)),description:j(k())}),{dedupeKey:Me}),DELETE_STORY:z("DELETE_STORY","story",R({})),SET_RULE_NAME:z("SET_RULE_NAME","rule",R({name:S(k(),I(1))})),SET_RULE_DESCRIPTION:z("SET_RULE_DESCRIPTION","rule",R({description:k()})),MOVE_RULE:z("MOVE_RULE","rule",R({storyId:S(k(),I(1)),after:me(k())}),{mode:"sequence"}),REORDER_RULE:z("REORDER_RULE","rule",R({after:me(k())}),{mode:"sequence"}),ADD_RULE:z("ADD_RULE","story",R({id:oe,name:S(k(),I(1)),description:j(k())}),{dedupeKey:Me}),DELETE_RULE:z("DELETE_RULE","rule",R({})),SET_EXAMPLE_NAME:z("SET_EXAMPLE_NAME","example",R({name:S(k(),I(1))})),SET_EXAMPLE_DESCRIPTION:z("SET_EXAMPLE_DESCRIPTION","example",R({description:k()})),MOVE_EXAMPLE:z("MOVE_EXAMPLE","example",R({ruleId:S(k(),I(1)),after:me(k())}),{mode:"sequence"}),REORDER_EXAMPLE:z("REORDER_EXAMPLE","example",R({after:me(k())}),{mode:"sequence"}),ADD_EXAMPLE:z("ADD_EXAMPLE","rule",R({id:oe,name:S(k(),I(1)),description:j(k())}),{dedupeKey:Me}),DELETE_EXAMPLE:z("DELETE_EXAMPLE","example",R({})),SET_QUESTION_NAME:z("SET_QUESTION_NAME","question",R({name:S(k(),I(1))})),SET_QUESTION_DESCRIPTION:z("SET_QUESTION_DESCRIPTION","question",R({description:k()})),MOVE_QUESTION:z("MOVE_QUESTION","question",R({ruleId:S(k(),I(1)),after:me(k())}),{mode:"sequence"}),REORDER_QUESTION:z("REORDER_QUESTION","question",R({after:me(k())}),{mode:"sequence"}),ADD_QUESTION:z("ADD_QUESTION","rule",R({id:oe,name:S(k(),I(1)),description:j(k())}),{dedupeKey:Me}),DELETE_QUESTION:z("DELETE_QUESTION","question",R({}))},Am=(t,e)=>{const n=Yt(V,e);if(n===null)return null;const o=n.target.id;switch(n.type){case"SET_STORY_NAME":return ta(t,o,i=>({...i,name:n.payload.name}));case"SET_STORY_DESCRIPTION":return ta(t,o,i=>({...i,description:n.payload.description}));case"REORDER_STORY":{const i=_m(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:$n(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 na(t,o,i=>({...i,name:n.payload.name}));case"SET_RULE_DESCRIPTION":return na(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:sa(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:sa(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:$n(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 oa(t,o,i=>({...i,name:n.payload.name}));case"SET_EXAMPLE_DESCRIPTION":return oa(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:En(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:En(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:$n(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 ia(t,o,i=>({...i,name:n.payload.name}));case"SET_QUESTION_DESCRIPTION":return ia(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:En(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:En(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:$n(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 jn(n)}},$n=(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),ta=(t,e,n)=>t.stories.some(o=>o.id===e)?{...t,stories:t.stories.map(o=>o.id===e?n(o):o)}:null,na=(t,e,n)=>t.rules.some(o=>o.id===e)?{...t,rules:t.rules.map(o=>o.id===e?n(o):o)}:null,oa=(t,e,n)=>t.examples.some(o=>o.id===e)?{...t,examples:t.examples.map(o=>o.id===e?n(o):o)}:null,ia=(t,e,n)=>t.questions.some(o=>o.id===e)?{...t,questions:t.questions.map(o=>o.id===e?n(o):o)}:null,sa=(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]:Yo(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)]},En=(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]:Yo(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)]},_m=(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 Yo(i,o,n)},Yo=(t,e,n)=>{const o=[...t],i=n===null?-1:o.findIndex(s=>s.id===n);return o.splice(i+1,0,e),o},Tn=(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)},Rm={SET_STORY_NAME:(t,e,n)=>({title:t.storyRenamedTitle,tone:"update",body:Tn(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:Sn(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:Tn(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:Sn(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:Tn(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:Sn(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:Tn(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:Sn(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)})},Sn=(t,e)=>e==null?t.toTop:t.afterPlacement(e),ra=(t,e,n,o)=>{let i;try{const s=Rm[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:Dm(t,n,e.target),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},Dm=(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 ${zm(e)}`;default:return`${n.type} \xB7 ${n.id}`}}catch{return`${n.type} \xB7 ${n.id}`}},Om=4,Nm=(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>Om?"too-big":a?"thin":"ready";return{rules:o.length,examples:s.length,questions:r,readiness:d,label:t.readinessLabel(d)}},zm=t=>t.title??"Example Mapping",Pm=t=>t==="comment"?"meta":t,qm=t=>{const e=Oe(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}},Fm=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=ra(t,s,o).title;if(!(s.type in V)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=qm(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Am(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=ra(t,d,l,o);i.push({id:s.id,title:c.title,tone:Pm(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Um={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}=Um[t];return`--em-card-bg:${e};--em-card-ink:${n}`},aa=t=>{const e=t.currentTarget;e instanceof HTMLElement&&(e.draggable=t.type==="focusout")},Bm=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,m=a.kindLabel(e);return v`
3414
3427
  <div
3415
3428
  class=${ve("em-card",s&&"is-focused",r&&"is-dragging")}
3416
3429
  data-card=${n.id}
3417
3430
  data-card-kind=${e}
3418
3431
  data-mode=${i}
3419
3432
  data-dpk-target=${d}
3420
- data-grill-questions=${Wt(l)}
3433
+ data-grill-questions=${Vt(l)}
3421
3434
  style=${`${Rt(e)};--em-tilt:${o}deg`}
3422
3435
  draggable="true"
3423
3436
  @click=${()=>c({kind:"select"})}
3424
- @focusin=${Zr}
3425
- @focusout=${Zr}
3437
+ @focusin=${aa}
3438
+ @focusout=${aa}
3426
3439
  @dragstart=${p}
3427
3440
  @dragend=${u}
3428
3441
  >
3429
- <div class="card-kind">${g}</div>
3442
+ <div class="card-kind">${m}</div>
3430
3443
  <dpk-inline-edit
3431
3444
  class="card-name"
3432
3445
  ?wrap=${!0}
3433
3446
  ?seamless=${!0}
3434
3447
  .value=${n.name}
3435
- .label=${a.nameField(g)}
3436
- @dpk-commit=${nt(b=>c({kind:"rename",name:b}))}
3448
+ .label=${a.nameField(m)}
3449
+ @dpk-commit=${ot(f=>c({kind:"rename",name:f}))}
3437
3450
  ></dpk-inline-edit>
3438
- ${n.description?k`<div class="card-text">${n.description}</div>`:T}
3451
+ ${n.description?v`<div class="card-text">${n.description}</div>`:T}
3439
3452
  <div class="card-tools">
3440
3453
  <button
3441
3454
  class="dpk-icon-btn"
3442
3455
  type="button"
3443
3456
  data-role="comment"
3444
3457
  aria-label=${a.commentCard}
3445
- @click=${b=>{b.stopPropagation(),h(e,n.id)}}
3458
+ @click=${f=>{f.stopPropagation(),h(e,n.id)}}
3446
3459
  >
3447
- ${Xn()}
3460
+ ${Kn()}
3448
3461
  </button>
3449
3462
  <button
3450
3463
  class="dpk-icon-btn"
3451
3464
  type="button"
3452
3465
  data-role="delete"
3453
3466
  aria-label=${a.deleteButton}
3454
- @click=${b=>{b.stopPropagation(),c({kind:"delete"})}}
3467
+ @click=${f=>{f.stopPropagation(),c({kind:"delete"})}}
3455
3468
  >
3456
- ${Bt()}
3469
+ ${Ht()}
3457
3470
  </button>
3458
3471
  </div>
3459
3472
  </div>
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`
3473
+ `},Go={kind:"idle"},da=(t,e)=>t.kind!=="idle"&&t.cardId===e,Hm=(t,e)=>da(t,e)&&t.kind==="editing"?"editing":"view",Ym=(t,e,n)=>{switch(n.kind){case"rename":case"delete":return da(t,e)?Go: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},Xm=t=>{const{state:e,handlers:n,m:o}=t;return e.stories.length===0?v`
3461
3474
  <div class="empty">
3462
3475
  <h2>${o.noStoriesTitle}</h2>
3463
3476
  <p>${o.noStoriesBody}</p>
3464
3477
  <button class="dpk-btn dpk-btn--accent" type="button" @click=${n.addStory}>${o.firstStory}</button>
3465
3478
  </div>
3466
- `:k`
3479
+ `:v`
3467
3480
  <div class="board" data-testid="example-mapping-board">
3468
- ${Me(e.stories,i=>i.id,i=>Am(t,i))}
3481
+ ${Se(e.stories,i=>i.id,i=>Km(t,i))}
3469
3482
  <button class="add-story" type="button" @click=${n.addStory}>${o.addStoryButton}</button>
3470
3483
  </div>
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`
3484
+ `},Xo=(t,e,n)=>{const{mode:o,drag:i,handlers:s,m:r}=t,a=i.source({type:e,id:n.id}),d=Gt(n.questions);return v`<span class="card-slot">
3485
+ ${Bm({kind:e,card:{id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}},tilt:Gm(e,n.id),mode:Hm(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})}
3486
+ </span>`},Km=(t,e)=>{const{state:n,drag:o,handlers:i,m:s}=t,r=Nm(s,n,e.id),a=`story:${e.id}`,d=o.target({key:a,accepts:"story",hovered:pa(".story-section","story"),onDrop:i.dropStory}),l=`rules:${e.id}`,c=o.target({key:l,accepts:"rule",hovered:pa(".rule-col","rule"),onDrop:h=>i.dropRule(e.id,h)});return v`
3474
3487
  <section
3475
3488
  class="story-section"
3476
3489
  data-story=${e.id}
@@ -3481,7 +3494,7 @@ ${o.renameContextHint}`}
3481
3494
  @drop=${d.drop}
3482
3495
  >
3483
3496
  <header class="story-row">
3484
- <div class="story-slot">${Ho(t,"story",e)}</div>
3497
+ <div class="story-slot">${Xo(t,"story",e)}</div>
3485
3498
  <div class="story-meta">
3486
3499
  <span class="readiness" data-readiness=${r.readiness}>${r.label}</span>
3487
3500
  <span class="tally"
@@ -3506,18 +3519,18 @@ ${o.renameContextHint}`}
3506
3519
  @dragleave=${c.dragleave}
3507
3520
  @drop=${c.drop}
3508
3521
  >
3509
- ${Me(im(n,e.id),h=>h.id,h=>Rm(t,h))}
3522
+ ${Se(km(n,e.id),h=>h.id,h=>jm(t,h))}
3510
3523
  <button class="add-rule" type="button" @click=${()=>i.addRule(e.id)}>
3511
3524
  <span class="add-plus">+</span>${s.kindLabel("rule")}
3512
3525
  </button>
3513
3526
  </div>
3514
3527
  </section>
3515
- `},Rm=(t,e)=>{const{drag:n}=t;return k`
3528
+ `},jm=(t,e)=>{const{drag:n}=t;return v`
3516
3529
  <div class="rule-col" data-rule=${e.id} ?data-dragging=${n.isDragging("rule",e.id)}>
3517
- ${Ho(t,"rule",e)} ${ea(t,e.id,"example")}
3518
- ${ea(t,e.id,"question")}
3530
+ ${Xo(t,"rule",e)} ${la(t,e.id,"example")}
3531
+ ${la(t,e.id,"question")}
3519
3532
  </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
3533
+ `},Wm={example:"examples",question:"questions"},Vm=(t,e)=>({testid:Wm[e],label:t.kindLabel(e),empty:e==="example"?t.noExamples:t.noQuestions,add:`+ ${t.kindLabel(e)}`}),la=(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:ca("example"),onDrop:p=>s.dropExample(e,p)}):i.target({key:d,accepts:"question",hovered:ca("question"),onDrop:p=>s.dropQuestion(e,p)}),c=n==="example"?vm(o,e):wm(o,e),h=n==="example"?s.addExample:s.addQuestion;return v`<div
3521
3534
  class="card-area card-area--${n}"
3522
3535
  data-testid=${`${a.testid}-${e}`}
3523
3536
  data-drop=${String(i.isOver(d))}
@@ -3527,10 +3540,10 @@ ${o.renameContextHint}`}
3527
3540
  @drop=${l.drop}
3528
3541
  >
3529
3542
  <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}
3543
+ ${Se(c,p=>p.id,p=>Xo(t,n,p))}
3544
+ ${c.length===0?v`<p class="stack-hint">${a.empty}</p>`:T}
3532
3545
  <button class="add-card add-${n}" type="button" @click=${()=>h(e)}>${a.add}</button>
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`
3546
+ </div>`},ca=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}},pa=(t,e)=>n=>{const o=n.target instanceof Element?n.target.closest(t):null;return o?{id:o.getAttribute(`data-${e}`),element:o}:null},Qm=de`
3534
3547
  /* ------------------------------------------------------------- board */
3535
3548
 
3536
3549
  .board {
@@ -3917,7 +3930,7 @@ ${o.renameContextHint}`}
3917
3930
  background: color-mix(in srgb, var(--dpk-paper-raised) 94%, transparent);
3918
3931
  box-shadow: var(--dpk-shadow-xs);
3919
3932
  }
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`
3933
+ `,Zm={story:"SET_STORY_NAME",rule:"SET_RULE_NAME",example:"SET_EXAMPLE_NAME",question:"SET_QUESTION_NAME"},Jm={story:"DELETE_STORY",rule:"DELETE_RULE",example:"DELETE_EXAMPLE",question:"DELETE_QUESTION"},eg="example-mapping";class ha extends rt{boardAddable(){return!0}static{this.styles=[st,Qm]}#o=new Tl(this);#i=null;#e=Go;parseData(e){return xm(e)}emptyData(){return ym()}reduceElementActions(e,n){return Fm(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 ea(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=Go)}render(){this.prepareRender();const e=Be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return v`
3921
3934
  <dpk-dialog-panel
3922
3935
  class=${this.shellClass()}
3923
3936
  ?maximizable=${this.frameControls}
@@ -3927,10 +3940,10 @@ ${o.renameContextHint}`}
3927
3940
  @dpk-maximize-change=${()=>this.closeComposer()}
3928
3941
  >
3929
3942
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
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))})}
3943
+ ${this.dataError!==null?v`<p class="em-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:Xm({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
3944
  </dpk-dialog-panel>
3932
3945
  ${this.renderSelection()}
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`
3946
+ `}#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:ea(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=wn(this.items()),n=Be(this.locale).newStory,o=ke(`story ${n}`,e);this.#n(this.dispatchElementAction("ADD_STORY",["page",eg],{id:o,name:n})?o:null)}#r(e){const n=wn(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=wn(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=wn(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(Zm[n],[n,e],{name:o.name});break;case"delete":this.dispatchElementAction(Jm[n],[n,e],{}),this.selection?.id===e&&this.select(null);break}this.#e=Ym(this.#e,e,o),this.requestUpdate()}#h(e){const n=$m(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=Em(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=Tm(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=Sm(this.items(),e,n.item.id,n.hoveredId,n.place);o&&this.dispatchElementAction(o.type,[o.target.type,o.target.id],o.payload)}}const ua=()=>{customElements.get("dpk-board-example-mapping")||customElements.define("dpk-board-example-mapping",ha)},Ve=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"}}),ma=S(ce(),Ti(),Xt(1)),tg=P({url:Ai,label:j(S(k(),I(1)))}),ng=P({id:S(k(),I(1)),number:L(ma),title:S(k(),I(1)),description:L(k()),tags:L(F(k())),assignee:L(k()),links:L(F(tg)),questions:L(k())}),og=["gray","blue","green","amber","violet","red"],ig=P({id:S(k(),I(1)),label:S(k(),I(1)),description:L(k()),color:L(G(og)),limit:L(S(ce(),Ti(),Xt(1))),cards:L(F(ng))}),sg=P({columns:F(ig)}),rg=()=>({columns:[]}),ag=t=>{const e=ue(sg,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),Qe=t=>t.columns.flatMap(e=>e.cards),dg=(t,e)=>e===null?t:{columns:t.columns.map(n=>({...n,cards:n.cards.filter(e)}))},lg=(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},Mn=t=>`TASK-${t.number}`,cg=t=>Math.max(0,...Qe(t).map(e=>e.number))+1,ga="ADD_CARD",fa="MOVE_CARD",ba="SET_CARD_TITLE",xa="SET_CARD_DESCRIPTION",ya="SET_CARD_ASSIGNEE",ka="ADD_CARD_TAG",va="REMOVE_CARD_TAG",wa="ADD_CARD_LINK",$a="REMOVE_CARD_LINK",pg=R({id:S(k(),I(1)),title:S(k(),ye(),I(1)),number:L(ma)}),hg=R({column:S(k(),I(1)),before:me(S(k(),I(1)))}),Ko=(t,e)=>{const n=Oe(t);return n?.length===3&&n[1]===e?n[2]??null:null},ug=(t,e)=>({columns:t.columns.map(n=>n.cards.some(o=>o.id===e)?{...n,cards:n.cards.filter(o=>o.id!==e)}:n)}),Ea=(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)]}})}),mg=(t,e,n)=>{const o=t.addCardTitle,i=Ko(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(pg,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??cg(e);if(Qe(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:Ea(e,d,{column:s.id,before:null}),result:{id:n.id,title:o,summary:t.addSummary(s.label,d.title),tone:"create"}}},gg=(t,e,n)=>{const o=t.moveCardTitle,i=Ko(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(hg,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:Ea(ug(e,s.id),h,{column:d.id,before:l}),result:{id:n.id,title:o,summary:p,tone:"move"}}},fg=(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)}),Ze=(t,e,n,o,i)=>{const s=Ko(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:fg(e,a),result:{id:n.id,title:o,summary:t.editSummary(Mn(r),r.title),tone:"update"}}},bg=R({title:S(k(),ye(),I(1))}),xg=R({description:k()}),yg=R({assignee:k()}),Ta=R({tag:S(k(),ye(),I(1))}),kg=R({url:Ai,label:j(S(k(),ye(),I(1)))}),vg=R({url:S(k(),I(1))}),wg=(t,e,n)=>{const o=re(bg,n.payload);return o.success?Ze(t,e,n,t.setTitleTitle,i=>({...i,title:o.output.title})):{data:e,result:{id:n.id,title:t.setTitleTitle,stale:"constraint-violated"}}},$g=(t,e,n)=>{const o=re(xg,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 Ze(t,e,n,t.setDescriptionTitle,s=>({...s,description:i}))},Eg=(t,e,n)=>{const o=re(yg,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 Ze(t,e,n,t.setAssigneeTitle,s=>({...s,assignee:i}))},Tg=(t,e,n)=>{const o=re(Ta,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.addTagTitle,stale:"constraint-violated"}};const i=o.output.tag;return Ze(t,e,n,t.addTagTitle,s=>s.tags.includes(i)?null:{...s,tags:[...s.tags,i]})},Sg=(t,e,n)=>{const o=re(Ta,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.removeTagTitle,stale:"constraint-violated"}};const i=o.output.tag;return Ze(t,e,n,t.removeTagTitle,s=>s.tags.includes(i)?{...s,tags:s.tags.filter(r=>r!==i)}:null)},Mg=(t,e,n)=>{const o=re(kg,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 Ze(t,e,n,t.addLinkTitle,s=>s.links.some(r=>r.url===i.url)?null:{...s,links:[...s.links,i]})},Cg=(t,e,n)=>{const o=re(vg,n.payload);if(!o.success)return{data:e,result:{id:n.id,title:t.removeLinkTitle,stale:"constraint-violated"}};const i=o.output.url;return Ze(t,e,n,t.removeLinkTitle,s=>s.links.some(r=>r.url===i)?{...s,links:s.links.filter(r=>r.url!==i)}:null)},Lg=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===ga?mg(t,o,s):s.type===fa?gg(t,o,s):s.type===ba?wg(t,o,s):s.type===xa?$g(t,o,s):s.type===ya?Eg(t,o,s):s.type===ka?Tg(t,o,s):s.type===va?Sg(t,o,s):s.type===wa?Mg(t,o,s):s.type===$a?Cg(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}},Ig=de`
3934
3947
  /* The columns and, while a card is open, its detail beside them. */
3935
3948
  .kanban-stage {
3936
3949
  display: flex;
@@ -4451,7 +4464,7 @@ ${o.renameContextHint}`}
4451
4464
  max-height: none;
4452
4465
  }
4453
4466
  }
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`
4467
+ `,Ag=3;class Sa extends rt{boardAddable(){return!0}static{this.styles=[st,Ml,Cl,Ig]}#o=null;#i=null;#e=null;#t=null;#n=!1;#a=!1;#r=null;#s=null;parseData(e){return ag(e)}emptyData(){return rg()}reduceElementActions(e,n){return Lg(Ve(this.locale),e,n)}defaultHeading(){return Ve(this.locale).heading}shellClass(){return"kanban"}emptyMessage(){return Ve(this.locale).empty}commentItems(){const e=this.items();return[...e.columns.map(n=>({value:this.commentRef("column",n.id),label:n.label})),...Qe(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=Ve(this.locale),s=Mn(o);return[{id:"kanban-card",entries:[{kind:"item",id:"copy-card-key",label:i.copyKey,run:()=>{Si(s)}},{kind:"item",id:"copy-card-key-title",label:i.copyKeyTitle,run:()=>{Si(`${s} ${o.title}`)}}]},...n??[]]}#d(e){if(e===null||e.type!=="element")return;const n=Oe(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)===Hn(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 Qe(this.items()).map(e=>e.tags)}statsText(){const e=Ve(this.locale),n=Qe(this.items()).length,o=Qe(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 v`
4455
4468
  <dpk-dialog-panel
4456
4469
  class=${this.shellClass()}
4457
4470
  ?maximizable=${this.frameControls}
@@ -4461,15 +4474,15 @@ ${o.renameContextHint}`}
4461
4474
  @dpk-maximize-change=${()=>this.closeComposer()}
4462
4475
  >
4463
4476
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
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()}
4477
+ ${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.#c()}
4465
4478
  </dpk-dialog-panel>
4466
4479
  ${this.renderSelection()}
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">
4480
+ `}#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 v`<div class="kanban-stage">
4468
4481
  <div class="kanban-board">
4469
- ${Me(e.columns,s=>s.id,s=>this.#u(s,n.get(s.id)??0))}
4482
+ ${Se(e.columns,s=>s.id,s=>this.#u(s,n.get(s.id)??0))}
4470
4483
  </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`
4484
+ ${o===void 0?T:this.#b(o,i,Ve(this.locale))}
4485
+ </div>`}#h(){const e=this.tagFilter;return dg(this.items(),e.active.length===0?null:n=>Ie(n.tags,e))}#p(e,n){const o=this.selection;return o!==null&&o.kind===e&&o.id===n}#u(e,n){const o=Ve(this.locale),i=e.limit!==null&&n>e.limit,s=this.#s?.column===e.id?this.#s:null;return v`
4473
4486
  <section
4474
4487
  class=${ve("kanban-column",i&&"is-over",this.#p("column",e.id)&&"is-selected",s!==null&&"is-drop-target")}
4475
4488
  data-column=${e.id}
@@ -4491,19 +4504,19 @@ ${o.renameContextHint}`}
4491
4504
  </span>
4492
4505
  </button>
4493
4506
  </div>
4494
- ${e.description===null?T:k`<p class="kanban-column-description">${e.description}</p>`}
4507
+ ${e.description===null?T:v`<p class="kanban-column-description">${e.description}</p>`}
4495
4508
  <div
4496
4509
  class="kanban-cards"
4497
4510
  @dragover=${r=>this.#$(r,e.id)}
4498
- @dragleave=${r=>this.#F(r)}
4499
- @drop=${r=>this.#S(r,e.id)}
4511
+ @dragleave=${r=>this.#q(r)}
4512
+ @drop=${r=>this.#O(r,e.id)}
4500
4513
  >
4501
- ${Me(e.cards,r=>r.id,r=>k`${s?.before===r.id?this.#l():T}${this.#m(r,o)}`)}
4514
+ ${Se(e.cards,r=>r.id,r=>v`${s?.before===r.id?this.#l():T}${this.#m(r,o)}`)}
4502
4515
  ${s!==null&&s.before===null?this.#l():T}
4503
4516
  </div>
4504
- ${this.#v(e,o)}
4517
+ ${this.#y(e,o)}
4505
4518
  </section>
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`
4519
+ `}#l(){return v`<div class="kanban-drop-marker" aria-hidden="true"></div>`}#m(e,n){const o=this.#p("card",e.id);return v`
4507
4520
  <div class="kanban-card-slot">
4508
4521
  <div
4509
4522
  role="button"
@@ -4517,28 +4530,28 @@ ${o.renameContextHint}`}
4517
4530
  title=${e.description??e.title}
4518
4531
  aria-pressed=${o?"true":"false"}
4519
4532
  @click=${()=>this.#f(e.id)}
4520
- @keydown=${i=>this.#T(i,e.id)}
4533
+ @keydown=${i=>this.#v(i,e.id)}
4521
4534
  @dragstart=${i=>this.#C(i,e.id)}
4522
- @dragend=${()=>this.#M()}
4535
+ @dragend=${()=>this.#E()}
4523
4536
  >
4524
4537
  <div class="dpk-card-head">
4525
4538
  <div class="dpk-card-title">${e.title}</div>
4526
- <span class="dpk-card-key">${Sn(e)}</span>
4539
+ <span class="dpk-card-key">${Mn(e)}</span>
4527
4540
  </div>
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"
4541
+ ${e.description===null?T:v`<div class="dpk-card-text">${e.description}</div>`}
4542
+ ${e.tags.length===0&&e.assignee===null?T:v`<div class="dpk-card-row kanban-card-meta">
4543
+ ${e.tags.map(i=>v`<span class="dpk-pill">${i}</span>`)}
4544
+ ${e.assignee===null?T:v`<span class="kanban-assignee"
4532
4545
  ><span class="dpk-avatar" aria-hidden="true">${Array.from(e.assignee)[0]??""}</span
4533
4546
  >${e.assignee}</span
4534
4547
  >`}
4535
4548
  </div>`}
4536
4549
  ${e.links.length===0?T:this.#g(e)}
4537
4550
  </div>
4538
- ${this.#e===e.id?k`<p class="kanban-error" role="alert">${n.notRecorded}</p>`:T}
4551
+ ${this.#e===e.id?v`<p class="kanban-error" role="alert">${n.notRecorded}</p>`:T}
4539
4552
  </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
4553
+ `}#g(e){const n=e.links.slice(0,Ag);return v`<div class="dpk-card-row kanban-card-links">
4554
+ ${n.map(o=>{const i=Qn(o.url);return v`<a
4542
4555
  class="link-chip"
4543
4556
  data-kind=${i.kind}
4544
4557
  href=${o.url}
@@ -4548,27 +4561,27 @@ ${o.renameContextHint}`}
4548
4561
  draggable="false"
4549
4562
  tabindex="-1"
4550
4563
  @click=${s=>s.stopPropagation()}
4551
- >${Ci(i.kind)}<span>${o.label??i.text}</span></a
4564
+ >${_i(i.kind)}<span>${o.label??i.text}</span></a
4552
4565
  >`})}
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
4566
+ ${e.links.length>n.length?v`<span class="link-chip">+${e.links.length-n.length}</span>`:T}
4567
+ </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()}#S(e){e.key==="Escape"&&(e.composedPath().some(n=>n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)||(e.preventDefault(),this.#x()))}#w(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(ka,["card",n],{tag:i});this.#n=!s,s&&(o.value=""),this.requestUpdate()}#M(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(wa,["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 v`<aside
4555
4568
  class="kanban-detail"
4556
4569
  role="dialog"
4557
4570
  aria-label=${o.cardDetailAria(e.title)}
4558
4571
  data-card=${e.id}
4559
4572
  tabindex="-1"
4560
- @keydown=${s=>this.#E(s)}
4573
+ @keydown=${s=>this.#S(s)}
4561
4574
  >
4562
4575
  <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>`}
4576
+ <span class="kanban-detail-key">${Mn(e)}</span>
4577
+ ${n===void 0?T:v`<span class="kanban-detail-column" data-color=${n.color??T}>${n.label}</span>`}
4565
4578
  <button
4566
4579
  class="dpk-icon-btn kanban-detail-close"
4567
4580
  type="button"
4568
4581
  aria-label=${o.closeCardDetail}
4569
4582
  @click=${()=>this.#x()}
4570
4583
  >
4571
- ${jn()}
4584
+ ${Wn()}
4572
4585
  </button>
4573
4586
  </header>
4574
4587
  <div class="kanban-detail-body">
@@ -4577,17 +4590,17 @@ ${o.renameContextHint}`}
4577
4590
  wrap
4578
4591
  .value=${e.title}
4579
4592
  .label=${o.cardTitleLabel}
4580
- @dpk-commit=${nt(s=>i(da,{title:s}))}
4593
+ @dpk-commit=${ot(s=>i(ba,{title:s}))}
4581
4594
  ></dpk-inline-edit>
4582
4595
  </h3>
4583
4596
  <section class="kanban-detail-field">
4584
4597
  <span class="dpk-label">${o.cardStatusLabel}</span>
4585
4598
  <div class="kanban-statuses">
4586
- ${this.items().columns.map(s=>k`<button
4599
+ ${this.items().columns.map(s=>v`<button
4587
4600
  class="kanban-status"
4588
4601
  type="button"
4589
4602
  aria-pressed=${String(s.id===e.column)}
4590
- @click=${()=>this.#w(e.id,{column:s.id,before:null})}
4603
+ @click=${()=>this.#k(e.id,{column:s.id,before:null})}
4591
4604
  >
4592
4605
  ${s.label}
4593
4606
  </button>`)}
@@ -4599,27 +4612,27 @@ ${o.renameContextHint}`}
4599
4612
  .value=${e.assignee??""}
4600
4613
  .label=${o.cardAssigneeLabel}
4601
4614
  .placeholder=${o.cardAssigneePlaceholder}
4602
- @dpk-commit=${nt(s=>i(ca,{assignee:s}))}
4615
+ @dpk-commit=${ot(s=>i(ya,{assignee:s}))}
4603
4616
  ></dpk-inline-edit>
4604
4617
  </section>
4605
4618
  <section class="kanban-detail-field">
4606
4619
  <span class="dpk-label">${o.cardTagsLabel}</span>
4607
4620
  <div class="kanban-tag-row">
4608
- ${e.tags.map(s=>k`<span class="dpk-pill kanban-tag"
4621
+ ${e.tags.map(s=>v`<span class="dpk-pill kanban-tag"
4609
4622
  >${s}<button
4610
4623
  type="button"
4611
4624
  class="kanban-tag-remove"
4612
4625
  aria-label=${o.removeTagAria(s)}
4613
- @click=${()=>i(ha,{tag:s})}
4626
+ @click=${()=>i(va,{tag:s})}
4614
4627
  >
4615
- ${jn()}
4628
+ ${Wn()}
4616
4629
  </button></span
4617
4630
  >`)}
4618
4631
  <input
4619
4632
  class="dpk-input kanban-tag-add"
4620
4633
  aria-label=${o.cardTagsPlaceholder}
4621
4634
  placeholder=${o.cardTagsPlaceholder}
4622
- @keydown=${s=>this.#k(s,e.id)}
4635
+ @keydown=${s=>this.#w(s,e.id)}
4623
4636
  />
4624
4637
  </div>
4625
4638
  </section>
@@ -4631,29 +4644,29 @@ ${o.renameContextHint}`}
4631
4644
  .value=${e.description??""}
4632
4645
  .label=${o.cardDescriptionLabel}
4633
4646
  .placeholder=${o.cardDescriptionPlaceholder}
4634
- @dpk-commit=${nt(s=>i(la,{description:s}))}
4647
+ @dpk-commit=${ot(s=>i(xa,{description:s}))}
4635
4648
  ></dpk-inline-edit>
4636
4649
  </section>
4637
4650
  <section class="kanban-detail-field">
4638
4651
  <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>
4652
+ ${e.links.length===0?T:v`<ul class="kanban-link-list">
4653
+ ${e.links.map(s=>v`<li>
4641
4654
  <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
4655
+ >${_i(Qn(s.url).kind)}<span
4656
+ >${s.label??Qn(s.url).text}</span
4644
4657
  ></a
4645
4658
  >
4646
4659
  <button
4647
4660
  type="button"
4648
4661
  class="dpk-icon-btn kanban-link-remove"
4649
4662
  aria-label=${o.removeLinkAria(s.url)}
4650
- @click=${()=>i(ma,{url:s.url})}
4663
+ @click=${()=>i($a,{url:s.url})}
4651
4664
  >
4652
- ${jn()}
4665
+ ${Wn()}
4653
4666
  </button>
4654
4667
  </li>`)}
4655
4668
  </ul>`}
4656
- <form class="kanban-link-add" @submit=${s=>this.#I(s,e.id)}>
4669
+ <form class="kanban-link-add" @submit=${s=>this.#M(s,e.id)}>
4657
4670
  <input
4658
4671
  class="dpk-input"
4659
4672
  data-role="link-url"
@@ -4673,28 +4686,28 @@ ${o.renameContextHint}`}
4673
4686
  <button class="dpk-btn" type="submit">${o.addLinkButton}</button>
4674
4687
  </form>
4675
4688
  </section>
4676
- ${this.#n?k`<p class="kanban-error" role="alert">${o.notRecorded}</p>`:T}
4689
+ ${this.#n?v`<p class="kanban-error" role="alert">${o.notRecorded}</p>`:T}
4677
4690
  </div>
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
4691
+ </aside>`}updated(){super.updated(),this.#a&&(this.#a=!1,this.renderRoot.querySelector(".kanban-detail")?.focus({preventScroll:!0}))}#y(e,n){const o=this.#i?.column===e.id?this.#i:null;return v`<div class="kanban-add">
4692
+ ${o===null?v`<button
4680
4693
  type="button"
4681
4694
  class="kanban-add-button"
4682
4695
  data-action="add"
4683
- @click=${()=>this.#N(e.id)}
4696
+ @click=${()=>this.#_(e.id)}
4684
4697
  >
4685
4698
  ${n.addCardButton}
4686
- </button>`:k`
4699
+ </button>`:v`
4687
4700
  <input
4688
4701
  class="dpk-input"
4689
4702
  aria-label="${n.addCardAriaLabel(e.label)}"
4690
4703
  placeholder="${n.addCardPlaceholder}"
4691
4704
  .value=${o.title}
4692
4705
  @input=${i=>{const s=i.currentTarget;s instanceof HTMLInputElement&&(this.#i={...o,title:s.value,failed:!1})}}
4693
- @keydown=${i=>this.#z(i,e.id)}
4706
+ @keydown=${i=>this.#P(i,e.id)}
4694
4707
  />
4695
- ${o.failed?k`<span class="kanban-error" role="alert">${n.notRecorded}</span>`:T}
4708
+ ${o.failed?v`<span class="kanban-error" role="alert">${n.notRecorded}</span>`:T}
4696
4709
  `}
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`
4710
+ </div>`}#v(e,n){e.target!==e.currentTarget||e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.#f(n))}#k(e,n){const o=this.dispatchElementAction(fa,["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.#z(e,n);this.#s?.column===o.column&&this.#s.before===o.before||(this.#s=o,this.requestUpdate())}#q(e){const n=e.currentTarget;!(n instanceof HTMLElement)||e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||(this.#s=null,this.requestUpdate())}#O(e,n){const o=this.#r;if(o===null)return;e.preventDefault();const i=this.#z(e,n);this.#E(),lg(this.items(),o,i.column,i.before)||this.#k(o,i)}#E(){this.#r===null&&this.#s===null||(this.#r=null,this.#s=null,this.requestUpdate())}#z(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}}#_(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}))}#P(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),...Qe(this.items()).map(r=>r.id)],s=ke(`card ${o}`,i);if(!this.dispatchElementAction(ga,["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 Ma=()=>{customElements.get("dpk-board-kanban")||customElements.define("dpk-board-kanban",Sa)},Ca=[72,52,40],La=[0,22,10,8],_g=t=>Ca[Math.min(t,Ca.length-1)]??40,Ia=t=>La[Math.min(t,La.length-1)]??8,Rg=(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,_)=>M+d(E)+(_===0?0:Ia(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 _=_g(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+_:C.x-_-O.width,y:D+B/2-O.height/2,node:O};l.push(q),c(q,s(O),E),D+=B+Ia(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)),m=Math.min(...l.map(C=>C.y)),f=Math.max(...l.map(C=>C.x+C.node.width)),g=Math.max(...l.map(C=>C.y+C.node.height)),b=n-u,y=n-m,x=new Map,w=l.map(C=>{const M=x.get(C.node.depth)??0;return x.set(C.node.depth,M+1),{id:C.node.id,x:C.x+b,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),_=i.get(C.to);if(M===void 0||E===void 0||_===void 0)return[];const D=_.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:f-u+n*2,height:g-m+n*2,nodes:w,routes:A}},Dg=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}`},Dt=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}`}}),Aa=ll(()=>P({id:S(k(),I(1)),label:S(k(),I(1)),description:L(k()),tags:L(F(k())),questions:L(k()),collapsed:L(yt()),side:L(G(["left","right"])),children:L(F(Aa))})),Og=P({root:Aa}),_a=()=>({root:null,nodes:[],edges:[]}),Ra=[{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}],Ng=t=>Ra[Math.min(t,Ra.length-1)]??{fontSize:12.5,padding:12,height:28,min:56,max:220},zg=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},Pg=(t,e)=>{const n=Ng(e),o=Math.ceil(zg(t,n.fontSize)+n.padding*2+4);return{width:Math.min(n.max,Math.max(n.min,o)),height:n.height}},qg=t=>({left:{x:0,y:t.height/2},right:{x:t.width,y:t.height/2}}),Fg=t=>t==="left"?{fromPort:"left",toPort:"right"}:{fromPort:"right",toPort:"left"},jo=t=>t.children===void 0||t.children.length===0?1:t.children.reduce((e,n)=>e+jo(n),0),Da=t=>{const e={left:0,right:0};for(const n of t)n.side!==void 0&&(e[n.side]+=jo(n));return t.map(n=>{if(n.side!==void 0)return n.side;const o=e.right<=e.left?"right":"left";return e[o]+=jo(n),o})},Ug=t=>Oa(ue(Og,t).root),Oa=(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=Pg(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(m=>m.id),collapsed:r.collapsed??!1,added:e.has(r.id),tags:r.tags??[],...p,ports:qg(p),...r.questions===void 0?{}:{questions:r.questions}}),a!==null&&c!==null&&o.push({id:r.id,from:a,to:r.id,tags:[],...Fg(c)});const u=d===0?Da(h):[];h.forEach((m,f)=>s(m,r.id,d+1,d===0?f:l,d===0?u[f]??"right":c))};return s(t,null,0,-1,null),{root:t,nodes:n,edges:o}},Na="ADD_TOPIC",Bg=R({id:S(k(),I(1)),label:S(k(),ye(),I(1))}),Hg=t=>{const e=Oe(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},za=(t,e,n)=>t.id===e?{...t,children:[...t.children??[],n]}:t.children===void 0?t:{...t,children:t.children.map(o=>za(o,e,n))},Yg=t=>{if(t.children===void 0)return t;const e=Da(t.children);return{...t,children:t.children.map((n,o)=>({...n,side:e[o]??"right"}))}},Gg=(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:Yg(e.root);for(const d of n){if(d.type!==Na){r.push({id:d.id,title:d.type,stale:"unsupported-action-type"});continue}const l=Hg(d.target.id),c=l===null?void 0:i.get(l),h=re(Bg,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=za(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:Oa(a,s),results:r}},Wo=(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},Xg=(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},Kg=(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 Wo(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))&&!Wo(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))}},jg=de`
4698
4711
  .branch-root {
4699
4712
  --mind-color: var(--dpk-ink);
4700
4713
  --mind-soft: var(--dpk-paper-sunken);
@@ -4911,16 +4924,16 @@ ${o.renameContextHint}`}
4911
4924
  opacity: 1;
4912
4925
  }
4913
4926
  }
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`
4927
+ `,Wg=5,Pa=.6;class qa extends at{static{this.styles=[Ne,jg]}#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&&Wo(this.items(),s.id).includes(e)&&this.select(null)}else this.#o.delete(e);this.requestUpdate()}}get collapsed(){return[...this.#o]}parseData(e){return Ug(e)}emptyData(){return _a()}reduceElementActions(e,n){return Gg(Dt(this.locale),e,n)}defaultHeading(){return Dt(this.locale).heading}emptyMessage(){return Dt(this.locale).empty}statsText(){const e=Dt(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=>Ie(o.tags,e);return Kg(this.items(),n,this.#o)}layoutSignature(){return this.filtered().nodes.map(e=>`${e.id}<${e.parent??""}:${e.side??""}`).join(",")}computePlacement(e){return Rg(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<Pa&&e.zoom(Pa/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=Dt(this.locale);return v`
4915
4928
  ${this.renderEdges(e.edges.map(o=>this.#a(o)),[])}
4916
4929
  ${e.nodes.map(o=>this.#r(o,n))} ${this.#d(n)}
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`
4930
+ `}#n(e){return e===void 0||e.branch<0?"branch-root":`branch-${e.branch%Wg}`}#a(e){const n=this.items().nodes.find(i=>i.id===e.to),o=this.edgeState(e.id);return Y`
4918
4931
  <path
4919
4932
  class=${this.elementClass(o,"d-edge","mind-branch",this.#n(n),`depth-${Math.min(n?.depth??1,3)}`)}
4920
4933
  data-branch=${e.id}
4921
- d=${xg(this.routeOf(e.id))}
4934
+ d=${Dg(this.routeOf(e.id))}
4922
4935
  ></path>
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`
4936
+ `}#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 v`
4924
4937
  <button
4925
4938
  type="button"
4926
4939
  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")}
@@ -4936,7 +4949,7 @@ ${o.renameContextHint}`}
4936
4949
  <span class="mind-label">${e.label}</span>
4937
4950
  </button>
4938
4951
  ${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`
4952
+ `}#s(e,n,o,i,s){const r=o?Xg(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`
4940
4953
  <button
4941
4954
  type="button"
4942
4955
  class=${this.elementClass({selected:!1,related:!1,dimmed:i,depth:null},"mind-toggle",this.#n(e),o&&"is-folded")}
@@ -4949,18 +4962,18 @@ ${o.renameContextHint}`}
4949
4962
  >
4950
4963
  ${o?r:"\u2212"}
4951
4964
  </button>
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`
4965
+ `}#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 v`
4953
4966
  <div
4954
4967
  class="mind-actions"
4955
4968
  data-for=${o.id}
4956
4969
  style="left:${this.#c(o,i)}px; top:${i.y+i.height+8}px"
4957
4970
  @click=${r=>r.stopPropagation()}
4958
4971
  >
4959
- ${s===null?k`
4972
+ ${s===null?v`
4960
4973
  <button type="button" class="dpk-btn" data-action="add" @click=${()=>this.#h(o.id)}>
4961
4974
  ${e.addSubtopicButton}
4962
4975
  </button>
4963
- `:k`
4976
+ `:v`
4964
4977
  <input
4965
4978
  class="dpk-input"
4966
4979
  aria-label="${e.addSubtopicAriaLabel(o.label)}"
@@ -4969,10 +4982,10 @@ ${o.renameContextHint}`}
4969
4982
  @input=${r=>{const a=r.currentTarget;a instanceof HTMLInputElement&&(this.#t={...s,label:a.value,failed:!1})}}
4970
4983
  @keydown=${r=>this.#p(r,o.id)}
4971
4984
  />
4972
- ${s.failed?k`<span class="mind-actions-error" role="alert">${e.notRecorded}</span>`:T}
4985
+ ${s.failed?v`<span class="mind-actions-error" role="alert">${e.notRecorded}</span>`:T}
4973
4986
  `}
4974
4987
  </div>
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`
4988
+ `}#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(Na,["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 Fa=()=>{customElements.get("dpk-board-mind-map")||customElements.define("dpk-board-mind-map",qa)},Ua=(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],Ot=pe({en:{heading:"Sequence diagram",empty:"No matching messages.",participants:"Participants",stats:(t,e)=>`${t} / ${e} messages`,detailLabel:t=>Ua(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=>Ua(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`}}),Vg=P({kind:he("message"),id:S(k(),I(1)),from:S(k(),I(1)),to:S(k(),I(1)),title:S(k(),I(1)),style:L(G(["request","response","async"]),"request"),tags:L(F(k()),[]),guard:L(k()),detail:L(k()),questions:L(k())}),Qg=P({label:S(k(),I(1)),items:F(Mi())}),Zg=P({kind:he("fragment"),id:S(k(),I(1)),operator:G(["alt","opt","loop","par"]),title:S(k(),I(1)),collapsed:L(yt(),!1),branches:S(F(Qg),I(1))}),Jg=Gn("kind",[Vg,Zg]),ef=P({id:S(k(),I(1)),name:S(k(),I(1)),role:L(k()),symbol:L(k()),kind:L(G(["internal","external"]),"internal"),description:L(k()),questions:L(k())}),tf=P({participants:S(F(ef),I(1)),items:L(F(Mi()),[])}),Vo=240,Qo=(t,e,n)=>{if(t.has(e))throw new Error(`duplicate ${n} id: ${e}`);t.add(e)},Ba=(t,e,n)=>t.map(o=>{const i=ue(Jg,o);if(i.kind==="message"){if(Qo(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 Qo(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:Ba(r.items,e,n)}))}}),nf=t=>{const e=ue(tf,t),n=new Set;for(const o of e.participants)Qo(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:Ba(e.items,n,new Set)}},of=()=>({participants:[],items:[]}),Ha=(t,e)=>{for(const n of t)if(n.kind==="message")e.push(n);else for(const o of n.branches)Ha(o.items,e)},Ye=t=>{const e=[];return Ha(t,e),e},Ya=t=>new Map(Ye(t.items).map((e,n)=>[e.id,String(n+1).padStart(2,"0")])),sf=t=>Ye(t).length,Ga=(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:Ga(s.items,e)})).filter(s=>s.items.length>0);i.length>0&&n.push({...o,branches:i})}return n},rf=64,af=86,df=31,lf=32,cf=40,pf=(t,e)=>{const n=Ga(t.items,e),o=new Set;for(const m of Ye(n))o.add(m.from),o.add(m.to);const i=t.participants.filter(m=>o.has(m.id)),s=new Map(i.map((m,f)=>[m.id,120+f*Vo])),r=Math.max(360,i.length*Vo),a=[],d=[],l=[],c=[],h=[];let p=25;const u=(m,f)=>{for(const g of m){if(g.kind==="message"){a.push({message:g,y:p+29,depth:f}),p+=g.from===g.to?af:rf;continue}const b=22+f*13,y=p,x=r-44-f*26;p+=df,g.collapsed?(h.push({fragment:g,x:b,y:p+6,width:x}),p+=cf):g.branches.forEach((w,$)=>{$>0&&(c.push({x:b,y:p,width:x}),p+=8),l.push({label:w.label,x:b+12,y:p,width:x-24}),p+=lf,u(w.items,f+1),p+=8}),d.push({fragment:g,x:b,y,width:x,height:p-y,count:sf([g])}),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}},hf=de`
4976
4989
  .sequence::part(canvas) {
4977
4990
  background-image: none;
4978
4991
  }
@@ -4994,10 +5007,16 @@ ${o.renameContextHint}`}
4994
5007
  transform-origin: 0 0;
4995
5008
  }
4996
5009
 
5010
+ /*
5011
+ * A card keeps its size at any zoom (only its centre follows the lifeline),
5012
+ * and narrows only when zooming out brings the lifelines closer than it is wide.
5013
+ */
4997
5014
  .sequence-participant {
5015
+ --sequence-card-width: min(190px, calc(var(--sequence-pitch) * var(--sequence-scale, 1) - 12px));
4998
5016
  position: absolute;
4999
5017
  top: 9px;
5000
- width: 190px;
5018
+ left: calc(var(--sequence-center) * var(--sequence-scale, 1) - var(--sequence-card-width) / 2);
5019
+ width: var(--sequence-card-width);
5001
5020
  height: 44px;
5002
5021
  display: flex;
5003
5022
  align-items: center;
@@ -5274,21 +5293,26 @@ ${o.renameContextHint}`}
5274
5293
  fill: var(--dpk-ink);
5275
5294
  stroke: var(--dpk-ink);
5276
5295
  }
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`
5279
- <div class="sequence-rail" role="group" aria-label=${n.participants}>
5296
+ `,uf=[{id:"seq-request"},{id:"seq-response"},{id:"seq-async"},{id:"seq-related"},{id:"seq-selected"}];class Xa extends so{static{this.styles=[Ne,hf]}#o=null;#i=new Map;#e=new Map;#t=new Set;#n=new Set;#a="";#r=0;commentItems(){const e=this.items(),n=Ya(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(),nf(e)}emptyData(){return of()}defaultHeading(){return Ot(this.locale).heading}shellClass(){return"sequence"}emptyMessage(){return Ot(this.locale).empty}fitMode(){return"width"}onViewChange(e){const n=this.renderRoot.querySelector(".sequence-rail-world");n!==null&&(n.style.transform=`translateX(${e.x}px)`,n.style.setProperty("--sequence-scale",String(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?"":Ot(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=Ya(this.items()),this.#o=pf(e,r=>Ie(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(`
5297
+ `)||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=Ot(this.locale);return v`
5298
+ <div
5299
+ class="sequence-rail"
5300
+ role="group"
5301
+ aria-label=${n.participants}
5302
+ style="--sequence-pitch:${Vo}px"
5303
+ >
5280
5304
  <div class="sequence-rail-world">
5281
5305
  ${e.participants.map(o=>this.#l(o,e))}
5282
5306
  </div>
5283
5307
  </div>
5284
- `}#l(e,n){const o=n.x.get(e.id)??0,i=this.#u(e.id);return k`
5308
+ `}#l(e,n){const o=n.x.get(e.id)??0,i=this.#u(e.id);return v`
5285
5309
  <button
5286
5310
  type="button"
5287
5311
  class=${this.elementClass(i,"sequence-participant",e.external&&"is-external")}
5288
5312
  data-participant=${e.id}
5289
5313
  data-grill-questions=${this.questionsOf(e)}
5290
5314
  data-dpk-target=${this.commentRef("participant",e.id)}
5291
- style="left:${o-95}px"
5315
+ style="--sequence-center:${o}px"
5292
5316
  aria-pressed=${i.selected?"true":"false"}
5293
5317
  title=${e.description??e.name}
5294
5318
  @click=${()=>this.select({kind:"participant",id:e.id})}
@@ -5296,23 +5320,23 @@ ${o.renameContextHint}`}
5296
5320
  <span class="sequence-symbol" aria-hidden="true">${e.symbol??e.name.slice(0,2)}</span>
5297
5321
  <span class="sequence-names">
5298
5322
  <span class="sequence-name">${e.name}</span>
5299
- ${e.role===null?T:k`<span class="sequence-role">${e.role}</span>`}
5323
+ ${e.role===null?T:v`<span class="sequence-role">${e.role}</span>`}
5300
5324
  </span>
5301
5325
  </button>
5302
- `}renderCanvas(){const e=this.#o;if(e===null)return k``;const n=Dt(this.locale);return k`
5326
+ `}renderCanvas(){const e=this.#o;if(e===null)return v``;const n=Ot(this.locale);return v`
5303
5327
  ${this.#m(e,n)}
5304
- ${e.frames.map(o=>k`<div
5328
+ ${e.frames.map(o=>v`<div
5305
5329
  class="sequence-frame"
5306
5330
  style="left:${o.x}px; top:${o.y}px; width:${o.width}px; height:${o.height}px"
5307
5331
  ></div>`)}
5308
5332
  ${e.frames.map(o=>this.#g(o.fragment,o.x,o.y,o.width,o.count,n))}
5309
- ${e.branches.map(o=>k`<span
5333
+ ${e.branches.map(o=>v`<span
5310
5334
  class="sequence-branch"
5311
5335
  style="left:${o.x}px; top:${o.y}px; max-width:${o.width}px"
5312
5336
  title=${o.label}
5313
5337
  >[${o.label}]</span
5314
5338
  >`)}
5315
- ${e.folds.map(o=>{const i=o.fragment.branches.map(s=>`[${s.label}]`).join(" / ");return k`<span
5339
+ ${e.folds.map(o=>{const i=o.fragment.branches.map(s=>`[${s.label}]`).join(" / ");return v`<span
5316
5340
  class="sequence-fold"
5317
5341
  style="left:${o.x}px; top:${o.y}px; max-width:${o.width}px"
5318
5342
  title=${i}
@@ -5334,9 +5358,9 @@ ${o.renameContextHint}`}
5334
5358
  @keydown=${u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),p())}}></path>
5335
5359
  <path class="sequence-message is-${r.message.style}" d=${l} marker-end=${`url(#${h})`}></path>
5336
5360
  </g>
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`
5361
+ `});return v`<svg class="diagram-edges" width=${e.width} height=${e.height}>
5362
+ ${rs(uf)} ${o} ${i} ${s}
5363
+ </svg>`}#g(e,n,o,i,s,r){const a=this.#c(e);return v`
5340
5364
  <button
5341
5365
  type="button"
5342
5366
  class="sequence-frame-header"
@@ -5346,12 +5370,12 @@ ${o.renameContextHint}`}
5346
5370
  aria-label=${r.frameHeaderLabel(e.operator,e.title,a)}
5347
5371
  @click=${()=>this.#h(e)}
5348
5372
  >
5349
- <span class="sequence-frame-chevron">${a?nl():Ei()}</span>
5373
+ <span class="sequence-frame-chevron">${a?cl():Ci()}</span>
5350
5374
  <span class="sequence-operator">${e.operator}</span>
5351
5375
  <span class="sequence-text">${e.title}</span>
5352
5376
  <span class="sequence-frame-count">${r.frameCount(s)}</span>
5353
5377
  </button>
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`
5378
+ `}#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 v`
5355
5379
  <button
5356
5380
  type="button"
5357
5381
  class=${this.elementClass(d,"sequence-label")}
@@ -5366,7 +5390,7 @@ ${o.renameContextHint}`}
5366
5390
  <span class="sequence-number">${this.#i.get(n.id)??""}</span>
5367
5391
  <span class="sequence-text">${n.title}</span>
5368
5392
  </button>
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`
5393
+ `}}const Ka=()=>{customElements.get("dpk-board-sequence-diagram")||customElements.define("dpk-board-sequence-diagram",Xa)},Cn=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}`}}),mf=P({x:ce(),y:ce()}),gf=P({id:S(k(),I(1)),name:S(k(),I(1)),code:L(k()),kind:L(G(["normal","initial","terminal","compensation"]),"normal"),description:L(k()),position:L(mf),questions:L(k())}),ff=P({id:S(k(),I(1)),from:S(k(),I(1)),to:S(k(),I(1)),title:S(k(),I(1)),kind:L(G(["normal","exception"]),"normal"),tags:L(F(k()),[]),guard:L(k()),effect:L(k()),questions:L(k())}),ja={width:178,height:86},bf=()=>({nodes:[],edges:[]}),xf=P({states:F(gf),transitions:L(F(ff),[])}),yf=t=>{const e=ue(xf,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:ja.width,height:ja.height,tags:[],...r.position===void 0?{}:{position:r.position},...r.questions===void 0?{}:{questions:r.questions}})),edges:i}},kf=t=>t.length>0&&t.every(e=>e.position!==void 0),vf={portGap:16,laneGap:10,margin:12},wf=12,$f=14,Ef=18,Tf=14,Ln=22,In=18,Sf=4,Mf=10,Wa=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}}},Va=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),Zo=(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)}),Nt=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},Jo=t=>t.slice(1).map((e,n)=>[t[n],e]),Cf=(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",Lf=(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($f,(r.high-r.low)/2),d=r.low+a,l=r.high-a,c=[...r.members].sort((b,y)=>b.point.y-y.point.y||b.id.localeCompare(y.id)),h=b=>b.map((y,x)=>ws(d,l,b.length,x,o.laneGap)),p=(b,y)=>Nt([b.point,{x:y,y:b.point.y},{x:y,y:b.end.y},b.end]),u=b=>{const y=h(b);let x=0;for(let w=0;w<b.length;w++){const $=p(b[w],y[w]);for(let A=w+1;A<b.length;A++)x+=ao($,Jo(p(b[A],y[A])))}return x};let m=[...c],f=m.length>Mf?Number.POSITIVE_INFINITY:u(m);if(Number.isFinite(f))for(let b=0;b<Sf&&f>0;b++)for(let y=0;y+1<m.length;y++){const x=[...m],w=x[y];x[y]=x[y+1],x[y+1]=w;const $=u(x);$<f&&(f=$,m=x)}const g=h(m);m.forEach((b,y)=>s.set(b.id,g[y]))}return s},If=(t,e,n={})=>{const o={...vf,...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=$s(t.nodes,s,{inset:wf,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?Cf(A,C,$):"right"}}),a=Lf(s,i,r,o),d=new Map(t.routes.map(w=>[w.id,w.points])),l=new Map(t.nodes.map(w=>[w.id,Va(w)])),c=(w,$)=>t.nodes.filter(A=>A.id!==w.id&&A.id!==$.id).map(Va),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 m=[],f=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){f.set(w.id,M),m.push(...Jo(M));continue}const E=C.from.point,_=C.to.point,D=[l.get($.id),l.get(A.id)],O=c($,A),B=(()=>{if($.id===A.id){const ne=$.x+$.width;return Nt([E,{x:ne+Ln,y:E.y},{x:ne+Ln,y:_.y+Ln},{x:_.x,y:_.y+Ln},_])}if(C.from.side==="bottom"){const ne=Math.max(E.y,_.y)+Ef+u*Tf;return u+=1,Nt([E,{x:E.x,y:ne},{x:_.x,y:ne},_])}const q=a.get(w.id)??(E.x+_.x)/2,ee=Nt([E,{x:q,y:E.y},{x:q,y:_.y},_]);if(!Zo(ee,O))return ee;const Q=Wa(C.from.side),X=Wa(C.to.side),Z=po({x:E.x+Q.x*In,y:E.y+Q.y*In},{x:_.x+X.x*In,y:_.y+X.y*In},O,o.margin,m,[...D,...O],D);return Nt([E,...Z,_])})(),H=Zo(B,O)&&!Zo(M,O)?M:B;f.set(w.id,H),m.push(...Jo(H))}const g=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:f.get(w.id)??[],obstacles:$!==void 0&&A!==void 0?c($,A):[],ownFrames:C}}),b=uo(g,{minPortRun:0}),y=s.map(w=>({id:w.id,points:b.get(w.id)??f.get(w.id)??[]})),x=[...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,...x.map(w=>w.x)),height:Math.max(t.height,...x.map(w=>w.y)),routes:[...t.routes.filter(w=>!s.some($=>$.id===w.id)),...y]}},Af=de`
5370
5394
  .state-node {
5371
5395
  display: flex;
5372
5396
  flex-direction: column;
@@ -5524,19 +5548,19 @@ ${o.renameContextHint}`}
5524
5548
  fill: var(--dpk-amber);
5525
5549
  stroke: var(--dpk-amber);
5526
5550
  }
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)}
5551
+ `,_f=[{id:"state-arrow"},{id:"state-arrow-active"},{id:"state-arrow-exception"}];class Qa extends at{static{this.styles=[Ne,Af]}parseData(e){return yf(e)}emptyData(){return bf()}defaultHeading(){return Cn(this.locale).heading}statsLabels(){const e=Cn(this.locale);return{node:e.node,edge:e.edge}}emptyMessage(){return Cn(this.locale).empty}get tagDimension(){return"edge"}get layoutMode(){return kf(this.filtered().nodes)?"fixed":"layered"}layoutOptions(){return this.layoutMode==="fixed"?{padding:44}:{nodeSpacing:40,layerSpacing:110,padding:44}}routePlacement(e,n){return If(e,n.edges)}relations(e,n){if(e===null||e.kind!=="node")return Le;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 v`
5552
+ ${this.renderEdges([...n,...this.visible.edges.map(o=>this.#t(o))],_f)}
5529
5553
  ${e.map(o=>this.#n(o))} ${this.visible.edges.map(o=>this.#a(o))}
5530
5554
  `}#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(`
5531
5555
  `)||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
5556
  <g class=${ve("state-initial-mark",i.dimmed&&"is-dimmed")}>
5533
5557
  <circle cx=${n.x-22} cy=${o} r="5"></circle>
5534
5558
  <path
5535
- d=${nn([{x:n.x-17,y:o},{x:n.x-1,y:o}])}
5559
+ d=${on([{x:n.x-17,y:o},{x:n.x-1,y:o}])}
5536
5560
  stroke-width="1.6"
5537
5561
  ></path>
5538
5562
  </g>
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`
5563
+ `}#t(e){const n=Cn(this.locale),o=this.edgeState(e.id),i=this.routeOf(e.id),s=on(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`
5540
5564
  <g
5541
5565
  class=${this.elementClass(o,"d-edge","state-edge",e.kind==="exception"&&"is-exception")}
5542
5566
  data-transition=${e.id}
@@ -5553,7 +5577,7 @@ ${o.renameContextHint}`}
5553
5577
  @keydown=${l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),d())}}
5554
5578
  ></path>
5555
5579
  </g>
5556
- `}#n(e){const n=this.placedNode(e.id);if(!n)return T;const o=this.nodeState(e.id);return k`
5580
+ `}#n(e){const n=this.placedNode(e.id);if(!n)return T;const o=this.nodeState(e.id);return v`
5557
5581
  <button
5558
5582
  type="button"
5559
5583
  class=${this.elementClass(o,"d-node","state-node",`is-${e.kind}`,this.isDraggingNode(e.id)&&"is-dragging")}
@@ -5567,9 +5591,9 @@ ${o.renameContextHint}`}
5567
5591
  @click=${()=>{this.consumeDragClick()||this.select({kind:"node",id:e.id})}}
5568
5592
  >
5569
5593
  <span class="state-name">${e.name}</span>
5570
- ${e.code===null?T:k`<span class="state-code">${e.code}</span>`}
5594
+ ${e.code===null?T:v`<span class="state-code">${e.code}</span>`}
5571
5595
  </button>
5572
- `}#a(e){const n=this.edgeState(e.id),o=ul(this.routeOf(e.id));return k`
5596
+ `}#a(e){const n=this.edgeState(e.id),o=vl(this.routeOf(e.id));return v`
5573
5597
  <span class="state-label-slot" style="left:${o.x}px; top:${o.y}px">
5574
5598
  <button
5575
5599
  type="button"
@@ -5584,13 +5608,13 @@ ${o.renameContextHint}`}
5584
5608
  ${e.title}
5585
5609
  </button>
5586
5610
  </span>
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
5611
+ `}}const Za=()=>{customElements.get("dpk-board-state-diagram")||customElements.define("dpk-board-state-diagram",Qa)},ei=["yellow","orange","pink","purple","blue","green","gray"],Rf=["rect","ellipse"],ti=["small","medium","large","xlarge"],An="medium",Ja=["arrow","line"],_n=["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"},ed=S(ce(),Kt()),Xe=S(ce(),Kt(),Xt(Rn)),ni=G(ei),oi=L(G(ti),An),Dn={id:oe,x:ed,y:ed,questions:nt},Df=P({...Dn,kind:he("sticky"),w:L(Xe,Ge.sticky.w),h:L(Xe,Ge.sticky.h),text:L(k(),""),color:L(ni,mt.sticky),fontSize:oi}),Of=P({...Dn,kind:he("text"),w:L(Xe,Ge.text.w),h:L(Xe,Ge.text.h),text:L(k(),""),fontSize:oi}),Nf=P({...Dn,kind:he("shape"),shape:L(G(Rf),"rect"),w:L(Xe,Ge.shape.w),h:L(Xe,Ge.shape.h),text:L(k(),""),color:L(ni,mt.shape),fontSize:oi}),zf=P({...Dn,kind:he("frame"),w:Xe,h:Xe,title:S(k(),I(1)),color:L(ni,mt.frame)}),td=Gn("kind",[Df,Of,Nf,zf]),Pf=P({id:oe,from:S(k(),I(1)),to:S(k(),I(1)),label:j(k()),style:L(G(Ja),"arrow"),route:L(G(_n),"straight")}),qf=P({title:j(k()),items:L(F(td),[]),connectors:L(F(Pf),[])}),Ff=t=>{const e=ue(qf,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},Uf=()=>({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)},ii=t=>[...t.items.map(e=>e.id),...t.connectors.map(e=>e.id)],Je=t=>t.kind==="frame"?t.title:t.text,On=t=>t.kind!=="text",zt=t=>t.kind!=="frame",Nn=t=>t.w*t.h,Bf=(t,e,n)=>e>=t.x&&e<=t.x+t.w&&n>=t.y&&n<=t.y+t.h,Pt=(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"&&Nn(s)<=Nn(e)||Bf(s,n,o)&&(i===void 0||Nn(s)<Nn(i))&&(i=s);return i},Hf=(t,e)=>{const n=[],o=i=>{let s=Pt(t,i);for(;s!==void 0;){if(s.id===e.id)return!0;s=Pt(t,s)}return!1};for(const i of t.items)i.id!==e.id&&o(i)&&n.push(i);return n},nd=S(ce(),Kt()),od=S(ce(),Kt(),Xt(Rn)),id={type:"page",id:"whiteboard"},si={ADD_ITEM:z("ADD_ITEM","page",td,{dedupeKey:Me}),SET_ITEM_TEXT:z("SET_ITEM_TEXT","item",R({text:k()})),MOVE_ITEM:z("MOVE_ITEM","item",R({x:nd,y:nd})),RESIZE_ITEM:z("RESIZE_ITEM","item",R({w:od,h:od})),SET_ITEM_COLOR:z("SET_ITEM_COLOR","item",R({color:G(ei)})),SET_ITEM_FONT_SIZE:z("SET_ITEM_FONT_SIZE","item",R({fontSize:G(ti)})),REORDER_ITEM:z("REORDER_ITEM","item",R({after:me(S(k(),I(1)))})),DELETE_ITEM:z("DELETE_ITEM","item",R({})),CONNECT_ITEMS:z("CONNECT_ITEMS","page",R({id:oe,from:S(k(),I(1)),to:S(k(),I(1)),label:j(k()),style:j(G(Ja)),route:j(G(_n))}),{dedupeKey:Me}),SET_CONNECTOR_LABEL:z("SET_CONNECTOR_LABEL","connector",R({label:k()})),SET_CONNECTOR_ROUTE:z("SET_CONNECTOR_ROUTE","connector",R({route:G(_n)})),DELETE_CONNECTOR:z("DELETE_CONNECTOR","connector",R({}))},et=t=>({type:"item",id:t}),ae={addItem:t=>({type:"ADD_ITEM",target:id,payload:t}),setText:(t,e)=>({type:"SET_ITEM_TEXT",target:et(t),payload:{text:e}}),move:(t,e,n)=>({type:"MOVE_ITEM",target:et(t),payload:{x:e,y:n}}),resize:(t,e,n)=>({type:"RESIZE_ITEM",target:et(t),payload:{w:e,h:n}}),setColor:(t,e)=>({type:"SET_ITEM_COLOR",target:et(t),payload:{color:e}}),setFontSize:(t,e)=>({type:"SET_ITEM_FONT_SIZE",target:et(t),payload:{fontSize:e}}),reorder:(t,e)=>({type:"REORDER_ITEM",target:et(t),payload:{after:e}}),deleteItem:t=>({type:"DELETE_ITEM",target:et(t),payload:{}}),connect:(t,e,n,o)=>({type:"CONNECT_ITEMS",target:id,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:{}})},zn=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}},sd=t=>[...t.items.filter(e=>e.kind==="frame"),...t.items.filter(e=>e.kind!=="frame")],Yf=t=>t.kind==="shape"&&t.shape==="ellipse",Pn=(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=Yf(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}),Gf=(t,e)=>{const n=Pn(t,gt(e)),o=Pn(e,gt(t));return{start:n,end:o,mid:{x:(n.x+o.x)/2,y:(n.y+o.y)/2}}},Ee=t=>`${t.x} ${t.y}`,ri=(t,e,n)=>{if(n==="straight"){const{start:m,end:f,mid:g}=Gf(t,e);return{d:`M ${Ee(m)} L ${Ee(f)}`,mid:g}}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=(m,f)=>{const g=gt(m);return s?{x:f?m.x+m.w:m.x,y:g.y}:{x:g.x,y:f?m.y+m.h:m.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 ${Ee(d)} L ${Ee(h)} L ${Ee(p)} L ${Ee(l)}`:`M ${Ee(d)} C ${Ee(h)} ${Ee(p)} ${Ee(l)}`,mid:c}},ai=(t,e)=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h,Xf=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,Kf=(t,e)=>t.items.filter(n=>n.kind==="frame"&&ai(n,e)).sort((n,o)=>n.w*n.h-o.w*o.h),rd=(t,e,n)=>{const o=sd(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")&&ai(r,e))return r}let i;for(const s of o)s.kind!=="frame"||s.id===n||!ai(s,e)||(i===void 0||s.w*s.h<i.w*i.h)&&(i=s);return i},jf=(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)}),Wf=(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,Vf=(t,e)=>t.items.filter(n=>n.kind==="frame"?Wf(e,n):qn(e,n,0)),qn=(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,Qf=(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=>qn(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}},ad=["front","forward","backward","back"],dd=t=>t.items.filter(e=>e.kind!=="frame"),ld=(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=>qn(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)]},cd=(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)=>ld(s,r,e,!0),[...t]);case"backward":return o.reduce((s,r)=>ld(s,r,e,!1),[...t])}},Zf=(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},Jf=(t,e,n)=>{const o=dd(t),i=new Set(e.filter(s=>o.some(r=>r.id===s)));return i.size===0?[]:Zf(o,cd(o,i,n),i)},eb=(t,e)=>{const n=dd(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)&&qn(r,a,0)).map(a=>[r,a]):[]),s=(r,[a,d])=>r.indexOf(a)>r.indexOf(d);return new Set(ad.filter(r=>{const a=cd(n,o,r);return i.some(d=>s(n,d)!==s(a,d))}))},pd=(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}},tb=(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 pd(t,r.offsetNode,r.offset)}if(typeof i.caretRangeFromPoint=="function"){const s=i.caretRangeFromPoint(e,n);if(s!==null)return pd(t,s.startContainer,s.startOffset)}},nb=["sticky","text","rect","ellipse","frame"],ob=t=>t==="rect"||t==="ellipse"?Ge.shape:Ge[t],ib=(t,e,n,o)=>{const{w:i,h:s}=ob(n),r={x:Math.round(o.x-i/2),y:Math.round(o.y-s/2)},a=Qf(t,{...r,w:i,h:s},n==="frame"),c={id:ke(`new-${n==="rect"||n==="ellipse"?"shape":n}`,ii(t)),x:a.x,y:a.y,w:i,h:s};switch(n){case"sticky":return{...c,kind:"sticky",text:"",color:mt.sticky,fontSize:An};case"text":return{...c,kind:"text",text:"",fontSize:An};case"rect":case"ellipse":return{...c,kind:"shape",shape:n,text:"",color:mt.shape,fontSize:An};case"frame":return{...c,kind:"frame",title:e.newFrameTitle,color:mt.frame}}},sb=(t,e,n)=>ke(`${e}-to-${n}`,ii(t)),rb=24,ab=(t,e,n)=>{const o=new Set(ii(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}})},db=(t,e)=>{const n=(t.kind==="frame"?e.replace(/\r?\n/g," "):e).trim();if(!(t.kind==="frame"&&n===""))return n===Je(t)?void 0:n},Fn=4,lb={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}},di=(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,...Hf(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}},cb=(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}},pb=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),hb=(t,e)=>({gesture:{...t,last:e,moved:t.moved||Math.hypot(e.x-t.start.x,e.y-t.start.y)>Fn},dx:e.x-t.last.x,dy:e.y-t.last.y}),hd=(t,e,n)=>({kind:"marquee",pointerId:t,base:n,start:e,current:e,moved:!1}),ub=(t,e,n,o,i)=>{const s=Kf(t,o).find(a=>e.includes(a.id));return(s===void 0?void 0:di(t,s.id,n,o,e))??hd(n,o,i)},ud=t=>t?.kind==="marquee"&&t.moved?jf(t.start,t.current):void 0,md=(t,e)=>{const n=ud(e);if(e.kind!=="marquee"||n===void 0)return[];const o=Vf(t,n).map(i=>i.id);return[...new Set([...e.base,...o])]},mb=(t,e,n)=>({kind:"connect",pointerId:e,fromId:t,start:n,current:n,moved:!1}),li=(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>Fn;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>Fn;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>Fn,a=rd(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}}}},qt=t=>Math.round(t),gd=(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:qt(r.x+n),y:qt(r.y+o)}})}}if(e.kind==="resize"){const n=bd(e);return{...t,items:t.items.map(o=>o.id===e.itemId?{...o,...n}:o)}}return t},fd=t=>Math.max(Rn,qt(t)),gb=(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:qt(t.w*o),h:qt(t.h*o)}},bd=t=>{const{origin:e,edge:n}=t,o=lb[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?gb(e,r,a):{w:r===void 0?e.w:fd(r),h:a===void 0?e.h:fd(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}},fb=(t,e,n,o)=>{const[i]=e;if(i===void 0)return[];const s=di(t,i,0,{x:0,y:0},e);if(s?.kind!=="move")return[];const r=xd(t,{...s,current:{x:n,y:o},moved:!0});return r.kind==="dispatch"?r.inputs:[]},xd=(t,e)=>{switch(e.kind){case"pan":return e.moved?{kind:"none"}:{kind:"click"};case"marquee":{if(e.moved)return{kind:"select",ids:md(t,e)};const n=rd(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=gd(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=bd(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}}},Un=.1,bb=2.5,xb={x:0,y:0,zoom:1},yb=96,ci=(t,e)=>({x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}),pi=(t,e)=>({x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}),hi=(t,e,n)=>({...t,x:t.x+e,y:t.y+n}),yd=(t,e,n)=>{const o=kt(t.zoom*n,Un,bb),i=ci(t,e);return{zoom:o,x:e.x-i.x*o,y:e.y-i.y*o}},kb=(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)),Un,o);return{zoom:r,x:e.width/2-(t.x+t.w/2)*r,y:e.height/2-(t.y+t.h/2)*r}},vb=(t,e,n=48)=>{const o=zn(t);if(o===null)return null;const i=Math.max(1,e.width-n*2)/Un,s=Math.max(1,e.height-n*2)/Un;if(o.w<=i&&o.h<=s)return o;const r=Ri(t.map(l=>l.x+l.w/2)),a=Ri(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 zn(d)??o},wb=(t,e,n)=>{if(e===null||n.width<=0||n.height<=0)return t;const o=(i,s,r,a)=>{const d=Math.min(yb,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)}},$b=(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}},kd=(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},Eb=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,Tb={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"},Ke={sticky:"sticky note",text:"text box",shape:"shape",frame:"frame"},Sb={rect:"Rectangle",ellipse:"Ellipse"},Mb={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},Cb={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},Lb={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},Ib={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},Ab={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},_b={straight:"Straight",elbow:"Elbow",curve:"Curved"},Rb={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},vd={small:"S",medium:"M",large:"L",xlarge:"XL"},Ft=pe({en:{kindLabel:t=>Tb[t],shapeLabel:t=>Sb[t],colorLabel:t=>Cb[t],fontSizeLabel:t=>Ib[t],fontSizeShort:t=>vd[t],routeLabel:t=>_b[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=>Re[t],shapeLabel:t=>Mb[t],colorLabel:t=>Lb[t],fontSizeLabel:t=>Ab[t],fontSizeShort:t=>vd[t],routeLabel:t=>Rb[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"}}),wd=40,ft=(t,e)=>{const n=e.replace(/\s+/g," ").trim();return n===""?t.empty:n.length>wd?`${n.slice(0,wd-1)}\u2026`:n},$d=(t,e)=>`${e.kind==="shape"?t.shapeLabel(e.shape):t.kindLabel(e.kind)} \xB7 ${ft(t,Je(e))}`,tt=(t,e,n,o)=>{const i=W(e,o)??W(n,o);return i===void 0?o:ft(t,Je(i))},Ed=(t,e,n,o=e)=>`${t.connector} \xB7 ${t.connection(tt(t,e,o,n.from),tt(t,e,o,n.to))}`,Db=(t,e,n,o,i)=>{const s=n===void 0?void 0:Pt(i,n),r=Pt(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)},Ob=(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=Pt(n,d),c=t.added(ft(t,Je(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,Je(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:Db(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&&On(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&&zt(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(tt(t,n,o,d))}}case"DELETE_ITEM":return{title:t.deletedTitle(a),tone:"delete",body:t.deleted(r===void 0?i:ft(t,Je(r)))};case"CONNECT_ITEMS":{const d=e.payload,l=t.connection(tt(t,n,o,d.from),tt(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(tt(t,n,o,d.from),tt(t,n,o,d.to))}}}}},Td=(t,e,n,o=n)=>{let i;try{const s=Yt(si,e);i=s===null?{title:e.type,tone:"meta"}:Ob(t,s,n,o)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:Nb(t,n,e.target,o),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},Nb=(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)`:$d(t,i)}case"connector":{const i=xe(e,n.id)??xe(o,n.id);return i===void 0?`${t.connector} \xB7 ${n.id} (missing)`:Ed(t,e,i,o)}case"page":return`${t.board} \xB7 ${e.title??"Whiteboard"}`;default:return`${n.type} \xB7 ${n.id}`}},zb=(t,e)=>{const n=Yt(si,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 Ut(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 Ut(t,o,i=>({...i,x:n.payload.x,y:n.payload.y}));case"RESIZE_ITEM":return Ut(t,o,i=>({...i,w:n.payload.w,h:n.payload.h}));case"SET_ITEM_COLOR":return Ut(t,o,i=>i.kind==="text"?null:{...i,color:n.payload.color});case"SET_ITEM_FONT_SIZE":return Ut(t,o,i=>i.kind==="frame"?null:{...i,fontSize:n.payload.fontSize});case"REORDER_ITEM":return Pb(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 jn(n)}},Ut=(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)}},Pb=(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)}},qb=t=>t==="comment"?"meta":t,Fb=t=>{const e=Oe(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}},Ub=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=Td(t,s,o).title;if(!(s.type in si)){i.push({id:s.id,title:r,stale:"unsupported-action-type"});continue}const a=Fb(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=zb(o,d);if(l===null){i.push({id:s.id,title:r,stale:"constraint-violated"});continue}const c=Td(t,d,l,o);i.push({id:s.id,title:c.title,tone:qb(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},De={kind:"idle"},bt=(t,e)=>t.kind==="editing"&&t.itemId===e,Bb={front:Ce(Ll),forward:Ce(hl),backward:Ce(pl),back:Ce(_l)},Md=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}]],Hb={straight:Ce([...Md,["path",{d:"M6.5 17.5 17.5 6.5"}]]),elbow:Ce([...Md,["path",{d:"M7 19h5V5h5"}]]),curve:Ce(Rl)},Yb=t=>Bb[t](),Gb=t=>Hb[t](),Xb=Ce(Il),Kb=Ce(Al),jb={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"}},Cd=t=>{const{paper:e,ink:n,stroke:o}=jb[t];return`--wb-paper:${e};--wb-ink:${n};--wb-stroke:${o}`},Ld={sticky:"addSticky",text:"addText",rect:"addRect",ellipse:"addEllipse",frame:"addFrame"},Id={small:.8,medium:1,large:1.4,xlarge:2},Wb=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},Vb=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=sd(n);return v`<div
5588
5612
  class=${r.join(" ")}
5589
5613
  data-testid="wb-canvas"
5590
5614
  tabindex="0"
5591
5615
  role="application"
5592
5616
  aria-label=${e.canvasLabel}
5593
- style=${_b(o)}
5617
+ style=${Wb(o)}
5594
5618
  @pointerdown=${s.canvasPointerDown}
5595
5619
  @pointermove=${s.canvasPointerMove}
5596
5620
  @pointerup=${s.canvasPointerUp}
@@ -5605,27 +5629,27 @@ ${o.renameContextHint}`}
5605
5629
  class="wb-world"
5606
5630
  style=${`transform:translate(${o.x}px, ${o.y}px) scale(${o.zoom});--wb-zoom:${o.zoom}`}
5607
5631
  >
5608
- ${Me(a,d=>d.id,d=>zb(t,d))}
5609
- ${Ub(t)} ${Bb(t)}
5632
+ ${Se(a,d=>d.id,d=>Jb(t,d))}
5633
+ ${ox(t)} ${ix(t)}
5610
5634
  </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
5635
+ ${n.items.length===0?v`<p class="wb-hint wb-hint--empty">${e.emptyHint}</p>`:T}
5636
+ ${Qb(t)} ${i?.moved===!0?T:t.overlay} ${sx(e,s)}
5637
+ ${rx(e,o,s)}
5638
+ </div>`},Qb=({marquee:t,viewport:e})=>{if(t===void 0)return T;const n=pi(e,t),o=`width:${t.w*e.zoom}px;height:${t.h*e.zoom}px`;return v`<div
5615
5639
  class="wb-marquee"
5616
5640
  aria-hidden="true"
5617
5641
  style=${`left:${n.x}px;top:${n.y}px;${o}`}
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)}
5642
+ ></div>`},Zb=(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(" ")},Jb=(t,e)=>{const{handlers:n}=t,o=`left:${e.x}px;top:${e.y}px;width:${e.w}px;height:${e.h}px`,i=On(e)?`;${Cd(e.color)}`:"",s=zt(e)?`;--wb-font-scale:${Id[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 v`<div
5643
+ class=${Zb(t,e)}
5620
5644
  style=${`${o}${i}${s}`}
5621
5645
  data-item-id=${e.id}
5622
5646
  data-dpk-target=${t.commentRef("item",e.id)}
5623
- data-grill-questions=${Wt(Yt(e.questions))}
5647
+ data-grill-questions=${Vt(Gt(e.questions))}
5624
5648
  data-kind=${e.kind}
5625
5649
  @pointerdown=${e.kind==="frame"?T:d}
5626
5650
  >
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}>
5651
+ ${e.kind==="frame"?v`<div class="wb-frame-title" @pointerdown=${d}>${Ad(t,e)}</div>`:v`<div class="wb-item-body">${Ad(t,e)}</div>`}
5652
+ ${e.kind==="frame"?T:v`<div class="wb-item-actions" @pointerdown=${xt} @click=${xt}>
5629
5653
  <button
5630
5654
  class="dpk-icon-btn"
5631
5655
  type="button"
@@ -5634,16 +5658,16 @@ ${o.renameContextHint}`}
5634
5658
  aria-label=${t.m.comment}
5635
5659
  @click=${()=>t.onComment(e.id)}
5636
5660
  >
5637
- ${Xn()}
5661
+ ${Kn()}
5638
5662
  </button>
5639
5663
  </div>`}
5640
- ${a?k`${Pb.map(l=>k`<span
5664
+ ${a?v`${ex.map(l=>v`<span
5641
5665
  class=${`wb-edge wb-edge--${l}`}
5642
5666
  role="presentation"
5643
5667
  aria-hidden="true"
5644
5668
  @pointerdown=${c=>n.resizePointerDown(e.id,c,l)}
5645
5669
  ></span>`)}`:T}
5646
- ${r?k`<span
5670
+ ${r?v`<span
5647
5671
  class="wb-handle wb-handle--resize"
5648
5672
  role="presentation"
5649
5673
  title=${t.m.resizeHandle}
@@ -5655,7 +5679,7 @@ ${o.renameContextHint}`}
5655
5679
  title=${t.m.connectHandle}
5656
5680
  @pointerdown=${l=>n.connectPointerDown(e.id,l)}
5657
5681
  ></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"
5682
+ </div>`},ex=["n","e","s","w","ne","sw","nw"],tx=t=>t.stopPropagation(),Ad=(t,e)=>{const{m:n,handlers:o}=t,i=Je(e);if(!bt(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"
5659
5683
  ><span class="wb-text" aria-hidden="true" data-copy=${i||n.textPlaceholder}></span
5660
5684
  ><input
5661
5685
  class="wb-editor"
@@ -5666,7 +5690,7 @@ ${o.renameContextHint}`}
5666
5690
  @input=${a}
5667
5691
  @blur=${s}
5668
5692
  @keydown=${r}
5669
- /></span>`:k`<textarea
5693
+ /></span>`:v`<textarea
5670
5694
  class="wb-editor"
5671
5695
  .value=${i}
5672
5696
  placeholder=${n.textPlaceholder}
@@ -5674,54 +5698,54 @@ ${o.renameContextHint}`}
5674
5698
  spellcheck="false"
5675
5699
  @blur=${s}
5676
5700
  @keydown=${r}
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">
5701
+ @wheel=${tx}
5702
+ ></textarea>`},nx=()=>Y`<marker id="wb-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">
5679
5703
  <path d="M0,0 L10,5 L0,10 z"></path>
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">
5704
+ </marker>`,_d=(t,e)=>{const n=W(t,e.from),o=W(t,e.to);return n===void 0||o===void 0?void 0:[n,o]},Rd=t=>t.label!==void 0,Dd=(t,e,n)=>Rd(e)===n?t.commentRef("connector",e.id):T,ox=t=>{const{state:e,handlers:n,gesture:o}=t,i=e.connectors.map(r=>{const a=_d(e,r);if(a===void 0)return T;const{d}=ri(...a,r.route),l=t.selectedIds.has(r.id)?" is-selected":"";return Y`<g data-connector-id=${r.id} data-dpk-target=${Dd(t,r,!1)} data-dpk-check="off">
5681
5705
  <path class="wb-link-hit" d=${d} @pointerdown=${c=>n.connectorPointerDown(r.id,c)}></path>
5682
5706
  <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>
5707
+ </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:Pn(a,gt(r)),l=Pn(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">
5708
+ <defs>${nx()}</defs>
5685
5709
  ${i} ${s}
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
5710
+ </svg>`},ix=t=>{const{state:e,handlers:n}=t;return e.connectors.flatMap(o=>{const i=_d(e,o);if(i===void 0||!Rd(o))return[];const{mid:s}=ri(...i,o.route),r=t.selectedIds.has(o.id)?" is-selected":"";return[v`<div
5687
5711
  class=${`wb-link-label${r}`}
5688
5712
  data-connector-label=${o.id}
5689
- data-dpk-target=${Sd(t,o,!0)}
5713
+ data-dpk-target=${Dd(t,o,!0)}
5690
5714
  data-dpk-check="off"
5691
5715
  style=${`left:${s.x}px;top:${s.y}px`}
5692
5716
  @pointerdown=${a=>n.connectorPointerDown(o.id,a)}
5693
5717
  >
5694
5718
  ${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
5719
+ </div>`]})},xt=t=>t.stopPropagation(),sx=(t,e)=>v`<div class="wb-tools" role="toolbar" aria-label=${t.toolsLabel} @pointerdown=${xt} @dblclick=${xt}>
5720
+ ${nb.map(n=>v`<button
5697
5721
  type="button"
5698
5722
  class="wb-tool"
5699
5723
  data-add=${n}
5700
- title=${t[vd[n]]}
5701
- aria-label=${t[vd[n]]}
5724
+ title=${t[Ld[n]]}
5725
+ aria-label=${t[Ld[n]]}
5702
5726
  @click=${()=>e.addItem(n)}
5703
5727
  >
5704
5728
  <span class=${`wb-tool-icon wb-tool-icon--${n}`} aria-hidden="true"></span>
5705
5729
  </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>
5730
+ </div>`,rx=(t,e,n)=>v`<div class="wb-zoom" @pointerdown=${xt} @dblclick=${xt}>
5731
+ <button type="button" aria-label=${t.zoomOut} @click=${()=>n.zoomStep(-1)}>${ul()}</button>
5708
5732
  <button type="button" class="wb-zoom-pct" title=${t.zoomReset} @click=${()=>n.zoomReset()}>
5709
5733
  ${Math.round(e.zoom*100)}%
5710
5734
  </button>
5711
- <button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${Gn()}</button>
5735
+ <button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${Xn()}</button>
5712
5736
  <button type="button" aria-label=${t.zoomFit} title=${t.zoomFit} @click=${()=>n.zoomFit()}>
5713
- ${Ab()}
5737
+ ${Kb()}
5714
5738
  </button>
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
5739
+ </div>`,ui={item:14,frame:40,connector:18},ax=t=>{const{selection:e,viewport:n,state:o}=t;if(e.kind==="items"){const a=zn(e.items);if(a===null)return;const d=e.items.some(c=>c.kind==="frame"&&c.y===a.y),l=pi(n,{x:a.x+a.w/2,y:a.y});return{x:l.x,y:l.y-(d?ui.frame:ui.item)}}const i=W(o,e.connector.from),s=W(o,e.connector.to);if(i===void 0||s===void 0)return;const r=pi(n,ri(i,s,e.connector.route).mid);return{x:r.x,y:r.y-ui.connector}},mi=t=>t.stopPropagation(),Bn=v`<span class="wb-toolbar-sep" aria-hidden="true"></span>`,Od=t=>t.length>0&&t.every(e=>e===t[0])?t[0]:void 0,dx=t=>{const e=ax(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 v`<div
5716
5740
  class="wb-toolbar"
5717
5741
  role="toolbar"
5718
5742
  aria-label=${s}
5719
5743
  style=${`left:${e.x}px;top:${e.y}px`}
5720
- @pointerdown=${ci}
5721
- @dblclick=${ci}
5722
- @keydown=${ci}
5744
+ @pointerdown=${mi}
5745
+ @dblclick=${mi}
5746
+ @keydown=${mi}
5723
5747
  >
5724
- ${o.kind==="items"?jb(t,o.items):Vb(t,o.connector)}
5748
+ ${o.kind==="items"?cx(t,o.items):hx(t,o.connector)}
5725
5749
  <button
5726
5750
  type="button"
5727
5751
  class="dpk-icon-btn wb-toolbar-btn"
@@ -5730,25 +5754,25 @@ ${o.renameContextHint}`}
5730
5754
  title=${n.delete}
5731
5755
  @click=${()=>i.deleteSelection()}
5732
5756
  >
5733
- ${Bt()}
5757
+ ${Ht()}
5734
5758
  </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
5759
+ </div>`},lx={front:"\u2318/Ctrl ]",forward:"]",backward:"[",back:"\u2318/Ctrl ["},cx=(t,e)=>{const{m:n,handlers:o}=t,i=e.filter(On).map(d=>d.color),s=e.flatMap(d=>zt(d)?[d.fontSize]:[]),r=Od(i),a=Od(s);return v`
5760
+ ${i.length>0?v`<div class="wb-swatches" role="radiogroup" aria-label=${n.colorLabelPrefix}>
5761
+ ${ei.map(d=>v`<button
5738
5762
  type="button"
5739
5763
  class="wb-swatch"
5740
5764
  role="radio"
5741
5765
  data-color=${d}
5742
- style=${kd(d)}
5766
+ style=${Cd(d)}
5743
5767
  aria-checked=${String(r===d)}
5744
5768
  aria-label=${`${n.colorLabelPrefix}: ${n.colorLabel(d)}`}
5745
5769
  title=${n.colorLabel(d)}
5746
5770
  @click=${()=>o.setColor(d)}
5747
5771
  ></button>`)}
5748
5772
  </div>
5749
- ${Un}`:T}
5750
- ${s.length>0?k`<div class="wb-choice" role="radiogroup" aria-label=${n.fontSizeLabelPrefix}>
5751
- ${Qo.map(d=>k`<button
5773
+ ${Bn}`:T}
5774
+ ${s.length>0?v`<div class="wb-choice" role="radiogroup" aria-label=${n.fontSizeLabelPrefix}>
5775
+ ${ti.map(d=>v`<button
5752
5776
  type="button"
5753
5777
  class="wb-choice-btn"
5754
5778
  role="radio"
@@ -5761,9 +5785,9 @@ ${o.renameContextHint}`}
5761
5785
  ${n.fontSizeShort(d)}
5762
5786
  </button>`)}
5763
5787
  </div>
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()}}>
5788
+ ${Bn}`:T}
5789
+ ${t.arrange.size>0?v`${px(t)} ${Bn}`:T}
5790
+ `},px=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()}}>
5767
5791
  <button
5768
5792
  type="button"
5769
5793
  class="wb-menu-btn"
@@ -5774,10 +5798,10 @@ ${o.renameContextHint}`}
5774
5798
  title=${e.arrangeLabel}
5775
5799
  @click=${()=>n.toggleArrangeMenu()}
5776
5800
  >
5777
- ${Ib()} ${Ei()}
5801
+ ${Xb()} ${Ci()}
5778
5802
  </button>
5779
- ${t.arrangeMenuOpen?k`<div class="wb-menu" role="menu" aria-label=${e.arrangeLabel}>
5780
- ${Ja.map(s=>k`<button
5803
+ ${t.arrangeMenuOpen?v`<div class="wb-menu" role="menu" aria-label=${e.arrangeLabel}>
5804
+ ${ad.map(s=>v`<button
5781
5805
  type="button"
5782
5806
  class="wb-menu-item"
5783
5807
  role="menuitem"
@@ -5785,13 +5809,13 @@ ${o.renameContextHint}`}
5785
5809
  ?disabled=${!t.arrange.has(s)}
5786
5810
  @click=${()=>n.arrange(s)}
5787
5811
  >
5788
- ${Cb(s)}
5812
+ ${Yb(s)}
5789
5813
  <span class="wb-menu-label">${o[s]}</span>
5790
- <kbd class="wb-menu-key">${Kb[s]}</kbd>
5814
+ <kbd class="wb-menu-key">${lx[s]}</kbd>
5791
5815
  </button>`)}
5792
5816
  </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
5817
+ </div>`},hx=(t,e)=>{const{m:n,handlers:o}=t;return v`<div class="wb-choice" role="radiogroup" aria-label=${n.routeLabelPrefix}>
5818
+ ${_n.map(i=>v`<button
5795
5819
  type="button"
5796
5820
  class="wb-choice-btn wb-choice-btn--icon"
5797
5821
  role="radio"
@@ -5801,17 +5825,17 @@ ${o.renameContextHint}`}
5801
5825
  title=${n.routeLabel(i)}
5802
5826
  @click=${()=>o.setRoute(e.id,i)}
5803
5827
  >
5804
- ${Lb(i)}
5828
+ ${Gb(i)}
5805
5829
  </button>`)}
5806
5830
  </div>
5807
- ${Un}
5831
+ ${Bn}
5808
5832
  <dpk-inline-edit
5809
5833
  class="wb-toolbar-label"
5810
5834
  .value=${e.label??""}
5811
5835
  .placeholder=${n.labelPlaceholder}
5812
5836
  .label=${n.labelField}
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`
5837
+ @dpk-commit=${ot(i=>o.setLabel(e.id,i))}
5838
+ ></dpk-inline-edit>`},Nd=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],ux=de`
5815
5839
  /*
5816
5840
  * The shell (\`<dpk-dialog-panel class="whiteboard">\`) is a panel: header, tag
5817
5841
  * row, canvas; \`--dpk-dialog-panel-height\` is the knob it reads for its own
@@ -6679,7 +6703,7 @@ ${o.renameContextHint}`}
6679
6703
  outline: 2px solid var(--dpk-blue);
6680
6704
  outline-offset: 1px;
6681
6705
  }
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`
6706
+ `,mx=10,zd=8,Pd=72,gx=t=>t!==void 0,fx="whiteboard";class qd extends rt{constructor(){super(...arguments),this.mode=De,this.viewport=xb,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=[st,ux]}#o;#i;#e;#t;#n;#a;#r;#s;#d;#c;#h;#p;parseData(e){return Ff(e)}emptyData(){return Uf()}reduceElementActions(e,n){return Ub(Ft(this.locale),e,n)}defaultHeading(){return Ft(this.locale).heading}shellClass(){return"whiteboard"}commentItems(){const e=this.items(),n=Ft(this.locale);return[{value:this.commentRef("page",fx),label:n.wholeBoard},...e.items.map(o=>({value:this.commentRef("item",o.id),label:$d(n,o)})),...e.connectors.map(o=>({value:this.commentRef("connector",o.id),label:Ed(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=Ft(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject(),i=gd(this.items(),this.gesture),s=ud(this.gesture),r=s!==void 0&&this.gesture!==void 0?md(this.items(),this.gesture):this.selectedIds;return v`
6683
6707
  <dpk-dialog-panel
6684
6708
  class=${this.shellClass()}
6685
6709
  flush
@@ -6690,7 +6714,7 @@ ${o.renameContextHint}`}
6690
6714
  @dpk-maximize-change=${()=>this.closeComposer()}
6691
6715
  >
6692
6716
  ${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
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)}})}
6717
+ ${this.dataError!==null?v`<p class="wb-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:Vb({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.#z(a),canvasPointerMove:a=>this.#Y(a),canvasPointerUp:a=>this.#G(a),canvasPointerCancel:()=>{this.gesture=void 0,this.requestUpdate()},canvasWheel:a=>this.#R(a),canvasDblClick:a=>this.#L(a),canvasKeyDown:a=>this.#J(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.#_(a,d),resizePointerDown:(a,d,l)=>this.#F(a,d,l),connectPointerDown:(a,d)=>this.#P(d,mb(a,d.pointerId,this.#$(d))),connectorPointerDown:(a,d)=>this.#U(a,d),editBlur:(a,d)=>this.#S(a,d),editKeyDown:(a,d)=>this.#y(a,d),addItem:a=>this.#Q(a,this.#q()),zoomStep:a=>this.#D(a===1?1.2:1/1.2),zoomFit:()=>this.#te(),zoomReset:()=>this.#D(1/this.viewport.zoom)}})}
6694
6718
  </dpk-dialog-panel>
6695
6719
  ${this.renderSelection()}
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};
6720
+ `}updated(){super.updated();const e=this.#v();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.#v(),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=kd(c.left-o("x")-i.left,c.width,i.width,zd,l),p=kd(c.top-o("y")-i.top,c.height,i.height,zd);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(gx)}#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:dx({m:n,state:e,viewport:this.viewport,selection:r,arrange:eb(e,o),arrangeMenuOpen:this.arrangeMenu,handlers:{setColor:a=>this.#ee(a),setFontSize:a=>this.#j(a),arrange:a=>{this.arrangeMenu=!1,this.#W(a),this.requestUpdate()},toggleArrangeMenu:()=>{this.arrangeMenu=!this.arrangeMenu,this.requestUpdate()},deleteSelection:()=>this.#V(),setLabel:(a,d)=>this.#N(ae.setConnectorLabel(a,d)),setRoute:(a,d)=>{xe(e,a)?.route!==d&&this.#N(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:tb(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}#S(e,n){if(!bt(this.mode,e))return;this.mode=De,this.requestUpdate(),this.#n=void 0;const o=W(this.items(),e),i=o===void 0?void 0:db(o,n);o===void 0||i===void 0||this.#T([ae.setText(e,i),...this.#w(o)])}#w(e,n){if(!zt(e))return[];const o=Xf(e,this.#M(e.id,n));return o===void 0?[]:[ae.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(Id[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=De,this.requestUpdate();return}this.#S(e,n.value)}#y(e,n){if(n.isComposing)return;if(n.key==="Escape"){n.preventDefault(),this.mode=De,this.requestUpdate(),this.#E();return}const o=W(this.items(),e)?.kind==="frame";n.key==="Enter"&&(o||n.metaKey||n.ctrlKey)&&(n.preventDefault(),this.#E())}#v(){return this.renderRoot.querySelector(".wb-canvas")}#k(){const e=this.#v();return{width:e?.clientWidth??0,height:e?.clientHeight??0}}#C(e){const n=this.#v()?.getBoundingClientRect();return n===void 0?{x:e.clientX,y:e.clientY}:{x:e.clientX-n.left,y:e.clientY-n.top}}#$(e){return ci(this.viewport,this.#C(e))}#q(){const{width:e,height:n}=this.#k();return ci(this.viewport,{x:e/2,y:n/2})}#O(e,n){if(n===void 0)return;const o=this.#v();if(o!==null&&typeof o.setPointerCapture=="function")try{o.setPointerCapture(e.pointerId)}catch{}this.gesture=n,this.requestUpdate()}#E(){this.#v()?.focus({preventScroll:!0})}#z(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.#E(),n){e.preventDefault(),this.#r={on:"other"},this.#O(e,pb(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?hd(e.pointerId,this.#$(e),i):ub(o,i,e.pointerId,this.#$(e),[]);this.#s=!1,this.#d=s.kind==="move"&&i.length>1,this.#O(e,s)}#_(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.#E(),this.arrangeMenu=!1,this.mode.kind!=="idle"&&(this.mode=De);const o=this.items(),i=this.selectedIds;if(n.shiftKey){this.#s=!1,this.#d=!1,this.#l(Nd(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.#O(n,di(o,e,n.pointerId,this.#$(n),s))}#P(e,n){e.button===0&&(e.stopPropagation(),e.preventDefault(),this.#r={on:"other"},this.#b(),this.#E(),this.#O(e,n))}#F(e,n,o){o!==void 0&&this.panReady||this.#P(n,cb(this.items(),e,n.pointerId,this.#$(n),o))}#U(e,n){n.button!==0||this.panReady||(n.stopPropagation(),n.preventDefault(),this.#r={on:"other"},this.#b(),this.#E(),this.mode=De,this.#l([e]))}#Y(e){const n=this.gesture;if(!(n===void 0||n.pointerId!==e.pointerId)){if(n.kind==="pan"){const o=hb(n,this.#C(e));this.gesture=o.gesture,this.#I(hi(this.viewport,o.dx,o.dy)),this.requestUpdate();return}this.gesture=li(this.items(),n,e.pointerId,this.#$(e),this.viewport.zoom,e.shiftKey),this.requestUpdate()}}#B(e){const n=this.gesture;n?.kind!=="resize"||n.keepRatio===e||(this.gesture=li(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:li(o,n,e.pointerId,this.#$(e),this.viewport.zoom,e.shiftKey);this.gesture=void 0,this.requestUpdate();const s=xd(o,i);switch(s.kind){case"none":return;case"dispatch":this.#T(s.inputs);return;case"connect":this.#X(s.from,s.to);return;case"select":this.#l(s.ids);return;case"click":if(i.kind==="pan"||i.kind==="marquee"){this.mode=De;const r=i.kind==="marquee"?i.base:[];s.itemId!==void 0?this.#l(r.length>0?Nd(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}}#R(e){e.preventDefault(),e.ctrlKey||e.metaKey?this.#I(yd(this.viewport,this.#C(e),Math.exp(-e.deltaY*.01))):this.#I(hi(this.viewport,-e.deltaX,-e.deltaY))}#L(e){const n=this.#r;n.on==="item"?this.#x(n.itemId,e):n.on==="ground"&&this.#Q("sticky",this.#$(e))}#J(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=De:o.length>0&&this.#l([]);else if((e.key==="Delete"||e.key==="Backspace")&&o.length>0)this.#V();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.#Z();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.#W(r?l?"front":"back":l?"forward":"backward")}else if(d!==void 0){const l=e.shiftKey?1:mx;i.length>0?this.#T(fb(n,i.map(c=>c.id),d[0]*l,d[1]*l)):this.#I(hi(this.viewport,-d[0]*40,-d[1]*40))}else if(e.key==="+"||e.key==="=")this.#D(1.2);else if(e.key==="-")this.#D(1/1.2);else if(e.key==="0")this.#te();else return;this.requestUpdate(),e.preventDefault()}#N(e){const{target:n,payload:o}=e;return typeof n=="string"?!1:this.dispatchElementAction(e.type,[n.type,n.id],io(o)?o:{})}#T(e){for(const n of e)this.#N(n)}#ee(e){const n=this.#m(this.items());this.#T(n.filter(On).flatMap(o=>o.color===e?[]:[ae.setColor(o.id,e)]))}#j(e){const n=this.#m(this.items());this.#T(n.filter(zt).flatMap(o=>o.fontSize===e?[]:[ae.setFontSize(o.id,e),...this.#w(o,e)]))}#W(e){this.#T(Jf(this.items(),this.selectedIds,e))}#V(){const e=this.items(),n=this.selectedIds;this.#T([...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=De,this.requestUpdate()}#Q(e,n){this.#b();const o=this.items(),i=ib(o,Ft(this.locale),e,n);if(!this.#N(ae.addItem(i)))return;const s=this.#k();s.width>0&&s.height>0&&this.#I($b(this.viewport,i,s)),this.#l([i.id]),this.#a=void 0,this.mode={kind:"editing",itemId:i.id}}#Z(){this.#p+=1;const e=ab(this.items(),this.#h,rb*this.#p),n=[];for(const o of e)this.#N(ae.addItem(o))&&n.push(o.id);n.length>0&&this.#l(n)}#X(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=sb(o,e,n);this.#N(ae.connect(s,e,n))&&this.#l([s])}#I(e){this.#i=!1;const n=wb(e,zn(this.items().items),this.#k());Eb(n,this.viewport)||(this.viewport=n,this.requestUpdate())}#D(e){const{width:n,height:o}=this.#k();this.#I(yd(this.viewport,{x:n/2,y:o/2},e))}#K(e){const n=this.#k();return e===null||n.width<=0||n.height<=0?!1:(this.#I(kb(e,n,Pd)),this.#i=!0,!0)}#H(){return vb(this.items().items,this.#k(),Pd)}#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.#K(this.#H())}#te(){this.#K(this.#H())}#ne(){if(this.#o)return;const e=this.#k();if(e.width<=0||e.height<=0)return;const n=this.#H();n===null?(this.viewport={x:e.width/2,y:e.height/2,zoom:1},this.requestUpdate()):this.#K(n),this.#o=!0}}const Fd=()=>{customElements.get("dpk-board-whiteboard")||customElements.define("dpk-board-whiteboard",qd)},bx=()=>{Za(),Ka(),Ds(),Lr(),As(),Fa(),Ma(),ua(),Fd(),Zr()};export{so as B,Is as D,at as a,rt as b,Rs as c,Mr as d,Qr as e,ha as f,Sa as g,qa as h,Xa as i,Qa as j,qd as k,As as l,Ds as m,Lr as n,Zr as o,ua as p,Ma as q,bx as r,Fa as s,Ka as t,Za as u,Fd as v,ns as w,Ne as x,io as y};