web-annotation-renderer 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -33
- package/dist/index.js.map +1 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.cjs.map +1 -1
- package/dist/index10.js +154 -119
- package/dist/index10.js.map +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +87 -87
- package/dist/index12.js.map +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +23 -117
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +53 -103
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +22 -57
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +113 -136
- package/dist/index18.js.map +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.cjs.map +1 -1
- package/dist/index19.js +101 -35
- package/dist/index19.js.map +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.cjs.map +1 -1
- package/dist/index20.js +58 -36
- package/dist/index20.js.map +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +140 -37
- package/dist/index21.js.map +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.cjs.map +1 -1
- package/dist/index22.js +37 -21
- package/dist/index22.js.map +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.cjs.map +1 -1
- package/dist/index23.js +37 -5
- package/dist/index23.js.map +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.cjs.map +1 -1
- package/dist/index24.js +37 -4
- package/dist/index24.js.map +1 -1
- package/dist/index25.cjs +2 -0
- package/dist/index25.cjs.map +1 -0
- package/dist/index25.js +43 -0
- package/dist/index25.js.map +1 -0
- package/dist/index26.cjs +2 -0
- package/dist/index26.cjs.map +1 -0
- package/dist/index26.js +8 -0
- package/dist/index26.js.map +1 -0
- package/dist/index27.cjs +2 -0
- package/dist/index27.cjs.map +1 -0
- package/dist/index27.js +8 -0
- package/dist/index27.js.map +1 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.cjs.map +1 -1
- package/dist/index5.js +57 -36
- package/dist/index5.js.map +1 -1
- package/package.json +1 -1
package/dist/index19.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index19.cjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index19.cjs","sources":["../src/pen/StrokeDrawer.js"],"sourcesContent":["/**\n * StrokeDrawer - Low-level canvas stroke drawing utilities\n *\n * Handles the actual drawing of strokes on canvas with support for:\n * - Progressive stroke reveal (partial drawing based on progress)\n * - Normalized to pixel coordinate conversion\n * - Variable width based on pressure data\n * - Smooth line rendering with round caps/joins\n */\nclass StrokeDrawer {\n /**\n * Creates a new StrokeDrawer instance\n *\n * @param {CanvasRenderingContext2D} ctx - Canvas 2D rendering context\n * @param {Object} viewport - Viewport dimensions for coordinate conversion\n * @param {number} viewport.width - Viewport width in pixels\n * @param {number} viewport.height - Viewport height in pixels\n */\n constructor(ctx, viewport) {\n this.ctx = ctx;\n this.viewport = viewport;\n }\n\n /**\n * Updates the viewport dimensions\n *\n * @param {Object} viewport - New viewport dimensions\n */\n setViewport(viewport) {\n this.viewport = viewport;\n }\n\n /**\n * Draws a stroke with optional progress for progressive reveal\n *\n * @param {Object} stroke - Stroke command object\n * @param {Array} stroke.points - Array of [x, y] normalized coordinates\n * @param {string} stroke.color - Stroke color (CSS color string)\n * @param {number} stroke.width - Base stroke width in pixels\n * @param {Array} [stroke.pressures] - Optional pressure values for variable width\n * @param {number} [progress=1.0] - Progress from 0 to 1 (for progressive reveal)\n */\n drawStroke(stroke, progress = 1.0) {\n const { points, color, width, pressures } = stroke;\n\n if (!points || points.length < 2) return;\n\n // Calculate how many points to draw based on progress\n const pointCount = Math.max(2, Math.floor(points.length * progress));\n const visiblePoints = points.slice(0, pointCount);\n\n // Configure stroke style\n this.ctx.strokeStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.lineCap = 'round';\n this.ctx.lineJoin = 'round';\n\n // Draw with variable width if pressures provided\n if (pressures && pressures.length >= visiblePoints.length) {\n this._drawVariableWidthStroke(visiblePoints, width, pressures.slice(0, pointCount));\n } else {\n this._drawConstantWidthStroke(visiblePoints, width);\n }\n }\n\n /**\n * Draws a stroke with constant width\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} width - Stroke width in pixels\n */\n _drawConstantWidthStroke(points, width) {\n this.ctx.lineWidth = width || 2;\n this.ctx.beginPath();\n\n for (let i = 0; i < points.length; i++) {\n const [px, py] = this._normalizedToPixel(points[i]);\n\n if (i === 0) {\n this.ctx.moveTo(px, py);\n } else {\n this.ctx.lineTo(px, py);\n }\n }\n\n this.ctx.stroke();\n }\n\n /**\n * Draws a stroke with variable width based on pressure\n *\n * Uses multiple line segments with varying widths for natural pen feel.\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} baseWidth - Base stroke width in pixels\n * @param {Array} pressures - Pressure values (0-1) for each point\n */\n _drawVariableWidthStroke(points, baseWidth, pressures) {\n for (let i = 1; i < points.length; i++) {\n const [x1, y1] = this._normalizedToPixel(points[i - 1]);\n const [x2, y2] = this._normalizedToPixel(points[i]);\n\n // Average pressure between two points\n const p1 = pressures[i - 1] || 1;\n const p2 = pressures[i] || 1;\n const avgPressure = (p1 + p2) / 2;\n\n // Apply pressure to width (min 0.5, max 2x base width)\n const width = Math.max(0.5, baseWidth * avgPressure);\n\n this.ctx.lineWidth = width;\n this.ctx.beginPath();\n this.ctx.moveTo(x1, y1);\n this.ctx.lineTo(x2, y2);\n this.ctx.stroke();\n }\n }\n\n /**\n * Draws a single point (dot)\n *\n * Useful for single-point strokes or debugging.\n *\n * @param {number} x - Normalized x coordinate (0-1)\n * @param {number} y - Normalized y coordinate (0-1)\n * @param {number} radius - Dot radius in pixels\n * @param {string} color - Fill color\n */\n drawPoint(x, y, radius, color) {\n const [px, py] = this._normalizedToPixel([x, y]);\n\n this.ctx.fillStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.beginPath();\n this.ctx.arc(px, py, radius, 0, Math.PI * 2);\n this.ctx.fill();\n }\n\n /**\n * Clears the entire canvas\n */\n clear() {\n const dpr = window.devicePixelRatio || 1;\n this.ctx.clearRect(0, 0, this.viewport.width * dpr, this.viewport.height * dpr);\n }\n\n /**\n * Converts normalized coordinates (0-1) to pixel coordinates\n *\n * @private\n * @param {Array} point - [x, y] normalized coordinates\n * @returns {Array} [x, y] pixel coordinates\n */\n _normalizedToPixel(point) {\n const [normX, normY] = point;\n return [\n normX * this.viewport.width,\n normY * this.viewport.height\n ];\n }\n}\n\nexport default StrokeDrawer;\n"],"names":["StrokeDrawer","ctx","viewport","stroke","progress","points","color","width","pressures","pointCount","visiblePoints","px","py","baseWidth","i","x1","y1","x2","y2","p1","p2","avgPressure","x","y","radius","dpr","point","normX","normY"],"mappings":"4GASA,MAAMA,CAAa,CASjB,YAAYC,EAAKC,EAAU,CACzB,KAAK,IAAMD,EACX,KAAK,SAAWC,CAClB,CAOA,YAAYA,EAAU,CACpB,KAAK,SAAWA,CAClB,CAYA,WAAWC,EAAQC,EAAW,EAAK,CACjC,KAAM,CAAE,OAAAC,EAAQ,MAAAC,EAAO,MAAAC,EAAO,UAAAC,CAAS,EAAKL,EAE5C,GAAI,CAACE,GAAUA,EAAO,OAAS,EAAG,OAGlC,MAAMI,EAAa,KAAK,IAAI,EAAG,KAAK,MAAMJ,EAAO,O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EAAIC,CAAE,EAAI,KAAK,mBAAmB,CAACU,EAAGC,CAAC,CAAC,EAE/C,KAAK,IAAI,UAAYjB,GAAS,qBAC9B,KAAK,IAAI,UAAS,EAClB,KAAK,IAAI,IAAIK,EAAIC,EAAIY,EAAQ,EAAG,KAAK,GAAK,CAAC,EAC3C,KAAK,IAAI,KAAI,CACf,CAKA,OAAQ,CACN,MAAMC,EAAM,OAAO,kBAAoB,EACvC,KAAK,IAAI,UAAU,EAAG,EAAG,KAAK,SAAS,MAAQA,EAAK,KAAK,SAAS,OAASA,CAAG,CAChF,CASA,mBAAmBC,EAAO,CACxB,KAAM,CAACC,EAAOC,CAAK,EAAIF,EACvB,MAAO,CACLC,EAAQ,KAAK,SAAS,MACtBC,EAAQ,KAAK,SAAS,MAC5B,CACE,CACF"}
|
package/dist/index19.js
CHANGED
|
@@ -1,41 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
n = typeof o == "string" ? JSON.parse(o) : o;
|
|
14
|
-
} catch (e) {
|
|
15
|
-
throw new Error(`Failed to parse tool call arguments: ${e.message}`);
|
|
16
|
-
}
|
|
17
|
-
switch (t) {
|
|
18
|
-
case "create_highlight_annotation":
|
|
19
|
-
return a(n);
|
|
20
|
-
case "create_text_annotation":
|
|
21
|
-
return i(n);
|
|
22
|
-
default:
|
|
23
|
-
throw new Error(`Unknown tool: ${t}. Supported tools: create_highlight_annotation, create_text_annotation`);
|
|
1
|
+
class w {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new StrokeDrawer instance
|
|
4
|
+
*
|
|
5
|
+
* @param {CanvasRenderingContext2D} ctx - Canvas 2D rendering context
|
|
6
|
+
* @param {Object} viewport - Viewport dimensions for coordinate conversion
|
|
7
|
+
* @param {number} viewport.width - Viewport width in pixels
|
|
8
|
+
* @param {number} viewport.height - Viewport height in pixels
|
|
9
|
+
*/
|
|
10
|
+
constructor(t, o) {
|
|
11
|
+
this.ctx = t, this.viewport = o;
|
|
24
12
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Updates the viewport dimensions
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} viewport - New viewport dimensions
|
|
17
|
+
*/
|
|
18
|
+
setViewport(t) {
|
|
19
|
+
this.viewport = t;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Draws a stroke with optional progress for progressive reveal
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} stroke - Stroke command object
|
|
25
|
+
* @param {Array} stroke.points - Array of [x, y] normalized coordinates
|
|
26
|
+
* @param {string} stroke.color - Stroke color (CSS color string)
|
|
27
|
+
* @param {number} stroke.width - Base stroke width in pixels
|
|
28
|
+
* @param {Array} [stroke.pressures] - Optional pressure values for variable width
|
|
29
|
+
* @param {number} [progress=1.0] - Progress from 0 to 1 (for progressive reveal)
|
|
30
|
+
*/
|
|
31
|
+
drawStroke(t, o = 1) {
|
|
32
|
+
const { points: i, color: e, width: s, pressures: h } = t;
|
|
33
|
+
if (!i || i.length < 2) return;
|
|
34
|
+
const n = Math.max(2, Math.floor(i.length * o)), r = i.slice(0, n);
|
|
35
|
+
this.ctx.strokeStyle = e || "rgba(0, 0, 0, 0.5)", this.ctx.lineCap = "round", this.ctx.lineJoin = "round", h && h.length >= r.length ? this._drawVariableWidthStroke(r, s, h.slice(0, n)) : this._drawConstantWidthStroke(r, s);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Draws a stroke with constant width
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
* @param {Array} points - Array of [x, y] normalized coordinates
|
|
42
|
+
* @param {number} width - Stroke width in pixels
|
|
43
|
+
*/
|
|
44
|
+
_drawConstantWidthStroke(t, o) {
|
|
45
|
+
this.ctx.lineWidth = o || 2, this.ctx.beginPath();
|
|
46
|
+
for (let i = 0; i < t.length; i++) {
|
|
47
|
+
const [e, s] = this._normalizedToPixel(t[i]);
|
|
48
|
+
i === 0 ? this.ctx.moveTo(e, s) : this.ctx.lineTo(e, s);
|
|
49
|
+
}
|
|
50
|
+
this.ctx.stroke();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Draws a stroke with variable width based on pressure
|
|
54
|
+
*
|
|
55
|
+
* Uses multiple line segments with varying widths for natural pen feel.
|
|
56
|
+
*
|
|
57
|
+
* @private
|
|
58
|
+
* @param {Array} points - Array of [x, y] normalized coordinates
|
|
59
|
+
* @param {number} baseWidth - Base stroke width in pixels
|
|
60
|
+
* @param {Array} pressures - Pressure values (0-1) for each point
|
|
61
|
+
*/
|
|
62
|
+
_drawVariableWidthStroke(t, o, i) {
|
|
63
|
+
for (let e = 1; e < t.length; e++) {
|
|
64
|
+
const [s, h] = this._normalizedToPixel(t[e - 1]), [n, r] = this._normalizedToPixel(t[e]), l = i[e - 1] || 1, c = i[e] || 1, a = (l + c) / 2, x = Math.max(0.5, o * a);
|
|
65
|
+
this.ctx.lineWidth = x, this.ctx.beginPath(), this.ctx.moveTo(s, h), this.ctx.lineTo(n, r), this.ctx.stroke();
|
|
34
66
|
}
|
|
35
|
-
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Draws a single point (dot)
|
|
70
|
+
*
|
|
71
|
+
* Useful for single-point strokes or debugging.
|
|
72
|
+
*
|
|
73
|
+
* @param {number} x - Normalized x coordinate (0-1)
|
|
74
|
+
* @param {number} y - Normalized y coordinate (0-1)
|
|
75
|
+
* @param {number} radius - Dot radius in pixels
|
|
76
|
+
* @param {string} color - Fill color
|
|
77
|
+
*/
|
|
78
|
+
drawPoint(t, o, i, e) {
|
|
79
|
+
const [s, h] = this._normalizedToPixel([t, o]);
|
|
80
|
+
this.ctx.fillStyle = e || "rgba(0, 0, 0, 0.5)", this.ctx.beginPath(), this.ctx.arc(s, h, i, 0, Math.PI * 2), this.ctx.fill();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Clears the entire canvas
|
|
84
|
+
*/
|
|
85
|
+
clear() {
|
|
86
|
+
const t = window.devicePixelRatio || 1;
|
|
87
|
+
this.ctx.clearRect(0, 0, this.viewport.width * t, this.viewport.height * t);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts normalized coordinates (0-1) to pixel coordinates
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
* @param {Array} point - [x, y] normalized coordinates
|
|
94
|
+
* @returns {Array} [x, y] pixel coordinates
|
|
95
|
+
*/
|
|
96
|
+
_normalizedToPixel(t) {
|
|
97
|
+
const [o, i] = t;
|
|
98
|
+
return [
|
|
99
|
+
o * this.viewport.width,
|
|
100
|
+
i * this.viewport.height
|
|
101
|
+
];
|
|
102
|
+
}
|
|
36
103
|
}
|
|
37
104
|
export {
|
|
38
|
-
|
|
39
|
-
h as handleToolCalls
|
|
105
|
+
w as default
|
|
40
106
|
};
|
|
41
107
|
//# sourceMappingURL=index19.js.map
|
package/dist/index19.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index19.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index19.js","sources":["../src/pen/StrokeDrawer.js"],"sourcesContent":["/**\n * StrokeDrawer - Low-level canvas stroke drawing utilities\n *\n * Handles the actual drawing of strokes on canvas with support for:\n * - Progressive stroke reveal (partial drawing based on progress)\n * - Normalized to pixel coordinate conversion\n * - Variable width based on pressure data\n * - Smooth line rendering with round caps/joins\n */\nclass StrokeDrawer {\n /**\n * Creates a new StrokeDrawer instance\n *\n * @param {CanvasRenderingContext2D} ctx - Canvas 2D rendering context\n * @param {Object} viewport - Viewport dimensions for coordinate conversion\n * @param {number} viewport.width - Viewport width in pixels\n * @param {number} viewport.height - Viewport height in pixels\n */\n constructor(ctx, viewport) {\n this.ctx = ctx;\n this.viewport = viewport;\n }\n\n /**\n * Updates the viewport dimensions\n *\n * @param {Object} viewport - New viewport dimensions\n */\n setViewport(viewport) {\n this.viewport = viewport;\n }\n\n /**\n * Draws a stroke with optional progress for progressive reveal\n *\n * @param {Object} stroke - Stroke command object\n * @param {Array} stroke.points - Array of [x, y] normalized coordinates\n * @param {string} stroke.color - Stroke color (CSS color string)\n * @param {number} stroke.width - Base stroke width in pixels\n * @param {Array} [stroke.pressures] - Optional pressure values for variable width\n * @param {number} [progress=1.0] - Progress from 0 to 1 (for progressive reveal)\n */\n drawStroke(stroke, progress = 1.0) {\n const { points, color, width, pressures } = stroke;\n\n if (!points || points.length < 2) return;\n\n // Calculate how many points to draw based on progress\n const pointCount = Math.max(2, Math.floor(points.length * progress));\n const visiblePoints = points.slice(0, pointCount);\n\n // Configure stroke style\n this.ctx.strokeStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.lineCap = 'round';\n this.ctx.lineJoin = 'round';\n\n // Draw with variable width if pressures provided\n if (pressures && pressures.length >= visiblePoints.length) {\n this._drawVariableWidthStroke(visiblePoints, width, pressures.slice(0, pointCount));\n } else {\n this._drawConstantWidthStroke(visiblePoints, width);\n }\n }\n\n /**\n * Draws a stroke with constant width\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} width - Stroke width in pixels\n */\n _drawConstantWidthStroke(points, width) {\n this.ctx.lineWidth = width || 2;\n this.ctx.beginPath();\n\n for (let i = 0; i < points.length; i++) {\n const [px, py] = this._normalizedToPixel(points[i]);\n\n if (i === 0) {\n this.ctx.moveTo(px, py);\n } else {\n this.ctx.lineTo(px, py);\n }\n }\n\n this.ctx.stroke();\n }\n\n /**\n * Draws a stroke with variable width based on pressure\n *\n * Uses multiple line segments with varying widths for natural pen feel.\n *\n * @private\n * @param {Array} points - Array of [x, y] normalized coordinates\n * @param {number} baseWidth - Base stroke width in pixels\n * @param {Array} pressures - Pressure values (0-1) for each point\n */\n _drawVariableWidthStroke(points, baseWidth, pressures) {\n for (let i = 1; i < points.length; i++) {\n const [x1, y1] = this._normalizedToPixel(points[i - 1]);\n const [x2, y2] = this._normalizedToPixel(points[i]);\n\n // Average pressure between two points\n const p1 = pressures[i - 1] || 1;\n const p2 = pressures[i] || 1;\n const avgPressure = (p1 + p2) / 2;\n\n // Apply pressure to width (min 0.5, max 2x base width)\n const width = Math.max(0.5, baseWidth * avgPressure);\n\n this.ctx.lineWidth = width;\n this.ctx.beginPath();\n this.ctx.moveTo(x1, y1);\n this.ctx.lineTo(x2, y2);\n this.ctx.stroke();\n }\n }\n\n /**\n * Draws a single point (dot)\n *\n * Useful for single-point strokes or debugging.\n *\n * @param {number} x - Normalized x coordinate (0-1)\n * @param {number} y - Normalized y coordinate (0-1)\n * @param {number} radius - Dot radius in pixels\n * @param {string} color - Fill color\n */\n drawPoint(x, y, radius, color) {\n const [px, py] = this._normalizedToPixel([x, y]);\n\n this.ctx.fillStyle = color || 'rgba(0, 0, 0, 0.5)';\n this.ctx.beginPath();\n this.ctx.arc(px, py, radius, 0, Math.PI * 2);\n this.ctx.fill();\n }\n\n /**\n * Clears the entire canvas\n */\n clear() {\n const dpr = window.devicePixelRatio || 1;\n this.ctx.clearRect(0, 0, this.viewport.width * dpr, this.viewport.height * dpr);\n }\n\n /**\n * Converts normalized coordinates (0-1) to pixel coordinates\n *\n * @private\n * @param {Array} point - [x, y] normalized coordinates\n * @returns {Array} [x, y] pixel coordinates\n */\n _normalizedToPixel(point) {\n const [normX, normY] = point;\n return [\n normX * this.viewport.width,\n normY * this.viewport.height\n ];\n }\n}\n\nexport default StrokeDrawer;\n"],"names":["StrokeDrawer","ctx","viewport","stroke","progress","points","color","width","pressures","pointCount","visiblePoints","px","py","baseWidth","i","x1","y1","x2","y2","p1","p2","avgPressure","x","y","radius","dpr","point","normX","normY"],"mappings":"AASA,MAAMA,EAAa;AAAA;AAAA;AAAA;AAAA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AS;AAAA,MACtBC,IAAQ,KAAK,SAAS;AAAA,IAC5B;AAAA,EACE;AACF;"}
|
package/dist/index20.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={name:"default",highlight:{color:"rgba(255, 255, 0, 0.3)",width:24},handText:{color:"rgba(220, 20, 60, 1.0)",width:2},ink:{color:"rgba(31, 41, 55, 1.0)",width:3}},r={name:"blue",highlight:{color:"rgba(100, 149, 237, 0.35)",width:24},handText:{color:"rgba(30, 64, 175, 1.0)",width:2},ink:{color:"rgba(30, 64, 175, 1.0)",width:3}},o={name:"minimal",highlight:{color:"rgba(156, 163, 175, 0.25)",width:20},handText:{color:"rgba(75, 85, 99, 1.0)",width:1.5},ink:{color:"rgba(75, 85, 99, 1.0)",width:2}},t={default:e,blue:r,minimal:o};function a(i){return t[i]||t.default}function l(){return Object.keys(t)}exports.BLUE_PRESET=r;exports.DEFAULT_PRESET=e;exports.MINIMAL_PRESET=o;exports.default=t;exports.getPreset=a;exports.getPresetNames=l;
|
|
2
2
|
//# sourceMappingURL=index20.cjs.map
|
package/dist/index20.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index20.cjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index20.cjs","sources":["../src/pen/presets.js"],"sourcesContent":["/**\n * Client-side style presets for Digital Pen\n *\n * These presets mirror the backend presets and are used for\n * client-side preview or when backend presets aren't available.\n */\n\n/**\n * Default preset - Yellow highlights, crimson handwriting\n */\nexport const DEFAULT_PRESET = {\n name: 'default',\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n width: 24\n },\n handText: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2\n },\n ink: {\n color: 'rgba(31, 41, 55, 1.0)',\n width: 3\n }\n};\n\n/**\n * Blue preset - Blue highlights and handwriting\n */\nexport const BLUE_PRESET = {\n name: 'blue',\n highlight: {\n color: 'rgba(100, 149, 237, 0.35)',\n width: 24\n },\n handText: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n ink: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 3\n }\n};\n\n/**\n * Minimal preset - Subtle gray, less visible effects\n */\nexport const MINIMAL_PRESET = {\n name: 'minimal',\n highlight: {\n color: 'rgba(156, 163, 175, 0.25)',\n width: 20\n },\n handText: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n ink: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 2\n }\n};\n\n/**\n * Preset registry\n */\nconst PRESETS = {\n default: DEFAULT_PRESET,\n blue: BLUE_PRESET,\n minimal: MINIMAL_PRESET\n};\n\n/**\n * Get a preset by name\n *\n * @param {string} name - Preset name\n * @returns {Object} Preset configuration\n */\nexport function getPreset(name) {\n return PRESETS[name] || PRESETS.default;\n}\n\n/**\n * Get all available preset names\n *\n * @returns {string[]} Array of preset names\n */\nexport function getPresetNames() {\n return Object.keys(PRESETS);\n}\n\nexport default PRESETS;\n"],"names":["DEFAULT_PRESET","BLUE_PRESET","MINIMAL_PRESET","PRESETS","getPreset","name","getPresetNames"],"mappings":"4GAUY,MAACA,EAAiB,CAC5B,KAAM,UACN,UAAW,CACT,MAAO,yBACP,MAAO,EACX,EACE,SAAU,CACR,MAAO,yBACP,MAAO,CACX,EACE,IAAK,CACH,MAAO,wBACP,MAAO,CACX,CACA,EAKaC,EAAc,CACzB,KAAM,OACN,UAAW,CACT,MAAO,4BACP,MAAO,EACX,EACE,SAAU,CACR,MAAO,yBACP,MAAO,CACX,EACE,IAAK,CACH,MAAO,yBACP,MAAO,CACX,CACA,EAKaC,EAAiB,CAC5B,KAAM,UACN,UAAW,CACT,MAAO,4BACP,MAAO,EACX,EACE,SAAU,CACR,MAAO,wBACP,MAAO,GACX,EACE,IAAK,CACH,MAAO,wBACP,MAAO,CACX,CACA,EAKMC,EAAU,CACd,QAASH,EACT,KAAMC,EACN,QAASC,CACX,EAQO,SAASE,EAAUC,EAAM,CAC9B,OAAOF,EAAQE,CAAI,GAAKF,EAAQ,OAClC,CAOO,SAASG,GAAiB,CAC/B,OAAO,OAAO,KAAKH,CAAO,CAC5B"}
|
package/dist/index20.js
CHANGED
|
@@ -1,40 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
const r = {
|
|
2
|
+
name: "default",
|
|
3
|
+
highlight: {
|
|
4
|
+
color: "rgba(255, 255, 0, 0.3)",
|
|
5
|
+
width: 24
|
|
6
|
+
},
|
|
7
|
+
handText: {
|
|
8
|
+
color: "rgba(220, 20, 60, 1.0)",
|
|
9
|
+
width: 2
|
|
10
|
+
},
|
|
11
|
+
ink: {
|
|
12
|
+
color: "rgba(31, 41, 55, 1.0)",
|
|
13
|
+
width: 3
|
|
14
|
+
}
|
|
15
|
+
}, e = {
|
|
16
|
+
name: "blue",
|
|
17
|
+
highlight: {
|
|
18
|
+
color: "rgba(100, 149, 237, 0.35)",
|
|
19
|
+
width: 24
|
|
20
|
+
},
|
|
21
|
+
handText: {
|
|
22
|
+
color: "rgba(30, 64, 175, 1.0)",
|
|
23
|
+
width: 2
|
|
24
|
+
},
|
|
25
|
+
ink: {
|
|
26
|
+
color: "rgba(30, 64, 175, 1.0)",
|
|
27
|
+
width: 3
|
|
28
|
+
}
|
|
29
|
+
}, i = {
|
|
30
|
+
name: "minimal",
|
|
31
|
+
highlight: {
|
|
32
|
+
color: "rgba(156, 163, 175, 0.25)",
|
|
33
|
+
width: 20
|
|
34
|
+
},
|
|
35
|
+
handText: {
|
|
36
|
+
color: "rgba(75, 85, 99, 1.0)",
|
|
37
|
+
width: 1.5
|
|
38
|
+
},
|
|
39
|
+
ink: {
|
|
40
|
+
color: "rgba(75, 85, 99, 1.0)",
|
|
41
|
+
width: 2
|
|
42
|
+
}
|
|
43
|
+
}, t = {
|
|
44
|
+
default: r,
|
|
45
|
+
blue: e,
|
|
46
|
+
minimal: i
|
|
47
|
+
};
|
|
48
|
+
function a(o) {
|
|
49
|
+
return t[o] || t.default;
|
|
50
|
+
}
|
|
51
|
+
function h() {
|
|
52
|
+
return Object.keys(t);
|
|
36
53
|
}
|
|
37
54
|
export {
|
|
38
|
-
|
|
55
|
+
e as BLUE_PRESET,
|
|
56
|
+
r as DEFAULT_PRESET,
|
|
57
|
+
i as MINIMAL_PRESET,
|
|
58
|
+
t as default,
|
|
59
|
+
a as getPreset,
|
|
60
|
+
h as getPresetNames
|
|
39
61
|
};
|
|
40
62
|
//# sourceMappingURL=index20.js.map
|
package/dist/index20.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index20.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index20.js","sources":["../src/pen/presets.js"],"sourcesContent":["/**\n * Client-side style presets for Digital Pen\n *\n * These presets mirror the backend presets and are used for\n * client-side preview or when backend presets aren't available.\n */\n\n/**\n * Default preset - Yellow highlights, crimson handwriting\n */\nexport const DEFAULT_PRESET = {\n name: 'default',\n highlight: {\n color: 'rgba(255, 255, 0, 0.3)',\n width: 24\n },\n handText: {\n color: 'rgba(220, 20, 60, 1.0)',\n width: 2\n },\n ink: {\n color: 'rgba(31, 41, 55, 1.0)',\n width: 3\n }\n};\n\n/**\n * Blue preset - Blue highlights and handwriting\n */\nexport const BLUE_PRESET = {\n name: 'blue',\n highlight: {\n color: 'rgba(100, 149, 237, 0.35)',\n width: 24\n },\n handText: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 2\n },\n ink: {\n color: 'rgba(30, 64, 175, 1.0)',\n width: 3\n }\n};\n\n/**\n * Minimal preset - Subtle gray, less visible effects\n */\nexport const MINIMAL_PRESET = {\n name: 'minimal',\n highlight: {\n color: 'rgba(156, 163, 175, 0.25)',\n width: 20\n },\n handText: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 1.5\n },\n ink: {\n color: 'rgba(75, 85, 99, 1.0)',\n width: 2\n }\n};\n\n/**\n * Preset registry\n */\nconst PRESETS = {\n default: DEFAULT_PRESET,\n blue: BLUE_PRESET,\n minimal: MINIMAL_PRESET\n};\n\n/**\n * Get a preset by name\n *\n * @param {string} name - Preset name\n * @returns {Object} Preset configuration\n */\nexport function getPreset(name) {\n return PRESETS[name] || PRESETS.default;\n}\n\n/**\n * Get all available preset names\n *\n * @returns {string[]} Array of preset names\n */\nexport function getPresetNames() {\n return Object.keys(PRESETS);\n}\n\nexport default PRESETS;\n"],"names":["DEFAULT_PRESET","BLUE_PRESET","MINIMAL_PRESET","PRESETS","getPreset","name","getPresetNames"],"mappings":"AAUY,MAACA,IAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,UAAU;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKaC,IAAc;AAAA,EACzB,MAAM;AAAA,EACN,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,UAAU;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKaC,IAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,WAAW;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,UAAU;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACE,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACA,GAKMC,IAAU;AAAA,EACd,SAASH;AAAA,EACT,MAAMC;AAAA,EACN,SAASC;AACX;AAQO,SAASE,EAAUC,GAAM;AAC9B,SAAOF,EAAQE,CAAI,KAAKF,EAAQ;AAClC;AAOO,SAASG,IAAiB;AAC/B,SAAO,OAAO,KAAKH,CAAO;AAC5B;"}
|
package/dist/index21.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=[{type:"function",function:{name:"create_highlight_annotation",description:"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.",parameters:{type:"object",properties:{quads:{type:"array",description:"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.",items:{type:"object",properties:{x:{type:"number",description:"Normalized x position (0 = left, 1 = right)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top, 1 = bottom)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1)",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1)",minimum:0,maximum:1}},required:["x","y","w","h"]},minItems:1},color:{type:"string",description:"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.",default:"rgba(255, 255, 0, 0.3)"},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["quads","page","sentence_ref"]}}},{type:"function",function:{name:"create_text_annotation",description:"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.",parameters:{type:"object",properties:{content:{type:"string",description:"The text content of the annotation",minLength:1,maxLength:500},x:{type:"number",description:"Normalized x position (0 = left edge, 1 = right edge)",minimum:0,maximum:1},y:{type:"number",description:"Normalized y position (0 = top edge, 1 = bottom edge)",minimum:0,maximum:1},w:{type:"number",description:"Normalized width (0-1) of the text box",minimum:0,maximum:1},h:{type:"number",description:"Normalized height (0-1) of the text box",minimum:0,maximum:1},page:{type:"integer",description:"Page number (1-indexed) where the annotation appears",minimum:1},textColor:{type:"string",description:"Text color in hex format (e.g., '#000000' for black). Default is dark gray.",default:"#1f2937"},bgColor:{type:"string",description:"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.",default:"transparent"},sentence_ref:{type:"string",description:"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization",pattern:"^S\\d+$"}},required:["content","x","y","w","h","page","sentence_ref"]}}}];function o(e=[]){if(!Array.isArray(e)||e.length===0)return[];const i={highlight:"create_highlight_annotation",text:"create_text_annotation"},r=e.map(t=>i[t]).filter(Boolean);return n.filter(t=>r.includes(t.function.name))}exports.annotationTools=n;exports.getAnnotationTools=o;
|
|
2
2
|
//# sourceMappingURL=index21.cjs.map
|
package/dist/index21.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index21.cjs","sources":["../src/ai-tools/
|
|
1
|
+
{"version":3,"file":"index21.cjs","sources":["../src/ai-tools/openai/schemas.js"],"sourcesContent":["/**\n * OpenAI Tool Schemas for PDF Annotation Generation\n *\n * Provides OpenAI-compatible function calling schemas for creating PDF annotations.\n * These schemas define the structure and parameters for AI-generated annotations.\n * Compatible with web-annotation-renderer library format.\n *\n * @module ai-tools/openai/schemas\n */\n\n/**\n * Complete set of annotation tools for OpenAI function calling\n *\n * Export this array to the OpenAI API's `tools` parameter to enable\n * AI-generated annotations.\n *\n * @constant {Array<Object>}\n * @example\n * ```javascript\n * import { annotationTools } from 'web-annotation-renderer/ai-tools';\n *\n * const response = await openai.chat.completions.create({\n * model: \"gpt-4\",\n * messages: [...],\n * tools: annotationTools\n * });\n * ```\n */\nexport const annotationTools = [\n {\n type: \"function\",\n function: {\n name: \"create_highlight_annotation\",\n description: \"Create a highlight annotation at specified coordinates on the PDF page. Use this to emphasize important text or regions. Highlights are rectangular regions that can span multiple lines.\",\n parameters: {\n type: \"object\",\n properties: {\n quads: {\n type: \"array\",\n description: \"Array of rectangular regions defining the highlight areas. Each quad is an object with normalized coordinates (0-1): {x, y, w, h}. Multiple quads can be used for multi-line highlights.\",\n items: {\n type: \"object\",\n properties: {\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left, 1 = right)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top, 1 = bottom)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1)\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1)\",\n minimum: 0,\n maximum: 1\n }\n },\n required: [\"x\", \"y\", \"w\", \"h\"]\n },\n minItems: 1\n },\n color: {\n type: \"string\",\n description: \"Highlight color in rgba format (e.g., 'rgba(255, 255, 0, 0.3)'). Default is semi-transparent yellow. Use rgba for transparency control.\",\n default: \"rgba(255, 255, 0, 0.3)\"\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"quads\", \"page\", \"sentence_ref\"]\n }\n }\n },\n {\n type: \"function\",\n function: {\n name: \"create_text_annotation\",\n description: \"Create a text box annotation with explanatory content. Use this to add clarifying notes, definitions, or explanations. Text boxes have background and appear as overlays.\",\n parameters: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The text content of the annotation\",\n minLength: 1,\n maxLength: 500\n },\n x: {\n type: \"number\",\n description: \"Normalized x position (0 = left edge, 1 = right edge)\",\n minimum: 0,\n maximum: 1\n },\n y: {\n type: \"number\",\n description: \"Normalized y position (0 = top edge, 1 = bottom edge)\",\n minimum: 0,\n maximum: 1\n },\n w: {\n type: \"number\",\n description: \"Normalized width (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n h: {\n type: \"number\",\n description: \"Normalized height (0-1) of the text box\",\n minimum: 0,\n maximum: 1\n },\n page: {\n type: \"integer\",\n description: \"Page number (1-indexed) where the annotation appears\",\n minimum: 1\n },\n textColor: {\n type: \"string\",\n description: \"Text color in hex format (e.g., '#000000' for black). Default is dark gray.\",\n default: \"#1f2937\"\n },\n bgColor: {\n type: \"string\",\n description: \"Background color in rgba format or 'transparent' (e.g., 'rgba(255, 255, 255, 0.9)' or 'transparent'). Default is transparent for better visibility of underlying content. Use rgba format when background is needed.\",\n default: \"transparent\"\n },\n sentence_ref: {\n type: \"string\",\n description: \"Reference to sentence marker (e.g., 'S1', 'S2') for timing synchronization\",\n pattern: \"^S\\\\d+$\"\n }\n },\n required: [\"content\", \"x\", \"y\", \"w\", \"h\", \"page\", \"sentence_ref\"]\n }\n }\n }\n];\n\n/**\n * Get filtered annotation tools based on enabled types\n *\n * @param {Array<string>} enabledTypes - Array of enabled tool types: ['highlight', 'text']\n * @returns {Array<Object>} Filtered annotation tools\n * @example\n * ```javascript\n * // Only enable highlights and text notes\n * const tools = getAnnotationTools(['highlight', 'text']);\n * ```\n */\nexport function getAnnotationTools(enabledTypes = []) {\n if (!Array.isArray(enabledTypes) || enabledTypes.length === 0) {\n return [];\n }\n\n const typeMap = {\n 'highlight': 'create_highlight_annotation',\n 'text': 'create_text_annotation'\n };\n\n const enabledFunctionNames = enabledTypes\n .map(type => typeMap[type])\n .filter(Boolean);\n\n return annotationTools.filter(tool =>\n enabledFunctionNames.includes(tool.function.name)\n );\n}\n"],"names":["annotationTools","getAnnotationTools","enabledTypes","typeMap","enabledFunctionNames","type","tool"],"mappings":"gFA4BY,MAACA,EAAkB,CAC7B,CACE,KAAM,WACN,SAAU,CACR,KAAM,8BACN,YAAa,4LACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,MAAO,CACL,KAAM,QACN,YAAa,2LACb,MAAO,CACL,KAAM,SACN,WAAY,CACV,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,8CACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,yBACb,QAAS,EACT,QAAS,CAC3B,EACgB,EAAG,CACD,KAAM,SACN,YAAa,0BACb,QAAS,EACT,QAAS,CAC3B,CACA,EACc,SAAU,CAAC,IAAK,IAAK,IAAK,GAAG,CAC3C,EACY,SAAU,CACtB,EACU,MAAO,CACL,KAAM,SACN,YAAa,0IACb,QAAS,wBACrB,EACU,KAAM,CACJ,KAAM,UACN,YAAa,uDACb,QAAS,CACrB,EACU,aAAc,CACZ,KAAM,SACN,YAAa,6EACb,QAAS,SACrB,CACA,EACQ,SAAU,CAAC,QAAS,OAAQ,cAAc,CAClD,CACA,CACA,EACE,CACE,KAAM,WACN,SAAU,CACR,KAAM,yBACN,YAAa,4KACb,WAAY,CACV,KAAM,SACN,WAAY,CACV,QAAS,CACP,KAAM,SACN,YAAa,qCACb,UAAW,EACX,UAAW,GACvB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,wDACb,QAAS,EACT,QAAS,CACrB,EACU,EAAG,CACD,KAAM,SACN,YAAa,yCACb,QAAS,EACT,QAAS,CACrB,EACU,EAA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