dev-process-kit 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boards.js +1 -1
- package/dist/chunks/{shared-C4EqS9Lp.js → shared-8-7i0SJv.js} +16 -16
- package/dist/chunks/shared-B3gYWxeF.js +1 -0
- package/dist/chunks/{shared-nrgnwzCU.js → shared-BAlmAjut.js} +2 -2
- package/dist/chunks/{shared-BBTySCXK.js → shared-C9Mo56gs.js} +13 -13
- package/dist/chunks/{shared-BblP0eEY.js → shared-CLrs15X7.js} +1 -1
- package/dist/chunks/{shared-C5wXNKl3.js → shared-CMe6_Sdn.js} +1 -1
- package/dist/chunks/shared-CVEzSR4J.js +3 -0
- package/dist/chunks/{shared-bP-1q7ZQ.js → shared-CkaifYF3.js} +9 -9
- package/dist/chunks/{shared-bQPXht-t.js → shared-ComyWGLL.js} +2 -2
- package/dist/chunks/{shared-7Yki1uKI.js → shared-D-lFQPYy.js} +37 -37
- package/dist/chunks/{shared-DlZJHHpN.js → shared-D7lvvzdN.js} +349 -303
- package/dist/chunks/shared-DIYD6Tuj.js +1 -0
- package/dist/chunks/{shared-Bu1HuBxn.js → shared-DTIEx3lM.js} +22 -22
- package/dist/chunks/{shared-Cbm3cQ8l.js → shared-DpOLnWXG.js} +62 -62
- package/dist/chunks/{shared-DPD_tBh8.js → shared-DstEY0ER.js} +1 -1
- package/dist/chunks/{shared-BPVvO01I.js → shared-DvpWdbzP.js} +20 -20
- package/dist/chunks/shared-MI4Xe0aq.js +1868 -0
- package/dist/chunks/{shared-UH4xqvj9.js → shared-ZjHQZcxc.js} +135 -135
- package/dist/components.js +1 -1
- package/dist/index.js +1 -1
- package/dist/sync.js +1 -0
- package/dist/views/delegation-poker.js +1 -1
- package/dist/views/plain.js +1 -1
- package/dist/views/prototype.js +1 -1
- package/dist/views/slides.js +1 -1
- package/dist/views/task-board.js +1 -1
- package/dist/views/usm.js +1 -1
- package/package.json +2 -1
- package/dist/chunks/shared-C44CU0VV.js +0 -1868
- package/dist/chunks/shared-hhwSHdS3.js +0 -1
- package/dist/chunks/shared-pYjptMZ1.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
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`
|
|
1
|
+
import{Z as Hd,L as Hn,_ as pe,$ as Yd,a0 as Gd,a1 as Xd,a2 as Kd,O as jd,i as gi,a3 as fi,a4 as de,a5 as T,a6 as Y,a7 as bi,a8 as xi,a9 as Wd,aa as Vd,ab as Qd,n as Zd,D as Jd,ac as el,N as tl,ad as Yn,ae as nl,af as yi,ag as v,C as ol,ah as il,ai as ki,aj as vi,ak as sl,al as Se,am as wi,x as $i,an as rl,z as Ei,A as Gn,B as Ht,ao as al,ap as nt,aq as ot,u as Xn,ar as yt,as as dl,at as Yt,au as ll,k as ye,av as Ti,t as Kn,aw as cl,ax as Si,ay as Me,az as pl,aA as hl,aB as ul}from"./shared-D7lvvzdN.js";import{Q as ml,A as gl,H as fl,R as bl,S as xl,T as ke,U as Ce,V as Mi,W as yl,X as ve,Y as kl,Z as jn,_ as Ci,$ as vl}from"./shared-DpOLnWXG.js";import{o as wl}from"./shared-D4PPk0Dk.js";import{s as re,o as R,h as F,l as he,j as k,n as ce,m as ue,q as P,k as L,v as S,w as I,x as G,y as we,g as kt,z as Wn,A as $l,B as j,C as oe,d as z,e as Le,D as me,p as Gt,b as Vn,f as U,E as Xt,F as Li,G as El,u as Ii,H as Kt}from"./shared-CVEzSR4J.js";import{E as Tl,t as Ie,u as Sl,v as Oe,B as jt,w as Wt,x as Ml}from"./shared-8-7i0SJv.js";import{a as Cl,c as Ll}from"./shared-CMe6_Sdn.js";import{o as Vt}from"./shared-DIYD6Tuj.js";import{h as Ai,l as Il,d as Qn,a as _i}from"./shared-ComyWGLL.js";const Al=[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2"}]],_l=[["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"}]],Rl=[["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"}]],Dl=[["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"}]],Ol=[["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 Nl(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)}},zl=(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)}}},Pl=(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},ql=(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,Pl(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 Zl(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)?ql(t,l,p,Zt(t,s),d,c,o):zl(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}}},Fl=(t,e,n)=>{if(t.length<=1)return t.map(c=>c.id);const o=t.map(c=>({id:c.id,width:c.width,height:c.height})),i=new Set(o.map(c=>c.id)),s=e.filter(c=>i.has(c.from)&&i.has(c.to)&&c.from!==c.to),{forward:r}=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)??[])},Ul=(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,Ul(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}},Bl=(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},Hl=(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}},Yl=(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,Gl=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 Bl(t,e,n)*nn.crossings+Hl(t,e,n)*nn.edgeLength+s*i},Xl=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++},Kl=7,jl=400,Wl=1e-6,no=(t,e,n,o,i=vt.sweeps,s=0,r=nn.aspectDeviation,a=jl)=>{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<=Kl){let $=c(p);for(const A of Xl(p)){const C=c(A);C.cost<$.cost&&($=C)}return $.packed}const u=s>0?Math.min(a,50):a;let m=Fl(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-Wl&&(y=E,b=M,m=A,w=!0)}}return b},Vl=(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,Ql=1.45,Zl=(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,Ql,o.sweeps,X,Gl),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=Vl(X,f,o.superGroupRowGap,o.superGroupColumnGap,K=>b.has(K)),ne=Yl(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)},Jl=(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"},ec=t=>({kind:"node",...t,moved:!1,preview:null}),tc=t=>({kind:"group",...t,moved:!1,preview:null}),nc=(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",oc=(t,e)=>t.board===e.board&&t.diagram===e.diagram&&t.node===e.node,is=(t,e,n)=>({...t,overrides:[...t.overrides.filter(o=>!oc(o,e)),{...e,position:n}]}),ic=(t,e)=>e.reduce((n,o)=>is(n,o,o.position),t),sc=(t,e,n)=>new Map(t.overrides.filter(o=>o.board===e&&o.diagram===n).map(o=>[o.node,o.position])),rc=(t,e,n)=>t.overrides.some(o=>o.board===e&&o.diagram===n),ac=(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}},dc=(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}},lc=R({x:ce(),y:ce()}),cc=R({board:k(),diagram:k(),node:k(),position:lc}),pc=R({v:he(1),overrides:F(cc)}),ss=t=>{const e=re(pc,t);return e.success?e.output:null},hc=t=>`dev-process-kit:layout-positions:${t}`,uc=()=>{const t=typeof location>"u"?"local":`${location.pathname}${location.search}`;return hc(t)},mc=()=>Gd(ss),gc=()=>Yd(ss),fc=t=>t.closest(Xd)?.getAttribute(Kd)??"";class bc{#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?gc():mc(),this.#t=uc(),this.#n=this.#e.read(this.#t)??os,window.addEventListener(oo,this.#a)}hostDisconnected(){window.removeEventListener(oo,this.#a)}get#r(){return fc(this.#i.host())}get#s(){return this.#i.diagram()}overrides(){return sc(this.#n,this.#r,this.#s)}hasOverrides(){return rc(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=ic(this.#n,n),this.#d()}prune(e){const n=dc(this.#n,this.#r,this.#s,e);n!==this.#n&&(this.#n=n,this.#d())}reset(){const e=ac(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 xc=(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 Hd,S as Hn,a5 as pe,a6 as Yd,a7 as Gd,a8 as re,a9 as R,aa as F,ab a
|
|
|
139
139
|
font-size: 11px;
|
|
140
140
|
color: var(--dpk-accent);
|
|
141
141
|
}
|
|
142
|
-
`],
|
|
142
|
+
`],yc=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 Hd,S as Hn,a5 as pe,a6 as Yd,a7 as Gd,a8 as re,a9 as R,aa as F,ab a
|
|
|
346
346
|
.d-edge-label.is-dimmed {
|
|
347
347
|
opacity: 0.3;
|
|
348
348
|
}
|
|
349
|
-
`,Ne=[...st,
|
|
349
|
+
`,Ne=[...st,yc],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,7 +368,7 @@ 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 a
|
|
|
368
368
|
</marker>
|
|
369
369
|
`)}
|
|
370
370
|
</defs>
|
|
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
|
|
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=Tl;#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(),this.#p?.reopen()}disconnectedCallback(){super.disconnectedCallback(),this.#s?.(),this.#s=null,queueMicrotask(()=>{this.isConnected||this.#p?.close()})}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=e?void 0:Qd(this,{storageKey:Zd(n.name),template:n.name}),i=new Jd(e?{definition:n,base:{},storage:null}:o===void 0?{definition:n,base:{}}:{definition:n,base:{},sync:o});return this.#p=i,e&&(this.dataset.template=n.name),i.subscribe(()=>this.#f()),this.#f(),i}#f(){const e=this.#p;if(!e)return;const n=this.#m();this.elementActions=el(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(il(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=tl(e.target,o),s=this.board;if(s===null)return{...e,target:i};const r=Yn(this)?.pageNames()??new Set;return{...e,target:nl(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
374
|
</div>`}renderTagFilterRow(e=T){return v`<div slot="toolbar" class="diagram-toolbar-rows">
|
|
@@ -379,9 +379,9 @@ 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 a
|
|
|
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.#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:
|
|
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:ol,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 ke(...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
|
-
class=${
|
|
384
|
+
class=${ke("diagram",this.shellClass())}
|
|
385
385
|
flush
|
|
386
386
|
?maximizable=${this.frameControls}
|
|
387
387
|
?resizable=${this.frameControls}
|
|
@@ -406,9 +406,9 @@ 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 a
|
|
|
406
406
|
</div>
|
|
407
407
|
</dpk-dialog-panel>
|
|
408
408
|
${this.renderSelection()}
|
|
409
|
-
`}}const
|
|
409
|
+
`}}const kc=4,vc=new Set,wc='button,[role="button"],a,input,textarea,select';class at extends so{#o=null;#i="";#e=null;#t="";#n=0;#a=Ce;#r=new bc(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 xc(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 Mi(e,this.selection,"node",this.#a)}edgeState(e){return Mi(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
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`
|
|
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(Jl(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(wc):null;if(o!==null&&o!==e.currentTarget)return;const i=this.placedNode(n),s=e.currentTarget;!i||!(s instanceof HTMLElement)||(e.stopPropagation(),this.#u(ec({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()):vc}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(tc({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=nc(n,{screenX:e.clientX,screenY:e.clientY},o,kc);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,$c=P({src:S(k(),I(1)),alt:S(k(),I(1)),license:L(k())}),Ec=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($c),position:P({x:ce(),y:ce()}),questions:L(k())}),Tc=P({id:S(k(),I(1)),label:S(k(),I(1)),kind:L(G(["internal","external"]),"internal")}),Sc=P({id:S(k(),I(1)),from:S(k(),I(1)),to:S(k(),I(1)),label:L(k())}),Mc=P({boundaries:L(F(Tc),[]),services:F(Ec),links:L(F(Sc),[])}),Cc=()=>({nodes:[],edges:[],boundaries:[]}),Lc=t=>{const e=ue(Mc,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},Ic={left:0,top:0,right:0,bottom:0},Ac=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))}),_c=(t,e,n,o)=>{const i=t.left-e.left<n.right+o.right&&n.left-o.left<t.right+e.right,s=t.top-e.top<n.bottom+o.bottom&&n.top-o.top<t.bottom+e.bottom;if(!i||!s)return e;const r=Math.max(n.left-t.right,t.left-n.right),a=Math.max(n.top-t.bottom,t.top-n.bottom);if(r<0&&a<0)return e;const d=(l,c,h)=>l===0?0:Math.max(0,h-Ac)*l/(l+c);return r>=a?n.left>=t.right?{...e,right:Math.min(e.right,d(e.right,o.left,r))}:{...e,left:Math.min(e.left,d(e.left,o.right,r))}:n.top>=t.bottom?{...e,bottom:Math.min(e.bottom,d(e.bottom,o.top,a))}:{...e,top:Math.min(e.top,d(e.top,o.bottom,a))}},Rc=(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:Ic}))];return n.map(({boundary:i,bounds:s})=>{const r=o.filter(l=>l.id!==i.id).map(l=>_c(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,Dc=t=>t.slice(1).map((e,n)=>[t[n],e]),Oc=(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))},Nc=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=>Nc(n).some(o=>Dc(t).some(i=>Oc(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},zc=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,zc),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)}),Pc=(t,e)=>t.maxX>=e.minX&&e.maxX>=t.minX&&t.maxY>=e.minY&&e.maxY>=t.minY,qc=(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(!Pc(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}},Fc=(t,e,n,o)=>{const i=new Set;for(const s of n)(o==="x"?s.y<e&&s.y+s.height>t:s.x<e&&s.x+s.width>t)&&(o==="x"?(i.add(s.x),i.add(s.x+s.width)):(i.add(s.y),i.add(s.y+s.height)));return[...i]},Uc=(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]},Bc=14,xs=(t,e,n,o,i)=>[...new Set([...Fc(t,e,n,i),...Uc(t,e,o,i,Bc)])],Hc=1.5,Yc=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}]],Gc=(t,e)=>{let n=!1,o=!1;for(const i of e)for(const s of Yc(i))for(const r of Et(t)){const a=lo(r,s,cs);if(a>ps&&(n=!0),a>1&&lo(r,s,Hc)>1&&(o=!0),n&&o)return{hugs:n,contact:o}}return{hugs:n,contact:o}},Xc=(t,e,n,o)=>{const i=qc(t.points,e,n),{hugs:s,contact:r}=Gc(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),Kc=(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},jc=(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=Xc(s,e,o,n);(i===null||ys(r,i))&&(i=r)}return i},Wc=(t,e,n,o,i,s)=>ks([...Kc(t,e,n,o,s),...jc(t,e,n,o,s)],i,s),rn=(t,e,n)=>Math.min(n,Math.max(e,t)),Vc=(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=Wc(t,e,a,d,i,s);return f!==null&&(m===null||ys(f,m))?f.points:m!==null?m.points:Vc(t,e,d,o)??dt([t,l,e])},Qc=12,Zc=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},Jc=(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)}},ep=(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??Qc,s=n.gap??Zc,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}=Jc(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=ep(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},tp=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,np=(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},op=(t,e)=>t.orientation==="vertical"?ge(e,t.rangeMin,t.rangeMax,t.obstacles):fe(e,t.rangeMin,t.rangeMax,t.obstacles),ip=(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)),sp=(t,e,n,o=[],i=0)=>{const s=d=>op(t,d)||o.length>0&&ip(t,d,o,i);let r=n,a=0;for(;s(r)&&a<8;)r=(r+e)/2,a++;return s(r)?e:r},rp=(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}},ap=(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=tp(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=np(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=ap(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}=rp(w.points,b.segIndex,c,i),M=i>0?A>C?$:Math.min(C,Math.max(A,x)):x,E=sp(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},dp={margin:16,portGap:16},lp=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)}),cp=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,pp=(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=up(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}:hp(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},hp=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},up=t=>{let e=0;for(const n of t)e+=(n.codePointAt(0)??0)>=11904?10:5.6;return Math.ceil(e+4)},mp=(t,e,n={})=>{const o={...dp,...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:lp,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=cp([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]}},gp=de`
|
|
412
412
|
.arch-toggle {
|
|
413
413
|
min-height: 26px;
|
|
414
414
|
padding: 0 9px;
|
|
@@ -570,7 +570,7 @@ 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 a
|
|
|
570
570
|
fill: var(--dpk-blue);
|
|
571
571
|
stroke: var(--dpk-blue);
|
|
572
572
|
}
|
|
573
|
-
`,
|
|
573
|
+
`,fp=[{id:"arch-neutral"},{id:"arch-selected"}];class Is extends at{static{this.styles=[Ne,gp]}#o=!0;parseData(e){return Lc(e)}emptyData(){return Cc()}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 mp(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 Ce;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)}${o.label===null?"":` \xB7 ${o.label}`}`}))]}renderToolbarActions(){const e=$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 Hd,S as Hn,a5 as pe,a6 as Yd,a7 as Gd,a8 as re,a9 as R,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
|
|
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 Rc(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}
|
|
@@ -612,8 +612,8 @@ 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 a
|
|
|
612
612
|
>
|
|
613
613
|
<span>${s.boundary.label}</span>
|
|
614
614
|
</div>`):T}
|
|
615
|
-
${this.renderEdges(i,
|
|
616
|
-
`}#t(e,n){const o=
|
|
615
|
+
${this.renderEdges(i,fp)} ${n.nodes.map(s=>this.#n(s,e))}
|
|
616
|
+
`}#t(e,n){const o=pp(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")}
|
|
@@ -637,7 +637,7 @@ 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 a
|
|
|
637
637
|
${e.description===null?T:v`<span class="arch-description">${e.description}</span>`}
|
|
638
638
|
</span>
|
|
639
639
|
</button>
|
|
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},
|
|
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},bp=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())}),xp=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())}),yp=P({modules:F(bp),dependencies:L(F(xp),[])}),kp=()=>({nodes:[],edges:[]}),vp=t=>{const e=ue(yp,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}},wp=de`
|
|
641
641
|
.dep-direction {
|
|
642
642
|
display: flex;
|
|
643
643
|
gap: 2px;
|
|
@@ -831,7 +831,7 @@ 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 a
|
|
|
831
831
|
fill: var(--dpk-blue);
|
|
832
832
|
stroke: var(--dpk-blue);
|
|
833
833
|
}
|
|
834
|
-
|
|
834
|
+
`,$p=[{id:"dep-neutral"},{id:"dep-outgoing"},{id:"dep-incoming"},{id:"dep-cycle"},{id:"dep-selected"}];class Rs extends at{static{this.styles=[Ne,wp]}#o="both";#i=!1;#e=!1;#t=[];#n=Ce;#a=Ce;parseData(e){return vp(e)}emptyData(){return kp()}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"?Ce:{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"?ve(s,r.id,"outgoing",this.#i):Ce,this.#a=r!==null&&r.kind==="node"&&this.#o!=="outgoing"?ve(s,r.id,"incoming",this.#i):Ce,super.refreshContent()}matchesFilter(e){return this.#e?jn(this.#t).has(e.id):!0}filtered(){const e=super.filtered();if(!this.#e)return e;const n=jn(this.#t),o=e.edges.filter(s=>Ci(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
836
|
${[["outgoing",e.directionOutgoing],["incoming",e.directionIncoming],["both",e.directionBoth]].map(([o,i])=>v`
|
|
837
837
|
<button
|
|
@@ -868,7 +868,7 @@ 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 a
|
|
|
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":
|
|
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":Ci(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=jn(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}
|
|
@@ -910,7 +910,7 @@ 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 a
|
|
|
910
910
|
<span class="dep-name">${a.name}</span>
|
|
911
911
|
<span class="dep-path">${a.path??""}</span>
|
|
912
912
|
</button>
|
|
913
|
-
`});return v`${this.renderEdges(s,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`
|
|
913
|
+
`});return v`${this.renderEdges(s,$p)}${r}`}}const Ds=()=>{customElements.get("dpk-board-dependency-graph")||customElements.define("dpk-board-dependency-graph",Rs)},Ep=t=>{switch(t){case"1":return{min:"one",max:"one"};case"0..1":return{min:"zero",max:"one"};case"1..N":return{min:"one",max:"many"};case"0..N":return{min:"zero",max:"many"}}},St=4,Os=6,Tp=12,Ns=7,Sp=7,go=13,fo=14,Mp=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}},Cp=(t,e)=>Ps(t,e),qs=t=>Math.round(t*100)/100||0,Lp=(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=Ep(n),l=d.max==="many"?[-Ns,0,Ns].map(f=>[r(Tp),r(0,f)]):[a(Sp)],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)+Mp,m=r(u);return{segments:h,circle:p,label:{...m,anchor:i.x>=0?"start":"end"}}},cn=10,Ip=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)),Ap=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=Cp(t,i),a={x:-r.y,y:r.x},d=Math.abs(r.x)>=Math.abs(r.y),l=Ip(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},_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)Fs(o,s.box)&&(i+=1e6);for(const s of e.frames)for(const[r,a]of Ap(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=_p(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}},Rp=(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)}`}},Dp=t=>t.map(vo).join(" "),ze=6,Op=2*ze+2,Np=.01,Bs=24,zp=t=>{const e=Pp(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)),Pp=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},qp=(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)]),Fp=(t,e)=>{const n=new Map([...t].filter(([o])=>e.has(o)).map(([o,i])=>[o,zp(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)>Np||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])=>qp(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)<Op?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"}}),Up=280,wo=48,Bp=32,Hp=52,Yp=16,Gp=18,Xp=10,Kp=440,Ks=["1","0..1"],js=["1","0..1","1..N","0..N"],$o=Ks.flatMap(t=>js.map(e=>`${t}:${e}`)),jp=["immutable","mutable","sti","cti","value-object"],Wp=G(jp),Ws=G(["PK","FK","UQ"]),Vp=P({id:S(k(),I(1)),type:S(k(),I(1)),key:L($l([Ws,S(F(Ws),I(1))])),ref:L(k()),nullable:L(kt(),!1),cardinality:L(G($o)),label:L(S(k(),I(1))),description:L(k()),questions:L(k())}),Qp=Wn("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))})]),Zp=P({id:S(k(),I(1)),name:S(k(),I(1)),tags:L(F(k()),[]),boundedContext:L(k()),aggregate:L(k()),pattern:L(Wp),fields:F(Vp),constraints:L(F(Qp),[]),questions:L(k())}),Vs=P({tables:F(Zp)}),Jp=P({before:L(Vs),after:Vs}),eh=()=>({nodes:[],edges:[]}),th=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,nh=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,oh=(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])),ih=(t,e)=>{const n=oh(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"?Hp:Bp)+(t.description===null?0:Yp),sh=t=>t.length===0?0:Xp+t.length*Gp,nr=(t,e=[])=>wo+t.reduce((n,o)=>n+So(o),0)+sh(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},rh=14,ah=(t,e)=>(t-(e-1)/2)*rh,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,ah(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:ih(e,n),label:n.label??null}]})),dh=(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},lh=70,ch=20,ph=168,hh=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(ph,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+lh+ch+hh(r))),s=Math.max(0,...n.map(r=>Ct(Zs(r),11)+24));return Math.min(Kp,Math.max(Up,Math.ceil(Math.max(o,i,s))))},uh=t=>{const e=ue(Jp,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=dh(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(nh);return[{id:f,name:y.name,status:w,fields:x,tags:[...s.get(f)??[],...$===null?[]:[Sl($)]],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",mh=R({id:S(k(),we(),I(1)),type:S(k(),we(),I(1)),nullable:L(kt(),!1),description:L(S(k(),we()))}),gh=R({field:S(k(),I(1)),type:S(k(),we(),I(1)),nullable:kt(),description:L(S(k(),we()))}),fh=R({field:S(k(),I(1))}),bh=R({cardinality:G($o)}),Mo=t=>{const e=Oe(t);return e?.length===3&&e[1]==="node"?e[2]??null:null},xh=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}},yh=(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(mh,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"}}},kh=(t,e,n)=>{const o=t.editFieldTitle,i=e.nodes.find(m=>m.id===Mo(n.target.id)),s=re(gh,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"}}},vh=(t,e,n)=>{const o=t.deleteFieldTitle,i=e.nodes.find(c=>c.id===Mo(n.target.id)),s=re(fh,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"}}},wh=(t,e,n)=>{const o=t.editCardinalityTitle,i=e.edges.find(f=>f.id===xh(n.target.id));if(i===void 0)return{data:e,result:{id:n.id,title:o,stale:"target-missing"}};const s=re(bh,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"}}},$h=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===dr?yh(t,o,s):s.type===lr?kh(t,o,s):s.type===cr?vh(t,o,s):s.type===pr?wh(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}},Eh=de`
|
|
914
914
|
.er-search {
|
|
915
915
|
display: flex;
|
|
916
916
|
align-items: center;
|
|
@@ -1948,7 +1948,7 @@ 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 a
|
|
|
1948
1948
|
padding: 0 10px;
|
|
1949
1949
|
font-size: 10.5px;
|
|
1950
1950
|
}
|
|
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`
|
|
1951
|
+
`,Th=(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",Sh=(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)}])},Mh=(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}},Ch=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,Lh=(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}},Ih=(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))},Ah=t=>`${t.parent}:${t.child}`,br=18,xr=22,Lo=30,Io=46,_h=160,Rh=120,Dh=(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:Dh(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}}},Oh=(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}}},Nh=(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},zh=(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 zh(t,e,n,o,s);const r=Oh(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},$=Nh(x,w,a,o,s,g,d);return Lt([r.start,...$,r.end])},Ph=t=>t.slice(1).map((e,n)=>[t[n],e]),qh=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)},Fh=(t,e,n,o,i=[])=>{const s=p=>qh(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(...Ph(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})},Uh=10,Bh=(t,e,n=Pe)=>{const o=t[0],i=t.at(-1);if(o===void 0||i===void 0||!Hh(t))return Yh(t,Uh,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},Hh=t=>t.length>=2&&t.length%2===0&&t.every((e,n)=>{const o=t[n-1];return o===void 0?!0:n%2===1?e.y===o.y&&e.x>=o.x:e.x===o.x})&&(t.at(-1)?.x??0)>(t[0]?.x??0),Yh=(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:_h,superGroupColumnGap:Rh},Tr=_o.nodeSpacing/2,Gh=_o.layerSpacing/2,Xh=16,Kh='[data-action="add-field"], [data-action="edit-field"]',Sr={same:"",added:"+",removed:"\u2212",changed:"~"},jh={primary:rl,foreign:$i,"not-null":wi,nullable:wi},Wh=(t,e)=>t.keys.filter(n=>!(e==="primary"&&n==="PK")&&!(e==="foreign"&&n==="FK")),Vh=.5,Qh=(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,Eh,Cl]}#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 sl(this,{open:()=>this.#e!==null,closesOn:e=>!e.some(n=>n instanceof Element&&n.matches(`.er-editor, ${Kh}`)),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:Ah(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};Qh(this.#r.get(o),l,Vh)||(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 uh(e)}reduceElementActions(e,n){return $h($e(this.locale),e,n)}emptyData(){return eh()}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}=th(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 Ce;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items();return[...e.nodes.map(n=>({value:this.commentRef("node",n.id),label:`${n.id} \xB7 ${n.name}`})),...e.edges.map(n=>({value:this.commentRef("edge",n.id),label:`${n.from}.${n.sourceField} \u2192 ${n.to}.${n.targetField}`}))]}renderToolbarActions(){const e=$e(this.locale);return v`
|
|
1952
1952
|
<label class="er-search">
|
|
1953
1953
|
<span class="dpk-label">${e.search}</span>
|
|
1954
1954
|
<input
|
|
@@ -1982,7 +1982,7 @@ 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 a
|
|
|
1982
1982
|
${i.label}
|
|
1983
1983
|
</button>`)}
|
|
1984
1984
|
</div>
|
|
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
|
|
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 Lh(e.edges,[this.#i,o].filter(i=>i!==null))}#y(e){return Ih(this.#l,e.nodes,e.edges)}#v(e,n){const o=this.#C(e),i=()=>new Map(e.edges.map(p=>[p.id,Bh(o.get(p.id)??[],Gh)]));if(this.draggedNodeIds().size>0)return new Map([...i()].map(([p,u])=>[p,Dp(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=Fp(i(),new Set(r));return d.size>=Xh&&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=Fh(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=Rp(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`
|
|
1986
1986
|
<g
|
|
1987
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
1988
|
data-relation=${x.id}
|
|
@@ -2006,17 +2006,17 @@ 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 a
|
|
|
2006
2006
|
${$.length>0?this.#$($,x,m.get(x.id)):T}
|
|
2007
2007
|
</g>
|
|
2008
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=${
|
|
2009
|
+
class=${ke("er-bc",i!==null&&!Ie([`${jt}${x.boundedContext}`],i)&&"is-bc-dimmed")}
|
|
2010
2010
|
style="left:${x.box.x}px; top:${x.box.y}px; width:${x.box.width}px; height:${x.box.height}px"
|
|
2011
2011
|
>
|
|
2012
2012
|
<span class="er-bc-label">${x.boundedContext}</span>
|
|
2013
2013
|
</div>`)}${y.map(x=>v`<div
|
|
2014
|
-
class=${
|
|
2014
|
+
class=${ke("er-aggregate",this.isDraggingGroup(x.aggregate)&&"is-dragging")}
|
|
2015
2015
|
style="left:${x.box.x}px; top:${x.box.y}px; width:${x.box.width}px; height:${x.box.height}px"
|
|
2016
2016
|
@pointerdown=${w=>{w.composedPath().some($=>$ instanceof Element&&$.matches(".d-node"))||this.onGroupDragStart(w,x.aggregate,x.tables)}}
|
|
2017
2017
|
>
|
|
2018
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=
|
|
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=Lp(e,h,p),f=o?.[h];return{glyph:m,content:Y`
|
|
2020
2020
|
<g class="er-end" data-end=${h} data-multiplicity=${p}>
|
|
2021
2021
|
${m.segments.map(([g,b])=>Y`<line x1=${g.x} y1=${g.y} x2=${b.x} y2=${b.y}></line>`)}
|
|
2022
2022
|
${m.circle===null?T:Y`<circle cx=${m.circle.x} cy=${m.circle.y} r=${St}></circle>`}
|
|
@@ -2082,13 +2082,13 @@ 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 a
|
|
|
2082
2082
|
`}#O(e,n){return e.constraints.length===0?T:v`<ul class="er-constraints" aria-label=${n.tableConstraintsLabel}>
|
|
2083
2083
|
${e.constraints.map(o=>v`<li class="er-constraint">${Zs(o)}</li>`)}
|
|
2084
2084
|
</ul>`}#E(e,n){return v`<span class="er-icon" data-icon=${e} role="img" aria-label=${n.columnRole(e)}
|
|
2085
|
-
>${
|
|
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=
|
|
2085
|
+
>${jh[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=Ch(n),c=Sh(n,i),h=c.find(u=>u.attribute==="type"),p=c.filter(u=>u.attribute!=="type");return v`
|
|
2087
2087
|
<div
|
|
2088
|
-
class=${
|
|
2088
|
+
class=${ke("er-field",`is-${n.status}`,d&&"is-match",o.columns.has(`${e.id}.${n.id}`)&&"is-lit",r&&"is-editing")}
|
|
2089
2089
|
data-field=${n.id}
|
|
2090
2090
|
data-grill-questions=${this.questionsOf(n)}
|
|
2091
|
-
title=${[i.statusLabel(n.status),n.id
|
|
2091
|
+
title=${[i.statusLabel(n.status),n.id,Th(n,i,!0)].join(" / ")}
|
|
2092
2092
|
@pointerenter=${()=>this.#T({kind:"column",table:e.id,field:n.id})}
|
|
2093
2093
|
@pointerleave=${()=>this.#T({kind:"table",id:e.id})}
|
|
2094
2094
|
>
|
|
@@ -2096,7 +2096,7 @@ 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 a
|
|
|
2096
2096
|
<span class="er-field-mark" aria-hidden="true">${Sr[n.status]}</span>
|
|
2097
2097
|
${this.#E(l,i)}
|
|
2098
2098
|
<span class="er-field-name"
|
|
2099
|
-
>${n.id}${
|
|
2099
|
+
>${n.id}${Wh(n,l).map(u=>v`<span class="er-key">${u}</span>`)}</span
|
|
2100
2100
|
>
|
|
2101
2101
|
<span class="er-field-type">
|
|
2102
2102
|
${h===void 0?n.type:v`<del>${h.before}</del><ins>${h.after}</ins>`}
|
|
@@ -2128,13 +2128,13 @@ 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 a
|
|
|
2128
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">
|
|
2129
2129
|
<button
|
|
2130
2130
|
type="button"
|
|
2131
|
-
class=${
|
|
2131
|
+
class=${ke("er-add-button",o&&"is-open")}
|
|
2132
2132
|
data-action="add-field"
|
|
2133
2133
|
aria-haspopup="dialog"
|
|
2134
2134
|
aria-expanded=${o?"true":"false"}
|
|
2135
2135
|
@click=${()=>this.#j({kind:"add",table:e.id,name:"",type:"",nullable:!1,description:"",failed:!1})}
|
|
2136
2136
|
>
|
|
2137
|
-
<span class="er-icon" aria-hidden="true">${
|
|
2137
|
+
<span class="er-icon" aria-hidden="true">${Gn()}</span><span>${n.addFieldButton}</span>
|
|
2138
2138
|
</button>
|
|
2139
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
|
|
2140
2140
|
class="er-editor"
|
|
@@ -2241,7 +2241,7 @@ 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 a
|
|
|
2241
2241
|
${this.#p.render({options:$o.map(i=>({value:i,label:i.replace(":"," : ")})),value:e.cardinality,ariaLabel:o.cardinalityLabel,onChange:i=>this.#R(i)})}
|
|
2242
2242
|
</label>
|
|
2243
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=
|
|
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=Mh(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">
|
|
2245
2245
|
<label class="er-editor-field">
|
|
2246
2246
|
<span class="dpk-label">${n.addFieldType}</span>
|
|
2247
2247
|
<input
|
|
@@ -2278,12 +2278,12 @@ 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 a
|
|
|
2278
2278
|
@pointerdown=${c=>c.preventDefault()}
|
|
2279
2279
|
@click=${()=>this.#Z(d.type)}
|
|
2280
2280
|
>
|
|
2281
|
-
${d.kind==="new"?v`<span class="er-icon" aria-hidden="true">${
|
|
2281
|
+
${d.kind==="new"?v`<span class="er-icon" aria-hidden="true">${Gn()}</span>`:T}
|
|
2282
2282
|
<code>${d.type}</code>
|
|
2283
2283
|
${d.kind==="new"?v`<span class="er-type-option-hint">${n.columnTypeNew}</span>`:T}
|
|
2284
2284
|
</li>`)}
|
|
2285
2285
|
</ul>`:T}
|
|
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`
|
|
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&&al(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"],Zh=P({id:oe,name:S(k(),I(1)),description:j(k()),questions:nt}),Jh=P({id:oe,type:G(Ro),name:S(k(),I(1)),description:j(k()),contextId:j(k()),questions:nt}),eu=P({id:oe,from:S(k(),I(1)),to:S(k(),I(1)),label:j(k()),kind:j(G(["member","flow"]))}),tu=P({title:j(k()),contexts:L(F(Zh),[]),elements:L(F(Jh),[]),links:L(F(eu),[])}),nu=t=>{const e=ue(tu,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},ou=()=>({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)},iu=(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:Le}),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:Le}),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:Le}),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"}}),su={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}=su[t];return`--es-note-bg:${e};--es-note-ink:${n}`},ru=de`
|
|
2287
2287
|
/*
|
|
2288
2288
|
* The host is the note's box and its ink. It is never rotated, scaled or
|
|
2289
2289
|
* filtered: any transform here promotes the note to a composited layer that
|
|
@@ -2547,7 +2547,7 @@ 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 a
|
|
|
2547
2547
|
backdrop-filter: blur(4px);
|
|
2548
2548
|
box-shadow: var(--dpk-bevel), var(--dpk-shadow-xs);
|
|
2549
2549
|
}
|
|
2550
|
-
`;class
|
|
2550
|
+
`;class au extends bi{static{this.styles=[gi,ru,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`
|
|
2551
2551
|
<div class="paper" aria-hidden="true"></div>
|
|
2552
2552
|
<div class="note-type">${n.noteTypeLabel(e.type)}</div>
|
|
2553
2553
|
<div class="note-editing" aria-hidden="true">${Ei()}</div>
|
|
@@ -2577,7 +2577,7 @@ 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 a
|
|
|
2577
2577
|
aria-label=${n.commentNote}
|
|
2578
2578
|
@click=${this.#n(()=>({kind:"comment"}))}
|
|
2579
2579
|
>
|
|
2580
|
-
${
|
|
2580
|
+
${Xn()}
|
|
2581
2581
|
</button>
|
|
2582
2582
|
<button
|
|
2583
2583
|
class="dpk-icon-btn"
|
|
@@ -2589,7 +2589,7 @@ 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 a
|
|
|
2589
2589
|
${Ht()}
|
|
2590
2590
|
</button>
|
|
2591
2591
|
</div>
|
|
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}>
|
|
2592
|
+
`}#n(e){return n=>{n.stopPropagation(),this.#a(e(n))}}#a(e){this.onIntent?.(e)}}const du=()=>{customElements.get("dpk-internal-event-storming-note")||customElements.define("dpk-internal-event-storming-note",au)},_r=.25,lu=2,cu=(t,e,n)=>({...t,panX:t.panX+e,panY:t.panY+n}),Rr=(t,e,n,o)=>{const i=yt(t.zoom*o,_r,lu),s=(e-t.panX)/t.zoom,r=(n-t.panY)/t.zoom;return{panX:e-s*i,panY:n-r*i,zoom:i}},pu=(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}},hu=(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)}},uu=(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&&uu(i.rect,e,n))return i.id}},mu=(t,e)=>e<t.left+t.width/2?"before":"after",gu=(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},fu=(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 dl(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:mu(a,i.x)}}:{}}}case"select":return{...s,kind:"select"}}},bu=new Set(["actor>command","command>aggregate","aggregate>event","command>event","policy>command","external>event"]),No=(t,e)=>bu.has(`${t}>${e}`),xu=(t,e,n)=>t.kind!==void 0?t.kind==="member":No(e,n),yu=["readmodel","actor","policy","command","aggregate","external","event","hotspot"],ku=(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},vu=(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||xu(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=ku(t,e),o=t.elements.filter(l=>!n.has(l.id)),{groups:i,rootOf:s}=vu(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(yu.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}})},wu=(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}},$u=(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}`,Eu=(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=>Nl(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),Tu=(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 Su{#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 Mu=(t,e)=>{const n=Gt(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=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?zr(i):i)}:null;default:return Vn(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,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},Lu={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=Lu[e.type],r=i?i(t,e,o??n):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:Iu(t,n,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},Iu=(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=iu(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}`}},Au=t=>t==="comment"?"meta":t,_u=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}},Ru=(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=_u(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Mu(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:Au(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Ae={kind:"idle"},Du=(t,e)=>t.kind==="editing"&&t.noteId===e?"editing":"view",Ou=(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}},Nu=6,zu=10,qr="\u2026",Pu=[[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 Pu.some(([n,o])=>e>=n&&e<=o)?zu:Nu},qu=(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,Fu=18,Ur=4,Br=t=>{const e=[];let n=Fu;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,Uu=6,Bu=26,Hu=(t,e)=>Math.max(Gr,t-bn+(e?Bu:0)),Yu=Br([Fo]).extent,Gu=["actor","command","aggregate","event","policy","readmodel","external"],jr=t=>fn*2+t*_t+(t-1)*Uo,Xu=(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}},Ku=(t,e,n,o)=>{const i=new Map(e.map(g=>[g.id,jr(g.notes.length)])),s=$u(t,e),r=Eu(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=Xu(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 $=Hu(Math.max(Yu,...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+Uu,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}},ju=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}>
|
|
2593
2593
|
<div class="empty">
|
|
2594
2594
|
<h2>${e.emptyTitle}</h2>
|
|
2595
2595
|
<p>${e.emptyBody}</p>
|
|
@@ -2597,7 +2597,7 @@ 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 a
|
|
|
2597
2597
|
${e.addFirstEvent}
|
|
2598
2598
|
</button>
|
|
2599
2599
|
</div>
|
|
2600
|
-
</div>`;const l=ht(n),c=
|
|
2600
|
+
</div>`;const l=ht(n),c=Ku(n,l,o,i);return v`
|
|
2601
2601
|
<div
|
|
2602
2602
|
class="board-viewport${t.gesture!==void 0?" board-viewport--gesturing":""}"
|
|
2603
2603
|
data-testid="es-viewport"
|
|
@@ -2616,34 +2616,34 @@ 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 a
|
|
|
2616
2616
|
style=${`transform:translate(${s.panX}px, ${s.panY}px) scale(${s.zoom})`}
|
|
2617
2617
|
>
|
|
2618
2618
|
<div class="wall" data-testid="es-wall" style=${`width:${c.width}px;height:${c.height}px`}>
|
|
2619
|
-
${
|
|
2620
|
-
${c.bands.map((h,p)=>
|
|
2619
|
+
${om(t,c)}
|
|
2620
|
+
${c.bands.map((h,p)=>Vu(t,c,h,p))}
|
|
2621
2621
|
</div>
|
|
2622
2622
|
</div>
|
|
2623
|
-
${
|
|
2624
|
-
${
|
|
2623
|
+
${Zu(t.gesture)} ${Ju(e,n,l)} ${em(t)}
|
|
2624
|
+
${tm(t)}
|
|
2625
2625
|
</div>
|
|
2626
|
-
`},
|
|
2626
|
+
`},Wu=(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(" ")},Vu=(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
2627
|
style=${m}
|
|
2628
2628
|
.note=${u}
|
|
2629
|
-
.mode=${
|
|
2629
|
+
.mode=${Du(s,u.id)}
|
|
2630
2630
|
?focused=${d===u.id}
|
|
2631
2631
|
?compact=${f}
|
|
2632
2632
|
data-pin=${f?u.id:T}
|
|
2633
2633
|
data-dpk-target=${t.commentRef("note",u.id)}
|
|
2634
|
-
data-grill-questions=${Vt(
|
|
2634
|
+
data-grill-questions=${Vt(Yt(u.questions))}
|
|
2635
2635
|
.onIntent=${g=>l.noteIntent(u.id,g)}
|
|
2636
2636
|
></dpk-internal-event-storming-note>`;return v`
|
|
2637
2637
|
<section class="band" data-band=${o} style=${`left:${ut+n.x}px;top:${n.y}px`}>
|
|
2638
2638
|
<div class="band-canvas" style=${`width:${n.width}px;height:${n.height}px`}>
|
|
2639
|
-
${
|
|
2639
|
+
${Qu(t,e,o)}
|
|
2640
2640
|
${c.map(u=>{const{x:m,y:f,w:g}=h(u);return v`<div
|
|
2641
|
-
class=${
|
|
2641
|
+
class=${Wu(t,u)}
|
|
2642
2642
|
data-slice-id=${u.id}
|
|
2643
2643
|
style=${`left:${m}px;top:${f}px;width:${g}px;height:${_e}px`}
|
|
2644
2644
|
@pointerdown=${b=>l.slicePointerDown(u.id,b)}
|
|
2645
2645
|
></div>`})}
|
|
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:${
|
|
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:${rm(m.id)}deg;z-index:2`)})}
|
|
2647
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
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
2649
|
class="slice-port${b?" slice-port--on":""}"
|
|
@@ -2655,7 +2655,7 @@ 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 a
|
|
|
2655
2655
|
>
|
|
2656
2656
|
→
|
|
2657
2657
|
</button>`})}
|
|
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=
|
|
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=Gu.filter(y=>!g.has(y));return v`<div
|
|
2659
2659
|
class="slice-chips"
|
|
2660
2660
|
style=${`left:${m}px;top:${f+_e+6}px`}
|
|
2661
2661
|
@pointerdown=${y=>y.stopPropagation()}
|
|
@@ -2666,11 +2666,11 @@ 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 a
|
|
|
2666
2666
|
</div>`})}
|
|
2667
2667
|
</div>
|
|
2668
2668
|
</section>
|
|
2669
|
-
`},
|
|
2669
|
+
`},Qu=(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
|
|
2670
2670
|
class="context-region"
|
|
2671
2671
|
data-hue=${y}
|
|
2672
2672
|
data-dpk-target=${t.commentRef("context",a.id)}
|
|
2673
|
-
data-grill-questions=${Vt(
|
|
2673
|
+
data-grill-questions=${Vt(Yt(a.questions))}
|
|
2674
2674
|
style=${`left:${p}px;top:${m}px;width:${u-p}px;height:${f-m}px`}
|
|
2675
2675
|
title=${a.description??a.name}
|
|
2676
2676
|
></div>
|
|
@@ -2698,25 +2698,25 @@ ${o.renameContextHint}`}
|
|
|
2698
2698
|
>
|
|
2699
2699
|
✕
|
|
2700
2700
|
</button>
|
|
2701
|
-
</div>`]});return r.length>0?v`${r}`:T},
|
|
2701
|
+
</div>`]});return r.length>0?v`${r}`:T},Zu=t=>{if(t===void 0||!t.moved)return T;if(t.kind==="connect")return v`<svg class="gesture-layer" aria-hidden="true">
|
|
2702
2702
|
${Y`<path class="connect-line" d=${`M ${t.start.x} ${t.start.y} L ${t.current.x} ${t.current.y}`}></path>
|
|
2703
2703
|
<circle class="connect-tip" cx=${t.current.x} cy=${t.current.y} r="5"></circle>`}
|
|
2704
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
|
|
2705
2705
|
class="select-rect"
|
|
2706
2706
|
style=${`left:${e}px;top:${n}px;width:${o}px;height:${i}px`}
|
|
2707
|
-
></div>`}return T},
|
|
2707
|
+
></div>`}return T},Ju=(t,e,n)=>v`<div class="board-hud">
|
|
2708
2708
|
<span class="board-hud-stat">${t.noteCount(e.elements.length)}</span>
|
|
2709
2709
|
<span class="board-hud-stat">${t.sliceCount(n.length)}</span>
|
|
2710
2710
|
<span class="board-hud-stat">${t.contextCount(e.contexts.length)}</span>
|
|
2711
2711
|
<span class="board-hint">${t.hudHint}</span>
|
|
2712
|
-
</div>`,
|
|
2712
|
+
</div>`,em=t=>{const{m:e,viewport:n,handlers:o}=t;return v`<div class="board-zoom" @pointerdown=${i=>i.stopPropagation()}>
|
|
2713
2713
|
<button type="button" aria-label=${e.zoomOut} @click=${()=>o.zoomStep(-1)}>−</button>
|
|
2714
2714
|
<button type="button" class="board-zoom-pct" title=${e.zoomReset} @click=${()=>o.zoomReset()}>
|
|
2715
2715
|
${Math.round(n.zoom*100)}%
|
|
2716
2716
|
</button>
|
|
2717
2717
|
<button type="button" aria-label=${e.zoomIn} @click=${()=>o.zoomStep(1)}>+</button>
|
|
2718
2718
|
<button type="button" aria-label=${e.zoomFit} title=${e.zoomFit} @click=${()=>o.zoomFit()}>⛶</button>
|
|
2719
|
-
</div>`},
|
|
2719
|
+
</div>`},tm=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
|
|
2720
2720
|
label=${e.selectedLinks(i.length)}
|
|
2721
2721
|
@pointerdown=${d=>d.stopPropagation()}
|
|
2722
2722
|
@dpk-selection-clear=${()=>r.clearSelection()}
|
|
@@ -2755,16 +2755,16 @@ ${o.renameContextHint}`}
|
|
|
2755
2755
|
<button class="dpk-icon-btn" type="button" aria-label=${e.clearSelection} @click=${()=>r.clearSelection()}>
|
|
2756
2756
|
✕
|
|
2757
2757
|
</button>
|
|
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}}),
|
|
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}}),nm=()=>Y`<marker id="es-arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
|
2759
2759
|
<path d="M0,0 L8,4 L0,8 z"></path>
|
|
2760
|
-
</marker>`,
|
|
2760
|
+
</marker>`,om=(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
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>
|
|
2762
2762
|
<path class=${`link-path${p}`} d=${d} marker-end=${n}></path>
|
|
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>${
|
|
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=
|
|
2765
|
-
<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>${qu(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=im(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=yt(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,sm([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>${nm()}</defs>
|
|
2766
2766
|
${o}
|
|
2767
|
-
</svg>`},
|
|
2767
|
+
</svg>`},im=(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)},sm=(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}`},rm=t=>{let e=0;for(const n of t)e=(e*31+n.charCodeAt(0))%997;return(e%17-8)*.09},am=de`
|
|
2768
2768
|
/*
|
|
2769
2769
|
* The shell (\`<dpk-dialog-panel class="event-storming">\`) is a panel: header, tag
|
|
2770
2770
|
* row, viewport; \`--dpk-dialog-panel-height\` is the knob it reads for its own
|
|
@@ -3362,7 +3362,7 @@ ${o.renameContextHint}`}
|
|
|
3362
3362
|
flex: 1 1 auto;
|
|
3363
3363
|
min-width: 0;
|
|
3364
3364
|
}
|
|
3365
|
-
`,
|
|
3365
|
+
`,dm={width:260,height:150},lm={width:236,height:210},cm=64,pm=["event","command","aggregate","actor","policy","readmodel","external"],hm=1200,Vr=5,um={x:20,top:46,bottom:40},mm=264,gm="event-storming";class Qr extends rt{constructor(){super(...arguments),this.mode=Ae,this.boardWidth=hm,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 Su(this),this.#t=new vi(this)}boardAddable(){return!0}static{this.styles=[st,am]}#o;#i;#e;#t;parseData(e){return nu(e)}emptyData(){return ou()}reduceElementActions(e,n){return Ru(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",gm),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,lm),this.naming!==void 0&&this.#n("#context-pop",this.naming.point,dm,"#context-name")}#n(e,n,o,i){const s=this.renderRoot.querySelector(e);if(!s||s.matches(":popover-open")||(this.#i.open(s,ll(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(mm,this.boardWidth-96)}render(){this.prepareRender();const e=be(this.locale),n=this.chromeMessages,o=this.subject??this.defaultSubject();return v`
|
|
3366
3366
|
<dpk-dialog-panel
|
|
3367
3367
|
class=${this.shellClass()}
|
|
3368
3368
|
flush
|
|
@@ -3373,12 +3373,12 @@ ${o.renameContextHint}`}
|
|
|
3373
3373
|
@dpk-maximize-change=${()=>this.closeComposer()}
|
|
3374
3374
|
>
|
|
3375
3375
|
${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
|
|
3376
|
-
${this.dataError!==null?v`<p class="es-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:v`${
|
|
3376
|
+
${this.dataError!==null?v`<p class="es-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:v`${ju({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
3377
|
${this.mode.kind==="append"?this.#B(this.mode.sliceId):T}
|
|
3378
3378
|
${this.naming!==void 0?this.#Y(this.naming):T} `}
|
|
3379
3379
|
</dpk-dialog-panel>
|
|
3380
3380
|
${this.renderSelection()}
|
|
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(
|
|
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(um),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=[...gu(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)):cu(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(pu(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:hu(e,o,{width:n.width,height:n.height},cm),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=Ou(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?Tu(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)?fu(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:wu(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=fm("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">
|
|
3382
3382
|
<span class="dpk-label"> ${e.kind==="create-context"?n.newContextTitle:n.renameContextTitle} </span>
|
|
3383
3383
|
<input
|
|
3384
3384
|
id="context-name"
|
|
@@ -3404,7 +3404,7 @@ ${o.renameContextHint}`}
|
|
|
3404
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">
|
|
3405
3405
|
<span class="dpk-label">${i===void 0?n.appendMenuNext:n.appendMenuAfter(i.name)}</span>
|
|
3406
3406
|
<div class="type-options">
|
|
3407
|
-
${
|
|
3407
|
+
${pm.map(s=>v`<button
|
|
3408
3408
|
class="type-chip"
|
|
3409
3409
|
type="button"
|
|
3410
3410
|
data-type=${s}
|
|
@@ -3423,9 +3423,9 @@ ${o.renameContextHint}`}
|
|
|
3423
3423
|
${n.cancel}
|
|
3424
3424
|
</button>
|
|
3425
3425
|
</div>
|
|
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`
|
|
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),fm=(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=()=>{du(),customElements.get("dpk-board-event-storming")||customElements.define("dpk-board-event-storming",Qr)},bm=P({id:oe,name:S(k(),I(1)),description:j(k()),questions:nt}),xm=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}),ym=P({title:j(k()),stories:L(F(bm),[]),rules:L(F(xm),[]),examples:L(F(Jr),[]),questions:L(F(Jr),[])}),km=t=>{const e=ue(ym,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},vm=()=>({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}}},wm=(t,e)=>t.rules.filter(n=>n.storyId===e),$m=(t,e)=>t.examples.filter(n=>n.ruleId===e),Em=(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)],Tm=(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)}}},Sm=(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)}}},Mm=(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)}}},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:Wt(s,n,o,i)}}},Lm={story:"Story",rule:"Rule",example:"Example",question:"Question"},Im={story:"\u30B9\u30C8\u30FC\u30EA\u30FC",rule:"\u30EB\u30FC\u30EB",example:"\u5177\u4F53\u4F8B",question:"\u8CEA\u554F"},Am={empty:"No rules yet","open-questions":"Open questions","too-big":"Consider splitting",thin:"A rule has no example",ready:"Looks ready"},_m={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=>Lm[t],readinessLabel:t=>Am[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=>Im[t],readinessLabel:t=>_m[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:Le}),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:Le}),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:Le}),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:Le}),DELETE_QUESTION:z("DELETE_QUESTION","question",R({}))},Rm=(t,e)=>{const n=Gt(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=Dm(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 Vn(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)]},Dm=(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)},Om={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=Om[e.type];i=s?s(t,e,o??n):{title:e.type,tone:"meta"}}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:Nm(t,n,e.target),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},Nm=(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 ${qm(e)}`;default:return`${n.type} \xB7 ${n.id}`}}catch{return`${n.type} \xB7 ${n.id}`}},zm=4,Pm=(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>zm?"too-big":a?"thin":"ready";return{rules:o.length,examples:s.length,questions:r,readiness:d,label:t.readinessLabel(d)}},qm=t=>t.title??"Example Mapping",Fm=t=>t==="comment"?"meta":t,Um=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}},Bm=(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=Um(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=Rm(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:Fm(c.tone),...c.summary===void 0?{}:{summary:c.summary}}),o=l}return{data:o,results:i}},Hm={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}=Hm[t];return`--em-card-bg:${e};--em-card-ink:${n}`},aa=t=>{const e=t.currentTarget;e instanceof HTMLElement&&(e.draggable=t.type==="focusout")},Ym=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`
|
|
3427
3427
|
<div
|
|
3428
|
-
class=${
|
|
3428
|
+
class=${ke("em-card",s&&"is-focused",r&&"is-dragging")}
|
|
3429
3429
|
data-card=${n.id}
|
|
3430
3430
|
data-card-kind=${e}
|
|
3431
3431
|
data-mode=${i}
|
|
@@ -3457,7 +3457,7 @@ ${o.renameContextHint}`}
|
|
|
3457
3457
|
aria-label=${a.commentCard}
|
|
3458
3458
|
@click=${f=>{f.stopPropagation(),h(e,n.id)}}
|
|
3459
3459
|
>
|
|
3460
|
-
${
|
|
3460
|
+
${Xn()}
|
|
3461
3461
|
</button>
|
|
3462
3462
|
<button
|
|
3463
3463
|
class="dpk-icon-btn"
|
|
@@ -3470,7 +3470,7 @@ ${o.renameContextHint}`}
|
|
|
3470
3470
|
</button>
|
|
3471
3471
|
</div>
|
|
3472
3472
|
</div>
|
|
3473
|
-
`},Go={kind:"idle"},da=(t,e)=>t.kind!=="idle"&&t.cardId===e,
|
|
3473
|
+
`},Go={kind:"idle"},da=(t,e)=>t.kind!=="idle"&&t.cardId===e,Gm=(t,e)=>da(t,e)&&t.kind==="editing"?"editing":"view",Xm=(t,e,n)=>{switch(n.kind){case"rename":case"delete":return da(t,e)?Go:t;case"select":return t}},Km=(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},jm=t=>{const{state:e,handlers:n,m:o}=t;return e.stories.length===0?v`
|
|
3474
3474
|
<div class="empty">
|
|
3475
3475
|
<h2>${o.noStoriesTitle}</h2>
|
|
3476
3476
|
<p>${o.noStoriesBody}</p>
|
|
@@ -3478,12 +3478,12 @@ ${o.renameContextHint}`}
|
|
|
3478
3478
|
</div>
|
|
3479
3479
|
`:v`
|
|
3480
3480
|
<div class="board" data-testid="example-mapping-board">
|
|
3481
|
-
${Se(e.stories,i=>i.id,i=>
|
|
3481
|
+
${Se(e.stories,i=>i.id,i=>Wm(t,i))}
|
|
3482
3482
|
<button class="add-story" type="button" @click=${n.addStory}>${o.addStoryButton}</button>
|
|
3483
3483
|
</div>
|
|
3484
|
-
`},Xo=(t,e,n)=>{const{mode:o,drag:i,handlers:s,m:r}=t,a=i.source({type:e,id:n.id}),d=
|
|
3485
|
-
${
|
|
3486
|
-
</span>`},
|
|
3484
|
+
`},Xo=(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 v`<span class="card-slot">
|
|
3485
|
+
${Ym({kind:e,card:{id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description}},tilt:Km(e,n.id),mode:Gm(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>`},Wm=(t,e)=>{const{state:n,drag:o,handlers:i,m:s}=t,r=Pm(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`
|
|
3487
3487
|
<section
|
|
3488
3488
|
class="story-section"
|
|
3489
3489
|
data-story=${e.id}
|
|
@@ -3519,18 +3519,18 @@ ${o.renameContextHint}`}
|
|
|
3519
3519
|
@dragleave=${c.dragleave}
|
|
3520
3520
|
@drop=${c.drop}
|
|
3521
3521
|
>
|
|
3522
|
-
${Se(
|
|
3522
|
+
${Se(wm(n,e.id),h=>h.id,h=>Vm(t,h))}
|
|
3523
3523
|
<button class="add-rule" type="button" @click=${()=>i.addRule(e.id)}>
|
|
3524
3524
|
<span class="add-plus">+</span>${s.kindLabel("rule")}
|
|
3525
3525
|
</button>
|
|
3526
3526
|
</div>
|
|
3527
3527
|
</section>
|
|
3528
|
-
`},
|
|
3528
|
+
`},Vm=(t,e)=>{const{drag:n}=t;return v`
|
|
3529
3529
|
<div class="rule-col" data-rule=${e.id} ?data-dragging=${n.isDragging("rule",e.id)}>
|
|
3530
3530
|
${Xo(t,"rule",e)} ${la(t,e.id,"example")}
|
|
3531
3531
|
${la(t,e.id,"question")}
|
|
3532
3532
|
</div>
|
|
3533
|
-
`},
|
|
3533
|
+
`},Qm={example:"examples",question:"questions"},Zm=(t,e)=>({testid:Qm[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=Zm(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"?$m(o,e):Em(o,e),h=n==="example"?s.addExample:s.addQuestion;return v`<div
|
|
3534
3534
|
class="card-area card-area--${n}"
|
|
3535
3535
|
data-testid=${`${a.testid}-${e}`}
|
|
3536
3536
|
data-drop=${String(i.isOver(d))}
|
|
@@ -3543,7 +3543,7 @@ ${o.renameContextHint}`}
|
|
|
3543
3543
|
${Se(c,p=>p.id,p=>Xo(t,n,p))}
|
|
3544
3544
|
${c.length===0?v`<p class="stack-hint">${a.empty}</p>`:T}
|
|
3545
3545
|
<button class="add-card add-${n}" type="button" @click=${()=>h(e)}>${a.add}</button>
|
|
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},
|
|
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},Jm=de`
|
|
3547
3547
|
/* ------------------------------------------------------------- board */
|
|
3548
3548
|
|
|
3549
3549
|
.board {
|
|
@@ -3930,7 +3930,7 @@ ${o.renameContextHint}`}
|
|
|
3930
3930
|
background: color-mix(in srgb, var(--dpk-paper-raised) 94%, transparent);
|
|
3931
3931
|
box-shadow: var(--dpk-shadow-xs);
|
|
3932
3932
|
}
|
|
3933
|
-
`,
|
|
3933
|
+
`,eg={story:"SET_STORY_NAME",rule:"SET_RULE_NAME",example:"SET_EXAMPLE_NAME",question:"SET_QUESTION_NAME"},tg={story:"DELETE_STORY",rule:"DELETE_RULE",example:"DELETE_EXAMPLE",question:"DELETE_QUESTION"},ng="example-mapping";class ha extends rt{boardAddable(){return!0}static{this.styles=[st,Jm]}#o=new Ml(this);#i=null;#e=Go;parseData(e){return km(e)}emptyData(){return vm()}reduceElementActions(e,n){return Bm(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`
|
|
3934
3934
|
<dpk-dialog-panel
|
|
3935
3935
|
class=${this.shellClass()}
|
|
3936
3936
|
?maximizable=${this.frameControls}
|
|
@@ -3940,10 +3940,10 @@ ${o.renameContextHint}`}
|
|
|
3940
3940
|
@dpk-maximize-change=${()=>this.closeComposer()}
|
|
3941
3941
|
>
|
|
3942
3942
|
${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
|
|
3943
|
-
${this.dataError!==null?v`<p class="em-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:
|
|
3943
|
+
${this.dataError!==null?v`<p class="em-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:jm({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))})}
|
|
3944
3944
|
</dpk-dialog-panel>
|
|
3945
3945
|
${this.renderSelection()}
|
|
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`
|
|
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=ye(`story ${n}`,e);this.#n(this.dispatchElementAction("ADD_STORY",["page",ng],{id:o,name:n})?o:null)}#r(e){const n=wn(this.items()),o=Be(this.locale).newRule,i=ye(`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=ye(`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=ye(`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(eg[n],[n,e],{name:o.name});break;case"delete":this.dispatchElementAction(tg[n],[n,e],{}),this.selection?.id===e&&this.select(null);break}this.#e=Xm(this.#e,e,o),this.requestUpdate()}#h(e){const n=Tm(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=Sm(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=Mm(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 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(),Li(),Xt(1)),og=P({url:Ai,label:j(S(k(),I(1)))}),ig=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(og)),questions:L(k())}),sg=["gray","blue","green","amber","violet","red"],rg=P({id:S(k(),I(1)),label:S(k(),I(1)),description:L(k()),color:L(G(sg)),limit:L(S(ce(),Li(),Xt(1))),cards:L(F(ig))}),ag=P({columns:F(rg)}),dg=()=>({columns:[]}),lg=t=>{const e=ue(ag,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),cg=(t,e)=>e===null?t:{columns:t.columns.map(n=>({...n,cards:n.cards.filter(e)}))},pg=(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}`,hg=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",ug=R({id:S(k(),I(1)),title:S(k(),we(),I(1)),number:L(ma)}),mg=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},gg=(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)]}})}),fg=(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(ug,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??hg(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"}}},bg=(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(mg,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(gg(e,s.id),h,{column:d.id,before:l}),result:{id:n.id,title:o,summary:p,tone:"move"}}},xg=(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:xg(e,a),result:{id:n.id,title:o,summary:t.editSummary(Mn(r),r.title),tone:"update"}}},yg=R({title:S(k(),we(),I(1))}),kg=R({description:k()}),vg=R({assignee:k()}),Ta=R({tag:S(k(),we(),I(1))}),wg=R({url:Ai,label:j(S(k(),we(),I(1)))}),$g=R({url:S(k(),I(1))}),Eg=(t,e,n)=>{const o=re(yg,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"}}},Tg=(t,e,n)=>{const o=re(kg,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}))},Sg=(t,e,n)=>{const o=re(vg,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}))},Mg=(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]})},Cg=(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)},Lg=(t,e,n)=>{const o=re(wg,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]})},Ig=(t,e,n)=>{const o=re($g,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)},Ag=(t,e,n)=>{let o=e;const i=[];for(const s of n){const r=s.type===ga?fg(t,o,s):s.type===fa?bg(t,o,s):s.type===ba?Eg(t,o,s):s.type===xa?Tg(t,o,s):s.type===ya?Sg(t,o,s):s.type===ka?Mg(t,o,s):s.type===va?Cg(t,o,s):s.type===wa?Lg(t,o,s):s.type===$a?Ig(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}},_g=de`
|
|
3947
3947
|
/* The columns and, while a card is open, its detail beside them. */
|
|
3948
3948
|
.kanban-stage {
|
|
3949
3949
|
display: flex;
|
|
@@ -4464,7 +4464,7 @@ ${o.renameContextHint}`}
|
|
|
4464
4464
|
max-height: none;
|
|
4465
4465
|
}
|
|
4466
4466
|
}
|
|
4467
|
-
`,
|
|
4467
|
+
`,Rg=3;class Sa extends rt{boardAddable(){return!0}static{this.styles=[st,Ll,Il,_g]}#o=null;#i=null;#e=null;#t=null;#n=!1;#a=!1;#r=null;#s=null;parseData(e){return lg(e)}emptyData(){return dg()}reduceElementActions(e,n){return Ag(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:()=>{Ti(s)}},{kind:"item",id:"copy-card-key-title",label:i.copyKeyTitle,run:()=>{Ti(`${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`
|
|
4468
4468
|
<dpk-dialog-panel
|
|
4469
4469
|
class=${this.shellClass()}
|
|
4470
4470
|
?maximizable=${this.frameControls}
|
|
@@ -4482,9 +4482,9 @@ ${o.renameContextHint}`}
|
|
|
4482
4482
|
${Se(e.columns,s=>s.id,s=>this.#u(s,n.get(s.id)??0))}
|
|
4483
4483
|
</div>
|
|
4484
4484
|
${o===void 0?T:this.#b(o,i,Ve(this.locale))}
|
|
4485
|
-
</div>`}#h(){const e=this.tagFilter;return
|
|
4485
|
+
</div>`}#h(){const e=this.tagFilter;return cg(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`
|
|
4486
4486
|
<section
|
|
4487
|
-
class=${
|
|
4487
|
+
class=${ke("kanban-column",i&&"is-over",this.#p("column",e.id)&&"is-selected",s!==null&&"is-drop-target")}
|
|
4488
4488
|
data-column=${e.id}
|
|
4489
4489
|
data-color=${e.color??T}
|
|
4490
4490
|
aria-label=${e.label}
|
|
@@ -4522,7 +4522,7 @@ ${o.renameContextHint}`}
|
|
|
4522
4522
|
role="button"
|
|
4523
4523
|
tabindex="0"
|
|
4524
4524
|
draggable="true"
|
|
4525
|
-
class=${
|
|
4525
|
+
class=${ke("dpk-card","kanban-card",e.change==="added"&&"is-added",e.change==="moved"&&"is-moved")}
|
|
4526
4526
|
data-state=${this.#r===e.id?"dragging":T}
|
|
4527
4527
|
data-card=${e.id}
|
|
4528
4528
|
data-grill-questions=${this.questionsOf(e)}
|
|
@@ -4550,7 +4550,7 @@ ${o.renameContextHint}`}
|
|
|
4550
4550
|
</div>
|
|
4551
4551
|
${this.#e===e.id?v`<p class="kanban-error" role="alert">${n.notRecorded}</p>`:T}
|
|
4552
4552
|
</div>
|
|
4553
|
-
`}#g(e){const n=e.links.slice(0,
|
|
4553
|
+
`}#g(e){const n=e.links.slice(0,Rg);return v`<div class="dpk-card-row kanban-card-links">
|
|
4554
4554
|
${n.map(o=>{const i=Qn(o.url);return v`<a
|
|
4555
4555
|
class="link-chip"
|
|
4556
4556
|
data-kind=${i.kind}
|
|
@@ -4581,7 +4581,7 @@ ${o.renameContextHint}`}
|
|
|
4581
4581
|
aria-label=${o.closeCardDetail}
|
|
4582
4582
|
@click=${()=>this.#x()}
|
|
4583
4583
|
>
|
|
4584
|
-
${
|
|
4584
|
+
${Kn()}
|
|
4585
4585
|
</button>
|
|
4586
4586
|
</header>
|
|
4587
4587
|
<div class="kanban-detail-body">
|
|
@@ -4625,7 +4625,7 @@ ${o.renameContextHint}`}
|
|
|
4625
4625
|
aria-label=${o.removeTagAria(s)}
|
|
4626
4626
|
@click=${()=>i(va,{tag:s})}
|
|
4627
4627
|
>
|
|
4628
|
-
${
|
|
4628
|
+
${Kn()}
|
|
4629
4629
|
</button></span
|
|
4630
4630
|
>`)}
|
|
4631
4631
|
<input
|
|
@@ -4662,7 +4662,7 @@ ${o.renameContextHint}`}
|
|
|
4662
4662
|
aria-label=${o.removeLinkAria(s.url)}
|
|
4663
4663
|
@click=${()=>i($a,{url:s.url})}
|
|
4664
4664
|
>
|
|
4665
|
-
${
|
|
4665
|
+
${Kn()}
|
|
4666
4666
|
</button>
|
|
4667
4667
|
</li>`)}
|
|
4668
4668
|
</ul>`}
|
|
@@ -4707,7 +4707,7 @@ ${o.renameContextHint}`}
|
|
|
4707
4707
|
/>
|
|
4708
4708
|
${o.failed?v`<span class="kanban-error" role="alert">${n.notRecorded}</span>`:T}
|
|
4709
4709
|
`}
|
|
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(),
|
|
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(),pg(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=ye("kanban",r)}const i=[...this.items().columns.map(r=>r.id),...Qe(this.items()).map(r=>r.id)],s=ye(`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],Dg=t=>Ca[Math.min(t,Ca.length-1)]??40,Ia=t=>La[Math.min(t,La.length-1)]??8,Og=(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 _=Dg(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}},Ng=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=El(()=>P({id:S(k(),I(1)),label:S(k(),I(1)),description:L(k()),tags:L(F(k())),questions:L(k()),collapsed:L(kt()),side:L(G(["left","right"])),children:L(F(Aa))})),zg=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}],Pg=t=>Ra[Math.min(t,Ra.length-1)]??{fontSize:12.5,padding:12,height:28,min:56,max:220},qg=(t,e)=>{let n=0;for(const o of t)n+=(o.codePointAt(0)??0)>=11904?e:e*.62;return n},Fg=(t,e)=>{const n=Pg(e),o=Math.ceil(qg(t,n.fontSize)+n.padding*2+4);return{width:Math.min(n.max,Math.max(n.min,o)),height:n.height}},Ug=t=>({left:{x:0,y:t.height/2},right:{x:t.width,y:t.height/2}}),Bg=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})},Hg=t=>Oa(ue(zg,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=Fg(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:Ug(p),...r.questions===void 0?{}:{questions:r.questions}}),a!==null&&c!==null&&o.push({id:r.id,from:a,to:r.id,tags:[],...Bg(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",Yg=R({id:S(k(),I(1)),label:S(k(),we(),I(1))}),Gg=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))},Xg=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"}))}},Kg=(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:Xg(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=Gg(d.target.id),c=l===null?void 0:i.get(l),h=re(Yg,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},jg=(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},Wg=(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))}},Vg=de`
|
|
4711
4711
|
.branch-root {
|
|
4712
4712
|
--mind-color: var(--dpk-ink);
|
|
4713
4713
|
--mind-soft: var(--dpk-paper-sunken);
|
|
@@ -4924,14 +4924,14 @@ ${o.renameContextHint}`}
|
|
|
4924
4924
|
opacity: 1;
|
|
4925
4925
|
}
|
|
4926
4926
|
}
|
|
4927
|
-
`,
|
|
4927
|
+
`,Qg=5,Pa=.6;class qa extends at{static{this.styles=[Ne,Vg]}#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 Hg(e)}emptyData(){return _a()}reduceElementActions(e,n){return Kg(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 Wg(this.items(),n,this.#o)}layoutSignature(){return this.filtered().nodes.map(e=>`${e.id}<${e.parent??""}:${e.side??""}`).join(",")}computePlacement(e){return Og(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=ve(n.edges,e.id,"outgoing",!0),i=ve(n.edges,e.id,"incoming",!0);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}renderCanvas(){const e=this.filtered(),n=Dt(this.locale);return v`
|
|
4928
4928
|
${this.renderEdges(e.edges.map(o=>this.#a(o)),[])}
|
|
4929
4929
|
${e.nodes.map(o=>this.#r(o,n))} ${this.#d(n)}
|
|
4930
|
-
`}#n(e){return e===void 0||e.branch<0?"branch-root":`branch-${e.branch%
|
|
4930
|
+
`}#n(e){return e===void 0||e.branch<0?"branch-root":`branch-${e.branch%Qg}`}#a(e){const n=this.items().nodes.find(i=>i.id===e.to),o=this.edgeState(e.id);return Y`
|
|
4931
4931
|
<path
|
|
4932
4932
|
class=${this.elementClass(o,"d-edge","mind-branch",this.#n(n),`depth-${Math.min(n?.depth??1,3)}`)}
|
|
4933
4933
|
data-branch=${e.id}
|
|
4934
|
-
d=${
|
|
4934
|
+
d=${Ng(this.routeOf(e.id))}
|
|
4935
4935
|
></path>
|
|
4936
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`
|
|
4937
4937
|
<button
|
|
@@ -4949,7 +4949,7 @@ ${o.renameContextHint}`}
|
|
|
4949
4949
|
<span class="mind-label">${e.label}</span>
|
|
4950
4950
|
</button>
|
|
4951
4951
|
${e.depth===0||e.children.length===0?T:this.#s(e,o,s,i.dimmed,n)}
|
|
4952
|
-
`}#s(e,n,o,i,s){const r=o?
|
|
4952
|
+
`}#s(e,n,o,i,s){const r=o?jg(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`
|
|
4953
4953
|
<button
|
|
4954
4954
|
type="button"
|
|
4955
4955
|
class=${this.elementClass({selected:!1,related:!1,dimmed:i,depth:null},"mind-toggle",this.#n(e),o&&"is-folded")}
|
|
@@ -4985,7 +4985,7 @@ ${o.renameContextHint}`}
|
|
|
4985
4985
|
${s.failed?v`<span class="mind-actions-error" role="alert">${e.notRecorded}</span>`:T}
|
|
4986
4986
|
`}
|
|
4987
4987
|
</div>
|
|
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=
|
|
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=ye(`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`}}),Zg=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())}),Jg=P({label:S(k(),I(1)),items:F(Ii())}),ef=P({kind:he("fragment"),id:S(k(),I(1)),operator:G(["alt","opt","loop","par"]),title:S(k(),I(1)),collapsed:L(kt(),!1),branches:S(F(Jg),I(1))}),tf=Wn("kind",[Zg,ef]),nf=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())}),of=P({participants:S(F(nf),I(1)),items:L(F(Ii()),[])}),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(tf,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)}))}}),sf=t=>{const e=ue(of,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)}},rf=()=>({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")])),af=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},df=64,lf=86,cf=31,pf=32,hf=40,uf=(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?lf:df;continue}const b=22+f*13,y=p,x=r-44-f*26;p+=cf,g.collapsed?(h.push({fragment:g,x:b,y:p+6,width:x}),p+=hf):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+=pf,u(w.items,f+1),p+=8}),d.push({fragment:g,x:b,y,width:x,height:p-y,count:af([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}},mf=de`
|
|
4989
4989
|
.sequence::part(canvas) {
|
|
4990
4990
|
background-image: none;
|
|
4991
4991
|
}
|
|
@@ -5293,7 +5293,7 @@ ${o.renameContextHint}`}
|
|
|
5293
5293
|
fill: var(--dpk-ink);
|
|
5294
5294
|
stroke: var(--dpk-ink);
|
|
5295
5295
|
}
|
|
5296
|
-
`,
|
|
5296
|
+
`,gf=[{id:"seq-request"},{id:"seq-response"},{id:"seq-async"},{id:"seq-related"},{id:"seq-selected"}];class Xa extends so{static{this.styles=[Ne,mf]}#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(),sf(e)}emptyData(){return rf()}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=uf(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
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
5298
|
<div
|
|
5299
5299
|
class="sequence-rail"
|
|
@@ -5359,7 +5359,7 @@ ${o.renameContextHint}`}
|
|
|
5359
5359
|
<path class="sequence-message is-${r.message.style}" d=${l} marker-end=${`url(#${h})`}></path>
|
|
5360
5360
|
</g>
|
|
5361
5361
|
`});return v`<svg class="diagram-edges" width=${e.width} height=${e.height}>
|
|
5362
|
-
${rs(
|
|
5362
|
+
${rs(gf)} ${o} ${i} ${s}
|
|
5363
5363
|
</svg>`}#g(e,n,o,i,s,r){const a=this.#c(e);return v`
|
|
5364
5364
|
<button
|
|
5365
5365
|
type="button"
|
|
@@ -5370,7 +5370,7 @@ ${o.renameContextHint}`}
|
|
|
5370
5370
|
aria-label=${r.frameHeaderLabel(e.operator,e.title,a)}
|
|
5371
5371
|
@click=${()=>this.#h(e)}
|
|
5372
5372
|
>
|
|
5373
|
-
<span class="sequence-frame-chevron">${a?cl():
|
|
5373
|
+
<span class="sequence-frame-chevron">${a?cl():Si()}</span>
|
|
5374
5374
|
<span class="sequence-operator">${e.operator}</span>
|
|
5375
5375
|
<span class="sequence-text">${e.title}</span>
|
|
5376
5376
|
<span class="sequence-frame-count">${r.frameCount(s)}</span>
|
|
@@ -5390,7 +5390,7 @@ ${o.renameContextHint}`}
|
|
|
5390
5390
|
<span class="sequence-number">${this.#i.get(n.id)??""}</span>
|
|
5391
5391
|
<span class="sequence-text">${n.title}</span>
|
|
5392
5392
|
</button>
|
|
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}`}}),
|
|
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}`}}),ff=P({x:ce(),y:ce()}),bf=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(ff),questions:L(k())}),xf=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},yf=()=>({nodes:[],edges:[]}),kf=P({states:F(bf),transitions:L(F(xf),[])}),vf=t=>{const e=ue(kf,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}},wf=t=>t.length>0&&t.every(e=>e.position!==void 0),$f={portGap:16,laneGap:10,margin:12},Ef=12,Tf=14,Sf=18,Mf=14,Ln=22,In=18,Cf=4,Lf=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]),If=(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",Af=(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(Tf,(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>Lf?Number.POSITIVE_INFINITY:u(m);if(Number.isFinite(f))for(let b=0;b<Cf&&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},_f=(t,e,n={})=>{const o={...$f,...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:Ef,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?If(A,C,$):"right"}}),a=Af(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)+Sf+u*Mf;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]}},Rf=de`
|
|
5394
5394
|
.state-node {
|
|
5395
5395
|
display: flex;
|
|
5396
5396
|
flex-direction: column;
|
|
@@ -5548,12 +5548,12 @@ ${o.renameContextHint}`}
|
|
|
5548
5548
|
fill: var(--dpk-amber);
|
|
5549
5549
|
stroke: var(--dpk-amber);
|
|
5550
5550
|
}
|
|
5551
|
-
`,
|
|
5552
|
-
${this.renderEdges([...n,...this.visible.edges.map(o=>this.#t(o))],
|
|
5551
|
+
`,Df=[{id:"state-arrow"},{id:"state-arrow-active"},{id:"state-arrow-exception"}];class Qa extends at{static{this.styles=[Ne,Rf]}parseData(e){return vf(e)}emptyData(){return yf()}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 wf(this.filtered().nodes)?"fixed":"layered"}layoutOptions(){return this.layoutMode==="fixed"?{padding:44}:{nodeSpacing:40,layerSpacing:110,padding:44}}routePlacement(e,n){return _f(e,n.edges)}relations(e,n){if(e===null||e.kind!=="node")return Ce;const o=ve(n.edges,e.id,"outgoing",!1),i=ve(n.edges,e.id,"incoming",!1);return{nodes:new Map([...o.nodes,...i.nodes]),edges:new Set([...o.edges,...i.edges])}}commentItems(){const e=this.items(),n=o=>e.nodes.find(i=>i.id===o)?.name??o;return[...e.nodes.map(o=>({value:this.commentRef("node",o.id),label:o.name})),...e.edges.map(o=>({value:this.commentRef("edge",o.id),label:`${n(o.from)} \u2192 ${n(o.to)} \xB7 ${o.title}`}))]}renderCanvas(){const e=this.visible.nodes,n=e.filter(o=>o.kind==="initial").map(o=>this.#e(o));return v`
|
|
5552
|
+
${this.renderEdges([...n,...this.visible.edges.map(o=>this.#t(o))],Df)}
|
|
5553
5553
|
${e.map(o=>this.#n(o))} ${this.visible.edges.map(o=>this.#a(o))}
|
|
5554
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(`
|
|
5555
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`
|
|
5556
|
-
<g class=${
|
|
5556
|
+
<g class=${ke("state-initial-mark",i.dimmed&&"is-dimmed")}>
|
|
5557
5557
|
<circle cx=${n.x-22} cy=${o} r="5"></circle>
|
|
5558
5558
|
<path
|
|
5559
5559
|
d=${on([{x:n.x-17,y:o},{x:n.x-1,y:o}])}
|
|
@@ -5608,13 +5608,13 @@ ${o.renameContextHint}`}
|
|
|
5608
5608
|
${e.title}
|
|
5609
5609
|
</button>
|
|
5610
5610
|
</span>
|
|
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
|
|
5611
|
+
`}}const Za=()=>{customElements.get("dpk-board-state-diagram")||customElements.define("dpk-board-state-diagram",Qa)},ei=["yellow","orange","pink","purple","blue","green","gray"],Of=["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},Nf=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}),zf=P({...Dn,kind:he("text"),w:L(Xe,Ge.text.w),h:L(Xe,Ge.text.h),text:L(k(),""),fontSize:oi}),Pf=P({...Dn,kind:he("shape"),shape:L(G(Of),"rect"),w:L(Xe,Ge.shape.w),h:L(Xe,Ge.shape.h),text:L(k(),""),color:L(ni,mt.shape),fontSize:oi}),qf=P({...Dn,kind:he("frame"),w:Xe,h:Xe,title:S(k(),I(1)),color:L(ni,mt.frame)}),td=Wn("kind",[Nf,zf,Pf,qf]),Ff=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")}),Uf=P({title:j(k()),items:L(F(td),[]),connectors:L(F(Ff),[])}),Bf=t=>{const e=ue(Uf,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},Hf=()=>({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,Yf=(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)||Yf(s,n,o)&&(i===void 0||Nn(s)<Nn(i))&&(i=s);return i},Gf=(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:Le}),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:Le}),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")],Xf=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=Xf(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}),Kf=(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}=Kf(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,jf=(t,e)=>e>.5?{w:t.w,h:Math.ceil(t.h+e)}:void 0,Wf=(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},Vf=(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)}),Qf=(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,Zf=(t,e)=>t.items.filter(n=>n.kind==="frame"?Qf(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,Jf=(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])}},eb=(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},tb=(t,e,n)=>{const o=dd(t),i=new Set(e.filter(s=>o.some(r=>r.id===s)));return i.size===0?[]:eb(o,cd(o,i,n),i)},nb=(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}},ob=(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)}},ib=["sticky","text","rect","ellipse","frame"],sb=t=>t==="rect"||t==="ellipse"?Ge.shape:Ge[t],rb=(t,e,n,o)=>{const{w:i,h:s}=sb(n),r={x:Math.round(o.x-i/2),y:Math.round(o.y-s/2)},a=Jf(t,{...r,w:i,h:s},n==="frame"),c={id:ye(`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}}},ab=(t,e,n)=>ye(`${e}-to-${n}`,ii(t)),db=24,lb=(t,e,n)=>{const o=new Set(ii(t));return e.map(i=>{const s=i.kind==="shape"?"shape":i.kind,r=ye(`new-${s}`,o);return o.add(r),{...i,id:r,x:i.x+n,y:i.y+n}})},cb=(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,pb={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,...Gf(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}},hb=(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}},ub=(t,e)=>({kind:"pan",pointerId:t,start:e,last:e,moved:!1}),mb=(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}),gb=(t,e,n,o,i)=>{const s=Wf(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?Vf(t.start,t.current):void 0,md=(t,e)=>{const n=ud(e);if(e.kind!=="marquee"||n===void 0)return[];const o=Zf(t,n).map(i=>i.id);return[...new Set([...e.base,...o])]},fb=(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)),bb=(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=pb[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?bb(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}},xb=(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,yb=2.5,kb={x:0,y:0,zoom:1},vb=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=yt(t.zoom*n,Un,yb),i=ci(t,e);return{zoom:o,x:e.x-i.x*o,y:e.y-i.y*o}},wb=(t,e,n=48,o=1)=>{const i=Math.max(1,e.width-n*2),s=Math.max(1,e.height-n*2),r=yt(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}},$b=(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},Eb=(t,e,n)=>{if(e===null||n.width<=0||n.height<=0)return t;const o=(i,s,r,a)=>{const d=Math.min(vb,a/2),l=d-(s+r)*t.zoom,c=a-d-s*t.zoom;return yt(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)}},Tb=(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},Sb=(t,e)=>t.x===e.x&&t.y===e.y&&t.zoom===e.zoom,Mb={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"},Cb={rect:"Rectangle",ellipse:"Ellipse"},Lb={rect:"\u56DB\u89D2\u5F62",ellipse:"\u6955\u5186"},Ib={yellow:"Yellow",orange:"Orange",pink:"Pink",purple:"Purple",blue:"Blue",green:"Green",gray:"Gray"},Ab={yellow:"\u9EC4",orange:"\u30AA\u30EC\u30F3\u30B8",pink:"\u30D4\u30F3\u30AF",purple:"\u7D2B",blue:"\u9752",green:"\u7DD1",gray:"\u30B0\u30EC\u30FC"},_b={small:"Small",medium:"Medium",large:"Large",xlarge:"Extra large"},Rb={small:"\u5C0F",medium:"\u4E2D",large:"\u5927",xlarge:"\u7279\u5927"},Db={straight:"Straight",elbow:"Elbow",curve:"Curved"},Ob={straight:"\u76F4\u7DDA",elbow:"\u30AB\u30AE\u7DDA",curve:"\u66F2\u7DDA"},vd={small:"S",medium:"M",large:"L",xlarge:"XL"},Ft=pe({en:{kindLabel:t=>Mb[t],shapeLabel:t=>Cb[t],colorLabel:t=>Ib[t],fontSizeLabel:t=>_b[t],fontSizeShort:t=>vd[t],routeLabel:t=>Db[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=>Lb[t],colorLabel:t=>Ab[t],fontSizeLabel:t=>Rb[t],fontSizeShort:t=>vd[t],routeLabel:t=>Ob[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))}`,Nb=(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)},zb=(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:Nb(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=Gt(si,e);i=s===null?{title:e.type,tone:"meta"}:zb(t,s,n,o)}catch{i={title:e.type,tone:"meta"}}return{title:i.title,targetLabel:Pb(t,n,e.target,o),tone:i.tone,...i.body===void 0?{}:{summary:i.body}}},Pb=(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}`}},qb=(t,e)=>{const n=Gt(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 Fb(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 Vn(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)}},Fb=(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)}},Ub=t=>t==="comment"?"meta":t,Bb=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}},Hb=(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=Bb(s.target.id);if(a===null){i.push({id:s.id,title:r,stale:"target-missing"});continue}const d={...s,target:a},l=qb(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:Ub(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,Yb={front:Me(Al),forward:Me(hl),backward:Me(pl),back:Me(Dl)},Md=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}]],Gb={straight:Me([...Md,["path",{d:"M6.5 17.5 17.5 6.5"}]]),elbow:Me([...Md,["path",{d:"M7 19h5V5h5"}]]),curve:Me(Ol)},Xb=t=>Yb[t](),Kb=t=>Gb[t](),jb=Me(_l),Wb=Me(Rl),Vb={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}=Vb[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},Qb=t=>{const e=24*t.zoom;return`background-size:${e}px ${e}px;background-position:${t.x}px ${t.y}px`},Zb=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
|
|
5612
5612
|
class=${r.join(" ")}
|
|
5613
5613
|
data-testid="wb-canvas"
|
|
5614
5614
|
tabindex="0"
|
|
5615
5615
|
role="application"
|
|
5616
5616
|
aria-label=${e.canvasLabel}
|
|
5617
|
-
style=${
|
|
5617
|
+
style=${Qb(o)}
|
|
5618
5618
|
@pointerdown=${s.canvasPointerDown}
|
|
5619
5619
|
@pointermove=${s.canvasPointerMove}
|
|
5620
5620
|
@pointerup=${s.canvasPointerUp}
|
|
@@ -5629,22 +5629,22 @@ ${o.renameContextHint}`}
|
|
|
5629
5629
|
class="wb-world"
|
|
5630
5630
|
style=${`transform:translate(${o.x}px, ${o.y}px) scale(${o.zoom});--wb-zoom:${o.zoom}`}
|
|
5631
5631
|
>
|
|
5632
|
-
${Se(a,d=>d.id,d=>
|
|
5633
|
-
${
|
|
5632
|
+
${Se(a,d=>d.id,d=>tx(t,d))}
|
|
5633
|
+
${sx(t)} ${rx(t)}
|
|
5634
5634
|
</div>
|
|
5635
5635
|
${n.items.length===0?v`<p class="wb-hint wb-hint--empty">${e.emptyHint}</p>`:T}
|
|
5636
|
-
${
|
|
5637
|
-
${
|
|
5638
|
-
</div>`},
|
|
5636
|
+
${Jb(t)} ${i?.moved===!0?T:t.overlay} ${ax(e,s)}
|
|
5637
|
+
${dx(e,o,s)}
|
|
5638
|
+
</div>`},Jb=({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
|
|
5639
5639
|
class="wb-marquee"
|
|
5640
5640
|
aria-hidden="true"
|
|
5641
5641
|
style=${`left:${n.x}px;top:${n.y}px;${o}`}
|
|
5642
|
-
></div>`},
|
|
5643
|
-
class=${
|
|
5642
|
+
></div>`},ex=(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(" ")},tx=(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=${ex(t,e)}
|
|
5644
5644
|
style=${`${o}${i}${s}`}
|
|
5645
5645
|
data-item-id=${e.id}
|
|
5646
5646
|
data-dpk-target=${t.commentRef("item",e.id)}
|
|
5647
|
-
data-grill-questions=${Vt(
|
|
5647
|
+
data-grill-questions=${Vt(Yt(e.questions))}
|
|
5648
5648
|
data-kind=${e.kind}
|
|
5649
5649
|
@pointerdown=${e.kind==="frame"?T:d}
|
|
5650
5650
|
>
|
|
@@ -5658,10 +5658,10 @@ ${o.renameContextHint}`}
|
|
|
5658
5658
|
aria-label=${t.m.comment}
|
|
5659
5659
|
@click=${()=>t.onComment(e.id)}
|
|
5660
5660
|
>
|
|
5661
|
-
${
|
|
5661
|
+
${Xn()}
|
|
5662
5662
|
</button>
|
|
5663
5663
|
</div>`}
|
|
5664
|
-
${a?v`${
|
|
5664
|
+
${a?v`${nx.map(l=>v`<span
|
|
5665
5665
|
class=${`wb-edge wb-edge--${l}`}
|
|
5666
5666
|
role="presentation"
|
|
5667
5667
|
aria-hidden="true"
|
|
@@ -5679,7 +5679,7 @@ ${o.renameContextHint}`}
|
|
|
5679
5679
|
title=${t.m.connectHandle}
|
|
5680
5680
|
@pointerdown=${l=>n.connectPointerDown(e.id,l)}
|
|
5681
5681
|
></span>`:T}
|
|
5682
|
-
</div>`},
|
|
5682
|
+
</div>`},nx=["n","e","s","w","ne","sw","nw"],ox=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"
|
|
5683
5683
|
><span class="wb-text" aria-hidden="true" data-copy=${i||n.textPlaceholder}></span
|
|
5684
5684
|
><input
|
|
5685
5685
|
class="wb-editor"
|
|
@@ -5698,16 +5698,16 @@ ${o.renameContextHint}`}
|
|
|
5698
5698
|
spellcheck="false"
|
|
5699
5699
|
@blur=${s}
|
|
5700
5700
|
@keydown=${r}
|
|
5701
|
-
@wheel=${
|
|
5702
|
-
></textarea>`},
|
|
5701
|
+
@wheel=${ox}
|
|
5702
|
+
></textarea>`},ix=()=>Y`<marker id="wb-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse">
|
|
5703
5703
|
<path d="M0,0 L10,5 L0,10 z"></path>
|
|
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,
|
|
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,sx=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">
|
|
5705
5705
|
<path class="wb-link-hit" d=${d} @pointerdown=${c=>n.connectorPointerDown(r.id,c)}></path>
|
|
5706
5706
|
<path class=${`wb-link${l}`} d=${d} marker-end=${r.style==="arrow"?"url(#wb-arrow)":T}></path>
|
|
5707
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>${
|
|
5708
|
+
<defs>${ix()}</defs>
|
|
5709
5709
|
${i} ${s}
|
|
5710
|
-
</svg>`},
|
|
5710
|
+
</svg>`},rx=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
|
|
5711
5711
|
class=${`wb-link-label${r}`}
|
|
5712
5712
|
data-connector-label=${o.id}
|
|
5713
5713
|
data-dpk-target=${Dd(t,o,!0)}
|
|
@@ -5716,8 +5716,8 @@ ${o.renameContextHint}`}
|
|
|
5716
5716
|
@pointerdown=${a=>n.connectorPointerDown(o.id,a)}
|
|
5717
5717
|
>
|
|
5718
5718
|
${o.label??T}
|
|
5719
|
-
</div>`]})},xt=t=>t.stopPropagation(),
|
|
5720
|
-
${
|
|
5719
|
+
</div>`]})},xt=t=>t.stopPropagation(),ax=(t,e)=>v`<div class="wb-tools" role="toolbar" aria-label=${t.toolsLabel} @pointerdown=${xt} @dblclick=${xt}>
|
|
5720
|
+
${ib.map(n=>v`<button
|
|
5721
5721
|
type="button"
|
|
5722
5722
|
class="wb-tool"
|
|
5723
5723
|
data-add=${n}
|
|
@@ -5727,16 +5727,16 @@ ${o.renameContextHint}`}
|
|
|
5727
5727
|
>
|
|
5728
5728
|
<span class=${`wb-tool-icon wb-tool-icon--${n}`} aria-hidden="true"></span>
|
|
5729
5729
|
</button>`)}
|
|
5730
|
-
</div>`,
|
|
5730
|
+
</div>`,dx=(t,e,n)=>v`<div class="wb-zoom" @pointerdown=${xt} @dblclick=${xt}>
|
|
5731
5731
|
<button type="button" aria-label=${t.zoomOut} @click=${()=>n.zoomStep(-1)}>${ul()}</button>
|
|
5732
5732
|
<button type="button" class="wb-zoom-pct" title=${t.zoomReset} @click=${()=>n.zoomReset()}>
|
|
5733
5733
|
${Math.round(e.zoom*100)}%
|
|
5734
5734
|
</button>
|
|
5735
|
-
<button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${
|
|
5735
|
+
<button type="button" aria-label=${t.zoomIn} @click=${()=>n.zoomStep(1)}>${Gn()}</button>
|
|
5736
5736
|
<button type="button" aria-label=${t.zoomFit} title=${t.zoomFit} @click=${()=>n.zoomFit()}>
|
|
5737
|
-
${
|
|
5737
|
+
${Wb()}
|
|
5738
5738
|
</button>
|
|
5739
|
-
</div>`,ui={item:14,frame:40,connector:18},
|
|
5739
|
+
</div>`,ui={item:14,frame:40,connector:18},lx=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,cx=t=>{const e=lx(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
|
|
5740
5740
|
class="wb-toolbar"
|
|
5741
5741
|
role="toolbar"
|
|
5742
5742
|
aria-label=${s}
|
|
@@ -5745,7 +5745,7 @@ ${o.renameContextHint}`}
|
|
|
5745
5745
|
@dblclick=${mi}
|
|
5746
5746
|
@keydown=${mi}
|
|
5747
5747
|
>
|
|
5748
|
-
${o.kind==="items"?
|
|
5748
|
+
${o.kind==="items"?hx(t,o.items):mx(t,o.connector)}
|
|
5749
5749
|
<button
|
|
5750
5750
|
type="button"
|
|
5751
5751
|
class="dpk-icon-btn wb-toolbar-btn"
|
|
@@ -5756,7 +5756,7 @@ ${o.renameContextHint}`}
|
|
|
5756
5756
|
>
|
|
5757
5757
|
${Ht()}
|
|
5758
5758
|
</button>
|
|
5759
|
-
</div>`},
|
|
5759
|
+
</div>`},px={front:"\u2318/Ctrl ]",forward:"]",backward:"[",back:"\u2318/Ctrl ["},hx=(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
5760
|
${i.length>0?v`<div class="wb-swatches" role="radiogroup" aria-label=${n.colorLabelPrefix}>
|
|
5761
5761
|
${ei.map(d=>v`<button
|
|
5762
5762
|
type="button"
|
|
@@ -5786,8 +5786,8 @@ ${o.renameContextHint}`}
|
|
|
5786
5786
|
</button>`)}
|
|
5787
5787
|
</div>
|
|
5788
5788
|
${Bn}`:T}
|
|
5789
|
-
${t.arrange.size>0?v`${
|
|
5790
|
-
`},
|
|
5789
|
+
${t.arrange.size>0?v`${ux(t)} ${Bn}`:T}
|
|
5790
|
+
`},ux=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()}}>
|
|
5791
5791
|
<button
|
|
5792
5792
|
type="button"
|
|
5793
5793
|
class="wb-menu-btn"
|
|
@@ -5798,7 +5798,7 @@ ${o.renameContextHint}`}
|
|
|
5798
5798
|
title=${e.arrangeLabel}
|
|
5799
5799
|
@click=${()=>n.toggleArrangeMenu()}
|
|
5800
5800
|
>
|
|
5801
|
-
${
|
|
5801
|
+
${jb()} ${Si()}
|
|
5802
5802
|
</button>
|
|
5803
5803
|
${t.arrangeMenuOpen?v`<div class="wb-menu" role="menu" aria-label=${e.arrangeLabel}>
|
|
5804
5804
|
${ad.map(s=>v`<button
|
|
@@ -5809,12 +5809,12 @@ ${o.renameContextHint}`}
|
|
|
5809
5809
|
?disabled=${!t.arrange.has(s)}
|
|
5810
5810
|
@click=${()=>n.arrange(s)}
|
|
5811
5811
|
>
|
|
5812
|
-
${
|
|
5812
|
+
${Xb(s)}
|
|
5813
5813
|
<span class="wb-menu-label">${o[s]}</span>
|
|
5814
|
-
<kbd class="wb-menu-key">${
|
|
5814
|
+
<kbd class="wb-menu-key">${px[s]}</kbd>
|
|
5815
5815
|
</button>`)}
|
|
5816
5816
|
</div>`:T}
|
|
5817
|
-
</div>`},
|
|
5817
|
+
</div>`},mx=(t,e)=>{const{m:n,handlers:o}=t;return v`<div class="wb-choice" role="radiogroup" aria-label=${n.routeLabelPrefix}>
|
|
5818
5818
|
${_n.map(i=>v`<button
|
|
5819
5819
|
type="button"
|
|
5820
5820
|
class="wb-choice-btn wb-choice-btn--icon"
|
|
@@ -5825,7 +5825,7 @@ ${o.renameContextHint}`}
|
|
|
5825
5825
|
title=${n.routeLabel(i)}
|
|
5826
5826
|
@click=${()=>o.setRoute(e.id,i)}
|
|
5827
5827
|
>
|
|
5828
|
-
${
|
|
5828
|
+
${Kb(i)}
|
|
5829
5829
|
</button>`)}
|
|
5830
5830
|
</div>
|
|
5831
5831
|
${Bn}
|
|
@@ -5835,7 +5835,7 @@ ${o.renameContextHint}`}
|
|
|
5835
5835
|
.placeholder=${n.labelPlaceholder}
|
|
5836
5836
|
.label=${n.labelField}
|
|
5837
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],
|
|
5838
|
+
></dpk-inline-edit>`},Nd=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],gx=de`
|
|
5839
5839
|
/*
|
|
5840
5840
|
* The shell (\`<dpk-dialog-panel class="whiteboard">\`) is a panel: header, tag
|
|
5841
5841
|
* row, canvas; \`--dpk-dialog-panel-height\` is the knob it reads for its own
|
|
@@ -6703,7 +6703,7 @@ ${o.renameContextHint}`}
|
|
|
6703
6703
|
outline: 2px solid var(--dpk-blue);
|
|
6704
6704
|
outline-offset: 1px;
|
|
6705
6705
|
}
|
|
6706
|
-
`,
|
|
6706
|
+
`,fx=10,zd=8,Pd=72,bx=t=>t!==void 0,xx="whiteboard";class qd extends rt{constructor(){super(...arguments),this.mode=De,this.viewport=kb,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,gx]}#o;#i;#e;#t;#n;#a;#r;#s;#d;#c;#h;#p;parseData(e){return Bf(e)}emptyData(){return Hf()}reduceElementActions(e,n){return Hb(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",xx),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`
|
|
6707
6707
|
<dpk-dialog-panel
|
|
6708
6708
|
class=${this.shellClass()}
|
|
6709
6709
|
flush
|
|
@@ -6714,7 +6714,7 @@ ${o.renameContextHint}`}
|
|
|
6714
6714
|
@dpk-maximize-change=${()=>this.closeComposer()}
|
|
6715
6715
|
>
|
|
6716
6716
|
${this.renderToolbarActionsSlot()} ${this.renderTagFilterRow()}
|
|
6717
|
-
${this.dataError!==null?v`<p class="wb-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:
|
|
6717
|
+
${this.dataError!==null?v`<p class="wb-notice" role="alert">${n.dataError}<br />${this.dataError}</p>`:Zb({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,fb(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)}})}
|
|
6718
6718
|
</dpk-dialog-panel>
|
|
6719
6719
|
${this.renderSelection()}
|
|
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};
|
|
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(bx)}#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:cx({m:n,state:e,viewport:this.viewport,selection:r,arrange:nb(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:ob(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:cb(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=jf(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,ub(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):gb(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,hb(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=mb(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:fx;i.length>0?this.#T(xb(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(tb(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=rb(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(Tb(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=lb(this.items(),this.#h,db*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=ab(o,e,n);this.#N(ae.connect(s,e,n))&&this.#l([s])}#I(e){this.#i=!1;const n=Eb(e,zn(this.items().items),this.#k());Sb(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(wb(e,n,Pd)),this.#i=!0,!0)}#H(){return $b(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)},yx=()=>{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,yx as r,Fa as s,Ka as t,Za as u,Fd as v,ns as w,Ne as x,io as y};
|