@phin-tech/dottie 0.5.4 → 0.6.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 CHANGED
@@ -22,6 +22,8 @@ fixture, so the gap is visible rather than silent.
22
22
  | Pages | Supported | [edge/themes](../fixtures/edge/themes.dottie) | `page` attribute or option: name or number |
23
23
  | Connectors: straight, curved, elbow | Supported | [edge/connectors](../fixtures/edge/connectors.dottie) | |
24
24
  | Ports and edge-following, rotated shapes, free ends | Supported | [edge/connectors](../fixtures/edge/connectors.dottie) | |
25
+ | Connectors and labels on outlines (ADR 0001) | Supported | [edge/extensions](../fixtures/edge/extensions.dottie) | Edge-following meets a `.path`'s actual outline, not its box (ray against 16-step flattened curves). Endpoints pinned with `portIndex` attach to the element's `ports`. A path's label goes in its `labelRect`. |
26
+ | Extension shapes as stored (ADR 0001) | Supported | [edge/extensions](../fixtures/edge/extensions.dottie) | Drawn from the stored path with no extension installed. The `extension` field is kept as metadata and nothing runs. Parameters, commands and handles are Dottie-only. |
25
27
  | Arrowheads: arrow, triangle, dot, bar | Supported | [edge/connectors](../fixtures/edge/connectors.dottie) | |
26
28
  | Connector labels | Supported | [edge/connectors](../fixtures/edge/connectors.dottie) | Label boxes sized with CoreText's measurements. The player paints them on the page color, like the app; Dottie's flipbook export leaves them unpainted |
27
29
  | Keys and eases (linear, in, out, in-out, hold, spring, bounce, elastic) | Supported | [edge/timeline](../fixtures/edge/timeline.dottie), [edge/eases](../fixtures/edge/eases.dottie) | Unknown ease names play linear, with a warning |
package/dist/compile.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dottie.js 0.5.4 | Apache-2.0 | https://github.com/phin-tech/dottie */
1
+ /*! dottie.js 0.6.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -41,12 +41,18 @@ var KNOWN_FIELDS = {
41
41
  "offset",
42
42
  "args",
43
43
  "image",
44
- "reveal"
44
+ "reveal",
45
+ "ports",
46
+ "labelRect",
47
+ "extension"
45
48
  ],
46
49
  strokePoint: ["x", "y"],
47
50
  subpath: ["closed", "coords"],
48
51
  inlineImage: ["data", "format"],
49
- endpoint: ["elementID", "port", "x", "y"],
52
+ endpoint: ["elementID", "port", "portIndex", "x", "y"],
53
+ extensionRef: ["id", "shape", "version", "params"],
54
+ normalizedPoint: ["x", "y"],
55
+ normalizedRect: ["x", "y", "width", "height"],
50
56
  connector: ["start", "end", "routing", "startHead", "endHead"],
51
57
  timeline: ["fps", "duration", "boil", "settle", "poster", "tracks", "camera", "markers"],
52
58
  track: ["element", "keys", "boil", "follow", "repeats", "march"],
@@ -129,9 +135,11 @@ var Reader = class {
129
135
  endpoint(v) {
130
136
  const e = isObj(v) ? v : {};
131
137
  const port = str(e.port);
138
+ const portIndex = num(e.portIndex);
132
139
  return {
133
140
  elementID: uuid(e.elementID) ?? null,
134
141
  port: port && ["top", "right", "bottom", "left"].includes(port) ? port : null,
142
+ portIndex: portIndex !== void 0 && Number.isInteger(portIndex) && portIndex >= 0 ? portIndex : null,
135
143
  x: num(e.x) ?? 0,
136
144
  y: num(e.y) ?? 0
137
145
  };
@@ -204,9 +212,36 @@ var Reader = class {
204
212
  offset: num(v.offset) ?? null,
205
213
  args: strings(v.args),
206
214
  image: this.image(v.image, images),
207
- reveal: num(v.reveal) ?? null
215
+ reveal: num(v.reveal) ?? null,
216
+ ports: Array.isArray(v.ports) ? v.ports.map((p) => {
217
+ const o = isObj(p) ? p : {};
218
+ return { x: num(o.x) ?? 0, y: num(o.y) ?? 0 };
219
+ }) : null,
220
+ labelRect: this.labelRect(v.labelRect),
221
+ extension: this.extension(v.extension)
208
222
  };
209
223
  }
224
+ labelRect(v) {
225
+ if (!isObj(v)) return null;
226
+ this.fields(v, "normalizedRect");
227
+ return { x: num(v.x) ?? 0, y: num(v.y) ?? 0, width: num(v.width) ?? 0, height: num(v.height) ?? 0 };
228
+ }
229
+ extension(v) {
230
+ if (!isObj(v)) return null;
231
+ this.fields(v, "extensionRef");
232
+ const id = str(v.id), shape = str(v.shape), version = str(v.version);
233
+ if (id === void 0 || shape === void 0 || version === void 0) {
234
+ this.warn("Skipped an extension without an id, shape or version");
235
+ return null;
236
+ }
237
+ const params = {};
238
+ if (isObj(v.params)) {
239
+ for (const [k, p] of Object.entries(v.params)) {
240
+ if (typeof p === "number" || typeof p === "boolean" || typeof p === "string") params[k] = p;
241
+ }
242
+ }
243
+ return { id, shape, version, params };
244
+ }
210
245
  click(v) {
211
246
  if (!isObj(v)) return null;
212
247
  this.fields(v, "click");
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /*! dottie.js 0.5.4 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
+ /*! dottie.js 0.6.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
3
3
  var __defProp = Object.defineProperty;
4
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
5
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -46,12 +46,18 @@ var KNOWN_FIELDS = {
46
46
  "offset",
47
47
  "args",
48
48
  "image",
49
- "reveal"
49
+ "reveal",
50
+ "ports",
51
+ "labelRect",
52
+ "extension"
50
53
  ],
51
54
  strokePoint: ["x", "y"],
52
55
  subpath: ["closed", "coords"],
53
56
  inlineImage: ["data", "format"],
54
- endpoint: ["elementID", "port", "x", "y"],
57
+ endpoint: ["elementID", "port", "portIndex", "x", "y"],
58
+ extensionRef: ["id", "shape", "version", "params"],
59
+ normalizedPoint: ["x", "y"],
60
+ normalizedRect: ["x", "y", "width", "height"],
55
61
  connector: ["start", "end", "routing", "startHead", "endHead"],
56
62
  timeline: ["fps", "duration", "boil", "settle", "poster", "tracks", "camera", "markers"],
57
63
  track: ["element", "keys", "boil", "follow", "repeats", "march"],
@@ -134,9 +140,11 @@ var Reader = class {
134
140
  endpoint(v) {
135
141
  const e = isObj(v) ? v : {};
136
142
  const port = str(e.port);
143
+ const portIndex = num(e.portIndex);
137
144
  return {
138
145
  elementID: uuid(e.elementID) ?? null,
139
146
  port: port && ["top", "right", "bottom", "left"].includes(port) ? port : null,
147
+ portIndex: portIndex !== void 0 && Number.isInteger(portIndex) && portIndex >= 0 ? portIndex : null,
140
148
  x: num(e.x) ?? 0,
141
149
  y: num(e.y) ?? 0
142
150
  };
@@ -209,9 +217,36 @@ var Reader = class {
209
217
  offset: num(v.offset) ?? null,
210
218
  args: strings(v.args),
211
219
  image: this.image(v.image, images),
212
- reveal: num(v.reveal) ?? null
220
+ reveal: num(v.reveal) ?? null,
221
+ ports: Array.isArray(v.ports) ? v.ports.map((p) => {
222
+ const o = isObj(p) ? p : {};
223
+ return { x: num(o.x) ?? 0, y: num(o.y) ?? 0 };
224
+ }) : null,
225
+ labelRect: this.labelRect(v.labelRect),
226
+ extension: this.extension(v.extension)
213
227
  };
214
228
  }
229
+ labelRect(v) {
230
+ if (!isObj(v)) return null;
231
+ this.fields(v, "normalizedRect");
232
+ return { x: num(v.x) ?? 0, y: num(v.y) ?? 0, width: num(v.width) ?? 0, height: num(v.height) ?? 0 };
233
+ }
234
+ extension(v) {
235
+ if (!isObj(v)) return null;
236
+ this.fields(v, "extensionRef");
237
+ const id = str(v.id), shape = str(v.shape), version = str(v.version);
238
+ if (id === void 0 || shape === void 0 || version === void 0) {
239
+ this.warn("Skipped an extension without an id, shape or version");
240
+ return null;
241
+ }
242
+ const params = {};
243
+ if (isObj(v.params)) {
244
+ for (const [k, p] of Object.entries(v.params)) {
245
+ if (typeof p === "number" || typeof p === "boolean" || typeof p === "string") params[k] = p;
246
+ }
247
+ }
248
+ return { id, shape, version, params };
249
+ }
215
250
  click(v) {
216
251
  if (!isObj(v)) return null;
217
252
  this.fields(v, "click");
@@ -491,7 +526,7 @@ function compile(source2, runtime, options2 = {}) {
491
526
  }
492
527
 
493
528
  // src/index.ts
494
- var VERSION = "0.5.4";
529
+ var VERSION = "0.6.0";
495
530
 
496
531
  // src/cli.ts
497
532
  var usage = `dottie-compile ${VERSION}: a Dottie drawing as one script that plays it on any page.
@@ -1,4 +1,4 @@
1
- /*! dottie.js 0.5.4 | Apache-2.0 | https://github.com/phin-tech/dottie */
1
+ /*! dottie.js 0.6.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
4
4
  var __export = (target, all) => {
@@ -97,12 +97,18 @@ var KNOWN_FIELDS = {
97
97
  "offset",
98
98
  "args",
99
99
  "image",
100
- "reveal"
100
+ "reveal",
101
+ "ports",
102
+ "labelRect",
103
+ "extension"
101
104
  ],
102
105
  strokePoint: ["x", "y"],
103
106
  subpath: ["closed", "coords"],
104
107
  inlineImage: ["data", "format"],
105
- endpoint: ["elementID", "port", "x", "y"],
108
+ endpoint: ["elementID", "port", "portIndex", "x", "y"],
109
+ extensionRef: ["id", "shape", "version", "params"],
110
+ normalizedPoint: ["x", "y"],
111
+ normalizedRect: ["x", "y", "width", "height"],
106
112
  connector: ["start", "end", "routing", "startHead", "endHead"],
107
113
  timeline: ["fps", "duration", "boil", "settle", "poster", "tracks", "camera", "markers"],
108
114
  track: ["element", "keys", "boil", "follow", "repeats", "march"],
@@ -187,9 +193,11 @@ var Reader = class {
187
193
  endpoint(v) {
188
194
  const e = isObj(v) ? v : {};
189
195
  const port = str(e.port);
196
+ const portIndex = num(e.portIndex);
190
197
  return {
191
198
  elementID: uuid(e.elementID) ?? null,
192
199
  port: port && ["top", "right", "bottom", "left"].includes(port) ? port : null,
200
+ portIndex: portIndex !== void 0 && Number.isInteger(portIndex) && portIndex >= 0 ? portIndex : null,
193
201
  x: num(e.x) ?? 0,
194
202
  y: num(e.y) ?? 0
195
203
  };
@@ -262,9 +270,36 @@ var Reader = class {
262
270
  offset: num(v.offset) ?? null,
263
271
  args: strings(v.args),
264
272
  image: this.image(v.image, images),
265
- reveal: num(v.reveal) ?? null
273
+ reveal: num(v.reveal) ?? null,
274
+ ports: Array.isArray(v.ports) ? v.ports.map((p) => {
275
+ const o = isObj(p) ? p : {};
276
+ return { x: num(o.x) ?? 0, y: num(o.y) ?? 0 };
277
+ }) : null,
278
+ labelRect: this.labelRect(v.labelRect),
279
+ extension: this.extension(v.extension)
266
280
  };
267
281
  }
282
+ labelRect(v) {
283
+ if (!isObj(v)) return null;
284
+ this.fields(v, "normalizedRect");
285
+ return { x: num(v.x) ?? 0, y: num(v.y) ?? 0, width: num(v.width) ?? 0, height: num(v.height) ?? 0 };
286
+ }
287
+ extension(v) {
288
+ if (!isObj(v)) return null;
289
+ this.fields(v, "extensionRef");
290
+ const id = str(v.id), shape = str(v.shape), version = str(v.version);
291
+ if (id === void 0 || shape === void 0 || version === void 0) {
292
+ this.warn("Skipped an extension without an id, shape or version");
293
+ return null;
294
+ }
295
+ const params = {};
296
+ if (isObj(v.params)) {
297
+ for (const [k, p] of Object.entries(v.params)) {
298
+ if (typeof p === "number" || typeof p === "boolean" || typeof p === "string") params[k] = p;
299
+ }
300
+ }
301
+ return { id, shape, version, params };
302
+ }
268
303
  click(v) {
269
304
  if (!isObj(v)) return null;
270
305
  this.fields(v, "click");
@@ -770,12 +805,42 @@ function portPoint(shape, port) {
770
805
  const p = port === "top" ? { x: midX(r), y: r.y } : port === "right" ? { x: maxX(r), y: midY(r) } : port === "bottom" ? { x: midX(r), y: maxY(r) } : { x: r.x, y: midY(r) };
771
806
  return rotated(shape, p);
772
807
  }
808
+ function flattenContour(cp) {
809
+ const out = [];
810
+ for (let s = 0; s + 3 < cp.length; s += 3) {
811
+ const seg = cp.slice(s, s + 4);
812
+ for (let k = 0; k < 16; k++) out.push(bezierPoint(seg, k / 16));
813
+ }
814
+ out.push(cp[cp.length - 1]);
815
+ return out;
816
+ }
817
+ function outlineCrossing(shape, c, d) {
818
+ let best = null;
819
+ for (const contour of shapeContours(shape)) {
820
+ const pts = flattenContour(contour.points);
821
+ const n = pts.length;
822
+ const edges = contour.closed ? n : n - 1;
823
+ for (let i = 0; i < edges; i++) {
824
+ const a = pts[i], b = pts[(i + 1) % n];
825
+ const e = { x: b.x - a.x, y: b.y - a.y }, w = { x: a.x - c.x, y: a.y - c.y };
826
+ const det = e.x * d.y - d.x * e.y;
827
+ if (det === 0) continue;
828
+ const t = (e.x * w.y - e.y * w.x) / det, s = (d.x * w.y - d.y * w.x) / det;
829
+ if (t > 0 && s >= 0 && s <= 1 && (best === null || t < best)) best = t;
830
+ }
831
+ }
832
+ return best === null ? null : { x: c.x + d.x * best, y: c.y + d.y * best };
833
+ }
773
834
  function edgePoint(shape, toward) {
774
835
  const r = frame(shape);
775
836
  const c = center(shape);
776
837
  const target = unrotated(shape, toward);
777
838
  const dx = target.x - c.x, dy = target.y - c.y;
778
839
  if (!((dx !== 0 || dy !== 0) && r.width > 0 && r.height > 0)) return c;
840
+ if (shape.kind === "path") {
841
+ const hit = outlineCrossing(shape, c, { x: dx, y: dy });
842
+ if (hit) return rotated(shape, hit);
843
+ }
779
844
  const hw = r.width / 2, hh = r.height / 2;
780
845
  let t;
781
846
  if (shape.kind === "ellipse") t = 1 / Math.sqrt(dx * dx / (hw * hw) + dy * dy / (hh * hh));
@@ -787,9 +852,15 @@ function reference(ep, index) {
787
852
  const s = ep.elementID ? index.get(ep.elementID) : void 0;
788
853
  return s ? center(s) : { x: ep.x, y: ep.y };
789
854
  }
855
+ function normalizedPoint(shape, p) {
856
+ const r = frame(shape);
857
+ return rotated(shape, { x: r.x + p.x * r.width, y: r.y + p.y * r.height });
858
+ }
790
859
  function resolve(ep, other, index) {
791
860
  const s = ep.elementID ? index.get(ep.elementID) : void 0;
792
861
  if (!s) return { x: ep.x, y: ep.y };
862
+ const i = ep.portIndex, ports = s.ports ?? [];
863
+ if (typeof i === "number" && Number.isInteger(i) && i >= 0 && i < ports.length) return normalizedPoint(s, ports[i]);
793
864
  return ep.port ? portPoint(s, ep.port) : edgePoint(s, other);
794
865
  }
795
866
  function endpoints(e, index) {
@@ -2900,7 +2971,7 @@ function svgElement(e, index, labelBackground) {
2900
2971
  }
2901
2972
  s += `<path d="${outline(e).data()}" fill="none" ${strokeAttrs}/>
2902
2973
  `;
2903
- if (text) s += e.kind === "note" ? noteMarkup(text, e) : textElement(text, frame(e), e, true);
2974
+ if (text) s += e.kind === "note" ? noteMarkup(text, e) : textElement(text, e.kind === "path" ? pathLabelBox(e) : frame(e), e, true);
2904
2975
  return s;
2905
2976
  }
2906
2977
  default:
@@ -2913,6 +2984,11 @@ function placeholder(e, strokeAttrs) {
2913
2984
  return `<path d="${p.data()}" fill="none" ${strokeAttrs} stroke-opacity="0.5" stroke-dasharray="6 4"/>
2914
2985
  ` + textElement(`${e.kind}${e.text ? `: ${e.text}` : ""}`, f, { ...e, style: { ...e.style, fontSize: Math.min(e.style.fontSize, 12) } }, true);
2915
2986
  }
2987
+ function pathLabelBox(e) {
2988
+ const f = frame(e), r = e.labelRect;
2989
+ if (!r) return f;
2990
+ return { x: f.x + r.x * f.width, y: f.y + r.y * f.height, width: r.width * f.width, height: r.height * f.height };
2991
+ }
2916
2992
  function textElement(text, f, e, centered) {
2917
2993
  const size = e.style.fontSize;
2918
2994
  const lines = text.split("\n");
@@ -3611,7 +3687,7 @@ function render(source, options = {}) {
3611
3687
  function isFile(v) {
3612
3688
  return typeof v === "object" && v !== null && Array.isArray(v.pages) && Array.isArray(v.warnings);
3613
3689
  }
3614
- var VERSION = "0.5.4";
3690
+ var VERSION = "0.6.0";
3615
3691
 
3616
3692
  // src/player-entry.ts
3617
3693
  definePlayer();
@@ -1,6 +1,6 @@
1
- /*! dottie.js 0.5.4 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
- "use strict";(()=>{var nn=Object.defineProperty;var xi=(t,e,n)=>e in t?nn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ki=(t,e)=>{for(var n in e)nn(t,n,{get:e[n],enumerable:!0})};var P=(t,e,n)=>xi(t,typeof e!="symbol"?e+"":e,n);var tn={};ki(tn,{BOIL_DRAWINGS:()=>ke,DottieFormatError:()=>Q,DottiePlayer:()=>Rt,KINDS:()=>on,KNOWN_FIELDS:()=>sn,MAX_DURATION:()=>gt,MAX_MARCH:()=>be,Playback:()=>Yt,SUPPORTED_VERSION:()=>Or,VERSION:()=>Lr,allowedURL:()=>Ht,black:()=>ut,bounds:()=>tt,cameraView:()=>Mt,clampFPS:()=>xt,clampMarch:()=>ln,clampTime:()=>C,clear:()=>an,cloneElement:()=>V,definePlayer:()=>fe,elementIndex:()=>Mi,frameTimes:()=>ee,inkOnDark:()=>cn,inspect:()=>bi,inspectFrame:()=>Ze,inspectPage:()=>Je,isAutomaticInk:()=>we,luminance:()=>kt,orderedElements:()=>ht,pageIndex:()=>Bt,parseDottie:()=>St,plan:()=>At,posterTime:()=>at,render:()=>Ir,repeatIsValid:()=>jt,resolved:()=>U,sameColor:()=>bt,sampleTimes:()=>Qe,sceneAt:()=>Yn,stableSortBy:()=>Nt,still:()=>zn,svg:()=>de,svgParts:()=>ct,themeNamed:()=>pt,themes:()=>Ke,transientElements:()=>Bn,withRoughness:()=>Gt});var Or=2,on=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image","symbol"],wi=["linear","easeIn","easeOut","easeInOut","hold","spring","bounce","elastic"],sn={file:["version","pages","images"],page:["id","name","layers","elements","theme","guidesX","guidesY","guidesLocked","timeline","symbols"],symbol:["id","name","width","height","layers","elements","timeline","button","params"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","gridSize","opacity","dashOffset"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","anchor","click","hover","symbol","playback","offset","args","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"],click:["scene","url"],hover:["stroke","fill","opacity"]},gt=3600,be=1e4,ln=t=>t===void 0||!Number.isFinite(t)||t===0?null:Math.min(Math.max(t,-be),be),ke=3,ut={r:.12,g:.12,b:.13,a:1},an={r:0,g:0,b:0,a:0},cn={r:.93,g:.93,b:.94,a:1},Q=class extends Error{},S=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),v=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,$=t=>typeof t=="string"?t:void 0,rn=t=>S(t)&&Object.values(t).every(e=>typeof e=="string")?{...t}:null,z=t=>typeof t=="boolean"?t:void 0,Y=t=>typeof t=="string"?t.toUpperCase():void 0;function C(t){return Number.isFinite(t)?Math.min(Math.max(t,0),gt):t===1/0?gt:0}function xt(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function Ht(t){let e=t.trim();return!/^(https?:\/\/|mailto:)/i.test(e)||[...e].length<=7||/[\u0000-\u001f\u007f-\u009f]/.test(e)?null:e}function yt(t){if(!S(t))return;let e=v(t.r),n=v(t.g),i=v(t.b);if(!(e===void 0||n===void 0||i===void 0))return{r:e,g:n,b:i,a:v(t.a)??1}}var xe=class{constructor(){P(this,"warnings",[]);P(this,"seen",new Set)}warn(e){this.seen.has(e)||(this.seen.add(e),this.warnings.push(e))}fields(e,n){let i=sn[n];for(let r of Object.keys(e))i.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=S(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:yt(n.stroke)??{...ut},fill:yt(n.fill)??{...an},fillStyle:["solid","hachure","crossHatch","grid"].includes(i)?i:"solid",strokeWidth:v(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:v(n.roughness)??1,bowing:v(n.bowing)??1,fontSize:v(n.fontSize)??18,gridSize:v(n.gridSize)??null,opacity:v(n.opacity)??null,dashOffset:v(n.dashOffset)??null}}endpoint(e){let n=S(e)?e:{},i=$(n.port);return{elementID:Y(n.elementID)??null,port:i&&["top","right","bottom","left"].includes(i)?i:null,x:v(n.x)??0,y:v(n.y)??0}}connector(e){if(!S(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(!S(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 Pi.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(!S(e))return null;this.fields(e,"element");let i=Y(e.id),r=$(e.kind),o=Y(e.layerID);if(!i||!r||!o)return this.warn("Skipped an element without an id, kind or layer"),null;on.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let s=Array.isArray(e.subpaths)?e.subpaths.filter(S).map(l=>({closed:z(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:i,kind:r,layerID:o,x:v(e.x)??0,y:v(e.y)??0,width:v(e.width)??0,height:v(e.height)??0,style:this.style(e.style),seed:(v(e.seed)??1)>>>0,text:$(e.text)??null,connector:this.connector(e.connector),groupID:Y(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(S).map(l=>({x:v(l.x)??0,y:v(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:s,evenOdd:z(e.evenOdd)??null,rotation:v(e.rotation)??null,link:Y(e.link)??null,anchor:$(e.anchor)??null,click:this.click(e.click),hover:this.hover(e.hover),symbol:Y(e.symbol)??null,playback:this.playback(e.playback),offset:v(e.offset)??null,args:rn(e.args),image:this.image(e.image,n),reveal:v(e.reveal)??null}}click(e){if(!S(e))return null;this.fields(e,"click");let n=$(e.url),i=n===void 0?null:Ht(n);return n!==void 0&&i===null&&this.warn("Skipped a click link that isn't http, https or mailto"),{scene:$(e.scene)??null,url:i}}playback(e){let n=$(e);return n===void 0?null:["loop","once","still","click"].includes(n)?n:"loop"}symbol(e,n){if(!S(e))return null;this.fields(e,"symbol");let i=Y(e.id);if(!i)return this.warn("Skipped a symbol without an id"),null;let r=s=>{let l=v(s);return Math.max(1,l??100)},o=(Array.isArray(e.layers)?e.layers:[]).filter(S).flatMap(s=>{let l=Y(s.id);return l?[{id:l,name:$(s.name)??"",visible:z(s.visible)??!0,locked:z(s.locked)??!1}]:[]});return o.length===0&&o.push({id:`${i}-LAYER`,name:"Layer 1",visible:!0,locked:!1}),{id:i,name:$(e.name)??"Symbol",width:r(e.width),height:r(e.height),layers:o,elements:(Array.isArray(e.elements)?e.elements:[]).map(s=>this.element(s,n)).filter(s=>s!==null),timeline:this.timeline(e.timeline),button:z(e.button)??null,params:rn(e.params)}}hover(e){return S(e)?(this.fields(e,"hover"),{stroke:yt(e.stroke)??null,fill:yt(e.fill)??null,opacity:v(e.opacity)??null}):null}ease(e){let n=$(e);return n===void 0?null:wi.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!S(e))return null;this.fields(e,"keyframe");let n=v(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 u=v(e[a]);u!==void 0&&(i[a]=u)}let r=yt(e.stroke),o=yt(e.fill),s=z(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(!S(e))return null;this.fields(e,"track");let n=Y(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<=gt);Nt(i,s=>s.t);let r=Array.isArray(e.follow)?e.follow.filter(S).flatMap(s=>{let l=Y(s.path),a=v(s.start),u=v(s.end);return!l||a===void 0||u===void 0||a<0||u>gt?[]:[{path:l,start:a,end:u,ease:this.ease(s.ease),reverse:z(s.reverse)??null,orient:z(s.orient)??null,laps:v(s.laps)??null}]}):null,o=Array.isArray(e.repeats)?e.repeats.filter(S).flatMap(s=>{let l=v(s.start),a=v(s.end);if(l===void 0||a===void 0)return[];let u=v(s.count),c={start:l,end:a,count:u===void 0?null:Math.trunc(u)};return jt(c)?[c]:[]}):null;return{element:n,keys:i,boil:z(e.boil)??null,follow:r,repeats:o,march:ln(v(e.march))}}timeline(e){if(!S(e))return null;this.fields(e,"timeline");let n=v(e.boil),i=Array.isArray(e.camera)?e.camera.filter(S).flatMap(s=>{let l=v(s.t),a=v(s.x),u=v(s.y),c=v(s.width),h=v(s.height);return l===void 0||a===void 0||u===void 0||c===void 0||h===void 0?[]:c>1&&h>1&&l>=0?[{t:l,x:a,y:u,width:c,height:h,ease:this.ease(s.ease)}]:[]}):null;i&&Nt(i,s=>s.t);let r=Array.isArray(e.markers)?e.markers.filter(S).flatMap(s=>{let l=v(s.t);return l!==void 0&&l>=0?[{t:l,name:$(s.name)??""}]:[]}):null;r&&Nt(r,s=>s.t);let o=v(e.poster);return{fps:xt(v(e.fps)??12),duration:C(v(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:z(e.settle)??null,poster:o===void 0?null:C(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(!S(e))throw new Q(`Page ${i} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(S).flatMap(o=>{let s=Y(o.id);return s?[{id:s,name:$(o.name)??"",visible:z(o.visible)??!0,locked:z(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:Y(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),symbols:Array.isArray(e.symbols)?e.symbols.map(o=>this.symbol(o,n)).filter(o=>o!==null):null}}},Pi=/^[A-Za-z0-9+/=\s]*$/;function jt(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=gt&&(t.count===null||t.count>=1&&t.count<=1e4)}function Nt(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 St(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new Q(`Not JSON: ${s.message}`)}if(!S(e))throw new Q("Not a Dottie drawing");let n=v(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 xe;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(S(e.images))for(let[s,l]of Object.entries(e.images))S(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 kt(t){return .2126*t.r+.7152*t.g+.0722*t.b}function bt(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function we(t){return bt(t,ut)||bt(t,cn)}function V(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 ht(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 Mi(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}var un=.5522847498307936,E=class t{constructor(){P(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*un,l=o*un;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 wt(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],u=o.points[s],c=i/l;r.lineTo({x:a.x+(u.x-a.x)*c,y:a.y+(u.y-a.y)*c}),i=0;break}}return r}data(){let e=[];for(let n of this.segments)switch(n.op){case"M":e.push(`M${x(n.p.x)} ${x(n.p.y)}`);break;case"L":e.push(`L${x(n.p.x)} ${x(n.p.y)}`);break;case"Q":e.push(`Q${x(n.c.x)} ${x(n.c.y)} ${x(n.p.x)} ${x(n.p.y)}`);break;case"C":e.push(`C${x(n.c1.x)} ${x(n.c1.y)} ${x(n.c2.x)} ${x(n.c2.y)} ${x(n.p.x)} ${x(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function It(t){return t<0?-Math.round(-t):Math.round(t)}function x(t){let e=It(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var wt=class{constructor(e){P(this,"points");P(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}}},N=t=>t.x+t.width/2,H=t=>t.y+t.height/2,G=t=>t.x+t.width,F=t=>t.y+t.height;function Pe(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(G(t),G(e))-n,height:Math.max(F(t),F(e))-i}}function Pt(t,e,n){return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}function nt(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 vi(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 hn(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(vi(r,l/s))}return n}var L=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),W=t=>t.rotation??0,$t=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),it=(t,e)=>nt(e,$t(t),W(t)),mn=(t,e)=>nt(e,$t(t),-W(t));function dn(t){let e=L(t);if(W(t)===0)return e;let n=[{x:e.x,y:e.y},{x:G(e),y:e.y},{x:G(e),y:F(e)},{x:e.x,y:F(e)}].map(l=>it(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 fn(t,e){if(!we(t.style.stroke))return t;let n=V(t),r=(t.style.fillStyle==="solid"||t.style.fillStyle==="grid")&&t.style.fill.a>=.5&&kt(t.style.fill)>.5;return n.style.stroke=kt(e)>.5&&r?{...ut}:{...e},n}function _t(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 Me(t){let e=new E;for(let n of _t(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 Ai(t,e){let n=L(t),i=e==="top"?{x:N(n),y:n.y}:e==="right"?{x:G(n),y:H(n)}:e==="bottom"?{x:N(n),y:F(n)}:{x:n.x,y:H(n)};return it(t,i)}function Ri(t,e){let n=L(t),i=$t(t),r=mn(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,u;return t.kind==="ellipse"?u=1/Math.sqrt(o*o/(l*l)+s*s/(a*a)):t.kind==="diamond"?u=1/(Math.abs(o)/l+Math.abs(s)/a):u=Math.min(o!==0?l/Math.abs(o):1/0,s!==0?a/Math.abs(s):1/0),it(t,{x:i.x+o*u,y:i.y+s*u})}function pn(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?$t(n):{x:t.x,y:t.y}}function yn(t,e,n){let i=t.elementID?n.get(t.elementID):void 0;return i?t.port?Ai(i,t.port):Ri(i,e):{x:t.x,y:t.y}}function Z(t,e){let n=t.connector;return n?[yn(n.start,pn(n.end,e),e),yn(n.end,pn(n.start,e),e)]:[{x:0,y:0},{x:0,y:0}]}function rt(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 ot(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[i,r]=Z(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=h=>h===null?null:h==="top"||h==="bottom",u=a(n.start.port)??!l,c=a(n.end.port)??!l;if(u&&c){let h=i.y+s/2;return{kind:"polyline",points:[i,{x:i.x,y:h},{x:r.x,y:h},r]}}if(!u&&!c){let h=i.x+o/2;return{kind:"polyline",points:[i,{x:h,y:i.y},{x:h,y:r.y},r]}}return u?{kind:"polyline",points:[i,{x:i.x,y:r.y},r]}:{kind:"polyline",points:[i,{x:r.x,y:i.y},r]}}}}function gn(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 bn(t,e){let n=rt(ot(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 xn(t,e){let n=rt(ot(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 q(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}function Ae(t,e,n){let i=t[1]+n>>>0,r=i<t[1]?1:0;return[t[0]+e+r>>>0,i]}function Ti(t,e){let n=t&65535,i=t>>>16,r=e&65535,o=e>>>16,s=n*r,l=n*o,a=i*r,u=i*o,c=l+a,h=s+c%65536*65536;return[u+Math.floor(c/65536)+Math.floor(h/4294967296)>>>0,h>>>0]}function Re(t,e,n){let i=Ti(t[1],n);return[i[0]+Math.imul(t[0],n)+Math.imul(t[1],e)>>>0,i[1]]}function ve(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function kn(t){return t=Re(ve(t,30),3210233709,484763065),t=Re(ve(t,27),2496678331,321982955),ve(t,31)}var st=class{constructor(e){P(this,"state");this.state=Ae([0,e>>>0],2654435769,2135587861)}next(){return this.state=Ae(this.state,2654435769,2135587861),kn(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 qt(t,e){let n=Ae([0,t>>>0],...Ei(e));return n=kn(n),Math.max(1,n[1]>>>0)}function Ei(t){let e=Re([0,t>>>0],2654435769,2135587861);return[e[0],e[1]]}var wn=(t,e,n)=>t.signed()*e*n;function J(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,u=l<20?l/10:2;for(let c=0;c<2;c++){let h=(c===0?1:.5)*a,f=()=>wn(n,u,i)*h,d=n.unit()*.4+.3,m=wn(n,l/60,i)*r*a,p=e.x-t.x,b=e.y-t.y,M=-b/l,w=p/l,y=o?t:{x:t.x+f(),y:t.y+f()},R=o?e:{x:e.x+f(),y:e.y+f()},A=t.x+p*d*.66+M*m+f()*.5,k=t.y+b*d*.66+w*m+f()*.5,g=t.x+p*(.5+d*.5)+M*m+f()*.5,T=t.y+b*(.5+d*.5)+w*m+f()*.5;s.moveTo(y),s.curveTo(R,{x:A,y:k},{x:g,y:T})}}function Te(t,e,n,i){let r=new E;for(let o=0;o<t.length;o++)J(t[o],t[(o+1)%t.length],e,n,i,!1,r);return r}function Pn(t,e,n){let i=new E,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))),u=Math.min(2.5,(s+l)/25)*n;for(let c=0;c<2;c++){let h=e.unit()*2*Math.PI,f=2*Math.PI*(c===0?1:1.04),d=Math.trunc(a*f/(2*Math.PI))+1,m=[];for(let p=0;p<d;p++){let b=h+f*p/a,M=e.signed()*u,w=e.signed()*u;m.push({x:r+s*Math.cos(b)+M,y:o+l*Math.sin(b)+w})}Si(m,i)}return i}function Si(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 Ee=-41*Math.PI/180;function Mn(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 u=(f,d)=>({x:f*i-d*r,y:f*r+d*i}),c=[],h=l+n/2;for(;h<a;){let f=[];for(let d of o)for(let m=0;m<d.length;m++){let p=d[m],b=d[(m+1)%d.length];(p.y<=h&&h<b.y||b.y<=h&&h<p.y)&&f.push(p.x+(h-p.y)/(b.y-p.y)*(b.x-p.x))}f.sort((d,m)=>d-m);for(let d=0;d+1<f.length;d+=2)f[d+1]-f[d]>.5&&c.push([u(f[d],h),u(f[d+1],h)]);h+=n}return c}var Tn=2,Se=.75,Ii=.8,An=.6;function En(t,e){return[...Rn(t,e,!1),...Rn(t,e,!0)]}function Rn(t,e,n){if(!(e>0))return[];let i=u=>n?{x:u.y,y:u.x}:u,r=t.filter(u=>u.length>=3).map(u=>u.map(i)),o=r.flat().map(u=>u.y);if(o.length===0)return[];let s=Math.min(...o),l=Math.max(...o),a=[];for(let u=Math.floor(s/e)*e;u<l-.5;u+=e){if(!(u>s+.5))continue;let c=[];for(let h of r)for(let f=0;f<h.length;f++){let d=h[f],m=h[(f+1)%h.length];(d.y<=u&&u<m.y||m.y<=u&&u<d.y)&&c.push(d.x+(u-d.y)/(m.y-d.y)*(m.x-d.x))}c.sort((h,f)=>h-f);for(let h=0;h+1<c.length;h+=2)c[h+1]-c[h]>.5&&a.push([i({x:c[h],y:u}),i({x:c[h+1],y:u})])}return a}function Sn(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 Ie(t){return t.style.fillStyle==="grid"&&t.style.fill.a>0&&["rectangle","ellipse","diamond","path"].includes(t.kind)}function Kt(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 In(t,e,n){let i=n/Tn;return{x:(t+.5+(Kt(t,e,1)-.5)*An)*i,y:(e+.5+(Kt(t,e,2)-.5)*An)*i}}function $i(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=In(t+o,e+s,i);r=Math.min(r,Math.hypot(l.x-n.x,l.y-n.y))}return r*Ii}function Li(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,u=t.y+i*s*l;return[{x:a-i*o,y:u-r*o},{x:a+i*o,y:u+r*o}]})}function Di(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 Oi(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,u=l*l+a*a,c=u>0?Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*a)/u)):0;n=Math.min(n,Math.hypot(t.x-(o.x+c*l),t.y-(o.y+c*a)))}return n}var Ci=(t,e)=>e.x>=t.x&&e.x<t.x+t.width&&e.y>=t.y&&e.y<t.y+t.height,Ut=new Map;function $n(t){if(t.length===0)return[];let e=t.map(r=>[r.kind,r.x,r.y,r.width,r.height,r.rotation??0,mt(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=Ut.get(e);if(n)return n;let i=Vi(t);return Ut.size>=16&&Ut.clear(),Ut.set(e,i),i}function Vi(t){let e=t.map(o=>{let s=$e(o).map(d=>d.map(m=>it(o,m))),l=s.flat(),a=l.map(d=>d.x),u=l.map(d=>d.y),c=a.length?Math.min(...a):0,h=u.length?Math.min(...u):0,f={x:c,y:h,width:(a.length?Math.max(...a):0)-c,height:(u.length?Math.max(...u):0)-h};return{contours:s,box:f,cell:mt(o),element:o}}),n=e.map(()=>[]),i=new Set;for(let o of e){let s=o.cell/Tn,l=Pt(o.box,-o.cell,-o.cell),a=Math.floor(l.x/s),u=Math.ceil((l.x+l.width)/s),c=Math.floor(l.y/s),h=Math.ceil((l.y+l.height)/s),f=Se*o.cell;for(let d=a;d<u;d++)for(let m=c;m<h;m++){let p=`${o.cell}|${d}|${m}`;if(i.has(p))continue;i.add(p);let b=In(d,m,o.cell),M=1/0,w=-1;for(let k=0;k<e.length;k++){let g=e[k];if(!Ci(Pt(g.box,-f,-f),b))continue;if(Di(g.contours,b)){M=0;break}let T=Oi(b,g.contours);T<M&&(M=T,w=k)}if(!(M>0&&M<=f&&w>=0))continue;let y=Kt(d,m,3)*Math.PI,R=$i(d,m,b,o.cell),A=Math.trunc(Kt(d,m,4)*4294967296)>>>0;for(let[k,g]of Li(b,y,R))n[w].push([k,g,A])}}let r=[];return e.forEach((o,s)=>{if(n[s].length===0)return;let l=o.element,a=new E;for(let[u,c,h]of n[s])l.style.roughness<=0?a.moveTo(u).lineTo(c):J(u,c,new st(h),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 Xt=class{constructor(e=6e3){P(this,"map",new Map);P(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}},Dn=new Xt,Wi=new Xt;function On(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"?mt(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var mt=t=>Math.max(8,t.style.gridSize??50);function dt(t){return t.kind==="freehand"&&t.path===null?Ln(t):Dn.get(On(t,0),()=>Ln(t))}function Cn(t){return[{x:t.x,y:t.y},{x:G(t),y:t.y},{x:G(t),y:F(t)},{x:t.x,y:F(t)}]}function Qt(t){return[{x:N(t),y:t.y},{x:G(t),y:H(t)},{x:N(t),y:F(t)},{x:t.x,y:H(t)}]}function Ln(t){let e=L(t),n=new st(t.seed),i=t.style.roughness;switch(t.kind){case"ellipse":return i<=0?E.ellipse(e):Pn(e,n,i);case"diamond":return i<=0?new E().addLines(Qt(e)).close():Te(Qt(e),n,i,t.style.bowing);case"text":case"connector":return E.rect(e);case"freehand":return Yi(t);case"path":return i<=0?Me(t):zi(t,n);default:return i<=0?E.rect(e):Te(Cn(e),n,i,t.style.bowing)}}function zi(t,e){let n=t.style.roughness,i=new E;for(let r of _t(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],u=o[3*s+2],c=o[3*s+3];if(a.x===l.x&&a.y===l.y&&u.x===c.x&&u.y===c.y){J(l,c,e,n,t.style.bowing,!0,i);continue}let h=Math.hypot(a.x-l.x,a.y-l.y)+Math.hypot(u.x-a.x,u.y-a.y)+Math.hypot(c.x-u.x,c.y-u.y),f=Math.min(2.5,h/30)*n;for(let d=0;d<2;d++){let m=d===0?1:.5,p=()=>e.signed()*f*m;i.moveTo(l);let b=a.x+p(),M=a.y+p(),w=u.x+p(),y=u.y+p();i.curveTo(c,{x:b,y:M},{x:w,y})}}}return i}function Yi(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 E().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 E;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 $e(t){return t.kind!=="path"?[Bi(t)]:_t(t).map(e=>hn(e.points,3))}function Bi(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:N(e)+e.width/2*Math.cos(r),y:H(e)+e.height/2*Math.sin(r)})}return n}return t.kind==="diamond"?Qt(e):Cn(e)}function Zt(t){let e=L(t);return t.kind==="ellipse"?E.ellipse(e):t.kind==="path"?Me(t):t.kind==="diamond"?new E().addLines(Qt(e)).close():E.rect(e)}function Le(t){return t.style.fillStyle==="solid"||["freehand","connector","text","image"].includes(t.kind)?new E:Dn.get(On(t,1),()=>Gi(t))}function Gi(t){let e=$e(t),n=new st((t.seed^1540483477)>>>0),i=new E;if(t.style.fillStyle==="grid"){for(let[s,l]of En(e,mt(t)))t.style.roughness<=0?i.moveTo(s).lineTo(l):J(s,l,n,t.style.roughness*.3,.3,!1,i);return i}let r=Math.max(4,t.style.strokeWidth*4),o=[Ee];t.style.fillStyle==="crossHatch"&&o.push(Ee+Math.PI/2);for(let s of o)for(let[l,a]of Mn(e,s,r))t.style.roughness<=0?i.moveTo(l).lineTo(a):J(l,a,n,t.style.roughness*.6,.5,!1,i);return i}function Jt(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 De(t,e){let n=t.connector;if(!n)return[new E,new E];let[i,r]=Z(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 Wi.get(o,()=>Fi(t,e))}function Fi(t,e){let n=t.connector,i=new st(t.seed),r=t.style.roughness,o=t.style.bowing,s=new E,l=new E,a=ot(t,e);if(a.kind==="polyline"){let d=a.points;for(let m=0;m<Math.max(d.length-1,0);m++)r<=0?s.moveTo(d[m]).lineTo(d[m+1]):J(d[m],d[m+1],i,r,o,!0,s)}else{s.moveTo(a.a);let d=r*3,m=()=>i.signed()*d,p=a.b.x+m(),b=a.b.y+m(),M=a.c.x+m(),w=a.c.y+m();s.curveTo(a.d,{x:p,y:b},{x:M,y:w})}let u=rt(a),c=Math.max(10,t.style.strokeWidth*5),h=(d,m)=>{r<=0?s.moveTo(d).lineTo(m):J(d,m,i,r*.5,0,!0,s)},f=(d,m,p)=>{let[b,M]=gn(m,p,c);switch(d){case"arrow":h(b,m),h(M,m);break;case"triangle":h(b,m),h(M,m),h(b,M),l.moveTo(m).lineTo(b).lineTo(M).close();break;case"dot":{let w=c*.32,y=Math.atan2(m.y-p.y,m.x-p.x),R=m.x-w*Math.cos(y),A=m.y-w*Math.sin(y);l.addEllipse({x:R-w,y:A-w,width:2*w,height:2*w});break}case"bar":{let w=Math.atan2(m.y-p.y,m.x-p.x)+Math.PI/2,y=c*.5;h({x:m.x-y*Math.cos(w),y:m.y-y*Math.sin(w)},{x:m.x+y*Math.cos(w),y:m.y+y*Math.sin(w)});break}}};return u.length>1&&(f(n.endHead,u[u.length-1],u[u.length-2]),f(n.startHead,u[0],u[1])),[s,l]}function Ve(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 Ni(e);case"bounce":return Hi(e);case"elastic":return ji(e)}}function Ni(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 Hi(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 ji(t){return t<=0?0:t>=1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1}var Lt=(t,e)=>t%e;function Dt(t,e){let n=(t.repeats??[]).filter(jt).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+Lt(e-i.start,r);let o=r*i.count;if(e<i.start+o)return i.start+Lt(e-i.start,r);e-=o-r}return e}function Oe(t,e,n,i,r){e=Dt(t,e);let o,s;for(let c of t.keys)if(n(c)!==void 0)if(c.t<=e)o=c;else{s=c;break}if(!o&&!s)return i;if(o&&!s)return n(o);if(!o&&s)return n(s);let l=o,a=s,u=a.t-l.t>0?(e-l.t)/(a.t-l.t):1;return r(n(l),n(a),Ve(l.ease??"linear",u))}var _i=(t,e,n)=>t+(e-t)*n,te=(t,e,n)=>Math.min(Math.max(t+(e-t)*n,0),1),Vn=(t,e,n)=>({r:te(t.r,e.r,n),g:te(t.g,e.g,n),b:te(t.b,e.b,n),a:te(t.a,e.a,n)});function lt(t,e,n,i){return Oe(t,e,r=>r[n],i,_i)}function qi(t,e){e=Dt(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,bt)||n(r=>r.fill,bt)||i("reveal")||i("opacity")}function Ce(t,e){e=Dt(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 Ui(t,e,n){if(e=V(e),t.keys.some(i=>i.reveal!==void 0)){let i=lt(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(lt(t,n,"opacity",e.style.opacity??1),0),1);e.style.opacity=i>=1?null:i}return e.kind==="connector"||(e.x=lt(t,n,"x",e.x),e.y=lt(t,n,"y",e.y),e.width=Math.max(0,lt(t,n,"width",e.width)),e.height=Math.max(0,lt(t,n,"height",e.height)),t.keys.some(i=>i.rotation!==void 0)&&(e.rotation=lt(t,n,"rotation",W(e))),e.style.strokeWidth=Math.max(0,lt(t,n,"strokeWidth",e.style.strokeWidth)),e.style.stroke=Oe(t,n,i=>i.stroke,e.style.stroke,Vn),e.style.fill=Oe(t,n,i=>i.fill,e.style.fill,Vn)),e}function Ki(t,e){e=Dt(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 Xi(t,e){if(t.kind==="connector")return new wt(rt(ot(t,q(e))));let n=V(t);n.style.roughness=0;let i=dt(n).contours()[0]??[];return new wt(W(t)===0?i:i.map(r=>it(t,r)))}function Qi(t,e,n,i){let r=Ki(t,n);if(!r)return e;n=Dt(t,n);let o=i.elements.find(h=>h.id===r.path);if(!o||o.id===e.id)return e;let s=Xi(o,i),l=r.end-r.start,a=Math.min(Math.max(Ve(r.ease??"easeInOut",l>0?Math.min(1,(n-r.start)/l):1),0),1)*(r.laps??1);a>1&&(a=Lt(a,1)===0?1:Lt(a,1)),r.reverse===!0&&(a=1-a);let u=s.point(a),c=V(e);if(c.x=u.x-e.width/2,c.y=u.y-e.height/2,r.orient===!0){let h=r.reverse===!0?-.01:.01,f=s.point(a-h/2),d=s.point(a+h/2);(f.x!==d.x||f.y!==d.y)&&(c.rotation=Math.atan2(d.y-f.y,d.x-f.x))}return c}function Zi(t,e,n,i){if(!(n>0))return 0;let r=C(t.duration);if(r>0){let s=It(e*r/n);s!==0&&(e=s*n/r)}let o=Lt(e*i,n);return o<0?-o:o===0?0:n-o}function Ji(t){let e=new Map;for(let n of t.tracks)e.has(n.element)||e.set(n.element,n);return e}function U(t,e){return j(Ot(t,e),C(e))}function Ot(t,e){let n=t.timeline;if(!n)return t;e=C(e);let i=Ji(n),r=n.boil===null?null:Math.trunc(Math.floor(e*xt(n.fps)+1e-9)/Math.max(1,n.boil))%ke>>>0,o=new Set;for(let d of i.values())Ce(d,e)||o.add(d.element);let s=null;if(n.settle===!0){s=new Set;for(let d of i.values())qi(d,e)&&s.add(d.element)}let l=d=>{let m=i.get(d.id)?.boil;return m??(s?d.connector?[d.connector.start.elementID,d.connector.end.elementID].some(p=>p!==null&&s.has(p)):s.has(d.id):!0)},a=t.elements.map(d=>{let m=i.get(d.id),p=m?Ui(m,d,e):d;r!==null&&r>0&&l(d)&&(p===d&&(p=V(d)),p.seed=qt(d.seed,r));let b=m?.march!=null?Jt(p.style.dash,p.style.strokeWidth):null;return m?.march!=null&&b&&(p===d&&(p=V(d)),p.style.dashOffset=Zi(n,m.march,b.reduce((M,w)=>M+w,0),e)),p});a=a.map((d,m)=>o.has(d.id)?t.elements[m]:d);let u={...t,elements:a,timeline:null};a=a.map(d=>{let m=i.get(d.id);return m?Qi(m,d,e,u):d});let c={...t,elements:a,timeline:null},h=q(c),f=new Set(o);return a=a.map(d=>{let m=d.connector;if(!m||![m.start.elementID,m.end.elementID].some(w=>w!==null&&o.has(w)))return d;if(!(i.get(d.id)?.keys.some(w=>w.visible!==void 0)??!1))return f.add(d.id),d;let[p,b]=Z(d,h),M=V(d);return M.connector.start={elementID:null,port:m.start.port,x:p.x,y:p.y},M.connector.end={elementID:null,port:m.end.port,x:b.x,y:b.y},M}),{...t,elements:a.filter(d=>!f.has(d.id)),timeline:null}}function at(t){return t.timeline?t.timeline.poster??t.timeline.duration:0}function zn(t){return t.timeline?U(t,at(t)):j(t,0)}function tr(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 Wn(n[0]);if(!r)return Wn(i);let o=Ve(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 Wn=t=>({x:t.x,y:t.y,width:t.width,height:t.height});function Mt(t,e){let n=t.camera?.[0],i=tr(t,e);return!n||!i||!(i.width>0&&i.height>0)?null:er(i,n.width/n.height)}function er(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 nr(t){return Math.max(1,Math.ceil(C(t.duration)*xt(t.fps)))}function ee(t){let e=xt(t.fps),n=[];for(let r=0;r<nr(t);r++)n.push(r/e);let i=n[n.length-1];return t.duration-i>1e-6&&n.push(t.duration),n}function Yn(t,e){let n=-1;return(t.markers??[]).forEach((i,r)=>{i.t<=e&&(n=r)}),n}function Bn(t){let e=t.timeline;if(!e)return new Set;let n=e.poster??e.duration;return new Set(e.tracks.filter(i=>!Ce(i,0)&&!Ce(i,n)).map(i=>i.element))}var ir=8,rr=2e4,We=1e-9;function ne(t,e){let n=(t.timeline?.markers??[]).find(i=>i.name.toLowerCase()===e);return n?Math.min(Math.max(n.t,0),C(t.timeline?.duration??0)):null}function Vt(t,e){switch(e){case"up":return ne(t,"up")??0;case"over":return ne(t,"over")??Vt(t,"up");case"down":return ne(t,"down")??Vt(t,"over");default:return ne(t,"hit")}}function or(t,e,n,i){let r=C(t.timeline?.duration??0);if(t.button===!0)return Vt(t,"up")??0;let o=i!==null&&Number.isFinite(i)?i:0;switch(n??"loop"){case"still":return Math.min(t.timeline?.poster??r,r);case"click":return Math.min(Math.max(o,0),r);case"once":return Math.min(Math.max(e+o,0),r);default:{if(r<=0)return 0;let s=e+o,l=s%r;return l<0&&(l+=r),s>We&&(l<We||r-l<We)?r:l}}}function sr(t,e){let n=t.params;if(!n||Object.keys(n).length===0)return t;let i=new Map(Object.entries(n));for(let[o,s]of Object.entries(e??{}))i.has(o)&&i.set(o,s);let r=o=>o.includes("{{")?o.replace(/\{\{\s*([^{}]*?)\s*\}\}/g,(s,l)=>i.get(l)??s):o;return{...t,elements:t.elements.map(o=>{if(o.text===null&&o.args===null)return o;let s=V(o);return s.text!==null&&(s.text=r(s.text)),s.args!==null&&(s.args=Object.fromEntries(Object.entries(s.args).map(([l,a])=>[l,r(a)]))),s})}}function lr(t){return{id:t.id,name:t.name,layers:t.layers,elements:t.elements,theme:null,timeline:t.timeline,symbols:null}}function ie(t){return t.elements.some(e=>e.kind==="symbol")}function j(t,e,n=!0,i=new Map){if(!ie(t))return t;let r={left:rr};return{...t,elements:Fn(t.elements,t,e,Be(t),[],n,r,i)}}function Be(t){let e=new Map;for(let n of t.symbols??[])e.has(n.id)||e.set(n.id,n);return e}function Fn(t,e,n,i,r,o,s,l=new Map){let a=new Set(t.filter(h=>h.kind==="symbol").map(h=>h.id));if(a.size===0)return s.left-=t.length,t;let u=q(e),c=[];for(let h of t){if(s.left<=0)break;let f=h.connector;if(h.kind==="connector"&&f&&[f.start.elementID,f.end.elementID].some(A=>A!==null&&a.has(A))){let[A,k]=Z(h,u),g=V(h);f.start.elementID!==null&&a.has(f.start.elementID)&&(g.connector.start={elementID:null,port:f.start.port,x:A.x,y:A.y}),f.end.elementID!==null&&a.has(f.end.elementID)&&(g.connector.end={elementID:null,port:f.end.port,x:k.x,y:k.y}),c.push(g),s.left-=1;continue}if(h.kind!=="symbol"){c.push(h),s.left-=1;continue}s.left-=1;let d=h.symbol,m=d===null?void 0:i.get(d);if(d===null||!m||r.includes(d)||r.length>=ir)continue;let p=r.length===0?l.get(h.id):void 0,b=p!==void 0?Math.min(Math.max(p,0),C(m.timeline?.duration??0)):or(m,n,h.playback,h.offset),M=lr(sr(m,h.args)),w=o?Ot(M,b):M,y=new Set(w.layers.filter(A=>A.visible).map(A=>A.id)),R={...w,elements:ht(w).filter(A=>y.has(A.layerID)),layers:[{id:h.layerID,name:"",visible:!0,locked:!1}]};for(let A of Fn(R.elements,R,b,i,[...r,d],o,s))c.push(ar(A,h,m))}return c}function ar(t,e,n){let i={x:e.x,y:e.y,width:e.width,height:e.height},r=i.width/n.width,o=i.height/n.height,s=Math.sqrt(Math.abs(r*o)),l={x:i.x+i.width/2,y:i.y+i.height/2},a=W(e),u=d=>nt({x:i.x+d.x*r,y:i.y+d.y*o},l,a),c=V(t);c.id=Ye(e.id,t.id),c.layerID=e.layerID,c.groupID=null,c.link=t.link===null?null:Ye(e.id,t.link),c.seed=qt(t.seed,e.seed),c.click=null,c.hover=null;let h={x:i.x+t.x*r,y:i.y+t.y*o,width:t.width*r,height:t.height*o},f=nt({x:h.x+h.width/2,y:h.y+h.height/2},l,a);if(c.x=f.x-h.width/2,c.y=f.y-h.height/2,c.width=h.width,c.height=h.height,(a!==0||t.rotation!==null)&&(c.rotation=W(t)+a),c.style.strokeWidth=t.style.strokeWidth*s,c.style.fontSize=t.style.fontSize*s,t.style.gridSize!==null&&(c.style.gridSize=t.style.gridSize*s),e.style.opacity!==null&&(c.style.opacity=(t.style.opacity??1)*e.style.opacity),t.connector){let d=m=>{if(m.elementID!==null)return{elementID:Ye(e.id,m.elementID),port:m.port,x:m.x,y:m.y};let p=u(m);return{elementID:null,port:m.port,x:p.x,y:p.y}};c.connector={...t.connector,start:d(t.connector.start),end:d(t.connector.end)}}return c}var ze=(1n<<64n)-1n;function Ct(t){let e=t+0x9e3779b97f4a7c15n&ze;return e=(e^e>>30n)*0xbf58476d1ce4e5b9n&ze,e=(e^e>>27n)*0x94d049bb133111ebn&ze,e^e>>31n}function Gn(t){let e=t.replace(/-/g,"").padStart(32,"0").slice(-32);return[BigInt(`0x${e.slice(0,16)}`),BigInt(`0x${e.slice(16)}`)]}function Ye(t,e){let[n,i]=Gn(t),[r,o]=Gn(e),s=Ct(Ct(Ct(Ct(n)^i)^r)^o),l=Ct(s^0x6a09e667f3bcc909n),a=s.toString(16).padStart(16,"0")+l.toString(16).padStart(16,"0");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`.toUpperCase()}function cr(t,e){let n=e.findIndex(i=>i.name===t);return n>=0?n:e.findIndex(i=>i.name.toLowerCase()===t.toLowerCase())}function Nn(t,e){let n=t.timeline?.markers??[],i=new Map,r=null;for(let o of t.elements){let s=o.click;if(s?.scene){let a=cr(s.scene,n);if(a>=0){i.set(o.id,{scene:a});continue}}let l=s?.url?Ht(s.url):null;if(l){i.set(o.id,{url:l});continue}if(o.link&&e&&e.pages.length>1){r||(r=new Map,e.pages.forEach((u,c)=>{for(let h of u.elements)r.has(h.id)||r.set(h.id,c)}));let a=r.get(o.link);a!==void 0&&e.pages[a]!==t&&i.set(o.id,{page:a})}}return i}function ur(t){let e=t.hover;if(!e)return t;let n={...t.style};if(e.stroke&&(n.stroke=e.stroke),e.fill&&(n.fill=e.fill),e.opacity!==null&&Number.isFinite(e.opacity)){let i=Math.min(Math.max(e.opacity,0),1);n.opacity=i>=1?null:i}return{...t,style:n}}function Hn(t,e){return{...t,elements:t.elements.map(n=>e.has(n.id)?ur(n):n)}}function jn(t){return!!t.hover&&(t.hover.stroke!==null||t.hover.fill!==null||t.hover.opacity!==null)}function _n(t,e){let n=(t.text??"").split(`
3
- `).find(i=>i.length>0);return n||(t.anchor?t.anchor:e||t.kind)}function qn(t,e){let n=new Map;for(let i of t.elements){if(!e.has(i.id)||i.kind!=="symbol")continue;let r={...t,layers:[{id:i.layerID,name:"",visible:!0,locked:!1}],elements:[i]};for(let o of j(r,0,!1).elements)n.set(o.id,i.id)}return n}var Un=`
1
+ /*! dottie.js 0.6.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
+ "use strict";(()=>{var rn=Object.defineProperty;var ki=(t,e,n)=>e in t?rn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var wi=(t,e)=>{for(var n in e)rn(t,n,{get:e[n],enumerable:!0})};var P=(t,e,n)=>ki(t,typeof e!="symbol"?e+"":e,n);var en={};wi(en,{BOIL_DRAWINGS:()=>ke,DottieFormatError:()=>Z,DottiePlayer:()=>Et,KINDS:()=>sn,KNOWN_FIELDS:()=>ln,MAX_DURATION:()=>gt,MAX_MARCH:()=>be,Playback:()=>Bt,SUPPORTED_VERSION:()=>Wr,VERSION:()=>zr,allowedURL:()=>jt,black:()=>ct,bounds:()=>et,cameraView:()=>vt,clampFPS:()=>xt,clampMarch:()=>an,clampTime:()=>C,clear:()=>un,cloneElement:()=>z,definePlayer:()=>fe,elementIndex:()=>vi,frameTimes:()=>ee,inkOnDark:()=>cn,inspect:()=>xi,inspectFrame:()=>Je,inspectPage:()=>tn,isAutomaticInk:()=>we,luminance:()=>kt,orderedElements:()=>ht,pageIndex:()=>Gt,parseDottie:()=>It,plan:()=>At,posterTime:()=>at,render:()=>Or,repeatIsValid:()=>_t,resolved:()=>K,sameColor:()=>bt,sampleTimes:()=>Ze,sceneAt:()=>Bn,stableSortBy:()=>Ht,still:()=>Yn,svg:()=>me,svgParts:()=>ut,themeNamed:()=>pt,themes:()=>Xe,transientElements:()=>Gn,withRoughness:()=>Nt});var Wr=2,sn=["rectangle","ellipse","diamond","text","connector","freehand","path","note","image","symbol"],Pi=["linear","easeIn","easeOut","easeInOut","hold","spring","bounce","elastic"],ln={file:["version","pages","images"],page:["id","name","layers","elements","theme","guidesX","guidesY","guidesLocked","timeline","symbols"],symbol:["id","name","width","height","layers","elements","timeline","button","params"],layer:["id","name","visible","locked"],rgba:["r","g","b","a"],style:["stroke","fill","fillStyle","strokeWidth","dash","roughness","bowing","fontSize","gridSize","opacity","dashOffset"],element:["id","kind","x","y","width","height","style","seed","layerID","text","connector","groupID","points","path","subpaths","evenOdd","rotation","link","anchor","click","hover","symbol","playback","offset","args","image","reveal","ports","labelRect","extension"],strokePoint:["x","y"],subpath:["closed","coords"],inlineImage:["data","format"],endpoint:["elementID","port","portIndex","x","y"],extensionRef:["id","shape","version","params"],normalizedPoint:["x","y"],normalizedRect:["x","y","width","height"],connector:["start","end","routing","startHead","endHead"],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"],click:["scene","url"],hover:["stroke","fill","opacity"]},gt=3600,be=1e4,an=t=>t===void 0||!Number.isFinite(t)||t===0?null:Math.min(Math.max(t,-be),be),ke=3,ct={r:.12,g:.12,b:.13,a:1},un={r:0,g:0,b:0,a:0},cn={r:.93,g:.93,b:.94,a:1},Z=class extends Error{},S=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),M=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,I=t=>typeof t=="string"?t:void 0,on=t=>S(t)&&Object.values(t).every(e=>typeof e=="string")?{...t}:null,W=t=>typeof t=="boolean"?t:void 0,Y=t=>typeof t=="string"?t.toUpperCase():void 0;function C(t){return Number.isFinite(t)?Math.min(Math.max(t,0),gt):t===1/0?gt:0}function xt(t){return Number.isFinite(t)?Math.min(Math.max(t,1),60):12}function jt(t){let e=t.trim();return!/^(https?:\/\/|mailto:)/i.test(e)||[...e].length<=7||/[\u0000-\u001f\u007f-\u009f]/.test(e)?null:e}function yt(t){if(!S(t))return;let e=M(t.r),n=M(t.g),i=M(t.b);if(!(e===void 0||n===void 0||i===void 0))return{r:e,g:n,b:i,a:M(t.a)??1}}var xe=class{constructor(){P(this,"warnings",[]);P(this,"seen",new Set)}warn(e){this.seen.has(e)||(this.seen.add(e),this.warnings.push(e))}fields(e,n){let i=ln[n];for(let r of Object.keys(e))i.includes(r)||this.warn(`Unknown field "${r}" on ${n}, ignored`)}style(e){let n=S(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:yt(n.stroke)??{...ct},fill:yt(n.fill)??{...un},fillStyle:["solid","hachure","crossHatch","grid"].includes(i)?i:"solid",strokeWidth:M(n.strokeWidth)??2,dash:["solid","dashed","dotted"].includes(r)?r:"solid",roughness:M(n.roughness)??1,bowing:M(n.bowing)??1,fontSize:M(n.fontSize)??18,gridSize:M(n.gridSize)??null,opacity:M(n.opacity)??null,dashOffset:M(n.dashOffset)??null}}endpoint(e){let n=S(e)?e:{},i=I(n.port),r=M(n.portIndex);return{elementID:Y(n.elementID)??null,port:i&&["top","right","bottom","left"].includes(i)?i:null,portIndex:r!==void 0&&Number.isInteger(r)&&r>=0?r:null,x:M(n.x)??0,y:M(n.y)??0}}connector(e){if(!S(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(!S(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 Mi.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(!S(e))return null;this.fields(e,"element");let i=Y(e.id),r=I(e.kind),o=Y(e.layerID);if(!i||!r||!o)return this.warn("Skipped an element without an id, kind or layer"),null;sn.includes(r)||this.warn(`Unknown element kind "${r}", drawn as a placeholder`);let s=Array.isArray(e.subpaths)?e.subpaths.filter(S).map(l=>({closed:W(l.closed)??!1,coords:Array.isArray(l.coords)?l.coords.filter(a=>typeof a=="number"):[]})):null;return{id:i,kind:r,layerID:o,x:M(e.x)??0,y:M(e.y)??0,width:M(e.width)??0,height:M(e.height)??0,style:this.style(e.style),seed:(M(e.seed)??1)>>>0,text:I(e.text)??null,connector:this.connector(e.connector),groupID:Y(e.groupID)??null,points:Array.isArray(e.points)?e.points.filter(S).map(l=>({x:M(l.x)??0,y:M(l.y)??0})):null,path:Array.isArray(e.path)?e.path.filter(l=>typeof l=="number"):null,subpaths:s,evenOdd:W(e.evenOdd)??null,rotation:M(e.rotation)??null,link:Y(e.link)??null,anchor:I(e.anchor)??null,click:this.click(e.click),hover:this.hover(e.hover),symbol:Y(e.symbol)??null,playback:this.playback(e.playback),offset:M(e.offset)??null,args:on(e.args),image:this.image(e.image,n),reveal:M(e.reveal)??null,ports:Array.isArray(e.ports)?e.ports.map(l=>{let a=S(l)?l:{};return{x:M(a.x)??0,y:M(a.y)??0}}):null,labelRect:this.labelRect(e.labelRect),extension:this.extension(e.extension)}}labelRect(e){return S(e)?(this.fields(e,"normalizedRect"),{x:M(e.x)??0,y:M(e.y)??0,width:M(e.width)??0,height:M(e.height)??0}):null}extension(e){if(!S(e))return null;this.fields(e,"extensionRef");let n=I(e.id),i=I(e.shape),r=I(e.version);if(n===void 0||i===void 0||r===void 0)return this.warn("Skipped an extension without an id, shape or version"),null;let o={};if(S(e.params))for(let[s,l]of Object.entries(e.params))(typeof l=="number"||typeof l=="boolean"||typeof l=="string")&&(o[s]=l);return{id:n,shape:i,version:r,params:o}}click(e){if(!S(e))return null;this.fields(e,"click");let n=I(e.url),i=n===void 0?null:jt(n);return n!==void 0&&i===null&&this.warn("Skipped a click link that isn't http, https or mailto"),{scene:I(e.scene)??null,url:i}}playback(e){let n=I(e);return n===void 0?null:["loop","once","still","click"].includes(n)?n:"loop"}symbol(e,n){if(!S(e))return null;this.fields(e,"symbol");let i=Y(e.id);if(!i)return this.warn("Skipped a symbol without an id"),null;let r=s=>{let l=M(s);return Math.max(1,l??100)},o=(Array.isArray(e.layers)?e.layers:[]).filter(S).flatMap(s=>{let l=Y(s.id);return l?[{id:l,name:I(s.name)??"",visible:W(s.visible)??!0,locked:W(s.locked)??!1}]:[]});return o.length===0&&o.push({id:`${i}-LAYER`,name:"Layer 1",visible:!0,locked:!1}),{id:i,name:I(e.name)??"Symbol",width:r(e.width),height:r(e.height),layers:o,elements:(Array.isArray(e.elements)?e.elements:[]).map(s=>this.element(s,n)).filter(s=>s!==null),timeline:this.timeline(e.timeline),button:W(e.button)??null,params:on(e.params)}}hover(e){return S(e)?(this.fields(e,"hover"),{stroke:yt(e.stroke)??null,fill:yt(e.fill)??null,opacity:M(e.opacity)??null}):null}ease(e){let n=I(e);return n===void 0?null:Pi.includes(n)?n:(this.warn(`Unknown ease "${n}", played linear`),null)}keyframe(e){if(!S(e))return null;this.fields(e,"keyframe");let n=M(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=M(e[a]);c!==void 0&&(i[a]=c)}let r=yt(e.stroke),o=yt(e.fill),s=W(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(!S(e))return null;this.fields(e,"track");let n=Y(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<=gt);Ht(i,s=>s.t);let r=Array.isArray(e.follow)?e.follow.filter(S).flatMap(s=>{let l=Y(s.path),a=M(s.start),c=M(s.end);return!l||a===void 0||c===void 0||a<0||c>gt?[]:[{path:l,start:a,end:c,ease:this.ease(s.ease),reverse:W(s.reverse)??null,orient:W(s.orient)??null,laps:M(s.laps)??null}]}):null,o=Array.isArray(e.repeats)?e.repeats.filter(S).flatMap(s=>{let l=M(s.start),a=M(s.end);if(l===void 0||a===void 0)return[];let c=M(s.count),u={start:l,end:a,count:c===void 0?null:Math.trunc(c)};return _t(u)?[u]:[]}):null;return{element:n,keys:i,boil:W(e.boil)??null,follow:r,repeats:o,march:an(M(e.march))}}timeline(e){if(!S(e))return null;this.fields(e,"timeline");let n=M(e.boil),i=Array.isArray(e.camera)?e.camera.filter(S).flatMap(s=>{let l=M(s.t),a=M(s.x),c=M(s.y),u=M(s.width),h=M(s.height);return l===void 0||a===void 0||c===void 0||u===void 0||h===void 0?[]:u>1&&h>1&&l>=0?[{t:l,x:a,y:c,width:u,height:h,ease:this.ease(s.ease)}]:[]}):null;i&&Ht(i,s=>s.t);let r=Array.isArray(e.markers)?e.markers.filter(S).flatMap(s=>{let l=M(s.t);return l!==void 0&&l>=0?[{t:l,name:I(s.name)??""}]:[]}):null;r&&Ht(r,s=>s.t);let o=M(e.poster);return{fps:xt(M(e.fps)??12),duration:C(M(e.duration)??0),boil:n!==void 0&&Number.isInteger(n)&&n>0?Math.min(n,1e4):null,settle:W(e.settle)??null,poster:o===void 0?null:C(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(!S(e))throw new Z(`Page ${i} is not an object`);this.fields(e,"page");let r=(Array.isArray(e.layers)?e.layers:[]).filter(S).flatMap(o=>{let s=Y(o.id);return s?[{id:s,name:I(o.name)??"",visible:W(o.visible)??!0,locked:W(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:Y(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),symbols:Array.isArray(e.symbols)?e.symbols.map(o=>this.symbol(o,n)).filter(o=>o!==null):null}}},Mi=/^[A-Za-z0-9+/=\s]*$/;function _t(t){return Number.isFinite(t.start)&&Number.isFinite(t.end)&&t.start>=0&&t.end-t.start>.001&&t.end<=gt&&(t.count===null||t.count>=1&&t.count<=1e4)}function Ht(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 It(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){throw new Z(`Not JSON: ${s.message}`)}if(!S(e))throw new Z("Not a Dottie drawing");let n=M(e.version);if(n===void 0)throw new Z("Not a Dottie drawing (no version)");if(!Array.isArray(e.pages)||e.pages.length===0)throw new Z("A drawing needs at least one page");let i=new xe;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(S(e.images))for(let[s,l]of Object.entries(e.images))S(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 Z("Two pages share an id");return{version:n,pages:o,warnings:i.warnings}}function kt(t){return .2126*t.r+.7152*t.g+.0722*t.b}function bt(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a}function we(t){return bt(t,ct)||bt(t,cn)}function z(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 ht(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 vi(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}var hn=.5522847498307936,T=class t{constructor(){P(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*hn,l=o*hn;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 wt(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${x(n.p.x)} ${x(n.p.y)}`);break;case"L":e.push(`L${x(n.p.x)} ${x(n.p.y)}`);break;case"Q":e.push(`Q${x(n.c.x)} ${x(n.c.y)} ${x(n.p.x)} ${x(n.p.y)}`);break;case"C":e.push(`C${x(n.c1.x)} ${x(n.c1.y)} ${x(n.c2.x)} ${x(n.c2.y)} ${x(n.p.x)} ${x(n.p.y)}`);break;case"Z":e.push("Z");break}return e.join(" ")}};function $t(t){return t<0?-Math.round(-t):Math.round(t)}function x(t){let e=$t(t*100)/100;return Number.isInteger(e)?String(e===0?0:e):String(e)}var wt=class{constructor(e){P(this,"points");P(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}}},F=t=>t.x+t.width/2,H=t=>t.y+t.height/2,G=t=>t.x+t.width,N=t=>t.y+t.height;function Pe(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(G(t),G(e))-n,height:Math.max(N(t),N(e))-i}}function Pt(t,e,n){return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}function it(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 Me(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 dn(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(Me(r,l/s))}return n}var L=t=>({x:t.x,y:t.y,width:t.width,height:t.height}),V=t=>t.rotation??0,Lt=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),q=(t,e)=>it(e,Lt(t),V(t)),mn=(t,e)=>it(e,Lt(t),-V(t));function fn(t){let e=L(t);if(V(t)===0)return e;let n=[{x:e.x,y:e.y},{x:G(e),y:e.y},{x:G(e),y:N(e)},{x:e.x,y:N(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 pn(t,e){if(!we(t.style.stroke))return t;let n=z(t),r=(t.style.fillStyle==="solid"||t.style.fillStyle==="grid")&&t.style.fill.a>=.5&&kt(t.style.fill)>.5;return n.style.stroke=kt(e)>.5&&r?{...ct}:{...e},n}function Mt(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 ve(t){let e=new T;for(let n of Mt(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:F(n),y:n.y}:e==="right"?{x:G(n),y:H(n)}:e==="bottom"?{x:F(n),y:N(n)}:{x:n.x,y:H(n)};return q(t,i)}function Ai(t){let e=[];for(let n=0;n+3<t.length;n+=3){let i=t.slice(n,n+4);for(let r=0;r<16;r++)e.push(Me(i,r/16))}return e.push(t[t.length-1]),e}function Ei(t,e,n){let i=null;for(let r of Mt(t)){let o=Ai(r.points),s=o.length,l=r.closed?s:s-1;for(let a=0;a<l;a++){let c=o[a],u=o[(a+1)%s],h={x:u.x-c.x,y:u.y-c.y},f={x:c.x-e.x,y:c.y-e.y},m=h.x*n.y-n.x*h.y;if(m===0)continue;let d=(h.x*f.y-h.y*f.x)/m,p=(n.x*f.y-n.y*f.x)/m;d>0&&p>=0&&p<=1&&(i===null||d<i)&&(i=d)}}return i===null?null:{x:e.x+n.x*i,y:e.y+n.y*i}}function Ti(t,e){let n=L(t),i=Lt(t),r=mn(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;if(t.kind==="path"){let u=Ei(t,i,{x:o,y:s});if(u)return q(t,u)}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 yn(t,e){let n=t.elementID?e.get(t.elementID):void 0;return n?Lt(n):{x:t.x,y:t.y}}function Si(t,e){let n=L(t);return q(t,{x:n.x+e.x*n.width,y:n.y+e.y*n.height})}function gn(t,e,n){let i=t.elementID?n.get(t.elementID):void 0;if(!i)return{x:t.x,y:t.y};let r=t.portIndex,o=i.ports??[];return typeof r=="number"&&Number.isInteger(r)&&r>=0&&r<o.length?Si(i,o[r]):t.port?Ri(i,t.port):Ti(i,e)}function J(t,e){let n=t.connector;return n?[gn(n.start,yn(n.end,e),e),gn(n.end,yn(n.start,e),e)]:[{x:0,y:0},{x:0,y:0}]}function rt(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 ot(t,e){let n=t.connector;if(!n)return{kind:"polyline",points:[]};let[i,r]=J(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=h=>h===null?null:h==="top"||h==="bottom",c=a(n.start.port)??!l,u=a(n.end.port)??!l;if(c&&u){let h=i.y+s/2;return{kind:"polyline",points:[i,{x:i.x,y:h},{x:r.x,y:h},r]}}if(!c&&!u){let h=i.x+o/2;return{kind:"polyline",points:[i,{x:h,y:i.y},{x:h,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 bn(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 xn(t,e){let n=rt(ot(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 kn(t,e){let n=rt(ot(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 U(t){let e=new Map;for(let n of t.elements)e.has(n.id)||e.set(n.id,n);return e}function Ae(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,h=s+u%65536*65536;return[c+Math.floor(u/65536)+Math.floor(h/4294967296)>>>0,h>>>0]}function Ee(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 Re(t,e){let n=(t[1]>>>e|t[0]<<32-e)>>>0;return[(t[0]^t[0]>>>e)>>>0,(t[1]^n)>>>0]}function wn(t){return t=Ee(Re(t,30),3210233709,484763065),t=Ee(Re(t,27),2496678331,321982955),Re(t,31)}var st=class{constructor(e){P(this,"state");this.state=Ae([0,e>>>0],2654435769,2135587861)}next(){return this.state=Ae(this.state,2654435769,2135587861),wn(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 qt(t,e){let n=Ae([0,t>>>0],...$i(e));return n=wn(n),Math.max(1,n[1]>>>0)}function $i(t){let e=Ee([0,t>>>0],2654435769,2135587861);return[e[0],e[1]]}var Pn=(t,e,n)=>t.signed()*e*n;function tt(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 h=(u===0?1:.5)*a,f=()=>Pn(n,c,i)*h,m=n.unit()*.4+.3,d=Pn(n,l/60,i)*r*a,p=e.x-t.x,b=e.y-t.y,v=-b/l,w=p/l,y=o?t:{x:t.x+f(),y:t.y+f()},A=o?e:{x:e.x+f(),y:e.y+f()},R=t.x+p*m*.66+v*d+f()*.5,k=t.y+b*m*.66+w*d+f()*.5,g=t.x+p*(.5+m*.5)+v*d+f()*.5,E=t.y+b*(.5+m*.5)+w*d+f()*.5;s.moveTo(y),s.curveTo(A,{x:R,y:k},{x:g,y:E})}}function Te(t,e,n,i){let r=new T;for(let o=0;o<t.length;o++)tt(t[o],t[(o+1)%t.length],e,n,i,!1,r);return r}function Mn(t,e,n){let i=new T,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 h=e.unit()*2*Math.PI,f=2*Math.PI*(u===0?1:1.04),m=Math.trunc(a*f/(2*Math.PI))+1,d=[];for(let p=0;p<m;p++){let b=h+f*p/a,v=e.signed()*c,w=e.signed()*c;d.push({x:r+s*Math.cos(b)+v,y:o+l*Math.sin(b)+w})}Li(d,i)}return i}function Li(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 Se=-41*Math.PI/180;function vn(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=[],h=l+n/2;for(;h<a;){let f=[];for(let m of o)for(let d=0;d<m.length;d++){let p=m[d],b=m[(d+1)%m.length];(p.y<=h&&h<b.y||b.y<=h&&h<p.y)&&f.push(p.x+(h-p.y)/(b.y-p.y)*(b.x-p.x))}f.sort((m,d)=>m-d);for(let m=0;m+1<f.length;m+=2)f[m+1]-f[m]>.5&&u.push([c(f[m],h),c(f[m+1],h)]);h+=n}return u}var Tn=2,Ie=.75,Di=.8,An=.6;function Sn(t,e){return[...En(t,e,!1),...En(t,e,!0)]}function En(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 h of r)for(let f=0;f<h.length;f++){let m=h[f],d=h[(f+1)%h.length];(m.y<=c&&c<d.y||d.y<=c&&c<m.y)&&u.push(m.x+(c-m.y)/(d.y-m.y)*(d.x-m.x))}u.sort((h,f)=>h-f);for(let h=0;h+1<u.length;h+=2)u[h+1]-u[h]>.5&&a.push([i({x:u[h],y:c}),i({x:u[h+1],y:c})])}return a}function In(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 $e(t){return t.style.fillStyle==="grid"&&t.style.fill.a>0&&["rectangle","ellipse","diamond","path"].includes(t.kind)}function Kt(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 $n(t,e,n){let i=n/Tn;return{x:(t+.5+(Kt(t,e,1)-.5)*An)*i,y:(e+.5+(Kt(t,e,2)-.5)*An)*i}}function Oi(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=$n(t+o,e+s,i);r=Math.min(r,Math.hypot(l.x-n.x,l.y-n.y))}return r*Di}function Ci(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 zi(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 Vi(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 Wi=(t,e)=>e.x>=t.x&&e.x<t.x+t.width&&e.y>=t.y&&e.y<t.y+t.height,Ut=new Map;function Ln(t){if(t.length===0)return[];let e=t.map(r=>[r.kind,r.x,r.y,r.width,r.height,r.rotation??0,dt(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=Ut.get(e);if(n)return n;let i=Yi(t);return Ut.size>=16&&Ut.clear(),Ut.set(e,i),i}function Yi(t){let e=t.map(o=>{let s=Le(o).map(m=>m.map(d=>q(o,d))),l=s.flat(),a=l.map(m=>m.x),c=l.map(m=>m.y),u=a.length?Math.min(...a):0,h=c.length?Math.min(...c):0,f={x:u,y:h,width:(a.length?Math.max(...a):0)-u,height:(c.length?Math.max(...c):0)-h};return{contours:s,box:f,cell:dt(o),element:o}}),n=e.map(()=>[]),i=new Set;for(let o of e){let s=o.cell/Tn,l=Pt(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),h=Math.ceil((l.y+l.height)/s),f=Ie*o.cell;for(let m=a;m<c;m++)for(let d=u;d<h;d++){let p=`${o.cell}|${m}|${d}`;if(i.has(p))continue;i.add(p);let b=$n(m,d,o.cell),v=1/0,w=-1;for(let k=0;k<e.length;k++){let g=e[k];if(!Wi(Pt(g.box,-f,-f),b))continue;if(zi(g.contours,b)){v=0;break}let E=Vi(b,g.contours);E<v&&(v=E,w=k)}if(!(v>0&&v<=f&&w>=0))continue;let y=Kt(m,d,3)*Math.PI,A=Oi(m,d,b,o.cell),R=Math.trunc(Kt(m,d,4)*4294967296)>>>0;for(let[k,g]of Ci(b,y,A))n[w].push([k,g,R])}}let r=[];return e.forEach((o,s)=>{if(n[s].length===0)return;let l=o.element,a=new T;for(let[c,u,h]of n[s])l.style.roughness<=0?a.moveTo(c).lineTo(u):tt(c,u,new st(h),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 Xt=class{constructor(e=6e3){P(this,"map",new Map);P(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}},On=new Xt,Bi=new Xt;function Cn(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"?dt(t):0,t.path?t.path.join(","):t.subpaths?JSON.stringify(t.subpaths):""].join("|")}var dt=t=>Math.max(8,t.style.gridSize??50);function mt(t){return t.kind==="freehand"&&t.path===null?Dn(t):On.get(Cn(t,0),()=>Dn(t))}function zn(t){return[{x:t.x,y:t.y},{x:G(t),y:t.y},{x:G(t),y:N(t)},{x:t.x,y:N(t)}]}function Qt(t){return[{x:F(t),y:t.y},{x:G(t),y:H(t)},{x:F(t),y:N(t)},{x:t.x,y:H(t)}]}function Dn(t){let e=L(t),n=new st(t.seed),i=t.style.roughness;switch(t.kind){case"ellipse":return i<=0?T.ellipse(e):Mn(e,n,i);case"diamond":return i<=0?new T().addLines(Qt(e)).close():Te(Qt(e),n,i,t.style.bowing);case"text":case"connector":return T.rect(e);case"freehand":return Ni(t);case"path":return i<=0?ve(t):Gi(t,n);default:return i<=0?T.rect(e):Te(zn(e),n,i,t.style.bowing)}}function Gi(t,e){let n=t.style.roughness,i=new T;for(let r of Mt(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){tt(l,u,e,n,t.style.bowing,!0,i);continue}let h=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,h/30)*n;for(let m=0;m<2;m++){let d=m===0?1:.5,p=()=>e.signed()*f*d;i.moveTo(l);let b=a.x+p(),v=a.y+p(),w=c.x+p(),y=c.y+p();i.curveTo(u,{x:b,y:v},{x:w,y})}}}return i}function Ni(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 T().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 T;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 Le(t){return t.kind!=="path"?[Fi(t)]:Mt(t).map(e=>dn(e.points,3))}function Fi(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:F(e)+e.width/2*Math.cos(r),y:H(e)+e.height/2*Math.sin(r)})}return n}return t.kind==="diamond"?Qt(e):zn(e)}function Zt(t){let e=L(t);return t.kind==="ellipse"?T.ellipse(e):t.kind==="path"?ve(t):t.kind==="diamond"?new T().addLines(Qt(e)).close():T.rect(e)}function De(t){return t.style.fillStyle==="solid"||["freehand","connector","text","image"].includes(t.kind)?new T:On.get(Cn(t,1),()=>Hi(t))}function Hi(t){let e=Le(t),n=new st((t.seed^1540483477)>>>0),i=new T;if(t.style.fillStyle==="grid"){for(let[s,l]of Sn(e,dt(t)))t.style.roughness<=0?i.moveTo(s).lineTo(l):tt(s,l,n,t.style.roughness*.3,.3,!1,i);return i}let r=Math.max(4,t.style.strokeWidth*4),o=[Se];t.style.fillStyle==="crossHatch"&&o.push(Se+Math.PI/2);for(let s of o)for(let[l,a]of vn(e,s,r))t.style.roughness<=0?i.moveTo(l).lineTo(a):tt(l,a,n,t.style.roughness*.6,.5,!1,i);return i}function Jt(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 Oe(t,e){let n=t.connector;if(!n)return[new T,new T];let[i,r]=J(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 Bi.get(o,()=>ji(t,e))}function ji(t,e){let n=t.connector,i=new st(t.seed),r=t.style.roughness,o=t.style.bowing,s=new T,l=new T,a=ot(t,e);if(a.kind==="polyline"){let m=a.points;for(let d=0;d<Math.max(m.length-1,0);d++)r<=0?s.moveTo(m[d]).lineTo(m[d+1]):tt(m[d],m[d+1],i,r,o,!0,s)}else{s.moveTo(a.a);let m=r*3,d=()=>i.signed()*m,p=a.b.x+d(),b=a.b.y+d(),v=a.c.x+d(),w=a.c.y+d();s.curveTo(a.d,{x:p,y:b},{x:v,y:w})}let c=rt(a),u=Math.max(10,t.style.strokeWidth*5),h=(m,d)=>{r<=0?s.moveTo(m).lineTo(d):tt(m,d,i,r*.5,0,!0,s)},f=(m,d,p)=>{let[b,v]=bn(d,p,u);switch(m){case"arrow":h(b,d),h(v,d);break;case"triangle":h(b,d),h(v,d),h(b,v),l.moveTo(d).lineTo(b).lineTo(v).close();break;case"dot":{let w=u*.32,y=Math.atan2(d.y-p.y,d.x-p.x),A=d.x-w*Math.cos(y),R=d.y-w*Math.sin(y);l.addEllipse({x:A-w,y:R-w,width:2*w,height:2*w});break}case"bar":{let w=Math.atan2(d.y-p.y,d.x-p.x)+Math.PI/2,y=u*.5;h({x:d.x-y*Math.cos(w),y:d.y-y*Math.sin(w)},{x:d.x+y*Math.cos(w),y:d.y+y*Math.sin(w)});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]}function Ve(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 _i(e);case"bounce":return qi(e);case"elastic":return Ui(e)}}function _i(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 qi(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 Ui(t){return t<=0?0:t>=1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1}var Dt=(t,e)=>t%e;function Ot(t,e){let n=(t.repeats??[]).filter(_t).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+Dt(e-i.start,r);let o=r*i.count;if(e<i.start+o)return i.start+Dt(e-i.start,r);e-=o-r}return e}function Ce(t,e,n,i,r){e=Ot(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),Ve(l.ease??"linear",c))}var Ki=(t,e,n)=>t+(e-t)*n,te=(t,e,n)=>Math.min(Math.max(t+(e-t)*n,0),1),Vn=(t,e,n)=>({r:te(t.r,e.r,n),g:te(t.g,e.g,n),b:te(t.b,e.b,n),a:te(t.a,e.a,n)});function lt(t,e,n,i){return Ce(t,e,r=>r[n],i,Ki)}function Xi(t,e){e=Ot(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,bt)||n(r=>r.fill,bt)||i("reveal")||i("opacity")}function ze(t,e){e=Ot(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 Qi(t,e,n){if(e=z(e),t.keys.some(i=>i.reveal!==void 0)){let i=lt(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(lt(t,n,"opacity",e.style.opacity??1),0),1);e.style.opacity=i>=1?null:i}return e.kind==="connector"||(e.x=lt(t,n,"x",e.x),e.y=lt(t,n,"y",e.y),e.width=Math.max(0,lt(t,n,"width",e.width)),e.height=Math.max(0,lt(t,n,"height",e.height)),t.keys.some(i=>i.rotation!==void 0)&&(e.rotation=lt(t,n,"rotation",V(e))),e.style.strokeWidth=Math.max(0,lt(t,n,"strokeWidth",e.style.strokeWidth)),e.style.stroke=Ce(t,n,i=>i.stroke,e.style.stroke,Vn),e.style.fill=Ce(t,n,i=>i.fill,e.style.fill,Vn)),e}function Zi(t,e){e=Ot(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 Ji(t,e){if(t.kind==="connector")return new wt(rt(ot(t,U(e))));let n=z(t);n.style.roughness=0;let i=mt(n).contours()[0]??[];return new wt(V(t)===0?i:i.map(r=>q(t,r)))}function tr(t,e,n,i){let r=Zi(t,n);if(!r)return e;n=Ot(t,n);let o=i.elements.find(h=>h.id===r.path);if(!o||o.id===e.id)return e;let s=Ji(o,i),l=r.end-r.start,a=Math.min(Math.max(Ve(r.ease??"easeInOut",l>0?Math.min(1,(n-r.start)/l):1),0),1)*(r.laps??1);a>1&&(a=Dt(a,1)===0?1:Dt(a,1)),r.reverse===!0&&(a=1-a);let c=s.point(a),u=z(e);if(u.x=c.x-e.width/2,u.y=c.y-e.height/2,r.orient===!0){let h=r.reverse===!0?-.01:.01,f=s.point(a-h/2),m=s.point(a+h/2);(f.x!==m.x||f.y!==m.y)&&(u.rotation=Math.atan2(m.y-f.y,m.x-f.x))}return u}function er(t,e,n,i){if(!(n>0))return 0;let r=C(t.duration);if(r>0){let s=$t(e*r/n);s!==0&&(e=s*n/r)}let o=Dt(e*i,n);return o<0?-o:o===0?0:n-o}function nr(t){let e=new Map;for(let n of t.tracks)e.has(n.element)||e.set(n.element,n);return e}function K(t,e){return j(Ct(t,e),C(e))}function Ct(t,e){let n=t.timeline;if(!n)return t;e=C(e);let i=nr(n),r=n.boil===null?null:Math.trunc(Math.floor(e*xt(n.fps)+1e-9)/Math.max(1,n.boil))%ke>>>0,o=new Set;for(let m of i.values())ze(m,e)||o.add(m.element);let s=null;if(n.settle===!0){s=new Set;for(let m of i.values())Xi(m,e)&&s.add(m.element)}let l=m=>{let d=i.get(m.id)?.boil;return d??(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 d=i.get(m.id),p=d?Qi(d,m,e):m;r!==null&&r>0&&l(m)&&(p===m&&(p=z(m)),p.seed=qt(m.seed,r));let b=d?.march!=null?Jt(p.style.dash,p.style.strokeWidth):null;return d?.march!=null&&b&&(p===m&&(p=z(m)),p.style.dashOffset=er(n,d.march,b.reduce((v,w)=>v+w,0),e)),p});a=a.map((m,d)=>o.has(m.id)?t.elements[d]:m);let c={...t,elements:a,timeline:null};a=a.map(m=>{let d=i.get(m.id);return d?tr(d,m,e,c):m});let u={...t,elements:a,timeline:null},h=U(u),f=new Set(o);return a=a.map(m=>{let d=m.connector;if(!d||![d.start.elementID,d.end.elementID].some(w=>w!==null&&o.has(w)))return m;if(!(i.get(m.id)?.keys.some(w=>w.visible!==void 0)??!1))return f.add(m.id),m;let[p,b]=J(m,h),v=z(m);return v.connector.start={elementID:null,port:d.start.port,x:p.x,y:p.y},v.connector.end={elementID:null,port:d.end.port,x:b.x,y:b.y},v}),{...t,elements:a.filter(m=>!f.has(m.id)),timeline:null}}function at(t){return t.timeline?t.timeline.poster??t.timeline.duration:0}function Yn(t){return t.timeline?K(t,at(t)):j(t,0)}function ir(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 Wn(n[0]);if(!r)return Wn(i);let o=Ve(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 Wn=t=>({x:t.x,y:t.y,width:t.width,height:t.height});function vt(t,e){let n=t.camera?.[0],i=ir(t,e);return!n||!i||!(i.width>0&&i.height>0)?null:rr(i,n.width/n.height)}function rr(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 or(t){return Math.max(1,Math.ceil(C(t.duration)*xt(t.fps)))}function ee(t){let e=xt(t.fps),n=[];for(let r=0;r<or(t);r++)n.push(r/e);let i=n[n.length-1];return t.duration-i>1e-6&&n.push(t.duration),n}function Bn(t,e){let n=-1;return(t.markers??[]).forEach((i,r)=>{i.t<=e&&(n=r)}),n}function Gn(t){let e=t.timeline;if(!e)return new Set;let n=e.poster??e.duration;return new Set(e.tracks.filter(i=>!ze(i,0)&&!ze(i,n)).map(i=>i.element))}var sr=8,lr=2e4,We=1e-9;function ne(t,e){let n=(t.timeline?.markers??[]).find(i=>i.name.toLowerCase()===e);return n?Math.min(Math.max(n.t,0),C(t.timeline?.duration??0)):null}function Vt(t,e){switch(e){case"up":return ne(t,"up")??0;case"over":return ne(t,"over")??Vt(t,"up");case"down":return ne(t,"down")??Vt(t,"over");default:return ne(t,"hit")}}function ar(t,e,n,i){let r=C(t.timeline?.duration??0);if(t.button===!0)return Vt(t,"up")??0;let o=i!==null&&Number.isFinite(i)?i:0;switch(n??"loop"){case"still":return Math.min(t.timeline?.poster??r,r);case"click":return Math.min(Math.max(o,0),r);case"once":return Math.min(Math.max(e+o,0),r);default:{if(r<=0)return 0;let s=e+o,l=s%r;return l<0&&(l+=r),s>We&&(l<We||r-l<We)?r:l}}}function ur(t,e){let n=t.params;if(!n||Object.keys(n).length===0)return t;let i=new Map(Object.entries(n));for(let[o,s]of Object.entries(e??{}))i.has(o)&&i.set(o,s);let r=o=>o.includes("{{")?o.replace(/\{\{\s*([^{}]*?)\s*\}\}/g,(s,l)=>i.get(l)??s):o;return{...t,elements:t.elements.map(o=>{if(o.text===null&&o.args===null)return o;let s=z(o);return s.text!==null&&(s.text=r(s.text)),s.args!==null&&(s.args=Object.fromEntries(Object.entries(s.args).map(([l,a])=>[l,r(a)]))),s})}}function cr(t){return{id:t.id,name:t.name,layers:t.layers,elements:t.elements,theme:null,timeline:t.timeline,symbols:null}}function ie(t){return t.elements.some(e=>e.kind==="symbol")}function j(t,e,n=!0,i=new Map){if(!ie(t))return t;let r={left:lr};return{...t,elements:Fn(t.elements,t,e,Ge(t),[],n,r,i)}}function Ge(t){let e=new Map;for(let n of t.symbols??[])e.has(n.id)||e.set(n.id,n);return e}function Fn(t,e,n,i,r,o,s,l=new Map){let a=new Set(t.filter(h=>h.kind==="symbol").map(h=>h.id));if(a.size===0)return s.left-=t.length,t;let c=U(e),u=[];for(let h of t){if(s.left<=0)break;let f=h.connector;if(h.kind==="connector"&&f&&[f.start.elementID,f.end.elementID].some(R=>R!==null&&a.has(R))){let[R,k]=J(h,c),g=z(h);f.start.elementID!==null&&a.has(f.start.elementID)&&(g.connector.start={elementID:null,port:f.start.port,x:R.x,y:R.y}),f.end.elementID!==null&&a.has(f.end.elementID)&&(g.connector.end={elementID:null,port:f.end.port,x:k.x,y:k.y}),u.push(g),s.left-=1;continue}if(h.kind!=="symbol"){u.push(h),s.left-=1;continue}s.left-=1;let m=h.symbol,d=m===null?void 0:i.get(m);if(m===null||!d||r.includes(m)||r.length>=sr)continue;let p=r.length===0?l.get(h.id):void 0,b=p!==void 0?Math.min(Math.max(p,0),C(d.timeline?.duration??0)):ar(d,n,h.playback,h.offset),v=cr(ur(d,h.args)),w=o?Ct(v,b):v,y=new Set(w.layers.filter(R=>R.visible).map(R=>R.id)),A={...w,elements:ht(w).filter(R=>y.has(R.layerID)),layers:[{id:h.layerID,name:"",visible:!0,locked:!1}]};for(let R of Fn(A.elements,A,b,i,[...r,m],o,s))u.push(hr(R,h,d))}return u}function hr(t,e,n){let i={x:e.x,y:e.y,width:e.width,height:e.height},r=i.width/n.width,o=i.height/n.height,s=Math.sqrt(Math.abs(r*o)),l={x:i.x+i.width/2,y:i.y+i.height/2},a=V(e),c=m=>it({x:i.x+m.x*r,y:i.y+m.y*o},l,a),u=z(t);u.id=Be(e.id,t.id),u.layerID=e.layerID,u.groupID=null,u.link=t.link===null?null:Be(e.id,t.link),u.seed=qt(t.seed,e.seed),u.click=null,u.hover=null;let h={x:i.x+t.x*r,y:i.y+t.y*o,width:t.width*r,height:t.height*o},f=it({x:h.x+h.width/2,y:h.y+h.height/2},l,a);if(u.x=f.x-h.width/2,u.y=f.y-h.height/2,u.width=h.width,u.height=h.height,(a!==0||t.rotation!==null)&&(u.rotation=V(t)+a),u.style.strokeWidth=t.style.strokeWidth*s,u.style.fontSize=t.style.fontSize*s,t.style.gridSize!==null&&(u.style.gridSize=t.style.gridSize*s),e.style.opacity!==null&&(u.style.opacity=(t.style.opacity??1)*e.style.opacity),t.connector){let m=d=>{if(d.elementID!==null)return{elementID:Be(e.id,d.elementID),port:d.port,x:d.x,y:d.y};let p=c(d);return{elementID:null,port:d.port,x:p.x,y:p.y}};u.connector={...t.connector,start:m(t.connector.start),end:m(t.connector.end)}}return u}var Ye=(1n<<64n)-1n;function zt(t){let e=t+0x9e3779b97f4a7c15n&Ye;return e=(e^e>>30n)*0xbf58476d1ce4e5b9n&Ye,e=(e^e>>27n)*0x94d049bb133111ebn&Ye,e^e>>31n}function Nn(t){let e=t.replace(/-/g,"").padStart(32,"0").slice(-32);return[BigInt(`0x${e.slice(0,16)}`),BigInt(`0x${e.slice(16)}`)]}function Be(t,e){let[n,i]=Nn(t),[r,o]=Nn(e),s=zt(zt(zt(zt(n)^i)^r)^o),l=zt(s^0x6a09e667f3bcc909n),a=s.toString(16).padStart(16,"0")+l.toString(16).padStart(16,"0");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`.toUpperCase()}function dr(t,e){let n=e.findIndex(i=>i.name===t);return n>=0?n:e.findIndex(i=>i.name.toLowerCase()===t.toLowerCase())}function Hn(t,e){let n=t.timeline?.markers??[],i=new Map,r=null;for(let o of t.elements){let s=o.click;if(s?.scene){let a=dr(s.scene,n);if(a>=0){i.set(o.id,{scene:a});continue}}let l=s?.url?jt(s.url):null;if(l){i.set(o.id,{url:l});continue}if(o.link&&e&&e.pages.length>1){r||(r=new Map,e.pages.forEach((c,u)=>{for(let h of c.elements)r.has(h.id)||r.set(h.id,u)}));let a=r.get(o.link);a!==void 0&&e.pages[a]!==t&&i.set(o.id,{page:a})}}return i}function mr(t){let e=t.hover;if(!e)return t;let n={...t.style};if(e.stroke&&(n.stroke=e.stroke),e.fill&&(n.fill=e.fill),e.opacity!==null&&Number.isFinite(e.opacity)){let i=Math.min(Math.max(e.opacity,0),1);n.opacity=i>=1?null:i}return{...t,style:n}}function jn(t,e){return{...t,elements:t.elements.map(n=>e.has(n.id)?mr(n):n)}}function _n(t){return!!t.hover&&(t.hover.stroke!==null||t.hover.fill!==null||t.hover.opacity!==null)}function qn(t,e){let n=(t.text??"").split(`
3
+ `).find(i=>i.length>0);return n||(t.anchor?t.anchor:e||t.kind)}function Un(t,e){let n=new Map;for(let i of t.elements){if(!e.has(i.id)||i.kind!=="symbol")continue;let r={...t,layers:[{id:i.layerID,name:"",visible:!0,locked:!1}],elements:[i]};for(let o of j(r,0,!1).elements)n.set(o.id,i.id)}return n}var Kn=`
4
4
  .dottie-a { cursor: pointer; outline: none; }
5
5
  .dottie-a .dottie-h { display: none; }
6
6
  .dottie-a:hover .dottie-h, .dottie-a.dottie-hover .dottie-h, .dottie-a:focus-visible .dottie-h { display: inline; }
@@ -10,45 +10,45 @@
10
10
  .dottie-a .dottie-d { display: none; }
11
11
  .dottie-b:active .dottie-n, .dottie-b:active .dottie-h, .dottie-b.dottie-press .dottie-n, .dottie-b.dottie-press .dottie-h { display: none; }
12
12
  .dottie-b:active .dottie-d, .dottie-b.dottie-press .dottie-d { display: inline; }
13
- `;var re=.951995849609375,oe=.2129974365234375,se=.0279998779296875,Kn=.975006103515625,Xn=.2169952392578125,Qn=.0290069580078125,Zn=.957000732421875,Jn=.2129974365234375,ti=.0279998779296875,ei=.975006103515625,ni=.2169952392578125,ii=.0290069580078125,ri=.60205078125,oi=.92822265625,si=.23583984375,vt={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}}},le={"\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 O(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 ae(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ce(t,e,n="regular"){let i=vt[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 hr(t){let e=Math.round(re*t),n=Math.round(oe*t),i=Math.round(se*t);return[e+n,e+n+i]}function Ge(t,e){return t===" "?!0:(t==="/"||t==="-")&&e!==""&&!/[\d\s/-]/.test(e)}function mr(t){let e=[...t],n=[],i="";return e.forEach((r,o)=>{i+=r;let s=e[o+1]??"";Ge(r,s)&&s!==" "&&(n.push(i),i="")}),(i||n.length===0)&&n.push(i),n}function dr(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 mr(o)){let a=s+l;for(s===""||ce(a.trimEnd(),e,i)<=n?s=a:(r.push(s),s=l);ce(s.trimEnd(),e,i)>n&&[...s.trimEnd()].length>1;){let u=[...s],c=u.length-1;for(;c>1&&ce(u.slice(0,c).join(""),e,i)>n;)c--;r.push(u.slice(0,c).join("")),s=u.slice(c).join("")}}r.push(s)}return r}function li(t,e,n){if(t==="")return{width:0,height:0};let i=dr(t,e,n),r=Math.max(...i.map(l=>ce(l.trimEnd(),e))),[o,s]=hr(e);return{width:Math.ceil(r-1e-9),height:Math.ceil(o+s*(i.length-1)-1e-9)}}var ai=12,ft="\u2028";function fr(t){let e=Math.min(ai,t.width/2),n=Math.min(ai,t.height/2);return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}var Ne=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,mi=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,He=/^ {0,3}(`{3,}|~{3,})/,Wt=/^( *)([-*+]|\d{1,9}[.)])([ \t]+|$)(.*)$/,ue=/^ {0,3}> ?(.*)$/,pr=/^ *\|? *:?-+:? *(\| *:?-+:? *)*\|? *$/;function Fe(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 yr(t){return Ue(t.replace(/\r\n?/g,`
13
+ `;var re=.951995849609375,oe=.2129974365234375,se=.0279998779296875,Xn=.975006103515625,Qn=.2169952392578125,Zn=.0290069580078125,Jn=.957000732421875,ti=.2129974365234375,ei=.0279998779296875,ni=.975006103515625,ii=.2169952392578125,ri=.0290069580078125,oi=.60205078125,si=.92822265625,li=.23583984375,Rt={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}}},le={"\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 O(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 ae(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ue(t,e,n="regular"){let i=Rt[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 fr(t){let e=Math.round(re*t),n=Math.round(oe*t),i=Math.round(se*t);return[e+n,e+n+i]}function Ne(t,e){return t===" "?!0:(t==="/"||t==="-")&&e!==""&&!/[\d\s/-]/.test(e)}function pr(t){let e=[...t],n=[],i="";return e.forEach((r,o)=>{i+=r;let s=e[o+1]??"";Ne(r,s)&&s!==" "&&(n.push(i),i="")}),(i||n.length===0)&&n.push(i),n}function yr(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 pr(o)){let a=s+l;for(s===""||ue(a.trimEnd(),e,i)<=n?s=a:(r.push(s),s=l);ue(s.trimEnd(),e,i)>n&&[...s.trimEnd()].length>1;){let c=[...s],u=c.length-1;for(;u>1&&ue(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 ai(t,e,n){if(t==="")return{width:0,height:0};let i=yr(t,e,n),r=Math.max(...i.map(l=>ue(l.trimEnd(),e))),[o,s]=fr(e);return{width:Math.ceil(r-1e-9),height:Math.ceil(o+s*(i.length-1)-1e-9)}}var ui=12,ft="\u2028";function gr(t){let e=Math.min(ui,t.width/2),n=Math.min(ui,t.height/2);return{x:t.x+e,y:t.y+n,width:t.width-2*e,height:t.height-2*n}}var He=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,mi=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/,je=/^ {0,3}(`{3,}|~{3,})/,Wt=/^( *)([-*+]|\d{1,9}[.)])([ \t]+|$)(.*)$/,ce=/^ {0,3}> ?(.*)$/,br=/^ *\|? *:?-+:? *(\| *:?-+:? *)*\|? *$/;function Fe(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 xr(t){return Ke(t.replace(/\r\n?/g,`
14
14
  `).split(`
15
- `))}function Ue(t){let e=[],n=0,i=null,r=()=>{i&&(e.push({kind:"paragraph",inline:K(i.join(`
16
- `))}),i=null)};for(;n<t.length;){let o=t[n];if(o.trim()===""){r(),n++;continue}let s=He.exec(o);if(s){r();let u=new RegExp(`^ {0,3}${s[1][0]==="`"?"`":"~"}{${s[1].length},}[ \\t]*$`),c=[];for(n++;n<t.length&&!u.test(t[n]);)c.push(t[n++]);n++,e.push({kind:"code",text:c.join(`
17
- `)});continue}let l=Ne.exec(o);if(l){r(),e.push({kind:"heading",level:l[1].length,inline:K(l[2]??"")}),n++;continue}if(i&&/^ {0,3}(=+|-+)[ \t]*$/.test(o)){let u=o.trim()[0]==="="?1:2;e.push({kind:"heading",level:u,inline:K(i.join(`
18
- `))}),i=null,n++;continue}if(mi.test(o)){r(),e.push({kind:"rule"}),n++;continue}if(ue.test(o)){r();let u=[];for(;n<t.length&&t[n].trim()!=="";){let c=ue.exec(t[n]);u.push(c?c[1]:t[n]),n++}e.push({kind:"quote",children:Ue(u)});continue}let a=Wt.exec(o);if(a&&(!i||a[4].trim()!=="")){r();let u=gr(t,n);e.push(u.block),n=u.next;continue}if(!i&&o.includes("|")&&n+1<t.length&&pr.test(t[n+1])&&t[n+1].includes("-")){let u=Fe(o),c=Fe(t[n+1]).map(f=>f.startsWith(":")&&f.endsWith(":")?"center":f.endsWith(":")?"right":f.startsWith(":")?"left":null),h=[];for(n+=2;n<t.length&&t[n].trim()!==""&&!Ne.test(t[n])&&!ue.test(t[n])&&!He.test(t[n]);)h.push(Fe(t[n]).slice(0,u.length).map(f=>K(f))),n++;e.push({kind:"table",align:c,head:u.map(f=>K(f)),rows:h});continue}i||(i=[]),i.push(o.replace(/^ +/,"")),n++}return r(),e}function gr(t,e){let n=Wt.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=Wt.exec(t[l]);if(!a||a[1].length!==i||r===null!==/^\d/.test(a[2])||r!==null&&a[2]!==r)break;let u=a[1].length+a[2].length+Math.max(1,Math.min(a[3].length,4)),c=[a[4]];l++;let h=!1;for(;l<t.length;){let m=t[l];if(m.trim()===""){h=!0,c.push(""),l++;continue}if(m.length-m.trimStart().length>=u){c.push(m.slice(u)),h=!1,l++;continue}if(!h&&!Wt.test(m)&&!Ne.test(m)&&!ue.test(m)&&!He.test(m)&&!mi.test(m)){c.push(m.trimStart()),l++;continue}break}for(;c.length&&c[c.length-1].trim()==="";)c.pop();let f=null,d=/^\[([ xX])\](?:[ \t]+|$)/.exec(c[0]??"");if(d&&(f=d[1]!==" ",c[0]=c[0].slice(d[0].length)),s.push({checkbox:f,children:Ue(c)}),h&&l<t.length&&t[l-1]?.trim()===""){let m=Wt.exec(t[l]);if(!m||m[1].length!==i)break}}return{block:{kind:"list",ordered:o,items:s},next:l}}function K(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(`\\
15
+ `))}function Ke(t){let e=[],n=0,i=null,r=()=>{i&&(e.push({kind:"paragraph",inline:X(i.join(`
16
+ `))}),i=null)};for(;n<t.length;){let o=t[n];if(o.trim()===""){r(),n++;continue}let s=je.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(`
17
+ `)});continue}let l=He.exec(o);if(l){r(),e.push({kind:"heading",level:l[1].length,inline:X(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:X(i.join(`
18
+ `))}),i=null,n++;continue}if(mi.test(o)){r(),e.push({kind:"rule"}),n++;continue}if(ce.test(o)){r();let c=[];for(;n<t.length&&t[n].trim()!=="";){let u=ce.exec(t[n]);c.push(u?u[1]:t[n]),n++}e.push({kind:"quote",children:Ke(c)});continue}let a=Wt.exec(o);if(a&&(!i||a[4].trim()!=="")){r();let c=kr(t,n);e.push(c.block),n=c.next;continue}if(!i&&o.includes("|")&&n+1<t.length&&br.test(t[n+1])&&t[n+1].includes("-")){let c=Fe(o),u=Fe(t[n+1]).map(f=>f.startsWith(":")&&f.endsWith(":")?"center":f.endsWith(":")?"right":f.startsWith(":")?"left":null),h=[];for(n+=2;n<t.length&&t[n].trim()!==""&&!He.test(t[n])&&!ce.test(t[n])&&!je.test(t[n]);)h.push(Fe(t[n]).slice(0,c.length).map(f=>X(f))),n++;e.push({kind:"table",align:u,head:c.map(f=>X(f)),rows:h});continue}i||(i=[]),i.push(o.replace(/^ +/,"")),n++}return r(),e}function kr(t,e){let n=Wt.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=Wt.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 h=!1;for(;l<t.length;){let d=t[l];if(d.trim()===""){h=!0,u.push(""),l++;continue}if(d.length-d.trimStart().length>=c){u.push(d.slice(c)),h=!1,l++;continue}if(!h&&!Wt.test(d)&&!He.test(d)&&!ce.test(d)&&!je.test(d)&&!mi.test(d)){u.push(d.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:Ke(u)}),h&&l<t.length&&t[l-1]?.trim()===""){let d=Wt.exec(t[l]);if(!d||d[1].length!==i)break}}return{block:{kind:"list",ordered:o,items:s},next:l}}function X(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(`\\
19
19
  `)){for(o+=ft,r+=2;t[r]===" ";)r++;continue}if(l[0]===`
20
- `){for(o=o.replace(/ +$/,""),o+=ft,r++;t[r]===" ";)r++;continue}if(a=/^(`+)([\s\S]*?[^`])\1(?!`)/.exec(l)){s();let u=a[2].replace(/\n/g," ");/^ .* $/.test(u)&&(u=u.slice(1,-1)),i(u,{...e,mono:!0}),r+=a[0].length;continue}if(a=/^!\[([^\]]*)\]\([^)]*\)/.exec(l)){s(),n.push(...K(a[1],e)),r+=a[0].length;continue}if(a=/^\[([^\]]+)\]\([^)]*\)/.exec(l)){s(),n.push(...K(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(...K(a[1],{...e,strike:!0})),r+=a[0].length;continue}if(a=/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/.exec(l)){s(),n.push(...K(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(...K(a[2],{...e,italic:!0})),r+=a[0].length;continue}o+=l[0],r++}return s(),br(n)}function br(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 di(t){return t.bold?t.italic?"boldItalic":"bold":t.italic?"italic":"regular"}function he(t,e){if(e.mono&&le[t]===void 0)return ri*e.size;let n=vt[di(e)];return(n.w[t]??vt.regular.w[t]??n.w.n)*e.size/1e3}function je(t,e,n){return n.mono?0:(vt[di(n)].k[t+e]??0)*n.size/1e3}function _e(t,e){let n=le[t];return n?[n[0]*e.size,n[1]*e.size,n[2]*e.size]:e.mono?[oi*e.size,si*e.size,0]:e.bold&&e.italic?[ei*e.size,ni*e.size,ii*e.size]:e.bold?[Kn*e.size,Xn*e.size,Qn*e.size]:e.italic?[Zn*e.size,Jn*e.size,ti*e.size]:[re*e.size,oe*e.size,se*e.size]}var qe=class{constructor(e,n){P(this,"paras",[]);P(this,"nextSpacing",null);P(this,"fontSize");P(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((u,c)=>u.checkbox===!0?"\u2611":u.checkbox===!1?"\u2610":e.ordered!==null?`${e.ordered+c}.`:n.listDepth%2===0?"\u2022":"\u25E6"),s=u=>ci({text:u,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((u,c)=>{(c>0||n.listDepth>0||n.marker)&&(this.nextSpacing=this.fontSize*.15);let h={...n,marker:{text:o[c],start:n.indent,hang:a},indent:a,listDepth:n.listDepth+1};u.children.length===0&&this.text([],h,this.spacing(this.gap));for(let f of u.children)this.block(f,h),h.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,ft),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(y=>({cells:y,header:!1}))],r=Math.max(1,...i.map(y=>y.cells.length)),o=n.quote!==null,s=(y,R,A)=>y.map(k=>({...this.run({...k,text:k.text.replaceAll(ft," ")},A,o?.7:1,{bold:R,italic:o})})),l=y=>{let R=new Array(r).fill(0);for(let A of i)A.cells.forEach((k,g)=>{g<r&&(R[g]=Math.max(R[g],s(k,A.header,y).reduce((T,D)=>T+ci(D),0)))});return R},a=Math.max(this.width-n.indent,1),u=this.fontSize,c=l(u),h=u*1.2,f=c.reduce((y,R)=>y+R,0)+h*(r-1);f>a&&(u=Math.max(this.fontSize*a/f,Math.min(this.fontSize,9)),c=l(u),h=u*1.2);let d=[],m=n.indent;for(let y of c)d.push(m),m+=y+h;let p=m-h-n.indent,b=[],M=!1;for(let y=0;y<r;y++){let R=e.align[y]??null;R==="center"?b.push({align:"center",x:d[y]+c[y]/2}):R==="right"?b.push({align:"right",x:d[y]+c[y]}):y>0&&b.push({align:"left",x:d[y]}),y===0&&(R==="center"||R==="right")&&(M=!0)}let w=y=>({text:y,size:u,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1});i.forEach((y,R)=>{let A=[];M&&A.push(w(" "));for(let g=0;g<r;g++)g>0&&A.push(w(" ")),g<y.cells.length&&A.push(...s(y.cells[g],y.header,u));A.length===0&&A.push(w(" "));let k=R===0?this.spacing(this.gap):R===1?u*.45:u*.2;this.paragraph({runs:A,spacing:k,firstIndent:n.indent,indent:n.indent,tabs:b,tableRule:y.header?[n.indent,p]:null},n.quote)})}};function ci(t){let e=0,n="";for(let i of t.text)e+=he(i,t),n&&(e+=je(n,i,t)),n=i;return e}var ui=28;function xr(t,e,n,i){let r=[],o=0,s=null;return t.forEach((l,a)=>{let u=a<t.length-1?[...l.runs,{text:`
21
- `,size:i,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1}]:l.runs,c=[];u.forEach((d,m)=>{for(let p of d.text)c.push({ch:p,run:m})});let h=0,f=!0;for(;h<c.length||f&&c.length===0;){let d=f?l.firstIndent:l.indent,m=e,p=[],b=d,M=-1,w=h;for(;w<c.length;w++){let{ch:g,run:T}=c[w],D=u[T];if(g===ft||g===`
22
- `){p.push({ch:g,run:T,x:b,w:0}),w++;break}if(g===" "){let et=l.tabs.find(Et=>Et.x>b+.01),Tt;if(et)if(et.align==="left")Tt=et.x;else{let Et=0,ge="";for(let X=w+1;X<c.length&&c[X].ch!==" "&&c[X].ch!==`
23
- `&&c[X].ch!==ft;X++){let en=u[c[X].run];Et+=he(c[X].ch,en)+(ge?je(ge,c[X].ch,en):0),ge=c[X].ch}Tt=Math.max(b,et.align==="right"?et.x-Et:et.x-Et/2)}else Tt=(Math.floor(b/ui)+1)*ui;p.push({ch:g,run:T,x:b,w:Tt-b}),b=Tt;continue}let _=p[p.length-1],pe=_&&_.run===T&&_.ch!==" "?je(_.ch,g,D):0;_&&(_.w+=pe,b+=pe);let ye=he(g,D);if(g!==" "&&b+ye>m+.01&&p.some(et=>et.ch!==" ")){M>=0&&(p.length=M+1,w=h+M+1),_&&(_.w-=pe);break}p.push({ch:g,run:T,x:b,w:ye}),b+=ye,Ge(g,c[w+1]?.ch??"")&&(M=p.length-1)}if(p.length===0&&w===h&&h<c.length){let{ch:g,run:T}=c[h];p.push({ch:g,run:T,x:d,w:he(g,u[T])}),w=h+1}let y=0,R=0,A=0;for(let g of p){let[T,D,_]=_e(g.ch,u[g.run]);y=Math.max(y,T),R=Math.max(R,D),A=Math.max(A,_)}if(p.length===0&&([y,R,A]=_e(" ",u[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(y):Math.round(y),o+R>n+.5)return;let k={glyphs:p,asc:y,desc:R,lead:A,baseline:o,para:l,first:f};if(k.glyphs.forEach(g=>{g.r=u[g.run]}),r.push(k),s=k,f=!1,h=w,c.length===0)break}}),r}function fi(t,e){let n=fr({x:e.x,y:e.y,width:e.width,height:e.height});if(!(n.width>1&&n.height>1))return"";let i=new qe(e.style.fontSize,n.width);for(let u of yr(t))i.block(u,{indent:0,marker:null,quote:null,listDepth:0});let r=xr(i.paras,n.width,n.height,e.style.fontSize),o=O(e.style.stroke),s="",l=[];for(let u of r){let c=u.para;if(c.quote!==null&&l.push([n.x+c.quote,n.y+u.baseline-u.asc,n.x+c.quote,n.y+u.baseline+u.desc]),c.rule!==null&&l.push([n.x+c.rule,n.y+u.baseline-3,n.x+n.width,n.y+u.baseline-3]),c.tableRule){let m=n.y+u.baseline+u.desc+2;l.push([n.x+c.tableRule[0],m,Math.min(n.x+n.width,n.x+c.tableRule[0]+c.tableRule[1]),m])}let h="",f=0,d=u.glyphs;for(;f<d.length;){let m=d[f].r,p=f,b="",M=hi(d[f].ch);for(;p<d.length&&kr(d[p].r,m)&&d[p].ch!==" "&&hi(d[p].ch)===M;)b+=d[p].ch,p++;let w=b.replaceAll(`
24
- `,"").replaceAll(ft,"");if(w.trim()!==""){let y=`font-size="${x(m.size)}"`;m.mono&&(y+=' font-family="Menlo, Consolas, monospace"'),m.bold&&(y+=' font-weight="bold"'),m.italic&&(y+=' font-style="italic"'),m.underline&&(y+=' text-decoration="underline"'),m.alpha<1&&(y+=` fill-opacity="${x(m.alpha*e.style.stroke.a)}"`),h+=`<tspan x="${x(n.x+d[f].x)}" ${y}>${ae(w)}</tspan>`}if(m.strike&&p>f){let y=u.baseline-_e(d[f].ch,m)[0]*.32;l.push([n.x+d[f].x,n.y+y,n.x+d[p-1].x+d[p-1].w,n.y+y])}p===f&&p++,f=p}h&&(s+=`<text y="${x(n.y+u.baseline)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" fill="${o}" xml:space="preserve">${h}</text>
25
- `)}let a=x(Math.max(1,e.style.fontSize/14));for(let[u,c,h,f]of l)s+=`<line x1="${x(u)}" y1="${x(c)}" x2="${x(h)}" y2="${x(f)}" stroke="${o}" stroke-width="${a}"/>
26
- `;return s}function hi(t){return le[t]?`fb:${t}`:""}function kr(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 B=(t,e,n)=>({r:t,g:e,b:n,a:1}),Ke=[{id:"paper",name:"Paper",background:B(.984,.98,.965),ink:B(.12,.12,.13)},{id:"white",name:"White",background:B(1,1,1),ink:B(.12,.12,.13)},{id:"sepia",name:"Sepia",background:B(.953,.914,.824),ink:B(.23,.18,.13)},{id:"blueprint",name:"Blueprint",background:B(.106,.227,.361),ink:B(.91,.945,.984)},{id:"chalkboard",name:"Chalkboard",background:B(.169,.227,.2),ink:B(.945,.945,.918)},{id:"midnight",name:"Midnight",background:B(.082,.086,.102),ink:B(.925,.925,.94)}];function pt(t){return Ke.find(e=>e.id===t)??null}function tt(t,e=24){if(ie(t))return tt(j(t,0),e);let n=q(t),i=s=>{if(s.kind==="connector")return bn(s,n);let l=Ie(s)?(Se+.25)*mt(s):0;return Pt(dn(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=Pe(o,i(s));return Pt(o,-e,-e)}function At(t){let e=t.timeline??{fps:12,duration:0,boil:null,settle:null,poster:null,tracks:[],camera:null,markers:null},n=ee(e),i=e.camera?.find(o=>o.width>1&&o.height>1);if(i){let o=i.width/i.height,s=n.map(a=>Mt(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=U(t,o);s.elements.length>0&&(r=Pe(r,tt(s)))}return r||(r=tt(U(t,n[0]))),{times:n,rects:n.map(()=>r),size:{width:r.width,height:r.height}}}var zt=(t,e)=>t.a<1?` ${e}="${x(t.a)}"`:"";function wr(t,e,n){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${x(t.width)}" height="${x(t.height)}" viewBox="${x(t.x)} ${x(t.y)} ${x(t.width)} ${x(t.height)}">
20
+ `){for(o=o.replace(/ +$/,""),o+=ft,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(...X(a[1],e)),r+=a[0].length;continue}if(a=/^\[([^\]]+)\]\([^)]*\)/.exec(l)){s(),n.push(...X(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(...X(a[1],{...e,strike:!0})),r+=a[0].length;continue}if(a=/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/.exec(l)){s(),n.push(...X(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(...X(a[2],{...e,italic:!0})),r+=a[0].length;continue}o+=l[0],r++}return s(),wr(n)}function wr(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 fi(t){return t.bold?t.italic?"boldItalic":"bold":t.italic?"italic":"regular"}function he(t,e){if(e.mono&&le[t]===void 0)return oi*e.size;let n=Rt[fi(e)];return(n.w[t]??Rt.regular.w[t]??n.w.n)*e.size/1e3}function _e(t,e,n){return n.mono?0:(Rt[fi(n)].k[t+e]??0)*n.size/1e3}function qe(t,e){let n=le[t];return n?[n[0]*e.size,n[1]*e.size,n[2]*e.size]:e.mono?[si*e.size,li*e.size,0]:e.bold&&e.italic?[ni*e.size,ii*e.size,ri*e.size]:e.bold?[Xn*e.size,Qn*e.size,Zn*e.size]:e.italic?[Jn*e.size,ti*e.size,ei*e.size]:[re*e.size,oe*e.size,se*e.size]}var Ue=class{constructor(e,n){P(this,"paras",[]);P(this,"nextSpacing",null);P(this,"fontSize");P(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=>ci({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 h={...n,marker:{text:o[u],start:n.indent,hang:a},indent:a,listDepth:n.listDepth+1};c.children.length===0&&this.text([],h,this.spacing(this.gap));for(let f of c.children)this.block(f,h),h.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,ft),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(y=>({cells:y,header:!1}))],r=Math.max(1,...i.map(y=>y.cells.length)),o=n.quote!==null,s=(y,A,R)=>y.map(k=>({...this.run({...k,text:k.text.replaceAll(ft," ")},R,o?.7:1,{bold:A,italic:o})})),l=y=>{let A=new Array(r).fill(0);for(let R of i)R.cells.forEach((k,g)=>{g<r&&(A[g]=Math.max(A[g],s(k,R.header,y).reduce((E,D)=>E+ci(D),0)))});return A},a=Math.max(this.width-n.indent,1),c=this.fontSize,u=l(c),h=c*1.2,f=u.reduce((y,A)=>y+A,0)+h*(r-1);f>a&&(c=Math.max(this.fontSize*a/f,Math.min(this.fontSize,9)),u=l(c),h=c*1.2);let m=[],d=n.indent;for(let y of u)m.push(d),d+=y+h;let p=d-h-n.indent,b=[],v=!1;for(let y=0;y<r;y++){let A=e.align[y]??null;A==="center"?b.push({align:"center",x:m[y]+u[y]/2}):A==="right"?b.push({align:"right",x:m[y]+u[y]}):y>0&&b.push({align:"left",x:m[y]}),y===0&&(A==="center"||A==="right")&&(v=!0)}let w=y=>({text:y,size:c,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1});i.forEach((y,A)=>{let R=[];v&&R.push(w(" "));for(let g=0;g<r;g++)g>0&&R.push(w(" ")),g<y.cells.length&&R.push(...s(y.cells[g],y.header,c));R.length===0&&R.push(w(" "));let k=A===0?this.spacing(this.gap):A===1?c*.45:c*.2;this.paragraph({runs:R,spacing:k,firstIndent:n.indent,indent:n.indent,tabs:b,tableRule:y.header?[n.indent,p]:null},n.quote)})}};function ci(t){let e=0,n="";for(let i of t.text)e+=he(i,t),n&&(e+=_e(n,i,t)),n=i;return e}var hi=28;function Pr(t,e,n,i){let r=[],o=0,s=null;return t.forEach((l,a)=>{let c=a<t.length-1?[...l.runs,{text:`
21
+ `,size:i,bold:!1,italic:!1,mono:!1,strike:!1,underline:!1,alpha:1}]:l.runs,u=[];c.forEach((m,d)=>{for(let p of m.text)u.push({ch:p,run:d})});let h=0,f=!0;for(;h<u.length||f&&u.length===0;){let m=f?l.firstIndent:l.indent,d=e,p=[],b=m,v=-1,w=h;for(;w<u.length;w++){let{ch:g,run:E}=u[w],D=c[E];if(g===ft||g===`
22
+ `){p.push({ch:g,run:E,x:b,w:0}),w++;break}if(g===" "){let nt=l.tabs.find(St=>St.x>b+.01),Tt;if(nt)if(nt.align==="left")Tt=nt.x;else{let St=0,ge="";for(let Q=w+1;Q<u.length&&u[Q].ch!==" "&&u[Q].ch!==`
23
+ `&&u[Q].ch!==ft;Q++){let nn=c[u[Q].run];St+=he(u[Q].ch,nn)+(ge?_e(ge,u[Q].ch,nn):0),ge=u[Q].ch}Tt=Math.max(b,nt.align==="right"?nt.x-St:nt.x-St/2)}else Tt=(Math.floor(b/hi)+1)*hi;p.push({ch:g,run:E,x:b,w:Tt-b}),b=Tt;continue}let _=p[p.length-1],pe=_&&_.run===E&&_.ch!==" "?_e(_.ch,g,D):0;_&&(_.w+=pe,b+=pe);let ye=he(g,D);if(g!==" "&&b+ye>d+.01&&p.some(nt=>nt.ch!==" ")){v>=0&&(p.length=v+1,w=h+v+1),_&&(_.w-=pe);break}p.push({ch:g,run:E,x:b,w:ye}),b+=ye,Ne(g,u[w+1]?.ch??"")&&(v=p.length-1)}if(p.length===0&&w===h&&h<u.length){let{ch:g,run:E}=u[h];p.push({ch:g,run:E,x:m,w:he(g,c[E])}),w=h+1}let y=0,A=0,R=0;for(let g of p){let[E,D,_]=qe(g.ch,c[g.run]);y=Math.max(y,E),A=Math.max(A,D),R=Math.max(R,_)}if(p.length===0&&([y,A,R]=qe(" ",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(y):Math.round(y),o+A>n+.5)return;let k={glyphs:p,asc:y,desc:A,lead:R,baseline:o,para:l,first:f};if(k.glyphs.forEach(g=>{g.r=c[g.run]}),r.push(k),s=k,f=!1,h=w,u.length===0)break}}),r}function pi(t,e){let n=gr({x:e.x,y:e.y,width:e.width,height:e.height});if(!(n.width>1&&n.height>1))return"";let i=new Ue(e.style.fontSize,n.width);for(let c of xr(t))i.block(c,{indent:0,marker:null,quote:null,listDepth:0});let r=Pr(i.paras,n.width,n.height,e.style.fontSize),o=O(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 d=n.y+c.baseline+c.desc+2;l.push([n.x+u.tableRule[0],d,Math.min(n.x+n.width,n.x+u.tableRule[0]+u.tableRule[1]),d])}let h="",f=0,m=c.glyphs;for(;f<m.length;){let d=m[f].r,p=f,b="",v=di(m[f].ch);for(;p<m.length&&Mr(m[p].r,d)&&m[p].ch!==" "&&di(m[p].ch)===v;)b+=m[p].ch,p++;let w=b.replaceAll(`
24
+ `,"").replaceAll(ft,"");if(w.trim()!==""){let y=`font-size="${x(d.size)}"`;d.mono&&(y+=' font-family="Menlo, Consolas, monospace"'),d.bold&&(y+=' font-weight="bold"'),d.italic&&(y+=' font-style="italic"'),d.underline&&(y+=' text-decoration="underline"'),d.alpha<1&&(y+=` fill-opacity="${x(d.alpha*e.style.stroke.a)}"`),h+=`<tspan x="${x(n.x+m[f].x)}" ${y}>${ae(w)}</tspan>`}if(d.strike&&p>f){let y=c.baseline-qe(m[f].ch,d)[0]*.32;l.push([n.x+m[f].x,n.y+y,n.x+m[p-1].x+m[p-1].w,n.y+y])}p===f&&p++,f=p}h&&(s+=`<text y="${x(n.y+c.baseline)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" fill="${o}" xml:space="preserve">${h}</text>
25
+ `)}let a=x(Math.max(1,e.style.fontSize/14));for(let[c,u,h,f]of l)s+=`<line x1="${x(c)}" y1="${x(u)}" x2="${x(h)}" y2="${x(f)}" stroke="${o}" stroke-width="${a}"/>
26
+ `;return s}function di(t){return le[t]?`fb:${t}`:""}function Mr(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 B=(t,e,n)=>({r:t,g:e,b:n,a:1}),Xe=[{id:"paper",name:"Paper",background:B(.984,.98,.965),ink:B(.12,.12,.13)},{id:"white",name:"White",background:B(1,1,1),ink:B(.12,.12,.13)},{id:"sepia",name:"Sepia",background:B(.953,.914,.824),ink:B(.23,.18,.13)},{id:"blueprint",name:"Blueprint",background:B(.106,.227,.361),ink:B(.91,.945,.984)},{id:"chalkboard",name:"Chalkboard",background:B(.169,.227,.2),ink:B(.945,.945,.918)},{id:"midnight",name:"Midnight",background:B(.082,.086,.102),ink:B(.925,.925,.94)}];function pt(t){return Xe.find(e=>e.id===t)??null}function et(t,e=24){if(ie(t))return et(j(t,0),e);let n=U(t),i=s=>{if(s.kind==="connector")return xn(s,n);let l=$e(s)?(Ie+.25)*dt(s):0;return Pt(fn(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=Pe(o,i(s));return Pt(o,-e,-e)}function At(t){let e=t.timeline??{fps:12,duration:0,boil:null,settle:null,poster:null,tracks:[],camera:null,markers:null},n=ee(e),i=e.camera?.find(o=>o.width>1&&o.height>1);if(i){let o=i.width/i.height,s=n.map(a=>vt(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=K(t,o);s.elements.length>0&&(r=Pe(r,et(s)))}return r||(r=et(K(t,n[0]))),{times:n,rects:n.map(()=>r),size:{width:r.width,height:r.height}}}var Yt=(t,e)=>t.a<1?` ${e}="${x(t.a)}"`:"";function vr(t,e,n){let i=`<svg xmlns="http://www.w3.org/2000/svg" width="${x(t.width)}" height="${x(t.height)}" viewBox="${x(t.x)} ${x(t.y)} ${x(t.width)} ${x(t.height)}">
27
27
  `;return n&&e&&(i+=`<rect x="${x(t.x)}" y="${x(t.y)}" width="${x(t.width)}" height="${x(t.height)}" fill="${O(e)}"/>
28
- `),i}function ct(t,e,n){if(ie(t))return ct(j(t,0),e,n);let i=pt(t.theme),r=e?i?.background??e:null,o=i?.ink??ut,s={...t,elements:t.elements.map(m=>fn(m,o))},l=n??tt(s),a=new Set(s.layers.filter(m=>m.visible).map(m=>m.id)),u=[],c=q(s),h=ht(s),f=h.filter(m=>a.has(m.layerID)&&Ie(m)),d=$n(f).map(m=>`<path d="${m.path.data()}" fill="none" stroke="${O(m.ink)}"${zt(m.ink,"stroke-opacity")} stroke-width="${x(m.width)}" stroke-linecap="round"/>
29
- `).join("");d&&u.push({key:"rock",markup:d});for(let m of h){if(!a.has(m.layerID))continue;let p=Math.min(Math.max(m.style.opacity??1,0),1);if(p<=0)continue;let b=Ar(m,c,r);W(m)!==0&&m.kind!=="connector"&&(b=`<g transform="rotate(${x(W(m)*180/Math.PI)} ${x(N(L(m)))} ${x(H(L(m)))})">
28
+ `),i}function ut(t,e,n){if(ie(t))return ut(j(t,0),e,n);let i=pt(t.theme),r=e?i?.background??e:null,o=i?.ink??ct,s={...t,elements:t.elements.map(d=>pn(d,o))},l=n??et(s),a=new Set(s.layers.filter(d=>d.visible).map(d=>d.id)),c=[],u=U(s),h=ht(s),f=h.filter(d=>a.has(d.layerID)&&$e(d)),m=Ln(f).map(d=>`<path d="${d.path.data()}" fill="none" stroke="${O(d.ink)}"${Yt(d.ink,"stroke-opacity")} stroke-width="${x(d.width)}" stroke-linecap="round"/>
29
+ `).join("");m&&c.push({key:"rock",markup:m});for(let d of h){if(!a.has(d.layerID))continue;let p=Math.min(Math.max(d.style.opacity??1,0),1);if(p<=0)continue;let b=Tr(d,u,r);V(d)!==0&&d.kind!=="connector"&&(b=`<g transform="rotate(${x(V(d)*180/Math.PI)} ${x(F(L(d)))} ${x(H(L(d)))})">
30
30
  ${b}</g>
31
- `),u.push({key:m.id,markup:p<1?`<g opacity="${x(p)}">
31
+ `),c.push({key:d.id,markup:p<1?`<g opacity="${x(p)}">
32
32
  ${b}</g>
33
- `:b})}return{bounds:l,parts:u}}function de(t,e={r:1,g:1,b:1,a:1},n){let{bounds:i,parts:r}=ct(t,e,n);return wr(i,pt(t.theme)?.background??e,e!==null)+r.map(o=>o.markup).join("")+`</svg>
34
- `}function Pr(t,e){let n=xn(t,e),i=t.text??"",r=li(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 Mr(t,e){let n=[...t];return n.slice(0,Math.floor(n.length*e)).join("")}function vr(t){return t.reveal!==null&&t.reveal<1?Math.max(0,t.reveal):null}function Ar(t,e,n){let i=O(t.style.stroke),r=`stroke="${i}" stroke-width="${x(t.style.strokeWidth)}" stroke-linecap="round" stroke-linejoin="round"`,o=Jt(t.style.dash,t.style.strokeWidth);o&&(r+=` stroke-dasharray="${o.map(x).join(" ")}"`),o&&t.style.dashOffset!==null&&x(t.style.dashOffset)!=="0"&&(r+=` stroke-dashoffset="${x(t.style.dashOffset)}"`);let s=t.text,l=vr(t);if(l!==null)if(t.kind==="text")s=Mr(s??"",l);else return t.kind==="connector"?`<path d="${De(t,e)[0].trimmed(l).data()}" fill="none" ${r}/>
35
- `:`<path d="${dt(t).trimmed(l).data()}" fill="none" ${r}/>
36
- `;switch(t.kind){case"connector":{let[a,u]=De(t,e),c=`<path d="${a.data()}" fill="none" ${r}/>
37
- `;if(u.isEmpty||(c+=`<path d="${u.data()}" fill="${i}" stroke="none"/>
38
- `),s){let h=Pr(t,e);n&&(c+=`<rect x="${x(h.x)}" y="${x(h.y)}" width="${x(h.width)}" height="${x(h.height)}" fill="${O(n)}"/>
39
- `),c+=me(s,h,t,!0)}return c}case"text":return me(s??"",L(t),t,!1);case"image":{let a=L(t),u="";if(t.image){let c=t.image.format==="jpeg"?"image/jpeg":"image/png";u+=`<image x="${x(a.x)}" y="${x(a.y)}" width="${x(a.width)}" height="${x(a.height)}" preserveAspectRatio="none" href="data:${c};base64,${t.image.data}"/>
40
- `}return t.style.stroke.a>0&&t.style.strokeWidth>0&&(u+=`<path d="${dt(t).data()}" fill="none" ${r}/>
41
- `),u}case"freehand":return`<path d="${dt(t).data()}" fill="none" ${r}/>
33
+ `:b})}return{bounds:l,parts:c}}function me(t,e={r:1,g:1,b:1,a:1},n){let{bounds:i,parts:r}=ut(t,e,n);return vr(i,pt(t.theme)?.background??e,e!==null)+r.map(o=>o.markup).join("")+`</svg>
34
+ `}function Rr(t,e){let n=kn(t,e),i=t.text??"",r=ai(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 Ar(t,e){let n=[...t];return n.slice(0,Math.floor(n.length*e)).join("")}function Er(t){return t.reveal!==null&&t.reveal<1?Math.max(0,t.reveal):null}function Tr(t,e,n){let i=O(t.style.stroke),r=`stroke="${i}" stroke-width="${x(t.style.strokeWidth)}" stroke-linecap="round" stroke-linejoin="round"`,o=Jt(t.style.dash,t.style.strokeWidth);o&&(r+=` stroke-dasharray="${o.map(x).join(" ")}"`),o&&t.style.dashOffset!==null&&x(t.style.dashOffset)!=="0"&&(r+=` stroke-dashoffset="${x(t.style.dashOffset)}"`);let s=t.text,l=Er(t);if(l!==null)if(t.kind==="text")s=Ar(s??"",l);else return t.kind==="connector"?`<path d="${Oe(t,e)[0].trimmed(l).data()}" fill="none" ${r}/>
35
+ `:`<path d="${mt(t).trimmed(l).data()}" fill="none" ${r}/>
36
+ `;switch(t.kind){case"connector":{let[a,c]=Oe(t,e),u=`<path d="${a.data()}" fill="none" ${r}/>
37
+ `;if(c.isEmpty||(u+=`<path d="${c.data()}" fill="${i}" stroke="none"/>
38
+ `),s){let h=Rr(t,e);n&&(u+=`<rect x="${x(h.x)}" y="${x(h.y)}" width="${x(h.width)}" height="${x(h.height)}" fill="${O(n)}"/>
39
+ `),u+=de(s,h,t,!0)}return u}case"text":return de(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="${x(a.x)}" y="${x(a.y)}" width="${x(a.width)}" height="${x(a.height)}" preserveAspectRatio="none" href="data:${u};base64,${t.image.data}"/>
40
+ `}return t.style.stroke.a>0&&t.style.strokeWidth>0&&(c+=`<path d="${mt(t).data()}" fill="none" ${r}/>
41
+ `),c}case"freehand":return`<path d="${mt(t).data()}" fill="none" ${r}/>
42
42
  `;case"rectangle":case"ellipse":case"diamond":case"path":case"note":{let a="";if(t.kind==="note"&&t.style.fill.a>0&&(a+=`<path d="${Zt(t).translated(2,3).data()}" fill="#000000" fill-opacity="${x(.14*t.style.fill.a)}" stroke="none"/>
43
- `),t.style.fill.a>0){let u=t.evenOdd===!0?' fill-rule="evenodd"':"";if(t.style.fillStyle==="solid")a+=`<path d="${Zt(t).data()}" fill="${O(t.style.fill)}"${zt(t.style.fill,"fill-opacity")}${u} stroke="none"/>
44
- `;else if(t.style.fillStyle==="grid"){let c=Sn(t.style.fill);a+=`<path d="${Zt(t).data()}" fill="${O(t.style.fill)}"${zt(t.style.fill,"fill-opacity")}${u} stroke="none"/>
45
- `,a+=`<path d="${Le(t).data()}" fill="none" stroke="${O(c)}"${zt(c,"stroke-opacity")} stroke-width="1" stroke-linecap="round"/>
46
- `}else a+=`<path d="${Le(t).data()}" fill="none" stroke="${O(t.style.fill)}"${zt(t.style.fill,"stroke-opacity")} stroke-width="${x(Math.max(1,t.style.strokeWidth/2))}" stroke-linecap="round"/>
47
- `}return a+=`<path d="${dt(t).data()}" fill="none" ${r}/>
48
- `,s&&(a+=t.kind==="note"?fi(s,t):me(s,L(t),t,!0)),a}default:return Rr(t,r)}}function Rr(t,e){let n=L(t);return`<path d="${E.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"/>
49
- `+me(`${t.kind}${t.text?`: ${t.text}`:""}`,n,{...t,style:{...t.style,fontSize:Math.min(t.style.fontSize,12)}},!0)}function me(t,e,n,i){let r=n.style.fontSize,o=t.split(`
50
- `),s=r*1.2,l=s*o.length,a=i?N(e):e.x,u=i?H(e)-l/2:e.y,c=`<text x="${x(a)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" font-size="${x(r)}" fill="${O(n.style.stroke)}"${i?' text-anchor="middle"':""}>`;return o.forEach((h,f)=>{c+=`<tspan x="${x(a)}" y="${x(u+s*(f+.8))}">${ae(h)}</tspan>`}),c+`</text>
51
- `}var Tr={r:1,g:1,b:1,a:1};function Bt(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 Gt(t,e){return{...t,elements:t.elements.map(n=>({...n,style:{...n.style,roughness:e}}))}}var Er=`
43
+ `),t.style.fill.a>0){let c=t.evenOdd===!0?' fill-rule="evenodd"':"";if(t.style.fillStyle==="solid")a+=`<path d="${Zt(t).data()}" fill="${O(t.style.fill)}"${Yt(t.style.fill,"fill-opacity")}${c} stroke="none"/>
44
+ `;else if(t.style.fillStyle==="grid"){let u=In(t.style.fill);a+=`<path d="${Zt(t).data()}" fill="${O(t.style.fill)}"${Yt(t.style.fill,"fill-opacity")}${c} stroke="none"/>
45
+ `,a+=`<path d="${De(t).data()}" fill="none" stroke="${O(u)}"${Yt(u,"stroke-opacity")} stroke-width="1" stroke-linecap="round"/>
46
+ `}else a+=`<path d="${De(t).data()}" fill="none" stroke="${O(t.style.fill)}"${Yt(t.style.fill,"stroke-opacity")} stroke-width="${x(Math.max(1,t.style.strokeWidth/2))}" stroke-linecap="round"/>
47
+ `}return a+=`<path d="${mt(t).data()}" fill="none" ${r}/>
48
+ `,s&&(a+=t.kind==="note"?pi(s,t):de(s,t.kind==="path"?Ir(t):L(t),t,!0)),a}default:return Sr(t,r)}}function Sr(t,e){let n=L(t);return`<path d="${T.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"/>
49
+ `+de(`${t.kind}${t.text?`: ${t.text}`:""}`,n,{...t,style:{...t.style,fontSize:Math.min(t.style.fontSize,12)}},!0)}function Ir(t){let e=L(t),n=t.labelRect;return n?{x:e.x+n.x*e.width,y:e.y+n.y*e.height,width:n.width*e.width,height:n.height*e.height}:e}function de(t,e,n,i){let r=n.style.fontSize,o=t.split(`
50
+ `),s=r*1.2,l=s*o.length,a=i?F(e):e.x,c=i?H(e)-l/2:e.y,u=`<text x="${x(a)}" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" font-size="${x(r)}" fill="${O(n.style.stroke)}"${i?' text-anchor="middle"':""}>`;return o.forEach((h,f)=>{u+=`<tspan x="${x(a)}" y="${x(c+s*(f+.8))}">${ae(h)}</tspan>`}),u+`</text>
51
+ `}var $r={r:1,g:1,b:1,a:1};function Gt(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 Nt(t,e){return{...t,elements:t.elements.map(n=>({...n,style:{...n.style,roughness:e}}))}}var Lr=`
52
52
  :host { display: block; position: relative; color: var(--dottie-ink); background: var(--dottie-page);
53
53
  font: 14px -apple-system, system-ui, sans-serif; border-radius: var(--dottie-radius, 0); }
54
54
  :host([hidden]) { display: none; }
@@ -63,16 +63,16 @@ input[type=range] { flex: 1; min-width: 60px; accent-color: currentColor; }
63
63
  output { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
64
64
  .scene { min-width: 0; flex: 0 1 auto; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
65
65
  .error { padding: 16px; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; }
66
- ${Un}`,Yt=class{constructor(e,n,i={}){P(this,"page");P(this,"plan");P(this,"scenes");P(this,"sceneNames");P(this,"background");P(this,"ink");P(this,"clicks");P(this,"replays",new Map);P(this,"replayStarts",new Map);P(this,"hoverIDs");P(this,"labels",new Map);P(this,"owner",new Map);P(this,"partsOfOwner",new Map);P(this,"overTimes",new Map);P(this,"downTimes",new Map);P(this,"hitTimes",new Map);P(this,"last",{t:0,i:0});P(this,"svg");P(this,"groups",new Map);P(this,"order",[]);P(this,"frame",-1);P(this,"onFrame",null);this.page=i.clean?Gt(e,0):e,this.plan=At(this.page),this.clicks=Nn(e,i.file);let r=Be(this.page);for(let c of this.page.elements){let h=c.kind==="symbol"&&c.symbol!==null?r.get(c.symbol):void 0;if(h)if(h.button===!0)for(let[f,d]of[["over",this.overTimes],["down",this.downTimes],["hit",this.hitTimes]]){let m=Vt(h,f);m!==null&&d.set(c.id,m)}else c.playback==="click"&&(h.timeline?.duration??0)>0&&this.replays.set(c.id,h.timeline.duration)}let o=new Set([...this.clicks.keys(),...this.replays.keys()]);this.hoverIDs=new Set(this.page.elements.filter(c=>o.has(c.id)&&c.kind!=="symbol"&&jn(c)).map(c=>c.id));let s=new Set(this.page.elements.filter(c=>o.has(c.id)&&c.kind==="symbol").map(c=>c.id));for(let c of this.page.elements)o.has(c.id)&&(this.labels.set(c.id,_n(c,c.symbol!==null?r.get(c.symbol)?.name:void 0)),c.kind!=="symbol"&&this.owner.set(c.id,c.id));for(let[c,h]of qn(this.page,s))this.owner.set(c,h);for(let[c,h]of this.owner)this.partsOfOwner.set(h,[...this.partsOfOwner.get(h)??[],c]);let l=c=>{let h=0;return this.plan.times.forEach((f,d)=>{Math.abs(f-c)<Math.abs(this.plan.times[h]-c)&&(h=d)}),h};this.scenes=(e.timeline?.markers??[]).map(c=>l(c.t)),this.sceneNames=(e.timeline?.markers??[]).map(c=>c.name);let a=pt(e.theme);this.background=a?.background??Tr,this.ink=a?.ink??{r:.12,g:.12,b:.13,a:1};let u="http://www.w3.org/2000/svg";this.svg=document.createElementNS(u,"svg"),this.svg.setAttribute("width",x(this.plan.size.width)),this.svg.setAttribute("height",x(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=at(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)}replay(e,n){this.replays.has(e)&&this.replayStarts.set(e,n)}replaying(e=performance.now()){for(let[n,i]of this.replayStarts)if(e-i<(this.replays.get(n)??0)*1e3)return!0;return!1}redraw(){this.drawAt(this.last.t,this.last.i)}drawAt(e,n=0){this.last={t:e,i:n};let i=this.plan.rects[Math.min(n,this.plan.rects.length-1)],r=typeof performance>"u"?0:performance.now(),o=new Map;for(let[k,g]of this.replayStarts)o.set(k,Math.min((r-g)/1e3,this.replays.get(k)??0));let s=C(e),l=Ot(this.page,s),a=j(l,s,!0,o),{parts:u}=ct(a,this.background,i),c=(k,g)=>{for(let T of g)this.owner.has(T.key)&&k.set(T.key,T.markup);return k},h=k=>k.size===0?new Map:c(new Map,ct(j(l,s,!0,new Map([...o,...k])),this.background,i).parts.filter(g=>k.has(this.owner.get(g.key)??""))),f=this.hoverIDs.size===0?new Map:c(new Map,ct(Hn(a,this.hoverIDs),this.background,i).parts.filter(k=>this.hoverIDs.has(k.key))),d=h(this.overTimes),m=h(this.downTimes),p=h(this.hitTimes),b=c(new Map,u),M=[],w=new Set;for(let k of u){let g=this.owner.get(k.key);if(g===void 0){M.push(k);continue}w.has(g)||(w.add(g),M.push(this.buttonPart(g,b,f,d,m,p,l)))}this.svg.setAttribute("viewBox",`${x(i.x)} ${x(i.y)} ${x(i.width)} ${x(i.height)}`);let y="http://www.w3.org/2000/svg",R=M.map(k=>k.key);for(let k of M){let g=k.markup,T=this.groups.get(k.key);if(T)T.markup!==g&&(T.g.innerHTML=g,T.markup=g),k.button!==void 0&&T.g.classList.toggle("dottie-b",k.button);else{let D=document.createElementNS(y,"g");D.innerHTML=g,k.button!==void 0&&(D.setAttribute("class",k.button?"dottie-a dottie-b":"dottie-a"),D.setAttribute("data-a",k.key),D.setAttribute("tabindex","0"),D.setAttribute("role","button"),D.setAttribute("aria-label",this.labels.get(k.key)??"")),this.groups.set(k.key,{g:D,markup:g})}}let A=new Set(R);for(let[k,g]of this.groups)A.has(k)||(g.g.remove(),this.groups.delete(k));if(R.length!==this.order.length||R.some((k,g)=>k!==this.order[g])){let k=this.svg.firstChild;for(let g of R){let T=this.groups.get(g).g;T===k?k=k.nextSibling:this.svg.insertBefore(T,k)}for(;k;){let g=k.nextSibling;k.remove(),k=g}this.order=R}}buttonPart(e,n,i,r,o,s,l){let a=this.partsOfOwner.get(e)??[e],u=w=>{let y=a.map(R=>w.get(R)??"").join("");return y===""?null:y},c=u(n)??"",h=l.elements.find(w=>w.id===e&&w.kind==="symbol"),f=u(h?r:i),d=h?u(o):null,m=f!==null&&f!==c?f:null,p=d!==null&&d!==(f??c)?d:null;if(!h&&m===null)return{key:e,markup:c,button:!1};let b=h?' pointer-events="none"':"",M=`<g class="dottie-n"${b}>
67
- ${c}</g>
68
- `;if(m!==null&&(M+=`<g class="dottie-h"${b}>
69
- ${m}</g>
70
- `),p!==null&&(M+=`<g class="dottie-d"${b}>
66
+ ${Kn}`,Bt=class{constructor(e,n,i={}){P(this,"page");P(this,"plan");P(this,"scenes");P(this,"sceneNames");P(this,"background");P(this,"ink");P(this,"clicks");P(this,"replays",new Map);P(this,"replayStarts",new Map);P(this,"hoverIDs");P(this,"labels",new Map);P(this,"owner",new Map);P(this,"partsOfOwner",new Map);P(this,"overTimes",new Map);P(this,"downTimes",new Map);P(this,"hitTimes",new Map);P(this,"last",{t:0,i:0});P(this,"svg");P(this,"groups",new Map);P(this,"order",[]);P(this,"frame",-1);P(this,"onFrame",null);this.page=i.clean?Nt(e,0):e,this.plan=At(this.page),this.clicks=Hn(e,i.file);let r=Ge(this.page);for(let u of this.page.elements){let h=u.kind==="symbol"&&u.symbol!==null?r.get(u.symbol):void 0;if(h)if(h.button===!0)for(let[f,m]of[["over",this.overTimes],["down",this.downTimes],["hit",this.hitTimes]]){let d=Vt(h,f);d!==null&&m.set(u.id,d)}else u.playback==="click"&&(h.timeline?.duration??0)>0&&this.replays.set(u.id,h.timeline.duration)}let o=new Set([...this.clicks.keys(),...this.replays.keys()]);this.hoverIDs=new Set(this.page.elements.filter(u=>o.has(u.id)&&u.kind!=="symbol"&&_n(u)).map(u=>u.id));let s=new Set(this.page.elements.filter(u=>o.has(u.id)&&u.kind==="symbol").map(u=>u.id));for(let u of this.page.elements)o.has(u.id)&&(this.labels.set(u.id,qn(u,u.symbol!==null?r.get(u.symbol)?.name:void 0)),u.kind!=="symbol"&&this.owner.set(u.id,u.id));for(let[u,h]of Un(this.page,s))this.owner.set(u,h);for(let[u,h]of this.owner)this.partsOfOwner.set(h,[...this.partsOfOwner.get(h)??[],u]);let l=u=>{let h=0;return this.plan.times.forEach((f,m)=>{Math.abs(f-u)<Math.abs(this.plan.times[h]-u)&&(h=m)}),h};this.scenes=(e.timeline?.markers??[]).map(u=>l(u.t)),this.sceneNames=(e.timeline?.markers??[]).map(u=>u.name);let a=pt(e.theme);this.background=a?.background??$r,this.ink=a?.ink??{r:.12,g:.12,b:.13,a:1};let c="http://www.w3.org/2000/svg";this.svg=document.createElementNS(c,"svg"),this.svg.setAttribute("width",x(this.plan.size.width)),this.svg.setAttribute("height",x(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=at(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)}replay(e,n){this.replays.has(e)&&this.replayStarts.set(e,n)}replaying(e=performance.now()){for(let[n,i]of this.replayStarts)if(e-i<(this.replays.get(n)??0)*1e3)return!0;return!1}redraw(){this.drawAt(this.last.t,this.last.i)}drawAt(e,n=0){this.last={t:e,i:n};let i=this.plan.rects[Math.min(n,this.plan.rects.length-1)],r=typeof performance>"u"?0:performance.now(),o=new Map;for(let[k,g]of this.replayStarts)o.set(k,Math.min((r-g)/1e3,this.replays.get(k)??0));let s=C(e),l=Ct(this.page,s),a=j(l,s,!0,o),{parts:c}=ut(a,this.background,i),u=(k,g)=>{for(let E of g)this.owner.has(E.key)&&k.set(E.key,E.markup);return k},h=k=>k.size===0?new Map:u(new Map,ut(j(l,s,!0,new Map([...o,...k])),this.background,i).parts.filter(g=>k.has(this.owner.get(g.key)??""))),f=this.hoverIDs.size===0?new Map:u(new Map,ut(jn(a,this.hoverIDs),this.background,i).parts.filter(k=>this.hoverIDs.has(k.key))),m=h(this.overTimes),d=h(this.downTimes),p=h(this.hitTimes),b=u(new Map,c),v=[],w=new Set;for(let k of c){let g=this.owner.get(k.key);if(g===void 0){v.push(k);continue}w.has(g)||(w.add(g),v.push(this.buttonPart(g,b,f,m,d,p,l)))}this.svg.setAttribute("viewBox",`${x(i.x)} ${x(i.y)} ${x(i.width)} ${x(i.height)}`);let y="http://www.w3.org/2000/svg",A=v.map(k=>k.key);for(let k of v){let g=k.markup,E=this.groups.get(k.key);if(E)E.markup!==g&&(E.g.innerHTML=g,E.markup=g),k.button!==void 0&&E.g.classList.toggle("dottie-b",k.button);else{let D=document.createElementNS(y,"g");D.innerHTML=g,k.button!==void 0&&(D.setAttribute("class",k.button?"dottie-a dottie-b":"dottie-a"),D.setAttribute("data-a",k.key),D.setAttribute("tabindex","0"),D.setAttribute("role","button"),D.setAttribute("aria-label",this.labels.get(k.key)??"")),this.groups.set(k.key,{g:D,markup:g})}}let R=new Set(A);for(let[k,g]of this.groups)R.has(k)||(g.g.remove(),this.groups.delete(k));if(A.length!==this.order.length||A.some((k,g)=>k!==this.order[g])){let k=this.svg.firstChild;for(let g of A){let E=this.groups.get(g).g;E===k?k=k.nextSibling:this.svg.insertBefore(E,k)}for(;k;){let g=k.nextSibling;k.remove(),k=g}this.order=A}}buttonPart(e,n,i,r,o,s,l){let a=this.partsOfOwner.get(e)??[e],c=w=>{let y=a.map(A=>w.get(A)??"").join("");return y===""?null:y},u=c(n)??"",h=l.elements.find(w=>w.id===e&&w.kind==="symbol"),f=c(h?r:i),m=h?c(o):null,d=f!==null&&f!==u?f:null,p=m!==null&&m!==(f??u)?m:null;if(!h&&d===null)return{key:e,markup:u,button:!1};let b=h?' pointer-events="none"':"",v=`<g class="dottie-n"${b}>
67
+ ${u}</g>
68
+ `;if(d!==null&&(v+=`<g class="dottie-h"${b}>
69
+ ${d}</g>
70
+ `),p!==null&&(v+=`<g class="dottie-d"${b}>
71
71
  ${p}</g>
72
- `),h){let w=u(s);if(w!==null)M+=`<g class="dottie-hit" opacity="0" pointer-events="all">
72
+ `),h){let w=c(s);if(w!==null)v+=`<g class="dottie-hit" opacity="0" pointer-events="all">
73
73
  ${w}</g>
74
- `;else{let y={x:h.x+h.width/2,y:h.y+h.height/2},R=h.rotation??0,A=[[h.x,h.y],[h.x+h.width,h.y],[h.x+h.width,h.y+h.height],[h.x,h.y+h.height]].map(([g,T])=>nt({x:g,y:T},y,R)),k=new E().moveTo(A[0]).lineTo(A[1]).lineTo(A[2]).lineTo(A[3]).close();M+=`<path class="dottie-hit" d="${k.data()}" fill="none" stroke="none" pointer-events="all"/>
75
- `}}return{key:e,markup:M,button:p!==null}}sceneAt(e){let n=-1;return this.scenes.forEach((i,r)=>{i<=e&&(n=r)}),n}},Sr=typeof HTMLElement>"u"?class{}:HTMLElement,Rt=class extends Sr{constructor(){super();P(this,"file",null);P(this,"playback",null);P(this,"root");P(this,"stage");P(this,"bar");P(this,"playButton");P(this,"scrub");P(this,"time");P(this,"sceneLabel");P(this,"prev");P(this,"next");P(this,"playing",!1);P(this,"last",0);P(this,"acc",0);P(this,"raf",0);P(this,"replayRaf",0);P(this,"loadToken",0);P(this,"visible",!0);P(this,"observer",null);this.root=this.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Er}</style><div class="stage" part="stage" role="img"></div>
74
+ `;else{let y={x:h.x+h.width/2,y:h.y+h.height/2},A=h.rotation??0,R=[[h.x,h.y],[h.x+h.width,h.y],[h.x+h.width,h.y+h.height],[h.x,h.y+h.height]].map(([g,E])=>it({x:g,y:E},y,A)),k=new T().moveTo(R[0]).lineTo(R[1]).lineTo(R[2]).lineTo(R[3]).close();v+=`<path class="dottie-hit" d="${k.data()}" fill="none" stroke="none" pointer-events="all"/>
75
+ `}}return{key:e,markup:v,button:p!==null}}sceneAt(e){let n=-1;return this.scenes.forEach((i,r)=>{i<=e&&(n=r)}),n}},Dr=typeof HTMLElement>"u"?class{}:HTMLElement,Et=class extends Dr{constructor(){super();P(this,"file",null);P(this,"playback",null);P(this,"root");P(this,"stage");P(this,"bar");P(this,"playButton");P(this,"scrub");P(this,"time");P(this,"sceneLabel");P(this,"prev");P(this,"next");P(this,"playing",!1);P(this,"last",0);P(this,"acc",0);P(this,"raf",0);P(this,"replayRaf",0);P(this,"loadToken",0);P(this,"visible",!0);P(this,"observer",null);this.root=this.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${Lr}</style><div class="stage" part="stage" role="img"></div>
76
76
  <div class="bar" part="controls" hidden>
77
77
  <button class="play" aria-label="Play">\u25B6</button>
78
78
  <button class="prev" aria-label="Previous scene" hidden>\u23EE</button>
@@ -80,4 +80,4 @@ ${w}</g>
80
80
  <button class="next" aria-label="Next scene" hidden>\u23ED</button>
81
81
  <input class="scrub" type="range" min="0" max="0" value="0" aria-label="Frame">
82
82
  <output class="time">0.0s</output>
83
- </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.stage.addEventListener("click",i=>{let r=pi(i.target);r&&this.activate(r.getAttribute("data-a")??"")}),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(St(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[Bt(n,this.getAttribute("page"))],r=new Yt(i,this.stage,{clean:this.hasAttribute("clean"),file:n});this.playback=r,this.style.setProperty("--dottie-page",O(r.background)),this.style.setProperty("--dottie-ink",O(r.ink)),this.style.colorScheme=kt(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=u=>{if(this.scrub.value=String(u),this.time.textContent=`${r.plan.times[u].toFixed(1)}s`,l){let c=r.sceneAt(u);this.sceneLabel.textContent=c<0?"":r.sceneNames[c]}this.dispatchEvent(new CustomEvent("frame",{detail:{frame:u,time:r.plan.times[u]}}))},!s){r.drawAt(o!==null?Number(o)||0:at(i),o!==null?yi(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(yi(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)}activate(n){let i=this.playback,r=i?.clicks.get(n),o=i?.replays.has(n)??!1;if(!i||!r&&!o)return;let s={element:n,...r??{},...o?{replay:!0}:{}};if(!this.dispatchEvent(new CustomEvent("action",{detail:s,cancelable:!0})))return;let l=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(o){let a=performance.now();i.replay(n,l?a-i.replays.get(n)*1e3:a),i.redraw(),this.scheduleReplay()}r&&("url"in r?/^(https?:|mailto:)/i.test(r.url)&&window.open(r.url,"_blank","noopener"):"page"in r?this.setAttribute("page",String(r.page+1)):r.scene>=0&&r.scene<i.scenes.length&&(l||this.hasAttribute("at")||i.frameCount<2?(this.setPlaying(!1),i.show(r.scene+1<i.scenes.length?i.scenes[r.scene+1]:i.frameCount-1)):(i.show(i.scenes[r.scene]),this.setPlaying(!0))))}scheduleReplay(){if(this.replayRaf)return;let n=()=>{this.replayRaf=0;let i=this.playback;!i||!this.isConnected||(this.playing||i.redraw(),i.replaying()?this.replayRaf=requestAnimationFrame(n):this.playing||i.redraw())};this.replayRaf=requestAnimationFrame(n)}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,r=n.composedPath()[0],o=pi(r);if(i&&o&&(n.key==="Enter"||n.key===" ")){n.preventDefault(),this.activate(o.getAttribute("data-a")??"");return}if(!i||i.page.timeline===null||i.frameCount<=1||this.hasAttribute("at")||r===this.scrub&&n.key!==" ")return;let s=i.scenes.length>0,l=!0;n.key===" "?s?this.playing?this.setPlaying(!1):this.nextScene():this.setPlaying(!this.playing):n.key==="ArrowRight"?s?this.nextScene():(this.setPlaying(!1),i.show(i.frame+1)):n.key==="ArrowLeft"?s?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)):l=!1,l&&n.preventDefault()}};P(Rt,"observedAttributes",["src","page","at","clean","no-controls","label"]);function pi(t){let e=t;return e&&typeof e.closest=="function"?e.closest(".dottie-a"):null}function yi(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 fe(t="dottie-player"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends Rt{})}var I=t=>{let e=It(t*1e4)/1e4;return e===0?0:e},Xe=t=>[I(t.x),I(t.y)],Ft=t=>[I(t.x),I(t.y),I(t.width),I(t.height)],gi=t=>[I(t.r),I(t.g),I(t.b),I(t.a)];function Qe(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(I))].filter(r=>r>=0&&r<=n).sort((r,o)=>r-o)}function Ze(t,e){let n=U(t,e),i=q(n),r=new Set(n.layers.filter(l=>l.visible).map(l=>l.id)),o={t:I(e)},s=t.timeline;if(s){let l=Mt(s,e);o.view=l?Ft(l):null;let a=-1;(s.markers??[]).forEach((u,c)=>{u.t<=e&&(a=c)}),o.scene=a}return s?.camera?.length||(o.bounds=Ft(tt(n))),o.elements=ht(n).map((l,a)=>{let u={id:l.id,kind:l.kind,z:a,seed:l.seed,frame:Ft({x:l.x,y:l.y,width:l.width,height:l.height})};if(r.has(l.layerID)||(u.hiddenLayer=!0),l.rotation!==null&&(u.rotation=I(l.rotation)),l.style.opacity!==null&&(u.opacity=I(l.style.opacity)),l.reveal!==null&&(u.reveal=I(l.reveal)),l.style.dashOffset!==null&&(u.dashOffset=I(l.style.dashOffset)),u.strokeWidth=I(l.style.strokeWidth),u.stroke=gi(l.style.stroke),u.fill=gi(l.style.fill),l.kind==="connector"){let[c,h]=Z(l,i);u.start=Xe(c),u.end=Xe(h),u.route=rt(ot(l,i)).map(Xe)}return u}),o}function Je(t,e,n){let i={page:e+1,name:t.name,id:t.id},r=t.timeline;if(r){let o=At(t);i.duration=I(r.duration),i.fps=I(r.fps),i.frameCount=o.times.length,i.poster=I(r.poster??r.duration),i.size=[I(o.size.width),I(o.size.height)],r.camera?.length||(i.bounds=Ft(o.rects[0])),i.markers=(r.markers??[]).map(s=>({t:I(s.t),name:s.name}))}else i.bounds=Ft(tt(t));return i.frames=n.map(o=>Ze(t,o)),i}function bi(t,e){return{version:t.version,pages:t.pages.map((n,i)=>Je(n,i,e??Qe(n)))}}function Ir(t,e={}){let n=$r(t)?t:St(t),i=n.pages[Bt(n,e.page===void 0?null:String(e.page))];return i=U(i,e.at??at(i)),e.clean&&(i=Gt(i,0)),de(i,e.background===void 0?{r:1,g:1,b:1,a:1}:e.background)}function $r(t){return typeof t=="object"&&t!==null&&Array.isArray(t.pages)&&Array.isArray(t.warnings)}var Lr="0.5.4";fe();globalThis.Dottie??(globalThis.Dottie=tn);})();
83
+ </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.stage.addEventListener("click",i=>{let r=yi(i.target);r&&this.activate(r.getAttribute("data-a")??"")}),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(It(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[Gt(n,this.getAttribute("page"))],r=new Bt(i,this.stage,{clean:this.hasAttribute("clean"),file:n});this.playback=r,this.style.setProperty("--dottie-page",O(r.background)),this.style.setProperty("--dottie-ink",O(r.ink)),this.style.colorScheme=kt(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:at(i),o!==null?gi(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(gi(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)}activate(n){let i=this.playback,r=i?.clicks.get(n),o=i?.replays.has(n)??!1;if(!i||!r&&!o)return;let s={element:n,...r??{},...o?{replay:!0}:{}};if(!this.dispatchEvent(new CustomEvent("action",{detail:s,cancelable:!0})))return;let l=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(o){let a=performance.now();i.replay(n,l?a-i.replays.get(n)*1e3:a),i.redraw(),this.scheduleReplay()}r&&("url"in r?/^(https?:|mailto:)/i.test(r.url)&&window.open(r.url,"_blank","noopener"):"page"in r?this.setAttribute("page",String(r.page+1)):r.scene>=0&&r.scene<i.scenes.length&&(l||this.hasAttribute("at")||i.frameCount<2?(this.setPlaying(!1),i.show(r.scene+1<i.scenes.length?i.scenes[r.scene+1]:i.frameCount-1)):(i.show(i.scenes[r.scene]),this.setPlaying(!0))))}scheduleReplay(){if(this.replayRaf)return;let n=()=>{this.replayRaf=0;let i=this.playback;!i||!this.isConnected||(this.playing||i.redraw(),i.replaying()?this.replayRaf=requestAnimationFrame(n):this.playing||i.redraw())};this.replayRaf=requestAnimationFrame(n)}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,r=n.composedPath()[0],o=yi(r);if(i&&o&&(n.key==="Enter"||n.key===" ")){n.preventDefault(),this.activate(o.getAttribute("data-a")??"");return}if(!i||i.page.timeline===null||i.frameCount<=1||this.hasAttribute("at")||r===this.scrub&&n.key!==" ")return;let s=i.scenes.length>0,l=!0;n.key===" "?s?this.playing?this.setPlaying(!1):this.nextScene():this.setPlaying(!this.playing):n.key==="ArrowRight"?s?this.nextScene():(this.setPlaying(!1),i.show(i.frame+1)):n.key==="ArrowLeft"?s?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)):l=!1,l&&n.preventDefault()}};P(Et,"observedAttributes",["src","page","at","clean","no-controls","label"]);function yi(t){let e=t;return e&&typeof e.closest=="function"?e.closest(".dottie-a"):null}function gi(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 fe(t="dottie-player"){typeof customElements<"u"&&!customElements.get(t)&&customElements.define(t,class extends Et{})}var $=t=>{let e=$t(t*1e4)/1e4;return e===0?0:e},Qe=t=>[$(t.x),$(t.y)],Ft=t=>[$(t.x),$(t.y),$(t.width),$(t.height)],bi=t=>[$(t.r),$(t.g),$(t.b),$(t.a)];function Ze(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($))].filter(r=>r>=0&&r<=n).sort((r,o)=>r-o)}function Je(t,e){let n=K(t,e),i=U(n),r=new Set(n.layers.filter(l=>l.visible).map(l=>l.id)),o={t:$(e)},s=t.timeline;if(s){let l=vt(s,e);o.view=l?Ft(l):null;let a=-1;(s.markers??[]).forEach((c,u)=>{c.t<=e&&(a=u)}),o.scene=a}return s?.camera?.length||(o.bounds=Ft(et(n))),o.elements=ht(n).map((l,a)=>{let c={id:l.id,kind:l.kind,z:a,seed:l.seed,frame:Ft({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=$(l.rotation)),l.style.opacity!==null&&(c.opacity=$(l.style.opacity)),l.reveal!==null&&(c.reveal=$(l.reveal)),l.style.dashOffset!==null&&(c.dashOffset=$(l.style.dashOffset)),c.strokeWidth=$(l.style.strokeWidth),c.stroke=bi(l.style.stroke),c.fill=bi(l.style.fill),l.kind==="connector"){let[u,h]=J(l,i);c.start=Qe(u),c.end=Qe(h),c.route=rt(ot(l,i)).map(Qe)}return c}),o}function tn(t,e,n){let i={page:e+1,name:t.name,id:t.id},r=t.timeline;if(r){let o=At(t);i.duration=$(r.duration),i.fps=$(r.fps),i.frameCount=o.times.length,i.poster=$(r.poster??r.duration),i.size=[$(o.size.width),$(o.size.height)],r.camera?.length||(i.bounds=Ft(o.rects[0])),i.markers=(r.markers??[]).map(s=>({t:$(s.t),name:s.name}))}else i.bounds=Ft(et(t));return i.frames=n.map(o=>Je(t,o)),i}function xi(t,e){return{version:t.version,pages:t.pages.map((n,i)=>tn(n,i,e??Ze(n)))}}function Or(t,e={}){let n=Cr(t)?t:It(t),i=n.pages[Gt(n,e.page===void 0?null:String(e.page))];return i=K(i,e.at??at(i)),e.clean&&(i=Nt(i,0)),me(i,e.background===void 0?{r:1,g:1,b:1,a:1}:e.background)}function Cr(t){return typeof t=="object"&&t!==null&&Array.isArray(t.pages)&&Array.isArray(t.warnings)}var zr="0.6.0";fe();globalThis.Dottie??(globalThis.Dottie=en);})();
package/dist/dottie.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dottie.js 0.5.4 | Apache-2.0 | https://github.com/phin-tech/dottie */
1
+ /*! dottie.js 0.6.0 | Apache-2.0 | https://github.com/phin-tech/dottie */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
4
4
  var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value2);
@@ -41,12 +41,18 @@ var KNOWN_FIELDS = {
41
41
  "offset",
42
42
  "args",
43
43
  "image",
44
- "reveal"
44
+ "reveal",
45
+ "ports",
46
+ "labelRect",
47
+ "extension"
45
48
  ],
46
49
  strokePoint: ["x", "y"],
47
50
  subpath: ["closed", "coords"],
48
51
  inlineImage: ["data", "format"],
49
- endpoint: ["elementID", "port", "x", "y"],
52
+ endpoint: ["elementID", "port", "portIndex", "x", "y"],
53
+ extensionRef: ["id", "shape", "version", "params"],
54
+ normalizedPoint: ["x", "y"],
55
+ normalizedRect: ["x", "y", "width", "height"],
50
56
  connector: ["start", "end", "routing", "startHead", "endHead"],
51
57
  timeline: ["fps", "duration", "boil", "settle", "poster", "tracks", "camera", "markers"],
52
58
  track: ["element", "keys", "boil", "follow", "repeats", "march"],
@@ -131,9 +137,11 @@ var Reader = class {
131
137
  endpoint(v) {
132
138
  const e = isObj(v) ? v : {};
133
139
  const port = str(e.port);
140
+ const portIndex = num(e.portIndex);
134
141
  return {
135
142
  elementID: uuid(e.elementID) ?? null,
136
143
  port: port && ["top", "right", "bottom", "left"].includes(port) ? port : null,
144
+ portIndex: portIndex !== void 0 && Number.isInteger(portIndex) && portIndex >= 0 ? portIndex : null,
137
145
  x: num(e.x) ?? 0,
138
146
  y: num(e.y) ?? 0
139
147
  };
@@ -206,9 +214,36 @@ var Reader = class {
206
214
  offset: num(v.offset) ?? null,
207
215
  args: strings(v.args),
208
216
  image: this.image(v.image, images),
209
- reveal: num(v.reveal) ?? null
217
+ reveal: num(v.reveal) ?? null,
218
+ ports: Array.isArray(v.ports) ? v.ports.map((p) => {
219
+ const o = isObj(p) ? p : {};
220
+ return { x: num(o.x) ?? 0, y: num(o.y) ?? 0 };
221
+ }) : null,
222
+ labelRect: this.labelRect(v.labelRect),
223
+ extension: this.extension(v.extension)
210
224
  };
211
225
  }
226
+ labelRect(v) {
227
+ if (!isObj(v)) return null;
228
+ this.fields(v, "normalizedRect");
229
+ return { x: num(v.x) ?? 0, y: num(v.y) ?? 0, width: num(v.width) ?? 0, height: num(v.height) ?? 0 };
230
+ }
231
+ extension(v) {
232
+ if (!isObj(v)) return null;
233
+ this.fields(v, "extensionRef");
234
+ const id = str(v.id), shape = str(v.shape), version = str(v.version);
235
+ if (id === void 0 || shape === void 0 || version === void 0) {
236
+ this.warn("Skipped an extension without an id, shape or version");
237
+ return null;
238
+ }
239
+ const params = {};
240
+ if (isObj(v.params)) {
241
+ for (const [k, p] of Object.entries(v.params)) {
242
+ if (typeof p === "number" || typeof p === "boolean" || typeof p === "string") params[k] = p;
243
+ }
244
+ }
245
+ return { id, shape, version, params };
246
+ }
212
247
  click(v) {
213
248
  if (!isObj(v)) return null;
214
249
  this.fields(v, "click");
@@ -714,12 +749,42 @@ function portPoint(shape, port) {
714
749
  const p = port === "top" ? { x: midX(r), y: r.y } : port === "right" ? { x: maxX(r), y: midY(r) } : port === "bottom" ? { x: midX(r), y: maxY(r) } : { x: r.x, y: midY(r) };
715
750
  return rotated(shape, p);
716
751
  }
752
+ function flattenContour(cp) {
753
+ const out = [];
754
+ for (let s = 0; s + 3 < cp.length; s += 3) {
755
+ const seg = cp.slice(s, s + 4);
756
+ for (let k = 0; k < 16; k++) out.push(bezierPoint(seg, k / 16));
757
+ }
758
+ out.push(cp[cp.length - 1]);
759
+ return out;
760
+ }
761
+ function outlineCrossing(shape, c, d) {
762
+ let best = null;
763
+ for (const contour of shapeContours(shape)) {
764
+ const pts = flattenContour(contour.points);
765
+ const n = pts.length;
766
+ const edges = contour.closed ? n : n - 1;
767
+ for (let i = 0; i < edges; i++) {
768
+ const a = pts[i], b = pts[(i + 1) % n];
769
+ const e = { x: b.x - a.x, y: b.y - a.y }, w = { x: a.x - c.x, y: a.y - c.y };
770
+ const det = e.x * d.y - d.x * e.y;
771
+ if (det === 0) continue;
772
+ const t = (e.x * w.y - e.y * w.x) / det, s = (d.x * w.y - d.y * w.x) / det;
773
+ if (t > 0 && s >= 0 && s <= 1 && (best === null || t < best)) best = t;
774
+ }
775
+ }
776
+ return best === null ? null : { x: c.x + d.x * best, y: c.y + d.y * best };
777
+ }
717
778
  function edgePoint(shape, toward) {
718
779
  const r = frame(shape);
719
780
  const c = center(shape);
720
781
  const target = unrotated(shape, toward);
721
782
  const dx = target.x - c.x, dy = target.y - c.y;
722
783
  if (!((dx !== 0 || dy !== 0) && r.width > 0 && r.height > 0)) return c;
784
+ if (shape.kind === "path") {
785
+ const hit = outlineCrossing(shape, c, { x: dx, y: dy });
786
+ if (hit) return rotated(shape, hit);
787
+ }
723
788
  const hw = r.width / 2, hh = r.height / 2;
724
789
  let t;
725
790
  if (shape.kind === "ellipse") t = 1 / Math.sqrt(dx * dx / (hw * hw) + dy * dy / (hh * hh));
@@ -731,9 +796,15 @@ function reference(ep, index) {
731
796
  const s = ep.elementID ? index.get(ep.elementID) : void 0;
732
797
  return s ? center(s) : { x: ep.x, y: ep.y };
733
798
  }
799
+ function normalizedPoint(shape, p) {
800
+ const r = frame(shape);
801
+ return rotated(shape, { x: r.x + p.x * r.width, y: r.y + p.y * r.height });
802
+ }
734
803
  function resolve(ep, other, index) {
735
804
  const s = ep.elementID ? index.get(ep.elementID) : void 0;
736
805
  if (!s) return { x: ep.x, y: ep.y };
806
+ const i = ep.portIndex, ports = s.ports ?? [];
807
+ if (typeof i === "number" && Number.isInteger(i) && i >= 0 && i < ports.length) return normalizedPoint(s, ports[i]);
737
808
  return ep.port ? portPoint(s, ep.port) : edgePoint(s, other);
738
809
  }
739
810
  function endpoints(e, index) {
@@ -2844,7 +2915,7 @@ function svgElement(e, index, labelBackground) {
2844
2915
  }
2845
2916
  s += `<path d="${outline(e).data()}" fill="none" ${strokeAttrs}/>
2846
2917
  `;
2847
- if (text) s += e.kind === "note" ? noteMarkup(text, e) : textElement(text, frame(e), e, true);
2918
+ if (text) s += e.kind === "note" ? noteMarkup(text, e) : textElement(text, e.kind === "path" ? pathLabelBox(e) : frame(e), e, true);
2848
2919
  return s;
2849
2920
  }
2850
2921
  default:
@@ -2857,6 +2928,11 @@ function placeholder(e, strokeAttrs) {
2857
2928
  return `<path d="${p.data()}" fill="none" ${strokeAttrs} stroke-opacity="0.5" stroke-dasharray="6 4"/>
2858
2929
  ` + textElement(`${e.kind}${e.text ? `: ${e.text}` : ""}`, f, { ...e, style: { ...e.style, fontSize: Math.min(e.style.fontSize, 12) } }, true);
2859
2930
  }
2931
+ function pathLabelBox(e) {
2932
+ const f = frame(e), r = e.labelRect;
2933
+ if (!r) return f;
2934
+ return { x: f.x + r.x * f.width, y: f.y + r.y * f.height, width: r.width * f.width, height: r.height * f.height };
2935
+ }
2860
2936
  function textElement(text, f, e, centered) {
2861
2937
  const size = e.style.fontSize;
2862
2938
  const lines = text.split("\n");
@@ -3555,7 +3631,7 @@ function render(source, options = {}) {
3555
3631
  function isFile(v) {
3556
3632
  return typeof v === "object" && v !== null && Array.isArray(v.pages) && Array.isArray(v.warnings);
3557
3633
  }
3558
- var VERSION = "0.5.4";
3634
+ var VERSION = "0.6.0";
3559
3635
  export {
3560
3636
  BOIL_DRAWINGS,
3561
3637
  DottieFormatError,
@@ -0,0 +1 @@
1
+ export {};
@@ -18,4 +18,4 @@ export interface RenderOptions {
18
18
  /** One page of a drawing as an SVG document, as Dottie's own SVG export draws it. */
19
19
  export declare function render(source: string | DottieFile | unknown, options?: RenderOptions): string;
20
20
  /** The library's version. */
21
- export declare const VERSION = "0.5.4";
21
+ export declare const VERSION = "0.6.0";
@@ -26,12 +26,21 @@ export interface Style {
26
26
  /** How far into its dash pattern a dashed or dotted line starts; marching ants set it on every frame. */
27
27
  dashOffset: number | null;
28
28
  }
29
+ /** `portIndex` pins the end to one of the bound element's `ports`, and wins over `port`. */
29
30
  export interface Endpoint {
30
31
  elementID: string | null;
31
32
  port: Port | null;
33
+ portIndex?: number | null;
32
34
  x: number;
33
35
  y: number;
34
36
  }
37
+ /** The shape an extension generated a path with. Read-only here: nothing runs in dottie.js. */
38
+ export interface ExtensionRef {
39
+ id: string;
40
+ shape: string;
41
+ version: string;
42
+ params: Record<string, number | boolean | string>;
43
+ }
35
44
  export interface ConnectorData {
36
45
  start: Endpoint;
37
46
  end: Endpoint;
@@ -94,6 +103,18 @@ export interface Element {
94
103
  /** Base64 bytes; an empty `data` is a picture that couldn't be found (drawn crossed out). */
95
104
  image: EmbeddedImage | null;
96
105
  reveal: number | null;
106
+ /** For an extension shape: connection points and label box, normalized to the frame. */
107
+ ports?: {
108
+ x: number;
109
+ y: number;
110
+ }[] | null;
111
+ labelRect?: {
112
+ x: number;
113
+ y: number;
114
+ width: number;
115
+ height: number;
116
+ } | null;
117
+ extension?: ExtensionRef | null;
97
118
  }
98
119
  export interface Layer {
99
120
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phin-tech/dottie",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Render, play and compile Dottie (.dottie) drawings and animations in the browser",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",