@algorisys/yappydraw 0.8.291 → 0.8.292

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.
Files changed (30) hide show
  1. package/README.md +2 -2
  2. package/chunks/browser-DbZP-BrN.js +641 -0
  3. package/chunks/{canva-ai-BFOytREO.js → canva-ai-DEXgo3RO.js} +1 -1
  4. package/chunks/{choice-dialog-state-BxwyrXRG.js → choice-dialog-state-DF7Hd13K.js} +1 -1
  5. package/chunks/custgeom-DK60FLyH.js +225 -0
  6. package/chunks/{design-generator-BGXMoviP.js → design-generator-dbNACXM-.js} +1 -1
  7. package/chunks/{drawing-engine-ChTNR20M.js → drawing-engine-Dpuzo1lz.js} +1 -1
  8. package/chunks/{drawings-store-C2gQVOCO.js → drawings-store-Day7j_Tw.js} +1 -1
  9. package/chunks/{ds-operations-aFfgZej1.js → ds-operations-DTBQ2jlO.js} +1 -1
  10. package/chunks/{export-game-vrAl7xq7.js → export-game-B-Zaoh5a.js} +1 -1
  11. package/chunks/from-yappy-ChDOEKXM.js +814 -0
  12. package/chunks/{game-runtime-CpvR1mdl.js → game-runtime-A4EiMP-P.js} +25 -25
  13. package/chunks/import-D8POTmPt.js +1430 -0
  14. package/chunks/{index-BhrKqu0C.js → index-Dxj5fgvO.js} +11437 -11204
  15. package/chunks/{index.es-Cmz4JyRm.js → index.es-m_qpxIjM.js} +1 -1
  16. package/chunks/jspdf.es.min-DGjtdWau.js +9526 -0
  17. package/chunks/{lucide-solid-DU0uSW4D.js → lucide-solid-BXo3zhMX.js} +1 -1
  18. package/chunks/{markdown-to-slides-CZ_4B6Pe.js → markdown-to-slides-DdrONEUr.js} +1 -1
  19. package/chunks/{morph-animator-CD-EWxCR.js → morph-animator-mlVxvG9t.js} +1 -1
  20. package/chunks/{onboarding-tour-DpXkBcSr.js → onboarding-tour-EDXLuYEp.js} +1 -1
  21. package/chunks/{pdf-vector-BBxb3gRO.js → pdf-vector-OO6sbSA5.js} +2 -2
  22. package/chunks/presets-DP49P8i2.js +379 -0
  23. package/chunks/{search-B09o2eIz.js → search-C28u5fM2.js} +2 -2
  24. package/chunks/{slide-generator-CyshVj2x.js → slide-generator-BxoPBOpW.js} +1 -1
  25. package/chunks/{svg2pdf.es.min-BVaMJ-wC.js → svg2pdf.es.min-B6z21zR3.js} +1 -1
  26. package/chunks/{turntable-ai-cz89NMQ6.js → turntable-ai-BxllwIBP.js} +1 -1
  27. package/chunks/write-DbVLX69U.js +212 -0
  28. package/package.json +1 -1
  29. package/yappy.js +6 -6
  30. package/chunks/jspdf.es.min-rJE95jGX.js +0 -9859
@@ -0,0 +1,814 @@
1
+ import { d as F, g as j, t as I, h as pt } from "./custgeom-DK60FLyH.js";
2
+ import { a1 as et, a2 as mt, a3 as xt, a4 as gt, a5 as yt, a6 as kt, a7 as bt, a8 as G, a9 as Mt, aa as wt, ab as vt, ac as St, ad as At, ae as $t, af as Ct, ag as It, ah as Tt, ai as Pt, aj as zt, ak as Ft } from "./index-Dxj5fgvO.js";
3
+ function Lt(t) {
4
+ const { l: n, c: e, h: r } = t, i = r * Math.PI / 180, o = e * Math.cos(i), l = e * Math.sin(i), f = n + 0.3963377774 * o + 0.2158037573 * l, a = n - 0.1055613458 * o - 0.0638541728 * l, s = n - 0.0894841775 * o - 1.291485548 * l, c = f * f * f, u = a * a * a, h = s * s * s, d = 1.2270138511 * c - 0.5577999807 * u + 0.2812561489 * h, p = -0.0405801784 * c + 1.1122568696 * u - 0.0716766787 * h, g = -0.0763812845 * c - 0.4214819787 * u + 1.5861632204 * h, x = 2.4039459 * d - 0.9898517 * p - 0.4141151 * g, k = -0.7797967 * d + 1.5445214 * p + 0.0352745 * g, m = 0.0384795 * d - 0.1141381 * p + 1.0756786 * g, y = (b) => {
5
+ const M = Math.abs(b), w = M > 31308e-7 ? 1.055 * Math.pow(M, 1 / 2.4) - 0.055 : 12.92 * M;
6
+ return b < 0 ? -w : w;
7
+ };
8
+ return {
9
+ r: y(x),
10
+ g: y(k),
11
+ b: y(m)
12
+ };
13
+ }
14
+ function O(t) {
15
+ const n = Math.abs(t), e = n > 31308e-7 ? 1.055 * Math.pow(n, 1 / 2.4) - 0.055 : 12.92 * n;
16
+ return t < 0 ? -e : e;
17
+ }
18
+ function X(t) {
19
+ const n = Math.abs(t), e = n > 0.04045 ? Math.pow((n + 0.055) / 1.055, 2.4) : n / 12.92;
20
+ return t < 0 ? -e : e;
21
+ }
22
+ function V(t, n, e) {
23
+ const r = X(t), i = X(n), o = X(e);
24
+ return {
25
+ r: O(1.2249401762805083 * r - 0.2249401762805082 * i),
26
+ g: O(-0.04205697751522136 * r + 1.0420569775152215 * i),
27
+ b: O(-0.019637554590334 * r - 0.07863604555063188 * i + 1.0982736001409656 * o)
28
+ };
29
+ }
30
+ function Et(t) {
31
+ return t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
32
+ }
33
+ function T(t) {
34
+ if (!t) return null;
35
+ const n = String(t).trim().toLowerCase();
36
+ if (!n || n === "transparent" || n === "none" || n === "currentcolor") return null;
37
+ if (n[0] === "#") {
38
+ let o = n.slice(1);
39
+ return (o.length === 3 || o.length === 4) && (o = o.slice(0, 3).split("").map((l) => l + l).join("")), o.length === 8 && (o = o.slice(0, 6)), /^[0-9a-f]{6}$/.test(o) ? [parseInt(o.slice(0, 2), 16), parseInt(o.slice(2, 4), 16), parseInt(o.slice(4, 6), 16)] : null;
40
+ }
41
+ const e = (o) => Math.round(Math.max(0, Math.min(1, o)) * 255), r = n.match(/^color\(\s*(display-p3|srgb)\s+([^/)]+?)\s*(?:\/[^)]*)?\)$/);
42
+ if (r) {
43
+ const o = r[2].split(/[\s,]+/).filter(Boolean).map(Et);
44
+ if (o.length < 3 || o.some((c) => !isFinite(c))) return null;
45
+ const [l, f, a] = o;
46
+ if (r[1] === "srgb") return [e(l), e(f), e(a)];
47
+ const s = V(l, f, a);
48
+ return [e(s.r), e(s.g), e(s.b)];
49
+ }
50
+ const i = n.match(/^oklch\(\s*([^/)]+?)\s*(?:\/[^)]*)?\)$/);
51
+ if (i) {
52
+ const o = i[1].split(/[\s,]+/).filter(Boolean);
53
+ if (o.length < 3) return null;
54
+ const l = o[0].endsWith("%") ? parseFloat(o[0]) / 100 : parseFloat(o[0]), f = parseFloat(o[1]), a = parseFloat(o[2]);
55
+ if (![l, f, a].every(isFinite)) return null;
56
+ const s = V(...(({ r: c, g: u, b: h }) => [c, u, h])(Lt({ l, c: f, h: a })));
57
+ return [e(s.r), e(s.g), e(s.b)];
58
+ }
59
+ return Rt(n);
60
+ }
61
+ const P = /* @__PURE__ */ new Map();
62
+ let $;
63
+ function Rt(t) {
64
+ if (P.has(t)) return P.get(t);
65
+ let n = null;
66
+ try {
67
+ if ($ === void 0) {
68
+ const e = typeof document < "u" ? document.createElement("canvas") : null;
69
+ $ = e ? e.getContext("2d", { willReadFrequently: !0 }) : null, $ && ($.canvas.width = 1, $.canvas.height = 1);
70
+ }
71
+ if ($ && ($.fillStyle = "#000000", $.fillStyle = t, $.fillStyle !== "#000000" || t === "#000000" || t === "black")) {
72
+ $.clearRect(0, 0, 1, 1), $.fillRect(0, 0, 1, 1);
73
+ const e = $.getImageData(0, 0, 1, 1).data;
74
+ n = [e[0], e[1], e[2]];
75
+ }
76
+ } catch {
77
+ n = null;
78
+ }
79
+ return P.size < 512 && P.set(t, n), n;
80
+ }
81
+ const L = (t) => "#" + t.map((n) => n.toString(16).padStart(2, "0")).join("");
82
+ function Ot(t) {
83
+ const n = t.trim().toLowerCase(), e = n.match(/^#([0-9a-f]{8})$/);
84
+ if (e) return parseInt(e[1].slice(6), 16) / 255;
85
+ const r = n.match(/^#([0-9a-f]{4})$/);
86
+ if (r) return parseInt(r[1][3] + r[1][3], 16) / 255;
87
+ const i = n.match(/^(?:rgba?|hsla?)\(([^)]*)\)$/);
88
+ if (i) {
89
+ const l = i[1].split(/[\s,/]+/).filter(Boolean);
90
+ if (l.length >= 4) return q(l[3]);
91
+ }
92
+ const o = n.match(/\/\s*([\d.]+%?)\s*\)$/);
93
+ return o ? q(o[1]) : 1;
94
+ }
95
+ const q = (t) => {
96
+ const n = t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
97
+ return Number.isFinite(n) ? Math.max(0, Math.min(1, n)) : 1;
98
+ };
99
+ function S(t, n = 1) {
100
+ if (!t) return null;
101
+ const e = T(t);
102
+ if (!e) return null;
103
+ const r = Ot(t) * n;
104
+ return r <= 0 ? null : r < 0.999 ? { hex: L(e), alpha: r } : { hex: L(e) };
105
+ }
106
+ const rt = (t) => mt(t).split(",")[0].trim().replace(/^['"]|['"]$/g, "") || "Calibri", Y = {
107
+ hachure: "ltUpDiag",
108
+ zigzag: "ltUpDiag",
109
+ "zigzag-line": "ltUpDiag",
110
+ dashed: "dashUpDiag",
111
+ "cross-hatch": "diagCross",
112
+ dots: "pct20"
113
+ };
114
+ function Xt(t, n) {
115
+ const e = t.fillStyle || "solid";
116
+ if ((e === "linear" || e === "radial" || e === "conic") && (t.gradientStops?.length ?? 0) > 0) {
117
+ const i = t.gradientStops.map((o) => ({ pos: Math.max(0, Math.min(1, o.offset)), color: S(o.color, n) ?? { hex: "#000000", alpha: 0 } }));
118
+ return e === "linear" ? { kind: "linear", stops: i, angle: t.gradientDirection ?? 45, scaled: !0 } : { kind: "radial", stops: i };
119
+ }
120
+ const r = S(t.backgroundColor, n);
121
+ return r ? Y[e] ? { kind: "pattern", preset: Y[e], color: r } : { kind: "solid", color: r } : { kind: "none" };
122
+ }
123
+ function ot(t) {
124
+ if (t.strokeStyle === "dotted") return "sysDot";
125
+ if (t.strokeStyle === "dashed") return "dash";
126
+ if (Array.isArray(t.strokeDashArray) && t.strokeDashArray.length >= 2) {
127
+ const [n] = t.strokeDashArray;
128
+ return n <= (t.strokeWidth || 2) * 1.5 ? "sysDot" : "dash";
129
+ }
130
+ }
131
+ function N(t, n, e = !1) {
132
+ const r = S(t.strokeColor, n);
133
+ if (!r || !(t.strokeWidth > 0)) return null;
134
+ const i = t.strokeLineCap === "butt" ? "flat" : t.strokeLineCap === "square" ? "sq" : "rnd";
135
+ return {
136
+ width: t.strokeWidth,
137
+ color: r,
138
+ dash: ot(t),
139
+ cap: e ? i : void 0,
140
+ join: t.strokeLineJoin === "miter" ? "miter" : t.strokeLineJoin === "bevel" ? "bevel" : "round"
141
+ };
142
+ }
143
+ function J(t, n, e) {
144
+ if (!t) return;
145
+ const r = n / Math.max(e, 0.5), i = r <= 2.5 ? "sm" : r <= 4 ? "med" : "lg";
146
+ return { type: t === "triangle" ? "triangle" : t === "dot" || t === "circle" ? "oval" : t === "diamond" || t === "diamondFilled" ? "diamond" : "arrow", size: i };
147
+ }
148
+ const U = (t, n) => t === "center" ? "ctr" : t === "right" ? "r" : t === "left" ? "l" : n, it = (t) => t === "top" ? "t" : t === "bottom" ? "b" : "ctr";
149
+ function st(t, n) {
150
+ return t.split(`
151
+ `).map((e) => ({ runs: e ? [{ text: e }] : [], align: n }));
152
+ }
153
+ function Bt(t) {
154
+ const n = { "lower-alpha": "alphaLc", "upper-alpha": "alphaUc", "lower-roman": "romanLc", "upper-roman": "romanUc" }[t.listNumberStyle ?? ""] ?? "arabic", e = { paren: "ParenR", parens: "ParenBoth", none: "Plain" }[t.listNumberSuffix ?? ""] ?? "Period";
155
+ return n + e;
156
+ }
157
+ let C;
158
+ function Dt(t, n) {
159
+ if (C === void 0 && (C = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), C)
160
+ return C.font = n, C.measureText(t).width;
161
+ const e = Number(/(\d+(?:\.\d+)?)px/.exec(n)?.[1] ?? 16);
162
+ return t.length * e * 0.6;
163
+ }
164
+ function Yt(t, n, e, r) {
165
+ const i = t.listLevel || 0, o = { bullet: t.listType === "ordered" ? "num" : "char", level: i };
166
+ if (o.bullet === "num") {
167
+ const a = Bt(t);
168
+ a !== "arabicPeriod" && (o.numType = a), !(e && e.level === i && e.scheme === a && (t.listIndex || 1) === e.index + 1) && (t.listIndex || 1) > 1 && (o.startAt = t.listIndex);
169
+ } else t.listMarker && t.listMarker !== "•" && (o.bulletChar = t.listMarker);
170
+ if (t.listMarkerColor) {
171
+ const a = S(t.listMarkerColor, n);
172
+ a && (o.bulletColor = a);
173
+ }
174
+ t.listMarkerScale && t.listMarkerScale !== 1 && (o.bulletScale = t.listMarkerScale);
175
+ const l = zt(t), f = Ft(Dt, t, r);
176
+ return o.marL = f, o.indent = l - f, o;
177
+ }
178
+ function at(t, n, e, r) {
179
+ const i = [];
180
+ let o = { runs: [], align: n }, l = !1, f = null;
181
+ const a = () => {
182
+ i.push(o), o = { runs: [], align: n }, l = !1;
183
+ };
184
+ for (const s of t)
185
+ String(s.text ?? "").split(`
186
+ `).forEach((u, h) => {
187
+ if (h > 0 && a(), s.fontSize && !l && (o.endSize = s.fontSize), !u) return;
188
+ l || (l = !0, s.paragraphSpaceBefore && (o.spaceBefore = s.paragraphSpaceBefore), s.paragraphAlign && (o.align = U(s.paragraphAlign, n ?? "l")), s.listType && s.listType !== "none" && Object.assign(o, Yt(s, e, f, r)), f = o.bullet === "num" ? { level: o.level ?? 0, scheme: o.numType ?? "arabicPeriod", index: s.listIndex || 1 } : null);
189
+ const d = { text: u };
190
+ if (s.bold && (d.bold = !0), s.italic && (d.italic = !0), s.underline && (d.underline = !0), s.strikethrough && (d.strike = !0), s.color) {
191
+ const p = S(s.color, e);
192
+ p && (d.color = p);
193
+ }
194
+ s.fontSize && (d.size = s.fontSize), s.fontFamily && (d.font = rt(s.fontFamily)), o.runs.push(d);
195
+ });
196
+ return a(), i;
197
+ }
198
+ function ct(t, n, e) {
199
+ const r = S(t.textColor || t.strokeColor || "#000000", n) ?? void 0;
200
+ return {
201
+ size: e,
202
+ color: r,
203
+ font: rt(t.fontFamily),
204
+ bold: Ct(t.fontWeight) >= 600 ? !0 : void 0,
205
+ italic: $t(t.fontStyle) === "italic" ? !0 : void 0
206
+ };
207
+ }
208
+ const lt = (t) => It(t) / Tt;
209
+ function Wt(t, n) {
210
+ const e = t.richText && t.richText.length > 0, r = U(t.textAlign, e ? "ctr" : "l");
211
+ return {
212
+ paragraphs: e ? at(t.richText, r, n, { fontSize: t.fontSize || 20, fontFamily: t.fontFamily || "sans-serif" }) : st(t.text || "", r),
213
+ anchor: it(t.verticalAlign),
214
+ insets: { l: 4, t: 4, r: 4, b: 4 },
215
+ wrap: !t.autoResize,
216
+ lineSpacing: lt(t),
217
+ defaults: ct(t, n, t.fontSize || 20)
218
+ };
219
+ }
220
+ function ft(t, n) {
221
+ const e = t.richContainerText && t.richContainerText.length > 0;
222
+ if (!e && !t.containerText) return;
223
+ const r = U(t.textAlign, "ctr");
224
+ return {
225
+ paragraphs: e ? at(t.richContainerText, r, n, { fontSize: t.fontSize || 28, fontFamily: t.fontFamily || "hand-drawn" }) : st(t.containerText, r),
226
+ anchor: it(t.verticalAlign),
227
+ insets: { l: 10, t: 4, r: 10, b: 4 },
228
+ wrap: !0,
229
+ lineSpacing: lt(t),
230
+ defaults: ct(t, n, t.fontSize || 16)
231
+ };
232
+ }
233
+ function Ht(t, n, e) {
234
+ const r = [], i = Math.abs(n) / 2, o = Math.abs(e) / 2, l = (a, s, c) => {
235
+ const u = I(F(a), i, o);
236
+ if (u.length === 0) return;
237
+ const h = s, d = { fill: h.noFill ? !1 : void 0, stroke: h.noStroke ? !1 : void 0 };
238
+ if (c) {
239
+ r.push({ cmds: u, ...d });
240
+ return;
241
+ }
242
+ let p = [];
243
+ for (const g of u)
244
+ g.op === "M" && p.length && (r.push({ cmds: p, ...d }), p = []), p.push(g);
245
+ p.length && r.push({ cmds: p, ...d });
246
+ }, f = (a) => {
247
+ const s = (c) => Math.round(c * 1e3) / 1e3;
248
+ switch (a.type) {
249
+ case "rect": {
250
+ const c = Math.min(Math.abs(a.w), Math.abs(a.h)) / 2, [u, h, d, p] = (Array.isArray(a.r) ? a.r : [a.r || 0, a.r || 0, a.r || 0, a.r || 0]).map((b) => Math.max(0, Math.min(b || 0, c))), g = (b, M, w) => b ? ` A ${s(b)} ${s(b)} 0 0 1 ${s(M)} ${s(w)}` : "", { x, y: k } = a, m = a.w, y = a.h;
251
+ l(`M ${x + u} ${k} H ${x + m - h}${g(h, x + m, k + h)} V ${k + y - d}${g(d, x + m - d, k + y)} H ${x + p}${g(p, x, k + y - p)} V ${k + u}${g(u, x + u, k)} Z`, a, !1);
252
+ break;
253
+ }
254
+ case "ellipse":
255
+ l(`M ${a.cx - a.rx} ${a.cy} A ${a.rx} ${a.ry} 0 1 0 ${a.cx + a.rx} ${a.cy} A ${a.rx} ${a.ry} 0 1 0 ${a.cx - a.rx} ${a.cy} Z`, a, !1);
256
+ break;
257
+ case "points":
258
+ a.points.length >= 2 && l(`M ${a.points.map((c) => `${c.x} ${c.y}`).join(" L ")}${a.isClosed !== !1 ? " Z" : ""}`, a, !1);
259
+ break;
260
+ case "path":
261
+ l(a.path, a, !!a.evenOdd);
262
+ break;
263
+ case "multi":
264
+ a.shapes.forEach(f);
265
+ break;
266
+ }
267
+ };
268
+ return f(t), r;
269
+ }
270
+ function jt(t) {
271
+ if (t.warp || t.points && t.points.length) return null;
272
+ if (t.type === "circle") return { kind: "preset", prst: "ellipse" };
273
+ if (t.type === "rectangle") {
274
+ const [n, e, r, i] = vt(t);
275
+ if (!n && !e && !r && !i) return { kind: "preset", prst: "rect" };
276
+ if (n === e && e === r && r === i) {
277
+ const o = Math.min(Math.abs(t.width), Math.abs(t.height));
278
+ return o > 0 ? { kind: "preset", prst: "roundRect", adj: { adj: Math.min(5e4, n / o * 1e5) } } : null;
279
+ }
280
+ }
281
+ return null;
282
+ }
283
+ const Nt = /* @__PURE__ */ new Set(["umlClass", "umlInterface", "qrCode", "video", "codeBlock"]), Ut = /* @__PURE__ */ new Set(["fineliner", "inkbrush", "marker", "ink"]), _t = /* @__PURE__ */ new Set(["text", "richtext", "image", "line", "arrow"]);
284
+ function Zt(t) {
285
+ const n = t;
286
+ if (Nt.has(t.type) || t.clipMaskId || t.shadowEnabled || t.glowEnabled || (t.featherRadius ?? 0) > 0 || t.blendMode && t.blendMode !== "normal" || t.shearX || t.shearY || xt(t) || gt(t) || yt(t) || kt(t) || t.appearance && (t.appearance.fills?.length ?? 0) + (t.appearance.strokes?.length ?? 0) > 0) return !0;
287
+ const e = t.fillStyle;
288
+ if (e === "image" || e === "mesh" || e === "pattern" || t.backgroundImage || t.curvedText || (t.type === "text" || t.type === "richtext") && (t.verticalText || (n.charTransforms?.length ?? 0) > 0)) return !0;
289
+ if (t.type === "image") {
290
+ if (t.warp || t.pixelEffect) return !0;
291
+ const r = t;
292
+ if ((r.filterBrightness ?? 100) !== 100 || (r.filterContrast ?? 100) !== 100 || (r.filterSaturate ?? 100) !== 100 || (r.filterBlur ?? 0) || (r.filterHueRotate ?? 0) || (r.filterInvert ?? 0) || (r.filterSepia ?? 0) || (r.filterGrayscale ?? 0)) return !0;
293
+ }
294
+ return !1;
295
+ }
296
+ function K(t) {
297
+ const n = /^data:([^;,]+)?(;base64)?,(.*)$/s.exec(t);
298
+ if (!n) return null;
299
+ try {
300
+ const e = n[2] ? atob(n[3]) : decodeURIComponent(n[3]), r = new Uint8Array(e.length);
301
+ for (let i = 0; i < e.length; i++) r[i] = e.charCodeAt(i) & 255;
302
+ return { bytes: r, mime: (n[1] || "").toLowerCase() };
303
+ } catch {
304
+ return null;
305
+ }
306
+ }
307
+ function _(t) {
308
+ if (!t) return null;
309
+ const n = K(t);
310
+ if (n && n.mime === "image/png") return { bytes: n.bytes, ext: "png" };
311
+ if (n && (n.mime === "image/jpeg" || n.mime === "image/jpg")) return { bytes: n.bytes, ext: "jpeg" };
312
+ if (n && n.mime === "image/gif") return { bytes: n.bytes, ext: "gif" };
313
+ const e = et(t);
314
+ if (!e || !e.naturalWidth) return null;
315
+ try {
316
+ const r = document.createElement("canvas");
317
+ r.width = e.naturalWidth, r.height = e.naturalHeight, r.getContext("2d").drawImage(e, 0, 0);
318
+ const i = K(r.toDataURL("image/png"));
319
+ return i ? { bytes: i.bytes, ext: "png" } : null;
320
+ } catch {
321
+ return null;
322
+ }
323
+ }
324
+ const A = (t) => t.name || t.type;
325
+ function Z(t, n) {
326
+ const e = Math.abs(t.width), r = Math.abs(t.height), i = Math.min(t.x, t.x + t.width) - n.ox, o = Math.min(t.y, t.y + t.height) - n.oy;
327
+ return { x: i, y: o, w: e, h: r, rot: t.angle ? t.angle * 180 / Math.PI : void 0, flipH: !!t.flipX || void 0, flipV: !!t.flipY || void 0 };
328
+ }
329
+ function W(t, n, e) {
330
+ const r = n.hooks.rasterize(t), i = r ? _(r.dataURL) : null;
331
+ return !r || !i ? [] : (n.report.pictures++, [{ kind: "picture", id: n.nextId++, name: e, x: r.x - n.ox, y: r.y - n.oy, w: r.width, h: r.height, media: i }]);
332
+ }
333
+ function Gt(t, n) {
334
+ const e = _(t.dataURL);
335
+ if (!e) return W([t], n, A(t));
336
+ let r;
337
+ if (t.crop) {
338
+ const o = t.dataURL ? et(t.dataURL) : null, l = o?.naturalWidth, f = o?.naturalHeight;
339
+ if (l && f) {
340
+ const a = t.crop;
341
+ r = { l: a.x / l, t: a.y / f, r: 1 - (a.x + a.width) / l, b: 1 - (a.y + a.height) / f };
342
+ }
343
+ }
344
+ const i = (t.opacity ?? 100) / 100;
345
+ return n.report.native++, [{ kind: "picture", id: n.nextId++, name: A(t), ...Z(t, n), media: e, crop: r, alpha: i < 1 ? i : void 0, descr: t.altText }];
346
+ }
347
+ function Vt(t, n, e, r) {
348
+ const i = ft(t, r);
349
+ if (!i) return [];
350
+ const o = t.fontSize || 16, l = (t.containerText || "").split(`
351
+ `), f = Math.max(1, ...l.map((c) => c.length)), a = Math.max(40, f * o * 0.6 + 24), s = Math.max(o * 1.6, l.length * o * 1.25 + 8);
352
+ return i.wrap = !1, i.anchor = "ctr", i.paragraphs.forEach((c) => {
353
+ c.align = "ctr";
354
+ }), [{
355
+ kind: "shape",
356
+ id: e.nextId++,
357
+ name: `${A(t)} label`,
358
+ textBox: !0,
359
+ x: n.x - e.ox - a / 2,
360
+ y: n.y - e.oy - s / 2,
361
+ w: a,
362
+ h: s,
363
+ geom: { kind: "preset", prst: "rect" },
364
+ fill: { kind: "none" },
365
+ line: null,
366
+ text: i
367
+ }];
368
+ }
369
+ function qt(t, n, e) {
370
+ const r = t.x + t.w / 2, i = t.y + t.h / 2, o = (t.rot || 0) * Math.PI / 180, l = [[0, -t.h / 2], [-t.w / 2, 0], [0, t.h / 2], [t.w / 2, 0]], f = n.x - e.ox, a = n.y - e.oy;
371
+ for (let s = 0; s < 4; s++) {
372
+ let [c, u] = l[s];
373
+ t.flipH && (c = -c), t.flipV && (u = -u);
374
+ const h = r + c * Math.cos(o) - u * Math.sin(o), d = i + c * Math.sin(o) + u * Math.cos(o);
375
+ if (Math.hypot(h - f, d - a) <= 2) return s;
376
+ }
377
+ return -1;
378
+ }
379
+ function Jt(t, n, e) {
380
+ const r = e.x - n.x, i = e.y - n.y, o = Math.hypot(r, i);
381
+ if (!(o > 0)) return !1;
382
+ const l = (s, c) => Math.abs((s - n.x) * i - (c - n.y) * r) / o, f = (s, c) => ((s - n.x) * r + (c - n.y) * i) / (o * o), a = (s, c) => l(s, c) <= 0.5 && f(s, c) >= -0.01 && f(s, c) <= 1.01;
383
+ return t.every((s) => s.op === "Z" ? !1 : s.op === "C" ? a(s.x1, s.y1) && a(s.x2, s.y2) && a(s.x, s.y) : a(s.x, s.y));
384
+ }
385
+ function Kt(t, n) {
386
+ const e = (t.opacity ?? 100) / 100, r = N(t, e, !0), i = bt(t), o = [];
387
+ if (r) {
388
+ const l = t.type === "arrow", f = l ? t.startArrowhead : null, a = l ? t.endArrowhead || (t.startArrowhead ? null : "arrow") : null, s = { ...r, head: J(f, G(t, "start"), t.strokeWidth), tail: J(a, G(t, "end"), t.strokeWidth) };
389
+ if (!i.d || Jt(F(i.d), i.start, i.end)) {
390
+ const { start: c, end: u } = i, h = {
391
+ kind: "connector",
392
+ id: n.nextId++,
393
+ name: A(t),
394
+ x: Math.min(c.x, u.x) - n.ox,
395
+ y: Math.min(c.y, u.y) - n.oy,
396
+ w: Math.abs(u.x - c.x),
397
+ h: Math.abs(u.y - c.y),
398
+ flipH: u.x < c.x || void 0,
399
+ flipV: u.y < c.y || void 0,
400
+ geom: { kind: "preset", prst: "straightConnector1" },
401
+ line: s
402
+ }, d = (p, g) => {
403
+ const x = p?.elementId ? n.ids.get(p.elementId) : void 0;
404
+ if (!x) return;
405
+ const k = qt(x.item, g, n);
406
+ return k >= 0 ? { id: x.id, idx: k } : void 0;
407
+ };
408
+ n.glue.push(() => {
409
+ h.start = d(t.startBinding, c), h.end = d(t.endBinding, u);
410
+ }), o.push(h);
411
+ } else {
412
+ const c = F(i.d), u = j(c);
413
+ if (u) {
414
+ const h = Math.max(u.maxX - u.minX, 0.01), d = Math.max(u.maxY - u.minY, 0.01);
415
+ o.push({
416
+ kind: "shape",
417
+ id: n.nextId++,
418
+ name: A(t),
419
+ x: u.minX - n.ox,
420
+ y: u.minY - n.oy,
421
+ w: h,
422
+ h: d,
423
+ geom: { kind: "custom", paths: [{ cmds: I(c, -u.minX, -u.minY), fill: !1 }] },
424
+ fill: { kind: "none" },
425
+ line: s
426
+ });
427
+ }
428
+ }
429
+ n.report.native++;
430
+ }
431
+ return o.push(...Vt(t, i.mid, n, e)), o;
432
+ }
433
+ function Qt(t, n) {
434
+ const e = (t.opacity ?? 100) / 100, r = Mt(t.points), i = N(t, e, !0);
435
+ if (r.length < 2 || !i) return [];
436
+ i.cap = "rnd", i.join = "round";
437
+ const o = r.map((h) => h.x), l = r.map((h) => h.y), f = Math.min(...o), a = Math.min(...l), s = Math.max(Math.max(...o) - f, 0.01), c = Math.max(Math.max(...l) - a, 0.01), u = r.map((h, d) => ({ op: d ? "L" : "M", x: h.x - f, y: h.y - a }));
438
+ return n.report.native++, [{
439
+ kind: "shape",
440
+ id: n.nextId++,
441
+ name: A(t),
442
+ x: t.x + f - n.ox,
443
+ y: t.y + a - n.oy,
444
+ w: s,
445
+ h: c,
446
+ rot: t.angle ? t.angle * 180 / Math.PI : void 0,
447
+ geom: { kind: "custom", paths: [{ cmds: u, fill: !1 }] },
448
+ fill: { kind: "none" },
449
+ line: i
450
+ }];
451
+ }
452
+ function tn(t, n) {
453
+ const e = (t.opacity ?? 100) / 100;
454
+ if (!(t.text || t.richText && t.richText.length > 0)) return [];
455
+ n.report.native++;
456
+ const i = S(t.backgroundColor, e);
457
+ return [{
458
+ kind: "shape",
459
+ id: n.nextId++,
460
+ name: A(t),
461
+ ...Z(t, n),
462
+ textBox: !0,
463
+ geom: { kind: "preset", prst: "rect" },
464
+ fill: i ? { kind: "solid", color: i } : { kind: "none" },
465
+ line: null,
466
+ text: Wt(t, e)
467
+ }];
468
+ }
469
+ const nn = (t) => {
470
+ const n = t && /matrix\(([^)]+)\)/.exec(t), e = n ? n[1].split(/[\s,]+/).map(Number) : [];
471
+ return e.length === 6 && e.every(Number.isFinite) ? e : [1, 0, 0, 1, 0, 0];
472
+ }, Q = (t, n, e) => ({ x: t[0] * n + t[2] * e + t[4], y: t[1] * n + t[3] * e + t[5] });
473
+ function en(t) {
474
+ const n = Pt.generator(), e = (i) => {
475
+ for (const o of n.toPaths(i))
476
+ t.save(), o.fill && o.fill !== "none" && (!o.stroke || o.stroke === "none") ? (t.fillStyle = o.fill, t.fillPath(o.d)) : o.stroke && o.stroke !== "none" && o.strokeWidth > 0 && (t.strokeStyle = o.stroke, t.lineWidth = o.strokeWidth, t.strokePath(o.d)), t.restore();
477
+ return i;
478
+ }, r = { generator: n, draw: e, getDefaultOptions: () => n.defaultOptions };
479
+ for (const i of ["line", "rectangle", "ellipse", "circle", "linearPath", "polygon", "arc", "curve", "path"])
480
+ r[i] = (...o) => e(n[i](...o));
481
+ return r;
482
+ }
483
+ function rn(t) {
484
+ const n = t.fillStyle, e = {
485
+ ...t,
486
+ renderStyle: "architectural",
487
+ roughness: 0,
488
+ angle: 0,
489
+ flipX: !1,
490
+ flipY: !1,
491
+ opacity: 100,
492
+ containerText: void 0,
493
+ richContainerText: void 0,
494
+ // Hatching is re-created as a pattern fill on the body; recording it would be hundreds of lines.
495
+ fillStyle: Y[n] ? "solid" : t.fillStyle
496
+ }, r = new St();
497
+ try {
498
+ const s = document.createElement("canvas");
499
+ At(en(r), s.getContext("2d"), e, !1, 1, r);
500
+ } catch {
501
+ return null;
502
+ }
503
+ if (r.failed) return null;
504
+ const i = /* @__PURE__ */ new Map();
505
+ for (const s of Array.from(r.defs.children)) s.id && i.set(s.id, s);
506
+ const o = (s, c) => {
507
+ const u = i.get(s.replace(/^url\(#|\)$/g, ""));
508
+ if (!u) return null;
509
+ const h = Array.from(u.children).map((d) => ({ pos: +(d.getAttribute("offset") || 0), color: S(d.getAttribute("stop-color")) ?? { hex: "#000000", alpha: 0 } }));
510
+ if (!h.length) return null;
511
+ if (u.tagName.toLowerCase() === "lineargradient") {
512
+ const d = Q(c, +u.getAttribute("x1"), +u.getAttribute("y1")), p = Q(c, +u.getAttribute("x2"), +u.getAttribute("y2"));
513
+ return { kind: "linear", x1: d.x, y1: d.y, x2: p.x, y2: p.y, stops: h };
514
+ }
515
+ return { kind: "radial", x1: 0, y1: 0, x2: 0, y2: 0, stops: h };
516
+ }, l = [];
517
+ let f = "ok";
518
+ const a = (s) => {
519
+ for (const c of Array.from(s.children)) {
520
+ if (f !== "ok") return;
521
+ const u = c.tagName.toLowerCase();
522
+ if (u === "g") {
523
+ if (c.getAttribute("clip-path")) {
524
+ f = "picture";
525
+ return;
526
+ }
527
+ a(c);
528
+ continue;
529
+ }
530
+ if (u === "text" || u === "image") {
531
+ f = "picture";
532
+ return;
533
+ }
534
+ let h = null;
535
+ if (u === "path") h = c.getAttribute("d");
536
+ else if (u === "rect") {
537
+ const b = +c.getAttribute("x"), M = +c.getAttribute("y"), w = +c.getAttribute("width"), v = +c.getAttribute("height");
538
+ h = `M ${b} ${M} L ${b + w} ${M} L ${b + w} ${M + v} L ${b} ${M + v} Z`;
539
+ } else {
540
+ f = "fail";
541
+ return;
542
+ }
543
+ const d = nn(c.getAttribute("transform")), p = pt(F(h || ""), d);
544
+ if (!p.length) continue;
545
+ const g = c.getAttribute("fill"), x = c.getAttribute("stroke"), k = !!g && g.startsWith("url("), m = +(c.getAttribute("fill-opacity") ?? 1), y = +(c.getAttribute("stroke-opacity") ?? 1);
546
+ l.push({
547
+ cmds: p,
548
+ fill: g && g !== "none" && !k ? g : null,
549
+ grad: k ? o(g, d) : null,
550
+ stroke: x && x !== "none" ? x : null,
551
+ fillAlpha: Number.isFinite(m) ? m : 1,
552
+ strokeAlpha: Number.isFinite(y) ? y : 1,
553
+ width: +(c.getAttribute("stroke-width") || 1) * Math.sqrt(Math.abs(d[0] * d[3] - d[1] * d[2])),
554
+ dash: !!c.getAttribute("stroke-dasharray"),
555
+ evenOdd: c.getAttribute("fill-rule") === "evenodd"
556
+ });
557
+ }
558
+ };
559
+ return a(r.root), f === "ok" ? l : f === "picture" ? "picture" : null;
560
+ }
561
+ const tt = (t, n) => {
562
+ if (!t || !n) return !1;
563
+ const e = T(t), r = T(n);
564
+ return !!e && !!r && e[0] === r[0] && e[1] === r[1] && e[2] === r[2];
565
+ };
566
+ function on(t, n, e) {
567
+ const r = t.stops.map((p) => ({ pos: p.pos, color: e < 1 ? { ...p.color, alpha: (p.color.alpha ?? 1) * e } : p.color }));
568
+ if (t.kind === "radial") return { kind: "radial", stops: r };
569
+ const i = t.x2 - t.x1, o = t.y2 - t.y1, l = Math.hypot(i, o);
570
+ if (!(l > 0)) return { kind: "solid", color: r[r.length - 1].color };
571
+ const f = i / l, a = o / l, s = (n.minX + n.maxX) / 2, c = (n.minY + n.maxY) / 2, u = (Math.abs((n.maxX - n.minX) * f) + Math.abs((n.maxY - n.minY) * a)) / 2;
572
+ if (!(u > 0)) return { kind: "solid", color: r[0].color };
573
+ const h = (p) => ((t.x1 + i * p - s) * f + (t.y1 + o * p - c) * a + u) / (2 * u), d = [...r].sort((p, g) => p.pos - g.pos).map((p) => ({ pos: h(p.pos), color: p.color }));
574
+ return { kind: "linear", angle: Math.atan2(o, i) * 180 / Math.PI, stops: ut(d) };
575
+ }
576
+ function ut(t) {
577
+ if (t.length < 2) return t.map((e) => ({ ...e, pos: Math.max(0, Math.min(1, e.pos)) }));
578
+ const n = (e) => {
579
+ if (e <= t[0].pos) return t[0].color;
580
+ for (let r = 1; r < t.length; r++) {
581
+ const i = t[r - 1], o = t[r];
582
+ if (e <= o.pos) return pn(i.color, o.color, o.pos > i.pos ? (e - i.pos) / (o.pos - i.pos) : 0);
583
+ }
584
+ return t[t.length - 1].color;
585
+ };
586
+ return [{ pos: 0, color: n(0) }, ...t.filter((e) => e.pos > 0 && e.pos < 1), { pos: 1, color: n(1) }];
587
+ }
588
+ function H(t) {
589
+ if (t.fill === !1) return [t];
590
+ const n = [];
591
+ for (const i of t.cmds)
592
+ (i.op === "M" || !n.length) && n.push([]), n[n.length - 1].push(i);
593
+ if (n.every((i) => i[i.length - 1].op === "Z")) return [t];
594
+ const r = [{ cmds: n.flatMap((i) => i[i.length - 1].op === "Z" ? i : [...i, { op: "Z" }]), fill: t.fill, stroke: !1 }];
595
+ return t.stroke !== !1 && r.push({ cmds: t.cmds, fill: !1, stroke: t.stroke }), r;
596
+ }
597
+ const E = (t) => JSON.stringify(t.cmds);
598
+ function sn(t, n) {
599
+ const e = (t.opacity ?? 100) / 100, r = Z(t, n), i = ft(t, e);
600
+ let o = jt(t);
601
+ if (!o) {
602
+ const f = wt(t), a = f ? Ht(f, t.width, t.height) : [], s = rn(t);
603
+ if (s === "picture") return null;
604
+ if (s && s.length) {
605
+ const c = Math.min(t.x, t.x + t.width), u = Math.min(t.y, t.y + t.height), h = a.length ? a.filter((m) => m.fill !== !1).map((m) => I(m.cmds, c, u)) : null, d = !!ot(t), p = ["linear", "radial", "conic"].includes(t.fillStyle);
606
+ if (!s.every((m) => (!m.grad || p) && m.fillAlpha >= 1 && m.strokeAlpha >= 1 && (!m.fill || tt(m.fill, t.backgroundColor)) && (!m.stroke || tt(m.stroke, t.strokeColor) && Math.abs(m.width - t.strokeWidth) < 0.75 && m.dash === d))) {
607
+ const m = cn(t, s, r, i, n, e, h);
608
+ return m ? [m] : null;
609
+ }
610
+ const x = [], k = (m) => I(m, -c, -u);
611
+ for (let m = 0; m < s.length; m++) {
612
+ const y = s[m], b = s[m + 1], M = !!((y.fill || y.grad) && !y.stroke && b && b.stroke && !b.fill && !b.grad && E(b) === E(y)), w = !!y.stroke || M;
613
+ if (y.fill || y.grad) {
614
+ const v = dt(y, h);
615
+ if (!v) return null;
616
+ v.length === 1 && v[0] === y.cmds ? x.push(...H({ cmds: k(y.cmds), stroke: w ? void 0 : !1 })) : (x.push(...v.map((R) => ({ cmds: k(R), stroke: !1 }))), w && x.push({ cmds: k(y.cmds), fill: !1 }));
617
+ } else
618
+ x.push({ cmds: k(y.cmds), fill: !1, stroke: w ? void 0 : !1 });
619
+ M && m++;
620
+ }
621
+ o = { kind: "custom", paths: x };
622
+ } else if (a.length)
623
+ o = { kind: "custom", paths: a.flatMap(H) };
624
+ else return null;
625
+ }
626
+ const l = {
627
+ kind: "shape",
628
+ id: n.nextId++,
629
+ name: A(t),
630
+ ...r,
631
+ geom: o,
632
+ fill: Xt(t, e),
633
+ line: N(t, e),
634
+ text: i
635
+ };
636
+ return n.ids.set(t.id, { id: l.id, item: l }), n.report.native++, [l];
637
+ }
638
+ const an = (t) => t.map((n) => n.op === "Z" ? "Z" : n.op === "C" ? `C ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}` : `${n.op} ${n.x} ${n.y}`).join(" ");
639
+ let B = null;
640
+ const z = 28;
641
+ function D(t, n, e) {
642
+ B ??= document.createElement("canvas").getContext("2d");
643
+ const r = [];
644
+ if (!B) return r;
645
+ const i = t.map((o) => new Path2D(an(o)));
646
+ for (let o = 0; o < z; o++) for (let l = 0; l < z; l++) {
647
+ const f = e.minX + (l + 0.5) / z * (e.maxX - e.minX), a = e.minY + (o + 0.5) / z * (e.maxY - e.minY);
648
+ r.push(i.some((s) => B.isPointInPath(s, f, a, n)));
649
+ }
650
+ return r;
651
+ }
652
+ const nt = (t, n) => t.reduce((e, r, i) => e + (r !== n[i] ? 1 : 0), 0) / Math.max(1, t.length);
653
+ function dt(t, n) {
654
+ if (t.evenOdd) return [t.cmds];
655
+ const e = j(t.cmds);
656
+ if (!e) return [t.cmds];
657
+ const r = D([t.cmds], "nonzero", e);
658
+ return nt(r, D([t.cmds], "evenodd", e)) === 0 ? [t.cmds] : n && nt(r, D(n, "evenodd", e)) <= 0.03 ? n : null;
659
+ }
660
+ function cn(t, n, e, r, i, o, l) {
661
+ const f = [];
662
+ for (let a = 0; a < n.length; a++) {
663
+ const s = n[a], c = n[a + 1], u = !!((s.fill || s.grad) && !s.stroke && c && c.stroke && !c.fill && !c.grad && E(c) === E(s)), h = u ? c : s, d = j(s.cmds);
664
+ if (!d) continue;
665
+ const p = Math.max(d.maxX - d.minX, 0.01), g = Math.max(d.maxY - d.minY, 0.01), x = S(s.fill, o * s.fillAlpha), k = s.grad ? on(s.grad, d, o) : x ? { kind: "solid", color: x } : { kind: "none" }, m = S(h.stroke, o * h.strokeAlpha), y = m ? { width: h.width, color: m, dash: h.dash ? "dash" : void 0, join: "round", cap: "rnd" } : null, b = !!(s.fill || s.grad), M = (v) => I(v, -d.minX, -d.minY);
666
+ let w;
667
+ if (b) {
668
+ const v = dt(s, l);
669
+ if (!v) return null;
670
+ w = v.length === 1 && v[0] === s.cmds ? H({ cmds: M(s.cmds), stroke: m ? void 0 : !1 }) : [...v.map((R) => ({ cmds: M(R), stroke: !1 })), ...m ? [{ cmds: M(s.cmds), fill: !1 }] : []];
671
+ } else w = [{ cmds: M(s.cmds), fill: !1, stroke: m ? void 0 : !1 }];
672
+ f.push({
673
+ kind: "shape",
674
+ id: i.nextId++,
675
+ name: `${A(t)} part`,
676
+ x: d.minX - i.ox,
677
+ y: d.minY - i.oy,
678
+ w: p,
679
+ h: g,
680
+ geom: { kind: "custom", paths: w },
681
+ fill: k,
682
+ line: y
683
+ }), u && a++;
684
+ }
685
+ return r && f.push({
686
+ kind: "shape",
687
+ id: i.nextId++,
688
+ name: `${A(t)} label`,
689
+ textBox: !0,
690
+ x: e.x,
691
+ y: e.y,
692
+ w: e.w,
693
+ h: e.h,
694
+ geom: { kind: "preset", prst: "rect" },
695
+ fill: { kind: "none" },
696
+ line: null,
697
+ text: r
698
+ }), i.report.native++, { kind: "group", id: i.nextId++, name: A(t), ...e, children: f };
699
+ }
700
+ function ln(t, n) {
701
+ if (Zt(t)) return W([t], n, A(t));
702
+ try {
703
+ if (t.type === "text" || t.type === "richtext") return tn(t, n);
704
+ if (t.type === "image") return Gt(t, n);
705
+ if (t.type === "line" || t.type === "arrow") return Kt(t, n);
706
+ if (Ut.has(t.type)) return Qt(t, n);
707
+ if (!_t.has(t.type)) {
708
+ const e = sn(t, n);
709
+ if (e) return e;
710
+ }
711
+ } catch {
712
+ }
713
+ return W([t], n, A(t));
714
+ }
715
+ function ht(t, n, e) {
716
+ const r = [];
717
+ let i = 0;
718
+ const o = (l) => {
719
+ const f = l.groupIds ?? [];
720
+ return f.length > n ? f[f.length - 1 - n] : void 0;
721
+ };
722
+ for (; i < t.length; ) {
723
+ const l = o(t[i]);
724
+ if (!l) {
725
+ r.push(...ln(t[i], e)), i++;
726
+ continue;
727
+ }
728
+ let f = i;
729
+ for (; f < t.length && o(t[f]) === l; ) f++;
730
+ const a = ht(t.slice(i, f), n + 1, e);
731
+ if (a.length > 1) {
732
+ const s = fn(a), c = { kind: "group", id: e.nextId++, name: t[i].groupNames?.[l] || "Group", ...s, children: a };
733
+ r.push(c);
734
+ } else r.push(...a);
735
+ i = f;
736
+ }
737
+ return r;
738
+ }
739
+ function fn(t) {
740
+ let n = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
741
+ for (const o of t)
742
+ n = Math.min(n, o.x), e = Math.min(e, o.y), r = Math.max(r, o.x + o.w), i = Math.max(i, o.y + o.h);
743
+ return { x: n, y: e, w: Math.max(0, r - n), h: Math.max(0, i - e) };
744
+ }
745
+ function un(t) {
746
+ if (!t || t.type === "none") return;
747
+ const n = t.duration ?? 500;
748
+ switch (t.type) {
749
+ case "fade":
750
+ return { kind: "fade", durationMs: n };
751
+ case "slide-left":
752
+ return { kind: "push", dir: "l", durationMs: n };
753
+ case "slide-right":
754
+ return { kind: "push", dir: "r", durationMs: n };
755
+ case "slide-up":
756
+ return { kind: "push", dir: "u", durationMs: n };
757
+ case "slide-down":
758
+ return { kind: "push", dir: "d", durationMs: n };
759
+ case "zoom-in":
760
+ return { kind: "zoom", zoomIn: !0, durationMs: n };
761
+ case "zoom-out":
762
+ return { kind: "zoom", zoomIn: !1, durationMs: n };
763
+ default:
764
+ return;
765
+ }
766
+ }
767
+ function dn(t, n) {
768
+ const e = t.slide;
769
+ if (!e) {
770
+ const f = S(t.background);
771
+ return f ? { kind: "solid", color: f } : void 0;
772
+ }
773
+ const r = e.fillStyle || "solid", i = !e.backgroundImage && (!e.canvasTexture || e.canvasTexture === "none");
774
+ if (i && r === "solid")
775
+ return { kind: "solid", color: S(e.backgroundColor === "transparent" ? "#ffffff" : e.backgroundColor || "#ffffff") ?? { hex: "#ffffff" } };
776
+ if (i && (r === "linear" || r === "radial") && (e.gradientStops?.length ?? 0) > 0) {
777
+ const f = e.gradientDirection || 0, a = e.gradientStops.map((s) => ({ pos: s.offset, color: S(s.color) ?? { hex: "#ffffff" } }));
778
+ return r === "radial" ? { kind: "radial", stops: a } : { kind: "linear", stops: hn(a, f, t.w, t.h), angle: f };
779
+ }
780
+ const o = n.rasterizeBackground?.(e), l = o ? _(o) : null;
781
+ return l ? { kind: "image", media: l } : { kind: "solid", color: S(e.backgroundColor) ?? { hex: "#ffffff" } };
782
+ }
783
+ function hn(t, n, e, r) {
784
+ const i = n * Math.PI / 180, o = Math.hypot(e, r) / 2, l = (Math.abs(e * Math.cos(i)) + Math.abs(r * Math.sin(i))) / 2;
785
+ if (!(l > 0) || t.length < 2) return t;
786
+ const f = [...t].sort((a, s) => a.pos - s.pos).map((a) => ({ pos: (-o + 2 * o * a.pos + l) / (2 * l), color: a.color }));
787
+ return ut(f);
788
+ }
789
+ function pn(t, n, e) {
790
+ const r = T(t.hex), i = T(n.hex), o = [0, 1, 2].map((s) => Math.round(r[s] + (i[s] - r[s]) * e)), l = t.alpha ?? 1, f = n.alpha ?? 1, a = l + (f - l) * e;
791
+ return a < 0.999 ? { hex: L(o), alpha: a } : { hex: L(o) };
792
+ }
793
+ function gn(t, n, e) {
794
+ const r = { ox: t.x, oy: t.y, nextId: 2, ids: /* @__PURE__ */ new Map(), glue: [], hooks: n, report: e }, i = ht(t.elements, 0, r);
795
+ return r.glue.forEach((o) => o()), {
796
+ name: t.name,
797
+ items: i,
798
+ background: dn(t, n),
799
+ transition: un(t.slide?.transition)
800
+ };
801
+ }
802
+ function yn(t, n, e, r) {
803
+ const i = Math.min(e / Math.max(t, 1), r / Math.max(n, 1));
804
+ return { scale: i, dx: (e - t * i) / 2, dy: (r - n * i) / 2 };
805
+ }
806
+ export {
807
+ yn as fitInto,
808
+ _ as mediaOf,
809
+ gn as pageToSlide,
810
+ hn as remapPageStops,
811
+ S as toColor,
812
+ un as transitionOf,
813
+ rt as typefaceOf
814
+ };