@kubohiroya/turbowarp-bubble 0.10.0 → 0.12.0

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.
@@ -4685,22 +4685,84 @@ function Fi(e) {
4685
4685
  });
4686
4686
  }
4687
4687
  //#endregion
4688
+ //#region src/content-run.ts
4689
+ function Ii(e) {
4690
+ return typeof e == "object" && !!e && !Array.isArray(e);
4691
+ }
4692
+ function Li(e, t) {
4693
+ let n = /* @__PURE__ */ new Set(["type", ...t]), r = Object.keys(e).filter((e) => !n.has(e));
4694
+ if (r.length > 0) throw TypeError(`Bubble content run has unknown properties: ${r.join(", ")}.`);
4695
+ for (let n of t) if (typeof e[n] != "string") throw TypeError(`Bubble content run ${n} must be a string.`);
4696
+ }
4697
+ function Ri(e) {
4698
+ if (!Ii(e)) throw TypeError("Bubble content run must be an object.");
4699
+ if (e.type === "text") return Li(e, ["text"]), Object.freeze({
4700
+ text: e.text,
4701
+ type: "text"
4702
+ });
4703
+ if (e.type === "ruby") {
4704
+ Li(e, ["base", "reading"]);
4705
+ let t = e.base, n = e.reading;
4706
+ if (t.length === 0) throw TypeError("Bubble ruby run base must not be empty.");
4707
+ if (n.length === 0) throw TypeError("Bubble ruby run reading must not be empty.");
4708
+ return Object.freeze({
4709
+ base: t,
4710
+ reading: n,
4711
+ type: "ruby"
4712
+ });
4713
+ }
4714
+ throw TypeError("Bubble content run type must be text or ruby.");
4715
+ }
4716
+ function zi(e) {
4717
+ if (typeof e == "string") return Object.freeze([Object.freeze({
4718
+ text: e,
4719
+ type: "text"
4720
+ })]);
4721
+ if (!Array.isArray(e)) throw TypeError("Bubble text must be a string or content run array.");
4722
+ let t = e.map((e) => Ri(e)).filter((e) => e.type !== "text" || e.text.length > 0);
4723
+ return t.length === 0 ? Object.freeze([Object.freeze({
4724
+ text: "",
4725
+ type: "text"
4726
+ })]) : Object.freeze(t);
4727
+ }
4728
+ function Bi(e) {
4729
+ return e.every((e) => e.type === "text");
4730
+ }
4731
+ function Vi(e) {
4732
+ return e.map((e) => e.type === "ruby" ? e.base : e.text).join("");
4733
+ }
4734
+ function Hi(e) {
4735
+ let t = [];
4736
+ for (let n of e) {
4737
+ let e = t[t.length - 1];
4738
+ if (n.type === "text" && e?.type === "text") {
4739
+ t[t.length - 1] = Object.freeze({
4740
+ text: `${e.text}${n.text}`,
4741
+ type: "text"
4742
+ });
4743
+ continue;
4744
+ }
4745
+ t.push(n);
4746
+ }
4747
+ return Object.freeze(t);
4748
+ }
4749
+ //#endregion
4688
4750
  //#region src/reveal.ts
4689
- var Ii = Object.freeze([
4751
+ var Ui = Object.freeze([
4690
4752
  "CHARACTER",
4691
4753
  "WORD",
4692
4754
  "LINE",
4693
4755
  "BLOCK"
4694
4756
  ]);
4695
- function Li(e) {
4757
+ function Wi(e) {
4696
4758
  let t = globalThis.Intl?.Segmenter;
4697
4759
  return typeof t == "function" ? [...new t(void 0, { granularity: "grapheme" }).segment(e)].map(({ segment: e }) => e) : Array.from(e);
4698
4760
  }
4699
- function Ri(e) {
4700
- if (typeof e != "string" || !Ii.includes(e)) throw TypeError("Bubble reveal unit must be CHARACTER, WORD, LINE, or BLOCK.");
4761
+ function Gi(e) {
4762
+ if (typeof e != "string" || !Ui.includes(e)) throw TypeError("Bubble reveal unit must be CHARACTER, WORD, LINE, or BLOCK.");
4701
4763
  return e;
4702
4764
  }
4703
- function zi(e) {
4765
+ function Ki(e) {
4704
4766
  if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError("Bubble reveal must be an object.");
4705
4767
  let t = e, n = /* @__PURE__ */ new Set([
4706
4768
  "unit",
@@ -4711,7 +4773,7 @@ function zi(e) {
4711
4773
  "sound"
4712
4774
  ]);
4713
4775
  if (Object.keys(t).filter((e) => !n.has(e)).length > 0 || t.unit === void 0) throw TypeError("Bubble reveal has unknown or missing properties.");
4714
- let r = Ri(t.unit), i = t.delimiters ?? " \r\n";
4776
+ let r = Gi(t.unit), i = t.delimiters ?? " \r\n";
4715
4777
  if (typeof i != "string" || i.length === 0) throw TypeError("Bubble WORD delimiters must be a non-empty string.");
4716
4778
  let a = t.showDelimiters ?? !1;
4717
4779
  if (typeof a != "boolean") throw TypeError("Bubble reveal showDelimiters must be boolean.");
@@ -4730,16 +4792,16 @@ function zi(e) {
4730
4792
  ...c === void 0 ? {} : { sound: c }
4731
4793
  });
4732
4794
  }
4733
- function Bi(e, t, n) {
4795
+ function qi(e, t, n) {
4734
4796
  let r = new Set(Array.from(t)), i = [], a = "";
4735
- for (let t of Li(e)) a += t, r.has(t) && ((n || a.slice(0, -t.length).length > 0) && i.push(n ? a : a.slice(0, -t.length)), a = "");
4797
+ for (let t of Wi(e)) a += t, r.has(t) && ((n || a.slice(0, -t.length).length > 0) && i.push(n ? a : a.slice(0, -t.length)), a = "");
4736
4798
  return a.length > 0 && i.push(a), i.filter((e) => e.length > 0);
4737
4799
  }
4738
- function Vi(e, t) {
4800
+ function Ji(e, t) {
4739
4801
  if (e.length === 0) return Object.freeze([""]);
4740
- if (t.unit === "CHARACTER") return Object.freeze(Li(e));
4802
+ if (t.unit === "CHARACTER") return Object.freeze(Wi(e));
4741
4803
  if (t.unit === "WORD") {
4742
- let n = Bi(e, t.delimiters, t.showDelimiters);
4804
+ let n = qi(e, t.delimiters, t.showDelimiters);
4743
4805
  if (t.showDelimiters) return Object.freeze(n);
4744
4806
  let r = [], i = 0;
4745
4807
  for (let a of n) {
@@ -4757,30 +4819,72 @@ function Vi(e, t) {
4757
4819
  let i = r;
4758
4820
  return Object.freeze(i.length > 0 ? i : [e]);
4759
4821
  }
4760
- function Hi(e, t) {
4761
- return e.slice(0, Math.max(0, Math.min(t, e.length))).join("");
4822
+ function Yi(e) {
4823
+ return Object.freeze(Hi(Object.freeze([...e])));
4824
+ }
4825
+ function Xi(e) {
4826
+ return Object.freeze({
4827
+ text: e,
4828
+ type: "text"
4829
+ });
4830
+ }
4831
+ function Zi(e, t) {
4832
+ let n = [], r = [], i = () => {
4833
+ r.length !== 0 && (n.push(Yi(r)), r = []);
4834
+ };
4835
+ for (let n of e) {
4836
+ if (n.type === "ruby") {
4837
+ r.push(n);
4838
+ continue;
4839
+ }
4840
+ if (t === "LINE") {
4841
+ for (let e of n.text.split(/(?<=\n)/u)) e.length !== 0 && (r.push(Xi(e)), e.endsWith("\n") && i());
4842
+ continue;
4843
+ }
4844
+ let e = n.text.split(/(\n{2,})/u);
4845
+ for (let [t, n] of e.entries()) n.length !== 0 && (r.push(Xi(n)), t % 2 == 1 && i());
4846
+ }
4847
+ return i(), Object.freeze(n.length > 0 ? n : [Yi(e)]);
4848
+ }
4849
+ function Qi(e, t) {
4850
+ if (Bi(e)) return Object.freeze(Ji(Vi(e), t).map((e) => Object.freeze([Xi(e)])));
4851
+ if (t.unit === "LINE" || t.unit === "BLOCK") return Zi(e, t.unit);
4852
+ let n = [];
4853
+ for (let r of e) {
4854
+ if (r.type === "ruby") {
4855
+ n.push(Object.freeze([r]));
4856
+ continue;
4857
+ }
4858
+ let e = t.unit === "CHARACTER" ? Wi(r.text) : qi(r.text, t.delimiters, t.showDelimiters);
4859
+ for (let t of e) n.push(Object.freeze([Xi(t)]));
4860
+ }
4861
+ return Object.freeze(n.length > 0 ? n : [Object.freeze([Xi("")])]);
4862
+ }
4863
+ function $i(e, t) {
4864
+ let n = e.slice(0, Math.max(0, Math.min(t, e.length)));
4865
+ return Hi(Object.freeze(n.flat()));
4762
4866
  }
4763
4867
  //#endregion
4764
4868
  //#region src/portrait-layout.ts
4765
- var Ui = Object.freeze([
4869
+ var ea = Object.freeze([
4766
4870
  "left",
4767
4871
  "right",
4768
4872
  "top-left",
4769
4873
  "top-right",
4770
4874
  "bottom-left",
4771
4875
  "bottom-right"
4772
- ]), Wi = Object.freeze({
4876
+ ]), ta = Object.freeze({
4773
4877
  x: 0,
4774
4878
  y: 0,
4775
4879
  zoomPercent: 100
4776
4880
  });
4777
- function Gi(e) {
4881
+ function na(e) {
4778
4882
  if (typeof e != "string") throw TypeError("Bubble portrait placement must be a string.");
4779
4883
  let t = e.trim().toLowerCase().replaceAll("_", "-");
4780
- if (!Ui.includes(t)) throw TypeError(`Unsupported Bubble portrait placement: ${e}`);
4884
+ if (!ea.includes(t)) throw TypeError(`Unsupported Bubble portrait placement: ${e}`);
4781
4885
  return t;
4782
4886
  }
4783
- function Ki(e) {
4887
+ function ra(e) {
4784
4888
  if (!Array.isArray(e) || e.length !== 2 && e.length !== 3) throw TypeError("Bubble portrait offset must be [x, y] or [x, y, zoom].");
4785
4889
  let [t, n, r = 100] = e;
4786
4890
  if (![
@@ -4794,11 +4898,11 @@ function Ki(e) {
4794
4898
  zoomPercent: r
4795
4899
  });
4796
4900
  }
4797
- function qi(e) {
4901
+ function ia(e) {
4798
4902
  if (typeof e != "number" || !Number.isFinite(e) || e < 0) throw TypeError("Bubble portrait corner radius must be zero or greater.");
4799
4903
  return e;
4800
4904
  }
4801
- var Ji = Object.freeze([
4905
+ var aa = Object.freeze([
4802
4906
  "placement",
4803
4907
  "maxWidth",
4804
4908
  "textLocale",
@@ -4813,13 +4917,13 @@ var Ji = Object.freeze([
4813
4917
  "showAnimation",
4814
4918
  "hideAnimation"
4815
4919
  ]);
4816
- function Yi(e) {
4920
+ function oa(e) {
4817
4921
  return typeof e == "object" && !!e && !Array.isArray(e);
4818
4922
  }
4819
- function Xi(e) {
4820
- return !Yi(e) || typeof e.textStyle != "string" || e.textStyle.trim() !== "default" ? "custom" : Ji.every((t) => e[t] === void 0) ? "scratch-default" : "custom";
4923
+ function sa(e) {
4924
+ return !oa(e) || typeof e.textStyle != "string" || e.textStyle.trim() !== "default" ? "custom" : aa.every((t) => e[t] === void 0) ? "scratch-default" : "custom";
4821
4925
  }
4822
- function Zi(e) {
4926
+ function ca(e) {
4823
4927
  let t = 0;
4824
4928
  for (let n of e) if (!/\p{Mark}/u.test(n)) {
4825
4929
  if (/\s/u.test(n)) {
@@ -4830,7 +4934,7 @@ function Zi(e) {
4830
4934
  }
4831
4935
  return t * 14;
4832
4936
  }
4833
- function Qi(e, t = Zi) {
4937
+ function la(e, t = ca) {
4834
4938
  let n = Fi({
4835
4939
  text: e.slice(0, 330),
4836
4940
  maxWidth: 170,
@@ -4839,9 +4943,9 @@ function Qi(e, t = Zi) {
4839
4943
  try {
4840
4944
  n = t(e);
4841
4945
  } catch {
4842
- return Zi(e);
4946
+ return ca(e);
4843
4947
  }
4844
- return Number.isFinite(n) && n >= 0 ? n : Zi(e);
4948
+ return Number.isFinite(n) && n >= 0 ? n : ca(e);
4845
4949
  }
4846
4950
  }), r = Object.freeze(n.lines.map((e) => Object.freeze({
4847
4951
  text: e.text,
@@ -4853,7 +4957,7 @@ function Qi(e, t = Zi) {
4853
4957
  text: r.map((e) => e.text).join("\n")
4854
4958
  });
4855
4959
  }
4856
- function $i(e) {
4960
+ function ua(e) {
4857
4961
  let t = Math.max(1, e.lines.length), n = Math.max(e.maxLineWidth, 50) + 20, r = 16 * t + 20;
4858
4962
  return Object.freeze({
4859
4963
  bodyHeight: r + 4,
@@ -4864,7 +4968,7 @@ function $i(e) {
4864
4968
  width: n + 4
4865
4969
  });
4866
4970
  }
4867
- function ea(e) {
4971
+ function da(e) {
4868
4972
  let t = -e.stageWidth / 2, n = e.stageWidth / 2, r = e.stageHeight / 2, i = e.pointsLeft;
4869
4973
  !i && e.width + e.bounds.right > n && e.bounds.left - e.width > t ? i = !0 : i && e.bounds.left - e.width < t && e.width + e.bounds.right < n && (i = !1);
4870
4974
  let a = i ? Math.min(n - e.width, Math.max(t, e.bounds.left - e.width)) : Math.max(t, Math.min(n - e.width, e.bounds.right)), o = Math.min(r, e.bounds.bottom + e.height);
@@ -4876,10 +4980,10 @@ function ea(e) {
4876
4980
  top: o
4877
4981
  });
4878
4982
  }
4879
- function ta(e) {
4983
+ function fa(e) {
4880
4984
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
4881
4985
  }
4882
- function na(e) {
4986
+ function pa(e) {
4883
4987
  let { paddedHeight: t, paddedWidth: n } = e, r = Math.min(16, n / 2, t / 2);
4884
4988
  return [
4885
4989
  `M ${r} ${t}`,
@@ -4892,16 +4996,16 @@ function na(e) {
4892
4996
  `Q ${n} ${t} ${n - r} ${t}`
4893
4997
  ].join(" ");
4894
4998
  }
4895
- function ra(e) {
4999
+ function ma(e) {
4896
5000
  let { paddedHeight: t, paddedWidth: n } = e;
4897
- return `<path d="${`${na(e)} C ${n - 16} ${t + 4} ${n - 12} ${t + 8} ${n - 12} ${t + 10} Q ${n - 12} ${t + 12} ${n - 14} ${t + 12} C ${n - 17} ${t + 12} ${n - 27} ${t + 8} ${n - 32} ${t} Z`}" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" stroke-linejoin="round" paint-order="stroke fill"/>`;
5001
+ return `<path d="${`${pa(e)} C ${n - 16} ${t + 4} ${n - 12} ${t + 8} ${n - 12} ${t + 10} Q ${n - 12} ${t + 12} ${n - 14} ${t + 12} C ${n - 17} ${t + 12} ${n - 27} ${t + 8} ${n - 32} ${t} Z`}" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" stroke-linejoin="round" paint-order="stroke fill"/>`;
4898
5002
  }
4899
- function ia(e) {
5003
+ function ha(e) {
4900
5004
  let { paddedHeight: t, paddedWidth: n } = e;
4901
- return `<path d="${`${na(e)} L ${n - 28} ${t} A 4 4 0 0 1 ${n - 36} ${t} Z`}" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" stroke-linejoin="round" paint-order="stroke fill"/><circle cx="${n - 25.25}" cy="${t + 7.25}" r="2.25" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" paint-order="stroke fill"/><circle cx="${n - 17.5}" cy="${t + 9.5}" r="1.5" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" paint-order="stroke fill"/>`;
5005
+ return `<path d="${`${pa(e)} L ${n - 28} ${t} A 4 4 0 0 1 ${n - 36} ${t} Z`}" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" stroke-linejoin="round" paint-order="stroke fill"/><circle cx="${n - 25.25}" cy="${t + 7.25}" r="2.25" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" paint-order="stroke fill"/><circle cx="${n - 17.5}" cy="${t + 9.5}" r="1.5" fill="white" stroke="rgba(0, 0, 0, 0.15)" stroke-width="4" paint-order="stroke fill"/>`;
4902
5006
  }
4903
- function aa(e) {
4904
- let t = $i(e.layout), n = e.kind === "say" ? ra(t) : ia(t), r = e.pointsLeft ? "translate(2 2)" : `translate(${t.width} 0) scale(-1 1) translate(2 2)`, i = e.layout.lines.map((e, t) => `<text x="12" y="${24.6 + 16 * t}" fill="#575E75" font-family="Helvetica, sans-serif" font-size="14" xml:space="preserve">${ta(e.text)}</text>`).join(""), a = ta(e.title ?? `${e.kind} bubble`);
5007
+ function ga(e) {
5008
+ let t = ua(e.layout), n = e.kind === "say" ? ma(t) : ha(t), r = e.pointsLeft ? "translate(2 2)" : `translate(${t.width} 0) scale(-1 1) translate(2 2)`, i = e.layout.lines.map((e, t) => `<text x="12" y="${24.6 + 16 * t}" fill="#575E75" font-family="Helvetica, sans-serif" font-size="14" xml:space="preserve">${fa(e.text)}</text>`).join(""), a = fa(e.title ?? `${e.kind} bubble`);
4905
5009
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}" role="img" data-bubble-profile="scratch-default" data-bubble-kind="${e.kind}"><title>${a}</title><g transform="${r}">${n}</g>${i}</svg>`;
4906
5010
  }
4907
5011
  //#endregion
@@ -4911,11 +5015,11 @@ var Z = class extends Error {
4911
5015
  constructor(e, t) {
4912
5016
  super(t), this.name = "BubbleCompositionError", this.code = e;
4913
5017
  }
4914
- }, oa = /* @__PURE__ */ new Set(["say", "think"]), sa = /* @__PURE__ */ new Set([
5018
+ }, _a = /* @__PURE__ */ new Set(["say", "think"]), va = /* @__PURE__ */ new Set([
4915
5019
  "idle",
4916
5020
  "talking",
4917
5021
  "awaiting-continue"
4918
- ]), ca = /* @__PURE__ */ new Set([
5022
+ ]), ya = /* @__PURE__ */ new Set([
4919
5023
  "fadeIn",
4920
5024
  "fadeOut",
4921
5025
  "floatIn",
@@ -4927,7 +5031,7 @@ var Z = class extends Error {
4927
5031
  "shake",
4928
5032
  "explode",
4929
5033
  "animateBubbleShape"
4930
- ]), la = /* @__PURE__ */ new Set([
5034
+ ]), ba = /* @__PURE__ */ new Set([
4931
5035
  "linear",
4932
5036
  "easeIn",
4933
5037
  "easeOut",
@@ -4936,45 +5040,45 @@ var Z = class extends Error {
4936
5040
  function Q(e) {
4937
5041
  return typeof e == "object" && !!e && !Array.isArray(e);
4938
5042
  }
4939
- function ua(e, t, n, r) {
5043
+ function xa(e, t, n, r) {
4940
5044
  let i = /* @__PURE__ */ new Set([...t, ...n]), a = t.filter((t) => !Object.prototype.hasOwnProperty.call(e, t)), o = Object.keys(e).filter((e) => !i.has(e));
4941
5045
  if (a.length > 0 || o.length > 0) throw new Z("BUBBLE-COMPOSITION-001", `${r} has missing or unknown properties.`);
4942
5046
  }
4943
- function da(e, t) {
5047
+ function Sa(e, t) {
4944
5048
  if (typeof e != "string" || e.trim().length === 0) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be a non-empty string.`);
4945
5049
  return e.trim();
4946
5050
  }
4947
- function fa(e, t) {
5051
+ function Ca(e, t) {
4948
5052
  if (typeof e != "string" || e.length === 0) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be a non-empty string.`);
4949
5053
  return e;
4950
5054
  }
4951
- function pa(e, t, n) {
5055
+ function wa(e, t, n) {
4952
5056
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be an object.`);
4953
- if (ua(e, ["frames", "frameIntervalSeconds"], [], t), !Array.isArray(e.frames) || e.frames.length < n) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frames must contain at least ${n} image asset name${n === 1 ? "" : "s"}.`);
4954
- let r = Object.freeze(e.frames.map((e, n) => fa(e, `${t}.frames[${n}]`))), i = e.frameIntervalSeconds;
5057
+ if (xa(e, ["frames", "frameIntervalSeconds"], [], t), !Array.isArray(e.frames) || e.frames.length < n) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frames must contain at least ${n} image asset name${n === 1 ? "" : "s"}.`);
5058
+ let r = Object.freeze(e.frames.map((e, n) => Ca(e, `${t}.frames[${n}]`))), i = e.frameIntervalSeconds;
4955
5059
  if (typeof i != "number" || !Number.isFinite(i) || i <= 0) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frameIntervalSeconds must be a positive finite number.`);
4956
5060
  return Object.freeze({
4957
5061
  frames: r,
4958
5062
  frameIntervalSeconds: i
4959
5063
  });
4960
5064
  }
4961
- function ma(e) {
5065
+ function Ta(e) {
4962
5066
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
4963
- ua(e, ["base"], [
5067
+ xa(e, ["base"], [
4964
5068
  "blink",
4965
5069
  "lipSync",
4966
5070
  "placement",
4967
5071
  "offset",
4968
5072
  "cornerRadius"
4969
5073
  ], "Bubble portrait");
4970
- let t = e.blink === void 0 ? void 0 : pa(e.blink, "Bubble portrait blink", 1), n = e.lipSync === void 0 ? void 0 : pa(e.lipSync, "Bubble portrait lip-sync", 1), r, i, a;
5074
+ let t = e.blink === void 0 ? void 0 : wa(e.blink, "Bubble portrait blink", 1), n = e.lipSync === void 0 ? void 0 : wa(e.lipSync, "Bubble portrait lip-sync", 1), r, i, a;
4971
5075
  try {
4972
- r = Gi(e.placement ?? "left"), i = e.offset === void 0 ? Wi : Ki(e.offset), a = qi(e.cornerRadius ?? 0);
5076
+ r = na(e.placement ?? "left"), i = e.offset === void 0 ? ta : ra(e.offset), a = ia(e.cornerRadius ?? 0);
4973
5077
  } catch (e) {
4974
5078
  throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble portrait layout is invalid.");
4975
5079
  }
4976
5080
  return Object.freeze({
4977
- base: fa(e.base, "Bubble portrait base"),
5081
+ base: Ca(e.base, "Bubble portrait base"),
4978
5082
  ...t === void 0 ? {} : { blink: t },
4979
5083
  ...n === void 0 ? {} : { lipSync: n },
4980
5084
  placement: r,
@@ -4982,9 +5086,9 @@ function ma(e) {
4982
5086
  cornerRadius: a
4983
5087
  });
4984
5088
  }
4985
- function ha(e, t) {
5089
+ function Ea(e, t) {
4986
5090
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be an object.`);
4987
- if (ua(e, ["name"], [
5091
+ if (xa(e, ["name"], [
4988
5092
  "durationSeconds",
4989
5093
  "ease",
4990
5094
  "direction",
@@ -4992,7 +5096,7 @@ function ha(e, t) {
4992
5096
  "relativeScale",
4993
5097
  "speed",
4994
5098
  "visualStyle"
4995
- ], t), !ca.has(e.name)) throw new Z("BUBBLE-COMPOSITION-001", `${t}.name is not a supported Bubble motion.`);
5099
+ ], t), !ya.has(e.name)) throw new Z("BUBBLE-COMPOSITION-001", `${t}.name is not a supported Bubble motion.`);
4996
5100
  let n = (n, r, i = !1) => {
4997
5101
  let a = e[n];
4998
5102
  if (a !== void 0) {
@@ -5002,7 +5106,7 @@ function ha(e, t) {
5002
5106
  }, r = n("durationSeconds", 0), i = n("count", 1, !0), a = n("relativeScale", 0), o = n("speed", 0), s = e.direction;
5003
5107
  if (s !== void 0 && typeof s != "number" && typeof s != "string") throw new Z("BUBBLE-COMPOSITION-001", `${t}.direction is invalid.`);
5004
5108
  let c = e.ease ?? "easeInOut";
5005
- if (typeof c != "string" || !la.has(c)) throw new Z("BUBBLE-COMPOSITION-001", `${t}.ease is invalid.`);
5109
+ if (typeof c != "string" || !ba.has(c)) throw new Z("BUBBLE-COMPOSITION-001", `${t}.ease is invalid.`);
5006
5110
  let l = e.visualStyle;
5007
5111
  if (l !== void 0 && (typeof l != "string" || !$e.includes(l))) throw new Z("BUBBLE-COMPOSITION-001", `${t}.visualStyle is invalid.`);
5008
5112
  return Object.freeze({
@@ -5016,10 +5120,10 @@ function ha(e, t) {
5016
5120
  ...l === void 0 ? {} : { visualStyle: l }
5017
5121
  });
5018
5122
  }
5019
- function ga(e) {
5123
+ function Da(e) {
5020
5124
  if (e === void 0) return;
5021
5125
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble audio must be an object.");
5022
- ua(e, [], [
5126
+ xa(e, [], [
5023
5127
  "voice",
5024
5128
  "reveal",
5025
5129
  "finish"
@@ -5031,13 +5135,13 @@ function ga(e) {
5031
5135
  "finish"
5032
5136
  ]) {
5033
5137
  let r = e[n];
5034
- r !== void 0 && (t[n] = fa(r, `Bubble audio ${n}`));
5138
+ r !== void 0 && (t[n] = Ca(r, `Bubble audio ${n}`));
5035
5139
  }
5036
5140
  return Object.freeze(t);
5037
5141
  }
5038
- function _a(e) {
5142
+ function Oa(e) {
5039
5143
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
5040
- ua(e, ["name", "textStyle"], [
5144
+ xa(e, ["name", "textStyle"], [
5041
5145
  "placement",
5042
5146
  "maxWidth",
5043
5147
  "textLocale",
@@ -5052,13 +5156,13 @@ function _a(e) {
5052
5156
  "showAnimation",
5053
5157
  "hideAnimation"
5054
5158
  ], "Bubble style");
5055
- let t = e.portrait === void 0 ? void 0 : ma(e.portrait), n = e.continueIndicator === void 0 ? void 0 : pa(e.continueIndicator, "Bubble continue indicator", 2), r;
5159
+ let t = e.portrait === void 0 ? void 0 : Ta(e.portrait), n = e.continueIndicator === void 0 ? void 0 : wa(e.continueIndicator, "Bubble continue indicator", 2), r;
5056
5160
  if (e.reveal !== void 0) try {
5057
- r = zi(e.reveal);
5161
+ r = Ki(e.reveal);
5058
5162
  } catch (e) {
5059
5163
  throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble reveal is invalid.");
5060
5164
  }
5061
- let i = ga(e.audio), a = e.showAnimation === void 0 ? void 0 : ha(e.showAnimation, "Bubble showAnimation"), o = e.hideAnimation === void 0 ? void 0 : ha(e.hideAnimation, "Bubble hideAnimation"), s;
5165
+ let i = Da(e.audio), a = e.showAnimation === void 0 ? void 0 : Ea(e.showAnimation, "Bubble showAnimation"), o = e.hideAnimation === void 0 ? void 0 : Ea(e.hideAnimation, "Bubble hideAnimation"), s;
5062
5166
  try {
5063
5167
  s = ze(e.placement ?? "up-right");
5064
5168
  } catch (e) {
@@ -5077,10 +5181,10 @@ function _a(e) {
5077
5181
  if (typeof e.maxWidth != "number" || !Number.isFinite(e.maxWidth) || e.maxWidth <= 0) throw new Z("BUBBLE-COMPOSITION-001", "Bubble style maxWidth must be a positive finite number.");
5078
5182
  f = e.maxWidth;
5079
5183
  }
5080
- let p = e.textLocale === void 0 ? void 0 : da(e.textLocale, "Bubble style text locale"), m = Xi(e);
5184
+ let p = e.textLocale === void 0 ? void 0 : Sa(e.textLocale, "Bubble style text locale"), m = sa(e);
5081
5185
  return Object.freeze({
5082
- name: da(e.name, "Bubble style name"),
5083
- textStyle: da(e.textStyle, "Bubble text style name"),
5186
+ name: Sa(e.name, "Bubble style name"),
5187
+ textStyle: Sa(e.textStyle, "Bubble text style name"),
5084
5188
  layoutProfile: m,
5085
5189
  ...f === void 0 ? {} : { maxWidth: f },
5086
5190
  ...p === void 0 ? {} : { textLocale: p },
@@ -5097,13 +5201,13 @@ function _a(e) {
5097
5201
  ...o === void 0 ? {} : { hideAnimation: o }
5098
5202
  });
5099
5203
  }
5100
- function va(e) {
5204
+ function ka(e) {
5101
5205
  if (e !== void 0) {
5102
5206
  if (!Q(e) || typeof e.applyToTarget != "function" || typeof e.getMimeType != "function" || typeof e.isRegistered != "function") throw TypeError("Bubble image capability must provide applyToTarget, getMimeType, and isRegistered.");
5103
5207
  return e;
5104
5208
  }
5105
5209
  }
5106
- function ya(e) {
5210
+ function Aa(e) {
5107
5211
  if (e !== void 0) {
5108
5212
  if (!Q(e) || typeof e.playSound != "function") throw TypeError("Bubble audio capability must provide playSound.");
5109
5213
  if (e.isRegistered !== void 0 && typeof e.isRegistered != "function") throw TypeError("Bubble audio capability isRegistered must be a function.");
@@ -5111,65 +5215,77 @@ function ya(e) {
5111
5215
  return e;
5112
5216
  }
5113
5217
  }
5114
- function ba(e) {
5218
+ function ja(e) {
5115
5219
  if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", "Bubble image assets require an image capability. Provide options.imageResolver.");
5116
5220
  return e;
5117
5221
  }
5118
- function xa(e) {
5222
+ function Ma(e) {
5119
5223
  if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble text capability must provide setText and releaseTarget.");
5120
5224
  return e;
5121
5225
  }
5122
- function Sa() {
5226
+ function Na() {
5123
5227
  return Object.freeze({
5124
5228
  setTimeout: (e, t) => globalThis.setTimeout(e, t),
5125
5229
  clearTimeout: (e) => globalThis.clearTimeout(e)
5126
5230
  });
5127
5231
  }
5128
- function Ca(e) {
5232
+ function Pa(e) {
5129
5233
  if (!Q(e) || typeof e.setTimeout != "function" || typeof e.clearTimeout != "function") throw TypeError("Bubble scheduler must provide setTimeout and clearTimeout.");
5130
5234
  return e;
5131
5235
  }
5132
- function wa(e, t) {
5236
+ function Fa(e, t) {
5133
5237
  if (!Q(e) || typeof e.id != "string" || e.id.length === 0 || typeof e.isStage != "boolean") throw new Z("BUBBLE-COMPOSITION-004", `${t} must provide id and isStage.`);
5134
5238
  return e;
5135
5239
  }
5136
- function Ta(e) {
5240
+ function Ia(e) {
5137
5241
  if (typeof e != "object" || !e) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must be a non-null object.");
5138
5242
  return e;
5139
5243
  }
5140
- function Ea(e, t) {
5244
+ function La(e, t) {
5141
5245
  if (!Q(e) || !Q(e.targets) || typeof e.setLayerVisible != "function" || typeof e.updateStyle != "function" || typeof e.show != "function" || typeof e.hide != "function" || typeof e.dispose != "function") throw new Z("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
5142
5246
  let n = e.targets;
5143
- Ta(n.text);
5247
+ Ia(n.text);
5144
5248
  let r = /* @__PURE__ */ new Set(), i = (e, t) => {
5145
5249
  let i = n[e];
5146
5250
  if (!t && i === void 0) return;
5147
- let a = wa(i, `Bubble surface ${e}`);
5251
+ let a = Fa(i, `Bubble surface ${e}`);
5148
5252
  if (r.has(a.id)) throw new Z("BUBBLE-COMPOSITION-004", "Bubble image layers must use distinct target IDs.");
5149
5253
  r.add(a.id);
5150
5254
  };
5151
5255
  return i("portraitBase", t.portrait !== void 0), i("portraitBlink", t.portrait?.blink !== void 0), i("portraitLipSync", t.portrait?.lipSync !== void 0), i("continueIndicator", t.continueIndicator !== void 0), e;
5152
5256
  }
5153
- function Da(e, t) {
5257
+ function Ra(e, t) {
5154
5258
  if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", `Bubble image capability is required for: ${t}. Provide options.imageResolver.`);
5155
5259
  if (!e.isRegistered(t)) throw new Z("BUBBLE-COMPOSITION-003", `Bubble image asset is not registered: ${t}`);
5156
5260
  if (!e.getMimeType(t).startsWith("image/")) throw new Z("BUBBLE-COMPOSITION-003", `Bubble asset is not an image: ${t}`);
5157
5261
  }
5158
- function Oa(e, t) {
5262
+ function za(e, t) {
5159
5263
  if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", `Bubble audio assets require an audio capability: ${t}. Provide options.audio.`);
5160
5264
  if (e.isRegistered?.(t) === !1) throw new Z("BUBBLE-COMPOSITION-003", `Bubble audio asset is not registered: ${t}`);
5161
5265
  let n = e.getMimeType?.(t);
5162
5266
  if (n !== void 0 && !n.startsWith("audio/")) throw new Z("BUBBLE-COMPOSITION-003", `Bubble asset is not audio: ${t}`);
5163
5267
  }
5164
- function ka(e) {
5268
+ function Ba(e) {
5165
5269
  return [...e.portrait === void 0 ? [] : [
5166
5270
  e.portrait.base,
5167
5271
  ...e.portrait.blink?.frames ?? [],
5168
5272
  ...e.portrait.lipSync?.frames ?? []
5169
5273
  ], ...e.continueIndicator?.frames ?? []];
5170
5274
  }
5171
- function Aa(e, t, n) {
5172
- if (t.layoutProfile === "scratch-default") return Qi(e, (e) => typeof n.measureText == "function" ? n.measureText({
5275
+ function Va(e) {
5276
+ let t = e.setRichText;
5277
+ if (typeof t != "function") throw new Z("BUBBLE-COMPOSITION-007", "Bubble ruby content requires the text capability setRichText method.");
5278
+ return t;
5279
+ }
5280
+ function Ha(e, t, n, r) {
5281
+ return !Bi(e) && typeof r.splitRichText == "function" ? r.splitRichText({
5282
+ reveal: t,
5283
+ runs: e,
5284
+ styleName: n
5285
+ }) : Qi(e, t);
5286
+ }
5287
+ function Ua(e, t, n) {
5288
+ if (t.layoutProfile === "scratch-default") return la(e, (e) => typeof n.measureText == "function" ? n.measureText({
5173
5289
  styleName: t.textStyle,
5174
5290
  text: e
5175
5291
  }) : NaN).text;
@@ -5185,11 +5301,11 @@ function Aa(e, t, n) {
5185
5301
  }) ?? 0
5186
5302
  }).lines.map(({ text: e }) => e).join("\n");
5187
5303
  }
5188
- function ja(e, t) {
5304
+ function Wa(e, t) {
5189
5305
  if (e.length === 1) throw e[0];
5190
5306
  if (e.length > 1) throw AggregateError(e, t);
5191
5307
  }
5192
- function Ma(e) {
5308
+ function Ga(e) {
5193
5309
  let t = !1, n = 0, r = 0, i, a = Promise.resolve(), o = async (t) => {
5194
5310
  let n = e.animation.frames[t];
5195
5311
  n !== void 0 && await e.imageResolver.applyToTarget(n, e.target);
@@ -5224,40 +5340,45 @@ function Ma(e) {
5224
5340
  }
5225
5341
  });
5226
5342
  }
5227
- function Na(e) {
5343
+ function Ka(e) {
5228
5344
  if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Show bubble input must be an object.");
5229
- if (ua(e, [
5345
+ if (xa(e, [
5230
5346
  "actor",
5231
5347
  "actorKey",
5232
5348
  "kind",
5233
5349
  "text",
5234
5350
  "styleName"
5235
- ], ["animationMode", "reveal"], "Show bubble input"), !oa.has(e.kind)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble kind must be say or think.");
5236
- if (typeof e.text != "string") throw new Z("BUBBLE-COMPOSITION-001", "Bubble text must be a string.");
5237
- let t = e.animationMode ?? "talking";
5238
- if (!sa.has(t)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid.");
5239
- let n;
5351
+ ], ["animationMode", "reveal"], "Show bubble input"), !_a.has(e.kind)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble kind must be say or think.");
5352
+ let t;
5353
+ try {
5354
+ t = zi(e.text);
5355
+ } catch (e) {
5356
+ throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble text is invalid.");
5357
+ }
5358
+ let n = e.animationMode ?? "talking";
5359
+ if (!va.has(n)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid.");
5360
+ let r;
5240
5361
  if (e.reveal !== void 0) try {
5241
- n = zi(e.reveal);
5362
+ r = Ki(e.reveal);
5242
5363
  } catch (e) {
5243
5364
  throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble reveal is invalid.");
5244
5365
  }
5245
5366
  return {
5246
5367
  actor: e.actor,
5247
- actorKey: da(e.actorKey, "Bubble actor key"),
5368
+ actorKey: Sa(e.actorKey, "Bubble actor key"),
5248
5369
  kind: e.kind,
5249
- text: e.text,
5250
- styleName: da(e.styleName, "Bubble style name"),
5251
- animationMode: t,
5252
- ...n === void 0 ? {} : { reveal: n }
5370
+ content: t,
5371
+ styleName: Sa(e.styleName, "Bubble style name"),
5372
+ animationMode: n,
5373
+ ...r === void 0 ? {} : { reveal: r }
5253
5374
  };
5254
5375
  }
5255
- function Pa(e) {
5376
+ function qa(e) {
5256
5377
  if (!Q(e)) throw TypeError("Bubble composition options must be an object.");
5257
- let t = va(e.imageResolver), n = ya(e.audio), r = xa(e.textCapability);
5378
+ let t = ka(e.imageResolver), n = Aa(e.audio), r = Ma(e.textCapability);
5258
5379
  if (typeof e.createSurface != "function") throw TypeError("Bubble composition createSurface must be a function.");
5259
5380
  if (e.onAnimationError !== void 0 && typeof e.onAnimationError != "function") throw TypeError("Bubble composition onAnimationError must be a function.");
5260
- let i = Ca(e.scheduler ?? Sa()), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = !1, l = () => {
5381
+ let i = Pa(e.scheduler ?? Na()), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = !1, l = () => {
5261
5382
  if (c) throw new Z("BUBBLE-COMPOSITION-005", "Bubble composition has been disposed.");
5262
5383
  }, u = async (e, t) => {
5263
5384
  let n = (s.get(e) ?? Promise.resolve()).catch(() => void 0).then(t);
@@ -5277,9 +5398,9 @@ function Pa(e) {
5277
5398
  layoutProfile: "custom",
5278
5399
  reveal: s.reveal
5279
5400
  }));
5280
- let d = s.text, f = (e) => {
5281
- let n = new Set(ka(e)), r = n.size === 0 ? void 0 : ba(t);
5282
- for (let e of n) Da(r, e);
5401
+ let d = s.content, f = (e) => {
5402
+ let n = new Set(Ba(e)), r = n.size === 0 ? void 0 : ja(t);
5403
+ for (let e of n) Ra(r, e);
5283
5404
  return r;
5284
5405
  }, p = f(u);
5285
5406
  for (let e of [
@@ -5287,13 +5408,13 @@ function Pa(e) {
5287
5408
  u.audio?.reveal,
5288
5409
  u.audio?.finish,
5289
5410
  u.reveal?.sound
5290
- ]) e !== void 0 && Oa(n, e);
5411
+ ]) e !== void 0 && za(n, e);
5291
5412
  let m = async (e, t = !1) => {
5292
5413
  e !== void 0 && n !== void 0 && await n.playSound(e, { untilDone: t });
5293
5414
  }, h = async (e, t, n) => {
5294
- let r = ka(e).length === 0 ? void 0 : ba(t), i = [];
5415
+ let r = Ba(e).length === 0 ? void 0 : ja(t), i = [];
5295
5416
  if (e.portrait) {
5296
- let t = ba(r);
5417
+ let t = ja(r);
5297
5418
  i.push(Promise.resolve(t.applyToTarget(e.portrait.base, n.targets.portraitBase)));
5298
5419
  let a = e.portrait.blink?.frames[0];
5299
5420
  a !== void 0 && i.push(Promise.resolve(t.applyToTarget(a, n.targets.portraitBlink)));
@@ -5302,169 +5423,176 @@ function Pa(e) {
5302
5423
  }
5303
5424
  let a = e.continueIndicator?.frames[0];
5304
5425
  if (a !== void 0) {
5305
- let e = ba(r);
5426
+ let e = ja(r);
5306
5427
  i.push(Promise.resolve(e.applyToTarget(a, n.targets.continueIndicator)));
5307
5428
  }
5308
5429
  await Promise.all(i);
5309
5430
  }, g = (t, n, r) => {
5310
- x = t.portrait?.blink === void 0 ? void 0 : Ma({
5431
+ x = t.portrait?.blink === void 0 ? void 0 : Ga({
5311
5432
  actorKey: s.actorKey,
5312
5433
  layer: "portraitBlink",
5313
5434
  animation: t.portrait.blink,
5314
5435
  target: r.targets.portraitBlink,
5315
- imageResolver: ba(n),
5436
+ imageResolver: ja(n),
5316
5437
  scheduler: i,
5317
5438
  ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
5318
- }), S = t.portrait?.lipSync === void 0 ? void 0 : Ma({
5439
+ }), S = t.portrait?.lipSync === void 0 ? void 0 : Ga({
5319
5440
  actorKey: s.actorKey,
5320
5441
  layer: "portraitLipSync",
5321
5442
  animation: t.portrait.lipSync,
5322
5443
  target: r.targets.portraitLipSync,
5323
- imageResolver: ba(n),
5444
+ imageResolver: ja(n),
5324
5445
  scheduler: i,
5325
5446
  ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
5326
- }), C = t.continueIndicator === void 0 ? void 0 : Ma({
5447
+ }), C = t.continueIndicator === void 0 ? void 0 : Ga({
5327
5448
  actorKey: s.actorKey,
5328
5449
  layer: "continueIndicator",
5329
5450
  animation: t.continueIndicator,
5330
5451
  target: r.targets.continueIndicator,
5331
- imageResolver: ba(n),
5452
+ imageResolver: ja(n),
5332
5453
  scheduler: i,
5333
5454
  ...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
5334
5455
  });
5335
5456
  }, _ = o.get(s.actorKey);
5336
5457
  _ && await _.close();
5337
- let v, y = !1, b = !1, x, S, C, w = u.reveal, T = w ? Vi(s.text, w) : Object.freeze([s.text]), E = w ? Math.min(1, T.length) : 1, D, O = 0;
5458
+ let v, y = !1, b = !1, x, S, C, w = u.reveal, T = w ? Ha(s.content, w, u.textStyle, r) : Object.freeze([s.content]), E = w ? Math.min(1, T.length) : 1, D, O = 0;
5338
5459
  try {
5339
- v = Ea(await e.createSurface(Object.freeze({
5460
+ v = La(await e.createSurface(Object.freeze({
5340
5461
  actor: s.actor,
5341
5462
  actorKey: s.actorKey,
5342
5463
  kind: s.kind,
5343
5464
  style: u
5344
5465
  })), u);
5345
- let t = async (e, t = u) => {
5346
- if (t.layoutProfile === "scratch-default" && v?.renderScratchText) {
5347
- let n = Qi(e, (e) => typeof r.measureText == "function" ? r.measureText({
5348
- styleName: t.textStyle,
5466
+ let t = (e, t, n) => {
5467
+ Va(r)({
5468
+ runs: e,
5469
+ styleName: t.textStyle,
5470
+ target: n,
5471
+ ...t.maxWidth === void 0 ? {} : { maxWidth: t.maxWidth }
5472
+ }), y = !0;
5473
+ }, a = () => !Bi(d), c = async (e, n = u) => {
5474
+ if (a()) {
5475
+ if (!v) return;
5476
+ if (n.layoutProfile === "scratch-default" && v.renderScratchText) throw new Z("BUBBLE-COMPOSITION-007", "Bubble ruby content requires a rich text capability; the scratch-default surface renders plain text only.");
5477
+ t(e, n, v.targets.text);
5478
+ return;
5479
+ }
5480
+ let i = Vi(e);
5481
+ if (n.layoutProfile === "scratch-default" && v?.renderScratchText) {
5482
+ let e = la(i, (e) => typeof r.measureText == "function" ? r.measureText({
5483
+ styleName: n.textStyle,
5349
5484
  text: e
5350
5485
  }) : NaN);
5351
- await v.renderScratchText(n);
5486
+ await v.renderScratchText(e);
5352
5487
  return;
5353
5488
  }
5354
5489
  v && (r.setText({
5355
- styleName: t.textStyle,
5490
+ styleName: n.textStyle,
5356
5491
  target: v.targets.text,
5357
- text: Aa(e, t, r)
5492
+ text: Ua(i, n, r)
5358
5493
  }), y = !0);
5359
- };
5360
- if (w?.layout === "RESERVED") {
5361
- let e = Aa(s.text, u, r);
5362
- r.setText({
5363
- styleName: u.textStyle,
5494
+ }, l = (e, n = u) => {
5495
+ v && (a() ? t(e, n, v.targets.text) : (r.setText({
5496
+ styleName: n.textStyle,
5364
5497
  target: v.targets.text,
5365
- text: e
5366
- }), y = !0, v.captureTextLayout?.();
5367
- }
5368
- await t(w ? Hi(T, E) : s.text), await h(u, p, v), g(u, p, v);
5369
- let a = "idle", c = !1, l = Promise.resolve(), _ = async () => {
5498
+ text: Ua(Vi(e), n, r)
5499
+ }), y = !0), v.captureTextLayout?.());
5500
+ };
5501
+ w?.layout === "RESERVED" && l(s.content), await c(w ? $i(T, E) : s.content), await h(u, p, v), g(u, p, v);
5502
+ let _ = "idle", k = !1, A = Promise.resolve(), j = async () => {
5370
5503
  if (!v) return;
5371
- let e = w ? Hi(T, E) : d;
5372
- await t(e), await v.show();
5373
- }, k = () => {
5504
+ let e = w ? $i(T, E) : d;
5505
+ await c(e), await v.show();
5506
+ }, M = () => {
5374
5507
  O += 1, D !== void 0 && i.clearTimeout(D), D = void 0;
5375
- }, A = async () => !w || E >= T.length ? !1 : (E += 1, await _(), await m(w.sound ?? u.audio?.reveal), E >= T.length && k(), !0), j = () => {
5508
+ }, N = async () => !w || E >= T.length ? !1 : (E += 1, await j(), await m(w.sound ?? u.audio?.reveal), E >= T.length && M(), !0), P = () => {
5376
5509
  if (!w || w.intervalSeconds <= 0 || E >= T.length) return;
5377
5510
  let e = O;
5378
5511
  D = i.setTimeout(() => {
5379
- D = void 0, !(c || e !== O) && (l = l.then(() => A()).then(() => j()));
5512
+ D = void 0, !(k || e !== O) && (A = A.then(() => N()).then(() => P()));
5380
5513
  }, w.intervalSeconds * 1e3);
5381
- }, M = async (e) => {
5382
- e !== a && (e === "talking" ? (await C?.stop(), await v?.setLayerVisible("continueIndicator", !1), await v?.setLayerVisible("portraitLipSync", S !== void 0), await S?.start({ primed: !0 })) : e === "awaiting-continue" ? (await S?.stop({ reset: !0 }), await v?.setLayerVisible("portraitLipSync", !1), await v?.setLayerVisible("continueIndicator", C !== void 0), await C?.start({ primed: !0 })) : (await Promise.all([S?.stop({ reset: !0 }), C?.stop()]), await Promise.all([v?.setLayerVisible("portraitLipSync", !1), v?.setLayerVisible("continueIndicator", !1)])), a = e);
5514
+ }, F = async (e) => {
5515
+ e !== _ && (e === "talking" ? (await C?.stop(), await v?.setLayerVisible("continueIndicator", !1), await v?.setLayerVisible("portraitLipSync", S !== void 0), await S?.start({ primed: !0 })) : e === "awaiting-continue" ? (await S?.stop({ reset: !0 }), await v?.setLayerVisible("portraitLipSync", !1), await v?.setLayerVisible("continueIndicator", C !== void 0), await C?.start({ primed: !0 })) : (await Promise.all([S?.stop({ reset: !0 }), C?.stop()]), await Promise.all([v?.setLayerVisible("portraitLipSync", !1), v?.setLayerVisible("continueIndicator", !1)])), _ = e);
5383
5516
  };
5384
5517
  await Promise.all([
5385
5518
  v.setLayerVisible("portraitBase", u.portrait !== void 0),
5386
5519
  v.setLayerVisible("portraitBlink", u.portrait?.blink !== void 0),
5387
5520
  v.setLayerVisible("portraitLipSync", !1),
5388
5521
  v.setLayerVisible("continueIndicator", !1)
5389
- ]), await v.show(), b = !0, await m(u.audio?.voice), w !== void 0 && await m(w.sound ?? u.audio?.reveal), await x?.start({ primed: !0 }), await M(s.animationMode);
5390
- let N = Object.freeze({
5522
+ ]), await v.show(), b = !0, await m(u.audio?.voice), w !== void 0 && await m(w.sound ?? u.audio?.reveal), await x?.start({ primed: !0 }), await F(s.animationMode);
5523
+ let I = Object.freeze({
5391
5524
  actorKey: s.actorKey,
5392
5525
  kind: s.kind,
5393
5526
  get animationMode() {
5394
- return a;
5527
+ return _;
5395
5528
  },
5396
5529
  setText(e) {
5397
- return c ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`)) : typeof e == "string" ? (l = l.then(async () => {
5398
- v && (k(), d = e, w ? (T = Vi(e, w), E = Math.min(1, T.length), w.layout === "RESERVED" && (r.setText({
5399
- styleName: u.textStyle,
5400
- target: v.targets.text,
5401
- text: Aa(e, u, r)
5402
- }), y = !0, v.captureTextLayout?.()), await _(), j()) : await _());
5403
- }), l) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble text must be a string."));
5530
+ if (k) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5531
+ let t;
5532
+ try {
5533
+ t = zi(e);
5534
+ } catch (e) {
5535
+ return Promise.reject(new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble text is invalid."));
5536
+ }
5537
+ return A = A.then(async () => {
5538
+ v && (M(), d = t, w ? (T = Ha(t, w, u.textStyle, r), E = Math.min(1, T.length), w.layout === "RESERVED" && l(t), await j(), P()) : await j());
5539
+ }), A;
5404
5540
  },
5405
5541
  updateStyle(e) {
5406
- if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5407
- let i;
5542
+ if (k) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5543
+ let t;
5408
5544
  try {
5409
- i = _a(e);
5545
+ t = Oa(e);
5410
5546
  } catch (e) {
5411
5547
  return Promise.reject(e);
5412
5548
  }
5413
- return l = l.then(async () => {
5549
+ return A = A.then(async () => {
5414
5550
  if (!v) return;
5415
- Ea(v, i);
5416
- let e = f(i);
5551
+ La(v, t);
5552
+ let e = f(t);
5417
5553
  for (let e of [
5418
- i.audio?.voice,
5419
- i.audio?.reveal,
5420
- i.audio?.finish,
5421
- i.reveal?.sound
5422
- ]) e !== void 0 && Oa(n, e);
5554
+ t.audio?.voice,
5555
+ t.audio?.reveal,
5556
+ t.audio?.finish,
5557
+ t.reveal?.sound
5558
+ ]) e !== void 0 && za(n, e);
5423
5559
  await Promise.all([
5424
5560
  x?.stop(),
5425
5561
  S?.stop(),
5426
5562
  C?.stop()
5427
- ]), await h(i, e, v), await v.updateStyle(i), u = i, w = i.reveal, T = w ? Vi(d, w) : Object.freeze([d]), E = w ? Math.min(1, T.length) : 1, k(), w?.layout === "RESERVED" && (r.setText({
5428
- styleName: i.textStyle,
5429
- target: v.targets.text,
5430
- text: Aa(d, i, r)
5431
- }), y = !0, v.captureTextLayout?.()), await t(d, i), g(i, e, v), await Promise.all([
5432
- v.setLayerVisible("portraitBase", i.portrait !== void 0),
5433
- v.setLayerVisible("portraitBlink", i.portrait?.blink !== void 0),
5563
+ ]), await h(t, e, v), await v.updateStyle(t), u = t, w = t.reveal, T = w ? Ha(d, w, t.textStyle, r) : Object.freeze([d]), E = w ? Math.min(1, T.length) : 1, M(), w?.layout === "RESERVED" && l(d, t), await c(d, t), g(t, e, v), await Promise.all([
5564
+ v.setLayerVisible("portraitBase", t.portrait !== void 0),
5565
+ v.setLayerVisible("portraitBlink", t.portrait?.blink !== void 0),
5434
5566
  v.setLayerVisible("portraitLipSync", !1),
5435
5567
  v.setLayerVisible("continueIndicator", !1)
5436
5568
  ]);
5437
- let o = a;
5438
- a = "idle", await x?.start({ primed: !0 }), await M(o), await _(), j(), await m(u.audio?.voice);
5439
- }), l;
5569
+ let i = _;
5570
+ _ = "idle", await x?.start({ primed: !0 }), await F(i), await j(), P(), await m(u.audio?.voice);
5571
+ }), A;
5440
5572
  },
5441
5573
  setAnimationMode(e) {
5442
- return c ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`)) : sa.has(e) ? (l = l.then(() => M(e)), l) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid."));
5574
+ return k ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`)) : va.has(e) ? (A = A.then(() => F(e)), A) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble animation mode is invalid."));
5443
5575
  },
5444
5576
  revealNext() {
5445
- if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5577
+ if (k) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5446
5578
  let e = !1;
5447
- return l = l.then(async () => {
5448
- e = await A(), e && j();
5449
- }), l.then(() => e);
5579
+ return A = A.then(async () => {
5580
+ e = await N(), e && P();
5581
+ }), A.then(() => e);
5450
5582
  },
5451
5583
  revealAll() {
5452
- return c ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`)) : (l = l.then(async () => {
5453
- if (k(), w) for (; await A(););
5454
- }), l);
5584
+ return k ? Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`)) : (A = A.then(async () => {
5585
+ if (M(), w) for (; await N(););
5586
+ }), A);
5455
5587
  },
5456
5588
  finish(e = {}) {
5457
- if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5589
+ if (k) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5458
5590
  let t = e.timeoutSeconds ?? 0;
5459
- return !Number.isFinite(t) || t < 0 ? Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble finish timeoutSeconds must be zero or greater.")) : e.condition !== void 0 && typeof e.condition != "function" ? Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble finish condition must be a function.")) : (l = l.then(async () => {
5460
- if (k(), e.unit !== void 0 && (w = zi({
5591
+ return !Number.isFinite(t) || t < 0 ? Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble finish timeoutSeconds must be zero or greater.")) : e.condition !== void 0 && typeof e.condition != "function" ? Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble finish condition must be a function.")) : (A = A.then(async () => {
5592
+ if (M(), e.unit !== void 0 && (w = Ki({
5461
5593
  ...w ?? {},
5462
5594
  unit: e.unit
5463
- }), T = Vi(d, w), E = Math.min(1, T.length), w.layout === "RESERVED" && v && (r.setText({
5464
- styleName: u.textStyle,
5465
- target: v.targets.text,
5466
- text: Aa(d, u, r)
5467
- }), y = !0, v.captureTextLayout?.())), w) for (; await A(););
5595
+ }), T = Ha(d, w, u.textStyle, r), E = Math.min(1, T.length), w.layout === "RESERVED" && v && l(d)), w) for (; await N(););
5468
5596
  let n = e.condition;
5469
5597
  if (n === void 0 && t === 0) {
5470
5598
  await m(u.audio?.finish);
@@ -5491,38 +5619,38 @@ function Pa(e) {
5491
5619
  };
5492
5620
  l();
5493
5621
  });
5494
- }), l);
5622
+ }), A);
5495
5623
  },
5496
5624
  animate(e) {
5497
- if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5498
- let n;
5625
+ if (k) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
5626
+ let t;
5499
5627
  try {
5500
- n = ha(e, "Bubble motion");
5628
+ t = Ea(e, "Bubble motion");
5501
5629
  } catch (e) {
5502
5630
  return Promise.reject(e);
5503
5631
  }
5504
- return l = l.then(async () => {
5505
- if (n.name === "animateBubbleShape" && n.visualStyle) {
5632
+ return A = A.then(async () => {
5633
+ if (t.name === "animateBubbleShape" && t.visualStyle) {
5506
5634
  let e = Object.freeze({
5507
5635
  ...u,
5508
5636
  layoutProfile: "custom"
5509
- }), r = Object.freeze({
5637
+ }), n = Object.freeze({
5510
5638
  ...e,
5511
- visualStyle: n.visualStyle
5639
+ visualStyle: t.visualStyle
5512
5640
  });
5513
- u.layoutProfile === "scratch-default" && (await v?.updateStyle(e), await t(d, e), await v?.show()), await v?.animate?.(n), u = r, await v?.updateStyle(u);
5641
+ u.layoutProfile === "scratch-default" && (await v?.updateStyle(e), await c(d, e), await v?.show()), await v?.animate?.(t), u = n, await v?.updateStyle(u);
5514
5642
  return;
5515
5643
  }
5516
- await v?.animate?.(n);
5517
- }), l;
5644
+ await v?.animate?.(t);
5645
+ }), A;
5518
5646
  },
5519
5647
  async close() {
5520
- if (c) return;
5521
- c = !0;
5648
+ if (k) return;
5649
+ k = !0;
5522
5650
  let e = [];
5523
- k();
5651
+ M();
5524
5652
  try {
5525
- await l;
5653
+ await A;
5526
5654
  } catch (t) {
5527
5655
  e.push(t);
5528
5656
  }
@@ -5543,10 +5671,10 @@ function Pa(e) {
5543
5671
  } catch (t) {
5544
5672
  e.push(t);
5545
5673
  }
5546
- o.get(s.actorKey) === N && o.delete(s.actorKey), ja(e, `Failed to close bubble: ${s.actorKey}`);
5674
+ o.get(s.actorKey) === I && o.delete(s.actorKey), Wa(e, `Failed to close bubble: ${s.actorKey}`);
5547
5675
  }
5548
5676
  });
5549
- return o.set(s.actorKey, N), j(), u.showAnimation !== void 0 && await N.animate(u.showAnimation), N;
5677
+ return o.set(s.actorKey, I), P(), u.showAnimation !== void 0 && await I.animate(u.showAnimation), I;
5550
5678
  } catch (e) {
5551
5679
  o.delete(s.actorKey);
5552
5680
  let t = [], n = await Promise.allSettled([
@@ -5575,85 +5703,85 @@ function Pa(e) {
5575
5703
  return Object.freeze({
5576
5704
  defineStyle(e) {
5577
5705
  l();
5578
- let t = _a(e);
5706
+ let t = Oa(e);
5579
5707
  a.set(t.name, t);
5580
5708
  },
5581
5709
  hasActiveBubble(e) {
5582
- return o.has(da(e, "Bubble actor key"));
5710
+ return o.has(Sa(e, "Bubble actor key"));
5583
5711
  },
5584
5712
  async show(e) {
5585
5713
  l();
5586
- let t = Na(e);
5714
+ let t = Ka(e);
5587
5715
  return u(t.actorKey, () => d(t));
5588
5716
  },
5589
5717
  releaseTarget(e) {
5590
5718
  l();
5591
- let t = da(e, "Bubble actor key");
5719
+ let t = Sa(e, "Bubble actor key");
5592
5720
  return u(t, async () => {
5593
5721
  await o.get(t)?.close();
5594
5722
  });
5595
5723
  },
5596
5724
  async releaseAll() {
5597
- l(), await Promise.allSettled([...s.values()]), ja((await Promise.allSettled([...o.values()].map((e) => e.close()))).flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to release all bubbles");
5725
+ l(), await Promise.allSettled([...s.values()]), Wa((await Promise.allSettled([...o.values()].map((e) => e.close()))).flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to release all bubbles");
5598
5726
  },
5599
5727
  async dispose() {
5600
5728
  if (c) return;
5601
5729
  c = !0, await Promise.allSettled([...s.values()]);
5602
5730
  let e = await Promise.allSettled([...o.values()].map((e) => e.close()));
5603
- a.clear(), ja(e.flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to dispose bubble composition");
5731
+ a.clear(), Wa(e.flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to dispose bubble composition");
5604
5732
  }
5605
5733
  });
5606
5734
  }
5607
5735
  //#endregion
5608
5736
  //#region src/turbowarp-svg-text-adapter.ts
5609
- function Fa(e) {
5737
+ function Ja(e) {
5610
5738
  return typeof e == "object" && !!e && !Array.isArray(e);
5611
5739
  }
5612
- function Ia(e) {
5613
- if (!Fa(e) || typeof e.setText != "function" || typeof e.releaseTextActor != "function") throw TypeError("TurboWarp SVG Text adapter requires setText and releaseTextActor.");
5740
+ function Ya(e) {
5741
+ if (!Ja(e) || typeof e.setText != "function" || typeof e.releaseTextActor != "function") throw TypeError("TurboWarp-SVG-Text adapter requires setText and releaseTextActor.");
5614
5742
  return e;
5615
5743
  }
5616
- function La(e) {
5617
- if (!Fa(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("SVG Text composition adapter requires setText and releaseTarget.");
5744
+ function Xa(e) {
5745
+ if (!Ja(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("SVG Text composition adapter requires setText and releaseTarget.");
5618
5746
  return e;
5619
5747
  }
5620
- function Ra(e) {
5621
- if (!Fa(e) || typeof e.layoutText != "function") throw TypeError("SVG Text overlay adapter requires the layoutText composition API.");
5748
+ function Za(e) {
5749
+ if (!Ja(e) || typeof e.layoutText != "function") throw TypeError("SVG Text overlay adapter requires the layoutText composition API.");
5622
5750
  return e;
5623
5751
  }
5624
- function za(e, t) {
5752
+ function Qa(e, t) {
5625
5753
  let n = Number(e);
5626
5754
  if (!Number.isFinite(n)) throw TypeError(`${t} must be a finite number.`);
5627
5755
  return n;
5628
5756
  }
5629
- function Ba(e) {
5630
- if (!Fa(e) || !Fa(e.style) || !Array.isArray(e.lines)) throw TypeError("SVG Text layout result is invalid.");
5757
+ function $a(e) {
5758
+ if (!Ja(e) || !Ja(e.style) || !Array.isArray(e.lines)) throw TypeError("SVG Text layout result is invalid.");
5631
5759
  let t = e.style, n = t.alignment;
5632
5760
  if (n !== "left" && n !== "center" && n !== "right") throw TypeError("SVG Text layout alignment is invalid.");
5633
- let r = za(e.width, "SVG Text layout width"), i = za(e.height, "SVG Text layout height"), a = Object.freeze(e.lines.map((e) => {
5634
- if (!Fa(e) || typeof e.text != "string") throw TypeError("SVG Text layout line is invalid.");
5761
+ let r = Qa(e.width, "SVG Text layout width"), i = Qa(e.height, "SVG Text layout height"), a = Object.freeze(e.lines.map((e) => {
5762
+ if (!Ja(e) || typeof e.text != "string") throw TypeError("SVG Text layout line is invalid.");
5635
5763
  return Object.freeze({
5636
- baseline: za(e.baseline, "SVG Text line baseline") - i / 2,
5764
+ baseline: Qa(e.baseline, "SVG Text line baseline") - i / 2,
5637
5765
  text: e.text,
5638
- x: za(e.x, "SVG Text line x") - r / 2
5766
+ x: Qa(e.x, "SVG Text line x") - r / 2
5639
5767
  });
5640
5768
  }));
5641
5769
  return Object.freeze({
5642
5770
  alignment: n,
5643
5771
  backgroundColor: String(t.backgroundColor),
5644
- backgroundCornerRadius: za(t.cornerRadius, "SVG Text corner radius"),
5772
+ backgroundCornerRadius: Qa(t.cornerRadius, "SVG Text corner radius"),
5645
5773
  fill: String(t.textColor),
5646
5774
  fontFamily: String(t.font),
5647
- fontSize: za(t.fontSize, "SVG Text font size"),
5775
+ fontSize: Qa(t.fontSize, "SVG Text font size"),
5648
5776
  height: i,
5649
- lineHeight: za(t.lineHeight, "SVG Text line height"),
5777
+ lineHeight: Qa(t.lineHeight, "SVG Text line height"),
5650
5778
  lines: a,
5651
5779
  preserveWhitespace: e.preserveWhitespace !== !1,
5652
5780
  width: r
5653
5781
  });
5654
5782
  }
5655
- function Va(e) {
5656
- let t = Ia(e);
5783
+ function eo(e) {
5784
+ let t = Ya(e);
5657
5785
  return Object.freeze({
5658
5786
  setText({ styleName: e, target: n, text: r }) {
5659
5787
  t.setText({
@@ -5665,13 +5793,13 @@ function Va(e) {
5665
5793
  t.releaseTextActor(e);
5666
5794
  },
5667
5795
  measureText({ styleName: e, text: n }) {
5668
- if (typeof t.measureText != "function") throw Error("TurboWarp SVG Text does not provide text measurement.");
5796
+ if (typeof t.measureText != "function") throw Error("TurboWarp-SVG-Text does not provide text measurement.");
5669
5797
  return t.measureText(e, n);
5670
5798
  }
5671
5799
  });
5672
5800
  }
5673
- function Ha(e) {
5674
- let t = La(e), n = {
5801
+ function to(e) {
5802
+ let t = Xa(e), n = {
5675
5803
  setText({ styleName: e, target: n, text: r }) {
5676
5804
  t.setText({
5677
5805
  styleName: e,
@@ -5686,13 +5814,24 @@ function Ha(e) {
5686
5814
  return typeof t.measureText == "function" && (n.measureText = ({ styleName: e, text: n }) => t.measureText?.({
5687
5815
  styleName: e,
5688
5816
  text: n
5817
+ }) ?? 0), typeof t.setRichText == "function" && (n.setRichText = ({ maxWidth: e, runs: n, styleName: r, target: i }) => {
5818
+ t.setRichText?.({
5819
+ runs: n,
5820
+ styleName: r,
5821
+ target: i,
5822
+ ...e === void 0 ? {} : { maxWidth: e }
5823
+ });
5824
+ }), typeof t.measureRichText == "function" && (n.measureRichText = ({ maxWidth: e, runs: n, styleName: r }) => t.measureRichText?.({
5825
+ runs: n,
5826
+ styleName: r,
5827
+ ...e === void 0 ? {} : { maxWidth: e }
5689
5828
  }) ?? 0), Object.freeze(n);
5690
5829
  }
5691
- function Ua(e) {
5692
- let t = Ra(e);
5830
+ function no(e) {
5831
+ let t = Za(e);
5693
5832
  return Object.freeze({
5694
5833
  layoutText({ nativeSize: e, styleName: n, text: r }) {
5695
- return Ba(t.layoutText({
5834
+ return $a(t.layoutText({
5696
5835
  nativeSize: [e.width, e.height],
5697
5836
  styleName: n,
5698
5837
  text: r
@@ -5704,17 +5843,17 @@ function Ua(e) {
5704
5843
  styleName: n,
5705
5844
  text: r
5706
5845
  });
5707
- return Math.max(1, ...i.lines.map((e) => za(e.width, "SVG Text line width")));
5846
+ return Math.max(1, ...i.lines.map((e) => Qa(e.width, "SVG Text line width")));
5708
5847
  }
5709
5848
  });
5710
5849
  }
5711
- function Wa(e) {
5712
- if (!Fa(e) || typeof e.getLayoutCapability != "function") throw TypeError("TurboWarp SVG Text overlay adapter requires SVG Text 0.8.1 getLayoutCapability().");
5713
- return Ua(e.getLayoutCapability());
5850
+ function ro(e) {
5851
+ if (!Ja(e) || typeof e.getLayoutCapability != "function") throw TypeError("TurboWarp-SVG-Text overlay adapter requires SVG Text 0.8.1 getLayoutCapability().");
5852
+ return no(e.getLayoutCapability());
5714
5853
  }
5715
5854
  //#endregion
5716
5855
  //#region src/asset-manager-image-adapter.ts
5717
- var Ga = /* @__PURE__ */ new Set([
5856
+ var io = /* @__PURE__ */ new Set([
5718
5857
  "image/avif",
5719
5858
  "image/gif",
5720
5859
  "image/jpeg",
@@ -5722,37 +5861,37 @@ var Ga = /* @__PURE__ */ new Set([
5722
5861
  "image/svg+xml",
5723
5862
  "image/webp"
5724
5863
  ]);
5725
- function Ka(e) {
5864
+ function ao(e) {
5726
5865
  return typeof e == "object" && !!e && !Array.isArray(e);
5727
5866
  }
5728
- function qa(e) {
5867
+ function oo(e) {
5729
5868
  let t = e.split(";", 1)[0]?.trim().toLowerCase() ?? "";
5730
5869
  return t === "image/jpg" || t === "image/pjpeg" ? "image/jpeg" : t === "image/x-png" ? "image/png" : t;
5731
5870
  }
5732
- function Ja(e) {
5733
- return Ga.has(qa(e));
5871
+ function so(e) {
5872
+ return io.has(oo(e));
5734
5873
  }
5735
- function Ya(e) {
5736
- if (!Ka(e) || typeof e.url != "string" || !e.url.startsWith("blob:") || typeof e.mimeType != "string" || !Ja(e.mimeType) || typeof e.width != "number" || !Number.isFinite(e.width) || e.width <= 0 || typeof e.height != "number" || !Number.isFinite(e.height) || e.height <= 0 || typeof e.release != "function") throw TypeError("Asset Manager DOM image resources must provide a supported MIME type, positive intrinsic dimensions, a blob URL, and release().");
5874
+ function co(e) {
5875
+ if (!ao(e) || typeof e.url != "string" || !e.url.startsWith("blob:") || typeof e.mimeType != "string" || !so(e.mimeType) || typeof e.width != "number" || !Number.isFinite(e.width) || e.width <= 0 || typeof e.height != "number" || !Number.isFinite(e.height) || e.height <= 0 || typeof e.release != "function") throw TypeError("Asset Manager DOM image resources must provide a supported MIME type, positive intrinsic dimensions, a blob URL, and release().");
5737
5876
  return e;
5738
5877
  }
5739
- function Xa(e) {
5740
- if (!Ka(e) || typeof e.isRegistered != "function" || typeof e.getMimeType != "function" || typeof e.resolveDOMImageResource != "function") throw TypeError("Asset Manager DOM image capability is invalid.");
5878
+ function lo(e) {
5879
+ if (!ao(e) || typeof e.isRegistered != "function" || typeof e.getMimeType != "function" || typeof e.resolveDOMImageResource != "function") throw TypeError("Asset Manager DOM image capability is invalid.");
5741
5880
  let t = e;
5742
5881
  return Object.freeze({
5743
5882
  isRegistered(e) {
5744
- return t.isRegistered(e) && Ja(t.getMimeType(e));
5883
+ return t.isRegistered(e) && so(t.getMimeType(e));
5745
5884
  },
5746
5885
  getMimeType(e) {
5747
- return qa(t.getMimeType(e));
5886
+ return oo(t.getMimeType(e));
5748
5887
  },
5749
5888
  async resolveImage(e) {
5750
- let n = qa(t.getMimeType(e));
5751
- if (!t.isRegistered(e) || !Ja(n)) throw TypeError("Asset Manager image is not registered with a Bubble-compatible MIME type.");
5889
+ let n = oo(t.getMimeType(e));
5890
+ if (!t.isRegistered(e) || !so(n)) throw TypeError("Asset Manager image is not registered with a Bubble-compatible MIME type.");
5752
5891
  let r = await t.resolveDOMImageResource(e);
5753
5892
  try {
5754
- Ya(r);
5755
- let e = qa(r.mimeType);
5893
+ co(r);
5894
+ let e = oo(r.mimeType);
5756
5895
  if (e !== n) throw TypeError("Asset Manager DOM image resource MIME type changed during resolution.");
5757
5896
  return Object.freeze({
5758
5897
  height: r.height,
@@ -5770,11 +5909,11 @@ function Xa(e) {
5770
5909
  }
5771
5910
  //#endregion
5772
5911
  //#region src/surface-motion.ts
5773
- function Za(e) {
5912
+ function uo(e) {
5774
5913
  return Math.max(0, Math.min(1, e));
5775
5914
  }
5776
- function Qa(e, t) {
5777
- let n = Za(e);
5915
+ function fo(e, t) {
5916
+ let n = uo(e);
5778
5917
  switch (t) {
5779
5918
  case "linear": return n;
5780
5919
  case "easeIn": return n * n;
@@ -5783,14 +5922,14 @@ function Qa(e, t) {
5783
5922
  default: return n;
5784
5923
  }
5785
5924
  }
5786
- function $a(e, t, n) {
5925
+ function po(e, t, n) {
5787
5926
  let r = Math.max(0, t * 1e3);
5788
5927
  return r === 0 ? (n(1), Promise.resolve()) : new Promise((t, i) => {
5789
5928
  let a = 0, o, s = () => {
5790
5929
  let c = Math.min(16, r - a);
5791
5930
  a += c;
5792
5931
  try {
5793
- n(Za(a / r));
5932
+ n(uo(a / r));
5794
5933
  } catch (t) {
5795
5934
  o !== void 0 && e.clearTimeout(o), i(t);
5796
5935
  return;
@@ -5806,33 +5945,33 @@ function $a(e, t, n) {
5806
5945
  }
5807
5946
  //#endregion
5808
5947
  //#region src/svg-overlay-surface.ts
5809
- var eo = "http://www.w3.org/2000/svg", to = "http://www.w3.org/XML/1998/namespace", no = 96, ro = 18, io = 8, ao = 16, oo = Symbol("BubbleSvgOverlayTextTarget"), so = Symbol("BubbleSvgOverlayImageTarget"), co = 0, lo = Object.freeze(["scratch-render", "svg-overlay"]), uo = "svg-overlay", fo = "error";
5810
- function po(e) {
5948
+ var mo = "http://www.w3.org/2000/svg", ho = "http://www.w3.org/XML/1998/namespace", go = 96, _o = 18, vo = 8, yo = 16, bo = Symbol("BubbleSvgOverlayTextTarget"), xo = Symbol("BubbleSvgOverlayImageTarget"), So = 0, Co = Object.freeze(["scratch-render", "svg-overlay"]), wo = "svg-overlay", To = "error";
5949
+ function Eo(e) {
5811
5950
  return typeof e == "object" && !!e && !Array.isArray(e);
5812
5951
  }
5813
- function mo(e) {
5952
+ function Do(e) {
5814
5953
  let t = e.getNativeSize(), n = Array.isArray(t) ? Number(t[0]) : NaN, r = Array.isArray(t) ? Number(t[1]) : NaN;
5815
5954
  return Object.freeze({
5816
5955
  width: n > 0 ? n : 480,
5817
5956
  height: r > 0 ? r : 360
5818
5957
  });
5819
5958
  }
5820
- function ho(e, t) {
5959
+ function Oo(e, t) {
5821
5960
  let n = Number(e);
5822
5961
  if (!Number.isFinite(n) || n <= 0) throw TypeError(`${t} must be a positive finite number.`);
5823
5962
  return n;
5824
5963
  }
5825
- function go(e, t) {
5964
+ function ko(e, t) {
5826
5965
  if (typeof e != "string" || e.length === 0 || e.length > 128) throw TypeError(`${t} must be a non-empty color string.`);
5827
5966
  if (/url\s*\(|[<>;]/iu.test(e)) throw TypeError(`${t} contains a disallowed SVG value.`);
5828
5967
  return e;
5829
5968
  }
5830
- function _o(e) {
5969
+ function Ao(e) {
5831
5970
  if (typeof e != "string" || e.length === 0 || e.length > 256 || /url\s*\(|[<>{};]/iu.test(e)) throw TypeError("SVG overlay fontFamily is invalid.");
5832
5971
  return e;
5833
5972
  }
5834
- function vo(e) {
5835
- if (!po(e) || !Array.isArray(e.lines)) throw TypeError("SVG overlay text layout is invalid.");
5973
+ function jo(e) {
5974
+ if (!Eo(e) || !Array.isArray(e.lines)) throw TypeError("SVG overlay text layout is invalid.");
5836
5975
  let t = e.alignment;
5837
5976
  if (t !== "left" && t !== "center" && t !== "right") throw TypeError("SVG overlay text alignment is invalid.");
5838
5977
  let n = e.fontStyle;
@@ -5841,7 +5980,7 @@ function vo(e) {
5841
5980
  if (r !== void 0 && r !== "normal" && r !== "bold" && (!Number.isFinite(r) || Number(r) < 1 || Number(r) > 1e3)) throw TypeError("SVG overlay fontWeight is invalid.");
5842
5981
  let i = Object.freeze(e.lines.map((e) => {
5843
5982
  if (typeof e == "string") return e;
5844
- if (!po(e) || typeof e.text != "string") throw TypeError("SVG overlay text lines must be strings or positioned line records.");
5983
+ if (!Eo(e) || typeof e.text != "string") throw TypeError("SVG overlay text lines must be strings or positioned line records.");
5845
5984
  let t = e.x !== void 0;
5846
5985
  if (t !== (e.baseline !== void 0)) throw TypeError("SVG overlay positioned text lines require both x and baseline.");
5847
5986
  if (t && (!Number.isFinite(e.x) || !Number.isFinite(e.baseline))) throw TypeError("SVG overlay text line coordinates must be finite numbers.");
@@ -5852,19 +5991,19 @@ function vo(e) {
5852
5991
  baseline: Number(e.baseline)
5853
5992
  } : {}
5854
5993
  });
5855
- })), a = e.backgroundColor === void 0 ? void 0 : go(e.backgroundColor, "SVG overlay backgroundColor"), o = e.backgroundCornerRadius === void 0 ? void 0 : Number(e.backgroundCornerRadius);
5994
+ })), a = e.backgroundColor === void 0 ? void 0 : ko(e.backgroundColor, "SVG overlay backgroundColor"), o = e.backgroundCornerRadius === void 0 ? void 0 : Number(e.backgroundCornerRadius);
5856
5995
  if (o !== void 0 && (!Number.isFinite(o) || o < 0)) throw TypeError("SVG overlay backgroundCornerRadius must be a non-negative finite number.");
5857
5996
  let s = e.preserveWhitespace;
5858
5997
  if (s !== void 0 && typeof s != "boolean") throw TypeError("SVG overlay preserveWhitespace must be a boolean.");
5859
5998
  return Object.freeze({
5860
5999
  alignment: t,
5861
- fill: go(e.fill, "SVG overlay text fill"),
5862
- fontFamily: _o(e.fontFamily),
5863
- fontSize: ho(e.fontSize, "SVG overlay fontSize"),
5864
- height: ho(e.height, "SVG overlay text height"),
5865
- lineHeight: ho(e.lineHeight, "SVG overlay lineHeight"),
6000
+ fill: ko(e.fill, "SVG overlay text fill"),
6001
+ fontFamily: Ao(e.fontFamily),
6002
+ fontSize: Oo(e.fontSize, "SVG overlay fontSize"),
6003
+ height: Oo(e.height, "SVG overlay text height"),
6004
+ lineHeight: Oo(e.lineHeight, "SVG overlay lineHeight"),
5866
6005
  lines: i,
5867
- width: ho(e.width, "SVG overlay text width"),
6006
+ width: Oo(e.width, "SVG overlay text width"),
5868
6007
  ...a === void 0 ? {} : { backgroundColor: a },
5869
6008
  ...o === void 0 ? {} : { backgroundCornerRadius: o },
5870
6009
  ...n === void 0 ? {} : { fontStyle: n },
@@ -5872,21 +6011,21 @@ function vo(e) {
5872
6011
  ...s === void 0 ? {} : { preserveWhitespace: s }
5873
6012
  });
5874
6013
  }
5875
- function yo(e, t) {
6014
+ function Mo(e, t) {
5876
6015
  let n = {
5877
6016
  width: 180,
5878
6017
  height: 48
5879
6018
  }, r, i, a, o = (r) => {
5880
- let i = vo(r), a = [];
6019
+ let i = jo(r), a = [];
5881
6020
  if (i.backgroundColor !== void 0 && i.backgroundColor !== "transparent") {
5882
- let t = e.createElementNS(eo, "rect");
6021
+ let t = e.createElementNS(mo, "rect");
5883
6022
  t.setAttribute("x", String(-i.width / 2)), t.setAttribute("y", String(-i.height / 2)), t.setAttribute("width", String(i.width)), t.setAttribute("height", String(i.height)), t.setAttribute("fill", i.backgroundColor), i.backgroundCornerRadius !== void 0 && t.setAttribute("rx", String(i.backgroundCornerRadius)), a.push(t);
5884
6023
  }
5885
- let o = e.createElementNS(eo, "text"), s = i.alignment === "left" ? "start" : i.alignment === "right" ? "end" : "middle", c = i.alignment === "left" ? -i.width / 2 : i.alignment === "right" ? i.width / 2 : 0;
5886
- o.setAttribute("text-anchor", s), o.setAttribute("fill", i.fill), o.setAttribute("font-family", i.fontFamily), o.setAttribute("font-size", String(i.fontSize)), i.preserveWhitespace !== !1 && o.setAttributeNS(to, "xml:space", "preserve"), i.fontStyle !== void 0 && o.setAttribute("font-style", i.fontStyle), i.fontWeight !== void 0 && o.setAttribute("font-weight", String(i.fontWeight));
6024
+ let o = e.createElementNS(mo, "text"), s = i.alignment === "left" ? "start" : i.alignment === "right" ? "end" : "middle", c = i.alignment === "left" ? -i.width / 2 : i.alignment === "right" ? i.width / 2 : 0;
6025
+ o.setAttribute("text-anchor", s), o.setAttribute("fill", i.fill), o.setAttribute("font-family", i.fontFamily), o.setAttribute("font-size", String(i.fontSize)), i.preserveWhitespace !== !1 && o.setAttributeNS(ho, "xml:space", "preserve"), i.fontStyle !== void 0 && o.setAttribute("font-style", i.fontStyle), i.fontWeight !== void 0 && o.setAttribute("font-weight", String(i.fontWeight));
5887
6026
  let l = -Math.max(i.fontSize, (i.lines.length - 1) * i.lineHeight + i.fontSize) / 2 + i.fontSize;
5888
6027
  i.lines.forEach((t, n) => {
5889
- let r = e.createElementNS(eo, "tspan"), a = typeof t == "string" ? void 0 : t;
6028
+ let r = e.createElementNS(mo, "tspan"), a = typeof t == "string" ? void 0 : t;
5890
6029
  r.setAttribute("x", String(a?.x ?? c)), r.setAttribute("y", String(a?.baseline ?? l + n * i.lineHeight)), r.textContent = typeof t == "string" ? t : t.text, o.appendChild(r);
5891
6030
  }), a.push(o), t.replaceChildren(...a), n = {
5892
6031
  width: i.width,
@@ -5894,7 +6033,7 @@ function yo(e, t) {
5894
6033
  };
5895
6034
  };
5896
6035
  return Object.freeze({
5897
- [oo]: !0,
6036
+ [bo]: !0,
5898
6037
  group: t,
5899
6038
  captureLayout() {
5900
6039
  i = r, a = { ...n };
@@ -5916,7 +6055,7 @@ function yo(e, t) {
5916
6055
  },
5917
6056
  refresh() {
5918
6057
  if (i !== void 0) {
5919
- let e = vo(i());
6058
+ let e = jo(i());
5920
6059
  a = {
5921
6060
  width: e.width,
5922
6061
  height: e.height
@@ -5929,29 +6068,29 @@ function yo(e, t) {
5929
6068
  }
5930
6069
  });
5931
6070
  }
5932
- function bo(e) {
6071
+ function No(e) {
5933
6072
  let t = e;
5934
- if (t?.[oo] !== !0) throw TypeError("SVG overlay text target is invalid.");
6073
+ if (t?.[bo] !== !0) throw TypeError("SVG overlay text target is invalid.");
5935
6074
  return t;
5936
6075
  }
5937
- function xo(e, t) {
5938
- if (!po(e) || typeof e.layoutText != "function") throw TypeError("SVG overlay backend requires a text layout capability.");
6076
+ function Po(e, t) {
6077
+ if (!Eo(e) || typeof e.layoutText != "function") throw TypeError("SVG overlay backend requires a text layout capability.");
5939
6078
  let n = e;
5940
6079
  return Object.freeze({
5941
6080
  setText({ styleName: e, target: r, text: i }) {
5942
- let a = bo(r), o = () => n.layoutText({
5943
- nativeSize: mo(t),
6081
+ let a = No(r), o = () => n.layoutText({
6082
+ nativeSize: Do(t),
5944
6083
  styleName: e,
5945
6084
  text: i
5946
6085
  });
5947
6086
  a.render(o(), o);
5948
6087
  },
5949
6088
  releaseTarget(e) {
5950
- bo(e).clear();
6089
+ No(e).clear();
5951
6090
  },
5952
6091
  measureText({ styleName: e, text: r }) {
5953
- let i = mo(t);
5954
- return ho(n.measureText?.({
6092
+ let i = Do(t);
6093
+ return Oo(n.measureText?.({
5955
6094
  nativeSize: i,
5956
6095
  styleName: e,
5957
6096
  text: r
@@ -5963,7 +6102,7 @@ function xo(e, t) {
5963
6102
  }
5964
6103
  });
5965
6104
  }
5966
- function So(e) {
6105
+ function Fo(e) {
5967
6106
  return !(/* @__PURE__ */ new Set([
5968
6107
  "image/avif",
5969
6108
  "image/gif",
@@ -5973,11 +6112,11 @@ function So(e) {
5973
6112
  "image/webp"
5974
6113
  ])).has(e.mimeType.toLowerCase()) || e.mimeType.toLowerCase() === "image/svg+xml" && e.svgSecurity !== "sanitized" ? !1 : e.src.startsWith("blob:") ? typeof e.release == "function" : /^data:image\/(?:avif|gif|jpeg|png|webp);base64,/iu.test(e.src);
5975
6114
  }
5976
- async function Co(e) {
6115
+ async function Io(e) {
5977
6116
  await e?.release?.();
5978
6117
  }
5979
- function wo(e, t, n) {
5980
- let r = e.createElementNS(eo, "image");
6118
+ function Lo(e, t, n) {
6119
+ let r = e.createElementNS(mo, "image");
5981
6120
  r.setAttribute("preserveAspectRatio", "xMidYMid meet"), n.appendChild(r);
5982
6121
  let i, a = {
5983
6122
  width: 1,
@@ -5988,22 +6127,22 @@ function wo(e, t, n) {
5988
6127
  return s(), Object.freeze({
5989
6128
  id: t,
5990
6129
  isStage: !1,
5991
- [so]: !0,
6130
+ [xo]: !0,
5992
6131
  group: n,
5993
6132
  async applyResource(e) {
5994
6133
  let t = o + 1;
5995
6134
  o = t;
5996
6135
  try {
5997
- if (ho(e.width, "SVG overlay image width"), ho(e.height, "SVG overlay image height"), typeof e.mimeType != "string" || !e.mimeType.startsWith("image/") || typeof e.src != "string" || !So(e)) throw TypeError("SVG overlay image resources must use a supported MIME type, a releasable blob URL or approved raster data URL, and sanitized SVG metadata when applicable.");
6136
+ if (Oo(e.width, "SVG overlay image width"), Oo(e.height, "SVG overlay image height"), typeof e.mimeType != "string" || !e.mimeType.startsWith("image/") || typeof e.src != "string" || !Fo(e)) throw TypeError("SVG overlay image resources must use a supported MIME type, a releasable blob URL or approved raster data URL, and sanitized SVG metadata when applicable.");
5998
6137
  } catch (t) {
5999
- throw await Co(e), t;
6138
+ throw await Io(e), t;
6000
6139
  }
6001
6140
  if (t !== o) {
6002
- await Co(e);
6141
+ await Io(e);
6003
6142
  return;
6004
6143
  }
6005
6144
  let n = i;
6006
- i = e, r.setAttribute("href", e.src), await Co(n);
6145
+ i = e, r.setAttribute("href", e.src), await Io(n);
6007
6146
  },
6008
6147
  getSize() {
6009
6148
  return i ? {
@@ -6017,7 +6156,7 @@ function wo(e, t, n) {
6017
6156
  async release() {
6018
6157
  o += 1;
6019
6158
  let e = i;
6020
- i = void 0, r.removeAttribute("href"), await Co(e);
6159
+ i = void 0, r.removeAttribute("href"), await Io(e);
6021
6160
  },
6022
6161
  setDisplaySize(e) {
6023
6162
  a = e, s();
@@ -6027,13 +6166,13 @@ function wo(e, t, n) {
6027
6166
  }
6028
6167
  });
6029
6168
  }
6030
- function To(e) {
6169
+ function Ro(e) {
6031
6170
  let t = e;
6032
- if (t?.[so] !== !0) throw TypeError("SVG overlay image target is invalid.");
6171
+ if (t?.[xo] !== !0) throw TypeError("SVG overlay image target is invalid.");
6033
6172
  return t;
6034
6173
  }
6035
- function Eo(e) {
6036
- if (!po(e) || typeof e.isRegistered != "function" || typeof e.getMimeType != "function" || typeof e.resolveImage != "function") throw TypeError("SVG overlay image capability is invalid.");
6174
+ function zo(e) {
6175
+ if (!Eo(e) || typeof e.isRegistered != "function" || typeof e.getMimeType != "function" || typeof e.resolveImage != "function") throw TypeError("SVG overlay image capability is invalid.");
6037
6176
  let t = e;
6038
6177
  return Object.freeze({
6039
6178
  isRegistered(e) {
@@ -6043,15 +6182,15 @@ function Eo(e) {
6043
6182
  return t.getMimeType(e);
6044
6183
  },
6045
6184
  async applyToTarget(e, n) {
6046
- await To(n).applyResource(await t.resolveImage(e));
6185
+ await Ro(n).applyResource(await t.resolveImage(e));
6047
6186
  }
6048
6187
  });
6049
6188
  }
6050
- function Do(e, t) {
6051
- let n = t.createElementNS(eo, "svg");
6052
- n.setAttribute("xmlns", eo), n.setAttribute("aria-hidden", "true"), n.setAttribute("focusable", "false"), n.setAttribute("data-bubble-render-backend", "svg-overlay"), n.style.display = "block", n.style.overflow = "hidden", n.style.pointerEvents = "none";
6189
+ function Bo(e, t) {
6190
+ let n = t.createElementNS(mo, "svg");
6191
+ n.setAttribute("xmlns", mo), n.setAttribute("aria-hidden", "true"), n.setAttribute("focusable", "false"), n.setAttribute("data-bubble-render-backend", "svg-overlay"), n.style.display = "block", n.style.overflow = "hidden", n.style.pointerEvents = "none";
6053
6192
  let r = /* @__PURE__ */ new Set(), i = !1, a = () => {
6054
- let t = mo(e);
6193
+ let t = Do(e);
6055
6194
  return n.setAttribute("width", String(t.width)), n.setAttribute("height", String(t.height)), n.setAttribute("viewBox", `0 0 ${t.width} ${t.height}`), t;
6056
6195
  };
6057
6196
  return Object.freeze({
@@ -6073,7 +6212,7 @@ function Do(e, t) {
6073
6212
  updateNativeSize: a
6074
6213
  });
6075
6214
  }
6076
- function Oo(e) {
6215
+ function Vo(e) {
6077
6216
  try {
6078
6217
  let t = e.getBoundsForBubble?.();
6079
6218
  if (t && [
@@ -6091,21 +6230,21 @@ function Oo(e) {
6091
6230
  top: n
6092
6231
  };
6093
6232
  }
6094
- function ko(e, t, n) {
6233
+ function Ho(e, t, n) {
6095
6234
  return n < t ? (t + n) / 2 : Math.min(n, Math.max(t, e));
6096
6235
  }
6097
- function Ao(e) {
6236
+ function Uo(e) {
6098
6237
  let t = Be(e);
6099
6238
  return (Math.atan2(-t.x, -t.y) * 180 / Math.PI % 360 + 360) % 360;
6100
6239
  }
6101
- var jo = /* @__PURE__ */ new Set([
6240
+ var Wo = /* @__PURE__ */ new Set([
6102
6241
  "circle",
6103
6242
  "g",
6104
6243
  "path",
6105
6244
  "rect",
6106
6245
  "text",
6107
6246
  "title"
6108
- ]), Mo = /* @__PURE__ */ new Set([
6247
+ ]), Go = /* @__PURE__ */ new Set([
6109
6248
  "cx",
6110
6249
  "cy",
6111
6250
  "d",
@@ -6130,46 +6269,46 @@ var jo = /* @__PURE__ */ new Set([
6130
6269
  "x",
6131
6270
  "y"
6132
6271
  ]);
6133
- function No(e, t) {
6272
+ function Ko(e, t) {
6134
6273
  let n = e.localName;
6135
- if (!jo.has(n)) throw TypeError(`Bubble body SVG element is not allowed: ${n}`);
6136
- let r = t.createElementNS(eo, n);
6274
+ if (!Wo.has(n)) throw TypeError(`Bubble body SVG element is not allowed: ${n}`);
6275
+ let r = t.createElementNS(mo, n);
6137
6276
  for (let t of e.getAttributeNames()) {
6138
- if (!Mo.has(t)) throw TypeError(`Bubble body SVG attribute is not allowed: ${t}`);
6277
+ if (!Go.has(t)) throw TypeError(`Bubble body SVG attribute is not allowed: ${t}`);
6139
6278
  let n = e.getAttribute(t) ?? "";
6140
6279
  if (/javascript:|url\s*\(/iu.test(n)) throw TypeError("Bubble body SVG contains an unsafe attribute value.");
6141
6280
  r.setAttribute(t, n);
6142
6281
  }
6143
6282
  (n === "title" || n === "text") && (r.textContent = e.textContent ?? "");
6144
- for (let n of Array.from(e.children)) r.appendChild(No(n, t));
6283
+ for (let n of Array.from(e.children)) r.appendChild(Ko(n, t));
6145
6284
  return r;
6146
6285
  }
6147
- function Po(e, t, n) {
6286
+ function qo(e, t, n) {
6148
6287
  let r = n.defaultView?.DOMParser;
6149
6288
  if (!r) throw TypeError("SVG overlay backend requires DOMParser.");
6150
6289
  let i = new r().parseFromString(t, "image/svg+xml");
6151
6290
  if (i.querySelector("parsererror")) throw TypeError("Canonical Bubble body SVG could not be parsed.");
6152
- let a = Array.from(i.documentElement.children).map((e) => No(e, n));
6291
+ let a = Array.from(i.documentElement.children).map((e) => Ko(e, n));
6153
6292
  e.replaceChildren(...a);
6154
6293
  }
6155
- function Fo(e, t, n = 1) {
6294
+ function Jo(e, t, n = 1) {
6156
6295
  let r = e.getSize(), i = Math.min(t / r.width, t / r.height), a = {
6157
6296
  width: r.width * i * n,
6158
6297
  height: r.height * i * n
6159
6298
  };
6160
6299
  return e.setDisplaySize(a), a;
6161
6300
  }
6162
- function Io(e, t, n, r, i, a) {
6163
- let { document: o, renderer: s } = e, c = co;
6164
- co += 1;
6165
- let l = o.createElementNS(eo, "g");
6301
+ function Yo(e, t, n, r, i, a) {
6302
+ let { document: o, renderer: s } = e, c = So;
6303
+ So += 1;
6304
+ let l = o.createElementNS(mo, "g");
6166
6305
  l.setAttribute("data-bubble-surface", `${n}:${c}`);
6167
- let u = o.createElementNS(eo, "g");
6306
+ let u = o.createElementNS(mo, "g");
6168
6307
  u.setAttribute("data-bubble-layer", "body"), l.appendChild(u);
6169
6308
  let d = (e) => {
6170
- let t = o.createElementNS(eo, "g");
6309
+ let t = o.createElementNS(mo, "g");
6171
6310
  return t.setAttribute("data-bubble-layer", e), t.setAttribute("visibility", "hidden"), l.appendChild(t), t;
6172
- }, f = wo(o, `bubble:${n}:${c}:portrait-base`, d("portrait-base")), p = wo(o, `bubble:${n}:${c}:portrait-blink`, d("portrait-blink")), m = wo(o, `bubble:${n}:${c}:portrait-lip-sync`, d("portrait-lip-sync")), h = d("text"), g = yo(o, h), _ = wo(o, `bubble:${n}:${c}:continue-indicator`, d("continue-indicator")), v = Object.freeze({
6311
+ }, f = Lo(o, `bubble:${n}:${c}:portrait-base`, d("portrait-base")), p = Lo(o, `bubble:${n}:${c}:portrait-blink`, d("portrait-blink")), m = Lo(o, `bubble:${n}:${c}:portrait-lip-sync`, d("portrait-lip-sync")), h = d("text"), g = Mo(o, h), _ = Lo(o, `bubble:${n}:${c}:continue-indicator`, d("continue-indicator")), v = Object.freeze({
6173
6312
  text: g,
6174
6313
  portraitBase: f,
6175
6314
  portraitBlink: p,
@@ -6180,7 +6319,7 @@ function Io(e, t, n, r, i, a) {
6180
6319
  ["portraitBlink", p],
6181
6320
  ["portraitLipSync", m],
6182
6321
  ["continueIndicator", _]
6183
- ]), b = /* @__PURE__ */ new Map(), x = `bubble-portrait-clip-${c}`, S = o.createElementNS(eo, "defs"), C = o.createElementNS(eo, "clipPath"), w = o.createElementNS(eo, "rect");
6322
+ ]), b = /* @__PURE__ */ new Map(), x = `bubble-portrait-clip-${c}`, S = o.createElementNS(mo, "defs"), C = o.createElementNS(mo, "clipPath"), w = o.createElementNS(mo, "rect");
6184
6323
  C.setAttribute("id", x), C.appendChild(w), S.appendChild(C), l.insertBefore(S, u);
6185
6324
  let T = i, E = !1, D = !1, O = "", k = [0, 0], A = 1, j = 1, M = [0, 0], N, P, F = !1, I = (t = e.updateNativeSize()) => {
6186
6325
  let n = t.width / 2 + M[0], r = t.height / 2 - M[1], i = n + k[0], a = r - k[1];
@@ -6194,8 +6333,8 @@ function Io(e, t, n, r, i, a) {
6194
6333
  if (E) return;
6195
6334
  let n = e.updateNativeSize();
6196
6335
  if (T.layoutProfile === "scratch-default" && P !== void 0) {
6197
- let e = $i(P), i = ea({
6198
- bounds: Oo(t),
6336
+ let e = ua(P), i = da({
6337
+ bounds: Vo(t),
6199
6338
  height: e.height,
6200
6339
  pointsLeft: F,
6201
6340
  stageHeight: n.height,
@@ -6208,7 +6347,7 @@ function Io(e, t, n, r, i, a) {
6208
6347
  layout: P,
6209
6348
  pointsLeft: F
6210
6349
  });
6211
- a !== O && (Po(u, aa({
6350
+ a !== O && (qo(u, ga({
6212
6351
  kind: r,
6213
6352
  layout: P,
6214
6353
  pointsLeft: F,
@@ -6220,16 +6359,16 @@ function Io(e, t, n, r, i, a) {
6220
6359
  let i = T.placement.basis === "actor" ? T.offset.scalePercent / 100 : 1, a = g.getCapturedSize() ?? g.getSize(), s = {
6221
6360
  width: a.width * i,
6222
6361
  height: a.height * i
6223
- }, c = (T.portrait?.offset.zoomPercent ?? 100) / 100, l = T.portrait !== void 0, d = l ? Fo(f, no * c, i) : {
6362
+ }, c = (T.portrait?.offset.zoomPercent ?? 100) / 100, l = T.portrait !== void 0, d = l ? Jo(f, go * c, i) : {
6224
6363
  width: 0,
6225
6364
  height: 0
6226
6365
  };
6227
- for (let e of [p, m]) l && Fo(e, no * c, i);
6228
- let v = Fo(_, ro, i), y = d.width + (l ? io * i : 0) + s.width, b = Math.max(d.height, s.height), S = nt(T.visualStyle, ...N === void 0 ? [] : [N.from, N.to]), C = Math.max(y / i + 48, S.width), D = Math.max(b / i + 48, S.height), k = Math.max(y, (C - 48) * i), A = Math.max(b, (D - 48) * i), j = -n.width / 2, I = n.width / 2, ee = n.height / 2, R = -n.height / 2, z, B;
6229
- if (T.placement.basis === "background") z = 0, B = T.placement.region === "HEADER_LIKE" ? ee - ao - A / 2 : T.placement.region === "FOOTER_LIKE" ? R + ao + A / 2 : 0;
6366
+ for (let e of [p, m]) l && Jo(e, go * c, i);
6367
+ let v = Jo(_, _o, i), y = d.width + (l ? vo * i : 0) + s.width, b = Math.max(d.height, s.height), S = nt(T.visualStyle, ...N === void 0 ? [] : [N.from, N.to]), C = Math.max(y / i + 48, S.width), D = Math.max(b / i + 48, S.height), k = Math.max(y, (C - 48) * i), A = Math.max(b, (D - 48) * i), j = -n.width / 2, I = n.width / 2, ee = n.height / 2, R = -n.height / 2, z, B;
6368
+ if (T.placement.basis === "background") z = 0, B = T.placement.region === "HEADER_LIKE" ? ee - yo - A / 2 : T.placement.region === "FOOTER_LIKE" ? R + yo + A / 2 : 0;
6230
6369
  else {
6231
6370
  let e = Ke({
6232
- bounds: Oo(t),
6371
+ bounds: Vo(t),
6233
6372
  bubbleWidth: k,
6234
6373
  bubbleHeight: A,
6235
6374
  direction: T.placement.direction,
@@ -6239,8 +6378,8 @@ function Io(e, t, n, r, i, a) {
6239
6378
  });
6240
6379
  z = e.x, B = e.y;
6241
6380
  }
6242
- z = ko(z, j + k / 2, I - k / 2), B = ko(B, R + A / 2, ee - A / 2), M = [z, B];
6243
- let te = T.placement.basis === "actor" ? Ao(T.placement.direction) : null, ne = T.placement.basis === "actor" ? [
6381
+ z = Ho(z, j + k / 2, I - k / 2), B = Ho(B, R + A / 2, ee - A / 2), M = [z, B];
6382
+ let te = T.placement.basis === "actor" ? Uo(T.placement.direction) : null, ne = T.placement.basis === "actor" ? [
6244
6383
  T.offset.x,
6245
6384
  T.offset.y,
6246
6385
  T.offset.scalePercent
@@ -6267,7 +6406,7 @@ function Io(e, t, n, r, i, a) {
6267
6406
  tailLength: T.tailLength,
6268
6407
  visualStyle: T.visualStyle
6269
6408
  });
6270
- ie !== O && (Po(u, Tt({
6409
+ ie !== O && (qo(u, Tt({
6271
6410
  style: T.visualStyle,
6272
6411
  lines: [],
6273
6412
  width: C,
@@ -6280,16 +6419,16 @@ function Io(e, t, n, r, i, a) {
6280
6419
  }), o), O = ie), u.setAttribute("data-bubble-style", T.visualStyle), u.setAttribute("data-bubble-body-width", String(C)), u.setAttribute("data-bubble-body-height", String(D)), N === void 0 ? (u.removeAttribute("data-bubble-shape-transition-from"), u.removeAttribute("data-bubble-shape-transition-to"), u.removeAttribute("data-bubble-shape-transition-progress")) : (u.setAttribute("data-bubble-shape-transition-from", N.from), u.setAttribute("data-bubble-shape-transition-to", N.to), u.setAttribute("data-bubble-shape-transition-progress", String(N.progress)));
6281
6420
  let ae = z - re.x, oe = B + re.y;
6282
6421
  u.setAttribute("transform", `translate(${n.width / 2 + ae - C / 2} ${n.height / 2 - oe - D / 2})`);
6283
- let se = z - y / 2, ce = T.portrait?.placement ?? "left", le = ce.endsWith("right"), V = (T.portrait?.offset.x ?? 0) * i, ue = (T.portrait?.offset.y ?? 0) * i, de = (le ? se + s.width + io * i : se) + d.width / 2 + V, fe = B;
6422
+ let se = z - y / 2, ce = T.portrait?.placement ?? "left", le = ce.endsWith("right"), V = (T.portrait?.offset.x ?? 0) * i, ue = (T.portrait?.offset.y ?? 0) * i, de = (le ? se + s.width + vo * i : se) + d.width / 2 + V, fe = B;
6284
6423
  ce.startsWith("top-") ? fe = B + b / 2 - d.height / 2 : ce.startsWith("bottom-") && (fe = B - b / 2 + d.height / 2), fe += ue;
6285
- let pe = (le || !l ? se : se + d.width + io * i) + s.width / 2, H = (e, t) => `translate(${n.width / 2 + e} ${n.height / 2 - t})`;
6424
+ let pe = (le || !l ? se : se + d.width + vo * i) + s.width / 2, H = (e, t) => `translate(${n.width / 2 + e} ${n.height / 2 - t})`;
6286
6425
  for (let e of [
6287
6426
  f,
6288
6427
  p,
6289
6428
  m
6290
6429
  ]) e.group.setAttribute("transform", H(de, fe));
6291
6430
  h.setAttribute("transform", `${H(pe, B)} scale(${i})`);
6292
- let U = pe + s.width / 2 - v.width / 2 - io * i, W = B - s.height / 2 + v.height / 2 + io * i;
6431
+ let U = pe + s.width / 2 - v.width / 2 - vo * i, W = B - s.height / 2 + v.height / 2 + vo * i;
6293
6432
  _.group.setAttribute("transform", H(U, W));
6294
6433
  let me = Math.min(T.portrait?.cornerRadius ?? 0, d.width / 2, d.height / 2);
6295
6434
  w.setAttribute("x", String(-d.width / 2)), w.setAttribute("y", String(-d.height / 2)), w.setAttribute("width", String(d.width)), w.setAttribute("height", String(d.height)), w.setAttribute("rx", String(me));
@@ -6335,11 +6474,11 @@ function Io(e, t, n, r, i, a) {
6335
6474
  if (E) return;
6336
6475
  let t = Math.max(0, e.durationSeconds ?? 0), n = () => {
6337
6476
  E || L();
6338
- }, r = (t) => Qa(t, e.ease ?? "easeInOut");
6477
+ }, r = (t) => fo(t, e.ease ?? "easeInOut");
6339
6478
  if (e.name === "fadeIn" || e.name === "floatIn" || e.name === "zoomIn" || e.name === "riseUp") {
6340
6479
  D = !0;
6341
6480
  let i = e.name === "floatIn" || e.name === "riseUp" ? [0, 16] : [0, 0], o = e.name === "zoomIn" ? .01 : 1;
6342
- k = i, A = o, j = e.name === "fadeIn" ? 0 : 1, n(), await $a(a, t, (t) => {
6481
+ k = i, A = o, j = e.name === "fadeIn" ? 0 : 1, n(), await po(a, t, (t) => {
6343
6482
  let a = r(t);
6344
6483
  k = [i[0] * (1 - a), i[1] * (1 - a)], A = o + (1 - o) * a, j = e.name === "fadeIn" ? a : 1, n();
6345
6484
  }), k = [0, 0], A = 1, j = 1, R();
@@ -6347,7 +6486,7 @@ function Io(e, t, n, r, i, a) {
6347
6486
  }
6348
6487
  if (e.name === "fadeOut" || e.name === "floatOut" || e.name === "zoomOut" || e.name === "sink") {
6349
6488
  let i = e.name === "floatOut" || e.name === "sink" ? [0, -16] : [0, 0], o = e.name === "zoomOut" ? .01 : 1;
6350
- await $a(a, t, (t) => {
6489
+ await po(a, t, (t) => {
6351
6490
  let a = r(t);
6352
6491
  k = [i[0] * a, i[1] * a], A = 1 + (o - 1) * a, j = e.name === "fadeOut" ? 1 - a : 1, n();
6353
6492
  }), D = !1, L(), k = [0, 0], A = 1, j = 1;
@@ -6355,7 +6494,7 @@ function Io(e, t, n, r, i, a) {
6355
6494
  }
6356
6495
  if (e.name === "shake") {
6357
6496
  let i = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : i * .08, s = Be(typeof e.direction == "number" ? e.direction : e.direction ?? "right");
6358
- await $a(a, o, (e) => {
6497
+ await po(a, o, (e) => {
6359
6498
  let t = Math.sin(r(e) * i * Math.PI * 2) * 5;
6360
6499
  k = [s.x * t, s.y * t], n();
6361
6500
  }), k = [0, 0], R();
@@ -6363,7 +6502,7 @@ function Io(e, t, n, r, i, a) {
6363
6502
  }
6364
6503
  if (e.name === "explode") {
6365
6504
  let i = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : i * .12, s = e.relativeScale ?? 1.15;
6366
- await $a(a, o, (e) => {
6505
+ await po(a, o, (e) => {
6367
6506
  let t = Math.abs(Math.sin(r(e) * i * Math.PI));
6368
6507
  A = 1 + (s - 1) * t, n();
6369
6508
  }), A = 1, R();
@@ -6375,12 +6514,12 @@ function Io(e, t, n, r, i, a) {
6375
6514
  from: r,
6376
6515
  to: n,
6377
6516
  progress: 0
6378
- }, R(), await $a(a, t, (a) => {
6379
- let o = t === 0 ? 1 : Za(a * Math.max(i, 1));
6517
+ }, R(), await po(a, t, (a) => {
6518
+ let o = t === 0 ? 1 : uo(a * Math.max(i, 1));
6380
6519
  N = {
6381
6520
  from: r,
6382
6521
  to: n,
6383
- progress: Qa(o, e.ease ?? "easeInOut")
6522
+ progress: fo(o, e.ease ?? "easeInOut")
6384
6523
  }, O = "", R();
6385
6524
  }), N = void 0, O = "", R();
6386
6525
  }
@@ -6412,17 +6551,17 @@ function Io(e, t, n, r, i, a) {
6412
6551
  }
6413
6552
  //#endregion
6414
6553
  //#region src/turbowarp-adapter.ts
6415
- var Lo = "sprite", Ro = 96, zo = 18, Bo = 8, Vo = 16, Ho = 0, $ = class extends Error {
6554
+ var Xo = "sprite", Zo = 96, Qo = 18, $o = 8, es = 16, ts = 0, $ = class extends Error {
6416
6555
  code;
6417
6556
  constructor(e, t) {
6418
6557
  super(t), this.name = "BubbleRuntimeAdapterError", this.code = e;
6419
6558
  }
6420
6559
  };
6421
- function Uo(e) {
6560
+ function ns(e) {
6422
6561
  return typeof e == "object" && !!e && !Array.isArray(e);
6423
6562
  }
6424
- function Wo(e) {
6425
- if (!Uo(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp renderer.");
6563
+ function rs(e) {
6564
+ if (!ns(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp renderer.");
6426
6565
  let t = [
6427
6566
  "createSVGSkin",
6428
6567
  "createDrawable",
@@ -6438,41 +6577,41 @@ function Wo(e) {
6438
6577
  if (t.some((t) => typeof e[t] != "function")) throw new $("BUBBLE-RUNTIME-001", `Bubble renderer must provide ${t.join(", ")}.`);
6439
6578
  return e;
6440
6579
  }
6441
- function Go(e) {
6580
+ function is(e) {
6442
6581
  let t = e ?? "svg-overlay";
6443
6582
  if (t !== "scratch-render" && t !== "svg-overlay") throw new $("BUBBLE-RUNTIME-004", "Bubble bubbleRenderBackend must be scratch-render or svg-overlay.");
6444
6583
  return t;
6445
6584
  }
6446
- function Ko(e) {
6585
+ function as(e) {
6447
6586
  let t = e ?? "error";
6448
6587
  if (t !== "error" && t !== "fallback") throw new $("BUBBLE-RUNTIME-004", "Bubble svgOverlayUnsupportedBehavior must be error or fallback.");
6449
6588
  return t;
6450
6589
  }
6451
- function qo(e) {
6590
+ function os(e) {
6452
6591
  let t = e ?? (globalThis.document === void 0 ? void 0 : globalThis.document);
6453
6592
  if (t !== void 0) {
6454
- if (!Uo(t) || typeof t.createElementNS != "function") throw new $("BUBBLE-RUNTIME-004", "Bubble SVG overlay document must provide createElementNS().");
6593
+ if (!ns(t) || typeof t.createElementNS != "function") throw new $("BUBBLE-RUNTIME-004", "Bubble SVG overlay document must provide createElementNS().");
6455
6594
  return t;
6456
6595
  }
6457
6596
  }
6458
- function Jo(e, t, n) {
6597
+ function ss(e, t, n) {
6459
6598
  if (typeof e.addOverlay != "function" || typeof e.removeOverlay != "function") return "the renderer does not provide addOverlay() and removeOverlay()";
6460
6599
  if (t === void 0) return "the host does not provide a DOM document";
6461
6600
  if (typeof t.defaultView?.DOMParser != "function") return "the host document does not provide DOMParser";
6462
- if (!Uo(n) || typeof n.layoutText != "function") return "a host-neutral svgOverlayTextCapability is not available";
6601
+ if (!ns(n) || typeof n.layoutText != "function") return "a host-neutral svgOverlayTextCapability is not available";
6463
6602
  }
6464
- function Yo() {
6603
+ function cs() {
6465
6604
  let e = ke(), t = /* @__PURE__ */ new Set(), n = (n) => {
6466
6605
  e.defineStyle({
6467
6606
  name: n,
6468
6607
  backgroundColor: "transparent"
6469
6608
  }), t.add(n);
6470
6609
  };
6471
- return n("default"), Ua(Object.freeze({ layoutText(r) {
6610
+ return n("default"), no(Object.freeze({ layoutText(r) {
6472
6611
  return t.has(r.styleName) || n(r.styleName), e.layoutText(r);
6473
6612
  } }));
6474
6613
  }
6475
- function Xo(e) {
6614
+ function ls(e) {
6476
6615
  let t = Ae({ runtime: e }), n = /* @__PURE__ */ new Set(), r = (e) => {
6477
6616
  t.defineStyle({
6478
6617
  name: e,
@@ -6481,7 +6620,7 @@ function Xo(e) {
6481
6620
  }, i = (e) => {
6482
6621
  n.has(e) || r(e);
6483
6622
  };
6484
- return r("default"), Ha(Object.freeze({
6623
+ return r("default"), to(Object.freeze({
6485
6624
  setText(e) {
6486
6625
  i(e.styleName), t.setText(e);
6487
6626
  },
@@ -6493,17 +6632,17 @@ function Xo(e) {
6493
6632
  }
6494
6633
  }));
6495
6634
  }
6496
- function Zo(e) {
6497
- if (!Uo(e) || typeof e.isLoaded != "function" || typeof e.getAssetMimeType != "function" || typeof e.resolveSkin != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
6635
+ function us(e) {
6636
+ if (!ns(e) || typeof e.isLoaded != "function" || typeof e.getAssetMimeType != "function" || typeof e.resolveSkin != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
6498
6637
  return e;
6499
6638
  }
6500
- function Qo(e) {
6501
- if (!Uo(e) || typeof e.getDOMImageCapability != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble SVG overlay image assets require @kubohiroya/turbowarp-asset-manager 0.12.1 or a host-provided options.svgOverlayImageCapability.");
6639
+ function ds(e) {
6640
+ if (!ns(e) || typeof e.getDOMImageCapability != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble SVG overlay image assets require @kubohiroya/turbowarp-asset-manager 0.12.1 or a host-provided options.svgOverlayImageCapability.");
6502
6641
  let t = e.getDOMImageCapability();
6503
- if (!Uo(t) || typeof t.isRegistered != "function" || typeof t.getMimeType != "function" || typeof t.resolveDOMImageResource != "function") throw new $("BUBBLE-RUNTIME-002", "Asset Manager did not provide a valid DOM image capability.");
6642
+ if (!ns(t) || typeof t.isRegistered != "function" || typeof t.getMimeType != "function" || typeof t.resolveDOMImageResource != "function") throw new $("BUBBLE-RUNTIME-002", "Asset Manager did not provide a valid DOM image capability.");
6504
6643
  return t;
6505
6644
  }
6506
- function $o(e) {
6645
+ function fs(e) {
6507
6646
  try {
6508
6647
  let t = e.getBoundsForBubble?.();
6509
6648
  if (t && [
@@ -6521,7 +6660,7 @@ function $o(e) {
6521
6660
  top: n
6522
6661
  };
6523
6662
  }
6524
- function es(e, t, n) {
6663
+ function ps(e, t, n) {
6525
6664
  let r = e.getCurrentSkinSize(t.drawableID);
6526
6665
  if (!Array.isArray(r) || r.length < 2) return n;
6527
6666
  let i = Number(r[0]), a = Number(r[1]);
@@ -6530,8 +6669,8 @@ function es(e, t, n) {
6530
6669
  height: a
6531
6670
  };
6532
6671
  }
6533
- function ts(e, t, n, r = 1) {
6534
- let i = es(e, t, {
6672
+ function ms(e, t, n, r = 1) {
6673
+ let i = ps(e, t, {
6535
6674
  width: n,
6536
6675
  height: n
6537
6676
  }), a = Math.min(n / i.width, n / i.height) * r;
@@ -6541,35 +6680,35 @@ function ts(e, t, n, r = 1) {
6541
6680
  scalePercent: a * 100
6542
6681
  };
6543
6682
  }
6544
- function ns(e, t, n) {
6683
+ function hs(e, t, n) {
6545
6684
  let r = Math.min(n, e / 2, t / 2), i = e - r, a = t - r;
6546
6685
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}" viewBox="0 0 ${e} ${t}">
6547
6686
  <path d="M0 0H${e}V${t}H0Z M${r} 0H${i}A${r} ${r} 0 0 1 ${e} ${r}V${a}A${r} ${r} 0 0 1 ${i} ${t}H${r}A${r} ${r} 0 0 1 0 ${a}V${r}A${r} ${r} 0 0 1 ${r} 0Z" fill="#fff4cc" fill-rule="evenodd" data-bubble-portrait-corner-radius="${r}"/>
6548
6687
  </svg>`;
6549
6688
  }
6550
- function rs(e, t, n) {
6689
+ function gs(e, t, n) {
6551
6690
  return n < t ? (t + n) / 2 : Math.min(n, Math.max(t, e));
6552
6691
  }
6553
- function is(e, t, n, r, i) {
6692
+ function _s(e, t, n, r, i) {
6554
6693
  let a = t + r * 2, o = n + i * 2;
6555
6694
  return e.replace(/<svg\b[^>]*>/u, (e) => e.replace(/\bwidth="[^"]*"/u, `width="${a}"`).replace(/\bheight="[^"]*"/u, `height="${o}"`).replace(/\bviewBox="[^"]*"/u, `viewBox="${-r} ${-i} ${a} ${o}"`));
6556
6695
  }
6557
- function as(e) {
6696
+ function vs(e) {
6558
6697
  let t = Be(e);
6559
6698
  return (Math.atan2(-t.x, -t.y) * 180 / Math.PI % 360 + 360) % 360;
6560
6699
  }
6561
- function os(e, t, n, r, i, a) {
6562
- let o = e.renderer, s = Ho;
6563
- Ho += 1;
6700
+ function ys(e, t, n, r, i, a) {
6701
+ let o = e.renderer, s = ts;
6702
+ ts += 1;
6564
6703
  let c = [], l, u, d = (e) => {
6565
- let t = o.createDrawable(Lo);
6704
+ let t = o.createDrawable(Xo);
6566
6705
  if (!Number.isInteger(t) || t < 0) throw new $("BUBBLE-RUNTIME-001", `TurboWarp did not create the Bubble ${e} drawable.`);
6567
6706
  let r = Object.freeze({
6568
6707
  id: `bubble:${n}:${s}:${e}`,
6569
6708
  isStage: !1,
6570
6709
  drawableID: t
6571
6710
  });
6572
- return c.push(r), o.updateDrawableVisible(t, !1), o.setDrawableOrder?.(t, Infinity, Lo), r;
6711
+ return c.push(r), o.updateDrawableVisible(t, !1), o.setDrawableOrder?.(t, Infinity, Xo), r;
6573
6712
  };
6574
6713
  try {
6575
6714
  let n = d("body"), s = i.portrait ? d("portrait-base") : void 0, f = i.portrait?.blink ? d("portrait-blink") : void 0, p = i.portrait?.lipSync ? d("portrait-lip-sync") : void 0, m = i.portrait ? d("portrait-corner-mask") : void 0, h = d("text"), g = i.continueIndicator ? d("continue-indicator") : void 0, _ = Object.freeze({
@@ -6595,8 +6734,8 @@ function os(e, t, n, r, i, a) {
6595
6734
  }, I = () => {
6596
6735
  if (x) return;
6597
6736
  if (w.layoutProfile === "scratch-default" && M !== void 0) {
6598
- let e = o.getNativeSize(), i = Array.isArray(e) && Number(e[0]) > 0 ? Number(e[0]) : 480, a = Array.isArray(e) && Number(e[1]) > 0 ? Number(e[1]) : 360, s = $i(M), c = ea({
6599
- bounds: $o(t),
6737
+ let e = o.getNativeSize(), i = Array.isArray(e) && Number(e[0]) > 0 ? Number(e[0]) : 480, a = Array.isArray(e) && Number(e[1]) > 0 ? Number(e[1]) : 360, s = ua(M), c = da({
6738
+ bounds: fs(t),
6600
6739
  height: s.height,
6601
6740
  pointsLeft: N,
6602
6741
  stageHeight: a,
@@ -6610,7 +6749,7 @@ function os(e, t, n, r, i, a) {
6610
6749
  pointsLeft: N
6611
6750
  });
6612
6751
  if (u !== S) {
6613
- let e = o.createSVGSkin(aa({
6752
+ let e = o.createSVGSkin(ga({
6614
6753
  kind: r,
6615
6754
  layout: M,
6616
6755
  pointsLeft: N,
@@ -6628,7 +6767,7 @@ function os(e, t, n, r, i, a) {
6628
6767
  o.updateDrawableScale(n.drawableID, [100, 100]), o.updateDrawablePosition(n.drawableID, [c.centerX, c.centerY]), E.set(n.drawableID, [c.centerX, c.centerY]), D.set(n.drawableID, [100, 100]), F();
6629
6768
  return;
6630
6769
  }
6631
- let e = w.placement.basis === "actor" ? w.offset.scalePercent / 100 : 1, i = T ?? es(o, h, {
6770
+ let e = w.placement.basis === "actor" ? w.offset.scalePercent / 100 : 1, i = T ?? ps(o, h, {
6632
6771
  width: 180,
6633
6772
  height: 48
6634
6773
  });
@@ -6636,25 +6775,25 @@ function os(e, t, n, r, i, a) {
6636
6775
  let a = {
6637
6776
  width: i.width * e,
6638
6777
  height: i.height * e
6639
- }, c = Ro * ((w.portrait?.offset.zoomPercent ?? 100) / 100), d = s !== void 0 && w.portrait !== void 0, _ = d ? ts(o, s, c, e) : {
6778
+ }, c = Zo * ((w.portrait?.offset.zoomPercent ?? 100) / 100), d = s !== void 0 && w.portrait !== void 0, _ = d ? ms(o, s, c, e) : {
6640
6779
  width: 0,
6641
6780
  height: 0,
6642
6781
  scalePercent: 0
6643
6782
  }, v = /* @__PURE__ */ new Map();
6644
6783
  d && v.set(s.drawableID, _.scalePercent);
6645
6784
  for (let t of [f, p]) if (t && d) {
6646
- let n = ts(o, t, c, e);
6785
+ let n = ms(o, t, c, e);
6647
6786
  v.set(t.drawableID, n.scalePercent);
6648
6787
  }
6649
- let y = g ? ts(o, g, zo, e) : {
6788
+ let y = g ? ms(o, g, Qo, e) : {
6650
6789
  width: 0,
6651
6790
  height: 0,
6652
6791
  scalePercent: 0
6653
- }, b = _.width + (d ? Bo * e : 0) + a.width, O = Math.max(_.height, a.height), k = nt(w.visualStyle, ...j === void 0 ? [] : [j.from, j.to]), A = Math.max(b / e + 48, k.width), I = Math.max(O / e + 48, k.height), ee = Math.max(b, (A - 48) * e), L = Math.max(O, (I - 48) * e), R = o.getNativeSize(), z = Array.isArray(R) && Number(R[0]) > 0 ? Number(R[0]) : 480, B = Array.isArray(R) && Number(R[1]) > 0 ? Number(R[1]) : 360, te = -z / 2, ne = z / 2, re = B / 2, ie = -B / 2, ae = te + ee / 2, oe = ne - ee / 2, se = ie + L / 2, ce = re - L / 2, le, V;
6654
- if (w.placement.basis === "background") le = 0, V = w.placement.region === "HEADER_LIKE" ? re - Vo - L / 2 : w.placement.region === "FOOTER_LIKE" ? ie + Vo + L / 2 : 0;
6792
+ }, b = _.width + (d ? $o * e : 0) + a.width, O = Math.max(_.height, a.height), k = nt(w.visualStyle, ...j === void 0 ? [] : [j.from, j.to]), A = Math.max(b / e + 48, k.width), I = Math.max(O / e + 48, k.height), ee = Math.max(b, (A - 48) * e), L = Math.max(O, (I - 48) * e), R = o.getNativeSize(), z = Array.isArray(R) && Number(R[0]) > 0 ? Number(R[0]) : 480, B = Array.isArray(R) && Number(R[1]) > 0 ? Number(R[1]) : 360, te = -z / 2, ne = z / 2, re = B / 2, ie = -B / 2, ae = te + ee / 2, oe = ne - ee / 2, se = ie + L / 2, ce = re - L / 2, le, V;
6793
+ if (w.placement.basis === "background") le = 0, V = w.placement.region === "HEADER_LIKE" ? re - es - L / 2 : w.placement.region === "FOOTER_LIKE" ? ie + es + L / 2 : 0;
6655
6794
  else {
6656
6795
  let e = Ke({
6657
- bounds: $o(t),
6796
+ bounds: fs(t),
6658
6797
  bubbleWidth: ee,
6659
6798
  bubbleHeight: L,
6660
6799
  direction: w.placement.direction,
@@ -6664,8 +6803,8 @@ function os(e, t, n, r, i, a) {
6664
6803
  });
6665
6804
  le = e.x, V = e.y;
6666
6805
  }
6667
- le = rs(le, ae, oe), V = rs(V, se, ce);
6668
- let ue = w.placement.basis === "actor" ? as(w.placement.direction) : null, de = w.placement.basis === "actor" ? [
6806
+ le = gs(le, ae, oe), V = gs(V, se, ce);
6807
+ let ue = w.placement.basis === "actor" ? vs(w.placement.direction) : null, de = w.placement.basis === "actor" ? [
6669
6808
  w.offset.x,
6670
6809
  w.offset.y,
6671
6810
  w.offset.scalePercent
@@ -6695,7 +6834,7 @@ function os(e, t, n, r, i, a) {
6695
6834
  shapeTransition: j
6696
6835
  });
6697
6836
  if (U !== S) {
6698
- let e = is(Tt({
6837
+ let e = _s(Tt({
6699
6838
  style: w.visualStyle,
6700
6839
  lines: [],
6701
6840
  width: A,
@@ -6716,9 +6855,9 @@ function os(e, t, n, r, i, a) {
6716
6855
  l = t, S = U, r !== void 0 && o.destroySkin(r);
6717
6856
  }
6718
6857
  o.updateDrawableScale(n.drawableID, [100, 100]), o.updateDrawablePosition(n.drawableID, [le - fe.x, V + fe.y]);
6719
- let W = le - b / 2, me = w.portrait?.placement ?? "left", he = me.endsWith("right"), ge = (w.portrait?.offset.x ?? 0) * e, _e = (w.portrait?.offset.y ?? 0) * e, ve = (he ? W + a.width + Bo * e : W) + _.width / 2 + ge, ye = V;
6858
+ let W = le - b / 2, me = w.portrait?.placement ?? "left", he = me.endsWith("right"), ge = (w.portrait?.offset.x ?? 0) * e, _e = (w.portrait?.offset.y ?? 0) * e, ve = (he ? W + a.width + $o * e : W) + _.width / 2 + ge, ye = V;
6720
6859
  me.startsWith("top-") ? ye = V + O / 2 - _.height / 2 : me.startsWith("bottom-") && (ye = V - O / 2 + _.height / 2), ye += _e;
6721
- let be = (he || !d ? W : W + _.width + Bo * e) + a.width / 2;
6860
+ let be = (he || !d ? W : W + _.width + $o * e) + a.width / 2;
6722
6861
  for (let e of [
6723
6862
  s,
6724
6863
  f,
@@ -6733,7 +6872,7 @@ function os(e, t, n, r, i, a) {
6733
6872
  if (i !== C) {
6734
6873
  let e = u;
6735
6874
  if (u = void 0, C = i, r > 0) {
6736
- let e = o.createSVGSkin(ns(t, n, r));
6875
+ let e = o.createSVGSkin(hs(t, n, r));
6737
6876
  if (!Number.isInteger(e) || e < 0) throw new $("BUBBLE-RUNTIME-001", "TurboWarp did not create the Bubble portrait corner mask SVG skin.");
6738
6877
  try {
6739
6878
  o.updateDrawableSkinId(m.drawableID, e), u = e;
@@ -6745,7 +6884,7 @@ function os(e, t, n, r, i, a) {
6745
6884
  }
6746
6885
  o.updateDrawablePosition(m.drawableID, [ve, ye]);
6747
6886
  }
6748
- o.updateDrawablePosition(h.drawableID, [be, V]), g && o.updateDrawablePosition(g.drawableID, [be + a.width / 2 - y.width / 2 - Bo * e, V - a.height / 2 + y.height / 2 + Bo * e]);
6887
+ o.updateDrawablePosition(h.drawableID, [be, V]), g && o.updateDrawablePosition(g.drawableID, [be + a.width / 2 - y.width / 2 - $o * e, V - a.height / 2 + y.height / 2 + $o * e]);
6749
6888
  let xe = (e, t) => {
6750
6889
  e && E.set(e.drawableID, t);
6751
6890
  };
@@ -6759,7 +6898,7 @@ function os(e, t, n, r, i, a) {
6759
6898
  let t = v.get(e.drawableID) ?? 0;
6760
6899
  D.set(e.drawableID, [t, t]);
6761
6900
  }
6762
- m && D.set(m.drawableID, [e * 100, e * 100]), g && D.set(g.drawableID, [y.scalePercent, y.scalePercent]), g && xe(g, [be + a.width / 2 - y.width / 2 - Bo * e, V - a.height / 2 + y.height / 2 + Bo * e]), P(), F();
6901
+ m && D.set(m.drawableID, [e * 100, e * 100]), g && D.set(g.drawableID, [y.scalePercent, y.scalePercent]), g && xe(g, [be + a.width / 2 - y.width / 2 - $o * e, V - a.height / 2 + y.height / 2 + $o * e]), P(), F();
6763
6902
  }, ee = t.onTargetVisualChange, L = (e) => {
6764
6903
  ee?.(e), I();
6765
6904
  }, R = () => I();
@@ -6776,7 +6915,7 @@ function os(e, t, n, r, i, a) {
6776
6915
  n && !r ? t.onTargetVisualChange === L && (t.onTargetVisualChange = ee ?? null) : !n && r && (t.onTargetVisualChange = L), I();
6777
6916
  },
6778
6917
  captureTextLayout() {
6779
- x || (T = es(o, h, {
6918
+ x || (T = ps(o, h, {
6780
6919
  width: 180,
6781
6920
  height: 48
6782
6921
  }), I());
@@ -6791,11 +6930,11 @@ function os(e, t, n, r, i, a) {
6791
6930
  if (x) return;
6792
6931
  let t = Math.max(0, e.durationSeconds ?? 0), n = () => {
6793
6932
  x || (P(), F());
6794
- }, r = (t) => Qa(t, e.ease ?? "easeInOut");
6933
+ }, r = (t) => fo(t, e.ease ?? "easeInOut");
6795
6934
  if (e.name === "fadeIn" || e.name === "floatIn" || e.name === "zoomIn" || e.name === "riseUp") {
6796
6935
  b = !0;
6797
6936
  let i = e.name === "floatIn" || e.name === "riseUp" ? [0, 16] : [0, 0], o = e.name === "zoomIn" ? .01 : 1;
6798
- O = i, k = o, A = e.name === "fadeIn" ? 0 : 1, n(), await $a(a, t, (t) => {
6937
+ O = i, k = o, A = e.name === "fadeIn" ? 0 : 1, n(), await po(a, t, (t) => {
6799
6938
  let a = r(t);
6800
6939
  O = [i[0] * (1 - a), i[1] * (1 - a)], k = o + (1 - o) * a, A = e.name === "fadeIn" ? a : 1, n();
6801
6940
  }), O = [0, 0], k = 1, A = 1, I();
@@ -6803,7 +6942,7 @@ function os(e, t, n, r, i, a) {
6803
6942
  }
6804
6943
  if (e.name === "fadeOut" || e.name === "floatOut" || e.name === "zoomOut" || e.name === "sink") {
6805
6944
  let i = e.name === "floatOut" || e.name === "sink" ? [0, -16] : [0, 0], o = e.name === "zoomOut" ? .01 : 1;
6806
- O = [0, 0], k = 1, A = 1, n(), await $a(a, t, (t) => {
6945
+ O = [0, 0], k = 1, A = 1, n(), await po(a, t, (t) => {
6807
6946
  let a = r(t);
6808
6947
  O = [i[0] * a, i[1] * a], k = 1 + (o - 1) * a, A = e.name === "fadeOut" ? 1 - a : 1, n();
6809
6948
  }), O = i, k = o, A = e.name === "fadeOut" ? 0 : 1, n(), b = !1, F(), O = [0, 0], k = 1, A = 1;
@@ -6811,7 +6950,7 @@ function os(e, t, n, r, i, a) {
6811
6950
  }
6812
6951
  if (e.name === "shake") {
6813
6952
  let i = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : i * .08, s = Be(typeof e.direction == "number" ? e.direction : e.direction ?? "right") ?? Be("right");
6814
- O = [0, 0], await $a(a, o, (e) => {
6953
+ O = [0, 0], await po(a, o, (e) => {
6815
6954
  let t = r(e) * i * Math.PI * 2, a = Math.sin(t) * 5;
6816
6955
  O = [s.x * a, s.y * a], n();
6817
6956
  }), O = [0, 0], I();
@@ -6819,7 +6958,7 @@ function os(e, t, n, r, i, a) {
6819
6958
  }
6820
6959
  if (e.name === "explode") {
6821
6960
  let i = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : i * .12, s = e.relativeScale ?? 1.15;
6822
- await $a(a, o, (e) => {
6961
+ await po(a, o, (e) => {
6823
6962
  let t = r(e), a = Math.abs(Math.sin(t * i * Math.PI));
6824
6963
  k = 1 + (s - 1) * a, n();
6825
6964
  }), k = 1, I();
@@ -6831,12 +6970,12 @@ function os(e, t, n, r, i, a) {
6831
6970
  from: r,
6832
6971
  to: n,
6833
6972
  progress: 0
6834
- }, I(), await $a(a, t, (a) => {
6835
- let o = t === 0 ? 1 : Za(a * Math.max(i, 1) / 1);
6973
+ }, I(), await po(a, t, (a) => {
6974
+ let o = t === 0 ? 1 : uo(a * Math.max(i, 1) / 1);
6836
6975
  j = {
6837
6976
  from: r,
6838
6977
  to: n,
6839
- progress: Qa(o, e.ease ?? "easeInOut")
6978
+ progress: fo(o, e.ease ?? "easeInOut")
6840
6979
  }, I();
6841
6980
  }), j = void 0, I();
6842
6981
  return;
@@ -6851,48 +6990,48 @@ function os(e, t, n, r, i, a) {
6851
6990
  dispose() {
6852
6991
  if (!x) {
6853
6992
  x = !0, o.off?.("NativeSizeChanged", R), w.placement.basis === "actor" && t.onTargetVisualChange === L && (t.onTargetVisualChange = ee ?? null);
6854
- for (let e of [...c].reverse()) o.destroyDrawable(e.drawableID, Lo);
6993
+ for (let e of [...c].reverse()) o.destroyDrawable(e.drawableID, Xo);
6855
6994
  l !== void 0 && (o.destroySkin(l), l = void 0), u !== void 0 && (o.destroySkin(u), u = void 0), e.requestRedraw?.();
6856
6995
  }
6857
6996
  }
6858
6997
  });
6859
6998
  } catch (e) {
6860
- for (let e of [...c].reverse()) o.destroyDrawable(e.drawableID, Lo);
6999
+ for (let e of [...c].reverse()) o.destroyDrawable(e.drawableID, Xo);
6861
7000
  throw l !== void 0 && o.destroySkin(l), u !== void 0 && o.destroySkin(u), e;
6862
7001
  }
6863
7002
  }
6864
- function ss(e, t = {}) {
6865
- if (!Uo(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp runtime.");
6866
- let n = e, r = Wo(n.renderer), i = Go(t.bubbleRenderBackend), a, o;
7003
+ function bs(e, t = {}) {
7004
+ if (!ns(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp runtime.");
7005
+ let n = e, r = rs(n.renderer), i = is(t.bubbleRenderBackend), a, o;
6867
7006
  if (i === "svg-overlay") {
6868
7007
  if (t.svgOverlayTextCapability !== void 0) a = t.svgOverlayTextCapability;
6869
- else if (n.ext_kubohiroyasvgtext === void 0) a = Yo();
7008
+ else if (n.ext_kubohiroyasvgtext === void 0) a = cs();
6870
7009
  else try {
6871
- a = Wa(n.ext_kubohiroyasvgtext);
7010
+ a = ro(n.ext_kubohiroyasvgtext);
6872
7011
  } catch (e) {
6873
7012
  o = e instanceof Error ? e.message : String(e);
6874
7013
  }
6875
7014
  }
6876
- let s = Ko(t.svgOverlayUnsupportedBehavior), c = i === "svg-overlay" ? qo(t.document) : void 0, l = i === "svg-overlay" ? o ?? Jo(r, c, a) : void 0;
7015
+ let s = as(t.svgOverlayUnsupportedBehavior), c = i === "svg-overlay" ? os(t.document) : void 0, l = i === "svg-overlay" ? o ?? ss(r, c, a) : void 0;
6877
7016
  if (i === "svg-overlay" && l !== void 0 && s === "error") throw new $("BUBBLE-RUNTIME-004", `Bubble SVG overlay backend is unavailable because ${l}. Use scratch-render or install the required public upstream capability.`);
6878
7017
  let u = i === "svg-overlay" && l === void 0 ? "svg-overlay" : "scratch-render", d = t.scheduler ?? {
6879
7018
  setTimeout: (e, t) => globalThis.setTimeout(e, t),
6880
7019
  clearTimeout: (e) => globalThis.clearTimeout(e)
6881
- }, f = () => Zo(n.ext_kubohiroyaassetmanager), p, m = () => (p ??= Qo(n.ext_kubohiroyaassetmanager), p), h;
7020
+ }, f = () => us(n.ext_kubohiroyaassetmanager), p, m = () => (p ??= ds(n.ext_kubohiroyaassetmanager), p), h;
6882
7021
  if (u === "svg-overlay") try {
6883
- h = xo(a, r);
7022
+ h = Po(a, r);
6884
7023
  } catch (e) {
6885
7024
  throw new $("BUBBLE-RUNTIME-004", `Bubble SVG overlay text capability is invalid: ${e instanceof Error ? e.message : String(e)}`);
6886
7025
  }
6887
7026
  else if (t.textCapability !== void 0) h = t.textCapability;
6888
7027
  else try {
6889
- h = n.ext_kubohiroyasvgtext === void 0 ? Xo(n) : Va(n.ext_kubohiroyasvgtext);
7028
+ h = n.ext_kubohiroyasvgtext === void 0 ? ls(n) : eo(n.ext_kubohiroyasvgtext);
6890
7029
  } catch (e) {
6891
7030
  throw new $("BUBBLE-RUNTIME-003", `Bubble could not initialize the scratch-render text provider: ${e instanceof Error ? e.message : String(e)}`);
6892
7031
  }
6893
7032
  let g;
6894
7033
  if (u === "svg-overlay") try {
6895
- g = Eo(t.svgOverlayImageCapability ?? Xa(Object.freeze({
7034
+ g = zo(t.svgOverlayImageCapability ?? lo(Object.freeze({
6896
7035
  isRegistered(e) {
6897
7036
  return m().isRegistered(e);
6898
7037
  },
@@ -6917,7 +7056,7 @@ function ss(e, t = {}) {
6917
7056
  let i = t.drawableID;
6918
7057
  if (!Number.isInteger(i) || i < 0) throw new $("BUBBLE-RUNTIME-001", "Bubble image target drawable is invalid.");
6919
7058
  let a = await f().resolveSkin(e);
6920
- if (!Uo(a) || !Number.isInteger(a.skinId) || a.skinId < 0) throw new $("BUBBLE-RUNTIME-002", `Asset Manager did not resolve an image skin: ${String(e)}`);
7059
+ if (!ns(a) || !Number.isInteger(a.skinId) || a.skinId < 0) throw new $("BUBBLE-RUNTIME-002", `Asset Manager did not resolve an image skin: ${String(e)}`);
6921
7060
  r.updateDrawableSkinId(i, a.skinId), n.requestRedraw?.();
6922
7061
  }
6923
7062
  };
@@ -6930,21 +7069,21 @@ function ss(e, t = {}) {
6930
7069
  },
6931
7070
  async playSound(e, t = {}) {
6932
7071
  let n = f(), r = t.untilDone ? n?.playSoundUntilDone : n?.playSound;
6933
- if (typeof r != "function") throw new $("BUBBLE-RUNTIME-002", "TurboWarp Asset Manager does not provide audio playback.");
7072
+ if (typeof r != "function") throw new $("BUBBLE-RUNTIME-002", "TurboWarp-Asset-Manager does not provide audio playback.");
6934
7073
  await r.call(n, { NAME: e });
6935
7074
  }
6936
- }, v = u === "svg-overlay" ? Do(r, c) : void 0;
6937
- return Pa({
7075
+ }, v = u === "svg-overlay" ? Bo(r, c) : void 0;
7076
+ return qa({
6938
7077
  ...g === void 0 ? {} : { imageResolver: g },
6939
7078
  audio: _,
6940
7079
  textCapability: h,
6941
7080
  createSurface({ actor: e, actorKey: t, kind: r, style: i }) {
6942
- if (!Uo(e) || typeof e.id != "string") throw new $("BUBBLE-RUNTIME-001", "Bubble actor target is invalid.");
6943
- return u === "svg-overlay" ? Io(v, e, t, r, i, d) : os(n, e, t, r, i, d);
7081
+ if (!ns(e) || typeof e.id != "string") throw new $("BUBBLE-RUNTIME-001", "Bubble actor target is invalid.");
7082
+ return u === "svg-overlay" ? Yo(v, e, t, r, i, d) : ys(n, e, t, r, i, d);
6944
7083
  },
6945
7084
  ...t.scheduler === void 0 ? {} : { scheduler: t.scheduler },
6946
7085
  ...t.onAnimationError === void 0 ? {} : { onAnimationError: t.onAnimationError }
6947
7086
  });
6948
7087
  }
6949
7088
  //#endregion
6950
- export { $ as BubbleRuntimeAdapterError, lo as bubbleRenderBackends, Xa as createAssetManagerSvgOverlayImageCapability, Eo as createSvgOverlayImageAdapter, Io as createSvgOverlaySurface, Do as createSvgOverlaySurfaceManager, xo as createSvgOverlayTextAdapter, Ha as createSvgTextCompositionCapability, Ua as createSvgTextOverlayTextCapability, ss as createTurboWarpBubbleComposition, Va as createTurboWarpSvgTextCapability, Wa as createTurboWarpSvgTextOverlayTextCapability, fo as defaultBubbleOverlayUnsupportedBehavior, uo as defaultBubbleRenderBackend };
7089
+ export { $ as BubbleRuntimeAdapterError, Co as bubbleRenderBackends, lo as createAssetManagerSvgOverlayImageCapability, zo as createSvgOverlayImageAdapter, Yo as createSvgOverlaySurface, Bo as createSvgOverlaySurfaceManager, Po as createSvgOverlayTextAdapter, to as createSvgTextCompositionCapability, no as createSvgTextOverlayTextCapability, bs as createTurboWarpBubbleComposition, eo as createTurboWarpSvgTextCapability, ro as createTurboWarpSvgTextOverlayTextCapability, To as defaultBubbleOverlayUnsupportedBehavior, wo as defaultBubbleRenderBackend };