@sailfish-ai/recorder 1.12.4 → 1.12.6

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 (144) hide show
  1. package/README.md +8 -0
  2. package/dist/canvas/adapters.js +382 -0
  3. package/dist/canvas/adapters.js.br +0 -0
  4. package/dist/canvas/adapters.js.gz +0 -0
  5. package/dist/canvas/canvasManager.js +1949 -0
  6. package/dist/canvas/canvasManager.js.br +0 -0
  7. package/dist/canvas/canvasManager.js.gz +0 -0
  8. package/dist/canvas/canvasPrivacy.js +233 -0
  9. package/dist/canvas/canvasPrivacy.js.br +0 -0
  10. package/dist/canvas/canvasPrivacy.js.gz +0 -0
  11. package/dist/canvas/codec.js +314 -0
  12. package/dist/canvas/codec.js.br +0 -0
  13. package/dist/canvas/codec.js.gz +0 -0
  14. package/dist/canvas/deviceClass.js +67 -0
  15. package/dist/canvas/deviceClass.js.br +0 -0
  16. package/dist/canvas/deviceClass.js.gz +0 -0
  17. package/dist/canvas/encodeWorker.js +284 -0
  18. package/dist/canvas/encodeWorker.js.br +0 -0
  19. package/dist/canvas/encodeWorker.js.gz +0 -0
  20. package/dist/canvas/governor.js +79 -0
  21. package/dist/canvas/governor.js.br +0 -0
  22. package/dist/canvas/governor.js.gz +0 -0
  23. package/dist/canvas/keyframes.js +183 -0
  24. package/dist/canvas/keyframes.js.br +0 -0
  25. package/dist/canvas/keyframes.js.gz +0 -0
  26. package/dist/canvas/mediaRecorderCapture.js +257 -0
  27. package/dist/canvas/mediaRecorderCapture.js.br +0 -0
  28. package/dist/canvas/mediaRecorderCapture.js.gz +0 -0
  29. package/dist/canvas/objectLog.js +150 -0
  30. package/dist/canvas/objectLog.js.br +0 -0
  31. package/dist/canvas/objectLog.js.gz +0 -0
  32. package/dist/canvas/patch2d.js +1302 -0
  33. package/dist/canvas/patch2d.js.br +0 -0
  34. package/dist/canvas/patch2d.js.gz +0 -0
  35. package/dist/canvas/patchGL.js +371 -0
  36. package/dist/canvas/patchGL.js.br +0 -0
  37. package/dist/canvas/patchGL.js.gz +0 -0
  38. package/dist/canvas/patchWebGPU.js +361 -0
  39. package/dist/canvas/patchWebGPU.js.br +0 -0
  40. package/dist/canvas/patchWebGPU.js.gz +0 -0
  41. package/dist/canvas/piiDetect.js +155 -0
  42. package/dist/canvas/piiDetect.js.br +0 -0
  43. package/dist/canvas/piiDetect.js.gz +0 -0
  44. package/dist/canvas/protocol.js +122 -0
  45. package/dist/canvas/protocol.js.br +0 -0
  46. package/dist/canvas/protocol.js.gz +0 -0
  47. package/dist/canvas/videoCapture.js +252 -0
  48. package/dist/canvas/videoCapture.js.br +0 -0
  49. package/dist/canvas/videoCapture.js.gz +0 -0
  50. package/dist/canvas/workerRelay.js +99 -0
  51. package/dist/canvas/workerRelay.js.br +0 -0
  52. package/dist/canvas/workerRelay.js.gz +0 -0
  53. package/dist/canvas/workerShim.js +227 -0
  54. package/dist/canvas/workerShim.js.br +0 -0
  55. package/dist/canvas/workerShim.js.gz +0 -0
  56. package/dist/canvas-worker.cjs +74 -0
  57. package/dist/canvas-worker.cjs.br +0 -0
  58. package/dist/canvas-worker.cjs.gz +0 -0
  59. package/dist/canvas-worker.js +78 -0
  60. package/dist/canvas-worker.js.br +0 -0
  61. package/dist/canvas-worker.js.gz +0 -0
  62. package/dist/canvasFrameStore.js +198 -0
  63. package/dist/canvasFrameStore.js.br +0 -0
  64. package/dist/canvasFrameStore.js.gz +0 -0
  65. package/dist/chunks/canvasManager-BYn3_oyo.js +1440 -0
  66. package/dist/chunks/canvasManager-BYn3_oyo.js.br +0 -0
  67. package/dist/chunks/canvasManager-BYn3_oyo.js.gz +0 -0
  68. package/dist/chunks/canvasManager-CoX5072G.js +1456 -0
  69. package/dist/chunks/canvasManager-CoX5072G.js.br +0 -0
  70. package/dist/chunks/canvasManager-CoX5072G.js.gz +0 -0
  71. package/dist/chunks/{chunkSerializer-FQtY90Av.js → chunkSerializer-C_K0Wyk0.js} +1 -1
  72. package/dist/chunks/chunkSerializer-C_K0Wyk0.js.br +0 -0
  73. package/dist/chunks/chunkSerializer-C_K0Wyk0.js.gz +0 -0
  74. package/dist/chunks/{chunkSerializer-DDukZpgl.js → chunkSerializer-CghPitF4.js} +1 -1
  75. package/dist/chunks/chunkSerializer-CghPitF4.js.br +0 -0
  76. package/dist/chunks/chunkSerializer-CghPitF4.js.gz +0 -0
  77. package/dist/chunks/{index-C-qbsfKe.js → index-BIj4l3CV.js} +1028 -650
  78. package/dist/chunks/index-BIj4l3CV.js.br +0 -0
  79. package/dist/chunks/index-BIj4l3CV.js.gz +0 -0
  80. package/dist/chunks/{index-D6axlCRu.js → index-DIYomvdD.js} +1119 -720
  81. package/dist/chunks/index-DIYomvdD.js.br +0 -0
  82. package/dist/chunks/index-DIYomvdD.js.gz +0 -0
  83. package/dist/chunks/patch2d-9voowhJ_.js +816 -0
  84. package/dist/chunks/patch2d-9voowhJ_.js.br +0 -0
  85. package/dist/chunks/patch2d-9voowhJ_.js.gz +0 -0
  86. package/dist/chunks/patch2d-PQxcaE6r.js +886 -0
  87. package/dist/chunks/patch2d-PQxcaE6r.js.br +0 -0
  88. package/dist/chunks/patch2d-PQxcaE6r.js.gz +0 -0
  89. package/dist/graphql.js +12 -1
  90. package/dist/graphql.js.br +0 -0
  91. package/dist/graphql.js.gz +0 -0
  92. package/dist/inAppReportIssueModal/index.js +48 -0
  93. package/dist/inAppReportIssueModal/index.js.br +0 -0
  94. package/dist/inAppReportIssueModal/index.js.gz +0 -0
  95. package/dist/index.js +144 -2
  96. package/dist/index.js.br +0 -0
  97. package/dist/index.js.gz +0 -0
  98. package/dist/recorder.cjs +2 -2
  99. package/dist/recorder.cjs.br +0 -0
  100. package/dist/recorder.cjs.gz +0 -0
  101. package/dist/recorder.js +52 -41
  102. package/dist/recorder.js.br +0 -0
  103. package/dist/recorder.js.gz +0 -0
  104. package/dist/recorder.umd.cjs +4847 -2212
  105. package/dist/recorder.umd.cjs.br +0 -0
  106. package/dist/recorder.umd.cjs.gz +0 -0
  107. package/dist/recording.js +119 -10
  108. package/dist/recording.js.br +0 -0
  109. package/dist/recording.js.gz +0 -0
  110. package/dist/types/canvas/adapters.d.ts +71 -0
  111. package/dist/types/canvas/canvasManager.d.ts +273 -0
  112. package/dist/types/canvas/canvasPrivacy.d.ts +184 -0
  113. package/dist/types/canvas/codec.d.ts +27 -0
  114. package/dist/types/canvas/deviceClass.d.ts +40 -0
  115. package/dist/types/canvas/encodeWorker.d.ts +54 -0
  116. package/dist/types/canvas/governor.d.ts +44 -0
  117. package/dist/types/canvas/keyframes.d.ts +81 -0
  118. package/dist/types/canvas/mediaRecorderCapture.d.ts +91 -0
  119. package/dist/types/canvas/objectLog.d.ts +75 -0
  120. package/dist/types/canvas/patch2d.d.ts +339 -0
  121. package/dist/types/canvas/patchGL.d.ts +74 -0
  122. package/dist/types/canvas/patchWebGPU.d.ts +37 -0
  123. package/dist/types/canvas/piiDetect.d.ts +60 -0
  124. package/dist/types/canvas/protocol.d.ts +176 -0
  125. package/dist/types/canvas/videoCapture.d.ts +67 -0
  126. package/dist/types/canvas/workerRelay.d.ts +29 -0
  127. package/dist/types/canvas/workerShim.d.ts +10 -0
  128. package/dist/types/canvasFrameStore.d.ts +23 -0
  129. package/dist/types/graphql.d.ts +1 -1
  130. package/dist/types/index.d.ts +99 -1
  131. package/dist/types/types.d.ts +40 -0
  132. package/dist/types/websocket.d.ts +19 -0
  133. package/dist/websocket.js +210 -0
  134. package/dist/websocket.js.br +0 -0
  135. package/dist/websocket.js.gz +0 -0
  136. package/package.json +7 -1
  137. package/dist/chunks/chunkSerializer-DDukZpgl.js.br +0 -0
  138. package/dist/chunks/chunkSerializer-DDukZpgl.js.gz +0 -0
  139. package/dist/chunks/chunkSerializer-FQtY90Av.js.br +0 -0
  140. package/dist/chunks/chunkSerializer-FQtY90Av.js.gz +0 -0
  141. package/dist/chunks/index-C-qbsfKe.js.br +0 -0
  142. package/dist/chunks/index-C-qbsfKe.js.gz +0 -0
  143. package/dist/chunks/index-D6axlCRu.js.br +0 -0
  144. package/dist/chunks/index-D6axlCRu.js.gz +0 -0
@@ -0,0 +1,886 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ function closestSafe(t2, e2) {
5
+ if (!t2 || !e2) return false;
6
+ try {
7
+ return !!t2.closest(e2);
8
+ } catch {
9
+ return false;
10
+ }
11
+ }
12
+ function matchesSelectorSafe(t2, e2) {
13
+ if (!e2) return false;
14
+ try {
15
+ return t2.matches(e2);
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ function buildMaskInputFn(t2) {
21
+ const { baseFn: e2, unmaskSelector: s2, maskInputSelector: a2, adminMaskInputOptions: i2 } = t2;
22
+ return s2 || a2 ? (t3, r2) => {
23
+ if ("hidden" === r2.type) return "";
24
+ if (closestSafe(r2, s2)) return t3;
25
+ const o2 = (r2.type || "").toLowerCase(), c2 = (r2.tagName || "").toLowerCase(), h2 = true === i2[o2] || true === i2[c2], l2 = matchesSelectorSafe(r2, a2);
26
+ return h2 || l2 ? e2(t3, r2) : t3;
27
+ } : e2;
28
+ }
29
+ function makeMaskTextFn(t2) {
30
+ return (e2, s2) => closestSafe(s2, t2) ? e2 : e2.replace(/\S/g, "*");
31
+ }
32
+ const t = /\d/, e = /\b\d{3}-\d{2}-\d{4}\b/, s = /\b(?:\d[ -]*?){13,16}\b/g, a = /\b\d{3}-\d{2}-\d{4}\b/g, i = /\b\d{1,2}[/\-.]\d{1,2}[/\-.]\d{2,4}\b/g;
33
+ function passesLuhn(t2) {
34
+ let e2 = "";
35
+ for (let s3 = 0; s3 < t2.length; s3++) {
36
+ const a3 = t2.charCodeAt(s3);
37
+ a3 >= 48 && a3 <= 57 && (e2 += t2[s3]);
38
+ }
39
+ const s2 = e2.length;
40
+ if (s2 < 13 || s2 > 16) return false;
41
+ let a2 = 0, i2 = false;
42
+ for (let t3 = s2 - 1; t3 >= 0; t3--) {
43
+ let s3 = e2.charCodeAt(t3) - 48;
44
+ i2 && (s3 *= 2, s3 > 9 && (s3 -= 9)), a2 += s3, i2 = !i2;
45
+ }
46
+ return a2 % 10 == 0;
47
+ }
48
+ function looksLikeCreditCard(t2) {
49
+ if ("string" != typeof t2) return false;
50
+ let e2;
51
+ for (s.lastIndex = 0; null !== (e2 = s.exec(t2)); ) {
52
+ if (passesLuhn(e2[0])) return true;
53
+ e2.index === s.lastIndex && s.lastIndex++;
54
+ }
55
+ return false;
56
+ }
57
+ function looksLikeSsn(t2) {
58
+ return "string" == typeof t2 && e.test(t2);
59
+ }
60
+ function redactCreditCard(t2) {
61
+ return "**** **** **** " + t2.slice(-4);
62
+ }
63
+ function redactSsn(t2) {
64
+ return "***-**-" + t2.slice(-4);
65
+ }
66
+ function redactDob(t2) {
67
+ return "**/**/" + t2.slice(-4);
68
+ }
69
+ function redactSensitiveContent(e2, r2) {
70
+ if ("string" != typeof e2 || 0 === e2.length) return e2;
71
+ if (!t.test(e2)) return e2;
72
+ let o2 = e2;
73
+ return false === r2.recordCreditCardInfo && (s.lastIndex = 0, o2 = o2.replace(s, (t2) => passesLuhn(t2) ? redactCreditCard(t2) : t2)), false === r2.recordSsn && (a.lastIndex = 0, o2 = o2.replace(a, (t2) => redactSsn(t2))), false === r2.recordDob && (i.lastIndex = 0, o2 = o2.replace(i, (t2) => redactDob(t2))), o2;
74
+ }
75
+ function maskCanvasSelector(t2) {
76
+ return `.${t2.maskCanvasClass || "sailfishSanitize"}, [data-sf-mask]`;
77
+ }
78
+ function classifyCanvasPrivacy(t2, e2) {
79
+ return closestSafe(t2, e2.unmaskSelector) ? "normal" : closestSafe(t2, e2.blockSelector) || closestSafe(t2, maskCanvasSelector(e2)) ? "suppress" : e2.maskTextClass && closestSafe(t2, `.${e2.maskTextClass}`) || matchesSelectorSafe(t2, e2.maskTextSelector) || closestSafe(t2, e2.maskTextSelector) || true === e2.maskCanvasText || false !== e2.maskCanvasText && (function domTextMaskingConfigured(t3) {
80
+ return !(!t3.maskTextSelector && !t3.maskTextClass);
81
+ })(e2) ? "redact" : "normal";
82
+ }
83
+ function suppressReason(t2, e2) {
84
+ if (!closestSafe(t2, e2.unmaskSelector)) return closestSafe(t2, e2.blockSelector) ? "block" : closestSafe(t2, maskCanvasSelector(e2)) ? "mask" : void 0;
85
+ }
86
+ function maskAllText(t2) {
87
+ return t2.replace(/\S/g, "*");
88
+ }
89
+ function redactCanvasText(t2, e2, s2) {
90
+ return "string" != typeof t2 ? t2 : "redact" === e2 ? maskAllText(t2) : "normal" === e2 ? redactSensitiveContent(t2, s2) : t2;
91
+ }
92
+ const r = { text: "asterisks", shape: "color" }, o = "#1f2433";
93
+ function resolveRedactStyle(t2, e2) {
94
+ const s2 = t2 ?? r;
95
+ return e2 ? { text: e2.text ?? s2.text, shape: e2.shape ?? s2.shape } : s2;
96
+ }
97
+ function transformedBox(t2, e2, s2, a2, i2, r2 = 1) {
98
+ if (![t2, e2, s2, a2, i2.a, i2.b, i2.c, i2.d, i2.e, i2.f].every(Number.isFinite)) return null;
99
+ const px = (t3, e3) => i2.a * t3 + i2.c * e3 + i2.e, py = (t3, e3) => i2.b * t3 + i2.d * e3 + i2.f, o2 = [px(t2, e2), px(s2, e2), px(s2, a2), px(t2, a2)], c2 = [py(t2, e2), py(s2, e2), py(s2, a2), py(t2, a2)], h2 = Math.min(...o2), l2 = Math.max(...o2), d2 = Math.min(...c2), u2 = Math.max(...c2);
100
+ return Number.isFinite(h2) && Number.isFinite(d2) ? { x: h2 - r2, y: d2 - r2, w: l2 - h2 + 2 * r2, h: u2 - d2 + 2 * r2 } : null;
101
+ }
102
+ function textLocalBox(t2) {
103
+ let e2 = t2.x;
104
+ const s2 = t2.align ?? "start";
105
+ "center" === s2 ? e2 = t2.x - t2.width / 2 : "right" !== s2 && "end" !== s2 || (e2 = t2.x - t2.width);
106
+ const a2 = e2 + t2.width, i2 = t2.ascent, r2 = t2.descent, o2 = i2 + r2;
107
+ let c2, h2;
108
+ switch (t2.baseline) {
109
+ case "top":
110
+ case "hanging":
111
+ c2 = t2.y, h2 = t2.y + o2;
112
+ break;
113
+ case "middle":
114
+ c2 = t2.y - o2 / 2, h2 = t2.y + o2 / 2;
115
+ break;
116
+ case "bottom":
117
+ case "ideographic":
118
+ c2 = t2.y - o2, h2 = t2.y;
119
+ break;
120
+ default:
121
+ c2 = t2.y - i2, h2 = t2.y + r2;
122
+ }
123
+ return { x0: e2, y0: c2, x1: a2, y1: h2 };
124
+ }
125
+ const c = new Map(["__frame", "__create", "__objcall", "arc", "arcTo", "beginPath", "bezierCurveTo", "clearRect", "clip", "closePath", "drawImage", "ellipse", "fill", "fillRect", "fillText", "lineTo", "moveTo", "putImageData", "quadraticCurveTo", "rect", "reset", "resetTransform", "restore", "rotate", "roundRect", "save", "scale", "setLineDash", "setTransform", "stroke", "strokeRect", "strokeText", "transform", "translate", "drawFocusIfNeeded", "fillStyle", "strokeStyle", "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap", "lineJoin", "miterLimit", "lineDashOffset", "font", "textAlign", "textBaseline", "direction", "shadowBlur", "shadowColor", "shadowOffsetX", "shadowOffsetY", "imageSmoothingEnabled", "imageSmoothingQuality", "filter", "letterSpacing", "wordSpacing", "useProgram", "bindBuffer", "bindTexture", "bindVertexArray", "bindFramebuffer", "bufferData", "bufferSubData", "uniform1f", "uniform1i", "uniform2f", "uniform3f", "uniform4f", "uniform1fv", "uniform2fv", "uniform3fv", "uniform4fv", "uniformMatrix3fv", "uniformMatrix4fv", "vertexAttribPointer", "enableVertexAttribArray", "drawArrays", "drawElements", "drawArraysInstanced", "drawElementsInstanced", "enable", "disable", "depthFunc", "depthMask", "blendFunc", "blendFuncSeparate", "blendEquation", "cullFace", "frontFace", "viewport", "scissor", "clearColor", "clearDepth", "clearStencil", "activeTexture", "texParameteri", "texImage2D", "texSubImage2D", "pixelStorei", "colorMask", "stencilFunc", "stencilOp", "stencilMask", "polygonOffset", "__site"].map((t2, e2) => [t2, e2]));
126
+ class ByteWriter {
127
+ constructor() {
128
+ __publicField(this, "buf", new Uint8Array(65536));
129
+ __publicField(this, "len", 0);
130
+ __publicField(this, "view", new DataView(this.buf.buffer));
131
+ }
132
+ ensure(t2) {
133
+ if (this.len + t2 <= this.buf.length) return;
134
+ const e2 = new Uint8Array(Math.max(2 * this.buf.length, this.len + t2));
135
+ e2.set(this.buf.subarray(0, this.len)), this.buf = e2, this.view = new DataView(e2.buffer);
136
+ }
137
+ u8(t2) {
138
+ this.ensure(1), this.buf[this.len++] = 255 & t2;
139
+ }
140
+ varint(t2) {
141
+ let e2 = t2 < 0 ? 2 * -t2 - 1 : 2 * t2;
142
+ for (this.ensure(10); e2 >= 128; ) this.buf[this.len++] = 127 & e2 | 128, e2 = Math.floor(e2 / 128);
143
+ this.buf[this.len++] = e2;
144
+ }
145
+ f64(t2) {
146
+ this.ensure(8), this.view.setFloat64(this.len, t2, true), this.len += 8;
147
+ }
148
+ bytes(t2) {
149
+ this.ensure(t2.length), this.buf.set(t2, this.len), this.len += t2.length;
150
+ }
151
+ take() {
152
+ const t2 = this.buf.slice(0, this.len);
153
+ return this.len = 0, t2;
154
+ }
155
+ get size() {
156
+ return this.len;
157
+ }
158
+ }
159
+ const h = new TextEncoder();
160
+ new TextDecoder();
161
+ class CommandEncoder {
162
+ constructor() {
163
+ __publicField(this, "w", new ByteWriter());
164
+ __publicField(this, "strings", /* @__PURE__ */ new Map());
165
+ __publicField(this, "lastTUs", 0);
166
+ __publicField(this, "ops", 0);
167
+ }
168
+ encode(t2) {
169
+ const e2 = Math.round(1e3 * t2.t);
170
+ e2 !== this.lastTUs && (this.w.u8(c.get("__frame")), this.w.varint(e2 - this.lastTUs), this.lastTUs = e2), t2.sfId && (this.w.u8(c.get("__site")), this.str(t2.sfId));
171
+ const s2 = c.get(t2.op);
172
+ void 0 === s2 ? (this.w.u8(255), this.str(t2.op)) : this.w.u8(t2.setter ? 128 | s2 : s2), this.w.varint(t2.args.length);
173
+ for (const e3 of t2.args) this.arg(e3);
174
+ this.ops++;
175
+ }
176
+ str(t2) {
177
+ const e2 = this.strings.get(t2);
178
+ if (void 0 !== e2) return this.w.u8(3), void this.w.varint(e2);
179
+ const s2 = this.strings.size;
180
+ this.strings.set(t2, s2);
181
+ const a2 = h.encode(t2);
182
+ this.w.u8(2), this.w.varint(a2.length), this.w.bytes(a2);
183
+ }
184
+ arg(t2) {
185
+ if (null !== t2) {
186
+ switch (typeof t2) {
187
+ case "number":
188
+ return void (Number.isInteger(t2) && Math.abs(t2) < 2 ** 30 ? (this.w.u8(1), this.w.varint(t2)) : (this.w.u8(0), this.w.f64(t2)));
189
+ case "string":
190
+ return void this.str(t2);
191
+ case "boolean":
192
+ return void this.w.u8(t2 ? 4 : 5);
193
+ }
194
+ if ("$" in t2) switch (t2.$) {
195
+ case "asset":
196
+ return this.w.u8(7), void this.w.varint(t2.id);
197
+ case "obj":
198
+ return this.w.u8(8), void this.w.varint(t2.id);
199
+ case "imagedata":
200
+ return this.w.u8(10), void this.w.varint(t2.id);
201
+ case "arr":
202
+ this.w.u8(9), this.w.varint(t2.v.length);
203
+ for (const e2 of t2.v) this.w.f64(e2);
204
+ return;
205
+ case "ta":
206
+ return this.w.u8(12), this.w.u8(t2.k), this.w.varint(t2.b.length), void this.w.bytes(t2.b);
207
+ case "unsupported":
208
+ return this.w.u8(11), void this.str(t2.kind);
209
+ }
210
+ this.w.u8(6);
211
+ } else this.w.u8(6);
212
+ }
213
+ takeBatch() {
214
+ return this.ops = 0, this.strings.clear(), this.lastTUs = 0, this.w.take();
215
+ }
216
+ }
217
+ async function deflate(t2) {
218
+ return (async function pipeThrough(t3, e2) {
219
+ const s2 = new Uint8Array(e2.buffer.slice(e2.byteOffset, e2.byteOffset + e2.byteLength)), a2 = new Response(t3.readable).arrayBuffer(), i2 = t3.writable.getWriter();
220
+ return await i2.write(s2), await i2.close(), new Uint8Array(await a2);
221
+ })(new CompressionStream("deflate"), t2);
222
+ }
223
+ const l = /* @__PURE__ */ new WeakMap();
224
+ function pushObjectCall(t2, e2, s2) {
225
+ t2 && (t2.calls.length >= 4096 ? t2.callsCapped = true : t2.calls.push({ method: e2, args: s2 }));
226
+ }
227
+ const d = ["createLinearGradient", "createRadialGradient", "createConicGradient", "createPattern"], u = ["addPath", "arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect", "roundRect"];
228
+ let f = null;
229
+ const p = /* @__PURE__ */ new WeakSet();
230
+ let g = false;
231
+ function installFactoryLoggingOnProto(t2) {
232
+ if (p.has(t2)) return;
233
+ p.add(t2);
234
+ const e2 = t2;
235
+ for (const s2 of d) {
236
+ const a2 = Object.getOwnPropertyDescriptor(t2, s2);
237
+ if (!a2 || "function" != typeof a2.value) continue;
238
+ const i2 = a2.value;
239
+ e2[s2] = function(...t3) {
240
+ const e3 = i2.apply(this, t3);
241
+ return e3 && "object" == typeof e3 && l.set(e3, { factory: s2, args: t3, calls: [] }), e3;
242
+ };
243
+ }
244
+ }
245
+ function installSharedObjectLogging() {
246
+ if (!g) {
247
+ if (g = true, "undefined" != typeof CanvasGradient) {
248
+ const t2 = CanvasGradient.prototype.addColorStop;
249
+ CanvasGradient.prototype.addColorStop = function(...e2) {
250
+ return pushObjectCall(l.get(this), "addColorStop", e2), t2.apply(this, e2);
251
+ };
252
+ }
253
+ if ("undefined" != typeof Path2D && !f) {
254
+ f = Path2D;
255
+ for (const t3 of u) {
256
+ const e2 = Path2D.prototype[t3];
257
+ "function" == typeof e2 && (Path2D.prototype[t3] = function(...s2) {
258
+ return pushObjectCall(l.get(this), t3, s2), e2.apply(this, s2);
259
+ });
260
+ }
261
+ const t2 = f, Wrapped = function(e2) {
262
+ var _a;
263
+ const s2 = void 0 === e2 ? new t2() : new t2(e2);
264
+ return l.set(s2, { factory: "__path2d", args: ["string" == typeof e2 ? e2 : null], calls: e2 instanceof t2 ? [...((_a = l.get(e2)) == null ? void 0 : _a.calls) ?? []] : [] }), s2;
265
+ };
266
+ Wrapped.prototype = t2.prototype, globalThis.Path2D = Wrapped;
267
+ }
268
+ }
269
+ }
270
+ function installEarlyObjectLogging() {
271
+ "undefined" != typeof CanvasRenderingContext2D && installFactoryLoggingOnProto(CanvasRenderingContext2D.prototype), "undefined" != typeof OffscreenCanvasRenderingContext2D && installFactoryLoggingOnProto(OffscreenCanvasRenderingContext2D.prototype), installSharedObjectLogging();
272
+ }
273
+ const m = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];
274
+ function serializeTypedArray(t2) {
275
+ var _a;
276
+ if (t2 instanceof ArrayBuffer) return { $: "ta", k: 1, b: new Uint8Array(t2.slice(0)) };
277
+ const e2 = m.findIndex((e3) => t2 instanceof e3);
278
+ if (e2 < 0) return { $: "unsupported", kind: ((_a = t2.constructor) == null ? void 0 : _a.name) ?? "view" };
279
+ return { $: "ta", k: e2, b: new Uint8Array(t2.buffer.slice(t2.byteOffset, t2.byteOffset + t2.byteLength)) };
280
+ }
281
+ class BufferSink {
282
+ constructor() {
283
+ __publicField(this, "ops", []);
284
+ __publicField(this, "assetEvents", []);
285
+ __publicField(this, "assetData", []);
286
+ __publicField(this, "notes", []);
287
+ }
288
+ onOp(t2) {
289
+ this.ops.push(t2);
290
+ }
291
+ onAssetBytes(t2, e2, s2) {
292
+ this.assetEvents.push({ id: t2, bytes: e2, t: s2 });
293
+ }
294
+ onAssetData(t2, e2) {
295
+ this.assetData.push({ info: t2, payload: e2 });
296
+ }
297
+ note(t2) {
298
+ this.notes.includes(t2) || this.notes.push(t2);
299
+ }
300
+ }
301
+ class DiscardSink {
302
+ constructor(t2) {
303
+ this.onDirty = t2;
304
+ }
305
+ onOp(t2) {
306
+ this.onDirty();
307
+ }
308
+ onAssetBytes(t2, e2, s2) {
309
+ }
310
+ note(t2) {
311
+ }
312
+ }
313
+ const y = { t: 0, op: "", args: [] }, k = new TextEncoder();
314
+ new TextDecoder();
315
+ const w = [83, 70, 67, 49];
316
+ function buildFrame(t2, e2) {
317
+ const s2 = null == e2 ? new Uint8Array(0) : e2 instanceof ArrayBuffer ? new Uint8Array(e2) : e2, a2 = k.encode(JSON.stringify({ ...t2, pLen: s2.byteLength })), i2 = new ArrayBuffer(8 + a2.length + s2.byteLength), r2 = new Uint8Array(i2);
318
+ return r2[0] = w[0], r2[1] = w[1], r2[2] = w[2], r2[3] = w[3], new DataView(i2).setUint32(4, a2.length, true), r2.set(a2, 8), r2.set(s2, 8 + a2.length), i2;
319
+ }
320
+ function bytesToBase64(t2) {
321
+ const e2 = t2 instanceof Uint8Array ? t2 : new Uint8Array(t2);
322
+ let s2 = "";
323
+ for (let t3 = 0; t3 < e2.length; t3 += 32768) s2 += String.fromCharCode.apply(null, e2.subarray(t3, t3 + 32768));
324
+ return btoa(s2);
325
+ }
326
+ const b = ["fillStyle", "strokeStyle", "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap", "lineJoin", "miterLimit", "lineDashOffset", "font", "textAlign", "textBaseline", "direction", "shadowBlur", "shadowColor", "shadowOffsetX", "shadowOffsetY", "imageSmoothingEnabled", "imageSmoothingQuality", "filter", "letterSpacing", "wordSpacing"];
327
+ let x = 1, S = 1;
328
+ const C = /* @__PURE__ */ new WeakSet();
329
+ let v = false;
330
+ function notePreAttachMaskUsed(t2) {
331
+ t2 ? C.add(t2) : v = true;
332
+ }
333
+ function wasPreAttachMaskUsed(t2) {
334
+ return !!v || !!t2 && C.has(t2);
335
+ }
336
+ const M = /* @__PURE__ */ new Set(["beginPath", "closePath", "moveTo", "lineTo", "rect", "roundRect", "arc", "arcTo", "ellipse", "bezierCurveTo", "quadraticCurveTo"]), T = /* @__PURE__ */ new Set(["fill", "stroke", "fillRect", "strokeRect", "drawImage", "putImageData"]), R = /* @__PURE__ */ new Set(["setTransform", "transform", "translate", "scale", "rotate", "resetTransform"]);
337
+ const A = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakSet();
338
+ function ignore2DContext(t2) {
339
+ D.add(t2);
340
+ }
341
+ let I = null;
342
+ function setUntracked2DContextNotifier(t2) {
343
+ I = t2;
344
+ }
345
+ function recorderForContext(t2) {
346
+ if (t2) return A.get(t2) ?? P.get(t2);
347
+ }
348
+ let O = null;
349
+ function setContextCreatedNotifier(t2) {
350
+ O = t2;
351
+ }
352
+ let B = null;
353
+ const P = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new WeakMap();
354
+ function getContextInfo(t2) {
355
+ return L.get(t2);
356
+ }
357
+ function setAutoAttach(t2) {
358
+ B = t2, t2 && P.clear();
359
+ }
360
+ function releaseAutoRecorder(t2) {
361
+ const e2 = P.get(t2);
362
+ e2 && !e2.bound && (A.delete(e2.rawCtx), P.delete(t2));
363
+ }
364
+ function pruneUnboundRecorders() {
365
+ for (const [t2, e2] of P) e2.bound || (A.delete(e2.rawCtx), P.delete(t2));
366
+ }
367
+ class ContextRecorder {
368
+ constructor(t2, e2, s2, a2, i2, r2) {
369
+ __publicField(this, "assets", /* @__PURE__ */ new Map());
370
+ __publicField(this, "assetBySource", /* @__PURE__ */ new WeakMap());
371
+ __publicField(this, "pendingEncodes", /* @__PURE__ */ new Set());
372
+ __publicField(this, "props", {});
373
+ __publicField(this, "stack", []);
374
+ __publicField(this, "cpuMs", 0);
375
+ __publicField(this, "bound", false);
376
+ __publicField(this, "retainAssets");
377
+ __publicField(this, "pendingSiteId");
378
+ __publicField(this, "textRedactor");
379
+ __publicField(this, "maskDepth", 0);
380
+ __publicField(this, "hasMaskedDraws", false);
381
+ __publicField(this, "redactStyle", r);
382
+ __publicField(this, "textOnlyMask", false);
383
+ __publicField(this, "maskedRegions", []);
384
+ __publicField(this, "keyframeUnsafe", false);
385
+ __publicField(this, "maskPathBounds", null);
386
+ __publicField(this, "objRefs", /* @__PURE__ */ new WeakMap());
387
+ this.ctx = t2, this.sink = e2, this.now = s2, this.assetMode = a2, this.encodeImage = i2, this.retainAssets = false !== (r2 == null ? void 0 : r2.retainAssets);
388
+ }
389
+ get rawCtx() {
390
+ return this.ctx;
391
+ }
392
+ swapSink(t2) {
393
+ var _a;
394
+ const e2 = this.sink;
395
+ if (this.sink = t2, this.bound = true, e2 instanceof BufferSink) {
396
+ for (const s2 of e2.ops) t2.onOp(s2);
397
+ for (const s2 of e2.assetEvents) t2.onAssetBytes(s2.id, s2.bytes, s2.t);
398
+ for (const s2 of e2.assetData) (_a = t2.onAssetData) == null ? void 0 : _a.call(t2, s2.info, s2.payload);
399
+ for (const s2 of e2.notes) t2.note(s2);
400
+ }
401
+ }
402
+ addAsset(t2, e2) {
403
+ if (this.assets.set(t2, e2), !this.retainAssets && this.assets.size > 2048) {
404
+ const t3 = this.assets.size - 2048;
405
+ let e3 = 0;
406
+ for (const s2 of this.assets.keys()) {
407
+ if (e3 >= t3) break;
408
+ this.assets.delete(s2), e3++;
409
+ }
410
+ }
411
+ }
412
+ takePendingSiteId() {
413
+ const t2 = this.pendingSiteId;
414
+ return this.pendingSiteId = void 0, t2;
415
+ }
416
+ recordCall(t2, e2) {
417
+ if (this.maskDepth > 0) return this.maskCall(t2, e2), void (this.pendingSiteId = void 0);
418
+ if (this.sink instanceof DiscardSink) return this.sink.onOp(y), void (this.pendingSiteId = void 0);
419
+ "clearRect" === t2 && this.maskedRegions.length > 0 && this.clipRegionsToClear(e2);
420
+ const s2 = performance.now(), a2 = this.now();
421
+ if (void 0 !== this.textRedactor && ("fillText" === t2 || "strokeText" === t2)) {
422
+ const t3 = e2[0];
423
+ if ("string" == typeof t3) {
424
+ const a3 = this.textRedactor(t3);
425
+ if (a3 !== t3) {
426
+ if (this.pushMaskRegion(this.textRegionFor(t3, e2)), "bar" === this.redactStyle.text) return this.emitRedactionBlock(this.textLocalRect(t3, e2)), void (this.cpuMs += performance.now() - s2);
427
+ (e2 = e2.slice())[0] = a3;
428
+ }
429
+ }
430
+ }
431
+ if ("save" === t2) this.stack.push({ props: { ...this.props }, transform: this.readTransform() });
432
+ else if ("restore" === t2) {
433
+ const t3 = this.stack.pop();
434
+ t3 && (this.props = t3.props);
435
+ }
436
+ const i2 = this.takePendingSiteId(), r2 = { t: a2, op: t2, args: this.serializeArgs(e2, a2) };
437
+ i2 && (r2.sfId = i2), this.sink.onOp(r2), this.cpuMs += performance.now() - s2;
438
+ }
439
+ serializeArgs(t2, e2) {
440
+ const s2 = t2.length, a2 = new Array(s2);
441
+ for (let i2 = 0; i2 < s2; i2++) {
442
+ const s3 = t2[i2];
443
+ switch (typeof s3) {
444
+ case "number":
445
+ a2[i2] = Number.isFinite(s3) ? s3 : 0;
446
+ break;
447
+ case "string":
448
+ case "boolean":
449
+ a2[i2] = s3;
450
+ break;
451
+ case "undefined":
452
+ a2[i2] = null;
453
+ break;
454
+ default:
455
+ a2[i2] = this.serializeArg(s3, e2);
456
+ }
457
+ }
458
+ return a2;
459
+ }
460
+ recordSet(t2, e2) {
461
+ if (this.maskDepth > 0 && !this.textOnlyMask) return this.hasMaskedDraws = true, void (this.pendingSiteId = void 0);
462
+ if (this.maskDepth > 0 && (this.hasMaskedDraws = true), this.sink instanceof DiscardSink) return this.sink.onOp(y), void (this.pendingSiteId = void 0);
463
+ const s2 = performance.now(), a2 = this.now(), i2 = this.serializeArg(e2, a2);
464
+ this.props[t2] = i2;
465
+ const r2 = this.takePendingSiteId(), o2 = { t: a2, op: t2, args: [i2], setter: true };
466
+ r2 && (o2.sfId = r2), this.sink.onOp(o2), this.cpuMs += performance.now() - s2;
467
+ }
468
+ maskCall(t2, e2) {
469
+ if (this.hasMaskedDraws = true, this.sink instanceof DiscardSink) return void this.sink.onOp(y);
470
+ const s2 = this.redactStyle, a2 = "fillText" === t2 || "strokeText" === t2;
471
+ if (!this.textOnlyMask || a2) if ("save" === t2 || "restore" === t2 || R.has(t2)) this.recordPassthrough(t2, e2);
472
+ else {
473
+ if (a2) {
474
+ const a3 = e2[0];
475
+ if ("string" != typeof a3) return;
476
+ if (this.pushMaskRegion(this.textRegionFor(a3, e2)), "asterisks" === s2.text) {
477
+ const s3 = e2.slice();
478
+ s3[0] = maskAllText(a3), this.emitSynthCall(t2, s3);
479
+ } else this.emitRedactionBlock(this.textLocalRect(a3, e2));
480
+ return;
481
+ }
482
+ if (M.has(t2)) return this.updatePathBounds(t2, e2), void ("color" === s2.shape && this.emitSynthCall(t2, e2));
483
+ if (T.has(t2)) {
484
+ this.pushMaskRegion(this.shapeRegion(t2, e2));
485
+ if (!("remove" === s2.shape || "putImageData" === t2)) if ("color" !== s2.shape || "fill" !== t2 && "stroke" !== t2 && "fillRect" !== t2 && "strokeRect" !== t2) this.emitRedactionBlock(this.shapeLocalRect(t2, e2));
486
+ else {
487
+ const s3 = "stroke" === t2 || "strokeRect" === t2 ? "strokeStyle" : "fillStyle";
488
+ this.emitSynthCall("save", []), this.emitSynthSetter(s3, o), this.emitSynthCall(t2, "fill" === t2 || "stroke" === t2 ? [] : e2), this.emitSynthCall("restore", []);
489
+ }
490
+ return void ("fill" !== t2 && "stroke" !== t2 || (this.maskPathBounds = null));
491
+ }
492
+ }
493
+ else this.recordPassthrough(t2, e2);
494
+ }
495
+ recordPassthrough(t2, e2) {
496
+ if (this.sink instanceof DiscardSink) return void this.sink.onOp(y);
497
+ const s2 = this.now();
498
+ if ("save" === t2) this.stack.push({ props: { ...this.props }, transform: this.readTransform() });
499
+ else if ("restore" === t2) {
500
+ const t3 = this.stack.pop();
501
+ t3 && (this.props = t3.props);
502
+ }
503
+ this.sink.onOp({ t: s2, op: t2, args: this.serializeArgs(e2, s2) });
504
+ }
505
+ pushRegion(t2) {
506
+ t2 && t2.w > 0 && t2.h > 0 && (this.maskedRegions.push(t2), this.maskedRegions.length > 4096 && this.coalesceRegions());
507
+ }
508
+ coalesceRegions() {
509
+ const t2 = this.canvasSize();
510
+ if (!t2) {
511
+ const t3 = (function unionRegion(t4) {
512
+ if (0 === t4.length) return null;
513
+ let e3 = 1 / 0, s3 = 1 / 0, a3 = -1 / 0, i3 = -1 / 0;
514
+ for (const r3 of t4) r3.x < e3 && (e3 = r3.x), r3.y < s3 && (s3 = r3.y), r3.x + r3.w > a3 && (a3 = r3.x + r3.w), r3.y + r3.h > i3 && (i3 = r3.y + r3.h);
515
+ return { x: e3, y: s3, w: a3 - e3, h: i3 - s3 };
516
+ })(this.maskedRegions);
517
+ return this.maskedRegions.length = 0, void (t3 && this.maskedRegions.push(t3));
518
+ }
519
+ let e2 = 64;
520
+ const fits = () => Math.ceil(t2.w / e2) * Math.ceil(t2.h / e2) <= 4096;
521
+ for (; !fits(); ) e2 *= 2;
522
+ const s2 = Math.max(1, Math.ceil(t2.w / e2)), a2 = s2 - 1, i2 = Math.max(0, Math.ceil(t2.h / e2) - 1), r2 = /* @__PURE__ */ new Map();
523
+ for (const o2 of this.maskedRegions) {
524
+ const c2 = Math.min(a2, Math.max(0, Math.floor(o2.x / e2))), h2 = Math.min(a2, Math.max(c2, Math.floor((o2.x + o2.w - 1) / e2))), l2 = Math.min(i2, Math.max(0, Math.floor(o2.y / e2))), d2 = Math.min(i2, Math.max(l2, Math.floor((o2.y + o2.h - 1) / e2)));
525
+ for (let a3 = l2; a3 <= d2; a3++) for (let i3 = c2; i3 <= h2; i3++) {
526
+ const o3 = a3 * s2 + i3;
527
+ if (!r2.has(o3)) {
528
+ const s3 = i3 * e2, c3 = a3 * e2;
529
+ r2.set(o3, { x: s3, y: c3, w: Math.min(e2, t2.w - s3), h: Math.min(e2, t2.h - c3) });
530
+ }
531
+ }
532
+ }
533
+ this.maskedRegions.length = 0;
534
+ for (const t3 of r2.values()) this.maskedRegions.push(t3);
535
+ }
536
+ pushMaskRegion(t2) {
537
+ t2 && t2.w > 0 && t2.h > 0 ? this.pushRegion(t2) : this.keyframeUnsafe = true;
538
+ }
539
+ resetMaskedRegions() {
540
+ this.maskedRegions.length = 0, this.maskPathBounds = null, this.keyframeUnsafe = false;
541
+ }
542
+ clipRegionsToClear(t2) {
543
+ if (0 === this.maskedRegions.length) return;
544
+ const e2 = this.getMat();
545
+ if (!e2) return;
546
+ if (!(0 === e2.b && 0 === e2.c || 0 === e2.a && 0 === e2.d)) return;
547
+ const n = (t3) => Number(t3) || 0, s2 = n(t2[0]), a2 = n(t2[1]), i2 = transformedBox(s2, a2, s2 + n(t2[2]), a2 + n(t2[3]), e2, 0);
548
+ if (!i2) return;
549
+ const r2 = i2.x + i2.w, o2 = i2.y + i2.h, c2 = this.maskedRegions.filter((t3) => !(t3.x >= i2.x && t3.y >= i2.y && t3.x + t3.w <= r2 && t3.y + t3.h <= o2));
550
+ if (c2.length !== this.maskedRegions.length) {
551
+ this.maskedRegions.length = 0;
552
+ for (const t3 of c2) this.maskedRegions.push(t3);
553
+ }
554
+ }
555
+ emitSynthCall(t2, e2) {
556
+ const s2 = this.now();
557
+ this.sink.onOp({ t: s2, op: t2, args: this.serializeArgs(e2, s2) });
558
+ }
559
+ emitSynthSetter(t2, e2) {
560
+ const s2 = this.now();
561
+ this.sink.onOp({ t: s2, op: t2, args: [e2], setter: true });
562
+ }
563
+ emitRedactionBlock(t2) {
564
+ t2 && 0 !== t2.w && 0 !== t2.h && (this.emitSynthCall("save", []), this.emitSynthSetter("fillStyle", o), this.emitSynthCall("fillRect", [t2.x, t2.y, t2.w, t2.h]), this.emitSynthCall("restore", []));
565
+ }
566
+ updatePathBounds(t2, e2) {
567
+ if ("beginPath" === t2) return void (this.maskPathBounds = null);
568
+ const n = (t3) => Number(t3) || 0, ext = (t3, e3) => {
569
+ if (!Number.isFinite(t3) || !Number.isFinite(e3)) return;
570
+ const s2 = this.maskPathBounds ?? { minX: t3, minY: e3, maxX: t3, maxY: e3 };
571
+ s2.minX = Math.min(s2.minX, t3), s2.minY = Math.min(s2.minY, e3), s2.maxX = Math.max(s2.maxX, t3), s2.maxY = Math.max(s2.maxY, e3), this.maskPathBounds = s2;
572
+ };
573
+ switch (t2) {
574
+ case "moveTo":
575
+ case "lineTo":
576
+ ext(n(e2[0]), n(e2[1]));
577
+ break;
578
+ case "rect":
579
+ case "roundRect":
580
+ ext(n(e2[0]), n(e2[1])), ext(n(e2[0]) + n(e2[2]), n(e2[1]) + n(e2[3]));
581
+ break;
582
+ case "arc": {
583
+ const t3 = n(e2[2]);
584
+ ext(n(e2[0]) - t3, n(e2[1]) - t3), ext(n(e2[0]) + t3, n(e2[1]) + t3);
585
+ break;
586
+ }
587
+ case "ellipse": {
588
+ const t3 = n(e2[2]), s2 = n(e2[3]);
589
+ ext(n(e2[0]) - t3, n(e2[1]) - s2), ext(n(e2[0]) + t3, n(e2[1]) + s2);
590
+ break;
591
+ }
592
+ case "arcTo":
593
+ case "quadraticCurveTo":
594
+ ext(n(e2[0]), n(e2[1])), ext(n(e2[2]), n(e2[3]));
595
+ break;
596
+ case "bezierCurveTo":
597
+ ext(n(e2[0]), n(e2[1])), ext(n(e2[2]), n(e2[3])), ext(n(e2[4]), n(e2[5]));
598
+ }
599
+ }
600
+ shapeLocalRect(t2, e2) {
601
+ const n = (t3) => Number(t3) || 0;
602
+ if ("fillRect" === t2 || "strokeRect" === t2) return { x: n(e2[0]), y: n(e2[1]), w: n(e2[2]), h: n(e2[3]) };
603
+ if ("fill" === t2 || "stroke" === t2) {
604
+ const t3 = this.maskPathBounds;
605
+ return t3 ? { x: t3.minX, y: t3.minY, w: t3.maxX - t3.minX, h: t3.maxY - t3.minY } : null;
606
+ }
607
+ return "drawImage" === t2 ? this.drawImageDest(e2) : null;
608
+ }
609
+ shapeRegion(t2, e2) {
610
+ const n = (t3) => Number(t3) || 0;
611
+ if ("putImageData" === t2) {
612
+ const t3 = e2[0], s3 = n(t3 == null ? void 0 : t3.width), a3 = n(t3 == null ? void 0 : t3.height);
613
+ return s3 > 0 && a3 > 0 ? { x: n(e2[1]), y: n(e2[2]), w: s3, h: a3 } : null;
614
+ }
615
+ const s2 = this.getMat(), a2 = this.shapeLocalRect(t2, e2);
616
+ return s2 && a2 ? (function rectRegion(t3, e3, s3, a3, i2) {
617
+ return transformedBox(t3, e3, t3 + s3, e3 + a3, i2);
618
+ })(a2.x, a2.y, a2.w, a2.h, s2) : null;
619
+ }
620
+ drawImageDest(t2) {
621
+ const n = (t3) => Number(t3) || 0;
622
+ if (t2.length >= 9) return { x: n(t2[5]), y: n(t2[6]), w: n(t2[7]), h: n(t2[8]) };
623
+ if (t2.length >= 5) return { x: n(t2[1]), y: n(t2[2]), w: n(t2[3]), h: n(t2[4]) };
624
+ if (t2.length >= 3) {
625
+ const e2 = t2[0];
626
+ return { x: n(t2[1]), y: n(t2[2]), w: n(e2 == null ? void 0 : e2.width), h: n(e2 == null ? void 0 : e2.height) };
627
+ }
628
+ return null;
629
+ }
630
+ textRegionFor(t2, e2) {
631
+ const s2 = this.getMat();
632
+ if (!s2) return null;
633
+ const a2 = Math.max(Math.hypot(s2.a, s2.b), Math.hypot(s2.c, s2.d)) || 1, i2 = this.fontSizePx(), r2 = Math.max(256, 0.5 * i2 * a2), o2 = Math.min(Math.max(2, 0.15 * i2 * a2), r2);
634
+ return (function textRegion(t3, e3, s3 = 1) {
635
+ const a3 = textLocalBox(t3);
636
+ return transformedBox(a3.x0, a3.y0, a3.x1, a3.y1, e3, s3);
637
+ })(this.textMetrics(t2, e2), s2, o2);
638
+ }
639
+ textLocalRect(t2, e2) {
640
+ const s2 = textLocalBox(this.textMetrics(t2, e2));
641
+ return { x: s2.x0, y: s2.y0, w: s2.x1 - s2.x0, h: s2.y1 - s2.y0 };
642
+ }
643
+ textMetrics(t2, e2) {
644
+ const s2 = Number(e2[1]) || 0, a2 = Number(e2[2]) || 0, i2 = this.ctx;
645
+ let r2, o2, c2 = NaN, h2 = NaN, l2 = NaN;
646
+ if ("function" == typeof i2.measureText) try {
647
+ const e3 = i2.measureText(t2);
648
+ c2 = e3.width, h2 = e3.actualBoundingBoxAscent, l2 = e3.actualBoundingBoxDescent, r2 = i2.textAlign, o2 = i2.textBaseline;
649
+ } catch {
650
+ }
651
+ const d2 = this.fontSizePx();
652
+ return Number.isFinite(c2) || (c2 = t2.length * d2 * 0.6), (!Number.isFinite(h2) || h2 <= 0) && (h2 = 0.8 * d2), (!Number.isFinite(l2) || l2 < 0) && (l2 = 0.2 * d2), void 0 === r2 && "string" == typeof this.props.textAlign && (r2 = this.props.textAlign), void 0 === o2 && "string" == typeof this.props.textBaseline && (o2 = this.props.textBaseline), { width: c2, ascent: h2, descent: l2, x: s2, y: a2, align: r2, baseline: o2 };
653
+ }
654
+ fontSizePx() {
655
+ const t2 = this.props.font;
656
+ if ("string" == typeof t2) {
657
+ const e2 = t2.match(/(\d+(?:\.\d+)?)px/);
658
+ if (e2) return parseFloat(e2[1]);
659
+ }
660
+ return 12;
661
+ }
662
+ canvasSize() {
663
+ const t2 = this.ctx.canvas;
664
+ return t2 && Number(t2.width) > 0 && Number(t2.height) > 0 ? { w: Number(t2.width), h: Number(t2.height) } : null;
665
+ }
666
+ getMat() {
667
+ try {
668
+ const t2 = this.ctx.getTransform();
669
+ return { a: t2.a, b: t2.b, c: t2.c, d: t2.d, e: t2.e, f: t2.f };
670
+ } catch {
671
+ return null;
672
+ }
673
+ }
674
+ snapshotState() {
675
+ return { stack: this.stack.map((t2) => ({ props: { ...t2.props }, transform: [...t2.transform] })), current: { props: { ...this.props }, transform: this.readTransform() } };
676
+ }
677
+ async settle() {
678
+ for (; this.pendingEncodes.size; ) await Promise.all([...this.pendingEncodes]);
679
+ }
680
+ pendingEncodeCount() {
681
+ return this.pendingEncodes.size;
682
+ }
683
+ trackEncode(t2) {
684
+ this.pendingEncodes.add(t2), t2.then(() => {
685
+ }, () => {
686
+ }).finally(() => this.pendingEncodes.delete(t2));
687
+ }
688
+ readTransform() {
689
+ const t2 = this.ctx.getTransform();
690
+ return [t2.a, t2.b, t2.c, t2.d, t2.e, t2.f];
691
+ }
692
+ serializeArg(t2, e2) {
693
+ var _a;
694
+ if (null === t2) return null;
695
+ switch (typeof t2) {
696
+ case "number":
697
+ return Number.isFinite(t2) ? t2 : 0;
698
+ case "string":
699
+ case "boolean":
700
+ return t2;
701
+ case "undefined":
702
+ return null;
703
+ case "object":
704
+ break;
705
+ default:
706
+ return { $: "unsupported", kind: typeof t2 };
707
+ }
708
+ const s2 = t2;
709
+ if (l.has(s2)) return this.serializeFactoryObject(s2, e2);
710
+ const a2 = /* @__PURE__ */ (function getNativePath2D() {
711
+ return f;
712
+ })();
713
+ return a2 && s2 instanceof a2 ? (this.sink.note("Path2D created before instrumentation — not serialized"), { $: "unsupported", kind: "Path2D" }) : Array.isArray(s2) ? { $: "arr", v: s2.map((t3) => Number(t3) || 0) } : s2 instanceof DOMMatrix || s2 instanceof DOMMatrixReadOnly ? { $: "arr", v: [s2.a, s2.b, s2.c, s2.d, s2.e, s2.f] } : s2 instanceof ImageData ? this.captureImageData(s2, e2) : (function isImageSource(t3) {
714
+ return "undefined" != typeof HTMLImageElement && t3 instanceof HTMLImageElement || "undefined" != typeof HTMLCanvasElement && t3 instanceof HTMLCanvasElement || "undefined" != typeof HTMLVideoElement && t3 instanceof HTMLVideoElement || "undefined" != typeof ImageBitmap && t3 instanceof ImageBitmap || "undefined" != typeof OffscreenCanvas && t3 instanceof OffscreenCanvas;
715
+ })(s2) ? this.captureImageSource(s2, e2) : { $: "unsupported", kind: ((_a = s2.constructor) == null ? void 0 : _a.name) ?? "object" };
716
+ }
717
+ serializeFactoryObject(t2, e2) {
718
+ const s2 = l.get(t2);
719
+ let a2 = this.objRefs.get(t2);
720
+ a2 || (a2 = { id: S++, emittedCalls: 0 }, this.objRefs.set(t2, a2), this.sink.onOp({ t: e2, op: "__create", create: true, args: [s2.factory, a2.id, ...s2.args.map((t3) => this.serializeArg(t3, e2))] }));
721
+ for (let t3 = a2.emittedCalls; t3 < s2.calls.length; t3++) {
722
+ const i2 = s2.calls[t3];
723
+ this.sink.onOp({ t: e2, op: "__objcall", objcall: true, args: [a2.id, i2.method, ...i2.args.map((t4) => this.serializeArg(t4, e2))] });
724
+ }
725
+ return a2.emittedCalls = s2.calls.length, { $: "obj", id: a2.id };
726
+ }
727
+ captureImageData(t2, e2) {
728
+ const s2 = x++, a2 = new ImageData(new Uint8ClampedArray(t2.data), t2.width, t2.height), i2 = { id: s2, kind: "imagedata", t: e2, bytes: 0, w: t2.width, h: t2.height };
729
+ return this.retainAssets && (i2.imageData = a2), this.addAsset(s2, i2), this.trackEncode(deflate(new Uint8Array(a2.data.buffer, a2.data.byteOffset, a2.data.byteLength)).then((a3) => {
730
+ var _a, _b;
731
+ i2.bytes = a3.length, this.sink.onAssetBytes(s2, a3.length, e2), (_b = (_a = this.sink).onAssetData) == null ? void 0 : _b.call(_a, { id: s2, format: "imagedata", w: t2.width, h: t2.height, t: e2 }, a3);
732
+ }).catch((t3) => this.sink.note(`imagedata deflate failed: ${t3.message}`))), { $: "imagedata", id: s2 };
733
+ }
734
+ captureImageSource(t2, e2) {
735
+ var _a, _b, _c, _d;
736
+ const s2 = "undefined" != typeof HTMLVideoElement && t2 instanceof HTMLVideoElement, a2 = s2 || "undefined" != typeof HTMLCanvasElement && t2 instanceof HTMLCanvasElement || "undefined" != typeof OffscreenCanvas && t2 instanceof OffscreenCanvas;
737
+ if (s2 && ((_b = (_a = this.sink).onVideoSource) == null ? void 0 : _b.call(_a, e2)), !a2 && this.assetBySource.has(t2)) return { $: "asset", id: this.assetBySource.get(t2) };
738
+ const i2 = x++;
739
+ a2 || this.assetBySource.set(t2, i2);
740
+ const r2 = { id: i2, kind: "image", t: e2, bytes: 0 };
741
+ if (this.addAsset(i2, r2), "dataurl" === this.assetMode) {
742
+ const s3 = performance.now();
743
+ try {
744
+ const { w: s4, h: a3 } = (function sourceSize(t3) {
745
+ if (t3 instanceof HTMLVideoElement) return { w: t3.videoWidth || 1, h: t3.videoHeight || 1 };
746
+ if (t3 instanceof HTMLImageElement) return { w: t3.naturalWidth || 1, h: t3.naturalHeight || 1 };
747
+ const e3 = t3;
748
+ return { w: Number(e3.width) || 1, h: Number(e3.height) || 1 };
749
+ })(t2), o2 = document.createElement("canvas");
750
+ o2.width = s4, o2.height = a3;
751
+ const c2 = o2.getContext("2d");
752
+ D.add(c2), c2.drawImage(t2, 0, 0);
753
+ const h2 = o2.toDataURL("image/png");
754
+ r2.bytes = h2.length, r2.w = s4, r2.h = a3, this.sink.onAssetBytes(i2, h2.length, e2), this.retainAssets && this.trackEncode(createImageBitmap(o2).then((t3) => {
755
+ r2.bitmap = t3;
756
+ }));
757
+ } catch (t3) {
758
+ this.sink.note(`asset capture failed: ${t3.message}`), isTaintError(t3) && ((_d = (_c = this.sink).onTaint) == null ? void 0 : _d.call(_c, e2));
759
+ }
760
+ this.cpuMs += performance.now() - s3;
761
+ } else {
762
+ const s3 = performance.now();
763
+ this.trackEncode(createImageBitmap(t2).then(async (t3) => {
764
+ var _a2, _b2;
765
+ const s4 = t3.width, a3 = t3.height;
766
+ let o2 = t3;
767
+ this.retainAssets && (r2.bitmap = t3, o2 = await createImageBitmap(t3));
768
+ const c2 = await this.encodeImage(o2);
769
+ r2.bytes = c2.size, r2.w = s4, r2.h = a3, this.sink.onAssetBytes(i2, c2.size, e2), c2.bytes && ((_b2 = (_a2 = this.sink).onAssetData) == null ? void 0 : _b2.call(_a2, { id: i2, format: "webp", w: s4, h: a3, t: e2 }, new Uint8Array(c2.bytes)));
770
+ }).catch((t3) => {
771
+ var _a2, _b2;
772
+ this.sink.note(`asset encode failed: ${t3.message}`), isTaintError(t3) && ((_b2 = (_a2 = this.sink).onTaint) == null ? void 0 : _b2.call(_a2, e2));
773
+ })), this.cpuMs += performance.now() - s3;
774
+ }
775
+ return { $: "asset", id: i2 };
776
+ }
777
+ }
778
+ function isTaintError(t2) {
779
+ if (!t2 || "object" != typeof t2) return false;
780
+ if ("SecurityError" === t2.name) return true;
781
+ const e2 = t2.message;
782
+ return "string" == typeof e2 && /tainted|cross-origin|insecure/i.test(e2);
783
+ }
784
+ let E = false;
785
+ function patch2DProto(t2) {
786
+ const e2 = t2;
787
+ installFactoryLoggingOnProto(t2), installSharedObjectLogging();
788
+ for (const s2 of Object.getOwnPropertyNames(t2)) {
789
+ const a2 = Object.getOwnPropertyDescriptor(t2, s2);
790
+ if (a2) {
791
+ if ("function" == typeof a2.value && "constructor" !== s2) {
792
+ const t3 = a2.value;
793
+ d.includes(s2) || "getImageData" === s2 || "getTransform" === s2 || "isPointInPath" === s2 || "isPointInStroke" === s2 || "measureText" === s2 || "getLineDash" === s2 || "getContextAttributes" === s2 || "createImageData" === s2 || (e2[s2] = function(...e3) {
794
+ const a3 = A.get(this);
795
+ return a3 ? a3.recordCall(s2, e3) : I && !D.has(this) && I(this), t3.apply(this, e3);
796
+ });
797
+ } else if (a2.set && b.includes(s2)) {
798
+ const { get: e3, set: i2 } = a2;
799
+ Object.defineProperty(t2, s2, { configurable: true, get: e3, set(t3) {
800
+ const e4 = A.get(this);
801
+ e4 ? e4.recordSet(s2, t3) : I && !D.has(this) && I(this), i2.call(this, t3);
802
+ } });
803
+ }
804
+ }
805
+ }
806
+ }
807
+ function installCommandHooks() {
808
+ if (E) return;
809
+ E = true, patch2DProto(CanvasRenderingContext2D.prototype);
810
+ const t2 = HTMLCanvasElement.prototype.getContext;
811
+ HTMLCanvasElement.prototype.getContext = function(e2, s2) {
812
+ const a2 = t2.call(this, e2, s2);
813
+ if (a2 && !L.has(this) && L.set(this, { type: e2, attrs: s2 ?? void 0 }), "2d" === e2 && a2 && B && !A.has(a2)) {
814
+ const t3 = new ContextRecorder(a2, new BufferSink(), B.now, B.assetMode, B.encodeImage, { retainAssets: B.retainAssets });
815
+ A.set(a2, t3), P.set(this, t3);
816
+ }
817
+ return a2 && O && O(this, e2), a2;
818
+ };
819
+ }
820
+ function attachRecorderToContext(t2, e2, s2, a2, i2, r2) {
821
+ const o2 = new ContextRecorder(t2, e2, s2, a2, i2, r2);
822
+ return o2.bound = true, A.set(t2, o2), o2;
823
+ }
824
+ function attachRecorder(t2, e2, s2, a2, i2, r2) {
825
+ const o2 = P.get(t2);
826
+ if (o2) return o2.swapSink(e2), o2;
827
+ let c2 = null;
828
+ try {
829
+ c2 = t2.getContext("2d");
830
+ } catch {
831
+ return null;
832
+ }
833
+ if (!c2) return null;
834
+ const h2 = new ContextRecorder(c2, e2, s2, a2, i2, r2);
835
+ return h2.bound = true, A.set(c2, h2), h2;
836
+ }
837
+ function detachRecorderFromContext(t2) {
838
+ A.delete(t2);
839
+ }
840
+ function noteCtxPendingSiteId(t2, e2) {
841
+ const s2 = A.get(t2);
842
+ return !!s2 && (s2.pendingSiteId = e2, true);
843
+ }
844
+ export {
845
+ classifyCanvasPrivacy as A,
846
+ BufferSink as B,
847
+ CommandEncoder as C,
848
+ DiscardSink as D,
849
+ redactCanvasText as E,
850
+ releaseAutoRecorder as F,
851
+ getContextInfo as G,
852
+ bytesToBase64 as H,
853
+ wasPreAttachMaskUsed as I,
854
+ suppressReason as J,
855
+ buildFrame as K,
856
+ setContextCreatedNotifier as L,
857
+ setUntracked2DContextNotifier as M,
858
+ o as R,
859
+ m as T,
860
+ attachRecorderToContext as a,
861
+ buildMaskInputFn as b,
862
+ redactCreditCard as c,
863
+ deflate as d,
864
+ looksLikeSsn as e,
865
+ redactSsn as f,
866
+ redactDob as g,
867
+ recorderForContext as h,
868
+ resolveRedactStyle as i,
869
+ installEarlyObjectLogging as j,
870
+ ignore2DContext as k,
871
+ looksLikeCreditCard as l,
872
+ makeMaskTextFn as m,
873
+ notePreAttachMaskUsed as n,
874
+ isTaintError as o,
875
+ patch2DProto as p,
876
+ y as q,
877
+ redactSensitiveContent as r,
878
+ serializeTypedArray as s,
879
+ r as t,
880
+ installCommandHooks as u,
881
+ setAutoAttach as v,
882
+ noteCtxPendingSiteId as w,
883
+ pruneUnboundRecorders as x,
884
+ detachRecorderFromContext as y,
885
+ attachRecorder as z
886
+ };