liveroom-client-element 0.0.4 → 0.0.5

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.
@@ -27,7 +27,7 @@ function B(s, n) {
27
27
  function Ne(s, n, t) {
28
28
  const e = Le(s);
29
29
  if (!e.getElementById(n)) {
30
- const r = W("style");
30
+ const r = G("style");
31
31
  r.id = n, r.textContent = t, Re(e, r);
32
32
  }
33
33
  }
@@ -54,7 +54,7 @@ function Ct(s, n, t) {
54
54
  function pt(s) {
55
55
  s.parentNode && s.parentNode.removeChild(s);
56
56
  }
57
- function W(s) {
57
+ function G(s) {
58
58
  return document.createElement(s);
59
59
  }
60
60
  function Qt(s) {
@@ -105,10 +105,10 @@ function Ue(s) {
105
105
  }
106
106
  const tt = [], Mt = [];
107
107
  let et = [];
108
- const Kt = [], Je = /* @__PURE__ */ Promise.resolve();
108
+ const Kt = [], ze = /* @__PURE__ */ Promise.resolve();
109
109
  let Nt = !1;
110
- function Ve() {
111
- Nt || (Nt = !0, Je.then(bt));
110
+ function Je() {
111
+ Nt || (Nt = !0, ze.then(bt));
112
112
  }
113
113
  function Lt(s) {
114
114
  et.push(s);
@@ -123,7 +123,7 @@ function bt() {
123
123
  try {
124
124
  for (; K < tt.length; ) {
125
125
  const n = tt[K];
126
- K++, it(n), qe(n.$$);
126
+ K++, it(n), Ve(n.$$);
127
127
  }
128
128
  } catch (n) {
129
129
  throw tt.length = 0, K = 0, n;
@@ -140,7 +140,7 @@ function bt() {
140
140
  Kt.pop()();
141
141
  Nt = !1, xt.clear(), it(s);
142
142
  }
143
- function qe(s) {
143
+ function Ve(s) {
144
144
  if (s.fragment !== null) {
145
145
  s.update(), ut(s.before_update);
146
146
  const n = s.dirty;
@@ -158,27 +158,27 @@ function le(s, n) {
158
158
  function te(s) {
159
159
  return (s == null ? void 0 : s.length) !== void 0 ? s : Array.from(s);
160
160
  }
161
- function ze(s, n) {
161
+ function We(s, n) {
162
162
  s.d(1), n.delete(s.key);
163
163
  }
164
- function We(s, n, t, e, r, i, o, h, p, d, b, _) {
164
+ function Ge(s, n, t, e, r, i, o, h, p, d, b, _) {
165
165
  let A = s.length, T = i.length, j = A;
166
166
  const R = {};
167
167
  for (; j--; )
168
168
  R[s[j].key] = j;
169
- const N = [], k = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), dt = [];
169
+ const N = [], k = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), dt = [];
170
170
  for (j = T; j--; ) {
171
171
  const S = _(r, i, j), U = t(S);
172
- let J = o.get(U);
173
- J ? e && dt.push(() => J.p(S, n)) : (J = d(U, S), J.c()), k.set(U, N[j] = J), U in R && G.set(U, Math.abs(j - R[U]));
172
+ let z = o.get(U);
173
+ z ? e && dt.push(() => z.p(S, n)) : (z = d(U, S), z.c()), k.set(U, N[j] = z), U in R && X.set(U, Math.abs(j - R[U]));
174
174
  }
175
175
  const gt = /* @__PURE__ */ new Set(), vt = /* @__PURE__ */ new Set();
176
176
  function st(S) {
177
177
  le(S, 1), S.m(h, b), o.set(S.key, S), b = S.first, T--;
178
178
  }
179
179
  for (; A && T; ) {
180
- const S = N[T - 1], U = s[A - 1], J = S.key, X = U.key;
181
- S === U ? (b = S.first, A--, T--) : k.has(X) ? !o.has(J) || gt.has(J) ? st(S) : vt.has(X) ? A-- : G.get(J) > G.get(X) ? (vt.add(J), st(S)) : (gt.add(X), A--) : (p(U, o), A--);
180
+ const S = N[T - 1], U = s[A - 1], z = S.key, q = U.key;
181
+ S === U ? (b = S.first, A--, T--) : k.has(q) ? !o.has(z) || gt.has(z) ? st(S) : vt.has(q) ? A-- : X.get(z) > X.get(q) ? (vt.add(z), st(S)) : (gt.add(q), A--) : (p(U, o), A--);
182
182
  }
183
183
  for (; A--; ) {
184
184
  const S = s[A];
@@ -188,19 +188,19 @@ function We(s, n, t, e, r, i, o, h, p, d, b, _) {
188
188
  st(N[T - 1]);
189
189
  return ut(dt), N;
190
190
  }
191
- function Ge(s, n, t) {
191
+ function Xe(s, n, t) {
192
192
  const { fragment: e, after_update: r } = s.$$;
193
193
  e && e.m(n, t), Lt(() => {
194
194
  const i = s.$$.on_mount.map(oe).filter(ae);
195
195
  s.$$.on_destroy ? s.$$.on_destroy.push(...i) : ut(i), s.$$.on_mount = [];
196
196
  }), r.forEach(Lt);
197
197
  }
198
- function Xe(s, n) {
198
+ function qe(s, n) {
199
199
  const t = s.$$;
200
200
  t.fragment !== null && (Be(t.after_update), ut(t.on_destroy), t.fragment && t.fragment.d(n), t.on_destroy = t.fragment = null, t.ctx = []);
201
201
  }
202
202
  function Ye(s, n) {
203
- s.$$.dirty[0] === -1 && (tt.push(s), Ve(), s.$$.dirty.fill(0)), s.$$.dirty[n / 31 | 0] |= 1 << n % 31;
203
+ s.$$.dirty[0] === -1 && (tt.push(s), Je(), s.$$.dirty.fill(0)), s.$$.dirty[n / 31 | 0] |= 1 << n % 31;
204
204
  }
205
205
  function Ze(s, n, t, e, r, i, o, h = [-1]) {
206
206
  const p = ct;
@@ -237,7 +237,7 @@ function Ze(s, n, t, e, r, i, o, h = [-1]) {
237
237
  d.fragment && d.fragment.l(_), _.forEach(pt);
238
238
  } else
239
239
  d.fragment && d.fragment.c();
240
- n.intro && le(s.$$.fragment), Ge(s, n.target, n.anchor), bt();
240
+ n.intro && le(s.$$.fragment), Xe(s, n.target, n.anchor), bt();
241
241
  }
242
242
  it(p);
243
243
  }
@@ -285,7 +285,7 @@ typeof HTMLElement == "function" && (ue = class extends HTMLElement {
285
285
  let o;
286
286
  return {
287
287
  c: function() {
288
- o = W("slot"), i !== "default" && x(o, "name", i);
288
+ o = G("slot"), i !== "default" && x(o, "name", i);
289
289
  },
290
290
  /**
291
291
  * @param {HTMLElement} target
@@ -441,7 +441,7 @@ class Ke {
441
441
  }
442
442
  /** @returns {void} */
443
443
  $destroy() {
444
- Xe(this, 1), this.$destroy = ht;
444
+ qe(this, 1), this.$destroy = ht;
445
445
  }
446
446
  /**
447
447
  * @template {Extract<keyof Events, string>} K
@@ -1555,7 +1555,7 @@ class Us extends Dt {
1555
1555
  this.ops[i].encode(t, this);
1556
1556
  }
1557
1557
  }
1558
- class Js extends Dt {
1558
+ class zs extends Dt {
1559
1559
  constructor(t, e) {
1560
1560
  super(t, e);
1561
1561
  f(this, "ops");
@@ -1595,7 +1595,7 @@ class Js extends Dt {
1595
1595
  this.ops[i].encode(t, this);
1596
1596
  }
1597
1597
  }
1598
- class Vs extends P {
1598
+ class Js extends P {
1599
1599
  constructor(t, e, r, i) {
1600
1600
  super(t);
1601
1601
  f(this, "value");
@@ -1630,7 +1630,7 @@ class Vs extends P {
1630
1630
  t.encodeArrayHeader(r ? 4 : 3), t.writer.u8(35), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), r && t.writer.u8(1);
1631
1631
  }
1632
1632
  }
1633
- const { isArray: qs } = Array;
1633
+ const { isArray: Vs } = Array;
1634
1634
  class Bs extends P {
1635
1635
  constructor(t, e) {
1636
1636
  super(t);
@@ -1645,7 +1645,7 @@ class Bs extends P {
1645
1645
  }
1646
1646
  test(t) {
1647
1647
  const { val: e } = O(t, this.path);
1648
- return e === null ? this.value === "null" : qs(e) ? this.value === "array" : typeof e === this.value || typeof e == "number" && e === Math.round(e) && this.value === "integer";
1648
+ return e === null ? this.value === "null" : Vs(e) ? this.value === "array" : typeof e === this.value || typeof e == "number" && e === Math.round(e) && this.value === "integer";
1649
1649
  }
1650
1650
  toJson(t) {
1651
1651
  return {
@@ -1713,7 +1713,7 @@ const Fs = (s, n) => {
1713
1713
  case "starts":
1714
1714
  return new Rs(w(s.path), s.value, !!s.ignore_case);
1715
1715
  case "matches":
1716
- return new Vs(w(s.path), s.value, !!s.ignore_case, n.createMatcher || Es);
1716
+ return new Js(w(s.path), s.value, !!s.ignore_case, n.createMatcher || Es);
1717
1717
  case "in":
1718
1718
  return new Hs(w(s.path), s.value);
1719
1719
  case "less":
@@ -1730,13 +1730,13 @@ const Fs = (s, n) => {
1730
1730
  }
1731
1731
  case "not": {
1732
1732
  const t = w(s.path);
1733
- return new Js(t, s.apply.map((e) => _t({ ...e, path: [...t, ...w(e.path)] }, n)));
1733
+ return new zs(t, s.apply.map((e) => _t({ ...e, path: [...t, ...w(e.path)] }, n)));
1734
1734
  }
1735
1735
  default:
1736
1736
  throw new Error("OP_UNKNOWN");
1737
1737
  }
1738
1738
  };
1739
- function zs(s, n, t) {
1739
+ function Ws(s, n, t) {
1740
1740
  t.mutate || (s = lt(s));
1741
1741
  const e = [], r = n.length;
1742
1742
  for (let i = 0; i < r; i++) {
@@ -1747,7 +1747,7 @@ function zs(s, n, t) {
1747
1747
  }
1748
1748
  var ot = (s) => typeof s == "function" ? s : function() {
1749
1749
  return s;
1750
- }, Ws = typeof self < "u" ? self : null, rt = typeof window < "u" ? window : null, at = Ws || rt || at, Gs = "2.0.0", V = { connecting: 0, open: 1, closing: 2, closed: 3 }, Xs = 1e4, Ys = 1e3, I = {
1750
+ }, Gs = typeof self < "u" ? self : null, rt = typeof window < "u" ? window : null, at = Gs || rt || at, Xs = "2.0.0", J = { connecting: 0, open: 1, closing: 2, closed: 3 }, qs = 1e4, Ys = 1e3, I = {
1751
1751
  closed: "closed",
1752
1752
  errored: "errored",
1753
1753
  joined: "joined",
@@ -1972,7 +1972,7 @@ var ot = (s) => typeof s == "function" ? s : function() {
1972
1972
  }, this.onerror = function() {
1973
1973
  }, this.onmessage = function() {
1974
1974
  }, this.onclose = function() {
1975
- }, this.pollEndpoint = this.normalizeEndpoint(s), this.readyState = V.connecting, this.poll();
1975
+ }, this.pollEndpoint = this.normalizeEndpoint(s), this.readyState = J.connecting, this.poll();
1976
1976
  }
1977
1977
  normalizeEndpoint(s) {
1978
1978
  return s.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + Pt.websocket), "$1/" + Pt.longpoll);
@@ -1981,13 +1981,13 @@ var ot = (s) => typeof s == "function" ? s : function() {
1981
1981
  return $t.appendParams(this.pollEndpoint, { token: this.token });
1982
1982
  }
1983
1983
  closeAndRetry(s, n, t) {
1984
- this.close(s, n, t), this.readyState = V.connecting;
1984
+ this.close(s, n, t), this.readyState = J.connecting;
1985
1985
  }
1986
1986
  ontimeout() {
1987
1987
  this.onerror("timeout"), this.closeAndRetry(1005, "timeout", !1);
1988
1988
  }
1989
1989
  isActive() {
1990
- return this.readyState === V.open || this.readyState === V.connecting;
1990
+ return this.readyState === J.open || this.readyState === J.connecting;
1991
1991
  }
1992
1992
  poll() {
1993
1993
  this.ajax("GET", null, () => this.ontimeout(), (s) => {
@@ -2006,7 +2006,7 @@ var ot = (s) => typeof s == "function" ? s : function() {
2006
2006
  this.poll();
2007
2007
  break;
2008
2008
  case 410:
2009
- this.readyState = V.open, this.onopen({}), this.poll();
2009
+ this.readyState = J.open, this.onopen({}), this.poll();
2010
2010
  break;
2011
2011
  case 403:
2012
2012
  this.onerror(403), this.close(1008, "forbidden", !1);
@@ -2028,7 +2028,7 @@ var ot = (s) => typeof s == "function" ? s : function() {
2028
2028
  close(s, n, t) {
2029
2029
  for (let r of this.reqs)
2030
2030
  r.abort();
2031
- this.readyState = V.closed;
2031
+ this.readyState = J.closed;
2032
2032
  let e = Object.assign({ code: 1e3, reason: void 0, wasClean: !0 }, { code: s, reason: n, wasClean: t });
2033
2033
  typeof CloseEvent < "u" ? this.onclose(new CloseEvent("close", e)) : this.onclose(e);
2034
2034
  }
@@ -2109,13 +2109,13 @@ var ot = (s) => typeof s == "function" ? s : function() {
2109
2109
  }
2110
2110
  }, Ks = class {
2111
2111
  constructor(s, n = {}) {
2112
- this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.timeout = n.timeout || Xs, this.transport = n.transport || at.WebSocket || St, this.establishedConnections = 0, this.defaultEncoder = mt.encode.bind(mt), this.defaultDecoder = mt.decode.bind(mt), this.closeWasClean = !1, this.binaryType = n.binaryType || "arraybuffer", this.connectClock = 1, this.transport !== St ? (this.encode = n.encode || this.defaultEncoder, this.decode = n.decode || this.defaultDecoder) : (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder);
2112
+ this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.timeout = n.timeout || qs, this.transport = n.transport || at.WebSocket || St, this.establishedConnections = 0, this.defaultEncoder = mt.encode.bind(mt), this.defaultDecoder = mt.decode.bind(mt), this.closeWasClean = !1, this.binaryType = n.binaryType || "arraybuffer", this.connectClock = 1, this.transport !== St ? (this.encode = n.encode || this.defaultEncoder, this.decode = n.decode || this.defaultDecoder) : (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder);
2113
2113
  let t = null;
2114
2114
  rt && rt.addEventListener && (rt.addEventListener("pagehide", (e) => {
2115
2115
  this.conn && (this.disconnect(), t = this.connectClock);
2116
2116
  }), rt.addEventListener("pageshow", (e) => {
2117
2117
  t === this.connectClock && (t = null, this.connect());
2118
- })), this.heartbeatIntervalMs = n.heartbeatIntervalMs || 3e4, this.rejoinAfterMs = (e) => n.rejoinAfterMs ? n.rejoinAfterMs(e) : [1e3, 2e3, 5e3][e - 1] || 1e4, this.reconnectAfterMs = (e) => n.reconnectAfterMs ? n.reconnectAfterMs(e) : [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][e - 1] || 5e3, this.logger = n.logger || null, this.longpollerTimeout = n.longpollerTimeout || 2e4, this.params = ot(n.params || {}), this.endPoint = `${s}/${Pt.websocket}`, this.vsn = n.vsn || Gs, this.heartbeatTimeoutTimer = null, this.heartbeatTimer = null, this.pendingHeartbeatRef = null, this.reconnectTimer = new de(() => {
2118
+ })), this.heartbeatIntervalMs = n.heartbeatIntervalMs || 3e4, this.rejoinAfterMs = (e) => n.rejoinAfterMs ? n.rejoinAfterMs(e) : [1e3, 2e3, 5e3][e - 1] || 1e4, this.reconnectAfterMs = (e) => n.reconnectAfterMs ? n.reconnectAfterMs(e) : [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][e - 1] || 5e3, this.logger = n.logger || null, this.longpollerTimeout = n.longpollerTimeout || 2e4, this.params = ot(n.params || {}), this.endPoint = `${s}/${Pt.websocket}`, this.vsn = n.vsn || Xs, this.heartbeatTimeoutTimer = null, this.heartbeatTimer = null, this.pendingHeartbeatRef = null, this.reconnectTimer = new de(() => {
2119
2119
  this.teardown(() => this.connect());
2120
2120
  }, this.reconnectAfterMs);
2121
2121
  }
@@ -2205,7 +2205,7 @@ var ot = (s) => typeof s == "function" ? s : function() {
2205
2205
  }, 150 * n);
2206
2206
  }
2207
2207
  waitForSocketClosed(s, n = 1) {
2208
- if (n === 5 || !this.conn || this.conn.readyState === V.closed) {
2208
+ if (n === 5 || !this.conn || this.conn.readyState === J.closed) {
2209
2209
  s();
2210
2210
  return;
2211
2211
  }
@@ -2231,11 +2231,11 @@ var ot = (s) => typeof s == "function" ? s : function() {
2231
2231
  }
2232
2232
  connectionState() {
2233
2233
  switch (this.conn && this.conn.readyState) {
2234
- case V.connecting:
2234
+ case J.connecting:
2235
2235
  return "connecting";
2236
- case V.open:
2236
+ case J.open:
2237
2237
  return "open";
2238
- case V.closing:
2238
+ case J.closing:
2239
2239
  return "closing";
2240
2240
  default:
2241
2241
  return "closed";
@@ -2350,7 +2350,7 @@ class tn {
2350
2350
  if (this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch", {
2351
2351
  detail: { patch: n, version: t }
2352
2352
  })), t === this.stateVersion + 1) {
2353
- const { doc: e, res: r } = zs(this.state, n, { mutate: !1 });
2353
+ const { doc: e, res: r } = Ws(this.state, n, { mutate: !1 });
2354
2354
  this.state = e, this.stateVersion = t, this.eventTarget.dispatchEvent(new CustomEvent("livestate-change", {
2355
2355
  detail: {
2356
2356
  state: this.state,
@@ -2422,19 +2422,19 @@ var se;
2422
2422
  }, b = Object.getPrototypeOf(Function), _ = typeof process == "object" && process.env && process.env.REFLECT_METADATA_USE_MAP_POLYFILL === "true", A = !_ && typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : Ae(), T = !_ && typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Te(), j = !_ && typeof WeakMap == "function" ? WeakMap : Oe(), R = new j();
2423
2423
  function N(a, c, l, u) {
2424
2424
  if (M(l)) {
2425
- if (!Wt(a))
2425
+ if (!Gt(a))
2426
2426
  throw new TypeError();
2427
- if (!Gt(c))
2427
+ if (!Xt(c))
2428
2428
  throw new TypeError();
2429
- return X(a, c);
2429
+ return q(a, c);
2430
2430
  } else {
2431
- if (!Wt(a))
2431
+ if (!Gt(a))
2432
2432
  throw new TypeError();
2433
2433
  if (!L(c))
2434
2434
  throw new TypeError();
2435
2435
  if (!L(u) && !M(u) && !Y(u))
2436
2436
  throw new TypeError();
2437
- return Y(u) && (u = void 0), l = q(l), ge(a, c, l, u);
2437
+ return Y(u) && (u = void 0), l = V(l), ge(a, c, l, u);
2438
2438
  }
2439
2439
  }
2440
2440
  n("decorate", N);
@@ -2444,57 +2444,57 @@ var se;
2444
2444
  throw new TypeError();
2445
2445
  if (!M(g) && !be(g))
2446
2446
  throw new TypeError();
2447
- qt(a, c, u, g);
2447
+ Vt(a, c, u, g);
2448
2448
  }
2449
2449
  return l;
2450
2450
  }
2451
2451
  n("metadata", k);
2452
- function G(a, c, l, u) {
2452
+ function X(a, c, l, u) {
2453
2453
  if (!L(l))
2454
2454
  throw new TypeError();
2455
- return M(u) || (u = q(u)), qt(a, c, l, u);
2455
+ return M(u) || (u = V(u)), Vt(a, c, l, u);
2456
2456
  }
2457
- n("defineMetadata", G);
2457
+ n("defineMetadata", X);
2458
2458
  function dt(a, c, l) {
2459
2459
  if (!L(c))
2460
2460
  throw new TypeError();
2461
- return M(l) || (l = q(l)), Ut(a, c, l);
2461
+ return M(l) || (l = V(l)), Ut(a, c, l);
2462
2462
  }
2463
2463
  n("hasMetadata", dt);
2464
2464
  function gt(a, c, l) {
2465
2465
  if (!L(c))
2466
2466
  throw new TypeError();
2467
- return M(l) || (l = q(l)), At(a, c, l);
2467
+ return M(l) || (l = V(l)), At(a, c, l);
2468
2468
  }
2469
2469
  n("hasOwnMetadata", gt);
2470
2470
  function vt(a, c, l) {
2471
2471
  if (!L(c))
2472
2472
  throw new TypeError();
2473
- return M(l) || (l = q(l)), Jt(a, c, l);
2473
+ return M(l) || (l = V(l)), zt(a, c, l);
2474
2474
  }
2475
2475
  n("getMetadata", vt);
2476
2476
  function st(a, c, l) {
2477
2477
  if (!L(c))
2478
2478
  throw new TypeError();
2479
- return M(l) || (l = q(l)), Vt(a, c, l);
2479
+ return M(l) || (l = V(l)), Jt(a, c, l);
2480
2480
  }
2481
2481
  n("getOwnMetadata", st);
2482
2482
  function S(a, c) {
2483
2483
  if (!L(a))
2484
2484
  throw new TypeError();
2485
- return M(c) || (c = q(c)), Bt(a, c);
2485
+ return M(c) || (c = V(c)), Bt(a, c);
2486
2486
  }
2487
2487
  n("getMetadataKeys", S);
2488
2488
  function U(a, c) {
2489
2489
  if (!L(a))
2490
2490
  throw new TypeError();
2491
- return M(c) || (c = q(c)), Ft(a, c);
2491
+ return M(c) || (c = V(c)), Ft(a, c);
2492
2492
  }
2493
2493
  n("getOwnMetadataKeys", U);
2494
- function J(a, c, l) {
2494
+ function z(a, c, l) {
2495
2495
  if (!L(c))
2496
2496
  throw new TypeError();
2497
- M(l) || (l = q(l));
2497
+ M(l) || (l = V(l));
2498
2498
  var u = nt(
2499
2499
  c,
2500
2500
  l,
@@ -2508,12 +2508,12 @@ var se;
2508
2508
  var g = R.get(c);
2509
2509
  return g.delete(l), g.size > 0 || R.delete(c), !0;
2510
2510
  }
2511
- n("deleteMetadata", J);
2512
- function X(a, c) {
2511
+ n("deleteMetadata", z);
2512
+ function q(a, c) {
2513
2513
  for (var l = a.length - 1; l >= 0; --l) {
2514
2514
  var u = a[l], g = u(c);
2515
2515
  if (!M(g) && !Y(g)) {
2516
- if (!Gt(g))
2516
+ if (!Xt(g))
2517
2517
  throw new TypeError();
2518
2518
  c = g;
2519
2519
  }
@@ -2562,15 +2562,15 @@ var se;
2562
2562
  );
2563
2563
  return M(u) ? !1 : we(u.has(a));
2564
2564
  }
2565
- function Jt(a, c, l) {
2565
+ function zt(a, c, l) {
2566
2566
  var u = At(a, c, l);
2567
2567
  if (u)
2568
- return Vt(a, c, l);
2568
+ return Jt(a, c, l);
2569
2569
  var g = Tt(c);
2570
2570
  if (!Y(g))
2571
- return Jt(a, g, l);
2571
+ return zt(a, g, l);
2572
2572
  }
2573
- function Vt(a, c, l) {
2573
+ function Jt(a, c, l) {
2574
2574
  var u = nt(
2575
2575
  c,
2576
2576
  l,
@@ -2580,7 +2580,7 @@ var se;
2580
2580
  if (!M(u))
2581
2581
  return u.get(a);
2582
2582
  }
2583
- function qt(a, c, l, u) {
2583
+ function Vt(a, c, l, u) {
2584
2584
  var g = nt(
2585
2585
  l,
2586
2586
  u,
@@ -2602,8 +2602,8 @@ var se;
2602
2602
  var E = v[m], $ = H.has(E);
2603
2603
  $ || (H.add(E), y.push(E));
2604
2604
  }
2605
- for (var z = 0, Yt = g; z < Yt.length; z++) {
2606
- var E = Yt[z], $ = H.has(E);
2605
+ for (var W = 0, Yt = g; W < Yt.length; W++) {
2606
+ var E = Yt[W], $ = H.has(E);
2607
2607
  $ || (H.add(E), y.push(E));
2608
2608
  }
2609
2609
  return y;
@@ -2634,7 +2634,7 @@ var se;
2634
2634
  y++;
2635
2635
  }
2636
2636
  }
2637
- function zt(a) {
2637
+ function Wt(a) {
2638
2638
  if (a === null)
2639
2639
  return 1;
2640
2640
  switch (typeof a) {
@@ -2667,7 +2667,7 @@ var se;
2667
2667
  return typeof a == "object" ? a !== null : typeof a == "function";
2668
2668
  }
2669
2669
  function ye(a, c) {
2670
- switch (zt(a)) {
2670
+ switch (Wt(a)) {
2671
2671
  case 0:
2672
2672
  return a;
2673
2673
  case 1:
@@ -2681,7 +2681,7 @@ var se;
2681
2681
  case 5:
2682
2682
  return a;
2683
2683
  }
2684
- var l = c === 3 ? "string" : c === 5 ? "number" : "default", u = Xt(a, r);
2684
+ var l = c === 3 ? "string" : c === 5 ? "number" : "default", u = qt(a, r);
2685
2685
  if (u !== void 0) {
2686
2686
  var g = u.call(a, l);
2687
2687
  if (L(g))
@@ -2726,7 +2726,7 @@ var se;
2726
2726
  function _e(a) {
2727
2727
  return "" + a;
2728
2728
  }
2729
- function q(a) {
2729
+ function V(a) {
2730
2730
  var c = ye(
2731
2731
  a,
2732
2732
  3
@@ -2734,17 +2734,17 @@ var se;
2734
2734
  );
2735
2735
  return ve(c) ? c : _e(c);
2736
2736
  }
2737
- function Wt(a) {
2737
+ function Gt(a) {
2738
2738
  return Array.isArray ? Array.isArray(a) : a instanceof Object ? a instanceof Array : Object.prototype.toString.call(a) === "[object Array]";
2739
2739
  }
2740
2740
  function Z(a) {
2741
2741
  return typeof a == "function";
2742
2742
  }
2743
- function Gt(a) {
2743
+ function Xt(a) {
2744
2744
  return typeof a == "function";
2745
2745
  }
2746
2746
  function be(a) {
2747
- switch (zt(a)) {
2747
+ switch (Wt(a)) {
2748
2748
  case 3:
2749
2749
  return !0;
2750
2750
  case 4:
@@ -2753,7 +2753,7 @@ var se;
2753
2753
  return !1;
2754
2754
  }
2755
2755
  }
2756
- function Xt(a, c) {
2756
+ function qt(a, c) {
2757
2757
  var l = a[c];
2758
2758
  if (l != null) {
2759
2759
  if (!Z(l))
@@ -2762,7 +2762,7 @@ var se;
2762
2762
  }
2763
2763
  }
2764
2764
  function Ee(a) {
2765
- var c = Xt(a, i);
2765
+ var c = qt(a, i);
2766
2766
  if (!Z(c))
2767
2767
  throw new TypeError();
2768
2768
  var l = c.call(a);
@@ -2945,12 +2945,12 @@ var se;
2945
2945
  );
2946
2946
  return $ !== void 0 ? d.get($, this._key) : void 0;
2947
2947
  }, v.prototype.set = function(E, $) {
2948
- var z = g(
2948
+ var W = g(
2949
2949
  E,
2950
2950
  /*create*/
2951
2951
  !0
2952
2952
  );
2953
- return z[this._key] = $, this;
2953
+ return W[this._key] = $, this;
2954
2954
  }, v.prototype.delete = function(E) {
2955
2955
  var $ = g(
2956
2956
  E,
@@ -2990,8 +2990,8 @@ var se;
2990
2990
  var v = y(a);
2991
2991
  v[6] = v[6] & 79 | 64, v[8] = v[8] & 191 | 128;
2992
2992
  for (var E = "", $ = 0; $ < a; ++$) {
2993
- var z = v[$];
2994
- ($ === 4 || $ === 6 || $ === 8) && (E += "-"), z < 16 && (E += "0"), E += z.toString(16).toLowerCase();
2993
+ var W = v[$];
2994
+ ($ === 4 || $ === 6 || $ === 8) && (E += "-"), W < 16 && (E += "0"), E += W.toString(16).toLowerCase();
2995
2995
  }
2996
2996
  return E;
2997
2997
  }
@@ -3002,7 +3002,7 @@ var se;
3002
3002
  });
3003
3003
  })(se || (se = {}));
3004
3004
  function en(s) {
3005
- Ne(s, "svelte-w16tqa", "#liveroom-client-element.svelte-w16tqa.svelte-w16tqa{font-family:Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;line-height:1.5;font-weight:400;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}#users-container.svelte-w16tqa.svelte-w16tqa{position:absolute;inset:0;overflow:hidden;pointer-events:none}.user.svelte-w16tqa.svelte-w16tqa{z-index:1000;position:absolute;top:0;left:0;user-select:none;transform:translate(var(--x), var(--y))}.user.svelte-w16tqa .cursor.svelte-w16tqa{position:absolute;top:0;left:0;color:var(--color);transform-origin:top left;transform:rotate(6deg)}.user[data-isself='true'].svelte-w16tqa .cursor.svelte-w16tqa{display:none}.user-name.svelte-w16tqa.svelte-w16tqa{padding:4px 10px;font-size:14px;line-height:20px;font-weight:600;color:black;background-color:var(--color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:9999px;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-w16tqa .user-name.svelte-w16tqa{position:absolute;top:20px;left:16px}.user[data-isself='true'].svelte-w16tqa .user-name.svelte-w16tqa{display:none}.user.svelte-w16tqa .halo.svelte-w16tqa{transform:scale(0);z-index:-1;position:absolute;top:-60px;left:-60px;width:120px;height:120px;border-radius:9999px;background-color:var(--color);opacity:0.25;transition:transform 0.15s ease-out;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-w16tqa .halo[data-show='true'].svelte-w16tqa{transform:scale(1)}");
3005
+ Ne(s, "svelte-or6zbb", '#liveroom-client-element.svelte-or6zbb.svelte-or6zbb{font-family:Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;line-height:1.5;font-weight:400;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}#users-container.svelte-or6zbb.svelte-or6zbb{position:fixed;inset:0;overflow:hidden;pointer-events:none}.user.svelte-or6zbb.svelte-or6zbb{z-index:1000;position:absolute;top:0;left:0;user-select:none;transform:translate(var(--x), var(--y))}.user.svelte-or6zbb .cursor.svelte-or6zbb{position:absolute;top:0;left:0;color:var(--color);transform-origin:top left;transform:rotate(6deg)}.user[data-isself="true"].svelte-or6zbb .cursor.svelte-or6zbb{display:none}.user-name.svelte-or6zbb.svelte-or6zbb{padding:4px 10px;font-size:14px;line-height:20px;font-weight:600;color:black;background-color:var(--color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:9999px;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-or6zbb .user-name.svelte-or6zbb{position:absolute;top:20px;left:16px}.user[data-isself="true"].svelte-or6zbb .user-name.svelte-or6zbb{display:none}.user.svelte-or6zbb .halo.svelte-or6zbb{transform:scale(0);z-index:-1;position:absolute;top:-60px;left:-60px;width:120px;height:120px;border-radius:9999px;background-color:var(--color);opacity:0.25;transition:transform 0.15s ease-out;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-or6zbb .halo[data-show="true"].svelte-or6zbb{transform:scale(1)}');
3006
3006
  }
3007
3007
  function ne(s, n, t) {
3008
3008
  const e = s.slice();
@@ -3023,10 +3023,10 @@ function re(s) {
3023
3023
  }
3024
3024
  return {
3025
3025
  c() {
3026
- n = W("div");
3026
+ n = G("div");
3027
3027
  for (let o = 0; o < t.length; o += 1)
3028
3028
  t[o].c();
3029
- x(n, "id", "users-container"), x(n, "class", "svelte-w16tqa");
3029
+ x(n, "id", "users-container"), x(n, "class", "svelte-or6zbb");
3030
3030
  },
3031
3031
  m(o, h) {
3032
3032
  Ct(o, n, h);
@@ -3038,7 +3038,7 @@ function re(s) {
3038
3038
  6 && (r = te(Object.values(
3039
3039
  /*users*/
3040
3040
  o[2]
3041
- )), t = We(t, h, i, 1, o, r, e, n, ze, ie, null, ne));
3041
+ )), t = Ge(t, h, i, 1, o, r, e, n, We, ie, null, ne));
3042
3042
  },
3043
3043
  d(o) {
3044
3044
  o && pt(n);
@@ -3056,10 +3056,10 @@ function ie(s, n) {
3056
3056
  key: s,
3057
3057
  first: null,
3058
3058
  c() {
3059
- t = W("div"), e = Qt("svg"), r = Qt("path"), i = jt(), o = W("span"), p = he(h), d = jt(), b = W("div"), A = jt(), x(r, "d", "M2.2706 0.0593359L25.4277 8.05957H25.45926C25.65896 8.13153 25.83096 8.25952 25.95221 8.42653C26.07357 8.59354 26.13851 8.79166 26.13851 8.99459C26.13851 9.19751 26.07357 9.39564 25.95221 9.56265C25.83096 9.72966 25.65896 9.85765 25.45926 9.92962L15.3543 13.7698L11.3124 23.37C11.2344 23.5561 11.0994 23.7156 10.9248 23.828C10.7503 23.9402 10.5443 24.0002 10.3335 24C10.1172 24 9.9061 23.9365 9.7291 23.8184C9.552 23.7004 9.4176 23.5332 9.344 23.34L0.9233 1.33937C0.8555 1.16076 0.8426 0.967504 0.8861 0.782189C0.9297 0.596873 1.0278 0.427163 1.1691 0.292901C1.3105 0.158639 1.4891 0.0653762 1.6841 0.0240151C1.8792 -0.0173461 2.0826 -0.00509504 2.2706 0.0593359Z"), x(e, "width", "23"), x(e, "viewBox", "0 0 27 24"), x(e, "fill", "currentColor"), x(e, "aria-hidden", "true"), x(e, "xmlns", "http://www.w3.org/2000/svg"), x(e, "class", "cursor svelte-w16tqa"), x(o, "class", "user-name svelte-w16tqa"), x(b, "class", "halo svelte-w16tqa"), x(b, "data-show", _ = /*user*/
3059
+ t = G("div"), e = Qt("svg"), r = Qt("path"), i = jt(), o = G("span"), p = he(h), d = jt(), b = G("div"), A = jt(), x(r, "d", "M2.2706 0.0593359L25.4277 8.05957H25.45926C25.65896 8.13153 25.83096 8.25952 25.95221 8.42653C26.07357 8.59354 26.13851 8.79166 26.13851 8.99459C26.13851 9.19751 26.07357 9.39564 25.95221 9.56265C25.83096 9.72966 25.65896 9.85765 25.45926 9.92962L15.3543 13.7698L11.3124 23.37C11.2344 23.5561 11.0994 23.7156 10.9248 23.828C10.7503 23.9402 10.5443 24.0002 10.3335 24C10.1172 24 9.9061 23.9365 9.7291 23.8184C9.552 23.7004 9.4176 23.5332 9.344 23.34L0.9233 1.33937C0.8555 1.16076 0.8426 0.967504 0.8861 0.782189C0.9297 0.596873 1.0278 0.427163 1.1691 0.292901C1.3105 0.158639 1.4891 0.0653762 1.6841 0.0240151C1.8792 -0.0173461 2.0826 -0.00509504 2.2706 0.0593359Z"), x(e, "width", "23"), x(e, "viewBox", "0 0 27 24"), x(e, "fill", "currentColor"), x(e, "aria-hidden", "true"), x(e, "xmlns", "http://www.w3.org/2000/svg"), x(e, "class", "cursor svelte-or6zbb"), x(o, "class", "user-name svelte-or6zbb"), x(b, "class", "halo svelte-or6zbb"), x(b, "data-show", _ = /*user*/
3060
3060
  n[14].is_mouse_down || /*user*/
3061
3061
  n[14].is_escape_key_down), x(t, "id", T = "user-" + /*user*/
3062
- n[14].id), x(t, "class", "user svelte-w16tqa"), x(t, "data-isself", j = /*user*/
3062
+ n[14].id), x(t, "class", "user svelte-or6zbb"), x(t, "data-isself", j = /*user*/
3063
3063
  n[14].id == /*me*/
3064
3064
  n[1].id), Q(
3065
3065
  t,
@@ -3117,7 +3117,7 @@ function sn(s) {
3117
3117
  );
3118
3118
  return {
3119
3119
  c() {
3120
- n = W("div"), t && t.c(), x(n, "id", "liveroom-client-element"), x(n, "class", "svelte-w16tqa");
3120
+ n = G("div"), t && t.c(), x(n, "id", "liveroom-client-element"), x(n, "class", "svelte-or6zbb");
3121
3121
  },
3122
3122
  m(e, r) {
3123
3123
  Ct(e, n, r), t && t.m(n, null), s[5](n);
@@ -3158,9 +3158,9 @@ function nn(s, n, t) {
3158
3158
  {
3159
3159
  detail: {
3160
3160
  user_id: h.id,
3161
- x: Number(k.pageX / window.innerWidth * 100).toFixed(2),
3161
+ x: Number(k.clientX / window.innerWidth * 100).toFixed(2),
3162
3162
  // in %
3163
- y: Number(k.pageY / window.innerHeight * 100).toFixed(2)
3163
+ y: Number(k.clientY / window.innerHeight * 100).toFixed(2)
3164
3164
  }
3165
3165
  // in %
3166
3166
  }
@@ -1,4 +1,4 @@
1
- (function(P,D){typeof exports=="object"&&typeof module<"u"?module.exports=D():typeof define=="function"&&define.amd?define(D):(P=typeof globalThis<"u"?globalThis:P||self,P.LiveroomClientElement=D())})(this,function(){"use strict";var nn=Object.defineProperty;var rn=(P,D,G)=>D in P?nn(P,D,{enumerable:!0,configurable:!0,writable:!0,value:G}):P[D]=G;var f=(P,D,G)=>(rn(P,typeof D!="symbol"?D+"":D,G),G);function P(){}function D(s){return s()}function G(){return Object.create(null)}function it(s){s.forEach(D)}function Vt(s){return typeof s=="function"}function ve(s,n){return s!=s?n==n:s!==n||s&&typeof s=="object"||typeof s=="function"}function ye(s){return Object.keys(s).length===0}function F(s,n){s.appendChild(n)}function me(s,n,t){const e=we(s);if(!e.getElementById(n)){const r=Y("style");r.id=n,r.textContent=t,_e(e,r)}}function we(s){if(!s)return document;const n=s.getRootNode?s.getRootNode():s.ownerDocument;return n&&n.host?n:s.ownerDocument}function _e(s,n){return F(s.head||s,n),n.sheet}function vt(s,n,t){s.insertBefore(n,t||null)}function ot(s){s.parentNode&&s.parentNode.removeChild(s)}function Y(s){return document.createElement(s)}function qt(s){return document.createElementNS("http://www.w3.org/2000/svg",s)}function Bt(s){return document.createTextNode(s)}function Ot(){return Bt(" ")}function j(s,n,t){t==null?s.removeAttribute(n):s.getAttribute(n)!==t&&s.setAttribute(n,t)}function be(s){return Array.from(s.childNodes)}function Ee(s,n){n=""+n,s.data!==n&&(s.data=n)}function Z(s,n,t,e){t==null?s.style.removeProperty(n):s.style.setProperty(n,t,e?"important":"")}function $e(s){const n={};return s.childNodes.forEach(t=>{n[t.slot||"default"]=!0}),n}let at;function ht(s){at=s}function Ft(){if(!at)throw new Error("Function called outside component initialization");return at}function Ce(s){Ft().$$.on_mount.push(s)}function ke(s){Ft().$$.on_destroy.push(s)}const Q=[],jt=[];let K=[];const zt=[],Ae=Promise.resolve();let xt=!1;function Te(){xt||(xt=!0,Ae.then(yt))}function St(s){K.push(s)}const Mt=new Set;let tt=0;function yt(){if(tt!==0)return;const s=at;do{try{for(;tt<Q.length;){const n=Q[tt];tt++,ht(n),Oe(n.$$)}}catch(n){throw Q.length=0,tt=0,n}for(ht(null),Q.length=0,tt=0;jt.length;)jt.pop()();for(let n=0;n<K.length;n+=1){const t=K[n];Mt.has(t)||(Mt.add(t),t())}K.length=0}while(Q.length);for(;zt.length;)zt.pop()();xt=!1,Mt.clear(),ht(s)}function Oe(s){if(s.fragment!==null){s.update(),it(s.before_update);const n=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,n),s.after_update.forEach(St)}}function je(s){const n=[],t=[];K.forEach(e=>s.indexOf(e)===-1?n.push(e):t.push(e)),t.forEach(e=>e()),K=n}const xe=new Set;function Wt(s,n){s&&s.i&&(xe.delete(s),s.i(n))}function Gt(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function Se(s,n){s.d(1),n.delete(s.key)}function Me(s,n,t,e,r,i,o,h,p,d,b,_){let A=s.length,O=i.length,x=A;const R={};for(;x--;)R[s[x].key]=x;const L=[],k=new Map,et=new Map,kt=[];for(x=O;x--;){const S=_(r,i,x),V=t(S);let q=o.get(V);q?e&&kt.push(()=>q.p(S,n)):(q=d(V,S),q.c()),k.set(V,L[x]=q),V in R&&et.set(V,Math.abs(x-R[V]))}const At=new Set,Tt=new Set;function dt(S){Wt(S,1),S.m(h,b),o.set(S.key,S),b=S.first,O--}for(;A&&O;){const S=L[O-1],V=s[A-1],q=S.key,st=V.key;S===V?(b=S.first,A--,O--):k.has(st)?!o.has(q)||At.has(q)?dt(S):Tt.has(st)?A--:et.get(q)>et.get(st)?(Tt.add(q),dt(S)):(At.add(st),A--):(p(V,o),A--)}for(;A--;){const S=s[A];k.has(S.key)||p(S,o)}for(;O;)dt(L[O-1]);return it(kt),L}function Le(s,n,t){const{fragment:e,after_update:r}=s.$$;e&&e.m(n,t),St(()=>{const i=s.$$.on_mount.map(D).filter(Vt);s.$$.on_destroy?s.$$.on_destroy.push(...i):it(i),s.$$.on_mount=[]}),r.forEach(St)}function Ne(s,n){const t=s.$$;t.fragment!==null&&(je(t.after_update),it(t.on_destroy),t.fragment&&t.fragment.d(n),t.on_destroy=t.fragment=null,t.ctx=[])}function Re(s,n){s.$$.dirty[0]===-1&&(Q.push(s),Te(),s.$$.dirty.fill(0)),s.$$.dirty[n/31|0]|=1<<n%31}function He(s,n,t,e,r,i,o,h=[-1]){const p=at;ht(s);const d=s.$$={fragment:null,ctx:[],props:i,update:P,not_equal:r,bound:G(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(n.context||(p?p.$$.context:[])),callbacks:G(),dirty:h,skip_bound:!1,root:n.target||p.$$.root};o&&o(d.root);let b=!1;if(d.ctx=t?t(s,n.props||{},(_,A,...O)=>{const x=O.length?O[0]:A;return d.ctx&&r(d.ctx[_],d.ctx[_]=x)&&(!d.skip_bound&&d.bound[_]&&d.bound[_](x),b&&Re(s,_)),A}):[],d.update(),b=!0,it(d.before_update),d.fragment=e?e(d.ctx):!1,n.target){if(n.hydrate){const _=be(n.target);d.fragment&&d.fragment.l(_),_.forEach(ot)}else d.fragment&&d.fragment.c();n.intro&&Wt(s.$$.fragment),Le(s,n.target,n.anchor),yt()}ht(p)}let Xt;typeof HTMLElement=="function"&&(Xt=class extends HTMLElement{constructor(n,t,e){super();f(this,"$$ctor");f(this,"$$s");f(this,"$$c");f(this,"$$cn",!1);f(this,"$$d",{});f(this,"$$r",!1);f(this,"$$p_d",{});f(this,"$$l",{});f(this,"$$l_u",new Map);this.$$ctor=n,this.$$s=t,e&&this.attachShadow({mode:"open"})}addEventListener(n,t,e){if(this.$$l[n]=this.$$l[n]||[],this.$$l[n].push(t),this.$$c){const r=this.$$c.$on(n,t);this.$$l_u.set(t,r)}super.addEventListener(n,t,e)}removeEventListener(n,t,e){if(super.removeEventListener(n,t,e),this.$$c){const r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let n=function(i){return()=>{let o;return{c:function(){o=Y("slot"),i!=="default"&&j(o,"name",i)},m:function(d,b){vt(d,o,b)},d:function(d){d&&ot(o)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},e=$e(this);for(const i of this.$$s)i in e&&(t[i]=[n(i)]);for(const i of this.attributes){const o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=mt(o,i.value,this.$$p_d,"toProp"))}this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const r=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const o=mt(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1};this.$$c.$$.after_update.push(r),r();for(const i in this.$$l)for(const o of this.$$l[i]){const h=this.$$c.$on(i,o);this.$$l_u.set(o,h)}this.$$l={}}}attributeChangedCallback(n,t,e){var r;this.$$r||(n=this.$$g_p(n),this.$$d[n]=mt(n,e,this.$$p_d,"toProp"),(r=this.$$c)==null||r.$set({[n]:this.$$d[n]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(n){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===n||!this.$$p_d[t].attribute&&t.toLowerCase()===n)||n}});function mt(s,n,t,e){var i;const r=(i=t[s])==null?void 0:i.type;if(n=r==="Boolean"&&typeof n!="boolean"?n!=null:n,!e||!t[s])return n;if(e==="toAttribute")switch(r){case"Object":case"Array":return n==null?null:JSON.stringify(n);case"Boolean":return n?"":null;case"Number":return n??null;default:return n}else switch(r){case"Object":case"Array":return n&&JSON.parse(n);case"Boolean":return n;case"Number":return n!=null?+n:n;default:return n}}function Pe(s,n,t,e,r,i){let o=class extends Xt{constructor(){super(s,t,r),this.$$p_d=n}static get observedAttributes(){return Object.keys(n).map(h=>(n[h].attribute||h).toLowerCase())}};return Object.keys(n).forEach(h=>{Object.defineProperty(o.prototype,h,{get(){return this.$$c&&h in this.$$c?this.$$c[h]:this.$$d[h]},set(p){var d;p=mt(h,p,n),this.$$d[h]=p,(d=this.$$c)==null||d.$set({[h]:p})}})}),e.forEach(h=>{Object.defineProperty(o.prototype,h,{get(){var p;return(p=this.$$c)==null?void 0:p[h]}})}),i&&(o=i(o)),s.element=o,o}class Ie{constructor(){f(this,"$$");f(this,"$$set")}$destroy(){Ne(this,1),this.$destroy=P}$on(n,t){if(!Vt(t))return P;const e=this.$$.callbacks[n]||(this.$$.callbacks[n]=[]);return e.push(t),()=>{const r=e.indexOf(t);r!==-1&&e.splice(r,1)}}$set(n){this.$$set&&!ye(n)&&(this.$$.skip_bound=!0,this.$$set(n),this.$$.skip_bound=!1)}}const De="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(De);const{isArray:Ue}=Array,Je=Object.keys,ct=s=>{if(!s)return s;if(Ue(s)){const n=[],t=s.length;for(let e=0;e<t;e++)n.push(ct(s[e]));return n}else if(typeof s=="object"){const n=Je(s),t=n.length,e={};for(let r=0;r<t;r++){const i=n[r];e[i]=ct(s[i])}return e}return s};class U{constructor(n){f(this,"path");f(this,"from");this.path=n}}const Ve=/~1/g,qe=/~0/g,Be=/~/g,Fe=/\//g;function ze(s){return s.indexOf("~")===-1?s:s.replace(Ve,"/").replace(qe,"~")}function We(s){return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(Be,"~0").replace(Fe,"~1")}function Ge(s){return s?s.slice(1).split("/").map(ze):[]}function E(s){return Xe(s)?"":"/"+s.map(n=>We(String(n))).join("/")}const w=s=>typeof s=="string"?Ge(s):s,Xe=s=>!s.length,Ye=Object.prototype.hasOwnProperty;function Ze(s,n){return Ye.call(s,n)}const{isArray:Yt}=Array,T=(s,n)=>{const t=n.length;if(!t)return{val:s};let e,r;for(let o=0;o<t;o++)if(e=s,r=n[o],Yt(e)){const h=e.length;if(r==="-")r=h;else if(typeof r=="string"){const p=~~r;if(""+p!==r)throw new Error("INVALID_INDEX");if(r=p,r<0)throw new Error("INVALID_INDEX")}s=e[r]}else if(typeof e=="object"&&e)s=Ze(e,r)?e[r]:void 0;else throw new Error("NOT_FOUND");return{val:s,obj:e,key:r}},lt=s=>Yt(s.obj)&&typeof s.key=="number",wt=s=>typeof s.obj=="object"&&typeof s.key=="string";class Lt extends U{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"add"}code(){return 0}apply(t){const{val:e,key:r,obj:i}=T(t,this.path),o=ct(this.value);if(!i)t=o;else if(typeof r=="string")i[r]=o;else{const h=i.length;if(r<h)i.splice(r,0,o);else{if(r>h)throw new Error("INVALID_INDEX");i.push(o)}}return{doc:t,old:e}}toJson(t){return{op:"add",path:E(this.path),value:this.value}}toCompact(t,e){return[e?"add":0,this.path,this.value]}encode(t){t.encodeArrayHeader(3),t.writer.u8(0),t.encodeArray(this.path),t.encodeAny(this.value)}}class Zt extends U{constructor(t,e){super(t);f(this,"oldValue");this.oldValue=e}op(){return"remove"}code(){return 1}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");return wt(e)?delete e.obj[e.key]:lt(e)?e.val!==void 0&&e.obj.splice(e.key,1):t=null,{doc:t,old:e.val}}toJson(t){const e={op:"remove",path:E(this.path)};return this.oldValue!==void 0&&(e.oldValue=this.oldValue),e}toCompact(t,e){const r=e?"remove":1;return this.oldValue===void 0?[r,this.path]:[r,this.path,this.oldValue]}encode(t,e){const r=this.oldValue!==void 0;t.encodeArrayHeader(r?3:2),t.writer.u8(1),t.encodeArray(this.path),r&&t.encodeAny(this.oldValue)}}class Qe extends U{constructor(t,e,r){super(t);f(this,"value");f(this,"oldValue");this.value=e,this.oldValue=r}op(){return"replace"}code(){return 2}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");return wt(e)?e.obj[e.key]=this.value:lt(e)?e.obj[e.key]=this.value:t=this.value,{doc:t,old:e.val}}toJson(t){const e={op:"replace",path:E(this.path),value:this.value};return this.oldValue!==void 0&&(e.oldValue=this.oldValue),e}toCompact(t,e){const r=e?"replace":2;return this.oldValue===void 0?[r,this.path,this.value]:[r,this.path,this.value,this.oldValue]}encode(t,e){const r=this.oldValue!==void 0;t.encodeArrayHeader(r?4:3),t.writer.u8(2),t.encodeArray(this.path),t.encodeAny(this.value),r&&t.encodeAny(this.oldValue)}}class Ke extends U{constructor(t,e){super(t);f(this,"from");this.from=e}op(){return"move"}code(){return 4}apply(t){const e=new Zt(w(this.from),void 0).apply(t);return new Lt(this.path,e.old).apply(e.doc)}toJson(t){return{op:"move",path:E(this.path),from:E(this.from)}}toCompact(t,e){return[e?"move":4,this.path,this.from]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class ts extends U{constructor(t,e){super(t);f(this,"from");this.from=e}op(){return"copy"}code(){return 3}apply(t){const{val:e}=T(t,this.from);if(e===void 0)throw new Error("NOT_FOUND");return new Lt(this.path,ct(e)).apply(t)}toJson(t){return{op:"copy",path:E(this.path),from:E(this.from)}}toCompact(t,e){return[e?"copy":3,this.path,this.from]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class I extends U{apply(n){if(!this.test(n))throw new Error("TEST");return{doc:n}}}const _t=(s,n)=>{if(s===n)return!0;if(s&&n&&typeof s=="object"&&typeof n=="object"){if(s.constructor!==n.constructor)return!1;let t,e,r;if(Array.isArray(s)){if(t=s.length,t!==n.length)return!1;for(e=t;e--!==0;)if(!_t(s[e],n[e]))return!1;return!0}if(r=Object.keys(s),t=r.length,t!==Object.keys(n).length)return!1;for(e=t;e--!==0;){const i=r[e];if(!_t(s[i],n[i]))return!1}return!0}return!1};class es extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"not");this.value=e,this.not=r}op(){return"test"}code(){return 5}test(t){const{val:e}=T(t,this.path);if(e===void 0)return!!this.not;const r=_t(e,this.value);return this.not?!r:r}toJson(t){const e={op:"test",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=t?this.path.slice(t.path.length):this.path,i=e?"test":5;return this.not?[i,r,this.value,1]:[i,r,this.value]}encode(t,e){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class ss extends U{constructor(n){super(n)}op(){return"flip"}code(){return 8}apply(n){const t=T(n,this.path);return t.obj?t.obj[t.key]=!t.val:n=!t.val,{doc:n,old:t.val}}toJson(n){return{op:"flip",path:E(this.path)}}toCompact(n,t){return[t?"flip":8,this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(8),n.encodeArray(this.path)}}class ns extends U{constructor(t,e){super(t);f(this,"inc");this.inc=e}op(){return"inc"}code(){return 9}apply(t){const e=T(t,this.path),r=this.inc+Number(e.val);return e.obj?e.obj[e.key]=r:t=r,{doc:t,old:e.val}}toJson(t){return{op:"inc",path:E(this.path),inc:this.inc}}toCompact(t,e){return[e?"inc":9,this.path,this.inc]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class rs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"str");this.pos=e,this.str=r}op(){return"str_ins"}code(){return 6}apply(t){const{val:e,key:r,obj:i}=T(t,this.path);if(typeof e!="string"){if(e!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const o=typeof e=="string"?e:"",h=Math.min(this.pos,o.length),p=o.slice(0,h),d=o.slice(h),b=p+this.str+d;return i?i[r]=b:t=b,{doc:t,old:e}}toJson(t){return{op:"str_ins",path:E(this.path),pos:this.pos,str:this.str}}toCompact(t,e){return[e?"str_ins":6,this.path,this.pos,this.str]}encode(t,e){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class is extends U{constructor(t,e,r,i){super(t);f(this,"pos");f(this,"str");f(this,"len");this.pos=e,this.str=r,this.len=i}op(){return"str_del"}code(){return 7}deleteLength(){return typeof this.str=="string"?this.str.length:this.len}apply(t){const{val:e,key:r,obj:i}=T(t,this.path);if(typeof e!="string")throw new Error("NOT_A_STRING");const o=e.length,h=Math.min(this.pos,e.length),p=Math.min(h,o),d=this.str!==void 0?this.str.length:this.len,b=Math.min(h+d,o),_=e.slice(0,p),A=e.substr(b),O=_+A;return i?i[r]=O:t=O,{doc:t,old:e}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:E(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:E(this.path),pos:this.pos,len:this.len}}toCompact(t,e){const r=e?"str_del":7;return typeof this.str=="string"?[r,this.path,this.pos,this.str]:[r,this.path,this.pos,0,this.len]}encode(t,e){const r=typeof this.str=="string";t.encodeArrayHeader(r?4:5),t.writer.u8(7),t.encodeArray(this.path),t.encodeNumber(this.pos),r?t.encodeString(this.str):(t.writer.u8(0),t.encodeNumber(this.len))}}const{isArray:os}=Array,Nt=s=>!!s&&typeof s=="object"&&typeof s.text=="string",Rt=s=>!!s&&typeof s=="object"&&os(s.children),as=(s,n)=>{const t=new RegExp(s,n?"i":void 0);return e=>t.test(e)};class hs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"props");this.pos=e,this.props=r}op(){return"split"}code(){return 10}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");const r=this.split(e.val);return wt(e)?e.obj[e.key]=r:lt(e)?(e.obj[e.key]=r[0],e.obj.splice(e.key+1,0,r[1])):t=r,{doc:t,old:e.val}}split(t){if(typeof t=="string"){const{pos:e,props:r}=this,i=t.slice(0,e),o=t.slice(e);return r?[{...r,text:i},{...r,text:o}]:[i,o]}else if(Nt(t)){const{pos:e,props:r}=this,i=t.text.slice(0,e),o=t.text.slice(e);return[{...t,...r,text:i},{...t,...r,text:o}]}else if(Rt(t)){const{pos:e,props:r}=this,i=t.children.slice(0,e),o=t.children.slice(e);return[{...t,...r,children:i},{...t,...r,children:o}]}else if(typeof t=="number"){const{pos:e}=this;return[e,t-e]}else return[t,t]}toJson(t){const e={op:"split",path:E(this.path),pos:this.pos};return this.props&&(e.props=this.props),e}toCompact(t,e){const r=e?"split":10;return this.props?[r,this.path,this.pos,this.props]:[r,this.path,this.pos]}encode(t,e){t.encodeArrayHeader(this.props?4:3),t.writer.u8(10),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeObject(this.props)}}class cs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"props");this.pos=e,this.props=r}op(){return"merge"}code(){return 11}apply(t){const e=T(t,this.path);if(!lt(e))throw new Error("INVALID_TARGET");if(e.key<=0)throw new Error("INVALID_KEY");const r=e.obj[e.key-1],i=e.obj[e.key],o=this.merge(r,i);return e.obj[e.key-1]=o,e.obj.splice(e.key,1),{doc:t,old:[r,i]}}merge(t,e){return typeof t=="string"&&typeof e=="string"||typeof t=="number"&&typeof e=="number"?t+e:Nt(t)&&Nt(e)?{...t,...e,text:t.text+e.text}:Rt(t)&&Rt(e)?{...t,...e,children:[...t.children,...e.children]}:[t,e]}toJson(t){const e={op:"merge",path:E(this.path),pos:this.pos};return this.props&&(e.props=this.props),e}toCompact(t,e){const r=e?"merge":11;return this.props?[r,this.path,this.pos,this.props]:[r,this.path,this.pos]}encode(t,e){t.encodeArrayHeader(this.props?4:3),t.writer.u8(11),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeAny(this.props)}}const{isArray:ls}=Array;class us extends U{constructor(t,e,r){super(t);f(this,"props");f(this,"deleteNull");this.props=e,this.deleteNull=r}op(){return"extend"}code(){return 12}apply(t){const e=T(t,this.path);return lt(e)?e.val!==void 0&&(e.obj[e.key]=this.extend(e.val)):wt(e)?e.obj[e.key]=this.extend(e.val):t=this.extend(t),{doc:t}}extend(t){if(ls(t)||typeof t!="object"||!t)return t;for(const[e,r]of Object.entries(this.props)){if(e==="__proto__")throw new Error("NO_PROTO");if(r===null&&this.deleteNull){delete t[e];continue}t[e]=r}return t}toJson(t){const e={op:"extend",path:E(this.path),props:this.props};return this.deleteNull&&(e.deleteNull=this.deleteNull),e}toCompact(t,e){const r=e?"extend":12;return this.deleteNull?[r,this.path,this.props,1]:[r,this.path,this.props]}encode(t,e){const{deleteNull:r}=this;t.encodeArrayHeader(r?4:3),t.writer.u8(12),t.encodeArray(this.path),t.encodeObject(this.props),r&&t.writer.u8(1)}}class ps extends I{constructor(n){super(n)}op(){return"defined"}code(){return 31}test(n){const{val:t}=T(n,this.path);return t!==void 0}toJson(n){return{op:"defined",path:E(n?this.path.slice(n.path.length):this.path)}}toCompact(n,t){return[t?"defined":31,n?this.path.slice(n.path.length):this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(31),n.encodeArray(t?this.path.slice(t.path.length):this.path)}}class fs extends I{constructor(n){super(n)}op(){return"undefined"}code(){return 38}test(n){try{const{val:t}=T(n,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(n){return{op:"undefined",path:E(n?this.path.slice(n.path.length):this.path)}}toCompact(n,t){return[t?"undefined":38,n?this.path.slice(n.path.length):this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(38),n.encodeArray(t?this.path.slice(t.path.length):this.path)}}const{isArray:ds}=Array;class gs extends I{constructor(t,e){super(t);f(this,"type");this.type=e}op(){return"test_type"}code(){return 39}test(t){const{val:e}=T(t,this.path);return e===null?this.type.indexOf("null")>-1:ds(e)?this.type.indexOf("array")>-1:this.type.indexOf(typeof e)>-1||typeof e=="number"&&e===Math.round(e)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:E(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,e){return[e?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeArray(this.type)}}class vs extends I{constructor(t,e,r,i){super(t);f(this,"pos");f(this,"str");f(this,"not");this.pos=e,this.str=r,this.not=i}op(){return"test_string"}code(){return 40}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=e.length,i=Math.min(this.pos,r),o=Math.min(this.pos+this.str.length,r),h=e.substring(i,o)===this.str;return this.not?!h:h}toJson(t){const e={op:"test_string",path:E(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=e?"test_string":40,i=t?this.path.slice(t.path.length):this.path;return this.not?[r,i,this.pos,this.str,1]:[r,i,this.pos,this.str]}encode(t,e){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class ys extends I{constructor(t,e,r){super(t);f(this,"len");f(this,"not");this.len=e,this.not=r}op(){return"test_string_len"}code(){return 41}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const i=e.length>=this.len;return this.not?!i:i}toJson(t){const e={op:"test_string_len",path:E(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=e?"test_string_len":41,i=t?this.path.slice(t.path.length):this.path;return this.not?[r,i,this.len,1]:[r,i,this.len]}encode(t,e){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class ms extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"contains"}code(){return 30}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.indexOf(i)>-1}toJson(t){const e={op:"contains",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"contains":30;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(30),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class ws extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"ends"}code(){return 32}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.endsWith(i)}toJson(t){const e={op:"ends",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"ends":32;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(32),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class _s extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"starts"}code(){return 37}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.startsWith(i)}toJson(t){const e={op:"starts",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"starts":37;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(37),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class bs extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"in"}code(){return 33}test(t){const{val:e}=T(t,this.path);for(const r of this.value)if(_t(e,r))return!0;return!1}toJson(t){return{op:"in",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeArray(this.value)}}class Es extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"less"}code(){return 34}test(t){const{val:e}=T(t,this.path);return typeof e!="number"?!1:e<this.value}toJson(t){return{op:"less",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.value)}}class $s extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"more"}code(){return 36}test(t){const{val:e}=T(t,this.path);return typeof e!="number"?!1:e>this.value}toJson(t){return{op:"more",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.value)}}class Ht extends I{constructor(t,e){super(t);f(this,"ops");this.ops=e}}class Cs extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"and"}code(){return 43}test(t){for(const e of this.ops)if(!e.test(t))return!1;return!0}toJson(t){return{op:"and",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){const r=e?this.path.slice(e.path.length):this.path;t.encodeArrayHeader(3),t.writer.u8(43),t.encodeArray(r);const i=this.ops.length;t.encodeArrayHeader(i);for(let o=0;o<i;o++)this.ops[o].encode(t,this)}}class ks extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"or"}code(){return 45}test(t){for(const e of this.ops)if(e.test(t))return!0;return!1}toJson(t){return{op:"or",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(e?this.path.slice(e.path.length):this.path);const r=this.ops.length;t.encodeArrayHeader(r);for(let i=0;i<r;i++)this.ops[i].encode(t,this)}}class As extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"not"}code(){return 44}test(t){for(const e of this.ops)if(e.test(t))return!1;return!0}toJson(t){return{op:"not",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(e?this.path.slice(e.path.length):this.path);const r=this.ops.length;t.encodeArrayHeader(r);for(let i=0;i<r;i++)this.ops[i].encode(t,this)}}class Ts extends I{constructor(t,e,r,i){super(t);f(this,"value");f(this,"ignore_case");f(this,"matcher");this.value=e,this.ignore_case=r,this.matcher=i(e,r)}op(){return"matches"}code(){return 35}test(t){const{val:e}=T(t,this.path);return typeof e!="string"?!1:this.matcher(e)}toJson(t){const e={op:"matches",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"matches":35;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(35),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}const{isArray:Os}=Array;class js extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"type"}code(){return 42}test(t){const{val:e}=T(t,this.path);return e===null?this.value==="null":Os(e)?this.value==="array":typeof e===this.value||typeof e=="number"&&e===Math.round(e)&&this.value==="integer"}toJson(t){return{op:"type",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value)}}const xs=(s,n)=>{switch(s.op){case"add":return new Lt(w(s.path),s.value);case"remove":return new Zt(w(s.path),s.oldValue);case"replace":return new Qe(w(s.path),s.value,s.oldValue);case"move":return new Ke(w(s.path),w(s.from));case"copy":return new ts(w(s.path),w(s.from));case"flip":return new ss(w(s.path));case"inc":return new ns(w(s.path),s.inc);case"str_ins":return new rs(w(s.path),s.pos,s.str);case"str_del":return new is(w(s.path),s.pos,s.str,s.len);case"split":return new hs(w(s.path),s.pos,s.props||null);case"merge":return new cs(w(s.path),s.pos,s.props||null);case"extend":return new us(w(s.path),s.props,!!s.deleteNull);default:return bt(s,n)}},bt=(s,n)=>{switch(s.op){case"test":return new es(w(s.path),s.value,!!s.not);case"defined":return new ps(w(s.path));case"undefined":return new fs(w(s.path));case"type":return new js(w(s.path),s.value);case"test_type":return new gs(w(s.path),s.type);case"test_string":return new vs(w(s.path),s.pos,s.str,!!s.not);case"test_string_len":return new ys(w(s.path),s.len,!!s.not);case"contains":return new ms(w(s.path),s.value,!!s.ignore_case);case"ends":return new ws(w(s.path),s.value,!!s.ignore_case);case"starts":return new _s(w(s.path),s.value,!!s.ignore_case);case"matches":return new Ts(w(s.path),s.value,!!s.ignore_case,n.createMatcher||as);case"in":return new bs(w(s.path),s.value);case"less":return new Es(w(s.path),s.value);case"more":return new $s(w(s.path),s.value);case"and":{const t=w(s.path);return new Cs(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}case"or":{const t=w(s.path);return new ks(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}case"not":{const t=w(s.path);return new As(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}default:throw new Error("OP_UNKNOWN")}};function Ss(s,n,t){t.mutate||(s=ct(s));const e=[],r=n.length;for(let i=0;i<r;i++){const h=xs(n[i],t).apply(s);s=h.doc,e.push(h)}return{doc:s,res:e}}var ut=s=>typeof s=="function"?s:function(){return s},Ms=typeof self<"u"?self:null,pt=typeof window<"u"?window:null,ft=Ms||pt||ft,Ls="2.0.0",B={connecting:0,open:1,closing:2,closed:3},Ns=1e4,Rs=1e3,J={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},z={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Pt={longpoll:"longpoll",websocket:"websocket"},Hs={complete:4},Et=class{constructor(s,n,t,e){this.channel=s,this.event=n,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=e,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(s){this.timeout=s,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(s,n){return this.hasReceived(s)&&n(this.receivedResp.response),this.recHooks.push({status:s,callback:n}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:s,response:n,_ref:t}){this.recHooks.filter(e=>e.status===s).forEach(e=>e.callback(n))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,s=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=s,this.matchReceive(s)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}trigger(s,n){this.channel.trigger(this.refEvent,{status:s,response:n})}},Qt=class{constructor(s,n){this.callback=s,this.timerCalc=n,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Ps=class{constructor(s,n,t){this.state=J.closed,this.topic=s,this.params=ut(n||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Et(this,z.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Qt(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=J.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=J.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=J.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=J.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Et(this,z.leave,ut({}),this.timeout).send(),this.state=J.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(z.reply,(e,r)=>{this.trigger(this.replyEventName(r),e)})}join(s=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=s,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(s){this.on(z.close,s)}onError(s){return this.on(z.error,n=>s(n))}on(s,n){let t=this.bindingRef++;return this.bindings.push({event:s,ref:t,callback:n}),t}off(s,n){this.bindings=this.bindings.filter(t=>!(t.event===s&&(typeof n>"u"||n===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(s,n,t=this.timeout){if(n=n||{},!this.joinedOnce)throw new Error(`tried to push '${s}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let e=new Et(this,s,function(){return n},t);return this.canPush()?e.send():(e.startTimeout(),this.pushBuffer.push(e)),e}leave(s=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=J.leaving;let n=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(z.close,"leave")},t=new Et(this,z.leave,ut({}),s);return t.receive("ok",()=>n()).receive("timeout",()=>n()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(s,n,t){return n}isMember(s,n,t,e){return this.topic!==s?!1:e&&e!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:s,event:n,payload:t,joinRef:e}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(s=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=J.joining,this.joinPush.resend(s))}trigger(s,n,t,e){let r=this.onMessage(s,n,t,e);if(n&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===s);for(let o=0;o<i.length;o++)i[o].callback(r,t,e||this.joinRef())}replyEventName(s){return`chan_reply_${s}`}isClosed(){return this.state===J.closed}isErrored(){return this.state===J.errored}isJoined(){return this.state===J.joined}isJoining(){return this.state===J.joining}isLeaving(){return this.state===J.leaving}},$t=class{static request(s,n,t,e,r,i,o){if(ft.XDomainRequest){let h=new ft.XDomainRequest;return this.xdomainRequest(h,s,n,e,r,i,o)}else{let h=new ft.XMLHttpRequest;return this.xhrRequest(h,s,n,t,e,r,i,o)}}static xdomainRequest(s,n,t,e,r,i,o){return s.timeout=r,s.open(n,t),s.onload=()=>{let h=this.parseJSON(s.responseText);o&&o(h)},i&&(s.ontimeout=i),s.onprogress=()=>{},s.send(e),s}static xhrRequest(s,n,t,e,r,i,o,h){return s.open(n,t,!0),s.timeout=i,s.setRequestHeader("Content-Type",e),s.onerror=()=>h&&h(null),s.onreadystatechange=()=>{if(s.readyState===Hs.complete&&h){let p=this.parseJSON(s.responseText);h(p)}},o&&(s.ontimeout=o),s.send(r),s}static parseJSON(s){if(!s||s==="")return null;try{return JSON.parse(s)}catch{return console&&console.log("failed to parse JSON response",s),null}}static serialize(s,n){let t=[];for(var e in s){if(!Object.prototype.hasOwnProperty.call(s,e))continue;let r=n?`${n}[${e}]`:e,i=s[e];typeof i=="object"?t.push(this.serialize(i,r)):t.push(encodeURIComponent(r)+"="+encodeURIComponent(i))}return t.join("&")}static appendParams(s,n){if(Object.keys(n).length===0)return s;let t=s.match(/\?/)?"&":"?";return`${s}${t}${this.serialize(n)}`}},It=class{constructor(s){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(s),this.readyState=B.connecting,this.poll()}normalizeEndpoint(s){return s.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Pt.websocket),"$1/"+Pt.longpoll)}endpointURL(){return $t.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(s,n,t){this.close(s,n,t),this.readyState=B.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===B.open||this.readyState===B.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),s=>{if(s){var{status:n,token:t,messages:e}=s;this.token=t}else n=0;switch(n){case 200:e.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=B.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${n}`)}})}send(s){this.ajax("POST",s,()=>this.onerror("timeout"),n=>{(!n||n.status!==200)&&(this.onerror(n&&n.status),this.closeAndRetry(1011,"internal server error",!1))})}close(s,n,t){for(let r of this.reqs)r.abort();this.readyState=B.closed;let e=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:s,reason:n,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",e)):this.onclose(e)}ajax(s,n,t,e){let r,i=()=>{this.reqs.delete(r),t()};r=$t.request(s,this.endpointURL(),"application/json",n,this.timeout,i,o=>{this.reqs.delete(r),this.isActive()&&e(o)}),this.reqs.add(r)}},Ct={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(s,n){if(s.payload.constructor===ArrayBuffer)return n(this.binaryEncode(s));{let t=[s.join_ref,s.ref,s.topic,s.event,s.payload];return n(JSON.stringify(t))}},decode(s,n){if(s.constructor===ArrayBuffer)return n(this.binaryDecode(s));{let[t,e,r,i,o]=JSON.parse(s);return n({join_ref:t,ref:e,topic:r,event:i,payload:o})}},binaryEncode(s){let{join_ref:n,ref:t,event:e,topic:r,payload:i}=s,o=this.META_LENGTH+n.length+t.length+r.length+e.length,h=new ArrayBuffer(this.HEADER_LENGTH+o),p=new DataView(h),d=0;p.setUint8(d++,this.KINDS.push),p.setUint8(d++,n.length),p.setUint8(d++,t.length),p.setUint8(d++,r.length),p.setUint8(d++,e.length),Array.from(n,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(t,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(r,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(e,_=>p.setUint8(d++,_.charCodeAt(0)));var b=new Uint8Array(h.byteLength+i.byteLength);return b.set(new Uint8Array(h),0),b.set(new Uint8Array(i),h.byteLength),b.buffer},binaryDecode(s){let n=new DataView(s),t=n.getUint8(0),e=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(s,n,e);case this.KINDS.reply:return this.decodeReply(s,n,e);case this.KINDS.broadcast:return this.decodeBroadcast(s,n,e)}},decodePush(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=n.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,h=t.decode(s.slice(o,o+e));o=o+e;let p=t.decode(s.slice(o,o+r));o=o+r;let d=t.decode(s.slice(o,o+i));o=o+i;let b=s.slice(o,s.byteLength);return{join_ref:h,ref:null,topic:p,event:d,payload:b}},decodeReply(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=n.getUint8(3),o=n.getUint8(4),h=this.HEADER_LENGTH+this.META_LENGTH,p=t.decode(s.slice(h,h+e));h=h+e;let d=t.decode(s.slice(h,h+r));h=h+r;let b=t.decode(s.slice(h,h+i));h=h+i;let _=t.decode(s.slice(h,h+o));h=h+o;let A=s.slice(h,s.byteLength),O={status:_,response:A};return{join_ref:p,ref:d,topic:b,event:z.reply,payload:O}},decodeBroadcast(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=this.HEADER_LENGTH+2,o=t.decode(s.slice(i,i+e));i=i+e;let h=t.decode(s.slice(i,i+r));i=i+r;let p=s.slice(i,s.byteLength);return{join_ref:null,ref:null,topic:o,event:h,payload:p}}},Is=class{constructor(s,n={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=n.timeout||Ns,this.transport=n.transport||ft.WebSocket||It,this.establishedConnections=0,this.defaultEncoder=Ct.encode.bind(Ct),this.defaultDecoder=Ct.decode.bind(Ct),this.closeWasClean=!1,this.binaryType=n.binaryType||"arraybuffer",this.connectClock=1,this.transport!==It?(this.encode=n.encode||this.defaultEncoder,this.decode=n.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;pt&&pt.addEventListener&&(pt.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),t=this.connectClock)}),pt.addEventListener("pageshow",e=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=n.heartbeatIntervalMs||3e4,this.rejoinAfterMs=e=>n.rejoinAfterMs?n.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>n.reconnectAfterMs?n.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=n.logger||null,this.longpollerTimeout=n.longpollerTimeout||2e4,this.params=ut(n.params||{}),this.endPoint=`${s}/${Pt.websocket}`,this.vsn=n.vsn||Ls,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Qt(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return It}replaceTransport(s){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=s}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let s=$t.appendParams($t.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return s.charAt(0)!=="/"?s:s.charAt(1)==="/"?`${this.protocol()}:${s}`:`${this.protocol()}://${location.host}${s}`}disconnect(s,n,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(s,n,t)}connect(s){s&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=ut(s)),!this.conn&&(this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=n=>this.onConnError(n),this.conn.onmessage=n=>this.onConnMessage(n),this.conn.onclose=n=>this.onConnClose(n))}log(s,n,t){this.logger(s,n,t)}hasLogger(){return this.logger!==null}onOpen(s){let n=this.makeRef();return this.stateChangeCallbacks.open.push([n,s]),n}onClose(s){let n=this.makeRef();return this.stateChangeCallbacks.close.push([n,s]),n}onError(s){let n=this.makeRef();return this.stateChangeCallbacks.error.push([n,s]),n}onMessage(s){let n=this.makeRef();return this.stateChangeCallbacks.message.push([n,s]),n}ping(s){if(!this.isConnected())return!1;let n=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:n});let e=this.onMessage(r=>{r.ref===n&&(this.off([e]),s(Date.now()-t))});return!0}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,s])=>s())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Rs,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(s,n,t){if(!this.conn)return s&&s();this.waitForBufferDone(()=>{this.conn&&(n?this.conn.close(n,t||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),s&&s()})})}waitForBufferDone(s,n=1){if(n===5||!this.conn||!this.conn.bufferedAmount){s();return}setTimeout(()=>{this.waitForBufferDone(s,n+1)},150*n)}waitForSocketClosed(s,n=1){if(n===5||!this.conn||this.conn.readyState===B.closed){s();return}setTimeout(()=>{this.waitForSocketClosed(s,n+1)},150*n)}onConnClose(s){let n=s&&s.code;this.hasLogger()&&this.log("transport","close",s),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&n!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(s))}onConnError(s){this.hasLogger()&&this.log("transport",s);let n=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,e])=>{e(s,n,t)}),(n===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(s=>{s.isErrored()||s.isLeaving()||s.isClosed()||s.trigger(z.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case B.connecting:return"connecting";case B.open:return"open";case B.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(s){this.off(s.stateChangeRefs),this.channels=this.channels.filter(n=>n.joinRef()!==s.joinRef())}off(s){for(let n in this.stateChangeCallbacks)this.stateChangeCallbacks[n]=this.stateChangeCallbacks[n].filter(([t])=>s.indexOf(t)===-1)}channel(s,n={}){let t=new Ps(s,n,this);return this.channels.push(t),t}push(s){if(this.hasLogger()){let{topic:n,event:t,payload:e,ref:r,join_ref:i}=s;this.log("push",`${n} ${t} (${i}, ${r})`,e)}this.isConnected()?this.encode(s,n=>this.conn.send(n)):this.sendBuffer.push(()=>this.encode(s,n=>this.conn.send(n)))}makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}onConnMessage(s){this.decode(s.data,n=>{let{topic:t,event:e,payload:r,ref:i,join_ref:o}=n;i&&i===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${r.status||""} ${t} ${e} ${i&&"("+i+")"||""}`,r);for(let h=0;h<this.channels.length;h++){const p=this.channels[h];p.isMember(t,e,r,o)&&p.trigger(e,r,i,o)}for(let h=0;h<this.stateChangeCallbacks.message.length;h++){let[,p]=this.stateChangeCallbacks.message[h];p(n)}})}leaveOpenTopic(s){let n=this.channels.find(t=>t.topic===s&&(t.isJoined()||t.isJoining()));n&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${s}"`),n.leave())}};class Ds{constructor(n){this.connected=!1,this.config=n,this.socket=new Is(this.config.url,{logger:(t,e,r)=>{console.log(`${t}: ${e}`,r)}}),this.channel=this.socket.channel(this.config.topic,this.config.params),this.eventTarget=new EventTarget}connect(){this.connected||(this.socket.onError(n=>this.emitError("socket error",n)),this.socket.connect(),this.channel.onError(n=>console.log("channel error",n)),this.channel.join().receive("ok",()=>{console.log("joined")}).receive("error",n=>{this.emitError("channel join error",n)}),this.channel.on("state:change",n=>this.handleChange(n)),this.channel.on("state:patch",n=>this.handlePatch(n)),this.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(n,t,e){var r;this.eventTarget.addEventListener(n,t,e),n.startsWith("livestate-")||(r=this.channel)==null||r.on(n,i=>{this.eventTarget.dispatchEvent(new CustomEvent(n,{detail:i}))})}removeEventListener(n,t,e){return this.eventTarget.removeEventListener(n,t,e)}subscribe(n){this.addEventListener("livestate-change",n)}unsubscribe(n){this.removeEventListener("livestate-change",n)}emitError(n,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{kind:n,error:t}}))}handleChange({state:n,version:t}){this.state=n,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}handlePatch({patch:n,version:t}){if(this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch",{detail:{patch:n,version:t}})),t===this.stateVersion+1){const{doc:e,res:r}=Ss(this.state,n,{mutate:!1});this.state=e,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}else this.channel.push("lvs_refresh")}pushEvent(n,t){this.dispatchEvent(new CustomEvent(n,{detail:t}))}dispatchEvent(n){return this.channel.push(`lvs_evt:${n.type}`,n.detail),!0}pushCustomEvent(n){this.dispatchEvent(n)}}Promise.resolve();var Kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/*! *****************************************************************************
1
+ (function(P,D){typeof exports=="object"&&typeof module<"u"?module.exports=D():typeof define=="function"&&define.amd?define(D):(P=typeof globalThis<"u"?globalThis:P||self,P.LiveroomClientElement=D())})(this,function(){"use strict";var nn=Object.defineProperty;var rn=(P,D,X)=>D in P?nn(P,D,{enumerable:!0,configurable:!0,writable:!0,value:X}):P[D]=X;var f=(P,D,X)=>(rn(P,typeof D!="symbol"?D+"":D,X),X);function P(){}function D(s){return s()}function X(){return Object.create(null)}function it(s){s.forEach(D)}function Jt(s){return typeof s=="function"}function ve(s,n){return s!=s?n==n:s!==n||s&&typeof s=="object"||typeof s=="function"}function ye(s){return Object.keys(s).length===0}function F(s,n){s.appendChild(n)}function me(s,n,t){const e=we(s);if(!e.getElementById(n)){const r=Y("style");r.id=n,r.textContent=t,_e(e,r)}}function we(s){if(!s)return document;const n=s.getRootNode?s.getRootNode():s.ownerDocument;return n&&n.host?n:s.ownerDocument}function _e(s,n){return F(s.head||s,n),n.sheet}function vt(s,n,t){s.insertBefore(n,t||null)}function ot(s){s.parentNode&&s.parentNode.removeChild(s)}function Y(s){return document.createElement(s)}function Vt(s){return document.createElementNS("http://www.w3.org/2000/svg",s)}function Bt(s){return document.createTextNode(s)}function Ot(){return Bt(" ")}function j(s,n,t){t==null?s.removeAttribute(n):s.getAttribute(n)!==t&&s.setAttribute(n,t)}function be(s){return Array.from(s.childNodes)}function Ee(s,n){n=""+n,s.data!==n&&(s.data=n)}function Z(s,n,t,e){t==null?s.style.removeProperty(n):s.style.setProperty(n,t,e?"important":"")}function $e(s){const n={};return s.childNodes.forEach(t=>{n[t.slot||"default"]=!0}),n}let at;function ht(s){at=s}function Ft(){if(!at)throw new Error("Function called outside component initialization");return at}function Ce(s){Ft().$$.on_mount.push(s)}function ke(s){Ft().$$.on_destroy.push(s)}const Q=[],jt=[];let K=[];const Wt=[],Ae=Promise.resolve();let xt=!1;function Te(){xt||(xt=!0,Ae.then(yt))}function St(s){K.push(s)}const Mt=new Set;let tt=0;function yt(){if(tt!==0)return;const s=at;do{try{for(;tt<Q.length;){const n=Q[tt];tt++,ht(n),Oe(n.$$)}}catch(n){throw Q.length=0,tt=0,n}for(ht(null),Q.length=0,tt=0;jt.length;)jt.pop()();for(let n=0;n<K.length;n+=1){const t=K[n];Mt.has(t)||(Mt.add(t),t())}K.length=0}while(Q.length);for(;Wt.length;)Wt.pop()();xt=!1,Mt.clear(),ht(s)}function Oe(s){if(s.fragment!==null){s.update(),it(s.before_update);const n=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,n),s.after_update.forEach(St)}}function je(s){const n=[],t=[];K.forEach(e=>s.indexOf(e)===-1?n.push(e):t.push(e)),t.forEach(e=>e()),K=n}const xe=new Set;function Gt(s,n){s&&s.i&&(xe.delete(s),s.i(n))}function Xt(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function Se(s,n){s.d(1),n.delete(s.key)}function Me(s,n,t,e,r,i,o,h,p,d,b,_){let A=s.length,O=i.length,x=A;const R={};for(;x--;)R[s[x].key]=x;const L=[],k=new Map,et=new Map,kt=[];for(x=O;x--;){const S=_(r,i,x),J=t(S);let V=o.get(J);V?e&&kt.push(()=>V.p(S,n)):(V=d(J,S),V.c()),k.set(J,L[x]=V),J in R&&et.set(J,Math.abs(x-R[J]))}const At=new Set,Tt=new Set;function dt(S){Gt(S,1),S.m(h,b),o.set(S.key,S),b=S.first,O--}for(;A&&O;){const S=L[O-1],J=s[A-1],V=S.key,st=J.key;S===J?(b=S.first,A--,O--):k.has(st)?!o.has(V)||At.has(V)?dt(S):Tt.has(st)?A--:et.get(V)>et.get(st)?(Tt.add(V),dt(S)):(At.add(st),A--):(p(J,o),A--)}for(;A--;){const S=s[A];k.has(S.key)||p(S,o)}for(;O;)dt(L[O-1]);return it(kt),L}function Le(s,n,t){const{fragment:e,after_update:r}=s.$$;e&&e.m(n,t),St(()=>{const i=s.$$.on_mount.map(D).filter(Jt);s.$$.on_destroy?s.$$.on_destroy.push(...i):it(i),s.$$.on_mount=[]}),r.forEach(St)}function Ne(s,n){const t=s.$$;t.fragment!==null&&(je(t.after_update),it(t.on_destroy),t.fragment&&t.fragment.d(n),t.on_destroy=t.fragment=null,t.ctx=[])}function Re(s,n){s.$$.dirty[0]===-1&&(Q.push(s),Te(),s.$$.dirty.fill(0)),s.$$.dirty[n/31|0]|=1<<n%31}function He(s,n,t,e,r,i,o,h=[-1]){const p=at;ht(s);const d=s.$$={fragment:null,ctx:[],props:i,update:P,not_equal:r,bound:X(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(n.context||(p?p.$$.context:[])),callbacks:X(),dirty:h,skip_bound:!1,root:n.target||p.$$.root};o&&o(d.root);let b=!1;if(d.ctx=t?t(s,n.props||{},(_,A,...O)=>{const x=O.length?O[0]:A;return d.ctx&&r(d.ctx[_],d.ctx[_]=x)&&(!d.skip_bound&&d.bound[_]&&d.bound[_](x),b&&Re(s,_)),A}):[],d.update(),b=!0,it(d.before_update),d.fragment=e?e(d.ctx):!1,n.target){if(n.hydrate){const _=be(n.target);d.fragment&&d.fragment.l(_),_.forEach(ot)}else d.fragment&&d.fragment.c();n.intro&&Gt(s.$$.fragment),Le(s,n.target,n.anchor),yt()}ht(p)}let qt;typeof HTMLElement=="function"&&(qt=class extends HTMLElement{constructor(n,t,e){super();f(this,"$$ctor");f(this,"$$s");f(this,"$$c");f(this,"$$cn",!1);f(this,"$$d",{});f(this,"$$r",!1);f(this,"$$p_d",{});f(this,"$$l",{});f(this,"$$l_u",new Map);this.$$ctor=n,this.$$s=t,e&&this.attachShadow({mode:"open"})}addEventListener(n,t,e){if(this.$$l[n]=this.$$l[n]||[],this.$$l[n].push(t),this.$$c){const r=this.$$c.$on(n,t);this.$$l_u.set(t,r)}super.addEventListener(n,t,e)}removeEventListener(n,t,e){if(super.removeEventListener(n,t,e),this.$$c){const r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let n=function(i){return()=>{let o;return{c:function(){o=Y("slot"),i!=="default"&&j(o,"name",i)},m:function(d,b){vt(d,o,b)},d:function(d){d&&ot(o)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},e=$e(this);for(const i of this.$$s)i in e&&(t[i]=[n(i)]);for(const i of this.attributes){const o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=mt(o,i.value,this.$$p_d,"toProp"))}this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const r=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const o=mt(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1};this.$$c.$$.after_update.push(r),r();for(const i in this.$$l)for(const o of this.$$l[i]){const h=this.$$c.$on(i,o);this.$$l_u.set(o,h)}this.$$l={}}}attributeChangedCallback(n,t,e){var r;this.$$r||(n=this.$$g_p(n),this.$$d[n]=mt(n,e,this.$$p_d,"toProp"),(r=this.$$c)==null||r.$set({[n]:this.$$d[n]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(n){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===n||!this.$$p_d[t].attribute&&t.toLowerCase()===n)||n}});function mt(s,n,t,e){var i;const r=(i=t[s])==null?void 0:i.type;if(n=r==="Boolean"&&typeof n!="boolean"?n!=null:n,!e||!t[s])return n;if(e==="toAttribute")switch(r){case"Object":case"Array":return n==null?null:JSON.stringify(n);case"Boolean":return n?"":null;case"Number":return n??null;default:return n}else switch(r){case"Object":case"Array":return n&&JSON.parse(n);case"Boolean":return n;case"Number":return n!=null?+n:n;default:return n}}function Pe(s,n,t,e,r,i){let o=class extends qt{constructor(){super(s,t,r),this.$$p_d=n}static get observedAttributes(){return Object.keys(n).map(h=>(n[h].attribute||h).toLowerCase())}};return Object.keys(n).forEach(h=>{Object.defineProperty(o.prototype,h,{get(){return this.$$c&&h in this.$$c?this.$$c[h]:this.$$d[h]},set(p){var d;p=mt(h,p,n),this.$$d[h]=p,(d=this.$$c)==null||d.$set({[h]:p})}})}),e.forEach(h=>{Object.defineProperty(o.prototype,h,{get(){var p;return(p=this.$$c)==null?void 0:p[h]}})}),i&&(o=i(o)),s.element=o,o}class Ie{constructor(){f(this,"$$");f(this,"$$set")}$destroy(){Ne(this,1),this.$destroy=P}$on(n,t){if(!Jt(t))return P;const e=this.$$.callbacks[n]||(this.$$.callbacks[n]=[]);return e.push(t),()=>{const r=e.indexOf(t);r!==-1&&e.splice(r,1)}}$set(n){this.$$set&&!ye(n)&&(this.$$.skip_bound=!0,this.$$set(n),this.$$.skip_bound=!1)}}const De="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(De);const{isArray:Ue}=Array,ze=Object.keys,ct=s=>{if(!s)return s;if(Ue(s)){const n=[],t=s.length;for(let e=0;e<t;e++)n.push(ct(s[e]));return n}else if(typeof s=="object"){const n=ze(s),t=n.length,e={};for(let r=0;r<t;r++){const i=n[r];e[i]=ct(s[i])}return e}return s};class U{constructor(n){f(this,"path");f(this,"from");this.path=n}}const Je=/~1/g,Ve=/~0/g,Be=/~/g,Fe=/\//g;function We(s){return s.indexOf("~")===-1?s:s.replace(Je,"/").replace(Ve,"~")}function Ge(s){return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(Be,"~0").replace(Fe,"~1")}function Xe(s){return s?s.slice(1).split("/").map(We):[]}function E(s){return qe(s)?"":"/"+s.map(n=>Ge(String(n))).join("/")}const w=s=>typeof s=="string"?Xe(s):s,qe=s=>!s.length,Ye=Object.prototype.hasOwnProperty;function Ze(s,n){return Ye.call(s,n)}const{isArray:Yt}=Array,T=(s,n)=>{const t=n.length;if(!t)return{val:s};let e,r;for(let o=0;o<t;o++)if(e=s,r=n[o],Yt(e)){const h=e.length;if(r==="-")r=h;else if(typeof r=="string"){const p=~~r;if(""+p!==r)throw new Error("INVALID_INDEX");if(r=p,r<0)throw new Error("INVALID_INDEX")}s=e[r]}else if(typeof e=="object"&&e)s=Ze(e,r)?e[r]:void 0;else throw new Error("NOT_FOUND");return{val:s,obj:e,key:r}},lt=s=>Yt(s.obj)&&typeof s.key=="number",wt=s=>typeof s.obj=="object"&&typeof s.key=="string";class Lt extends U{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"add"}code(){return 0}apply(t){const{val:e,key:r,obj:i}=T(t,this.path),o=ct(this.value);if(!i)t=o;else if(typeof r=="string")i[r]=o;else{const h=i.length;if(r<h)i.splice(r,0,o);else{if(r>h)throw new Error("INVALID_INDEX");i.push(o)}}return{doc:t,old:e}}toJson(t){return{op:"add",path:E(this.path),value:this.value}}toCompact(t,e){return[e?"add":0,this.path,this.value]}encode(t){t.encodeArrayHeader(3),t.writer.u8(0),t.encodeArray(this.path),t.encodeAny(this.value)}}class Zt extends U{constructor(t,e){super(t);f(this,"oldValue");this.oldValue=e}op(){return"remove"}code(){return 1}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");return wt(e)?delete e.obj[e.key]:lt(e)?e.val!==void 0&&e.obj.splice(e.key,1):t=null,{doc:t,old:e.val}}toJson(t){const e={op:"remove",path:E(this.path)};return this.oldValue!==void 0&&(e.oldValue=this.oldValue),e}toCompact(t,e){const r=e?"remove":1;return this.oldValue===void 0?[r,this.path]:[r,this.path,this.oldValue]}encode(t,e){const r=this.oldValue!==void 0;t.encodeArrayHeader(r?3:2),t.writer.u8(1),t.encodeArray(this.path),r&&t.encodeAny(this.oldValue)}}class Qe extends U{constructor(t,e,r){super(t);f(this,"value");f(this,"oldValue");this.value=e,this.oldValue=r}op(){return"replace"}code(){return 2}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");return wt(e)?e.obj[e.key]=this.value:lt(e)?e.obj[e.key]=this.value:t=this.value,{doc:t,old:e.val}}toJson(t){const e={op:"replace",path:E(this.path),value:this.value};return this.oldValue!==void 0&&(e.oldValue=this.oldValue),e}toCompact(t,e){const r=e?"replace":2;return this.oldValue===void 0?[r,this.path,this.value]:[r,this.path,this.value,this.oldValue]}encode(t,e){const r=this.oldValue!==void 0;t.encodeArrayHeader(r?4:3),t.writer.u8(2),t.encodeArray(this.path),t.encodeAny(this.value),r&&t.encodeAny(this.oldValue)}}class Ke extends U{constructor(t,e){super(t);f(this,"from");this.from=e}op(){return"move"}code(){return 4}apply(t){const e=new Zt(w(this.from),void 0).apply(t);return new Lt(this.path,e.old).apply(e.doc)}toJson(t){return{op:"move",path:E(this.path),from:E(this.from)}}toCompact(t,e){return[e?"move":4,this.path,this.from]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class ts extends U{constructor(t,e){super(t);f(this,"from");this.from=e}op(){return"copy"}code(){return 3}apply(t){const{val:e}=T(t,this.from);if(e===void 0)throw new Error("NOT_FOUND");return new Lt(this.path,ct(e)).apply(t)}toJson(t){return{op:"copy",path:E(this.path),from:E(this.from)}}toCompact(t,e){return[e?"copy":3,this.path,this.from]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class I extends U{apply(n){if(!this.test(n))throw new Error("TEST");return{doc:n}}}const _t=(s,n)=>{if(s===n)return!0;if(s&&n&&typeof s=="object"&&typeof n=="object"){if(s.constructor!==n.constructor)return!1;let t,e,r;if(Array.isArray(s)){if(t=s.length,t!==n.length)return!1;for(e=t;e--!==0;)if(!_t(s[e],n[e]))return!1;return!0}if(r=Object.keys(s),t=r.length,t!==Object.keys(n).length)return!1;for(e=t;e--!==0;){const i=r[e];if(!_t(s[i],n[i]))return!1}return!0}return!1};class es extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"not");this.value=e,this.not=r}op(){return"test"}code(){return 5}test(t){const{val:e}=T(t,this.path);if(e===void 0)return!!this.not;const r=_t(e,this.value);return this.not?!r:r}toJson(t){const e={op:"test",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=t?this.path.slice(t.path.length):this.path,i=e?"test":5;return this.not?[i,r,this.value,1]:[i,r,this.value]}encode(t,e){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class ss extends U{constructor(n){super(n)}op(){return"flip"}code(){return 8}apply(n){const t=T(n,this.path);return t.obj?t.obj[t.key]=!t.val:n=!t.val,{doc:n,old:t.val}}toJson(n){return{op:"flip",path:E(this.path)}}toCompact(n,t){return[t?"flip":8,this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(8),n.encodeArray(this.path)}}class ns extends U{constructor(t,e){super(t);f(this,"inc");this.inc=e}op(){return"inc"}code(){return 9}apply(t){const e=T(t,this.path),r=this.inc+Number(e.val);return e.obj?e.obj[e.key]=r:t=r,{doc:t,old:e.val}}toJson(t){return{op:"inc",path:E(this.path),inc:this.inc}}toCompact(t,e){return[e?"inc":9,this.path,this.inc]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class rs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"str");this.pos=e,this.str=r}op(){return"str_ins"}code(){return 6}apply(t){const{val:e,key:r,obj:i}=T(t,this.path);if(typeof e!="string"){if(e!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const o=typeof e=="string"?e:"",h=Math.min(this.pos,o.length),p=o.slice(0,h),d=o.slice(h),b=p+this.str+d;return i?i[r]=b:t=b,{doc:t,old:e}}toJson(t){return{op:"str_ins",path:E(this.path),pos:this.pos,str:this.str}}toCompact(t,e){return[e?"str_ins":6,this.path,this.pos,this.str]}encode(t,e){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class is extends U{constructor(t,e,r,i){super(t);f(this,"pos");f(this,"str");f(this,"len");this.pos=e,this.str=r,this.len=i}op(){return"str_del"}code(){return 7}deleteLength(){return typeof this.str=="string"?this.str.length:this.len}apply(t){const{val:e,key:r,obj:i}=T(t,this.path);if(typeof e!="string")throw new Error("NOT_A_STRING");const o=e.length,h=Math.min(this.pos,e.length),p=Math.min(h,o),d=this.str!==void 0?this.str.length:this.len,b=Math.min(h+d,o),_=e.slice(0,p),A=e.substr(b),O=_+A;return i?i[r]=O:t=O,{doc:t,old:e}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:E(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:E(this.path),pos:this.pos,len:this.len}}toCompact(t,e){const r=e?"str_del":7;return typeof this.str=="string"?[r,this.path,this.pos,this.str]:[r,this.path,this.pos,0,this.len]}encode(t,e){const r=typeof this.str=="string";t.encodeArrayHeader(r?4:5),t.writer.u8(7),t.encodeArray(this.path),t.encodeNumber(this.pos),r?t.encodeString(this.str):(t.writer.u8(0),t.encodeNumber(this.len))}}const{isArray:os}=Array,Nt=s=>!!s&&typeof s=="object"&&typeof s.text=="string",Rt=s=>!!s&&typeof s=="object"&&os(s.children),as=(s,n)=>{const t=new RegExp(s,n?"i":void 0);return e=>t.test(e)};class hs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"props");this.pos=e,this.props=r}op(){return"split"}code(){return 10}apply(t){const e=T(t,this.path);if(e.val===void 0)throw new Error("NOT_FOUND");const r=this.split(e.val);return wt(e)?e.obj[e.key]=r:lt(e)?(e.obj[e.key]=r[0],e.obj.splice(e.key+1,0,r[1])):t=r,{doc:t,old:e.val}}split(t){if(typeof t=="string"){const{pos:e,props:r}=this,i=t.slice(0,e),o=t.slice(e);return r?[{...r,text:i},{...r,text:o}]:[i,o]}else if(Nt(t)){const{pos:e,props:r}=this,i=t.text.slice(0,e),o=t.text.slice(e);return[{...t,...r,text:i},{...t,...r,text:o}]}else if(Rt(t)){const{pos:e,props:r}=this,i=t.children.slice(0,e),o=t.children.slice(e);return[{...t,...r,children:i},{...t,...r,children:o}]}else if(typeof t=="number"){const{pos:e}=this;return[e,t-e]}else return[t,t]}toJson(t){const e={op:"split",path:E(this.path),pos:this.pos};return this.props&&(e.props=this.props),e}toCompact(t,e){const r=e?"split":10;return this.props?[r,this.path,this.pos,this.props]:[r,this.path,this.pos]}encode(t,e){t.encodeArrayHeader(this.props?4:3),t.writer.u8(10),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeObject(this.props)}}class cs extends U{constructor(t,e,r){super(t);f(this,"pos");f(this,"props");this.pos=e,this.props=r}op(){return"merge"}code(){return 11}apply(t){const e=T(t,this.path);if(!lt(e))throw new Error("INVALID_TARGET");if(e.key<=0)throw new Error("INVALID_KEY");const r=e.obj[e.key-1],i=e.obj[e.key],o=this.merge(r,i);return e.obj[e.key-1]=o,e.obj.splice(e.key,1),{doc:t,old:[r,i]}}merge(t,e){return typeof t=="string"&&typeof e=="string"||typeof t=="number"&&typeof e=="number"?t+e:Nt(t)&&Nt(e)?{...t,...e,text:t.text+e.text}:Rt(t)&&Rt(e)?{...t,...e,children:[...t.children,...e.children]}:[t,e]}toJson(t){const e={op:"merge",path:E(this.path),pos:this.pos};return this.props&&(e.props=this.props),e}toCompact(t,e){const r=e?"merge":11;return this.props?[r,this.path,this.pos,this.props]:[r,this.path,this.pos]}encode(t,e){t.encodeArrayHeader(this.props?4:3),t.writer.u8(11),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeAny(this.props)}}const{isArray:ls}=Array;class us extends U{constructor(t,e,r){super(t);f(this,"props");f(this,"deleteNull");this.props=e,this.deleteNull=r}op(){return"extend"}code(){return 12}apply(t){const e=T(t,this.path);return lt(e)?e.val!==void 0&&(e.obj[e.key]=this.extend(e.val)):wt(e)?e.obj[e.key]=this.extend(e.val):t=this.extend(t),{doc:t}}extend(t){if(ls(t)||typeof t!="object"||!t)return t;for(const[e,r]of Object.entries(this.props)){if(e==="__proto__")throw new Error("NO_PROTO");if(r===null&&this.deleteNull){delete t[e];continue}t[e]=r}return t}toJson(t){const e={op:"extend",path:E(this.path),props:this.props};return this.deleteNull&&(e.deleteNull=this.deleteNull),e}toCompact(t,e){const r=e?"extend":12;return this.deleteNull?[r,this.path,this.props,1]:[r,this.path,this.props]}encode(t,e){const{deleteNull:r}=this;t.encodeArrayHeader(r?4:3),t.writer.u8(12),t.encodeArray(this.path),t.encodeObject(this.props),r&&t.writer.u8(1)}}class ps extends I{constructor(n){super(n)}op(){return"defined"}code(){return 31}test(n){const{val:t}=T(n,this.path);return t!==void 0}toJson(n){return{op:"defined",path:E(n?this.path.slice(n.path.length):this.path)}}toCompact(n,t){return[t?"defined":31,n?this.path.slice(n.path.length):this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(31),n.encodeArray(t?this.path.slice(t.path.length):this.path)}}class fs extends I{constructor(n){super(n)}op(){return"undefined"}code(){return 38}test(n){try{const{val:t}=T(n,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(n){return{op:"undefined",path:E(n?this.path.slice(n.path.length):this.path)}}toCompact(n,t){return[t?"undefined":38,n?this.path.slice(n.path.length):this.path]}encode(n,t){n.encodeArrayHeader(2),n.writer.u8(38),n.encodeArray(t?this.path.slice(t.path.length):this.path)}}const{isArray:ds}=Array;class gs extends I{constructor(t,e){super(t);f(this,"type");this.type=e}op(){return"test_type"}code(){return 39}test(t){const{val:e}=T(t,this.path);return e===null?this.type.indexOf("null")>-1:ds(e)?this.type.indexOf("array")>-1:this.type.indexOf(typeof e)>-1||typeof e=="number"&&e===Math.round(e)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:E(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,e){return[e?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeArray(this.type)}}class vs extends I{constructor(t,e,r,i){super(t);f(this,"pos");f(this,"str");f(this,"not");this.pos=e,this.str=r,this.not=i}op(){return"test_string"}code(){return 40}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=e.length,i=Math.min(this.pos,r),o=Math.min(this.pos+this.str.length,r),h=e.substring(i,o)===this.str;return this.not?!h:h}toJson(t){const e={op:"test_string",path:E(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=e?"test_string":40,i=t?this.path.slice(t.path.length):this.path;return this.not?[r,i,this.pos,this.str,1]:[r,i,this.pos,this.str]}encode(t,e){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class ys extends I{constructor(t,e,r){super(t);f(this,"len");f(this,"not");this.len=e,this.not=r}op(){return"test_string_len"}code(){return 41}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const i=e.length>=this.len;return this.not?!i:i}toJson(t){const e={op:"test_string_len",path:E(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(e.not=this.not),e}toCompact(t,e){const r=e?"test_string_len":41,i=t?this.path.slice(t.path.length):this.path;return this.not?[r,i,this.len,1]:[r,i,this.len]}encode(t,e){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class ms extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"contains"}code(){return 30}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.indexOf(i)>-1}toJson(t){const e={op:"contains",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"contains":30;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(30),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class ws extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"ends"}code(){return 32}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.endsWith(i)}toJson(t){const e={op:"ends",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"ends":32;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(32),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class _s extends I{constructor(t,e,r){super(t);f(this,"value");f(this,"ignore_case");this.value=e,this.ignore_case=r}op(){return"starts"}code(){return 37}test(t){const{val:e}=T(t,this.path);if(typeof e!="string")return!1;const r=this.ignore_case?e.toLowerCase():e,i=this.ignore_case?this.value.toLowerCase():this.value;return r.startsWith(i)}toJson(t){const e={op:"starts",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"starts":37;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(37),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}class bs extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"in"}code(){return 33}test(t){const{val:e}=T(t,this.path);for(const r of this.value)if(_t(e,r))return!0;return!1}toJson(t){return{op:"in",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeArray(this.value)}}class Es extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"less"}code(){return 34}test(t){const{val:e}=T(t,this.path);return typeof e!="number"?!1:e<this.value}toJson(t){return{op:"less",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.value)}}class $s extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"more"}code(){return 36}test(t){const{val:e}=T(t,this.path);return typeof e!="number"?!1:e>this.value}toJson(t){return{op:"more",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeNumber(this.value)}}class Ht extends I{constructor(t,e){super(t);f(this,"ops");this.ops=e}}class Cs extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"and"}code(){return 43}test(t){for(const e of this.ops)if(!e.test(t))return!1;return!0}toJson(t){return{op:"and",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){const r=e?this.path.slice(e.path.length):this.path;t.encodeArrayHeader(3),t.writer.u8(43),t.encodeArray(r);const i=this.ops.length;t.encodeArrayHeader(i);for(let o=0;o<i;o++)this.ops[o].encode(t,this)}}class ks extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"or"}code(){return 45}test(t){for(const e of this.ops)if(e.test(t))return!0;return!1}toJson(t){return{op:"or",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(e?this.path.slice(e.path.length):this.path);const r=this.ops.length;t.encodeArrayHeader(r);for(let i=0;i<r;i++)this.ops[i].encode(t,this)}}class As extends Ht{constructor(t,e){super(t,e);f(this,"ops");this.ops=e}op(){return"not"}code(){return 44}test(t){for(const e of this.ops)if(e.test(t))return!1;return!0}toJson(t){return{op:"not",path:E(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(r=>r.toJson(this))}}toCompact(t,e){return[e?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(i=>i.toCompact(this,e))]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(e?this.path.slice(e.path.length):this.path);const r=this.ops.length;t.encodeArrayHeader(r);for(let i=0;i<r;i++)this.ops[i].encode(t,this)}}class Ts extends I{constructor(t,e,r,i){super(t);f(this,"value");f(this,"ignore_case");f(this,"matcher");this.value=e,this.ignore_case=r,this.matcher=i(e,r)}op(){return"matches"}code(){return 35}test(t){const{val:e}=T(t,this.path);return typeof e!="string"?!1:this.matcher(e)}toJson(t){const e={op:"matches",path:E(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(e.ignore_case=this.ignore_case),e}toCompact(t,e){const r=e?"matches":35;return this.ignore_case?[r,t?this.path.slice(t.path.length):this.path,this.value,1]:[r,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){const r=this.ignore_case;t.encodeArrayHeader(r?4:3),t.writer.u8(35),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value),r&&t.writer.u8(1)}}const{isArray:Os}=Array;class js extends I{constructor(t,e){super(t);f(this,"value");this.value=e}op(){return"type"}code(){return 42}test(t){const{val:e}=T(t,this.path);return e===null?this.value==="null":Os(e)?this.value==="array":typeof e===this.value||typeof e=="number"&&e===Math.round(e)&&this.value==="integer"}toJson(t){return{op:"type",path:E(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,e){return[e?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,e){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(e?this.path.slice(e.path.length):this.path),t.encodeString(this.value)}}const xs=(s,n)=>{switch(s.op){case"add":return new Lt(w(s.path),s.value);case"remove":return new Zt(w(s.path),s.oldValue);case"replace":return new Qe(w(s.path),s.value,s.oldValue);case"move":return new Ke(w(s.path),w(s.from));case"copy":return new ts(w(s.path),w(s.from));case"flip":return new ss(w(s.path));case"inc":return new ns(w(s.path),s.inc);case"str_ins":return new rs(w(s.path),s.pos,s.str);case"str_del":return new is(w(s.path),s.pos,s.str,s.len);case"split":return new hs(w(s.path),s.pos,s.props||null);case"merge":return new cs(w(s.path),s.pos,s.props||null);case"extend":return new us(w(s.path),s.props,!!s.deleteNull);default:return bt(s,n)}},bt=(s,n)=>{switch(s.op){case"test":return new es(w(s.path),s.value,!!s.not);case"defined":return new ps(w(s.path));case"undefined":return new fs(w(s.path));case"type":return new js(w(s.path),s.value);case"test_type":return new gs(w(s.path),s.type);case"test_string":return new vs(w(s.path),s.pos,s.str,!!s.not);case"test_string_len":return new ys(w(s.path),s.len,!!s.not);case"contains":return new ms(w(s.path),s.value,!!s.ignore_case);case"ends":return new ws(w(s.path),s.value,!!s.ignore_case);case"starts":return new _s(w(s.path),s.value,!!s.ignore_case);case"matches":return new Ts(w(s.path),s.value,!!s.ignore_case,n.createMatcher||as);case"in":return new bs(w(s.path),s.value);case"less":return new Es(w(s.path),s.value);case"more":return new $s(w(s.path),s.value);case"and":{const t=w(s.path);return new Cs(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}case"or":{const t=w(s.path);return new ks(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}case"not":{const t=w(s.path);return new As(t,s.apply.map(e=>bt({...e,path:[...t,...w(e.path)]},n)))}default:throw new Error("OP_UNKNOWN")}};function Ss(s,n,t){t.mutate||(s=ct(s));const e=[],r=n.length;for(let i=0;i<r;i++){const h=xs(n[i],t).apply(s);s=h.doc,e.push(h)}return{doc:s,res:e}}var ut=s=>typeof s=="function"?s:function(){return s},Ms=typeof self<"u"?self:null,pt=typeof window<"u"?window:null,ft=Ms||pt||ft,Ls="2.0.0",B={connecting:0,open:1,closing:2,closed:3},Ns=1e4,Rs=1e3,z={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},W={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Pt={longpoll:"longpoll",websocket:"websocket"},Hs={complete:4},Et=class{constructor(s,n,t,e){this.channel=s,this.event=n,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=e,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(s){this.timeout=s,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(s,n){return this.hasReceived(s)&&n(this.receivedResp.response),this.recHooks.push({status:s,callback:n}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:s,response:n,_ref:t}){this.recHooks.filter(e=>e.status===s).forEach(e=>e.callback(n))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,s=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=s,this.matchReceive(s)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}trigger(s,n){this.channel.trigger(this.refEvent,{status:s,response:n})}},Qt=class{constructor(s,n){this.callback=s,this.timerCalc=n,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Ps=class{constructor(s,n,t){this.state=z.closed,this.topic=s,this.params=ut(n||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Et(this,W.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Qt(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=z.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=z.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=z.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=z.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Et(this,W.leave,ut({}),this.timeout).send(),this.state=z.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(W.reply,(e,r)=>{this.trigger(this.replyEventName(r),e)})}join(s=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=s,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(s){this.on(W.close,s)}onError(s){return this.on(W.error,n=>s(n))}on(s,n){let t=this.bindingRef++;return this.bindings.push({event:s,ref:t,callback:n}),t}off(s,n){this.bindings=this.bindings.filter(t=>!(t.event===s&&(typeof n>"u"||n===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(s,n,t=this.timeout){if(n=n||{},!this.joinedOnce)throw new Error(`tried to push '${s}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let e=new Et(this,s,function(){return n},t);return this.canPush()?e.send():(e.startTimeout(),this.pushBuffer.push(e)),e}leave(s=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=z.leaving;let n=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(W.close,"leave")},t=new Et(this,W.leave,ut({}),s);return t.receive("ok",()=>n()).receive("timeout",()=>n()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(s,n,t){return n}isMember(s,n,t,e){return this.topic!==s?!1:e&&e!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:s,event:n,payload:t,joinRef:e}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(s=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=z.joining,this.joinPush.resend(s))}trigger(s,n,t,e){let r=this.onMessage(s,n,t,e);if(n&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===s);for(let o=0;o<i.length;o++)i[o].callback(r,t,e||this.joinRef())}replyEventName(s){return`chan_reply_${s}`}isClosed(){return this.state===z.closed}isErrored(){return this.state===z.errored}isJoined(){return this.state===z.joined}isJoining(){return this.state===z.joining}isLeaving(){return this.state===z.leaving}},$t=class{static request(s,n,t,e,r,i,o){if(ft.XDomainRequest){let h=new ft.XDomainRequest;return this.xdomainRequest(h,s,n,e,r,i,o)}else{let h=new ft.XMLHttpRequest;return this.xhrRequest(h,s,n,t,e,r,i,o)}}static xdomainRequest(s,n,t,e,r,i,o){return s.timeout=r,s.open(n,t),s.onload=()=>{let h=this.parseJSON(s.responseText);o&&o(h)},i&&(s.ontimeout=i),s.onprogress=()=>{},s.send(e),s}static xhrRequest(s,n,t,e,r,i,o,h){return s.open(n,t,!0),s.timeout=i,s.setRequestHeader("Content-Type",e),s.onerror=()=>h&&h(null),s.onreadystatechange=()=>{if(s.readyState===Hs.complete&&h){let p=this.parseJSON(s.responseText);h(p)}},o&&(s.ontimeout=o),s.send(r),s}static parseJSON(s){if(!s||s==="")return null;try{return JSON.parse(s)}catch{return console&&console.log("failed to parse JSON response",s),null}}static serialize(s,n){let t=[];for(var e in s){if(!Object.prototype.hasOwnProperty.call(s,e))continue;let r=n?`${n}[${e}]`:e,i=s[e];typeof i=="object"?t.push(this.serialize(i,r)):t.push(encodeURIComponent(r)+"="+encodeURIComponent(i))}return t.join("&")}static appendParams(s,n){if(Object.keys(n).length===0)return s;let t=s.match(/\?/)?"&":"?";return`${s}${t}${this.serialize(n)}`}},It=class{constructor(s){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(s),this.readyState=B.connecting,this.poll()}normalizeEndpoint(s){return s.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Pt.websocket),"$1/"+Pt.longpoll)}endpointURL(){return $t.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(s,n,t){this.close(s,n,t),this.readyState=B.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===B.open||this.readyState===B.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),s=>{if(s){var{status:n,token:t,messages:e}=s;this.token=t}else n=0;switch(n){case 200:e.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=B.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${n}`)}})}send(s){this.ajax("POST",s,()=>this.onerror("timeout"),n=>{(!n||n.status!==200)&&(this.onerror(n&&n.status),this.closeAndRetry(1011,"internal server error",!1))})}close(s,n,t){for(let r of this.reqs)r.abort();this.readyState=B.closed;let e=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:s,reason:n,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",e)):this.onclose(e)}ajax(s,n,t,e){let r,i=()=>{this.reqs.delete(r),t()};r=$t.request(s,this.endpointURL(),"application/json",n,this.timeout,i,o=>{this.reqs.delete(r),this.isActive()&&e(o)}),this.reqs.add(r)}},Ct={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(s,n){if(s.payload.constructor===ArrayBuffer)return n(this.binaryEncode(s));{let t=[s.join_ref,s.ref,s.topic,s.event,s.payload];return n(JSON.stringify(t))}},decode(s,n){if(s.constructor===ArrayBuffer)return n(this.binaryDecode(s));{let[t,e,r,i,o]=JSON.parse(s);return n({join_ref:t,ref:e,topic:r,event:i,payload:o})}},binaryEncode(s){let{join_ref:n,ref:t,event:e,topic:r,payload:i}=s,o=this.META_LENGTH+n.length+t.length+r.length+e.length,h=new ArrayBuffer(this.HEADER_LENGTH+o),p=new DataView(h),d=0;p.setUint8(d++,this.KINDS.push),p.setUint8(d++,n.length),p.setUint8(d++,t.length),p.setUint8(d++,r.length),p.setUint8(d++,e.length),Array.from(n,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(t,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(r,_=>p.setUint8(d++,_.charCodeAt(0))),Array.from(e,_=>p.setUint8(d++,_.charCodeAt(0)));var b=new Uint8Array(h.byteLength+i.byteLength);return b.set(new Uint8Array(h),0),b.set(new Uint8Array(i),h.byteLength),b.buffer},binaryDecode(s){let n=new DataView(s),t=n.getUint8(0),e=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(s,n,e);case this.KINDS.reply:return this.decodeReply(s,n,e);case this.KINDS.broadcast:return this.decodeBroadcast(s,n,e)}},decodePush(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=n.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,h=t.decode(s.slice(o,o+e));o=o+e;let p=t.decode(s.slice(o,o+r));o=o+r;let d=t.decode(s.slice(o,o+i));o=o+i;let b=s.slice(o,s.byteLength);return{join_ref:h,ref:null,topic:p,event:d,payload:b}},decodeReply(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=n.getUint8(3),o=n.getUint8(4),h=this.HEADER_LENGTH+this.META_LENGTH,p=t.decode(s.slice(h,h+e));h=h+e;let d=t.decode(s.slice(h,h+r));h=h+r;let b=t.decode(s.slice(h,h+i));h=h+i;let _=t.decode(s.slice(h,h+o));h=h+o;let A=s.slice(h,s.byteLength),O={status:_,response:A};return{join_ref:p,ref:d,topic:b,event:W.reply,payload:O}},decodeBroadcast(s,n,t){let e=n.getUint8(1),r=n.getUint8(2),i=this.HEADER_LENGTH+2,o=t.decode(s.slice(i,i+e));i=i+e;let h=t.decode(s.slice(i,i+r));i=i+r;let p=s.slice(i,s.byteLength);return{join_ref:null,ref:null,topic:o,event:h,payload:p}}},Is=class{constructor(s,n={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=n.timeout||Ns,this.transport=n.transport||ft.WebSocket||It,this.establishedConnections=0,this.defaultEncoder=Ct.encode.bind(Ct),this.defaultDecoder=Ct.decode.bind(Ct),this.closeWasClean=!1,this.binaryType=n.binaryType||"arraybuffer",this.connectClock=1,this.transport!==It?(this.encode=n.encode||this.defaultEncoder,this.decode=n.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;pt&&pt.addEventListener&&(pt.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),t=this.connectClock)}),pt.addEventListener("pageshow",e=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=n.heartbeatIntervalMs||3e4,this.rejoinAfterMs=e=>n.rejoinAfterMs?n.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>n.reconnectAfterMs?n.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=n.logger||null,this.longpollerTimeout=n.longpollerTimeout||2e4,this.params=ut(n.params||{}),this.endPoint=`${s}/${Pt.websocket}`,this.vsn=n.vsn||Ls,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Qt(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return It}replaceTransport(s){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=s}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let s=$t.appendParams($t.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return s.charAt(0)!=="/"?s:s.charAt(1)==="/"?`${this.protocol()}:${s}`:`${this.protocol()}://${location.host}${s}`}disconnect(s,n,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(s,n,t)}connect(s){s&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=ut(s)),!this.conn&&(this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=n=>this.onConnError(n),this.conn.onmessage=n=>this.onConnMessage(n),this.conn.onclose=n=>this.onConnClose(n))}log(s,n,t){this.logger(s,n,t)}hasLogger(){return this.logger!==null}onOpen(s){let n=this.makeRef();return this.stateChangeCallbacks.open.push([n,s]),n}onClose(s){let n=this.makeRef();return this.stateChangeCallbacks.close.push([n,s]),n}onError(s){let n=this.makeRef();return this.stateChangeCallbacks.error.push([n,s]),n}onMessage(s){let n=this.makeRef();return this.stateChangeCallbacks.message.push([n,s]),n}ping(s){if(!this.isConnected())return!1;let n=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:n});let e=this.onMessage(r=>{r.ref===n&&(this.off([e]),s(Date.now()-t))});return!0}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,s])=>s())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Rs,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(s,n,t){if(!this.conn)return s&&s();this.waitForBufferDone(()=>{this.conn&&(n?this.conn.close(n,t||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),s&&s()})})}waitForBufferDone(s,n=1){if(n===5||!this.conn||!this.conn.bufferedAmount){s();return}setTimeout(()=>{this.waitForBufferDone(s,n+1)},150*n)}waitForSocketClosed(s,n=1){if(n===5||!this.conn||this.conn.readyState===B.closed){s();return}setTimeout(()=>{this.waitForSocketClosed(s,n+1)},150*n)}onConnClose(s){let n=s&&s.code;this.hasLogger()&&this.log("transport","close",s),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&n!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(s))}onConnError(s){this.hasLogger()&&this.log("transport",s);let n=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,e])=>{e(s,n,t)}),(n===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(s=>{s.isErrored()||s.isLeaving()||s.isClosed()||s.trigger(W.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case B.connecting:return"connecting";case B.open:return"open";case B.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(s){this.off(s.stateChangeRefs),this.channels=this.channels.filter(n=>n.joinRef()!==s.joinRef())}off(s){for(let n in this.stateChangeCallbacks)this.stateChangeCallbacks[n]=this.stateChangeCallbacks[n].filter(([t])=>s.indexOf(t)===-1)}channel(s,n={}){let t=new Ps(s,n,this);return this.channels.push(t),t}push(s){if(this.hasLogger()){let{topic:n,event:t,payload:e,ref:r,join_ref:i}=s;this.log("push",`${n} ${t} (${i}, ${r})`,e)}this.isConnected()?this.encode(s,n=>this.conn.send(n)):this.sendBuffer.push(()=>this.encode(s,n=>this.conn.send(n)))}makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}onConnMessage(s){this.decode(s.data,n=>{let{topic:t,event:e,payload:r,ref:i,join_ref:o}=n;i&&i===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${r.status||""} ${t} ${e} ${i&&"("+i+")"||""}`,r);for(let h=0;h<this.channels.length;h++){const p=this.channels[h];p.isMember(t,e,r,o)&&p.trigger(e,r,i,o)}for(let h=0;h<this.stateChangeCallbacks.message.length;h++){let[,p]=this.stateChangeCallbacks.message[h];p(n)}})}leaveOpenTopic(s){let n=this.channels.find(t=>t.topic===s&&(t.isJoined()||t.isJoining()));n&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${s}"`),n.leave())}};class Ds{constructor(n){this.connected=!1,this.config=n,this.socket=new Is(this.config.url,{logger:(t,e,r)=>{console.log(`${t}: ${e}`,r)}}),this.channel=this.socket.channel(this.config.topic,this.config.params),this.eventTarget=new EventTarget}connect(){this.connected||(this.socket.onError(n=>this.emitError("socket error",n)),this.socket.connect(),this.channel.onError(n=>console.log("channel error",n)),this.channel.join().receive("ok",()=>{console.log("joined")}).receive("error",n=>{this.emitError("channel join error",n)}),this.channel.on("state:change",n=>this.handleChange(n)),this.channel.on("state:patch",n=>this.handlePatch(n)),this.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(n,t,e){var r;this.eventTarget.addEventListener(n,t,e),n.startsWith("livestate-")||(r=this.channel)==null||r.on(n,i=>{this.eventTarget.dispatchEvent(new CustomEvent(n,{detail:i}))})}removeEventListener(n,t,e){return this.eventTarget.removeEventListener(n,t,e)}subscribe(n){this.addEventListener("livestate-change",n)}unsubscribe(n){this.removeEventListener("livestate-change",n)}emitError(n,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{kind:n,error:t}}))}handleChange({state:n,version:t}){this.state=n,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}handlePatch({patch:n,version:t}){if(this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch",{detail:{patch:n,version:t}})),t===this.stateVersion+1){const{doc:e,res:r}=Ss(this.state,n,{mutate:!1});this.state=e,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}else this.channel.push("lvs_refresh")}pushEvent(n,t){this.dispatchEvent(new CustomEvent(n,{detail:t}))}dispatchEvent(n){return this.channel.push(`lvs_evt:${n.type}`,n.detail),!0}pushCustomEvent(n){this.dispatchEvent(n)}}Promise.resolve();var Kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,4 +11,4 @@
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var te;(function(s){(function(n){var t=typeof Kt=="object"?Kt:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),e=r(s);typeof t.Reflect>"u"?t.Reflect=s:e=r(t.Reflect,e),n(e);function r(i,o){return function(h,p){typeof i[h]!="function"&&Object.defineProperty(i,h,{configurable:!0,writable:!0,value:p}),o&&o(h,p)}}})(function(n){var t=Object.prototype.hasOwnProperty,e=typeof Symbol=="function",r=e&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",i=e&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",h={__proto__:[]}instanceof Array,p=!o&&!h,d={create:o?function(){return Jt(Object.create(null))}:h?function(){return Jt({__proto__:null})}:function(){return Jt({})},has:p?function(a,c){return t.call(a,c)}:function(a,c){return c in a},get:p?function(a,c){return t.call(a,c)?a[c]:void 0}:function(a,c){return a[c]}},b=Object.getPrototypeOf(Function),_=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",A=!_&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:tn(),O=!_&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:en(),x=!_&&typeof WeakMap=="function"?WeakMap:sn(),R=new x;function L(a,c,l,u){if(M(l)){if(!pe(a))throw new TypeError;if(!fe(c))throw new TypeError;return st(a,c)}else{if(!pe(a))throw new TypeError;if(!N(c))throw new TypeError;if(!N(u)&&!M(u)&&!nt(u))throw new TypeError;return nt(u)&&(u=void 0),l=W(l),qs(a,c,l,u)}}n("decorate",L);function k(a,c){function l(u,g){if(!N(u))throw new TypeError;if(!M(g)&&!Xs(g))throw new TypeError;he(a,c,u,g)}return l}n("metadata",k);function et(a,c,l,u){if(!N(l))throw new TypeError;return M(u)||(u=W(u)),he(a,c,l,u)}n("defineMetadata",et);function kt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=W(l)),ie(a,c,l)}n("hasMetadata",kt);function At(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=W(l)),Dt(a,c,l)}n("hasOwnMetadata",At);function Tt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=W(l)),oe(a,c,l)}n("getMetadata",Tt);function dt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=W(l)),ae(a,c,l)}n("getOwnMetadata",dt);function S(a,c){if(!N(a))throw new TypeError;return M(c)||(c=W(c)),ce(a,c)}n("getMetadataKeys",S);function V(a,c){if(!N(a))throw new TypeError;return M(c)||(c=W(c)),le(a,c)}n("getOwnMetadataKeys",V);function q(a,c,l){if(!N(c))throw new TypeError;M(l)||(l=W(l));var u=gt(c,l,!1);if(M(u)||!u.delete(a))return!1;if(u.size>0)return!0;var g=R.get(c);return g.delete(l),g.size>0||R.delete(c),!0}n("deleteMetadata",q);function st(a,c){for(var l=a.length-1;l>=0;--l){var u=a[l],g=u(c);if(!M(g)&&!nt(g)){if(!fe(g))throw new TypeError;c=g}}return c}function qs(a,c,l,u){for(var g=a.length-1;g>=0;--g){var H=a[g],y=H(c,l,u);if(!M(y)&&!nt(y)){if(!N(y))throw new TypeError;u=y}}return u}function gt(a,c,l){var u=R.get(a);if(M(u)){if(!l)return;u=new A,R.set(a,u)}var g=u.get(c);if(M(g)){if(!l)return;g=new A,u.set(c,g)}return g}function ie(a,c,l){var u=Dt(a,c,l);if(u)return!0;var g=Ut(c);return nt(g)?!1:ie(a,g,l)}function Dt(a,c,l){var u=gt(c,l,!1);return M(u)?!1:Ws(u.has(a))}function oe(a,c,l){var u=Dt(a,c,l);if(u)return ae(a,c,l);var g=Ut(c);if(!nt(g))return oe(a,g,l)}function ae(a,c,l){var u=gt(c,l,!1);if(!M(u))return u.get(a)}function he(a,c,l,u){var g=gt(l,u,!0);g.set(a,c)}function ce(a,c){var l=le(a,c),u=Ut(a);if(u===null)return l;var g=ce(u,c);if(g.length<=0)return l;if(l.length<=0)return g;for(var H=new O,y=[],m=0,v=l;m<v.length;m++){var $=v[m],C=H.has($);C||(H.add($),y.push($))}for(var X=0,ge=g;X<ge.length;X++){var $=ge[X],C=H.has($);C||(H.add($),y.push($))}return y}function le(a,c){var l=[],u=gt(a,c,!1);if(M(u))return l;for(var g=u.keys(),H=Ys(g),y=0;;){var m=Qs(H);if(!m)return l.length=y,l;var v=Zs(m);try{l[y]=v}catch($){try{Ks(H)}finally{throw $}}y++}}function ue(a){if(a===null)return 1;switch(typeof a){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return a===null?1:6;default:return 6}}function M(a){return a===void 0}function nt(a){return a===null}function Bs(a){return typeof a=="symbol"}function N(a){return typeof a=="object"?a!==null:typeof a=="function"}function Fs(a,c){switch(ue(a)){case 0:return a;case 1:return a;case 2:return a;case 3:return a;case 4:return a;case 5:return a}var l=c===3?"string":c===5?"number":"default",u=de(a,r);if(u!==void 0){var g=u.call(a,l);if(N(g))throw new TypeError;return g}return zs(a,l==="default"?"number":l)}function zs(a,c){if(c==="string"){var l=a.toString;if(rt(l)){var u=l.call(a);if(!N(u))return u}var g=a.valueOf;if(rt(g)){var u=g.call(a);if(!N(u))return u}}else{var g=a.valueOf;if(rt(g)){var u=g.call(a);if(!N(u))return u}var H=a.toString;if(rt(H)){var u=H.call(a);if(!N(u))return u}}throw new TypeError}function Ws(a){return!!a}function Gs(a){return""+a}function W(a){var c=Fs(a,3);return Bs(c)?c:Gs(c)}function pe(a){return Array.isArray?Array.isArray(a):a instanceof Object?a instanceof Array:Object.prototype.toString.call(a)==="[object Array]"}function rt(a){return typeof a=="function"}function fe(a){return typeof a=="function"}function Xs(a){switch(ue(a)){case 3:return!0;case 4:return!0;default:return!1}}function de(a,c){var l=a[c];if(l!=null){if(!rt(l))throw new TypeError;return l}}function Ys(a){var c=de(a,i);if(!rt(c))throw new TypeError;var l=c.call(a);if(!N(l))throw new TypeError;return l}function Zs(a){return a.value}function Qs(a){var c=a.next();return c.done?!1:c}function Ks(a){var c=a.return;c&&c.call(a)}function Ut(a){var c=Object.getPrototypeOf(a);if(typeof a!="function"||a===b||c!==b)return c;var l=a.prototype,u=l&&Object.getPrototypeOf(l);if(u==null||u===Object.prototype)return c;var g=u.constructor;return typeof g!="function"||g===a?c:g}function tn(){var a={},c=[],l=function(){function y(m,v,$){this._index=0,this._keys=m,this._values=v,this._selector=$}return y.prototype["@@iterator"]=function(){return this},y.prototype[i]=function(){return this},y.prototype.next=function(){var m=this._index;if(m>=0&&m<this._keys.length){var v=this._selector(this._keys[m],this._values[m]);return m+1>=this._keys.length?(this._index=-1,this._keys=c,this._values=c):this._index++,{value:v,done:!1}}return{value:void 0,done:!0}},y.prototype.throw=function(m){throw this._index>=0&&(this._index=-1,this._keys=c,this._values=c),m},y.prototype.return=function(m){return this._index>=0&&(this._index=-1,this._keys=c,this._values=c),{value:m,done:!0}},y}();return function(){function y(){this._keys=[],this._values=[],this._cacheKey=a,this._cacheIndex=-2}return Object.defineProperty(y.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),y.prototype.has=function(m){return this._find(m,!1)>=0},y.prototype.get=function(m){var v=this._find(m,!1);return v>=0?this._values[v]:void 0},y.prototype.set=function(m,v){var $=this._find(m,!0);return this._values[$]=v,this},y.prototype.delete=function(m){var v=this._find(m,!1);if(v>=0){for(var $=this._keys.length,C=v+1;C<$;C++)this._keys[C-1]=this._keys[C],this._values[C-1]=this._values[C];return this._keys.length--,this._values.length--,m===this._cacheKey&&(this._cacheKey=a,this._cacheIndex=-2),!0}return!1},y.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=a,this._cacheIndex=-2},y.prototype.keys=function(){return new l(this._keys,this._values,u)},y.prototype.values=function(){return new l(this._keys,this._values,g)},y.prototype.entries=function(){return new l(this._keys,this._values,H)},y.prototype["@@iterator"]=function(){return this.entries()},y.prototype[i]=function(){return this.entries()},y.prototype._find=function(m,v){return this._cacheKey!==m&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=m)),this._cacheIndex<0&&v&&(this._cacheIndex=this._keys.length,this._keys.push(m),this._values.push(void 0)),this._cacheIndex},y}();function u(y,m){return y}function g(y,m){return m}function H(y,m){return[y,m]}}function en(){return function(){function a(){this._map=new A}return Object.defineProperty(a.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),a.prototype.has=function(c){return this._map.has(c)},a.prototype.add=function(c){return this._map.set(c,c),this},a.prototype.delete=function(c){return this._map.delete(c)},a.prototype.clear=function(){this._map.clear()},a.prototype.keys=function(){return this._map.keys()},a.prototype.values=function(){return this._map.values()},a.prototype.entries=function(){return this._map.entries()},a.prototype["@@iterator"]=function(){return this.keys()},a.prototype[i]=function(){return this.keys()},a}()}function sn(){var a=16,c=d.create(),l=u();return function(){function v(){this._key=u()}return v.prototype.has=function($){var C=g($,!1);return C!==void 0?d.has(C,this._key):!1},v.prototype.get=function($){var C=g($,!1);return C!==void 0?d.get(C,this._key):void 0},v.prototype.set=function($,C){var X=g($,!0);return X[this._key]=C,this},v.prototype.delete=function($){var C=g($,!1);return C!==void 0?delete C[this._key]:!1},v.prototype.clear=function(){this._key=u()},v}();function u(){var v;do v="@@WeakMap@@"+m();while(d.has(c,v));return c[v]=!0,v}function g(v,$){if(!t.call(v,l)){if(!$)return;Object.defineProperty(v,l,{value:d.create()})}return v[l]}function H(v,$){for(var C=0;C<$;++C)v[C]=Math.random()*255|0;return v}function y(v){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(v)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(v)):H(new Uint8Array(v),v):H(new Array(v),v)}function m(){var v=y(a);v[6]=v[6]&79|64,v[8]=v[8]&191|128;for(var $="",C=0;C<a;++C){var X=v[C];(C===4||C===6||C===8)&&($+="-"),X<16&&($+="0"),$+=X.toString(16).toLowerCase()}return $}}function Jt(a){return a.__=void 0,delete a.__,a}})})(te||(te={}));function Us(s){me(s,"svelte-w16tqa","#liveroom-client-element.svelte-w16tqa.svelte-w16tqa{font-family:Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;line-height:1.5;font-weight:400;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}#users-container.svelte-w16tqa.svelte-w16tqa{position:absolute;inset:0;overflow:hidden;pointer-events:none}.user.svelte-w16tqa.svelte-w16tqa{z-index:1000;position:absolute;top:0;left:0;user-select:none;transform:translate(var(--x), var(--y))}.user.svelte-w16tqa .cursor.svelte-w16tqa{position:absolute;top:0;left:0;color:var(--color);transform-origin:top left;transform:rotate(6deg)}.user[data-isself='true'].svelte-w16tqa .cursor.svelte-w16tqa{display:none}.user-name.svelte-w16tqa.svelte-w16tqa{padding:4px 10px;font-size:14px;line-height:20px;font-weight:600;color:black;background-color:var(--color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:9999px;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-w16tqa .user-name.svelte-w16tqa{position:absolute;top:20px;left:16px}.user[data-isself='true'].svelte-w16tqa .user-name.svelte-w16tqa{display:none}.user.svelte-w16tqa .halo.svelte-w16tqa{transform:scale(0);z-index:-1;position:absolute;top:-60px;left:-60px;width:120px;height:120px;border-radius:9999px;background-color:var(--color);opacity:0.25;transition:transform 0.15s ease-out;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-w16tqa .halo[data-show='true'].svelte-w16tqa{transform:scale(1)}")}function ee(s,n,t){const e=s.slice();return e[14]=n[t],e}function se(s){let n,t=[],e=new Map,r=Gt(Object.values(s[2]));const i=o=>o[14].id;for(let o=0;o<r.length;o+=1){let h=ee(s,r,o),p=i(h);e.set(p,t[o]=ne(p,h))}return{c(){n=Y("div");for(let o=0;o<t.length;o+=1)t[o].c();j(n,"id","users-container"),j(n,"class","svelte-w16tqa")},m(o,h){vt(o,n,h);for(let p=0;p<t.length;p+=1)t[p]&&t[p].m(n,null)},p(o,h){h&6&&(r=Gt(Object.values(o[2])),t=Me(t,h,i,1,o,r,e,n,Se,ne,null,ee))},d(o){o&&ot(n);for(let h=0;h<t.length;h+=1)t[h].d()}}}function ne(s,n){let t,e,r,i,o,h=n[14].name+"",p,d,b,_,A,O,x;return{key:s,first:null,c(){t=Y("div"),e=qt("svg"),r=qt("path"),i=Ot(),o=Y("span"),p=Bt(h),d=Ot(),b=Y("div"),A=Ot(),j(r,"d","M2.2706 0.0593359L25.4277 8.05957H25.45926C25.65896 8.13153 25.83096 8.25952 25.95221 8.42653C26.07357 8.59354 26.13851 8.79166 26.13851 8.99459C26.13851 9.19751 26.07357 9.39564 25.95221 9.56265C25.83096 9.72966 25.65896 9.85765 25.45926 9.92962L15.3543 13.7698L11.3124 23.37C11.2344 23.5561 11.0994 23.7156 10.9248 23.828C10.7503 23.9402 10.5443 24.0002 10.3335 24C10.1172 24 9.9061 23.9365 9.7291 23.8184C9.552 23.7004 9.4176 23.5332 9.344 23.34L0.9233 1.33937C0.8555 1.16076 0.8426 0.967504 0.8861 0.782189C0.9297 0.596873 1.0278 0.427163 1.1691 0.292901C1.3105 0.158639 1.4891 0.0653762 1.6841 0.0240151C1.8792 -0.0173461 2.0826 -0.00509504 2.2706 0.0593359Z"),j(e,"width","23"),j(e,"viewBox","0 0 27 24"),j(e,"fill","currentColor"),j(e,"aria-hidden","true"),j(e,"xmlns","http://www.w3.org/2000/svg"),j(e,"class","cursor svelte-w16tqa"),j(o,"class","user-name svelte-w16tqa"),j(b,"class","halo svelte-w16tqa"),j(b,"data-show",_=n[14].is_mouse_down||n[14].is_escape_key_down),j(t,"id",O="user-"+n[14].id),j(t,"class","user svelte-w16tqa"),j(t,"data-isself",x=n[14].id==n[1].id),Z(t,"--color",n[14].color),Z(t,"--x",parseFloat(n[14].x)+"vw"),Z(t,"--y",parseFloat(n[14].y)+"vh"),this.first=t},m(R,L){vt(R,t,L),F(t,e),F(e,r),F(t,i),F(t,o),F(o,p),F(t,d),F(t,b),F(t,A)},p(R,L){n=R,L&4&&h!==(h=n[14].name+"")&&Ee(p,h),L&4&&_!==(_=n[14].is_mouse_down||n[14].is_escape_key_down)&&j(b,"data-show",_),L&4&&O!==(O="user-"+n[14].id)&&j(t,"id",O),L&6&&x!==(x=n[14].id==n[1].id)&&j(t,"data-isself",x),L&4&&Z(t,"--color",n[14].color),L&4&&Z(t,"--x",parseFloat(n[14].x)+"vw"),L&4&&Z(t,"--y",parseFloat(n[14].y)+"vh")},d(R){R&&ot(t)}}}function Js(s){let n,t=s[1]&&s[2]&&se(s);return{c(){n=Y("div"),t&&t.c(),j(n,"id","liveroom-client-element"),j(n,"class","svelte-w16tqa")},m(e,r){vt(e,n,r),t&&t.m(n,null),s[5](n)},p(e,[r]){e[1]&&e[2]?t?t.p(e,r):(t=se(e),t.c(),t.m(n,null)):t&&(t.d(1),t=null)},i:P,o:P,d(e){e&&ot(n),t&&t.d(),s[5](null)}}}function Vs(s,n,t){let{url:e}=n,{room_id:r}=n,i,o,h,p;Ce(async()=>{o=new Ds({url:e,topic:`liveroom-livestate:${r}`,params:{room_id:r,current_url:window.origin,inner_width:window.innerWidth,inner_height:window.innerHeight}}),o.connect(),o.addEventListener("livestate-change",({detail:{state:k}})=>{t(3,r=k.room_id),t(1,h=k.me),t(2,p=k.users)}),window.addEventListener("mousemove",d),window.addEventListener("mousedown",b),window.addEventListener("mouseup",_),window.addEventListener("keydown",O),window.addEventListener("keyup",x),window.addEventListener("resize",R)}),ke(()=>{window.removeEventListener("resize",R),window.removeEventListener("keyup",x),window.removeEventListener("keydown",O),window.removeEventListener("mouseup",_),window.removeEventListener("mousedown",b),window.removeEventListener("mousemove",d),o==null||o.disconnect()});function d(k){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_move",{detail:{user_id:h.id,x:Number(k.pageX/window.innerWidth*100).toFixed(2),y:Number(k.pageY/window.innerHeight*100).toFixed(2)}}))}function b(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_down",{detail:{user_id:h.id}}))}function _(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_up",{detail:{user_id:h.id}}))}const A=["Escape"];function O(k){!k.repeat&&A.includes(k.key)&&o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("key_down",{detail:{key:k.key,user_id:h.id}}))}function x(k){A.includes(k.key)&&o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("key_up",{detail:{key:k.key,user_id:h.id}}))}function R(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("window_resize",{detail:{inner_width:window.innerWidth,inner_height:window.innerHeight,user_id:h.id}}))}function L(k){jt[k?"unshift":"push"](()=>{i=k,t(0,i)})}return s.$$set=k=>{"url"in k&&t(4,e=k.url),"room_id"in k&&t(3,r=k.room_id)},[i,h,p,r,e,L]}class re extends Ie{constructor(n){super(),He(this,n,Vs,Js,ve,{url:4,room_id:3},Us)}get url(){return this.$$.ctx[4]}set url(n){this.$$set({url:n}),yt()}get room_id(){return this.$$.ctx[3]}set room_id(n){this.$$set({room_id:n}),yt()}}return customElements.define("liveroom-client-element",Pe(re,{url:{},room_id:{}},[],[],!0)),re});
14
+ ***************************************************************************** */var te;(function(s){(function(n){var t=typeof Kt=="object"?Kt:typeof self=="object"?self:typeof this=="object"?this:Function("return this;")(),e=r(s);typeof t.Reflect>"u"?t.Reflect=s:e=r(t.Reflect,e),n(e);function r(i,o){return function(h,p){typeof i[h]!="function"&&Object.defineProperty(i,h,{configurable:!0,writable:!0,value:p}),o&&o(h,p)}}})(function(n){var t=Object.prototype.hasOwnProperty,e=typeof Symbol=="function",r=e&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",i=e&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",h={__proto__:[]}instanceof Array,p=!o&&!h,d={create:o?function(){return zt(Object.create(null))}:h?function(){return zt({__proto__:null})}:function(){return zt({})},has:p?function(a,c){return t.call(a,c)}:function(a,c){return c in a},get:p?function(a,c){return t.call(a,c)?a[c]:void 0}:function(a,c){return a[c]}},b=Object.getPrototypeOf(Function),_=typeof process=="object"&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL==="true",A=!_&&typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:tn(),O=!_&&typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:en(),x=!_&&typeof WeakMap=="function"?WeakMap:sn(),R=new x;function L(a,c,l,u){if(M(l)){if(!pe(a))throw new TypeError;if(!fe(c))throw new TypeError;return st(a,c)}else{if(!pe(a))throw new TypeError;if(!N(c))throw new TypeError;if(!N(u)&&!M(u)&&!nt(u))throw new TypeError;return nt(u)&&(u=void 0),l=G(l),Vs(a,c,l,u)}}n("decorate",L);function k(a,c){function l(u,g){if(!N(u))throw new TypeError;if(!M(g)&&!qs(g))throw new TypeError;he(a,c,u,g)}return l}n("metadata",k);function et(a,c,l,u){if(!N(l))throw new TypeError;return M(u)||(u=G(u)),he(a,c,l,u)}n("defineMetadata",et);function kt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=G(l)),ie(a,c,l)}n("hasMetadata",kt);function At(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=G(l)),Dt(a,c,l)}n("hasOwnMetadata",At);function Tt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=G(l)),oe(a,c,l)}n("getMetadata",Tt);function dt(a,c,l){if(!N(c))throw new TypeError;return M(l)||(l=G(l)),ae(a,c,l)}n("getOwnMetadata",dt);function S(a,c){if(!N(a))throw new TypeError;return M(c)||(c=G(c)),ce(a,c)}n("getMetadataKeys",S);function J(a,c){if(!N(a))throw new TypeError;return M(c)||(c=G(c)),le(a,c)}n("getOwnMetadataKeys",J);function V(a,c,l){if(!N(c))throw new TypeError;M(l)||(l=G(l));var u=gt(c,l,!1);if(M(u)||!u.delete(a))return!1;if(u.size>0)return!0;var g=R.get(c);return g.delete(l),g.size>0||R.delete(c),!0}n("deleteMetadata",V);function st(a,c){for(var l=a.length-1;l>=0;--l){var u=a[l],g=u(c);if(!M(g)&&!nt(g)){if(!fe(g))throw new TypeError;c=g}}return c}function Vs(a,c,l,u){for(var g=a.length-1;g>=0;--g){var H=a[g],y=H(c,l,u);if(!M(y)&&!nt(y)){if(!N(y))throw new TypeError;u=y}}return u}function gt(a,c,l){var u=R.get(a);if(M(u)){if(!l)return;u=new A,R.set(a,u)}var g=u.get(c);if(M(g)){if(!l)return;g=new A,u.set(c,g)}return g}function ie(a,c,l){var u=Dt(a,c,l);if(u)return!0;var g=Ut(c);return nt(g)?!1:ie(a,g,l)}function Dt(a,c,l){var u=gt(c,l,!1);return M(u)?!1:Gs(u.has(a))}function oe(a,c,l){var u=Dt(a,c,l);if(u)return ae(a,c,l);var g=Ut(c);if(!nt(g))return oe(a,g,l)}function ae(a,c,l){var u=gt(c,l,!1);if(!M(u))return u.get(a)}function he(a,c,l,u){var g=gt(l,u,!0);g.set(a,c)}function ce(a,c){var l=le(a,c),u=Ut(a);if(u===null)return l;var g=ce(u,c);if(g.length<=0)return l;if(l.length<=0)return g;for(var H=new O,y=[],m=0,v=l;m<v.length;m++){var $=v[m],C=H.has($);C||(H.add($),y.push($))}for(var q=0,ge=g;q<ge.length;q++){var $=ge[q],C=H.has($);C||(H.add($),y.push($))}return y}function le(a,c){var l=[],u=gt(a,c,!1);if(M(u))return l;for(var g=u.keys(),H=Ys(g),y=0;;){var m=Qs(H);if(!m)return l.length=y,l;var v=Zs(m);try{l[y]=v}catch($){try{Ks(H)}finally{throw $}}y++}}function ue(a){if(a===null)return 1;switch(typeof a){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return a===null?1:6;default:return 6}}function M(a){return a===void 0}function nt(a){return a===null}function Bs(a){return typeof a=="symbol"}function N(a){return typeof a=="object"?a!==null:typeof a=="function"}function Fs(a,c){switch(ue(a)){case 0:return a;case 1:return a;case 2:return a;case 3:return a;case 4:return a;case 5:return a}var l=c===3?"string":c===5?"number":"default",u=de(a,r);if(u!==void 0){var g=u.call(a,l);if(N(g))throw new TypeError;return g}return Ws(a,l==="default"?"number":l)}function Ws(a,c){if(c==="string"){var l=a.toString;if(rt(l)){var u=l.call(a);if(!N(u))return u}var g=a.valueOf;if(rt(g)){var u=g.call(a);if(!N(u))return u}}else{var g=a.valueOf;if(rt(g)){var u=g.call(a);if(!N(u))return u}var H=a.toString;if(rt(H)){var u=H.call(a);if(!N(u))return u}}throw new TypeError}function Gs(a){return!!a}function Xs(a){return""+a}function G(a){var c=Fs(a,3);return Bs(c)?c:Xs(c)}function pe(a){return Array.isArray?Array.isArray(a):a instanceof Object?a instanceof Array:Object.prototype.toString.call(a)==="[object Array]"}function rt(a){return typeof a=="function"}function fe(a){return typeof a=="function"}function qs(a){switch(ue(a)){case 3:return!0;case 4:return!0;default:return!1}}function de(a,c){var l=a[c];if(l!=null){if(!rt(l))throw new TypeError;return l}}function Ys(a){var c=de(a,i);if(!rt(c))throw new TypeError;var l=c.call(a);if(!N(l))throw new TypeError;return l}function Zs(a){return a.value}function Qs(a){var c=a.next();return c.done?!1:c}function Ks(a){var c=a.return;c&&c.call(a)}function Ut(a){var c=Object.getPrototypeOf(a);if(typeof a!="function"||a===b||c!==b)return c;var l=a.prototype,u=l&&Object.getPrototypeOf(l);if(u==null||u===Object.prototype)return c;var g=u.constructor;return typeof g!="function"||g===a?c:g}function tn(){var a={},c=[],l=function(){function y(m,v,$){this._index=0,this._keys=m,this._values=v,this._selector=$}return y.prototype["@@iterator"]=function(){return this},y.prototype[i]=function(){return this},y.prototype.next=function(){var m=this._index;if(m>=0&&m<this._keys.length){var v=this._selector(this._keys[m],this._values[m]);return m+1>=this._keys.length?(this._index=-1,this._keys=c,this._values=c):this._index++,{value:v,done:!1}}return{value:void 0,done:!0}},y.prototype.throw=function(m){throw this._index>=0&&(this._index=-1,this._keys=c,this._values=c),m},y.prototype.return=function(m){return this._index>=0&&(this._index=-1,this._keys=c,this._values=c),{value:m,done:!0}},y}();return function(){function y(){this._keys=[],this._values=[],this._cacheKey=a,this._cacheIndex=-2}return Object.defineProperty(y.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),y.prototype.has=function(m){return this._find(m,!1)>=0},y.prototype.get=function(m){var v=this._find(m,!1);return v>=0?this._values[v]:void 0},y.prototype.set=function(m,v){var $=this._find(m,!0);return this._values[$]=v,this},y.prototype.delete=function(m){var v=this._find(m,!1);if(v>=0){for(var $=this._keys.length,C=v+1;C<$;C++)this._keys[C-1]=this._keys[C],this._values[C-1]=this._values[C];return this._keys.length--,this._values.length--,m===this._cacheKey&&(this._cacheKey=a,this._cacheIndex=-2),!0}return!1},y.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=a,this._cacheIndex=-2},y.prototype.keys=function(){return new l(this._keys,this._values,u)},y.prototype.values=function(){return new l(this._keys,this._values,g)},y.prototype.entries=function(){return new l(this._keys,this._values,H)},y.prototype["@@iterator"]=function(){return this.entries()},y.prototype[i]=function(){return this.entries()},y.prototype._find=function(m,v){return this._cacheKey!==m&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=m)),this._cacheIndex<0&&v&&(this._cacheIndex=this._keys.length,this._keys.push(m),this._values.push(void 0)),this._cacheIndex},y}();function u(y,m){return y}function g(y,m){return m}function H(y,m){return[y,m]}}function en(){return function(){function a(){this._map=new A}return Object.defineProperty(a.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),a.prototype.has=function(c){return this._map.has(c)},a.prototype.add=function(c){return this._map.set(c,c),this},a.prototype.delete=function(c){return this._map.delete(c)},a.prototype.clear=function(){this._map.clear()},a.prototype.keys=function(){return this._map.keys()},a.prototype.values=function(){return this._map.values()},a.prototype.entries=function(){return this._map.entries()},a.prototype["@@iterator"]=function(){return this.keys()},a.prototype[i]=function(){return this.keys()},a}()}function sn(){var a=16,c=d.create(),l=u();return function(){function v(){this._key=u()}return v.prototype.has=function($){var C=g($,!1);return C!==void 0?d.has(C,this._key):!1},v.prototype.get=function($){var C=g($,!1);return C!==void 0?d.get(C,this._key):void 0},v.prototype.set=function($,C){var q=g($,!0);return q[this._key]=C,this},v.prototype.delete=function($){var C=g($,!1);return C!==void 0?delete C[this._key]:!1},v.prototype.clear=function(){this._key=u()},v}();function u(){var v;do v="@@WeakMap@@"+m();while(d.has(c,v));return c[v]=!0,v}function g(v,$){if(!t.call(v,l)){if(!$)return;Object.defineProperty(v,l,{value:d.create()})}return v[l]}function H(v,$){for(var C=0;C<$;++C)v[C]=Math.random()*255|0;return v}function y(v){return typeof Uint8Array=="function"?typeof crypto<"u"?crypto.getRandomValues(new Uint8Array(v)):typeof msCrypto<"u"?msCrypto.getRandomValues(new Uint8Array(v)):H(new Uint8Array(v),v):H(new Array(v),v)}function m(){var v=y(a);v[6]=v[6]&79|64,v[8]=v[8]&191|128;for(var $="",C=0;C<a;++C){var q=v[C];(C===4||C===6||C===8)&&($+="-"),q<16&&($+="0"),$+=q.toString(16).toLowerCase()}return $}}function zt(a){return a.__=void 0,delete a.__,a}})})(te||(te={}));function Us(s){me(s,"svelte-or6zbb",'#liveroom-client-element.svelte-or6zbb.svelte-or6zbb{font-family:Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;line-height:1.5;font-weight:400;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}#users-container.svelte-or6zbb.svelte-or6zbb{position:fixed;inset:0;overflow:hidden;pointer-events:none}.user.svelte-or6zbb.svelte-or6zbb{z-index:1000;position:absolute;top:0;left:0;user-select:none;transform:translate(var(--x), var(--y))}.user.svelte-or6zbb .cursor.svelte-or6zbb{position:absolute;top:0;left:0;color:var(--color);transform-origin:top left;transform:rotate(6deg)}.user[data-isself="true"].svelte-or6zbb .cursor.svelte-or6zbb{display:none}.user-name.svelte-or6zbb.svelte-or6zbb{padding:4px 10px;font-size:14px;line-height:20px;font-weight:600;color:black;background-color:var(--color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:9999px;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-or6zbb .user-name.svelte-or6zbb{position:absolute;top:20px;left:16px}.user[data-isself="true"].svelte-or6zbb .user-name.svelte-or6zbb{display:none}.user.svelte-or6zbb .halo.svelte-or6zbb{transform:scale(0);z-index:-1;position:absolute;top:-60px;left:-60px;width:120px;height:120px;border-radius:9999px;background-color:var(--color);opacity:0.25;transition:transform 0.15s ease-out;box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05)}.user.svelte-or6zbb .halo[data-show="true"].svelte-or6zbb{transform:scale(1)}')}function ee(s,n,t){const e=s.slice();return e[14]=n[t],e}function se(s){let n,t=[],e=new Map,r=Xt(Object.values(s[2]));const i=o=>o[14].id;for(let o=0;o<r.length;o+=1){let h=ee(s,r,o),p=i(h);e.set(p,t[o]=ne(p,h))}return{c(){n=Y("div");for(let o=0;o<t.length;o+=1)t[o].c();j(n,"id","users-container"),j(n,"class","svelte-or6zbb")},m(o,h){vt(o,n,h);for(let p=0;p<t.length;p+=1)t[p]&&t[p].m(n,null)},p(o,h){h&6&&(r=Xt(Object.values(o[2])),t=Me(t,h,i,1,o,r,e,n,Se,ne,null,ee))},d(o){o&&ot(n);for(let h=0;h<t.length;h+=1)t[h].d()}}}function ne(s,n){let t,e,r,i,o,h=n[14].name+"",p,d,b,_,A,O,x;return{key:s,first:null,c(){t=Y("div"),e=Vt("svg"),r=Vt("path"),i=Ot(),o=Y("span"),p=Bt(h),d=Ot(),b=Y("div"),A=Ot(),j(r,"d","M2.2706 0.0593359L25.4277 8.05957H25.45926C25.65896 8.13153 25.83096 8.25952 25.95221 8.42653C26.07357 8.59354 26.13851 8.79166 26.13851 8.99459C26.13851 9.19751 26.07357 9.39564 25.95221 9.56265C25.83096 9.72966 25.65896 9.85765 25.45926 9.92962L15.3543 13.7698L11.3124 23.37C11.2344 23.5561 11.0994 23.7156 10.9248 23.828C10.7503 23.9402 10.5443 24.0002 10.3335 24C10.1172 24 9.9061 23.9365 9.7291 23.8184C9.552 23.7004 9.4176 23.5332 9.344 23.34L0.9233 1.33937C0.8555 1.16076 0.8426 0.967504 0.8861 0.782189C0.9297 0.596873 1.0278 0.427163 1.1691 0.292901C1.3105 0.158639 1.4891 0.0653762 1.6841 0.0240151C1.8792 -0.0173461 2.0826 -0.00509504 2.2706 0.0593359Z"),j(e,"width","23"),j(e,"viewBox","0 0 27 24"),j(e,"fill","currentColor"),j(e,"aria-hidden","true"),j(e,"xmlns","http://www.w3.org/2000/svg"),j(e,"class","cursor svelte-or6zbb"),j(o,"class","user-name svelte-or6zbb"),j(b,"class","halo svelte-or6zbb"),j(b,"data-show",_=n[14].is_mouse_down||n[14].is_escape_key_down),j(t,"id",O="user-"+n[14].id),j(t,"class","user svelte-or6zbb"),j(t,"data-isself",x=n[14].id==n[1].id),Z(t,"--color",n[14].color),Z(t,"--x",parseFloat(n[14].x)+"vw"),Z(t,"--y",parseFloat(n[14].y)+"vh"),this.first=t},m(R,L){vt(R,t,L),F(t,e),F(e,r),F(t,i),F(t,o),F(o,p),F(t,d),F(t,b),F(t,A)},p(R,L){n=R,L&4&&h!==(h=n[14].name+"")&&Ee(p,h),L&4&&_!==(_=n[14].is_mouse_down||n[14].is_escape_key_down)&&j(b,"data-show",_),L&4&&O!==(O="user-"+n[14].id)&&j(t,"id",O),L&6&&x!==(x=n[14].id==n[1].id)&&j(t,"data-isself",x),L&4&&Z(t,"--color",n[14].color),L&4&&Z(t,"--x",parseFloat(n[14].x)+"vw"),L&4&&Z(t,"--y",parseFloat(n[14].y)+"vh")},d(R){R&&ot(t)}}}function zs(s){let n,t=s[1]&&s[2]&&se(s);return{c(){n=Y("div"),t&&t.c(),j(n,"id","liveroom-client-element"),j(n,"class","svelte-or6zbb")},m(e,r){vt(e,n,r),t&&t.m(n,null),s[5](n)},p(e,[r]){e[1]&&e[2]?t?t.p(e,r):(t=se(e),t.c(),t.m(n,null)):t&&(t.d(1),t=null)},i:P,o:P,d(e){e&&ot(n),t&&t.d(),s[5](null)}}}function Js(s,n,t){let{url:e}=n,{room_id:r}=n,i,o,h,p;Ce(async()=>{o=new Ds({url:e,topic:`liveroom-livestate:${r}`,params:{room_id:r,current_url:window.origin,inner_width:window.innerWidth,inner_height:window.innerHeight}}),o.connect(),o.addEventListener("livestate-change",({detail:{state:k}})=>{t(3,r=k.room_id),t(1,h=k.me),t(2,p=k.users)}),window.addEventListener("mousemove",d),window.addEventListener("mousedown",b),window.addEventListener("mouseup",_),window.addEventListener("keydown",O),window.addEventListener("keyup",x),window.addEventListener("resize",R)}),ke(()=>{window.removeEventListener("resize",R),window.removeEventListener("keyup",x),window.removeEventListener("keydown",O),window.removeEventListener("mouseup",_),window.removeEventListener("mousedown",b),window.removeEventListener("mousemove",d),o==null||o.disconnect()});function d(k){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_move",{detail:{user_id:h.id,x:Number(k.clientX/window.innerWidth*100).toFixed(2),y:Number(k.clientY/window.innerHeight*100).toFixed(2)}}))}function b(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_down",{detail:{user_id:h.id}}))}function _(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("mouse_up",{detail:{user_id:h.id}}))}const A=["Escape"];function O(k){!k.repeat&&A.includes(k.key)&&o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("key_down",{detail:{key:k.key,user_id:h.id}}))}function x(k){A.includes(k.key)&&o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("key_up",{detail:{key:k.key,user_id:h.id}}))}function R(){o&&(h!=null&&h.id)&&o.dispatchEvent(new CustomEvent("window_resize",{detail:{inner_width:window.innerWidth,inner_height:window.innerHeight,user_id:h.id}}))}function L(k){jt[k?"unshift":"push"](()=>{i=k,t(0,i)})}return s.$$set=k=>{"url"in k&&t(4,e=k.url),"room_id"in k&&t(3,r=k.room_id)},[i,h,p,r,e,L]}class re extends Ie{constructor(n){super(),He(this,n,Js,zs,ve,{url:4,room_id:3},Us)}get url(){return this.$$.ctx[4]}set url(n){this.$$set({url:n}),yt()}get room_id(){return this.$$.ctx[3]}set room_id(n){this.$$set({room_id:n}),yt()}}return customElements.define("liveroom-client-element",Pe(re,{url:{},room_id:{}},[],[],!0)),re});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "liveroom-client-element",
3
3
  "private": false,
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "main": "./dist/liveroom-client-element.umd.cjs",
7
7
  "module": "./dist/liveroom-client-element.js",