omnix-chat 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,458 +1,441 @@
1
1
  import "./chunk-C-6Xjtra.js";
2
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/util.js
3
- function resolveUrl(e, t) {
4
- if (e.match(/^[a-z]+:\/\//i)) return e;
5
- if (e.match(/^\/\//)) return window.location.protocol + e;
6
- if (e.match(/^[a-z]+:/i)) return e;
7
- let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
8
- return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
9
- }
10
- var e = (() => {
11
- let e = 0, random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
12
- return () => (e += 1, `u${random()}${e}`);
2
+ function resolveUrl(e2, t2) {
3
+ if (e2.match(/^[a-z]+:\/\//i)) return e2;
4
+ if (e2.match(/^\/\//)) return window.location.protocol + e2;
5
+ if (e2.match(/^[a-z]+:/i)) return e2;
6
+ let n2 = document.implementation.createHTMLDocument(), r2 = n2.createElement("base"), i2 = n2.createElement("a");
7
+ return n2.head.appendChild(r2), n2.body.appendChild(i2), t2 && (r2.href = t2), i2.href = e2, i2.href;
8
+ }
9
+ var e = /* @__PURE__ */ (() => {
10
+ let e2 = 0, random = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
11
+ return () => (e2 += 1, `u${random()}${e2}`);
13
12
  })();
14
- function toArray(e) {
15
- let t = [];
16
- for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
17
- return t;
13
+ function toArray(e2) {
14
+ let t2 = [];
15
+ for (let n2 = 0, r2 = e2.length; n2 < r2; n2++) t2.push(e2[n2]);
16
+ return t2;
18
17
  }
19
18
  var t = null;
20
- function getStyleProperties(e = {}) {
21
- return t || (e.includeStyleProperties ? (t = e.includeStyleProperties, t) : (t = toArray(window.getComputedStyle(document.documentElement)), t));
19
+ function getStyleProperties(e2 = {}) {
20
+ return t || (e2.includeStyleProperties ? (t = e2.includeStyleProperties, t) : (t = toArray(window.getComputedStyle(document.documentElement)), t));
22
21
  }
23
- function px(e, t) {
24
- let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
25
- return n ? parseFloat(n.replace("px", "")) : 0;
22
+ function px(e2, t2) {
23
+ let n2 = (e2.ownerDocument.defaultView || window).getComputedStyle(e2).getPropertyValue(t2);
24
+ return n2 ? parseFloat(n2.replace("px", "")) : 0;
26
25
  }
27
- function getNodeWidth(e) {
28
- let t = px(e, "border-left-width"), n = px(e, "border-right-width");
29
- return e.clientWidth + t + n;
26
+ function getNodeWidth(e2) {
27
+ let t2 = px(e2, "border-left-width"), n2 = px(e2, "border-right-width");
28
+ return e2.clientWidth + t2 + n2;
30
29
  }
31
- function getNodeHeight(e) {
32
- let t = px(e, "border-top-width"), n = px(e, "border-bottom-width");
33
- return e.clientHeight + t + n;
30
+ function getNodeHeight(e2) {
31
+ let t2 = px(e2, "border-top-width"), n2 = px(e2, "border-bottom-width");
32
+ return e2.clientHeight + t2 + n2;
34
33
  }
35
- function getImageSize(e, t = {}) {
36
- return {
37
- width: t.width || getNodeWidth(e),
38
- height: t.height || getNodeHeight(e)
39
- };
34
+ function getImageSize(e2, t2 = {}) {
35
+ return {
36
+ width: t2.width || getNodeWidth(e2),
37
+ height: t2.height || getNodeHeight(e2)
38
+ };
40
39
  }
41
40
  function getPixelRatio() {
42
- let e, t;
43
- try {
44
- t = process;
45
- } catch {}
46
- let n = t && t.env ? t.env.devicePixelRatio : null;
47
- return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
41
+ let e2, t2;
42
+ try {
43
+ t2 = process;
44
+ } catch {
45
+ }
46
+ let n2 = t2 && t2.env ? t2.env.devicePixelRatio : null;
47
+ return n2 && (e2 = parseInt(n2, 10), Number.isNaN(e2) && (e2 = 1)), e2 || window.devicePixelRatio || 1;
48
48
  }
49
49
  var n = 16384;
50
- function checkCanvasDimensions(e) {
51
- (e.width > n || e.height > n) && (e.width > n && e.height > n ? e.width > e.height ? (e.height *= n / e.width, e.width = n) : (e.width *= n / e.height, e.height = n) : e.width > n ? (e.height *= n / e.width, e.width = n) : (e.width *= n / e.height, e.height = n));
52
- }
53
- function createImage(e) {
54
- return new Promise((t, n) => {
55
- let r = new Image();
56
- r.onload = () => {
57
- r.decode().then(() => {
58
- requestAnimationFrame(() => t(r));
59
- });
60
- }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
61
- });
62
- }
63
- async function svgToDataURL(e) {
64
- return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
65
- }
66
- async function nodeToDataURL(e, t, n) {
67
- let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
68
- return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), svgToDataURL(i);
69
- }
70
- var isInstanceOfElement = (e, t) => {
71
- if (e instanceof t) return !0;
72
- let n = Object.getPrototypeOf(e);
73
- return n === null ? !1 : n.constructor.name === t.name || isInstanceOfElement(n, t);
50
+ function checkCanvasDimensions(e2) {
51
+ (e2.width > n || e2.height > n) && (e2.width > n && e2.height > n ? e2.width > e2.height ? (e2.height *= n / e2.width, e2.width = n) : (e2.width *= n / e2.height, e2.height = n) : e2.width > n ? (e2.height *= n / e2.width, e2.width = n) : (e2.width *= n / e2.height, e2.height = n));
52
+ }
53
+ function createImage(e2) {
54
+ return new Promise((t2, n2) => {
55
+ let r2 = new Image();
56
+ r2.onload = () => {
57
+ r2.decode().then(() => {
58
+ requestAnimationFrame(() => t2(r2));
59
+ });
60
+ }, r2.onerror = n2, r2.crossOrigin = "anonymous", r2.decoding = "async", r2.src = e2;
61
+ });
62
+ }
63
+ async function svgToDataURL(e2) {
64
+ return Promise.resolve().then(() => new XMLSerializer().serializeToString(e2)).then(encodeURIComponent).then((e3) => `data:image/svg+xml;charset=utf-8,${e3}`);
65
+ }
66
+ async function nodeToDataURL(e2, t2, n2) {
67
+ let r2 = "http://www.w3.org/2000/svg", i2 = document.createElementNS(r2, "svg"), a2 = document.createElementNS(r2, "foreignObject");
68
+ return i2.setAttribute("width", `${t2}`), i2.setAttribute("height", `${n2}`), i2.setAttribute("viewBox", `0 0 ${t2} ${n2}`), a2.setAttribute("width", "100%"), a2.setAttribute("height", "100%"), a2.setAttribute("x", "0"), a2.setAttribute("y", "0"), a2.setAttribute("externalResourcesRequired", "true"), i2.appendChild(a2), a2.appendChild(e2), svgToDataURL(i2);
69
+ }
70
+ var isInstanceOfElement = (e2, t2) => {
71
+ if (e2 instanceof t2) return true;
72
+ let n2 = Object.getPrototypeOf(e2);
73
+ return n2 === null ? false : n2.constructor.name === t2.name || isInstanceOfElement(n2, t2);
74
74
  };
75
- //#endregion
76
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-pseudos.js
77
- function formatCSSText(e) {
78
- let t = e.getPropertyValue("content");
79
- return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
80
- }
81
- function formatCSSProperties(e, t) {
82
- return getStyleProperties(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
83
- }
84
- function getPseudoElementStyle(e, t, n, r) {
85
- let i = `.${e}:${t}`, a = n.cssText ? formatCSSText(n) : formatCSSProperties(n, r);
86
- return document.createTextNode(`${i}{${a}}`);
87
- }
88
- function clonePseudoElement(t, n, r, i) {
89
- let a = window.getComputedStyle(t, r), o = a.getPropertyValue("content");
90
- if (o === "" || o === "none") return;
91
- let s = e();
92
- try {
93
- n.className = `${n.className} ${s}`;
94
- } catch {
95
- return;
96
- }
97
- let c = document.createElement("style");
98
- c.appendChild(getPseudoElementStyle(s, r, a, i)), n.appendChild(c);
99
- }
100
- function clonePseudoElements(e, t, n) {
101
- clonePseudoElement(e, t, ":before", n), clonePseudoElement(e, t, ":after", n);
102
- }
103
- //#endregion
104
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/mimes.js
75
+ function formatCSSText(e2) {
76
+ let t2 = e2.getPropertyValue("content");
77
+ return `${e2.cssText} content: '${t2.replace(/'|"/g, "")}';`;
78
+ }
79
+ function formatCSSProperties(e2, t2) {
80
+ return getStyleProperties(t2).map((t3) => `${t3}: ${e2.getPropertyValue(t3)}${e2.getPropertyPriority(t3) ? " !important" : ""};`).join(" ");
81
+ }
82
+ function getPseudoElementStyle(e2, t2, n2, r2) {
83
+ let i2 = `.${e2}:${t2}`, a2 = n2.cssText ? formatCSSText(n2) : formatCSSProperties(n2, r2);
84
+ return document.createTextNode(`${i2}{${a2}}`);
85
+ }
86
+ function clonePseudoElement(t2, n2, r2, i2) {
87
+ let a2 = window.getComputedStyle(t2, r2), o2 = a2.getPropertyValue("content");
88
+ if (o2 === "" || o2 === "none") return;
89
+ let s2 = e();
90
+ try {
91
+ n2.className = `${n2.className} ${s2}`;
92
+ } catch {
93
+ return;
94
+ }
95
+ let c2 = document.createElement("style");
96
+ c2.appendChild(getPseudoElementStyle(s2, r2, a2, i2)), n2.appendChild(c2);
97
+ }
98
+ function clonePseudoElements(e2, t2, n2) {
99
+ clonePseudoElement(e2, t2, ":before", n2), clonePseudoElement(e2, t2, ":after", n2);
100
+ }
105
101
  var r = "application/font-woff", i = "image/jpeg", a = {
106
- woff: r,
107
- woff2: r,
108
- ttf: "application/font-truetype",
109
- eot: "application/vnd.ms-fontobject",
110
- png: "image/png",
111
- jpg: i,
112
- jpeg: i,
113
- gif: "image/gif",
114
- tiff: "image/tiff",
115
- svg: "image/svg+xml",
116
- webp: "image/webp"
102
+ woff: r,
103
+ woff2: r,
104
+ ttf: "application/font-truetype",
105
+ eot: "application/vnd.ms-fontobject",
106
+ png: "image/png",
107
+ jpg: i,
108
+ jpeg: i,
109
+ gif: "image/gif",
110
+ tiff: "image/tiff",
111
+ svg: "image/svg+xml",
112
+ webp: "image/webp"
117
113
  };
118
- function getExtension(e) {
119
- let t = /\.([^./]*?)$/g.exec(e);
120
- return t ? t[1] : "";
121
- }
122
- function getMimeType(e) {
123
- return a[getExtension(e).toLowerCase()] || "";
124
- }
125
- //#endregion
126
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/dataurl.js
127
- function getContentFromDataUrl(e) {
128
- return e.split(/,/)[1];
129
- }
130
- function isDataUrl(e) {
131
- return e.search(/^(data:)/) !== -1;
132
- }
133
- function makeDataUrl(e, t) {
134
- return `data:${t};base64,${e}`;
135
- }
136
- async function fetchAsDataURL(e, t, n) {
137
- let r = await fetch(e, t);
138
- if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
139
- let i = await r.blob();
140
- return new Promise((e, t) => {
141
- let a = new FileReader();
142
- a.onerror = t, a.onloadend = () => {
143
- try {
144
- e(n({
145
- res: r,
146
- result: a.result
147
- }));
148
- } catch (e) {
149
- t(e);
150
- }
151
- }, a.readAsDataURL(i);
152
- });
114
+ function getExtension(e2) {
115
+ let t2 = /\.([^./]*?)$/g.exec(e2);
116
+ return t2 ? t2[1] : "";
117
+ }
118
+ function getMimeType(e2) {
119
+ return a[getExtension(e2).toLowerCase()] || "";
120
+ }
121
+ function getContentFromDataUrl(e2) {
122
+ return e2.split(/,/)[1];
123
+ }
124
+ function isDataUrl(e2) {
125
+ return e2.search(/^(data:)/) !== -1;
126
+ }
127
+ function makeDataUrl(e2, t2) {
128
+ return `data:${t2};base64,${e2}`;
129
+ }
130
+ async function fetchAsDataURL(e2, t2, n2) {
131
+ let r2 = await fetch(e2, t2);
132
+ if (r2.status === 404) throw Error(`Resource "${r2.url}" not found`);
133
+ let i2 = await r2.blob();
134
+ return new Promise((e3, t3) => {
135
+ let a2 = new FileReader();
136
+ a2.onerror = t3, a2.onloadend = () => {
137
+ try {
138
+ e3(n2({
139
+ res: r2,
140
+ result: a2.result
141
+ }));
142
+ } catch (e4) {
143
+ t3(e4);
144
+ }
145
+ }, a2.readAsDataURL(i2);
146
+ });
153
147
  }
154
148
  var o = {};
155
- function getCacheKey(e, t, n) {
156
- let r = e.replace(/\?.*/, "");
157
- return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
158
- }
159
- async function resourceToDataURL(e, t, n) {
160
- let r = getCacheKey(e, t, n.includeQueryParams);
161
- if (o[r] != null) return o[r];
162
- n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
163
- let i;
164
- try {
165
- i = makeDataUrl(await fetchAsDataURL(e, n.fetchRequestInit, ({ res: e, result: n }) => (t || (t = e.headers.get("Content-Type") || ""), getContentFromDataUrl(n))), t);
166
- } catch (t) {
167
- i = n.imagePlaceholder || "";
168
- let r = `Failed to fetch resource: ${e}`;
169
- t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
170
- }
171
- return o[r] = i, i;
172
- }
173
- //#endregion
174
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-node.js
175
- async function cloneCanvasElement(e) {
176
- let t = e.toDataURL();
177
- return t === "data:," ? e.cloneNode(!1) : createImage(t);
178
- }
179
- async function cloneVideoElement(e, t) {
180
- if (e.currentSrc) {
181
- let t = document.createElement("canvas"), n = t.getContext("2d");
182
- return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), createImage(t.toDataURL());
183
- }
184
- let n = e.poster;
185
- return createImage(await resourceToDataURL(n, getMimeType(n), t));
186
- }
187
- async function cloneIFrameElement(e, t) {
188
- try {
189
- if (e?.contentDocument?.body) return await cloneNode(e.contentDocument.body, t, !0);
190
- } catch {}
191
- return e.cloneNode(!1);
192
- }
193
- async function cloneSingleNode(e, t) {
194
- return isInstanceOfElement(e, HTMLCanvasElement) ? cloneCanvasElement(e) : isInstanceOfElement(e, HTMLVideoElement) ? cloneVideoElement(e, t) : isInstanceOfElement(e, HTMLIFrameElement) ? cloneIFrameElement(e, t) : e.cloneNode(isSVGElement(e));
195
- }
196
- var isSlotElement = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", isSVGElement = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
197
- async function cloneChildren(e, t, n) {
198
- if (isSVGElement(t)) return t;
199
- let r = [];
200
- return r = isSlotElement(e) && e.assignedNodes ? toArray(e.assignedNodes()) : isInstanceOfElement(e, HTMLIFrameElement) && e.contentDocument?.body ? toArray(e.contentDocument.body.childNodes) : toArray((e.shadowRoot ?? e).childNodes), r.length === 0 || isInstanceOfElement(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => cloneNode(r, n)).then((e) => {
201
- e && t.appendChild(e);
202
- }), Promise.resolve()), t;
203
- }
204
- function cloneCSSStyle(e, t, n) {
205
- let r = t.style;
206
- if (!r) return;
207
- let i = window.getComputedStyle(e);
208
- i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : getStyleProperties(n).forEach((n) => {
209
- let a = i.getPropertyValue(n);
210
- n === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), isInstanceOfElement(e, HTMLIFrameElement) && n === "display" && a === "inline" && (a = "block"), n === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), r.setProperty(n, a, i.getPropertyPriority(n));
211
- });
212
- }
213
- function cloneInputValue(e, t) {
214
- isInstanceOfElement(e, HTMLTextAreaElement) && (t.innerHTML = e.value), isInstanceOfElement(e, HTMLInputElement) && t.setAttribute("value", e.value);
215
- }
216
- function cloneSelectValue(e, t) {
217
- if (isInstanceOfElement(e, HTMLSelectElement)) {
218
- let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
219
- r && r.setAttribute("selected", "");
220
- }
221
- }
222
- function decorate(e, t, n) {
223
- return isInstanceOfElement(t, Element) && (cloneCSSStyle(e, t, n), clonePseudoElements(e, t, n), cloneInputValue(e, t), cloneSelectValue(e, t)), t;
224
- }
225
- async function ensureSVGSymbols(e, t) {
226
- let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
227
- if (n.length === 0) return e;
228
- let r = {};
229
- for (let i = 0; i < n.length; i++) {
230
- let a = n[i].getAttribute("xlink:href");
231
- if (a) {
232
- let n = e.querySelector(a), i = document.querySelector(a);
233
- !n && i && !r[a] && (r[a] = await cloneNode(i, t, !0));
234
- }
235
- }
236
- let i = Object.values(r);
237
- if (i.length) {
238
- let t = "http://www.w3.org/1999/xhtml", n = document.createElementNS(t, "svg");
239
- n.setAttribute("xmlns", t), n.style.position = "absolute", n.style.width = "0", n.style.height = "0", n.style.overflow = "hidden", n.style.display = "none";
240
- let r = document.createElementNS(t, "defs");
241
- n.appendChild(r);
242
- for (let e = 0; e < i.length; e++) r.appendChild(i[e]);
243
- e.appendChild(n);
244
- }
245
- return e;
246
- }
247
- async function cloneNode(e, t, n) {
248
- return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => cloneSingleNode(e, t)).then((n) => cloneChildren(e, n, t)).then((n) => decorate(e, n, t)).then((e) => ensureSVGSymbols(e, t));
249
- }
250
- //#endregion
251
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-resources.js
149
+ function getCacheKey(e2, t2, n2) {
150
+ let r2 = e2.replace(/\?.*/, "");
151
+ return n2 && (r2 = e2), /ttf|otf|eot|woff2?/i.test(r2) && (r2 = r2.replace(/.*\//, "")), t2 ? `[${t2}]${r2}` : r2;
152
+ }
153
+ async function resourceToDataURL(e2, t2, n2) {
154
+ let r2 = getCacheKey(e2, t2, n2.includeQueryParams);
155
+ if (o[r2] != null) return o[r2];
156
+ n2.cacheBust && (e2 += (/\?/.test(e2) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
157
+ let i2;
158
+ try {
159
+ i2 = makeDataUrl(await fetchAsDataURL(e2, n2.fetchRequestInit, ({ res: e3, result: n3 }) => (t2 || (t2 = e3.headers.get("Content-Type") || ""), getContentFromDataUrl(n3))), t2);
160
+ } catch (t3) {
161
+ i2 = n2.imagePlaceholder || "";
162
+ let r3 = `Failed to fetch resource: ${e2}`;
163
+ t3 && (r3 = typeof t3 == "string" ? t3 : t3.message), r3 && console.warn(r3);
164
+ }
165
+ return o[r2] = i2, i2;
166
+ }
167
+ async function cloneCanvasElement(e2) {
168
+ let t2 = e2.toDataURL();
169
+ return t2 === "data:," ? e2.cloneNode(false) : createImage(t2);
170
+ }
171
+ async function cloneVideoElement(e2, t2) {
172
+ if (e2.currentSrc) {
173
+ let t3 = document.createElement("canvas"), n3 = t3.getContext("2d");
174
+ return t3.width = e2.clientWidth, t3.height = e2.clientHeight, n3?.drawImage(e2, 0, 0, t3.width, t3.height), createImage(t3.toDataURL());
175
+ }
176
+ let n2 = e2.poster;
177
+ return createImage(await resourceToDataURL(n2, getMimeType(n2), t2));
178
+ }
179
+ async function cloneIFrameElement(e2, t2) {
180
+ try {
181
+ if (e2?.contentDocument?.body) return await cloneNode(e2.contentDocument.body, t2, true);
182
+ } catch {
183
+ }
184
+ return e2.cloneNode(false);
185
+ }
186
+ async function cloneSingleNode(e2, t2) {
187
+ return isInstanceOfElement(e2, HTMLCanvasElement) ? cloneCanvasElement(e2) : isInstanceOfElement(e2, HTMLVideoElement) ? cloneVideoElement(e2, t2) : isInstanceOfElement(e2, HTMLIFrameElement) ? cloneIFrameElement(e2, t2) : e2.cloneNode(isSVGElement(e2));
188
+ }
189
+ var isSlotElement = (e2) => e2.tagName != null && e2.tagName.toUpperCase() === "SLOT", isSVGElement = (e2) => e2.tagName != null && e2.tagName.toUpperCase() === "SVG";
190
+ async function cloneChildren(e2, t2, n2) {
191
+ if (isSVGElement(t2)) return t2;
192
+ let r2 = [];
193
+ return r2 = isSlotElement(e2) && e2.assignedNodes ? toArray(e2.assignedNodes()) : isInstanceOfElement(e2, HTMLIFrameElement) && e2.contentDocument?.body ? toArray(e2.contentDocument.body.childNodes) : toArray((e2.shadowRoot ?? e2).childNodes), r2.length === 0 || isInstanceOfElement(e2, HTMLVideoElement) || await r2.reduce((e3, r3) => e3.then(() => cloneNode(r3, n2)).then((e4) => {
194
+ e4 && t2.appendChild(e4);
195
+ }), Promise.resolve()), t2;
196
+ }
197
+ function cloneCSSStyle(e2, t2, n2) {
198
+ let r2 = t2.style;
199
+ if (!r2) return;
200
+ let i2 = window.getComputedStyle(e2);
201
+ i2.cssText ? (r2.cssText = i2.cssText, r2.transformOrigin = i2.transformOrigin) : getStyleProperties(n2).forEach((n3) => {
202
+ let a2 = i2.getPropertyValue(n3);
203
+ n3 === "font-size" && a2.endsWith("px") && (a2 = `${Math.floor(parseFloat(a2.substring(0, a2.length - 2))) - 0.1}px`), isInstanceOfElement(e2, HTMLIFrameElement) && n3 === "display" && a2 === "inline" && (a2 = "block"), n3 === "d" && t2.getAttribute("d") && (a2 = `path(${t2.getAttribute("d")})`), r2.setProperty(n3, a2, i2.getPropertyPriority(n3));
204
+ });
205
+ }
206
+ function cloneInputValue(e2, t2) {
207
+ isInstanceOfElement(e2, HTMLTextAreaElement) && (t2.innerHTML = e2.value), isInstanceOfElement(e2, HTMLInputElement) && t2.setAttribute("value", e2.value);
208
+ }
209
+ function cloneSelectValue(e2, t2) {
210
+ if (isInstanceOfElement(e2, HTMLSelectElement)) {
211
+ let n2 = t2, r2 = Array.from(n2.children).find((t3) => e2.value === t3.getAttribute("value"));
212
+ r2 && r2.setAttribute("selected", "");
213
+ }
214
+ }
215
+ function decorate(e2, t2, n2) {
216
+ return isInstanceOfElement(t2, Element) && (cloneCSSStyle(e2, t2, n2), clonePseudoElements(e2, t2, n2), cloneInputValue(e2, t2), cloneSelectValue(e2, t2)), t2;
217
+ }
218
+ async function ensureSVGSymbols(e2, t2) {
219
+ let n2 = e2.querySelectorAll ? e2.querySelectorAll("use") : [];
220
+ if (n2.length === 0) return e2;
221
+ let r2 = {};
222
+ for (let i3 = 0; i3 < n2.length; i3++) {
223
+ let a2 = n2[i3].getAttribute("xlink:href");
224
+ if (a2) {
225
+ let n3 = e2.querySelector(a2), i4 = document.querySelector(a2);
226
+ !n3 && i4 && !r2[a2] && (r2[a2] = await cloneNode(i4, t2, true));
227
+ }
228
+ }
229
+ let i2 = Object.values(r2);
230
+ if (i2.length) {
231
+ let t3 = "http://www.w3.org/1999/xhtml", n3 = document.createElementNS(t3, "svg");
232
+ n3.setAttribute("xmlns", t3), n3.style.position = "absolute", n3.style.width = "0", n3.style.height = "0", n3.style.overflow = "hidden", n3.style.display = "none";
233
+ let r3 = document.createElementNS(t3, "defs");
234
+ n3.appendChild(r3);
235
+ for (let e3 = 0; e3 < i2.length; e3++) r3.appendChild(i2[e3]);
236
+ e2.appendChild(n3);
237
+ }
238
+ return e2;
239
+ }
240
+ async function cloneNode(e2, t2, n2) {
241
+ return !n2 && t2.filter && !t2.filter(e2) ? null : Promise.resolve(e2).then((e3) => cloneSingleNode(e3, t2)).then((n3) => cloneChildren(e2, n3, t2)).then((n3) => decorate(e2, n3, t2)).then((e3) => ensureSVGSymbols(e3, t2));
242
+ }
252
243
  var s = /url\((['"]?)([^'"]+?)\1\)/g, c = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, l = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
253
- function toRegex(e) {
254
- let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
255
- return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
256
- }
257
- function parseURLs(e) {
258
- let t = [];
259
- return e.replace(s, (e, n, r) => (t.push(r), e)), t.filter((e) => !isDataUrl(e));
260
- }
261
- async function embed(e, t, n, r, i) {
262
- try {
263
- let a = n ? resolveUrl(t, n) : t, o = getMimeType(t), s;
264
- return s = i ? makeDataUrl(await i(a), o) : await resourceToDataURL(a, o, r), e.replace(toRegex(t), `$1${s}$3`);
265
- } catch {}
266
- return e;
267
- }
268
- function filterPreferredFontFormat(e, { preferredFontFormat: t }) {
269
- return t ? e.replace(l, (e) => {
270
- for (;;) {
271
- let [n, , r] = c.exec(e) || [];
272
- if (!r) return "";
273
- if (r === t) return `src: ${n};`;
274
- }
275
- }) : e;
276
- }
277
- function shouldEmbed(e) {
278
- return e.search(s) !== -1;
279
- }
280
- async function embedResources(e, t, n) {
281
- if (!shouldEmbed(e)) return e;
282
- let r = filterPreferredFontFormat(e, n);
283
- return parseURLs(r).reduce((e, r) => e.then((e) => embed(e, r, t, n)), Promise.resolve(r));
284
- }
285
- //#endregion
286
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-images.js
287
- async function embedProp(e, t, n) {
288
- let r = t.style?.getPropertyValue(e);
289
- if (r) {
290
- let i = await embedResources(r, null, n);
291
- return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
292
- }
293
- return !1;
294
- }
295
- async function embedBackground(e, t) {
296
- await embedProp("background", e, t) || await embedProp("background-image", e, t), await embedProp("mask", e, t) || await embedProp("-webkit-mask", e, t) || await embedProp("mask-image", e, t) || await embedProp("-webkit-mask-image", e, t);
297
- }
298
- async function embedImageNode(e, t) {
299
- let n = isInstanceOfElement(e, HTMLImageElement);
300
- if (!(n && !isDataUrl(e.src)) && !(isInstanceOfElement(e, SVGImageElement) && !isDataUrl(e.href.baseVal))) return;
301
- let r = n ? e.src : e.href.baseVal, i = await resourceToDataURL(r, getMimeType(r), t);
302
- await new Promise((r, a) => {
303
- e.onload = r, e.onerror = t.onImageErrorHandler ? (...e) => {
304
- try {
305
- r(t.onImageErrorHandler(...e));
306
- } catch (e) {
307
- a(e);
308
- }
309
- } : a;
310
- let o = e;
311
- o.decode && (o.decode = r), o.loading === "lazy" && (o.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
312
- });
313
- }
314
- async function embedChildren(e, t) {
315
- let n = toArray(e.childNodes).map((e) => embedImages(e, t));
316
- await Promise.all(n).then(() => e);
317
- }
318
- async function embedImages(e, t) {
319
- isInstanceOfElement(e, Element) && (await embedBackground(e, t), await embedImageNode(e, t), await embedChildren(e, t));
320
- }
321
- //#endregion
322
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/apply-style.js
323
- function applyStyle(e, t) {
324
- let { style: n } = e;
325
- t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
326
- let r = t.style;
327
- return r != null && Object.keys(r).forEach((e) => {
328
- n[e] = r[e];
329
- }), e;
330
- }
331
- //#endregion
332
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-webfonts.js
244
+ function toRegex(e2) {
245
+ let t2 = e2.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
246
+ return RegExp(`(url\\(['"]?)(${t2})(['"]?\\))`, "g");
247
+ }
248
+ function parseURLs(e2) {
249
+ let t2 = [];
250
+ return e2.replace(s, (e3, n2, r2) => (t2.push(r2), e3)), t2.filter((e3) => !isDataUrl(e3));
251
+ }
252
+ async function embed(e2, t2, n2, r2, i2) {
253
+ try {
254
+ let a2 = n2 ? resolveUrl(t2, n2) : t2, o2 = getMimeType(t2), s2;
255
+ return s2 = i2 ? makeDataUrl(await i2(a2), o2) : await resourceToDataURL(a2, o2, r2), e2.replace(toRegex(t2), `$1${s2}$3`);
256
+ } catch {
257
+ }
258
+ return e2;
259
+ }
260
+ function filterPreferredFontFormat(e2, { preferredFontFormat: t2 }) {
261
+ return t2 ? e2.replace(l, (e3) => {
262
+ for (; ; ) {
263
+ let [n2, , r2] = c.exec(e3) || [];
264
+ if (!r2) return "";
265
+ if (r2 === t2) return `src: ${n2};`;
266
+ }
267
+ }) : e2;
268
+ }
269
+ function shouldEmbed(e2) {
270
+ return e2.search(s) !== -1;
271
+ }
272
+ async function embedResources(e2, t2, n2) {
273
+ if (!shouldEmbed(e2)) return e2;
274
+ let r2 = filterPreferredFontFormat(e2, n2);
275
+ return parseURLs(r2).reduce((e3, r3) => e3.then((e4) => embed(e4, r3, t2, n2)), Promise.resolve(r2));
276
+ }
277
+ async function embedProp(e2, t2, n2) {
278
+ let r2 = t2.style?.getPropertyValue(e2);
279
+ if (r2) {
280
+ let i2 = await embedResources(r2, null, n2);
281
+ return t2.style.setProperty(e2, i2, t2.style.getPropertyPriority(e2)), true;
282
+ }
283
+ return false;
284
+ }
285
+ async function embedBackground(e2, t2) {
286
+ await embedProp("background", e2, t2) || await embedProp("background-image", e2, t2), await embedProp("mask", e2, t2) || await embedProp("-webkit-mask", e2, t2) || await embedProp("mask-image", e2, t2) || await embedProp("-webkit-mask-image", e2, t2);
287
+ }
288
+ async function embedImageNode(e2, t2) {
289
+ let n2 = isInstanceOfElement(e2, HTMLImageElement);
290
+ if (!(n2 && !isDataUrl(e2.src)) && !(isInstanceOfElement(e2, SVGImageElement) && !isDataUrl(e2.href.baseVal))) return;
291
+ let r2 = n2 ? e2.src : e2.href.baseVal, i2 = await resourceToDataURL(r2, getMimeType(r2), t2);
292
+ await new Promise((r3, a2) => {
293
+ e2.onload = r3, e2.onerror = t2.onImageErrorHandler ? (...e3) => {
294
+ try {
295
+ r3(t2.onImageErrorHandler(...e3));
296
+ } catch (e4) {
297
+ a2(e4);
298
+ }
299
+ } : a2;
300
+ let o2 = e2;
301
+ o2.decode && (o2.decode = r3), o2.loading === "lazy" && (o2.loading = "eager"), n2 ? (e2.srcset = "", e2.src = i2) : e2.href.baseVal = i2;
302
+ });
303
+ }
304
+ async function embedChildren(e2, t2) {
305
+ let n2 = toArray(e2.childNodes).map((e3) => embedImages(e3, t2));
306
+ await Promise.all(n2).then(() => e2);
307
+ }
308
+ async function embedImages(e2, t2) {
309
+ isInstanceOfElement(e2, Element) && (await embedBackground(e2, t2), await embedImageNode(e2, t2), await embedChildren(e2, t2));
310
+ }
311
+ function applyStyle(e2, t2) {
312
+ let { style: n2 } = e2;
313
+ t2.backgroundColor && (n2.backgroundColor = t2.backgroundColor), t2.width && (n2.width = `${t2.width}px`), t2.height && (n2.height = `${t2.height}px`);
314
+ let r2 = t2.style;
315
+ return r2 != null && Object.keys(r2).forEach((e3) => {
316
+ n2[e3] = r2[e3];
317
+ }), e2;
318
+ }
333
319
  var u = {};
334
- async function fetchCSS(e) {
335
- let t = u[e];
336
- return t ?? (t = {
337
- url: e,
338
- cssText: await (await fetch(e)).text()
339
- }, u[e] = t, t);
340
- }
341
- async function embedFonts(e, t) {
342
- let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
343
- let a = i.replace(r, "$1");
344
- return a.startsWith("https://") || (a = new URL(a, e.url).href), fetchAsDataURL(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
345
- });
346
- return Promise.all(i).then(() => n);
347
- }
348
- function parseCSS(e) {
349
- if (e == null) return [];
350
- let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
351
- for (;;) {
352
- let e = r.exec(n);
353
- if (e === null) break;
354
- t.push(e[0]);
355
- }
356
- n = n.replace(r, "");
357
- let i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
358
- for (;;) {
359
- let e = i.exec(n);
360
- if (e === null) {
361
- if (e = a.exec(n), e === null) break;
362
- i.lastIndex = a.lastIndex;
363
- } else a.lastIndex = i.lastIndex;
364
- t.push(e[0]);
365
- }
366
- return t;
367
- }
368
- async function getCSSRules(e, t) {
369
- let n = [], r = [];
370
- return e.forEach((n) => {
371
- if ("cssRules" in n) try {
372
- toArray(n.cssRules || []).forEach((e, i) => {
373
- if (e.type === CSSRule.IMPORT_RULE) {
374
- let a = i + 1, o = e.href, s = fetchCSS(o).then((e) => embedFonts(e, t)).then((e) => parseCSS(e).forEach((e) => {
375
- try {
376
- n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
377
- } catch (t) {
378
- console.error("Error inserting rule from remote css", {
379
- rule: e,
380
- error: t
381
- });
382
- }
383
- })).catch((e) => {
384
- console.error("Error loading remote css", e.toString());
385
- });
386
- r.push(s);
387
- }
388
- });
389
- } catch (i) {
390
- let a = e.find((e) => e.href == null) || document.styleSheets[0];
391
- n.href != null && r.push(fetchCSS(n.href).then((e) => embedFonts(e, t)).then((e) => parseCSS(e).forEach((e) => {
392
- a.insertRule(e, a.cssRules.length);
393
- })).catch((e) => {
394
- console.error("Error loading remote stylesheet", e);
395
- })), console.error("Error inlining remote css file", i);
396
- }
397
- }), Promise.all(r).then(() => (e.forEach((e) => {
398
- if ("cssRules" in e) try {
399
- toArray(e.cssRules || []).forEach((e) => {
400
- n.push(e);
401
- });
402
- } catch (t) {
403
- console.error(`Error while reading CSS rules from ${e.href}`, t);
404
- }
405
- }), n));
406
- }
407
- function getWebFontRules(e) {
408
- return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => shouldEmbed(e.style.getPropertyValue("src")));
409
- }
410
- async function parseWebFontRules(e, t) {
411
- if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
412
- return getWebFontRules(await getCSSRules(toArray(e.ownerDocument.styleSheets), t));
413
- }
414
- function normalizeFontFamily(e) {
415
- return e.trim().replace(/["']/g, "");
416
- }
417
- function getUsedFonts(e) {
418
- let t = /* @__PURE__ */ new Set();
419
- function traverse(e) {
420
- (e.style.fontFamily || getComputedStyle(e).fontFamily).split(",").forEach((e) => {
421
- t.add(normalizeFontFamily(e));
422
- }), Array.from(e.children).forEach((e) => {
423
- e instanceof HTMLElement && traverse(e);
424
- });
425
- }
426
- return traverse(e), t;
427
- }
428
- async function getWebFontCSS(e, t) {
429
- let n = await parseWebFontRules(e, t), r = getUsedFonts(e);
430
- return (await Promise.all(n.filter((e) => r.has(normalizeFontFamily(e.style.fontFamily))).map((e) => {
431
- let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
432
- return embedResources(e.cssText, n, t);
433
- }))).join("\n");
434
- }
435
- async function embedWebFonts(e, t) {
436
- let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await getWebFontCSS(e, t) : t.fontEmbedCSS;
437
- if (n) {
438
- let t = document.createElement("style"), r = document.createTextNode(n);
439
- t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
440
- }
441
- }
442
- //#endregion
443
- //#region node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/index.js
444
- async function toSvg(e, t = {}) {
445
- let { width: n, height: r } = getImageSize(e, t), i = await cloneNode(e, t, !0);
446
- return await embedWebFonts(i, t), await embedImages(i, t), applyStyle(i, t), await nodeToDataURL(i, n, r);
447
- }
448
- async function toCanvas(e, t = {}) {
449
- let { width: n, height: r } = getImageSize(e, t), i = await createImage(await toSvg(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || getPixelRatio(), c = t.canvasWidth || n, l = t.canvasHeight || r;
450
- return a.width = c * s, a.height = l * s, t.skipAutoScale || checkCanvasDimensions(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
451
- }
452
- async function toPng(e, t = {}) {
453
- return (await toCanvas(e, t)).toDataURL();
454
- }
455
- //#endregion
456
- export { toPng };
457
-
458
- //# sourceMappingURL=es-BAQ_ERKH.js.map
320
+ async function fetchCSS(e2) {
321
+ let t2 = u[e2];
322
+ return t2 ?? (t2 = {
323
+ url: e2,
324
+ cssText: await (await fetch(e2)).text()
325
+ }, u[e2] = t2, t2);
326
+ }
327
+ async function embedFonts(e2, t2) {
328
+ let n2 = e2.cssText, r2 = /url\(["']?([^"')]+)["']?\)/g, i2 = (n2.match(/url\([^)]+\)/g) || []).map(async (i3) => {
329
+ let a2 = i3.replace(r2, "$1");
330
+ return a2.startsWith("https://") || (a2 = new URL(a2, e2.url).href), fetchAsDataURL(a2, t2.fetchRequestInit, ({ result: e3 }) => (n2 = n2.replace(i3, `url(${e3})`), [i3, e3]));
331
+ });
332
+ return Promise.all(i2).then(() => n2);
333
+ }
334
+ function parseCSS(e2) {
335
+ if (e2 == null) return [];
336
+ let t2 = [], n2 = e2.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r2 = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
337
+ for (; ; ) {
338
+ let e3 = r2.exec(n2);
339
+ if (e3 === null) break;
340
+ t2.push(e3[0]);
341
+ }
342
+ n2 = n2.replace(r2, "");
343
+ let i2 = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a2 = /* @__PURE__ */ RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", "gi");
344
+ for (; ; ) {
345
+ let e3 = i2.exec(n2);
346
+ if (e3 === null) {
347
+ if (e3 = a2.exec(n2), e3 === null) break;
348
+ i2.lastIndex = a2.lastIndex;
349
+ } else a2.lastIndex = i2.lastIndex;
350
+ t2.push(e3[0]);
351
+ }
352
+ return t2;
353
+ }
354
+ async function getCSSRules(e2, t2) {
355
+ let n2 = [], r2 = [];
356
+ return e2.forEach((n3) => {
357
+ if ("cssRules" in n3) try {
358
+ toArray(n3.cssRules || []).forEach((e3, i2) => {
359
+ if (e3.type === CSSRule.IMPORT_RULE) {
360
+ let a2 = i2 + 1, o2 = e3.href, s2 = fetchCSS(o2).then((e4) => embedFonts(e4, t2)).then((e4) => parseCSS(e4).forEach((e5) => {
361
+ try {
362
+ n3.insertRule(e5, e5.startsWith("@import") ? a2 += 1 : n3.cssRules.length);
363
+ } catch (t3) {
364
+ console.error("Error inserting rule from remote css", {
365
+ rule: e5,
366
+ error: t3
367
+ });
368
+ }
369
+ })).catch((e4) => {
370
+ console.error("Error loading remote css", e4.toString());
371
+ });
372
+ r2.push(s2);
373
+ }
374
+ });
375
+ } catch (i2) {
376
+ let a2 = e2.find((e3) => e3.href == null) || document.styleSheets[0];
377
+ n3.href != null && r2.push(fetchCSS(n3.href).then((e3) => embedFonts(e3, t2)).then((e3) => parseCSS(e3).forEach((e4) => {
378
+ a2.insertRule(e4, a2.cssRules.length);
379
+ })).catch((e3) => {
380
+ console.error("Error loading remote stylesheet", e3);
381
+ })), console.error("Error inlining remote css file", i2);
382
+ }
383
+ }), Promise.all(r2).then(() => (e2.forEach((e3) => {
384
+ if ("cssRules" in e3) try {
385
+ toArray(e3.cssRules || []).forEach((e4) => {
386
+ n2.push(e4);
387
+ });
388
+ } catch (t3) {
389
+ console.error(`Error while reading CSS rules from ${e3.href}`, t3);
390
+ }
391
+ }), n2));
392
+ }
393
+ function getWebFontRules(e2) {
394
+ return e2.filter((e3) => e3.type === CSSRule.FONT_FACE_RULE).filter((e3) => shouldEmbed(e3.style.getPropertyValue("src")));
395
+ }
396
+ async function parseWebFontRules(e2, t2) {
397
+ if (e2.ownerDocument == null) throw Error("Provided element is not within a Document");
398
+ return getWebFontRules(await getCSSRules(toArray(e2.ownerDocument.styleSheets), t2));
399
+ }
400
+ function normalizeFontFamily(e2) {
401
+ return e2.trim().replace(/["']/g, "");
402
+ }
403
+ function getUsedFonts(e2) {
404
+ let t2 = /* @__PURE__ */ new Set();
405
+ function traverse(e3) {
406
+ (e3.style.fontFamily || getComputedStyle(e3).fontFamily).split(",").forEach((e4) => {
407
+ t2.add(normalizeFontFamily(e4));
408
+ }), Array.from(e3.children).forEach((e4) => {
409
+ e4 instanceof HTMLElement && traverse(e4);
410
+ });
411
+ }
412
+ return traverse(e2), t2;
413
+ }
414
+ async function getWebFontCSS(e2, t2) {
415
+ let n2 = await parseWebFontRules(e2, t2), r2 = getUsedFonts(e2);
416
+ return (await Promise.all(n2.filter((e3) => r2.has(normalizeFontFamily(e3.style.fontFamily))).map((e3) => {
417
+ let n3 = e3.parentStyleSheet ? e3.parentStyleSheet.href : null;
418
+ return embedResources(e3.cssText, n3, t2);
419
+ }))).join("\n");
420
+ }
421
+ async function embedWebFonts(e2, t2) {
422
+ let n2 = t2.fontEmbedCSS == null ? t2.skipFonts ? null : await getWebFontCSS(e2, t2) : t2.fontEmbedCSS;
423
+ if (n2) {
424
+ let t3 = document.createElement("style"), r2 = document.createTextNode(n2);
425
+ t3.appendChild(r2), e2.firstChild ? e2.insertBefore(t3, e2.firstChild) : e2.appendChild(t3);
426
+ }
427
+ }
428
+ async function toSvg(e2, t2 = {}) {
429
+ let { width: n2, height: r2 } = getImageSize(e2, t2), i2 = await cloneNode(e2, t2, true);
430
+ return await embedWebFonts(i2, t2), await embedImages(i2, t2), applyStyle(i2, t2), await nodeToDataURL(i2, n2, r2);
431
+ }
432
+ async function toCanvas(e2, t2 = {}) {
433
+ let { width: n2, height: r2 } = getImageSize(e2, t2), i2 = await createImage(await toSvg(e2, t2)), a2 = document.createElement("canvas"), o2 = a2.getContext("2d"), s2 = t2.pixelRatio || getPixelRatio(), c2 = t2.canvasWidth || n2, l2 = t2.canvasHeight || r2;
434
+ return a2.width = c2 * s2, a2.height = l2 * s2, t2.skipAutoScale || checkCanvasDimensions(a2), a2.style.width = `${c2}`, a2.style.height = `${l2}`, t2.backgroundColor && (o2.fillStyle = t2.backgroundColor, o2.fillRect(0, 0, a2.width, a2.height)), o2.drawImage(i2, 0, 0, a2.width, a2.height), a2;
435
+ }
436
+ async function toPng(e2, t2 = {}) {
437
+ return (await toCanvas(e2, t2)).toDataURL();
438
+ }
439
+ export {
440
+ toPng
441
+ };