playhtml 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  var Zs = Object.defineProperty;
2
2
  var Ps = (e, t, n) => t in e ? Zs(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var _ = (e, t, n) => (Ps(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- const v = () => /* @__PURE__ */ new Map(), xe = (e) => {
5
- const t = v();
4
+ const O = () => /* @__PURE__ */ new Map(), xe = (e) => {
5
+ const t = O();
6
6
  return e.forEach((n, s) => {
7
7
  t.set(s, n);
8
8
  }), t;
@@ -147,7 +147,7 @@ let R;
147
147
  const Er = () => {
148
148
  if (R === void 0)
149
149
  if (_t) {
150
- R = v();
150
+ R = O();
151
151
  const e = process.argv;
152
152
  let t = null;
153
153
  for (let n = 0; n < e.length; n++) {
@@ -156,16 +156,16 @@ const Er = () => {
156
156
  }
157
157
  t !== null && R.set(t, "");
158
158
  } else
159
- typeof location == "object" ? (R = v(), (location.search || "?").slice(1).split("&").forEach((e) => {
159
+ typeof location == "object" ? (R = O(), (location.search || "?").slice(1).split("&").forEach((e) => {
160
160
  if (e.length !== 0) {
161
161
  const [t, n] = e.split("=");
162
162
  R.set(`--${gn(t, "-")}`, n), R.set(`-${gn(t, "-")}`, n);
163
163
  }
164
- })) : R = v();
164
+ })) : R = O();
165
165
  return R;
166
166
  }, Me = (e) => Er().has(e), Ue = (e) => pn(_t ? process.env[e.toUpperCase()] : Fn.getItem(e)), Ir = (e) => Me("--" + e) || Ue(e) !== null;
167
167
  Ir("production");
168
- const wn = _t && Cr(process.env.FORCE_COLOR, ["true", "1", "2"]), Ar = !Me("no-colors") && (!_t || process.stdout.isTTY || wn) && (!_t || Me("color") || wn || Ue("COLORTERM") !== null || (Ue("TERM") || "").includes("color")), K = Math.floor, Wt = Math.abs, je = (e, t) => e < t ? e : t, lt = (e, t) => e > t ? e : t, Lr = Math.pow, Kn = (e) => e !== 0 ? e < 0 : 1 / e < 0, mn = 1, yn = 2, me = 4, ye = 8, Ot = 32, $ = 64, U = 128, le = 31, Te = 63, tt = 127, xr = 2147483647, jn = Number.MAX_SAFE_INTEGER, Mr = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && K(e) === e);
168
+ const wn = _t && Cr(process.env.FORCE_COLOR, ["true", "1", "2"]), Ar = !Me("no-colors") && (!_t || process.stdout.isTTY || wn) && (!_t || Me("color") || wn || Ue("COLORTERM") !== null || (Ue("TERM") || "").includes("color")), K = Math.floor, Wt = Math.abs, je = (e, t) => e < t ? e : t, lt = (e, t) => e > t ? e : t, Lr = Math.pow, Kn = (e) => e !== 0 ? e < 0 : 1 / e < 0, mn = 1, yn = 2, me = 4, ye = 8, vt = 32, $ = 64, U = 128, le = 31, Te = 63, tt = 127, xr = 2147483647, jn = Number.MAX_SAFE_INTEGER, Mr = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && K(e) === e);
169
169
  class Ht {
170
170
  constructor() {
171
171
  this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
@@ -190,7 +190,7 @@ const M = () => new Ht(), Je = (e) => {
190
190
  }, I = (e, t) => {
191
191
  const n = e.cbuf.length;
192
192
  e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
193
- }, Oe = I, p = (e, t) => {
193
+ }, ve = I, p = (e, t) => {
194
194
  for (; t > tt; )
195
195
  I(e, U | tt & t), t = K(t / 128);
196
196
  I(e, tt & t);
@@ -198,15 +198,15 @@ const M = () => new Ht(), Je = (e) => {
198
198
  const n = Kn(t);
199
199
  for (n && (t = -t), I(e, (t > Te ? U : 0) | (n ? $ : 0) | Te & t), t = K(t / 64); t > 0; )
200
200
  I(e, (t > tt ? U : 0) | tt & t), t = K(t / 128);
201
- }, ve = new Uint8Array(3e4), Tr = ve.length / 3, Or = (e, t) => {
201
+ }, Oe = new Uint8Array(3e4), Tr = Oe.length / 3, vr = (e, t) => {
202
202
  if (t.length < Tr) {
203
- const n = Tt.encodeInto(t, ve).written || 0;
203
+ const n = Tt.encodeInto(t, Oe).written || 0;
204
204
  p(e, n);
205
205
  for (let s = 0; s < n; s++)
206
- I(e, ve[s]);
206
+ I(e, Oe[s]);
207
207
  } else
208
208
  D(e, ur(t));
209
- }, vr = (e, t) => {
209
+ }, Or = (e, t) => {
210
210
  const n = unescape(encodeURIComponent(t)), s = n.length;
211
211
  p(e, s);
212
212
  for (let r = 0; r < s; r++)
@@ -216,7 +216,7 @@ const M = () => new Ht(), Je = (e) => {
216
216
  n.codePointAt(r)
217
217
  );
218
218
  }, et = Tt && /** @type {any} */
219
- Tt.encodeInto ? Or : vr, ae = (e, t) => {
219
+ Tt.encodeInto ? vr : Or, ae = (e, t) => {
220
220
  const n = e.cbuf.length, s = e.cpos, r = je(n - s, t.length), i = t.length - r;
221
221
  e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(lt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
222
222
  }, D = (e, t) => {
@@ -228,7 +228,7 @@ Tt.encodeInto ? Or : vr, ae = (e, t) => {
228
228
  }, Rr = (e, t) => Ye(e, 4).setFloat32(0, t, !1), Nr = (e, t) => Ye(e, 8).setFloat64(0, t, !1), Br = (e, t) => (
229
229
  /** @type {any} */
230
230
  Ye(e, 8).setBigInt64(0, t, !1)
231
- ), _n = new DataView(new ArrayBuffer(4)), Vr = (e) => (_n.setFloat32(0, e), _n.getFloat32(0) === e), vt = (e, t) => {
231
+ ), _n = new DataView(new ArrayBuffer(4)), Vr = (e) => (_n.setFloat32(0, e), _n.getFloat32(0) === e), Ot = (e, t) => {
232
232
  switch (typeof t) {
233
233
  case "string":
234
234
  I(e, 119), et(e, t);
@@ -245,7 +245,7 @@ Tt.encodeInto ? Or : vr, ae = (e, t) => {
245
245
  else if (sr(t)) {
246
246
  I(e, 117), p(e, t.length);
247
247
  for (let n = 0; n < t.length; n++)
248
- vt(e, t[n]);
248
+ Ot(e, t[n]);
249
249
  } else if (t instanceof Uint8Array)
250
250
  I(e, 116), D(e, t);
251
251
  else {
@@ -254,7 +254,7 @@ Tt.encodeInto ? Or : vr, ae = (e, t) => {
254
254
  p(e, n.length);
255
255
  for (let s = 0; s < n.length; s++) {
256
256
  const r = n[s];
257
- et(e, r), vt(e, t[r]);
257
+ et(e, r), Ot(e, t[r]);
258
258
  }
259
259
  }
260
260
  break;
@@ -549,7 +549,7 @@ const ri = typeof BroadcastChannel > "u" ? si : BroadcastChannel, qe = (e) => j(
549
549
  }, st = Date.now;
550
550
  class ue {
551
551
  constructor() {
552
- this._observers = v();
552
+ this._observers = O();
553
553
  }
554
554
  /**
555
555
  * @param {N} name
@@ -586,10 +586,10 @@ class ue {
586
586
  * @param {Array<any>} args The arguments that are applied to the event listener.
587
587
  */
588
588
  emit(t, n) {
589
- return q((this._observers.get(t) || v()).values()).forEach((s) => s(...n));
589
+ return q((this._observers.get(t) || O()).values()).forEach((s) => s(...n));
590
590
  }
591
591
  destroy() {
592
- this._observers = v();
592
+ this._observers = O();
593
593
  }
594
594
  }
595
595
  const ci = crypto.getRandomValues.bind(crypto), Gn = () => ci(new Uint32Array(1))[0], li = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, ai = () => li.replace(
@@ -632,7 +632,7 @@ const ui = (e) => tr(e, (t, n) => `${n}:${t};`).join(""), J = Symbol, Wn = J(),
632
632
  // not well supported in chrome when debugging node with inspector - TODO: deprecate
633
633
  [wi]: H("color", "black")
634
634
  }, _i = (e) => {
635
- const t = [], n = [], s = v();
635
+ const t = [], n = [], s = O();
636
636
  let r = [], i = 0;
637
637
  for (; i < e.length; i++) {
638
638
  const o = e[i], c = yi[o];
@@ -1267,7 +1267,7 @@ class Kt extends is {
1267
1267
  * @param {number} info An unsigned 8-bit integer
1268
1268
  */
1269
1269
  writeInfo(t) {
1270
- Oe(this.restEncoder, t);
1270
+ ve(this.restEncoder, t);
1271
1271
  }
1272
1272
  /**
1273
1273
  * @param {string} s
@@ -1299,7 +1299,7 @@ class Kt extends is {
1299
1299
  * @param {any} any
1300
1300
  */
1301
1301
  writeAny(t) {
1302
- vt(this.restEncoder, t);
1302
+ Ot(this.restEncoder, t);
1303
1303
  }
1304
1304
  /**
1305
1305
  * @param {Uint8Array} buf
@@ -1346,7 +1346,7 @@ class os {
1346
1346
  }
1347
1347
  class rt extends os {
1348
1348
  constructor() {
1349
- super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new _e(), this.clientEncoder = new qt(), this.leftClockEncoder = new _e(), this.rightClockEncoder = new _e(), this.infoEncoder = new bn(Oe), this.stringEncoder = new Fr(), this.parentInfoEncoder = new bn(Oe), this.typeRefEncoder = new qt(), this.lenEncoder = new qt();
1349
+ super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new _e(), this.clientEncoder = new qt(), this.leftClockEncoder = new _e(), this.rightClockEncoder = new _e(), this.infoEncoder = new bn(ve), this.stringEncoder = new Fr(), this.parentInfoEncoder = new bn(ve), this.typeRefEncoder = new qt(), this.lenEncoder = new qt();
1350
1350
  }
1351
1351
  toUint8Array() {
1352
1352
  const t = M();
@@ -1406,7 +1406,7 @@ class rt extends os {
1406
1406
  * @param {any} any
1407
1407
  */
1408
1408
  writeAny(t) {
1409
- vt(this.restEncoder, t);
1409
+ Ot(this.restEncoder, t);
1410
1410
  }
1411
1411
  /**
1412
1412
  * @param {Uint8Array} buf
@@ -1422,7 +1422,7 @@ class rt extends os {
1422
1422
  * @param {any} embed
1423
1423
  */
1424
1424
  writeJSON(t) {
1425
- vt(this.restEncoder, t);
1425
+ Ot(this.restEncoder, t);
1426
1426
  }
1427
1427
  /**
1428
1428
  * Property keys are often reused. For example, in y-prosemirror the key `bold` might
@@ -1461,7 +1461,7 @@ const xi = (e, t, n, s) => {
1461
1461
  );
1462
1462
  });
1463
1463
  }, Mi = (e, t) => {
1464
- const n = v(), s = m(e.restDecoder);
1464
+ const n = O(), s = m(e.restDecoder);
1465
1465
  for (let r = 0; r < s; r++) {
1466
1466
  const i = m(e.restDecoder), o = new Array(i), c = e.readClient();
1467
1467
  let l = m(e.restDecoder);
@@ -1476,7 +1476,7 @@ const xi = (e, t, n, s) => {
1476
1476
  }
1477
1477
  case 10: {
1478
1478
  const u = m(e.restDecoder);
1479
- o[a] = new O(y(c, l), u), l += u;
1479
+ o[a] = new v(y(c, l), u), l += u;
1480
1480
  break;
1481
1481
  }
1482
1482
  default: {
@@ -1492,9 +1492,9 @@ const xi = (e, t, n, s) => {
1492
1492
  // right origin
1493
1493
  u ? e.readParentInfo() ? t.get(e.readString()) : e.readLeftID() : null,
1494
1494
  // parent
1495
- u && (h & Ot) === Ot ? e.readString() : null,
1495
+ u && (h & vt) === vt ? e.readString() : null,
1496
1496
  // parentSub
1497
- Os(e, h)
1497
+ vs(e, h)
1498
1498
  // item content
1499
1499
  );
1500
1500
  o[a] = d, l += d.length;
@@ -1545,7 +1545,7 @@ const xi = (e, t, n, s) => {
1545
1545
  s.length = 0;
1546
1546
  };
1547
1547
  for (; ; ) {
1548
- if (h.constructor !== O) {
1548
+ if (h.constructor !== v) {
1549
1549
  const g = j(u, h.id.client, () => A(t, h.id.client)) - h.id.clock;
1550
1550
  if (g < 0)
1551
1551
  s.push(h), a(h.id.client, h.id.clock - 1), d();
@@ -1589,7 +1589,7 @@ const xi = (e, t, n, s) => {
1589
1589
  return tn(f, c, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
1590
1590
  }
1591
1591
  return null;
1592
- }, Ti = (e, t) => tn(e, t.doc.store, t.beforeState), Oi = (e, t, n, s = new St(e)) => b(t, (r) => {
1592
+ }, Ti = (e, t) => tn(e, t.doc.store, t.beforeState), vi = (e, t, n, s = new St(e)) => b(t, (r) => {
1593
1593
  r.local = !1;
1594
1594
  let i = !1;
1595
1595
  const o = r.doc, c = o.store, l = Mi(s, o), a = Ui(r, c, l), h = c.pendingStructs;
@@ -1625,12 +1625,12 @@ const xi = (e, t, n, s) => {
1625
1625
  }
1626
1626
  }, n, !1), cs = (e, t, n, s = St) => {
1627
1627
  const r = Z(t);
1628
- Oi(r, e, n, new s(r));
1629
- }, ls = (e, t, n) => cs(e, t, n, rs), vi = (e, t, n = /* @__PURE__ */ new Map()) => {
1628
+ vi(r, e, n, new s(r));
1629
+ }, ls = (e, t, n) => cs(e, t, n, rs), Oi = (e, t, n = /* @__PURE__ */ new Map()) => {
1630
1630
  tn(e, t.store, n), Ct(e, Ai(t.store));
1631
1631
  }, Ri = (e, t = new Uint8Array([0]), n = new rt()) => {
1632
1632
  const s = as(t);
1633
- vi(n, e, s);
1633
+ Oi(n, e, s);
1634
1634
  const r = [n.toUint8Array()];
1635
1635
  if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(qi(e.store.pendingStructs.update, t)), r.length > 1) {
1636
1636
  if (n.constructor === Kt)
@@ -1878,7 +1878,7 @@ function* zi(e) {
1878
1878
  const c = e.readInfo();
1879
1879
  if (c === 10) {
1880
1880
  const l = m(e.restDecoder);
1881
- yield new O(y(r, i), l), i += l;
1881
+ yield new v(y(r, i), l), i += l;
1882
1882
  } else if (le & c) {
1883
1883
  const l = (c & ($ | U)) === 0, a = new C(
1884
1884
  y(r, i),
@@ -1893,9 +1893,9 @@ function* zi(e) {
1893
1893
  // @ts-ignore Force writing a string here.
1894
1894
  l ? e.readParentInfo() ? e.readString() : e.readLeftID() : null,
1895
1895
  // parent
1896
- l && (c & Ot) === Ot ? e.readString() : null,
1896
+ l && (c & vt) === vt ? e.readString() : null,
1897
1897
  // parentSub
1898
- Os(e, c)
1898
+ vs(e, c)
1899
1899
  // item content
1900
1900
  );
1901
1901
  yield a, i += a.length;
@@ -1920,7 +1920,7 @@ class nn {
1920
1920
  next() {
1921
1921
  do
1922
1922
  this.curr = this.gen.next().value || null;
1923
- while (this.filterSkips && this.curr !== null && this.curr.constructor === O);
1923
+ while (this.filterSkips && this.curr !== null && this.curr.constructor === v);
1924
1924
  return this.curr;
1925
1925
  }
1926
1926
  }
@@ -1936,9 +1936,9 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
1936
1936
  if (e.constructor === T) {
1937
1937
  const { client: n, clock: s } = e.id;
1938
1938
  return new T(y(n, s + t), e.length - t);
1939
- } else if (e.constructor === O) {
1939
+ } else if (e.constructor === v) {
1940
1940
  const { client: n, clock: s } = e.id;
1941
- return new O(y(n, s + t), e.length - t);
1941
+ return new v(y(n, s + t), e.length - t);
1942
1942
  } else {
1943
1943
  const n = (
1944
1944
  /** @type {Item} */
@@ -1966,7 +1966,7 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
1966
1966
  (d, f) => {
1967
1967
  if (d.curr.id.client === f.curr.id.client) {
1968
1968
  const g = d.curr.id.clock - f.curr.id.clock;
1969
- return g === 0 ? d.curr.constructor === f.curr.constructor ? 0 : d.curr.constructor === O ? 1 : -1 : g;
1969
+ return g === 0 ? d.curr.constructor === f.curr.constructor ? 0 : d.curr.constructor === v ? 1 : -1 : g;
1970
1970
  } else
1971
1971
  return f.curr.id.client - d.curr.id.client;
1972
1972
  }
@@ -1989,16 +1989,16 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
1989
1989
  if (u !== i.struct.id.client)
1990
1990
  z(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next();
1991
1991
  else if (i.struct.id.clock + i.struct.length < d.id.clock)
1992
- if (i.struct.constructor === O)
1992
+ if (i.struct.constructor === v)
1993
1993
  i.struct.length = d.id.clock + d.length - i.struct.id.clock;
1994
1994
  else {
1995
1995
  z(c, i.struct, i.offset);
1996
1996
  const g = d.id.clock - i.struct.id.clock - i.struct.length;
1997
- i = { struct: new O(y(u, i.struct.id.clock + i.struct.length), g), offset: 0 };
1997
+ i = { struct: new v(y(u, i.struct.id.clock + i.struct.length), g), offset: 0 };
1998
1998
  }
1999
1999
  else {
2000
2000
  const g = i.struct.id.clock + i.struct.length - d.id.clock;
2001
- g > 0 && (i.struct.constructor === O ? i.struct.length -= g : d = Wi(d, g)), i.struct.mergeWith(
2001
+ g > 0 && (i.struct.constructor === v ? i.struct.length -= g : d = Wi(d, g)), i.struct.mergeWith(
2002
2002
  /** @type {any} */
2003
2003
  d
2004
2004
  ) || (z(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next());
@@ -2008,7 +2008,7 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
2008
2008
  /** @type {Item | GC} */
2009
2009
  h.curr
2010
2010
  ), offset: 0 }, h.next();
2011
- for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === i.struct.id.clock + i.struct.length && d.constructor !== O; d = h.next())
2011
+ for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === i.struct.id.clock + i.struct.length && d.constructor !== v; d = h.next())
2012
2012
  z(c, i.struct, i.offset), i = { struct: d, offset: 0 };
2013
2013
  }
2014
2014
  i !== null && (z(c, i.struct, i.offset), i = null), rn(c);
@@ -2018,7 +2018,7 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
2018
2018
  const r = as(t), i = new s(), o = new sn(i), c = new n(Z(e)), l = new nn(c, !1);
2019
2019
  for (; l.curr; ) {
2020
2020
  const h = l.curr, u = h.id.client, d = r.get(u) || 0;
2021
- if (l.curr.constructor === O) {
2021
+ if (l.curr.constructor === v) {
2022
2022
  l.next();
2023
2023
  continue;
2024
2024
  }
@@ -3141,7 +3141,7 @@ const Un = (e, t, n) => {
3141
3141
  Ls(e, t, n, c);
3142
3142
  }, Us = (e, t, n, s, r) => {
3143
3143
  let i = t;
3144
- const o = v();
3144
+ const o = O();
3145
3145
  for (; i && (!i.countable || i.deleted); ) {
3146
3146
  if (!i.deleted && i.content.constructor === E) {
3147
3147
  const a = (
@@ -3198,7 +3198,7 @@ const Un = (e, t, n) => {
3198
3198
  let s = (
3199
3199
  /** @type {Item} */
3200
3200
  e._start
3201
- ), r = e._start, i = v();
3201
+ ), r = e._start, i = O();
3202
3202
  const o = xe(i);
3203
3203
  for (; r; ) {
3204
3204
  if (r.deleted === !1)
@@ -3254,7 +3254,7 @@ const Un = (e, t, n) => {
3254
3254
  for (const r of t)
3255
3255
  ho(r);
3256
3256
  });
3257
- }, On = (e, t, n) => {
3257
+ }, vn = (e, t, n) => {
3258
3258
  const s = n, r = xe(t.currentAttributes), i = t.right;
3259
3259
  for (; n > 0 && t.right !== null; ) {
3260
3260
  if (t.right.deleted === !1)
@@ -3486,7 +3486,7 @@ class Dt extends L {
3486
3486
  ` ? o.insert.slice(0, -1) : o.insert;
3487
3487
  (typeof c != "string" || c.length > 0) && De(s, this, r, c, o.attributes || {});
3488
3488
  } else
3489
- o.retain !== void 0 ? Tn(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && On(s, r, o.delete);
3489
+ o.retain !== void 0 ? Tn(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && vn(s, r, o.delete);
3490
3490
  }
3491
3491
  }) : this._pending.push(() => this.applyDelta(t));
3492
3492
  }
@@ -3612,7 +3612,7 @@ class Dt extends L {
3612
3612
  return;
3613
3613
  const s = this.doc;
3614
3614
  s !== null ? b(s, (r) => {
3615
- On(r, Gt(r, this, t), n);
3615
+ vn(r, Gt(r, this, t), n);
3616
3616
  }) : this._pending.push(() => this.delete(t, n));
3617
3617
  }
3618
3618
  /**
@@ -3996,7 +3996,7 @@ class ot extends L {
3996
3996
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
3997
3997
  */
3998
3998
  _write(t) {
3999
- t.writeTypeRef(vo);
3999
+ t.writeTypeRef(Oo);
4000
4000
  }
4001
4001
  }
4002
4002
  const po = (e) => new ot();
@@ -4186,7 +4186,7 @@ class Vt extends ot {
4186
4186
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
4187
4187
  */
4188
4188
  _write(t) {
4189
- t.writeTypeRef(Oo), t.writeKey(this.nodeName);
4189
+ t.writeTypeRef(vo), t.writeKey(this.nodeName);
4190
4190
  }
4191
4191
  }
4192
4192
  const wo = (e) => new Vt(e.readKey());
@@ -5082,7 +5082,7 @@ const Lo = (e) => new F(e.readString()), xo = [
5082
5082
  po,
5083
5083
  yo,
5084
5084
  _o
5085
- ], Mo = 0, Uo = 1, To = 2, Oo = 3, vo = 4, Ro = 5, No = 6;
5085
+ ], Mo = 0, Uo = 1, To = 2, vo = 3, Oo = 4, Ro = 5, No = 6;
5086
5086
  class X {
5087
5087
  /**
5088
5088
  * @param {AbstractType<any>} type
@@ -5395,7 +5395,7 @@ class C extends an {
5395
5395
  write(t, n) {
5396
5396
  const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & le | (s === null ? 0 : U) | // origin is defined
5397
5397
  (r === null ? 0 : $) | // right origin is defined
5398
- (i === null ? 0 : Ot);
5398
+ (i === null ? 0 : vt);
5399
5399
  if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
5400
5400
  const c = (
5401
5401
  /** @type {AbstractType<any>} */
@@ -5415,7 +5415,7 @@ class C extends an {
5415
5415
  this.content.write(t, n);
5416
5416
  }
5417
5417
  }
5418
- const Os = (e, t) => Vo[t & le](e), Vo = [
5418
+ const vs = (e, t) => Vo[t & le](e), Vo = [
5419
5419
  () => {
5420
5420
  B();
5421
5421
  },
@@ -5443,7 +5443,7 @@ const Os = (e, t) => Vo[t & le](e), Vo = [
5443
5443
  }
5444
5444
  // 10 - Skip is not ItemContent
5445
5445
  ], Fo = 10;
5446
- class O extends an {
5446
+ class v extends an {
5447
5447
  get deleted() {
5448
5448
  return !0;
5449
5449
  }
@@ -5479,12 +5479,12 @@ class O extends an {
5479
5479
  return null;
5480
5480
  }
5481
5481
  }
5482
- const vs = (
5482
+ const Os = (
5483
5483
  /** @type {any} */
5484
5484
  typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
5485
5485
  ), Rs = "__ $YJS$ __";
5486
- vs[Rs] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5487
- vs[Rs] = !0;
5486
+ Os[Rs] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5487
+ Os[Rs] = !0;
5488
5488
  const Ns = 0, hn = 1, Bs = 2, Ve = (e, t) => {
5489
5489
  p(e, Ns);
5490
5490
  const n = Fi(t);
@@ -5668,7 +5668,7 @@ Xt[Wo] = (e, t, n, s, r) => {
5668
5668
  (i, o) => Qo(n, o)
5669
5669
  );
5670
5670
  };
5671
- var vn = 3e4;
5671
+ var On = 3e4;
5672
5672
  function Qo(e, t) {
5673
5673
  console.warn(`Permission denied to access ${e.url}.
5674
5674
  ${t}`);
@@ -5808,8 +5808,8 @@ var Zo = class extends ue {
5808
5808
  );
5809
5809
  }, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
5810
5810
  setInterval(() => {
5811
- this.wsconnected && vn < st() - this.wsLastMessageReceived && (qo(this.ws !== null, "ws must not be null"), this.ws.close());
5812
- }, vn / 10), r && this.connect();
5811
+ this.wsconnected && On < st() - this.wsLastMessageReceived && (qo(this.ws !== null, "ws must not be null"), this.ws.close());
5812
+ }, On / 10), r && this.connect();
5813
5813
  }
5814
5814
  /**
5815
5815
  * @type {boolean}
@@ -6217,7 +6217,7 @@ class yc {
6217
6217
  this.data = this.defaultData;
6218
6218
  }
6219
6219
  }
6220
- const _c = process.env.NODE_ENV === "development" ? "localhost:1999" : "playhtml.spencerc99.partykit.dev", dn = new Et(), qs = window.location.href, Qs = new Po(_c, qs, dn, {
6220
+ const _c = process !== void 0 && process.env.NODE_ENV === "development" ? "localhost:1999" : "playhtml.spencerc99.partykit.dev", dn = new Et(), qs = window.location.href, Qs = new Po(_c, qs, dn, {
6221
6221
  connect: !1
6222
6222
  });
6223
6223
  new gc(qs, dn);
@@ -3,4 +3,4 @@
3
3
  `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&tn(s,this,r,c,o.attributes||{})}else o.retain!==void 0?Es(s,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&As(s,r,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,s){const r=[],i=new Map,o=this.doc;let c="",l=this._start;function a(){if(c.length>0){const u={};let d=!1;i.forEach((g,w)=>{d=!0,u[w]=g});const f={insert:c};d&&(f.attributes=u),r.push(f),c=""}}const h=()=>{for(;l!==null;){if(Vt(l,t)||n!==void 0&&Vt(l,n))switch(l.content.constructor){case H:{const u=i.get("ychange");t!==void 0&&!Vt(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(a(),i.set("ychange",s?s("removed",l.id):{type:"removed"})):n!==void 0&&!Vt(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(a(),i.set("ychange",s?s("added",l.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),c+=l.content.str;break}case z:case ht:{a();const u={insert:l.content.getContent()[0]};if(i.size>0){const d={};u.attributes=d,i.forEach((f,g)=>{d[g]=f})}r.push(u);break}case E:Vt(l,t)&&(a(),Dt(i,l.content));break}l=l.right}a()};return t||n?b(o,u=>{t&&Je(u,t),n&&Je(u,n),h()},"cleanup"):h(),r}insert(t,n,s){if(n.length<=0)return;const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);s||(s={},o.currentAttributes.forEach((c,l)=>{s[l]=c})),tn(i,this,o,n,s)}):this._pending.push(()=>this.insert(t,n,s))}insertEmbed(t,n,s={}){const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);tn(i,this,o,n,s)}):this._pending.push(()=>this.insertEmbed(t,n,s))}delete(t,n){if(n===0)return;const s=this.doc;s!==null?b(s,r=>{As(r,fe(r,this,t),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,s){if(n===0)return;const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);o.right!==null&&Es(i,this,o,n,s)}):this._pending.push(()=>this.format(t,n,s))}removeAttribute(t){this.doc!==null?b(this.doc,n=>{ue(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?b(this.doc,s=>{Qe(s,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Ze(this,t)}getAttributes(){return _s(this)}_write(t){t.writeTypeRef(Do)}}const ro=e=>new Ct;class en{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===$t||n.constructor===at)&&n._start!==null)t=n._start;else for(;t!==null;)if(t.right!==null){t=t.right;break}else t.parent===this._root?t=null:t=t.parent._item;while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class at extends x{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new at}clone(){const t=new at;return t.insert(0,this.toArray().map(n=>n instanceof x?n.clone():n)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new en(this,t)}querySelector(t){t=t.toUpperCase();const s=new en(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),W(new en(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){ae(this,t,new co(this,n,t))}toString(){return gs(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},s){const r=t.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),Ht(this,i=>{r.insertBefore(i.toDOM(t,n,s),null)}),r}insert(t,n){this.doc!==null?b(this.doc,s=>{ms(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)b(this.doc,s=>{const r=t&&t instanceof x?t._item:t;he(s,this,r,n)});else{const s=this._prelimContent,r=t===null?0:s.findIndex(i=>i===t)+1;if(r===0&&t!==null)throw it("Reference item not found");s.splice(r,0,...n)}}delete(t,n=1){this.doc!==null?b(this.doc,s=>{ys(s,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return fs(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ps(this,t)}slice(t=0,n=this.length){return ds(this,t,n)}forEach(t){Ht(this,t)}_write(t){t.writeTypeRef(Eo)}}const io=e=>new at;class $t extends at{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new $t(this.nodeName)}clone(){const t=new $t(this.nodeName),n=this.getAttributes();return wr(n,(s,r)=>{typeof s=="string"&&t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof x?s.clone():s)),t}toString(){const t=this.getAttributes(),n=[],s=[];for(const c in t)s.push(c);s.sort();const r=s.length;for(let c=0;c<r;c++){const l=s[c];n.push(l+'="'+t[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?b(this.doc,n=>{ue(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?b(this.doc,s=>{Qe(s,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Ze(this,t)}hasAttribute(t){return bs(this,t)}getAttributes(){return _s(this)}toDOM(t=document,n={},s){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const c=i[o];typeof c=="string"&&r.setAttribute(o,c)}return Ht(this,o=>{r.appendChild(o.toDOM(t,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(Co),t.writeKey(this.nodeName)}}const oo=e=>new $t(e.readKey());class co extends ce{constructor(t,n,s){super(t,s),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class ge extends lt{constructor(t){super(),this.hookName=t}_copy(){return new ge(this.hookName)}clone(){const t=new ge(this.hookName);return this.forEach((n,s)=>{t.set(s,n)}),t}toDOM(t=document,n={},s){const r=n[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(t){t.writeTypeRef(Io),t.writeKey(this.hookName)}}const lo=e=>new ge(e.readKey());class pe extends Ct{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new pe}clone(){const t=new pe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,s){const r=t.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const n=[];for(const r in t.attributes){const i=[];for(const o in t.attributes[r])i.push({key:o,value:t.attributes[r][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:r,attrs:i})}n.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<n.length;r++){const i=n[r];s+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const c=i.attrs[o];s+=` ${c.key}="${c.value}"`}s+=">"}s+=t.insert;for(let r=n.length-1;r>=0;r--)s+=`</${n[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Ao)}}const ao=e=>new pe;class nn{constructor(t,n){this.id=t,this.length=n}get deleted(){throw B()}mergeWith(t){return!1}write(t,n,s){throw B()}integrate(t,n){throw B()}}const ho=0;class O extends nn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),ss(t.doc.store,this)}write(t,n){t.writeInfo(ho),t.writeLen(this.length-n)}getMissing(t,n){return null}}class jt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new jt(this.content)}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const uo=e=>new jt(e.readBuf());class Kt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Kt(this.len)}splice(t){const n=new Kt(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){ne(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const fo=e=>new Kt(e.readLen()),Ls=(e,t)=>new _t({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Jt{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Jt(Ls(this.doc.guid,this.opts))}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const go=e=>new Jt(Ls(e.readString(),e.readAny()));class ht{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ht(this.embed)}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const po=e=>new ht(e.readJSON());class E{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new E(this.key,this.value)}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){const s=n.parent;s._searchMarker=null,s._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const wo=e=>new E(e.readKey(),e.readJSON());class we{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new we(this.arr)}splice(t){const n=new we(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const mo=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++){const r=e.readString();r==="undefined"?n.push(void 0):n.push(JSON.parse(r))}return new we(n)};class ut{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ut(this.arr)}splice(t){const n=new ut(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeAny(i)}}getRef(){return 8}}const yo=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++)n.push(e.readAny());return new ut(n)};class H{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(t){const n=new H(this.str.slice(t));this.str=this.str.slice(0,t);const s=this.str.charCodeAt(t-1);return s>=55296&&s<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const _o=e=>new H(e.readString()),bo=[Qi,Pi,ro,oo,io,lo,ao],ko=0,So=1,Do=2,Co=3,Eo=4,Io=5,Ao=6;class z{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new z(this.type._copy())}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(s=>{s.deleted?t._mergeStructs.push(s):s.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(t,!0),s=s.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const Lo=e=>new z(bo[e.readTypeRef()](e)),me=(e,t,n)=>{const{client:s,clock:r}=t.id,i=new I(y(s,r+n),t,y(s,r+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=y(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i};class I extends nn{constructor(t,n,s,r,i,o,c,l){super(t,l.getLength()),this.origin=s,this.left=n,this.right=r,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?Dn:0}set marker(t){(this.info&Ee)>0!==t&&(this.info^=Ee)}get marker(){return(this.info&Ee)>0}get keep(){return(this.info&Sn)>0}set keep(t){this.keep!==t&&(this.info^=Sn)}get countable(){return(this.info&Dn)>0}get deleted(){return(this.info&Ce)>0}set deleted(t){this.deleted!==t&&(this.info^=Ce)}markDeleted(){this.info|=Ce}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=L(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=L(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===kt&&this.id.client!==this.parent.client&&this.parent.clock>=L(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=rs(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Z(t,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===O||this.right&&this.right.constructor===O)&&(this.parent=null),!this.parent)this.left&&this.left.constructor===I&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===I&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===kt){const s=Xe(n,this.parent);s.constructor===O?this.parent=null:this.parent=s.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=rs(t,t.doc.store,y(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),i.add(r),se(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(se(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Xe(t.doc.store,r.origin)))i.has(Xe(t.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start,this.parent._start=this;this.right=s}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ss(t.doc.store,this),this.content.integrate(t,this),cs(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new O(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:y(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&se(t.origin,this.lastId)&&this.right===t&&se(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(s=>{s.p===t&&(s.p=this,!this.deleted&&this.countable&&(s.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),cs(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw V();this.content.gc(t),n?Oi(t,this,new O(this.id,this.length)):this.content=new Kt(this.length)}write(t,n){const s=n>0?y(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&qt|(s===null?0:v)|(r===null?0:J)|(i===null?0:Tt);if(t.writeInfo(o),s!==null&&t.writeLeftID(s),r!==null&&t.writeRightID(r),s===null&&r===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const a=vi(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===kt?(t.writeParentInfo(!1),t.writeLeftID(c)):V();i!==null&&t.writeString(i)}this.content.write(t,n)}}const xs=(e,t)=>xo[t&qt](e),xo=[()=>{V()},fo,mo,uo,_o,po,wo,Lo,yo,go,()=>{V()}],Mo=10;class R extends nn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){V()}write(t,n){t.writeInfo(Mo),p(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Us="__ $YJS$ __";Ms[Us]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ms[Us]=!0;const Ts=0,sn=1,vs=2,rn=(e,t)=>{p(e,Ts);const n=Ui(t);C(e,n)},Os=(e,t,n)=>{p(e,sn),C(e,Ke(t,n))},Uo=(e,t,n)=>Os(t,n,U(e)),Rs=(e,t,n)=>{try{Wn(t,U(e),n)}catch(s){console.error("Caught error while handling a Yjs update",s)}},To=(e,t)=>{p(e,vs),C(e,t)},vo=Rs,Oo=(e,t,n,s)=>{const r=m(e);switch(r){case Ts:Uo(e,t,n);break;case sn:Rs(e,n,s);break;case vs:vo(e,n,s);break;default:throw new Error("Unknown message type")}return r},Ro=0,No=(e,t,n)=>{switch(m(e)){case Ro:n(t,Q(e))}},on=3e4;class Bo extends ee{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=ot();this.getLocalState()!==null&&on/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&on<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&cn(this,s,"timeout")},K(on/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const n=this.clientID,s=this.meta.get(n),r=s===void 0?0:s.clock+1,i=this.states.get(n);t===null?this.states.delete(n):this.states.set(n,t),this.meta.set(n,{clock:r,lastUpdated:ot()});const o=[],c=[],l=[],a=[];t===null?a.push(n):i==null?t!=null&&o.push(n):(c.push(n),Ut(i,t)||l.push(n)),(o.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:o,updated:l,removed:a},"local"]),this.emit("update",[{added:o,updated:c,removed:a},"local"])}setLocalStateField(t,n){const s=this.getLocalState();s!==null&&this.setLocalState({...s,[t]:n})}getStates(){return this.states}}const cn=(e,t,n)=>{const s=[];for(let r=0;r<t.length;r++){const i=t[r];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){const o=e.meta.get(i);e.meta.set(i,{clock:o.clock+1,lastUpdated:ot()})}s.push(i)}}s.length>0&&(e.emit("change",[{added:[],updated:[],removed:s},n]),e.emit("update",[{added:[],updated:[],removed:s},n]))},Xt=(e,t,n=e.states)=>{const s=t.length,r=M();p(r,s);for(let i=0;i<s;i++){const o=t[i],c=n.get(o)||null,l=e.meta.get(o).clock;p(r,o),p(r,l),rt(r,JSON.stringify(c))}return D(r)},Vo=(e,t,n)=>{const s=q(t),r=ot(),i=[],o=[],c=[],l=[],a=m(s);for(let h=0;h<a;h++){const u=m(s);let d=m(s);const f=JSON.parse(Q(s)),g=e.meta.get(u),w=e.states.get(u),k=g===void 0?0:g.clock;(k<d||k===d&&f===null&&e.states.has(u))&&(f===null?u===e.clientID&&e.getLocalState()!=null?d++:e.states.delete(u):e.states.set(u,f),e.meta.set(u,{clock:d,lastUpdated:r}),g===void 0&&f!==null?i.push(u):g!==void 0&&f===null?l.push(u):f!==null&&(Ut(f,w)||c.push(u),o.push(u)))}(i.length>0||c.length>0||l.length>0)&&e.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||o.length>0||l.length>0)&&e.emit("update",[{added:i,updated:o,removed:l},n])},Fo=e=>mr(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");var dt=0,Ns=3,Et=1,Ho=2;function $o(e,t){if(!e)throw new Error(t)}var Yt=[];Yt[dt]=(e,t,n,s,r)=>{p(e,dt);const i=Oo(t,e,n.doc,n);s&&i===sn&&!n.synced&&(n.synced=!0)},Yt[Ns]=(e,t,n,s,r)=>{p(e,Et),C(e,Xt(n.awareness,Array.from(n.awareness.getStates().keys())))},Yt[Et]=(e,t,n,s,r)=>{Vo(n.awareness,U(t),n)},Yt[Ho]=(e,t,n,s,r)=>{No(t,n.doc,(i,o)=>jo(n,o))};var Bs=3e4;function jo(e,t){console.warn(`Permission denied to access ${e.url}.
4
4
  ${t}`)}function Vs(e,t,n){const s=q(t),r=M(),i=m(s),o=e.messageHandlers[i];return o?o(r,s,e,n,i):console.error("Unable to compute message"),r}function Fs(e){if(e.shouldConnect&&e.ws===null){const t=new e._WS(e.url);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{if(n.data==="ping"){t.send("pong");return}e.wsLastMessageReceived=ot();const s=Vs(e,new Uint8Array(n.data),!0);Ae(s)>1&&t.send(D(s))},t.onerror=n=>{e.emit("connection-error",[n,e])},t.onclose=n=>{e.emit("connection-close",[n,e]),e.ws=null,e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,cn(e.awareness,Array.from(e.awareness.getStates().keys()).filter(s=>s!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(Fs,De(Ir(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e)},t.onopen=()=>{e.wsLastMessageReceived=ot(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=M();if(p(n,dt),rn(n,e.doc),t.send(D(n)),e.awareness.getLocalState()!==null){const s=M();p(s,Et),C(s,Xt(e.awareness,[e.doc.clientID])),t.send(D(s))}},e.emit("status",[{status:"connecting"}])}}function ln(e,t){const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&wt(e.bcChannel,t,e)}var Ko=class extends ee{constructor(t,n,s,{connect:r=!0,awareness:i=new Bo(s),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:l=-1,maxBackoffTime:a=2500,disableBc:h=!1}={}){super();_(this,"maxBackoffTime");_(this,"bcChannel");_(this,"url");_(this,"roomname");_(this,"doc");_(this,"_WS");_(this,"awareness");_(this,"wsconnected");_(this,"wsconnecting");_(this,"bcconnected");_(this,"disableBc");_(this,"wsUnsuccessfulReconnects");_(this,"messageHandlers");_(this,"_synced");_(this,"ws");_(this,"wsLastMessageReceived");_(this,"shouldConnect");_(this,"_resyncInterval");_(this,"_bcSubscriber");_(this,"_updateHandler");_(this,"_awarenessUpdateHandler");_(this,"_unloadHandler");_(this,"_checkInterval");for(;t[t.length-1]==="/";)t=t.slice(0,t.length-1);const u=Fo(o);this.maxBackoffTime=a,this.bcChannel=t+"/"+n,this.url=t+"/"+n+(u.length===0?"":"?"+u),this.roomname=n,this.doc=s,this._WS=c,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Yt.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=M();p(d,dt),rn(d,s),this.ws.send(D(d))}},l)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Vs(this,new Uint8Array(d),!1);Ae(g)>1&&wt(this.bcChannel,D(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=M();p(g,dt),To(g,d),ln(this,D(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},w)=>{const k=d.concat(f).concat(g),At=M();p(At,Et),C(At,Xt(i,k)),ln(this,D(At))},this._unloadHandler=()=>{cn(this.awareness,[s.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Bs<ot()-this.wsLastMessageReceived&&($o(this.ws!==null,"ws must not be null"),this.ws.close())},Bs/10),r&&this.connect()}get synced(){return this._synced}set synced(t){this._synced!==t&&(this._synced=t,this.emit("synced",[t]),this.emit("sync",[t]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Zr(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const t=M();p(t,dt),rn(t,this.doc),wt(this.bcChannel,D(t),this);const n=M();p(n,dt),Os(n,this.doc),wt(this.bcChannel,D(n),this);const s=M();p(s,Ns),wt(this.bcChannel,D(s),this);const r=M();p(r,Et),C(r,Xt(this.awareness,[this.doc.clientID])),wt(this.bcChannel,D(r),this)}disconnectBc(){const t=M();p(t,Et),C(t,Xt(this.awareness,[this.doc.clientID],new Map)),ln(this,D(t)),this.bcconnected&&(Pr(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Fs(this),this.connectBc())}};function Hs(){if(crypto.randomUUID)return crypto.randomUUID();let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let s=Math.random()*16;return e>0?(s=(e+s)%16|0,e=Math.floor(e/16)):(s=(t+s)%16|0,t=Math.floor(t/16)),(n==="x"?s:s&3|8).toString(16)})}var Jo=class extends Ko{constructor(e,t,n,s={}){const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}/party`;s.params===void 0?s.params={_pk:Hs()}:s.params._pk=Hs(),super(r,t,n,s)}};const ft=e=>mt((t,n)=>{e.onerror=s=>n(new Error(s.target.error)),e.onsuccess=s=>t(s.target.result)}),Xo=(e,t)=>mt((n,s)=>{const r=indexedDB.open(e);r.onupgradeneeded=i=>t(i.target.result),r.onerror=i=>s(it(i.target.error)),r.onsuccess=i=>{const o=i.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),n(o)}}),Yo=e=>ft(indexedDB.deleteDatabase(e)),zo=(e,t)=>t.forEach(n=>e.createObjectStore.apply(e,n)),zt=(e,t,n="readwrite")=>{const s=e.transaction(t,n);return t.map(r=>ec(s,r))},$s=(e,t)=>ft(e.count(t)),Go=(e,t)=>ft(e.get(t)),js=(e,t)=>ft(e.delete(t)),Wo=(e,t,n)=>ft(e.put(t,n)),an=(e,t)=>ft(e.add(t)),qo=(e,t,n)=>ft(e.getAll(t,n)),Qo=(e,t,n)=>{let s=null;return tc(e,t,r=>(s=r,!1),n).then(()=>s)},Zo=(e,t=null)=>Qo(e,t,"prev"),Po=(e,t)=>mt((n,s)=>{e.onerror=s,e.onsuccess=async r=>{const i=r.target.result;if(i===null||await t(i)===!1)return n();i.continue()}}),tc=(e,t,n,s="next")=>Po(e.openKeyCursor(t,s),r=>n(r.key)),ec=(e,t)=>e.objectStore(t),nc=(e,t)=>IDBKeyRange.upperBound(e,t),sc=(e,t)=>IDBKeyRange.lowerBound(e,t),hn="custom",Ks="updates",Js=500,Xs=(e,t=()=>{},n=()=>{})=>{const[s]=zt(e.db,[Ks]);return qo(s,sc(e._dbref,!1)).then(r=>{e._destroyed||(t(s),b(e.doc,()=>{r.forEach(i=>Wn(e.doc,i))},e,!1),n(s))}).then(()=>Zo(s).then(r=>{e._dbref=r+1})).then(()=>$s(s).then(r=>{e._dbsize=r})).then(()=>s)},rc=(e,t=!0)=>Xs(e).then(n=>{(t||e._dbsize>=Js)&&an(n,Ke(e.doc)).then(()=>js(n,nc(e._dbref,!0))).then(()=>$s(n).then(s=>{e._dbsize=s}))});class ic extends ee{constructor(t,n){super(),this.doc=n,this.name=t,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Xo(t,s=>zo(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=mt(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,Xs(this,o=>an(o,Ke(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(s,r)=>{if(this.db&&r!==this){const[i]=zt(this.db,[Ks]);an(i,s),++this._dbsize>=Js&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{rc(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(t=>{t.close()})}clearData(){return this.destroy().then(()=>{Yo(this.name)})}get(t){return this._db.then(n=>{const[s]=zt(n,[hn],"readonly");return Go(s,t)})}set(t,n){return this._db.then(s=>{const[r]=zt(s,[hn]);return Wo(r,n,t)})}del(t){return this._db.then(n=>{const[s]=zt(n,[hn]);return js(s,t)})}}const Dc="";var It=(e=>(e.CanMove="can-move",e.CanSpin="can-spin",e.CanGrow="can-grow",e.CanToggle="can-toggle",e))(It||{});const oc=(e,t=300)=>{let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}},cc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},Ys=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
5
5
  16 0,
6
- auto`,lc=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function un(e,t,n){if(t.isHovering=!0,e.altKey){if(t.scale<=.5){n.style.cursor="not-allowed";return}n.style.cursor=lc}else{if(t.scale>=t.maxScale){n.style.cursor="not-allowed";return}n.style.cursor=Ys}return{...t}}const zs={[It.CanMove]:{defaultData:{x:0,y:0,startMouseX:0,startMouseY:0},updateElement:(e,t)=>{e.style.transform=`translate(${t.x}px, ${t.y}px)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX,startMouseY:e.clientY}),onDrag:(e,t)=>({x:t.x+e.clientX-t.startMouseX,y:t.y+e.clientY-t.startMouseY,startMouseX:e.clientX,startMouseY:e.clientY}),resetShortcut:"shiftKey"},[It.CanSpin]:{defaultData:{rotation:0,startMouseX:0},updateElement:(e,t)=>{e.style.transform=`rotate(${t.rotation}deg)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX}),onDrag:(e,t)=>{let n=Math.abs(e.pageX-t.startMouseX)*2,s=t.rotation;return e.pageX>t.startMouseX?s+=n:e.pageX<t.startMouseX&&(s-=n),{rotation:s,startMouseX:e.pageX}},resetShortcut:"shiftKey"},[It.CanToggle]:{defaultData:!1,updateElement:(e,t)=>{e.classList.toggle("clicked",t)},onClick:(e,t)=>!t,resetShortcut:"shiftKey"},[It.CanGrow]:{defaultData:{scale:1,maxScale:2,isHovering:!1},updateElement:(e,t)=>{e.style.transform=`scale(${t.scale})`},onClick:(e,t,n)=>{if(e.altKey){if(t.scale<=.5)return;t.scale-=.1}else{if(n.style.cursor=Ys,t.scale>=t.maxScale)return;t.scale+=.1}return{...t}},onMouseEnter:un,onKeyDown:un,onKeyUp:un}};class ac{constructor({element:t,onChange:n,defaultData:s,data:r,updateElement:i,onClick:o,onDrag:c,onDragStart:l,onMouseEnter:a,onKeyDown:h,onKeyUp:u,resetShortcut:d,debounceMs:f}){_(this,"defaultData");_(this,"element");_(this,"_data");_(this,"onChange");_(this,"debouncedOnChange");_(this,"resetShortcut");_(this,"updateElement");this.element=t,this.defaultData=s,this.onChange=n,this.resetShortcut=d,this.debouncedOnChange=oc(this.onChange,f),this.updateElement=i;const g=r===void 0?s:r;this._data=g,this.__data=g,o&&t.addEventListener("click",w=>{const k=o(w,this.data,this.element);k!==void 0&&(this.data=k)}),c&&t.addEventListener("mousedown",w=>{if(l){const Lt=l(w,this.data,this.element);Lt!==void 0&&(this.data=Lt)}const k=Lt=>{Lt.preventDefault();const Ps=c(Lt,this.data,this.element);Ps!==void 0&&(this.data=Ps)},At=Lt=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",At)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",At)}),a&&t.addEventListener("mouseenter",w=>{const k=a(w,this.data,this.element);k!==void 0&&(this.data=k)}),h&&t.addEventListener("keydown",w=>{const k=h(w,this.data,this.element);k!==void 0&&(this.data=k)}),u&&t.addEventListener("keyup",w=>{const k=u(w,this.data,this.element);k!==void 0&&(this.data=k)}),d&&(t.title||(t.title=`Hold down the ${cc[d]} key while clicking to reset.`),t.addEventListener("click",w=>{switch(d){case"ctrlKey":if(!w.ctrlKey)return;break;case"altKey":if(!w.altKey)return;break;case"shiftKey":if(!w.shiftKey)return;break;case"metaKey":if(!w.metaKey)return;break;default:return}this.reset(),w.preventDefault(),w.stopPropagation()}))}get data(){return this._data}set __data(t){this._data=t,this.updateElement(this.element,t)}set data(t){this.onChange(t)}setDataDebounced(t){this.debouncedOnChange(t)}reset(){this.data=this.defaultData}}const hc=process.env.NODE_ENV==="development"?"localhost:1999":"playhtml.spencerc99.partykit.dev",dn=new _t,Gs=window.location.href,Ws=new Jo(hc,Gs,dn,{connect:!1});new ic(Gs,dn),Ws.connect();const G=dn.getMap("playhtml-global");function fn(e){return e.id}function uc(e){return document.getElementById(e)}Ws.on("sync",e=>{e||console.error("Issue connecting to yjs..."),Zs()});function qs(e){return e instanceof HTMLElement}function Qs(e,t){const n=zs[t],s=G.get(t),r=fn(e),i={...n,data:s.get(r)||n.defaultData,element:e,onChange:o=>{s.get(r)!==o&&s.set(r,o)}};return new ac(i)}function Zs(){const e=new Map;console.log("EXISTING DATA",G.toJSON());for(const t of Object.values(It)){const n=Array.from(document.querySelectorAll(`[${t}]`)).filter(qs);if(!n.length)continue;const s=zs[t];if(console.log(s),!s)continue;console.log(`initializing ${t}`),G.get(t)||G.set(t,new lt);const r=G.get(t);for(const i of n){const o=Qs(i,t);e.set(fn(i),o),i.classList.add("__playhtml-element"),i.classList.add(`__playhtml-${t}`)}r.observe(i=>{i.changes.keys.forEach((o,c)=>{if(o.action==="add"){const l=uc(c);if(!qs(l)){console.log(`Element ${c} not an HTML element. Ignoring.`);return}const a=Qs(l,t);e.set(fn(l),a)}else if(o.action==="update"){const l=e.get(c);l.__data=r.get(c)}else o.action==="delete"?e.delete(c):console.log(`Unhandled action: ${o.action}`)})})}G.observe(t=>{t.changes.keys.forEach((n,s)=>{n.action==="add"&&G.set(s,G.get(s))})})}T.globalData=G,T.setupElements=Zs,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
6
+ auto`,lc=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function un(e,t,n){if(t.isHovering=!0,e.altKey){if(t.scale<=.5){n.style.cursor="not-allowed";return}n.style.cursor=lc}else{if(t.scale>=t.maxScale){n.style.cursor="not-allowed";return}n.style.cursor=Ys}return{...t}}const zs={[It.CanMove]:{defaultData:{x:0,y:0,startMouseX:0,startMouseY:0},updateElement:(e,t)=>{e.style.transform=`translate(${t.x}px, ${t.y}px)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX,startMouseY:e.clientY}),onDrag:(e,t)=>({x:t.x+e.clientX-t.startMouseX,y:t.y+e.clientY-t.startMouseY,startMouseX:e.clientX,startMouseY:e.clientY}),resetShortcut:"shiftKey"},[It.CanSpin]:{defaultData:{rotation:0,startMouseX:0},updateElement:(e,t)=>{e.style.transform=`rotate(${t.rotation}deg)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX}),onDrag:(e,t)=>{let n=Math.abs(e.pageX-t.startMouseX)*2,s=t.rotation;return e.pageX>t.startMouseX?s+=n:e.pageX<t.startMouseX&&(s-=n),{rotation:s,startMouseX:e.pageX}},resetShortcut:"shiftKey"},[It.CanToggle]:{defaultData:!1,updateElement:(e,t)=>{e.classList.toggle("clicked",t)},onClick:(e,t)=>!t,resetShortcut:"shiftKey"},[It.CanGrow]:{defaultData:{scale:1,maxScale:2,isHovering:!1},updateElement:(e,t)=>{e.style.transform=`scale(${t.scale})`},onClick:(e,t,n)=>{if(e.altKey){if(t.scale<=.5)return;t.scale-=.1}else{if(n.style.cursor=Ys,t.scale>=t.maxScale)return;t.scale+=.1}return{...t}},onMouseEnter:un,onKeyDown:un,onKeyUp:un}};class ac{constructor({element:t,onChange:n,defaultData:s,data:r,updateElement:i,onClick:o,onDrag:c,onDragStart:l,onMouseEnter:a,onKeyDown:h,onKeyUp:u,resetShortcut:d,debounceMs:f}){_(this,"defaultData");_(this,"element");_(this,"_data");_(this,"onChange");_(this,"debouncedOnChange");_(this,"resetShortcut");_(this,"updateElement");this.element=t,this.defaultData=s,this.onChange=n,this.resetShortcut=d,this.debouncedOnChange=oc(this.onChange,f),this.updateElement=i;const g=r===void 0?s:r;this._data=g,this.__data=g,o&&t.addEventListener("click",w=>{const k=o(w,this.data,this.element);k!==void 0&&(this.data=k)}),c&&t.addEventListener("mousedown",w=>{if(l){const Lt=l(w,this.data,this.element);Lt!==void 0&&(this.data=Lt)}const k=Lt=>{Lt.preventDefault();const Ps=c(Lt,this.data,this.element);Ps!==void 0&&(this.data=Ps)},At=Lt=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",At)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",At)}),a&&t.addEventListener("mouseenter",w=>{const k=a(w,this.data,this.element);k!==void 0&&(this.data=k)}),h&&t.addEventListener("keydown",w=>{const k=h(w,this.data,this.element);k!==void 0&&(this.data=k)}),u&&t.addEventListener("keyup",w=>{const k=u(w,this.data,this.element);k!==void 0&&(this.data=k)}),d&&(t.title||(t.title=`Hold down the ${cc[d]} key while clicking to reset.`),t.addEventListener("click",w=>{switch(d){case"ctrlKey":if(!w.ctrlKey)return;break;case"altKey":if(!w.altKey)return;break;case"shiftKey":if(!w.shiftKey)return;break;case"metaKey":if(!w.metaKey)return;break;default:return}this.reset(),w.preventDefault(),w.stopPropagation()}))}get data(){return this._data}set __data(t){this._data=t,this.updateElement(this.element,t)}set data(t){this.onChange(t)}setDataDebounced(t){this.debouncedOnChange(t)}reset(){this.data=this.defaultData}}const hc=process!==void 0&&process.env.NODE_ENV==="development"?"localhost:1999":"playhtml.spencerc99.partykit.dev",dn=new _t,Gs=window.location.href,Ws=new Jo(hc,Gs,dn,{connect:!1});new ic(Gs,dn),Ws.connect();const G=dn.getMap("playhtml-global");function fn(e){return e.id}function uc(e){return document.getElementById(e)}Ws.on("sync",e=>{e||console.error("Issue connecting to yjs..."),Zs()});function qs(e){return e instanceof HTMLElement}function Qs(e,t){const n=zs[t],s=G.get(t),r=fn(e),i={...n,data:s.get(r)||n.defaultData,element:e,onChange:o=>{s.get(r)!==o&&s.set(r,o)}};return new ac(i)}function Zs(){const e=new Map;console.log("EXISTING DATA",G.toJSON());for(const t of Object.values(It)){const n=Array.from(document.querySelectorAll(`[${t}]`)).filter(qs);if(!n.length)continue;const s=zs[t];if(console.log(s),!s)continue;console.log(`initializing ${t}`),G.get(t)||G.set(t,new lt);const r=G.get(t);for(const i of n){const o=Qs(i,t);e.set(fn(i),o),i.classList.add("__playhtml-element"),i.classList.add(`__playhtml-${t}`)}r.observe(i=>{i.changes.keys.forEach((o,c)=>{if(o.action==="add"){const l=uc(c);if(!qs(l)){console.log(`Element ${c} not an HTML element. Ignoring.`);return}const a=Qs(l,t);e.set(fn(l),a)}else if(o.action==="update"){const l=e.get(c);l.__data=r.get(c)}else o.action==="delete"?e.delete(c):console.log(`Unhandled action: ${o.action}`)})})}G.observe(t=>{t.changes.keys.forEach((n,s)=>{n.action==="add"&&G.set(s,G.get(s))})})}T.globalData=G,T.setupElements=Zs,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playhtml",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/playhtml.umd.js",