@phin-tech/dottie 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +11 -8
- package/README.md +7 -0
- package/dist/compile.js +109 -9
- package/dist/dottie-compile.mjs +110 -10
- package/dist/dottie-player.js +821 -173
- package/dist/dottie-player.min.js +54 -53
- package/dist/dottie-sim.min.js +4 -0
- package/dist/dottie.js +803 -173
- package/dist/types/compile.d.ts +1 -1
- package/dist/types/connector.d.ts +4 -0
- package/dist/types/elbow.d.ts +18 -0
- package/dist/types/flows.d.ts +7 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/measure.d.ts +29 -3
- package/dist/types/model.d.ts +32 -0
- package/dist/types/planner.d.ts +12 -0
- package/dist/types/player.d.ts +9 -0
- package/dist/types/sim-entry.d.ts +1 -0
- package/dist/types/svg.d.ts +9 -2
- package/dist/types/symbols.d.ts +19 -3
- package/dist/types/theme.d.ts +13 -1
- package/dist/types/timeline.d.ts +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! dottie.js 0.10.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
|
+
"use strict";(()=>{var xn=Object.defineProperty;var bn=(t,e,n)=>e in t?xn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var K=(t,e,n)=>bn(t,typeof e!="symbol"?e+"":e,n);var St=.5522847498307936,se=class t{constructor(){K(this,"segments",[])}get isEmpty(){return this.segments.length===0}moveTo(e){return this.segments.push({op:"M",p:e}),this}lineTo(e){return this.segments.push({op:"L",p:e}),this}quadTo(e,n){return this.segments.push({op:"Q",c:n,p:e}),this}curveTo(e,n,o){return this.segments.push({op:"C",c1:n,c2:o,p:e}),this}close(){return this.segments.push({op:"Z"}),this}addPath(e){return this.segments.push(...e.segments),this}addLines(e){return e.forEach((n,o)=>o===0?this.moveTo(n):this.lineTo(n)),this}static rect(e){return new t().addLines([{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]).close()}addEllipse(e){let n=e.x+e.width/2,o=e.y+e.height/2,r=e.width/2,s=e.height/2,i=r*St,l=s*St;return this.moveTo({x:n+r,y:o}),this.curveTo({x:n,y:o+s},{x:n+r,y:o+l},{x:n+i,y:o+s}),this.curveTo({x:n-r,y:o},{x:n-i,y:o+s},{x:n-r,y:o+l}),this.curveTo({x:n,y:o-s},{x:n-r,y:o-l},{x:n-i,y:o-s}),this.curveTo({x:n+r,y:o},{x:n+i,y:o-s},{x:n+r,y:o-l}),this.close()}static ellipse(e){return new t().addEllipse(e)}translated(e,n){let o=s=>({x:s.x+e,y:s.y+n}),r=new t;return r.segments=this.segments.map(s=>{switch(s.op){case"M":case"L":return{op:s.op,p:o(s.p)};case"Q":return{op:"Q",c:o(s.c),p:o(s.p)};case"C":return{op:"C",c1:o(s.c1),c2:o(s.c2),p:o(s.p)};case"Z":return s}}),r}contours(){let e=[],n=[],o={x:0,y:0};for(let r of this.segments){let s=n.length?n[n.length-1]:o;switch(r.op){case"M":n.length>1&&e.push(n),o=r.p,n=[r.p];break;case"L":n.push(r.p);break;case"Q":for(let i=1;i<=12;i++){let l=i/12,a=1-l;n.push({x:a*a*s.x+2*a*l*r.c.x+l*l*r.p.x,y:a*a*s.y+2*a*l*r.c.y+l*l*r.p.y})}break;case"C":for(let i=1;i<=16;i++){let l=i/16,a=1-l;n.push({x:a*a*a*s.x+3*a*a*l*r.c1.x+3*a*l*l*r.c2.x+l*l*l*r.p.x,y:a*a*a*s.y+3*a*a*l*r.c1.y+3*a*l*l*r.c2.y+l*l*l*r.p.y})}break;case"Z":n.push(o),n.length>1&&e.push(n),n=[o];break}}return n.length>1&&e.push(n),e}trimmed(e){let n=this.contours().map(s=>new ke(s)),o=Math.min(Math.max(e,0),1)*n.reduce((s,i)=>s+i.length,0),r=new t;for(let s of n){if(!(o>0))break;r.moveTo(s.points[0]);for(let i=1;i<s.points.length;i++){let l=s.lengths[i]-s.lengths[i-1];if(l<=o){r.lineTo(s.points[i]),o-=l;continue}let a=s.points[i-1],c=s.points[i],u=o/l;r.lineTo({x:a.x+(c.x-a.x)*u,y:a.y+(c.y-a.y)*u}),o=0;break}}return r}data(){let e=[];for(let n of this.segments)switch(n.op){case"M":e.push(`M${ue(n.p.x)} ${ue(n.p.y)}`);break;case"L":e.push(`L${ue(n.p.x)} ${ue(n.p.y)}`);break;case"Q":e.push(`Q${ue(n.c.x)} ${ue(n.c.y)} ${ue(n.p.x)} ${ue(n.p.y)}`);break;case"C":e.push(`C${ue(n.c1.x)} ${ue(n.c1.y)} ${ue(n.c2.x)} ${ue(n.c2.y)} ${ue(n.p.x)} ${ue(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function It(t){return t<0?-Math.round(-t):Math.round(t)}function ue(t){let e=It(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var ke=class{constructor(e){K(this,"points");K(this,"lengths");this.points=e;let n=0;this.lengths=e.map((o,r)=>(r>0&&(n+=Math.hypot(o.x-e[r-1].x,o.y-e[r-1].y)),n))}get length(){return this.lengths.length?this.lengths[this.lengths.length-1]:0}point(e){if(this.points.length<=1||!(this.length>0))return this.points[0]??{x:0,y:0};let n=Math.min(Math.max(e,0),1)*this.length,o=1;for(;o<this.lengths.length-1&&this.lengths[o]<n;)o++;let r=this.lengths[o]-this.lengths[o-1],s=r>0?(n-this.lengths[o-1])/r:0,i=this.points[o-1],l=this.points[o];return{x:i.x+(l.x-i.x)*s,y:i.y+(l.y-i.y)*s}}},Ae=t=>t.x+t.width/2,Se=t=>t.y+t.height/2,xe=t=>t.x+t.width,be=t=>t.y+t.height;function qe(t,e,n){if(n===0)return t;let o=t.x-e.x,r=t.y-e.y;return{x:e.x+o*Math.cos(n)-r*Math.sin(n),y:e.y+o*Math.sin(n)+r*Math.cos(n)}}function Tt(t,e){let n=1-e;return{x:t[0].x*(n*n*n)+t[1].x*(3*e*n*n)+t[2].x*(3*e*e*n)+t[3].x*(e*e*e),y:t[0].y*(n*n*n)+t[1].y*(3*e*n*n)+t[2].y*(3*e*e*n)+t[3].y*(e*e*e)}}var de=(t,e,n)=>({r:t,g:e,b:n,a:1});function wn(t){let e=parseInt(t.slice(1),16);return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255,a:1}}var kn=["accent","muted","danger","warning","success","info"],nt=t=>kn.map((e,n)=>({name:e,color:wn(t[n])})),tt=nt(["#2563eb","#6b7280","#dc2626","#d97706","#16a34a","#0891b2"]),Qe=nt(["#93c5fd","#cbd5e1","#fca5a5","#fcd34d","#86efac","#67e8f9"]),Mn=[{id:"paper",name:"Paper",background:de(.984,.98,.965),ink:de(.12,.12,.13),palette:tt},{id:"white",name:"White",background:de(1,1,1),ink:de(.12,.12,.13),palette:tt},{id:"sepia",name:"Sepia",background:de(.953,.914,.824),ink:de(.23,.18,.13),palette:nt(["#9a3412","#78716c","#b91c1c","#b45309","#4d7c0f","#0e7490"])},{id:"blueprint",name:"Blueprint",background:de(.106,.227,.361),ink:de(.91,.945,.984),palette:Qe},{id:"chalkboard",name:"Chalkboard",background:de(.169,.227,.2),ink:de(.945,.945,.918),palette:Qe},{id:"midnight",name:"Midnight",background:de(.082,.086,.102),ink:de(.925,.925,.94),palette:Qe}];function Pn(t){return Mn.find(e=>e.id===t)??null}function En(t){let e=t.customTheme;return e?{id:"custom",name:e.name,background:e.background,ink:e.ink,palette:e.palette}:Pn(t.theme)}function et(t,e){let n=e.trim().toLowerCase();return(En(t)?.palette??tt).find(o=>o.name.toLowerCase()===n)?.color??null}function Ot(t){let e=o=>!!o.style.named;if(!t.elements.some(e)&&!(t.symbols??[]).some(o=>o.elements.some(e)))return t;let n=o=>{let r=o.style.named;if(!r)return o;let s={...o.style},i=r.fill!==null?et(t,r.fill):null,l=r.stroke!==null?et(t,r.stroke):null,a=r.textColor!==null?et(t,r.textColor):null;return i&&(s.fill={...i}),l&&(s.stroke={...l}),a&&(s.textColor={...a}),{...o,style:s}};return{...t,elements:t.elements.map(n),symbols:t.symbols?t.symbols.map(o=>({...o,elements:o.elements.map(n)})):t.symbols}}var Ct=2,Rn=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image","symbol"],An=["linear","easeIn","easeOut","easeInOut","hold","spring","bounce","elastic"],Sn={file:["version","pages","images"],page:["id","name","layers","elements","theme","customTheme","guidesX","guidesY","guidesLocked","timeline","symbols","variables","flows"],flow:["id","from","to","every","speed","color","size","when","spread","volume","overrides"],flowOverride:["when","volume"],symbol:["id","name","width","height","layers","elements","timeline","button","params"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","font","gridSize","opacity","dashOffset","textColor","named"],colorNames:["fill","stroke","textColor"],customTheme:["name","background","ink","palette","base"],paletteColor:["name","color"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","url","anchor","click","hover","when","overrides","symbol","playback","offset","args","image","reveal","ports","labelRect","extension","capacity","delay","queue","gauge","containerID","container"],container:["fixed","lanes"],gauge:["metric","of","max","warn","alarm","style","label"],strokePoint:["x","y"],subpath:["closed","coords"],inlineImage:["data","format"],endpoint:["elementID","port","portIndex","x","y"],extensionRef:["id","shape","version","params"],normalizedPoint:["x","y"],normalizedRect:["x","y","width","height"],connector:["start","end","routing","startHead","endHead","waypoints","hops","avoid","cost"],waypoint:["x","y"],timeline:["fps","duration","boil","settle","poster","tracks","camera","markers"],track:["element","keys","boil","follow","repeats","march"],keyframe:["t","x","y","width","height","rotation","strokeWidth","stroke","fill","visible","reveal","opacity","ease"],follow:["path","start","end","ease","reverse","orient","laps"],repeat:["start","end","count"],cameraKey:["t","x","y","width","height","ease"],marker:["t","name","loop"],click:["scene","url","set","toggle","reset"],hover:["stroke","fill","opacity"],override:["when","stroke","fill","textColor","opacity","strokeWidth","dash","text","reroute","offline","cost","capacity","delay"]},De=3600,Ft=1e4,In=t=>t===void 0||!Number.isFinite(t)||t===0?null:Math.min(Math.max(t,-Ft),Ft);var Tn={r:.12,g:.12,b:.13,a:1},On={r:0,g:0,b:0,a:0};var Me=class extends Error{},M=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),g=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,k=t=>typeof t=="string"?t:void 0,Dt=t=>M(t)&&Object.values(t).every(e=>typeof e=="string")?{...t}:null,me=t=>typeof t=="boolean"?t:void 0,Gt="00000000-0000-0000-0000-000000000000",Fe=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,fe=t=>typeof t=="string"?t.toUpperCase():void 0;function rt(t){return Number.isFinite(t)?Math.min(Math.max(t,0),De):t===1/0?De:0}function Nt(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function Cn(t){let e=t.trim();return!/^(https?:\/\/|mailto:)/i.test(e)||[...e].length<=7||/[\u0000-\u001f\u007f-\u009f]/.test(e)?null:e}function ce(t){if(!M(t))return;let e=g(t.r),n=g(t.g),o=g(t.b);if(!(e===void 0||n===void 0||o===void 0))return{r:e,g:n,b:o,a:g(t.a)??1}}var st=class{constructor(){K(this,"warnings",[]);K(this,"seen",new Set)}warn(e){this.seen.has(e)||(this.seen.add(e),this.warnings.push(e))}fields(e,n){let o=Sn[n];for(let r of Object.keys(e))o.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=M(e)?e:{};this.fields(n,"style");let o=k(n.fillStyle)??"solid",r=k(n.dash)??"solid";return["solid","hachure","crossHatch","grid"].includes(o)||this.warn(`Unknown fill style "${o}", drawn solid`),["solid","dashed","dotted"].includes(r)||this.warn(`Unknown dash "${r}", drawn solid`),{stroke:ce(n.stroke)??{...Tn},fill:ce(n.fill)??{...On},fillStyle:["solid","hachure","crossHatch","grid"].includes(o)?o:"solid",strokeWidth:g(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:g(n.roughness)??1,bowing:g(n.bowing)??1,fontSize:g(n.fontSize)??18,font:k(n.font)||null,gridSize:g(n.gridSize)??null,opacity:g(n.opacity)??null,dashOffset:g(n.dashOffset)??null,textColor:ce(n.textColor)??null,named:this.colorNames(n.named)}}container(e){return M(e)?(this.fields(e,"container"),{fixed:e.fixed===!0?!0:null,lanes:e.lanes==="rows"||e.lanes==="columns"?e.lanes:null}):null}colorNames(e){if(!M(e))return null;this.fields(e,"colorNames");let n={fill:k(e.fill)??null,stroke:k(e.stroke)??null,textColor:k(e.textColor)??null};return n.fill===null&&n.stroke===null&&n.textColor===null?null:n}customTheme(e){if(!M(e))return null;this.fields(e,"customTheme");let n=ce(e.background),o=ce(e.ink);if(!n||!o)return this.warn("A custom theme needs a background and an ink; drawn without it"),null;let r=(Array.isArray(e.palette)?e.palette:[]).filter(M).flatMap(s=>{this.fields(s,"paletteColor");let i=k(s.name),l=ce(s.color);return i&&l?[{name:i,color:l}]:[]});return{name:k(e.name)??"Custom",background:n,ink:o,palette:r,base:k(e.base)??null}}endpoint(e){let n=M(e)?e:{},o=k(n.port),r=g(n.portIndex);return{elementID:fe(n.elementID)??null,port:o&&["top","right","bottom","left"].includes(o)?o:null,portIndex:r!==void 0&&Number.isInteger(r)&&r>=0?r:null,x:g(n.x)??0,y:g(n.y)??0}}connector(e){if(!M(e))return null;this.fields(e,"connector");let n=(r,s)=>{let i=k(r);return i&&["none","arrow","triangle","dot","bar"].includes(i)?i:s},o=k(e.routing);return{start:this.endpoint(e.start),end:this.endpoint(e.end),routing:o&&["straight","curved","elbow"].includes(o)?o:"straight",startHead:n(e.startHead,"none"),endHead:n(e.endHead,"arrow"),waypoints:Array.isArray(e.waypoints)?e.waypoints.filter(M).map(r=>(this.fields(r,"waypoint"),{x:g(r.x)??0,y:g(r.y)??0})):null,hops:typeof e.hops=="boolean"?e.hops:null,avoid:typeof e.avoid=="boolean"?e.avoid:null,cost:typeof e.cost=="number"&&Number.isFinite(e.cost)?e.cost:null}}image(e,n){if(!M(e))return null;let o=k(e.ref);if(o!==void 0)return n[o]??{data:"",format:"png"};let r=k(e.data);return r===void 0?null:this.picture(r,k(e.format))}picture(e,n){return Fn.test(e)?{data:e.replace(/\s+/g,""),format:n==="jpeg"?"jpeg":"png"}:(this.warn("Skipped a picture whose data isn't base64"),{data:"",format:"png"})}element(e,n){if(!M(e))return null;this.fields(e,"element");let o=fe(e.id),r=k(e.kind),s=fe(e.layerID);if(!o||!r||!s)return this.warn("Skipped an element without an id, kind or layer"),null;Rn.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let i=Array.isArray(e.subpaths)?e.subpaths.filter(M).map(l=>({closed:me(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:o,kind:r,layerID:s,x:g(e.x)??0,y:g(e.y)??0,width:g(e.width)??0,height:g(e.height)??0,style:this.style(e.style),seed:(g(e.seed)??1)>>>0,text:k(e.text)??null,connector:this.connector(e.connector),groupID:fe(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(M).map(l=>({x:g(l.x)??0,y:g(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:i,evenOdd:me(e.evenOdd)??null,rotation:g(e.rotation)??null,link:fe(e.link)??null,url:k(e.url)??null,anchor:k(e.anchor)??null,click:this.click(e.click),hover:this.hover(e.hover),when:k(e.when)??null,overrides:this.overrides(e.overrides),symbol:fe(e.symbol)??null,playback:this.playback(e.playback),offset:g(e.offset)??null,args:Dt(e.args),image:this.image(e.image,n),reveal:g(e.reveal)??null,ports:Array.isArray(e.ports)?e.ports.map(l=>{let a=M(l)?l:{};return{x:g(a.x)??0,y:g(a.y)??0}}):null,labelRect:this.labelRect(e.labelRect),extension:this.extension(e.extension),capacity:g(e.capacity)??null,delay:g(e.delay)??null,queue:e.queue===!0?!0:null,gauge:this.gauge(e.gauge),containerID:fe(e.containerID)??null,container:this.container(e.container)}}gauge(e){if(!M(e))return null;this.fields(e,"gauge");let n=r=>typeof r=="number"&&Number.isFinite(r)?r:null,o=k(e.style);return{metric:k(e.metric)??"",of:typeof e.of=="string"&&Fe.test(e.of)?e.of.toUpperCase():Gt,max:n(e.max),warn:n(e.warn),alarm:n(e.alarm),style:o==="number"||o==="bar"||o==="dial"?o:null,label:k(e.label)??null}}labelRect(e){return M(e)?(this.fields(e,"normalizedRect"),{x:g(e.x)??0,y:g(e.y)??0,width:g(e.width)??0,height:g(e.height)??0}):null}extension(e){if(!M(e))return null;this.fields(e,"extensionRef");let n=k(e.id),o=k(e.shape),r=k(e.version);if(n===void 0||o===void 0||r===void 0)return this.warn("Skipped an extension without an id, shape or version"),null;let s={};if(M(e.params))for(let[i,l]of Object.entries(e.params))(typeof l=="number"||typeof l=="boolean"||typeof l=="string")&&(s[i]=l);return{id:n,shape:o,version:r,params:s}}variables(e){if(!M(e))return null;let n={};for(let[o,r]of Object.entries(e))typeof r=="boolean"&&(n[o]=r);return Object.keys(n).length>0?n:null}click(e){if(!M(e))return null;this.fields(e,"click");let n=k(e.url),o=n===void 0?null:Cn(n);n!==void 0&&o===null&&this.warn("Skipped a click link that isn't http, https or mailto");let r=null;if(M(e.set)){r={};for(let[l,a]of Object.entries(e.set))typeof a=="boolean"&&Be(l)&&(r[l]=a);Object.keys(r).length===0&&(r=null)}let s=typeof e.toggle=="string"?[e.toggle]:Array.isArray(e.toggle)&&e.toggle.every(l=>typeof l=="string")?e.toggle:null,i=s?s.filter(Be):null;return{scene:k(e.scene)??null,url:o,set:r,toggle:i&&i.length>0?i:null,reset:e.reset===!0?!0:null}}playback(e){let n=k(e);return n===void 0?null:["loop","once","still","click"].includes(n)?n:"loop"}symbol(e,n){if(!M(e))return null;this.fields(e,"symbol");let o=fe(e.id);if(!o)return this.warn("Skipped a symbol without an id"),null;let r=i=>{let l=g(i);return Math.max(1,l??100)},s=(Array.isArray(e.layers)?e.layers:[]).filter(M).flatMap(i=>{let l=fe(i.id);return l?[{id:l,name:k(i.name)??"",visible:me(i.visible)??!0,locked:me(i.locked)??!1}]:[]});return s.length===0&&s.push({id:`${o}-LAYER`,name:"Layer 1",visible:!0,locked:!1}),{id:o,name:k(e.name)??"Symbol",width:r(e.width),height:r(e.height),layers:s,elements:(Array.isArray(e.elements)?e.elements:[]).map(i=>this.element(i,n)).filter(i=>i!==null),timeline:this.timeline(e.timeline),button:me(e.button)??null,params:Dt(e.params)}}overrides(e){return Array.isArray(e)?e.filter(M).map(n=>{this.fields(n,"override");let o=k(n.dash),r=null;if(M(n.reroute)&&Object.values(n.reroute).every(s=>typeof s=="string"&&Fe.test(s))){r={};for(let[s,i]of Object.entries(n.reroute))Fe.test(s)&&(r[s.toUpperCase()]=i.toUpperCase());Object.keys(r).length===0&&(r=null)}return{when:k(n.when)??"",stroke:ce(n.stroke)??null,fill:ce(n.fill)??null,textColor:ce(n.textColor)??null,opacity:g(n.opacity)??null,strokeWidth:g(n.strokeWidth)??null,dash:o!==void 0&&["solid","dashed","dotted"].includes(o)?o:null,text:k(n.text)??null,reroute:r,offline:n.offline===!0?!0:null,cost:typeof n.cost=="number"&&Number.isFinite(n.cost)?n.cost:null,capacity:typeof n.capacity=="number"&&Number.isFinite(n.capacity)?n.capacity:null,delay:typeof n.delay=="number"&&Number.isFinite(n.delay)?n.delay:null}}):null}hover(e){return M(e)?(this.fields(e,"hover"),{stroke:ce(e.stroke)??null,fill:ce(e.fill)??null,opacity:g(e.opacity)??null}):null}ease(e){let n=k(e);return n===void 0?null:An.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!M(e))return null;this.fields(e,"keyframe");let n=g(e.t);if(n===void 0)return null;let o={t:n};for(let a of["x","y","width","height","rotation","strokeWidth","reveal","opacity"]){let c=g(e[a]);c!==void 0&&(o[a]=c)}let r=ce(e.stroke),s=ce(e.fill),i=me(e.visible),l=this.ease(e.ease);return r&&(o.stroke=r),s&&(o.fill=s),i!==void 0&&(o.visible=i),l&&(o.ease=l),o}track(e){if(!M(e))return null;this.fields(e,"track");let n=fe(e.element);if(!n)return null;let o=(Array.isArray(e.keys)?e.keys:[]).map(i=>this.keyframe(i)).filter(i=>i!==null&&i.t>=0&&i.t<=De);ot(o,i=>i.t);let r=Array.isArray(e.follow)?e.follow.filter(M).flatMap(i=>{let l=fe(i.path),a=g(i.start),c=g(i.end);return!l||a===void 0||c===void 0||a<0||c>De?[]:[{path:l,start:a,end:c,ease:this.ease(i.ease),reverse:me(i.reverse)??null,orient:me(i.orient)??null,laps:g(i.laps)??null}]}):null,s=Array.isArray(e.repeats)?e.repeats.filter(M).flatMap(i=>{let l=g(i.start),a=g(i.end);if(l===void 0||a===void 0)return[];let c=g(i.count),u={start:l,end:a,count:c===void 0?null:Math.trunc(c)};return Lt(u)?[u]:[]}):null;return{element:n,keys:o,boil:me(e.boil)??null,follow:r,repeats:s,march:In(g(e.march))}}timeline(e){if(!M(e))return null;this.fields(e,"timeline");let n=g(e.boil),o=Array.isArray(e.camera)?e.camera.filter(M).flatMap(i=>{let l=g(i.t),a=g(i.x),c=g(i.y),u=g(i.width),p=g(i.height);return l===void 0||a===void 0||c===void 0||u===void 0||p===void 0?[]:u>1&&p>1&&l>=0?[{t:l,x:a,y:c,width:u,height:p,ease:this.ease(i.ease)}]:[]}):null;o&&ot(o,i=>i.t);let r=Array.isArray(e.markers)?e.markers.filter(M).flatMap(i=>{let l=g(i.t);return l!==void 0&&l>=0?[{t:l,name:k(i.name)??"",loop:me(i.loop)??null}]:[]}):null;r&&ot(r,i=>i.t);let s=g(e.poster);return{fps:Nt(g(e.fps)??12),duration:rt(g(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:me(e.settle)??null,poster:s===void 0?null:rt(s),tracks:(Array.isArray(e.tracks)?e.tracks:[]).map(i=>this.track(i)).filter(i=>i!==null),camera:o,markers:r}}page(e,n,o){if(!M(e))throw new Me(`Page ${o} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(M).flatMap(s=>{let i=fe(s.id);return i?[{id:i,name:k(s.name)??"",visible:me(s.visible)??!0,locked:me(s.locked)??!1}]:[]});return r.length===0&&(this.warn(`Page ${o} has no layers`),r.push({id:"LAYER",name:"Layer 1",visible:!0,locked:!1})),{id:fe(e.id)??`PAGE-${o}`,name:k(e.name)??`Page ${o}`,layers:r,elements:(Array.isArray(e.elements)?e.elements:[]).map(s=>this.element(s,n)).filter(s=>s!==null),theme:k(e.theme)??null,customTheme:this.customTheme(e.customTheme),timeline:this.timeline(e.timeline),symbols:Array.isArray(e.symbols)?e.symbols.map(s=>this.symbol(s,n)).filter(s=>s!==null):null,variables:this.variables(e.variables),flows:Array.isArray(e.flows)?e.flows.filter(M).map(s=>this.flow(s)):null}}flow(e){this.fields(e,"flow");let n=r=>typeof r=="string"&&Fe.test(r)?r.toUpperCase():Gt,o=r=>{let s=g(r);return s!==void 0&&Number.isFinite(s)?s:null};return{id:n(e.id),from:n(e.from),to:Array.isArray(e.to)&&e.to.every(r=>typeof r=="string")?e.to.filter(r=>Fe.test(r)).map(r=>r.toUpperCase()):[],every:o(e.every),speed:o(e.speed),size:o(e.size),color:M(e.color)&&["r","g","b","a"].every(r=>typeof e.color[r]=="number")?ce(e.color)??null:null,when:k(e.when)??null,spread:e.spread===!0?!0:null,volume:o(e.volume),overrides:Array.isArray(e.overrides)&&e.overrides.length>0?e.overrides.filter(M).map(r=>(this.fields(r,"flowOverride"),{when:k(r.when)??"",volume:o(r.volume)})):null}}},Fn=/^[A-Za-z0-9+/=\s]*$/;function Lt(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=De&&(t.count===null||t.count>=1&&t.count<=1e4)}function ot(t,e){let n=t.map((o,r)=>[o,r]);n.sort((o,r)=>e(o[0])-e(r[0])||o[1]-r[1]);for(let o=0;o<t.length;o++)t[o]=n[o][0]}function vt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(i){throw new Me(`Not JSON: ${i.message}`)}if(!M(e))throw new Me("Not a Dottie drawing");let n=g(e.version);if(n===void 0)throw new Me("Not a Dottie drawing (no version)");if(!Array.isArray(e.pages)||e.pages.length===0)throw new Me("A drawing needs at least one page");let o=new st;o.fields(e,"file"),n>Ct&&o.warn(`File version ${n} is newer than this player knows (${Ct}); some things may not show`);let r={};if(M(e.images))for(let[i,l]of Object.entries(e.images))M(l)&&typeof l.data=="string"&&(r[i]=o.picture(l.data,k(l.format)));let s=e.pages.map((i,l)=>Ot(o.page(i,r,l+1)));if(new Set(s.map(i=>i.id)).size!==s.length)throw new Me("Two pages share an id");return{version:n,pages:s,warnings:o.warnings}}function Ue(t){return{...t,style:{...t.style,stroke:{...t.style.stroke},fill:{...t.style.fill},textColor:t.style.textColor?{...t.style.textColor}:null,named:t.style.named?{...t.style.named}:t.style.named},connector:t.connector?{...t.connector,start:{...t.connector.start},end:{...t.connector.end},waypoints:t.connector.waypoints?.map(e=>({...e}))??null}:null,gauge:t.gauge?{...t.gauge}:t.gauge}}var Dn=64;function Be(t){return t.length<=Dn&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)}var Bt=["throughput","load","delay","backlog","depth","inFlight","transit","backup"],Gn=[">=","<=","==","!=",">","<"];function _e(t){let e=ye(t);if(!e.includes("(")){let a=e.search(/[>=<!]/);if(a<0)return null;let c=ye(e.slice(0,a));if(!Bt.includes(c))return null;let u=_e(c+"() "+e.slice(a));return u?{...u,target:""}:null}let n=e.indexOf("("),o=e.indexOf(")");if(n<0||o<0||n>=o)return null;let r=ye(e.slice(0,n)),s=ye(e.slice(n+1,o)),i=ye(e.slice(o+1));if(!Bt.includes(r)||s.includes("("))return null;let l=Gn.find(a=>i.startsWith(a));return l===void 0||(i=ye(i.slice(l.length)),!/^-?[0-9]+(\.[0-9]+)?$/.test(i))?null:{metric:r,target:s,op:l,value:Number(i)}}function Nn(t,e){switch(t.op){case">":return e>t.value;case">=":return e>=t.value;case"<":return e<t.value;case"<=":return e<=t.value;case"==":return e===t.value;default:return e!==t.value}}function it(t){return t.split("||").some(e=>e.split("&&").some(n=>_e(n)!==null))}function Ln(t){let e=[];for(let n of t.split("||"))for(let o of n.split("&&")){if(_e(o)!==null)continue;let r=ye(o);if(r.startsWith("!")&&(r=ye(r.slice(1))),!Be(r))return null;e.push(r)}return e}function je(t,e,n=null){return Ln(t)===null?!1:t.split("||").some(o=>o.split("&&").every(r=>{let s=_e(r);if(s!==null){let a=n?n(s):null;return a!==null&&Nn(s,a)}let i=ye(r),l=!1;return i.startsWith("!")&&(l=!0,i=ye(i.slice(1))),(e[i]??!1)!==l}))}function lt(t){return{...t,reroute:null,offline:null,cost:null,capacity:null,delay:null}}function at(t,e){let n=Ue(e);if(t.stroke&&(n.style.stroke={...t.stroke}),t.fill&&(n.style.fill={...t.fill}),t.textColor&&(n.style.textColor={...t.textColor}),t.strokeWidth!==null&&(n.style.strokeWidth=Math.max(0,t.strokeWidth)),t.dash!==null&&(n.style.dash=t.dash),t.text!==null&&(n.text=t.text),t.cost!==null&&n.connector&&(n.connector.cost=Math.min(Math.max(t.cost,0),1e6)),t.capacity!==null&&(n.capacity=Math.max(t.capacity,0)),t.delay!==null&&n.kind!=="connector"&&(n.delay=Math.max(t.delay,0)),t.opacity!==null){let o=Math.min(Math.max(t.opacity,0),1)*(n.style.opacity??1);n.style.opacity=o>=1?null:o}return n}function ye(t){return t.replace(/^[ \t ]+|[ \t ]+$/g,"")}var Pe=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),Te=t=>t.rotation??0,Ge=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Ee=(t,e)=>qe(e,Ge(t),Te(t)),Ut=(t,e)=>qe(e,Ge(t),-Te(t));function _t(t){let e=Pe(t);if(Te(t)===0)return e;let n=[{x:e.x,y:e.y},{x:xe(e),y:e.y},{x:xe(e),y:be(e)},{x:e.x,y:be(e)}].map(l=>Ee(t,l)),o=n.map(l=>l.x),r=n.map(l=>l.y),s=Math.min(...o),i=Math.min(...r);return{x:s,y:i,width:Math.max(...o)-s,height:Math.max(...r)-i}}function Ne(t){if(t.kind!=="path"||!t.subpaths)return[];let e=[];for(let n of t.subpaths){if(n.coords.length<8||(n.coords.length-2)%6!==0)continue;let o=[];for(let r=0;r<n.coords.length;r+=2)o.push({x:t.x+n.coords[r]*t.width,y:t.y+n.coords[r+1]*t.height});e.push({closed:n.closed,points:o})}return e}function jt(t){let e=new se;for(let n of Ne(t)){e.moveTo(n.points[0]);for(let o=0;o<(n.points.length-1)/3;o++)e.curveTo(n.points[3*o+3],n.points[3*o+1],n.points[3*o+2]);n.closed&&e.close()}return e}var He=16,vn=24,Ht=24,Bn=48;function Un(t){if(t.kind==="connector"||t.kind==="text"||t.kind==="freehand"||t.kind==="path"&&!t.extension||t.style.opacity!==null&&t.style.opacity<=0)return null;let e=_t(t);return e.width<Ht||e.height<Ht?null:e}function ut(t,e){let n=e.x+e.width,o=e.y+e.height;for(let r=1;r<t.length;r++){let s=t[r-1],i=t[r];if(s.y===i.y){if(e.y<s.y&&s.y<o&&Math.min(s.x,i.x)<n&&Math.max(s.x,i.x)>e.x)return!0}else if(s.x===i.x&&e.x<s.x&&s.x<n&&Math.min(s.y,i.y)<o&&Math.max(s.y,i.y)>e.y)return!0}return!1}var ct=t=>({x:t.x-He,y:t.y-He,width:t.width+2*He,height:t.height+2*He}),Wt=(t,e)=>e.x<t.x&&t.x<e.x+e.width&&e.y<t.y&&t.y<e.y+e.height,We=new Map;function zt(t,e,n,o,r,s,i){let l=m=>!Wt(e,ct(m))&&!Wt(n,ct(m)),a=[],c=!1;for(let m of s){if(i.has(m.id))continue;let y=Un(m);!y||!l(y)||(a.push(y),!c&&ut(t,y)&&(c=!0))}if(!c)return t;let u=JSON.stringify([e.x,e.y,n.x,n.y,o,r,a.map(m=>[m.x,m.y,m.width,m.height])]),p=We.get(u);if(p)return p;let f=_n(t,e,n,o,r,a);return We.size>=512&&We.clear(),We.set(u,f),f}function _n(t,e,n,o,r,s){let i=s.map((l,a)=>a).filter(l=>ut(t,s[l]));if(i.length===0)return t;for(let l=0;l<4;l++){if(i.length>Bn)return t;let a=jn(e,n,o,r,i.map(u=>ct(s[u])));if(!a)return t;let c=s.map((u,p)=>p).filter(u=>!i.includes(u)&&ut(a,s[u]));if(c.length===0)return a;i=[...i,...c].sort((u,p)=>u-p)}return t}function jn(t,e,n,o,r){let s=[t.x,e.x,(t.x+e.x)/2],i=[t.y,e.y,(t.y+e.y)/2];for(let w of r)s.push(w.x,w.x+w.width),i.push(w.y,w.y+w.height);s=[...new Set(s)].sort((w,L)=>w-L),i=[...new Set(i)].sort((w,L)=>w-L);let l=s.length,a=i.length,c=s.indexOf(t.x),u=i.indexOf(t.y),p=s.indexOf(e.x),f=i.indexOf(e.y);if(c<0||u<0||p<0||f<0)return null;let m=new Map(s.map((w,L)=>[w,L])),y=new Map(i.map((w,L)=>[w,L])),O=new Uint8Array(l*a),N=new Uint8Array(l*a),X=new Uint8Array(l*a);for(let w of r){let L=m.get(w.x),h=m.get(w.x+w.width),d=y.get(w.y),E=y.get(w.y+w.height);if(!(L===void 0||h===void 0||d===void 0||E===void 0))for(let R=L;R<h;R++)for(let b=d;b<E;b++)b>d&&(N[R*a+b]=1),R>L&&(X[R*a+b]=1),R>L&&b>d&&(O[R*a+b]=1)}let q=(w,L)=>O[w*a+L]===1,ie=(w,L,h)=>N[Math.min(w,L)*a+h]===1,ne=(w,L,h)=>X[h*a+Math.min(w,L)]===1,x=l*a*2,P=new Array(x).fill(1/0),_=new Array(x).fill(-1),B=new Array(x).fill(!1),W=new ht,he=(c*a+u)*2+(n?1:0);P[he]=0,W.push(0,he);let Q=(p*a+f)*2+(o?1:0);for(let w=W.pop();w;w=W.pop()){let[L,h]=w;if(B[h])continue;if(B[h]=!0,h===Q)break;let d=Math.floor(h/2),E=h%2,R=Math.floor(d/a),b=d%a;for(let[S,z]of[[1,0],[-1,0],[0,1],[0,-1]]){let ee=R+S,v=b+z;if(ee<0||ee>=l||v<0||v>=a||q(ee,v))continue;let le=S!==0?0:1;if(S!==0?ie(R,ee,b):ne(b,v,R))continue;let C=Math.abs(s[ee]-s[R])+Math.abs(i[v]-i[b]),J=L+C+(le!==E?vn:0),ae=(ee*a+v)*2+le;J<P[ae]&&(P[ae]=J,_[ae]=h,W.push(J,ae))}}if(!B[Q])return null;let we=[];for(let w=Q;w>=0;w=_[w]){let L=Math.floor(w/2);we.push({x:s[Math.floor(L/a)],y:i[L%a]})}return we.reverse()}var ht=class{constructor(){K(this,"heap",[]);K(this,"next",0)}less(e,n){let o=this.heap[e],r=this.heap[n];return o[0]<r[0]||o[0]===r[0]&&o[1]<r[1]}push(e,n){this.heap.push([e,this.next++,n]);for(let o=this.heap.length-1;o>0;){let r=o-1>>1;if(!this.less(o,r))break;[this.heap[o],this.heap[r]]=[this.heap[r],this.heap[o]],o=r}}pop(){if(this.heap.length===0)return null;let e=this.heap[0],n=this.heap.pop();if(this.heap.length>0){this.heap[0]=n;for(let o=0;;){let r=2*o+1,s=r+1,i=o;if(r<this.heap.length&&this.less(r,i)&&(i=r),s<this.heap.length&&this.less(s,i)&&(i=s),i===o)break;[this.heap[o],this.heap[i]]=[this.heap[i],this.heap[o]],o=i}}return[e[0],e[2]]}};function Hn(t,e){let n=Pe(t),o=e==="top"?{x:Ae(n),y:n.y}:e==="right"?{x:xe(n),y:Se(n)}:e==="bottom"?{x:Ae(n),y:be(n)}:{x:n.x,y:Se(n)};return Ee(t,o)}function Wn(t){let e=[];for(let n=0;n+3<t.length;n+=3){let o=t.slice(n,n+4);for(let r=0;r<16;r++)e.push(Tt(o,r/16))}return e.push(t[t.length-1]),e}function zn(t,e,n){let o=null,r=null;for(let i of Ne(t)){let l=Wn(i.points),a=l.length,c=i.closed?a:a-1;for(let u=0;u<c;u++){let p=l[u],f=l[(u+1)%a],m={x:f.x-p.x,y:f.y-p.y},y={x:p.x-e.x,y:p.y-e.y},O=m.x*n.y-n.x*m.y;if(O===0)continue;let N=(m.x*y.y-m.y*y.x)/O,X=(n.x*y.y-n.y*y.x)/O;N>0&&X>=0&&X<=1&&((o===null||N<o)&&(o=N),N<=1&&(r===null||N>r)&&(r=N))}}let s=r??o;return s===null?null:{x:e.x+n.x*s,y:e.y+n.y*s}}function $n(t,e){let n=Pe(t),o=Ge(t),r=Ut(t,e),s=r.x-o.x,i=r.y-o.y;if(!((s!==0||i!==0)&&n.width>0&&n.height>0))return o;if(t.kind==="path"){let u=zn(t,o,{x:s,y:i});if(u)return Ee(t,u)}let l=n.width/2,a=n.height/2,c;return t.kind==="ellipse"?c=1/Math.sqrt(s*s/(l*l)+i*i/(a*a)):t.kind==="diamond"?c=1/(Math.abs(s)/l+Math.abs(i)/a):c=Math.min(s!==0?l/Math.abs(s):1/0,i!==0?a/Math.abs(i):1/0),Ee(t,{x:o.x+s*c,y:o.y+i*c})}function $t(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?Ge(n):{x:t.x,y:t.y}}function Kn(t,e){let n=Pe(t);return Ee(t,{x:n.x+e.x*n.width,y:n.y+e.y*n.height})}function Kt(t,e,n){let o=t.elementID?n.get(t.elementID):void 0;if(!o)return{x:t.x,y:t.y};let r=t.portIndex,s=o.ports??[];return typeof r=="number"&&Number.isInteger(r)&&r>=0&&r<s.length?Kn(o,s[r]):t.port?Hn(o,t.port):$n(o,e)}function Yt(t,e){let n=t.connector;if(!n)return[{x:0,y:0},{x:0,y:0}];let o=n.waypoints??[];return[Kt(n.start,o.length>0?o[0]:$t(n.end,e),e),Kt(n.end,o.length>0?o[o.length-1]:$t(n.start,e),e)]}function Xt(t){if(t.kind==="polyline")return t.points;let e=[],n=t.points;for(let o=0;o<Math.floor((n.length-1)/3);o++){let r=n[3*o],s=n[3*o+1],i=n[3*o+2],l=n[3*o+3];for(let a=o===0?0:1;a<=24;a++){let c=a/24,u=1-c;e.push({x:u*u*u*r.x+3*u*u*c*s.x+3*u*c*c*i.x+c*c*c*l.x,y:u*u*u*r.y+3*u*u*c*s.y+3*u*c*c*i.y+c*c*c*l.y})}}return e}var ze=t=>t===null?null:t==="top"||t==="bottom";function Jt(t){let e=[];for(let n of t){let o=e[e.length-1];if(!(o&&Math.abs(o.x-n.x)<.5&&Math.abs(o.y-n.y)<.5)){if(e.length>=2){let r=e[e.length-2],s=e[e.length-1];if(Math.abs(r.x-s.x)<.5&&Math.abs(s.x-n.x)<.5||Math.abs(r.y-s.y)<.5&&Math.abs(s.y-n.y)<.5){e[e.length-1]=n;continue}}e.push(n)}}return e.length>=2?e:t}function Vn(t,e){switch(e.routing){case"straight":return{kind:"polyline",points:t};case"curved":{let n=[t[0]];for(let o=0;o<t.length-1;o++){let r=t[Math.max(o-1,0)],s=t[o],i=t[o+1],l=t[Math.min(o+2,t.length-1)];n.push({x:s.x+(i.x-r.x)/6,y:s.y+(i.y-r.y)/6}),n.push({x:i.x-(l.x-s.x)/6,y:i.y-(l.y-s.y)/6}),n.push(i)}return{kind:"curve",points:n}}case"elbow":{let n=t[0],o=t[1],r=ze(e.start.port)??Math.abs(o.y-n.y)>Math.abs(o.x-n.x),s=ze(e.end.port),i=[n];for(let l=1;l<t.length;l++){let a=t[l],c=i[i.length-1],u=Math.abs(c.x-a.x)<.5,p=Math.abs(c.y-a.y)<.5;if(u||p){i.push(a),u!==p&&(r=!u);continue}let f=l===t.length-1&&s!==null?!s:r;i.push(f?{x:c.x,y:a.y}:{x:a.x,y:c.y},a),r=f}return{kind:"polyline",points:Jt(i)}}}}function Zt(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[o,r]=Yt(t,e);if(n.waypoints&&n.waypoints.length>0)return Vn([o,...n.waypoints.map(a=>({x:a.x,y:a.y})),r],n);let s=r.x-o.x,i=r.y-o.y,l=Math.abs(s)>=Math.abs(i);switch(n.routing){case"straight":return{kind:"polyline",points:[o,r]};case"curved":return l?{kind:"curve",points:[o,{x:o.x+s/2,y:o.y},{x:r.x-s/2,y:r.y},r]}:{kind:"curve",points:[o,{x:o.x,y:o.y+i/2},{x:r.x,y:r.y-i/2},r]};case"elbow":{let a=ze(n.start.port)??!l,c=ze(n.end.port)??!l,u;if(a&&c){let m=o.y+i/2;u=[o,{x:o.x,y:m},{x:r.x,y:m},r]}else if(!a&&!c){let m=o.x+s/2;u=[o,{x:m,y:o.y},{x:m,y:r.y},r]}else a?u=[o,{x:o.x,y:r.y},r]:u=[o,{x:r.x,y:o.y},r];if(n.avoid!==!0)return{kind:"polyline",points:u};let p=new Set([n.start.elementID,n.end.elementID].filter(m=>m!==null)),f=zt(u,o,r,a,c,e.values(),p);return{kind:"polyline",points:f===u?u:Jt(f)}}}}var Vt=new WeakMap;function $e(t){let e=t.elements,n=Vt.get(e);if(n&&n.members.length===e.length&&n.members.every((r,s)=>r===e[s]))return n.index;let o=new Map;for(let r of e)o.has(r.id)||o.set(r.id,r);return Vt.set(e,{members:[...e],index:o}),o}function qt(t,e,n){let o=t[1]+n>>>0,r=o<t[1]?1:0;return[t[0]+e+r>>>0,o]}function Yn(t,e){let n=t&65535,o=t>>>16,r=e&65535,s=e>>>16,i=n*r,l=n*s,a=o*r,c=o*s,u=l+a,p=i+u%65536*65536;return[c+Math.floor(u/65536)+Math.floor(p/4294967296)>>>0,p>>>0]}function Qt(t,e,n){let o=Yn(t[1],n);return[o[0]+Math.imul(t[0],n)+Math.imul(t[1],e)>>>0,o[1]]}function mt(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function Xn(t){return t=Qt(mt(t,30),3210233709,484763065),t=Qt(mt(t,27),2496678331,321982955),mt(t,31)}var Ke=class{constructor(e){K(this,"state");this.state=qt([0,e>>>0],2654435769,2135587861)}next(){return this.state=qt(this.state,2654435769,2135587861),Xn(this.state)}top53(){let[e,n]=this.next();return e*2097152+(n>>>11)}signed(){return Math.floor(this.top53())/2**52-1}unit(){return this.top53()/2**53}};var en=(t,e,n)=>t.signed()*e*n;function ft(t,e,n,o,r,s,i){let l=Math.hypot(e.x-t.x,e.y-t.y);if(!(l>.5))return;let a=l<200?1:l>500?.4:-.0016668*l+1.233334,c=l<20?l/10:2;for(let u=0;u<2;u++){let p=(u===0?1:.5)*a,f=()=>en(n,c,o)*p,m=n.unit()*.4+.3,y=en(n,l/60,o)*r*a,O=e.x-t.x,N=e.y-t.y,X=-N/l,q=O/l,ie=s?t:{x:t.x+f(),y:t.y+f()},ne=s?e:{x:e.x+f(),y:e.y+f()},x=t.x+O*m*.66+X*y+f()*.5,P=t.y+N*m*.66+q*y+f()*.5,_=t.x+O*(.5+m*.5)+X*y+f()*.5,B=t.y+N*(.5+m*.5)+q*y+f()*.5;i.moveTo(ie),i.curveTo(ne,{x,y:P},{x:_,y:B})}}function dt(t,e,n,o){let r=new se;for(let s=0;s<t.length;s++)ft(t[s],t[(s+1)%t.length],e,n,o,!1,r);return r}function tn(t,e,n){let o=new se,r=t.x+t.width/2,s=t.y+t.height/2,i=t.width/2,l=t.height/2;if(!(i>.5&&l>.5))return o;let a=Math.max(8,Math.min(24,Math.trunc((i+l)/6))),c=Math.min(2.5,(i+l)/25)*n;for(let u=0;u<2;u++){let p=e.unit()*2*Math.PI,f=2*Math.PI*(u===0?1:1.04),m=Math.trunc(a*f/(2*Math.PI))+1,y=[];for(let O=0;O<m;O++){let N=p+f*O/a,X=e.signed()*c,q=e.signed()*c;y.push({x:r+i*Math.cos(N)+X,y:s+l*Math.sin(N)+q})}Jn(y,o)}return o}function Jn(t,e){if(!(t.length<=2)){e.moveTo(t[0]);for(let n=0;n<t.length-1;n++){let o=t[Math.max(n-1,0)],r=t[n],s=t[n+1],i=t[Math.min(n+2,t.length-1)];e.curveTo(s,{x:r.x+(s.x-o.x)/6,y:r.y+(s.y-o.y)/6},{x:s.x-(i.x-r.x)/6,y:s.y-(i.y-r.y)/6})}}}var Zn=-41*Math.PI/180;var Ve=class{constructor(e=6e3){K(this,"map",new Map);K(this,"limit");this.limit=e}get(e,n){let o=this.map.get(e);if(o!==void 0)return o;let r=n();return this.map.size>=this.limit&&this.map.clear(),this.map.set(e,r),r}},Qn=new Ve,Ko=new Ve;function eo(t,e){let n=t.style;return[e,t.kind,t.x,t.y,t.width,t.height,t.seed,n.roughness,n.bowing,n.strokeWidth,n.fillStyle,n.fillStyle==="grid"?to(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var to=t=>Math.max(8,t.style.gridSize??50);function rn(t){return t.kind==="freehand"&&t.path===null?on(t):Qn.get(eo(t,0),()=>on(t))}function no(t){return[{x:t.x,y:t.y},{x:xe(t),y:t.y},{x:xe(t),y:be(t)},{x:t.x,y:be(t)}]}function nn(t){return[{x:Ae(t),y:t.y},{x:xe(t),y:Se(t)},{x:Ae(t),y:be(t)},{x:t.x,y:Se(t)}]}function on(t){let e=Pe(t),n=new Ke(t.seed),o=t.style.roughness;switch(t.kind){case"ellipse":return o<=0?se.ellipse(e):tn(e,n,o);case"diamond":return o<=0?new se().addLines(nn(e)).close():dt(nn(e),n,o,t.style.bowing);case"text":case"connector":return se.rect(e);case"freehand":return ro(t);case"path":return o<=0?jt(t):oo(t,n);default:return o<=0?se.rect(e):dt(no(e),n,o,t.style.bowing)}}function oo(t,e){let n=t.style.roughness,o=new se;for(let r of Ne(t)){let s=r.points;for(let i=0;i<(s.length-1)/3;i++){let l=s[3*i],a=s[3*i+1],c=s[3*i+2],u=s[3*i+3];if(a.x===l.x&&a.y===l.y&&c.x===u.x&&c.y===u.y){ft(l,u,e,n,t.style.bowing,!0,o);continue}let p=Math.hypot(a.x-l.x,a.y-l.y)+Math.hypot(c.x-a.x,c.y-a.y)+Math.hypot(u.x-c.x,u.y-c.y),f=Math.min(2.5,p/30)*n;for(let m=0;m<2;m++){let y=m===0?1:.5,O=()=>e.signed()*f*y;o.moveTo(l);let N=a.x+O(),X=a.y+O(),q=c.x+O(),ie=c.y+O();o.curveTo(u,{x:N,y:X},{x:q,y:ie})}}}return o}function ro(t){let e=Pe(t),n=t.path;if(n&&n.length>=8&&(n.length-2)%6===0){let s=l=>({x:e.x+n[2*l]*e.width,y:e.y+n[2*l+1]*e.height}),i=new se().moveTo(s(0));for(let l=0;l<Math.floor((n.length/2-1)/3);l++)i.curveTo(s(3*l+3),s(3*l+1),s(3*l+2));return i}let o=(t.points??[]).map(s=>({x:e.x+s.x*e.width,y:e.y+s.y*e.height})),r=new se;if(o.length===0)return r;if(r.moveTo(o[0]),o.length===1)return r.lineTo(o[0]);if(o.length===2)return r.lineTo(o[1]);for(let s=1;s<o.length-1;s++)r.quadTo({x:(o[s].x+o[s+1].x)/2,y:(o[s].y+o[s+1].y)/2},o[s]);return r.lineTo(o[o.length-1])}function sn(t,e,n=$e(e)){if(t.kind==="connector")return new ke(Xt(Zt(t,n)));let o=Ue(t);o.style.roughness=0;let r=rn(o).contours()[0]??[];return new ke(Te(t)===0?r:r.map(s=>Ee(t,s)))}var an=.5,gt=160,xt=12,bt={r:.95,g:.36,b:.33,a:1},Ie=(t,e,n,o)=>t===null||!Number.isFinite(t)?e:Math.min(Math.max(t,n),o);function Le(t,e){let n=(e+1099511627776)%281474976710656;return t.slice(0,24)+(n<0?n+2**48:n).toString(16).toUpperCase().padStart(12,"0")}var Xe=t=>t===null||!Number.isFinite(t)?1:Math.min(Math.max(t,0),1e6),ln=new WeakMap,Ye=new Map;function so(t){let e=t.elements,n=ln.get(e);if(n&&n.members.length===e.length&&n.members.every((l,a)=>l===e[a]))return n.graph;let o=new Set(e.filter(l=>l.kind!=="connector").map(l=>l.id)),r=[];for(let l of e){let a=l.connector;a&&r.push([l.id,a.start.elementID,a.end.elementID,String(Xe(a.cost)),a.startHead!=="none"?"both":"one"])}let s=JSON.stringify([[...o],r]),i=Ye.get(s);if(!i){let l=new Map,a=(c,u)=>{let p=l.get(c);p?p.push(u):l.set(c,[u])};for(let c of e){let u=c.connector,p=u?.start.elementID??null,f=u?.end.elementID??null;if(!u||p===null||f===null||p===f||!o.has(p)||!o.has(f))continue;let m=Xe(u.cost);a(p,{to:f,via:c.id,back:!1,cost:m}),u.startHead!=="none"&&a(f,{to:p,via:c.id,back:!0,cost:m})}i={shapes:o,next:l,trees:new Map},Ye.size>=16&&Ye.clear(),Ye.set(s,i)}return ln.set(e,{members:[...e],graph:i}),i}var pt=class{constructor(){K(this,"heap",[])}get size(){return this.heap.length}less(e,n){let o=this.heap[e],r=this.heap[n];return o.dist<r.dist||o.dist===r.dist&&o.order<r.order}swap(e,n){[this.heap[e],this.heap[n]]=[this.heap[n],this.heap[e]]}push(e,n,o){this.heap.push({id:e,dist:n,order:o});for(let r=this.heap.length-1;r>0;){let s=r-1>>1;if(!this.less(r,s))break;this.swap(r,s),r=s}}pop(){let e=this.heap[0],n=this.heap.pop();if(this.heap.length>0){this.heap[0]=n;for(let o=0;;){let r=2*o+1,s=r+1,i=o;if(r<this.heap.length&&this.less(r,i)&&(i=r),s<this.heap.length&&this.less(s,i)&&(i=s),i===o)break;this.swap(o,i),o=i}}return e}};function Je(t,e,n=new Set,o){let r=so(e),s=JSON.stringify([t,o??null,[...n].sort()]);if(r.trees.has(s))return r.trees.get(s);let i=io(r,t,n,o);return r.trees.size>=4096&&r.trees.clear(),r.trees.set(s,i),i}function io({shapes:t,next:e},n,o,r){if(!t.has(n)||o.has(n))return null;let s=new Map([[n,0]]),i=new Map([[n,0]]),l=1,a=new yt(n),c=new pt;for(c.push(n,0,0);c.size>0;){let{id:u,order:p}=c.pop();if(!(a.settled.has(u)||i.get(u)!==p)){if(a.settled.add(u),u===r&&u!==n)break;for(let f of e.get(u)??[]){if(o.has(f.via)||o.has(f.to)||a.settled.has(f.to))continue;let m=s.get(u)+f.cost,y=s.get(f.to);y!==void 0&&y<=m||(s.set(f.to,m),i.set(f.to,l),c.push(f.to,m,l++),a.came.set(f.to,{from:u,via:f.via,back:f.back}))}}}return a}var yt=class{constructor(e){K(this,"settled",new Set);K(this,"came",new Map);K(this,"from");this.from=e}goals(e,n){let o=e.filter(r=>r!==this.from&&this.settled.has(r));return o.length===0?[]:n&&o[0]!==e[0]?o:[o[0]]}hops(e){let n=[];for(let o=e,r=this.came.get(o);r;o=r.from,r=this.came.get(o))n.push([r.via,r.back]);return n.reverse()}};var lo=()=>({elements:new Map,flows:new Map,carry:{}});function mn(t,e,n){let o=t.flows.get(n);if(o)switch(e){case"throughput":return o.placed;case"backlog":return o.backlog;case"backup":return o.backup;case"transit":return o.transit;default:return null}let r=t.elements.get(n);if(!r)return null;switch(e){case"throughput":return r.throughput;case"load":return r.load;case"delay":return r.delay;case"backlog":return r.backlog;case"inFlight":return r.inFlight;case"depth":return r.depth;default:return null}}var H=1e-9,Rt=t=>Ie(t.volume,1,0,1e12);function wt(t,e){if(e===null||!t.overrides)return Rt(t);let n=null;for(let o of t.overrides)o.volume!==null&&!it(o.when)&&je(o.when,e)&&(n=o.volume);return n===null?Rt(t):Math.min(Math.max(Number.isFinite(n)?n:1,0),1e12)}function un(t){let e=t.delay??null;return t.kind==="connector"||e===null||!Number.isFinite(e)?0:Math.min(Math.max(e,0),3600)}var kt=(t,e)=>t+"|"+e;function fn(t,e,n,o,r=new Set,s=null,i={}){let l=Math.max(0,Math.min(s??n,1e6)),a=$e(e),c=new Map,u=h=>{let d=c.get(h.id);return d||(d=sn(h,e,a).points,c.set(h.id,d)),d},p=lo(),f=new Map;for(let h of e.elements)h.kind==="connector"&&!h.connector||p.elements.set(h.id,{throughput:0,load:null,delay:h.kind!=="connector"?un(h):0,backlog:0,inFlight:0,depth:0});let m=t??[],y=new Map;for(let h of e.elements){let d=h.capacity??null;d!==null&&Number.isFinite(d)&&y.set(h.id,Math.max(d,0))}let O=()=>new Set([...y].filter(([,h])=>h<=H).map(([h])=>h)),N=(h,d)=>{let E=[],R=[],b=d;for(let S=h.came.get(b);S;S=h.came.get(b))E.push([S.via,S.back]),R.push(b),b=S.from;return R.push(b),{hops:E.reverse(),shapes:R.reverse()}},X=(h,d)=>{let E=[],R=[],b=[],S=0;return h.forEach(([z,ee],v)=>{let le=a.get(z);if(!le)return;let C=ee?[...u(le)].reverse():u(le);if(C.length===0)return;let J=E[E.length-1];if(J){let oe=Math.hypot(C[0].x-J.x,C[0].y-J.y),pe=a.get(d[v]);R.push([S,S+oe,pe?un(pe):0]),S+=oe}let ae=S;for(let oe=1;oe<C.length;oe++)S+=Math.hypot(C[oe].x-C[oe-1].x,C[oe].y-C[oe-1].y);b.push([z,ae,S]),E.push(...C)}),S>0?{line:new ke(E),length:S,inside:R,stretches:b}:null},q=(h,d,E)=>{let R=d,b=0;for(let[S,z,ee]of h.inside){let v=(S-b)/E;if(R<=v)break;R-=v,b=S;let le=(z-S)/E+ee;if(R<le)return null;R-=le,b=z}return b+=R*E,b>=0&&b<=h.length?b:null},ie=(h,d)=>new Set([...h,...d]),ne=(h,d)=>{let E=p.elements.get(h);E&&d(E)},x=new Map,P=[];for(let h of m){let d=x.get(h.from)??0;P.push(d),x.set(h.from,d+1)}let _=m.length>0?Math.max(...m.map(Rt)):1,B=[],W=new Map,he=h=>Math.min(Math.max(Ie(h.every,an,.05,60)*_/Math.max(wt(h,o),H),.05),60),Q=new Map,we=h=>(Q.has(h)||Q.set(h,Je(h,e,r)),Q.get(h));for(let[h,d]of m.entries()){if(d.when!==null&&o!==null&&!je(d.when,o))continue;let E=a.get(d.from),R=E?we(d.from):null;if(f.set(d.id,[]),!E||!R)continue;let b=wt(d,o),S={volume:b,placed:0,backlog:0,backup:0,transit:null},z=[],ee=[],v=R.goals(d.to,d.spread===!0),le=v.length>1?v.map(I=>[[I],b/v.length]):[[d.to,b]];for(let[I,T]of le){if(!(T>H))continue;let F=T;for(let D=0;D<32&&F>H;D++){let Y=Je(d.from,e,ie(r,O()),I[0]),Z=Y?.goals(I,!1)[0];if(!Y||Z===void 0)break;let G=N(Y,Z),j=[...G.shapes,...G.hops.map(([A])=>A)],$=j.filter(A=>y.has(A)).map(A=>y.get(A)),U=Math.min(F,$.length>0?Math.min(...$):1/0);if(!(U>H))break;for(let A of j)y.has(A)&&y.set(A,y.get(A)-U);z.push({hops:G.hops,shapes:G.shapes,goal:Z,amount:U}),F-=U}if(!(F>H))continue;let V=d.from,ge=R.goals(I,!1)[0];if(ge!==void 0){let D=N(R,ge),Y=O(),Z=[[D.shapes[0],D.shapes[0]]];D.hops.forEach(([$],U)=>{Z.push([$,D.shapes[U]],[D.shapes[U+1],D.shapes[U]])});let G=Z.find(([$])=>Y.has($));if(G){V=G[1];let $=D.shapes.indexOf(V);for(let U=$;U>=0;U--){let A=a.get(D.shapes[U]);if(A&&A.queue===!0&&A.kind!=="connector"){V=D.shapes[U];break}}}let j=D.shapes.indexOf(V);if(V!==d.from&&j>=0){let $=D.shapes.slice(0,j+1),U=D.hops.slice(0,j);for(let A of[...$,...U.map(([Ze])=>Ze)])y.has(A)&&y.set(A,Math.max(0,y.get(A)-F));z.push({hops:U,shapes:$,goal:V,amount:F,waits:!0})}}let te=ee.find(([D])=>D===V);te?te[1]+=F:ee.push([V,F])}W.set(d.id,ee),f.set(d.id,z.map(I=>({goal:I.goal,hops:I.hops,amount:I.amount,waits:I.waits===!0,cost:I.hops.reduce((T,[F])=>T+Xe(a.get(F)?.connector?.cost??null),0)})));for(let I of z){for(let T of[...I.shapes,...I.hops.map(([F])=>F)])ne(T,F=>{F.throughput+=I.amount});I.waits||(S.placed+=I.amount)}for(let[I,T]of ee)ne(I,F=>{F.backlog+=T}),S.backlog+=T;let C=z.filter(I=>!I.waits&&I.goal===d.to[0]).reduce((I,T)=>I+T.amount,0);S.backup=b>H?Math.max(0,(b-C)/b):0;let J=he(d),ae=Ie(d.speed,gt,1,1e4),oe=Ie(d.size,xt,2,200),pe=P[h]/x.get(d.from)*J,Re=d.color??bt,re=[],Ce=0;for(let I of z)Ce+=I.amount/Math.max(b,H),re.push(Ce);re.length>0&&Math.abs(re[re.length-1]-1)<1e-9&&(re[re.length-1]=1);let ve=0;z.forEach((I,T)=>{let F=X(I.hops,I.shapes);if(!F)return;let V=F.length/ae+F.inside.reduce((G,j)=>G+j[2],0);I.waits||(ve+=V*I.amount);let ge=Math.ceil((n-pe-V)/J),te=Math.floor((n-pe)/J),D=T===0?0:re[T-1],Y=re[T],Z=(G,j)=>Math.floor((j+1)*G)-Math.floor(j*G);for(let G=Math.max(ge,te-3999);G<=te;G++){if(Z(Y,G)-Z(D,G)!==1)continue;let j=q(F,n-G*J-pe,ae);if(j===null)continue;let $=F.stretches.find(([,A,Ze])=>j>=A&&j<=Ze);$&&ne($[0],A=>{A.inFlight+=1});let U=F.line.point(j/F.length);B.push(Mt(Le(d.id,G),U.x-oe/2,U.y-oe/2,oe,Re,E.layerID))}}),S.transit=S.placed>H?ve/S.placed:null,p.flows.set(d.id,S)}let w=new Map,L=Object.keys(i).filter(h=>i[h]>H);for(let h of m){let d=W.get(h.id)??[],E=d.map(([C])=>C),R="|"+h.id;if(L.some(C=>C.endsWith(R)))for(let C of e.elements){let J=i[kt(C.id,h.id)];J!==void 0&&J>H&&!E.includes(C.id)&&E.push(C.id)}if(E.length===0)continue;let b=wt(h,o),z=he(h)*Math.max(b,H),ee=Ie(h.speed,gt,1,1e4),v=Ie(h.size,xt,2,200),le=h.color??bt;E.forEach((C,J)=>{let ae=a.get(C);if(!ae)return;let oe=a.get(h.from)?.layerID??ae.layerID,pe=d.find(([T])=>T===C)?.[1]??0,Re=Math.max(0,i[kt(C,h.id)]??0),re=Re+pe*l;if(pe<=H&&Re>H){let T=new Map(y),F=[],V=0;for(let ge=0;ge<32;ge++){let te=new Set([...T].filter(([,A])=>A<=H).map(([A])=>A)),D=Je(C,e,ie(r,te),h.to[0]),Y=D?.goals(h.to,!1)[0];if(!D||Y===void 0)break;let Z=N(D,Y),G=[...Z.shapes.slice(1),...Z.hops.map(([A])=>A)],j=G.filter(A=>T.has(A)).map(A=>T.get(A)),$=j.length>0?Math.min(...j):1/0,U=Number.isFinite($)?$:Math.max(Re/.5-V,H*2);if(!(U>H))break;for(let A of G)T.has(A)&&T.set(A,T.get(A)-U);if(F.push({hops:Z.hops,shapes:Z.shapes,rate:U}),V+=U,!Number.isFinite($))break}if(V>H){if(re=Math.max(0,Re-V*l),re>H){for(let[te,D]of T)y.set(te,D);for(let te of F)for(let D of[...te.shapes,...te.hops.map(([Y])=>Y)])ne(D,Y=>{Y.throughput+=te.rate})}let ge=Re/V;F.forEach((te,D)=>{let Y=X(te.hops,te.shapes);if(!Y)return;let Z=Math.max(z/te.rate,.05);for(let G=0;G*Z<ge&&G*Z<=l&&G<2048;G++){let j=q(Y,l-G*Z,ee);if(j===null)continue;let $=Y.line.point(j/Y.length);B.push(Mt(Le(h.id,2**39+2**20+J*2**14+D*2**11+G),$.x-v/2,$.y-v/2,v,le,oe))}})}}if(!(re>H||pe>H))return;ne(C,T=>{T.depth+=re}),re>H&&(p.carry[kt(C,h.id)]=re);let Ce=Math.min(Math.max(Math.ceil(re/z-1e-9),1),30),ve=Math.trunc((Ce+9)/10),I=w.get(C)??0;w.set(C,I+ve);for(let T=0;T<Ce;T++){let F=ae.x+2+v/2+T%10*(v+3),V=ae.y-4-v/2-(I+Math.trunc(T/10))*(v+3);B.push(Mt(Le(h.id,2**39+J*64+T),F-v/2,V-v/2,v,le,oe))}})}for(let h of e.elements){let d=h.capacity??null,E=p.elements.get(h.id);d===null||!Number.isFinite(d)||!E||(E.load=d>0?E.throughput/d:1)}return{packets:B,metrics:p,routes:f}}var dn={seed:1,text:null,connector:null,groupID:null,points:null,path:null,subpaths:null,evenOdd:null,rotation:null,link:null,url:null,anchor:null,click:null,hover:null,when:null,overrides:null,symbol:null,playback:null,offset:null,args:null,image:null,reveal:null};function pn(t,e,n,o="solid",r=null){return{stroke:{...t},fill:{...e},fillStyle:o,strokeWidth:n,dash:"solid",roughness:0,bowing:1,fontSize:18,font:null,gridSize:null,opacity:r,dashOffset:null,textColor:null}}function Mt(t,e,n,o,r,s){return{...dn,id:t,kind:"ellipse",layerID:s,x:e,y:n,width:o,height:o,style:pn(r,r,1.5)}}function ao(t,e){let n=new Map;for(let r of e.elements)r.anchor!==null&&!n.has(r.anchor)&&n.set(r.anchor,r.id);let o=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;return(r,s)=>{let i=r.target===""?s:n.get(r.target)??(o.test(r.target)?r.target.toUpperCase():null);return i===null?null:mn(t,r.metric,i)}}function yn(t,e,n,o,r=1/0,s={}){let i=ao(e,o),l=[],a={};for(let c of t){let u=[];n!==null&&c.overrides&&c.overrides.forEach((y,O)=>{it(y.when)&&je(y.when,n,N=>i(N,c.id))&&u.push(O)});let p=n===null?null:c.gauge;if(!p){l.push({applied:u,gauge:null});continue}let f=mn(e,p.metric,p.of),m=s[cn(c.id)];if(f!==null&&m!==void 0&&p.metric!=="depth"&&p.metric!=="inFlight"&&r<hn){let y=Math.max(0,r/hn),O=y*y*(3-2*y);f=m+(f-m)*O}f!==null&&(a[cn(c.id)]=f),l.push({applied:u,gauge:{value:f}})}return{plan:l,readings:a}}var cn=t=>"gauge|"+t,hn=1,Oe=t=>{let e=parseInt(t.slice(1),16);return{r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255,a:1}},uo=Oe("#16a34a"),co=Oe("#d97706"),ho=Oe("#dc2626"),mo=Oe("#2f6fdf"),Pt=Oe("#e5e7eb"),fo=Oe("#9ca3af");function po(t,e){if(e===null||!Number.isFinite(e))return"\u2013";switch(t){case"load":case"backup":return Et(e*100,0)+"%";case"transit":case"delay":return Et(e,Math.abs(e)>=10?1:2)+"s";default:return Et(e,Math.abs(e)>=100?0:Math.abs(e)>=10?1:2)}}function Et(t,e){let n=e===0?1:e===1?10:100,o=Math.floor(Math.abs(t)*n+.5);if(!(o<1e15))return t<0?"-\u221E":"\u221E";let r=Math.trunc(o/n),s=o-r*n,i=String(r);if(e>0&&s>0){let l=String(s);for(;l.length<e;)l="0"+l;for(;l.endsWith("0");)l=l.slice(0,-1);i+="."+l}return(t<0&&o>0?"-":"")+i}function gn(t,e,n,o,r){let s=o.elements.find(x=>x.id===e.of),i=e.max??(e.metric==="load"?1:s?.capacity??n??1),l=n===null?0:i>0?Math.min(Math.max(n/i,0),1):0,a=e.warn??(e.metric==="load"?.7:null),c=e.alarm??(e.metric==="load"?.9:null),u=a===null&&c===null?mo:uo;n!==null&&a!==null&&n>=a&&(u=co),n!==null&&c!==null&&n>=c&&(u=ho),n===null&&(u=fo);let p=e.label;if(p===null){let x=s?s.text!==null?s.text.split(`
|
|
3
|
+
`)[0]:s.anchor:null;p=`${e.metric} ${x??(r.some(P=>P.id===e.of)?"flow":"?")}`}let f=e.style??"number",m=Math.max(t.width,1),y=Math.max(t.height,1),O=(x,P)=>[x.x/m,x.y/y,(x.x+(P.x-x.x)/3)/m,(x.y+(P.y-x.y)/3)/y,(x.x+2*(P.x-x.x)/3)/m,(x.y+2*(P.y-x.y)/3)/y,P.x/m,P.y/y],N=(x,P,_,B)=>{let W=[{x,y:P},{x:x+_,y:P},{x:x+_,y:P+B},{x,y:P+B}],he=O(W[0],W[1]);for(let Q=1;Q<4;Q++)he=he.concat(O(W[Q],W[(Q+1)%4]).slice(2));return{closed:!0,coords:he}},X=(x,P,_,B)=>{let W=Math.max(1,Math.ceil(Math.abs(B-_)/(Math.PI/2)-1e-9)),he=(B-_)/W,Q=4/3*Math.tan(he/4),we=h=>({x:x.x+P*Math.cos(h),y:x.y+P*Math.sin(h)}),w=we(_),L=[w.x/m,w.y/y];for(let h=0;h<W;h++){let d=_+h*he,E=d+he,R=we(d),b=we(E),S={x:R.x-Q*P*Math.sin(d),y:R.y+Q*P*Math.cos(d)},z={x:b.x+Q*P*Math.sin(E),y:b.y-Q*P*Math.cos(E)};L.push(S.x/m,S.y/y,z.x/m,z.y/y,b.x/m,b.y/y)}return{closed:!1,coords:L}},q=(x,P,_,B,W)=>({...dn,id:Le(t.id,-(2**38)-x),kind:"path",layerID:t.layerID,x:t.x,y:t.y,width:t.width,height:t.height,style:pn(_,B??{r:0,g:0,b:0,a:0},W,"solid",t.style.opacity),subpaths:P}),ie={...t,gauge:null,kind:"path",subpaths:[N(0,0,m,y)],text:p+`
|
|
4
|
+
`+po(e.metric,n),style:{...t.style}},ne=[];if(f==="number")ie.labelRect={x:0,y:0,width:1,height:1},ie.style.textColor={...u};else if(f==="bar"){ie.labelRect={x:0,y:0,width:1,height:.66};let x=Math.min(10,m*.08),P=Math.min(12,y*.18),_=y*.72,B=m-2*x;ne.push(q(1,[N(x,_,B,P)],Pt,Pt,.5)),l>0&&ne.push(q(2,[N(x,_,B*l,P)],u,u,.5))}else{ie.labelRect={x:0,y:.54,width:1,height:.46};let x=Math.min(m*.38,y*.4),P={x:m/2,y:y*.5},_=Math.max(2,x*.16);ne.push(q(1,[X(P,x,Math.PI,2*Math.PI)],Pt,null,_)),l>0&&ne.push(q(2,[X(P,x,Math.PI,Math.PI+Math.PI*l)],u,null,_));let B=Math.PI+Math.PI*l,W={x:P.x+x*.85*Math.cos(B),y:P.y+x*.85*Math.sin(B)};ne.push(q(3,[{closed:!1,coords:O(P,W)}],{r:.2,g:.2,b:.2,a:1},null,2))}return[ie,...ne]}var At=null;function yo(t){At=vt({version:2,pages:[JSON.parse(t)]}).pages[0]}function go(t){if(!At)throw new Error("no page");let e=JSON.parse(t);e.values??(e.values=null),e.since??(e.since=null),e.offline??(e.offline=[]),e.carried??(e.carried={});let n=At,o=fn(n.flows,n,e.t,e.values,new Set(e.offline),e.since,e.carried),r=Math.max(0,Math.min(e.since??e.t,1e6)),{plan:s,readings:i}=yn(n.elements,o.metrics,e.values,n,r,e.carried),l=[];return n.elements.forEach((a,c)=>{let{applied:u,gauge:p}=s[c];if(u.length===0&&!p)return;let f=a;for(let m of u)f=at(lt(a.overrides[m]),f);l.push([a.id,u,p&&f.gauge?xo(gn(f,f.gauge,p.value,n,n.flows??[])):null])}),JSON.stringify({packets:o.packets.map(a=>[a.id,a.x,a.y,a.width,a.layerID]),elements:Object.fromEntries(o.metrics.elements),flows:Object.fromEntries(o.metrics.flows),carry:{...o.metrics.carry,...i},finish:l,routes:e.routes?Object.fromEntries([...o.routes].map(([a,c])=>[a,c.map(u=>[u.goal,u.hops,u.amount,u.waits,u.cost])])):void 0})}function xo([t,...e]){let n=t.labelRect;return{text:t.text??"",label:[n.x,n.y,n.width,n.height],textColor:t.style.textColor,subpaths:t.subpaths??[],parts:e.map(o=>[o.id,o.subpaths??[],o.style.stroke,o.style.fill.a>0?o.style.fill:null,o.style.strokeWidth])}}globalThis.DottieSim={page:yo,frame:go};})();
|