@tixyel/streamelements 4.1.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- const $ = [
1
+ const et = [
2
2
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/13e5fa74-defa-11e9-809c-784f43822e80-profile_image-300x300.png",
3
3
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/dbdc9198-def8-11e9-8681-784f43822e80-profile_image-300x300.png",
4
4
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/998f01ae-def8-11e9-b95c-784f43822e80-profile_image-300x300.png",
@@ -6,7 +6,7 @@ const $ = [
6
6
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/ebe4cd89-b4f4-4cd9-adac-2f30151b4209-profile_image-300x300.png",
7
7
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/215b7342-def9-11e9-9a66-784f43822e80-profile_image-300x300.png",
8
8
  "https://static-cdn.jtvnw.net/user-default-pictures-uv/ead5c8b2-a4c9-4724-b1dd-9f00b46cbd3d-profile_image-300x300.png"
9
- ], tt = {
9
+ ], at = {
10
10
  "100 bits": {
11
11
  type: "100 bits",
12
12
  version: "1",
@@ -97,7 +97,7 @@ const $ = [
97
97
  url: "https://static-cdn.jtvnw.net/badges/v1/b817aba4-fad8-49e2-b88a-7cc744dfa6ec/3",
98
98
  description: "VIP"
99
99
  }
100
- }, et = Object.values([
100
+ }, st = Object.values([
101
101
  {
102
102
  type: "twitch",
103
103
  name: "TheIlluminati",
@@ -1448,13 +1448,13 @@ const $ = [
1448
1448
  }
1449
1449
  }
1450
1450
  ]).reduce(
1451
- (i, e) => (i.some((a) => a.name === e.name) || i.push({
1451
+ (s, e) => (s.some((a) => a.name === e.name) || s.push({
1452
1452
  ...e,
1453
1453
  start: 0,
1454
1454
  end: 0
1455
- }), i),
1455
+ }), s),
1456
1456
  []
1457
- ), st = [
1457
+ ), it = [
1458
1458
  "Hello everyone!",
1459
1459
  "PogChamp",
1460
1460
  "This stream is amazing!",
@@ -1505,7 +1505,7 @@ const $ = [
1505
1505
  "BloodTrail hunting time",
1506
1506
  "CatBag kitty!",
1507
1507
  "c! poggers"
1508
- ], at = ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"], it = [
1508
+ ], nt = ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"], rt = [
1509
1509
  "Filiz",
1510
1510
  "Astrid",
1511
1511
  "Tatyana",
@@ -1593,7 +1593,7 @@ const $ = [
1593
1593
  "Szabolcs",
1594
1594
  "Hoda",
1595
1595
  "Naayf"
1596
- ], nt = [], rt = ["1000", "2000", "3000", "prime"], ct = [
1596
+ ], ct = [], ot = ["1000", "2000", "3000", "prime"], dt = [
1597
1597
  "aliceblue",
1598
1598
  "antiquewhite",
1599
1599
  "aqua",
@@ -1743,7 +1743,7 @@ const $ = [
1743
1743
  "yellow",
1744
1744
  "yellowgreen",
1745
1745
  "transparent"
1746
- ], ot = [
1746
+ ], ht = [
1747
1747
  {
1748
1748
  emojiId: "UCkszU2WH9gy1mb0dV-11UJg/flower-rainbow-heart-red",
1749
1749
  shortcuts: [":pride-flower-rainbow-heart:"],
@@ -4918,54 +4918,54 @@ const $ = [
4918
4918
  }
4919
4919
  ];
4920
4920
  var W;
4921
- ((i) => {
4921
+ ((s) => {
4922
4922
  let e;
4923
- ((r) => {
4923
+ ((i) => {
4924
4924
  ((t) => {
4925
4925
  t.hehim = "He/Him", t.sheher = "She/Her", t.theythem = "They/Them", t.shethem = "She/They", t.hethem = "He/They", t.heshe = "He/She", t.xexem = "Xe/Xem", t.faefaer = "Fae/Faer", t.vever = "Ve/Ver", t.aeaer = "Ae/Aer", t.ziehir = "Zie/Hir", t.perper = "Per/Per", t.eem = "E/Em", t.itits = "It/Its";
4926
- })(r.map || (r.map = {}));
4927
- })(e = i.Pronouns || (i.Pronouns = {}));
4926
+ })(i.map || (i.map = {}));
4927
+ })(e = s.Pronouns || (s.Pronouns = {}));
4928
4928
  async function a() {
4929
4929
  try {
4930
- const r = await fetch("https://pronouns.alejo.io/api/pronouns").then((t) => t.json());
4931
- if (Array.isArray(r) && r.length) {
4932
- const t = Object.fromEntries(r.map(({ name: s, display: n }) => [s, n]));
4930
+ const i = await fetch("https://pronouns.alejo.io/api/pronouns").then((t) => t.json());
4931
+ if (Array.isArray(i) && i.length) {
4932
+ const t = Object.fromEntries(i.map(({ name: n, display: c }) => [n, c]));
4933
4933
  return { ...e.map, ...t };
4934
4934
  }
4935
4935
  } catch {
4936
4936
  }
4937
4937
  return { ...e.map };
4938
4938
  }
4939
- i.list = a;
4940
- async function c(r) {
4941
- if (!r) throw new Error("Username is required to fetch Alejo data.");
4942
- if (r = r.toLowerCase(), r in client.storage.data.pronoun && client.storage.data.pronoun[r].expire > Date.now())
4943
- return client.storage.data.pronoun[r].value;
4939
+ s.list = a;
4940
+ async function o(i) {
4941
+ if (!i) throw new Error("Username is required to fetch Alejo data.");
4942
+ if (i = i.toLowerCase(), i in client.storage.data.pronoun && client.storage.data.pronoun[i].expire > Date.now())
4943
+ return client.storage.data.pronoun[i].value;
4944
4944
  try {
4945
- const t = await fetch(`https://pronouns.alejo.io/api/users/${r}`).then((s) => s.json()).then(([s]) => s);
4945
+ const t = await fetch(`https://pronouns.alejo.io/api/users/${i}`).then((n) => n.json()).then(([n]) => n);
4946
4946
  if (t)
4947
- return client.storage.add(`pronoun.${r}`, {
4947
+ return client.storage.add(`pronoun.${i}`, {
4948
4948
  value: t.pronoun_id,
4949
4949
  timestamp: Date.now(),
4950
4950
  expire: Date.now() + client.cache.pronoun * 60 * 1e3
4951
- }), client.storage.data.pronoun[r].value ?? t.pronoun_id;
4951
+ }), client.storage.data.pronoun[i].value ?? t.pronoun_id;
4952
4952
  } catch (t) {
4953
- throw new Error(`Failed to fetch pronoun data for user "${r}": ${t instanceof Error ? t.message : t}`);
4953
+ throw new Error(`Failed to fetch pronoun data for user "${i}": ${t instanceof Error ? t.message : t}`);
4954
4954
  }
4955
4955
  }
4956
- i.get = c;
4956
+ s.get = o;
4957
4957
  })(W || (W = {}));
4958
- function dt(i, e) {
4958
+ function lt(s, e) {
4959
4959
  if (!e) return null;
4960
4960
  switch (e) {
4961
4961
  case "hex": {
4962
- const a = i.replace("#", "");
4963
- let c = 0, r = 0, t = 0, s = 1;
4964
- return a.length === 3 ? (c = parseInt(a[0] + a[0], 16), r = parseInt(a[1] + a[1], 16), t = parseInt(a[2] + a[2], 16)) : a.length === 6 ? (c = parseInt(a.slice(0, 2), 16), r = parseInt(a.slice(2, 4), 16), t = parseInt(a.slice(4, 6), 16)) : a.length === 4 ? (c = parseInt(a[0] + a[0], 16), r = parseInt(a[1] + a[1], 16), t = parseInt(a[2] + a[2], 16), s = parseInt(a[3] + a[3], 16) / 255) : a.length === 8 && (c = parseInt(a.slice(0, 2), 16), r = parseInt(a.slice(2, 4), 16), t = parseInt(a.slice(4, 6), 16), s = parseInt(a.slice(6, 8), 16) / 255), { r: c, g: r, b: t, a: s };
4962
+ const a = s.replace("#", "");
4963
+ let o = 0, i = 0, t = 0, n = 1;
4964
+ return a.length === 3 ? (o = parseInt(a[0] + a[0], 16), i = parseInt(a[1] + a[1], 16), t = parseInt(a[2] + a[2], 16)) : a.length === 6 ? (o = parseInt(a.slice(0, 2), 16), i = parseInt(a.slice(2, 4), 16), t = parseInt(a.slice(4, 6), 16)) : a.length === 4 ? (o = parseInt(a[0] + a[0], 16), i = parseInt(a[1] + a[1], 16), t = parseInt(a[2] + a[2], 16), n = parseInt(a[3] + a[3], 16) / 255) : a.length === 8 && (o = parseInt(a.slice(0, 2), 16), i = parseInt(a.slice(2, 4), 16), t = parseInt(a.slice(4, 6), 16), n = parseInt(a.slice(6, 8), 16) / 255), { r: o, g: i, b: t, a: n };
4965
4965
  }
4966
4966
  case "rgb":
4967
4967
  case "rgba": {
4968
- const a = i.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
4968
+ const a = s.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);
4969
4969
  return a ? {
4970
4970
  r: parseInt(a[1]),
4971
4971
  g: parseInt(a[2]),
@@ -4975,106 +4975,639 @@ function dt(i, e) {
4975
4975
  }
4976
4976
  case "hsl":
4977
4977
  case "hsla": {
4978
- const a = i.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*([\d.]+))?\s*\)/);
4978
+ const a = s.match(/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*([\d.]+))?\s*\)/);
4979
4979
  if (!a) return null;
4980
- const c = parseInt(a[1]), r = parseInt(a[2]), t = parseInt(a[3]), s = a[4] ? parseFloat(a[4]) : 1;
4981
- return { ...lt(c, r, t), a: s };
4980
+ const o = parseInt(a[1]), i = parseInt(a[2]), t = parseInt(a[3]), n = a[4] ? parseFloat(a[4]) : 1;
4981
+ return { ...ut(o, i, t), a: n };
4982
4982
  }
4983
4983
  case "css-color-name": {
4984
4984
  const a = document.createElement("canvas");
4985
4985
  a.width = a.height = 1;
4986
- const c = a.getContext("2d");
4987
- if (!c) return null;
4988
- c.fillStyle = i, c.fillRect(0, 0, 1, 1);
4989
- const [r, t, s] = c.getImageData(0, 0, 1, 1).data;
4990
- return { r, g: t, b: s, a: 1 };
4986
+ const o = a.getContext("2d");
4987
+ if (!o) return null;
4988
+ o.fillStyle = s, o.fillRect(0, 0, 1, 1);
4989
+ const [i, t, n] = o.getImageData(0, 0, 1, 1).data;
4990
+ return { r: i, g: t, b: n, a: 1 };
4991
4991
  }
4992
4992
  default:
4993
4993
  return null;
4994
4994
  }
4995
4995
  }
4996
- function ht(i, e = !0) {
4997
- const a = (r) => Math.round(r).toString(16).padStart(2, "0");
4998
- let c = `#${a(i.r)}${a(i.g)}${a(i.b)}`;
4999
- return e && i.a < 1 && (c += a(i.a * 255)), c;
4996
+ function mt(s, e = !0) {
4997
+ const a = (i) => Math.round(i).toString(16).padStart(2, "0");
4998
+ let o = `#${a(s.r)}${a(s.g)}${a(s.b)}`;
4999
+ return e && s.a < 1 && (o += a(s.a * 255)), o;
5000
5000
  }
5001
- function X(i, e, a) {
5002
- i /= 255, e /= 255, a /= 255;
5003
- const c = Math.max(i, e, a), r = Math.min(i, e, a), t = c - r;
5004
- let s = 0, n = 0;
5005
- const o = (c + r) / 2;
5001
+ function X(s, e, a) {
5002
+ s /= 255, e /= 255, a /= 255;
5003
+ const o = Math.max(s, e, a), i = Math.min(s, e, a), t = o - i;
5004
+ let n = 0, c = 0;
5005
+ const r = (o + i) / 2;
5006
5006
  if (t !== 0)
5007
- switch (n = o > 0.5 ? t / (2 - c - r) : t / (c + r), c) {
5008
- case i:
5009
- s = ((e - a) / t + (e < a ? 6 : 0)) / 6;
5007
+ switch (c = r > 0.5 ? t / (2 - o - i) : t / (o + i), o) {
5008
+ case s:
5009
+ n = ((e - a) / t + (e < a ? 6 : 0)) / 6;
5010
5010
  break;
5011
5011
  case e:
5012
- s = ((a - i) / t + 2) / 6;
5012
+ n = ((a - s) / t + 2) / 6;
5013
5013
  break;
5014
5014
  case a:
5015
- s = ((i - e) / t + 4) / 6;
5015
+ n = ((s - e) / t + 4) / 6;
5016
5016
  break;
5017
5017
  }
5018
5018
  return {
5019
- h: Math.round(s * 360),
5020
- s: Math.round(n * 100),
5021
- l: Math.round(o * 100)
5019
+ h: Math.round(n * 360),
5020
+ s: Math.round(c * 100),
5021
+ l: Math.round(r * 100)
5022
5022
  };
5023
5023
  }
5024
- function lt(i, e, a) {
5025
- i /= 360, e /= 100, a /= 100;
5026
- let c, r, t;
5024
+ function ut(s, e, a) {
5025
+ s /= 360, e /= 100, a /= 100;
5026
+ let o, i, t;
5027
5027
  if (e === 0)
5028
- c = r = t = a;
5028
+ o = i = t = a;
5029
5029
  else {
5030
- const s = (h, u, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? h + (u - h) * 6 * m : m < 0.5 ? u : m < 0.6666666666666666 ? h + (u - h) * (0.6666666666666666 - m) * 6 : h), n = a < 0.5 ? a * (1 + e) : a + e - a * e, o = 2 * a - n;
5031
- c = s(o, n, i + 1 / 3), r = s(o, n, i), t = s(o, n, i - 1 / 3);
5030
+ const n = (d, l, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? d + (l - d) * 6 * m : m < 0.5 ? l : m < 0.6666666666666666 ? d + (l - d) * (0.6666666666666666 - m) * 6 : d), c = a < 0.5 ? a * (1 + e) : a + e - a * e, r = 2 * a - c;
5031
+ o = n(r, c, s + 1 / 3), i = n(r, c, s), t = n(r, c, s - 1 / 3);
5032
5032
  }
5033
5033
  return {
5034
- r: Math.round(c * 255),
5035
- g: Math.round(r * 255),
5034
+ r: Math.round(o * 255),
5035
+ g: Math.round(i * 255),
5036
5036
  b: Math.round(t * 255)
5037
5037
  };
5038
5038
  }
5039
- function mt(i, e, a) {
5040
- const c = C.data.css_color_names;
5041
- let r = c[0], t = 1 / 0;
5042
- for (const s of c) {
5043
- const n = document.createElement("canvas");
5044
- n.width = n.height = 1;
5045
- const o = n.getContext("2d");
5046
- if (!o) continue;
5047
- o.fillStyle = s, o.fillRect(0, 0, 1, 1);
5048
- const [h, u, m] = o.getImageData(0, 0, 1, 1).data, g = Math.sqrt(Math.pow(i - h, 2) + Math.pow(e - u, 2) + Math.pow(a - m, 2));
5049
- if (g < t && (t = g, r = s), g === 0) break;
5039
+ function gt(s, e, a) {
5040
+ const o = x.data.css_color_names;
5041
+ let i = o[0], t = 1 / 0;
5042
+ for (const n of o) {
5043
+ const c = document.createElement("canvas");
5044
+ c.width = c.height = 1;
5045
+ const r = c.getContext("2d");
5046
+ if (!r) continue;
5047
+ r.fillStyle = n, r.fillRect(0, 0, 1, 1);
5048
+ const [d, l, m] = r.getImageData(0, 0, 1, 1).data, u = Math.sqrt(Math.pow(s - d, 2) + Math.pow(e - l, 2) + Math.pow(a - m, 2));
5049
+ if (u < t && (t = u, i = n), u === 0) break;
5050
5050
  }
5051
- return r;
5051
+ return i;
5052
5052
  }
5053
- var C;
5054
- ((i) => {
5055
- i.data = {
5056
- names: at,
5057
- messages: st,
5058
- tiers: rt,
5059
- avatars: $,
5060
- emotes: et,
5061
- youtube_emotes: ot,
5062
- badges: tt,
5063
- items: nt,
5064
- tts: it,
5053
+ class O {
5054
+ /**
5055
+ * Stores registered event listeners.
5056
+ */
5057
+ registeredEvents = {};
5058
+ /**
5059
+ * Emits an event to all registered listeners.
5060
+ * Returns an array of return values from the listeners.
5061
+ * @param eventName The name of the event.
5062
+ * @param args Arguments to pass to the listeners.
5063
+ */
5064
+ emit(e, ...a) {
5065
+ return (this.registeredEvents[e] || []).map((i) => i.apply(this, a));
5066
+ }
5067
+ /**
5068
+ * Registers an event listener.
5069
+ * @param eventName The name of the event.
5070
+ * @param callback The callback function.
5071
+ */
5072
+ on(e, a) {
5073
+ if (typeof a != "function")
5074
+ throw new TypeError("Callback must be a function");
5075
+ return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(a), this;
5076
+ }
5077
+ /**
5078
+ * Removes a specific event listener.
5079
+ * @param eventName The name of the event.
5080
+ * @param callback The callback function to remove.
5081
+ */
5082
+ off(e, a) {
5083
+ const o = this.registeredEvents[e] || [];
5084
+ return a ? (this.registeredEvents[e] = o.filter((i) => i !== a), this) : (this.registeredEvents[e] = [], this);
5085
+ }
5086
+ /**
5087
+ * Registers a listener that is executed only once.
5088
+ * @param eventName The name of the event.
5089
+ * @param callback The callback function.
5090
+ */
5091
+ once(e, a) {
5092
+ const o = (...i) => {
5093
+ this.off(e, o), a.apply(this, i);
5094
+ };
5095
+ return this.on(e, o), this;
5096
+ }
5097
+ /**
5098
+ * Removes all listeners for a specific event.
5099
+ * @param eventName The name of the event.
5100
+ */
5101
+ removeAllListeners(e) {
5102
+ return this.registeredEvents[e] = [], this;
5103
+ }
5104
+ }
5105
+ var _ = [];
5106
+ class S extends O {
5107
+ /**
5108
+ * The unique identifier for the storage instance.
5109
+ */
5110
+ id = "default";
5111
+ loaded = !1;
5112
+ data;
5113
+ constructor(e) {
5114
+ super(), this.id = e.id || this.id, this.data = e.data ?? {}, _.push(this), this.start();
5115
+ }
5116
+ SE_API = null;
5117
+ start() {
5118
+ tt?.then((e) => {
5119
+ this.SE_API = e, e.store.get(this.id).then((a) => {
5120
+ this.data = a ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(a) && this.emit("update", this.data);
5121
+ }).catch(() => {
5122
+ this.loaded = !0, this.emit("load", this.data);
5123
+ });
5124
+ });
5125
+ }
5126
+ /**
5127
+ * Saves the current data to storage.
5128
+ * @param data Data to save (defaults to current)
5129
+ */
5130
+ save(e = this.data) {
5131
+ this.loaded && this.SE_API && (this.data = e, this.SE_API.store.set(this.id, this.data), this.emit("update", this.data));
5132
+ }
5133
+ /**
5134
+ * Updates the storage data and emits an update event
5135
+ * @param data Data to update (defaults to current)
5136
+ */
5137
+ update(e = this.data) {
5138
+ this.loaded && JSON.stringify(this.data) !== JSON.stringify(e) && (this.data = { ...this.data, ...e }, this.save(this.data));
5139
+ }
5140
+ /**
5141
+ * Adds a value to the storage at the specified path.
5142
+ * @param path Path to add the value to
5143
+ * @param value Value to add
5144
+ */
5145
+ add(e, a) {
5146
+ this.loaded && (S.setByPath(this.data, e, a), this.save(this.data));
5147
+ }
5148
+ /**
5149
+ * Clears all data from the storage.
5150
+ */
5151
+ clear() {
5152
+ this.loaded && (this.data = {}, this.save(this.data));
5153
+ }
5154
+ /**
5155
+ * Sets a value in the storage at the specified path.
5156
+ * @param obj The object to set the value in
5157
+ * @param path The path to set the value at
5158
+ * @param value The value to set
5159
+ * @returns The updated object
5160
+ */
5161
+ static setByPath(e, a, o) {
5162
+ const i = a.split(".");
5163
+ let t = e;
5164
+ for (let n = 0; n < i.length - 1; n++)
5165
+ (typeof t[i[n]] != "object" || t[i[n]] == null) && (t[i[n]] = {}), t = t[i[n]];
5166
+ return t[i[i.length - 1]] = o, t;
5167
+ }
5168
+ on(e, a) {
5169
+ return e === "load" && this.loaded ? (a.apply(this, [this.data]), this) : (super.on(e, a), this);
5170
+ }
5171
+ }
5172
+ class J extends O {
5173
+ id = "default";
5174
+ debug = !1;
5175
+ storage;
5176
+ fields = {};
5177
+ session;
5178
+ loaded = !1;
5179
+ constructor(e) {
5180
+ super(), this.id = e.id || this.id, this.storage = new S({
5181
+ id: this.id,
5182
+ data: {
5183
+ user: {},
5184
+ avatar: {},
5185
+ pronoun: {},
5186
+ emote: {}
5187
+ }
5188
+ }), this.on("load", () => {
5189
+ this.debug = !!(typeof e.debug == "function" ? e.debug() : e.debug);
5190
+ }), window.client = this;
5191
+ }
5192
+ actions = {
5193
+ commands: [],
5194
+ buttons: []
5195
+ };
5196
+ details;
5197
+ cache = {
5198
+ avatar: 30,
5199
+ pronoun: 60,
5200
+ emote: 120
5201
+ };
5202
+ on(e, a) {
5203
+ return e === "load" && this.loaded ? (a.apply(this, [
5204
+ {
5205
+ channel: this.details.user,
5206
+ currency: this.details.currency,
5207
+ fieldData: this.fields,
5208
+ recents: [],
5209
+ session: {
5210
+ data: this.session,
5211
+ settings: {
5212
+ autoReset: !1,
5213
+ calendar: !1,
5214
+ resetOnStart: !1
5215
+ }
5216
+ },
5217
+ overlay: this.details.overlay,
5218
+ emulated: !1
5219
+ }
5220
+ ]), this) : (super.on(e, a), this);
5221
+ }
5222
+ }
5223
+ class Q extends O {
5224
+ queue = [];
5225
+ priorityQueue = [];
5226
+ history = [];
5227
+ timeouts = [];
5228
+ running = !1;
5229
+ duration = void 0;
5230
+ loaded = !1;
5231
+ processor;
5232
+ constructor(e) {
5233
+ super(), window.client instanceof J && (this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration), window.client.on("load", () => {
5234
+ e.duration === "client" && (this.duration = client.fields.widgetDuration ?? 0), this.emit("load"), this.loaded = !0;
5235
+ }));
5236
+ }
5237
+ enqueue(e, a = {}) {
5238
+ const o = {
5239
+ isoDate: (/* @__PURE__ */ new Date()).toISOString(),
5240
+ isLoop: a?.isLoop ?? !1,
5241
+ isPriority: a?.isPriority ?? !1,
5242
+ isImmediate: a?.isImmediate ?? !1,
5243
+ value: e
5244
+ }, i = this.hasItems();
5245
+ return o.isPriority && o.isImmediate ? (this.cancel(), this.priorityQueue.unshift(o)) : (o.isPriority ? this.priorityQueue : this.queue).push(o), this.running === !1 && i === !1 && this.run(), this.emit("update", this.queue, this.priorityQueue, this.history, this.timeouts), this;
5246
+ }
5247
+ async run() {
5248
+ if (!this.hasItems()) {
5249
+ this.running = !1;
5250
+ return;
5251
+ }
5252
+ this.running = !0, await this.next(), typeof this.duration == "number" && this.duration > 0 ? this.timeouts.push(setTimeout(() => this.run(), this.duration)) : (this.duration === 0 || this.duration !== -1 && this.duration !== !1) && this.run();
5253
+ }
5254
+ async next() {
5255
+ const e = this.priorityQueue.length > 0 ? this.priorityQueue.shift() : this.queue.shift();
5256
+ if (!e) {
5257
+ this.running = !1;
5258
+ return;
5259
+ }
5260
+ try {
5261
+ await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
5262
+ } catch (o) {
5263
+ k.error(`Error during item processing: ${o instanceof Error ? o.message : String(o)}`);
5264
+ }
5265
+ this.history.push(e);
5266
+ const a = e.isPriority ? this.priorityQueue : this.queue;
5267
+ e.isLoop && a.push(e);
5268
+ }
5269
+ resume() {
5270
+ return this.running && this.cancel(), this.hasItems() && this.run(), this;
5271
+ }
5272
+ update(e) {
5273
+ return this.queue = e.queue ?? this.queue, this.priorityQueue = e.priorityQueue ?? this.priorityQueue, this.history = e.history ?? this.history, this.hasItems() && this.running === !1 && window.client?.on("load", () => this.run()), this;
5274
+ }
5275
+ cancel() {
5276
+ this.running && (this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts = [], this.running = !1, this.emit("cancel"));
5277
+ }
5278
+ hasItems() {
5279
+ return this.queue.length > 0 || this.priorityQueue.length > 0;
5280
+ }
5281
+ on(e, a) {
5282
+ return e === "load" && this.loaded ? (a.apply(this), this) : (super.on(e, a), this);
5283
+ }
5284
+ }
5285
+ class R {
5286
+ prefix = "!";
5287
+ name;
5288
+ description;
5289
+ arguments = !1;
5290
+ test = `${this.prefix}${this.name} arg1 arg2`;
5291
+ aliases = [];
5292
+ permissions = void 0;
5293
+ admins = [];
5294
+ constructor(e) {
5295
+ window.client instanceof J && (this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, window.client.actions.commands.push(this), window.client.emit("action", this, "created"));
5296
+ }
5297
+ run(e, a) {
5298
+ }
5299
+ verify(e, a, o) {
5300
+ return this.arguments === !0 && (!o || !o.length) ? !1 : this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase()) ? !0 : this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length ? !1 : !!(Array.isArray(this.permissions) && this.permissions.some((i) => e.toLowerCase() === i.toLowerCase() || a.map((t) => t.toLowerCase()).includes(i.toLowerCase())));
5301
+ }
5302
+ parse(e, a) {
5303
+ if (!(window.client instanceof J)) return !1;
5304
+ const o = e.replace(this.prefix, "").split(" ").slice(1).map((r) => r.trim());
5305
+ var i = "", t = [];
5306
+ const n = { bits: "cheer", premium: "prime" };
5307
+ switch (a.provider) {
5308
+ case "twitch": {
5309
+ const r = a.data;
5310
+ i = r.event.data.nick || r.event.data.displayName, r.event.data.tags?.badges && (t = r.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((l) => l in n ? n[l] : l));
5311
+ break;
5312
+ }
5313
+ case "youtube": {
5314
+ const r = a.data, d = {
5315
+ isVerified: "verified",
5316
+ isChatOwner: "owner",
5317
+ isChatSponsor: "sponsor",
5318
+ isChatModerator: "moderator"
5319
+ };
5320
+ i = r.event.data.nick || r.event.data.displayName, t = Object.entries(r.event.data.authorDetails).filter(([l, m]) => l.startsWith("is") && m).map(([l]) => d[l]).filter(Boolean);
5321
+ break;
5322
+ }
5323
+ case "kick":
5324
+ return !1;
5325
+ }
5326
+ const c = this.verify(i, t, o);
5327
+ return c === !0 && this.run.apply(window.client, [o, a]), c;
5328
+ }
5329
+ remove() {
5330
+ if (!(window.client instanceof J)) return;
5331
+ const e = window.client.actions.commands.indexOf(this);
5332
+ e > -1 && (window.client.actions.commands.splice(e, 1), window.client.emit("action", this, "removed"));
5333
+ }
5334
+ static execute(e) {
5335
+ if (!(window.client instanceof J)) return !1;
5336
+ const a = e.data;
5337
+ try {
5338
+ if (window.client.actions.commands.length && window.client.actions.commands.some((o) => a.event.data.text.startsWith(o.prefix))) {
5339
+ const o = window.client.actions.commands.filter((i) => {
5340
+ var t = [i.name, ...i.aliases ?? []], n = a.event.data.text.replace(i.prefix, "").split(" ")[0];
5341
+ return t.includes(n);
5342
+ });
5343
+ if (o.length && o.every((i) => i instanceof R))
5344
+ return o.forEach((i) => {
5345
+ i.parse(a.event.data.text, e), window.client.emit("action", i, "executed"), k.received(`Command executed: ${a.event.data.text} by ${a.event.data.nick || a.event.data.displayName}`, a);
5346
+ }), !0;
5347
+ }
5348
+ } catch {
5349
+ return !1;
5350
+ } finally {
5351
+ return !1;
5352
+ }
5353
+ }
5354
+ }
5355
+ class V {
5356
+ field = "button";
5357
+ template = "button";
5358
+ run;
5359
+ constructor(e) {
5360
+ window.client instanceof J && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
5361
+ }
5362
+ parse(e, a) {
5363
+ var o = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
5364
+ try {
5365
+ this.run.apply(window.client, [o.length ? o : e ?? e, a]);
5366
+ } catch (i) {
5367
+ throw new Error(`Error running button "${this.field}": ${i instanceof Error ? i.message : i}`);
5368
+ }
5369
+ return this;
5370
+ }
5371
+ remove() {
5372
+ if (!(window.client instanceof J)) return;
5373
+ const e = window.client.actions.buttons.indexOf(this);
5374
+ e > -1 && (window.client.actions.buttons.splice(e, 1), window.client.emit("action", this, "removed"));
5375
+ }
5376
+ static execute(e, a) {
5377
+ try {
5378
+ if (!(window.client instanceof J)) return !1;
5379
+ if (window.client.actions.buttons.length) {
5380
+ const o = window.client.actions.buttons.filter((i) => typeof i.field == "string" ? i.field === e : typeof i.field == "function" ? i.field(e, a) : !1);
5381
+ if (o.length && o.every((i) => i instanceof V))
5382
+ return o.forEach((i) => {
5383
+ try {
5384
+ i.parse(e, a), window.client.emit("action", i, "executed"), k.received(`Button executed: ${e}${a ? ` with value: ${a}` : ""}`);
5385
+ } catch (t) {
5386
+ k.error(`Error executing button "${e}": ${t instanceof Error ? t.message : t}`);
5387
+ }
5388
+ }), !0;
5389
+ }
5390
+ } catch {
5391
+ return !1;
5392
+ } finally {
5393
+ return !1;
5394
+ }
5395
+ }
5396
+ }
5397
+ window.addEventListener("load", () => {
5398
+ });
5399
+ window.addEventListener("onWidgetLoad", async (s) => {
5400
+ const { detail: e } = s;
5401
+ if (window.client instanceof J) {
5402
+ const a = window.client;
5403
+ a.fields = e.fieldData, a.session = e.session.data, a.details = {
5404
+ ...a.details,
5405
+ user: e.channel,
5406
+ currency: e.currency,
5407
+ overlay: e.overlay
5408
+ }, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((o) => o.json()).then((o) => {
5409
+ if (o.provider)
5410
+ return a.details.provider = o.provider, o.provider;
5411
+ a.details.provider = "local";
5412
+ }).catch(() => {
5413
+ a.details.provider = "local";
5414
+ }) : a.details.provider = "local", a.emit("load", e), a.loaded = !0, a.storage.on("load", (o) => {
5415
+ if (a.debug && o ? k.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, o) : a.debug && k.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, "No data found."), o) {
5416
+ const i = (d) => {
5417
+ const l = Date.now(), m = {};
5418
+ for (const u in d)
5419
+ if (d.hasOwnProperty(u)) {
5420
+ const f = d[u];
5421
+ f.expire && f.expire > l && (m[u] = f);
5422
+ }
5423
+ return m;
5424
+ }, t = i(o.user || {}), n = i(o.avatar || {}), c = i(o.pronoun || {}), r = i(o.emote || {});
5425
+ a.storage.update({
5426
+ user: t,
5427
+ avatar: n,
5428
+ pronoun: c,
5429
+ emote: r
5430
+ });
5431
+ }
5432
+ e.channel.providerId.length && a.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
5433
+ value: e.channel.avatar,
5434
+ timestamp: Date.now(),
5435
+ expire: Date.now() + a.cache.avatar * 60 * 1e3
5436
+ });
5437
+ });
5438
+ }
5439
+ });
5440
+ window.addEventListener("onSessionUpdate", (s) => {
5441
+ const { detail: e } = s;
5442
+ if (window.client instanceof J) {
5443
+ const a = window.client;
5444
+ a.session = e.session, a.emit("session", e.session), a.debug && k.debug("[Client]", "Session updated", e.session);
5445
+ }
5446
+ });
5447
+ function Z(s) {
5448
+ var e = s.event?.provider || s.event?.service || s.event?.data?.provider || window.client.details.provider;
5449
+ return [
5450
+ "kvstore:update",
5451
+ "bot:counter",
5452
+ "alertService:toggleSound",
5453
+ "tip-latest",
5454
+ "event:test",
5455
+ "event:skip"
5456
+ ].some((i) => i === s.listener) && (e = "streamelements"), { provider: e, data: s };
5457
+ }
5458
+ window.addEventListener("onEventReceived", ({ detail: s }) => {
5459
+ if (window.client instanceof J) {
5460
+ const a = Z(s);
5461
+ switch (a.provider) {
5462
+ case "streamelements": {
5463
+ const i = a.data;
5464
+ switch (i.listener) {
5465
+ case "tip-latest": {
5466
+ i.event;
5467
+ break;
5468
+ }
5469
+ case "event:skip": {
5470
+ i.event;
5471
+ break;
5472
+ }
5473
+ case "event:test": {
5474
+ switch (i.event.listener) {
5475
+ case "widget-button": {
5476
+ const t = i.event;
5477
+ V.execute(t.field, t.value);
5478
+ break;
5479
+ }
5480
+ case "subscriber-latest": {
5481
+ i.event;
5482
+ break;
5483
+ }
5484
+ }
5485
+ break;
5486
+ }
5487
+ case "kvstore:update": {
5488
+ const t = i.event;
5489
+ if (_.length) {
5490
+ var e = _.find((n) => n.id === t.data.key.replace("customWidget.", ""));
5491
+ e && e.update(t.data.value);
5492
+ }
5493
+ break;
5494
+ }
5495
+ case "bot:counter": {
5496
+ i.event;
5497
+ break;
5498
+ }
5499
+ case "alertService:toggleSound": {
5500
+ const t = i.event;
5501
+ client.details.overlay.muted = !!t.muted;
5502
+ break;
5503
+ }
5504
+ }
5505
+ window.client.emit("event", "streamelements", a.data);
5506
+ break;
5507
+ }
5508
+ case "twitch": {
5509
+ const i = a.data;
5510
+ switch (i.listener) {
5511
+ case "delete-message": {
5512
+ i.event;
5513
+ break;
5514
+ }
5515
+ case "delete-messages": {
5516
+ i.event;
5517
+ break;
5518
+ }
5519
+ case "message": {
5520
+ i.event, R.execute({ provider: "twitch", data: i });
5521
+ break;
5522
+ }
5523
+ case "follower-latest": {
5524
+ i.event;
5525
+ break;
5526
+ }
5527
+ case "cheer-latest": {
5528
+ i.event;
5529
+ break;
5530
+ }
5531
+ case "subscriber-latest": {
5532
+ (!i.event.gifted && !i.event.bulkGifted && !i.event.isCommunityGift || i.event.gifted && !i.event.bulkGifted && !i.event.isCommunityGift || i.event.gifted && !i.event.bulkGifted && i.event.isCommunityGift || !i.event.gifted && i.event.bulkGifted && !i.event.isCommunityGift) && i.event;
5533
+ break;
5534
+ }
5535
+ case "raid-latest": {
5536
+ i.event;
5537
+ break;
5538
+ }
5539
+ }
5540
+ window.client.emit("event", "twitch", a.data);
5541
+ break;
5542
+ }
5543
+ case "youtube": {
5544
+ const i = a.data;
5545
+ switch (i.listener) {
5546
+ case "message": {
5547
+ i.event, R.execute({ provider: "youtube", data: i });
5548
+ break;
5549
+ }
5550
+ case "subscriber-latest": {
5551
+ i.event;
5552
+ break;
5553
+ }
5554
+ case "sponsor-latest": {
5555
+ i.event, (!i.event.gifted && !i.event.bulkGifted && !i.event.isCommunityGift || i.event.gifted && !i.event.bulkGifted && !i.event.isCommunityGift || i.event.gifted && !i.event.bulkGifted && i.event.isCommunityGift || !i.event.gifted && i.event.bulkGifted && !i.event.isCommunityGift) && i.event;
5556
+ break;
5557
+ }
5558
+ case "superchat-latest": {
5559
+ i.event;
5560
+ break;
5561
+ }
5562
+ }
5563
+ window.client.emit("event", "youtube", a.data);
5564
+ break;
5565
+ }
5566
+ case "kick": {
5567
+ a.data, window.client.emit("event", "kick", a.data);
5568
+ break;
5569
+ }
5570
+ case "facebook": {
5571
+ a.data, window.client.emit("event", "facebook", a.data);
5572
+ break;
5573
+ }
5574
+ }
5575
+ const o = [
5576
+ "bot:counter",
5577
+ "alertService:toggleSound",
5578
+ "event",
5579
+ "event:skip",
5580
+ "event:test",
5581
+ "kvstore:update"
5582
+ ];
5583
+ client.debug && !o.some((i) => i === a.data.listener) && k.received("[Client]", `Event ${a.data.listener} received from ${a.provider}`, a.data.event);
5584
+ }
5585
+ });
5586
+ var x;
5587
+ ((s) => {
5588
+ s.data = {
5589
+ names: nt,
5590
+ messages: it,
5591
+ tiers: ot,
5592
+ avatars: et,
5593
+ emotes: st,
5594
+ youtube_emotes: ht,
5595
+ badges: at,
5596
+ items: ct,
5597
+ tts: rt,
5065
5598
  pronouns: W.Pronouns.map,
5066
- css_color_names: ct
5067
- }, i.color = {
5599
+ css_color_names: dt
5600
+ }, s.color = {
5068
5601
  /**
5069
5602
  * Generate opacity hex value
5070
5603
  * @param opacity - Opacity value from 0 to 100
5071
5604
  * @param color - Hex color code
5072
5605
  * @returns - Hex color code with opacity
5073
5606
  */
5074
- opacity(t = 100, s = "") {
5075
- s = s.length > 7 ? s?.substring(0, 6) : s, t = t > 1 ? t / 100 : t;
5076
- let n = Math.round(Math.min(Math.max(t, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
5077
- return s + n;
5607
+ opacity(t = 100, n = "") {
5608
+ n = n.length > 7 ? n?.substring(0, 6) : n, t = t > 1 ? t / 100 : t;
5609
+ let c = Math.round(Math.min(Math.max(t, 0), 1) * 255).toString(16).toLowerCase().padStart(2, "0");
5610
+ return n + c;
5078
5611
  },
5079
5612
  /**
5080
5613
  * Extract color and opacity from hex code
@@ -5087,16 +5620,16 @@ var C;
5087
5620
  color: t,
5088
5621
  opacity: 100
5089
5622
  };
5090
- var o = t.slice(-2), s = parseInt(o, 16) / 255, n = Math.round(s * 100), o = t.length > 7 ? t.slice(0, 7) : t;
5623
+ var r = t.slice(-2), n = parseInt(r, 16) / 255, c = Math.round(n * 100), r = t.length > 7 ? t.slice(0, 7) : t;
5091
5624
  return {
5092
- color: o,
5093
- opacity: n
5625
+ color: r,
5626
+ opacity: c
5094
5627
  };
5095
5628
  },
5096
5629
  validate(t) {
5097
5630
  if (typeof t != "string" || !String(t).trim().length) return !1;
5098
- const s = t.trim();
5099
- return /^#([A-Fa-f0-9]{3}){1,2}$/.test(s) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(s) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(s) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(s) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(s) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(s) ? "hsla" : i.data.css_color_names.includes(s.toLowerCase()) ? "css-color-name" : !1;
5631
+ const n = t.trim();
5632
+ return /^#([A-Fa-f0-9]{3}){1,2}$/.test(n) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(n) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(n) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(n) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(n) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(n) ? "hsla" : s.data.css_color_names.includes(n.toLowerCase()) ? "css-color-name" : !1;
5100
5633
  },
5101
5634
  /**
5102
5635
  * Convert color to different format
@@ -5111,37 +5644,37 @@ var C;
5111
5644
  * const colorName = Simulation.color.convert("#FF5733", "css-color-name"); // "orangered"
5112
5645
  * ```
5113
5646
  */
5114
- convert(t, s) {
5115
- const n = this.validate(t);
5116
- if (!n)
5647
+ convert(t, n) {
5648
+ const c = this.validate(t);
5649
+ if (!c)
5117
5650
  throw new Error(`Invalid color format: ${t}`);
5118
- if (n === s)
5119
- throw new Error(`Color is already in the desired format: ${s}`);
5120
- const o = dt(t.trim(), n);
5121
- if (!o)
5651
+ if (c === n)
5652
+ throw new Error(`Color is already in the desired format: ${n}`);
5653
+ const r = lt(t.trim(), c);
5654
+ if (!r)
5122
5655
  throw new Error(`Failed to parse color: ${t}`);
5123
- switch (s) {
5656
+ switch (n) {
5124
5657
  case "hex":
5125
- return ht(o, !1);
5658
+ return mt(r, !1);
5126
5659
  case "rgb":
5127
- return `rgb(${o.r}, ${o.g}, ${o.b})`;
5660
+ return `rgb(${r.r}, ${r.g}, ${r.b})`;
5128
5661
  case "rgba":
5129
- return `rgba(${o.r}, ${o.g}, ${o.b}, ${o.a})`;
5662
+ return `rgba(${r.r}, ${r.g}, ${r.b}, ${r.a})`;
5130
5663
  case "hsl": {
5131
- const h = X(o.r, o.g, o.b);
5132
- return `hsl(${h.h}, ${h.s}%, ${h.l}%)`;
5664
+ const d = X(r.r, r.g, r.b);
5665
+ return `hsl(${d.h}, ${d.s}%, ${d.l}%)`;
5133
5666
  }
5134
5667
  case "hsla": {
5135
- const h = X(o.r, o.g, o.b);
5136
- return `hsla(${h.h}, ${h.s}%, ${h.l}%, ${o.a})`;
5668
+ const d = X(r.r, r.g, r.b);
5669
+ return `hsla(${d.h}, ${d.s}%, ${d.l}%, ${r.a})`;
5137
5670
  }
5138
5671
  case "css-color-name":
5139
- return mt(o.r, o.g, o.b);
5672
+ return gt(r.r, r.g, r.b);
5140
5673
  default:
5141
5674
  return null;
5142
5675
  }
5143
5676
  }
5144
- }, i.rand = {
5677
+ }, s.rand = {
5145
5678
  /**
5146
5679
  * Generate random color
5147
5680
  * @param type - Color format
@@ -5161,28 +5694,28 @@ var C;
5161
5694
  case "hex":
5162
5695
  return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
5163
5696
  case "hexa": {
5164
- const n = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, o = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
5165
- return n + o;
5697
+ const c = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, r = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
5698
+ return c + r;
5166
5699
  }
5167
5700
  case "rgb": {
5168
- const n = Math.floor(Math.random() * 256), o = Math.floor(Math.random() * 256), h = Math.floor(Math.random() * 256);
5169
- return `rgb(${n}, ${o}, ${h})`;
5701
+ const c = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256);
5702
+ return `rgb(${c}, ${r}, ${d})`;
5170
5703
  }
5171
5704
  case "rgba": {
5172
- const n = Math.floor(Math.random() * 256), o = Math.floor(Math.random() * 256), h = Math.floor(Math.random() * 256), u = Math.random().toFixed(2);
5173
- return `rgba(${n}, ${o}, ${h}, ${u})`;
5705
+ const c = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.floor(Math.random() * 256), l = Math.random().toFixed(2);
5706
+ return `rgba(${c}, ${r}, ${d}, ${l})`;
5174
5707
  }
5175
5708
  case "hsl": {
5176
- const n = Math.floor(Math.random() * 361), o = Math.floor(Math.random() * 101), h = Math.floor(Math.random() * 101);
5177
- return `hsl(${n}, ${o}%, ${h}%)`;
5709
+ const c = Math.floor(Math.random() * 361), r = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101);
5710
+ return `hsl(${c}, ${r}%, ${d}%)`;
5178
5711
  }
5179
5712
  case "hsla": {
5180
- const n = Math.floor(Math.random() * 361), o = Math.floor(Math.random() * 101), h = Math.floor(Math.random() * 101), u = Math.random().toFixed(2);
5181
- return `hsla(${n}, ${o}%, ${h}%, ${u})`;
5713
+ const c = Math.floor(Math.random() * 361), r = Math.floor(Math.random() * 101), d = Math.floor(Math.random() * 101), l = Math.random().toFixed(2);
5714
+ return `hsla(${c}, ${r}%, ${d}%, ${l})`;
5182
5715
  }
5183
5716
  case "css-color-name": {
5184
- var s = i.data.css_color_names;
5185
- return this.array(s)[0];
5717
+ var n = s.data.css_color_names;
5718
+ return this.array(n)[0];
5186
5719
  }
5187
5720
  }
5188
5721
  },
@@ -5201,10 +5734,10 @@ var C;
5201
5734
  * console.log(floatNumber); // e.g. 3.14
5202
5735
  * ```
5203
5736
  */
5204
- number(t, s, n = 0) {
5205
- t > s && ([t, s] = [s, t]);
5206
- const o = Math.random() * (s - t) + t;
5207
- return n ? Number(o.toFixed(n)) : Math.round(o);
5737
+ number(t, n, c = 0) {
5738
+ t > n && ([t, n] = [n, t]);
5739
+ const r = Math.random() * (n - t) + t;
5740
+ return c ? Number(r.toFixed(c)) : Math.round(r);
5208
5741
  },
5209
5742
  /**
5210
5743
  * Generate random boolean
@@ -5230,11 +5763,11 @@ var C;
5230
5763
  * console.log(randString); // e.g. "aZ3bT9xYqP"
5231
5764
  * ```
5232
5765
  */
5233
- string(t, s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
5234
- let n = "";
5235
- for (let o = 0; o < t; o++)
5236
- n += s.charAt(Math.floor(Math.random() * s.length));
5237
- return n;
5766
+ string(t, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
5767
+ let c = "";
5768
+ for (let r = 0; r < t; r++)
5769
+ c += n.charAt(Math.floor(Math.random() * n.length));
5770
+ return c;
5238
5771
  },
5239
5772
  /**
5240
5773
  * Pick random element from array
@@ -5247,8 +5780,8 @@ var C;
5247
5780
  * ```
5248
5781
  */
5249
5782
  array(t) {
5250
- const s = this.number(0, t.length - 1);
5251
- return [t[s], s];
5783
+ const n = this.number(0, t.length - 1);
5784
+ return [t[n], n];
5252
5785
  },
5253
5786
  /**
5254
5787
  * Generate random date
@@ -5261,8 +5794,8 @@ var C;
5261
5794
  * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
5262
5795
  * ```
5263
5796
  */
5264
- date(t = new Date(2e3, 0, 1), s = /* @__PURE__ */ new Date()) {
5265
- return new Date(this.number(t.getTime(), s.getTime()));
5797
+ date(t = new Date(2e3, 0, 1), n = /* @__PURE__ */ new Date()) {
5798
+ return new Date(this.number(t.getTime(), n.getTime()));
5266
5799
  },
5267
5800
  /**
5268
5801
  * Generate ISO date string offset by days
@@ -5278,8 +5811,8 @@ var C;
5278
5811
  * ```
5279
5812
  */
5280
5813
  daysOffset(t) {
5281
- const n = Date.now() - this.number(0, t * 24 * 60 * 60 * 1e3);
5282
- return new Date(n).toISOString();
5814
+ const c = Date.now() - this.number(0, t * 24 * 60 * 60 * 1e3);
5815
+ return new Date(c).toISOString();
5283
5816
  },
5284
5817
  /**
5285
5818
  * Generate UUID v4
@@ -5296,7 +5829,7 @@ var C;
5296
5829
  (t) => (+t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +t / 4).toString(16)
5297
5830
  );
5298
5831
  }
5299
- }, i.string = {
5832
+ }, s.string = {
5300
5833
  /**
5301
5834
  * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
5302
5835
  * @param string - The input string to perform replacements on.
@@ -5311,14 +5844,14 @@ var C;
5311
5844
  * console.log(result); // Output will depend on the fetched data
5312
5845
  * ```
5313
5846
  */
5314
- async replace(t, s, n) {
5315
- const o = [];
5316
- t.replace(s, (u, ...m) => {
5317
- const g = typeof n == "function" ? n(u, ...m) : u;
5318
- return o.push(Promise.resolve(g)), u;
5847
+ async replace(t, n, c) {
5848
+ const r = [];
5849
+ t.replace(n, (l, ...m) => {
5850
+ const u = typeof c == "function" ? c(l, ...m) : l;
5851
+ return r.push(Promise.resolve(u)), l;
5319
5852
  });
5320
- const h = await Promise.all(o);
5321
- return t.replace(s, () => h.shift() ?? "");
5853
+ const d = await Promise.all(r);
5854
+ return t.replace(n, () => d.shift() ?? "");
5322
5855
  },
5323
5856
  /**
5324
5857
  * Capitalizes the first letter of a given string.
@@ -5347,57 +5880,57 @@ var C;
5347
5880
  * console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
5348
5881
  * ```
5349
5882
  */
5350
- compose(t, s = {}, n = {
5883
+ compose(t, n = {}, c = {
5351
5884
  method: "index",
5352
5885
  html: !1,
5353
5886
  modifiers: {},
5354
5887
  aliases: {}
5355
5888
  }) {
5356
- const { mergeSpanStyles: o } = i.element;
5357
- s.skip = "<br/>", s.newline = "<br/>";
5358
- const h = Object.entries(i.object.flatten(s)).reduce(
5359
- (d, [l, f]) => {
5360
- if (d[l] = String(f), ["username", "name", "nick", "nickname", "sender"].some((k) => l === k)) {
5361
- const k = d?.username || d?.name || d?.nick || d?.nickname || d?.sender;
5362
- d.username = d.username || k, d.usernameAt = `@${d.username}`, d.name = d.name || k, d.nick = d.nick || k, d.nickname = d.nickname || k, d.sender = d.sender || k, d.senderAt = `@${d.sender}`;
5889
+ const { mergeSpanStyles: r } = s.element;
5890
+ n.skip = "<br/>", n.newline = "<br/>";
5891
+ const d = Object.entries(s.object.flatten(n)).reduce(
5892
+ (h, [g, b]) => {
5893
+ if (h[g] = String(b), ["username", "name", "nick", "nickname", "sender"].some((U) => g === U)) {
5894
+ const U = h?.username || h?.name || h?.nick || h?.nickname || h?.sender;
5895
+ h.username = h.username || U, h.usernameAt = `@${h.username}`, h.name = h.name || U, h.nick = h.nick || U, h.nickname = h.nickname || U, h.sender = h.sender || U, h.senderAt = `@${h.sender}`;
5363
5896
  }
5364
- return ["amount", "count"].some((k) => l === k) && (d.amount = String(d?.amount || d.count || f), d.count = String(d?.count || d?.amount || f)), d.currency = d.currency || window.client?.details.currency.symbol || "$", d.currencyCode = d.currencyCode || window.client?.details.currency.code || "USD", d;
5897
+ return ["amount", "count"].some((U) => g === U) && (h.amount = String(h?.amount || h.count || b), h.count = String(h?.count || h?.amount || b)), h.currency = h.currency || window.client?.details.currency.symbol || "$", h.currencyCode = h.currencyCode || window.client?.details.currency.code || "USD", h;
5365
5898
  },
5366
5899
  {}
5367
- ), u = {
5900
+ ), l = {
5368
5901
  PLACEHOLDERS: /{([^}]+)}/g,
5369
5902
  MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
5370
5903
  };
5371
- var m = parseFloat(h?.amount ?? h?.count ?? 0);
5372
- const g = {
5373
- COLOR: (d, l) => o(l && i.color.validate(l) ? `color: ${l}` : "", d),
5374
- WEIGHT: (d, l) => o(l && !isNaN(parseInt(l)) ? `font-weight: ${l}` : "", d),
5375
- BOLD: (d) => o("font-weight: bold", d),
5376
- LIGHT: (d) => o("font-weight: lighter", d),
5377
- STRONG: (d) => o("font-weight: bolder", d),
5378
- ITALIC: (d) => o("font-style: italic", d),
5379
- UNDERLINE: (d) => o("text-decoration: underline", d),
5380
- STRIKETHROUGH: (d) => o("text-decoration: line-through", d),
5381
- SUB: (d) => o("vertical-align: sub", d),
5382
- SUP: (d) => o("vertical-align: super", d),
5383
- LARGER: (d) => o("font-size: larger", d),
5384
- SMALL: (d) => o("font-size: smaller", d),
5385
- SHADOW: (d, l) => o(`text-shadow: ${l}`, d),
5386
- SIZE: (d, l) => o(l ? `font-size: ${l}` : "", d)
5904
+ var m = parseFloat(d?.amount ?? d?.count ?? 0);
5905
+ const u = {
5906
+ COLOR: (h, g) => r(g && s.color.validate(g) ? `color: ${g}` : "", h),
5907
+ WEIGHT: (h, g) => r(g && !isNaN(parseInt(g)) ? `font-weight: ${g}` : "", h),
5908
+ BOLD: (h) => r("font-weight: bold", h),
5909
+ LIGHT: (h) => r("font-weight: lighter", h),
5910
+ STRONG: (h) => r("font-weight: bolder", h),
5911
+ ITALIC: (h) => r("font-style: italic", h),
5912
+ UNDERLINE: (h) => r("text-decoration: underline", h),
5913
+ STRIKETHROUGH: (h) => r("text-decoration: line-through", h),
5914
+ SUB: (h) => r("vertical-align: sub", h),
5915
+ SUP: (h) => r("vertical-align: super", h),
5916
+ LARGER: (h) => r("font-size: larger", h),
5917
+ SMALL: (h) => r("font-size: smaller", h),
5918
+ SHADOW: (h, g) => r(`text-shadow: ${g}`, h),
5919
+ SIZE: (h, g) => r(g ? `font-size: ${g}` : "", h)
5387
5920
  }, y = {
5388
5921
  ...{
5389
- BT1: (d) => m > 1 ? d : "",
5390
- BT0: (d) => m > 0 ? d : "",
5391
- ST1: (d) => m < 1 ? d : "",
5392
- ST0: (d) => m < 0 ? d : "",
5393
- UPC: (d) => d.toUpperCase(),
5394
- LOW: (d) => d.toLowerCase(),
5395
- REV: (d) => d.split("").reverse().join(""),
5396
- CAP: (d) => d.charAt(0).toUpperCase() + d.slice(1).toLowerCase(),
5397
- FALLBACK: (d, l) => d.length ? d : l ?? d
5922
+ BT1: (h) => m > 1 ? h : "",
5923
+ BT0: (h) => m > 0 ? h : "",
5924
+ ST1: (h) => m < 1 ? h : "",
5925
+ ST0: (h) => m < 0 ? h : "",
5926
+ UPC: (h) => h.toUpperCase(),
5927
+ LOW: (h) => h.toLowerCase(),
5928
+ REV: (h) => h.split("").reverse().join(""),
5929
+ CAP: (h) => h.charAt(0).toUpperCase() + h.slice(1).toLowerCase(),
5930
+ FALLBACK: (h, g) => h.length ? h : g ?? h
5398
5931
  },
5399
- ...n?.html ? g : {},
5400
- ...n.modifiers ?? {}
5932
+ ...c?.html ? u : {},
5933
+ ...c.modifiers ?? {}
5401
5934
  }, j = {
5402
5935
  UPC: ["UPPERCASE", "UPPER", "UPP"],
5403
5936
  LOW: ["LOWERCASE", "LOWER", "LWC"],
@@ -5419,61 +5952,61 @@ var C;
5419
5952
  SMALL: ["SMALLER", "SM"],
5420
5953
  SHADOW: ["SHADOW", "SHD"],
5421
5954
  FALLBACK: ["FALLBACK", "FB"],
5422
- ...n.aliases ?? {}
5955
+ ...c.aliases ?? {}
5423
5956
  };
5424
- function x(d, l, f) {
5425
- const k = Object.entries(j).find(([E, I]) => I.some((T) => T.toUpperCase() === l.toUpperCase()) ? !0 : E.toUpperCase() === l.toUpperCase()), D = k ? k[0] : l.toUpperCase();
5426
- return y[D] ? y[D](d, typeof f == "string" ? f.trim() : null, h) : d;
5427
- }
5428
- function U(d) {
5429
- let l = d, f;
5430
- for (; (f = u.MODIFIERS.exec(l)) !== null; ) {
5431
- const [k, D, E, I] = f, T = x(U(I), D, E);
5432
- l = l.replace(k, T ?? ""), u.MODIFIERS.lastIndex = 0;
5433
- }
5434
- return l;
5435
- }
5436
- function p(d) {
5437
- let l = 0;
5438
- const f = d.length;
5439
- function k(E) {
5957
+ function C(h, g, b) {
5958
+ const U = Object.entries(j).find(([E, I]) => I.some((T) => T.toUpperCase() === g.toUpperCase()) ? !0 : E.toUpperCase() === g.toUpperCase()), D = U ? U[0] : g.toUpperCase();
5959
+ return y[D] ? y[D](h, typeof b == "string" ? b.trim() : null, d) : h;
5960
+ }
5961
+ function w(h) {
5962
+ let g = h, b;
5963
+ for (; (b = l.MODIFIERS.exec(g)) !== null; ) {
5964
+ const [U, D, E, I] = b, T = C(w(I), D, E);
5965
+ g = g.replace(U, T ?? ""), l.MODIFIERS.lastIndex = 0;
5966
+ }
5967
+ return g;
5968
+ }
5969
+ function p(h) {
5970
+ let g = 0;
5971
+ const b = h.length;
5972
+ function U(E) {
5440
5973
  let I = "";
5441
- for (; l < f; )
5442
- if (d[l] === "\\")
5443
- l + 1 < f ? (I += d[l + 1], l += 2) : l++;
5444
- else if (d[l] === "[" && (!E || E !== "["))
5974
+ for (; g < b; )
5975
+ if (h[g] === "\\")
5976
+ g + 1 < b ? (I += h[g + 1], g += 2) : g++;
5977
+ else if (h[g] === "[" && (!E || E !== "["))
5445
5978
  I += D();
5446
- else if (E && d[l] === E) {
5447
- l++;
5979
+ else if (E && h[g] === E) {
5980
+ g++;
5448
5981
  break;
5449
5982
  } else
5450
- I += d[l++];
5983
+ I += h[g++];
5451
5984
  return I;
5452
5985
  }
5453
5986
  function D() {
5454
- l++;
5987
+ g++;
5455
5988
  let E = "";
5456
- for (; l < f && /[A-Za-z0-9]/.test(d[l]); ) E += d[l++];
5989
+ for (; g < b && /[A-Za-z0-9]/.test(h[g]); ) E += h[g++];
5457
5990
  let I = null;
5458
- if (d[l] === ":") {
5459
- l++;
5460
- const S = l;
5461
- for (; l < f && d[l] !== "="; ) l++;
5462
- I = d.slice(S, l);
5991
+ if (h[g] === ":") {
5992
+ g++;
5993
+ const q = g;
5994
+ for (; g < b && h[g] !== "="; ) g++;
5995
+ I = h.slice(q, g);
5463
5996
  }
5464
- d[l] === "=" && l++;
5465
- const T = k("]");
5466
- return x(T, E, I);
5997
+ h[g] === "=" && g++;
5998
+ const T = U("]");
5999
+ return C(T, E, I);
5467
6000
  }
5468
- return k();
6001
+ return U();
5469
6002
  }
5470
6003
  let v = t.replace(
5471
- u.PLACEHOLDERS,
5472
- (d, l) => typeof h[l] == "string" || typeof h[l] == "number" ? String(h[l]) : l ?? l
6004
+ l.PLACEHOLDERS,
6005
+ (h, g) => typeof d[g] == "string" || typeof d[g] == "number" ? String(d[g]) : g ?? g
5473
6006
  );
5474
- return v = n.method === "loop" ? U(v) : p(v), v;
6007
+ return v = c.method === "loop" ? w(v) : p(v), v;
5475
6008
  }
5476
- }, i.number = {
6009
+ }, s.number = {
5477
6010
  /**
5478
6011
  * Translate number to words
5479
6012
  * @param num - Number to translate
@@ -5485,64 +6018,64 @@ var C;
5485
6018
  * console.log(cardinal); // "forty-two"
5486
6019
  * ```
5487
6020
  */
5488
- translate(t, s = "cardinal") {
5489
- const n = {
6021
+ translate(t, n = "cardinal") {
6022
+ const c = {
5490
6023
  single: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
5491
6024
  tens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
5492
6025
  decades: ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
5493
- }, o = {
6026
+ }, r = {
5494
6027
  single: ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"],
5495
6028
  tens: ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"],
5496
6029
  decades: ["twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]
5497
- }, h = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], u = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], m = u.map((p) => p ? `${p}th` : "");
5498
- if (t = Math.abs(Math.floor(t)), s === "suffix") {
6030
+ }, d = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"], l = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"], m = l.map((p) => p ? `${p}th` : "");
6031
+ if (t = Math.abs(Math.floor(t)), n === "suffix") {
5499
6032
  const p = t % 100;
5500
6033
  if (p >= 11 && p <= 13) return `${t}th`;
5501
6034
  const v = t % 10;
5502
- return `${t}${h[v]}`;
5503
- }
5504
- function g(p, v) {
5505
- if (p < 10) return v === "ordinal" ? o.single[p] : n.single[p];
5506
- if (p < 20) return v === "ordinal" ? o.tens[p - 10] : n.tens[p - 10];
5507
- const d = Math.floor(p / 10), l = p % 10;
5508
- if (l === 0) return v === "ordinal" ? o.decades[d - 2] : n.decades[d - 2];
5509
- const f = n.decades[d - 2], k = v === "ordinal" ? o.single[l] : n.single[l];
5510
- return `${f}-${k}`;
5511
- }
5512
- function b(p, v) {
5513
- if (p === 0) return v === "ordinal" ? o.single[0] : n.single[0];
5514
- const d = Math.floor(p / 100), l = p % 100, f = [];
5515
- return d > 0 && (v === "ordinal" && l === 0 ? f.push(`${n.single[d]} hundredth`) : f.push(`${n.single[d]} hundred`)), l > 0 && f.push(g(l, v)), f.join(" ");
5516
- }
5517
- if (t < 1e3) return b(t, s);
6035
+ return `${t}${d[v]}`;
6036
+ }
6037
+ function u(p, v) {
6038
+ if (p < 10) return v === "ordinal" ? r.single[p] : c.single[p];
6039
+ if (p < 20) return v === "ordinal" ? r.tens[p - 10] : c.tens[p - 10];
6040
+ const h = Math.floor(p / 10), g = p % 10;
6041
+ if (g === 0) return v === "ordinal" ? r.decades[h - 2] : c.decades[h - 2];
6042
+ const b = c.decades[h - 2], U = v === "ordinal" ? r.single[g] : c.single[g];
6043
+ return `${b}-${U}`;
6044
+ }
6045
+ function f(p, v) {
6046
+ if (p === 0) return v === "ordinal" ? r.single[0] : c.single[0];
6047
+ const h = Math.floor(p / 100), g = p % 100, b = [];
6048
+ return h > 0 && (v === "ordinal" && g === 0 ? b.push(`${c.single[h]} hundredth`) : b.push(`${c.single[h]} hundred`)), g > 0 && b.push(u(g, v)), b.join(" ");
6049
+ }
6050
+ if (t < 1e3) return f(t, n);
5518
6051
  const y = [];
5519
6052
  let j = t;
5520
6053
  for (; j > 0; )
5521
6054
  y.push(j % 1e3), j = Math.floor(j / 1e3);
5522
- let x = -1;
5523
- for (let p = 0; p < y.length; p++) y[p] !== 0 && (x = p);
5524
- const U = [];
6055
+ let C = -1;
6056
+ for (let p = 0; p < y.length; p++) y[p] !== 0 && (C = p);
6057
+ const w = [];
5525
6058
  for (let p = y.length - 1; p >= 0; p--) {
5526
6059
  const v = y[p];
5527
6060
  if (v === 0) continue;
5528
- const d = u[p];
5529
- if (s === "cardinal") {
5530
- let l = b(v, "cardinal");
5531
- d && (l += ` ${d}`), U.push(l);
5532
- } else if (p === x)
6061
+ const h = l[p];
6062
+ if (n === "cardinal") {
6063
+ let g = f(v, "cardinal");
6064
+ h && (g += ` ${h}`), w.push(g);
6065
+ } else if (p === C)
5533
6066
  if (p > 0) {
5534
- const f = b(v, "cardinal"), k = m[p];
5535
- U.push(f ? `${f} ${k}` : k);
6067
+ const b = f(v, "cardinal"), U = m[p];
6068
+ w.push(b ? `${b} ${U}` : U);
5536
6069
  } else {
5537
- const f = b(v, "ordinal");
5538
- U.push(f);
6070
+ const b = f(v, "ordinal");
6071
+ w.push(b);
5539
6072
  }
5540
6073
  else {
5541
- let f = b(v, "cardinal");
5542
- d && (f += ` ${d}`), U.push(f);
6074
+ let b = f(v, "cardinal");
6075
+ h && (b += ` ${h}`), w.push(b);
5543
6076
  }
5544
6077
  }
5545
- return U.join(", ");
6078
+ return w.join(", ");
5546
6079
  },
5547
6080
  /**
5548
6081
  * Balances a number within a specified range
@@ -5556,10 +6089,10 @@ var C;
5556
6089
  * console.log(balancedValue); // 100
5557
6090
  * ```
5558
6091
  */
5559
- balance(t, s = 0, n = 100) {
5560
- return Math.min(Math.max(t, s), n);
6092
+ balance(t, n = 0, c = 100) {
6093
+ return Math.min(Math.max(t, n), c);
5561
6094
  }
5562
- }, i.element = {
6095
+ }, s.element = {
5563
6096
  /**
5564
6097
  * Merges outer span styles with inner span styles in the provided HTML string.
5565
6098
  * @param outerStyle - The style string to be applied to the outer span.
@@ -5571,13 +6104,13 @@ var C;
5571
6104
  * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
5572
6105
  * ```
5573
6106
  */
5574
- mergeSpanStyles(t, s) {
5575
- const n = s.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
5576
- if (n) {
5577
- const o = n[1], h = n[2];
5578
- return `<span style="${[o, t].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${h}</span>`;
6107
+ mergeSpanStyles(t, n) {
6108
+ const c = n.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
6109
+ if (c) {
6110
+ const r = c[1], d = c[2];
6111
+ return `<span style="${[r, t].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${d}</span>`;
5579
6112
  } else
5580
- return `<span style="${t}">${s}</span>`;
6113
+ return `<span style="${t}">${n}</span>`;
5581
6114
  },
5582
6115
  /**
5583
6116
  * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
@@ -5592,29 +6125,29 @@ var C;
5592
6125
  * Simulation.element.scale(element, 0.5, 1, { return: false });
5593
6126
  * ```
5594
6127
  */
5595
- scale(t, s = 0, n = 1, o) {
5596
- const { return: h = !1, parent: u, base: m } = o || {}, g = u || t.parentElement || document.body;
5597
- if (!g) {
5598
- w.warn("No parent element found for scaling");
6128
+ scale(t, n = 0, c = 1, r) {
6129
+ const { return: d = !1, parent: l, base: m } = r || {}, u = l || t.parentElement || document.body;
6130
+ if (!u) {
6131
+ k.warn("No parent element found for scaling");
5599
6132
  return;
5600
6133
  }
5601
- const b = g.getBoundingClientRect(), y = t.offsetWidth, j = t.offsetHeight;
6134
+ const f = u.getBoundingClientRect(), y = t.offsetWidth, j = t.offsetHeight;
5602
6135
  if (y === 0 || j === 0) {
5603
- w.warn("Element has zero width or height, cannot scale");
6136
+ k.warn("Element has zero width or height, cannot scale");
5604
6137
  return;
5605
6138
  }
5606
- const x = b.width * n / y, U = b.height * n / j;
5607
- let p = m === "width" ? x : m === "height" ? U : Math.min(x, U);
5608
- if (s > 0) {
5609
- const d = b.width * s / y, l = b.height * s / j, f = Math.max(d, l);
5610
- p = Math.max(f, p);
6139
+ const C = f.width * c / y, w = f.height * c / j;
6140
+ let p = m === "width" ? C : m === "height" ? w : Math.min(C, w);
6141
+ if (n > 0) {
6142
+ const h = f.width * n / y, g = f.height * n / j, b = Math.max(h, g);
6143
+ p = Math.max(b, p);
5611
6144
  }
5612
6145
  const v = {
5613
6146
  width: y * p,
5614
6147
  height: j * p,
5615
6148
  scale: p
5616
6149
  };
5617
- return h || (t.style.transform = `scale(${p})`, t.style.transformOrigin = "center center"), v;
6150
+ return d || (t.style.transform = `scale(${p})`, t.style.transformOrigin = "center center"), v;
5618
6151
  },
5619
6152
  /**
5620
6153
  * Splits the text content of an HTML string into individual characters wrapped in span elements with a data-index attribute.
@@ -5628,34 +6161,34 @@ var C;
5628
6161
  * // Output: '<p><span class="char" data-index="0">H</span><span class="char" data-index="1">e</span><span class="char" data-index="2">l</span><span class="char" data-index="3">l</span><span class="char" data-index="4">o</span></p>'
5629
6162
  * ```
5630
6163
  */
5631
- splitTextToChars(t, s = 0) {
5632
- const o = new DOMParser().parseFromString(t, "text/html");
5633
- let h = s;
5634
- function u(b) {
5635
- if (b.nodeType === Node.TEXT_NODE) {
5636
- const j = b.textContent?.split("").map((U) => {
6164
+ splitTextToChars(t, n = 0) {
6165
+ const r = new DOMParser().parseFromString(t, "text/html");
6166
+ let d = n;
6167
+ function l(f) {
6168
+ if (f.nodeType === Node.TEXT_NODE) {
6169
+ const j = f.textContent?.split("").map((w) => {
5637
6170
  const p = document.createElement("span");
5638
- return p.className = "char", p.dataset.index = String(h++), p.textContent = U, h++, p.outerHTML;
5639
- }), x = document.createElement("span");
5640
- return x.innerHTML = j?.join("") ?? "", x;
5641
- } else if (b.nodeType === Node.ELEMENT_NODE) {
5642
- const y = b.cloneNode(!1);
5643
- return b.childNodes.forEach((j) => {
5644
- const x = u(j);
5645
- x instanceof Node && Array.from(x.childNodes).forEach((U) => {
5646
- y.appendChild(U);
6171
+ return p.className = "char", p.dataset.index = String(d++), p.textContent = w, d++, p.outerHTML;
6172
+ }), C = document.createElement("span");
6173
+ return C.innerHTML = j?.join("") ?? "", C;
6174
+ } else if (f.nodeType === Node.ELEMENT_NODE) {
6175
+ const y = f.cloneNode(!1);
6176
+ return f.childNodes.forEach((j) => {
6177
+ const C = l(j);
6178
+ C instanceof Node && Array.from(C.childNodes).forEach((w) => {
6179
+ y.appendChild(w);
5647
6180
  });
5648
6181
  }), y;
5649
6182
  }
5650
- return b.cloneNode(!0);
6183
+ return f.cloneNode(!0);
5651
6184
  }
5652
- const m = o.body, g = document.createElement("div");
5653
- return m.childNodes.forEach((b) => {
5654
- const y = u(b);
5655
- y instanceof Node && g.appendChild(y);
5656
- }), g.innerHTML;
6185
+ const m = r.body, u = document.createElement("div");
6186
+ return m.childNodes.forEach((f) => {
6187
+ const y = l(f);
6188
+ y instanceof Node && u.appendChild(y);
6189
+ }), u.innerHTML;
5657
6190
  }
5658
- }, i.object = {
6191
+ }, s.object = {
5659
6192
  /**
5660
6193
  * Flattens a nested object into a single-level object with dot-separated keys.
5661
6194
  * @param obj - The nested object to be flattened.
@@ -5669,48 +6202,48 @@ var C;
5669
6202
  * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
5670
6203
  * ```
5671
6204
  */
5672
- flatten(t, s = "") {
5673
- const n = {};
5674
- for (const o in t) {
5675
- if (!Object.prototype.hasOwnProperty.call(t, o)) continue;
5676
- const h = t[o], u = s ? `${s}.${o}` : o;
5677
- if (h == null) {
5678
- n[u] = String(h);
6205
+ flatten(t, n = "") {
6206
+ const c = {};
6207
+ for (const r in t) {
6208
+ if (!Object.prototype.hasOwnProperty.call(t, r)) continue;
6209
+ const d = t[r], l = n ? `${n}.${r}` : r;
6210
+ if (d == null) {
6211
+ c[l] = String(d);
5679
6212
  continue;
5680
6213
  }
5681
- if (h instanceof Date) {
5682
- n[u] = h.toISOString();
6214
+ if (d instanceof Date) {
6215
+ c[l] = d.toISOString();
5683
6216
  continue;
5684
6217
  }
5685
- if (h instanceof Map) {
5686
- h.forEach((m, g) => {
5687
- n[`${u}.${g}`] = JSON.stringify(m);
6218
+ if (d instanceof Map) {
6219
+ d.forEach((m, u) => {
6220
+ c[`${l}.${u}`] = JSON.stringify(m);
5688
6221
  });
5689
6222
  continue;
5690
6223
  }
5691
- if (Array.isArray(h)) {
5692
- h.forEach((m, g) => {
5693
- const b = `${u}:${g}`;
5694
- typeof m == "object" ? Object.assign(n, this.flatten(m, b)) : n[b] = String(m);
6224
+ if (Array.isArray(d)) {
6225
+ d.forEach((m, u) => {
6226
+ const f = `${l}:${u}`;
6227
+ typeof m == "object" ? Object.assign(c, this.flatten(m, f)) : c[f] = String(m);
5695
6228
  });
5696
6229
  continue;
5697
6230
  }
5698
- if (typeof h == "object") {
5699
- Object.assign(n, this.flatten(h, u));
6231
+ if (typeof d == "object") {
6232
+ Object.assign(c, this.flatten(d, l));
5700
6233
  continue;
5701
6234
  }
5702
- n[u] = String(h);
6235
+ c[l] = String(d);
5703
6236
  }
5704
- return n;
6237
+ return c;
5705
6238
  }
5706
- }, i.generate = {
6239
+ }, s.generate = {
5707
6240
  session: {
5708
6241
  types: {
5709
- name: { type: "string", options: i.data.names.filter((t) => t.length) },
5710
- tier: { type: "string", options: i.data.tiers.filter((t) => t.length) },
5711
- message: { type: "string", options: i.data.messages.filter((t) => t.length) },
5712
- item: { type: "array", options: i.data.items },
5713
- avatar: { type: "string", options: i.data.avatars.filter((t) => t.length) }
6242
+ name: { type: "string", options: s.data.names.filter((t) => t.length) },
6243
+ tier: { type: "string", options: s.data.tiers.filter((t) => t.length) },
6244
+ message: { type: "string", options: s.data.messages.filter((t) => t.length) },
6245
+ item: { type: "array", options: s.data.items },
6246
+ avatar: { type: "string", options: s.data.avatars.filter((t) => t.length) }
5714
6247
  },
5715
6248
  available() {
5716
6249
  const t = this.types;
@@ -5956,49 +6489,49 @@ var C;
5956
6489
  };
5957
6490
  },
5958
6491
  async get() {
5959
- const t = this.available(), s = (o) => {
5960
- const h = (g) => {
5961
- if (!g || !("amount" in g)) return [];
5962
- const b = [];
5963
- for (let y = 0; y < g.amount; y++)
5964
- b.push(s(g.value));
5965
- return b.sort((y, j) => new Date(j.createdAt).getTime() - new Date(y.createdAt).getTime());
5966
- }, u = (g) => {
5967
- const b = {};
5968
- for (const y in g) {
6492
+ const t = this.available(), n = (r) => {
6493
+ const d = (u) => {
6494
+ if (!u || !("amount" in u)) return [];
6495
+ const f = [];
6496
+ for (let y = 0; y < u.amount; y++)
6497
+ f.push(n(u.value));
6498
+ return f.sort((y, j) => new Date(j.createdAt).getTime() - new Date(y.createdAt).getTime());
6499
+ }, l = (u) => {
6500
+ const f = {};
6501
+ for (const y in u) {
5969
6502
  const j = y.replace("_type", "type");
5970
- b[j] = s(g[y]);
6503
+ f[j] = n(u[y]);
5971
6504
  }
5972
- return b;
5973
- }, m = (g) => {
5974
- if (!g) return g;
5975
- switch (g.type) {
6505
+ return f;
6506
+ }, m = (u) => {
6507
+ if (!u) return u;
6508
+ switch (u.type) {
5976
6509
  case "int":
5977
- return i.rand.number(g.min, g.max);
6510
+ return s.rand.number(u.min, u.max);
5978
6511
  case "string":
5979
- return i.rand.array(g.options)[0];
6512
+ return s.rand.array(u.options)[0];
5980
6513
  case "date":
5981
- return i.rand.daysOffset(g.range);
6514
+ return s.rand.daysOffset(u.range);
5982
6515
  case "array":
5983
- return i.rand.array(g.options)[0];
6516
+ return s.rand.array(u.options)[0];
5984
6517
  case "recent":
5985
- return h(g);
6518
+ return d(u);
5986
6519
  default:
5987
- return g;
6520
+ return u;
5988
6521
  }
5989
6522
  };
5990
- return typeof o != "object" || o === null ? o : "type" in o && typeof o.type == "string" ? m(o) : u(o);
6523
+ return typeof r != "object" || r === null ? r : "type" in r && typeof r.type == "string" ? m(r) : l(r);
5991
6524
  };
5992
- var n = Object.entries(s(t)).reduce(
5993
- (o, [h, u]) => (Object.entries(u).forEach(
5994
- ([m, g]) => (
6525
+ var c = Object.entries(n(t)).reduce(
6526
+ (r, [d, l]) => (Object.entries(l).forEach(
6527
+ ([m, u]) => (
5995
6528
  //
5996
- o[`${h}-${m}`] = g
6529
+ r[`${d}-${m}`] = u
5997
6530
  )
5998
- ), o),
6531
+ ), r),
5999
6532
  {}
6000
6533
  );
6001
- return n;
6534
+ return c;
6002
6535
  }
6003
6536
  },
6004
6537
  event: {
@@ -6009,8 +6542,8 @@ var C;
6009
6542
  * @param currency - The currency to be used (default is 'USD').
6010
6543
  * @returns A Promise that resolves to the simulated onWidgetLoad event data.
6011
6544
  */
6012
- async onWidgetLoad(t, s, n = "USD") {
6013
- const o = {
6545
+ async onWidgetLoad(t, n, c = "USD") {
6546
+ const r = {
6014
6547
  BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
6015
6548
  USD: { code: "USD", name: "US Dollar", symbol: "$" },
6016
6549
  EUR: { code: "EUR", name: "Euro", symbol: "€" }
@@ -6023,11 +6556,11 @@ var C;
6023
6556
  providerId: "",
6024
6557
  avatar: ""
6025
6558
  },
6026
- currency: o[n] ?? o.USD,
6559
+ currency: r[c] ?? r.USD,
6027
6560
  fieldData: t,
6028
6561
  recents: [],
6029
6562
  session: {
6030
- data: s,
6563
+ data: n,
6031
6564
  settings: {
6032
6565
  autoReset: !1,
6033
6566
  calendar: !1,
@@ -6046,8 +6579,104 @@ var C;
6046
6579
  * @param session - The session data to be included in the event.
6047
6580
  * @returns A Promise that resolves to the simulated onSessionUpdate event data.
6048
6581
  */
6049
- async onSessionUpdate(t) {
6050
- return t ??= await i.generate.session.get(), { session: t };
6582
+ async onSessionUpdate(t, n) {
6583
+ if (t ??= await s.generate.session.get(), n) {
6584
+ const c = (r, d) => new Date(d.createdAt).getTime() - new Date(r.createdAt).getTime();
6585
+ switch (n.provider) {
6586
+ case "twitch": {
6587
+ const r = n.data;
6588
+ switch (r.listener) {
6589
+ case "cheer-latest": {
6590
+ const d = r.event.amount, l = r.event.displayName ?? r.event.name, m = r.event.message;
6591
+ t["cheer-latest"] = { name: l, amount: d, message: m };
6592
+ const u = (f) => {
6593
+ if (f === "all") {
6594
+ u("alltime"), u("monthly"), u("weekly"), u("session");
6595
+ return;
6596
+ }
6597
+ const y = t[`cheer-${f}-top-donation`];
6598
+ y && d > y.amount && (y.amount = d, y.name = l);
6599
+ const j = t[`cheer-${f}-top-donator`], C = t["cheer-recent"].filter((p) => p.name.toLowerCase() === j.name.toLowerCase()).reduce((p, v) => p + v.amount, 0), w = t["cheer-recent"].filter((p) => p.name.toLowerCase() === l.toLowerCase()).reduce((p, v) => p + v.amount, 0);
6600
+ w > C && (j.amount = w, j.name = l);
6601
+ };
6602
+ u("all"), t["cheer-session"].amount += d, t["cheer-week"].amount += d, t["cheer-month"].amount += d, t["cheer-total"].amount += d, t["cheer-count"].count += 1, t["cheer-goal"].amount += d, t["cheer-recent"].unshift({ name: l, amount: d, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["cheer-recent"] = (t["cheer-recent"] || []).sort(c);
6603
+ break;
6604
+ }
6605
+ case "follower-latest": {
6606
+ const d = r.event.displayName ?? r.event.name;
6607
+ t["follower-latest"].name = d, t["follower-session"].count += 1, t["follower-week"].count += 1, t["follower-month"].count += 1, t["follower-total"].count += 1, t["follower-goal"].amount += 1, t["follower-recent"].unshift({ name: d, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["follower-recent"] = (t["follower-recent"] || []).sort(c);
6608
+ break;
6609
+ }
6610
+ case "subscriber-latest": {
6611
+ const d = r.event.displayName ?? r.event.name, l = r.event.amount, m = r.event.tier, u = r.event.message;
6612
+ if (t["subscriber-latest"] = { name: d, amount: l, tier: m, message: u ?? "" }, t["subscriber-recent"].find((f) => f.name.toLowerCase() === d.toLowerCase()) ? l > 1 && (t["subscriber-resub-latest"] = { name: d, amount: l, message: u ?? "" }, t["subscriber-resub-session"].count += 1) : (t["subscriber-new-latest"] = { name: d, amount: l, message: u ?? "" }, t["subscriber-new-session"].count += 1), !(!r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift)) if (r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift) {
6613
+ const f = r.event.sender;
6614
+ t["subscriber-gifted-latest"] = {
6615
+ name: d,
6616
+ amount: l,
6617
+ tier: m,
6618
+ message: u ?? "",
6619
+ sender: f
6620
+ }, t["subscriber-gifted-session"].count += 1, t["subscriber-alltime-gifter"] = { name: f, amount: l };
6621
+ } else r.event.gifted && !r.event.bulkGifted && r.event.isCommunityGift || !r.event.gifted && r.event.bulkGifted && r.event.isCommunityGift;
6622
+ t["subscriber-session"].count += l, t["subscriber-week"].count += l, t["subscriber-month"].count += l, t["subscriber-total"].count += l, t["subscriber-goal"].amount += l, t["subscriber-points"].amount += l, t["subscriber-recent"].unshift({ name: d, amount: l, tier: m, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["subscriber-recent"] = (t["subscriber-recent"] || []).sort(c);
6623
+ break;
6624
+ }
6625
+ case "raid-latest": {
6626
+ const d = r.event.displayName ?? r.event.name, l = r.event.amount;
6627
+ t["raid-latest"] = { name: d, amount: l }, t["raid-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["raid-recent"] = (t["raid-recent"] || []).sort(c);
6628
+ break;
6629
+ }
6630
+ }
6631
+ break;
6632
+ }
6633
+ case "youtube": {
6634
+ const r = n.data;
6635
+ switch (r.listener) {
6636
+ case "superchat-latest": {
6637
+ const d = r.event.displayName ?? r.event.name, l = r.event.amount;
6638
+ t["superchat-latest"] = { name: d, amount: l };
6639
+ const m = (u) => {
6640
+ if (u === "all") {
6641
+ m("alltime"), m("monthly"), m("weekly"), m("session");
6642
+ return;
6643
+ }
6644
+ const f = t[`superchat-${u}-top-donation`];
6645
+ f && l > f.amount && (f.amount = l, f.name = d);
6646
+ const y = t[`superchat-${u}-top-donator`], j = t["superchat-recent"].filter((w) => w.name.toLowerCase() === y.name.toLowerCase()).reduce((w, p) => w + p.amount, 0), C = t["superchat-recent"].filter((w) => w.name.toLowerCase() === d.toLowerCase()).reduce((w, p) => w + p.amount, 0);
6647
+ C > j && (y.amount = C, y.name = d);
6648
+ };
6649
+ m("all"), t["superchat-session"].amount += l, t["superchat-week"].amount += l, t["superchat-month"].amount += l, t["superchat-total"].amount += l, t["superchat-count"].count += 1, t["superchat-goal"].amount += l, t["superchat-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["superchat-recent"] = (t["superchat-recent"] || []).sort(c);
6650
+ break;
6651
+ }
6652
+ }
6653
+ break;
6654
+ }
6655
+ case "streamelements": {
6656
+ const r = n.data;
6657
+ switch (r.listener) {
6658
+ case "tip-latest": {
6659
+ const d = r.event.displayName ?? r.event.name, l = r.event.amount;
6660
+ t["tip-latest"] = { name: d, amount: l };
6661
+ const m = (u) => {
6662
+ if (u === "all") {
6663
+ m("alltime"), m("monthly"), m("weekly"), m("session");
6664
+ return;
6665
+ }
6666
+ const f = t[`tip-${u}-top-donation`];
6667
+ f && l > f.amount && (f.amount = l, f.name = d);
6668
+ const y = t[`tip-${u}-top-donator`], j = t["tip-recent"].filter((w) => w.name.toLowerCase() === y.name.toLowerCase()).reduce((w, p) => w + p.amount, 0), C = t["tip-recent"].filter((w) => w.name.toLowerCase() === d.toLowerCase()).reduce((w, p) => w + p.amount, 0);
6669
+ C > j && (y.amount = C, y.name = d);
6670
+ };
6671
+ m("all"), t["tip-session"].amount += l, t["tip-week"].amount += l, t["tip-month"].amount += l, t["tip-total"].amount += l, t["tip-count"].count += 1, t["tip-goal"].amount += l, t["tip-recent"].unshift({ name: d, amount: l, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), t["tip-recent"] = (t["tip-recent"] || []).sort(c);
6672
+ break;
6673
+ }
6674
+ }
6675
+ break;
6676
+ }
6677
+ }
6678
+ }
6679
+ return { session: t };
6051
6680
  },
6052
6681
  /**
6053
6682
  * Simulates the onEventReceived event for a widget.
@@ -6064,8 +6693,8 @@ var C;
6064
6693
  * const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
6065
6694
  * ```
6066
6695
  */
6067
- async onEventReceived(t = "random", s = "random", n = {}) {
6068
- const o = {
6696
+ async onEventReceived(t = "random", n = "random", c = {}) {
6697
+ const r = {
6069
6698
  twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
6070
6699
  streamelements: ["tip-latest"],
6071
6700
  youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
@@ -6075,18 +6704,18 @@ var C;
6075
6704
  switch (t) {
6076
6705
  default:
6077
6706
  case "random": {
6078
- var h = i.rand.array(Object.keys(o).filter((H) => o[H].length))[0], u = i.rand.array(o[h])[0];
6079
- return this.onEventReceived(h, u);
6707
+ var d = s.rand.array(Object.keys(r).filter((H) => r[H].length))[0], l = s.rand.array(r[d])[0];
6708
+ return this.onEventReceived(d, l);
6080
6709
  }
6081
6710
  case "twitch":
6082
- switch (s) {
6711
+ switch (n) {
6083
6712
  default:
6084
6713
  case "random": {
6085
- var u = i.rand.array(o[t])[0];
6086
- return this.onEventReceived(t, u);
6714
+ var l = s.rand.array(r[t])[0];
6715
+ return this.onEventReceived(t, l);
6087
6716
  }
6088
6717
  case "message": {
6089
- var m = n?.name ?? i.rand.array(i.data.names.filter((L) => L.length))[0], g = n?.message ?? i.rand.array(i.data.messages.filter((L) => L.length))[0], b = await K(n?.badges ?? [], t), y = F(g), j = B(g, y), x = n?.color ?? i.rand.color("hex"), U = n?.userId ?? i.rand.number(1e7, 99999999).toString(), p = n?.msgId ?? i.rand.uuid(), v = n?.time ?? Date.now(), d = n?.channel ?? client.details.user.username;
6718
+ var m = c?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], u = c?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0], f = await K(c?.badges ?? [], t), y = F(u), j = B(u, y), C = c?.color ?? s.rand.color("hex"), w = c?.userId ?? s.rand.number(1e7, 99999999).toString(), p = c?.msgId ?? s.rand.uuid(), v = c?.time ?? Date.now(), h = c?.channel ?? client.details.user.username;
6090
6719
  return {
6091
6720
  listener: "message",
6092
6721
  event: {
@@ -6094,18 +6723,18 @@ var C;
6094
6723
  data: {
6095
6724
  time: v,
6096
6725
  tags: {
6097
- "badge-info": `${b.keys.map((L) => `${L}/${i.rand.number(1, 5)}`).join(",")}`,
6098
- badges: b.keys.join("/1,"),
6099
- mod: b.keys.includes("moderator") ? "1" : "0",
6100
- subscriber: b.keys.includes("subscriber") ? "1" : "0",
6101
- turbo: b.keys.includes("turbo") ? "1" : "0",
6726
+ "badge-info": `${f.keys.map((L) => `${L}/${s.rand.number(1, 5)}`).join(",")}`,
6727
+ badges: f.keys.join("/1,"),
6728
+ mod: f.keys.includes("moderator") ? "1" : "0",
6729
+ subscriber: f.keys.includes("subscriber") ? "1" : "0",
6730
+ turbo: f.keys.includes("turbo") ? "1" : "0",
6102
6731
  "tmi-sent-ts": v.toString(),
6103
- "user-id": U,
6732
+ "user-id": w,
6104
6733
  "user-type": "",
6105
- color: x,
6734
+ color: C,
6106
6735
  "display-name": m,
6107
6736
  emotes: "",
6108
- "client-nonce": i.rand.string(16),
6737
+ "client-nonce": s.rand.string(16),
6109
6738
  flags: "",
6110
6739
  id: p,
6111
6740
  "first-msg": "0",
@@ -6113,13 +6742,13 @@ var C;
6113
6742
  },
6114
6743
  nick: m.toLowerCase(),
6115
6744
  displayName: m,
6116
- displayColor: x,
6117
- channel: d,
6118
- text: g,
6745
+ displayColor: C,
6746
+ channel: h,
6747
+ text: u,
6119
6748
  isAction: !1,
6120
- userId: U,
6749
+ userId: w,
6121
6750
  msgId: p,
6122
- badges: b.badges,
6751
+ badges: f.badges,
6123
6752
  emotes: y
6124
6753
  },
6125
6754
  renderedText: j
@@ -6128,17 +6757,17 @@ var C;
6128
6757
  }
6129
6758
  case "cheer":
6130
6759
  case "cheer-latest": {
6131
- var l = n?.amount ?? i.rand.number(100, 1e4), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((A) => A.length))[0], g = n?.message ?? i.rand.array(i.data.messages.filter((A) => A.length))[0];
6760
+ var g = c?.amount ?? s.rand.number(100, 1e4), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], u = c?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0];
6132
6761
  return {
6133
6762
  listener: "cheer-latest",
6134
6763
  event: {
6135
- amount: l,
6136
- avatar: f,
6764
+ amount: g,
6765
+ avatar: b,
6137
6766
  name: m.toLowerCase(),
6138
6767
  displayName: m,
6139
- message: g,
6768
+ message: u,
6140
6769
  providerId: "",
6141
- _id: i.rand.uuid(),
6770
+ _id: s.rand.uuid(),
6142
6771
  sessionTop: !1,
6143
6772
  type: "cheer",
6144
6773
  originalEventName: "cheer-latest",
@@ -6148,15 +6777,15 @@ var C;
6148
6777
  }
6149
6778
  case "follower":
6150
6779
  case "follower-latest": {
6151
- var f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((A) => A.length))[0];
6780
+ var b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
6152
6781
  return {
6153
6782
  listener: "follower-latest",
6154
6783
  event: {
6155
- avatar: f,
6784
+ avatar: b,
6156
6785
  name: m.toLowerCase(),
6157
6786
  displayName: m,
6158
6787
  providerId: "",
6159
- _id: i.rand.uuid(),
6788
+ _id: s.rand.uuid(),
6160
6789
  sessionTop: !1,
6161
6790
  type: "follower",
6162
6791
  originalEventName: "follower-latest",
@@ -6166,16 +6795,16 @@ var C;
6166
6795
  }
6167
6796
  case "raid":
6168
6797
  case "raid-latest": {
6169
- var l = n?.amount ?? i.rand.number(1, 100), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((z) => z.length))[0];
6798
+ var g = c?.amount ?? s.rand.number(1, 100), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
6170
6799
  return {
6171
6800
  listener: "raid-latest",
6172
6801
  event: {
6173
- amount: l,
6174
- avatar: f,
6802
+ amount: g,
6803
+ avatar: b,
6175
6804
  name: m.toLowerCase(),
6176
6805
  displayName: m,
6177
6806
  providerId: "",
6178
- _id: i.rand.uuid(),
6807
+ _id: s.rand.uuid(),
6179
6808
  sessionTop: !1,
6180
6809
  type: "raid",
6181
6810
  originalEventName: "raid-latest",
@@ -6185,10 +6814,9 @@ var C;
6185
6814
  }
6186
6815
  case "subscriber":
6187
6816
  case "subscriber-latest": {
6188
- var k = n?.tier ?? i.rand.array(["1000", "2000", "3000"])[0], l = n?.amount ?? i.rand.number(1, 24), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((P) => P.length))[0], D = n?.sender ?? i.rand.array(i.data.names.filter((P) => P.length && P !== m))[0], g = n?.message ?? i.rand.array(i.data.messages.filter((P) => P.length))[0], E = {
6817
+ var U = c?.tier ?? s.rand.array(["1000", "2000", "3000", "prime"])[0], g = c?.amount ?? s.rand.number(1, 24), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((P) => P.length))[0], D = c?.sender ?? s.rand.array(s.data.names.filter((P) => P.length && P !== m))[0], u = c?.message ?? s.rand.array(s.data.messages.filter((P) => P.length))[0], E = {
6189
6818
  default: {
6190
- avatar: f,
6191
- tier: k,
6819
+ avatar: b,
6192
6820
  playedAsCommunityGift: !1
6193
6821
  },
6194
6822
  gift: {
@@ -6196,7 +6824,7 @@ var C;
6196
6824
  gifted: !0
6197
6825
  },
6198
6826
  community: {
6199
- message: g,
6827
+ message: u,
6200
6828
  sender: D,
6201
6829
  bulkGifted: !0
6202
6830
  },
@@ -6205,17 +6833,18 @@ var C;
6205
6833
  gifted: !0,
6206
6834
  isCommunityGift: !0
6207
6835
  }
6208
- }, I = ["default", "gift", "community", "spam"], T = n?.subType ?? i.rand.array(I)[0];
6836
+ }, I = ["default", "gift", "community", "spam"], T = c?.subType ?? s.rand.array(I)[0];
6209
6837
  return T = I.includes(T) ? T : "default", {
6210
6838
  listener: "subscriber-latest",
6211
6839
  event: {
6212
- amount: l,
6840
+ amount: g,
6213
6841
  name: m.toLowerCase(),
6214
6842
  displayName: m,
6215
6843
  providerId: "",
6844
+ tier: U,
6216
6845
  ...E.default,
6217
6846
  ...E[T],
6218
- _id: i.rand.uuid(),
6847
+ _id: s.rand.uuid(),
6219
6848
  sessionTop: !1,
6220
6849
  type: "subscriber",
6221
6850
  originalEventName: "subscriber-latest",
@@ -6227,7 +6856,7 @@ var C;
6227
6856
  return {
6228
6857
  listener: "delete-message",
6229
6858
  event: {
6230
- msgId: n?.id ?? i.rand.uuid(),
6859
+ msgId: c?.id ?? s.rand.uuid(),
6231
6860
  provider: t
6232
6861
  }
6233
6862
  };
@@ -6235,30 +6864,30 @@ var C;
6235
6864
  return {
6236
6865
  listener: "delete-messages",
6237
6866
  event: {
6238
- userId: n?.id ?? i.rand.number(1e7, 99999999).toString(),
6867
+ userId: c?.id ?? s.rand.number(1e7, 99999999).toString(),
6239
6868
  provider: t
6240
6869
  }
6241
6870
  };
6242
6871
  }
6243
6872
  case "streamelements":
6244
- switch (s) {
6873
+ switch (n) {
6245
6874
  default:
6246
6875
  case "random": {
6247
- var u = i.rand.array(o[t])[0];
6248
- return this.onEventReceived(t, u);
6876
+ var l = s.rand.array(r[t])[0];
6877
+ return this.onEventReceived(t, l);
6249
6878
  }
6250
6879
  case "tip":
6251
6880
  case "tip-latest": {
6252
- var l = n?.amount ?? i.rand.number(100, 4e3), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((z) => z.length))[0];
6881
+ var g = c?.amount ?? s.rand.number(100, 4e3), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
6253
6882
  return {
6254
6883
  listener: "tip-latest",
6255
6884
  event: {
6256
- amount: l,
6257
- avatar: f,
6885
+ amount: g,
6886
+ avatar: b,
6258
6887
  name: m.toLowerCase(),
6259
6888
  displayName: m,
6260
6889
  providerId: "",
6261
- _id: i.rand.uuid(),
6890
+ _id: s.rand.uuid(),
6262
6891
  sessionTop: !1,
6263
6892
  type: "tip",
6264
6893
  originalEventName: "tip-latest",
@@ -6271,8 +6900,8 @@ var C;
6271
6900
  listener: "kvstore:update",
6272
6901
  event: {
6273
6902
  data: {
6274
- key: `customWidget.${n?.key ?? "sampleKey"}`,
6275
- value: n?.value ?? "sampleValue"
6903
+ key: `customWidget.${c?.key ?? "sampleKey"}`,
6904
+ value: c?.value ?? "sampleValue"
6276
6905
  },
6277
6906
  provider: t
6278
6907
  }
@@ -6281,19 +6910,19 @@ var C;
6281
6910
  return {
6282
6911
  listener: "bot:counter",
6283
6912
  event: {
6284
- counter: n?.counter ?? "sampleCounter",
6285
- value: n?.value ?? i.rand.number(0, 100),
6913
+ counter: c?.counter ?? "sampleCounter",
6914
+ value: c?.value ?? s.rand.number(0, 100),
6286
6915
  provider: t
6287
6916
  }
6288
6917
  };
6289
6918
  case "mute":
6290
6919
  case "unmute":
6291
6920
  case "alertService:toggleSound": {
6292
- var S = n?.muted ?? !client.details.overlay.muted;
6921
+ var q = c?.muted ?? !client.details.overlay.muted;
6293
6922
  return {
6294
6923
  listener: "alertService:toggleSound",
6295
6924
  event: {
6296
- muted: S,
6925
+ muted: q,
6297
6926
  provider: t
6298
6927
  }
6299
6928
  };
@@ -6308,16 +6937,16 @@ var C;
6308
6937
  };
6309
6938
  }
6310
6939
  case "youtube":
6311
- switch (s) {
6940
+ switch (n) {
6312
6941
  default:
6313
6942
  case "random": {
6314
- var u = i.rand.array(o[t])[0];
6315
- return this.onEventReceived(t, u);
6943
+ var l = s.rand.array(r[t])[0];
6944
+ return this.onEventReceived(t, l);
6316
6945
  }
6317
6946
  case "message": {
6318
- var m = n?.name ?? i.rand.array(i.data.names.filter((G) => G.length))[0], g = n?.message ?? i.rand.array(i.data.messages.filter((G) => G.length))[0];
6319
- const N = await K(n?.badges ?? [], t);
6320
- var y = F(g), j = B(g, y), x = n?.color ?? i.rand.color("hex"), U = n?.userId ?? i.rand.number(1e7, 99999999).toString(), p = n?.msgId ?? i.rand.uuid(), v = n?.time ?? Date.now(), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], d = n?.channel ?? client.details.user.username;
6947
+ var m = c?.name ?? s.rand.array(s.data.names.filter((G) => G.length))[0], u = c?.message ?? s.rand.array(s.data.messages.filter((G) => G.length))[0];
6948
+ const N = await K(c?.badges ?? [], t);
6949
+ var y = F(u), j = B(u, y), C = c?.color ?? s.rand.color("hex"), w = c?.userId ?? s.rand.number(1e7, 99999999).toString(), p = c?.msgId ?? s.rand.uuid(), v = c?.time ?? Date.now(), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], h = c?.channel ?? client.details.user.username;
6321
6950
  return {
6322
6951
  listener: "message",
6323
6952
  event: {
@@ -6329,870 +6958,556 @@ var C;
6329
6958
  snippet: {
6330
6959
  type: "",
6331
6960
  liveChatId: "",
6332
- authorChannelId: d,
6961
+ authorChannelId: h,
6333
6962
  publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
6334
6963
  hasDisplayContent: !0,
6335
- displayMessage: g,
6964
+ displayMessage: u,
6336
6965
  textMessageDetails: {
6337
- messageText: g
6966
+ messageText: u
6338
6967
  }
6339
6968
  },
6340
6969
  authorDetails: {
6341
- channelId: d,
6970
+ channelId: h,
6342
6971
  channelUrl: "",
6343
6972
  displayName: m,
6344
- profileImageUrl: f,
6973
+ profileImageUrl: b,
6345
6974
  ...N
6346
6975
  },
6347
6976
  msgId: p,
6348
- userId: U,
6977
+ userId: w,
6349
6978
  nick: m.toLowerCase(),
6350
6979
  badges: [],
6351
6980
  displayName: m,
6352
6981
  isAction: !1,
6353
6982
  time: v,
6354
6983
  tags: [],
6355
- displayColor: x,
6356
- channel: d,
6357
- text: g,
6358
- avatar: f,
6984
+ displayColor: C,
6985
+ channel: h,
6986
+ text: u,
6987
+ avatar: b,
6359
6988
  emotes: []
6360
6989
  },
6361
- renderedText: g
6990
+ renderedText: u
6362
6991
  }
6363
6992
  };
6364
6993
  }
6365
6994
  case "subscriber":
6366
6995
  case "subscriber-latest": {
6367
- var f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((A) => A.length))[0];
6996
+ var b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
6368
6997
  return {
6369
6998
  listener: "subscriber-latest",
6370
6999
  event: {
6371
- avatar: f,
6372
- displayName: m,
6373
- name: m.toLowerCase(),
6374
- providerId: "",
6375
- _id: i.rand.uuid(),
6376
- sessionTop: !1,
6377
- type: "subscriber",
6378
- originalEventName: "subscriber-latest",
6379
- provider: t
6380
- }
6381
- };
6382
- }
6383
- case "superchat":
6384
- case "superchat-latest": {
6385
- var l = n?.amount ?? i.rand.number(100, 4e3), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((z) => z.length))[0];
6386
- return {
6387
- listener: "superchat-latest",
6388
- event: {
6389
- amount: l,
6390
- avatar: f,
6391
- name: m.toLowerCase(),
6392
- displayName: m,
6393
- providerId: "",
6394
- _id: i.rand.uuid(),
6395
- sessionTop: !1,
6396
- type: "superchat",
6397
- originalEventName: "superchat-latest",
6398
- provider: t
6399
- }
6400
- };
6401
- }
6402
- case "sponsor":
6403
- case "sponsor-latest": {
6404
- var k = n?.tier ?? i.rand.array(["1000", "2000", "3000"])[0], l = n?.amount ?? i.rand.number(1, 24), f = n?.avatar ?? i.rand.array(i.data.avatars)[0], m = n?.name ?? i.rand.array(i.data.names.filter((M) => M.length))[0], D = n?.sender ?? i.rand.array(i.data.names.filter((M) => M.length && M !== m))[0], g = n?.message ?? i.rand.array(i.data.messages.filter((M) => M.length))[0], E = {
6405
- default: {
6406
- avatar: f,
6407
- tier: k,
6408
- playedAsCommunityGift: !1
6409
- },
6410
- gift: {
6411
- sender: D,
6412
- gifted: !0
6413
- },
6414
- community: {
6415
- message: g,
6416
- sender: D,
6417
- bulkGifted: !0
6418
- },
6419
- spam: {
6420
- sender: D,
6421
- gifted: !0,
6422
- isCommunityGift: !0
6423
- }
6424
- }, I = ["default", "gift", "community", "spam"], T = n?.subType ?? i.rand.array(I)[0];
6425
- return T = I.includes(T) ? T : "default", {
6426
- listener: "sponsor-latest",
6427
- event: {
6428
- amount: l,
6429
- name: m.toLowerCase(),
6430
- displayName: m,
6431
- providerId: "",
6432
- ...E.default,
6433
- ...E[T],
6434
- _id: i.rand.uuid(),
6435
- sessionTop: !1,
6436
- type: "sponsor",
6437
- originalEventName: "sponsor-latest",
6438
- provider: t
6439
- }
6440
- };
6441
- }
6442
- }
6443
- }
6444
- }
6445
- }
6446
- }, i.emulate = {
6447
- twitch: {
6448
- message(t = {}) {
6449
- i.generate.event.onEventReceived("twitch", "message", t).then((s) => {
6450
- s && i.emulate.send("onEventReceived", s);
6451
- });
6452
- },
6453
- deleteMessage(t) {
6454
- if (!t || typeof t != "string") return;
6455
- const s = {
6456
- listener: "delete-message",
6457
- event: {
6458
- msgId: t
6459
- }
6460
- };
6461
- i.emulate.send("onEventReceived", s);
6462
- },
6463
- deleteMessages(t) {
6464
- if (!t || typeof t != "string") return;
6465
- const s = {
6466
- listener: "delete-messages",
6467
- event: {
6468
- userId: t
6469
- }
6470
- };
6471
- i.emulate.send("onEventReceived", s);
6472
- },
6473
- follower(t = {}) {
6474
- i.generate.event.onEventReceived("twitch", "follower-latest", t).then((s) => {
6475
- s && i.emulate.send("onEventReceived", s);
6476
- });
6477
- },
6478
- raid(t = {}) {
6479
- i.generate.event.onEventReceived("twitch", "raid-latest", t).then((s) => {
6480
- s && i.emulate.send("onEventReceived", s);
6481
- });
6482
- },
6483
- cheer(t = {}) {
6484
- i.generate.event.onEventReceived("twitch", "cheer-latest", t).then((s) => {
6485
- s && i.emulate.send("onEventReceived", s);
6486
- });
6487
- },
6488
- subscriber(t = {}) {
6489
- i.generate.event.onEventReceived("twitch", "subscriber-latest", t).then((s) => {
6490
- s && i.emulate.send("onEventReceived", s);
6491
- });
6492
- }
6493
- },
6494
- streamelements: {
6495
- tip(t = {}) {
6496
- i.generate.event.onEventReceived("streamelements", "tip-latest", t).then((s) => {
6497
- s && i.emulate.send("onEventReceived", s);
6498
- });
6499
- }
6500
- },
6501
- youtube: {
6502
- message(t = {}) {
6503
- i.generate.event.onEventReceived("youtube", "message", t).then((s) => {
6504
- s && i.emulate.send("onEventReceived", s);
6505
- });
6506
- },
6507
- subscriber(t = {}) {
6508
- i.generate.event.onEventReceived("youtube", "subscriber-latest", t).then((s) => {
6509
- s && i.emulate.send("onEventReceived", s);
6510
- });
6511
- },
6512
- superchat(t = {}) {
6513
- i.generate.event.onEventReceived("youtube", "superchat-latest", t).then((s) => {
6514
- s && i.emulate.send("onEventReceived", s);
6515
- });
6516
- },
6517
- sponsor(t = {}) {
6518
- i.generate.event.onEventReceived("youtube", "sponsor-latest", t).then((s) => {
6519
- s && i.emulate.send("onEventReceived", s);
6520
- });
6521
- }
6522
- },
6523
- kick: {},
6524
- facebook: {},
6525
- send(t, s) {
6526
- window.dispatchEvent(new CustomEvent(t, { detail: s }));
6527
- }
6528
- };
6529
- function e(t) {
6530
- return new Promise((s) => setTimeout(s, t));
6531
- }
6532
- i.delay = e;
6533
- function a(t) {
6534
- return Object.entries(t);
6535
- }
6536
- i.typedEntries = a;
6537
- function c(t) {
6538
- const s = Object.values(t).reduce((u, m) => u + m, 0), n = a(t).sort((u, m) => m[1] - u[1]), o = Math.random() * s;
6539
- let h = 0;
6540
- for (const [u, m] of n)
6541
- if (h += m, o < h)
6542
- return u;
6543
- }
6544
- i.probability = c;
6545
- async function r(t = ["fields.json", "cf.json", "field.json", "customfields.json"], s = ["data.json", "fielddata.json", "fd.json", "DATA.json"]) {
6546
- const n = {
6547
- fields: t.find((h) => {
6548
- try {
6549
- return new URL("./" + h, window.location.href), !0;
6550
- } catch {
6551
- return !1;
6552
- }
6553
- }),
6554
- data: s.find((h) => {
6555
- try {
6556
- return new URL("./" + h, window.location.href), !0;
6557
- } catch {
6558
- return !1;
6559
- }
6560
- })
6561
- }, o = await fetch("./" + (n.data ?? "data.json"), {
6562
- cache: "no-store"
6563
- }).then((h) => h.json()).catch(() => ({}));
6564
- await fetch("./" + (n.fields ?? "fields.json"), {
6565
- cache: "no-store"
6566
- }).then((h) => h.json()).then(async (h) => {
6567
- const u = Object.entries(h).filter(([g, { value: b }]) => b != null).reduce(
6568
- (g, [b, { value: y }]) => (o && o[b] !== void 0 && (y = o[b]), g[b] = y, g),
6569
- {
6570
- ...o
6571
- }
6572
- ), m = await i.generate.event.onWidgetLoad(u, await i.generate.session.get());
6573
- window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: m }));
6574
- });
6575
- }
6576
- i.start = r;
6577
- })(C || (C = {}));
6578
- function F(i, e = C.data.emotes) {
6579
- const a = [];
6580
- return e.forEach((c) => {
6581
- const r = c.name;
6582
- let t = 0, s = 0;
6583
- for (; t < i.length; ) {
6584
- const n = i.indexOf(r, s);
6585
- if (n === -1) break;
6586
- const o = n > 0 ? i[n - 1] : " ", h = n + r.length < i.length ? i[n + r.length] : " ";
6587
- /\s/.test(o) && /\s/.test(h) && a.push({ ...c, start: n, end: n + r.length }), s = n + 1;
6588
- }
6589
- }), a.sort((c, r) => c.start - r.start);
6590
- }
6591
- function B(i, e) {
6592
- if (!e.length) return i;
6593
- let a = "", c = 0;
6594
- return e.forEach((r) => {
6595
- a += i.substring(c, r.start);
6596
- const s = Array.from({ ...r.urls, length: 5 }).slice(1).reverse().filter(Boolean)[0] || r.urls[1];
6597
- a += `<img src="${s}" alt="${r.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, c = r.end;
6598
- }), a += i.substring(c), a;
6599
- }
6600
- function ut(i, e = C.data.youtube_emotes) {
6601
- return Array.from(i.matchAll(/:(.*?):/gim), (c) => c[0]).forEach((c) => {
6602
- const r = e.find((t) => t.shortcuts.includes(c) || t.searchTerms.includes(c.slice(1, -1)));
6603
- if (r) {
6604
- const t = r.image.thumbnails.at(-1)?.url, s = r.image.accessibility.accessibilityData.label;
6605
- t && (i = i.replace(c, `<img src="${t}" alt="${s}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
6606
- }
6607
- }), i;
6608
- }
6609
- async function K(i = [], e = "twitch") {
6610
- if (!Array.isArray(i) && typeof i == "string" && (i = i.split(",").map((s) => s.trim())), !i || !i.length) {
6611
- var a = C.rand.number(1, 3);
6612
- for await (const s of Array.from({ length: a }, () => "")) {
6613
- var c = C.rand.array(Object.keys(C.data.badges))[0];
6614
- !i.includes(c) && Array.isArray(i) ? i.push(c) : i = [c];
6615
- }
6616
- }
6617
- var r;
6618
- switch (e) {
6619
- case "twitch": {
6620
- r = {
6621
- keys: Array.from(i).filter((s) => s in C.data.badges),
6622
- badges: Array.from(i).slice(0, 3).map((s) => C.data.badges[s]).filter(Boolean)
6623
- };
6624
- break;
6625
- }
6626
- case "youtube": {
6627
- var t = {
6628
- verified: { isVerified: !0 },
6629
- broadcaster: { isChatOwner: !0 },
6630
- host: { isChatOwner: !0 },
6631
- sponsor: { isChatSponsor: !0 },
6632
- subscriber: { isChatSponsor: !0 },
6633
- moderator: { isChatModerator: !0 }
6634
- };
6635
- r = Object.entries(i).reduce(
6636
- (s, [n]) => (n in t && Object.assign(s, t[n]), s),
6637
- {
6638
- isVerified: !1,
6639
- isChatOwner: !1,
6640
- isChatSponsor: !1,
6641
- isChatModerator: !1
7000
+ avatar: b,
7001
+ displayName: m,
7002
+ name: m.toLowerCase(),
7003
+ providerId: "",
7004
+ _id: s.rand.uuid(),
7005
+ sessionTop: !1,
7006
+ type: "subscriber",
7007
+ originalEventName: "subscriber-latest",
7008
+ provider: t
7009
+ }
7010
+ };
7011
+ }
7012
+ case "superchat":
7013
+ case "superchat-latest": {
7014
+ var g = c?.amount ?? s.rand.number(100, 4e3), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((z) => z.length))[0];
7015
+ return {
7016
+ listener: "superchat-latest",
7017
+ event: {
7018
+ amount: g,
7019
+ avatar: b,
7020
+ name: m.toLowerCase(),
7021
+ displayName: m,
7022
+ providerId: "",
7023
+ _id: s.rand.uuid(),
7024
+ sessionTop: !1,
7025
+ type: "superchat",
7026
+ originalEventName: "superchat-latest",
7027
+ provider: t
7028
+ }
7029
+ };
7030
+ }
7031
+ case "sponsor":
7032
+ case "sponsor-latest": {
7033
+ var U = c?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], g = c?.amount ?? s.rand.number(1, 24), b = c?.avatar ?? s.rand.array(s.data.avatars)[0], m = c?.name ?? s.rand.array(s.data.names.filter((M) => M.length))[0], D = c?.sender ?? s.rand.array(s.data.names.filter((M) => M.length && M !== m))[0], u = c?.message ?? s.rand.array(s.data.messages.filter((M) => M.length))[0], E = {
7034
+ default: {
7035
+ avatar: b,
7036
+ playedAsCommunityGift: !1
7037
+ },
7038
+ gift: {
7039
+ sender: D,
7040
+ gifted: !0
7041
+ },
7042
+ community: {
7043
+ message: u,
7044
+ sender: D,
7045
+ bulkGifted: !0
7046
+ },
7047
+ spam: {
7048
+ sender: D,
7049
+ gifted: !0,
7050
+ isCommunityGift: !0
7051
+ }
7052
+ }, I = ["default", "gift", "community", "spam"], T = c?.subType ?? s.rand.array(I)[0];
7053
+ return T = I.includes(T) ? T : "default", {
7054
+ listener: "sponsor-latest",
7055
+ event: {
7056
+ amount: g,
7057
+ name: m.toLowerCase(),
7058
+ displayName: m,
7059
+ providerId: "",
7060
+ ...E.default,
7061
+ ...E[T],
7062
+ _id: s.rand.uuid(),
7063
+ sessionTop: !1,
7064
+ type: "sponsor",
7065
+ originalEventName: "sponsor-latest",
7066
+ provider: t
7067
+ }
7068
+ };
7069
+ }
7070
+ }
6642
7071
  }
6643
- );
6644
- break;
7072
+ }
6645
7073
  }
6646
- }
6647
- return r;
6648
- }
6649
- const Y = {
6650
- getOverlayStatus: () => ({
6651
- isEditorMode: !1,
6652
- muted: !1
6653
- }),
6654
- resumeQueue: () => {
6655
- },
6656
- responses: {},
6657
- sendMessage(i, e) {
6658
- },
6659
- counters: {
6660
- get(i) {
6661
- return null;
7074
+ }, s.Queue = new Q({
7075
+ duration: "client",
7076
+ async processor(t) {
7077
+ if (window.dispatchEvent(new CustomEvent(t.listener, { detail: t.data })), t.listener === "onEventReceived" && t.session) {
7078
+ const n = await s.generate.event.onSessionUpdate(client.session, Z(t.data));
7079
+ window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: n }));
7080
+ }
6662
7081
  }
6663
- },
6664
- sanitize(i) {
6665
- return i;
6666
- },
6667
- cheerFilter(i) {
6668
- return i;
6669
- },
6670
- setField(i, e, a) {
6671
- },
6672
- store: {
6673
- set: function(i, e) {
6674
- this.list[i] = e, localStorage.setItem("SE_API-STORE", JSON.stringify(Y.store.list));
6675
- },
6676
- get: async function(i) {
6677
- return this.list[i] ? this.list[i] : null;
6678
- },
6679
- list: {}
6680
- }
6681
- };
6682
- async function gt() {
6683
- let i = localStorage.getItem("SE_API-STORE") ?? "", e = i ? JSON.parse(i) : {};
6684
- return Y.store.list = e, Y;
6685
- }
6686
- class O {
6687
- /**
6688
- * Stores registered event listeners.
6689
- */
6690
- registeredEvents = {};
6691
- /**
6692
- * Emits an event to all registered listeners.
6693
- * Returns an array of return values from the listeners.
6694
- * @param eventName The name of the event.
6695
- * @param args Arguments to pass to the listeners.
6696
- */
6697
- emit(e, ...a) {
6698
- return (this.registeredEvents[e] || []).map((r) => r.apply(this, a));
6699
- }
6700
- /**
6701
- * Registers an event listener.
6702
- * @param eventName The name of the event.
6703
- * @param callback The callback function.
6704
- */
6705
- on(e, a) {
6706
- if (typeof a != "function")
6707
- throw new TypeError("Callback must be a function");
6708
- return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(a), this;
6709
- }
6710
- /**
6711
- * Removes a specific event listener.
6712
- * @param eventName The name of the event.
6713
- * @param callback The callback function to remove.
6714
- */
6715
- off(e, a) {
6716
- const c = this.registeredEvents[e] || [];
6717
- return a ? (this.registeredEvents[e] = c.filter((r) => r !== a), this) : (this.registeredEvents[e] = [], this);
6718
- }
6719
- /**
6720
- * Registers a listener that is executed only once.
6721
- * @param eventName The name of the event.
6722
- * @param callback The callback function.
6723
- */
6724
- once(e, a) {
6725
- const c = (...r) => {
6726
- this.off(e, c), a.apply(this, r);
6727
- };
6728
- return this.on(e, c), this;
6729
- }
6730
- /**
6731
- * Removes all listeners for a specific event.
6732
- * @param eventName The name of the event.
6733
- */
6734
- removeAllListeners(e) {
6735
- return this.registeredEvents[e] = [], this;
6736
- }
6737
- }
6738
- var _ = [];
6739
- class V extends O {
6740
- /**
6741
- * The unique identifier for the storage instance.
6742
- */
6743
- id = "default";
6744
- loaded = !1;
6745
- data;
6746
- constructor(e) {
6747
- super(), this.id = e.id || this.id, this.data = e.data ?? {}, _.push(this), this.start();
6748
- }
6749
- SE_API = null;
6750
- start() {
6751
- Z?.then((e) => {
6752
- this.SE_API = e, e.store.get(this.id).then((a) => {
6753
- this.data = a ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(a) && this.emit("update", this.data);
6754
- }).catch(() => {
6755
- this.loaded = !0, this.emit("load", this.data);
6756
- });
6757
- });
6758
- }
6759
- /**
6760
- * Saves the current data to storage.
6761
- * @param data Data to save (defaults to current)
6762
- */
6763
- save(e = this.data) {
6764
- this.loaded && this.SE_API && (this.data = e, this.SE_API.store.set(this.id, this.data), this.emit("update", this.data));
6765
- }
6766
- /**
6767
- * Updates the storage data and emits an update event
6768
- * @param data Data to update (defaults to current)
6769
- */
6770
- update(e = this.data) {
6771
- this.loaded && JSON.stringify(this.data) !== JSON.stringify(e) && (this.data = { ...this.data, ...e }, this.save(this.data));
6772
- }
6773
- /**
6774
- * Adds a value to the storage at the specified path.
6775
- * @param path Path to add the value to
6776
- * @param value Value to add
6777
- */
6778
- add(e, a) {
6779
- this.loaded && (V.setByPath(this.data, e, a), this.save(this.data));
6780
- }
6781
- /**
6782
- * Clears all data from the storage.
6783
- */
6784
- clear() {
6785
- this.loaded && (this.data = {}, this.save(this.data));
6786
- }
6787
- /**
6788
- * Sets a value in the storage at the specified path.
6789
- * @param obj The object to set the value in
6790
- * @param path The path to set the value at
6791
- * @param value The value to set
6792
- * @returns The updated object
6793
- */
6794
- static setByPath(e, a, c) {
6795
- const r = a.split(".");
6796
- let t = e;
6797
- for (let s = 0; s < r.length - 1; s++)
6798
- (typeof t[r[s]] != "object" || t[r[s]] == null) && (t[r[s]] = {}), t = t[r[s]];
6799
- return t[r[r.length - 1]] = c, t;
6800
- }
6801
- on(e, a) {
6802
- return e === "load" && this.loaded ? (a.apply(this, [this.data]), this) : (super.on(e, a), this);
6803
- }
6804
- }
6805
- class pt extends O {
6806
- instance;
6807
- username;
6808
- password;
6809
- channels;
6810
- isDebug = !1;
6811
- init = !1;
6812
- emulate = !1;
6813
- /**
6814
- * Initializes a new ComfyJS instance and connects to Twitch chat.
6815
- * @param options - Configuration options for ComfyJS instance.
6816
- * @param emulate - Whether to emulate chat messages in the Simulation module.
6817
- */
6818
- constructor(e, a) {
6819
- super(), this.username = e.username, this.password = e.password, this.channels = e.channels, this.isDebug = !!e.isDebug, this.init = !!e.init, this.emulate = a, this.load().then((c) => {
6820
- this.instance = c, this.emit("load", c), this.connect();
6821
- }).catch((c) => {
6822
- w.error("useComfyJs: Failed to load ComfyJS", c);
6823
- });
6824
- }
6825
- /**
6826
- * Loads the ComfyJS script if not already loaded.
6827
- * @returns A promise that resolves to the ComfyJS instance.
6828
- */
6829
- load() {
6830
- return typeof window.ComfyJS < "u" && !window.ComfyJS ? new Promise((e, a) => {
6831
- if (this.emulate && !client)
6832
- return a(new Error("useComfyJs: Cannot emulate chat messages without a Client instance."));
6833
- const c = document.createElement("script");
6834
- c.src = "https://cdn.jsdelivr.net/npm/comfy.js@latest/dist/comfy.min.js", c.type = "text/javascript", c.async = !0, c.onload = () => e(window.ComfyJS), c.onerror = (r) => a(r), document.head.appendChild(c);
6835
- }) : Promise.resolve(window.ComfyJS);
6836
- }
6837
- /**
6838
- * Connects event handlers to the ComfyJS instance.
6839
- */
6840
- connect() {
6841
- this.instance.onError = (e) => {
6842
- this.emit("error", e), client.debug && w.error("[Client]", "ComfyJS Error:", e);
6843
- }, this.instance.onCommand = (e, a, c, r, t) => {
6844
- if (this.emit("command", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Command: !${a} ${c} (User: ${e})`), this.emulate) {
6845
- const s = {
6846
- ...r,
6847
- broadcaster: r.broadcaster,
6848
- moderator: r.mod,
6849
- vip: r.vip,
6850
- subscriber: r.subscriber,
6851
- founder: r.founder
6852
- }, n = {
6853
- name: e,
6854
- message: `!${a} ${c}`,
6855
- badges: Object.entries(s).map(([o, h]) => h ? o : null).filter(Boolean),
6856
- color: t.userColor,
6857
- time: new Date(t.timestamp).getTime(),
6858
- userId: t.userId,
6859
- msgId: t.id,
6860
- channel: t.channel
7082
+ }), s.emulate = {
7083
+ twitch: {
7084
+ message(t = {}) {
7085
+ s.generate.event.onEventReceived("twitch", "message", t).then((n) => {
7086
+ n && s.emulate.send("onEventReceived", n);
7087
+ });
7088
+ },
7089
+ deleteMessage(t) {
7090
+ if (!t || typeof t != "string") return;
7091
+ const n = {
7092
+ listener: "delete-message",
7093
+ event: {
7094
+ msgId: t
7095
+ }
6861
7096
  };
6862
- C.emulate.twitch.message(n);
6863
- }
6864
- }, this.instance.onChat = (e, a, c, r, t) => {
6865
- if (this.emit("chat", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Chat: ${a} (User: ${e})`), this.emulate) {
6866
- const s = {
6867
- ...c,
6868
- ...t.userBadges,
6869
- broadcaster: c.broadcaster,
6870
- moderator: c.mod,
6871
- vip: c.vip,
6872
- subscriber: c.subscriber,
6873
- founder: c.founder
7097
+ s.emulate.send("onEventReceived", n);
7098
+ },
7099
+ deleteMessages(t) {
7100
+ if (!t || typeof t != "string") return;
7101
+ const n = {
7102
+ listener: "delete-messages",
7103
+ event: {
7104
+ userId: t
7105
+ }
6874
7106
  };
6875
- C.emulate.twitch.message({
6876
- name: e,
6877
- message: a,
6878
- badges: Object.entries(s).map(([n, o]) => o ? n : null).filter(Boolean),
6879
- color: t.userColor,
6880
- time: new Date(t.timestamp).getTime(),
6881
- userId: t.userId,
6882
- msgId: t.id,
6883
- channel: t.channel
7107
+ s.emulate.send("onEventReceived", n);
7108
+ },
7109
+ follower(t = {}) {
7110
+ s.generate.event.onEventReceived("twitch", "follower-latest", t).then((n) => {
7111
+ n && s.emulate.send("onEventReceived", n);
6884
7112
  });
6885
- }
6886
- }, this.instance.onWhisper = (e, a, c, r, t) => {
6887
- this.emit("whisper", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Whisper: ${a} (User: ${e})`);
6888
- }, this.instance.onMessageDeleted = (e, a) => {
6889
- this.emit("messageDeleted", e, a), client.debug && w.debug("[Client]", `ComfyJS Message Deleted: ${e}`), this.emulate && C.emulate.twitch.deleteMessage(e);
6890
- }, this.instance.onJoin = (e, a, c) => {
6891
- this.emit("join", e, a, c), client.debug && w.debug("[Client]", `ComfyJS Join: ${e}`);
6892
- }, this.instance.onPart = (e, a, c) => {
6893
- this.emit("part", e, a, c), client.debug && w.debug("[Client]", `ComfyJS Part: ${e}`);
6894
- }, this.instance.onHosted = (e, a, c, r) => {
6895
- this.emit("hosted", e, a, c, r), client.debug && w.debug("[Client]", `ComfyJS Hosted: ${e} (${a} viewers)`);
6896
- }, this.instance.onRaid = (e, a, c) => {
6897
- this.emit("raid", e, a, c), client.debug && w.debug("[Client]", `ComfyJS Raid: ${e} (${a} viewers)`), this.emulate && C.emulate.twitch.raid({
6898
- name: e,
6899
- amount: a
6900
- });
6901
- }, this.instance.onSub = (e, a, c, r) => {
6902
- if (this.emit("sub", e, a, c, r), client.debug && w.debug("[Client]", `ComfyJS Sub: ${e} (${c.plan})`), this.emulate) {
6903
- const t = c.plan === "Prime" ? "prime" : c.plan;
6904
- C.emulate.twitch.subscriber({
6905
- name: e,
6906
- message: a,
6907
- tier: t,
6908
- subType: "default"
7113
+ },
7114
+ raid(t = {}) {
7115
+ s.generate.event.onEventReceived("twitch", "raid-latest", t).then((n) => {
7116
+ n && s.emulate.send("onEventReceived", n);
6909
7117
  });
6910
- }
6911
- }, this.instance.onResub = (e, a, c, r, t, s) => {
6912
- if (this.emit("resub", e, a, c, r, t, s), client.debug && w.debug("[Client]", `ComfyJS Resub: ${e} (${r} months)`), this.emulate) {
6913
- const n = t.plan === "Prime" ? "prime" : t.plan;
6914
- C.emulate.twitch.subscriber({
6915
- name: e,
6916
- message: a,
6917
- tier: n,
6918
- amount: r,
6919
- subType: "default"
7118
+ },
7119
+ cheer(t = {}) {
7120
+ s.generate.event.onEventReceived("twitch", "cheer-latest", t).then((n) => {
7121
+ n && s.emulate.send("onEventReceived", n);
7122
+ });
7123
+ },
7124
+ subscriber(t = {}) {
7125
+ s.generate.event.onEventReceived("twitch", "subscriber-latest", t).then((n) => {
7126
+ n && s.emulate.send("onEventReceived", n);
6920
7127
  });
6921
7128
  }
6922
- }, this.instance.onSubGift = (e, a, c, r, t, s) => {
6923
- if (this.emit("subGift", e, a, c, r, t, s), client.debug && w.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${r} subs`), this.emulate) {
6924
- const n = t.plan === "Prime" ? "prime" : t.plan;
6925
- C.emulate.twitch.subscriber({
6926
- name: c,
6927
- message: "",
6928
- sender: e,
6929
- tier: n,
6930
- amount: r,
6931
- subType: "gift"
7129
+ },
7130
+ streamelements: {
7131
+ tip(t = {}) {
7132
+ s.generate.event.onEventReceived("streamelements", "tip-latest", t).then((n) => {
7133
+ n && s.emulate.send("onEventReceived", n);
6932
7134
  });
6933
7135
  }
6934
- }, this.instance.onSubMysteryGift = (e, a, c, r, t) => {
6935
- if (this.emit("subMysteryGift", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Sub Mystery Gift: ${e} gifted ${a} subs`), this.emulate) {
6936
- const s = r.plan === "Prime" ? "prime" : r.plan;
6937
- C.emulate.twitch.subscriber({
6938
- name: e,
6939
- message: "",
6940
- amount: a,
6941
- tier: s,
6942
- subType: "community"
7136
+ },
7137
+ youtube: {
7138
+ message(t = {}) {
7139
+ s.generate.event.onEventReceived("youtube", "message", t).then((n) => {
7140
+ n && s.emulate.send("onEventReceived", n);
7141
+ });
7142
+ },
7143
+ subscriber(t = {}) {
7144
+ s.generate.event.onEventReceived("youtube", "subscriber-latest", t).then((n) => {
7145
+ n && s.emulate.send("onEventReceived", n);
7146
+ });
7147
+ },
7148
+ superchat(t = {}) {
7149
+ s.generate.event.onEventReceived("youtube", "superchat-latest", t).then((n) => {
7150
+ n && s.emulate.send("onEventReceived", n);
7151
+ });
7152
+ },
7153
+ sponsor(t = {}) {
7154
+ s.generate.event.onEventReceived("youtube", "sponsor-latest", t).then((n) => {
7155
+ n && s.emulate.send("onEventReceived", n);
6943
7156
  });
6944
7157
  }
6945
- }, this.instance.onGiftSubContinue = (e, a, c) => {
6946
- this.emit("giftSubContinue", e, a, c), client.debug && w.debug("[Client]", `ComfyJS Gift Sub Continue: ${e} continued their gifted sub from ${a}`), this.emulate && C.emulate.twitch.subscriber({
6947
- name: e,
6948
- message: "",
6949
- sender: a,
6950
- tier: "1000",
6951
- subType: "gift"
6952
- });
6953
- }, this.instance.onCheer = (e, a, c, r, t) => {
6954
- this.emit("cheer", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Cheer: ${e} cheered ${c} bits - ${a}`), this.emulate && C.emulate.twitch.cheer({
6955
- name: e,
6956
- message: a,
6957
- amount: c
6958
- });
6959
- }, this.instance.onChatMode = (e, a) => {
6960
- this.emit("chatMode", e, a), client.debug && w.debug("[Client]", `ComfyJS Chat Mode Changed on ${a}`);
6961
- }, this.instance.onReward = (e, a, c, r, t) => {
6962
- this.emit("reward", e, a, c, r, t), client.debug && w.debug("[Client]", `ComfyJS Reward: ${e} redeemed ${a} for ${c} - ${r}`);
6963
- }, this.instance.onConnected = (e, a, c) => {
6964
- this.emit("connected", e, a, c), client.debug && w.debug("[Client]", `ComfyJS Connected: ${e}:${a} (First Connect: ${c})`);
6965
- }, this.instance.onReconnect = (e) => {
6966
- this.emit("reconnect", e), client.debug && w.debug("[Client]", `ComfyJS Reconnect: Attempt #${e}`);
6967
- }, this.init && this.instance.Init(this.username, this.password, this.channels, this.isDebug);
6968
- }
6969
- }
6970
- class J extends O {
6971
- id = "default";
6972
- debug = !1;
6973
- storage;
6974
- fields = {};
6975
- session;
6976
- loaded = !1;
6977
- constructor(e) {
6978
- super(), this.id = e.id || this.id, this.storage = new V({
6979
- id: this.id,
6980
- data: {
6981
- user: {},
6982
- avatar: {},
6983
- pronoun: {},
6984
- emote: {}
7158
+ },
7159
+ kick: {},
7160
+ facebook: {},
7161
+ send(t, n) {
7162
+ switch (t) {
7163
+ case "onEventReceived": {
7164
+ s.Queue.enqueue({
7165
+ listener: t,
7166
+ data: n,
7167
+ session: t === "onEventReceived" ? !0 : void 0
7168
+ });
7169
+ break;
7170
+ }
7171
+ case "onSessionUpdate": {
7172
+ s.Queue.enqueue({
7173
+ listener: t,
7174
+ data: n
7175
+ });
7176
+ break;
7177
+ }
7178
+ case "onWidgetLoad": {
7179
+ s.Queue.enqueue({
7180
+ listener: t,
7181
+ data: n
7182
+ });
7183
+ break;
7184
+ }
6985
7185
  }
6986
- }), this.on("load", () => {
6987
- this.debug = !!(typeof e.debug == "function" ? e.debug() : e.debug);
6988
- }), window.client = this;
6989
- }
6990
- actions = {
6991
- commands: [],
6992
- buttons: []
6993
- };
6994
- details;
6995
- cache = {
6996
- avatar: 30,
6997
- pronoun: 60,
6998
- emote: 120
7186
+ }
6999
7187
  };
7000
- on(e, a) {
7001
- return e === "load" && this.loaded ? (a.apply(this, [
7002
- {
7003
- channel: this.details.user,
7004
- currency: this.details.currency,
7005
- fieldData: this.fields,
7006
- recents: [],
7007
- session: {
7008
- data: this.session,
7009
- settings: {
7010
- autoReset: !1,
7011
- calendar: !1,
7012
- resetOnStart: !1
7013
- }
7014
- },
7015
- overlay: this.details.overlay,
7016
- emulated: !1
7017
- }
7018
- ]), this) : (super.on(e, a), this);
7188
+ function e(t) {
7189
+ return new Promise((n) => setTimeout(n, t));
7019
7190
  }
7020
- }
7021
- class R {
7022
- prefix = "!";
7023
- name;
7024
- description;
7025
- arguments = !1;
7026
- test = `${this.prefix}${this.name} arg1 arg2`;
7027
- aliases = [];
7028
- permissions = void 0;
7029
- admins = [];
7030
- constructor(e) {
7031
- window.client instanceof J && (this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, window.client.actions.commands.push(this), window.client.emit("action", this, "created"));
7191
+ s.delay = e;
7192
+ function a(t) {
7193
+ return Object.entries(t);
7032
7194
  }
7033
- run(e, a) {
7195
+ s.typedEntries = a;
7196
+ function o(t) {
7197
+ const n = Object.values(t).reduce((l, m) => l + m, 0), c = a(t).sort((l, m) => m[1] - l[1]), r = Math.random() * n;
7198
+ let d = 0;
7199
+ for (const [l, m] of c)
7200
+ if (d += m, r < d)
7201
+ return l;
7034
7202
  }
7035
- verify(e, a, c) {
7036
- return this.arguments === !0 && (!c || !c.length) ? !1 : this.admins.some((r) => e.toLocaleLowerCase() === r.toLocaleLowerCase()) ? !0 : this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length ? !1 : !!(Array.isArray(this.permissions) && this.permissions.some((r) => e.toLowerCase() === r.toLowerCase() || a.map((t) => t.toLowerCase()).includes(r.toLowerCase())));
7203
+ s.probability = o;
7204
+ async function i(t = ["fields.json", "cf.json", "field.json", "customfields.json"], n = ["data.json", "fielddata.json", "fd.json", "DATA.json"]) {
7205
+ const c = {
7206
+ fields: t.find((d) => {
7207
+ try {
7208
+ return new URL("./" + d, window.location.href), !0;
7209
+ } catch {
7210
+ return !1;
7211
+ }
7212
+ }),
7213
+ data: n.find((d) => {
7214
+ try {
7215
+ return new URL("./" + d, window.location.href), !0;
7216
+ } catch {
7217
+ return !1;
7218
+ }
7219
+ })
7220
+ }, r = await fetch("./" + (c.data ?? "data.json"), {
7221
+ cache: "no-store"
7222
+ }).then((d) => d.json()).catch(() => ({}));
7223
+ await fetch("./" + (c.fields ?? "fields.json"), {
7224
+ cache: "no-store"
7225
+ }).then((d) => d.json()).then(async (d) => {
7226
+ const l = Object.entries(d).filter(([u, { value: f }]) => f != null).reduce(
7227
+ (u, [f, { value: y }]) => (r && r[f] !== void 0 && (y = r[f]), u[f] = y, u),
7228
+ {
7229
+ ...r
7230
+ }
7231
+ ), m = await s.generate.event.onWidgetLoad(l, await s.generate.session.get());
7232
+ window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: m }));
7233
+ });
7037
7234
  }
7038
- parse(e, a) {
7039
- if (!(window.client instanceof J)) return !1;
7040
- const c = e.replace(this.prefix, "").split(" ").slice(1).map((o) => o.trim());
7041
- var r = "", t = [];
7042
- const s = { bits: "cheer", premium: "prime" };
7043
- switch (a.provider) {
7044
- case "twitch": {
7045
- const o = a.data;
7046
- r = o.event.data.nick || o.event.data.displayName, o.event.data.tags?.badges && (t = o.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((u) => u in s ? s[u] : u));
7047
- break;
7048
- }
7049
- case "youtube": {
7050
- const o = a.data, h = {
7051
- isVerified: "verified",
7052
- isChatOwner: "owner",
7053
- isChatSponsor: "sponsor",
7054
- isChatModerator: "moderator"
7055
- };
7056
- r = o.event.data.nick || o.event.data.displayName, t = Object.entries(o.event.data.authorDetails).filter(([u, m]) => u.startsWith("is") && m).map(([u]) => h[u]).filter(Boolean);
7057
- break;
7058
- }
7059
- case "kick":
7060
- return !1;
7235
+ s.start = i;
7236
+ })(x || (x = {}));
7237
+ function F(s, e = x.data.emotes) {
7238
+ const a = [];
7239
+ return e.forEach((o) => {
7240
+ const i = o.name;
7241
+ let t = 0, n = 0;
7242
+ for (; t < s.length; ) {
7243
+ const c = s.indexOf(i, n);
7244
+ if (c === -1) break;
7245
+ const r = c > 0 ? s[c - 1] : " ", d = c + i.length < s.length ? s[c + i.length] : " ";
7246
+ /\s/.test(r) && /\s/.test(d) && a.push({ ...o, start: c, end: c + i.length }), n = c + 1;
7061
7247
  }
7062
- const n = this.verify(r, t, c);
7063
- return n === !0 && this.run.apply(window.client, [c, a]), n;
7064
- }
7065
- remove() {
7066
- if (!(window.client instanceof J)) return;
7067
- const e = window.client.actions.commands.indexOf(this);
7068
- e > -1 && (window.client.actions.commands.splice(e, 1), window.client.emit("action", this, "removed"));
7069
- }
7070
- static execute(e) {
7071
- if (!(window.client instanceof J)) return !1;
7072
- const a = e.data;
7073
- try {
7074
- if (window.client.actions.commands.length && window.client.actions.commands.some((c) => a.event.data.text.startsWith(c.prefix))) {
7075
- const c = window.client.actions.commands.filter((r) => {
7076
- var t = [r.name, ...r.aliases ?? []], s = a.event.data.text.replace(r.prefix, "").split(" ")[0];
7077
- return t.includes(s);
7078
- });
7079
- if (c.length && c.every((r) => r instanceof R))
7080
- return c.forEach((r) => {
7081
- r.parse(a.event.data.text, e), window.client.emit("action", r, "executed"), w.received(`Command executed: ${a.event.data.text} by ${a.event.data.nick || a.event.data.displayName}`, a);
7082
- }), !0;
7083
- }
7084
- } catch {
7085
- return !1;
7086
- } finally {
7087
- return !1;
7248
+ }), a.sort((o, i) => o.start - i.start);
7249
+ }
7250
+ function B(s, e) {
7251
+ if (!e.length) return s;
7252
+ let a = "", o = 0;
7253
+ return e.forEach((i) => {
7254
+ a += s.substring(o, i.start);
7255
+ const n = Array.from({ ...i.urls, length: 5 }).slice(1).reverse().filter(Boolean)[0] || i.urls[1];
7256
+ a += `<img src="${n}" alt="${i.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, o = i.end;
7257
+ }), a += s.substring(o), a;
7258
+ }
7259
+ function pt(s, e = x.data.youtube_emotes) {
7260
+ return Array.from(s.matchAll(/:(.*?):/gim), (o) => o[0]).forEach((o) => {
7261
+ const i = e.find((t) => t.shortcuts.includes(o) || t.searchTerms.includes(o.slice(1, -1)));
7262
+ if (i) {
7263
+ const t = i.image.thumbnails.at(-1)?.url, n = i.image.accessibility.accessibilityData.label;
7264
+ t && (s = s.replace(o, `<img src="${t}" alt="${n}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`));
7088
7265
  }
7089
- }
7266
+ }), s;
7090
7267
  }
7091
- class ft extends O {
7092
- queue = [];
7093
- priorityQueue = [];
7094
- history = [];
7095
- timeouts = [];
7096
- running = !1;
7097
- duration = void 0;
7098
- loaded = !1;
7099
- processor;
7100
- constructor(e) {
7101
- window.client instanceof J && (super(), this.duration = e.duration, this.processor = e.processor, window.client.on("load", () => {
7102
- this.emit("load"), this.loaded = !0;
7103
- }));
7104
- }
7105
- enqueue(e, a = {}) {
7106
- const c = {
7107
- isoDate: (/* @__PURE__ */ new Date()).toISOString(),
7108
- isLoop: a?.isLoop ?? !1,
7109
- isPriority: a?.isPriority ?? !1,
7110
- isImmediate: a?.isImmediate ?? !1,
7111
- value: e
7112
- }, r = this.hasItems();
7113
- return c.isPriority && c.isImmediate ? (this.cancel(), this.priorityQueue.unshift(c)) : (c.isPriority ? this.priorityQueue : this.queue).push(c), this.running === !1 && r === !1 && this.run(), this.emit("update", this.queue, this.priorityQueue, this.history, this.timeouts), this;
7114
- }
7115
- async run() {
7116
- if (!this.hasItems()) {
7117
- this.running = !1;
7118
- return;
7268
+ async function K(s = [], e = "twitch") {
7269
+ if (!Array.isArray(s) && typeof s == "string" && (s = s.split(",").map((n) => n.trim())), !s || !s.length) {
7270
+ var a = x.rand.number(1, 3);
7271
+ for await (const n of Array.from({ length: a }, () => "")) {
7272
+ var o = x.rand.array(Object.keys(x.data.badges))[0];
7273
+ !s.includes(o) && Array.isArray(s) ? s.push(o) : s = [o];
7119
7274
  }
7120
- this.running = !0, await this.next(), typeof this.duration == "number" && this.duration > 0 ? this.timeouts.push(setTimeout(() => this.run(), this.duration)) : (this.duration === 0 || this.duration !== -1 && this.duration !== !1) && this.run();
7121
7275
  }
7122
- async next() {
7123
- const e = this.priorityQueue.length > 0 ? this.priorityQueue.shift() : this.queue.shift();
7124
- if (!e) {
7125
- this.running = !1;
7126
- return;
7127
- }
7128
- try {
7129
- await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
7130
- } catch (c) {
7131
- w.error(`Error during item processing: ${c instanceof Error ? c.message : String(c)}`);
7276
+ var i;
7277
+ switch (e) {
7278
+ case "twitch": {
7279
+ i = {
7280
+ keys: Array.from(s).filter((n) => n in x.data.badges),
7281
+ badges: Array.from(s).slice(0, 3).map((n) => x.data.badges[n]).filter(Boolean)
7282
+ };
7283
+ break;
7284
+ }
7285
+ case "youtube": {
7286
+ var t = {
7287
+ verified: { isVerified: !0 },
7288
+ broadcaster: { isChatOwner: !0 },
7289
+ host: { isChatOwner: !0 },
7290
+ sponsor: { isChatSponsor: !0 },
7291
+ subscriber: { isChatSponsor: !0 },
7292
+ moderator: { isChatModerator: !0 }
7293
+ };
7294
+ i = Object.entries(s).reduce(
7295
+ (n, [c]) => (c in t && Object.assign(n, t[c]), n),
7296
+ {
7297
+ isVerified: !1,
7298
+ isChatOwner: !1,
7299
+ isChatSponsor: !1,
7300
+ isChatModerator: !1
7301
+ }
7302
+ );
7303
+ break;
7132
7304
  }
7133
- this.history.push(e);
7134
- const a = e.isPriority ? this.priorityQueue : this.queue;
7135
- e.isLoop && a.push(e);
7136
- }
7137
- resume() {
7138
- return this.running && this.cancel(), this.hasItems() && this.run(), this;
7139
- }
7140
- update(e) {
7141
- return this.queue = e.queue ?? this.queue, this.priorityQueue = e.priorityQueue ?? this.priorityQueue, this.history = e.history ?? this.history, this.hasItems() && this.running === !1 && window.client?.on("load", () => this.run()), this;
7142
- }
7143
- cancel() {
7144
- this.running && (this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts = [], this.running = !1, this.emit("cancel"));
7145
- }
7146
- hasItems() {
7147
- return this.queue.length > 0 || this.priorityQueue.length > 0;
7148
- }
7149
- on(e, a) {
7150
- return e === "load" && this.loaded ? (a.apply(this), this) : (super.on(e, a), this);
7151
7305
  }
7306
+ return i;
7152
7307
  }
7153
- class q {
7154
- field = "button";
7155
- template = "button";
7156
- run;
7157
- constructor(e) {
7158
- window.client instanceof J && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
7159
- }
7160
- parse(e, a) {
7161
- var c = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
7162
- try {
7163
- this.run.apply(window.client, [c.length ? c : e ?? e, a]);
7164
- } catch (r) {
7165
- throw new Error(`Error running button "${this.field}": ${r instanceof Error ? r.message : r}`);
7308
+ const Y = {
7309
+ getOverlayStatus: () => ({
7310
+ isEditorMode: !1,
7311
+ muted: !1
7312
+ }),
7313
+ resumeQueue: () => {
7314
+ },
7315
+ responses: {},
7316
+ sendMessage(s, e) {
7317
+ },
7318
+ counters: {
7319
+ get(s) {
7320
+ return null;
7166
7321
  }
7167
- return this;
7322
+ },
7323
+ sanitize(s) {
7324
+ return s;
7325
+ },
7326
+ cheerFilter(s) {
7327
+ return s;
7328
+ },
7329
+ setField(s, e, a) {
7330
+ },
7331
+ store: {
7332
+ set: function(s, e) {
7333
+ this.list[s] = e, localStorage.setItem("SE_API-STORE", JSON.stringify(Y.store.list));
7334
+ },
7335
+ get: async function(s) {
7336
+ return this.list[s] ? this.list[s] : null;
7337
+ },
7338
+ list: {}
7168
7339
  }
7169
- remove() {
7170
- if (!(window.client instanceof J)) return;
7171
- const e = window.client.actions.buttons.indexOf(this);
7172
- e > -1 && (window.client.actions.buttons.splice(e, 1), window.client.emit("action", this, "removed"));
7340
+ };
7341
+ async function ft() {
7342
+ let s = localStorage.getItem("SE_API-STORE") ?? "", e = s ? JSON.parse(s) : {};
7343
+ return Y.store.list = e, Y;
7344
+ }
7345
+ class bt extends O {
7346
+ instance;
7347
+ username;
7348
+ password;
7349
+ channels;
7350
+ isDebug = !1;
7351
+ init = !1;
7352
+ emulate = !1;
7353
+ /**
7354
+ * Initializes a new ComfyJS instance and connects to Twitch chat.
7355
+ * @param options - Configuration options for ComfyJS instance.
7356
+ * @param emulate - Whether to emulate chat messages in the Simulation module.
7357
+ */
7358
+ constructor(e, a) {
7359
+ super(), this.username = e.username, this.password = e.password, this.channels = e.channels, this.isDebug = !!e.isDebug, this.init = !!e.init, this.emulate = a, this.load().then((o) => {
7360
+ this.instance = o, this.emit("load", o), this.connect();
7361
+ }).catch((o) => {
7362
+ k.error("useComfyJs: Failed to load ComfyJS", o);
7363
+ });
7173
7364
  }
7174
- static execute(e, a) {
7175
- try {
7176
- if (!(window.client instanceof J)) return !1;
7177
- if (window.client.actions.buttons.length) {
7178
- const c = window.client.actions.buttons.filter((r) => typeof r.field == "string" ? r.field === e : typeof r.field == "function" ? r.field(e, a) : !1);
7179
- if (c.length && c.every((r) => r instanceof q))
7180
- return c.forEach((r) => {
7181
- try {
7182
- r.parse(e, a), window.client.emit("action", r, "executed"), w.received(`Button executed: ${e}${a ? ` with value: ${a}` : ""}`);
7183
- } catch (t) {
7184
- w.error(`Error executing button "${e}": ${t instanceof Error ? t.message : t}`);
7185
- }
7186
- }), !0;
7365
+ /**
7366
+ * Loads the ComfyJS script if not already loaded.
7367
+ * @returns A promise that resolves to the ComfyJS instance.
7368
+ */
7369
+ load() {
7370
+ return typeof window.ComfyJS < "u" && !window.ComfyJS ? new Promise((e, a) => {
7371
+ if (this.emulate && !client)
7372
+ return a(new Error("useComfyJs: Cannot emulate chat messages without a Client instance."));
7373
+ const o = document.createElement("script");
7374
+ o.src = "https://cdn.jsdelivr.net/npm/comfy.js@latest/dist/comfy.min.js", o.type = "text/javascript", o.async = !0, o.onload = () => e(window.ComfyJS), o.onerror = (i) => a(i), document.head.appendChild(o);
7375
+ }) : Promise.resolve(window.ComfyJS);
7376
+ }
7377
+ /**
7378
+ * Connects event handlers to the ComfyJS instance.
7379
+ */
7380
+ connect() {
7381
+ this.instance.onError = (e) => {
7382
+ this.emit("error", e), client.debug && k.error("[Client]", "ComfyJS Error:", e);
7383
+ }, this.instance.onCommand = (e, a, o, i, t) => {
7384
+ if (this.emit("command", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Command: !${a} ${o} (User: ${e})`), this.emulate) {
7385
+ const n = {
7386
+ ...i,
7387
+ broadcaster: i.broadcaster,
7388
+ moderator: i.mod,
7389
+ vip: i.vip,
7390
+ subscriber: i.subscriber,
7391
+ founder: i.founder
7392
+ }, c = {
7393
+ name: e,
7394
+ message: `!${a} ${o}`,
7395
+ badges: Object.entries(n).map(([r, d]) => d ? r : null).filter(Boolean),
7396
+ color: t.userColor,
7397
+ time: new Date(t.timestamp).getTime(),
7398
+ userId: t.userId,
7399
+ msgId: t.id,
7400
+ channel: t.channel
7401
+ };
7402
+ x.emulate.twitch.message(c);
7187
7403
  }
7188
- } catch {
7189
- return !1;
7190
- } finally {
7191
- return !1;
7192
- }
7404
+ }, this.instance.onChat = (e, a, o, i, t) => {
7405
+ if (this.emit("chat", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Chat: ${a} (User: ${e})`), this.emulate) {
7406
+ const n = {
7407
+ ...o,
7408
+ ...t.userBadges,
7409
+ broadcaster: o.broadcaster,
7410
+ moderator: o.mod,
7411
+ vip: o.vip,
7412
+ subscriber: o.subscriber,
7413
+ founder: o.founder
7414
+ };
7415
+ x.emulate.twitch.message({
7416
+ name: e,
7417
+ message: a,
7418
+ badges: Object.entries(n).map(([c, r]) => r ? c : null).filter(Boolean),
7419
+ color: t.userColor,
7420
+ time: new Date(t.timestamp).getTime(),
7421
+ userId: t.userId,
7422
+ msgId: t.id,
7423
+ channel: t.channel
7424
+ });
7425
+ }
7426
+ }, this.instance.onWhisper = (e, a, o, i, t) => {
7427
+ this.emit("whisper", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Whisper: ${a} (User: ${e})`);
7428
+ }, this.instance.onMessageDeleted = (e, a) => {
7429
+ this.emit("messageDeleted", e, a), client.debug && k.debug("[Client]", `ComfyJS Message Deleted: ${e}`), this.emulate && x.emulate.twitch.deleteMessage(e);
7430
+ }, this.instance.onJoin = (e, a, o) => {
7431
+ this.emit("join", e, a, o), client.debug && k.debug("[Client]", `ComfyJS Join: ${e}`);
7432
+ }, this.instance.onPart = (e, a, o) => {
7433
+ this.emit("part", e, a, o), client.debug && k.debug("[Client]", `ComfyJS Part: ${e}`);
7434
+ }, this.instance.onHosted = (e, a, o, i) => {
7435
+ this.emit("hosted", e, a, o, i), client.debug && k.debug("[Client]", `ComfyJS Hosted: ${e} (${a} viewers)`);
7436
+ }, this.instance.onRaid = (e, a, o) => {
7437
+ this.emit("raid", e, a, o), client.debug && k.debug("[Client]", `ComfyJS Raid: ${e} (${a} viewers)`), this.emulate && x.emulate.twitch.raid({
7438
+ name: e,
7439
+ amount: a
7440
+ });
7441
+ }, this.instance.onSub = (e, a, o, i) => {
7442
+ if (this.emit("sub", e, a, o, i), client.debug && k.debug("[Client]", `ComfyJS Sub: ${e} (${o.plan})`), this.emulate) {
7443
+ const t = o.plan === "Prime" ? "prime" : o.plan;
7444
+ x.emulate.twitch.subscriber({
7445
+ name: e,
7446
+ message: a,
7447
+ tier: t,
7448
+ subType: "default"
7449
+ });
7450
+ }
7451
+ }, this.instance.onResub = (e, a, o, i, t, n) => {
7452
+ if (this.emit("resub", e, a, o, i, t, n), client.debug && k.debug("[Client]", `ComfyJS Resub: ${e} (${i} months)`), this.emulate) {
7453
+ const c = t.plan === "Prime" ? "prime" : t.plan;
7454
+ x.emulate.twitch.subscriber({
7455
+ name: e,
7456
+ message: a,
7457
+ tier: c,
7458
+ amount: i,
7459
+ subType: "default"
7460
+ });
7461
+ }
7462
+ }, this.instance.onSubGift = (e, a, o, i, t, n) => {
7463
+ if (this.emit("subGift", e, a, o, i, t, n), client.debug && k.debug("[Client]", `ComfyJS Sub Gift: ${e} gifted ${i} subs`), this.emulate) {
7464
+ const c = t.plan === "Prime" ? "prime" : t.plan;
7465
+ x.emulate.twitch.subscriber({
7466
+ name: o,
7467
+ message: "",
7468
+ sender: e,
7469
+ tier: c,
7470
+ amount: i,
7471
+ subType: "gift"
7472
+ });
7473
+ }
7474
+ }, this.instance.onSubMysteryGift = (e, a, o, i, t) => {
7475
+ if (this.emit("subMysteryGift", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Sub Mystery Gift: ${e} gifted ${a} subs`), this.emulate) {
7476
+ const n = i.plan === "Prime" ? "prime" : i.plan;
7477
+ x.emulate.twitch.subscriber({
7478
+ name: e,
7479
+ message: "",
7480
+ amount: a,
7481
+ tier: n,
7482
+ subType: "community"
7483
+ });
7484
+ }
7485
+ }, this.instance.onGiftSubContinue = (e, a, o) => {
7486
+ this.emit("giftSubContinue", e, a, o), client.debug && k.debug("[Client]", `ComfyJS Gift Sub Continue: ${e} continued their gifted sub from ${a}`), this.emulate && x.emulate.twitch.subscriber({
7487
+ name: e,
7488
+ message: "",
7489
+ sender: a,
7490
+ tier: "1000",
7491
+ subType: "gift"
7492
+ });
7493
+ }, this.instance.onCheer = (e, a, o, i, t) => {
7494
+ this.emit("cheer", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Cheer: ${e} cheered ${o} bits - ${a}`), this.emulate && x.emulate.twitch.cheer({
7495
+ name: e,
7496
+ message: a,
7497
+ amount: o
7498
+ });
7499
+ }, this.instance.onChatMode = (e, a) => {
7500
+ this.emit("chatMode", e, a), client.debug && k.debug("[Client]", `ComfyJS Chat Mode Changed on ${a}`);
7501
+ }, this.instance.onReward = (e, a, o, i, t) => {
7502
+ this.emit("reward", e, a, o, i, t), client.debug && k.debug("[Client]", `ComfyJS Reward: ${e} redeemed ${a} for ${o} - ${i}`);
7503
+ }, this.instance.onConnected = (e, a, o) => {
7504
+ this.emit("connected", e, a, o), client.debug && k.debug("[Client]", `ComfyJS Connected: ${e}:${a} (First Connect: ${o})`);
7505
+ }, this.instance.onReconnect = (e) => {
7506
+ this.emit("reconnect", e), client.debug && k.debug("[Client]", `ComfyJS Reconnect: Attempt #${e}`);
7507
+ }, this.init && this.instance.Init(this.username, this.password, this.channels, this.isDebug);
7193
7508
  }
7194
7509
  }
7195
- class Q {
7510
+ class $ {
7196
7511
  enabled;
7197
7512
  prefix;
7198
7513
  error = this.apply({
@@ -7265,16 +7580,16 @@ class Q {
7265
7580
  this.enabled = e.enabled ?? !0, this.prefix = e.prefix ? `[${e.prefix}]` : "";
7266
7581
  }
7267
7582
  apply(e) {
7268
- const a = this.style(e), c = e.icon ? `${e.icon} ` : "";
7269
- return (...r) => {
7583
+ const a = this.style(e), o = e.icon ? `${e.icon} ` : "";
7584
+ return (...i) => {
7270
7585
  if (!this.enabled || typeof console > "u") return;
7271
- const t = this.prefix ? `${this.prefix} ` : "", s = [], n = [];
7272
- if (r.forEach((o) => {
7273
- typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? s.push(o) : n.push(o);
7274
- }), s.length > 0) {
7275
- const o = s.join(" ");
7276
- console.log(`%c${c}${t}${o}`, a, ...n);
7277
- } else n.length > 0 && console.log(`%c${c}${t}`, a, ...n);
7586
+ const t = this.prefix ? `${this.prefix} ` : "", n = [], c = [];
7587
+ if (i.forEach((r) => {
7588
+ typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? n.push(r) : c.push(r);
7589
+ }), n.length > 0) {
7590
+ const r = n.join(" ");
7591
+ console.log(`%c${o}${t}${r}`, a, ...c);
7592
+ } else c.length > 0 && console.log(`%c${o}${t}`, a, ...c);
7278
7593
  };
7279
7594
  }
7280
7595
  style(e) {
@@ -7300,215 +7615,35 @@ class Q {
7300
7615
  !this.enabled || !console.timeEnd || console.timeEnd(e);
7301
7616
  }
7302
7617
  }
7303
- window.addEventListener("load", () => {
7304
- });
7305
- window.addEventListener("onWidgetLoad", async (i) => {
7306
- const { detail: e } = i;
7307
- if (window.client instanceof J) {
7308
- const a = window.client;
7309
- a.fields = e.fieldData, a.session = e.session.data, a.details = {
7310
- ...a.details,
7311
- user: e.channel,
7312
- currency: e.currency,
7313
- overlay: e.overlay
7314
- }, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((c) => c.json()).then((c) => {
7315
- if (c.provider)
7316
- return a.details.provider = c.provider, c.provider;
7317
- a.details.provider = "local";
7318
- }).catch(() => {
7319
- a.details.provider = "local";
7320
- }) : a.details.provider = "local", a.emit("load", e), a.loaded = !0, a.storage.on("load", (c) => {
7321
- if (a.debug && c ? w.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, c) : a.debug && w.debug("[Client]", "Storage loaded for client", `"${a.id}";`, `Provider: "${a.details.provider}";`, "No data found."), c) {
7322
- const r = (h) => {
7323
- const u = Date.now(), m = {};
7324
- for (const g in h)
7325
- if (h.hasOwnProperty(g)) {
7326
- const b = h[g];
7327
- b.expire && b.expire > u && (m[g] = b);
7328
- }
7329
- return m;
7330
- }, t = r(c.user || {}), s = r(c.avatar || {}), n = r(c.pronoun || {}), o = r(c.emote || {});
7331
- a.storage.update({
7332
- user: t,
7333
- avatar: s,
7334
- pronoun: n,
7335
- emote: o
7336
- });
7337
- }
7338
- e.channel.providerId.length && a.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
7339
- value: e.channel.avatar,
7340
- timestamp: Date.now(),
7341
- expire: Date.now() + a.cache.avatar * 60 * 1e3
7342
- });
7343
- });
7344
- }
7345
- });
7346
- window.addEventListener("onSessionUpdate", (i) => {
7347
- const { detail: e } = i;
7348
- if (window.client instanceof J) {
7349
- const a = window.client;
7350
- a.session = e.session, a.emit("session", e.session), a.debug && w.debug("[Client]", "Session updated", e.session);
7351
- }
7352
- });
7353
- window.addEventListener("onEventReceived", ({ detail: i }) => {
7354
- if (window.client instanceof J) {
7355
- var e = i.event?.provider || i.event?.service || i.event?.data?.provider || window.client.details.provider;
7356
- ["kvstore:update", "bot:counter", "alertService:toggleSound", "event:skip", "tip-latest", "event:test"].some((s) => s === i.listener) && (e = "streamelements");
7357
- const r = { provider: e, data: i };
7358
- switch (r.provider) {
7359
- case "streamelements": {
7360
- const s = r.data;
7361
- switch (s.listener) {
7362
- case "tip-latest": {
7363
- s.event;
7364
- break;
7365
- }
7366
- case "event:skip": {
7367
- s.event;
7368
- break;
7369
- }
7370
- case "event:test": {
7371
- switch (s.event.listener) {
7372
- case "widget-button": {
7373
- const n = s.event;
7374
- q.execute(n.field, n.value);
7375
- break;
7376
- }
7377
- case "subscriber-latest": {
7378
- s.event;
7379
- break;
7380
- }
7381
- }
7382
- break;
7383
- }
7384
- case "kvstore:update": {
7385
- const n = s.event;
7386
- if (_.length) {
7387
- var a = _.find((o) => o.id === n.data.key.replace("customWidget.", ""));
7388
- a && a.update(n.data.value);
7389
- }
7390
- break;
7391
- }
7392
- case "bot:counter": {
7393
- s.event;
7394
- break;
7395
- }
7396
- case "alertService:toggleSound": {
7397
- const n = s.event;
7398
- client.details.overlay.muted = !!n.muted;
7399
- break;
7400
- }
7401
- }
7402
- window.client.emit("event", "streamelements", r.data);
7403
- break;
7404
- }
7405
- case "twitch": {
7406
- const s = r.data;
7407
- switch (s.listener) {
7408
- case "delete-message": {
7409
- s.event;
7410
- break;
7411
- }
7412
- case "delete-messages": {
7413
- s.event;
7414
- break;
7415
- }
7416
- case "message": {
7417
- s.event, R.execute({ provider: "twitch", data: s });
7418
- break;
7419
- }
7420
- case "follower-latest": {
7421
- s.event;
7422
- break;
7423
- }
7424
- case "cheer-latest": {
7425
- s.event;
7426
- break;
7427
- }
7428
- case "subscriber-latest": {
7429
- (!s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift || s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift || s.event.gifted && !s.event.bulkGifted && s.event.isCommunityGift || !s.event.gifted && s.event.bulkGifted && !s.event.isCommunityGift) && s.event;
7430
- break;
7431
- }
7432
- case "raid-latest": {
7433
- s.event;
7434
- break;
7435
- }
7436
- }
7437
- window.client.emit("event", "twitch", r.data);
7438
- break;
7439
- }
7440
- case "youtube": {
7441
- const s = r.data;
7442
- switch (s.listener) {
7443
- case "message": {
7444
- s.event, R.execute({ provider: "youtube", data: s });
7445
- break;
7446
- }
7447
- case "subscriber-latest": {
7448
- s.event;
7449
- break;
7450
- }
7451
- case "sponsor-latest": {
7452
- s.event, (!s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift || s.event.gifted && !s.event.bulkGifted && !s.event.isCommunityGift || s.event.gifted && !s.event.bulkGifted && s.event.isCommunityGift || !s.event.gifted && s.event.bulkGifted && !s.event.isCommunityGift) && s.event;
7453
- break;
7454
- }
7455
- case "superchat-latest": {
7456
- s.event;
7457
- break;
7458
- }
7459
- }
7460
- window.client.emit("event", "youtube", r.data);
7461
- break;
7462
- }
7463
- case "kick": {
7464
- window.client.emit("event", "kick", r.data);
7465
- break;
7466
- }
7467
- case "facebook": {
7468
- window.client.emit("event", "facebook", r.data);
7469
- break;
7470
- }
7471
- }
7472
- const t = [
7473
- "bot:counter",
7474
- "alertService:toggleSound",
7475
- "event",
7476
- "event:skip",
7477
- "event:test",
7478
- "kvstore:update"
7479
- ];
7480
- client.debug && !t.some((s) => s === r.data.listener) && w.received("[Client]", `Event ${r.data.listener} received`, e, r.data.event);
7481
- }
7482
- });
7483
- const Z = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(gt()), w = new Q(), bt = {
7618
+ const tt = typeof SE_API < "u" ? Promise.resolve(SE_API) : Promise.resolve(ft()), k = new $(), yt = {
7484
7619
  Client: J,
7485
- USE_SE_API: Z,
7486
- Simulation: C,
7487
- logger: w,
7620
+ USE_SE_API: tt,
7621
+ Simulation: x,
7622
+ logger: k,
7488
7623
  Alejo: W,
7489
7624
  utils: {
7490
7625
  findEmotesInText: F,
7491
7626
  replaceEmotesWithHTML: B,
7492
- replaceYoutubeEmotesWithHTML: ut,
7627
+ replaceYoutubeEmotesWithHTML: pt,
7493
7628
  generateBadges: K
7494
7629
  },
7495
7630
  modules: {
7496
- Button: q,
7631
+ Button: V,
7497
7632
  Command: R,
7498
7633
  EventProvider: O,
7499
- useComfyJs: pt,
7500
- useStorage: V,
7501
- useQueue: ft,
7502
- Logger: Q
7634
+ useComfyJs: bt,
7635
+ useStorage: S,
7636
+ useQueue: Q,
7637
+ Logger: $
7503
7638
  },
7504
7639
  data: {
7505
7640
  usedStorages: _
7506
7641
  }
7507
7642
  };
7508
- typeof window < "u" && (window.Tixyel = bt);
7643
+ typeof window < "u" && (window.Tixyel = yt);
7509
7644
  export {
7510
- bt as Tixyel,
7511
- Z as USE_SE_API,
7512
- w as logger
7645
+ yt as Tixyel,
7646
+ tt as USE_SE_API,
7647
+ k as logger
7513
7648
  };
7514
7649
  //# sourceMappingURL=index.es.js.map