@pie-element/shared-utils 0.1.7-next.20261023101922 → 0.1.7-next.20261024175806

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/ime.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ interface ComposableKeyEvent {
2
+ isComposing?: boolean;
3
+ keyCode?: number;
4
+ /** A React synthetic event carries `isComposing` only on its native event. */
5
+ nativeEvent?: {
6
+ isComposing?: boolean;
7
+ };
8
+ }
9
+ /**
10
+ * Whether a keydown belongs to an IME composition, so it must not act as a shortcut. Safari
11
+ * reports `isComposing` false on the Enter that commits a composition and marks it only with
12
+ * `keyCode` 229.
13
+ */
14
+ export declare function isComposingKeyEvent(event: ComposableKeyEvent | null | undefined): boolean;
15
+ export {};
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@
6
6
  export * from './utils.js';
7
7
  export * from './sanitize-model-html.js';
8
8
  export * from './prompt-audio.js';
9
+ export { isComposingKeyEvent } from './ime.js';
9
10
  export { AUTHORED_BORDER_ATTR, AUTHORED_FILL_ATTR, AUTHORED_INK_ATTR, markAuthoredColors, type AuthoredFill, } from './authored-colors.js';
package/dist/index.js CHANGED
@@ -59,12 +59,12 @@ function d(e, t) {
59
59
  }
60
60
  //#endregion
61
61
  //#region src/authored-colors.ts
62
- var f = "data-pie-authored-ink", p = "data-pie-authored-fill", m = "data-pie-authored-border", h = [
62
+ var f = "data-pie-authored-ink", p = "data-pie-authored-fill", m = "data-pie-authored-border", ee = [
63
63
  "border-top-color",
64
64
  "border-right-color",
65
65
  "border-bottom-color",
66
66
  "border-left-color"
67
- ], g = /* @__PURE__ */ new Set([
67
+ ], te = /* @__PURE__ */ new Set([
68
68
  "currentcolor",
69
69
  "inherit",
70
70
  "initial",
@@ -73,35 +73,35 @@ var f = "data-pie-authored-ink", p = "data-pie-authored-fill", m = "data-pie-aut
73
73
  "revert-layer",
74
74
  "transparent"
75
75
  ]);
76
- function _(e) {
76
+ function h(e) {
77
77
  let t = e?.trim().toLowerCase();
78
- return !t || g.has(t) || t.includes("var(") ? !1 : y(t)?.a !== 0;
78
+ return !t || te.has(t) || t.includes("var(") ? !1 : v(t)?.a !== 0;
79
79
  }
80
- function ee(e) {
81
- let t = y(e);
80
+ function ne(e) {
81
+ let t = v(e);
82
82
  if (!t) return "shade";
83
83
  let n = (e) => (e * t.a + 255 * (1 - t.a)) / 255, [r, i, a] = [
84
84
  n(t.r),
85
85
  n(t.g),
86
86
  n(t.b)
87
- ], o = .2126 * P(r) + .7152 * P(i) + .0722 * P(a), s = Math.max(r, i, a) - Math.min(r, i, a);
87
+ ], o = .2126 * F(r) + .7152 * F(i) + .0722 * F(a), s = Math.max(r, i, a) - Math.min(r, i, a);
88
88
  return o >= .85 && s <= .08 ? "light" : "shade";
89
89
  }
90
- function v(e) {
90
+ function g(e) {
91
91
  e.removeAttribute(f), e.removeAttribute(p), e.removeAttribute(m);
92
92
  let t = e.hasAttribute("style") ? e.style : void 0, n = (e) => t?.getPropertyValue(e).trim() ?? "", r = [], i = n("color"), a = e.localName === "font" ? e.getAttribute("color") : null;
93
- _(i || a) && (e.setAttribute(f, ""), i && r.push("color"));
94
- let o = n("background-color"), s = o || te(e.getAttribute("bgcolor"));
95
- _(s) && (e.setAttribute(p, ee(s)), o && r.push("background-color"));
96
- let c = h.filter((e) => _(n(e)));
93
+ h(i || a) && (e.setAttribute(f, ""), i && r.push("color"));
94
+ let o = n("background-color"), s = o || _(e.getAttribute("bgcolor"));
95
+ h(s) && (e.setAttribute(p, ne(s)), o && r.push("background-color"));
96
+ let c = ee.filter((e) => h(n(e)));
97
97
  c.length && (e.setAttribute(m, ""), r.push(...c));
98
98
  for (let e of r) t?.getPropertyPriority(e) === "important" && t.setProperty(e, t.getPropertyValue(e));
99
99
  }
100
- function te(e) {
100
+ function _(e) {
101
101
  let t = e?.trim() ?? "";
102
102
  return /^(?:[\da-f]{3}|[\da-f]{6})$/i.test(t) ? `#${t}` : t;
103
103
  }
104
- function y(e) {
104
+ function v(e) {
105
105
  let t = e.trim().toLowerCase();
106
106
  if (t === "transparent") return {
107
107
  r: 0,
@@ -109,14 +109,14 @@ function y(e) {
109
109
  b: 0,
110
110
  a: 0
111
111
  };
112
- let n = x().get(t);
113
- if (n) return S(n);
114
- if (t.startsWith("#")) return S(t.slice(1));
112
+ let n = re().get(t);
113
+ if (n) return b(n);
114
+ if (t.startsWith("#")) return b(t.slice(1));
115
115
  let r = /^([a-z]+)\(([^()]*)\)$/.exec(t);
116
116
  if (!r) return null;
117
117
  let i = r[2].trim().split(/\s*[\s,/]\s*/);
118
118
  if (i.length !== 3 && i.length !== 4) return null;
119
- let [a, o, s, c] = i, l = ne(c), u;
119
+ let [a, o, s, c] = i, l = ie(c), u;
120
120
  switch (r[1]) {
121
121
  case "rgb":
122
122
  case "rgba":
@@ -124,31 +124,31 @@ function y(e) {
124
124
  a,
125
125
  o,
126
126
  s
127
- ].map((e) => w(e, 255) / 255);
127
+ ].map((e) => S(e, 255) / 255);
128
128
  break;
129
129
  case "hsl":
130
130
  case "hsla":
131
- u = D(T(a), w(o, 100) / 100, w(s, 100) / 100);
131
+ u = T(C(a), S(o, 100) / 100, S(s, 100) / 100);
132
132
  break;
133
133
  case "hwb":
134
- u = re(T(a), w(o, 100) / 100, w(s, 100) / 100);
134
+ u = ae(C(a), S(o, 100) / 100, S(s, 100) / 100);
135
135
  break;
136
136
  case "lab":
137
- u = A(w(a, 100), w(o, 125), w(s, 125));
137
+ u = j(S(a, 100), S(o, 125), S(s, 125));
138
138
  break;
139
139
  case "lch":
140
- u = A(w(a, 100), ...E(w(o, 150), T(s)));
140
+ u = j(S(a, 100), ...w(S(o, 150), C(s)));
141
141
  break;
142
142
  case "oklab":
143
- u = j(w(a, 1), w(o, .4), w(s, .4));
143
+ u = M(S(a, 1), S(o, .4), S(s, .4));
144
144
  break;
145
145
  case "oklch":
146
- u = j(w(a, 1), ...E(w(o, .4), T(s)));
146
+ u = M(S(a, 1), ...w(S(o, .4), C(s)));
147
147
  break;
148
148
  default: return null;
149
149
  }
150
150
  if (Number.isNaN(l) || u.some(Number.isNaN)) return null;
151
- let [d, f, p] = u.map((e) => F(e, 0, 1) * 255);
151
+ let [d, f, p] = u.map((e) => I(e, 0, 1) * 255);
152
152
  return {
153
153
  r: d,
154
154
  g: f,
@@ -156,11 +156,11 @@ function y(e) {
156
156
  a: l
157
157
  };
158
158
  }
159
- var b;
160
- function x() {
161
- return b ??= new Map("aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 yellowgreen:9acd32".split(" ").map((e) => e.split(":"))), b;
159
+ var y;
160
+ function re() {
161
+ return y ??= new Map("aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 yellowgreen:9acd32".split(" ").map((e) => e.split(":"))), y;
162
162
  }
163
- function S(e) {
163
+ function b(e) {
164
164
  if (!/^(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.test(e)) return null;
165
165
  let [t, n, r, i = 255] = (e.length <= 4 ? [...e].map((e) => e + e) : e.match(/../g) ?? []).map((e) => Number.parseInt(e, 16));
166
166
  return {
@@ -170,28 +170,28 @@ function S(e) {
170
170
  a: i / 255
171
171
  };
172
172
  }
173
- var C = /^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(%|deg|rad|grad|turn)?$/;
174
- function w(e, t) {
173
+ var x = /^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(%|deg|rad|grad|turn)?$/;
174
+ function S(e, t) {
175
175
  if (e === "none") return 0;
176
- let n = C.exec(e);
176
+ let n = x.exec(e);
177
177
  return !n || n[2] && n[2] !== "%" ? NaN : n[2] ? Number(n[1]) / 100 * t : Number(n[1]);
178
178
  }
179
- function T(e) {
179
+ function C(e) {
180
180
  if (e === "none") return 0;
181
- let t = C.exec(e);
181
+ let t = x.exec(e);
182
182
  if (!t || t[2] === "%") return NaN;
183
183
  let n = Number(t[1]);
184
184
  return ((t[2] === "rad" ? n * 180 / Math.PI : t[2] === "grad" ? n * .9 : t[2] === "turn" ? n * 360 : n) % 360 + 360) % 360;
185
185
  }
186
- function ne(e) {
187
- return e === void 0 ? 1 : F(w(e, 1), 0, 1);
186
+ function ie(e) {
187
+ return e === void 0 ? 1 : I(S(e, 1), 0, 1);
188
188
  }
189
- function E(e, t) {
189
+ function w(e, t) {
190
190
  let n = Math.max(0, e), r = t * Math.PI / 180;
191
191
  return [n * Math.cos(r), n * Math.sin(r)];
192
192
  }
193
- function D(e, t, n) {
194
- let r = F(t, 0, 1), i = F(n, 0, 1), a = (t) => {
193
+ function T(e, t, n) {
194
+ let r = I(t, 0, 1), i = I(n, 0, 1), a = (t) => {
195
195
  let n = (t + e / 30) % 12, a = r * Math.min(i, 1 - i);
196
196
  return i - a * Math.max(-1, Math.min(n - 3, 9 - n, 1));
197
197
  };
@@ -201,19 +201,19 @@ function D(e, t, n) {
201
201
  a(4)
202
202
  ];
203
203
  }
204
- function re(e, t, n) {
205
- let r = F(t, 0, 1), i = F(n, 0, 1);
204
+ function ae(e, t, n) {
205
+ let r = I(t, 0, 1), i = I(n, 0, 1);
206
206
  return r + i >= 1 ? [
207
207
  ,
208
208
  ,
209
209
  ,
210
- ].fill(r / (r + i)) : D(e, 1, .5).map((e) => e * (1 - r - i) + r);
210
+ ].fill(r / (r + i)) : T(e, 1, .5).map((e) => e * (1 - r - i) + r);
211
211
  }
212
- var O = 24389 / 27, k = 216 / 24389, ie = [
212
+ var E = 24389 / 27, D = 216 / 24389, O = [
213
213
  .3457 / .3585,
214
214
  1,
215
215
  .2958 / .3585
216
- ], ae = [
216
+ ], k = [
217
217
  [
218
218
  .955473421488075,
219
219
  -.02309845494876471,
@@ -229,7 +229,7 @@ var O = 24389 / 27, k = 216 / 24389, ie = [
229
229
  -.020507649298898964,
230
230
  1.330365926242124
231
231
  ]
232
- ], oe = [
232
+ ], A = [
233
233
  [
234
234
  12831 / 3959,
235
235
  -329 / 214,
@@ -246,17 +246,17 @@ var O = 24389 / 27, k = 216 / 24389, ie = [
246
246
  705 / 667
247
247
  ]
248
248
  ];
249
- function A(e, t, n) {
250
- let r = F(e, 0, 100), i = (r + 16) / 116, a = t / 500 + i, o = i - n / 200;
251
- return M(oe, M(ae, [
252
- a ** 3 > k ? a ** 3 : (116 * a - 16) / O,
253
- r > O * k ? i ** 3 : r / O,
254
- o ** 3 > k ? o ** 3 : (116 * o - 16) / O
255
- ].map((e, t) => e * ie[t]))).map(N);
256
- }
257
249
  function j(e, t, n) {
258
- let r = F(e, 0, 1);
259
- return M([
250
+ let r = I(e, 0, 100), i = (r + 16) / 116, a = t / 500 + i, o = i - n / 200;
251
+ return N(A, N(k, [
252
+ a ** 3 > D ? a ** 3 : (116 * a - 16) / E,
253
+ r > E * D ? i ** 3 : r / E,
254
+ o ** 3 > D ? o ** 3 : (116 * o - 16) / E
255
+ ].map((e, t) => e * O[t]))).map(P);
256
+ }
257
+ function M(e, t, n) {
258
+ let r = I(e, 0, 1);
259
+ return N([
260
260
  [
261
261
  4.0767416621,
262
262
  -3.3077115913,
@@ -276,25 +276,25 @@ function j(e, t, n) {
276
276
  r + .3963377774 * t + .2158037573 * n,
277
277
  r - .1055613458 * t - .0638541728 * n,
278
278
  r - .0894841775 * t - 1.291485548 * n
279
- ].map((e) => e ** 3)).map(N);
279
+ ].map((e) => e ** 3)).map(P);
280
280
  }
281
- function M(e, t) {
281
+ function N(e, t) {
282
282
  return e.map((e) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2]);
283
283
  }
284
- function N(e) {
285
- let t = F(e, 0, 1);
284
+ function P(e) {
285
+ let t = I(e, 0, 1);
286
286
  return t <= .0031308 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - .055;
287
287
  }
288
- function P(e) {
288
+ function F(e) {
289
289
  return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
290
290
  }
291
- function F(e, t, n) {
291
+ function I(e, t, n) {
292
292
  return Math.min(n, Math.max(t, e));
293
293
  }
294
294
  //#endregion
295
295
  //#region src/prompt-audio.ts
296
- var I = (e) => !!e?.autoplayAudioEnabled && !e?.autoplayAudioHeld, L = ["autoplay"];
297
- function R(e, t) {
296
+ var L = (e) => !!e?.autoplayAudioEnabled && !e?.autoplayAudioHeld, R = ["autoplay"];
297
+ function z(e, t) {
298
298
  let n = e.audioStartTime || t.audioStartTime, r = e.audioEndTime || t.audioEndTime, i = {
299
299
  ...e,
300
300
  ...n ? { audioStartTime: n } : {},
@@ -302,7 +302,7 @@ function R(e, t) {
302
302
  };
303
303
  return !i.waitTime && n && r && (i.waitTime = r - n), i;
304
304
  }
305
- var se = class {
305
+ var oe = class {
306
306
  #e;
307
307
  #t;
308
308
  #n = !1;
@@ -335,27 +335,27 @@ var se = class {
335
335
  this.#n = e;
336
336
  }
337
337
  #i(e) {
338
- let t = this.#e.session() ?? {}, n = R(t, e);
338
+ let t = this.#e.session() ?? {}, n = z(t, e);
339
339
  (n.audioStartTime !== t.audioStartTime || n.audioEndTime !== t.audioEndTime || n.waitTime !== t.waitTime) && this.#e.writeSession(n);
340
340
  }
341
- }, z = (e) => e.getAttribute("src") || e.querySelector("source[src]:not([src=\"\"])")?.getAttribute("src") || "";
342
- function B(e, t) {
343
- t.follow(z(e));
341
+ }, B = (e) => e.getAttribute("src") || e.querySelector("source[src]:not([src=\"\"])")?.getAttribute("src") || "";
342
+ function V(e, t) {
343
+ t.follow(B(e));
344
344
  let n = () => t.recordStart(), r = () => t.recordEnd(), i = () => t.recordFailure();
345
345
  return e.addEventListener("playing", n), e.addEventListener("ended", r), e.addEventListener("error", i, !0), () => {
346
346
  e.removeEventListener("playing", n), e.removeEventListener("ended", r), e.removeEventListener("error", i, !0);
347
347
  };
348
348
  }
349
- var V = (e) => {
349
+ var H = (e) => {
350
350
  let t = e?.querySelector("audio");
351
351
  return t?.closest(".preview-prompt") ? t : null;
352
352
  };
353
- function H(e, t) {
353
+ function U(e, t) {
354
354
  if (!t.pending) return !1;
355
- let n = V(e);
356
- return !!n && z(n) !== "" && n.error === null;
355
+ let n = H(e);
356
+ return !!n && B(n) !== "" && n.error === null;
357
357
  }
358
- var U = "play-audio-info", W = 500, G = class {
358
+ var W = "play-audio-info", G = 500, K = class {
359
359
  #e;
360
360
  #t = null;
361
361
  #n = null;
@@ -374,18 +374,18 @@ var U = "play-audio-info", W = 500, G = class {
374
374
  }
375
375
  #i() {
376
376
  let e = this.#e.settings();
377
- if (!I(e) && !e?.completeAudioEnabled) return;
378
- let t = V(this.#e.root);
379
- t && t !== this.#n && (this.#o(), this.#a(t, I(e)));
377
+ if (!L(e) && !e?.completeAudioEnabled) return;
378
+ let t = H(this.#e.root);
379
+ t && t !== this.#n && (this.#o(), this.#a(t, L(e)));
380
380
  }
381
381
  #a(e, t) {
382
- let { root: n, tracker: r, enableAudioImage: i } = this.#e, a = B(e, r), o = ce(i), s = () => {
382
+ let { root: n, tracker: r, enableAudioImage: i } = this.#e, a = V(e, r), o = se(i), s = () => {
383
383
  o.isConnected && (e.play()?.catch(() => {}), o.remove()), document.removeEventListener("click", s);
384
384
  }, c = () => o.remove();
385
385
  e.addEventListener("playing", c);
386
386
  let l = t ? setTimeout(() => {
387
- e.paused && !n.querySelector(`.${U}`) && ((n.querySelector(".main-container") ?? n).appendChild(o), document.addEventListener("click", s));
388
- }, W) : void 0;
387
+ e.paused && !n.querySelector(`.${W}`) && ((n.querySelector(".main-container") ?? n).appendChild(o), document.addEventListener("click", s));
388
+ }, G) : void 0;
389
389
  this.#n = e, this.#r = () => {
390
390
  clearTimeout(l), a(), e.removeEventListener("playing", c), document.removeEventListener("click", s), o.remove();
391
391
  };
@@ -394,9 +394,9 @@ var U = "play-audio-info", W = 500, G = class {
394
394
  this.#r?.(), this.#r = null, this.#n = null;
395
395
  }
396
396
  };
397
- function ce(e) {
397
+ function se(e) {
398
398
  let t = document.createElement("div");
399
- t.id = `${U}-${Math.random().toString(36).slice(2, 10)}`, t.className = U, Object.assign(t.style, {
399
+ t.id = `${W}-${Math.random().toString(36).slice(2, 10)}`, t.className = W, Object.assign(t.style, {
400
400
  position: "absolute",
401
401
  top: "0",
402
402
  width: "100%",
@@ -413,7 +413,7 @@ function ce(e) {
413
413
  }
414
414
  //#endregion
415
415
  //#region src/sanitize-model-html.ts
416
- var K = [
416
+ var q = [
417
417
  "script",
418
418
  "embed",
419
419
  "base",
@@ -422,7 +422,7 @@ var K = [
422
422
  "link",
423
423
  "style",
424
424
  "foreignobject"
425
- ], q = [
425
+ ], J = [
426
426
  "onerror",
427
427
  "onload",
428
428
  "onclick",
@@ -440,7 +440,7 @@ var K = [
440
440
  "onbeforeunload",
441
441
  "formaction",
442
442
  "xlink:href"
443
- ], le = /* @__PURE__ */ new Set([
443
+ ], ce = /* @__PURE__ */ new Set([
444
444
  "iframe",
445
445
  "object",
446
446
  "mstack",
@@ -453,7 +453,7 @@ var K = [
453
453
  "semantics",
454
454
  "annotation",
455
455
  "none"
456
- ]), ue = /^[a-z_][\w.-]*:[a-z][\w.-]*$/, de = [
456
+ ]), le = /^[a-z_][\w.-]*:[a-z][\w.-]*$/, ue = [
457
457
  "alignment",
458
458
  "target",
459
459
  "allow",
@@ -473,18 +473,18 @@ var K = [
473
473
  "rightoverhang",
474
474
  "mslinethickness",
475
475
  "linebreak"
476
- ], fe = /^\s*document\.getElementById\((['"])([^'"]+)\1\)\.play\(\)\s*;?\s*(?:return\s+false\s*;?\s*)?$/, J = "data-pie-play-audio", Y = {
477
- ADD_TAGS: (e) => le.has(e) || ue.test(e),
478
- ADD_ATTR: de,
479
- FORBID_TAGS: K,
480
- FORBID_ATTR: [...q, ...L],
476
+ ], de = /^\s*document\.getElementById\((['"])([^'"]+)\1\)\.play\(\)\s*;?\s*(?:return\s+false\s*;?\s*)?$/, Y = "data-pie-play-audio", fe = {
477
+ ADD_TAGS: (e) => ce.has(e) || le.test(e),
478
+ ADD_ATTR: ue,
479
+ FORBID_TAGS: q,
480
+ FORBID_ATTR: [...J, ...R],
481
481
  ALLOW_UNKNOWN_PROTOCOLS: !1,
482
482
  RETURN_TRUSTED_TYPE: !1
483
483
  }, pe = !1;
484
484
  function me(e) {
485
485
  for (let t of e.composedPath()) {
486
486
  if (!(t instanceof Element)) continue;
487
- let n = t.getAttribute(J);
487
+ let n = t.getAttribute(Y);
488
488
  if (n === null) continue;
489
489
  e.preventDefault();
490
490
  let r = t.getRootNode().getElementById?.(n) ?? document.getElementById(n);
@@ -496,16 +496,16 @@ var X = null;
496
496
  function he() {
497
497
  return X || (X = e(window), X.addHook("beforeSanitizeAttributes", (e) => {
498
498
  if (e.nodeName !== "A") return;
499
- let t = fe.exec(e.getAttribute("onclick") ?? "")?.[2];
500
- t !== void 0 && (e.removeAttribute("onclick"), e.setAttribute(J, t), pe ||= (document.addEventListener("click", me), !0));
501
- }), X.addHook("afterSanitizeAttributes", v), X);
499
+ let t = de.exec(e.getAttribute("onclick") ?? "")?.[2];
500
+ t !== void 0 && (e.removeAttribute("onclick"), e.setAttribute(Y, t), pe ||= (document.addEventListener("click", me), !0));
501
+ }), X.addHook("afterSanitizeAttributes", g), X);
502
502
  }
503
503
  var Z = 1e6, Q = /* @__PURE__ */ new Map(), $ = 0;
504
504
  function ge(t) {
505
505
  if (t == null || t === "" || !e.isSupported) return "";
506
506
  let n = typeof t == "string" ? t : String(t), r = Q.get(n);
507
507
  if (r !== void 0) return r;
508
- let i = String(he().sanitize(n, Y)), a = n.length + i.length;
508
+ let i = String(he().sanitize(n, fe)), a = n.length + i.length;
509
509
  if (a > Z) return i;
510
510
  for (let [e, t] of Q) {
511
511
  if ($ + a <= Z) break;
@@ -514,4 +514,10 @@ function ge(t) {
514
514
  return Q.set(n, i), $ += a, i;
515
515
  }
516
516
  //#endregion
517
- export { m as AUTHORED_BORDER_ATTR, p as AUTHORED_FILL_ATTR, f as AUTHORED_INK_ATTR, L as AUTOPLAY_AUDIO_MARKUP_ATTRS, q as MODEL_HTML_FORBIDDEN_ATTRS, K as MODEL_HTML_FORBIDDEN_TAGS, J as PLAY_AUDIO_ATTR, se as PromptAudioTracker, G as PromptAudioWatcher, u as assignProps, I as autoplayAudioOn, B as bindPromptAudio, a as clamp, s as debounce, t as debug, n as isEmpty, v as markAuthoredColors, H as promptAudioPending, ge as sanitizeModelHtml, d as sessionsEqual, r as showFeedback, i as showRationale, c as shuffle, o as uuid, R as withPromptAudioTiming };
517
+ //#region src/ime.ts
518
+ var _e = 229;
519
+ function ve(e) {
520
+ return e ? !!(e.isComposing || e.nativeEvent?.isComposing || e.keyCode === _e) : !1;
521
+ }
522
+ //#endregion
523
+ export { m as AUTHORED_BORDER_ATTR, p as AUTHORED_FILL_ATTR, f as AUTHORED_INK_ATTR, R as AUTOPLAY_AUDIO_MARKUP_ATTRS, J as MODEL_HTML_FORBIDDEN_ATTRS, q as MODEL_HTML_FORBIDDEN_TAGS, Y as PLAY_AUDIO_ATTR, oe as PromptAudioTracker, K as PromptAudioWatcher, u as assignProps, L as autoplayAudioOn, V as bindPromptAudio, a as clamp, s as debounce, t as debug, ve as isComposingKeyEvent, n as isEmpty, g as markAuthoredColors, U as promptAudioPending, ge as sanitizeModelHtml, d as sessionsEqual, r as showFeedback, i as showRationale, c as shuffle, o as uuid, z as withPromptAudioTiming };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/shared-utils",
3
- "version": "0.1.7-next.20261023101922",
3
+ "version": "0.1.7-next.20261024175806",
4
4
  "description": "Shared utilities for PIE elements",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "clean": "rm -rf dist"
22
22
  },
23
23
  "dependencies": {
24
- "@pie-element/shared-types": "0.2.4-next.20261023101922",
24
+ "@pie-element/shared-types": "0.2.4-next.20261024053312",
25
25
  "dompurify": "^3.4.17"
26
26
  },
27
27
  "publishConfig": {