liveroom-client-element 0.0.2 → 0.0.4

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.
@@ -1,3473 +0,0 @@
1
- var Xe = Object.defineProperty;
2
- var Ke = (n, s, t) => s in n ? Xe(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
- var g = (n, s, t) => (Ke(n, typeof s != "symbol" ? s + "" : s, t), t);
4
- /**
5
- * @license
6
- * Copyright 2019 Google LLC
7
- * SPDX-License-Identifier: BSD-3-Clause
8
- */
9
- const dt = window, Lt = dt.ShadowRoot && (dt.ShadyCSS === void 0 || dt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Ut = Symbol(), Qt = /* @__PURE__ */ new WeakMap();
10
- let ve = class {
11
- constructor(s, t, e) {
12
- if (this._$cssResult$ = !0, e !== Ut)
13
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
14
- this.cssText = s, this.t = t;
15
- }
16
- get styleSheet() {
17
- let s = this.o;
18
- const t = this.t;
19
- if (Lt && s === void 0) {
20
- const e = t !== void 0 && t.length === 1;
21
- e && (s = Qt.get(t)), s === void 0 && ((this.o = s = new CSSStyleSheet()).replaceSync(this.cssText), e && Qt.set(t, s));
22
- }
23
- return s;
24
- }
25
- toString() {
26
- return this.cssText;
27
- }
28
- };
29
- const Ye = (n) => new ve(typeof n == "string" ? n : n + "", void 0, Ut), Ze = (n, ...s) => {
30
- const t = n.length === 1 ? n[0] : s.reduce((e, i, r) => e + ((o) => {
31
- if (o._$cssResult$ === !0)
32
- return o.cssText;
33
- if (typeof o == "number")
34
- return o;
35
- throw Error("Value passed to 'css' function must be a 'css' function result: " + o + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
36
- })(i) + n[r + 1], n[0]);
37
- return new ve(t, n, Ut);
38
- }, Qe = (n, s) => {
39
- Lt ? n.adoptedStyleSheets = s.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet) : s.forEach((t) => {
40
- const e = document.createElement("style"), i = dt.litNonce;
41
- i !== void 0 && e.setAttribute("nonce", i), e.textContent = t.cssText, n.appendChild(e);
42
- });
43
- }, te = Lt ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((s) => {
44
- let t = "";
45
- for (const e of s.cssRules)
46
- t += e.cssText;
47
- return Ye(t);
48
- })(n) : n;
49
- /**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */
54
- var $t;
55
- const vt = window, ee = vt.trustedTypes, ts = ee ? ee.emptyScript : "", se = vt.reactiveElementPolyfillSupport, Mt = { toAttribute(n, s) {
56
- switch (s) {
57
- case Boolean:
58
- n = n ? ts : null;
59
- break;
60
- case Object:
61
- case Array:
62
- n = n == null ? n : JSON.stringify(n);
63
- }
64
- return n;
65
- }, fromAttribute(n, s) {
66
- let t = n;
67
- switch (s) {
68
- case Boolean:
69
- t = n !== null;
70
- break;
71
- case Number:
72
- t = n === null ? null : Number(n);
73
- break;
74
- case Object:
75
- case Array:
76
- try {
77
- t = JSON.parse(n);
78
- } catch {
79
- t = null;
80
- }
81
- }
82
- return t;
83
- } }, ge = (n, s) => s !== n && (s == s || n == n), Ct = { attribute: !0, type: String, converter: Mt, reflect: !1, hasChanged: ge };
84
- let q = class extends HTMLElement {
85
- constructor() {
86
- super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this.u();
87
- }
88
- static addInitializer(s) {
89
- var t;
90
- this.finalize(), ((t = this.h) !== null && t !== void 0 ? t : this.h = []).push(s);
91
- }
92
- static get observedAttributes() {
93
- this.finalize();
94
- const s = [];
95
- return this.elementProperties.forEach((t, e) => {
96
- const i = this._$Ep(e, t);
97
- i !== void 0 && (this._$Ev.set(i, e), s.push(i));
98
- }), s;
99
- }
100
- static createProperty(s, t = Ct) {
101
- if (t.state && (t.attribute = !1), this.finalize(), this.elementProperties.set(s, t), !t.noAccessor && !this.prototype.hasOwnProperty(s)) {
102
- const e = typeof s == "symbol" ? Symbol() : "__" + s, i = this.getPropertyDescriptor(s, e, t);
103
- i !== void 0 && Object.defineProperty(this.prototype, s, i);
104
- }
105
- }
106
- static getPropertyDescriptor(s, t, e) {
107
- return { get() {
108
- return this[t];
109
- }, set(i) {
110
- const r = this[s];
111
- this[t] = i, this.requestUpdate(s, r, e);
112
- }, configurable: !0, enumerable: !0 };
113
- }
114
- static getPropertyOptions(s) {
115
- return this.elementProperties.get(s) || Ct;
116
- }
117
- static finalize() {
118
- if (this.hasOwnProperty("finalized"))
119
- return !1;
120
- this.finalized = !0;
121
- const s = Object.getPrototypeOf(this);
122
- if (s.finalize(), s.h !== void 0 && (this.h = [...s.h]), this.elementProperties = new Map(s.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
123
- const t = this.properties, e = [...Object.getOwnPropertyNames(t), ...Object.getOwnPropertySymbols(t)];
124
- for (const i of e)
125
- this.createProperty(i, t[i]);
126
- }
127
- return this.elementStyles = this.finalizeStyles(this.styles), !0;
128
- }
129
- static finalizeStyles(s) {
130
- const t = [];
131
- if (Array.isArray(s)) {
132
- const e = new Set(s.flat(1 / 0).reverse());
133
- for (const i of e)
134
- t.unshift(te(i));
135
- } else
136
- s !== void 0 && t.push(te(s));
137
- return t;
138
- }
139
- static _$Ep(s, t) {
140
- const e = t.attribute;
141
- return e === !1 ? void 0 : typeof e == "string" ? e : typeof s == "string" ? s.toLowerCase() : void 0;
142
- }
143
- u() {
144
- var s;
145
- this._$E_ = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), (s = this.constructor.h) === null || s === void 0 || s.forEach((t) => t(this));
146
- }
147
- addController(s) {
148
- var t, e;
149
- ((t = this._$ES) !== null && t !== void 0 ? t : this._$ES = []).push(s), this.renderRoot !== void 0 && this.isConnected && ((e = s.hostConnected) === null || e === void 0 || e.call(s));
150
- }
151
- removeController(s) {
152
- var t;
153
- (t = this._$ES) === null || t === void 0 || t.splice(this._$ES.indexOf(s) >>> 0, 1);
154
- }
155
- _$Eg() {
156
- this.constructor.elementProperties.forEach((s, t) => {
157
- this.hasOwnProperty(t) && (this._$Ei.set(t, this[t]), delete this[t]);
158
- });
159
- }
160
- createRenderRoot() {
161
- var s;
162
- const t = (s = this.shadowRoot) !== null && s !== void 0 ? s : this.attachShadow(this.constructor.shadowRootOptions);
163
- return Qe(t, this.constructor.elementStyles), t;
164
- }
165
- connectedCallback() {
166
- var s;
167
- this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (s = this._$ES) === null || s === void 0 || s.forEach((t) => {
168
- var e;
169
- return (e = t.hostConnected) === null || e === void 0 ? void 0 : e.call(t);
170
- });
171
- }
172
- enableUpdating(s) {
173
- }
174
- disconnectedCallback() {
175
- var s;
176
- (s = this._$ES) === null || s === void 0 || s.forEach((t) => {
177
- var e;
178
- return (e = t.hostDisconnected) === null || e === void 0 ? void 0 : e.call(t);
179
- });
180
- }
181
- attributeChangedCallback(s, t, e) {
182
- this._$AK(s, e);
183
- }
184
- _$EO(s, t, e = Ct) {
185
- var i;
186
- const r = this.constructor._$Ep(s, e);
187
- if (r !== void 0 && e.reflect === !0) {
188
- const o = (((i = e.converter) === null || i === void 0 ? void 0 : i.toAttribute) !== void 0 ? e.converter : Mt).toAttribute(t, e.type);
189
- this._$El = s, o == null ? this.removeAttribute(r) : this.setAttribute(r, o), this._$El = null;
190
- }
191
- }
192
- _$AK(s, t) {
193
- var e;
194
- const i = this.constructor, r = i._$Ev.get(s);
195
- if (r !== void 0 && this._$El !== r) {
196
- const o = i.getPropertyOptions(r), l = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((e = o.converter) === null || e === void 0 ? void 0 : e.fromAttribute) !== void 0 ? o.converter : Mt;
197
- this._$El = r, this[r] = l.fromAttribute(t, o.type), this._$El = null;
198
- }
199
- }
200
- requestUpdate(s, t, e) {
201
- let i = !0;
202
- s !== void 0 && (((e = e || this.constructor.getPropertyOptions(s)).hasChanged || ge)(this[s], t) ? (this._$AL.has(s) || this._$AL.set(s, t), e.reflect === !0 && this._$El !== s && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(s, e))) : i = !1), !this.isUpdatePending && i && (this._$E_ = this._$Ej());
203
- }
204
- async _$Ej() {
205
- this.isUpdatePending = !0;
206
- try {
207
- await this._$E_;
208
- } catch (t) {
209
- Promise.reject(t);
210
- }
211
- const s = this.scheduleUpdate();
212
- return s != null && await s, !this.isUpdatePending;
213
- }
214
- scheduleUpdate() {
215
- return this.performUpdate();
216
- }
217
- performUpdate() {
218
- var s;
219
- if (!this.isUpdatePending)
220
- return;
221
- this.hasUpdated, this._$Ei && (this._$Ei.forEach((i, r) => this[r] = i), this._$Ei = void 0);
222
- let t = !1;
223
- const e = this._$AL;
224
- try {
225
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$ES) === null || s === void 0 || s.forEach((i) => {
226
- var r;
227
- return (r = i.hostUpdate) === null || r === void 0 ? void 0 : r.call(i);
228
- }), this.update(e)) : this._$Ek();
229
- } catch (i) {
230
- throw t = !1, this._$Ek(), i;
231
- }
232
- t && this._$AE(e);
233
- }
234
- willUpdate(s) {
235
- }
236
- _$AE(s) {
237
- var t;
238
- (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
239
- var i;
240
- return (i = e.hostUpdated) === null || i === void 0 ? void 0 : i.call(e);
241
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(s)), this.updated(s);
242
- }
243
- _$Ek() {
244
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
245
- }
246
- get updateComplete() {
247
- return this.getUpdateComplete();
248
- }
249
- getUpdateComplete() {
250
- return this._$E_;
251
- }
252
- shouldUpdate(s) {
253
- return !0;
254
- }
255
- update(s) {
256
- this._$EC !== void 0 && (this._$EC.forEach((t, e) => this._$EO(e, this[e], t)), this._$EC = void 0), this._$Ek();
257
- }
258
- updated(s) {
259
- }
260
- firstUpdated(s) {
261
- }
262
- };
263
- q.finalized = !0, q.elementProperties = /* @__PURE__ */ new Map(), q.elementStyles = [], q.shadowRootOptions = { mode: "open" }, se == null || se({ ReactiveElement: q }), (($t = vt.reactiveElementVersions) !== null && $t !== void 0 ? $t : vt.reactiveElementVersions = []).push("1.6.1");
264
- /**
265
- * @license
266
- * Copyright 2017 Google LLC
267
- * SPDX-License-Identifier: BSD-3-Clause
268
- */
269
- var Tt;
270
- const gt = window, X = gt.trustedTypes, ne = X ? X.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, Rt = "$lit$", I = `lit$${(Math.random() + "").slice(9)}$`, ye = "?" + I, es = `<${ye}>`, J = document, it = () => J.createComment(""), rt = (n) => n === null || typeof n != "object" && typeof n != "function", me = Array.isArray, ss = (n) => me(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", kt = `[
271
- \f\r]`, Q = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ie = /-->/g, re = />/g, V = RegExp(`>|${kt}(?:([^\\s"'>=/]+)(${kt}*=${kt}*(?:[^
272
- \f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g, _e = /^(?:script|style|textarea|title)$/i, ns = (n) => (s, ...t) => ({ _$litType$: n, strings: s, values: t }), he = ns(1), K = Symbol.for("lit-noChange"), O = Symbol.for("lit-nothing"), le = /* @__PURE__ */ new WeakMap(), z = J.createTreeWalker(J, 129, null, !1), is = (n, s) => {
273
- const t = n.length - 1, e = [];
274
- let i, r = s === 2 ? "<svg>" : "", o = Q;
275
- for (let u = 0; u < t; u++) {
276
- const d = n[u];
277
- let C, y, $ = -1, x = 0;
278
- for (; x < d.length && (o.lastIndex = x, y = o.exec(d), y !== null); )
279
- x = o.lastIndex, o === Q ? y[1] === "!--" ? o = ie : y[1] !== void 0 ? o = re : y[2] !== void 0 ? (_e.test(y[2]) && (i = RegExp("</" + y[2], "g")), o = V) : y[3] !== void 0 && (o = V) : o === V ? y[0] === ">" ? (o = i ?? Q, $ = -1) : y[1] === void 0 ? $ = -2 : ($ = o.lastIndex - y[2].length, C = y[1], o = y[3] === void 0 ? V : y[3] === '"' ? ae : oe) : o === ae || o === oe ? o = V : o === ie || o === re ? o = Q : (o = V, i = void 0);
280
- const W = o === V && n[u + 1].startsWith("/>") ? " " : "";
281
- r += o === Q ? d + es : $ >= 0 ? (e.push(C), d.slice(0, $) + Rt + d.slice($) + I + W) : d + I + ($ === -2 ? (e.push(void 0), u) : W);
282
- }
283
- const l = r + (n[t] || "<?>") + (s === 2 ? "</svg>" : "");
284
- if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
285
- throw Error("invalid template strings array");
286
- return [ne !== void 0 ? ne.createHTML(l) : l, e];
287
- };
288
- class ot {
289
- constructor({ strings: s, _$litType$: t }, e) {
290
- let i;
291
- this.parts = [];
292
- let r = 0, o = 0;
293
- const l = s.length - 1, u = this.parts, [d, C] = is(s, t);
294
- if (this.el = ot.createElement(d, e), z.currentNode = this.el.content, t === 2) {
295
- const y = this.el.content, $ = y.firstChild;
296
- $.remove(), y.append(...$.childNodes);
297
- }
298
- for (; (i = z.nextNode()) !== null && u.length < l; ) {
299
- if (i.nodeType === 1) {
300
- if (i.hasAttributes()) {
301
- const y = [];
302
- for (const $ of i.getAttributeNames())
303
- if ($.endsWith(Rt) || $.startsWith(I)) {
304
- const x = C[o++];
305
- if (y.push($), x !== void 0) {
306
- const W = i.getAttribute(x.toLowerCase() + Rt).split(I), H = /([.?@])?(.*)/.exec(x);
307
- u.push({ type: 1, index: r, name: H[2], strings: W, ctor: H[1] === "." ? os : H[1] === "?" ? hs : H[1] === "@" ? ls : _t });
308
- } else
309
- u.push({ type: 6, index: r });
310
- }
311
- for (const $ of y)
312
- i.removeAttribute($);
313
- }
314
- if (_e.test(i.tagName)) {
315
- const y = i.textContent.split(I), $ = y.length - 1;
316
- if ($ > 0) {
317
- i.textContent = X ? X.emptyScript : "";
318
- for (let x = 0; x < $; x++)
319
- i.append(y[x], it()), z.nextNode(), u.push({ type: 2, index: ++r });
320
- i.append(y[$], it());
321
- }
322
- }
323
- } else if (i.nodeType === 8)
324
- if (i.data === ye)
325
- u.push({ type: 2, index: r });
326
- else {
327
- let y = -1;
328
- for (; (y = i.data.indexOf(I, y + 1)) !== -1; )
329
- u.push({ type: 7, index: r }), y += I.length - 1;
330
- }
331
- r++;
332
- }
333
- }
334
- static createElement(s, t) {
335
- const e = J.createElement("template");
336
- return e.innerHTML = s, e;
337
- }
338
- }
339
- function Y(n, s, t = n, e) {
340
- var i, r, o, l;
341
- if (s === K)
342
- return s;
343
- let u = e !== void 0 ? (i = t._$Co) === null || i === void 0 ? void 0 : i[e] : t._$Cl;
344
- const d = rt(s) ? void 0 : s._$litDirective$;
345
- return (u == null ? void 0 : u.constructor) !== d && ((r = u == null ? void 0 : u._$AO) === null || r === void 0 || r.call(u, !1), d === void 0 ? u = void 0 : (u = new d(n), u._$AT(n, t, e)), e !== void 0 ? ((o = (l = t)._$Co) !== null && o !== void 0 ? o : l._$Co = [])[e] = u : t._$Cl = u), u !== void 0 && (s = Y(n, u._$AS(n, s.values), u, e)), s;
346
- }
347
- class rs {
348
- constructor(s, t) {
349
- this._$AV = [], this._$AN = void 0, this._$AD = s, this._$AM = t;
350
- }
351
- get parentNode() {
352
- return this._$AM.parentNode;
353
- }
354
- get _$AU() {
355
- return this._$AM._$AU;
356
- }
357
- u(s) {
358
- var t;
359
- const { el: { content: e }, parts: i } = this._$AD, r = ((t = s == null ? void 0 : s.creationScope) !== null && t !== void 0 ? t : J).importNode(e, !0);
360
- z.currentNode = r;
361
- let o = z.nextNode(), l = 0, u = 0, d = i[0];
362
- for (; d !== void 0; ) {
363
- if (l === d.index) {
364
- let C;
365
- d.type === 2 ? C = new ht(o, o.nextSibling, this, s) : d.type === 1 ? C = new d.ctor(o, d.name, d.strings, this, s) : d.type === 6 && (C = new cs(o, this, s)), this._$AV.push(C), d = i[++u];
366
- }
367
- l !== (d == null ? void 0 : d.index) && (o = z.nextNode(), l++);
368
- }
369
- return z.currentNode = J, r;
370
- }
371
- v(s) {
372
- let t = 0;
373
- for (const e of this._$AV)
374
- e !== void 0 && (e.strings !== void 0 ? (e._$AI(s, e, t), t += e.strings.length - 2) : e._$AI(s[t])), t++;
375
- }
376
- }
377
- class ht {
378
- constructor(s, t, e, i) {
379
- var r;
380
- this.type = 2, this._$AH = O, this._$AN = void 0, this._$AA = s, this._$AB = t, this._$AM = e, this.options = i, this._$Cp = (r = i == null ? void 0 : i.isConnected) === null || r === void 0 || r;
381
- }
382
- get _$AU() {
383
- var s, t;
384
- return (t = (s = this._$AM) === null || s === void 0 ? void 0 : s._$AU) !== null && t !== void 0 ? t : this._$Cp;
385
- }
386
- get parentNode() {
387
- let s = this._$AA.parentNode;
388
- const t = this._$AM;
389
- return t !== void 0 && (s == null ? void 0 : s.nodeType) === 11 && (s = t.parentNode), s;
390
- }
391
- get startNode() {
392
- return this._$AA;
393
- }
394
- get endNode() {
395
- return this._$AB;
396
- }
397
- _$AI(s, t = this) {
398
- s = Y(this, s, t), rt(s) ? s === O || s == null || s === "" ? (this._$AH !== O && this._$AR(), this._$AH = O) : s !== this._$AH && s !== K && this._(s) : s._$litType$ !== void 0 ? this.g(s) : s.nodeType !== void 0 ? this.$(s) : ss(s) ? this.T(s) : this._(s);
399
- }
400
- k(s) {
401
- return this._$AA.parentNode.insertBefore(s, this._$AB);
402
- }
403
- $(s) {
404
- this._$AH !== s && (this._$AR(), this._$AH = this.k(s));
405
- }
406
- _(s) {
407
- this._$AH !== O && rt(this._$AH) ? this._$AA.nextSibling.data = s : this.$(J.createTextNode(s)), this._$AH = s;
408
- }
409
- g(s) {
410
- var t;
411
- const { values: e, _$litType$: i } = s, r = typeof i == "number" ? this._$AC(s) : (i.el === void 0 && (i.el = ot.createElement(i.h, this.options)), i);
412
- if (((t = this._$AH) === null || t === void 0 ? void 0 : t._$AD) === r)
413
- this._$AH.v(e);
414
- else {
415
- const o = new rs(r, this), l = o.u(this.options);
416
- o.v(e), this.$(l), this._$AH = o;
417
- }
418
- }
419
- _$AC(s) {
420
- let t = le.get(s.strings);
421
- return t === void 0 && le.set(s.strings, t = new ot(s)), t;
422
- }
423
- T(s) {
424
- me(this._$AH) || (this._$AH = [], this._$AR());
425
- const t = this._$AH;
426
- let e, i = 0;
427
- for (const r of s)
428
- i === t.length ? t.push(e = new ht(this.k(it()), this.k(it()), this, this.options)) : e = t[i], e._$AI(r), i++;
429
- i < t.length && (this._$AR(e && e._$AB.nextSibling, i), t.length = i);
430
- }
431
- _$AR(s = this._$AA.nextSibling, t) {
432
- var e;
433
- for ((e = this._$AP) === null || e === void 0 || e.call(this, !1, !0, t); s && s !== this._$AB; ) {
434
- const i = s.nextSibling;
435
- s.remove(), s = i;
436
- }
437
- }
438
- setConnected(s) {
439
- var t;
440
- this._$AM === void 0 && (this._$Cp = s, (t = this._$AP) === null || t === void 0 || t.call(this, s));
441
- }
442
- }
443
- class _t {
444
- constructor(s, t, e, i, r) {
445
- this.type = 1, this._$AH = O, this._$AN = void 0, this.element = s, this.name = t, this._$AM = i, this.options = r, e.length > 2 || e[0] !== "" || e[1] !== "" ? (this._$AH = Array(e.length - 1).fill(new String()), this.strings = e) : this._$AH = O;
446
- }
447
- get tagName() {
448
- return this.element.tagName;
449
- }
450
- get _$AU() {
451
- return this._$AM._$AU;
452
- }
453
- _$AI(s, t = this, e, i) {
454
- const r = this.strings;
455
- let o = !1;
456
- if (r === void 0)
457
- s = Y(this, s, t, 0), o = !rt(s) || s !== this._$AH && s !== K, o && (this._$AH = s);
458
- else {
459
- const l = s;
460
- let u, d;
461
- for (s = r[0], u = 0; u < r.length - 1; u++)
462
- d = Y(this, l[e + u], t, u), d === K && (d = this._$AH[u]), o || (o = !rt(d) || d !== this._$AH[u]), d === O ? s = O : s !== O && (s += (d ?? "") + r[u + 1]), this._$AH[u] = d;
463
- }
464
- o && !i && this.j(s);
465
- }
466
- j(s) {
467
- s === O ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, s ?? "");
468
- }
469
- }
470
- class os extends _t {
471
- constructor() {
472
- super(...arguments), this.type = 3;
473
- }
474
- j(s) {
475
- this.element[this.name] = s === O ? void 0 : s;
476
- }
477
- }
478
- const as = X ? X.emptyScript : "";
479
- class hs extends _t {
480
- constructor() {
481
- super(...arguments), this.type = 4;
482
- }
483
- j(s) {
484
- s && s !== O ? this.element.setAttribute(this.name, as) : this.element.removeAttribute(this.name);
485
- }
486
- }
487
- class ls extends _t {
488
- constructor(s, t, e, i, r) {
489
- super(s, t, e, i, r), this.type = 5;
490
- }
491
- _$AI(s, t = this) {
492
- var e;
493
- if ((s = (e = Y(this, s, t, 0)) !== null && e !== void 0 ? e : O) === K)
494
- return;
495
- const i = this._$AH, r = s === O && i !== O || s.capture !== i.capture || s.once !== i.once || s.passive !== i.passive, o = s !== O && (i === O || r);
496
- r && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, s), this._$AH = s;
497
- }
498
- handleEvent(s) {
499
- var t, e;
500
- typeof this._$AH == "function" ? this._$AH.call((e = (t = this.options) === null || t === void 0 ? void 0 : t.host) !== null && e !== void 0 ? e : this.element, s) : this._$AH.handleEvent(s);
501
- }
502
- }
503
- class cs {
504
- constructor(s, t, e) {
505
- this.element = s, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = e;
506
- }
507
- get _$AU() {
508
- return this._$AM._$AU;
509
- }
510
- _$AI(s) {
511
- Y(this, s);
512
- }
513
- }
514
- const ce = gt.litHtmlPolyfillSupport;
515
- ce == null || ce(ot, ht), ((Tt = gt.litHtmlVersions) !== null && Tt !== void 0 ? Tt : gt.litHtmlVersions = []).push("2.7.4");
516
- const us = (n, s, t) => {
517
- var e, i;
518
- const r = (e = t == null ? void 0 : t.renderBefore) !== null && e !== void 0 ? e : s;
519
- let o = r._$litPart$;
520
- if (o === void 0) {
521
- const l = (i = t == null ? void 0 : t.renderBefore) !== null && i !== void 0 ? i : null;
522
- r._$litPart$ = o = new ht(s.insertBefore(it(), l), l, void 0, t ?? {});
523
- }
524
- return o._$AI(n), o;
525
- };
526
- /**
527
- * @license
528
- * Copyright 2017 Google LLC
529
- * SPDX-License-Identifier: BSD-3-Clause
530
- */
531
- var xt, St;
532
- class et extends q {
533
- constructor() {
534
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
535
- }
536
- createRenderRoot() {
537
- var s, t;
538
- const e = super.createRenderRoot();
539
- return (s = (t = this.renderOptions).renderBefore) !== null && s !== void 0 || (t.renderBefore = e.firstChild), e;
540
- }
541
- update(s) {
542
- const t = this.render();
543
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(s), this._$Do = us(t, this.renderRoot, this.renderOptions);
544
- }
545
- connectedCallback() {
546
- var s;
547
- super.connectedCallback(), (s = this._$Do) === null || s === void 0 || s.setConnected(!0);
548
- }
549
- disconnectedCallback() {
550
- var s;
551
- super.disconnectedCallback(), (s = this._$Do) === null || s === void 0 || s.setConnected(!1);
552
- }
553
- render() {
554
- return K;
555
- }
556
- }
557
- et.finalized = !0, et._$litElement$ = !0, (xt = globalThis.litElementHydrateSupport) === null || xt === void 0 || xt.call(globalThis, { LitElement: et });
558
- const ue = globalThis.litElementPolyfillSupport;
559
- ue == null || ue({ LitElement: et });
560
- ((St = globalThis.litElementVersions) !== null && St !== void 0 ? St : globalThis.litElementVersions = []).push("3.3.2");
561
- /**
562
- * @license
563
- * Copyright 2017 Google LLC
564
- * SPDX-License-Identifier: BSD-3-Clause
565
- */
566
- const ps = (n) => (s) => typeof s == "function" ? ((t, e) => (customElements.define(t, e), e))(n, s) : ((t, e) => {
567
- const { kind: i, elements: r } = e;
568
- return { kind: i, elements: r, finisher(o) {
569
- customElements.define(t, o);
570
- } };
571
- })(n, s);
572
- /**
573
- * @license
574
- * Copyright 2017 Google LLC
575
- * SPDX-License-Identifier: BSD-3-Clause
576
- */
577
- const ds = (n, s) => s.kind === "method" && s.descriptor && !("value" in s.descriptor) ? { ...s, finisher(t) {
578
- t.createProperty(s.key, n);
579
- } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: s.key, initializer() {
580
- typeof s.initializer == "function" && (this[s.key] = s.initializer.call(this));
581
- }, finisher(t) {
582
- t.createProperty(s.key, n);
583
- } };
584
- function Dt(n) {
585
- return (s, t) => t !== void 0 ? ((e, i, r) => {
586
- i.constructor.createProperty(r, e);
587
- })(n, s, t) : ds(n, s);
588
- }
589
- /**
590
- * @license
591
- * Copyright 2017 Google LLC
592
- * SPDX-License-Identifier: BSD-3-Clause
593
- */
594
- function we(n) {
595
- return Dt({ ...n, state: !0 });
596
- }
597
- /**
598
- * @license
599
- * Copyright 2021 Google LLC
600
- * SPDX-License-Identifier: BSD-3-Clause
601
- */
602
- var Ot;
603
- ((Ot = window.HTMLSlotElement) === null || Ot === void 0 ? void 0 : Ot.prototype.assignedElements) != null;
604
- const { isArray: fs } = Array, vs = Object.keys, at = (n) => {
605
- if (!n)
606
- return n;
607
- if (fs(n)) {
608
- const s = [], t = n.length;
609
- for (let e = 0; e < t; e++)
610
- s.push(at(n[e]));
611
- return s;
612
- } else if (typeof n == "object") {
613
- const s = vs(n), t = s.length, e = {};
614
- for (let i = 0; i < t; i++) {
615
- const r = s[i];
616
- e[r] = at(n[r]);
617
- }
618
- return e;
619
- }
620
- return n;
621
- };
622
- class N {
623
- constructor(s) {
624
- g(this, "path");
625
- g(this, "from");
626
- this.path = s;
627
- }
628
- }
629
- const gs = /~1/g, ys = /~0/g, ms = /~/g, _s = /\//g;
630
- function ws(n) {
631
- return n.indexOf("~") === -1 ? n : n.replace(gs, "/").replace(ys, "~");
632
- }
633
- function As(n) {
634
- return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(ms, "~0").replace(_s, "~1");
635
- }
636
- function Es(n) {
637
- return n ? n.slice(1).split("/").map(ws) : [];
638
- }
639
- function b(n) {
640
- return bs(n) ? "" : "/" + n.map((s) => As(String(s))).join("/");
641
- }
642
- const w = (n) => typeof n == "string" ? Es(n) : n, bs = (n) => !n.length, $s = Object.prototype.hasOwnProperty;
643
- function Cs(n, s) {
644
- return $s.call(n, s);
645
- }
646
- const { isArray: Ae } = Array, T = (n, s) => {
647
- const t = s.length;
648
- if (!t)
649
- return { val: n };
650
- let e, i;
651
- for (let o = 0; o < t; o++)
652
- if (e = n, i = s[o], Ae(e)) {
653
- const l = e.length;
654
- if (i === "-")
655
- i = l;
656
- else if (typeof i == "string") {
657
- const u = ~~i;
658
- if ("" + u !== i)
659
- throw new Error("INVALID_INDEX");
660
- if (i = u, i < 0)
661
- throw new Error("INVALID_INDEX");
662
- }
663
- n = e[i];
664
- } else if (typeof e == "object" && e)
665
- n = Cs(e, i) ? e[i] : void 0;
666
- else
667
- throw new Error("NOT_FOUND");
668
- return { val: n, obj: e, key: i };
669
- }, lt = (n) => Ae(n.obj) && typeof n.key == "number", wt = (n) => typeof n.obj == "object" && typeof n.key == "string";
670
- class It extends N {
671
- constructor(t, e) {
672
- super(t);
673
- g(this, "value");
674
- this.value = e;
675
- }
676
- op() {
677
- return "add";
678
- }
679
- code() {
680
- return 0;
681
- }
682
- apply(t) {
683
- const { val: e, key: i, obj: r } = T(t, this.path), o = at(this.value);
684
- if (!r)
685
- t = o;
686
- else if (typeof i == "string")
687
- r[i] = o;
688
- else {
689
- const l = r.length;
690
- if (i < l)
691
- r.splice(i, 0, o);
692
- else {
693
- if (i > l)
694
- throw new Error("INVALID_INDEX");
695
- r.push(o);
696
- }
697
- }
698
- return { doc: t, old: e };
699
- }
700
- toJson(t) {
701
- return {
702
- op: "add",
703
- path: b(this.path),
704
- value: this.value
705
- };
706
- }
707
- toCompact(t, e) {
708
- return [e ? "add" : 0, this.path, this.value];
709
- }
710
- encode(t) {
711
- t.encodeArrayHeader(3), t.writer.u8(0), t.encodeArray(this.path), t.encodeAny(this.value);
712
- }
713
- }
714
- class Ee extends N {
715
- constructor(t, e) {
716
- super(t);
717
- g(this, "oldValue");
718
- this.oldValue = e;
719
- }
720
- op() {
721
- return "remove";
722
- }
723
- code() {
724
- return 1;
725
- }
726
- apply(t) {
727
- const e = T(t, this.path);
728
- if (e.val === void 0)
729
- throw new Error("NOT_FOUND");
730
- 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 };
731
- }
732
- toJson(t) {
733
- const e = {
734
- op: "remove",
735
- path: b(this.path)
736
- };
737
- return this.oldValue !== void 0 && (e.oldValue = this.oldValue), e;
738
- }
739
- toCompact(t, e) {
740
- const i = e ? "remove" : 1;
741
- return this.oldValue === void 0 ? [i, this.path] : [i, this.path, this.oldValue];
742
- }
743
- encode(t, e) {
744
- const i = this.oldValue !== void 0;
745
- t.encodeArrayHeader(i ? 3 : 2), t.writer.u8(1), t.encodeArray(this.path), i && t.encodeAny(this.oldValue);
746
- }
747
- }
748
- class Ts extends N {
749
- constructor(t, e, i) {
750
- super(t);
751
- g(this, "value");
752
- g(this, "oldValue");
753
- this.value = e, this.oldValue = i;
754
- }
755
- op() {
756
- return "replace";
757
- }
758
- code() {
759
- return 2;
760
- }
761
- apply(t) {
762
- const e = T(t, this.path);
763
- if (e.val === void 0)
764
- throw new Error("NOT_FOUND");
765
- 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 };
766
- }
767
- toJson(t) {
768
- const e = {
769
- op: "replace",
770
- path: b(this.path),
771
- value: this.value
772
- };
773
- return this.oldValue !== void 0 && (e.oldValue = this.oldValue), e;
774
- }
775
- toCompact(t, e) {
776
- const i = e ? "replace" : 2;
777
- return this.oldValue === void 0 ? [i, this.path, this.value] : [i, this.path, this.value, this.oldValue];
778
- }
779
- encode(t, e) {
780
- const i = this.oldValue !== void 0;
781
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(2), t.encodeArray(this.path), t.encodeAny(this.value), i && t.encodeAny(this.oldValue);
782
- }
783
- }
784
- class ks extends N {
785
- constructor(t, e) {
786
- super(t);
787
- g(this, "from");
788
- this.from = e;
789
- }
790
- op() {
791
- return "move";
792
- }
793
- code() {
794
- return 4;
795
- }
796
- apply(t) {
797
- const e = new Ee(w(this.from), void 0).apply(t);
798
- return new It(this.path, e.old).apply(e.doc);
799
- }
800
- toJson(t) {
801
- return {
802
- op: "move",
803
- path: b(this.path),
804
- from: b(this.from)
805
- };
806
- }
807
- toCompact(t, e) {
808
- return [e ? "move" : 4, this.path, this.from];
809
- }
810
- encode(t, e) {
811
- t.encodeArrayHeader(3), t.writer.u8(4), t.encodeArray(this.path), t.encodeArray(this.from);
812
- }
813
- }
814
- class xs extends N {
815
- constructor(t, e) {
816
- super(t);
817
- g(this, "from");
818
- this.from = e;
819
- }
820
- op() {
821
- return "copy";
822
- }
823
- code() {
824
- return 3;
825
- }
826
- apply(t) {
827
- const { val: e } = T(t, this.from);
828
- if (e === void 0)
829
- throw new Error("NOT_FOUND");
830
- return new It(this.path, at(e)).apply(t);
831
- }
832
- toJson(t) {
833
- return {
834
- op: "copy",
835
- path: b(this.path),
836
- from: b(this.from)
837
- };
838
- }
839
- toCompact(t, e) {
840
- return [e ? "copy" : 3, this.path, this.from];
841
- }
842
- encode(t, e) {
843
- t.encodeArrayHeader(3), t.writer.u8(3), t.encodeArray(this.path), t.encodeArray(this.from);
844
- }
845
- }
846
- class M extends N {
847
- apply(s) {
848
- if (!this.test(s))
849
- throw new Error("TEST");
850
- return { doc: s };
851
- }
852
- }
853
- const yt = (n, s) => {
854
- if (n === s)
855
- return !0;
856
- if (n && s && typeof n == "object" && typeof s == "object") {
857
- if (n.constructor !== s.constructor)
858
- return !1;
859
- let t, e, i;
860
- if (Array.isArray(n)) {
861
- if (t = n.length, t !== s.length)
862
- return !1;
863
- for (e = t; e-- !== 0; )
864
- if (!yt(n[e], s[e]))
865
- return !1;
866
- return !0;
867
- }
868
- if (i = Object.keys(n), t = i.length, t !== Object.keys(s).length)
869
- return !1;
870
- for (e = t; e-- !== 0; ) {
871
- const r = i[e];
872
- if (!yt(n[r], s[r]))
873
- return !1;
874
- }
875
- return !0;
876
- }
877
- return !1;
878
- };
879
- class Ss extends M {
880
- constructor(t, e, i) {
881
- super(t);
882
- g(this, "value");
883
- g(this, "not");
884
- this.value = e, this.not = i;
885
- }
886
- op() {
887
- return "test";
888
- }
889
- code() {
890
- return 5;
891
- }
892
- test(t) {
893
- const { val: e } = T(t, this.path);
894
- if (e === void 0)
895
- return !!this.not;
896
- const i = yt(e, this.value);
897
- return this.not ? !i : i;
898
- }
899
- toJson(t) {
900
- const e = {
901
- op: "test",
902
- path: b(t ? this.path.slice(t.path.length) : this.path),
903
- value: this.value
904
- };
905
- return this.not && (e.not = this.not), e;
906
- }
907
- toCompact(t, e) {
908
- const i = t ? this.path.slice(t.path.length) : this.path, r = e ? "test" : 5;
909
- return this.not ? [r, i, this.value, 1] : [r, i, this.value];
910
- }
911
- encode(t, e) {
912
- 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);
913
- }
914
- }
915
- class Os extends N {
916
- constructor(s) {
917
- super(s);
918
- }
919
- op() {
920
- return "flip";
921
- }
922
- code() {
923
- return 8;
924
- }
925
- apply(s) {
926
- const t = T(s, this.path);
927
- return t.obj ? t.obj[t.key] = !t.val : s = !t.val, { doc: s, old: t.val };
928
- }
929
- toJson(s) {
930
- return {
931
- op: "flip",
932
- path: b(this.path)
933
- };
934
- }
935
- toCompact(s, t) {
936
- return [t ? "flip" : 8, this.path];
937
- }
938
- encode(s, t) {
939
- s.encodeArrayHeader(2), s.writer.u8(8), s.encodeArray(this.path);
940
- }
941
- }
942
- class js extends N {
943
- constructor(t, e) {
944
- super(t);
945
- g(this, "inc");
946
- this.inc = e;
947
- }
948
- op() {
949
- return "inc";
950
- }
951
- code() {
952
- return 9;
953
- }
954
- apply(t) {
955
- const e = T(t, this.path), i = this.inc + Number(e.val);
956
- return e.obj ? e.obj[e.key] = i : t = i, { doc: t, old: e.val };
957
- }
958
- toJson(t) {
959
- return {
960
- op: "inc",
961
- path: b(this.path),
962
- inc: this.inc
963
- };
964
- }
965
- toCompact(t, e) {
966
- return [e ? "inc" : 9, this.path, this.inc];
967
- }
968
- encode(t, e) {
969
- t.encodeArrayHeader(3), t.writer.u8(9), t.encodeArray(this.path), t.encodeNumber(this.inc);
970
- }
971
- }
972
- class Ms extends N {
973
- constructor(t, e, i) {
974
- super(t);
975
- g(this, "pos");
976
- g(this, "str");
977
- this.pos = e, this.str = i;
978
- }
979
- op() {
980
- return "str_ins";
981
- }
982
- code() {
983
- return 6;
984
- }
985
- apply(t) {
986
- const { val: e, key: i, obj: r } = T(t, this.path);
987
- if (typeof e != "string") {
988
- if (e !== void 0)
989
- throw new Error("NOT_A_STRING");
990
- if (this.pos !== 0)
991
- throw new Error("POS");
992
- }
993
- const o = typeof e == "string" ? e : "", l = Math.min(this.pos, o.length), u = o.slice(0, l), d = o.slice(l), C = u + this.str + d;
994
- return r ? r[i] = C : t = C, { doc: t, old: e };
995
- }
996
- toJson(t) {
997
- return {
998
- op: "str_ins",
999
- path: b(this.path),
1000
- pos: this.pos,
1001
- str: this.str
1002
- };
1003
- }
1004
- toCompact(t, e) {
1005
- return [e ? "str_ins" : 6, this.path, this.pos, this.str];
1006
- }
1007
- encode(t, e) {
1008
- t.encodeArrayHeader(4), t.writer.u8(6), t.encodeArray(this.path), t.encodeNumber(this.pos), t.encodeString(this.str);
1009
- }
1010
- }
1011
- class Rs extends N {
1012
- constructor(t, e, i, r) {
1013
- super(t);
1014
- g(this, "pos");
1015
- g(this, "str");
1016
- g(this, "len");
1017
- this.pos = e, this.str = i, this.len = r;
1018
- }
1019
- op() {
1020
- return "str_del";
1021
- }
1022
- code() {
1023
- return 7;
1024
- }
1025
- deleteLength() {
1026
- return typeof this.str == "string" ? this.str.length : this.len;
1027
- }
1028
- apply(t) {
1029
- const { val: e, key: i, obj: r } = T(t, this.path);
1030
- if (typeof e != "string")
1031
- throw new Error("NOT_A_STRING");
1032
- const o = e.length, l = Math.min(this.pos, e.length), u = Math.min(l, o), d = this.str !== void 0 ? this.str.length : this.len, C = Math.min(l + d, o), y = e.slice(0, u), $ = e.substr(C), x = y + $;
1033
- return r ? r[i] = x : t = x, { doc: t, old: e };
1034
- }
1035
- toJson(t) {
1036
- return typeof this.str == "string" ? {
1037
- op: "str_del",
1038
- path: b(this.path),
1039
- pos: this.pos,
1040
- str: this.str
1041
- } : {
1042
- op: "str_del",
1043
- path: b(this.path),
1044
- pos: this.pos,
1045
- len: this.len
1046
- };
1047
- }
1048
- toCompact(t, e) {
1049
- const i = e ? "str_del" : 7;
1050
- return typeof this.str == "string" ? [i, this.path, this.pos, this.str] : [i, this.path, this.pos, 0, this.len];
1051
- }
1052
- encode(t, e) {
1053
- const i = typeof this.str == "string";
1054
- t.encodeArrayHeader(i ? 4 : 5), t.writer.u8(7), t.encodeArray(this.path), t.encodeNumber(this.pos), i ? t.encodeString(this.str) : (t.writer.u8(0), t.encodeNumber(this.len));
1055
- }
1056
- }
1057
- const { isArray: Ns } = Array, Nt = (n) => !!n && typeof n == "object" && typeof n.text == "string", Pt = (n) => !!n && typeof n == "object" && Ns(n.children), Ps = (n, s) => {
1058
- const t = new RegExp(n, s ? "i" : void 0);
1059
- return (e) => t.test(e);
1060
- };
1061
- class Hs extends N {
1062
- constructor(t, e, i) {
1063
- super(t);
1064
- g(this, "pos");
1065
- g(this, "props");
1066
- this.pos = e, this.props = i;
1067
- }
1068
- op() {
1069
- return "split";
1070
- }
1071
- code() {
1072
- return 10;
1073
- }
1074
- apply(t) {
1075
- const e = T(t, this.path);
1076
- if (e.val === void 0)
1077
- throw new Error("NOT_FOUND");
1078
- const i = this.split(e.val);
1079
- return wt(e) ? e.obj[e.key] = i : lt(e) ? (e.obj[e.key] = i[0], e.obj.splice(e.key + 1, 0, i[1])) : t = i, { doc: t, old: e.val };
1080
- }
1081
- split(t) {
1082
- if (typeof t == "string") {
1083
- const { pos: e, props: i } = this, r = t.slice(0, e), o = t.slice(e);
1084
- return i ? [
1085
- {
1086
- ...i,
1087
- text: r
1088
- },
1089
- {
1090
- ...i,
1091
- text: o
1092
- }
1093
- ] : [r, o];
1094
- } else if (Nt(t)) {
1095
- const { pos: e, props: i } = this, r = t.text.slice(0, e), o = t.text.slice(e);
1096
- return [
1097
- {
1098
- ...t,
1099
- ...i,
1100
- text: r
1101
- },
1102
- {
1103
- ...t,
1104
- ...i,
1105
- text: o
1106
- }
1107
- ];
1108
- } else if (Pt(t)) {
1109
- const { pos: e, props: i } = this, r = t.children.slice(0, e), o = t.children.slice(e);
1110
- return [
1111
- {
1112
- ...t,
1113
- ...i,
1114
- children: r
1115
- },
1116
- {
1117
- ...t,
1118
- ...i,
1119
- children: o
1120
- }
1121
- ];
1122
- } else if (typeof t == "number") {
1123
- const { pos: e } = this;
1124
- return [e, t - e];
1125
- } else
1126
- return [t, t];
1127
- }
1128
- toJson(t) {
1129
- const e = {
1130
- op: "split",
1131
- path: b(this.path),
1132
- pos: this.pos
1133
- };
1134
- return this.props && (e.props = this.props), e;
1135
- }
1136
- toCompact(t, e) {
1137
- const i = e ? "split" : 10;
1138
- return this.props ? [i, this.path, this.pos, this.props] : [i, this.path, this.pos];
1139
- }
1140
- encode(t, e) {
1141
- t.encodeArrayHeader(this.props ? 4 : 3), t.writer.u8(10), t.encodeArray(this.path), t.encodeNumber(this.pos), this.props && t.encodeObject(this.props);
1142
- }
1143
- }
1144
- class Ls extends N {
1145
- constructor(t, e, i) {
1146
- super(t);
1147
- g(this, "pos");
1148
- g(this, "props");
1149
- this.pos = e, this.props = i;
1150
- }
1151
- op() {
1152
- return "merge";
1153
- }
1154
- code() {
1155
- return 11;
1156
- }
1157
- apply(t) {
1158
- const e = T(t, this.path);
1159
- if (!lt(e))
1160
- throw new Error("INVALID_TARGET");
1161
- if (e.key <= 0)
1162
- throw new Error("INVALID_KEY");
1163
- const i = e.obj[e.key - 1], r = e.obj[e.key], o = this.merge(i, r);
1164
- return e.obj[e.key - 1] = o, e.obj.splice(e.key, 1), { doc: t, old: [i, r] };
1165
- }
1166
- merge(t, e) {
1167
- 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 } : Pt(t) && Pt(e) ? { ...t, ...e, children: [...t.children, ...e.children] } : [t, e];
1168
- }
1169
- toJson(t) {
1170
- const e = {
1171
- op: "merge",
1172
- path: b(this.path),
1173
- pos: this.pos
1174
- };
1175
- return this.props && (e.props = this.props), e;
1176
- }
1177
- toCompact(t, e) {
1178
- const i = e ? "merge" : 11;
1179
- return this.props ? [i, this.path, this.pos, this.props] : [i, this.path, this.pos];
1180
- }
1181
- encode(t, e) {
1182
- t.encodeArrayHeader(this.props ? 4 : 3), t.writer.u8(11), t.encodeArray(this.path), t.encodeNumber(this.pos), this.props && t.encodeAny(this.props);
1183
- }
1184
- }
1185
- const { isArray: Us } = Array;
1186
- class Ds extends N {
1187
- constructor(t, e, i) {
1188
- super(t);
1189
- g(this, "props");
1190
- g(this, "deleteNull");
1191
- this.props = e, this.deleteNull = i;
1192
- }
1193
- op() {
1194
- return "extend";
1195
- }
1196
- code() {
1197
- return 12;
1198
- }
1199
- apply(t) {
1200
- const e = T(t, this.path);
1201
- 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 };
1202
- }
1203
- extend(t) {
1204
- if (Us(t) || typeof t != "object" || !t)
1205
- return t;
1206
- for (const [e, i] of Object.entries(this.props)) {
1207
- if (e === "__proto__")
1208
- throw new Error("NO_PROTO");
1209
- if (i === null && this.deleteNull) {
1210
- delete t[e];
1211
- continue;
1212
- }
1213
- t[e] = i;
1214
- }
1215
- return t;
1216
- }
1217
- toJson(t) {
1218
- const e = {
1219
- op: "extend",
1220
- path: b(this.path),
1221
- props: this.props
1222
- };
1223
- return this.deleteNull && (e.deleteNull = this.deleteNull), e;
1224
- }
1225
- toCompact(t, e) {
1226
- const i = e ? "extend" : 12;
1227
- return this.deleteNull ? [i, this.path, this.props, 1] : [i, this.path, this.props];
1228
- }
1229
- encode(t, e) {
1230
- const { deleteNull: i } = this;
1231
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(12), t.encodeArray(this.path), t.encodeObject(this.props), i && t.writer.u8(1);
1232
- }
1233
- }
1234
- class Is extends M {
1235
- constructor(s) {
1236
- super(s);
1237
- }
1238
- op() {
1239
- return "defined";
1240
- }
1241
- code() {
1242
- return 31;
1243
- }
1244
- test(s) {
1245
- const { val: t } = T(s, this.path);
1246
- return t !== void 0;
1247
- }
1248
- toJson(s) {
1249
- return {
1250
- op: "defined",
1251
- path: b(s ? this.path.slice(s.path.length) : this.path)
1252
- };
1253
- }
1254
- toCompact(s, t) {
1255
- return [t ? "defined" : 31, s ? this.path.slice(s.path.length) : this.path];
1256
- }
1257
- encode(s, t) {
1258
- s.encodeArrayHeader(2), s.writer.u8(31), s.encodeArray(t ? this.path.slice(t.path.length) : this.path);
1259
- }
1260
- }
1261
- class Vs extends M {
1262
- constructor(s) {
1263
- super(s);
1264
- }
1265
- op() {
1266
- return "undefined";
1267
- }
1268
- code() {
1269
- return 38;
1270
- }
1271
- test(s) {
1272
- try {
1273
- const { val: t } = T(s, this.path);
1274
- return t === void 0;
1275
- } catch (t) {
1276
- if (t.message === "NOT_FOUND")
1277
- return !0;
1278
- throw t;
1279
- }
1280
- }
1281
- toJson(s) {
1282
- return {
1283
- op: "undefined",
1284
- path: b(s ? this.path.slice(s.path.length) : this.path)
1285
- };
1286
- }
1287
- toCompact(s, t) {
1288
- return [t ? "undefined" : 38, s ? this.path.slice(s.path.length) : this.path];
1289
- }
1290
- encode(s, t) {
1291
- s.encodeArrayHeader(2), s.writer.u8(38), s.encodeArray(t ? this.path.slice(t.path.length) : this.path);
1292
- }
1293
- }
1294
- const { isArray: zs } = Array;
1295
- class Js extends M {
1296
- constructor(t, e) {
1297
- super(t);
1298
- g(this, "type");
1299
- this.type = e;
1300
- }
1301
- op() {
1302
- return "test_type";
1303
- }
1304
- code() {
1305
- return 39;
1306
- }
1307
- test(t) {
1308
- const { val: e } = T(t, this.path);
1309
- return e === null ? this.type.indexOf("null") > -1 : zs(e) ? this.type.indexOf("array") > -1 : this.type.indexOf(typeof e) > -1 || typeof e == "number" && e === Math.round(e) && this.type.indexOf("integer") > -1;
1310
- }
1311
- toJson(t) {
1312
- return {
1313
- op: "test_type",
1314
- path: b(t ? this.path.slice(t.path.length) : this.path),
1315
- type: this.type
1316
- };
1317
- }
1318
- toCompact(t, e) {
1319
- return [e ? "test_type" : 39, t ? this.path.slice(t.path.length) : this.path, this.type];
1320
- }
1321
- encode(t, e) {
1322
- t.encodeArrayHeader(3), t.writer.u8(39), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeArray(this.type);
1323
- }
1324
- }
1325
- class Bs extends M {
1326
- constructor(t, e, i, r) {
1327
- super(t);
1328
- g(this, "pos");
1329
- g(this, "str");
1330
- g(this, "not");
1331
- this.pos = e, this.str = i, this.not = r;
1332
- }
1333
- op() {
1334
- return "test_string";
1335
- }
1336
- code() {
1337
- return 40;
1338
- }
1339
- test(t) {
1340
- const { val: e } = T(t, this.path);
1341
- if (typeof e != "string")
1342
- return !1;
1343
- const i = e.length, r = Math.min(this.pos, i), o = Math.min(this.pos + this.str.length, i), l = e.substring(r, o) === this.str;
1344
- return this.not ? !l : l;
1345
- }
1346
- toJson(t) {
1347
- const e = {
1348
- op: "test_string",
1349
- path: b(t ? this.path.slice(t.path.length) : this.path),
1350
- pos: this.pos,
1351
- str: this.str
1352
- };
1353
- return this.not && (e.not = this.not), e;
1354
- }
1355
- toCompact(t, e) {
1356
- const i = e ? "test_string" : 40, r = t ? this.path.slice(t.path.length) : this.path;
1357
- return this.not ? [i, r, this.pos, this.str, 1] : [i, r, this.pos, this.str];
1358
- }
1359
- encode(t, e) {
1360
- 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);
1361
- }
1362
- }
1363
- class Ws extends M {
1364
- constructor(t, e, i) {
1365
- super(t);
1366
- g(this, "len");
1367
- g(this, "not");
1368
- this.len = e, this.not = i;
1369
- }
1370
- op() {
1371
- return "test_string_len";
1372
- }
1373
- code() {
1374
- return 41;
1375
- }
1376
- test(t) {
1377
- const { val: e } = T(t, this.path);
1378
- if (typeof e != "string")
1379
- return !1;
1380
- const r = e.length >= this.len;
1381
- return this.not ? !r : r;
1382
- }
1383
- toJson(t) {
1384
- const e = {
1385
- op: "test_string_len",
1386
- path: b(t ? this.path.slice(t.path.length) : this.path),
1387
- len: this.len
1388
- };
1389
- return this.not && (e.not = this.not), e;
1390
- }
1391
- toCompact(t, e) {
1392
- const i = e ? "test_string_len" : 41, r = t ? this.path.slice(t.path.length) : this.path;
1393
- return this.not ? [i, r, this.len, 1] : [i, r, this.len];
1394
- }
1395
- encode(t, e) {
1396
- 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);
1397
- }
1398
- }
1399
- class Gs extends M {
1400
- constructor(t, e, i) {
1401
- super(t);
1402
- g(this, "value");
1403
- g(this, "ignore_case");
1404
- this.value = e, this.ignore_case = i;
1405
- }
1406
- op() {
1407
- return "contains";
1408
- }
1409
- code() {
1410
- return 30;
1411
- }
1412
- test(t) {
1413
- const { val: e } = T(t, this.path);
1414
- if (typeof e != "string")
1415
- return !1;
1416
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1417
- return i.indexOf(r) > -1;
1418
- }
1419
- toJson(t) {
1420
- const e = {
1421
- op: "contains",
1422
- path: b(t ? this.path.slice(t.path.length) : this.path),
1423
- value: this.value
1424
- };
1425
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1426
- }
1427
- toCompact(t, e) {
1428
- const i = e ? "contains" : 30;
1429
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1430
- }
1431
- encode(t, e) {
1432
- const i = this.ignore_case;
1433
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(30), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1434
- }
1435
- }
1436
- class Fs extends M {
1437
- constructor(t, e, i) {
1438
- super(t);
1439
- g(this, "value");
1440
- g(this, "ignore_case");
1441
- this.value = e, this.ignore_case = i;
1442
- }
1443
- op() {
1444
- return "ends";
1445
- }
1446
- code() {
1447
- return 32;
1448
- }
1449
- test(t) {
1450
- const { val: e } = T(t, this.path);
1451
- if (typeof e != "string")
1452
- return !1;
1453
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1454
- return i.endsWith(r);
1455
- }
1456
- toJson(t) {
1457
- const e = {
1458
- op: "ends",
1459
- path: b(t ? this.path.slice(t.path.length) : this.path),
1460
- value: this.value
1461
- };
1462
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1463
- }
1464
- toCompact(t, e) {
1465
- const i = e ? "ends" : 32;
1466
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1467
- }
1468
- encode(t, e) {
1469
- const i = this.ignore_case;
1470
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(32), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1471
- }
1472
- }
1473
- class qs extends M {
1474
- constructor(t, e, i) {
1475
- super(t);
1476
- g(this, "value");
1477
- g(this, "ignore_case");
1478
- this.value = e, this.ignore_case = i;
1479
- }
1480
- op() {
1481
- return "starts";
1482
- }
1483
- code() {
1484
- return 37;
1485
- }
1486
- test(t) {
1487
- const { val: e } = T(t, this.path);
1488
- if (typeof e != "string")
1489
- return !1;
1490
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1491
- return i.startsWith(r);
1492
- }
1493
- toJson(t) {
1494
- const e = {
1495
- op: "starts",
1496
- path: b(t ? this.path.slice(t.path.length) : this.path),
1497
- value: this.value
1498
- };
1499
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1500
- }
1501
- toCompact(t, e) {
1502
- const i = e ? "starts" : 37;
1503
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1504
- }
1505
- encode(t, e) {
1506
- const i = this.ignore_case;
1507
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(37), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1508
- }
1509
- }
1510
- class Xs extends M {
1511
- constructor(t, e) {
1512
- super(t);
1513
- g(this, "value");
1514
- this.value = e;
1515
- }
1516
- op() {
1517
- return "in";
1518
- }
1519
- code() {
1520
- return 33;
1521
- }
1522
- test(t) {
1523
- const { val: e } = T(t, this.path);
1524
- for (const i of this.value)
1525
- if (yt(e, i))
1526
- return !0;
1527
- return !1;
1528
- }
1529
- toJson(t) {
1530
- return {
1531
- op: "in",
1532
- path: b(t ? this.path.slice(t.path.length) : this.path),
1533
- value: this.value
1534
- };
1535
- }
1536
- toCompact(t, e) {
1537
- return [e ? "in" : 33, t ? this.path.slice(t.path.length) : this.path, this.value];
1538
- }
1539
- encode(t, e) {
1540
- t.encodeArrayHeader(3), t.writer.u8(33), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeArray(this.value);
1541
- }
1542
- }
1543
- class Ks extends M {
1544
- constructor(t, e) {
1545
- super(t);
1546
- g(this, "value");
1547
- this.value = e;
1548
- }
1549
- op() {
1550
- return "less";
1551
- }
1552
- code() {
1553
- return 34;
1554
- }
1555
- test(t) {
1556
- const { val: e } = T(t, this.path);
1557
- return typeof e != "number" ? !1 : e < this.value;
1558
- }
1559
- toJson(t) {
1560
- return {
1561
- op: "less",
1562
- path: b(t ? this.path.slice(t.path.length) : this.path),
1563
- value: this.value
1564
- };
1565
- }
1566
- toCompact(t, e) {
1567
- return [e ? "less" : 34, t ? this.path.slice(t.path.length) : this.path, this.value];
1568
- }
1569
- encode(t, e) {
1570
- t.encodeArrayHeader(3), t.writer.u8(34), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.value);
1571
- }
1572
- }
1573
- class Ys extends M {
1574
- constructor(t, e) {
1575
- super(t);
1576
- g(this, "value");
1577
- this.value = e;
1578
- }
1579
- op() {
1580
- return "more";
1581
- }
1582
- code() {
1583
- return 36;
1584
- }
1585
- test(t) {
1586
- const { val: e } = T(t, this.path);
1587
- return typeof e != "number" ? !1 : e > this.value;
1588
- }
1589
- toJson(t) {
1590
- return {
1591
- op: "more",
1592
- path: b(t ? this.path.slice(t.path.length) : this.path),
1593
- value: this.value
1594
- };
1595
- }
1596
- toCompact(t, e) {
1597
- return [e ? "more" : 36, t ? this.path.slice(t.path.length) : this.path, this.value];
1598
- }
1599
- encode(t, e) {
1600
- t.encodeArrayHeader(3), t.writer.u8(36), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.value);
1601
- }
1602
- }
1603
- class Vt extends M {
1604
- constructor(t, e) {
1605
- super(t);
1606
- g(this, "ops");
1607
- this.ops = e;
1608
- }
1609
- }
1610
- class Zs extends Vt {
1611
- constructor(t, e) {
1612
- super(t, e);
1613
- g(this, "ops");
1614
- this.ops = e;
1615
- }
1616
- op() {
1617
- return "and";
1618
- }
1619
- code() {
1620
- return 43;
1621
- }
1622
- test(t) {
1623
- for (const e of this.ops)
1624
- if (!e.test(t))
1625
- return !1;
1626
- return !0;
1627
- }
1628
- toJson(t) {
1629
- return {
1630
- op: "and",
1631
- path: b(t ? this.path.slice(t.path.length) : this.path),
1632
- apply: this.ops.map((i) => i.toJson(this))
1633
- };
1634
- }
1635
- toCompact(t, e) {
1636
- return [
1637
- e ? "and" : 43,
1638
- t ? this.path.slice(t.path.length) : this.path,
1639
- this.ops.map((r) => r.toCompact(this, e))
1640
- ];
1641
- }
1642
- encode(t, e) {
1643
- const i = e ? this.path.slice(e.path.length) : this.path;
1644
- t.encodeArrayHeader(3), t.writer.u8(43), t.encodeArray(i);
1645
- const r = this.ops.length;
1646
- t.encodeArrayHeader(r);
1647
- for (let o = 0; o < r; o++)
1648
- this.ops[o].encode(t, this);
1649
- }
1650
- }
1651
- class Qs extends Vt {
1652
- constructor(t, e) {
1653
- super(t, e);
1654
- g(this, "ops");
1655
- this.ops = e;
1656
- }
1657
- op() {
1658
- return "or";
1659
- }
1660
- code() {
1661
- return 45;
1662
- }
1663
- test(t) {
1664
- for (const e of this.ops)
1665
- if (e.test(t))
1666
- return !0;
1667
- return !1;
1668
- }
1669
- toJson(t) {
1670
- return {
1671
- op: "or",
1672
- path: b(t ? this.path.slice(t.path.length) : this.path),
1673
- apply: this.ops.map((i) => i.toJson(this))
1674
- };
1675
- }
1676
- toCompact(t, e) {
1677
- return [
1678
- e ? "or" : 45,
1679
- t ? this.path.slice(t.path.length) : this.path,
1680
- this.ops.map((r) => r.toCompact(this, e))
1681
- ];
1682
- }
1683
- encode(t, e) {
1684
- t.encodeArrayHeader(3), t.writer.u8(45), t.encodeArray(e ? this.path.slice(e.path.length) : this.path);
1685
- const i = this.ops.length;
1686
- t.encodeArrayHeader(i);
1687
- for (let r = 0; r < i; r++)
1688
- this.ops[r].encode(t, this);
1689
- }
1690
- }
1691
- class tn extends Vt {
1692
- constructor(t, e) {
1693
- super(t, e);
1694
- g(this, "ops");
1695
- this.ops = e;
1696
- }
1697
- op() {
1698
- return "not";
1699
- }
1700
- code() {
1701
- return 44;
1702
- }
1703
- test(t) {
1704
- for (const e of this.ops)
1705
- if (e.test(t))
1706
- return !1;
1707
- return !0;
1708
- }
1709
- toJson(t) {
1710
- return {
1711
- op: "not",
1712
- path: b(t ? this.path.slice(t.path.length) : this.path),
1713
- apply: this.ops.map((i) => i.toJson(this))
1714
- };
1715
- }
1716
- toCompact(t, e) {
1717
- return [
1718
- e ? "not" : 44,
1719
- t ? this.path.slice(t.path.length) : this.path,
1720
- this.ops.map((r) => r.toCompact(this, e))
1721
- ];
1722
- }
1723
- encode(t, e) {
1724
- t.encodeArrayHeader(3), t.writer.u8(44), t.encodeArray(e ? this.path.slice(e.path.length) : this.path);
1725
- const i = this.ops.length;
1726
- t.encodeArrayHeader(i);
1727
- for (let r = 0; r < i; r++)
1728
- this.ops[r].encode(t, this);
1729
- }
1730
- }
1731
- class en extends M {
1732
- constructor(t, e, i, r) {
1733
- super(t);
1734
- g(this, "value");
1735
- g(this, "ignore_case");
1736
- g(this, "matcher");
1737
- this.value = e, this.ignore_case = i, this.matcher = r(e, i);
1738
- }
1739
- op() {
1740
- return "matches";
1741
- }
1742
- code() {
1743
- return 35;
1744
- }
1745
- test(t) {
1746
- const { val: e } = T(t, this.path);
1747
- return typeof e != "string" ? !1 : this.matcher(e);
1748
- }
1749
- toJson(t) {
1750
- const e = {
1751
- op: "matches",
1752
- path: b(t ? this.path.slice(t.path.length) : this.path),
1753
- value: this.value
1754
- };
1755
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1756
- }
1757
- toCompact(t, e) {
1758
- const i = e ? "matches" : 35;
1759
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1760
- }
1761
- encode(t, e) {
1762
- const i = this.ignore_case;
1763
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(35), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1764
- }
1765
- }
1766
- const { isArray: sn } = Array;
1767
- class nn extends M {
1768
- constructor(t, e) {
1769
- super(t);
1770
- g(this, "value");
1771
- this.value = e;
1772
- }
1773
- op() {
1774
- return "type";
1775
- }
1776
- code() {
1777
- return 42;
1778
- }
1779
- test(t) {
1780
- const { val: e } = T(t, this.path);
1781
- return e === null ? this.value === "null" : sn(e) ? this.value === "array" : typeof e === this.value || typeof e == "number" && e === Math.round(e) && this.value === "integer";
1782
- }
1783
- toJson(t) {
1784
- return {
1785
- op: "type",
1786
- path: b(t ? this.path.slice(t.path.length) : this.path),
1787
- value: this.value
1788
- };
1789
- }
1790
- toCompact(t, e) {
1791
- return [e ? "type" : 42, t ? this.path.slice(t.path.length) : this.path, this.value];
1792
- }
1793
- encode(t, e) {
1794
- t.encodeArrayHeader(3), t.writer.u8(42), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value);
1795
- }
1796
- }
1797
- const rn = (n, s) => {
1798
- switch (n.op) {
1799
- case "add":
1800
- return new It(w(n.path), n.value);
1801
- case "remove":
1802
- return new Ee(w(n.path), n.oldValue);
1803
- case "replace":
1804
- return new Ts(w(n.path), n.value, n.oldValue);
1805
- case "move":
1806
- return new ks(w(n.path), w(n.from));
1807
- case "copy":
1808
- return new xs(w(n.path), w(n.from));
1809
- case "flip":
1810
- return new Os(w(n.path));
1811
- case "inc":
1812
- return new js(w(n.path), n.inc);
1813
- case "str_ins":
1814
- return new Ms(w(n.path), n.pos, n.str);
1815
- case "str_del":
1816
- return new Rs(w(n.path), n.pos, n.str, n.len);
1817
- case "split":
1818
- return new Hs(w(n.path), n.pos, n.props || null);
1819
- case "merge":
1820
- return new Ls(w(n.path), n.pos, n.props || null);
1821
- case "extend":
1822
- return new Ds(w(n.path), n.props, !!n.deleteNull);
1823
- default:
1824
- return ft(n, s);
1825
- }
1826
- }, ft = (n, s) => {
1827
- switch (n.op) {
1828
- case "test":
1829
- return new Ss(w(n.path), n.value, !!n.not);
1830
- case "defined":
1831
- return new Is(w(n.path));
1832
- case "undefined":
1833
- return new Vs(w(n.path));
1834
- case "type":
1835
- return new nn(w(n.path), n.value);
1836
- case "test_type":
1837
- return new Js(w(n.path), n.type);
1838
- case "test_string":
1839
- return new Bs(w(n.path), n.pos, n.str, !!n.not);
1840
- case "test_string_len":
1841
- return new Ws(w(n.path), n.len, !!n.not);
1842
- case "contains":
1843
- return new Gs(w(n.path), n.value, !!n.ignore_case);
1844
- case "ends":
1845
- return new Fs(w(n.path), n.value, !!n.ignore_case);
1846
- case "starts":
1847
- return new qs(w(n.path), n.value, !!n.ignore_case);
1848
- case "matches":
1849
- return new en(w(n.path), n.value, !!n.ignore_case, s.createMatcher || Ps);
1850
- case "in":
1851
- return new Xs(w(n.path), n.value);
1852
- case "less":
1853
- return new Ks(w(n.path), n.value);
1854
- case "more":
1855
- return new Ys(w(n.path), n.value);
1856
- case "and": {
1857
- const t = w(n.path);
1858
- return new Zs(t, n.apply.map((e) => ft({ ...e, path: [...t, ...w(e.path)] }, s)));
1859
- }
1860
- case "or": {
1861
- const t = w(n.path);
1862
- return new Qs(t, n.apply.map((e) => ft({ ...e, path: [...t, ...w(e.path)] }, s)));
1863
- }
1864
- case "not": {
1865
- const t = w(n.path);
1866
- return new tn(t, n.apply.map((e) => ft({ ...e, path: [...t, ...w(e.path)] }, s)));
1867
- }
1868
- default:
1869
- throw new Error("OP_UNKNOWN");
1870
- }
1871
- };
1872
- function on(n, s, t) {
1873
- t.mutate || (n = at(n));
1874
- const e = [], i = s.length;
1875
- for (let r = 0; r < i; r++) {
1876
- const l = rn(s[r], t).apply(n);
1877
- n = l.doc, e.push(l);
1878
- }
1879
- return { doc: n, res: e };
1880
- }
1881
- var st = (n) => typeof n == "function" ? n : function() {
1882
- return n;
1883
- }, an = typeof self < "u" ? self : null, tt = typeof window < "u" ? window : null, nt = an || tt || nt, hn = "2.0.0", P = { connecting: 0, open: 1, closing: 2, closed: 3 }, ln = 1e4, cn = 1e3, R = {
1884
- closed: "closed",
1885
- errored: "errored",
1886
- joined: "joined",
1887
- joining: "joining",
1888
- leaving: "leaving"
1889
- }, U = {
1890
- close: "phx_close",
1891
- error: "phx_error",
1892
- join: "phx_join",
1893
- reply: "phx_reply",
1894
- leave: "phx_leave"
1895
- }, Ht = {
1896
- longpoll: "longpoll",
1897
- websocket: "websocket"
1898
- }, un = {
1899
- complete: 4
1900
- }, ut = class {
1901
- constructor(n, s, t, e) {
1902
- this.channel = n, this.event = s, this.payload = t || function() {
1903
- return {};
1904
- }, this.receivedResp = null, this.timeout = e, this.timeoutTimer = null, this.recHooks = [], this.sent = !1;
1905
- }
1906
- resend(n) {
1907
- this.timeout = n, this.reset(), this.send();
1908
- }
1909
- send() {
1910
- this.hasReceived("timeout") || (this.startTimeout(), this.sent = !0, this.channel.socket.push({
1911
- topic: this.channel.topic,
1912
- event: this.event,
1913
- payload: this.payload(),
1914
- ref: this.ref,
1915
- join_ref: this.channel.joinRef()
1916
- }));
1917
- }
1918
- receive(n, s) {
1919
- return this.hasReceived(n) && s(this.receivedResp.response), this.recHooks.push({ status: n, callback: s }), this;
1920
- }
1921
- reset() {
1922
- this.cancelRefEvent(), this.ref = null, this.refEvent = null, this.receivedResp = null, this.sent = !1;
1923
- }
1924
- matchReceive({ status: n, response: s, _ref: t }) {
1925
- this.recHooks.filter((e) => e.status === n).forEach((e) => e.callback(s));
1926
- }
1927
- cancelRefEvent() {
1928
- this.refEvent && this.channel.off(this.refEvent);
1929
- }
1930
- cancelTimeout() {
1931
- clearTimeout(this.timeoutTimer), this.timeoutTimer = null;
1932
- }
1933
- startTimeout() {
1934
- this.timeoutTimer && this.cancelTimeout(), this.ref = this.channel.socket.makeRef(), this.refEvent = this.channel.replyEventName(this.ref), this.channel.on(this.refEvent, (n) => {
1935
- this.cancelRefEvent(), this.cancelTimeout(), this.receivedResp = n, this.matchReceive(n);
1936
- }), this.timeoutTimer = setTimeout(() => {
1937
- this.trigger("timeout", {});
1938
- }, this.timeout);
1939
- }
1940
- hasReceived(n) {
1941
- return this.receivedResp && this.receivedResp.status === n;
1942
- }
1943
- trigger(n, s) {
1944
- this.channel.trigger(this.refEvent, { status: n, response: s });
1945
- }
1946
- }, be = class {
1947
- constructor(n, s) {
1948
- this.callback = n, this.timerCalc = s, this.timer = null, this.tries = 0;
1949
- }
1950
- reset() {
1951
- this.tries = 0, clearTimeout(this.timer);
1952
- }
1953
- scheduleTimeout() {
1954
- clearTimeout(this.timer), this.timer = setTimeout(() => {
1955
- this.tries = this.tries + 1, this.callback();
1956
- }, this.timerCalc(this.tries + 1));
1957
- }
1958
- }, pn = class {
1959
- constructor(n, s, t) {
1960
- this.state = R.closed, this.topic = n, this.params = st(s || {}), this.socket = t, this.bindings = [], this.bindingRef = 0, this.timeout = this.socket.timeout, this.joinedOnce = !1, this.joinPush = new ut(this, U.join, this.params, this.timeout), this.pushBuffer = [], this.stateChangeRefs = [], this.rejoinTimer = new be(() => {
1961
- this.socket.isConnected() && this.rejoin();
1962
- }, this.socket.rejoinAfterMs), this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset())), this.stateChangeRefs.push(this.socket.onOpen(() => {
1963
- this.rejoinTimer.reset(), this.isErrored() && this.rejoin();
1964
- })), this.joinPush.receive("ok", () => {
1965
- this.state = R.joined, this.rejoinTimer.reset(), this.pushBuffer.forEach((e) => e.send()), this.pushBuffer = [];
1966
- }), this.joinPush.receive("error", () => {
1967
- this.state = R.errored, this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1968
- }), this.onClose(() => {
1969
- this.rejoinTimer.reset(), this.socket.hasLogger() && this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`), this.state = R.closed, this.socket.remove(this);
1970
- }), this.onError((e) => {
1971
- this.socket.hasLogger() && this.socket.log("channel", `error ${this.topic}`, e), this.isJoining() && this.joinPush.reset(), this.state = R.errored, this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1972
- }), this.joinPush.receive("timeout", () => {
1973
- this.socket.hasLogger() && this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout), new ut(this, U.leave, st({}), this.timeout).send(), this.state = R.errored, this.joinPush.reset(), this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1974
- }), this.on(U.reply, (e, i) => {
1975
- this.trigger(this.replyEventName(i), e);
1976
- });
1977
- }
1978
- join(n = this.timeout) {
1979
- if (this.joinedOnce)
1980
- throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
1981
- return this.timeout = n, this.joinedOnce = !0, this.rejoin(), this.joinPush;
1982
- }
1983
- onClose(n) {
1984
- this.on(U.close, n);
1985
- }
1986
- onError(n) {
1987
- return this.on(U.error, (s) => n(s));
1988
- }
1989
- on(n, s) {
1990
- let t = this.bindingRef++;
1991
- return this.bindings.push({ event: n, ref: t, callback: s }), t;
1992
- }
1993
- off(n, s) {
1994
- this.bindings = this.bindings.filter((t) => !(t.event === n && (typeof s > "u" || s === t.ref)));
1995
- }
1996
- canPush() {
1997
- return this.socket.isConnected() && this.isJoined();
1998
- }
1999
- push(n, s, t = this.timeout) {
2000
- if (s = s || {}, !this.joinedOnce)
2001
- throw new Error(`tried to push '${n}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
2002
- let e = new ut(this, n, function() {
2003
- return s;
2004
- }, t);
2005
- return this.canPush() ? e.send() : (e.startTimeout(), this.pushBuffer.push(e)), e;
2006
- }
2007
- leave(n = this.timeout) {
2008
- this.rejoinTimer.reset(), this.joinPush.cancelTimeout(), this.state = R.leaving;
2009
- let s = () => {
2010
- this.socket.hasLogger() && this.socket.log("channel", `leave ${this.topic}`), this.trigger(U.close, "leave");
2011
- }, t = new ut(this, U.leave, st({}), n);
2012
- return t.receive("ok", () => s()).receive("timeout", () => s()), t.send(), this.canPush() || t.trigger("ok", {}), t;
2013
- }
2014
- onMessage(n, s, t) {
2015
- return s;
2016
- }
2017
- isMember(n, s, t, e) {
2018
- return this.topic !== n ? !1 : e && e !== this.joinRef() ? (this.socket.hasLogger() && this.socket.log("channel", "dropping outdated message", { topic: n, event: s, payload: t, joinRef: e }), !1) : !0;
2019
- }
2020
- joinRef() {
2021
- return this.joinPush.ref;
2022
- }
2023
- rejoin(n = this.timeout) {
2024
- this.isLeaving() || (this.socket.leaveOpenTopic(this.topic), this.state = R.joining, this.joinPush.resend(n));
2025
- }
2026
- trigger(n, s, t, e) {
2027
- let i = this.onMessage(n, s, t, e);
2028
- if (s && !i)
2029
- throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
2030
- let r = this.bindings.filter((o) => o.event === n);
2031
- for (let o = 0; o < r.length; o++)
2032
- r[o].callback(i, t, e || this.joinRef());
2033
- }
2034
- replyEventName(n) {
2035
- return `chan_reply_${n}`;
2036
- }
2037
- isClosed() {
2038
- return this.state === R.closed;
2039
- }
2040
- isErrored() {
2041
- return this.state === R.errored;
2042
- }
2043
- isJoined() {
2044
- return this.state === R.joined;
2045
- }
2046
- isJoining() {
2047
- return this.state === R.joining;
2048
- }
2049
- isLeaving() {
2050
- return this.state === R.leaving;
2051
- }
2052
- }, mt = class {
2053
- static request(n, s, t, e, i, r, o) {
2054
- if (nt.XDomainRequest) {
2055
- let l = new nt.XDomainRequest();
2056
- return this.xdomainRequest(l, n, s, e, i, r, o);
2057
- } else {
2058
- let l = new nt.XMLHttpRequest();
2059
- return this.xhrRequest(l, n, s, t, e, i, r, o);
2060
- }
2061
- }
2062
- static xdomainRequest(n, s, t, e, i, r, o) {
2063
- return n.timeout = i, n.open(s, t), n.onload = () => {
2064
- let l = this.parseJSON(n.responseText);
2065
- o && o(l);
2066
- }, r && (n.ontimeout = r), n.onprogress = () => {
2067
- }, n.send(e), n;
2068
- }
2069
- static xhrRequest(n, s, t, e, i, r, o, l) {
2070
- return n.open(s, t, !0), n.timeout = r, n.setRequestHeader("Content-Type", e), n.onerror = () => l && l(null), n.onreadystatechange = () => {
2071
- if (n.readyState === un.complete && l) {
2072
- let u = this.parseJSON(n.responseText);
2073
- l(u);
2074
- }
2075
- }, o && (n.ontimeout = o), n.send(i), n;
2076
- }
2077
- static parseJSON(n) {
2078
- if (!n || n === "")
2079
- return null;
2080
- try {
2081
- return JSON.parse(n);
2082
- } catch {
2083
- return console && console.log("failed to parse JSON response", n), null;
2084
- }
2085
- }
2086
- static serialize(n, s) {
2087
- let t = [];
2088
- for (var e in n) {
2089
- if (!Object.prototype.hasOwnProperty.call(n, e))
2090
- continue;
2091
- let i = s ? `${s}[${e}]` : e, r = n[e];
2092
- typeof r == "object" ? t.push(this.serialize(r, i)) : t.push(encodeURIComponent(i) + "=" + encodeURIComponent(r));
2093
- }
2094
- return t.join("&");
2095
- }
2096
- static appendParams(n, s) {
2097
- if (Object.keys(s).length === 0)
2098
- return n;
2099
- let t = n.match(/\?/) ? "&" : "?";
2100
- return `${n}${t}${this.serialize(s)}`;
2101
- }
2102
- }, jt = class {
2103
- constructor(n) {
2104
- this.endPoint = null, this.token = null, this.skipHeartbeat = !0, this.reqs = /* @__PURE__ */ new Set(), this.onopen = function() {
2105
- }, this.onerror = function() {
2106
- }, this.onmessage = function() {
2107
- }, this.onclose = function() {
2108
- }, this.pollEndpoint = this.normalizeEndpoint(n), this.readyState = P.connecting, this.poll();
2109
- }
2110
- normalizeEndpoint(n) {
2111
- return n.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + Ht.websocket), "$1/" + Ht.longpoll);
2112
- }
2113
- endpointURL() {
2114
- return mt.appendParams(this.pollEndpoint, { token: this.token });
2115
- }
2116
- closeAndRetry(n, s, t) {
2117
- this.close(n, s, t), this.readyState = P.connecting;
2118
- }
2119
- ontimeout() {
2120
- this.onerror("timeout"), this.closeAndRetry(1005, "timeout", !1);
2121
- }
2122
- isActive() {
2123
- return this.readyState === P.open || this.readyState === P.connecting;
2124
- }
2125
- poll() {
2126
- this.ajax("GET", null, () => this.ontimeout(), (n) => {
2127
- if (n) {
2128
- var { status: s, token: t, messages: e } = n;
2129
- this.token = t;
2130
- } else
2131
- s = 0;
2132
- switch (s) {
2133
- case 200:
2134
- e.forEach((i) => {
2135
- setTimeout(() => this.onmessage({ data: i }), 0);
2136
- }), this.poll();
2137
- break;
2138
- case 204:
2139
- this.poll();
2140
- break;
2141
- case 410:
2142
- this.readyState = P.open, this.onopen({}), this.poll();
2143
- break;
2144
- case 403:
2145
- this.onerror(403), this.close(1008, "forbidden", !1);
2146
- break;
2147
- case 0:
2148
- case 500:
2149
- this.onerror(500), this.closeAndRetry(1011, "internal server error", 500);
2150
- break;
2151
- default:
2152
- throw new Error(`unhandled poll status ${s}`);
2153
- }
2154
- });
2155
- }
2156
- send(n) {
2157
- this.ajax("POST", n, () => this.onerror("timeout"), (s) => {
2158
- (!s || s.status !== 200) && (this.onerror(s && s.status), this.closeAndRetry(1011, "internal server error", !1));
2159
- });
2160
- }
2161
- close(n, s, t) {
2162
- for (let i of this.reqs)
2163
- i.abort();
2164
- this.readyState = P.closed;
2165
- let e = Object.assign({ code: 1e3, reason: void 0, wasClean: !0 }, { code: n, reason: s, wasClean: t });
2166
- typeof CloseEvent < "u" ? this.onclose(new CloseEvent("close", e)) : this.onclose(e);
2167
- }
2168
- ajax(n, s, t, e) {
2169
- let i, r = () => {
2170
- this.reqs.delete(i), t();
2171
- };
2172
- i = mt.request(n, this.endpointURL(), "application/json", s, this.timeout, r, (o) => {
2173
- this.reqs.delete(i), this.isActive() && e(o);
2174
- }), this.reqs.add(i);
2175
- }
2176
- }, pt = {
2177
- HEADER_LENGTH: 1,
2178
- META_LENGTH: 4,
2179
- KINDS: { push: 0, reply: 1, broadcast: 2 },
2180
- encode(n, s) {
2181
- if (n.payload.constructor === ArrayBuffer)
2182
- return s(this.binaryEncode(n));
2183
- {
2184
- let t = [n.join_ref, n.ref, n.topic, n.event, n.payload];
2185
- return s(JSON.stringify(t));
2186
- }
2187
- },
2188
- decode(n, s) {
2189
- if (n.constructor === ArrayBuffer)
2190
- return s(this.binaryDecode(n));
2191
- {
2192
- let [t, e, i, r, o] = JSON.parse(n);
2193
- return s({ join_ref: t, ref: e, topic: i, event: r, payload: o });
2194
- }
2195
- },
2196
- binaryEncode(n) {
2197
- let { join_ref: s, ref: t, event: e, topic: i, payload: r } = n, o = this.META_LENGTH + s.length + t.length + i.length + e.length, l = new ArrayBuffer(this.HEADER_LENGTH + o), u = new DataView(l), d = 0;
2198
- u.setUint8(d++, this.KINDS.push), u.setUint8(d++, s.length), u.setUint8(d++, t.length), u.setUint8(d++, i.length), u.setUint8(d++, e.length), Array.from(s, (y) => u.setUint8(d++, y.charCodeAt(0))), Array.from(t, (y) => u.setUint8(d++, y.charCodeAt(0))), Array.from(i, (y) => u.setUint8(d++, y.charCodeAt(0))), Array.from(e, (y) => u.setUint8(d++, y.charCodeAt(0)));
2199
- var C = new Uint8Array(l.byteLength + r.byteLength);
2200
- return C.set(new Uint8Array(l), 0), C.set(new Uint8Array(r), l.byteLength), C.buffer;
2201
- },
2202
- binaryDecode(n) {
2203
- let s = new DataView(n), t = s.getUint8(0), e = new TextDecoder();
2204
- switch (t) {
2205
- case this.KINDS.push:
2206
- return this.decodePush(n, s, e);
2207
- case this.KINDS.reply:
2208
- return this.decodeReply(n, s, e);
2209
- case this.KINDS.broadcast:
2210
- return this.decodeBroadcast(n, s, e);
2211
- }
2212
- },
2213
- decodePush(n, s, t) {
2214
- let e = s.getUint8(1), i = s.getUint8(2), r = s.getUint8(3), o = this.HEADER_LENGTH + this.META_LENGTH - 1, l = t.decode(n.slice(o, o + e));
2215
- o = o + e;
2216
- let u = t.decode(n.slice(o, o + i));
2217
- o = o + i;
2218
- let d = t.decode(n.slice(o, o + r));
2219
- o = o + r;
2220
- let C = n.slice(o, n.byteLength);
2221
- return { join_ref: l, ref: null, topic: u, event: d, payload: C };
2222
- },
2223
- decodeReply(n, s, t) {
2224
- let e = s.getUint8(1), i = s.getUint8(2), r = s.getUint8(3), o = s.getUint8(4), l = this.HEADER_LENGTH + this.META_LENGTH, u = t.decode(n.slice(l, l + e));
2225
- l = l + e;
2226
- let d = t.decode(n.slice(l, l + i));
2227
- l = l + i;
2228
- let C = t.decode(n.slice(l, l + r));
2229
- l = l + r;
2230
- let y = t.decode(n.slice(l, l + o));
2231
- l = l + o;
2232
- let $ = n.slice(l, n.byteLength), x = { status: y, response: $ };
2233
- return { join_ref: u, ref: d, topic: C, event: U.reply, payload: x };
2234
- },
2235
- decodeBroadcast(n, s, t) {
2236
- let e = s.getUint8(1), i = s.getUint8(2), r = this.HEADER_LENGTH + 2, o = t.decode(n.slice(r, r + e));
2237
- r = r + e;
2238
- let l = t.decode(n.slice(r, r + i));
2239
- r = r + i;
2240
- let u = n.slice(r, n.byteLength);
2241
- return { join_ref: null, ref: null, topic: o, event: l, payload: u };
2242
- }
2243
- }, dn = class {
2244
- constructor(n, s = {}) {
2245
- this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.timeout = s.timeout || ln, this.transport = s.transport || nt.WebSocket || jt, this.establishedConnections = 0, this.defaultEncoder = pt.encode.bind(pt), this.defaultDecoder = pt.decode.bind(pt), this.closeWasClean = !1, this.binaryType = s.binaryType || "arraybuffer", this.connectClock = 1, this.transport !== jt ? (this.encode = s.encode || this.defaultEncoder, this.decode = s.decode || this.defaultDecoder) : (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder);
2246
- let t = null;
2247
- tt && tt.addEventListener && (tt.addEventListener("pagehide", (e) => {
2248
- this.conn && (this.disconnect(), t = this.connectClock);
2249
- }), tt.addEventListener("pageshow", (e) => {
2250
- t === this.connectClock && (t = null, this.connect());
2251
- })), this.heartbeatIntervalMs = s.heartbeatIntervalMs || 3e4, this.rejoinAfterMs = (e) => s.rejoinAfterMs ? s.rejoinAfterMs(e) : [1e3, 2e3, 5e3][e - 1] || 1e4, this.reconnectAfterMs = (e) => s.reconnectAfterMs ? s.reconnectAfterMs(e) : [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][e - 1] || 5e3, this.logger = s.logger || null, this.longpollerTimeout = s.longpollerTimeout || 2e4, this.params = st(s.params || {}), this.endPoint = `${n}/${Ht.websocket}`, this.vsn = s.vsn || hn, this.heartbeatTimeoutTimer = null, this.heartbeatTimer = null, this.pendingHeartbeatRef = null, this.reconnectTimer = new be(() => {
2252
- this.teardown(() => this.connect());
2253
- }, this.reconnectAfterMs);
2254
- }
2255
- getLongPollTransport() {
2256
- return jt;
2257
- }
2258
- replaceTransport(n) {
2259
- this.connectClock++, this.closeWasClean = !0, this.reconnectTimer.reset(), this.sendBuffer = [], this.conn && (this.conn.close(), this.conn = null), this.transport = n;
2260
- }
2261
- protocol() {
2262
- return location.protocol.match(/^https/) ? "wss" : "ws";
2263
- }
2264
- endPointURL() {
2265
- let n = mt.appendParams(mt.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
2266
- return n.charAt(0) !== "/" ? n : n.charAt(1) === "/" ? `${this.protocol()}:${n}` : `${this.protocol()}://${location.host}${n}`;
2267
- }
2268
- disconnect(n, s, t) {
2269
- this.connectClock++, this.closeWasClean = !0, this.reconnectTimer.reset(), this.teardown(n, s, t);
2270
- }
2271
- connect(n) {
2272
- n && (console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"), this.params = st(n)), !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 = (s) => this.onConnError(s), this.conn.onmessage = (s) => this.onConnMessage(s), this.conn.onclose = (s) => this.onConnClose(s));
2273
- }
2274
- log(n, s, t) {
2275
- this.logger(n, s, t);
2276
- }
2277
- hasLogger() {
2278
- return this.logger !== null;
2279
- }
2280
- onOpen(n) {
2281
- let s = this.makeRef();
2282
- return this.stateChangeCallbacks.open.push([s, n]), s;
2283
- }
2284
- onClose(n) {
2285
- let s = this.makeRef();
2286
- return this.stateChangeCallbacks.close.push([s, n]), s;
2287
- }
2288
- onError(n) {
2289
- let s = this.makeRef();
2290
- return this.stateChangeCallbacks.error.push([s, n]), s;
2291
- }
2292
- onMessage(n) {
2293
- let s = this.makeRef();
2294
- return this.stateChangeCallbacks.message.push([s, n]), s;
2295
- }
2296
- ping(n) {
2297
- if (!this.isConnected())
2298
- return !1;
2299
- let s = this.makeRef(), t = Date.now();
2300
- this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: s });
2301
- let e = this.onMessage((i) => {
2302
- i.ref === s && (this.off([e]), n(Date.now() - t));
2303
- });
2304
- return !0;
2305
- }
2306
- clearHeartbeats() {
2307
- clearTimeout(this.heartbeatTimer), clearTimeout(this.heartbeatTimeoutTimer);
2308
- }
2309
- onConnOpen() {
2310
- 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(([, n]) => n());
2311
- }
2312
- heartbeatTimeout() {
2313
- 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(), cn, "heartbeat timeout"));
2314
- }
2315
- resetHeartbeat() {
2316
- this.conn && this.conn.skipHeartbeat || (this.pendingHeartbeatRef = null, this.clearHeartbeats(), this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs));
2317
- }
2318
- teardown(n, s, t) {
2319
- if (!this.conn)
2320
- return n && n();
2321
- this.waitForBufferDone(() => {
2322
- this.conn && (s ? this.conn.close(s, t || "") : this.conn.close()), this.waitForSocketClosed(() => {
2323
- this.conn && (this.conn.onopen = function() {
2324
- }, this.conn.onerror = function() {
2325
- }, this.conn.onmessage = function() {
2326
- }, this.conn.onclose = function() {
2327
- }, this.conn = null), n && n();
2328
- });
2329
- });
2330
- }
2331
- waitForBufferDone(n, s = 1) {
2332
- if (s === 5 || !this.conn || !this.conn.bufferedAmount) {
2333
- n();
2334
- return;
2335
- }
2336
- setTimeout(() => {
2337
- this.waitForBufferDone(n, s + 1);
2338
- }, 150 * s);
2339
- }
2340
- waitForSocketClosed(n, s = 1) {
2341
- if (s === 5 || !this.conn || this.conn.readyState === P.closed) {
2342
- n();
2343
- return;
2344
- }
2345
- setTimeout(() => {
2346
- this.waitForSocketClosed(n, s + 1);
2347
- }, 150 * s);
2348
- }
2349
- onConnClose(n) {
2350
- let s = n && n.code;
2351
- this.hasLogger() && this.log("transport", "close", n), this.triggerChanError(), this.clearHeartbeats(), !this.closeWasClean && s !== 1e3 && this.reconnectTimer.scheduleTimeout(), this.stateChangeCallbacks.close.forEach(([, t]) => t(n));
2352
- }
2353
- onConnError(n) {
2354
- this.hasLogger() && this.log("transport", n);
2355
- let s = this.transport, t = this.establishedConnections;
2356
- this.stateChangeCallbacks.error.forEach(([, e]) => {
2357
- e(n, s, t);
2358
- }), (s === this.transport || t > 0) && this.triggerChanError();
2359
- }
2360
- triggerChanError() {
2361
- this.channels.forEach((n) => {
2362
- n.isErrored() || n.isLeaving() || n.isClosed() || n.trigger(U.error);
2363
- });
2364
- }
2365
- connectionState() {
2366
- switch (this.conn && this.conn.readyState) {
2367
- case P.connecting:
2368
- return "connecting";
2369
- case P.open:
2370
- return "open";
2371
- case P.closing:
2372
- return "closing";
2373
- default:
2374
- return "closed";
2375
- }
2376
- }
2377
- isConnected() {
2378
- return this.connectionState() === "open";
2379
- }
2380
- remove(n) {
2381
- this.off(n.stateChangeRefs), this.channels = this.channels.filter((s) => s.joinRef() !== n.joinRef());
2382
- }
2383
- off(n) {
2384
- for (let s in this.stateChangeCallbacks)
2385
- this.stateChangeCallbacks[s] = this.stateChangeCallbacks[s].filter(([t]) => n.indexOf(t) === -1);
2386
- }
2387
- channel(n, s = {}) {
2388
- let t = new pn(n, s, this);
2389
- return this.channels.push(t), t;
2390
- }
2391
- push(n) {
2392
- if (this.hasLogger()) {
2393
- let { topic: s, event: t, payload: e, ref: i, join_ref: r } = n;
2394
- this.log("push", `${s} ${t} (${r}, ${i})`, e);
2395
- }
2396
- this.isConnected() ? this.encode(n, (s) => this.conn.send(s)) : this.sendBuffer.push(() => this.encode(n, (s) => this.conn.send(s)));
2397
- }
2398
- makeRef() {
2399
- let n = this.ref + 1;
2400
- return n === this.ref ? this.ref = 0 : this.ref = n, this.ref.toString();
2401
- }
2402
- sendHeartbeat() {
2403
- 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));
2404
- }
2405
- flushSendBuffer() {
2406
- this.isConnected() && this.sendBuffer.length > 0 && (this.sendBuffer.forEach((n) => n()), this.sendBuffer = []);
2407
- }
2408
- onConnMessage(n) {
2409
- this.decode(n.data, (s) => {
2410
- let { topic: t, event: e, payload: i, ref: r, join_ref: o } = s;
2411
- r && r === this.pendingHeartbeatRef && (this.clearHeartbeats(), this.pendingHeartbeatRef = null, this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs)), this.hasLogger() && this.log("receive", `${i.status || ""} ${t} ${e} ${r && "(" + r + ")" || ""}`, i);
2412
- for (let l = 0; l < this.channels.length; l++) {
2413
- const u = this.channels[l];
2414
- u.isMember(t, e, i, o) && u.trigger(e, i, r, o);
2415
- }
2416
- for (let l = 0; l < this.stateChangeCallbacks.message.length; l++) {
2417
- let [, u] = this.stateChangeCallbacks.message[l];
2418
- u(s);
2419
- }
2420
- });
2421
- }
2422
- leaveOpenTopic(n) {
2423
- let s = this.channels.find((t) => t.topic === n && (t.isJoined() || t.isJoining()));
2424
- s && (this.hasLogger() && this.log("transport", `leaving duplicate topic "${n}"`), s.leave());
2425
- }
2426
- };
2427
- class fn {
2428
- constructor(s) {
2429
- this.connected = !1, this.config = s, this.socket = new dn(this.config.url, { logger: (t, e, i) => {
2430
- console.log(`${t}: ${e}`, i);
2431
- } }), this.channel = this.socket.channel(this.config.topic, this.config.params), this.eventTarget = new EventTarget();
2432
- }
2433
- /** connect to socket and join channel. will do nothing if already connected */
2434
- connect() {
2435
- this.connected || (this.socket.onError((s) => this.emitError("socket error", s)), this.socket.connect(), this.channel.onError((s) => console.log("channel error", s)), this.channel.join().receive("ok", () => {
2436
- console.log("joined");
2437
- }).receive("error", (s) => {
2438
- this.emitError("channel join error", s);
2439
- }), this.channel.on("state:change", (s) => this.handleChange(s)), this.channel.on("state:patch", (s) => this.handlePatch(s)), this.connected = !0);
2440
- }
2441
- /** leave channel and disconnect from socket */
2442
- disconnect() {
2443
- this.channel && this.channel.leave(), this.socket.disconnect(), this.connected = !1;
2444
- }
2445
- /** for events that begin with 'livestate-', add a listener. For
2446
- * other events, additionally call `channel.on` to receive the event
2447
- * over the channel, which will then be dispatched.
2448
- */
2449
- addEventListener(s, t, e) {
2450
- var i;
2451
- this.eventTarget.addEventListener(s, t, e), s.startsWith("livestate-") || (i = this.channel) == null || i.on(s, (r) => {
2452
- this.eventTarget.dispatchEvent(new CustomEvent(s, { detail: r }));
2453
- });
2454
- }
2455
- removeEventListener(s, t, e) {
2456
- return this.eventTarget.removeEventListener(s, t, e);
2457
- }
2458
- /** @deprecated */
2459
- subscribe(s) {
2460
- this.addEventListener("livestate-change", s);
2461
- }
2462
- /** @deprecated */
2463
- unsubscribe(s) {
2464
- this.removeEventListener("livestate-change", s);
2465
- }
2466
- emitError(s, t) {
2467
- this.eventTarget.dispatchEvent(new CustomEvent("livestate-error", {
2468
- detail: {
2469
- kind: s,
2470
- error: t
2471
- }
2472
- }));
2473
- }
2474
- handleChange({ state: s, version: t }) {
2475
- this.state = s, this.stateVersion = t, this.eventTarget.dispatchEvent(new CustomEvent("livestate-change", {
2476
- detail: {
2477
- state: this.state,
2478
- version: this.stateVersion
2479
- }
2480
- }));
2481
- }
2482
- handlePatch({ patch: s, version: t }) {
2483
- if (this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch", {
2484
- detail: { patch: s, version: t }
2485
- })), t === this.stateVersion + 1) {
2486
- const { doc: e, res: i } = on(this.state, s, { mutate: !1 });
2487
- this.state = e, this.stateVersion = t, this.eventTarget.dispatchEvent(new CustomEvent("livestate-change", {
2488
- detail: {
2489
- state: this.state,
2490
- version: this.stateVersion
2491
- }
2492
- }));
2493
- } else
2494
- this.channel.push("lvs_refresh");
2495
- }
2496
- pushEvent(s, t) {
2497
- this.dispatchEvent(new CustomEvent(s, { detail: t }));
2498
- }
2499
- /** Pushes the event over the channel, adding the `lvs_evt:` prefix and using the CustomEvent
2500
- * detail property as the payload
2501
- */
2502
- dispatchEvent(s) {
2503
- return this.channel.push(`lvs_evt:${s.type}`, s.detail), !0;
2504
- }
2505
- pushCustomEvent(s) {
2506
- this.dispatchEvent(s);
2507
- }
2508
- }
2509
- const vn = (n, s, { properties: t, attributes: e, events: i }) => {
2510
- var r, o;
2511
- s.liveState !== n && (n.connect(), t == null || t.forEach((l) => gn(n, s, l)), e == null || e.forEach((l) => yn(n, s, l)), (r = i == null ? void 0 : i.send) == null || r.forEach((l) => _n(n, s, l)), (o = i == null ? void 0 : i.receive) == null || o.forEach((l) => mn(n, s, l)), s.liveState = n);
2512
- }, gn = (n, s, t) => {
2513
- n.addEventListener("livestate-change", ({ detail: { state: e } }) => {
2514
- s[t] = e[t];
2515
- });
2516
- }, yn = (n, s, t) => {
2517
- n.addEventListener("livestate-change", ({ detail: { state: e } }) => {
2518
- s.setAttribute(t, e[t]);
2519
- });
2520
- }, mn = (n, s, t) => {
2521
- n.addEventListener(t, ({ detail: e }) => {
2522
- s.dispatchEvent(new CustomEvent(t, { detail: e }));
2523
- });
2524
- }, _n = (n, s, t) => {
2525
- s.addEventListener(t, (e) => {
2526
- const { detail: i } = e;
2527
- n.dispatchEvent(new CustomEvent(t, { detail: i }));
2528
- });
2529
- };
2530
- Promise.resolve();
2531
- var pe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2532
- /*! *****************************************************************************
2533
- Copyright (C) Microsoft. All rights reserved.
2534
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2535
- this file except in compliance with the License. You may obtain a copy of the
2536
- License at http://www.apache.org/licenses/LICENSE-2.0
2537
-
2538
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2539
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2540
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2541
- MERCHANTABLITY OR NON-INFRINGEMENT.
2542
-
2543
- See the Apache Version 2.0 License for specific language governing permissions
2544
- and limitations under the License.
2545
- ***************************************************************************** */
2546
- var de;
2547
- (function(n) {
2548
- (function(s) {
2549
- var t = typeof pe == "object" ? pe : typeof self == "object" ? self : typeof this == "object" ? this : Function("return this;")(), e = i(n);
2550
- typeof t.Reflect > "u" ? t.Reflect = n : e = i(t.Reflect, e), s(e);
2551
- function i(r, o) {
2552
- return function(l, u) {
2553
- typeof r[l] != "function" && Object.defineProperty(r, l, { configurable: !0, writable: !0, value: u }), o && o(l, u);
2554
- };
2555
- }
2556
- })(function(s) {
2557
- var t = Object.prototype.hasOwnProperty, e = typeof Symbol == "function", i = e && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", r = e && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", o = typeof Object.create == "function", l = { __proto__: [] } instanceof Array, u = !o && !l, d = {
2558
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
2559
- create: o ? function() {
2560
- return bt(/* @__PURE__ */ Object.create(null));
2561
- } : l ? function() {
2562
- return bt({ __proto__: null });
2563
- } : function() {
2564
- return bt({});
2565
- },
2566
- has: u ? function(a, h) {
2567
- return t.call(a, h);
2568
- } : function(a, h) {
2569
- return h in a;
2570
- },
2571
- get: u ? function(a, h) {
2572
- return t.call(a, h) ? a[h] : void 0;
2573
- } : function(a, h) {
2574
- return a[h];
2575
- }
2576
- }, C = Object.getPrototypeOf(Function), y = typeof process == "object" && process.env && process.env.REFLECT_METADATA_USE_MAP_POLYFILL === "true", $ = !y && typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : Ge(), x = !y && typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Fe(), W = !y && typeof WeakMap == "function" ? WeakMap : qe(), H = new W();
2577
- function $e(a, h, c, p) {
2578
- if (k(c)) {
2579
- if (!Xt(a))
2580
- throw new TypeError();
2581
- if (!Kt(h))
2582
- throw new TypeError();
2583
- return Ne(a, h);
2584
- } else {
2585
- if (!Xt(a))
2586
- throw new TypeError();
2587
- if (!S(h))
2588
- throw new TypeError();
2589
- if (!S(p) && !k(p) && !G(p))
2590
- throw new TypeError();
2591
- return G(p) && (p = void 0), c = L(c), Pe(a, h, c, p);
2592
- }
2593
- }
2594
- s("decorate", $e);
2595
- function Ce(a, h) {
2596
- function c(p, f) {
2597
- if (!S(p))
2598
- throw new TypeError();
2599
- if (!k(f) && !Ve(f))
2600
- throw new TypeError();
2601
- Wt(a, h, p, f);
2602
- }
2603
- return c;
2604
- }
2605
- s("metadata", Ce);
2606
- function Te(a, h, c, p) {
2607
- if (!S(c))
2608
- throw new TypeError();
2609
- return k(p) || (p = L(p)), Wt(a, h, c, p);
2610
- }
2611
- s("defineMetadata", Te);
2612
- function ke(a, h, c) {
2613
- if (!S(h))
2614
- throw new TypeError();
2615
- return k(c) || (c = L(c)), zt(a, h, c);
2616
- }
2617
- s("hasMetadata", ke);
2618
- function xe(a, h, c) {
2619
- if (!S(h))
2620
- throw new TypeError();
2621
- return k(c) || (c = L(c)), At(a, h, c);
2622
- }
2623
- s("hasOwnMetadata", xe);
2624
- function Se(a, h, c) {
2625
- if (!S(h))
2626
- throw new TypeError();
2627
- return k(c) || (c = L(c)), Jt(a, h, c);
2628
- }
2629
- s("getMetadata", Se);
2630
- function Oe(a, h, c) {
2631
- if (!S(h))
2632
- throw new TypeError();
2633
- return k(c) || (c = L(c)), Bt(a, h, c);
2634
- }
2635
- s("getOwnMetadata", Oe);
2636
- function je(a, h) {
2637
- if (!S(a))
2638
- throw new TypeError();
2639
- return k(h) || (h = L(h)), Gt(a, h);
2640
- }
2641
- s("getMetadataKeys", je);
2642
- function Me(a, h) {
2643
- if (!S(a))
2644
- throw new TypeError();
2645
- return k(h) || (h = L(h)), Ft(a, h);
2646
- }
2647
- s("getOwnMetadataKeys", Me);
2648
- function Re(a, h, c) {
2649
- if (!S(h))
2650
- throw new TypeError();
2651
- k(c) || (c = L(c));
2652
- var p = Z(
2653
- h,
2654
- c,
2655
- /*Create*/
2656
- !1
2657
- );
2658
- if (k(p) || !p.delete(a))
2659
- return !1;
2660
- if (p.size > 0)
2661
- return !0;
2662
- var f = H.get(h);
2663
- return f.delete(c), f.size > 0 || H.delete(h), !0;
2664
- }
2665
- s("deleteMetadata", Re);
2666
- function Ne(a, h) {
2667
- for (var c = a.length - 1; c >= 0; --c) {
2668
- var p = a[c], f = p(h);
2669
- if (!k(f) && !G(f)) {
2670
- if (!Kt(f))
2671
- throw new TypeError();
2672
- h = f;
2673
- }
2674
- }
2675
- return h;
2676
- }
2677
- function Pe(a, h, c, p) {
2678
- for (var f = a.length - 1; f >= 0; --f) {
2679
- var j = a[f], m = j(h, c, p);
2680
- if (!k(m) && !G(m)) {
2681
- if (!S(m))
2682
- throw new TypeError();
2683
- p = m;
2684
- }
2685
- }
2686
- return p;
2687
- }
2688
- function Z(a, h, c) {
2689
- var p = H.get(a);
2690
- if (k(p)) {
2691
- if (!c)
2692
- return;
2693
- p = new $(), H.set(a, p);
2694
- }
2695
- var f = p.get(h);
2696
- if (k(f)) {
2697
- if (!c)
2698
- return;
2699
- f = new $(), p.set(h, f);
2700
- }
2701
- return f;
2702
- }
2703
- function zt(a, h, c) {
2704
- var p = At(a, h, c);
2705
- if (p)
2706
- return !0;
2707
- var f = Et(h);
2708
- return G(f) ? !1 : zt(a, f, c);
2709
- }
2710
- function At(a, h, c) {
2711
- var p = Z(
2712
- h,
2713
- c,
2714
- /*Create*/
2715
- !1
2716
- );
2717
- return k(p) ? !1 : De(p.has(a));
2718
- }
2719
- function Jt(a, h, c) {
2720
- var p = At(a, h, c);
2721
- if (p)
2722
- return Bt(a, h, c);
2723
- var f = Et(h);
2724
- if (!G(f))
2725
- return Jt(a, f, c);
2726
- }
2727
- function Bt(a, h, c) {
2728
- var p = Z(
2729
- h,
2730
- c,
2731
- /*Create*/
2732
- !1
2733
- );
2734
- if (!k(p))
2735
- return p.get(a);
2736
- }
2737
- function Wt(a, h, c, p) {
2738
- var f = Z(
2739
- c,
2740
- p,
2741
- /*Create*/
2742
- !0
2743
- );
2744
- f.set(a, h);
2745
- }
2746
- function Gt(a, h) {
2747
- var c = Ft(a, h), p = Et(a);
2748
- if (p === null)
2749
- return c;
2750
- var f = Gt(p, h);
2751
- if (f.length <= 0)
2752
- return c;
2753
- if (c.length <= 0)
2754
- return f;
2755
- for (var j = new x(), m = [], _ = 0, v = c; _ < v.length; _++) {
2756
- var A = v[_], E = j.has(A);
2757
- E || (j.add(A), m.push(A));
2758
- }
2759
- for (var D = 0, Zt = f; D < Zt.length; D++) {
2760
- var A = Zt[D], E = j.has(A);
2761
- E || (j.add(A), m.push(A));
2762
- }
2763
- return m;
2764
- }
2765
- function Ft(a, h) {
2766
- var c = [], p = Z(
2767
- a,
2768
- h,
2769
- /*Create*/
2770
- !1
2771
- );
2772
- if (k(p))
2773
- return c;
2774
- for (var f = p.keys(), j = ze(f), m = 0; ; ) {
2775
- var _ = Be(j);
2776
- if (!_)
2777
- return c.length = m, c;
2778
- var v = Je(_);
2779
- try {
2780
- c[m] = v;
2781
- } catch (A) {
2782
- try {
2783
- We(j);
2784
- } finally {
2785
- throw A;
2786
- }
2787
- }
2788
- m++;
2789
- }
2790
- }
2791
- function qt(a) {
2792
- if (a === null)
2793
- return 1;
2794
- switch (typeof a) {
2795
- case "undefined":
2796
- return 0;
2797
- case "boolean":
2798
- return 2;
2799
- case "string":
2800
- return 3;
2801
- case "symbol":
2802
- return 4;
2803
- case "number":
2804
- return 5;
2805
- case "object":
2806
- return a === null ? 1 : 6;
2807
- default:
2808
- return 6;
2809
- }
2810
- }
2811
- function k(a) {
2812
- return a === void 0;
2813
- }
2814
- function G(a) {
2815
- return a === null;
2816
- }
2817
- function He(a) {
2818
- return typeof a == "symbol";
2819
- }
2820
- function S(a) {
2821
- return typeof a == "object" ? a !== null : typeof a == "function";
2822
- }
2823
- function Le(a, h) {
2824
- switch (qt(a)) {
2825
- case 0:
2826
- return a;
2827
- case 1:
2828
- return a;
2829
- case 2:
2830
- return a;
2831
- case 3:
2832
- return a;
2833
- case 4:
2834
- return a;
2835
- case 5:
2836
- return a;
2837
- }
2838
- var c = h === 3 ? "string" : h === 5 ? "number" : "default", p = Yt(a, i);
2839
- if (p !== void 0) {
2840
- var f = p.call(a, c);
2841
- if (S(f))
2842
- throw new TypeError();
2843
- return f;
2844
- }
2845
- return Ue(a, c === "default" ? "number" : c);
2846
- }
2847
- function Ue(a, h) {
2848
- if (h === "string") {
2849
- var c = a.toString;
2850
- if (F(c)) {
2851
- var p = c.call(a);
2852
- if (!S(p))
2853
- return p;
2854
- }
2855
- var f = a.valueOf;
2856
- if (F(f)) {
2857
- var p = f.call(a);
2858
- if (!S(p))
2859
- return p;
2860
- }
2861
- } else {
2862
- var f = a.valueOf;
2863
- if (F(f)) {
2864
- var p = f.call(a);
2865
- if (!S(p))
2866
- return p;
2867
- }
2868
- var j = a.toString;
2869
- if (F(j)) {
2870
- var p = j.call(a);
2871
- if (!S(p))
2872
- return p;
2873
- }
2874
- }
2875
- throw new TypeError();
2876
- }
2877
- function De(a) {
2878
- return !!a;
2879
- }
2880
- function Ie(a) {
2881
- return "" + a;
2882
- }
2883
- function L(a) {
2884
- var h = Le(
2885
- a,
2886
- 3
2887
- /* String */
2888
- );
2889
- return He(h) ? h : Ie(h);
2890
- }
2891
- function Xt(a) {
2892
- return Array.isArray ? Array.isArray(a) : a instanceof Object ? a instanceof Array : Object.prototype.toString.call(a) === "[object Array]";
2893
- }
2894
- function F(a) {
2895
- return typeof a == "function";
2896
- }
2897
- function Kt(a) {
2898
- return typeof a == "function";
2899
- }
2900
- function Ve(a) {
2901
- switch (qt(a)) {
2902
- case 3:
2903
- return !0;
2904
- case 4:
2905
- return !0;
2906
- default:
2907
- return !1;
2908
- }
2909
- }
2910
- function Yt(a, h) {
2911
- var c = a[h];
2912
- if (c != null) {
2913
- if (!F(c))
2914
- throw new TypeError();
2915
- return c;
2916
- }
2917
- }
2918
- function ze(a) {
2919
- var h = Yt(a, r);
2920
- if (!F(h))
2921
- throw new TypeError();
2922
- var c = h.call(a);
2923
- if (!S(c))
2924
- throw new TypeError();
2925
- return c;
2926
- }
2927
- function Je(a) {
2928
- return a.value;
2929
- }
2930
- function Be(a) {
2931
- var h = a.next();
2932
- return h.done ? !1 : h;
2933
- }
2934
- function We(a) {
2935
- var h = a.return;
2936
- h && h.call(a);
2937
- }
2938
- function Et(a) {
2939
- var h = Object.getPrototypeOf(a);
2940
- if (typeof a != "function" || a === C || h !== C)
2941
- return h;
2942
- var c = a.prototype, p = c && Object.getPrototypeOf(c);
2943
- if (p == null || p === Object.prototype)
2944
- return h;
2945
- var f = p.constructor;
2946
- return typeof f != "function" || f === a ? h : f;
2947
- }
2948
- function Ge() {
2949
- var a = {}, h = [], c = (
2950
- /** @class */
2951
- function() {
2952
- function m(_, v, A) {
2953
- this._index = 0, this._keys = _, this._values = v, this._selector = A;
2954
- }
2955
- return m.prototype["@@iterator"] = function() {
2956
- return this;
2957
- }, m.prototype[r] = function() {
2958
- return this;
2959
- }, m.prototype.next = function() {
2960
- var _ = this._index;
2961
- if (_ >= 0 && _ < this._keys.length) {
2962
- var v = this._selector(this._keys[_], this._values[_]);
2963
- return _ + 1 >= this._keys.length ? (this._index = -1, this._keys = h, this._values = h) : this._index++, { value: v, done: !1 };
2964
- }
2965
- return { value: void 0, done: !0 };
2966
- }, m.prototype.throw = function(_) {
2967
- throw this._index >= 0 && (this._index = -1, this._keys = h, this._values = h), _;
2968
- }, m.prototype.return = function(_) {
2969
- return this._index >= 0 && (this._index = -1, this._keys = h, this._values = h), { value: _, done: !0 };
2970
- }, m;
2971
- }()
2972
- );
2973
- return (
2974
- /** @class */
2975
- function() {
2976
- function m() {
2977
- this._keys = [], this._values = [], this._cacheKey = a, this._cacheIndex = -2;
2978
- }
2979
- return Object.defineProperty(m.prototype, "size", {
2980
- get: function() {
2981
- return this._keys.length;
2982
- },
2983
- enumerable: !0,
2984
- configurable: !0
2985
- }), m.prototype.has = function(_) {
2986
- return this._find(
2987
- _,
2988
- /*insert*/
2989
- !1
2990
- ) >= 0;
2991
- }, m.prototype.get = function(_) {
2992
- var v = this._find(
2993
- _,
2994
- /*insert*/
2995
- !1
2996
- );
2997
- return v >= 0 ? this._values[v] : void 0;
2998
- }, m.prototype.set = function(_, v) {
2999
- var A = this._find(
3000
- _,
3001
- /*insert*/
3002
- !0
3003
- );
3004
- return this._values[A] = v, this;
3005
- }, m.prototype.delete = function(_) {
3006
- var v = this._find(
3007
- _,
3008
- /*insert*/
3009
- !1
3010
- );
3011
- if (v >= 0) {
3012
- for (var A = this._keys.length, E = v + 1; E < A; E++)
3013
- this._keys[E - 1] = this._keys[E], this._values[E - 1] = this._values[E];
3014
- return this._keys.length--, this._values.length--, _ === this._cacheKey && (this._cacheKey = a, this._cacheIndex = -2), !0;
3015
- }
3016
- return !1;
3017
- }, m.prototype.clear = function() {
3018
- this._keys.length = 0, this._values.length = 0, this._cacheKey = a, this._cacheIndex = -2;
3019
- }, m.prototype.keys = function() {
3020
- return new c(this._keys, this._values, p);
3021
- }, m.prototype.values = function() {
3022
- return new c(this._keys, this._values, f);
3023
- }, m.prototype.entries = function() {
3024
- return new c(this._keys, this._values, j);
3025
- }, m.prototype["@@iterator"] = function() {
3026
- return this.entries();
3027
- }, m.prototype[r] = function() {
3028
- return this.entries();
3029
- }, m.prototype._find = function(_, v) {
3030
- return this._cacheKey !== _ && (this._cacheIndex = this._keys.indexOf(this._cacheKey = _)), this._cacheIndex < 0 && v && (this._cacheIndex = this._keys.length, this._keys.push(_), this._values.push(void 0)), this._cacheIndex;
3031
- }, m;
3032
- }()
3033
- );
3034
- function p(m, _) {
3035
- return m;
3036
- }
3037
- function f(m, _) {
3038
- return _;
3039
- }
3040
- function j(m, _) {
3041
- return [m, _];
3042
- }
3043
- }
3044
- function Fe() {
3045
- return (
3046
- /** @class */
3047
- function() {
3048
- function a() {
3049
- this._map = new $();
3050
- }
3051
- return Object.defineProperty(a.prototype, "size", {
3052
- get: function() {
3053
- return this._map.size;
3054
- },
3055
- enumerable: !0,
3056
- configurable: !0
3057
- }), a.prototype.has = function(h) {
3058
- return this._map.has(h);
3059
- }, a.prototype.add = function(h) {
3060
- return this._map.set(h, h), this;
3061
- }, a.prototype.delete = function(h) {
3062
- return this._map.delete(h);
3063
- }, a.prototype.clear = function() {
3064
- this._map.clear();
3065
- }, a.prototype.keys = function() {
3066
- return this._map.keys();
3067
- }, a.prototype.values = function() {
3068
- return this._map.values();
3069
- }, a.prototype.entries = function() {
3070
- return this._map.entries();
3071
- }, a.prototype["@@iterator"] = function() {
3072
- return this.keys();
3073
- }, a.prototype[r] = function() {
3074
- return this.keys();
3075
- }, a;
3076
- }()
3077
- );
3078
- }
3079
- function qe() {
3080
- var a = 16, h = d.create(), c = p();
3081
- return (
3082
- /** @class */
3083
- function() {
3084
- function v() {
3085
- this._key = p();
3086
- }
3087
- return v.prototype.has = function(A) {
3088
- var E = f(
3089
- A,
3090
- /*create*/
3091
- !1
3092
- );
3093
- return E !== void 0 ? d.has(E, this._key) : !1;
3094
- }, v.prototype.get = function(A) {
3095
- var E = f(
3096
- A,
3097
- /*create*/
3098
- !1
3099
- );
3100
- return E !== void 0 ? d.get(E, this._key) : void 0;
3101
- }, v.prototype.set = function(A, E) {
3102
- var D = f(
3103
- A,
3104
- /*create*/
3105
- !0
3106
- );
3107
- return D[this._key] = E, this;
3108
- }, v.prototype.delete = function(A) {
3109
- var E = f(
3110
- A,
3111
- /*create*/
3112
- !1
3113
- );
3114
- return E !== void 0 ? delete E[this._key] : !1;
3115
- }, v.prototype.clear = function() {
3116
- this._key = p();
3117
- }, v;
3118
- }()
3119
- );
3120
- function p() {
3121
- var v;
3122
- do
3123
- v = "@@WeakMap@@" + _();
3124
- while (d.has(h, v));
3125
- return h[v] = !0, v;
3126
- }
3127
- function f(v, A) {
3128
- if (!t.call(v, c)) {
3129
- if (!A)
3130
- return;
3131
- Object.defineProperty(v, c, { value: d.create() });
3132
- }
3133
- return v[c];
3134
- }
3135
- function j(v, A) {
3136
- for (var E = 0; E < A; ++E)
3137
- v[E] = Math.random() * 255 | 0;
3138
- return v;
3139
- }
3140
- function m(v) {
3141
- return typeof Uint8Array == "function" ? typeof crypto < "u" ? crypto.getRandomValues(new Uint8Array(v)) : typeof msCrypto < "u" ? msCrypto.getRandomValues(new Uint8Array(v)) : j(new Uint8Array(v), v) : j(new Array(v), v);
3142
- }
3143
- function _() {
3144
- var v = m(a);
3145
- v[6] = v[6] & 79 | 64, v[8] = v[8] & 191 | 128;
3146
- for (var A = "", E = 0; E < a; ++E) {
3147
- var D = v[E];
3148
- (E === 4 || E === 6 || E === 8) && (A += "-"), D < 16 && (A += "0"), A += D.toString(16).toLowerCase();
3149
- }
3150
- return A;
3151
- }
3152
- }
3153
- function bt(a) {
3154
- return a.__ = void 0, delete a.__, a;
3155
- }
3156
- });
3157
- })(de || (de = {}));
3158
- var wn = Object.defineProperty, An = Object.getOwnPropertyDescriptor, ct = (n, s, t, e) => {
3159
- for (var i = e > 1 ? void 0 : e ? An(s, t) : s, r = n.length - 1, o; r >= 0; r--)
3160
- (o = n[r]) && (i = (e ? o(s, t, i) : o(i)) || i);
3161
- return e && i && wn(s, t, i), i;
3162
- };
3163
- let B = class extends et {
3164
- constructor() {
3165
- super(...arguments), this.users = {}, this._throttledDispatchMouseMove = En(
3166
- this._dispatchMouseMove.bind(this),
3167
- // 15 // 15ms throttle interval = ~66.6 fps
3168
- // 10 // 10ms throttle interval = 100 fps
3169
- 8
3170
- // 8ms throttle interval = 125 fps
3171
- );
3172
- }
3173
- render() {
3174
- var n, s;
3175
- return he`
3176
- <div id="users-container">
3177
- ${Object.values(this.users).map(
3178
- (t) => {
3179
- var e;
3180
- return he`
3181
- <div
3182
- id="user-${t.id}"
3183
- class="user"
3184
- data-isself="${t.id == ((e = this.me) == null ? void 0 : e.id)}"
3185
- style="--color: ${t.color}; --x: ${t.x}vw; --y: ${t.y}vh;"
3186
- >
3187
- <svg
3188
- width="23"
3189
- viewBox="0 0 27 24"
3190
- fill="currentColor"
3191
- aria-hidden="true"
3192
- xmlns="http://www.w3.org/2000/svg"
3193
- class="cursor"
3194
- >
3195
- <path
3196
- 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"
3197
- />
3198
- </svg>
3199
- <span class="name">${t.name}</span>
3200
- <div
3201
- class="halo"
3202
- data-show="${t.is_mouse_down || t.is_escape_key_down}"
3203
- />
3204
- </div>
3205
- `;
3206
- }
3207
- )}
3208
- </div>
3209
-
3210
- <div class="banner" style="--color: ${(n = this.me) == null ? void 0 : n.color}">
3211
- <div class="pills">
3212
- <div class="current_user">
3213
- <span class="colorpoint"></span>
3214
- <p class="name">${(s = this.me) == null ? void 0 : s.name}</p>
3215
- </div>
3216
-
3217
- <div class="other_users">
3218
- <span>${Object.values(this.users).length}</span>
3219
- <svg
3220
- viewBox="0 0 20 20"
3221
- fill="currentColor"
3222
- aria-hidden="true"
3223
- xmlns="http://www.w3.org/2000/svg"
3224
- >
3225
- <path
3226
- fill-rule="evenodd"
3227
- clip-rule="evenodd"
3228
- d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-5.5-2.5a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0zM10 12a5.99 5.99 0 00-4.793 2.39A6.483 6.483 0 0010 16.5a6.483 6.483 0 004.793-2.11A5.99 5.99 0 0010 12z"
3229
- />
3230
- </svg>
3231
- </div>
3232
- </div>
3233
- </div>
3234
- `;
3235
- }
3236
- connectedCallback() {
3237
- super.connectedCallback();
3238
- const n = new fn({
3239
- url: this.url,
3240
- topic: `liveroom-livestate:${this.room_id}`,
3241
- params: {
3242
- room_id: this.room_id,
3243
- current_url: window.origin,
3244
- inner_width: window.innerWidth,
3245
- inner_height: window.innerHeight
3246
- }
3247
- });
3248
- vn(n, this, {
3249
- properties: ["room_id", "me", "users"],
3250
- events: {
3251
- send: [
3252
- "mouse_move",
3253
- "mouse_down",
3254
- "mouse_up",
3255
- "key_down",
3256
- "key_up",
3257
- "window_resize"
3258
- ],
3259
- receive: []
3260
- }
3261
- }), this.liveState = n, window.addEventListener("mousemove", this._throttledDispatchMouseMove), window.addEventListener("mousedown", this._dispatchMouseDown.bind(this)), window.addEventListener("mouseup", this._dispatchMouseUp.bind(this)), window.addEventListener("keydown", this._dispatchKeyDown.bind(this)), window.addEventListener("keyup", this._dispatchKeyUp.bind(this)), window.addEventListener("resize", this._dispatchWindowResize.bind(this));
3262
- }
3263
- disconnectedCallback() {
3264
- window.removeEventListener("resize", this._dispatchWindowResize.bind(this)), window.removeEventListener("keyup", this._dispatchKeyUp.bind(this)), window.removeEventListener("keydown", this._dispatchKeyDown.bind(this)), window.removeEventListener("mouseup", this._dispatchMouseUp.bind(this)), window.removeEventListener("mousedown", this._dispatchMouseDown.bind(this)), window.removeEventListener("mousemove", this._throttledDispatchMouseMove), this.liveState && this.liveState.disconnect(), super.disconnectedCallback();
3265
- }
3266
- _dispatchMouseMove(n) {
3267
- this.me && this.dispatchEvent(
3268
- new CustomEvent("mouse_move", {
3269
- detail: {
3270
- user_id: this.me.id,
3271
- x: Number(n.pageX / window.innerWidth * 100).toFixed(2),
3272
- // in %
3273
- y: Number(n.pageY / window.innerHeight * 100).toFixed(2)
3274
- // in %
3275
- }
3276
- })
3277
- );
3278
- }
3279
- _dispatchMouseDown(n) {
3280
- this.me && this.dispatchEvent(
3281
- new CustomEvent("mouse_down", {
3282
- detail: {
3283
- user_id: this.me.id
3284
- }
3285
- })
3286
- );
3287
- }
3288
- _dispatchMouseUp(n) {
3289
- this.me && this.dispatchEvent(
3290
- new CustomEvent("mouse_up", {
3291
- detail: {
3292
- user_id: this.me.id
3293
- }
3294
- })
3295
- );
3296
- }
3297
- _dispatchKeyDown(n) {
3298
- !n.repeat && fe.includes(n.key) && this.me && this.dispatchEvent(
3299
- new CustomEvent("key_down", {
3300
- detail: {
3301
- key: n.key,
3302
- user_id: this.me.id
3303
- }
3304
- })
3305
- );
3306
- }
3307
- _dispatchKeyUp(n) {
3308
- fe.includes(n.key) && this.me && this.dispatchEvent(
3309
- new CustomEvent("key_up", {
3310
- detail: {
3311
- key: n.key,
3312
- user_id: this.me.id
3313
- }
3314
- })
3315
- );
3316
- }
3317
- _dispatchWindowResize(n) {
3318
- this.me && this.dispatchEvent(
3319
- new CustomEvent("window_resize", {
3320
- detail: {
3321
- inner_width: window.innerWidth,
3322
- inner_height: window.innerHeight,
3323
- user_id: this.me.id
3324
- }
3325
- })
3326
- );
3327
- }
3328
- };
3329
- B.styles = Ze`
3330
- .user {
3331
- z-index: 1000;
3332
- position: absolute;
3333
- top: 0;
3334
- left: 0;
3335
- user-select: none;
3336
- transform: translate(var(--x), var(--y));
3337
- }
3338
-
3339
- .user .cursor {
3340
- position: absolute;
3341
- top: 0;
3342
- left: 0;
3343
- color: var(--color);
3344
- transform-origin: top left;
3345
- transform: rotate(6deg);
3346
- }
3347
- .user[data-isself="true"] .cursor {
3348
- display: none;
3349
- }
3350
-
3351
- .user .name {
3352
- position: absolute;
3353
- top: 20px;
3354
- left: 16px;
3355
- padding: 4px 10px;
3356
- font-size: 14px;
3357
- line-height: 20px;
3358
- font-weight: 600;
3359
- color: black;
3360
- background-color: var(--color);
3361
- overflow: hidden;
3362
- text-overflow: ellipsis;
3363
- white-space: nowrap;
3364
- border-radius: 9999px;
3365
- // Tailwind 'shadow-sm'
3366
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
3367
- }
3368
- .user[data-isself="true"] .name {
3369
- display: none;
3370
- }
3371
-
3372
- .user .halo {
3373
- transform: scale(0);
3374
- z-index: -1;
3375
- position: absolute;
3376
- top: -60px;
3377
- left: -60px;
3378
- width: 120px;
3379
- height: 120px;
3380
- border-radius: 9999px;
3381
- background-color: var(--color);
3382
- opacity: 0.25;
3383
- transition: transform 0.15s ease-out;
3384
- // Tailwind 'shadow-sm'
3385
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
3386
- }
3387
- .user .halo[data-show="true"] {
3388
- transform: scale(1);
3389
- }
3390
-
3391
- .banner {
3392
- z-index: 1000;
3393
- position: fixed;
3394
- bottom: 12px;
3395
- inset-inline: 0;
3396
- display: flex;
3397
- justify-content: center;
3398
- justify-items: center;
3399
- }
3400
-
3401
- .banner .pills {
3402
- display: flex;
3403
- justify-content: between;
3404
- align-items: center;
3405
- gap: 36px;
3406
- padding: 3px 8px;
3407
- background-color: white;
3408
- border-radius: 9999px;
3409
- }
3410
-
3411
- .banner .pills .current_user {
3412
- display: flex;
3413
- justify-content: center;
3414
- align-items: center;
3415
- gap: 8px;
3416
- }
3417
- .banner .pills .current_user .colorpoint {
3418
- display: block;
3419
- width: 14px;
3420
- height: 14px;
3421
- border-radius: 100%;
3422
- background-color: var(--color);
3423
- }
3424
- .banner .pills .current_user .name {
3425
- margin: 0;
3426
- font-size: 14px;
3427
- font-weight: bold;
3428
- color: black;
3429
- }
3430
-
3431
- .banner .pills .other_users {
3432
- display: flex;
3433
- justify-content: center;
3434
- align-items: center;
3435
- gap: 4px;
3436
- color: gray;
3437
- }
3438
- .banner .pills .other_users span {
3439
- font-size: 14px;
3440
- font-weight: bold;
3441
- }
3442
- .banner .pills .other_users svg {
3443
- width: 18px;
3444
- opacity: 0.8;
3445
- }
3446
- `;
3447
- ct([
3448
- Dt({ attribute: "url" })
3449
- ], B.prototype, "url", 2);
3450
- ct([
3451
- Dt({ attribute: "room_id" })
3452
- ], B.prototype, "room_id", 2);
3453
- ct([
3454
- we()
3455
- ], B.prototype, "me", 2);
3456
- ct([
3457
- we()
3458
- ], B.prototype, "users", 2);
3459
- B = ct([
3460
- ps("liveroom-client-element")
3461
- ], B);
3462
- const fe = ["Escape"];
3463
- function En(n, s) {
3464
- let t = 0;
3465
- return function(...e) {
3466
- let i = Date.now();
3467
- if (i - t > s)
3468
- return t = i, n.apply(this, e);
3469
- };
3470
- }
3471
- export {
3472
- B as LiveroomClientElement
3473
- };