@a9n-shoji/rvw 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/web/assets/{StructureViewer-CXtsUfYG.js → StructureViewer-DoWyE2t8.js} +1 -1
- package/dist/web/assets/{index-zyXQjX9Z.js → index-DMEUAYTa.js} +2 -2
- package/dist/web/assets/{index-CbUV8NfH.css → index-d26m24-l.css} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,l as r,t as i}from"./FileIcon-wDKKQgGv.js";import{A as a,C as o,D as s,E as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,k as x,l as S,m as C,n as w,o as ee,p as T,r as te,s as ne,t as re,u as ie,v as ae,w as oe,x as se,y as ce}from"./index-zyXQjX9Z.js";var E=e(r(),1),le=210,ue=136,de=64,fe=11,pe=2,me=300,he=180,ge=26,D=5,O=5,_e=[me,240,180,144],k=[`below-left`,`above-left`,`below-right`,`above-right`],ve=5,A=20,ye=72,j=12,be=6,M=36,xe=4096,Se=32768,Ce=22,we=24,Te=12,N=8,Ee=12,De=3,Oe=32,ke=3,Ae=64,je=128,Me=[1,2];Me.length;var Ne=Array.from({length:22},(e,t)=>.08+t*.04).sort((e,t)=>Math.abs(e-.5)-Math.abs(t-.5)),Pe=[0,14,-14,28,-28,44,-44,64,-64,88,-88,116,-116,152,-152,196,-196,248,-248];function P(e,t){return e===t?0:e<t?-1:1}function Fe(e){let t=[...new Set(e)],n=new Map(t.map(e=>[e,e.split(`/`)]));return new Map(t.map(e=>{let r=n.get(e);for(let i=1;i<=r.length;i+=1){let a=r.slice(-i).join(`/`);if(t.every(t=>t===e||n.get(t).slice(-i).join(`/`)!==a))return[e,a]}return[e,e]}))}function Ie(e,t){let n=e.anchors.flatMap(e=>{let n=t.get(e.path);return n?[n]:[]}),r=[...new Set(n)].sort(P);return{anchorCount:e.anchors.length,changeKind:r.length>1?`mixed`:r.length===1?r[0]:null}}var Le=12,Re=56,ze=28,Be=22;function Ve(e){return Array.from({length:49},(t,n)=>{let r=n/48,i=1-r;return{x:i**3*e.start.x+3*i**2*r*e.control1.x+3*i*r**2*e.control2.x+r**3*e.end.x,y:i**3*e.start.y+3*i**2*r*e.control1.y+3*i*r**2*e.control2.y+r**3*e.end.y}})}function He(e){return{left:Math.min(...e.map(({x:e})=>e)),top:Math.min(...e.map(({y:e})=>e)),right:Math.max(...e.map(({x:e})=>e)),bottom:Math.max(...e.map(({y:e})=>e))}}function Ue(e){let t=e.at(-1),n=[...e].reverse().slice(1).find(e=>e.x!==t.x||e.y!==t.y),r=t.x-n.x,i=t.y-n.y,a=Math.hypot(r,i),o={x:r/a,y:i/a},s=Math.min(12,a),c={x:t.x-o.x*s,y:t.y-o.y*s};return{base:c,path:`M ${c.x} ${c.y} L ${t.x} ${t.y}`,tangent:o}}function F(e,t){let n=Ue(e.points);return{...e,strokePath:t,arrowPath:n.path,arrowBaseX:n.base.x,arrowBaseY:n.base.y,arrowTangentX:n.tangent.x,arrowTangentY:n.tangent.y}}function We(e){let t=Ve(e);return{path:`M ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y}`,points:t,startX:e.start.x,startY:e.start.y,control1X:e.control1.x,control1Y:e.control1.y,control2X:e.control2.x,control2Y:e.control2.y,endX:e.end.x,endY:e.end.y,bounds:He([...t,e.control1,e.control2])}}function Ge(e){let t=We(e),n=I([e.boundaryStart,...t.points,e.boundaryEnd]),r={...t,path:`M ${e.boundaryStart.x} ${e.boundaryStart.y} L ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y} L ${e.boundaryEnd.x} ${e.boundaryEnd.y}`,points:n,startX:e.boundaryStart.x,startY:e.boundaryStart.y,endX:e.boundaryEnd.x,endY:e.boundaryEnd.y,bounds:He([...n,e.control1,e.control2])},i=Ue(n);return F(r,`M ${e.boundaryStart.x} ${e.boundaryStart.y} L ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y} L ${i.base.x} ${i.base.y}`)}function I(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&e.x===n.x&&e.y===n.y)continue;let r=t.at(-2);r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)?t[t.length-1]=n:t.push(n)}return t}function Ke(e){let t=I(e),n=t[0],r=t.at(-1);if(!n||!r||t.length<2)return null;let i=e=>{let t=e[0],n=e.slice(1).map((t,n)=>{let r=e[n];return`C ${r.x+(t.x-r.x)/3} ${r.y+(t.y-r.y)/3}, ${r.x+(t.x-r.x)*2/3} ${r.y+(t.y-r.y)*2/3}, ${t.x} ${t.y}`});return`M ${t.x} ${t.y} ${n.join(` `)}`},a=t[1],o=t.at(-2),s={path:i(t),points:t,startX:n.x,startY:n.y,control1X:n.x+(a.x-n.x)/3,control1Y:n.y+(a.y-n.y)/3,control2X:o.x+(r.x-o.x)*2/3,control2Y:o.y+(r.y-o.y)*2/3,endX:r.x,endY:r.y,bounds:He(t)},c=Ue(t);return F(s,i(I([...t.slice(0,-1),c.base])))}function qe(e,t,n,r,i,a){let o=t[e.from],s=t[e.to];if(!o||!s||e.from===e.to)return null;let c={x:o.x+114,y:o.y+56},l={x:s.x+114,y:s.y+56},u=at(c,l),d=at(l,c),f=$e(Ye(o,0),i?.from??n,Be,a?.get(e.from)).find(({side:e})=>e===u),p=$e(Ye(s,0),i?.to??n,Be,a?.get(e.to)).find(({side:e})=>e===d),m=p.point.x-f.point.x,h=p.point.y-f.point.y,g=Math.max(1,Math.hypot(m,h)),_=m/g,v=-(h/g),y=_,b=f.point,x=p.point,S=n*(r?5.5:4),C={x:b.x+(x.x-b.x)/3+v*S,y:b.y+(x.y-b.y)/3+y*S},w={x:b.x+(x.x-b.x)*2/3+v*S,y:b.y+(x.y-b.y)*2/3+y*S};return Ge({boundaryStart:f.boundaryPoint,start:b,control1:C,control2:w,end:x,boundaryEnd:p.boundaryPoint})}function Je(e){let t=new Set(e.filter(e=>e.directed&&e.from!==e.to).map(e=>JSON.stringify([e.from,e.to])));return new Set(e.filter(e=>e.directed&&e.from!==e.to&&t.has(JSON.stringify([e.to,e.from]))).map(e=>e.id))}function Ye(e,t=Le){return{left:e.x-t,top:e.y-t,right:e.x+228+t,bottom:e.y+112+t}}function Xe(e,t){return e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom}function Ze(e,t,n){if(e.y===t.y){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x);return n.some(t=>e.y>t.top&&e.y<t.bottom&&r<t.right&&i>t.left)}if(e.x===t.x){let r=Math.min(e.y,t.y),i=Math.max(e.y,t.y);return n.some(t=>e.x>t.left&&e.x<t.right&&r<t.bottom&&i>t.top)}return!0}function Qe(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=0,o=1;for(let[t,s,c,l]of[[e.x,r,n.left,n.right],[e.y,i,n.top,n.bottom]]){if(Math.abs(s)<1e-6){if(t<c||t>l)return!1;continue}let e=(c-t)/s,n=(l-t)/s;if(a=Math.max(a,Math.min(e,n)),o=Math.min(o,Math.max(e,n)),a>o)return!1}return o>=0&&a<=1}function L(e,t){return e.slice(1).some((n,r)=>t.some(t=>Qe(e[r],n,t)))}function $e(e,t,n,r=`plain`){let i=(e.left+e.right)/2,a=(e.top+e.bottom)/2,o=e=>typeof t==`number`?t:t[e],s=t=>Math.max(-(e.right-e.left)/2+16,Math.min((e.right-e.left)/2-16,o(t))),c=t=>Math.max(-(e.bottom-e.top)/2+16,Math.min((e.bottom-e.top)/2-16,o(t)));return[{boundaryPoint:{x:e.left,y:a+c(`left`)},side:`left`},{boundaryPoint:{x:e.right,y:a+c(`right`)},side:`right`},{boundaryPoint:{x:i+s(`top`),y:e.top},side:`top`},{boundaryPoint:{x:i+s(`bottom`),y:e.bottom},side:`bottom`}].map(({boundaryPoint:t,side:i})=>{let a=nt(e,i,t,r);return{point:(()=>{switch(i){case`left`:return{x:e.left-n,y:a.y};case`right`:return{x:e.right+n,y:a.y};case`top`:return{x:a.x,y:e.top-n};case`bottom`:return{x:a.x,y:e.bottom+n}}})(),boundaryPoint:a,side:i}})}function et(e,t,n,r,i){let a=(e.left+e.right)/2,o=(e.top+e.bottom)/2,s=(e.right-e.left)/2,c=(e.bottom-e.top)/2,l=Math.max(0,s-r),u=Math.max(0,c-i);if(t===`top`||t===`bottom`){let o=n.x-a;if(Math.abs(o)<=l)return n;let s=a+Math.sign(o||1)*l,c=Math.max(-1,Math.min(1,(n.x-s)/r)),u=i*(1-Math.sqrt(Math.max(0,1-c**2)));return{x:n.x,y:t===`top`?e.top+u:e.bottom-u}}let d=n.y-o;if(Math.abs(d)<=u)return n;let f=o+Math.sign(d||1)*u,p=Math.max(-1,Math.min(1,(n.y-f)/i)),m=r*(1-Math.sqrt(Math.max(0,1-p**2)));return{x:t===`left`?e.left+m:e.right-m,y:n.y}}function tt(e,t,n){let r=e.right-e.left,i=e.bottom-e.top,a=(e.left+e.right)/2,o=(e.top+e.bottom)/2,s=r*.09;if(t===`left`||t===`right`){let r=s*Math.min(1,Math.abs(n.y-o)/(i/2));return{x:t===`left`?e.left+r:e.right-r,y:n.y}}let c=r/2-s,l=n.x-a;if(Math.abs(l)<=c)return n;let u=(Math.abs(l)-c)/s*(i/2);return{x:n.x,y:t===`top`?e.top+u:e.bottom-u}}function nt(e,t,n,r){if(r===`external`)return tt(e,t,n);if(r===`concept`){let r=Math.min((e.right-e.left)/2,(e.bottom-e.top)/2);return et(e,t,n,r,r)}return r===`database`?et(e,t,n,(e.right-e.left)/2,(e.bottom-e.top)*.14):n}function rt(e,t){if(e<=1)return[0];let n=Math.max(1,t/2-16),r=n*2/(e-1);return Array.from({length:e},(e,t)=>-n+t*r)}function it(e,t){let n=new Map;for(let r of e){if(r.from===r.to)continue;let e=t[r.from],i=t[r.to];if(!e||!i)continue;let a={x:e.x+114,y:e.y+56},o={x:i.x+114,y:i.y+56},s=[{edge:r,end:`from`,nodeId:r.from,otherNodeId:r.to,otherCenter:o},{edge:r,end:`to`,nodeId:r.to,otherNodeId:r.from,otherCenter:a}];for(let e of s){let t=n.get(e.nodeId)??[];t.push(e),n.set(e.nodeId,t)}}let r=new Map,i=()=>({left:0,right:0,top:0,bottom:0}),a=e=>(t,n)=>(e===`left`||e===`right`?t.otherCenter.y:t.otherCenter.x)-(e===`left`||e===`right`?n.otherCenter.y:n.otherCenter.x)||P(t.otherNodeId,n.otherNodeId)||P(t.edge.id,n.edge.id)||P(t.end,n.end);for(let e of n.values())for(let t of[`left`,`right`,`top`,`bottom`]){let n=[...e].sort(a(t)),o=t===`left`||t===`right`?112:228,s=rt(n.length,o);n.forEach((e,n)=>{let a=r.get(e.edge.id)??{from:i(),to:i()};a[e.end][t]=s[n],r.set(e.edge.id,a)})}return r}function at(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.abs(n)>=Math.abs(r)?n>=0?`right`:`left`:r>=0?`bottom`:`top`}function ot(e,t){return e===t?0:e===`left`&&t===`right`||e===`right`&&t===`left`||e===`top`&&t===`bottom`||e===`bottom`&&t===`top`?72:24}function R(e){return`${e.x}:${e.y}`}function st(e,t){return e.cost-t.cost||P(e.stateKey,t.stateKey)}function ct(e,t){e.push(t);for(let t=e.length-1;t>0;){let n=Math.floor((t-1)/2);if(st(e[n],e[t])<=0)break;[e[n],e[t]]=[e[t],e[n]],t=n}}function lt(e){let t=e[0],n=e.pop();if(!t||!n||e.length===0)return t;e[0]=n;for(let t=0;t<e.length;){let n=t*2+1,r=n+1,i=t;if(n<e.length&&st(e[n],e[i])<0&&(i=n),r<e.length&&st(e[r],e[i])<0&&(i=r),i===t)break;[e[t],e[i]]=[e[i],e[t]],t=i}return t}function ut(e){let t=jt([...e.obstacles,...e.sources.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y})),...e.targets.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y}))]);if(!t)return null;let n=null;for(let r of e.sources)for(let i of e.targets){let a=e.channelOffset===0?[[r.point,{x:i.point.x,y:r.point.y},i.point],[r.point,{x:r.point.x,y:i.point.y},i.point]]:[t.left-Re-e.channelOffset,t.right+Re+e.channelOffset].map(e=>[r.point,{x:e,y:r.point.y},{x:e,y:i.point.y},i.point]).concat([t.top-Re-e.channelOffset,t.bottom+Re+e.channelOffset].map(e=>[r.point,{x:r.point.x,y:e},{x:i.point.x,y:e},i.point]));for(let t of a){let a=I(t);if(a.length<2||a.slice(1).some((t,n)=>Ze(a[n],t,e.obstacles)))continue;let o=a.slice(1).reduce((e,t,n)=>{let r=a[n];return e+Math.abs(t.x-r.x)+Math.abs(t.y-r.y)},0),s=r.penalty+i.penalty+o+Math.max(0,a.length-2)*ze,c=a.map(R).join(`|`);(n===null||s<n.cost||s===n.cost&&P(c,n.key)<0)&&(n={cost:s,key:c,points:a})}}return n?.points??null}function dt(e){if(e.sources.length===0||e.targets.length===0)return null;if(e.obstacles.length>=64){let t=ut({...e,channelOffset:Math.max(0,e.channelOffset??0)});if(t)return t}let t=[...e.sources,...e.targets],n=jt([...e.obstacles,...t.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y}))]);if(!n)return null;let r=Math.max(0,e.channelOffset??0),i=[n.left-Re-r,n.right+Re+r,...e.obstacles.flatMap(e=>[e.left-r,e.right+r]),...t.map(({point:e})=>e.x)].sort((e,t)=>e-t),a=[n.top-Re-r,n.bottom+Re+r,...e.obstacles.flatMap(e=>[e.top-r,e.bottom+r]),...t.map(({point:e})=>e.y)].sort((e,t)=>e-t),o=[...new Set(i)],s=[...new Set(a)],c=new Map;for(let t of s)for(let n of o){let r={x:n,y:t};e.obstacles.some(e=>Xe(r,e))||c.set(R(r),r)}let l=new Map([...c.keys()].map(e=>[e,new Set])),u=(t,n)=>{if(Ze(t,n,e.obstacles))return;let r=R(t),i=R(n);l.get(r)?.add(i),l.get(i)?.add(r)};for(let e of s){let t=null;for(let n of o){let r=c.get(R({x:n,y:e}));r&&(t&&u(t,r),t=r)}}for(let e of o){let t=null;for(let n of s){let r=c.get(R({x:e,y:n}));r&&(t&&u(t,r),t=r)}}let d=new Map;for(let{point:t,penalty:n}of e.targets){let e=R(t);d.set(e,Math.min(n,d.get(e)??1/0))}let f=[],p=new Map,m=new Map;for(let{point:t,penalty:n}of e.sources){let e=R(t);if(!c.has(e))continue;let r=`${e}|start`,i=n;i>=(p.get(r)??1/0)||(p.set(r,i),m.set(r,null),ct(f,{stateKey:r,vertexKey:e,direction:`start`,cost:i}))}let h=null,g=1/0;for(;f.length>0;){let e=lt(f);if(e.cost!==p.get(e.stateKey))continue;if(e.cost>g)break;let t=d.get(e.vertexKey);if(t!==void 0){let n=e.cost+t;(n<g||n===g&&(!h||P(e.stateKey,h.stateKey)<0))&&(h=e,g=n)}let n=c.get(e.vertexKey);for(let t of[...l.get(e.vertexKey)??[]].sort(P)){let r=c.get(t),i=n.x===r.x?`vertical`:`horizontal`,a=Math.abs(n.x-r.x)+Math.abs(n.y-r.y),o=e.direction===`start`||e.direction===i?0:ze,s=e.cost+a+o,l=`${t}|${i}`;s>=(p.get(l)??1/0)||(p.set(l,s),m.set(l,e.stateKey),ct(f,{stateKey:l,vertexKey:t,direction:i,cost:s}))}}if(!h)return null;let _=[];for(let e=h.stateKey;e!==null;){let t=e.lastIndexOf(`|`),n=e.slice(0,t);_.push(c.get(n)),e=m.get(e)??null}return I(_.reverse())}function ft(e){let t=at(e.from,e.to),n=at(e.to,e.from),r=Le,i=Be,a=$e(e.fromBox,e.portOffsets.from,r,e.fromNotation),o=$e(e.toBox,e.portOffsets.to,i,e.toNotation),s=dt({sources:a.map(({point:e,side:n})=>({point:e,penalty:ot(n,t)})),targets:o.map(({point:e,side:t})=>({point:e,penalty:ot(t,n)})),obstacles:e.obstacles,...e.channelOffset===void 0?{}:{channelOffset:e.channelOffset}});if(!s)return null;let c=s[0],l=s.at(-1),u=a.find(({point:e})=>R(e)===R(c)),d=o.find(({point:e})=>R(e)===R(l));return!u||!d?null:I([u.boundaryPoint,...s,d.boundaryPoint])}function z(e){return e.points.slice(1).flatMap((t,n)=>{let r=e.points[n];return r.y===t.y&&r.x!==t.x?[{orientation:`horizontal`,fixed:t.y,minimum:Math.min(r.x,t.x),maximum:Math.max(r.x,t.x)}]:r.x===t.x&&r.y!==t.y?[{orientation:`vertical`,fixed:t.x,minimum:Math.min(r.y,t.y),maximum:Math.max(r.y,t.y)}]:[]})}function pt(e,t){return z(e).some(e=>z(t).some(t=>e.orientation!==t.orientation||Math.abs(e.fixed-t.fixed)>4?!1:Math.min(e.maximum,t.maximum)-Math.max(e.minimum,t.minimum)>=48))}function B(e,t){let n=new Map(e.map(e=>[e,new Set]));for(let r=0;r<e.length;r+=1){let i=e[r],a=t.get(i);if(a)for(let o=r+1;o<e.length;o+=1){let r=e[o],s=t.get(r);!s||!pt(a,s)||(n.get(i).add(r),n.get(r).add(i))}}let r=[],i=new Set;for(let t of e){if(i.has(t)||n.get(t)?.size===0)continue;let e=[],a=[t];i.add(t);for(let t=0;t<a.length;t+=1){let r=a[t];e.push(r);for(let e of[...n.get(r)??[]].sort(P))i.has(e)||(i.add(e),a.push(e))}r.push(e.sort(P))}return r}function V(e){let{point:t,notation:n,laneOffset:r,obstacles:i}=e,a=t.x,o=t.x+228,s=t.y,c=t.y+112,l=r*.55,u=e=>Math.max(a+16,Math.min(o-16,e)),d=e=>Math.max(s+16,Math.min(c-16,e));for(let e=0;e<12;e+=1){let t=88+Math.abs(r)*2+e*72,f={left:a,right:o,top:s,bottom:c},p=nt(f,`right`,{x:o,y:d(s+32+l)},n),m=nt(f,`right`,{x:o,y:d(c-32+l)},n),h=nt(f,`left`,{x:a,y:d(c-32-l)},n),g=nt(f,`left`,{x:a,y:d(s+32-l)},n),_=nt(f,`top`,{x:u(a+48+l),y:s},n),v=nt(f,`top`,{x:u(o-48+l),y:s},n),y=nt(f,`bottom`,{x:u(o-48-l),y:c},n),b=nt(f,`bottom`,{x:u(a+48-l),y:c},n),x=[Ge({boundaryStart:p,start:{x:o+Be,y:p.y},control1:{x:o+t,y:s-64+l},control2:{x:o+t,y:c+64+l},end:{x:o+Be,y:m.y},boundaryEnd:m}),Ge({boundaryStart:h,start:{x:a-Be,y:h.y},control1:{x:a-t,y:c+64-l},control2:{x:a-t,y:s-64-l},end:{x:a-Be,y:g.y},boundaryEnd:g}),Ge({boundaryStart:_,start:{x:_.x,y:s-Be},control1:{x:a-72+l,y:s-t},control2:{x:o+72+l,y:s-t},end:{x:v.x,y:s-Be},boundaryEnd:v}),Ge({boundaryStart:y,start:{x:y.x,y:c+Be},control1:{x:o+72-l,y:c+t},control2:{x:a-72-l,y:c+t},end:{x:b.x,y:c+Be},boundaryEnd:b})].find(e=>!L(e.points,i));if(x)return x}return null}function mt(e,t,n){let r=c(e),i=it(e,n),a=new Map(t.map(e=>[e.id,e.notation])),o=Je(e),s=new Map(t.flatMap(e=>{let t=n[e.id];return t?[[e.id,Ye(t,0)]]:[]})),l=new Map(t.flatMap(e=>{let t=n[e.id];return t?[[e.id,Ye(t)]]:[]})),u=new Map,d=[],f=[...e].sort((e,t)=>P(e.id,t.id)),p=(e,t=0)=>{let r=n[e.from],o=n[e.to],c=s.get(e.from),u=s.get(e.to);if(!r||!o||!c||!u)return null;let d=[...l].filter(([t])=>{if(t===e.from||t===e.to)return!0;let n=s.get(t);return!n||!H(n,c)&&!H(n,u)}).map(([,e])=>e),f=ft({from:{x:r.x+114,y:r.y+56},to:{x:o.x+114,y:o.y+56},fromBox:c,toBox:u,obstacles:d,portOffsets:i.get(e.id)??{from:{left:0,right:0,top:0,bottom:0},to:{left:0,right:0,top:0,bottom:0}},fromNotation:a.get(e.from)??`plain`,toNotation:a.get(e.to)??`plain`,channelOffset:t});return f?Ke(f):null};for(let e of f){let t=n[e.from],c=n[e.to];if(!t||!c)continue;let f=[...l].filter(([t])=>{if(t===e.from||t===e.to)return!1;let n=s.get(t),r=s.get(e.from),i=s.get(e.to);return n&&r&&i?!H(n,r)&&!H(n,i):!0}).map(([,e])=>e),m=r.get(e.id)??0;if(e.from===e.to){let n=V({point:t,notation:a.get(e.from)??`plain`,laneOffset:m,obstacles:f});n&&u.set(e.id,n);continue}let h=qe(e,n,m,o.has(e.id),i.get(e.id),a);if(h&&!H(l.get(e.from),l.get(e.to))&&!L(h.points,f)){u.set(e.id,h);continue}let g=p(e);g&&u.set(e.id,g),d.push(e.id)}let m=new Map([...d].sort(P).map((e,t)=>[e,t])),h=new Map(f.map(e=>[e.id,e]));for(let e=0;e<Math.min(8,d.length);e+=1){let e=B(d,u);if(e.length===0)break;for(let t of e)t.forEach(e=>{let t=h.get(e),n=m.get(e),r=p(t,(n+1)*8);r&&u.set(e,r)})}return u}function ht(e,t,n){let r=e.points.slice(1).map((t,n)=>{let r=e.points[n];return{previous:r,point:t,length:Math.hypot(t.x-r.x,t.y-r.y)}}),i=r.reduce((e,t)=>e+t.length,0)*t,a=r.find(e=>i<=e.length||(i-=e.length,!1))??r.at(-1);if(!a){let r={x:e.startX,y:e.startY};return{point:r,routePoint:r,tangent:{x:1,y:0},fraction:t,normalOffset:n}}let o=a.length===0?0:Math.min(1,i/a.length),s=a.previous.x+(a.point.x-a.previous.x)*o,c=a.previous.y+(a.point.y-a.previous.y)*o,l=a.point.x-a.previous.x,u=a.point.y-a.previous.y,d=Math.max(1,Math.hypot(l,u)),f={x:l/d,y:u/d},p={x:s,y:c};return{point:{x:s+-f.y*n,y:c+f.x*n},routePoint:p,tangent:f,fraction:t,normalOffset:n}}function H(e,t){return!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function U(e,t,n,r,i=0){return{left:e-n/2-i,top:t-r/2-i,right:e+n/2+i,bottom:t+r/2+i}}function W(e,t){return{left:e.left-t,top:e.top-t,right:e.right+t,bottom:e.bottom+t}}function gt(e,t){let n=Math.max(t.left-e.x,0,e.x-t.right),r=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.hypot(n,r)}function _t(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+r*o),e.y-(t.y+i*o))}function G(e,t,n){if(Qe(t,n,e))return 0;let r=[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.right,y:e.bottom},{x:e.left,y:e.bottom}];return Math.min(gt(t,e),gt(n,e),...r.map(e=>_t(e,t,n)))}function vt(e,t){return t.length<2?1/0:Math.min(...t.slice(1).map((n,r)=>G(e,t[r],n)))}function yt(e,t,n=0){return{left:Math.min(e.x,t.x)-n,top:Math.min(e.y,t.y)-n,right:Math.max(e.x,t.x)+n,bottom:Math.max(e.y,t.y)+n}}function bt(e){let t=[],n=Math.floor(e.left/je),r=Math.floor(e.right/je),i=Math.floor(e.top/je),a=Math.floor(e.bottom/je);for(let e=n;e<=r;e+=1)for(let n=i;n<=a;n+=1)t.push(`${e}:${n}`);return t}function xt(){let e=new Map;return{addPolyline(t,n){n.slice(1).forEach((r,i)=>{let a=n[i];if(a.x===r.x&&a.y===r.y)return;let o={ownerId:t,start:a,end:r};for(let t of bt(yt(a,r))){let n=e.get(t)??[];n.push(o),e.set(t,n)}})},query(t){let n=new Set;for(let r of bt(t))for(let t of e.get(r)??[])n.add(t);return[...n]}}}function St(e,t,n,r){let i={x:t.x-e.x,y:t.y-e.y},a={x:r.x-n.x,y:r.y-n.y},o=Math.hypot(i.x,i.y),s=Math.hypot(a.x,a.y);if(o===0||s===0||Math.abs(i.x*a.y-i.y*a.x)/(o*s)>.17||Math.min(_t(e,n,r),_t(t,n,r),_t(n,e,t),_t(r,e,t))>be)return null;let c={x:i.x/o,y:i.y/o},l=t=>(t.x-e.x)*c.x+(t.y-e.y)*c.y,u=l(n),d=l(r),f=Math.max(0,Math.min(u,d)),p=Math.min(o,Math.max(u,d));return p>f?{start:f,end:p}:null}function Ct(e){let t=0;for(let n of e.values()){let e=[...n].sort((e,t)=>e.start-t.start||e.end-t.end),r=null,i=null;for(let n of e){if(r===null||i===null){r=n.start,i=n.end;continue}if(n.start<=i+.001){i=Math.max(i,n.end);continue}t=Math.max(t,i-r),r=n.start,i=n.end}r!==null&&i!==null&&(t=Math.max(t,i-r))}return t}function wt(e,t,n,r){let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=i(e,t,n),o=i(e,t,r),s=i(n,r,e),c=i(n,r,t);return a*o<-1e-6&&s*c<-1e-6}function Tt(e){return e.slice(1).reduce((t,n,r)=>{let i=e[r];return t+Math.hypot(n.x-i.x,n.y-i.y)},0)}function Et(e,t,n){let r=new Map,i=0,a=0;return e.slice(1).forEach((o,s)=>{let c=e[s],l=yt(c,o,be),u=(e,t)=>{let n=St(c,o,e.start,e.end);if(n){let i=`${t}:${e.ownerId}`,o=r.get(i)??[];o.push({start:a+n.start,end:a+n.end}),r.set(i,o)}wt(c,o,e.start,e.end)&&(i+=1)};for(let e of t.query(l))u(e,`route`);for(let e of n.query(l))u(e,`leader`);a+=Math.hypot(o.x-c.x,o.y-c.y)}),{length:a,maxParallelOverlap:Ct(r),crossingCount:i}}function Dt(e,t){let n={x:(e.left+e.right)/2,y:(e.top+e.bottom)/2},r=t.x-n.x,i=t.y-n.y;if(r===0&&i===0)return{x:n.x,y:e.top};let a=Math.max(1,(e.right-e.left)/2),o=Math.max(1,(e.bottom-e.top)/2),s=1/Math.max(Math.abs(r)/a,Math.abs(i)/o);return{x:n.x+r*s,y:n.y+i*s}}function Ot(e){let t=(e.left+e.right)/2,n=(e.top+e.bottom)/2;return[{x:e.left,y:n},{x:e.right,y:n},{x:t,y:e.top},{x:t,y:e.bottom}]}function kt(e){let t=new Set([...e.obstacles.flatMap(e=>[e.left,e.right]),...e.sources.map(({point:e})=>e.x),...e.targets.map(({point:e})=>e.x)]),n=new Set([...e.obstacles.flatMap(e=>[e.top,e.bottom]),...e.sources.map(({point:e})=>e.y),...e.targets.map(({point:e})=>e.y)]);return t.size*n.size}function At(e){if(e.obstacles.some(t=>Xe(e.routePoint,t)))return null;let t={x:-e.routeTangent.y,y:e.routeTangent.x},n={x:(e.label.left+e.label.right)/2,y:(e.label.top+e.label.bottom)/2},r=(n.x-e.routePoint.x)*t.x+(n.y-e.routePoint.y)*t.y>=0?1:-1,i=e.targetPorts??Ot(e.label),a=e.targetPorts?[...i].sort((t,n)=>Math.hypot(t.x-e.routePoint.x,t.y-e.routePoint.y)-Math.hypot(n.x-e.routePoint.x,n.y-e.routePoint.y)||P(R(t),R(n)))[0]:Dt(e.label,e.routePoint),o=Math.hypot(a.x-e.routePoint.x,a.y-e.routePoint.y),s=Math.min(j,Math.max(2,o*.45)),c=[],l=[];for(let n of[r,-r]){let r={x:e.routePoint.x+t.x*s*n,y:e.routePoint.y+t.y*s*n};if(e.obstacles.some(t=>Qe(e.routePoint,r,t)))continue;l.push(r);let i=Dt(e.label,r);e.obstacles.some(e=>Qe(r,i,e))||c.push([e.routePoint,r,i])}let u=t=>[...new Map(t.map(e=>I(e)).filter(t=>t.length>=2&&!t.slice(1).some((n,r)=>e.obstacles.some(e=>Qe(t[r],n,W(e,-.001))))).map(e=>[e.map(R).join(`|`),e])).values()].map(t=>({points:t,...Et(t,e.routeSegments,e.leaderSegments)})),d=(e,t)=>{let n=e.maxParallelOverlap>=M,r=t.maxParallelOverlap>=M;return Number(n)-Number(r)||e.length+e.crossingCount*8-(t.length+t.crossingCount*8)||e.maxParallelOverlap-t.maxParallelOverlap||e.points.length-t.points.length||P(e.points.map(R).join(`|`),t.points.map(R).join(`|`))},f=u(c).sort(d);if(f[0]&&f[0].maxParallelOverlap<M)return f[0];let p=l.flatMap(t=>{let n={sources:[{point:t,penalty:0}],targets:i.map(e=>({point:e,penalty:0})),obstacles:[...e.obstacles,e.label],channelOffset:0},r=ut(n)??(e.allowOuterRoute?ut({...n,channelOffset:N}):null)??(kt(n)<=(e.fullGridVertexLimit??xe)?dt(n):null);return r?[[e.routePoint,...r]]:[]});return[...f,...u(p)].sort(d)[0]??null}function jt(e){return e.length===0?null:{left:Math.min(...e.map(e=>e.left)),top:Math.min(...e.map(e=>e.top)),right:Math.max(...e.map(e=>e.right)),bottom:Math.max(...e.map(e=>e.bottom))}}function Mt(e){return[...e].reduce((e,t)=>e+(/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}/u.test(t)?1:.56),0)}function Nt(e,t){if(/\s/u.test(e)||/[./_-]/u.test(e)||e===`:`&&t===`:`)return!0;if(!t||!/[\p{L}\p{N}]/u.test(e)||!/[\p{L}\p{N}]/u.test(t))return!1;let n=e=>/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}/u.test(e);return n(e)!==n(t)}function Pt(e,t){let n=[...e.trimEnd()];for(;n.length>0&&Mt(n.join(``)+`…`)>t;)n.pop();return`${n.join(``).trimEnd()}…`}function Ft(e,t){let n=e.trim();if(!n)return[``];let r=[];for(;Mt(n)>t;){let e=[...n],i=0,a=0,o=0;for(let n=0;n<e.length;n+=1){let r=e[n],s=i+Mt(r);if(s>t&&a>0)break;if(i=s,a=n+1,Nt(r,e[n+1])){if(r===`:`&&e[n+1]===`:`){if(s+Mt(e[n+1])<=t)o=n+2;else if(n>0){o=n;break}}else o=n+1}if(i>t)break}let s=Math.min(e.length,o>0?o:Math.max(1,a));if(r.push(e.slice(0,s).join(``).trimEnd()),n=e.slice(s).join(``).trimStart(),!n)break}return n&&r.push(n),r}function It(e){let t=Math.max(.56,e.maxUnits),n=e.text.replaceAll(`\r
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,l as r,t as i}from"./FileIcon-wDKKQgGv.js";import{A as a,C as o,D as s,E as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,k as x,l as S,m as C,n as w,o as ee,p as T,r as te,s as ne,t as re,u as ie,v as ae,w as oe,x as se,y as ce}from"./index-DMEUAYTa.js";var E=e(r(),1),le=210,ue=136,de=64,fe=11,pe=2,me=300,he=180,ge=26,D=5,O=5,_e=[me,240,180,144],k=[`below-left`,`above-left`,`below-right`,`above-right`],ve=5,A=20,ye=72,j=12,be=6,M=36,xe=4096,Se=32768,Ce=22,we=24,Te=12,N=8,Ee=12,De=3,Oe=32,ke=3,Ae=64,je=128,Me=[1,2];Me.length;var Ne=Array.from({length:22},(e,t)=>.08+t*.04).sort((e,t)=>Math.abs(e-.5)-Math.abs(t-.5)),Pe=[0,14,-14,28,-28,44,-44,64,-64,88,-88,116,-116,152,-152,196,-196,248,-248];function P(e,t){return e===t?0:e<t?-1:1}function Fe(e){let t=[...new Set(e)],n=new Map(t.map(e=>[e,e.split(`/`)]));return new Map(t.map(e=>{let r=n.get(e);for(let i=1;i<=r.length;i+=1){let a=r.slice(-i).join(`/`);if(t.every(t=>t===e||n.get(t).slice(-i).join(`/`)!==a))return[e,a]}return[e,e]}))}function Ie(e,t){let n=e.anchors.flatMap(e=>{let n=t.get(e.path);return n?[n]:[]}),r=[...new Set(n)].sort(P);return{anchorCount:e.anchors.length,changeKind:r.length>1?`mixed`:r.length===1?r[0]:null}}var Le=12,Re=56,ze=28,Be=22;function Ve(e){return Array.from({length:49},(t,n)=>{let r=n/48,i=1-r;return{x:i**3*e.start.x+3*i**2*r*e.control1.x+3*i*r**2*e.control2.x+r**3*e.end.x,y:i**3*e.start.y+3*i**2*r*e.control1.y+3*i*r**2*e.control2.y+r**3*e.end.y}})}function He(e){return{left:Math.min(...e.map(({x:e})=>e)),top:Math.min(...e.map(({y:e})=>e)),right:Math.max(...e.map(({x:e})=>e)),bottom:Math.max(...e.map(({y:e})=>e))}}function Ue(e){let t=e.at(-1),n=[...e].reverse().slice(1).find(e=>e.x!==t.x||e.y!==t.y),r=t.x-n.x,i=t.y-n.y,a=Math.hypot(r,i),o={x:r/a,y:i/a},s=Math.min(12,a),c={x:t.x-o.x*s,y:t.y-o.y*s};return{base:c,path:`M ${c.x} ${c.y} L ${t.x} ${t.y}`,tangent:o}}function F(e,t){let n=Ue(e.points);return{...e,strokePath:t,arrowPath:n.path,arrowBaseX:n.base.x,arrowBaseY:n.base.y,arrowTangentX:n.tangent.x,arrowTangentY:n.tangent.y}}function We(e){let t=Ve(e);return{path:`M ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y}`,points:t,startX:e.start.x,startY:e.start.y,control1X:e.control1.x,control1Y:e.control1.y,control2X:e.control2.x,control2Y:e.control2.y,endX:e.end.x,endY:e.end.y,bounds:He([...t,e.control1,e.control2])}}function Ge(e){let t=We(e),n=I([e.boundaryStart,...t.points,e.boundaryEnd]),r={...t,path:`M ${e.boundaryStart.x} ${e.boundaryStart.y} L ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y} L ${e.boundaryEnd.x} ${e.boundaryEnd.y}`,points:n,startX:e.boundaryStart.x,startY:e.boundaryStart.y,endX:e.boundaryEnd.x,endY:e.boundaryEnd.y,bounds:He([...n,e.control1,e.control2])},i=Ue(n);return F(r,`M ${e.boundaryStart.x} ${e.boundaryStart.y} L ${e.start.x} ${e.start.y} C ${e.control1.x} ${e.control1.y}, ${e.control2.x} ${e.control2.y}, ${e.end.x} ${e.end.y} L ${i.base.x} ${i.base.y}`)}function I(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&e.x===n.x&&e.y===n.y)continue;let r=t.at(-2);r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)?t[t.length-1]=n:t.push(n)}return t}function Ke(e){let t=I(e),n=t[0],r=t.at(-1);if(!n||!r||t.length<2)return null;let i=e=>{let t=e[0],n=e.slice(1).map((t,n)=>{let r=e[n];return`C ${r.x+(t.x-r.x)/3} ${r.y+(t.y-r.y)/3}, ${r.x+(t.x-r.x)*2/3} ${r.y+(t.y-r.y)*2/3}, ${t.x} ${t.y}`});return`M ${t.x} ${t.y} ${n.join(` `)}`},a=t[1],o=t.at(-2),s={path:i(t),points:t,startX:n.x,startY:n.y,control1X:n.x+(a.x-n.x)/3,control1Y:n.y+(a.y-n.y)/3,control2X:o.x+(r.x-o.x)*2/3,control2Y:o.y+(r.y-o.y)*2/3,endX:r.x,endY:r.y,bounds:He(t)},c=Ue(t);return F(s,i(I([...t.slice(0,-1),c.base])))}function qe(e,t,n,r,i,a){let o=t[e.from],s=t[e.to];if(!o||!s||e.from===e.to)return null;let c={x:o.x+114,y:o.y+56},l={x:s.x+114,y:s.y+56},u=at(c,l),d=at(l,c),f=$e(Ye(o,0),i?.from??n,Be,a?.get(e.from)).find(({side:e})=>e===u),p=$e(Ye(s,0),i?.to??n,Be,a?.get(e.to)).find(({side:e})=>e===d),m=p.point.x-f.point.x,h=p.point.y-f.point.y,g=Math.max(1,Math.hypot(m,h)),_=m/g,v=-(h/g),y=_,b=f.point,x=p.point,S=n*(r?5.5:4),C={x:b.x+(x.x-b.x)/3+v*S,y:b.y+(x.y-b.y)/3+y*S},w={x:b.x+(x.x-b.x)*2/3+v*S,y:b.y+(x.y-b.y)*2/3+y*S};return Ge({boundaryStart:f.boundaryPoint,start:b,control1:C,control2:w,end:x,boundaryEnd:p.boundaryPoint})}function Je(e){let t=new Set(e.filter(e=>e.directed&&e.from!==e.to).map(e=>JSON.stringify([e.from,e.to])));return new Set(e.filter(e=>e.directed&&e.from!==e.to&&t.has(JSON.stringify([e.to,e.from]))).map(e=>e.id))}function Ye(e,t=Le){return{left:e.x-t,top:e.y-t,right:e.x+228+t,bottom:e.y+112+t}}function Xe(e,t){return e.x>t.left&&e.x<t.right&&e.y>t.top&&e.y<t.bottom}function Ze(e,t,n){if(e.y===t.y){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x);return n.some(t=>e.y>t.top&&e.y<t.bottom&&r<t.right&&i>t.left)}if(e.x===t.x){let r=Math.min(e.y,t.y),i=Math.max(e.y,t.y);return n.some(t=>e.x>t.left&&e.x<t.right&&r<t.bottom&&i>t.top)}return!0}function Qe(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=0,o=1;for(let[t,s,c,l]of[[e.x,r,n.left,n.right],[e.y,i,n.top,n.bottom]]){if(Math.abs(s)<1e-6){if(t<c||t>l)return!1;continue}let e=(c-t)/s,n=(l-t)/s;if(a=Math.max(a,Math.min(e,n)),o=Math.min(o,Math.max(e,n)),a>o)return!1}return o>=0&&a<=1}function L(e,t){return e.slice(1).some((n,r)=>t.some(t=>Qe(e[r],n,t)))}function $e(e,t,n,r=`plain`){let i=(e.left+e.right)/2,a=(e.top+e.bottom)/2,o=e=>typeof t==`number`?t:t[e],s=t=>Math.max(-(e.right-e.left)/2+16,Math.min((e.right-e.left)/2-16,o(t))),c=t=>Math.max(-(e.bottom-e.top)/2+16,Math.min((e.bottom-e.top)/2-16,o(t)));return[{boundaryPoint:{x:e.left,y:a+c(`left`)},side:`left`},{boundaryPoint:{x:e.right,y:a+c(`right`)},side:`right`},{boundaryPoint:{x:i+s(`top`),y:e.top},side:`top`},{boundaryPoint:{x:i+s(`bottom`),y:e.bottom},side:`bottom`}].map(({boundaryPoint:t,side:i})=>{let a=nt(e,i,t,r);return{point:(()=>{switch(i){case`left`:return{x:e.left-n,y:a.y};case`right`:return{x:e.right+n,y:a.y};case`top`:return{x:a.x,y:e.top-n};case`bottom`:return{x:a.x,y:e.bottom+n}}})(),boundaryPoint:a,side:i}})}function et(e,t,n,r,i){let a=(e.left+e.right)/2,o=(e.top+e.bottom)/2,s=(e.right-e.left)/2,c=(e.bottom-e.top)/2,l=Math.max(0,s-r),u=Math.max(0,c-i);if(t===`top`||t===`bottom`){let o=n.x-a;if(Math.abs(o)<=l)return n;let s=a+Math.sign(o||1)*l,c=Math.max(-1,Math.min(1,(n.x-s)/r)),u=i*(1-Math.sqrt(Math.max(0,1-c**2)));return{x:n.x,y:t===`top`?e.top+u:e.bottom-u}}let d=n.y-o;if(Math.abs(d)<=u)return n;let f=o+Math.sign(d||1)*u,p=Math.max(-1,Math.min(1,(n.y-f)/i)),m=r*(1-Math.sqrt(Math.max(0,1-p**2)));return{x:t===`left`?e.left+m:e.right-m,y:n.y}}function tt(e,t,n){let r=e.right-e.left,i=e.bottom-e.top,a=(e.left+e.right)/2,o=(e.top+e.bottom)/2,s=r*.09;if(t===`left`||t===`right`){let r=s*Math.min(1,Math.abs(n.y-o)/(i/2));return{x:t===`left`?e.left+r:e.right-r,y:n.y}}let c=r/2-s,l=n.x-a;if(Math.abs(l)<=c)return n;let u=(Math.abs(l)-c)/s*(i/2);return{x:n.x,y:t===`top`?e.top+u:e.bottom-u}}function nt(e,t,n,r){if(r===`external`)return tt(e,t,n);if(r===`concept`){let r=Math.min((e.right-e.left)/2,(e.bottom-e.top)/2);return et(e,t,n,r,r)}return r===`database`?et(e,t,n,(e.right-e.left)/2,(e.bottom-e.top)*.14):n}function rt(e,t){if(e<=1)return[0];let n=Math.max(1,t/2-16),r=n*2/(e-1);return Array.from({length:e},(e,t)=>-n+t*r)}function it(e,t){let n=new Map;for(let r of e){if(r.from===r.to)continue;let e=t[r.from],i=t[r.to];if(!e||!i)continue;let a={x:e.x+114,y:e.y+56},o={x:i.x+114,y:i.y+56},s=[{edge:r,end:`from`,nodeId:r.from,otherNodeId:r.to,otherCenter:o},{edge:r,end:`to`,nodeId:r.to,otherNodeId:r.from,otherCenter:a}];for(let e of s){let t=n.get(e.nodeId)??[];t.push(e),n.set(e.nodeId,t)}}let r=new Map,i=()=>({left:0,right:0,top:0,bottom:0}),a=e=>(t,n)=>(e===`left`||e===`right`?t.otherCenter.y:t.otherCenter.x)-(e===`left`||e===`right`?n.otherCenter.y:n.otherCenter.x)||P(t.otherNodeId,n.otherNodeId)||P(t.edge.id,n.edge.id)||P(t.end,n.end);for(let e of n.values())for(let t of[`left`,`right`,`top`,`bottom`]){let n=[...e].sort(a(t)),o=t===`left`||t===`right`?112:228,s=rt(n.length,o);n.forEach((e,n)=>{let a=r.get(e.edge.id)??{from:i(),to:i()};a[e.end][t]=s[n],r.set(e.edge.id,a)})}return r}function at(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.abs(n)>=Math.abs(r)?n>=0?`right`:`left`:r>=0?`bottom`:`top`}function ot(e,t){return e===t?0:e===`left`&&t===`right`||e===`right`&&t===`left`||e===`top`&&t===`bottom`||e===`bottom`&&t===`top`?72:24}function R(e){return`${e.x}:${e.y}`}function st(e,t){return e.cost-t.cost||P(e.stateKey,t.stateKey)}function ct(e,t){e.push(t);for(let t=e.length-1;t>0;){let n=Math.floor((t-1)/2);if(st(e[n],e[t])<=0)break;[e[n],e[t]]=[e[t],e[n]],t=n}}function lt(e){let t=e[0],n=e.pop();if(!t||!n||e.length===0)return t;e[0]=n;for(let t=0;t<e.length;){let n=t*2+1,r=n+1,i=t;if(n<e.length&&st(e[n],e[i])<0&&(i=n),r<e.length&&st(e[r],e[i])<0&&(i=r),i===t)break;[e[t],e[i]]=[e[i],e[t]],t=i}return t}function ut(e){let t=jt([...e.obstacles,...e.sources.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y})),...e.targets.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y}))]);if(!t)return null;let n=null;for(let r of e.sources)for(let i of e.targets){let a=e.channelOffset===0?[[r.point,{x:i.point.x,y:r.point.y},i.point],[r.point,{x:r.point.x,y:i.point.y},i.point]]:[t.left-Re-e.channelOffset,t.right+Re+e.channelOffset].map(e=>[r.point,{x:e,y:r.point.y},{x:e,y:i.point.y},i.point]).concat([t.top-Re-e.channelOffset,t.bottom+Re+e.channelOffset].map(e=>[r.point,{x:r.point.x,y:e},{x:i.point.x,y:e},i.point]));for(let t of a){let a=I(t);if(a.length<2||a.slice(1).some((t,n)=>Ze(a[n],t,e.obstacles)))continue;let o=a.slice(1).reduce((e,t,n)=>{let r=a[n];return e+Math.abs(t.x-r.x)+Math.abs(t.y-r.y)},0),s=r.penalty+i.penalty+o+Math.max(0,a.length-2)*ze,c=a.map(R).join(`|`);(n===null||s<n.cost||s===n.cost&&P(c,n.key)<0)&&(n={cost:s,key:c,points:a})}}return n?.points??null}function dt(e){if(e.sources.length===0||e.targets.length===0)return null;if(e.obstacles.length>=64){let t=ut({...e,channelOffset:Math.max(0,e.channelOffset??0)});if(t)return t}let t=[...e.sources,...e.targets],n=jt([...e.obstacles,...t.map(({point:e})=>({left:e.x,top:e.y,right:e.x,bottom:e.y}))]);if(!n)return null;let r=Math.max(0,e.channelOffset??0),i=[n.left-Re-r,n.right+Re+r,...e.obstacles.flatMap(e=>[e.left-r,e.right+r]),...t.map(({point:e})=>e.x)].sort((e,t)=>e-t),a=[n.top-Re-r,n.bottom+Re+r,...e.obstacles.flatMap(e=>[e.top-r,e.bottom+r]),...t.map(({point:e})=>e.y)].sort((e,t)=>e-t),o=[...new Set(i)],s=[...new Set(a)],c=new Map;for(let t of s)for(let n of o){let r={x:n,y:t};e.obstacles.some(e=>Xe(r,e))||c.set(R(r),r)}let l=new Map([...c.keys()].map(e=>[e,new Set])),u=(t,n)=>{if(Ze(t,n,e.obstacles))return;let r=R(t),i=R(n);l.get(r)?.add(i),l.get(i)?.add(r)};for(let e of s){let t=null;for(let n of o){let r=c.get(R({x:n,y:e}));r&&(t&&u(t,r),t=r)}}for(let e of o){let t=null;for(let n of s){let r=c.get(R({x:e,y:n}));r&&(t&&u(t,r),t=r)}}let d=new Map;for(let{point:t,penalty:n}of e.targets){let e=R(t);d.set(e,Math.min(n,d.get(e)??1/0))}let f=[],p=new Map,m=new Map;for(let{point:t,penalty:n}of e.sources){let e=R(t);if(!c.has(e))continue;let r=`${e}|start`,i=n;i>=(p.get(r)??1/0)||(p.set(r,i),m.set(r,null),ct(f,{stateKey:r,vertexKey:e,direction:`start`,cost:i}))}let h=null,g=1/0;for(;f.length>0;){let e=lt(f);if(e.cost!==p.get(e.stateKey))continue;if(e.cost>g)break;let t=d.get(e.vertexKey);if(t!==void 0){let n=e.cost+t;(n<g||n===g&&(!h||P(e.stateKey,h.stateKey)<0))&&(h=e,g=n)}let n=c.get(e.vertexKey);for(let t of[...l.get(e.vertexKey)??[]].sort(P)){let r=c.get(t),i=n.x===r.x?`vertical`:`horizontal`,a=Math.abs(n.x-r.x)+Math.abs(n.y-r.y),o=e.direction===`start`||e.direction===i?0:ze,s=e.cost+a+o,l=`${t}|${i}`;s>=(p.get(l)??1/0)||(p.set(l,s),m.set(l,e.stateKey),ct(f,{stateKey:l,vertexKey:t,direction:i,cost:s}))}}if(!h)return null;let _=[];for(let e=h.stateKey;e!==null;){let t=e.lastIndexOf(`|`),n=e.slice(0,t);_.push(c.get(n)),e=m.get(e)??null}return I(_.reverse())}function ft(e){let t=at(e.from,e.to),n=at(e.to,e.from),r=Le,i=Be,a=$e(e.fromBox,e.portOffsets.from,r,e.fromNotation),o=$e(e.toBox,e.portOffsets.to,i,e.toNotation),s=dt({sources:a.map(({point:e,side:n})=>({point:e,penalty:ot(n,t)})),targets:o.map(({point:e,side:t})=>({point:e,penalty:ot(t,n)})),obstacles:e.obstacles,...e.channelOffset===void 0?{}:{channelOffset:e.channelOffset}});if(!s)return null;let c=s[0],l=s.at(-1),u=a.find(({point:e})=>R(e)===R(c)),d=o.find(({point:e})=>R(e)===R(l));return!u||!d?null:I([u.boundaryPoint,...s,d.boundaryPoint])}function z(e){return e.points.slice(1).flatMap((t,n)=>{let r=e.points[n];return r.y===t.y&&r.x!==t.x?[{orientation:`horizontal`,fixed:t.y,minimum:Math.min(r.x,t.x),maximum:Math.max(r.x,t.x)}]:r.x===t.x&&r.y!==t.y?[{orientation:`vertical`,fixed:t.x,minimum:Math.min(r.y,t.y),maximum:Math.max(r.y,t.y)}]:[]})}function pt(e,t){return z(e).some(e=>z(t).some(t=>e.orientation!==t.orientation||Math.abs(e.fixed-t.fixed)>4?!1:Math.min(e.maximum,t.maximum)-Math.max(e.minimum,t.minimum)>=48))}function B(e,t){let n=new Map(e.map(e=>[e,new Set]));for(let r=0;r<e.length;r+=1){let i=e[r],a=t.get(i);if(a)for(let o=r+1;o<e.length;o+=1){let r=e[o],s=t.get(r);!s||!pt(a,s)||(n.get(i).add(r),n.get(r).add(i))}}let r=[],i=new Set;for(let t of e){if(i.has(t)||n.get(t)?.size===0)continue;let e=[],a=[t];i.add(t);for(let t=0;t<a.length;t+=1){let r=a[t];e.push(r);for(let e of[...n.get(r)??[]].sort(P))i.has(e)||(i.add(e),a.push(e))}r.push(e.sort(P))}return r}function V(e){let{point:t,notation:n,laneOffset:r,obstacles:i}=e,a=t.x,o=t.x+228,s=t.y,c=t.y+112,l=r*.55,u=e=>Math.max(a+16,Math.min(o-16,e)),d=e=>Math.max(s+16,Math.min(c-16,e));for(let e=0;e<12;e+=1){let t=88+Math.abs(r)*2+e*72,f={left:a,right:o,top:s,bottom:c},p=nt(f,`right`,{x:o,y:d(s+32+l)},n),m=nt(f,`right`,{x:o,y:d(c-32+l)},n),h=nt(f,`left`,{x:a,y:d(c-32-l)},n),g=nt(f,`left`,{x:a,y:d(s+32-l)},n),_=nt(f,`top`,{x:u(a+48+l),y:s},n),v=nt(f,`top`,{x:u(o-48+l),y:s},n),y=nt(f,`bottom`,{x:u(o-48-l),y:c},n),b=nt(f,`bottom`,{x:u(a+48-l),y:c},n),x=[Ge({boundaryStart:p,start:{x:o+Be,y:p.y},control1:{x:o+t,y:s-64+l},control2:{x:o+t,y:c+64+l},end:{x:o+Be,y:m.y},boundaryEnd:m}),Ge({boundaryStart:h,start:{x:a-Be,y:h.y},control1:{x:a-t,y:c+64-l},control2:{x:a-t,y:s-64-l},end:{x:a-Be,y:g.y},boundaryEnd:g}),Ge({boundaryStart:_,start:{x:_.x,y:s-Be},control1:{x:a-72+l,y:s-t},control2:{x:o+72+l,y:s-t},end:{x:v.x,y:s-Be},boundaryEnd:v}),Ge({boundaryStart:y,start:{x:y.x,y:c+Be},control1:{x:o+72-l,y:c+t},control2:{x:a-72-l,y:c+t},end:{x:b.x,y:c+Be},boundaryEnd:b})].find(e=>!L(e.points,i));if(x)return x}return null}function mt(e,t,n){let r=c(e),i=it(e,n),a=new Map(t.map(e=>[e.id,e.notation])),o=Je(e),s=new Map(t.flatMap(e=>{let t=n[e.id];return t?[[e.id,Ye(t,0)]]:[]})),l=new Map(t.flatMap(e=>{let t=n[e.id];return t?[[e.id,Ye(t)]]:[]})),u=new Map,d=[],f=[...e].sort((e,t)=>P(e.id,t.id)),p=(e,t=0)=>{let r=n[e.from],o=n[e.to],c=s.get(e.from),u=s.get(e.to);if(!r||!o||!c||!u)return null;let d=[...l].filter(([t])=>{if(t===e.from||t===e.to)return!0;let n=s.get(t);return!n||!H(n,c)&&!H(n,u)}).map(([,e])=>e),f=ft({from:{x:r.x+114,y:r.y+56},to:{x:o.x+114,y:o.y+56},fromBox:c,toBox:u,obstacles:d,portOffsets:i.get(e.id)??{from:{left:0,right:0,top:0,bottom:0},to:{left:0,right:0,top:0,bottom:0}},fromNotation:a.get(e.from)??`plain`,toNotation:a.get(e.to)??`plain`,channelOffset:t});return f?Ke(f):null};for(let e of f){let t=n[e.from],c=n[e.to];if(!t||!c)continue;let f=[...l].filter(([t])=>{if(t===e.from||t===e.to)return!1;let n=s.get(t),r=s.get(e.from),i=s.get(e.to);return n&&r&&i?!H(n,r)&&!H(n,i):!0}).map(([,e])=>e),m=r.get(e.id)??0;if(e.from===e.to){let n=V({point:t,notation:a.get(e.from)??`plain`,laneOffset:m,obstacles:f});n&&u.set(e.id,n);continue}let h=qe(e,n,m,o.has(e.id),i.get(e.id),a);if(h&&!H(l.get(e.from),l.get(e.to))&&!L(h.points,f)){u.set(e.id,h);continue}let g=p(e);g&&u.set(e.id,g),d.push(e.id)}let m=new Map([...d].sort(P).map((e,t)=>[e,t])),h=new Map(f.map(e=>[e.id,e]));for(let e=0;e<Math.min(8,d.length);e+=1){let e=B(d,u);if(e.length===0)break;for(let t of e)t.forEach(e=>{let t=h.get(e),n=m.get(e),r=p(t,(n+1)*8);r&&u.set(e,r)})}return u}function ht(e,t,n){let r=e.points.slice(1).map((t,n)=>{let r=e.points[n];return{previous:r,point:t,length:Math.hypot(t.x-r.x,t.y-r.y)}}),i=r.reduce((e,t)=>e+t.length,0)*t,a=r.find(e=>i<=e.length||(i-=e.length,!1))??r.at(-1);if(!a){let r={x:e.startX,y:e.startY};return{point:r,routePoint:r,tangent:{x:1,y:0},fraction:t,normalOffset:n}}let o=a.length===0?0:Math.min(1,i/a.length),s=a.previous.x+(a.point.x-a.previous.x)*o,c=a.previous.y+(a.point.y-a.previous.y)*o,l=a.point.x-a.previous.x,u=a.point.y-a.previous.y,d=Math.max(1,Math.hypot(l,u)),f={x:l/d,y:u/d},p={x:s,y:c};return{point:{x:s+-f.y*n,y:c+f.x*n},routePoint:p,tangent:f,fraction:t,normalOffset:n}}function H(e,t){return!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function U(e,t,n,r,i=0){return{left:e-n/2-i,top:t-r/2-i,right:e+n/2+i,bottom:t+r/2+i}}function W(e,t){return{left:e.left-t,top:e.top-t,right:e.right+t,bottom:e.bottom+t}}function gt(e,t){let n=Math.max(t.left-e.x,0,e.x-t.right),r=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.hypot(n,r)}function _t(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+r*o),e.y-(t.y+i*o))}function G(e,t,n){if(Qe(t,n,e))return 0;let r=[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.right,y:e.bottom},{x:e.left,y:e.bottom}];return Math.min(gt(t,e),gt(n,e),...r.map(e=>_t(e,t,n)))}function vt(e,t){return t.length<2?1/0:Math.min(...t.slice(1).map((n,r)=>G(e,t[r],n)))}function yt(e,t,n=0){return{left:Math.min(e.x,t.x)-n,top:Math.min(e.y,t.y)-n,right:Math.max(e.x,t.x)+n,bottom:Math.max(e.y,t.y)+n}}function bt(e){let t=[],n=Math.floor(e.left/je),r=Math.floor(e.right/je),i=Math.floor(e.top/je),a=Math.floor(e.bottom/je);for(let e=n;e<=r;e+=1)for(let n=i;n<=a;n+=1)t.push(`${e}:${n}`);return t}function xt(){let e=new Map;return{addPolyline(t,n){n.slice(1).forEach((r,i)=>{let a=n[i];if(a.x===r.x&&a.y===r.y)return;let o={ownerId:t,start:a,end:r};for(let t of bt(yt(a,r))){let n=e.get(t)??[];n.push(o),e.set(t,n)}})},query(t){let n=new Set;for(let r of bt(t))for(let t of e.get(r)??[])n.add(t);return[...n]}}}function St(e,t,n,r){let i={x:t.x-e.x,y:t.y-e.y},a={x:r.x-n.x,y:r.y-n.y},o=Math.hypot(i.x,i.y),s=Math.hypot(a.x,a.y);if(o===0||s===0||Math.abs(i.x*a.y-i.y*a.x)/(o*s)>.17||Math.min(_t(e,n,r),_t(t,n,r),_t(n,e,t),_t(r,e,t))>be)return null;let c={x:i.x/o,y:i.y/o},l=t=>(t.x-e.x)*c.x+(t.y-e.y)*c.y,u=l(n),d=l(r),f=Math.max(0,Math.min(u,d)),p=Math.min(o,Math.max(u,d));return p>f?{start:f,end:p}:null}function Ct(e){let t=0;for(let n of e.values()){let e=[...n].sort((e,t)=>e.start-t.start||e.end-t.end),r=null,i=null;for(let n of e){if(r===null||i===null){r=n.start,i=n.end;continue}if(n.start<=i+.001){i=Math.max(i,n.end);continue}t=Math.max(t,i-r),r=n.start,i=n.end}r!==null&&i!==null&&(t=Math.max(t,i-r))}return t}function wt(e,t,n,r){let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),a=i(e,t,n),o=i(e,t,r),s=i(n,r,e),c=i(n,r,t);return a*o<-1e-6&&s*c<-1e-6}function Tt(e){return e.slice(1).reduce((t,n,r)=>{let i=e[r];return t+Math.hypot(n.x-i.x,n.y-i.y)},0)}function Et(e,t,n){let r=new Map,i=0,a=0;return e.slice(1).forEach((o,s)=>{let c=e[s],l=yt(c,o,be),u=(e,t)=>{let n=St(c,o,e.start,e.end);if(n){let i=`${t}:${e.ownerId}`,o=r.get(i)??[];o.push({start:a+n.start,end:a+n.end}),r.set(i,o)}wt(c,o,e.start,e.end)&&(i+=1)};for(let e of t.query(l))u(e,`route`);for(let e of n.query(l))u(e,`leader`);a+=Math.hypot(o.x-c.x,o.y-c.y)}),{length:a,maxParallelOverlap:Ct(r),crossingCount:i}}function Dt(e,t){let n={x:(e.left+e.right)/2,y:(e.top+e.bottom)/2},r=t.x-n.x,i=t.y-n.y;if(r===0&&i===0)return{x:n.x,y:e.top};let a=Math.max(1,(e.right-e.left)/2),o=Math.max(1,(e.bottom-e.top)/2),s=1/Math.max(Math.abs(r)/a,Math.abs(i)/o);return{x:n.x+r*s,y:n.y+i*s}}function Ot(e){let t=(e.left+e.right)/2,n=(e.top+e.bottom)/2;return[{x:e.left,y:n},{x:e.right,y:n},{x:t,y:e.top},{x:t,y:e.bottom}]}function kt(e){let t=new Set([...e.obstacles.flatMap(e=>[e.left,e.right]),...e.sources.map(({point:e})=>e.x),...e.targets.map(({point:e})=>e.x)]),n=new Set([...e.obstacles.flatMap(e=>[e.top,e.bottom]),...e.sources.map(({point:e})=>e.y),...e.targets.map(({point:e})=>e.y)]);return t.size*n.size}function At(e){if(e.obstacles.some(t=>Xe(e.routePoint,t)))return null;let t={x:-e.routeTangent.y,y:e.routeTangent.x},n={x:(e.label.left+e.label.right)/2,y:(e.label.top+e.label.bottom)/2},r=(n.x-e.routePoint.x)*t.x+(n.y-e.routePoint.y)*t.y>=0?1:-1,i=e.targetPorts??Ot(e.label),a=e.targetPorts?[...i].sort((t,n)=>Math.hypot(t.x-e.routePoint.x,t.y-e.routePoint.y)-Math.hypot(n.x-e.routePoint.x,n.y-e.routePoint.y)||P(R(t),R(n)))[0]:Dt(e.label,e.routePoint),o=Math.hypot(a.x-e.routePoint.x,a.y-e.routePoint.y),s=Math.min(j,Math.max(2,o*.45)),c=[],l=[];for(let n of[r,-r]){let r={x:e.routePoint.x+t.x*s*n,y:e.routePoint.y+t.y*s*n};if(e.obstacles.some(t=>Qe(e.routePoint,r,t)))continue;l.push(r);let i=Dt(e.label,r);e.obstacles.some(e=>Qe(r,i,e))||c.push([e.routePoint,r,i])}let u=t=>[...new Map(t.map(e=>I(e)).filter(t=>t.length>=2&&!t.slice(1).some((n,r)=>e.obstacles.some(e=>Qe(t[r],n,W(e,-.001))))).map(e=>[e.map(R).join(`|`),e])).values()].map(t=>({points:t,...Et(t,e.routeSegments,e.leaderSegments)})),d=(e,t)=>{let n=e.maxParallelOverlap>=M,r=t.maxParallelOverlap>=M;return Number(n)-Number(r)||e.length+e.crossingCount*8-(t.length+t.crossingCount*8)||e.maxParallelOverlap-t.maxParallelOverlap||e.points.length-t.points.length||P(e.points.map(R).join(`|`),t.points.map(R).join(`|`))},f=u(c).sort(d);if(f[0]&&f[0].maxParallelOverlap<M)return f[0];let p=l.flatMap(t=>{let n={sources:[{point:t,penalty:0}],targets:i.map(e=>({point:e,penalty:0})),obstacles:[...e.obstacles,e.label],channelOffset:0},r=ut(n)??(e.allowOuterRoute?ut({...n,channelOffset:N}):null)??(kt(n)<=(e.fullGridVertexLimit??xe)?dt(n):null);return r?[[e.routePoint,...r]]:[]});return[...f,...u(p)].sort(d)[0]??null}function jt(e){return e.length===0?null:{left:Math.min(...e.map(e=>e.left)),top:Math.min(...e.map(e=>e.top)),right:Math.max(...e.map(e=>e.right)),bottom:Math.max(...e.map(e=>e.bottom))}}function Mt(e){return[...e].reduce((e,t)=>e+(/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}/u.test(t)?1:.56),0)}function Nt(e,t){if(/\s/u.test(e)||/[./_-]/u.test(e)||e===`:`&&t===`:`)return!0;if(!t||!/[\p{L}\p{N}]/u.test(e)||!/[\p{L}\p{N}]/u.test(t))return!1;let n=e=>/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}/u.test(e);return n(e)!==n(t)}function Pt(e,t){let n=[...e.trimEnd()];for(;n.length>0&&Mt(n.join(``)+`…`)>t;)n.pop();return`${n.join(``).trimEnd()}…`}function Ft(e,t){let n=e.trim();if(!n)return[``];let r=[];for(;Mt(n)>t;){let e=[...n],i=0,a=0,o=0;for(let n=0;n<e.length;n+=1){let r=e[n],s=i+Mt(r);if(s>t&&a>0)break;if(i=s,a=n+1,Nt(r,e[n+1])){if(r===`:`&&e[n+1]===`:`){if(s+Mt(e[n+1])<=t)o=n+2;else if(n>0){o=n;break}}else o=n+1}if(i>t)break}let s=Math.min(e.length,o>0?o:Math.max(1,a));if(r.push(e.slice(0,s).join(``).trimEnd()),n=e.slice(s).join(``).trimStart(),!n)break}return n&&r.push(n),r}function It(e){let t=Math.max(.56,e.maxUnits),n=e.text.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`).replaceAll(`\r`,`
|
|
4
4
|
`).split(`
|