@phin-tech/dottie 0.1.0 → 0.3.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 +2 -1
- package/README.md +19 -0
- package/dist/compile.js +394 -0
- package/dist/dottie-compile.mjs +496 -0
- package/dist/dottie-loader.js +20 -0
- package/dist/dottie-player.js +77 -18
- package/dist/dottie-player.min.js +36 -36
- package/dist/dottie.js +75 -18
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/compile.d.ts +19 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/model.d.ts +8 -1
- package/dist/types/timeline.d.ts +3 -0
- package/package.json +9 -2
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/*! dottie.js 0.
|
|
2
|
-
"use strict";(()=>{var Oe=Object.defineProperty;var Kn=(t,e,n)=>e in t?Oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Xn=(t,e)=>{for(var n in e)Oe(t,n,{get:e[n],enumerable:!0})};var b=(t,e,n)=>Kn(t,typeof e!="symbol"?e+"":e,n);var Ge={};Xn(Ge,{BOIL_DRAWINGS:()=>le,DottieFormatError:()=>q,DottiePlayer:()=>wt,KINDS:()=>Fe,KNOWN_FIELDS:()=>Ne,MAX_DURATION:()=>ht,Playback:()=>It,SUPPORTED_VERSION:()=>Zi,VERSION:()=>Xi,black:()=>ot,bounds:()=>rt,cameraView:()=>bt,clampFPS:()=>ft,clampTime:()=>dt,clear:()=>He,cloneElement:()=>_,definePlayer:()=>ne,elementIndex:()=>Jn,frameTimes:()=>Jt,inkOnDark:()=>je,inspect:()=>Un,inspectFrame:()=>ze,inspectPage:()=>Ce,isAutomaticInk:()=>ae,luminance:()=>pt,orderedElements:()=>At,pageIndex:()=>Lt,parseDottie:()=>Rt,plan:()=>kt,posterTime:()=>it,render:()=>Ui,repeatIsValid:()=>zt,resolved:()=>W,sameColor:()=>mt,sampleTimes:()=>Ye,sceneAt:()=>Hn,stableSortBy:()=>Yt,still:()=>Nn,svg:()=>ee,svgParts:()=>$t,themeNamed:()=>ut,themes:()=>Ie,transientElements:()=>jn,withRoughness:()=>Vt});var Zi=2,Fe=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image"],Qn=["linear","easeIn","easeOut","easeInOut","hold"],Ne={file:["version","pages","images"],page:["id","name","layers","elements","theme","guidesX","guidesY","guidesLocked","timeline"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","gridSize","opacity"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","anchor","image","reveal"],strokePoint:["x","y"],subpath:["closed","coords"],inlineImage:["data","format"],endpoint:["elementID","port","x","y"],connector:["start","end","routing","startHead","endHead"],timeline:["fps","duration","boil","settle","poster","tracks","camera","markers"],track:["element","keys","boil","follow","repeats"],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"]},ht=3600,le=3,ot={r:.12,g:.12,b:.13,a:1},He={r:0,g:0,b:0,a:0},je={r:.93,g:.93,b:.94,a:1},q=class extends Error{},E=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),w=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,I=t=>typeof t=="string"?t:void 0,H=t=>typeof t=="boolean"?t:void 0,j=t=>typeof t=="string"?t.toUpperCase():void 0;function dt(t){return Number.isFinite(t)?Math.min(Math.max(t,0),ht):t===1/0?ht:0}function ft(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function Wt(t){if(!E(t))return;let e=w(t.r),n=w(t.g),i=w(t.b);if(!(e===void 0||n===void 0||i===void 0))return{r:e,g:n,b:i,a:w(t.a)??1}}var se=class{constructor(){b(this,"warnings",[]);b(this,"seen",new Set)}warn(e){this.seen.has(e)||(this.seen.add(e),this.warnings.push(e))}fields(e,n){let i=Ne[n];for(let r of Object.keys(e))i.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=E(e)?e:{};this.fields(n,"style");let i=I(n.fillStyle)??"solid",r=I(n.dash)??"solid";return["solid","hachure","crossHatch","grid"].includes(i)||this.warn(`Unknown fill style "${i}", drawn solid`),["solid","dashed","dotted"].includes(r)||this.warn(`Unknown dash "${r}", drawn solid`),{stroke:Wt(n.stroke)??{...ot},fill:Wt(n.fill)??{...He},fillStyle:["solid","hachure","crossHatch","grid"].includes(i)?i:"solid",strokeWidth:w(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:w(n.roughness)??1,bowing:w(n.bowing)??1,fontSize:w(n.fontSize)??18,gridSize:w(n.gridSize)??null,opacity:w(n.opacity)??null}}endpoint(e){let n=E(e)?e:{},i=I(n.port);return{elementID:j(n.elementID)??null,port:i&&["top","right","bottom","left"].includes(i)?i:null,x:w(n.x)??0,y:w(n.y)??0}}connector(e){if(!E(e))return null;this.fields(e,"connector");let n=(r,o)=>{let s=I(r);return s&&["none","arrow","triangle","dot","bar"].includes(s)?s:o},i=I(e.routing);return{start:this.endpoint(e.start),end:this.endpoint(e.end),routing:i&&["straight","curved","elbow"].includes(i)?i:"straight",startHead:n(e.startHead,"none"),endHead:n(e.endHead,"arrow")}}image(e,n){if(!E(e))return null;let i=I(e.ref);if(i!==void 0)return n[i]??{data:"",format:"png"};let r=I(e.data);return r===void 0?null:this.picture(r,I(e.format))}picture(e,n){return Zn.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(!E(e))return null;this.fields(e,"element");let i=j(e.id),r=I(e.kind),o=j(e.layerID);if(!i||!r||!o)return this.warn("Skipped an element without an id, kind or layer"),null;Fe.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let s=Array.isArray(e.subpaths)?e.subpaths.filter(E).map(l=>({closed:H(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:i,kind:r,layerID:o,x:w(e.x)??0,y:w(e.y)??0,width:w(e.width)??0,height:w(e.height)??0,style:this.style(e.style),seed:(w(e.seed)??1)>>>0,text:I(e.text)??null,connector:this.connector(e.connector),groupID:j(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(E).map(l=>({x:w(l.x)??0,y:w(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:s,evenOdd:H(e.evenOdd)??null,rotation:w(e.rotation)??null,link:j(e.link)??null,anchor:I(e.anchor)??null,image:this.image(e.image,n),reveal:w(e.reveal)??null}}ease(e){let n=I(e);return n===void 0?null:Qn.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!E(e))return null;this.fields(e,"keyframe");let n=w(e.t);if(n===void 0)return null;let i={t:n};for(let a of["x","y","width","height","rotation","strokeWidth","reveal","opacity"]){let c=w(e[a]);c!==void 0&&(i[a]=c)}let r=Wt(e.stroke),o=Wt(e.fill),s=H(e.visible),l=this.ease(e.ease);return r&&(i.stroke=r),o&&(i.fill=o),s!==void 0&&(i.visible=s),l&&(i.ease=l),i}track(e){if(!E(e))return null;this.fields(e,"track");let n=j(e.element);if(!n)return null;let i=(Array.isArray(e.keys)?e.keys:[]).map(s=>this.keyframe(s)).filter(s=>s!==null&&s.t>=0&&s.t<=ht);Yt(i,s=>s.t);let r=Array.isArray(e.follow)?e.follow.filter(E).flatMap(s=>{let l=j(s.path),a=w(s.start),c=w(s.end);return!l||a===void 0||c===void 0||a<0||c>ht?[]:[{path:l,start:a,end:c,ease:this.ease(s.ease),reverse:H(s.reverse)??null,orient:H(s.orient)??null,laps:w(s.laps)??null}]}):null,o=Array.isArray(e.repeats)?e.repeats.filter(E).flatMap(s=>{let l=w(s.start),a=w(s.end);if(l===void 0||a===void 0)return[];let c=w(s.count),u={start:l,end:a,count:c===void 0?null:Math.trunc(c)};return zt(u)?[u]:[]}):null;return{element:n,keys:i,boil:H(e.boil)??null,follow:r,repeats:o}}timeline(e){if(!E(e))return null;this.fields(e,"timeline");let n=w(e.boil),i=Array.isArray(e.camera)?e.camera.filter(E).flatMap(s=>{let l=w(s.t),a=w(s.x),c=w(s.y),u=w(s.width),m=w(s.height);return l===void 0||a===void 0||c===void 0||u===void 0||m===void 0?[]:u>1&&m>1&&l>=0?[{t:l,x:a,y:c,width:u,height:m,ease:this.ease(s.ease)}]:[]}):null;i&&Yt(i,s=>s.t);let r=Array.isArray(e.markers)?e.markers.filter(E).flatMap(s=>{let l=w(s.t);return l!==void 0&&l>=0?[{t:l,name:I(s.name)??""}]:[]}):null;r&&Yt(r,s=>s.t);let o=w(e.poster);return{fps:ft(w(e.fps)??12),duration:dt(w(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:H(e.settle)??null,poster:o===void 0?null:dt(o),tracks:(Array.isArray(e.tracks)?e.tracks:[]).map(s=>this.track(s)).filter(s=>s!==null),camera:i,markers:r}}page(e,n,i){if(!E(e))throw new q(`Page ${i} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(E).flatMap(o=>{let s=j(o.id);return s?[{id:s,name:I(o.name)??"",visible:H(o.visible)??!0,locked:H(o.locked)??!1}]:[]});return r.length===0&&(this.warn(`Page ${i} has no layers`),r.push({id:"LAYER",name:"Layer 1",visible:!0,locked:!1})),{id:j(e.id)??`PAGE-${i}`,name:I(e.name)??`Page ${i}`,layers:r,elements:(Array.isArray(e.elements)?e.elements:[]).map(o=>this.element(o,n)).filter(o=>o!==null),theme:I(e.theme)??null,timeline:this.timeline(e.timeline)}}},Zn=/^[A-Za-z0-9+/=\s]*$/;function zt(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=ht&&(t.count===null||t.count>=1&&t.count<=1e4)}function Yt(t,e){let n=t.map((i,r)=>[i,r]);n.sort((i,r)=>e(i[0])-e(r[0])||i[1]-r[1]);for(let i=0;i<t.length;i++)t[i]=n[i][0]}function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new q(`Not JSON: ${s.message}`)}if(!E(e))throw new q("Not a Dottie drawing");let n=w(e.version);if(n===void 0)throw new q("Not a Dottie drawing (no version)");if(!Array.isArray(e.pages)||e.pages.length===0)throw new q("A drawing needs at least one page");let i=new se;i.fields(e,"file"),n>2&&i.warn(`File version ${n} is newer than this player knows (2); some things may not show`);let r={};if(E(e.images))for(let[s,l]of Object.entries(e.images))E(l)&&typeof l.data=="string"&&(r[s]=i.picture(l.data,I(l.format)));let o=e.pages.map((s,l)=>i.page(s,r,l+1));if(new Set(o.map(s=>s.id)).size!==o.length)throw new q("Two pages share an id");return{version:n,pages:o,warnings:i.warnings}}function pt(t){return .2126*t.r+.7152*t.g+.0722*t.b}function mt(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function ae(t){return mt(t,ot)||mt(t,je)}function _(t){return{...t,style:{...t.style,stroke:{...t.style.stroke},fill:{...t.style.fill}},connector:t.connector?{...t.connector,start:{...t.connector.start},end:{...t.connector.end}}:null}}function At(t){if(t.layers.length<=1)return t.elements;let e=new Map;t.layers.forEach((i,r)=>{e.has(i.id)||e.set(i.id,r)});let n=t.layers.map(()=>[]);for(let i of t.elements)n[e.get(i.layerID)??0].push(i);return n.flat()}function Jn(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}var qe=.5522847498307936,R=class t{constructor(){b(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,i){return this.segments.push({op:"C",c1:n,c2:i,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,i)=>i===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,i=e.y+e.height/2,r=e.width/2,o=e.height/2,s=r*qe,l=o*qe;return this.moveTo({x:n+r,y:i}),this.curveTo({x:n,y:i+o},{x:n+r,y:i+l},{x:n+s,y:i+o}),this.curveTo({x:n-r,y:i},{x:n-s,y:i+o},{x:n-r,y:i+l}),this.curveTo({x:n,y:i-o},{x:n-r,y:i-l},{x:n-s,y:i-o}),this.curveTo({x:n+r,y:i},{x:n+s,y:i-o},{x:n+r,y:i-l}),this.close()}static ellipse(e){return new t().addEllipse(e)}translated(e,n){let i=o=>({x:o.x+e,y:o.y+n}),r=new t;return r.segments=this.segments.map(o=>{switch(o.op){case"M":case"L":return{op:o.op,p:i(o.p)};case"Q":return{op:"Q",c:i(o.c),p:i(o.p)};case"C":return{op:"C",c1:i(o.c1),c2:i(o.c2),p:i(o.p)};case"Z":return o}}),r}contours(){let e=[],n=[],i={x:0,y:0};for(let r of this.segments){let o=n.length?n[n.length-1]:i;switch(r.op){case"M":n.length>1&&e.push(n),i=r.p,n=[r.p];break;case"L":n.push(r.p);break;case"Q":for(let s=1;s<=12;s++){let l=s/12,a=1-l;n.push({x:a*a*o.x+2*a*l*r.c.x+l*l*r.p.x,y:a*a*o.y+2*a*l*r.c.y+l*l*r.p.y})}break;case"C":for(let s=1;s<=16;s++){let l=s/16,a=1-l;n.push({x:a*a*a*o.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*o.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(i),n.length>1&&e.push(n),n=[i];break}}return n.length>1&&e.push(n),e}trimmed(e){let n=this.contours().map(o=>new yt(o)),i=Math.min(Math.max(e,0),1)*n.reduce((o,s)=>o+s.length,0),r=new t;for(let o of n){if(!(i>0))break;r.moveTo(o.points[0]);for(let s=1;s<o.points.length;s++){let l=o.lengths[s]-o.lengths[s-1];if(l<=i){r.lineTo(o.points[s]),i-=l;continue}let a=o.points[s-1],c=o.points[s],u=i/l;r.lineTo({x:a.x+(c.x-a.x)*u,y:a.y+(c.y-a.y)*u}),i=0;break}}return r}data(){let e=[];for(let n of this.segments)switch(n.op){case"M":e.push(`M${y(n.p.x)} ${y(n.p.y)}`);break;case"L":e.push(`L${y(n.p.x)} ${y(n.p.y)}`);break;case"Q":e.push(`Q${y(n.c.x)} ${y(n.c.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"C":e.push(`C${y(n.c1.x)} ${y(n.c1.y)} ${y(n.c2.x)} ${y(n.c2.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function ce(t){return t<0?-Math.round(-t):Math.round(t)}function y(t){let e=ce(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var yt=class{constructor(e){b(this,"points");b(this,"lengths");this.points=e;let n=0;this.lengths=e.map((i,r)=>(r>0&&(n+=Math.hypot(i.x-e[r-1].x,i.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,i=1;for(;i<this.lengths.length-1&&this.lengths[i]<n;)i++;let r=this.lengths[i]-this.lengths[i-1],o=r>0?(n-this.lengths[i-1])/r:0,s=this.points[i-1],l=this.points[i];return{x:s.x+(l.x-s.x)*o,y:s.y+(l.y-s.y)*o}}},C=t=>t.x+t.width/2,G=t=>t.y+t.height/2,Y=t=>t.x+t.width,z=t=>t.y+t.height;function ue(t,e){if(!t)return{...e};let n=Math.min(t.x,e.x),i=Math.min(t.y,e.y);return{x:n,y:i,width:Math.max(Y(t),Y(e))-n,height:Math.max(z(t),z(e))-i}}function gt(t,e,n){return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}function he(t,e,n){if(n===0)return t;let i=t.x-e.x,r=t.y-e.y;return{x:e.x+i*Math.cos(n)-r*Math.sin(n),y:e.y+i*Math.sin(n)+r*Math.cos(n)}}function ti(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)}}function _e(t,e){let n=[t[0]];for(let i=0;i<Math.floor((t.length-1)/3);i++){let r=t.slice(3*i,3*i+4),o=0;for(let l=1;l<r.length;l++)o+=Math.hypot(r[l].x-r[l-1].x,r[l].y-r[l-1].y);let s=Math.min(400,Math.max(4,Math.ceil(o/Math.max(e,.5))));for(let l=1;l<=s;l++)n.push(ti(r,l/s))}return n}var L=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),O=t=>t.rotation??0,Tt=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Q=(t,e)=>he(e,Tt(t),O(t)),Ue=(t,e)=>he(e,Tt(t),-O(t));function Ke(t){let e=L(t);if(O(t)===0)return e;let n=[{x:e.x,y:e.y},{x:Y(e),y:e.y},{x:Y(e),y:z(e)},{x:e.x,y:z(e)}].map(l=>Q(t,l)),i=n.map(l=>l.x),r=n.map(l=>l.y),o=Math.min(...i),s=Math.min(...r);return{x:o,y:s,width:Math.max(...i)-o,height:Math.max(...r)-s}}function Xe(t,e){if(!ae(t.style.stroke))return t;let n=_(t),r=(t.style.fillStyle==="solid"||t.style.fillStyle==="grid")&&t.style.fill.a>=.5&&pt(t.style.fill)>.5;return n.style.stroke=pt(e)>.5&&r?{...ot}:{...e},n}function Ct(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 i=[];for(let r=0;r<n.coords.length;r+=2)i.push({x:t.x+n.coords[r]*t.width,y:t.y+n.coords[r+1]*t.height});e.push({closed:n.closed,points:i})}return e}function de(t){let e=new R;for(let n of Ct(t)){e.moveTo(n.points[0]);for(let i=0;i<(n.points.length-1)/3;i++)e.curveTo(n.points[3*i+3],n.points[3*i+1],n.points[3*i+2]);n.closed&&e.close()}return e}function ei(t,e){let n=L(t),i=e==="top"?{x:C(n),y:n.y}:e==="right"?{x:Y(n),y:G(n)}:e==="bottom"?{x:C(n),y:z(n)}:{x:n.x,y:G(n)};return Q(t,i)}function ni(t,e){let n=L(t),i=Tt(t),r=Ue(t,e),o=r.x-i.x,s=r.y-i.y;if(!((o!==0||s!==0)&&n.width>0&&n.height>0))return i;let l=n.width/2,a=n.height/2,c;return t.kind==="ellipse"?c=1/Math.sqrt(o*o/(l*l)+s*s/(a*a)):t.kind==="diamond"?c=1/(Math.abs(o)/l+Math.abs(s)/a):c=Math.min(o!==0?l/Math.abs(o):1/0,s!==0?a/Math.abs(s):1/0),Q(t,{x:i.x+o*c,y:i.y+s*c})}function Qe(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?Tt(n):{x:t.x,y:t.y}}function Ze(t,e,n){let i=t.elementID?n.get(t.elementID):void 0;return i?t.port?ei(i,t.port):ni(i,e):{x:t.x,y:t.y}}function st(t,e){let n=t.connector;return n?[Ze(n.start,Qe(n.end,e),e),Ze(n.end,Qe(n.start,e),e)]:[{x:0,y:0},{x:0,y:0}]}function Z(t){if(t.kind==="polyline")return t.points;let e=[];for(let n=0;n<=24;n++){let i=n/24,r=1-i;e.push({x:r*r*r*t.a.x+3*r*r*i*t.b.x+3*r*i*i*t.c.x+i*i*i*t.d.x,y:r*r*r*t.a.y+3*r*r*i*t.b.y+3*r*i*i*t.c.y+i*i*i*t.d.y})}return e}function J(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[i,r]=st(t,e),o=r.x-i.x,s=r.y-i.y,l=Math.abs(o)>=Math.abs(s);switch(n.routing){case"straight":return{kind:"polyline",points:[i,r]};case"curved":return l?{kind:"cubic",a:i,b:{x:i.x+o/2,y:i.y},c:{x:r.x-o/2,y:r.y},d:r}:{kind:"cubic",a:i,b:{x:i.x,y:i.y+s/2},c:{x:r.x,y:r.y-s/2},d:r};case"elbow":{let a=m=>m===null?null:m==="top"||m==="bottom",c=a(n.start.port)??!l,u=a(n.end.port)??!l;if(c&&u){let m=i.y+s/2;return{kind:"polyline",points:[i,{x:i.x,y:m},{x:r.x,y:m},r]}}if(!c&&!u){let m=i.x+o/2;return{kind:"polyline",points:[i,{x:m,y:i.y},{x:m,y:r.y},r]}}return c?{kind:"polyline",points:[i,{x:i.x,y:r.y},r]}:{kind:"polyline",points:[i,{x:r.x,y:i.y},r]}}}}function Je(t,e,n){let i=Math.atan2(t.y-e.y,t.x-e.x),r=Math.PI/7,o=s=>({x:t.x-n*Math.cos(i+s),y:t.y-n*Math.sin(i+s)});return[o(r),o(-r)]}function tn(t,e){let n=Z(J(t,e));if(n.length===0)return{x:0,y:0,width:0,height:0};let i=n[0].x,r=n[0].y,o=i,s=r;for(let l of n)i=Math.min(i,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),s=Math.max(s,l.y);return{x:i,y:r,width:o-i,height:s-r}}function en(t,e){let n=Z(J(t,e));if(n.length<=1)return n[0]??{x:0,y:0};let i=[],r=0;for(let s=0;s<n.length-1;s++){let l=Math.hypot(n[s+1].x-n[s].x,n[s+1].y-n[s].y);i.push(l),r+=l}let o=r/2;for(let s=0;s<i.length;s++){let l=i[s];if(o<=l||s===i.length-1){let a=l===0?0:o/l;return{x:n[s].x+(n[s+1].x-n[s].x)*a,y:n[s].y+(n[s+1].y-n[s].y)*a}}o-=l}return n[0]}function tt(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}function fe(t,e,n){let i=t[1]+n>>>0,r=i<t[1]?1:0;return[t[0]+e+r>>>0,i]}function ii(t,e){let n=t&65535,i=t>>>16,r=e&65535,o=e>>>16,s=n*r,l=n*o,a=i*r,c=i*o,u=l+a,m=s+u%65536*65536;return[c+Math.floor(u/65536)+Math.floor(m/4294967296)>>>0,m>>>0]}function pe(t,e,n){let i=ii(t[1],n);return[i[0]+Math.imul(t[0],n)+Math.imul(t[1],e)>>>0,i[1]]}function me(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function nn(t){return t=pe(me(t,30),3210233709,484763065),t=pe(me(t,27),2496678331,321982955),me(t,31)}var et=class{constructor(e){b(this,"state");this.state=fe([0,e>>>0],2654435769,2135587861)}next(){return this.state=fe(this.state,2654435769,2135587861),nn(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}};function rn(t,e){let n=fe([0,t>>>0],...ri(e));return n=nn(n),Math.max(1,n[1]>>>0)}function ri(t){let e=pe([0,t>>>0],2654435769,2135587861);return[e[0],e[1]]}var on=(t,e,n)=>t.signed()*e*n;function U(t,e,n,i,r,o,s){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 m=(u===0?1:.5)*a,f=()=>on(n,c,i)*m,d=n.unit()*.4+.3,h=on(n,l/60,i)*r*a,p=e.x-t.x,x=e.y-t.y,M=-x/l,k=p/l,g=o?t:{x:t.x+f(),y:t.y+f()},A=o?e:{x:e.x+f(),y:e.y+f()},T=t.x+p*d*.66+M*h+f()*.5,S=t.y+x*d*.66+k*h+f()*.5,P=t.x+p*(.5+d*.5)+M*h+f()*.5,$=t.y+x*(.5+d*.5)+k*h+f()*.5;s.moveTo(g),s.curveTo(A,{x:T,y:S},{x:P,y:$})}}function ye(t,e,n,i){let r=new R;for(let o=0;o<t.length;o++)U(t[o],t[(o+1)%t.length],e,n,i,!1,r);return r}function sn(t,e,n){let i=new R,r=t.x+t.width/2,o=t.y+t.height/2,s=t.width/2,l=t.height/2;if(!(s>.5&&l>.5))return i;let a=Math.max(8,Math.min(24,Math.trunc((s+l)/6))),c=Math.min(2.5,(s+l)/25)*n;for(let u=0;u<2;u++){let m=e.unit()*2*Math.PI,f=2*Math.PI*(u===0?1:1.04),d=Math.trunc(a*f/(2*Math.PI))+1,h=[];for(let p=0;p<d;p++){let x=m+f*p/a,M=e.signed()*c,k=e.signed()*c;h.push({x:r+s*Math.cos(x)+M,y:o+l*Math.sin(x)+k})}oi(h,i)}return i}function oi(t,e){if(!(t.length<=2)){e.moveTo(t[0]);for(let n=0;n<t.length-1;n++){let i=t[Math.max(n-1,0)],r=t[n],o=t[n+1],s=t[Math.min(n+2,t.length-1)];e.curveTo(o,{x:r.x+(o.x-i.x)/6,y:r.y+(o.y-i.y)/6},{x:o.x-(s.x-r.x)/6,y:o.y-(s.y-r.y)/6})}}}var ge=-41*Math.PI/180;function ln(t,e,n){if(!(n>0))return[];let i=Math.cos(e),r=Math.sin(e),o=t.filter(f=>f.length>=3).map(f=>f.map(d=>({x:d.x*i+d.y*r,y:-d.x*r+d.y*i}))),s=o.flat();if(s.length===0)return[];let l=1/0,a=-1/0;for(let f of s)l=Math.min(l,f.y),a=Math.max(a,f.y);let c=(f,d)=>({x:f*i-d*r,y:f*r+d*i}),u=[],m=l+n/2;for(;m<a;){let f=[];for(let d of o)for(let h=0;h<d.length;h++){let p=d[h],x=d[(h+1)%d.length];(p.y<=m&&m<x.y||x.y<=m&&m<p.y)&&f.push(p.x+(m-p.y)/(x.y-p.y)*(x.x-p.x))}f.sort((d,h)=>d-h);for(let d=0;d+1<f.length;d+=2)f[d+1]-f[d]>.5&&u.push([c(f[d],m),c(f[d+1],m)]);m+=n}return u}var Gt=class{constructor(e=6e3){b(this,"map",new Map);b(this,"limit");this.limit=e}get(e,n){let i=this.map.get(e);if(i!==void 0)return i;let r=n();return this.map.size>=this.limit&&this.map.clear(),this.map.set(e,r),r}},un=new Gt,si=new Gt;function hn(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"?lt(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var lt=t=>Math.max(8,t.style.gridSize??50);function at(t){return t.kind==="freehand"&&t.path===null?cn(t):un.get(hn(t,0),()=>cn(t))}function dn(t){return[{x:t.x,y:t.y},{x:Y(t),y:t.y},{x:Y(t),y:z(t)},{x:t.x,y:z(t)}]}function Bt(t){return[{x:C(t),y:t.y},{x:Y(t),y:G(t)},{x:C(t),y:z(t)},{x:t.x,y:G(t)}]}function cn(t){let e=L(t),n=new et(t.seed),i=t.style.roughness;switch(t.kind){case"ellipse":return i<=0?R.ellipse(e):sn(e,n,i);case"diamond":return i<=0?new R().addLines(Bt(e)).close():ye(Bt(e),n,i,t.style.bowing);case"text":case"connector":return R.rect(e);case"freehand":return ai(t);case"path":return i<=0?de(t):li(t,n);default:return i<=0?R.rect(e):ye(dn(e),n,i,t.style.bowing)}}function li(t,e){let n=t.style.roughness,i=new R;for(let r of Ct(t)){let o=r.points;for(let s=0;s<(o.length-1)/3;s++){let l=o[3*s],a=o[3*s+1],c=o[3*s+2],u=o[3*s+3];if(a.x===l.x&&a.y===l.y&&c.x===u.x&&c.y===u.y){U(l,u,e,n,t.style.bowing,!0,i);continue}let m=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,m/30)*n;for(let d=0;d<2;d++){let h=d===0?1:.5,p=()=>e.signed()*f*h;i.moveTo(l);let x=a.x+p(),M=a.y+p(),k=c.x+p(),g=c.y+p();i.curveTo(u,{x,y:M},{x:k,y:g})}}}return i}function ai(t){let e=L(t),n=t.path;if(n&&n.length>=8&&(n.length-2)%6===0){let o=l=>({x:e.x+n[2*l]*e.width,y:e.y+n[2*l+1]*e.height}),s=new R().moveTo(o(0));for(let l=0;l<Math.floor((n.length/2-1)/3);l++)s.curveTo(o(3*l+3),o(3*l+1),o(3*l+2));return s}let i=(t.points??[]).map(o=>({x:e.x+o.x*e.width,y:e.y+o.y*e.height})),r=new R;if(i.length===0)return r;if(r.moveTo(i[0]),i.length===1)return r.lineTo(i[0]);if(i.length===2)return r.lineTo(i[1]);for(let o=1;o<i.length-1;o++)r.quadTo({x:(i[o].x+i[o+1].x)/2,y:(i[o].y+i[o+1].y)/2},i[o]);return r.lineTo(i[i.length-1])}function xe(t){return t.kind!=="path"?[ci(t)]:Ct(t).map(e=>_e(e.points,3))}function ci(t){let e=L(t);if(t.kind==="ellipse"){let n=[];for(let i=0;i<48;i++){let r=2*Math.PI*i/48;n.push({x:C(e)+e.width/2*Math.cos(r),y:G(e)+e.height/2*Math.sin(r)})}return n}return t.kind==="diamond"?Bt(e):dn(e)}function Ot(t){let e=L(t);return t.kind==="ellipse"?R.ellipse(e):t.kind==="path"?de(t):t.kind==="diamond"?new R().addLines(Bt(e)).close():R.rect(e)}function be(t){return t.style.fillStyle==="solid"||["freehand","connector","text","image"].includes(t.kind)?new R:un.get(hn(t,1),()=>ui(t))}function ui(t){let e=xe(t),n=new et((t.seed^1540483477)>>>0),i=new R;if(t.style.fillStyle==="grid"){for(let[s,l]of fn(e,lt(t)))t.style.roughness<=0?i.moveTo(s).lineTo(l):U(s,l,n,t.style.roughness*.3,.3,!1,i);return i}let r=Math.max(4,t.style.strokeWidth*4),o=[ge];t.style.fillStyle==="crossHatch"&&o.push(ge+Math.PI/2);for(let s of o)for(let[l,a]of ln(e,s,r))t.style.roughness<=0?i.moveTo(l).lineTo(a):U(l,a,n,t.style.roughness*.6,.5,!1,i);return i}function mn(t,e){switch(t){case"solid":return null;case"dashed":return[Math.max(8,e*4),Math.max(6,e*3)];case"dotted":return[.01,Math.max(5,e*2.6)]}}function ke(t,e){let n=t.connector;if(!n)return[new R,new R];let[i,r]=st(t,e),o=[t.seed,t.style.roughness,t.style.bowing,t.style.strokeWidth,n.routing,n.startHead,n.endHead,n.start.port,n.end.port,i.x,i.y,r.x,r.y].join("|");return si.get(o,()=>hi(t,e))}function hi(t,e){let n=t.connector,i=new et(t.seed),r=t.style.roughness,o=t.style.bowing,s=new R,l=new R,a=J(t,e);if(a.kind==="polyline"){let d=a.points;for(let h=0;h<Math.max(d.length-1,0);h++)r<=0?s.moveTo(d[h]).lineTo(d[h+1]):U(d[h],d[h+1],i,r,o,!0,s)}else{s.moveTo(a.a);let d=r*3,h=()=>i.signed()*d,p=a.b.x+h(),x=a.b.y+h(),M=a.c.x+h(),k=a.c.y+h();s.curveTo(a.d,{x:p,y:x},{x:M,y:k})}let c=Z(a),u=Math.max(10,t.style.strokeWidth*5),m=(d,h)=>{r<=0?s.moveTo(d).lineTo(h):U(d,h,i,r*.5,0,!0,s)},f=(d,h,p)=>{let[x,M]=Je(h,p,u);switch(d){case"arrow":m(x,h),m(M,h);break;case"triangle":m(x,h),m(M,h),m(x,M),l.moveTo(h).lineTo(x).lineTo(M).close();break;case"dot":{let k=u*.32,g=Math.atan2(h.y-p.y,h.x-p.x),A=h.x-k*Math.cos(g),T=h.y-k*Math.sin(g);l.addEllipse({x:A-k,y:T-k,width:2*k,height:2*k});break}case"bar":{let k=Math.atan2(h.y-p.y,h.x-p.x)+Math.PI/2,g=u*.5;m({x:h.x-g*Math.cos(k),y:h.y-g*Math.sin(k)},{x:h.x+g*Math.cos(k),y:h.y+g*Math.sin(k)});break}}};return c.length>1&&(f(n.endHead,c[c.length-1],c[c.length-2]),f(n.startHead,c[0],c[1])),[s,l]}var gn=2,we=.75,di=.8,pn=.6;function fn(t,e){return[...yn(t,e,!1),...yn(t,e,!0)]}function yn(t,e,n){if(!(e>0))return[];let i=c=>n?{x:c.y,y:c.x}:c,r=t.filter(c=>c.length>=3).map(c=>c.map(i)),o=r.flat().map(c=>c.y);if(o.length===0)return[];let s=Math.min(...o),l=Math.max(...o),a=[];for(let c=Math.floor(s/e)*e;c<l-.5;c+=e){if(!(c>s+.5))continue;let u=[];for(let m of r)for(let f=0;f<m.length;f++){let d=m[f],h=m[(f+1)%m.length];(d.y<=c&&c<h.y||h.y<=c&&c<d.y)&&u.push(d.x+(c-d.y)/(h.y-d.y)*(h.x-d.x))}u.sort((m,f)=>m-f);for(let m=0;m+1<u.length;m+=2)u[m+1]-u[m]>.5&&a.push([i({x:u[m],y:c}),i({x:u[m+1],y:c})])}return a}function xn(t){return .2126*t.r+.7152*t.g+.0722*t.b>.5?{r:t.r*.84,g:t.g*.84,b:t.b*.8,a:t.a}:{r:t.r+(1-t.r)*.25,g:t.g+(1-t.g)*.25,b:t.b+(1-t.b)*.25,a:t.a}}function Pe(t){return t.style.fillStyle==="grid"&&t.style.fill.a>0&&["rectangle","ellipse","diamond","path"].includes(t.kind)}function Nt(t,e,n){let i=(Math.imul(t,668265261)^Math.imul(e,374761393)^Math.imul(n,2654435761))>>>0;return i=Math.imul(i^i>>>15,2246822507)>>>0,i=Math.imul(i^i>>>13,3266489909)>>>0,i=(i^i>>>16)>>>0,i/4294967296}function bn(t,e,n){let i=n/gn;return{x:(t+.5+(Nt(t,e,1)-.5)*pn)*i,y:(e+.5+(Nt(t,e,2)-.5)*pn)*i}}function mi(t,e,n,i){let r=1/0;for(let o=-1;o<=1;o++)for(let s=-1;s<=1;s++){if(o===0&&s===0)continue;let l=bn(t+o,e+s,i);r=Math.min(r,Math.hypot(l.x-n.x,l.y-n.y))}return r*di}function fi(t,e,n){let i=Math.cos(e),r=Math.sin(e),o=n*.8,s=n*.5;return[-1,0,1].map(l=>{let a=t.x-r*s*l,c=t.y+i*s*l;return[{x:a-i*o,y:c-r*o},{x:a+i*o,y:c+r*o}]})}function pi(t,e){let n=!1;for(let i of t){if(i.length<3)continue;let r=i.length-1;for(let o=0;o<i.length;o++){let s=i[o],l=i[r];s.y>e.y!=l.y>e.y&&e.x<(l.x-s.x)*(e.y-s.y)/(l.y-s.y)+s.x&&(n=!n),r=o}}return n}function yi(t,e){let n=1/0;for(let i of e)if(!(i.length<2))for(let r=0;r<i.length;r++){let o=i[r],s=i[(r+1)%i.length],l=s.x-o.x,a=s.y-o.y,c=l*l+a*a,u=c>0?Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*a)/c)):0;n=Math.min(n,Math.hypot(t.x-(o.x+u*l),t.y-(o.y+u*a)))}return n}var gi=(t,e)=>e.x>=t.x&&e.x<t.x+t.width&&e.y>=t.y&&e.y<t.y+t.height,Ft=new Map;function kn(t){if(t.length===0)return[];let e=t.map(r=>[r.kind,r.x,r.y,r.width,r.height,r.rotation??0,lt(r),JSON.stringify(r.subpaths??null),r.style.stroke.r,r.style.stroke.g,r.style.stroke.b,r.style.stroke.a,r.style.roughness,r.style.strokeWidth].join(",")).join(";"),n=Ft.get(e);if(n)return n;let i=xi(t);return Ft.size>=16&&Ft.clear(),Ft.set(e,i),i}function xi(t){let e=t.map(o=>{let s=xe(o).map(d=>d.map(h=>Q(o,h))),l=s.flat(),a=l.map(d=>d.x),c=l.map(d=>d.y),u=a.length?Math.min(...a):0,m=c.length?Math.min(...c):0,f={x:u,y:m,width:(a.length?Math.max(...a):0)-u,height:(c.length?Math.max(...c):0)-m};return{contours:s,box:f,cell:lt(o),element:o}}),n=e.map(()=>[]),i=new Set;for(let o of e){let s=o.cell/gn,l=gt(o.box,-o.cell,-o.cell),a=Math.floor(l.x/s),c=Math.ceil((l.x+l.width)/s),u=Math.floor(l.y/s),m=Math.ceil((l.y+l.height)/s),f=we*o.cell;for(let d=a;d<c;d++)for(let h=u;h<m;h++){let p=`${o.cell}|${d}|${h}`;if(i.has(p))continue;i.add(p);let x=bn(d,h,o.cell),M=1/0,k=-1;for(let S=0;S<e.length;S++){let P=e[S];if(!gi(gt(P.box,-f,-f),x))continue;if(pi(P.contours,x)){M=0;break}let $=yi(x,P.contours);$<M&&(M=$,k=S)}if(!(M>0&&M<=f&&k>=0))continue;let g=Nt(d,h,3)*Math.PI,A=mi(d,h,x,o.cell),T=Math.trunc(Nt(d,h,4)*4294967296)>>>0;for(let[S,P]of fi(x,g,A))n[k].push([S,P,T])}}let r=[];return e.forEach((o,s)=>{if(n[s].length===0)return;let l=o.element,a=new R;for(let[c,u,m]of n[s])l.style.roughness<=0?a.moveTo(c).lineTo(u):U(c,u,new et(m),l.style.roughness*.35,.2,!1,a);r.push({ink:{...l.style.stroke,a:l.style.stroke.a*.6},width:Math.max(.8,l.style.strokeWidth*.45),path:a})}),r}var Ht=.951995849609375,jt=.2129974365234375,qt=.0279998779296875,wn=.975006103515625,Pn=.2169952392578125,Mn=.0290069580078125,Rn=.957000732421875,An=.2129974365234375,Tn=.0279998779296875,vn=.975006103515625,En=.2169952392578125,Sn=.0290069580078125,$n=.60205078125,In=.92822265625,Ln=.23583984375,xt={bold:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-30,fi:20,fl:20,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":278,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':463,"\u201C":463,"\u201D":463,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":371,"\\":371,"&":685,"#":556,"%":1e3,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":223,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:704,c:574,C:741,d:611,D:741,e:574,E:648,\u00E9:574,f:333,F:593,g:611,G:759,h:593,H:741,i:258,I:295,j:278,J:556,k:574,K:722,l:258,L:593,m:906,M:907,n:593,N:741,o:611,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:537,S:649,t:352,T:611,u:593,U:741,v:520,V:630,w:814,W:944,x:537,X:667,y:519,Y:667,z:519,Z:648}},boldItalic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-68,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":296,"?":574,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':481,"\u201C":481,"\u201D":481,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":389,"\\":389,"&":685,"#":556,"%":963,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:722,c:556,C:741,d:611,D:741,e:574,E:667,\u00E9:574,f:352,F:593,g:611,G:759,h:611,H:741,i:259,I:296,j:259,J:556,k:556,K:722,l:259,L:574,m:907,M:907,n:611,N:741,o:593,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:519,S:648,t:370,T:611,u:611,U:741,v:519,V:630,w:815,W:944,x:519,X:667,y:519,Y:648,z:500,Z:648}},italic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,fi:1,fl:1,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":926,"\u2022":500,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:519,A:667,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:481,K:667,l:222,L:556,m:852,M:870,n:556,N:722,o:574,O:759,p:593,P:648,q:593,Q:759,r:333,R:685,s:481,S:648,t:315,T:574,u:556,U:722,v:481,V:611,w:759,W:926,x:481,X:611,y:481,Y:611,z:444,Z:611}},regular:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":1e3,"\u2022":350,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:537,A:648,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:519,K:667,l:222,L:556,m:853,M:871,n:556,N:722,o:574,O:760,p:593,P:648,q:593,Q:760,r:333,R:685,s:500,S:648,t:315,T:574,u:556,U:722,v:500,V:611,w:758,W:926,x:518,X:611,y:500,Y:648,z:480,Z:611}}},_t={"\u2190":[.966796875,.2109375,0],"\u2192":[.966796875,.2109375,0],"\u2191":[.966796875,.2109375,0],"\u2193":[.966796875,.2109375,0],"\u25E6":[.966796875,.2109375,0],"\u2610":[.66650390625,.25,.08349609375],"\u2611":[.66650390625,.25,.08349609375],"\u2713":[.966796875,.2109375,0]};function V(t){let e=n=>Math.round(Math.min(Math.max(n,0),1)*255).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}function Ut(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Kt(t,e,n="regular"){let i=xt[n],r=i.w.n,o=0,s="";for(let l of t)o+=i.w[l]??r,s&&(o+=i.k[s+l]??0),s=l;return o*e/1e3}function bi(t){let e=Math.round(Ht*t),n=Math.round(jt*t),i=Math.round(qt*t);return[e+n,e+n+i]}function Me(t,e){return t===" "?!0:(t==="/"||t==="-")&&e!==""&&!/[\d\s/-]/.test(e)}function ki(t){let e=[...t],n=[],i="";return e.forEach((r,o)=>{i+=r;let s=e[o+1]??"";Me(r,s)&&s!==" "&&(n.push(i),i="")}),(i||n.length===0)&&n.push(i),n}function wi(t,e,n,i="regular"){let r=[];for(let o of t.split(/\r\n|\n|\r|\u2028|\u2029/)){let s="";for(let l of ki(o)){let a=s+l;for(s===""||Kt(a.trimEnd(),e,i)<=n?s=a:(r.push(s),s=l);Kt(s.trimEnd(),e,i)>n&&[...s.trimEnd()].length>1;){let c=[...s],u=c.length-1;for(;u>1&&Kt(c.slice(0,u).join(""),e,i)>n;)u--;r.push(c.slice(0,u).join("")),s=c.slice(u).join("")}}r.push(s)}return r}function Vn(t,e,n){if(t==="")return{width:0,height:0};let i=wi(t,e,n),r=Math.max(...i.map(l=>Kt(l.trimEnd(),e))),[o,s]=bi(e);return{width:Math.ceil(r-1e-9),height:Math.ceil(o+s*(i.length-1)-1e-9)}}var Dn=12,ct="\u2028";function Pi(t){let e=Math.min(Dn,t.width/2),n=Math.min(Dn,t.height/2);return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}var Ae=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,Cn=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,Te=/^ {0,3}(`{3,}|~{3,})/,vt=/^( *)([-*+]|\d{1,9}[.)])([ \t]+|$)(.*)$/,Xt=/^ {0,3}> ?(.*)$/,Mi=/^ *\|? *:?-+:? *(\| *:?-+:? *)*\|? *$/;function Re(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1)),e.split(/(?<!\\)\|/).map(n=>n.trim())}function Ri(t){return $e(t.replace(/\r\n?/g,`
|
|
1
|
+
/*! dottie.js 0.3.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
|
|
2
|
+
"use strict";(()=>{var He=Object.defineProperty;var Zn=(t,e,n)=>e in t?He(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Jn=(t,e)=>{for(var n in e)He(t,n,{get:e[n],enumerable:!0})};var k=(t,e,n)=>Zn(t,typeof e!="symbol"?e+"":e,n);var Fe={};Jn(Fe,{BOIL_DRAWINGS:()=>he,DottieFormatError:()=>q,DottiePlayer:()=>wt,KINDS:()=>je,KNOWN_FIELDS:()=>_e,MAX_DURATION:()=>mt,MAX_MARCH:()=>ce,Playback:()=>Vt,SUPPORTED_VERSION:()=>or,VERSION:()=>ir,black:()=>st,bounds:()=>rt,cameraView:()=>bt,clampFPS:()=>ft,clampMarch:()=>qe,clampTime:()=>ot,clear:()=>Ue,cloneElement:()=>B,definePlayer:()=>oe,elementIndex:()=>ni,frameTimes:()=>ne,inkOnDark:()=>Ke,inspect:()=>Qn,inspectFrame:()=>Ge,inspectPage:()=>Be,isAutomaticInk:()=>me,luminance:()=>pt,orderedElements:()=>At,pageIndex:()=>Dt,parseDottie:()=>Rt,plan:()=>kt,posterTime:()=>it,render:()=>er,repeatIsValid:()=>Ct,resolved:()=>W,sameColor:()=>dt,sampleTimes:()=>Ce,sceneAt:()=>qn,stableSortBy:()=>zt,still:()=>_n,svg:()=>re,svgParts:()=>Lt,themeNamed:()=>ht,themes:()=>De,transientElements:()=>Un,withRoughness:()=>Wt});var or=2,je=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image"],ti=["linear","easeIn","easeOut","easeInOut","hold","spring","bounce","elastic"],_e={file:["version","pages","images"],page:["id","name","layers","elements","theme","guidesX","guidesY","guidesLocked","timeline"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","gridSize","opacity","dashOffset"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","anchor","image","reveal"],strokePoint:["x","y"],subpath:["closed","coords"],inlineImage:["data","format"],endpoint:["elementID","port","x","y"],connector:["start","end","routing","startHead","endHead"],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"]},mt=3600,ce=1e4,qe=t=>t===void 0||!Number.isFinite(t)||t===0?null:Math.min(Math.max(t,-ce),ce),he=3,st={r:.12,g:.12,b:.13,a:1},Ue={r:0,g:0,b:0,a:0},Ke={r:.93,g:.93,b:.94,a:1},q=class extends Error{},E=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),w=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,$=t=>typeof t=="string"?t:void 0,j=t=>typeof t=="boolean"?t:void 0,_=t=>typeof t=="string"?t.toUpperCase():void 0;function ot(t){return Number.isFinite(t)?Math.min(Math.max(t,0),mt):t===1/0?mt:0}function ft(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function Ot(t){if(!E(t))return;let e=w(t.r),n=w(t.g),i=w(t.b);if(!(e===void 0||n===void 0||i===void 0))return{r:e,g:n,b:i,a:w(t.a)??1}}var ue=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 i=_e[n];for(let r of Object.keys(e))i.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=E(e)?e:{};this.fields(n,"style");let i=$(n.fillStyle)??"solid",r=$(n.dash)??"solid";return["solid","hachure","crossHatch","grid"].includes(i)||this.warn(`Unknown fill style "${i}", drawn solid`),["solid","dashed","dotted"].includes(r)||this.warn(`Unknown dash "${r}", drawn solid`),{stroke:Ot(n.stroke)??{...st},fill:Ot(n.fill)??{...Ue},fillStyle:["solid","hachure","crossHatch","grid"].includes(i)?i:"solid",strokeWidth:w(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:w(n.roughness)??1,bowing:w(n.bowing)??1,fontSize:w(n.fontSize)??18,gridSize:w(n.gridSize)??null,opacity:w(n.opacity)??null,dashOffset:w(n.dashOffset)??null}}endpoint(e){let n=E(e)?e:{},i=$(n.port);return{elementID:_(n.elementID)??null,port:i&&["top","right","bottom","left"].includes(i)?i:null,x:w(n.x)??0,y:w(n.y)??0}}connector(e){if(!E(e))return null;this.fields(e,"connector");let n=(r,o)=>{let s=$(r);return s&&["none","arrow","triangle","dot","bar"].includes(s)?s:o},i=$(e.routing);return{start:this.endpoint(e.start),end:this.endpoint(e.end),routing:i&&["straight","curved","elbow"].includes(i)?i:"straight",startHead:n(e.startHead,"none"),endHead:n(e.endHead,"arrow")}}image(e,n){if(!E(e))return null;let i=$(e.ref);if(i!==void 0)return n[i]??{data:"",format:"png"};let r=$(e.data);return r===void 0?null:this.picture(r,$(e.format))}picture(e,n){return ei.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(!E(e))return null;this.fields(e,"element");let i=_(e.id),r=$(e.kind),o=_(e.layerID);if(!i||!r||!o)return this.warn("Skipped an element without an id, kind or layer"),null;je.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let s=Array.isArray(e.subpaths)?e.subpaths.filter(E).map(l=>({closed:j(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:i,kind:r,layerID:o,x:w(e.x)??0,y:w(e.y)??0,width:w(e.width)??0,height:w(e.height)??0,style:this.style(e.style),seed:(w(e.seed)??1)>>>0,text:$(e.text)??null,connector:this.connector(e.connector),groupID:_(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(E).map(l=>({x:w(l.x)??0,y:w(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:s,evenOdd:j(e.evenOdd)??null,rotation:w(e.rotation)??null,link:_(e.link)??null,anchor:$(e.anchor)??null,image:this.image(e.image,n),reveal:w(e.reveal)??null}}ease(e){let n=$(e);return n===void 0?null:ti.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!E(e))return null;this.fields(e,"keyframe");let n=w(e.t);if(n===void 0)return null;let i={t:n};for(let a of["x","y","width","height","rotation","strokeWidth","reveal","opacity"]){let c=w(e[a]);c!==void 0&&(i[a]=c)}let r=Ot(e.stroke),o=Ot(e.fill),s=j(e.visible),l=this.ease(e.ease);return r&&(i.stroke=r),o&&(i.fill=o),s!==void 0&&(i.visible=s),l&&(i.ease=l),i}track(e){if(!E(e))return null;this.fields(e,"track");let n=_(e.element);if(!n)return null;let i=(Array.isArray(e.keys)?e.keys:[]).map(s=>this.keyframe(s)).filter(s=>s!==null&&s.t>=0&&s.t<=mt);zt(i,s=>s.t);let r=Array.isArray(e.follow)?e.follow.filter(E).flatMap(s=>{let l=_(s.path),a=w(s.start),c=w(s.end);return!l||a===void 0||c===void 0||a<0||c>mt?[]:[{path:l,start:a,end:c,ease:this.ease(s.ease),reverse:j(s.reverse)??null,orient:j(s.orient)??null,laps:w(s.laps)??null}]}):null,o=Array.isArray(e.repeats)?e.repeats.filter(E).flatMap(s=>{let l=w(s.start),a=w(s.end);if(l===void 0||a===void 0)return[];let c=w(s.count),u={start:l,end:a,count:c===void 0?null:Math.trunc(c)};return Ct(u)?[u]:[]}):null;return{element:n,keys:i,boil:j(e.boil)??null,follow:r,repeats:o,march:qe(w(e.march))}}timeline(e){if(!E(e))return null;this.fields(e,"timeline");let n=w(e.boil),i=Array.isArray(e.camera)?e.camera.filter(E).flatMap(s=>{let l=w(s.t),a=w(s.x),c=w(s.y),u=w(s.width),d=w(s.height);return l===void 0||a===void 0||c===void 0||u===void 0||d===void 0?[]:u>1&&d>1&&l>=0?[{t:l,x:a,y:c,width:u,height:d,ease:this.ease(s.ease)}]:[]}):null;i&&zt(i,s=>s.t);let r=Array.isArray(e.markers)?e.markers.filter(E).flatMap(s=>{let l=w(s.t);return l!==void 0&&l>=0?[{t:l,name:$(s.name)??""}]:[]}):null;r&&zt(r,s=>s.t);let o=w(e.poster);return{fps:ft(w(e.fps)??12),duration:ot(w(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:j(e.settle)??null,poster:o===void 0?null:ot(o),tracks:(Array.isArray(e.tracks)?e.tracks:[]).map(s=>this.track(s)).filter(s=>s!==null),camera:i,markers:r}}page(e,n,i){if(!E(e))throw new q(`Page ${i} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(E).flatMap(o=>{let s=_(o.id);return s?[{id:s,name:$(o.name)??"",visible:j(o.visible)??!0,locked:j(o.locked)??!1}]:[]});return r.length===0&&(this.warn(`Page ${i} has no layers`),r.push({id:"LAYER",name:"Layer 1",visible:!0,locked:!1})),{id:_(e.id)??`PAGE-${i}`,name:$(e.name)??`Page ${i}`,layers:r,elements:(Array.isArray(e.elements)?e.elements:[]).map(o=>this.element(o,n)).filter(o=>o!==null),theme:$(e.theme)??null,timeline:this.timeline(e.timeline)}}},ei=/^[A-Za-z0-9+/=\s]*$/;function Ct(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=mt&&(t.count===null||t.count>=1&&t.count<=1e4)}function zt(t,e){let n=t.map((i,r)=>[i,r]);n.sort((i,r)=>e(i[0])-e(r[0])||i[1]-r[1]);for(let i=0;i<t.length;i++)t[i]=n[i][0]}function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new q(`Not JSON: ${s.message}`)}if(!E(e))throw new q("Not a Dottie drawing");let n=w(e.version);if(n===void 0)throw new q("Not a Dottie drawing (no version)");if(!Array.isArray(e.pages)||e.pages.length===0)throw new q("A drawing needs at least one page");let i=new ue;i.fields(e,"file"),n>2&&i.warn(`File version ${n} is newer than this player knows (2); some things may not show`);let r={};if(E(e.images))for(let[s,l]of Object.entries(e.images))E(l)&&typeof l.data=="string"&&(r[s]=i.picture(l.data,$(l.format)));let o=e.pages.map((s,l)=>i.page(s,r,l+1));if(new Set(o.map(s=>s.id)).size!==o.length)throw new q("Two pages share an id");return{version:n,pages:o,warnings:i.warnings}}function pt(t){return .2126*t.r+.7152*t.g+.0722*t.b}function dt(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function me(t){return dt(t,st)||dt(t,Ke)}function B(t){return{...t,style:{...t.style,stroke:{...t.style.stroke},fill:{...t.style.fill}},connector:t.connector?{...t.connector,start:{...t.connector.start},end:{...t.connector.end}}:null}}function At(t){if(t.layers.length<=1)return t.elements;let e=new Map;t.layers.forEach((i,r)=>{e.has(i.id)||e.set(i.id,r)});let n=t.layers.map(()=>[]);for(let i of t.elements)n[e.get(i.layerID)??0].push(i);return n.flat()}function ni(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}var Xe=.5522847498307936,R=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,i){return this.segments.push({op:"C",c1:n,c2:i,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,i)=>i===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,i=e.y+e.height/2,r=e.width/2,o=e.height/2,s=r*Xe,l=o*Xe;return this.moveTo({x:n+r,y:i}),this.curveTo({x:n,y:i+o},{x:n+r,y:i+l},{x:n+s,y:i+o}),this.curveTo({x:n-r,y:i},{x:n-s,y:i+o},{x:n-r,y:i+l}),this.curveTo({x:n,y:i-o},{x:n-r,y:i-l},{x:n-s,y:i-o}),this.curveTo({x:n+r,y:i},{x:n+s,y:i-o},{x:n+r,y:i-l}),this.close()}static ellipse(e){return new t().addEllipse(e)}translated(e,n){let i=o=>({x:o.x+e,y:o.y+n}),r=new t;return r.segments=this.segments.map(o=>{switch(o.op){case"M":case"L":return{op:o.op,p:i(o.p)};case"Q":return{op:"Q",c:i(o.c),p:i(o.p)};case"C":return{op:"C",c1:i(o.c1),c2:i(o.c2),p:i(o.p)};case"Z":return o}}),r}contours(){let e=[],n=[],i={x:0,y:0};for(let r of this.segments){let o=n.length?n[n.length-1]:i;switch(r.op){case"M":n.length>1&&e.push(n),i=r.p,n=[r.p];break;case"L":n.push(r.p);break;case"Q":for(let s=1;s<=12;s++){let l=s/12,a=1-l;n.push({x:a*a*o.x+2*a*l*r.c.x+l*l*r.p.x,y:a*a*o.y+2*a*l*r.c.y+l*l*r.p.y})}break;case"C":for(let s=1;s<=16;s++){let l=s/16,a=1-l;n.push({x:a*a*a*o.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*o.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(i),n.length>1&&e.push(n),n=[i];break}}return n.length>1&&e.push(n),e}trimmed(e){let n=this.contours().map(o=>new yt(o)),i=Math.min(Math.max(e,0),1)*n.reduce((o,s)=>o+s.length,0),r=new t;for(let o of n){if(!(i>0))break;r.moveTo(o.points[0]);for(let s=1;s<o.points.length;s++){let l=o.lengths[s]-o.lengths[s-1];if(l<=i){r.lineTo(o.points[s]),i-=l;continue}let a=o.points[s-1],c=o.points[s],u=i/l;r.lineTo({x:a.x+(c.x-a.x)*u,y:a.y+(c.y-a.y)*u}),i=0;break}}return r}data(){let e=[];for(let n of this.segments)switch(n.op){case"M":e.push(`M${y(n.p.x)} ${y(n.p.y)}`);break;case"L":e.push(`L${y(n.p.x)} ${y(n.p.y)}`);break;case"Q":e.push(`Q${y(n.c.x)} ${y(n.c.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"C":e.push(`C${y(n.c1.x)} ${y(n.c1.y)} ${y(n.c2.x)} ${y(n.c2.y)} ${y(n.p.x)} ${y(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function Tt(t){return t<0?-Math.round(-t):Math.round(t)}function y(t){let e=Tt(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var yt=class{constructor(e){k(this,"points");k(this,"lengths");this.points=e;let n=0;this.lengths=e.map((i,r)=>(r>0&&(n+=Math.hypot(i.x-e[r-1].x,i.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,i=1;for(;i<this.lengths.length-1&&this.lengths[i]<n;)i++;let r=this.lengths[i]-this.lengths[i-1],o=r>0?(n-this.lengths[i-1])/r:0,s=this.points[i-1],l=this.points[i];return{x:s.x+(l.x-s.x)*o,y:s.y+(l.y-s.y)*o}}},z=t=>t.x+t.width/2,C=t=>t.y+t.height/2,Y=t=>t.x+t.width,O=t=>t.y+t.height;function de(t,e){if(!t)return{...e};let n=Math.min(t.x,e.x),i=Math.min(t.y,e.y);return{x:n,y:i,width:Math.max(Y(t),Y(e))-n,height:Math.max(O(t),O(e))-i}}function gt(t,e,n){return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}function fe(t,e,n){if(n===0)return t;let i=t.x-e.x,r=t.y-e.y;return{x:e.x+i*Math.cos(n)-r*Math.sin(n),y:e.y+i*Math.sin(n)+r*Math.cos(n)}}function ii(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)}}function Qe(t,e){let n=[t[0]];for(let i=0;i<Math.floor((t.length-1)/3);i++){let r=t.slice(3*i,3*i+4),o=0;for(let l=1;l<r.length;l++)o+=Math.hypot(r[l].x-r[l-1].x,r[l].y-r[l-1].y);let s=Math.min(400,Math.max(4,Math.ceil(o/Math.max(e,.5))));for(let l=1;l<=s;l++)n.push(ii(r,l/s))}return n}var L=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),F=t=>t.rotation??0,vt=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Q=(t,e)=>fe(e,vt(t),F(t)),Ze=(t,e)=>fe(e,vt(t),-F(t));function Je(t){let e=L(t);if(F(t)===0)return e;let n=[{x:e.x,y:e.y},{x:Y(e),y:e.y},{x:Y(e),y:O(e)},{x:e.x,y:O(e)}].map(l=>Q(t,l)),i=n.map(l=>l.x),r=n.map(l=>l.y),o=Math.min(...i),s=Math.min(...r);return{x:o,y:s,width:Math.max(...i)-o,height:Math.max(...r)-s}}function tn(t,e){if(!me(t.style.stroke))return t;let n=B(t),r=(t.style.fillStyle==="solid"||t.style.fillStyle==="grid")&&t.style.fill.a>=.5&&pt(t.style.fill)>.5;return n.style.stroke=pt(e)>.5&&r?{...st}:{...e},n}function Gt(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 i=[];for(let r=0;r<n.coords.length;r+=2)i.push({x:t.x+n.coords[r]*t.width,y:t.y+n.coords[r+1]*t.height});e.push({closed:n.closed,points:i})}return e}function pe(t){let e=new R;for(let n of Gt(t)){e.moveTo(n.points[0]);for(let i=0;i<(n.points.length-1)/3;i++)e.curveTo(n.points[3*i+3],n.points[3*i+1],n.points[3*i+2]);n.closed&&e.close()}return e}function ri(t,e){let n=L(t),i=e==="top"?{x:z(n),y:n.y}:e==="right"?{x:Y(n),y:C(n)}:e==="bottom"?{x:z(n),y:O(n)}:{x:n.x,y:C(n)};return Q(t,i)}function oi(t,e){let n=L(t),i=vt(t),r=Ze(t,e),o=r.x-i.x,s=r.y-i.y;if(!((o!==0||s!==0)&&n.width>0&&n.height>0))return i;let l=n.width/2,a=n.height/2,c;return t.kind==="ellipse"?c=1/Math.sqrt(o*o/(l*l)+s*s/(a*a)):t.kind==="diamond"?c=1/(Math.abs(o)/l+Math.abs(s)/a):c=Math.min(o!==0?l/Math.abs(o):1/0,s!==0?a/Math.abs(s):1/0),Q(t,{x:i.x+o*c,y:i.y+s*c})}function en(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?vt(n):{x:t.x,y:t.y}}function nn(t,e,n){let i=t.elementID?n.get(t.elementID):void 0;return i?t.port?ri(i,t.port):oi(i,e):{x:t.x,y:t.y}}function lt(t,e){let n=t.connector;return n?[nn(n.start,en(n.end,e),e),nn(n.end,en(n.start,e),e)]:[{x:0,y:0},{x:0,y:0}]}function Z(t){if(t.kind==="polyline")return t.points;let e=[];for(let n=0;n<=24;n++){let i=n/24,r=1-i;e.push({x:r*r*r*t.a.x+3*r*r*i*t.b.x+3*r*i*i*t.c.x+i*i*i*t.d.x,y:r*r*r*t.a.y+3*r*r*i*t.b.y+3*r*i*i*t.c.y+i*i*i*t.d.y})}return e}function J(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[i,r]=lt(t,e),o=r.x-i.x,s=r.y-i.y,l=Math.abs(o)>=Math.abs(s);switch(n.routing){case"straight":return{kind:"polyline",points:[i,r]};case"curved":return l?{kind:"cubic",a:i,b:{x:i.x+o/2,y:i.y},c:{x:r.x-o/2,y:r.y},d:r}:{kind:"cubic",a:i,b:{x:i.x,y:i.y+s/2},c:{x:r.x,y:r.y-s/2},d:r};case"elbow":{let a=d=>d===null?null:d==="top"||d==="bottom",c=a(n.start.port)??!l,u=a(n.end.port)??!l;if(c&&u){let d=i.y+s/2;return{kind:"polyline",points:[i,{x:i.x,y:d},{x:r.x,y:d},r]}}if(!c&&!u){let d=i.x+o/2;return{kind:"polyline",points:[i,{x:d,y:i.y},{x:d,y:r.y},r]}}return c?{kind:"polyline",points:[i,{x:i.x,y:r.y},r]}:{kind:"polyline",points:[i,{x:r.x,y:i.y},r]}}}}function rn(t,e,n){let i=Math.atan2(t.y-e.y,t.x-e.x),r=Math.PI/7,o=s=>({x:t.x-n*Math.cos(i+s),y:t.y-n*Math.sin(i+s)});return[o(r),o(-r)]}function on(t,e){let n=Z(J(t,e));if(n.length===0)return{x:0,y:0,width:0,height:0};let i=n[0].x,r=n[0].y,o=i,s=r;for(let l of n)i=Math.min(i,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),s=Math.max(s,l.y);return{x:i,y:r,width:o-i,height:s-r}}function sn(t,e){let n=Z(J(t,e));if(n.length<=1)return n[0]??{x:0,y:0};let i=[],r=0;for(let s=0;s<n.length-1;s++){let l=Math.hypot(n[s+1].x-n[s].x,n[s+1].y-n[s].y);i.push(l),r+=l}let o=r/2;for(let s=0;s<i.length;s++){let l=i[s];if(o<=l||s===i.length-1){let a=l===0?0:o/l;return{x:n[s].x+(n[s+1].x-n[s].x)*a,y:n[s].y+(n[s+1].y-n[s].y)*a}}o-=l}return n[0]}function tt(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}function ge(t,e,n){let i=t[1]+n>>>0,r=i<t[1]?1:0;return[t[0]+e+r>>>0,i]}function si(t,e){let n=t&65535,i=t>>>16,r=e&65535,o=e>>>16,s=n*r,l=n*o,a=i*r,c=i*o,u=l+a,d=s+u%65536*65536;return[c+Math.floor(u/65536)+Math.floor(d/4294967296)>>>0,d>>>0]}function xe(t,e,n){let i=si(t[1],n);return[i[0]+Math.imul(t[0],n)+Math.imul(t[1],e)>>>0,i[1]]}function ye(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function ln(t){return t=xe(ye(t,30),3210233709,484763065),t=xe(ye(t,27),2496678331,321982955),ye(t,31)}var et=class{constructor(e){k(this,"state");this.state=ge([0,e>>>0],2654435769,2135587861)}next(){return this.state=ge(this.state,2654435769,2135587861),ln(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}};function an(t,e){let n=ge([0,t>>>0],...li(e));return n=ln(n),Math.max(1,n[1]>>>0)}function li(t){let e=xe([0,t>>>0],2654435769,2135587861);return[e[0],e[1]]}var cn=(t,e,n)=>t.signed()*e*n;function U(t,e,n,i,r,o,s){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 d=(u===0?1:.5)*a,f=()=>cn(n,c,i)*d,m=n.unit()*.4+.3,h=cn(n,l/60,i)*r*a,p=e.x-t.x,x=e.y-t.y,M=-x/l,b=p/l,g=o?t:{x:t.x+f(),y:t.y+f()},A=o?e:{x:e.x+f(),y:e.y+f()},v=t.x+p*m*.66+M*h+f()*.5,S=t.y+x*m*.66+b*h+f()*.5,P=t.x+p*(.5+m*.5)+M*h+f()*.5,I=t.y+x*(.5+m*.5)+b*h+f()*.5;s.moveTo(g),s.curveTo(A,{x:v,y:S},{x:P,y:I})}}function be(t,e,n,i){let r=new R;for(let o=0;o<t.length;o++)U(t[o],t[(o+1)%t.length],e,n,i,!1,r);return r}function un(t,e,n){let i=new R,r=t.x+t.width/2,o=t.y+t.height/2,s=t.width/2,l=t.height/2;if(!(s>.5&&l>.5))return i;let a=Math.max(8,Math.min(24,Math.trunc((s+l)/6))),c=Math.min(2.5,(s+l)/25)*n;for(let u=0;u<2;u++){let d=e.unit()*2*Math.PI,f=2*Math.PI*(u===0?1:1.04),m=Math.trunc(a*f/(2*Math.PI))+1,h=[];for(let p=0;p<m;p++){let x=d+f*p/a,M=e.signed()*c,b=e.signed()*c;h.push({x:r+s*Math.cos(x)+M,y:o+l*Math.sin(x)+b})}ai(h,i)}return i}function ai(t,e){if(!(t.length<=2)){e.moveTo(t[0]);for(let n=0;n<t.length-1;n++){let i=t[Math.max(n-1,0)],r=t[n],o=t[n+1],s=t[Math.min(n+2,t.length-1)];e.curveTo(o,{x:r.x+(o.x-i.x)/6,y:r.y+(o.y-i.y)/6},{x:o.x-(s.x-r.x)/6,y:o.y-(s.y-r.y)/6})}}}var ke=-41*Math.PI/180;function hn(t,e,n){if(!(n>0))return[];let i=Math.cos(e),r=Math.sin(e),o=t.filter(f=>f.length>=3).map(f=>f.map(m=>({x:m.x*i+m.y*r,y:-m.x*r+m.y*i}))),s=o.flat();if(s.length===0)return[];let l=1/0,a=-1/0;for(let f of s)l=Math.min(l,f.y),a=Math.max(a,f.y);let c=(f,m)=>({x:f*i-m*r,y:f*r+m*i}),u=[],d=l+n/2;for(;d<a;){let f=[];for(let m of o)for(let h=0;h<m.length;h++){let p=m[h],x=m[(h+1)%m.length];(p.y<=d&&d<x.y||x.y<=d&&d<p.y)&&f.push(p.x+(d-p.y)/(x.y-p.y)*(x.x-p.x))}f.sort((m,h)=>m-h);for(let m=0;m+1<f.length;m+=2)f[m+1]-f[m]>.5&&u.push([c(f[m],d),c(f[m+1],d)]);d+=n}return u}var Bt=class{constructor(e=6e3){k(this,"map",new Map);k(this,"limit");this.limit=e}get(e,n){let i=this.map.get(e);if(i!==void 0)return i;let r=n();return this.map.size>=this.limit&&this.map.clear(),this.map.set(e,r),r}},fn=new Bt,ci=new Bt;function pn(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"?at(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var at=t=>Math.max(8,t.style.gridSize??50);function ct(t){return t.kind==="freehand"&&t.path===null?dn(t):fn.get(pn(t,0),()=>dn(t))}function yn(t){return[{x:t.x,y:t.y},{x:Y(t),y:t.y},{x:Y(t),y:O(t)},{x:t.x,y:O(t)}]}function Ft(t){return[{x:z(t),y:t.y},{x:Y(t),y:C(t)},{x:z(t),y:O(t)},{x:t.x,y:C(t)}]}function dn(t){let e=L(t),n=new et(t.seed),i=t.style.roughness;switch(t.kind){case"ellipse":return i<=0?R.ellipse(e):un(e,n,i);case"diamond":return i<=0?new R().addLines(Ft(e)).close():be(Ft(e),n,i,t.style.bowing);case"text":case"connector":return R.rect(e);case"freehand":return hi(t);case"path":return i<=0?pe(t):ui(t,n);default:return i<=0?R.rect(e):be(yn(e),n,i,t.style.bowing)}}function ui(t,e){let n=t.style.roughness,i=new R;for(let r of Gt(t)){let o=r.points;for(let s=0;s<(o.length-1)/3;s++){let l=o[3*s],a=o[3*s+1],c=o[3*s+2],u=o[3*s+3];if(a.x===l.x&&a.y===l.y&&c.x===u.x&&c.y===u.y){U(l,u,e,n,t.style.bowing,!0,i);continue}let d=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,d/30)*n;for(let m=0;m<2;m++){let h=m===0?1:.5,p=()=>e.signed()*f*h;i.moveTo(l);let x=a.x+p(),M=a.y+p(),b=c.x+p(),g=c.y+p();i.curveTo(u,{x,y:M},{x:b,y:g})}}}return i}function hi(t){let e=L(t),n=t.path;if(n&&n.length>=8&&(n.length-2)%6===0){let o=l=>({x:e.x+n[2*l]*e.width,y:e.y+n[2*l+1]*e.height}),s=new R().moveTo(o(0));for(let l=0;l<Math.floor((n.length/2-1)/3);l++)s.curveTo(o(3*l+3),o(3*l+1),o(3*l+2));return s}let i=(t.points??[]).map(o=>({x:e.x+o.x*e.width,y:e.y+o.y*e.height})),r=new R;if(i.length===0)return r;if(r.moveTo(i[0]),i.length===1)return r.lineTo(i[0]);if(i.length===2)return r.lineTo(i[1]);for(let o=1;o<i.length-1;o++)r.quadTo({x:(i[o].x+i[o+1].x)/2,y:(i[o].y+i[o+1].y)/2},i[o]);return r.lineTo(i[i.length-1])}function we(t){return t.kind!=="path"?[mi(t)]:Gt(t).map(e=>Qe(e.points,3))}function mi(t){let e=L(t);if(t.kind==="ellipse"){let n=[];for(let i=0;i<48;i++){let r=2*Math.PI*i/48;n.push({x:z(e)+e.width/2*Math.cos(r),y:C(e)+e.height/2*Math.sin(r)})}return n}return t.kind==="diamond"?Ft(e):yn(e)}function Nt(t){let e=L(t);return t.kind==="ellipse"?R.ellipse(e):t.kind==="path"?pe(t):t.kind==="diamond"?new R().addLines(Ft(e)).close():R.rect(e)}function Pe(t){return t.style.fillStyle==="solid"||["freehand","connector","text","image"].includes(t.kind)?new R:fn.get(pn(t,1),()=>di(t))}function di(t){let e=we(t),n=new et((t.seed^1540483477)>>>0),i=new R;if(t.style.fillStyle==="grid"){for(let[s,l]of gn(e,at(t)))t.style.roughness<=0?i.moveTo(s).lineTo(l):U(s,l,n,t.style.roughness*.3,.3,!1,i);return i}let r=Math.max(4,t.style.strokeWidth*4),o=[ke];t.style.fillStyle==="crossHatch"&&o.push(ke+Math.PI/2);for(let s of o)for(let[l,a]of hn(e,s,r))t.style.roughness<=0?i.moveTo(l).lineTo(a):U(l,a,n,t.style.roughness*.6,.5,!1,i);return i}function Ht(t,e){switch(t){case"solid":return null;case"dashed":return[Math.max(8,e*4),Math.max(6,e*3)];case"dotted":return[.01,Math.max(5,e*2.6)]}}function Me(t,e){let n=t.connector;if(!n)return[new R,new R];let[i,r]=lt(t,e),o=[t.seed,t.style.roughness,t.style.bowing,t.style.strokeWidth,n.routing,n.startHead,n.endHead,n.start.port,n.end.port,i.x,i.y,r.x,r.y].join("|");return ci.get(o,()=>fi(t,e))}function fi(t,e){let n=t.connector,i=new et(t.seed),r=t.style.roughness,o=t.style.bowing,s=new R,l=new R,a=J(t,e);if(a.kind==="polyline"){let m=a.points;for(let h=0;h<Math.max(m.length-1,0);h++)r<=0?s.moveTo(m[h]).lineTo(m[h+1]):U(m[h],m[h+1],i,r,o,!0,s)}else{s.moveTo(a.a);let m=r*3,h=()=>i.signed()*m,p=a.b.x+h(),x=a.b.y+h(),M=a.c.x+h(),b=a.c.y+h();s.curveTo(a.d,{x:p,y:x},{x:M,y:b})}let c=Z(a),u=Math.max(10,t.style.strokeWidth*5),d=(m,h)=>{r<=0?s.moveTo(m).lineTo(h):U(m,h,i,r*.5,0,!0,s)},f=(m,h,p)=>{let[x,M]=rn(h,p,u);switch(m){case"arrow":d(x,h),d(M,h);break;case"triangle":d(x,h),d(M,h),d(x,M),l.moveTo(h).lineTo(x).lineTo(M).close();break;case"dot":{let b=u*.32,g=Math.atan2(h.y-p.y,h.x-p.x),A=h.x-b*Math.cos(g),v=h.y-b*Math.sin(g);l.addEllipse({x:A-b,y:v-b,width:2*b,height:2*b});break}case"bar":{let b=Math.atan2(h.y-p.y,h.x-p.x)+Math.PI/2,g=u*.5;d({x:h.x-g*Math.cos(b),y:h.y-g*Math.sin(b)},{x:h.x+g*Math.cos(b),y:h.y+g*Math.sin(b)});break}}};return c.length>1&&(f(n.endHead,c[c.length-1],c[c.length-2]),f(n.startHead,c[0],c[1])),[s,l]}var kn=2,Re=.75,pi=.8,xn=.6;function gn(t,e){return[...bn(t,e,!1),...bn(t,e,!0)]}function bn(t,e,n){if(!(e>0))return[];let i=c=>n?{x:c.y,y:c.x}:c,r=t.filter(c=>c.length>=3).map(c=>c.map(i)),o=r.flat().map(c=>c.y);if(o.length===0)return[];let s=Math.min(...o),l=Math.max(...o),a=[];for(let c=Math.floor(s/e)*e;c<l-.5;c+=e){if(!(c>s+.5))continue;let u=[];for(let d of r)for(let f=0;f<d.length;f++){let m=d[f],h=d[(f+1)%d.length];(m.y<=c&&c<h.y||h.y<=c&&c<m.y)&&u.push(m.x+(c-m.y)/(h.y-m.y)*(h.x-m.x))}u.sort((d,f)=>d-f);for(let d=0;d+1<u.length;d+=2)u[d+1]-u[d]>.5&&a.push([i({x:u[d],y:c}),i({x:u[d+1],y:c})])}return a}function wn(t){return .2126*t.r+.7152*t.g+.0722*t.b>.5?{r:t.r*.84,g:t.g*.84,b:t.b*.8,a:t.a}:{r:t.r+(1-t.r)*.25,g:t.g+(1-t.g)*.25,b:t.b+(1-t.b)*.25,a:t.a}}function Ae(t){return t.style.fillStyle==="grid"&&t.style.fill.a>0&&["rectangle","ellipse","diamond","path"].includes(t.kind)}function _t(t,e,n){let i=(Math.imul(t,668265261)^Math.imul(e,374761393)^Math.imul(n,2654435761))>>>0;return i=Math.imul(i^i>>>15,2246822507)>>>0,i=Math.imul(i^i>>>13,3266489909)>>>0,i=(i^i>>>16)>>>0,i/4294967296}function Pn(t,e,n){let i=n/kn;return{x:(t+.5+(_t(t,e,1)-.5)*xn)*i,y:(e+.5+(_t(t,e,2)-.5)*xn)*i}}function yi(t,e,n,i){let r=1/0;for(let o=-1;o<=1;o++)for(let s=-1;s<=1;s++){if(o===0&&s===0)continue;let l=Pn(t+o,e+s,i);r=Math.min(r,Math.hypot(l.x-n.x,l.y-n.y))}return r*pi}function gi(t,e,n){let i=Math.cos(e),r=Math.sin(e),o=n*.8,s=n*.5;return[-1,0,1].map(l=>{let a=t.x-r*s*l,c=t.y+i*s*l;return[{x:a-i*o,y:c-r*o},{x:a+i*o,y:c+r*o}]})}function xi(t,e){let n=!1;for(let i of t){if(i.length<3)continue;let r=i.length-1;for(let o=0;o<i.length;o++){let s=i[o],l=i[r];s.y>e.y!=l.y>e.y&&e.x<(l.x-s.x)*(e.y-s.y)/(l.y-s.y)+s.x&&(n=!n),r=o}}return n}function bi(t,e){let n=1/0;for(let i of e)if(!(i.length<2))for(let r=0;r<i.length;r++){let o=i[r],s=i[(r+1)%i.length],l=s.x-o.x,a=s.y-o.y,c=l*l+a*a,u=c>0?Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*a)/c)):0;n=Math.min(n,Math.hypot(t.x-(o.x+u*l),t.y-(o.y+u*a)))}return n}var ki=(t,e)=>e.x>=t.x&&e.x<t.x+t.width&&e.y>=t.y&&e.y<t.y+t.height,jt=new Map;function Mn(t){if(t.length===0)return[];let e=t.map(r=>[r.kind,r.x,r.y,r.width,r.height,r.rotation??0,at(r),JSON.stringify(r.subpaths??null),r.style.stroke.r,r.style.stroke.g,r.style.stroke.b,r.style.stroke.a,r.style.roughness,r.style.strokeWidth].join(",")).join(";"),n=jt.get(e);if(n)return n;let i=wi(t);return jt.size>=16&&jt.clear(),jt.set(e,i),i}function wi(t){let e=t.map(o=>{let s=we(o).map(m=>m.map(h=>Q(o,h))),l=s.flat(),a=l.map(m=>m.x),c=l.map(m=>m.y),u=a.length?Math.min(...a):0,d=c.length?Math.min(...c):0,f={x:u,y:d,width:(a.length?Math.max(...a):0)-u,height:(c.length?Math.max(...c):0)-d};return{contours:s,box:f,cell:at(o),element:o}}),n=e.map(()=>[]),i=new Set;for(let o of e){let s=o.cell/kn,l=gt(o.box,-o.cell,-o.cell),a=Math.floor(l.x/s),c=Math.ceil((l.x+l.width)/s),u=Math.floor(l.y/s),d=Math.ceil((l.y+l.height)/s),f=Re*o.cell;for(let m=a;m<c;m++)for(let h=u;h<d;h++){let p=`${o.cell}|${m}|${h}`;if(i.has(p))continue;i.add(p);let x=Pn(m,h,o.cell),M=1/0,b=-1;for(let S=0;S<e.length;S++){let P=e[S];if(!ki(gt(P.box,-f,-f),x))continue;if(xi(P.contours,x)){M=0;break}let I=bi(x,P.contours);I<M&&(M=I,b=S)}if(!(M>0&&M<=f&&b>=0))continue;let g=_t(m,h,3)*Math.PI,A=yi(m,h,x,o.cell),v=Math.trunc(_t(m,h,4)*4294967296)>>>0;for(let[S,P]of gi(x,g,A))n[b].push([S,P,v])}}let r=[];return e.forEach((o,s)=>{if(n[s].length===0)return;let l=o.element,a=new R;for(let[c,u,d]of n[s])l.style.roughness<=0?a.moveTo(c).lineTo(u):U(c,u,new et(d),l.style.roughness*.35,.2,!1,a);r.push({ink:{...l.style.stroke,a:l.style.stroke.a*.6},width:Math.max(.8,l.style.strokeWidth*.45),path:a})}),r}var qt=.951995849609375,Ut=.2129974365234375,Kt=.0279998779296875,Rn=.975006103515625,An=.2169952392578125,Tn=.0290069580078125,vn=.957000732421875,En=.2129974365234375,Sn=.0279998779296875,In=.975006103515625,$n=.2169952392578125,Ln=.0290069580078125,Vn=.60205078125,Dn=.92822265625,Wn=.23583984375,xt={bold:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-30,fi:20,fl:20,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":278,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':463,"\u201C":463,"\u201D":463,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":371,"\\":371,"&":685,"#":556,"%":1e3,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":223,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:704,c:574,C:741,d:611,D:741,e:574,E:648,\u00E9:574,f:333,F:593,g:611,G:759,h:593,H:741,i:258,I:295,j:278,J:556,k:574,K:722,l:258,L:593,m:906,M:907,n:593,N:741,o:611,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:537,S:649,t:352,T:611,u:593,U:741,v:520,V:630,w:814,W:944,x:537,X:667,y:519,Y:667,z:519,Z:648}},boldItalic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-68,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":407,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":296,"?":574,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':481,"\u201C":481,"\u201D":481,"(":296,")":296,"[":333,"]":333,"{":333,"}":333,"@":800,"*":407,"/":389,"\\":389,"&":685,"#":556,"%":963,"\u2022":350,"`":259,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":722.66,"\u2193":722.66,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":608.4,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:574,A:685,b:611,B:722,c:556,C:741,d:611,D:741,e:574,E:667,\u00E9:574,f:352,F:593,g:611,G:759,h:611,H:741,i:259,I:296,j:259,J:556,k:556,K:722,l:259,L:574,m:907,M:907,n:611,N:741,o:593,O:778,p:611,P:667,q:611,Q:778,r:389,R:722,s:519,S:648,t:370,T:611,u:611,U:741,v:519,V:630,w:815,W:944,x:519,X:667,y:519,Y:648,z:500,Z:648}},italic:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,fi:1,fl:1,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":926,"\u2022":500,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:519,A:667,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:481,K:667,l:222,L:556,m:852,M:870,n:556,N:722,o:574,O:759,p:593,P:648,q:593,Q:759,r:333,R:685,s:481,S:648,t:315,T:574,u:556,U:722,v:481,V:611,w:759,W:926,x:481,X:611,y:481,Y:611,z:444,Z:611}},regular:{k:{"\u2018\u2018":-95,"\u2019\u2019":-95,"\u2019s":-74,"\u2019t":-18,"A\u2019":-74,AT:-92,Av:-18,AV:-46,Aw:-18,AW:-24,Ay:-18,AY:-74,"F,":-157,"F.":-157,"f\u2019":18,FA:-55,ff:-15,"L\u2019":-74,LT:-92,LV:-92,LW:-55,Ly:-37,LY:-111,"P,":-179,"P.":-179,PA:-74,"r-":-55,"r,":-92,"r.":-92,rc:-18,rd:-18,re:-18,rg:-28,rn:18,ro:-18,rq:-18,RT:-18,RV:-18,RW:-18,RY:-37,"T-":-129,"T,":-111,"T;":-111,"T:":-111,"T.":-111,Ta:-111,TA:-92,Tc:-111,Te:-111,To:-111,Tr:-92,Ts:-111,Tu:-92,Tw:-111,Ty:-111,"V-":-55,"v,":-74,"V,":-129,"V;":-46,"V:":-46,"v.":-74,"V.":-129,Va:-55,VA:-46,Ve:-55,Vi:-18,Vo:-55,Vr:-37,Vu:-37,Vy:-18,"w,":-55,"W,":-74,"W;":-18,"W:":-18,"w.":-55,"W.":-74,Wa:-37,WA:-24,We:-57,Wo:-57,Wr:-18,Wu:-18,"Y-":-111,"y,":-74,"Y,":-139,"Y;":-92,"Y:":-92,"y.":-74,"Y.":-139,Ya:-92,YA:-74,Ye:-111,Yi:-37,Yo:-111,Yp:-74,Yq:-92,Yu:-74,Yv:-55},w:{" ":278,_:500,"-":389,"\u2013":500,"\u2014":1e3,",":278,";":278,":":278,"!":259,"?":556,".":278,"\u2026":1e3,"\xB7":278,"'":278,"\u2018":278,"\u2019":278,'"':426,"\u201C":426,"\u201D":426,"(":259,")":259,"[":259,"]":259,"{":333,"}":333,"@":800,"*":352,"/":333,"\\":333,"&":630,"#":556,"%":1e3,"\u2022":350,"`":222,"^":600,"\u2190":1e3,"\u2192":1e3,"\u2191":645.02,"\u2193":645.02,"+":600,"\xD7":600,"<":600,"=":600,">":600,"|":222,"~":600,"\u25E6":578.13,"\u2610":830.08,"\u2611":830.08,"\u2713":764.16,$:556,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,a:537,A:648,b:593,B:685,c:537,C:722,d:593,D:704,e:537,E:611,\u00E9:537,f:296,F:574,g:574,G:759,h:556,H:722,i:222,I:259,j:222,J:519,k:519,K:667,l:222,L:556,m:853,M:871,n:556,N:722,o:574,O:760,p:593,P:648,q:593,Q:760,r:333,R:685,s:500,S:648,t:315,T:574,u:556,U:722,v:500,V:611,w:758,W:926,x:518,X:611,y:500,Y:648,z:480,Z:611}}},Xt={"\u2190":[.966796875,.2109375,0],"\u2192":[.966796875,.2109375,0],"\u2191":[.966796875,.2109375,0],"\u2193":[.966796875,.2109375,0],"\u25E6":[.966796875,.2109375,0],"\u2610":[.66650390625,.25,.08349609375],"\u2611":[.66650390625,.25,.08349609375],"\u2713":[.966796875,.2109375,0]};function V(t){let e=n=>Math.round(Math.min(Math.max(n,0),1)*255).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}function Qt(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Zt(t,e,n="regular"){let i=xt[n],r=i.w.n,o=0,s="";for(let l of t)o+=i.w[l]??r,s&&(o+=i.k[s+l]??0),s=l;return o*e/1e3}function Pi(t){let e=Math.round(qt*t),n=Math.round(Ut*t),i=Math.round(Kt*t);return[e+n,e+n+i]}function Te(t,e){return t===" "?!0:(t==="/"||t==="-")&&e!==""&&!/[\d\s/-]/.test(e)}function Mi(t){let e=[...t],n=[],i="";return e.forEach((r,o)=>{i+=r;let s=e[o+1]??"";Te(r,s)&&s!==" "&&(n.push(i),i="")}),(i||n.length===0)&&n.push(i),n}function Ri(t,e,n,i="regular"){let r=[];for(let o of t.split(/\r\n|\n|\r|\u2028|\u2029/)){let s="";for(let l of Mi(o)){let a=s+l;for(s===""||Zt(a.trimEnd(),e,i)<=n?s=a:(r.push(s),s=l);Zt(s.trimEnd(),e,i)>n&&[...s.trimEnd()].length>1;){let c=[...s],u=c.length-1;for(;u>1&&Zt(c.slice(0,u).join(""),e,i)>n;)u--;r.push(c.slice(0,u).join("")),s=c.slice(u).join("")}}r.push(s)}return r}function Yn(t,e,n){if(t==="")return{width:0,height:0};let i=Ri(t,e,n),r=Math.max(...i.map(l=>Zt(l.trimEnd(),e))),[o,s]=Pi(e);return{width:Math.ceil(r-1e-9),height:Math.ceil(o+s*(i.length-1)-1e-9)}}var On=12,ut="\u2028";function Ai(t){let e=Math.min(On,t.width/2),n=Math.min(On,t.height/2);return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}var Ee=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,Bn=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,Se=/^ {0,3}(`{3,}|~{3,})/,Et=/^( *)([-*+]|\d{1,9}[.)])([ \t]+|$)(.*)$/,Jt=/^ {0,3}> ?(.*)$/,Ti=/^ *\|? *:?-+:? *(\| *:?-+:? *)*\|? *$/;function ve(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1)),e.split(/(?<!\\)\|/).map(n=>n.trim())}function vi(t){return Ve(t.replace(/\r\n?/g,`
|
|
3
3
|
`).split(`
|
|
4
|
-
`))}function
|
|
5
|
-
`))}),i=null)};for(;n<t.length;){let o=t[n];if(o.trim()===""){r(),n++;continue}let s=
|
|
6
|
-
`)});continue}let l=
|
|
7
|
-
`))}),i=null,n++;continue}if(
|
|
8
|
-
`)){for(o+=
|
|
9
|
-
`){for(o=o.replace(/ +$/,""),o+=
|
|
10
|
-
`,size:i,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1}]:l.runs,u=[];c.forEach((
|
|
11
|
-
`){p.push({ch:P,run
|
|
12
|
-
`&&u[
|
|
13
|
-
`,"").replaceAll(
|
|
14
|
-
`)}let a=y(Math.max(1,e.style.fontSize/14));for(let[c,u,
|
|
15
|
-
`;return s}function
|
|
4
|
+
`))}function Ve(t){let e=[],n=0,i=null,r=()=>{i&&(e.push({kind:"paragraph",inline:N(i.join(`
|
|
5
|
+
`))}),i=null)};for(;n<t.length;){let o=t[n];if(o.trim()===""){r(),n++;continue}let s=Se.exec(o);if(s){r();let c=new RegExp(`^ {0,3}${s[1][0]==="`"?"`":"~"}{${s[1].length},}[ \\t]*$`),u=[];for(n++;n<t.length&&!c.test(t[n]);)u.push(t[n++]);n++,e.push({kind:"code",text:u.join(`
|
|
6
|
+
`)});continue}let l=Ee.exec(o);if(l){r(),e.push({kind:"heading",level:l[1].length,inline:N(l[2]??"")}),n++;continue}if(i&&/^ {0,3}(=+|-+)[ \t]*$/.test(o)){let c=o.trim()[0]==="="?1:2;e.push({kind:"heading",level:c,inline:N(i.join(`
|
|
7
|
+
`))}),i=null,n++;continue}if(Bn.test(o)){r(),e.push({kind:"rule"}),n++;continue}if(Jt.test(o)){r();let c=[];for(;n<t.length&&t[n].trim()!=="";){let u=Jt.exec(t[n]);c.push(u?u[1]:t[n]),n++}e.push({kind:"quote",children:Ve(c)});continue}let a=Et.exec(o);if(a&&(!i||a[4].trim()!=="")){r();let c=Ei(t,n);e.push(c.block),n=c.next;continue}if(!i&&o.includes("|")&&n+1<t.length&&Ti.test(t[n+1])&&t[n+1].includes("-")){let c=ve(o),u=ve(t[n+1]).map(f=>f.startsWith(":")&&f.endsWith(":")?"center":f.endsWith(":")?"right":f.startsWith(":")?"left":null),d=[];for(n+=2;n<t.length&&t[n].trim()!==""&&!Ee.test(t[n])&&!Jt.test(t[n])&&!Se.test(t[n]);)d.push(ve(t[n]).slice(0,c.length).map(f=>N(f))),n++;e.push({kind:"table",align:u,head:c.map(f=>N(f)),rows:d});continue}i||(i=[]),i.push(o.replace(/^ +/,"")),n++}return r(),e}function Ei(t,e){let n=Et.exec(t[e]),i=n[1].length,r=/^\d/.test(n[2])?null:n[2],o=r===null?parseInt(n[2],10):null,s=[],l=e;for(;l<t.length;){let a=Et.exec(t[l]);if(!a||a[1].length!==i||r===null!==/^\d/.test(a[2])||r!==null&&a[2]!==r)break;let c=a[1].length+a[2].length+Math.max(1,Math.min(a[3].length,4)),u=[a[4]];l++;let d=!1;for(;l<t.length;){let h=t[l];if(h.trim()===""){d=!0,u.push(""),l++;continue}if(h.length-h.trimStart().length>=c){u.push(h.slice(c)),d=!1,l++;continue}if(!d&&!Et.test(h)&&!Ee.test(h)&&!Jt.test(h)&&!Se.test(h)&&!Bn.test(h)){u.push(h.trimStart()),l++;continue}break}for(;u.length&&u[u.length-1].trim()==="";)u.pop();let f=null,m=/^\[([ xX])\](?:[ \t]+|$)/.exec(u[0]??"");if(m&&(f=m[1]!==" ",u[0]=u[0].slice(m[0].length)),s.push({checkbox:f,children:Ve(u)}),d&&l<t.length&&t[l-1]?.trim()===""){let h=Et.exec(t[l]);if(!h||h[1].length!==i)break}}return{block:{kind:"list",ordered:o,items:s},next:l}}function N(t,e={}){let n=[],i=(l,a)=>{l&&n.push({...a,text:l})},r=0,o="",s=()=>{i(o,e),o=""};for(;r<t.length;){let l=t.slice(r),a;if(l[0]==="\\"&&/^\\[\\`*_{}[\]()#+\-.!|~>]/.test(l)){o+=l[1],r+=2;continue}if(l.startsWith(`\\
|
|
8
|
+
`)){for(o+=ut,r+=2;t[r]===" ";)r++;continue}if(l[0]===`
|
|
9
|
+
`){for(o=o.replace(/ +$/,""),o+=ut,r++;t[r]===" ";)r++;continue}if(a=/^(`+)([\s\S]*?[^`])\1(?!`)/.exec(l)){s();let c=a[2].replace(/\n/g," ");/^ .* $/.test(c)&&(c=c.slice(1,-1)),i(c,{...e,mono:!0}),r+=a[0].length;continue}if(a=/^!\[([^\]]*)\]\([^)]*\)/.exec(l)){s(),n.push(...N(a[1],e)),r+=a[0].length;continue}if(a=/^\[([^\]]+)\]\([^)]*\)/.exec(l)){s(),n.push(...N(a[1],{...e,link:!0})),r+=a[0].length;continue}if(a=/^<((?:https?|ftp|mailto):[^>\s]+)>/.exec(l)){s(),i(a[1],{...e,link:!0}),r+=a[0].length;continue}if(a=/^~~(?=\S)([\s\S]*?\S)~~/.exec(l)){s(),n.push(...N(a[1],{...e,strike:!0})),r+=a[0].length;continue}if(a=/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/.exec(l)){s(),n.push(...N(a[2],{...e,bold:!0})),r+=a[0].length;continue}if((a=/^(\*|_)(?=\S)([\s\S]*?\S)\1(?!\1)/.exec(l))&&(a[1]==="*"||!/\w/.test(t[r-1]??""))){s(),n.push(...N(a[2],{...e,italic:!0})),r+=a[0].length;continue}o+=l[0],r++}return s(),Si(n)}function Si(t){let e=/\b(?:(?:https?|ftp):\/\/|www\.)[^\s<]*[^\s<.,:;"')\]!?]/g;return t.flatMap(n=>{if(n.link||n.mono||!(n.text.includes("://")||n.text.includes("www.")))return[n];let i=[],r=0;for(let o of n.text.matchAll(e))o.index>r&&i.push({...n,text:n.text.slice(r,o.index)}),i.push({...n,text:o[0],link:!0}),r=o.index+o[0].length;return r<n.text.length&&i.push({...n,text:n.text.slice(r)}),i})}function Fn(t){return t.bold?t.italic?"boldItalic":"bold":t.italic?"italic":"regular"}function te(t,e){if(e.mono&&Xt[t]===void 0)return Vn*e.size;let n=xt[Fn(e)];return(n.w[t]??xt.regular.w[t]??n.w.n)*e.size/1e3}function Ie(t,e,n){return n.mono?0:(xt[Fn(n)].k[t+e]??0)*n.size/1e3}function $e(t,e){let n=Xt[t];return n?[n[0]*e.size,n[1]*e.size,n[2]*e.size]:e.mono?[Dn*e.size,Wn*e.size,0]:e.bold&&e.italic?[In*e.size,$n*e.size,Ln*e.size]:e.bold?[Rn*e.size,An*e.size,Tn*e.size]:e.italic?[vn*e.size,En*e.size,Sn*e.size]:[qt*e.size,Ut*e.size,Kt*e.size]}var Le=class{constructor(e,n){k(this,"paras",[]);k(this,"nextSpacing",null);k(this,"fontSize");k(this,"width");this.fontSize=e,this.width=n}get gap(){return this.fontSize*.5}spacing(e){return this.paras.length===0?0:this.nextSpacing??e}run(e,n,i,r={}){let o=!!e.mono;return{text:e.text,size:o?n*.9:n,bold:!!(e.bold||r.bold),italic:!!(e.italic||r.italic),mono:o,strike:!!e.strike,underline:!!e.link,alpha:i}}paragraph(e,n){this.paras.push({tabs:[],rule:null,tableRule:null,...e,quote:n}),this.nextSpacing=null}text(e,n,i,r={}){if(n.marker){let o={text:n.marker.text+" ",size:this.fontSize,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1};this.paragraph({runs:[o,...e],spacing:i,firstIndent:n.marker.start,indent:n.marker.hang,tabs:[{align:"left",x:n.marker.hang}],...r},n.quote)}else this.paragraph({runs:e,spacing:i,firstIndent:n.indent,indent:n.indent,...r},n.quote)}block(e,n){let i=n.quote!==null,r=i?.7:1;switch(e.kind){case"heading":{let o=[1.5,1.3,1.15,1.05,1,1][Math.min(Math.max(e.level,1),6)-1];this.text(e.inline.map(s=>this.run(s,this.fontSize*o,r,{bold:!0,italic:i})),n,this.spacing(this.gap*1.4));break}case"paragraph":this.text(e.inline.map(o=>this.run(o,this.fontSize,r,{italic:i})),n,this.spacing(this.gap));break;case"list":{let o=e.items.map((c,u)=>c.checkbox===!0?"\u2611":c.checkbox===!1?"\u2610":e.ordered!==null?`${e.ordered+u}.`:n.listDepth%2===0?"\u2022":"\u25E6"),s=c=>zn({text:c,size:this.fontSize,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1}),l=Math.max(0,...o.map(s)),a=n.indent+Math.max(l+this.fontSize*.45,this.fontSize*1.2);e.items.forEach((c,u)=>{(u>0||n.listDepth>0||n.marker)&&(this.nextSpacing=this.fontSize*.15);let d={...n,marker:{text:o[u],start:n.indent,hang:a},indent:a,listDepth:n.listDepth+1};c.children.length===0&&this.text([],d,this.spacing(this.gap));for(let f of c.children)this.block(f,d),d.marker=null,this.nextSpacing=this.fontSize*.3;this.nextSpacing=null});break}case"quote":{let o={...n,quote:n.indent+3,indent:n.indent+this.fontSize};for(let s of e.children)this.block(s,o);break}case"code":{let s={text:e.text===""?" ":e.text.replace(/\n/g,ut),size:this.fontSize*.85,bold:!1,italic:!1,mono:!0,strike:!1,underline:!1,alpha:r};this.text([s],{...n,indent:n.indent+this.fontSize*.5},this.spacing(this.gap));break}case"rule":{let o={text:" ",size:this.fontSize*.6,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1};this.text([o],n,this.spacing(this.gap),{rule:n.indent});break}case"table":this.table(e,n);break}}table(e,n){let i=[{cells:e.head,header:!0},...e.rows.map(g=>({cells:g,header:!1}))],r=Math.max(1,...i.map(g=>g.cells.length)),o=n.quote!==null,s=(g,A,v)=>g.map(S=>({...this.run({...S,text:S.text.replaceAll(ut," ")},v,o?.7:1,{bold:A,italic:o})})),l=g=>{let A=new Array(r).fill(0);for(let v of i)v.cells.forEach((S,P)=>{P<r&&(A[P]=Math.max(A[P],s(S,v.header,g).reduce((I,K)=>I+zn(K),0)))});return A},a=Math.max(this.width-n.indent,1),c=this.fontSize,u=l(c),d=c*1.2,f=u.reduce((g,A)=>g+A,0)+d*(r-1);f>a&&(c=Math.max(this.fontSize*a/f,Math.min(this.fontSize,9)),u=l(c),d=c*1.2);let m=[],h=n.indent;for(let g of u)m.push(h),h+=g+d;let p=h-d-n.indent,x=[],M=!1;for(let g=0;g<r;g++){let A=e.align[g]??null;A==="center"?x.push({align:"center",x:m[g]+u[g]/2}):A==="right"?x.push({align:"right",x:m[g]+u[g]}):g>0&&x.push({align:"left",x:m[g]}),g===0&&(A==="center"||A==="right")&&(M=!0)}let b=g=>({text:g,size:c,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1});i.forEach((g,A)=>{let v=[];M&&v.push(b(" "));for(let P=0;P<r;P++)P>0&&v.push(b(" ")),P<g.cells.length&&v.push(...s(g.cells[P],g.header,c));v.length===0&&v.push(b(" "));let S=A===0?this.spacing(this.gap):A===1?c*.45:c*.2;this.paragraph({runs:v,spacing:S,firstIndent:n.indent,indent:n.indent,tabs:x,tableRule:g.header?[n.indent,p]:null},n.quote)})}};function zn(t){let e=0,n="";for(let i of t.text)e+=te(i,t),n&&(e+=Ie(n,i,t)),n=i;return e}var Cn=28;function Ii(t,e,n,i){let r=[],o=0,s=null;return t.forEach((l,a)=>{let c=a<t.length-1?[...l.runs,{text:`
|
|
10
|
+
`,size:i,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1}]:l.runs,u=[];c.forEach((m,h)=>{for(let p of m.text)u.push({ch:p,run:h})});let d=0,f=!0;for(;d<u.length||f&&u.length===0;){let m=f?l.firstIndent:l.indent,h=e,p=[],x=m,M=-1,b=d;for(;b<u.length;b++){let{ch:P,run:I}=u[b],K=c[I];if(P===ut||P===`
|
|
11
|
+
`){p.push({ch:P,run:I,x,w:0}),b++;break}if(P===" "){let X=l.tabs.find(Mt=>Mt.x>x+.01),Pt;if(X)if(X.align==="left")Pt=X.x;else{let Mt=0,ae="";for(let H=b+1;H<u.length&&u[H].ch!==" "&&u[H].ch!==`
|
|
12
|
+
`&&u[H].ch!==ut;H++){let Ne=c[u[H].run];Mt+=te(u[H].ch,Ne)+(ae?Ie(ae,u[H].ch,Ne):0),ae=u[H].ch}Pt=Math.max(x,X.align==="right"?X.x-Mt:X.x-Mt/2)}else Pt=(Math.floor(x/Cn)+1)*Cn;p.push({ch:P,run:I,x,w:Pt-x}),x=Pt;continue}let G=p[p.length-1],se=G&&G.run===I&&G.ch!==" "?Ie(G.ch,P,K):0;G&&(G.w+=se,x+=se);let le=te(P,K);if(P!==" "&&x+le>h+.01&&p.some(X=>X.ch!==" ")){M>=0&&(p.length=M+1,b=d+M+1),G&&(G.w-=se);break}p.push({ch:P,run:I,x,w:le}),x+=le,Te(P,u[b+1]?.ch??"")&&(M=p.length-1)}if(p.length===0&&b===d&&d<u.length){let{ch:P,run:I}=u[d];p.push({ch:P,run:I,x:m,w:te(P,c[I])}),b=d+1}let g=0,A=0,v=0;for(let P of p){let[I,K,G]=$e(P.ch,c[P.run]);g=Math.max(g,I),A=Math.max(A,K),v=Math.max(v,G)}if(p.length===0&&([g,A,v]=$e(" ",c[0]??{text:" ",size:i,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1})),o=s?o+Math.round(s.desc)+Math.round(s.lead)+(f?l.spacing:0)+Math.round(g):Math.round(g),o+A>n+.5)return;let S={glyphs:p,asc:g,desc:A,lead:v,baseline:o,para:l,first:f};if(S.glyphs.forEach(P=>{P.r=c[P.run]}),r.push(S),s=S,f=!1,d=b,u.length===0)break}}),r}function Nn(t,e){let n=Ai({x:e.x,y:e.y,width:e.width,height:e.height});if(!(n.width>1&&n.height>1))return"";let i=new Le(e.style.fontSize,n.width);for(let c of vi(t))i.block(c,{indent:0,marker:null,quote:null,listDepth:0});let r=Ii(i.paras,n.width,n.height,e.style.fontSize),o=V(e.style.stroke),s="",l=[];for(let c of r){let u=c.para;if(u.quote!==null&&l.push([n.x+u.quote,n.y+c.baseline-c.asc,n.x+u.quote,n.y+c.baseline+c.desc]),u.rule!==null&&l.push([n.x+u.rule,n.y+c.baseline-3,n.x+n.width,n.y+c.baseline-3]),u.tableRule){let h=n.y+c.baseline+c.desc+2;l.push([n.x+u.tableRule[0],h,Math.min(n.x+n.width,n.x+u.tableRule[0]+u.tableRule[1]),h])}let d="",f=0,m=c.glyphs;for(;f<m.length;){let h=m[f].r,p=f,x="",M=Gn(m[f].ch);for(;p<m.length&&$i(m[p].r,h)&&m[p].ch!==" "&&Gn(m[p].ch)===M;)x+=m[p].ch,p++;let b=x.replaceAll(`
|
|
13
|
+
`,"").replaceAll(ut,"");if(b.trim()!==""){let g=`font-size="${y(h.size)}"`;h.mono&&(g+=' font-family="Menlo, Consolas, monospace"'),h.bold&&(g+=' font-weight="bold"'),h.italic&&(g+=' font-style="italic"'),h.underline&&(g+=' text-decoration="underline"'),h.alpha<1&&(g+=` fill-opacity="${y(h.alpha*e.style.stroke.a)}"`),d+=`<tspan x="${y(n.x+m[f].x)}" ${g}>${Qt(b)}</tspan>`}if(h.strike&&p>f){let g=c.baseline-$e(m[f].ch,h)[0]*.32;l.push([n.x+m[f].x,n.y+g,n.x+m[p-1].x+m[p-1].w,n.y+g])}p===f&&p++,f=p}d&&(s+=`<text y="${y(n.y+c.baseline)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" fill="${o}" xml:space="preserve">${d}</text>
|
|
14
|
+
`)}let a=y(Math.max(1,e.style.fontSize/14));for(let[c,u,d,f]of l)s+=`<line x1="${y(c)}" y1="${y(u)}" x2="${y(d)}" y2="${y(f)}" stroke="${o}" stroke-width="${a}"/>
|
|
15
|
+
`;return s}function Gn(t){return Xt[t]?`fb:${t}`:""}function $i(t,e){return t===e||t.size===e.size&&t.bold===e.bold&&t.italic===e.italic&&t.mono===e.mono&&t.strike===e.strike&&t.underline===e.underline&&t.alpha===e.alpha}var D=(t,e,n)=>({r:t,g:e,b:n,a:1}),De=[{id:"paper",name:"Paper",background:D(.984,.98,.965),ink:D(.12,.12,.13)},{id:"white",name:"White",background:D(1,1,1),ink:D(.12,.12,.13)},{id:"sepia",name:"Sepia",background:D(.953,.914,.824),ink:D(.23,.18,.13)},{id:"blueprint",name:"Blueprint",background:D(.106,.227,.361),ink:D(.91,.945,.984)},{id:"chalkboard",name:"Chalkboard",background:D(.169,.227,.2),ink:D(.945,.945,.918)},{id:"midnight",name:"Midnight",background:D(.082,.086,.102),ink:D(.925,.925,.94)}];function ht(t){return De.find(e=>e.id===t)??null}function Oe(t,e){switch(t){case"linear":return e;case"easeIn":return e*e*e;case"easeOut":return 1-Math.pow(1-e,3);case"easeInOut":return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;case"hold":return 0;case"spring":return Li(e);case"bounce":return Vi(e);case"elastic":return Di(e)}}function Li(t){if(t<=0)return 0;if(t>=1)return 1;let e=n=>1-Math.exp(-6*n)*(Math.cos(3*Math.PI*n)+6/(3*Math.PI)*Math.sin(3*Math.PI*n));return e(t)+t*(1-e(1))}function Vi(t){if(t<=0)return 0;if(t>=1)return 1;let e=7.5625,n=2.75;if(t<1/n)return e*t*t;if(t<2/n){let r=t-1.5/n;return e*r*r+.75}if(t<2.5/n){let r=t-2.25/n;return e*r*r+.9375}let i=t-2.625/n;return e*i*i+.984375}function Di(t){return t<=0?0:t>=1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1}var St=(t,e)=>t%e;function It(t,e){let n=(t.repeats??[]).filter(Ct).slice().sort((i,r)=>i.start-r.start);if(n.length===0)return e;for(let i of n){if(!(e>=i.end))continue;let r=i.end-i.start;if(i.count===null)return i.start+St(e-i.start,r);let o=r*i.count;if(e<i.start+o)return i.start+St(e-i.start,r);e-=o-r}return e}function We(t,e,n,i,r){e=It(t,e);let o,s;for(let u of t.keys)if(n(u)!==void 0)if(u.t<=e)o=u;else{s=u;break}if(!o&&!s)return i;if(o&&!s)return n(o);if(!o&&s)return n(s);let l=o,a=s,c=a.t-l.t>0?(e-l.t)/(a.t-l.t):1;return r(n(l),n(a),Oe(l.ease??"linear",c))}var Wi=(t,e,n)=>t+(e-t)*n,ee=(t,e,n)=>Math.min(Math.max(t+(e-t)*n,0),1),Hn=(t,e,n)=>({r:ee(t.r,e.r,n),g:ee(t.g,e.g,n),b:ee(t.b,e.b,n),a:ee(t.a,e.a,n)});function nt(t,e,n,i){return We(t,e,r=>r[n],i,Wi)}function Yi(t,e){e=It(t,e);let n=(r,o)=>{let s;for(let a of t.keys)a.t<=e&&r(a)!==void 0&&(s=a);let l=t.keys.find(a=>a.t>e&&r(a)!==void 0);return!s||!l?!1:s.ease!=="hold"&&!o(r(s),r(l))},i=r=>n(o=>o[r],(o,s)=>o===s);return i("x")||i("y")||i("width")||i("height")||i("rotation")||i("strokeWidth")||n(r=>r.stroke,dt)||n(r=>r.fill,dt)||i("reveal")||i("opacity")}function Ye(t,e){e=It(t,e);let n=t.keys.filter(r=>r.visible!==void 0);if(n.length===0)return!0;let i;for(let r of n)r.t<=e&&(i=r);return i?i.visible:!n[0].visible}function Oi(t,e,n){if(e=B(e),t.keys.some(i=>i.reveal!==void 0)){let i=nt(t,n,"reveal",e.reveal??1);e.reveal=i>=1?null:Math.max(0,i)}if(t.keys.some(i=>i.opacity!==void 0)){let i=Math.min(Math.max(nt(t,n,"opacity",e.style.opacity??1),0),1);e.style.opacity=i>=1?null:i}return e.kind==="connector"||(e.x=nt(t,n,"x",e.x),e.y=nt(t,n,"y",e.y),e.width=Math.max(0,nt(t,n,"width",e.width)),e.height=Math.max(0,nt(t,n,"height",e.height)),t.keys.some(i=>i.rotation!==void 0)&&(e.rotation=nt(t,n,"rotation",F(e))),e.style.strokeWidth=Math.max(0,nt(t,n,"strokeWidth",e.style.strokeWidth)),e.style.stroke=We(t,n,i=>i.stroke,e.style.stroke,Hn),e.style.fill=We(t,n,i=>i.fill,e.style.fill,Hn)),e}function zi(t,e){e=It(t,e);let n=null;for(let r of t.follow??[])r.start<=e&&(n===null||r.start>n.start)&&(n=r);if(!n)return null;let i=n;return t.keys.some(r=>r.t>=i.end&&r.t<=e&&(r.x!==void 0||r.y!==void 0))?null:n}function Ci(t,e){if(t.kind==="connector")return new yt(Z(J(t,tt(e))));let n=B(t);n.style.roughness=0;let i=ct(n).contours()[0]??[];return new yt(F(t)===0?i:i.map(r=>Q(t,r)))}function Gi(t,e,n,i){let r=zi(t,n);if(!r)return e;n=It(t,n);let o=i.elements.find(d=>d.id===r.path);if(!o||o.id===e.id)return e;let s=Ci(o,i),l=r.end-r.start,a=Math.min(Math.max(Oe(r.ease??"easeInOut",l>0?Math.min(1,(n-r.start)/l):1),0),1)*(r.laps??1);a>1&&(a=St(a,1)===0?1:St(a,1)),r.reverse===!0&&(a=1-a);let c=s.point(a),u=B(e);if(u.x=c.x-e.width/2,u.y=c.y-e.height/2,r.orient===!0){let d=r.reverse===!0?-.01:.01,f=s.point(a-d/2),m=s.point(a+d/2);(f.x!==m.x||f.y!==m.y)&&(u.rotation=Math.atan2(m.y-f.y,m.x-f.x))}return u}function Bi(t,e,n,i){if(!(n>0))return 0;let r=ot(t.duration);if(r>0){let s=Tt(e*r/n);s!==0&&(e=s*n/r)}let o=St(e*i,n);return o<0?-o:o===0?0:n-o}function Fi(t){let e=new Map;for(let n of t.tracks)e.has(n.element)||e.set(n.element,n);return e}function W(t,e){let n=t.timeline;if(!n)return t;e=ot(e);let i=Fi(n),r=n.boil===null?null:Math.trunc(Math.floor(e*ft(n.fps)+1e-9)/Math.max(1,n.boil))%he>>>0,o=new Set;for(let m of i.values())Ye(m,e)||o.add(m.element);let s=null;if(n.settle===!0){s=new Set;for(let m of i.values())Yi(m,e)&&s.add(m.element)}let l=m=>{let h=i.get(m.id)?.boil;return h??(s?m.connector?[m.connector.start.elementID,m.connector.end.elementID].some(p=>p!==null&&s.has(p)):s.has(m.id):!0)},a=t.elements.map(m=>{let h=i.get(m.id),p=h?Oi(h,m,e):m;r!==null&&r>0&&l(m)&&(p===m&&(p=B(m)),p.seed=an(m.seed,r));let x=h?.march!=null?Ht(p.style.dash,p.style.strokeWidth):null;return h?.march!=null&&x&&(p===m&&(p=B(m)),p.style.dashOffset=Bi(n,h.march,x.reduce((M,b)=>M+b,0),e)),p});a=a.map((m,h)=>o.has(m.id)?t.elements[h]:m);let c={...t,elements:a,timeline:null};a=a.map(m=>{let h=i.get(m.id);return h?Gi(h,m,e,c):m});let u={...t,elements:a,timeline:null},d=tt(u),f=new Set(o);return a=a.map(m=>{let h=m.connector;if(!h||![h.start.elementID,h.end.elementID].some(b=>b!==null&&o.has(b)))return m;if(!(i.get(m.id)?.keys.some(b=>b.visible!==void 0)??!1))return f.add(m.id),m;let[p,x]=lt(m,d),M=B(m);return M.connector.start={elementID:null,port:h.start.port,x:p.x,y:p.y},M.connector.end={elementID:null,port:h.end.port,x:x.x,y:x.y},M}),{...t,elements:a.filter(m=>!f.has(m.id)),timeline:null}}function it(t){return t.timeline?t.timeline.poster??t.timeline.duration:0}function _n(t){return t.timeline?W(t,it(t)):t}function Ni(t,e){let n=t.camera??[];if(n.length===0)return null;let i;for(let l of n)l.t<=e&&(i=l);let r=n.find(l=>l.t>e);if(!i)return jn(n[0]);if(!r)return jn(i);let o=Oe(i.ease??"easeInOut",(e-i.t)/Math.max(r.t-i.t,1e-9)),s=(l,a)=>l+(a-l)*o;return{x:s(i.x,r.x),y:s(i.y,r.y),width:Math.max(1,s(i.width,r.width)),height:Math.max(1,s(i.height,r.height))}}var jn=t=>({x:t.x,y:t.y,width:t.width,height:t.height});function bt(t,e){let n=t.camera?.[0],i=Ni(t,e);return!n||!i||!(i.width>0&&i.height>0)?null:Hi(i,n.width/n.height)}function Hi(t,e){if(!(t.width>0&&t.height>0&&e>0))return t;let n=t.width,i=t.height;return t.width/t.height<e?n=t.height*e:i=t.width/e,{x:t.x+t.width/2-n/2,y:t.y+t.height/2-i/2,width:n,height:i}}function ji(t){return Math.max(1,Math.ceil(ot(t.duration)*ft(t.fps)))}function ne(t){let e=ft(t.fps),n=[];for(let r=0;r<ji(t);r++)n.push(r/e);let i=n[n.length-1];return t.duration-i>1e-6&&n.push(t.duration),n}function qn(t,e){let n=-1;return(t.markers??[]).forEach((i,r)=>{i.t<=e&&(n=r)}),n}function Un(t){let e=t.timeline;if(!e)return new Set;let n=e.poster??e.duration;return new Set(e.tracks.filter(i=>!Ye(i,0)&&!Ye(i,n)).map(i=>i.element))}function rt(t,e=24){let n=tt(t),i=s=>{if(s.kind==="connector")return on(s,n);let l=Ae(s)?(Re+.25)*at(s):0;return gt(Je(s),-l,-l)};if(t.elements.length===0)return{x:0,y:0,width:200,height:200};let r=t.elements.filter(s=>(s.style.opacity??1)>0),o=null;for(let s of r.length?r:t.elements)o=de(o,i(s));return gt(o,-e,-e)}function kt(t){let e=t.timeline??{fps:12,duration:0,boil:null,settle:null,poster:null,tracks:[],camera:null,markers:null},n=ne(e),i=e.camera?.find(o=>o.width>1&&o.height>1);if(i){let o=i.width/i.height,s=n.map(a=>bt(e,a)??{x:i.x,y:i.y,width:i.width,height:i.height}),l=Math.min(Math.max(...s.map(a=>a.width)),4096);return{times:n,rects:s,size:{width:l,height:l/o}}}let r=null;for(let o of n){let s=W(t,o);s.elements.length>0&&(r=de(r,rt(s)))}return r||(r=rt(W(t,n[0]))),{times:n,rects:n.map(()=>r),size:{width:r.width,height:r.height}}}var $t=(t,e)=>t.a<1?` ${e}="${y(t.a)}"`:"";function _i(t,e,n){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${y(t.width)}" height="${y(t.height)}" viewBox="${y(t.x)} ${y(t.y)} ${y(t.width)} ${y(t.height)}">
|
|
16
16
|
`;return n&&e&&(i+=`<rect x="${y(t.x)}" y="${y(t.y)}" width="${y(t.width)}" height="${y(t.height)}" fill="${V(e)}"/>
|
|
17
|
-
`),i}function
|
|
18
|
-
`).join("");
|
|
17
|
+
`),i}function Lt(t,e,n){let i=ht(t.theme),r=e?i?.background??e:null,o=i?.ink??st,s={...t,elements:t.elements.map(h=>tn(h,o))},l=n??rt(s),a=new Set(s.layers.filter(h=>h.visible).map(h=>h.id)),c=[],u=tt(s),d=At(s),f=d.filter(h=>a.has(h.layerID)&&Ae(h)),m=Mn(f).map(h=>`<path d="${h.path.data()}" fill="none" stroke="${V(h.ink)}"${$t(h.ink,"stroke-opacity")} stroke-width="${y(h.width)}" stroke-linecap="round"/>
|
|
18
|
+
`).join("");m&&c.push({key:"rock",markup:m});for(let h of d){if(!a.has(h.layerID))continue;let p=Math.min(Math.max(h.style.opacity??1,0),1);if(p<=0)continue;let x=Xi(h,u,r);F(h)!==0&&h.kind!=="connector"&&(x=`<g transform="rotate(${y(F(h)*180/Math.PI)} ${y(z(L(h)))} ${y(C(L(h)))})">
|
|
19
19
|
${x}</g>
|
|
20
20
|
`),c.push({key:h.id,markup:p<1?`<g opacity="${y(p)}">
|
|
21
21
|
${x}</g>
|
|
22
|
-
`:x})}return{bounds:l,parts:c}}function
|
|
23
|
-
`}function
|
|
24
|
-
`:`<path d="${
|
|
25
|
-
`;switch(t.kind){case"connector":{let[a,c]=
|
|
22
|
+
`:x})}return{bounds:l,parts:c}}function re(t,e={r:1,g:1,b:1,a:1},n){let{bounds:i,parts:r}=Lt(t,e,n);return _i(i,ht(t.theme)?.background??e,e!==null)+r.map(o=>o.markup).join("")+`</svg>
|
|
23
|
+
`}function qi(t,e){let n=sn(t,e),i=t.text??"",r=Yn(i===""?"Label":i,t.style.fontSize,200),o=Math.max(r.width+12,44),s=r.height+6;return{x:n.x-o/2,y:n.y-s/2,width:o,height:s}}function Ui(t,e){let n=[...t];return n.slice(0,Math.floor(n.length*e)).join("")}function Ki(t){return t.reveal!==null&&t.reveal<1?Math.max(0,t.reveal):null}function Xi(t,e,n){let i=V(t.style.stroke),r=`stroke="${i}" stroke-width="${y(t.style.strokeWidth)}" stroke-linecap="round" stroke-linejoin="round"`,o=Ht(t.style.dash,t.style.strokeWidth);o&&(r+=` stroke-dasharray="${o.map(y).join(" ")}"`),o&&t.style.dashOffset!==null&&y(t.style.dashOffset)!=="0"&&(r+=` stroke-dashoffset="${y(t.style.dashOffset)}"`);let s=t.text,l=Ki(t);if(l!==null)if(t.kind==="text")s=Ui(s??"",l);else return t.kind==="connector"?`<path d="${Me(t,e)[0].trimmed(l).data()}" fill="none" ${r}/>
|
|
24
|
+
`:`<path d="${ct(t).trimmed(l).data()}" fill="none" ${r}/>
|
|
25
|
+
`;switch(t.kind){case"connector":{let[a,c]=Me(t,e),u=`<path d="${a.data()}" fill="none" ${r}/>
|
|
26
26
|
`;if(c.isEmpty||(u+=`<path d="${c.data()}" fill="${i}" stroke="none"/>
|
|
27
|
-
`),s){let
|
|
28
|
-
`),u+=
|
|
29
|
-
`}return t.style.stroke.a>0&&t.style.strokeWidth>0&&(c+=`<path d="${
|
|
30
|
-
`),c}case"freehand":return`<path d="${
|
|
31
|
-
`;case"rectangle":case"ellipse":case"diamond":case"path":case"note":{let a="";if(t.kind==="note"&&t.style.fill.a>0&&(a+=`<path d="${
|
|
32
|
-
`),t.style.fill.a>0){let c=t.evenOdd===!0?' fill-rule="evenodd"':"";if(t.style.fillStyle==="solid")a+=`<path d="${
|
|
33
|
-
`;else if(t.style.fillStyle==="grid"){let u=
|
|
34
|
-
`,a+=`<path d="${
|
|
35
|
-
`}else a+=`<path d="${
|
|
36
|
-
`}return a+=`<path d="${
|
|
37
|
-
`,s&&(a+=t.kind==="note"?
|
|
38
|
-
`+
|
|
39
|
-
`),s=r*1.2,l=s*o.length,a=i?
|
|
40
|
-
`}var
|
|
27
|
+
`),s){let d=qi(t,e);n&&(u+=`<rect x="${y(d.x)}" y="${y(d.y)}" width="${y(d.width)}" height="${y(d.height)}" fill="${V(n)}"/>
|
|
28
|
+
`),u+=ie(s,d,t,!0)}return u}case"text":return ie(s??"",L(t),t,!1);case"image":{let a=L(t),c="";if(t.image){let u=t.image.format==="jpeg"?"image/jpeg":"image/png";c+=`<image x="${y(a.x)}" y="${y(a.y)}" width="${y(a.width)}" height="${y(a.height)}" preserveAspectRatio="none" href="data:${u};base64,${t.image.data}"/>
|
|
29
|
+
`}return t.style.stroke.a>0&&t.style.strokeWidth>0&&(c+=`<path d="${ct(t).data()}" fill="none" ${r}/>
|
|
30
|
+
`),c}case"freehand":return`<path d="${ct(t).data()}" fill="none" ${r}/>
|
|
31
|
+
`;case"rectangle":case"ellipse":case"diamond":case"path":case"note":{let a="";if(t.kind==="note"&&t.style.fill.a>0&&(a+=`<path d="${Nt(t).translated(2,3).data()}" fill="#000000" fill-opacity="${y(.14*t.style.fill.a)}" stroke="none"/>
|
|
32
|
+
`),t.style.fill.a>0){let c=t.evenOdd===!0?' fill-rule="evenodd"':"";if(t.style.fillStyle==="solid")a+=`<path d="${Nt(t).data()}" fill="${V(t.style.fill)}"${$t(t.style.fill,"fill-opacity")}${c} stroke="none"/>
|
|
33
|
+
`;else if(t.style.fillStyle==="grid"){let u=wn(t.style.fill);a+=`<path d="${Nt(t).data()}" fill="${V(t.style.fill)}"${$t(t.style.fill,"fill-opacity")}${c} stroke="none"/>
|
|
34
|
+
`,a+=`<path d="${Pe(t).data()}" fill="none" stroke="${V(u)}"${$t(u,"stroke-opacity")} stroke-width="1" stroke-linecap="round"/>
|
|
35
|
+
`}else a+=`<path d="${Pe(t).data()}" fill="none" stroke="${V(t.style.fill)}"${$t(t.style.fill,"stroke-opacity")} stroke-width="${y(Math.max(1,t.style.strokeWidth/2))}" stroke-linecap="round"/>
|
|
36
|
+
`}return a+=`<path d="${ct(t).data()}" fill="none" ${r}/>
|
|
37
|
+
`,s&&(a+=t.kind==="note"?Nn(s,t):ie(s,L(t),t,!0)),a}default:return Qi(t,r)}}function Qi(t,e){let n=L(t);return`<path d="${R.rect(n).moveTo({x:n.x,y:n.y}).lineTo({x:n.x+n.width,y:n.y+n.height}).data()}" fill="none" ${e} stroke-opacity="0.5" stroke-dasharray="6 4"/>
|
|
38
|
+
`+ie(`${t.kind}${t.text?`: ${t.text}`:""}`,n,{...t,style:{...t.style,fontSize:Math.min(t.style.fontSize,12)}},!0)}function ie(t,e,n,i){let r=n.style.fontSize,o=t.split(`
|
|
39
|
+
`),s=r*1.2,l=s*o.length,a=i?z(e):e.x,c=i?C(e)-l/2:e.y,u=`<text x="${y(a)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" font-size="${y(r)}" fill="${V(n.style.stroke)}"${i?' text-anchor="middle"':""}>`;return o.forEach((d,f)=>{u+=`<tspan x="${y(a)}" y="${y(c+s*(f+.8))}">${Qt(d)}</tspan>`}),u+`</text>
|
|
40
|
+
`}var Zi={r:1,g:1,b:1,a:1};function Dt(t,e){let n=(e??"").trim();if(!n)return 0;let i=t.pages.findIndex(o=>o.name.toLowerCase()===n.toLowerCase());if(i>=0)return i;let r=Number(n);return Number.isInteger(r)&&r>=1&&r<=t.pages.length?r-1:0}function Wt(t,e){return{...t,elements:t.elements.map(n=>({...n,style:{...n.style,roughness:e}}))}}var Ji=`
|
|
41
41
|
:host { display: block; position: relative; color: var(--dottie-ink); background: var(--dottie-page);
|
|
42
42
|
font: 14px -apple-system, system-ui, sans-serif; border-radius: var(--dottie-radius, 0); }
|
|
43
43
|
:host([hidden]) { display: none; }
|
|
@@ -52,7 +52,7 @@ input[type=range] { flex: 1; min-width: 60px; accent-color: currentColor; }
|
|
|
52
52
|
output { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
|
|
53
53
|
.scene { min-width: 0; flex: 0 1 auto; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
54
54
|
.error { padding: 16px; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; }
|
|
55
|
-
`,
|
|
55
|
+
`,Vt=class{constructor(e,n,i={}){k(this,"page");k(this,"plan");k(this,"scenes");k(this,"sceneNames");k(this,"background");k(this,"ink");k(this,"svg");k(this,"groups",new Map);k(this,"order",[]);k(this,"frame",-1);k(this,"onFrame",null);this.page=i.clean?Wt(e,0):e,this.plan=kt(this.page);let r=l=>{let a=0;return this.plan.times.forEach((c,u)=>{Math.abs(c-l)<Math.abs(this.plan.times[a]-l)&&(a=u)}),a};this.scenes=(e.timeline?.markers??[]).map(l=>r(l.t)),this.sceneNames=(e.timeline?.markers??[]).map(l=>l.name);let o=ht(e.theme);this.background=o?.background??Zi,this.ink=o?.ink??{r:.12,g:.12,b:.13,a:1};let s="http://www.w3.org/2000/svg";this.svg=document.createElementNS(s,"svg"),this.svg.setAttribute("width",y(this.plan.size.width)),this.svg.setAttribute("height",y(this.plan.size.height)),this.svg.style.maxWidth=`${Math.ceil(this.plan.size.width)}px`,n.replaceChildren(this.svg)}get frameCount(){return this.plan.times.length}get posterFrame(){let e=it(this.page),n=0;return this.plan.times.forEach((i,r)=>{Math.abs(i-e)<Math.abs(this.plan.times[n]-e)&&(n=r)}),n}show(e){let n=this.frameCount;e=(e%n+n)%n,this.drawAt(this.plan.times[e],e),this.frame=e,this.onFrame?.(e)}drawAt(e,n=0){let i=this.plan.rects[Math.min(n,this.plan.rects.length-1)],{parts:r}=Lt(W(this.page,e),this.background,i);this.svg.setAttribute("viewBox",`${y(i.x)} ${y(i.y)} ${y(i.width)} ${y(i.height)}`);let o="http://www.w3.org/2000/svg",s=r.map(a=>a.key);for(let a of r){let c=this.groups.get(a.key);if(c)c.markup!==a.markup&&(c.g.innerHTML=a.markup,c.markup=a.markup);else{let u=document.createElementNS(o,"g");u.innerHTML=a.markup,this.groups.set(a.key,{g:u,markup:a.markup})}}let l=new Set(s);for(let[a,c]of this.groups)l.has(a)||(c.g.remove(),this.groups.delete(a));(s.length!==this.order.length||s.some((a,c)=>a!==this.order[c]))&&(this.svg.replaceChildren(...s.map(a=>this.groups.get(a).g)),this.order=s)}sceneAt(e){let n=-1;return this.scenes.forEach((i,r)=>{i<=e&&(n=r)}),n}},tr=typeof HTMLElement>"u"?class{}:HTMLElement,wt=class extends tr{constructor(){super();k(this,"file",null);k(this,"playback",null);k(this,"root");k(this,"stage");k(this,"bar");k(this,"playButton");k(this,"scrub");k(this,"time");k(this,"sceneLabel");k(this,"prev");k(this,"next");k(this,"playing",!1);k(this,"last",0);k(this,"acc",0);k(this,"raf",0);k(this,"loadToken",0);k(this,"visible",!0);k(this,"observer",null);this.root=this.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Ji}</style><div class="stage" part="stage" role="img"></div>
|
|
56
56
|
<div class="bar" part="controls" hidden>
|
|
57
57
|
<button class="play" aria-label="Play">\u25B6</button>
|
|
58
58
|
<button class="prev" aria-label="Previous scene" hidden>\u23EE</button>
|
|
@@ -60,4 +60,4 @@ output { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right
|
|
|
60
60
|
<button class="next" aria-label="Next scene" hidden>\u23ED</button>
|
|
61
61
|
<input class="scrub" type="range" min="0" max="0" value="0" aria-label="Frame">
|
|
62
62
|
<output class="time">0.0s</output>
|
|
63
|
-
</div>`;let n=i=>this.root.querySelector(i);this.stage=n(".stage"),this.bar=n(".bar"),this.playButton=n(".play"),this.scrub=n(".scrub"),this.time=n(".time"),this.sceneLabel=n(".scene"),this.prev=n(".prev"),this.next=n(".next"),this.playButton.onclick=()=>{let i=this.playback;i&&!this.playing&&i.scenes.length&&i.frame>=i.frameCount-1&&i.show(0),this.setPlaying(!this.playing)},this.scrub.oninput=()=>{this.setPlaying(!1),this.playback?.show(Number(this.scrub.value))},this.next.onclick=()=>this.nextScene(),this.prev.onclick=()=>this.prevScene(),this.addEventListener("keydown",i=>this.key(i))}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(n=>{this.visible=n.some(i=>i.isIntersecting),this.schedule()}),this.observer.observe(this)),this.load()}disconnectedCallback(){cancelAnimationFrame(this.raf),this.raf=0,this.observer?.disconnect()}attributeChangedCallback(n,i,r){i===r||!this.isConnected||(n==="src"?this.load():n==="label"?this.stage.setAttribute("aria-label",r??""):this.file&&this.mount())}async load(){let n=++this.loadToken;try{let i,r=this.getAttribute("src");if(r){let o=await fetch(r);if(!o.ok)throw new Error(`${r}: ${o.status} ${o.statusText}`);i=await o.text()}else{let o=this.querySelector('script[type="application/json"], script[type="application/vnd.dottie+json"]');if(!o)return;i=o.textContent??""}if(n!==this.loadToken)return;this.setFile(Rt(i))}catch(i){if(n!==this.loadToken)return;this.stage.innerHTML="";let r=document.createElement("div");r.className="error",r.textContent=`Couldn't show this drawing: ${i.message}`,this.stage.append(r),this.dispatchEvent(new CustomEvent("error",{detail:i}))}}setFile(n){this.file=n;for(let i of n.warnings)console.warn(`dottie-player: ${i}`);this.mount(),this.dispatchEvent(new CustomEvent("load",{detail:{file:n}}))}mount(){let n=this.file,i=n.pages[
|
|
63
|
+
</div>`;let n=i=>this.root.querySelector(i);this.stage=n(".stage"),this.bar=n(".bar"),this.playButton=n(".play"),this.scrub=n(".scrub"),this.time=n(".time"),this.sceneLabel=n(".scene"),this.prev=n(".prev"),this.next=n(".next"),this.playButton.onclick=()=>{let i=this.playback;i&&!this.playing&&i.scenes.length&&i.frame>=i.frameCount-1&&i.show(0),this.setPlaying(!this.playing)},this.scrub.oninput=()=>{this.setPlaying(!1),this.playback?.show(Number(this.scrub.value))},this.next.onclick=()=>this.nextScene(),this.prev.onclick=()=>this.prevScene(),this.addEventListener("keydown",i=>this.key(i))}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(n=>{this.visible=n.some(i=>i.isIntersecting),this.schedule()}),this.observer.observe(this)),this.load()}disconnectedCallback(){cancelAnimationFrame(this.raf),this.raf=0,this.observer?.disconnect()}attributeChangedCallback(n,i,r){i===r||!this.isConnected||(n==="src"?this.load():n==="label"?this.stage.setAttribute("aria-label",r??""):this.file&&this.mount())}async load(){let n=++this.loadToken;try{let i,r=this.getAttribute("src");if(r){let o=await fetch(r);if(!o.ok)throw new Error(`${r}: ${o.status} ${o.statusText}`);i=await o.text()}else{let o=this.querySelector('script[type="application/json"], script[type="application/vnd.dottie+json"]');if(!o)return;i=o.textContent??""}if(n!==this.loadToken)return;this.setFile(Rt(i))}catch(i){if(n!==this.loadToken)return;this.stage.innerHTML="";let r=document.createElement("div");r.className="error",r.textContent=`Couldn't show this drawing: ${i.message}`,this.stage.append(r),this.dispatchEvent(new CustomEvent("error",{detail:i}))}}setFile(n){this.file=n;for(let i of n.warnings)console.warn(`dottie-player: ${i}`);this.mount(),this.dispatchEvent(new CustomEvent("load",{detail:{file:n}}))}mount(){let n=this.file,i=n.pages[Dt(n,this.getAttribute("page"))],r=new Vt(i,this.stage,{clean:this.hasAttribute("clean")});this.playback=r,this.style.setProperty("--dottie-page",V(r.background)),this.style.setProperty("--dottie-ink",V(r.ink)),this.style.colorScheme=pt(r.background)<.5?"dark":"light",this.stage.setAttribute("aria-label",this.getAttribute("label")??i.name);let o=this.getAttribute("at"),s=i.timeline!==null&&r.frameCount>1&&o===null;this.bar.hidden=!s||this.hasAttribute("no-controls");let l=r.scenes.length>0;if(this.prev.hidden=this.next.hidden=this.sceneLabel.hidden=!l,this.scrub.max=String(r.frameCount-1),r.onFrame=c=>{if(this.scrub.value=String(c),this.time.textContent=`${r.plan.times[c].toFixed(1)}s`,l){let u=r.sceneAt(c);this.sceneLabel.textContent=u<0?"":r.sceneNames[u]}this.dispatchEvent(new CustomEvent("frame",{detail:{frame:c,time:r.plan.times[c]}}))},!s){r.drawAt(o!==null?Number(o)||0:it(i),o!==null?Kn(r,Number(o)||0):r.posterFrame),this.setPlaying(!1);return}if(r.show(0),typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches){r.show(r.posterFrame),this.setPlaying(!1);return}this.setPlaying(!this.hasAttribute("no-autoplay")&&!r.scenes.includes(0))}get paused(){return!this.playing}get currentTime(){let n=this.playback;return n&&n.frame>=0?n.plan.times[n.frame]:0}set currentTime(n){let i=this.playback;i&&(this.setPlaying(!1),i.show(Kn(i,n)))}get duration(){return this.playback?.page.timeline?.duration??0}play(){this.setPlaying(!0)}pause(){this.setPlaying(!1)}nextScene(){let n=this.playback;n&&(n.frame>=n.frameCount-1&&n.show(0),this.setPlaying(!0))}prevScene(){let n=this.playback;if(!n)return;let i=n.sceneAt(n.frame);i>=0&&n.scenes[i]===n.frame&&(i-=1),this.setPlaying(!1),n.show(i>=0?n.scenes[i]:0)}setPlaying(n){let i=this.playback;this.playing=n&&!!i&&i.frameCount>1&&i.page.timeline!==null,this.playButton.textContent=this.playing?"\u275A\u275A":"\u25B6",this.playButton.setAttribute("aria-label",this.playing?"Pause":"Play"),this.last=0,this.acc=0,this.schedule()}schedule(){this.playing&&this.visible&&!this.raf&&this.isConnected&&(this.raf=requestAnimationFrame(n=>this.tick(n)))}tick(n){this.raf=0;let i=this.playback;if(!this.playing||!i)return;let r=1e3/(i.page.timeline?.fps??12);this.last&&(this.acc+=Math.min(n-this.last,1e3)),this.last=n;let o=!1;for(;this.playing&&this.acc>=r;){this.acc-=r;let s=i.frame+1;if(s>=i.frameCount&&(i.scenes.length||this.hasAttribute("no-loop"))){this.setPlaying(!1);break}if(i.frame=s%i.frameCount,o=!0,i.scenes.includes(i.frame)){this.setPlaying(!1);break}}o&&i.show(i.frame),this.playing&&!this.visible&&(this.last=0),this.schedule()}key(n){let i=this.playback;if(!i||i.page.timeline===null||i.frameCount<=1||this.hasAttribute("at")||n.target===this.scrub&&n.key!==" ")return;let r=i.scenes.length>0,o=!0;n.key===" "?r?this.playing?this.setPlaying(!1):this.nextScene():this.setPlaying(!this.playing):n.key==="ArrowRight"?r?this.nextScene():(this.setPlaying(!1),i.show(i.frame+1)):n.key==="ArrowLeft"?r?this.prevScene():(this.setPlaying(!1),i.show(i.frame-1)):n.key==="."?(this.setPlaying(!1),i.show(i.frame+1)):n.key===","?(this.setPlaying(!1),i.show(i.frame-1)):o=!1,o&&n.preventDefault()}};k(wt,"observedAttributes",["src","page","at","clean","no-controls","label"]);function Kn(t,e){let n=0;return t.plan.times.forEach((i,r)=>{Math.abs(i-e)<Math.abs(t.plan.times[n]-e)&&(n=r)}),n}function oe(t="dottie-player"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends wt{})}var T=t=>{let e=Tt(t*1e4)/1e4;return e===0?0:e},ze=t=>[T(t.x),T(t.y)],Yt=t=>[T(t.x),T(t.y),T(t.width),T(t.height)],Xn=t=>[T(t.r),T(t.g),T(t.b),T(t.a)];function Ce(t){let e=t.timeline;if(!e)return[0];let n=e.duration,i=[0,n];for(let r=1;r<16;r++)i.push(n*(r+.37)/16);for(let r of e.markers??[])i.push(r.t);return e.poster!==null&&i.push(e.poster),[...new Set(i.map(T))].filter(r=>r>=0&&r<=n).sort((r,o)=>r-o)}function Ge(t,e){let n=W(t,e),i=tt(n),r=new Set(n.layers.filter(l=>l.visible).map(l=>l.id)),o={t:T(e)},s=t.timeline;if(s){let l=bt(s,e);o.view=l?Yt(l):null;let a=-1;(s.markers??[]).forEach((c,u)=>{c.t<=e&&(a=u)}),o.scene=a}return s?.camera?.length||(o.bounds=Yt(rt(n))),o.elements=At(n).map((l,a)=>{let c={id:l.id,kind:l.kind,z:a,seed:l.seed,frame:Yt({x:l.x,y:l.y,width:l.width,height:l.height})};if(r.has(l.layerID)||(c.hiddenLayer=!0),l.rotation!==null&&(c.rotation=T(l.rotation)),l.style.opacity!==null&&(c.opacity=T(l.style.opacity)),l.reveal!==null&&(c.reveal=T(l.reveal)),l.style.dashOffset!==null&&(c.dashOffset=T(l.style.dashOffset)),c.strokeWidth=T(l.style.strokeWidth),c.stroke=Xn(l.style.stroke),c.fill=Xn(l.style.fill),l.kind==="connector"){let[u,d]=lt(l,i);c.start=ze(u),c.end=ze(d),c.route=Z(J(l,i)).map(ze)}return c}),o}function Be(t,e,n){let i={page:e+1,name:t.name,id:t.id},r=t.timeline;if(r){let o=kt(t);i.duration=T(r.duration),i.fps=T(r.fps),i.frameCount=o.times.length,i.poster=T(r.poster??r.duration),i.size=[T(o.size.width),T(o.size.height)],r.camera?.length||(i.bounds=Yt(o.rects[0])),i.markers=(r.markers??[]).map(s=>({t:T(s.t),name:s.name}))}else i.bounds=Yt(rt(t));return i.frames=n.map(o=>Ge(t,o)),i}function Qn(t,e){return{version:t.version,pages:t.pages.map((n,i)=>Be(n,i,e??Ce(n)))}}function er(t,e={}){let n=nr(t)?t:Rt(t),i=n.pages[Dt(n,e.page===void 0?null:String(e.page))];return i=W(i,e.at??it(i)),e.clean&&(i=Wt(i,0)),re(i,e.background===void 0?{r:1,g:1,b:1,a:1}:e.background)}function nr(t){return typeof t=="object"&&t!==null&&Array.isArray(t.pages)&&Array.isArray(t.warnings)}var ir="0.3.0";oe();globalThis.Dottie??(globalThis.Dottie=Fe);})();
|