@thatopen/services 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,75 +1,75 @@
1
- var es = Object.defineProperty;
2
- var ge = (n) => {
1
+ var cs = Object.defineProperty;
2
+ var ve = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var ss = (n, t, e) => t in n ? es(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var T = (n, t, e) => ss(n, typeof t != "symbol" ? t + "" : t, e), Pt = (n, t, e) => t.has(n) || ge("Cannot " + e);
7
- var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ge("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), _ = (n, t, e, s) => (Pt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Pt(n, t, "access private method"), e);
8
- const P = /* @__PURE__ */ Object.create(null);
9
- P.open = "0";
10
- P.close = "1";
11
- P.ping = "2";
12
- P.pong = "3";
13
- P.message = "4";
14
- P.upgrade = "5";
15
- P.noop = "6";
16
- const Et = /* @__PURE__ */ Object.create(null);
17
- Object.keys(P).forEach((n) => {
18
- Et[P[n]] = n;
5
+ var hs = (n, t, e) => t in n ? cs(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var T = (n, t, e) => hs(n, typeof t != "symbol" ? t + "" : t, e), Lt = (n, t, e) => t.has(n) || ve("Cannot " + e);
7
+ var l = (n, t, e) => (Lt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), b = (n, t, e) => t.has(n) ? ve("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), _ = (n, t, e, s) => (Lt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), a = (n, t, e) => (Lt(n, t, "access private method"), e);
8
+ const B = /* @__PURE__ */ Object.create(null);
9
+ B.open = "0";
10
+ B.close = "1";
11
+ B.ping = "2";
12
+ B.pong = "3";
13
+ B.message = "4";
14
+ B.upgrade = "5";
15
+ B.noop = "6";
16
+ const kt = /* @__PURE__ */ Object.create(null);
17
+ Object.keys(B).forEach((n) => {
18
+ kt[B[n]] = n;
19
19
  });
20
- const jt = { type: "error", data: "parser error" }, $e = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ce = typeof ArrayBuffer == "function", Re = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, he = ({ type: n, data: t }, e, s) => $e && t instanceof Blob ? e ? s(t) : we(t, s) : Ce && (t instanceof ArrayBuffer || Re(t)) ? e ? s(t) : we(new Blob([t]), s) : s(P[n] + (t || "")), we = (n, t) => {
20
+ const Ht = { type: "error", data: "parser error" }, Le = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Fe = typeof ArrayBuffer == "function", qe = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, fe = ({ type: n, data: t }, e, s) => Le && t instanceof Blob ? e ? s(t) : Ee(t, s) : Fe && (t instanceof ArrayBuffer || qe(t)) ? e ? s(t) : Ee(new Blob([t]), s) : s(B[n] + (t || "")), Ee = (n, t) => {
21
21
  const e = new FileReader();
22
22
  return e.onload = function() {
23
23
  const s = e.result.split(",")[1];
24
24
  t("b" + (s || ""));
25
25
  }, e.readAsDataURL(n);
26
26
  };
27
- function be(n) {
27
+ function Te(n) {
28
28
  return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
29
29
  }
30
- let Bt;
31
- function ns(n, t) {
32
- if ($e && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(be).then(t);
34
- if (Ce && (n.data instanceof ArrayBuffer || Re(n.data)))
35
- return t(be(n.data));
36
- he(n, !1, (e) => {
37
- Bt || (Bt = new TextEncoder()), t(Bt.encode(e));
30
+ let Ft;
31
+ function ls(n, t) {
32
+ if (Le && n.data instanceof Blob)
33
+ return n.data.arrayBuffer().then(Te).then(t);
34
+ if (Fe && (n.data instanceof ArrayBuffer || qe(n.data)))
35
+ return t(Te(n.data));
36
+ fe(n, !1, (e) => {
37
+ Ft || (Ft = new TextEncoder()), t(Ft.encode(e));
38
38
  });
39
39
  }
40
- const _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ot = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
- for (let n = 0; n < _e.length; n++)
42
- ot[_e.charCodeAt(n)] = n;
43
- const rs = (n) => {
44
- let t = n.length * 0.75, e = n.length, s, r = 0, i, o, h, u;
40
+ const Se = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", lt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
+ for (let n = 0; n < Se.length; n++)
42
+ lt[Se.charCodeAt(n)] = n;
43
+ const us = (n) => {
44
+ let t = n.length * 0.75, e = n.length, s, r = 0, i, o, c, u;
45
45
  n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
46
- const f = new ArrayBuffer(t), p = new Uint8Array(f);
46
+ const f = new ArrayBuffer(t), y = new Uint8Array(f);
47
47
  for (s = 0; s < e; s += 4)
48
- i = ot[n.charCodeAt(s)], o = ot[n.charCodeAt(s + 1)], h = ot[n.charCodeAt(s + 2)], u = ot[n.charCodeAt(s + 3)], p[r++] = i << 2 | o >> 4, p[r++] = (o & 15) << 4 | h >> 2, p[r++] = (h & 3) << 6 | u & 63;
48
+ i = lt[n.charCodeAt(s)], o = lt[n.charCodeAt(s + 1)], c = lt[n.charCodeAt(s + 2)], u = lt[n.charCodeAt(s + 3)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | c >> 2, y[r++] = (c & 3) << 6 | u & 63;
49
49
  return f;
50
- }, is = typeof ArrayBuffer == "function", le = (n, t) => {
50
+ }, ds = typeof ArrayBuffer == "function", pe = (n, t) => {
51
51
  if (typeof n != "string")
52
52
  return {
53
53
  type: "message",
54
- data: Ne(n, t)
54
+ data: De(n, t)
55
55
  };
56
56
  const e = n.charAt(0);
57
57
  return e === "b" ? {
58
58
  type: "message",
59
- data: os(n.substring(1), t)
60
- } : Et[e] ? n.length > 1 ? {
61
- type: Et[e],
59
+ data: fs(n.substring(1), t)
60
+ } : kt[e] ? n.length > 1 ? {
61
+ type: kt[e],
62
62
  data: n.substring(1)
63
63
  } : {
64
- type: Et[e]
65
- } : jt;
66
- }, os = (n, t) => {
67
- if (is) {
68
- const e = rs(n);
69
- return Ne(e, t);
64
+ type: kt[e]
65
+ } : Ht;
66
+ }, fs = (n, t) => {
67
+ if (ds) {
68
+ const e = us(n);
69
+ return De(e, t);
70
70
  } else
71
71
  return { base64: !0, data: n };
72
- }, Ne = (n, t) => {
72
+ }, De = (n, t) => {
73
73
  switch (t) {
74
74
  case "blob":
75
75
  return n instanceof Blob ? n : new Blob([n]);
@@ -77,27 +77,27 @@ const rs = (n) => {
77
77
  default:
78
78
  return n instanceof ArrayBuffer ? n : n.buffer;
79
79
  }
80
- }, Pe = "", as = (n, t) => {
80
+ }, Ue = "", ps = (n, t) => {
81
81
  const e = n.length, s = new Array(e);
82
82
  let r = 0;
83
83
  n.forEach((i, o) => {
84
- he(i, !1, (h) => {
85
- s[o] = h, ++r === e && t(s.join(Pe));
84
+ fe(i, !1, (c) => {
85
+ s[o] = c, ++r === e && t(s.join(Ue));
86
86
  });
87
87
  });
88
- }, cs = (n, t) => {
89
- const e = n.split(Pe), s = [];
88
+ }, ys = (n, t) => {
89
+ const e = n.split(Ue), s = [];
90
90
  for (let r = 0; r < e.length; r++) {
91
- const i = le(e[r], t);
91
+ const i = pe(e[r], t);
92
92
  if (s.push(i), i.type === "error")
93
93
  break;
94
94
  }
95
95
  return s;
96
96
  };
97
- function hs() {
97
+ function ms() {
98
98
  return new TransformStream({
99
99
  transform(n, t) {
100
- ns(n, (e) => {
100
+ ls(n, (e) => {
101
101
  const s = e.length;
102
102
  let r;
103
103
  if (s < 126)
@@ -116,11 +116,11 @@ function hs() {
116
116
  }
117
117
  });
118
118
  }
119
- let Lt;
120
- function wt(n) {
119
+ let qt;
120
+ function Et(n) {
121
121
  return n.reduce((t, e) => t + e.length, 0);
122
122
  }
123
- function bt(n, t) {
123
+ function Tt(n, t) {
124
124
  if (n[0].length === t)
125
125
  return n.shift();
126
126
  const e = new Uint8Array(t);
@@ -129,65 +129,65 @@ function bt(n, t) {
129
129
  e[r] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
130
130
  return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
131
131
  }
132
- function ls(n, t) {
133
- Lt || (Lt = new TextDecoder());
132
+ function gs(n, t) {
133
+ qt || (qt = new TextDecoder());
134
134
  const e = [];
135
135
  let s = 0, r = -1, i = !1;
136
136
  return new TransformStream({
137
- transform(o, h) {
137
+ transform(o, c) {
138
138
  for (e.push(o); ; ) {
139
139
  if (s === 0) {
140
- if (wt(e) < 1)
140
+ if (Et(e) < 1)
141
141
  break;
142
- const u = bt(e, 1);
142
+ const u = Tt(e, 1);
143
143
  i = (u[0] & 128) === 128, r = u[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
144
144
  } else if (s === 1) {
145
- if (wt(e) < 2)
145
+ if (Et(e) < 2)
146
146
  break;
147
- const u = bt(e, 2);
147
+ const u = Tt(e, 2);
148
148
  r = new DataView(u.buffer, u.byteOffset, u.length).getUint16(0), s = 3;
149
149
  } else if (s === 2) {
150
- if (wt(e) < 8)
150
+ if (Et(e) < 8)
151
151
  break;
152
- const u = bt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), p = f.getUint32(0);
153
- if (p > Math.pow(2, 21) - 1) {
154
- h.enqueue(jt);
152
+ const u = Tt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
153
+ if (y > Math.pow(2, 21) - 1) {
154
+ c.enqueue(Ht);
155
155
  break;
156
156
  }
157
- r = p * Math.pow(2, 32) + f.getUint32(4), s = 3;
157
+ r = y * Math.pow(2, 32) + f.getUint32(4), s = 3;
158
158
  } else {
159
- if (wt(e) < r)
159
+ if (Et(e) < r)
160
160
  break;
161
- const u = bt(e, r);
162
- h.enqueue(le(i ? u : Lt.decode(u), t)), s = 0;
161
+ const u = Tt(e, r);
162
+ c.enqueue(pe(i ? u : qt.decode(u), t)), s = 0;
163
163
  }
164
164
  if (r === 0 || r > n) {
165
- h.enqueue(jt);
165
+ c.enqueue(Ht);
166
166
  break;
167
167
  }
168
168
  }
169
169
  }
170
170
  });
171
171
  }
172
- const Be = 4;
173
- function E(n) {
174
- if (n) return us(n);
172
+ const je = 4;
173
+ function v(n) {
174
+ if (n) return ws(n);
175
175
  }
176
- function us(n) {
177
- for (var t in E.prototype)
178
- n[t] = E.prototype[t];
176
+ function ws(n) {
177
+ for (var t in v.prototype)
178
+ n[t] = v.prototype[t];
179
179
  return n;
180
180
  }
181
- E.prototype.on = E.prototype.addEventListener = function(n, t) {
181
+ v.prototype.on = v.prototype.addEventListener = function(n, t) {
182
182
  return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(t), this;
183
183
  };
184
- E.prototype.once = function(n, t) {
184
+ v.prototype.once = function(n, t) {
185
185
  function e() {
186
186
  this.off(n, e), t.apply(this, arguments);
187
187
  }
188
188
  return e.fn = t, this.on(n, e), this;
189
189
  };
190
- E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(n, t) {
190
+ v.prototype.off = v.prototype.removeListener = v.prototype.removeAllListeners = v.prototype.removeEventListener = function(n, t) {
191
191
  if (this._callbacks = this._callbacks || {}, arguments.length == 0)
192
192
  return this._callbacks = {}, this;
193
193
  var e = this._callbacks["$" + n];
@@ -201,7 +201,7 @@ E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners =
201
201
  }
202
202
  return e.length === 0 && delete this._callbacks["$" + n], this;
203
203
  };
204
- E.prototype.emit = function(n) {
204
+ v.prototype.emit = function(n) {
205
205
  this._callbacks = this._callbacks || {};
206
206
  for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
207
207
  t[s - 1] = arguments[s];
@@ -212,41 +212,41 @@ E.prototype.emit = function(n) {
212
212
  }
213
213
  return this;
214
214
  };
215
- E.prototype.emitReserved = E.prototype.emit;
216
- E.prototype.listeners = function(n) {
215
+ v.prototype.emitReserved = v.prototype.emit;
216
+ v.prototype.listeners = function(n) {
217
217
  return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
218
218
  };
219
- E.prototype.hasListeners = function(n) {
219
+ v.prototype.hasListeners = function(n) {
220
220
  return !!this.listeners(n).length;
221
221
  };
222
- const Rt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), A = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), ds = "arraybuffer";
223
- function Le(n, ...t) {
222
+ const Pt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), I = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), bs = "arraybuffer";
223
+ function Me(n, ...t) {
224
224
  return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
225
225
  }
226
- const fs = A.setTimeout, ps = A.clearTimeout;
227
- function Nt(n, t) {
228
- t.useNativeTimers ? (n.setTimeoutFn = fs.bind(A), n.clearTimeoutFn = ps.bind(A)) : (n.setTimeoutFn = A.setTimeout.bind(A), n.clearTimeoutFn = A.clearTimeout.bind(A));
226
+ const _s = I.setTimeout, vs = I.clearTimeout;
227
+ function Bt(n, t) {
228
+ t.useNativeTimers ? (n.setTimeoutFn = _s.bind(I), n.clearTimeoutFn = vs.bind(I)) : (n.setTimeoutFn = I.setTimeout.bind(I), n.clearTimeoutFn = I.clearTimeout.bind(I));
229
229
  }
230
- const ys = 1.33;
231
- function ms(n) {
232
- return typeof n == "string" ? gs(n) : Math.ceil((n.byteLength || n.size) * ys);
230
+ const Es = 1.33;
231
+ function Ts(n) {
232
+ return typeof n == "string" ? Ss(n) : Math.ceil((n.byteLength || n.size) * Es);
233
233
  }
234
- function gs(n) {
234
+ function Ss(n) {
235
235
  let t = 0, e = 0;
236
236
  for (let s = 0, r = n.length; s < r; s++)
237
237
  t = n.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
238
238
  return e;
239
239
  }
240
- function qe() {
240
+ function He() {
241
241
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
242
242
  }
243
- function ws(n) {
243
+ function ks(n) {
244
244
  let t = "";
245
245
  for (let e in n)
246
246
  n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
247
247
  return t;
248
248
  }
249
- function bs(n) {
249
+ function Os(n) {
250
250
  let t = {}, e = n.split("&");
251
251
  for (let s = 0, r = e.length; s < r; s++) {
252
252
  let i = e[s].split("=");
@@ -254,12 +254,12 @@ function bs(n) {
254
254
  }
255
255
  return t;
256
256
  }
257
- class _s extends Error {
257
+ class Is extends Error {
258
258
  constructor(t, e, s) {
259
259
  super(t), this.description = e, this.context = s, this.type = "TransportError";
260
260
  }
261
261
  }
262
- class ue extends E {
262
+ class ye extends v {
263
263
  /**
264
264
  * Transport abstract constructor.
265
265
  *
@@ -267,7 +267,7 @@ class ue extends E {
267
267
  * @protected
268
268
  */
269
269
  constructor(t) {
270
- super(), this.writable = !1, Nt(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
270
+ super(), this.writable = !1, Bt(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
271
271
  }
272
272
  /**
273
273
  * Emits an error.
@@ -279,7 +279,7 @@ class ue extends E {
279
279
  * @protected
280
280
  */
281
281
  onError(t, e, s) {
282
- return super.emitReserved("error", new _s(t, e, s)), this;
282
+ return super.emitReserved("error", new Is(t, e, s)), this;
283
283
  }
284
284
  /**
285
285
  * Opens the transport.
@@ -316,7 +316,7 @@ class ue extends E {
316
316
  * @protected
317
317
  */
318
318
  onData(t) {
319
- const e = le(t, this.socket.binaryType);
319
+ const e = pe(t, this.socket.binaryType);
320
320
  this.onPacket(e);
321
321
  }
322
322
  /**
@@ -353,11 +353,11 @@ class ue extends E {
353
353
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
354
354
  }
355
355
  _query(t) {
356
- const e = ws(t);
356
+ const e = ks(t);
357
357
  return e.length ? "?" + e : "";
358
358
  }
359
359
  }
360
- class Es extends ue {
360
+ class As extends ye {
361
361
  constructor() {
362
362
  super(...arguments), this._polling = !1;
363
363
  }
@@ -413,7 +413,7 @@ class Es extends ue {
413
413
  return this.onClose({ description: "transport closed by the server" }), !1;
414
414
  this.onPacket(s);
415
415
  };
416
- cs(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
416
+ ys(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
417
417
  }
418
418
  /**
419
419
  * For polling, send a close packet.
@@ -433,7 +433,7 @@ class Es extends ue {
433
433
  * @protected
434
434
  */
435
435
  write(t) {
436
- this.writable = !1, as(t, (e) => {
436
+ this.writable = !1, ps(t, (e) => {
437
437
  this.doWrite(e, () => {
438
438
  this.writable = !0, this.emitReserved("drain");
439
439
  });
@@ -446,18 +446,18 @@ class Es extends ue {
446
446
  */
447
447
  uri() {
448
448
  const t = this.opts.secure ? "https" : "http", e = this.query || {};
449
- return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = qe()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
449
+ return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = He()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
450
450
  }
451
451
  }
452
- let Fe = !1;
452
+ let Ge = !1;
453
453
  try {
454
- Fe = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
454
+ Ge = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
455
455
  } catch {
456
456
  }
457
- const vs = Fe;
458
- function Ts() {
457
+ const xs = Ge;
458
+ function $s() {
459
459
  }
460
- class Ss extends Es {
460
+ class Cs extends As {
461
461
  /**
462
462
  * XHR Polling constructor.
463
463
  *
@@ -499,7 +499,7 @@ class Ss extends Es {
499
499
  }), this.pollXhr = t;
500
500
  }
501
501
  }
502
- class N extends E {
502
+ class P extends v {
503
503
  /**
504
504
  * Request constructor
505
505
  *
@@ -507,7 +507,7 @@ class N extends E {
507
507
  * @package
508
508
  */
509
509
  constructor(t, e, s) {
510
- super(), this.createRequest = t, Nt(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
510
+ super(), this.createRequest = t, Bt(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
511
511
  }
512
512
  /**
513
513
  * Creates the XHR object and sends the request.
@@ -516,7 +516,7 @@ class N extends E {
516
516
  */
517
517
  _create() {
518
518
  var t;
519
- const e = Le(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
519
+ const e = Me(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
520
520
  e.xdomain = !!this._opts.xd;
521
521
  const s = this._xhr = this.createRequest(e);
522
522
  try {
@@ -553,7 +553,7 @@ class N extends E {
553
553
  }, 0);
554
554
  return;
555
555
  }
556
- typeof document < "u" && (this._index = N.requestsCount++, N.requests[this._index] = this);
556
+ typeof document < "u" && (this._index = P.requestsCount++, P.requests[this._index] = this);
557
557
  }
558
558
  /**
559
559
  * Called upon error.
@@ -570,12 +570,12 @@ class N extends E {
570
570
  */
571
571
  _cleanup(t) {
572
572
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
573
- if (this._xhr.onreadystatechange = Ts, t)
573
+ if (this._xhr.onreadystatechange = $s, t)
574
574
  try {
575
575
  this._xhr.abort();
576
576
  } catch {
577
577
  }
578
- typeof document < "u" && delete N.requests[this._index], this._xhr = null;
578
+ typeof document < "u" && delete P.requests[this._index], this._xhr = null;
579
579
  }
580
580
  }
581
581
  /**
@@ -596,56 +596,56 @@ class N extends E {
596
596
  this._cleanup();
597
597
  }
598
598
  }
599
- N.requestsCount = 0;
600
- N.requests = {};
599
+ P.requestsCount = 0;
600
+ P.requests = {};
601
601
  if (typeof document < "u") {
602
602
  if (typeof attachEvent == "function")
603
- attachEvent("onunload", Ee);
603
+ attachEvent("onunload", ke);
604
604
  else if (typeof addEventListener == "function") {
605
- const n = "onpagehide" in A ? "pagehide" : "unload";
606
- addEventListener(n, Ee, !1);
605
+ const n = "onpagehide" in I ? "pagehide" : "unload";
606
+ addEventListener(n, ke, !1);
607
607
  }
608
608
  }
609
- function Ee() {
610
- for (let n in N.requests)
611
- N.requests.hasOwnProperty(n) && N.requests[n].abort();
609
+ function ke() {
610
+ for (let n in P.requests)
611
+ P.requests.hasOwnProperty(n) && P.requests[n].abort();
612
612
  }
613
- const ks = function() {
614
- const n = Ue({
613
+ const Rs = function() {
614
+ const n = Ve({
615
615
  xdomain: !1
616
616
  });
617
617
  return n && n.responseType !== null;
618
618
  }();
619
- class Os extends Ss {
619
+ class Ns extends Cs {
620
620
  constructor(t) {
621
621
  super(t);
622
622
  const e = t && t.forceBase64;
623
- this.supportsBinary = ks && !e;
623
+ this.supportsBinary = Rs && !e;
624
624
  }
625
625
  request(t = {}) {
626
- return Object.assign(t, { xd: this.xd }, this.opts), new N(Ue, this.uri(), t);
626
+ return Object.assign(t, { xd: this.xd }, this.opts), new P(Ve, this.uri(), t);
627
627
  }
628
628
  }
629
- function Ue(n) {
629
+ function Ve(n) {
630
630
  const t = n.xdomain;
631
631
  try {
632
- if (typeof XMLHttpRequest < "u" && (!t || vs))
632
+ if (typeof XMLHttpRequest < "u" && (!t || xs))
633
633
  return new XMLHttpRequest();
634
634
  } catch {
635
635
  }
636
636
  if (!t)
637
637
  try {
638
- return new A[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
638
+ return new I[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
639
639
  } catch {
640
640
  }
641
641
  }
642
- const De = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
- class As extends ue {
642
+ const Je = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
+ class Ps extends ye {
644
644
  get name() {
645
645
  return "websocket";
646
646
  }
647
647
  doOpen() {
648
- const t = this.uri(), e = this.opts.protocols, s = De ? {} : Le(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
648
+ const t = this.uri(), e = this.opts.protocols, s = Je ? {} : Me(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
649
649
  this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
650
650
  try {
651
651
  this.ws = this.createSocket(t, e, s);
@@ -671,12 +671,12 @@ class As extends ue {
671
671
  this.writable = !1;
672
672
  for (let e = 0; e < t.length; e++) {
673
673
  const s = t[e], r = e === t.length - 1;
674
- he(s, this.supportsBinary, (i) => {
674
+ fe(s, this.supportsBinary, (i) => {
675
675
  try {
676
676
  this.doWrite(s, i);
677
677
  } catch {
678
678
  }
679
- r && Rt(() => {
679
+ r && Pt(() => {
680
680
  this.writable = !0, this.emitReserved("drain");
681
681
  }, this.setTimeoutFn);
682
682
  });
@@ -693,19 +693,19 @@ class As extends ue {
693
693
  */
694
694
  uri() {
695
695
  const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
696
- return this.opts.timestampRequests && (e[this.opts.timestampParam] = qe()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
696
+ return this.opts.timestampRequests && (e[this.opts.timestampParam] = He()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
697
697
  }
698
698
  }
699
- const qt = A.WebSocket || A.MozWebSocket;
700
- class Is extends As {
699
+ const Dt = I.WebSocket || I.MozWebSocket;
700
+ class Bs extends Ps {
701
701
  createSocket(t, e, s) {
702
- return De ? new qt(t, e, s) : e ? new qt(t, e) : new qt(t);
702
+ return Je ? new Dt(t, e, s) : e ? new Dt(t, e) : new Dt(t);
703
703
  }
704
704
  doWrite(t, e) {
705
705
  this.ws.send(e);
706
706
  }
707
707
  }
708
- class xs extends ue {
708
+ class Ls extends ye {
709
709
  get name() {
710
710
  return "webtransport";
711
711
  }
@@ -721,12 +721,12 @@ class xs extends ue {
721
721
  this.onError("webtransport error", t);
722
722
  }), this._transport.ready.then(() => {
723
723
  this._transport.createBidirectionalStream().then((t) => {
724
- const e = ls(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = hs();
724
+ const e = gs(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = ms();
725
725
  r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
726
726
  const i = () => {
727
- s.read().then(({ done: h, value: u }) => {
728
- h || (this.onPacket(u), i());
729
- }).catch((h) => {
727
+ s.read().then(({ done: c, value: u }) => {
728
+ c || (this.onPacket(u), i());
729
+ }).catch((c) => {
730
730
  });
731
731
  };
732
732
  i();
@@ -740,7 +740,7 @@ class xs extends ue {
740
740
  for (let e = 0; e < t.length; e++) {
741
741
  const s = t[e], r = e === t.length - 1;
742
742
  this._writer.write(s).then(() => {
743
- r && Rt(() => {
743
+ r && Pt(() => {
744
744
  this.writable = !0, this.emitReserved("drain");
745
745
  }, this.setTimeoutFn);
746
746
  });
@@ -751,11 +751,11 @@ class xs extends ue {
751
751
  (t = this._transport) === null || t === void 0 || t.close();
752
752
  }
753
753
  }
754
- const $s = {
755
- websocket: Is,
756
- webtransport: xs,
757
- polling: Os
758
- }, Cs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Rs = [
754
+ const Fs = {
755
+ websocket: Bs,
756
+ webtransport: Ls,
757
+ polling: Ns
758
+ }, qs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Ds = [
759
759
  "source",
760
760
  "protocol",
761
761
  "authority",
@@ -771,31 +771,31 @@ const $s = {
771
771
  "query",
772
772
  "anchor"
773
773
  ];
774
- function Mt(n) {
774
+ function Gt(n) {
775
775
  if (n.length > 8e3)
776
776
  throw "URI too long";
777
777
  const t = n, e = n.indexOf("["), s = n.indexOf("]");
778
778
  e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
779
- let r = Cs.exec(n || ""), i = {}, o = 14;
779
+ let r = qs.exec(n || ""), i = {}, o = 14;
780
780
  for (; o--; )
781
- i[Rs[o]] = r[o] || "";
782
- return e != -1 && s != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Ns(i, i.path), i.queryKey = Ps(i, i.query), i;
781
+ i[Ds[o]] = r[o] || "";
782
+ return e != -1 && s != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Us(i, i.path), i.queryKey = js(i, i.query), i;
783
783
  }
784
- function Ns(n, t) {
784
+ function Us(n, t) {
785
785
  const e = /\/{2,9}/g, s = t.replace(e, "/").split("/");
786
786
  return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
787
787
  }
788
- function Ps(n, t) {
788
+ function js(n, t) {
789
789
  const e = {};
790
790
  return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
791
791
  r && (e[r] = i);
792
792
  }), e;
793
793
  }
794
- const Ht = typeof addEventListener == "function" && typeof removeEventListener == "function", vt = [];
795
- Ht && addEventListener("offline", () => {
796
- vt.forEach((n) => n());
794
+ const Vt = typeof addEventListener == "function" && typeof removeEventListener == "function", Ot = [];
795
+ Vt && addEventListener("offline", () => {
796
+ Ot.forEach((n) => n());
797
797
  }, !1);
798
- class J extends E {
798
+ class Y extends v {
799
799
  /**
800
800
  * Socket constructor.
801
801
  *
@@ -803,11 +803,11 @@ class J extends E {
803
803
  * @param {Object} opts - options
804
804
  */
805
805
  constructor(t, e) {
806
- if (super(), this.binaryType = ds, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
807
- const s = Mt(t);
806
+ if (super(), this.binaryType = bs, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
807
+ const s = Gt(t);
808
808
  e.hostname = s.host, e.secure = s.protocol === "https" || s.protocol === "wss", e.port = s.port, s.query && (e.query = s.query);
809
- } else e.host && (e.hostname = Mt(e.host).host);
810
- Nt(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((s) => {
809
+ } else e.host && (e.hostname = Gt(e.host).host);
810
+ Bt(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((s) => {
811
811
  const r = s.prototype.name;
812
812
  this.transports.push(r), this._transportsByName[r] = s;
813
813
  }), this.opts = Object.assign({
@@ -824,13 +824,13 @@ class J extends E {
824
824
  },
825
825
  transportOptions: {},
826
826
  closeOnBeforeunload: !1
827
- }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = bs(this.opts.query)), Ht && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
827
+ }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Os(this.opts.query)), Vt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
828
828
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
829
829
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
830
830
  this._onClose("transport close", {
831
831
  description: "network connection lost"
832
832
  });
833
- }, vt.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
833
+ }, Ot.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
834
834
  }
835
835
  /**
836
836
  * Creates transport of the given type.
@@ -841,7 +841,7 @@ class J extends E {
841
841
  */
842
842
  createTransport(t) {
843
843
  const e = Object.assign({}, this.opts.query);
844
- e.EIO = Be, e.transport = t, this.id && (e.sid = this.id);
844
+ e.EIO = je, e.transport = t, this.id && (e.sid = this.id);
845
845
  const s = Object.assign({}, this.opts, {
846
846
  query: e,
847
847
  socket: this,
@@ -863,7 +863,7 @@ class J extends E {
863
863
  }, 0);
864
864
  return;
865
865
  }
866
- const t = this.opts.rememberUpgrade && J.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
866
+ const t = this.opts.rememberUpgrade && Y.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
867
867
  this.readyState = "opening";
868
868
  const e = this.createTransport(t);
869
869
  e.open(), this.setTransport(e);
@@ -882,7 +882,7 @@ class J extends E {
882
882
  * @private
883
883
  */
884
884
  onOpen() {
885
- this.readyState = "open", J.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
885
+ this.readyState = "open", Y.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
886
886
  }
887
887
  /**
888
888
  * Handles a packet.
@@ -959,7 +959,7 @@ class J extends E {
959
959
  let e = 1;
960
960
  for (let s = 0; s < this.writeBuffer.length; s++) {
961
961
  const r = this.writeBuffer[s].data;
962
- if (r && (e += ms(r)), s > 0 && e > this._maxPayload)
962
+ if (r && (e += Ts(r)), s > 0 && e > this._maxPayload)
963
963
  return this.writeBuffer.slice(0, s);
964
964
  e += 2;
965
965
  }
@@ -979,7 +979,7 @@ class J extends E {
979
979
  if (!this._pingTimeoutTime)
980
980
  return !0;
981
981
  const t = Date.now() > this._pingTimeoutTime;
982
- return t && (this._pingTimeoutTime = 0, Rt(() => {
982
+ return t && (this._pingTimeoutTime = 0, Pt(() => {
983
983
  this._onClose("ping timeout");
984
984
  }, this.setTimeoutFn)), t;
985
985
  }
@@ -1046,7 +1046,7 @@ class J extends E {
1046
1046
  * @private
1047
1047
  */
1048
1048
  _onError(t) {
1049
- if (J.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1049
+ if (Y.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1050
1050
  return this.transports.shift(), this._open();
1051
1051
  this.emitReserved("error", t), this._onClose("transport error", t);
1052
1052
  }
@@ -1057,16 +1057,16 @@ class J extends E {
1057
1057
  */
1058
1058
  _onClose(t, e) {
1059
1059
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
1060
- if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Ht && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
- const s = vt.indexOf(this._offlineEventListener);
1062
- s !== -1 && vt.splice(s, 1);
1060
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Vt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
+ const s = Ot.indexOf(this._offlineEventListener);
1062
+ s !== -1 && Ot.splice(s, 1);
1063
1063
  }
1064
1064
  this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
1065
1065
  }
1066
1066
  }
1067
1067
  }
1068
- J.protocol = Be;
1069
- class Bs extends J {
1068
+ Y.protocol = je;
1069
+ class Ms extends Y {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1083,15 +1083,15 @@ class Bs extends J {
1083
1083
  */
1084
1084
  _probe(t) {
1085
1085
  let e = this.createTransport(t), s = !1;
1086
- J.priorWebsocketSuccess = !1;
1086
+ Y.priorWebsocketSuccess = !1;
1087
1087
  const r = () => {
1088
1088
  s || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (w) => {
1089
1089
  if (!s)
1090
1090
  if (w.type === "pong" && w.data === "probe") {
1091
1091
  if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
1092
1092
  return;
1093
- J.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
- s || this.readyState !== "closed" && (p(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
1093
+ Y.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
+ s || this.readyState !== "closed" && (y(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
1095
1095
  });
1096
1096
  } else {
1097
1097
  const C = new Error("probe error");
@@ -1100,13 +1100,13 @@ class Bs extends J {
1100
1100
  }));
1101
1101
  };
1102
1102
  function i() {
1103
- s || (s = !0, p(), e.close(), e = null);
1103
+ s || (s = !0, y(), e.close(), e = null);
1104
1104
  }
1105
1105
  const o = (w) => {
1106
1106
  const C = new Error("probe error: " + w);
1107
1107
  C.transport = e.name, i(), this.emitReserved("upgradeError", C);
1108
1108
  };
1109
- function h() {
1109
+ function c() {
1110
1110
  o("transport closed");
1111
1111
  }
1112
1112
  function u() {
@@ -1115,10 +1115,10 @@ class Bs extends J {
1115
1115
  function f(w) {
1116
1116
  e && w.name !== e.name && i();
1117
1117
  }
1118
- const p = () => {
1119
- e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", h), this.off("close", u), this.off("upgrading", f);
1118
+ const y = () => {
1119
+ e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", c), this.off("close", u), this.off("upgrading", f);
1120
1120
  };
1121
- e.once("open", r), e.once("error", o), e.once("close", h), this.once("close", u), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
1121
+ e.once("open", r), e.once("error", o), e.once("close", c), this.once("close", u), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
1122
1122
  s || e.open();
1123
1123
  }, 200) : e.open();
1124
1124
  }
@@ -1138,67 +1138,67 @@ class Bs extends J {
1138
1138
  return e;
1139
1139
  }
1140
1140
  }
1141
- let Ls = class extends Bs {
1141
+ let Hs = class extends Ms {
1142
1142
  constructor(t, e = {}) {
1143
1143
  const s = typeof t == "object", r = s ? { ...t } : { ...e };
1144
- (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => $s[i]).filter((i) => !!i)), super(s ? r : t, r);
1144
+ (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Fs[i]).filter((i) => !!i)), super(s ? r : t, r);
1145
1145
  }
1146
1146
  };
1147
- function qs(n, t = "", e) {
1147
+ function Gs(n, t = "", e) {
1148
1148
  let s = n;
1149
- e = e || typeof location < "u" && location, n == null && (n = e.protocol + "//" + e.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = e.protocol + n : n = e.host + n), /^(https?|wss?):\/\//.test(n) || (typeof e < "u" ? n = e.protocol + "//" + n : n = "https://" + n), s = Mt(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1149
+ e = e || typeof location < "u" && location, n == null && (n = e.protocol + "//" + e.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = e.protocol + n : n = e.host + n), /^(https?|wss?):\/\//.test(n) || (typeof e < "u" ? n = e.protocol + "//" + n : n = "https://" + n), s = Gt(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1150
1150
  const i = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1151
1151
  return s.id = s.protocol + "://" + i + ":" + s.port + t, s.href = s.protocol + "://" + i + (e && e.port === s.port ? "" : ":" + s.port), s;
1152
1152
  }
1153
- const Fs = typeof ArrayBuffer == "function", Us = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, je = Object.prototype.toString, Ds = typeof Blob == "function" || typeof Blob < "u" && je.call(Blob) === "[object BlobConstructor]", js = typeof File == "function" || typeof File < "u" && je.call(File) === "[object FileConstructor]";
1154
- function de(n) {
1155
- return Fs && (n instanceof ArrayBuffer || Us(n)) || Ds && n instanceof Blob || js && n instanceof File;
1153
+ const Vs = typeof ArrayBuffer == "function", Js = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Ye = Object.prototype.toString, Ys = typeof Blob == "function" || typeof Blob < "u" && Ye.call(Blob) === "[object BlobConstructor]", Ws = typeof File == "function" || typeof File < "u" && Ye.call(File) === "[object FileConstructor]";
1154
+ function me(n) {
1155
+ return Vs && (n instanceof ArrayBuffer || Js(n)) || Ys && n instanceof Blob || Ws && n instanceof File;
1156
1156
  }
1157
- function Tt(n, t) {
1157
+ function It(n, t) {
1158
1158
  if (!n || typeof n != "object")
1159
1159
  return !1;
1160
1160
  if (Array.isArray(n)) {
1161
1161
  for (let e = 0, s = n.length; e < s; e++)
1162
- if (Tt(n[e]))
1162
+ if (It(n[e]))
1163
1163
  return !0;
1164
1164
  return !1;
1165
1165
  }
1166
- if (de(n))
1166
+ if (me(n))
1167
1167
  return !0;
1168
1168
  if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1169
- return Tt(n.toJSON(), !0);
1169
+ return It(n.toJSON(), !0);
1170
1170
  for (const e in n)
1171
- if (Object.prototype.hasOwnProperty.call(n, e) && Tt(n[e]))
1171
+ if (Object.prototype.hasOwnProperty.call(n, e) && It(n[e]))
1172
1172
  return !0;
1173
1173
  return !1;
1174
1174
  }
1175
- function Ms(n) {
1175
+ function Ks(n) {
1176
1176
  const t = [], e = n.data, s = n;
1177
- return s.data = Gt(e, t), s.attachments = t.length, { packet: s, buffers: t };
1177
+ return s.data = Jt(e, t), s.attachments = t.length, { packet: s, buffers: t };
1178
1178
  }
1179
- function Gt(n, t) {
1179
+ function Jt(n, t) {
1180
1180
  if (!n)
1181
1181
  return n;
1182
- if (de(n)) {
1182
+ if (me(n)) {
1183
1183
  const e = { _placeholder: !0, num: t.length };
1184
1184
  return t.push(n), e;
1185
1185
  } else if (Array.isArray(n)) {
1186
1186
  const e = new Array(n.length);
1187
1187
  for (let s = 0; s < n.length; s++)
1188
- e[s] = Gt(n[s], t);
1188
+ e[s] = Jt(n[s], t);
1189
1189
  return e;
1190
1190
  } else if (typeof n == "object" && !(n instanceof Date)) {
1191
1191
  const e = {};
1192
1192
  for (const s in n)
1193
- Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Gt(n[s], t));
1193
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = Jt(n[s], t));
1194
1194
  return e;
1195
1195
  }
1196
1196
  return n;
1197
1197
  }
1198
- function Hs(n, t) {
1199
- return n.data = Vt(n.data, t), delete n.attachments, n;
1198
+ function zs(n, t) {
1199
+ return n.data = Yt(n.data, t), delete n.attachments, n;
1200
1200
  }
1201
- function Vt(n, t) {
1201
+ function Yt(n, t) {
1202
1202
  if (!n)
1203
1203
  return n;
1204
1204
  if (n && n._placeholder === !0) {
@@ -1207,13 +1207,13 @@ function Vt(n, t) {
1207
1207
  throw new Error("illegal attachments");
1208
1208
  } else if (Array.isArray(n))
1209
1209
  for (let e = 0; e < n.length; e++)
1210
- n[e] = Vt(n[e], t);
1210
+ n[e] = Yt(n[e], t);
1211
1211
  else if (typeof n == "object")
1212
1212
  for (const e in n)
1213
- Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Vt(n[e], t));
1213
+ Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Yt(n[e], t));
1214
1214
  return n;
1215
1215
  }
1216
- const Gs = [
1216
+ const Xs = [
1217
1217
  "connect",
1218
1218
  // used on the client side
1219
1219
  "connect_error",
@@ -1231,7 +1231,7 @@ var g;
1231
1231
  (function(n) {
1232
1232
  n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
1233
1233
  })(g || (g = {}));
1234
- class Vs {
1234
+ class Qs {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,7 +1247,7 @@ class Vs {
1247
1247
  * @param {Object} obj - packet object
1248
1248
  */
1249
1249
  encode(t) {
1250
- return (t.type === g.EVENT || t.type === g.ACK) && Tt(t) ? this.encodeAsBinary({
1250
+ return (t.type === g.EVENT || t.type === g.ACK) && It(t) ? this.encodeAsBinary({
1251
1251
  type: t.type === g.EVENT ? g.BINARY_EVENT : g.BINARY_ACK,
1252
1252
  nsp: t.nsp,
1253
1253
  data: t.data,
@@ -1267,11 +1267,11 @@ class Vs {
1267
1267
  * a list of buffers.
1268
1268
  */
1269
1269
  encodeAsBinary(t) {
1270
- const e = Ms(t), s = this.encodeAsString(e.packet), r = e.buffers;
1270
+ const e = Ks(t), s = this.encodeAsString(e.packet), r = e.buffers;
1271
1271
  return r.unshift(s), r;
1272
1272
  }
1273
1273
  }
1274
- class fe extends E {
1274
+ class ge extends v {
1275
1275
  /**
1276
1276
  * Decoder constructor
1277
1277
  */
@@ -1293,8 +1293,8 @@ class fe extends E {
1293
1293
  throw new Error("got plaintext data when reconstructing a packet");
1294
1294
  e = this.decodeString(t);
1295
1295
  const s = e.type === g.BINARY_EVENT;
1296
- s || e.type === g.BINARY_ACK ? (e.type = s ? g.EVENT : g.ACK, this.reconstructor = new Js(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
- } else if (de(t) || t.base64)
1296
+ s || e.type === g.BINARY_ACK ? (e.type = s ? g.EVENT : g.ACK, this.reconstructor = new Zs(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
+ } else if (me(t) || t.base64)
1298
1298
  if (this.reconstructor)
1299
1299
  e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
1300
1300
  else
@@ -1322,12 +1322,12 @@ class fe extends E {
1322
1322
  const o = t.substring(i, e);
1323
1323
  if (o != Number(o) || t.charAt(e) !== "-")
1324
1324
  throw new Error("Illegal attachments");
1325
- const h = Number(o);
1326
- if (!Ys(h) || h < 0)
1325
+ const c = Number(o);
1326
+ if (!tn(c) || c < 0)
1327
1327
  throw new Error("Illegal attachments");
1328
- if (h > this.opts.maxAttachments)
1328
+ if (c > this.opts.maxAttachments)
1329
1329
  throw new Error("too many attachments");
1330
- s.attachments = h;
1330
+ s.attachments = c;
1331
1331
  }
1332
1332
  if (t.charAt(e + 1) === "/") {
1333
1333
  const i = e + 1;
@@ -1352,7 +1352,7 @@ class fe extends E {
1352
1352
  }
1353
1353
  if (t.charAt(++e)) {
1354
1354
  const i = this.tryParse(t.substr(e));
1355
- if (fe.isPayloadValid(s.type, i))
1355
+ if (ge.isPayloadValid(s.type, i))
1356
1356
  s.data = i;
1357
1357
  else
1358
1358
  throw new Error("invalid payload");
@@ -1369,14 +1369,14 @@ class fe extends E {
1369
1369
  static isPayloadValid(t, e) {
1370
1370
  switch (t) {
1371
1371
  case g.CONNECT:
1372
- return ve(e);
1372
+ return Oe(e);
1373
1373
  case g.DISCONNECT:
1374
1374
  return e === void 0;
1375
1375
  case g.CONNECT_ERROR:
1376
- return typeof e == "string" || ve(e);
1376
+ return typeof e == "string" || Oe(e);
1377
1377
  case g.EVENT:
1378
1378
  case g.BINARY_EVENT:
1379
- return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Gs.indexOf(e[0]) === -1);
1379
+ return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Xs.indexOf(e[0]) === -1);
1380
1380
  case g.ACK:
1381
1381
  case g.BINARY_ACK:
1382
1382
  return Array.isArray(e);
@@ -1389,7 +1389,7 @@ class fe extends E {
1389
1389
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1390
1390
  }
1391
1391
  }
1392
- class Js {
1392
+ class Zs {
1393
1393
  constructor(t) {
1394
1394
  this.packet = t, this.buffers = [], this.reconPack = t;
1395
1395
  }
@@ -1403,7 +1403,7 @@ class Js {
1403
1403
  */
1404
1404
  takeBinaryData(t) {
1405
1405
  if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1406
- const e = Hs(this.reconPack, this.buffers);
1406
+ const e = zs(this.reconPack, this.buffers);
1407
1407
  return this.finishedReconstruction(), e;
1408
1408
  }
1409
1409
  return null;
@@ -1415,16 +1415,16 @@ class Js {
1415
1415
  this.reconPack = null, this.buffers = [];
1416
1416
  }
1417
1417
  }
1418
- const Ys = Number.isInteger || function(n) {
1418
+ const tn = Number.isInteger || function(n) {
1419
1419
  return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1420
1420
  };
1421
- function ve(n) {
1421
+ function Oe(n) {
1422
1422
  return Object.prototype.toString.call(n) === "[object Object]";
1423
1423
  }
1424
- const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1424
+ const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1425
1425
  __proto__: null,
1426
- Decoder: fe,
1427
- Encoder: Vs,
1426
+ Decoder: ge,
1427
+ Encoder: Qs,
1428
1428
  get PacketType() {
1429
1429
  return g;
1430
1430
  }
@@ -1434,7 +1434,7 @@ function $(n, t, e) {
1434
1434
  n.off(t, e);
1435
1435
  };
1436
1436
  }
1437
- const Ks = Object.freeze({
1437
+ const sn = Object.freeze({
1438
1438
  connect: 1,
1439
1439
  connect_error: 1,
1440
1440
  disconnect: 1,
@@ -1443,7 +1443,7 @@ const Ks = Object.freeze({
1443
1443
  newListener: 1,
1444
1444
  removeListener: 1
1445
1445
  });
1446
- class Me extends E {
1446
+ class We extends v {
1447
1447
  /**
1448
1448
  * `Socket` constructor.
1449
1449
  */
@@ -1559,7 +1559,7 @@ class Me extends E {
1559
1559
  */
1560
1560
  emit(t, ...e) {
1561
1561
  var s, r, i;
1562
- if (Ks.hasOwnProperty(t))
1562
+ if (sn.hasOwnProperty(t))
1563
1563
  throw new Error('"' + t.toString() + '" is a reserved event name');
1564
1564
  if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1565
1565
  return this._addToQueue(e), this;
@@ -1568,11 +1568,11 @@ class Me extends E {
1568
1568
  data: e
1569
1569
  };
1570
1570
  if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
1571
- const p = this.ids++, w = e.pop();
1572
- this._registerAckCallback(p, w), o.id = p;
1571
+ const y = this.ids++, w = e.pop();
1572
+ this._registerAckCallback(y, w), o.id = y;
1573
1573
  }
1574
- const h = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, u = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
1575
- return this.flags.volatile && !h || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1574
+ const c = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, u = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
1575
+ return this.flags.volatile && !c || (u ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1576
1576
  }
1577
1577
  /**
1578
1578
  * @private
@@ -1586,11 +1586,11 @@ class Me extends E {
1586
1586
  }
1587
1587
  const i = this.io.setTimeoutFn(() => {
1588
1588
  delete this.acks[t];
1589
- for (let h = 0; h < this.sendBuffer.length; h++)
1590
- this.sendBuffer[h].id === t && this.sendBuffer.splice(h, 1);
1589
+ for (let c = 0; c < this.sendBuffer.length; c++)
1590
+ this.sendBuffer[c].id === t && this.sendBuffer.splice(c, 1);
1591
1591
  e.call(this, new Error("operation has timed out"));
1592
- }, r), o = (...h) => {
1593
- this.io.clearTimeoutFn(i), e.apply(this, h);
1592
+ }, r), o = (...c) => {
1593
+ this.io.clearTimeoutFn(i), e.apply(this, c);
1594
1594
  };
1595
1595
  o.withError = !0, this.acks[t] = o;
1596
1596
  }
@@ -1612,7 +1612,7 @@ class Me extends E {
1612
1612
  */
1613
1613
  emitWithAck(t, ...e) {
1614
1614
  return new Promise((s, r) => {
1615
- const i = (o, h) => o ? r(o) : s(h);
1615
+ const i = (o, c) => o ? r(o) : s(c);
1616
1616
  i.withError = !0, e.push(i), this.emit(t, ...e);
1617
1617
  });
1618
1618
  }
@@ -2035,10 +2035,10 @@ class Me extends E {
2035
2035
  }
2036
2036
  }
2037
2037
  }
2038
- function rt(n) {
2038
+ function ct(n) {
2039
2039
  n = n || {}, this.ms = n.min || 100, this.max = n.max || 1e4, this.factor = n.factor || 2, this.jitter = n.jitter > 0 && n.jitter <= 1 ? n.jitter : 0, this.attempts = 0;
2040
2040
  }
2041
- rt.prototype.duration = function() {
2041
+ ct.prototype.duration = function() {
2042
2042
  var n = this.ms * Math.pow(this.factor, this.attempts++);
2043
2043
  if (this.jitter) {
2044
2044
  var t = Math.random(), e = Math.floor(t * this.jitter * n);
@@ -2046,27 +2046,27 @@ rt.prototype.duration = function() {
2046
2046
  }
2047
2047
  return Math.min(n, this.max) | 0;
2048
2048
  };
2049
- rt.prototype.reset = function() {
2049
+ ct.prototype.reset = function() {
2050
2050
  this.attempts = 0;
2051
2051
  };
2052
- rt.prototype.setMin = function(n) {
2052
+ ct.prototype.setMin = function(n) {
2053
2053
  this.ms = n;
2054
2054
  };
2055
- rt.prototype.setMax = function(n) {
2055
+ ct.prototype.setMax = function(n) {
2056
2056
  this.max = n;
2057
2057
  };
2058
- rt.prototype.setJitter = function(n) {
2058
+ ct.prototype.setJitter = function(n) {
2059
2059
  this.jitter = n;
2060
2060
  };
2061
- class Jt extends E {
2061
+ class Wt extends v {
2062
2062
  constructor(t, e) {
2063
2063
  var s;
2064
- super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Nt(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new rt({
2064
+ super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, Bt(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((s = e.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new ct({
2065
2065
  min: this.reconnectionDelay(),
2066
2066
  max: this.reconnectionDelayMax(),
2067
2067
  jitter: this.randomizationFactor()
2068
2068
  }), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
2069
- const r = e.parser || Ws;
2069
+ const r = e.parser || en;
2070
2070
  this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2071
2071
  }
2072
2072
  reconnection(t) {
@@ -2109,18 +2109,18 @@ class Jt extends E {
2109
2109
  open(t) {
2110
2110
  if (~this._readyState.indexOf("open"))
2111
2111
  return this;
2112
- this.engine = new Ls(this.uri, this.opts);
2112
+ this.engine = new Hs(this.uri, this.opts);
2113
2113
  const e = this.engine, s = this;
2114
2114
  this._readyState = "opening", this.skipReconnect = !1;
2115
2115
  const r = $(e, "open", function() {
2116
2116
  s.onopen(), t && t();
2117
- }), i = (h) => {
2118
- this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), t ? t(h) : this.maybeReconnectOnOpen();
2117
+ }), i = (c) => {
2118
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", c), t ? t(c) : this.maybeReconnectOnOpen();
2119
2119
  }, o = $(e, "error", i);
2120
2120
  if (this._timeout !== !1) {
2121
- const h = this._timeout, u = this.setTimeoutFn(() => {
2121
+ const c = this._timeout, u = this.setTimeoutFn(() => {
2122
2122
  r(), i(new Error("timeout")), e.close();
2123
- }, h);
2123
+ }, c);
2124
2124
  this.opts.autoUnref && u.unref(), this.subs.push(() => {
2125
2125
  this.clearTimeoutFn(u);
2126
2126
  });
@@ -2179,7 +2179,7 @@ class Jt extends E {
2179
2179
  * @private
2180
2180
  */
2181
2181
  ondecoded(t) {
2182
- Rt(() => {
2182
+ Pt(() => {
2183
2183
  this.emitReserved("packet", t);
2184
2184
  }, this.setTimeoutFn);
2185
2185
  }
@@ -2199,7 +2199,7 @@ class Jt extends E {
2199
2199
  */
2200
2200
  socket(t, e) {
2201
2201
  let s = this.nsps[t];
2202
- return s ? this._autoConnect && !s.active && s.connect() : (s = new Me(this, t, e), this.nsps[t] = s), s;
2202
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new We(this, t, e), this.nsps[t] = s), s;
2203
2203
  }
2204
2204
  /**
2205
2205
  * Called upon a socket close.
@@ -2296,99 +2296,204 @@ class Jt extends E {
2296
2296
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2297
2297
  }
2298
2298
  }
2299
- const it = {};
2300
- function ut(n, t) {
2299
+ const ht = {};
2300
+ function pt(n, t) {
2301
2301
  typeof n == "object" && (t = n, n = void 0), t = t || {};
2302
- const e = qs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = it[r] && i in it[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2302
+ const e = Gs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = ht[r] && i in ht[r].nsps, c = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2303
2303
  let u;
2304
- return h ? u = new Jt(s, t) : (it[r] || (it[r] = new Jt(s, t)), u = it[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
2304
+ return c ? u = new Wt(s, t) : (ht[r] || (ht[r] = new Wt(s, t)), u = ht[r]), e.query && !t.query && (t.query = e.queryKey), u.socket(e.path, t);
2305
2305
  }
2306
- Object.assign(ut, {
2307
- Manager: Jt,
2308
- Socket: Me,
2309
- io: ut,
2310
- connect: ut
2306
+ Object.assign(pt, {
2307
+ Manager: Wt,
2308
+ Socket: We,
2309
+ io: pt,
2310
+ connect: pt
2311
2311
  });
2312
- class Te extends Error {
2312
+ const Kt = "thatopen/document@1", Ie = "document.json", Ae = () => `v-${Date.now()}`;
2313
+ function nn(n) {
2314
+ return String(n._id ?? n.id ?? "");
2315
+ }
2316
+ var yt, zt;
2317
+ class Ke {
2318
+ constructor(t, e) {
2319
+ b(this, yt);
2320
+ this.client = t, this.projectId = e;
2321
+ }
2322
+ /**
2323
+ * The document's descriptor, read and validated, or null when the folder
2324
+ * has none yet (an old folder, or a plain folder that is not a document).
2325
+ */
2326
+ async descriptor(t) {
2327
+ const e = await a(this, yt, zt).call(this, t);
2328
+ if (!e) return null;
2329
+ const r = await (await this.client.downloadFile(e.id)).text();
2330
+ if (!r.trim()) return null;
2331
+ let i;
2332
+ try {
2333
+ i = JSON.parse(r);
2334
+ } catch {
2335
+ return null;
2336
+ }
2337
+ return rn(i);
2338
+ }
2339
+ /**
2340
+ * The first view whose format appears in `formats` — searched in the ORDER
2341
+ * OF THE LIST, so the caller's preference wins (ask `['frag', 'ifc']` and a
2342
+ * document carrying both answers the frag). Null when none matches: that is
2343
+ * where an interface offers "Process".
2344
+ */
2345
+ async view(t, e) {
2346
+ const s = await this.descriptor(t);
2347
+ if (!s) return null;
2348
+ for (const r of e) {
2349
+ const i = s.views.find((o) => o.format === r);
2350
+ if (i) return i;
2351
+ }
2352
+ return null;
2353
+ }
2354
+ /**
2355
+ * Registers a renderable representation — a processor's last act. One view
2356
+ * per format: an existing view of the same format is replaced (a re-run
2357
+ * processor updates, it does not accumulate). The descriptor must exist;
2358
+ * create it first with {@link setDescriptor}.
2359
+ */
2360
+ async addView(t, e) {
2361
+ const s = await this.descriptor(t);
2362
+ if (!s)
2363
+ throw new Error(
2364
+ "This folder has no document descriptor yet: call setDescriptor first."
2365
+ );
2366
+ s.views = [
2367
+ ...s.views.filter((r) => r.format !== e.format),
2368
+ e
2369
+ ], await this.setDescriptor(t, s);
2370
+ }
2371
+ /** Writes the descriptor, creating or replacing `document.json`. */
2372
+ async setDescriptor(t, e) {
2373
+ const s = {
2374
+ ...e,
2375
+ schema: Kt,
2376
+ views: e.views ?? []
2377
+ }, r = new Blob([JSON.stringify(s)], {
2378
+ type: "application/json"
2379
+ }), i = await a(this, yt, zt).call(this, t);
2380
+ if (i) {
2381
+ await this.client.updateFile(i.id, {
2382
+ file: r,
2383
+ versionTag: Ae()
2384
+ });
2385
+ return;
2386
+ }
2387
+ await this.client.createFile({
2388
+ file: r,
2389
+ name: Ie,
2390
+ versionTag: Ae(),
2391
+ parentFolderId: t,
2392
+ projectId: this.projectId
2393
+ });
2394
+ }
2395
+ }
2396
+ yt = new WeakSet(), zt = async function(t) {
2397
+ const s = (await this.client.listFiles({ folderId: t })).find(
2398
+ (r) => String(r.name ?? "") === Ie
2399
+ );
2400
+ return s ? { id: nn(s) } : void 0;
2401
+ };
2402
+ function rn(n) {
2403
+ if (!n || typeof n != "object") return null;
2404
+ const t = n;
2405
+ if (t.schema !== Kt || typeof t.name != "string") return null;
2406
+ const e = Array.isArray(t.views) ? t.views.filter(
2407
+ (i) => !!i && typeof i == "object" && typeof i.fileId == "string" && typeof i.format == "string"
2408
+ ) : [], s = t.native, r = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string";
2409
+ return {
2410
+ schema: Kt,
2411
+ name: t.name,
2412
+ ...r ? { native: { fileId: s.fileId, format: s.format } } : {},
2413
+ views: e
2414
+ };
2415
+ }
2416
+ class xe extends Error {
2313
2417
  constructor(t, e) {
2314
2418
  super(
2315
2419
  `The document history advanced while this version was being prepared: expected head ${t}, found ${e ?? "none"}. Read the timeline again and rebuild on the new head.`
2316
2420
  ), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
2317
2421
  }
2318
2422
  }
2319
- const Se = "bimterop", Yt = "revitflow_history.json", z = "revitflow_ops.json", ke = "revitflow/ops@1", He = "revitflow_model.frag", Ge = "revitflow_", _t = () => `v-${Date.now()}`;
2320
- function Ve(n, t) {
2423
+ const $e = "bimterop", Xt = "revitflow_history.json", Q = "revitflow_ops.json", Ce = "revitflow/ops@1", ze = "revitflow_model.frag", Xe = "revitflow_", on = "bimterop-locks-anchor", St = () => `v-${Date.now()}`;
2424
+ function Qe(n, t) {
2321
2425
  return n.filter((e) => String(e.parentId ?? "") === t);
2322
2426
  }
2323
- function j(n) {
2427
+ function N(n) {
2324
2428
  return String(n._id ?? n.id ?? "");
2325
2429
  }
2326
- var x, dt, Wt;
2327
- class Xs {
2430
+ var x, mt, Qt;
2431
+ class an {
2328
2432
  constructor(t, e) {
2329
- b(this, dt);
2433
+ b(this, mt);
2330
2434
  b(this, x);
2331
2435
  this.client = t, this.projectId = e;
2332
2436
  }
2333
2437
  /** The project's connected documents. */
2334
2438
  async docs() {
2335
- const t = await a(this, dt, Wt).call(this);
2439
+ const t = await a(this, mt, Qt).call(this);
2336
2440
  if (!t) return [];
2337
2441
  const e = await this.client.listFolders({
2338
2442
  parentFolderId: t,
2339
2443
  projectId: this.projectId
2340
2444
  }), s = [];
2341
- for (const r of Ve(e, t)) {
2445
+ for (const r of Qe(e, t)) {
2342
2446
  const i = String(r.name ?? ""), o = i.indexOf("-");
2343
2447
  if (o <= 0) continue;
2344
2448
  const u = (await this.client.listFiles({
2345
- folderId: j(r)
2449
+ folderId: N(r)
2346
2450
  })).map(
2347
2451
  (w) => String(w.name ?? "")
2348
- ), f = u.find((w) => w === He) ?? u.find(
2349
- (w) => w.endsWith(".frag") && !w.startsWith(Ge)
2350
- ), p = u.includes(Yt) || u.includes(z) || !!f;
2452
+ ), f = u.find((w) => w === ze) ?? u.find(
2453
+ (w) => w.endsWith(".frag") && !w.startsWith(Xe)
2454
+ ), y = u.includes(Xt) || u.includes(Q) || !!f;
2351
2455
  s.push({
2352
2456
  source: i.slice(0, o),
2353
2457
  docId: i.slice(o + 1),
2458
+ folderId: N(r),
2354
2459
  modelName: f,
2355
- ...p ? {} : { empty: !0 }
2460
+ ...y ? {} : { empty: !0 }
2356
2461
  });
2357
2462
  }
2358
2463
  return s;
2359
2464
  }
2360
2465
  /** One document's history. `source` and `docId` as {@link docs} lists them. */
2361
2466
  doc(t, e) {
2362
- return new zs(this.client, this, t, e);
2467
+ return new cn(this.client, this, t, e);
2363
2468
  }
2364
2469
  /** @internal The `bimterop` folder id, resolved once. */
2365
2470
  async rootFolderId(t = !1) {
2366
2471
  if (l(this, x)) return l(this, x);
2367
- const e = await a(this, dt, Wt).call(this);
2472
+ const e = await a(this, mt, Qt).call(this);
2368
2473
  if (e) return e;
2369
2474
  if (!t) return;
2370
2475
  const s = await this.client.createFolder(
2371
- Se,
2476
+ $e,
2372
2477
  void 0,
2373
2478
  this.projectId
2374
2479
  );
2375
- return _(this, x, j(s)), l(this, x);
2480
+ return _(this, x, N(s)), l(this, x);
2376
2481
  }
2377
2482
  }
2378
- x = new WeakMap(), dt = new WeakSet(), Wt = async function() {
2483
+ x = new WeakMap(), mt = new WeakSet(), Qt = async function() {
2379
2484
  if (l(this, x)) return l(this, x);
2380
2485
  const e = (await this.client.listFolders({
2381
2486
  projectId: this.projectId
2382
2487
  })).find(
2383
- (s) => String(s.name ?? "") === Se && !s.parentId
2488
+ (s) => String(s.name ?? "") === $e && !s.parentId
2384
2489
  );
2385
- return e && _(this, x, j(e)), l(this, x);
2490
+ return e && _(this, x, N(e)), l(this, x);
2386
2491
  };
2387
- var L, y, at, ct, Kt, St, kt, Xt, Ot, ht, At, zt, Je;
2388
- class zs {
2492
+ var q, d, Z, tt, F, Zt, ut, et, te, At, dt, xt, ee, Ze;
2493
+ class cn {
2389
2494
  constructor(t, e, s, r) {
2390
- b(this, y);
2391
- b(this, L);
2495
+ b(this, d);
2496
+ b(this, q);
2392
2497
  this.client = t, this.project = e, this.source = s, this.docId = r;
2393
2498
  }
2394
2499
  // ─── Reading ───────────────────────────────────────────────────────────────
@@ -2398,8 +2503,8 @@ class zs {
2398
2503
  * Each version gets its `ordinal` filled in.
2399
2504
  */
2400
2505
  async timeline() {
2401
- const t = await a(this, y, Ot).call(this);
2402
- return Ye((t == null ? void 0 : t.commits) ?? []);
2506
+ const t = await a(this, d, At).call(this);
2507
+ return ts((t == null ? void 0 : t.commits) ?? []);
2403
2508
  }
2404
2509
  /** The head of the timeline, or null before the first sync. */
2405
2510
  async latest() {
@@ -2419,13 +2524,97 @@ class zs {
2419
2524
  }
2420
2525
  /** The visible model .frag as last fully exported. */
2421
2526
  async model() {
2422
- const t = await a(this, y, kt).call(this);
2527
+ const t = await a(this, d, et).call(this);
2423
2528
  if (!t)
2424
2529
  throw new Error(
2425
2530
  `Document ${this.source}-${this.docId} has no model file yet.`
2426
2531
  );
2427
2532
  return await (await this.client.downloadFile(t.id)).blob();
2428
2533
  }
2534
+ /** The document folder's item id — the id the CDE knows this document by. */
2535
+ async folderId() {
2536
+ return await a(this, d, F).call(this, !1);
2537
+ }
2538
+ // ─── The document descriptor ───────────────────────────────────────────────
2539
+ /**
2540
+ * The document descriptor (`document.json`), or null when the folder does
2541
+ * not carry one yet — an old folder from before descriptors existed.
2542
+ */
2543
+ async descriptor() {
2544
+ return await l(this, d, Z).descriptor(await a(this, d, F).call(this, !1));
2545
+ }
2546
+ /**
2547
+ * The first view whose format appears in `formats`, searched in the order
2548
+ * of the list (the caller's preference wins). Falls back to the visible
2549
+ * model .frag on a descriptor-less folder, so old documents keep viewing.
2550
+ */
2551
+ async view(t) {
2552
+ const e = await a(this, d, F).call(this, !1), s = await l(this, d, Z).descriptor(e);
2553
+ if (s) {
2554
+ for (const i of t) {
2555
+ const o = s.views.find((c) => c.format === i);
2556
+ if (o) return o;
2557
+ }
2558
+ return null;
2559
+ }
2560
+ if (!t.includes("frag")) return null;
2561
+ const r = await a(this, d, et).call(this);
2562
+ return r ? { fileId: r.id, format: "frag" } : null;
2563
+ }
2564
+ /**
2565
+ * Registers a renderable representation, creating the descriptor when the
2566
+ * folder predates them (named after the model file, or the folder itself).
2567
+ * One view per format: a same-format view is replaced, not accumulated.
2568
+ */
2569
+ async addView(t) {
2570
+ const e = await a(this, d, F).call(this, !0);
2571
+ if (await l(this, d, Z).descriptor(e)) {
2572
+ await l(this, d, Z).addView(e, t);
2573
+ return;
2574
+ }
2575
+ const r = await a(this, d, et).call(this);
2576
+ await l(this, d, Z).setDescriptor(e, {
2577
+ name: (r == null ? void 0 : r.name.replace(/\.frag$/, "")) ?? l(this, d, tt),
2578
+ views: [t]
2579
+ });
2580
+ }
2581
+ // ─── Ownership (element locks) ─────────────────────────────────────────────
2582
+ /**
2583
+ * Who currently holds which elements, read from the lock registry the
2584
+ * native plugins arbitrate through. Read-only: claiming and releasing stay
2585
+ * with the plugins. Empty when nobody holds anything (or the document has
2586
+ * no lock anchor yet). Arbitration is applied: a key contested by two
2587
+ * claims counts only for the earliest one, matching the plugins' rule.
2588
+ */
2589
+ async ownership() {
2590
+ const t = await a(this, d, ut).call(this, on);
2591
+ if (!t) return [];
2592
+ const e = await this.client.getHiddenFilesByParent(t.id), s = await Promise.all(
2593
+ e.map(async (o) => {
2594
+ try {
2595
+ const c = N(o), u = await this.client.downloadHiddenFile(c), f = JSON.parse(await u.text());
2596
+ return !f || typeof f != "object" || !("revitflowlock" in f) || !Array.isArray(f.keys) ? null : {
2597
+ owner: String(f.user ?? ""),
2598
+ keys: f.keys.filter((y) => typeof y == "string")
2599
+ };
2600
+ } catch {
2601
+ return null;
2602
+ }
2603
+ })
2604
+ ), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
2605
+ for (const o of s)
2606
+ if (o)
2607
+ for (const c of o.keys) {
2608
+ if (!c || r.has(c)) continue;
2609
+ r.add(c);
2610
+ const u = i.get(o.owner) ?? [];
2611
+ u.push(c), i.set(o.owner, u);
2612
+ }
2613
+ return [...i.entries()].map(([o, c]) => ({
2614
+ owner: o,
2615
+ elements: c
2616
+ }));
2617
+ }
2429
2618
  // ─── Writing versions ─────────────────────────────────────────────────────
2430
2619
  /**
2431
2620
  * Appends one version: uploads the geometry it carries, then the updated
@@ -2434,29 +2623,29 @@ class zs {
2434
2623
  * silent fork.
2435
2624
  */
2436
2625
  async sync(t) {
2437
- var h;
2438
- const e = await a(this, y, ct).call(this, !0);
2439
- let s = await a(this, y, Ot).call(this) ?? {
2626
+ var c;
2627
+ const e = await a(this, d, F).call(this, !0);
2628
+ let s = await a(this, d, At).call(this) ?? {
2440
2629
  model: this.docId,
2441
2630
  commits: []
2442
2631
  };
2443
- const r = Oe(s.commits);
2632
+ const r = Re(s.commits);
2444
2633
  if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
2445
- throw new Te(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2634
+ throw new xe(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2446
2635
  const i = {
2447
- guid: Qt(),
2636
+ guid: se(),
2448
2637
  ...r ? { parents: [r.guid] } : {},
2449
2638
  author: t.author,
2450
2639
  source: t.source,
2451
2640
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2452
2641
  ...t.message ? { message: t.message } : {},
2453
2642
  ...t.userId ? { userId: t.userId } : {},
2454
- ...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
2643
+ ...(c = t.appliedOps) != null && c.length ? { appliedOps: t.appliedOps } : {},
2455
2644
  changes: t.changes,
2456
- counts: Qs(t.changes)
2645
+ counts: hn(t.changes)
2457
2646
  };
2458
- if (t.model && (await a(this, y, Je).call(this, e, t.model), i.full = !0), t.delta) {
2459
- const u = await a(this, y, kt).call(this);
2647
+ if (t.model && (await a(this, d, Ze).call(this, e, t.model), i.full = !0), t.delta) {
2648
+ const u = await a(this, d, et).call(this);
2460
2649
  if (!u)
2461
2650
  throw new Error(
2462
2651
  "A delta needs the model file to hang from: sync a full model first."
@@ -2469,20 +2658,20 @@ class zs {
2469
2658
  f._id ?? f.id
2470
2659
  );
2471
2660
  }
2472
- const o = await a(this, y, Ot).call(this);
2661
+ const o = await a(this, d, At).call(this);
2473
2662
  if (o) {
2474
2663
  s = o;
2475
- const u = Oe(s.commits);
2664
+ const u = Re(s.commits);
2476
2665
  if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
2477
- throw new Te(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2666
+ throw new xe(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2478
2667
  u && !i.parents && (i.parents = [u.guid]);
2479
2668
  }
2480
- return s.commits.push(i), await a(this, y, At).call(this, e, Yt, s), i;
2669
+ return s.commits.push(i), await a(this, d, xt).call(this, e, Xt, s), i;
2481
2670
  }
2482
2671
  // ─── Suggestions (change requests) ────────────────────────────────────────
2483
2672
  /** Every suggestion in the document's queue, pending or resolved. */
2484
2673
  async suggestions() {
2485
- const t = await a(this, y, ht).call(this);
2674
+ const t = await a(this, d, dt).call(this);
2486
2675
  return (t == null ? void 0 : t.ops) ?? [];
2487
2676
  }
2488
2677
  /** The suggestions still waiting for the owner, oldest first. */
@@ -2494,8 +2683,9 @@ class zs {
2494
2683
  * uploaded as a hidden file under the suggestions index.
2495
2684
  */
2496
2685
  async suggest(t) {
2497
- const e = await a(this, y, ct).call(this, !0), s = await a(this, y, ht).call(this) ?? { schema: ke, ops: [] }, r = await a(this, y, St).call(this, z), i = {
2498
- opId: t.opId ?? Qt(),
2686
+ const e = await a(this, d, F).call(this, !0), s = await a(this, d, dt).call(this) ?? { schema: Ce, ops: [] }, r = await a(this, d, ut).call(this, Q), i = {
2687
+ opId: t.opId ?? se(),
2688
+ to: t.to ?? this.source,
2499
2689
  title: t.title,
2500
2690
  verb: t.verb,
2501
2691
  author: t.author,
@@ -2507,16 +2697,16 @@ class zs {
2507
2697
  ...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
2508
2698
  };
2509
2699
  if (t.payload) {
2510
- const h = r ?? await a(this, y, zt).call(this, e, z, s), u = await this.client.createHiddenFile(
2700
+ const c = r ?? await a(this, d, ee).call(this, e, Q, s), u = await this.client.createHiddenFile(
2511
2701
  t.payload,
2512
- h.id
2702
+ c.id
2513
2703
  );
2514
2704
  i.fragId = String(
2515
2705
  u._id ?? u.id
2516
2706
  );
2517
2707
  }
2518
- const o = await a(this, y, ht).call(this) ?? s;
2519
- return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this, y, At).call(this, e, z, o), i;
2708
+ const o = await a(this, d, dt).call(this) ?? s;
2709
+ return o.schema ?? (o.schema = Ce), o.ops.push(i), await a(this, d, xt).call(this, e, Q, o), i;
2520
2710
  }
2521
2711
  /** A suggestion's .frag payload. */
2522
2712
  async suggestionPayload(t) {
@@ -2530,18 +2720,20 @@ class zs {
2530
2720
  * use it for `discarded`.
2531
2721
  */
2532
2722
  async resolveSuggestion(t, e) {
2533
- const s = await a(this, y, ct).call(this, !1);
2723
+ const s = await a(this, d, F).call(this, !1);
2534
2724
  if (!s) throw new Error("This document has no suggestion queue.");
2535
- const r = await a(this, y, ht).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
2725
+ const r = await a(this, d, dt).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === t);
2536
2726
  if (!r || !i)
2537
2727
  throw new Error(`No suggestion ${t} in this document's queue.`);
2538
- return Object.assign(i, e), await a(this, y, At).call(this, s, z, r), i;
2728
+ return Object.assign(i, e), await a(this, d, xt).call(this, s, Q, r), i;
2539
2729
  }
2540
2730
  }
2541
- L = new WeakMap(), y = new WeakSet(), at = function() {
2731
+ q = new WeakMap(), d = new WeakSet(), Z = function() {
2732
+ return new Ke(this.client, this.project.projectId);
2733
+ }, tt = function() {
2542
2734
  return `${this.source}-${this.docId}`;
2543
- }, ct = async function(t) {
2544
- if (l(this, L)) return l(this, L);
2735
+ }, F = async function(t) {
2736
+ if (l(this, q)) return l(this, q);
2545
2737
  const e = await this.project.rootFolderId(t);
2546
2738
  if (!e)
2547
2739
  throw new Error(
@@ -2550,153 +2742,153 @@ L = new WeakMap(), y = new WeakSet(), at = function() {
2550
2742
  const s = await this.client.listFolders({
2551
2743
  parentFolderId: e,
2552
2744
  projectId: this.project.projectId
2553
- }), r = Ve(s, e).find(
2554
- (o) => String(o.name ?? "") === l(this, y, at)
2745
+ }), r = Qe(s, e).find(
2746
+ (o) => String(o.name ?? "") === l(this, d, tt)
2555
2747
  );
2556
2748
  if (r)
2557
- return _(this, L, j(r)), l(this, L);
2749
+ return _(this, q, N(r)), l(this, q);
2558
2750
  if (!t)
2559
2751
  throw new Error(
2560
- `Document ${l(this, y, at)} does not exist in this project.`
2752
+ `Document ${l(this, d, tt)} does not exist in this project.`
2561
2753
  );
2562
2754
  const i = await this.client.createFolder(
2563
- l(this, y, at),
2755
+ l(this, d, tt),
2564
2756
  e,
2565
2757
  this.project.projectId
2566
2758
  );
2567
- return _(this, L, j(i)), l(this, L);
2568
- }, Kt = async function() {
2569
- const t = await a(this, y, ct).call(this, !1);
2759
+ return _(this, q, N(i)), l(this, q);
2760
+ }, Zt = async function() {
2761
+ const t = await a(this, d, F).call(this, !1);
2570
2762
  return (await this.client.listFiles({ folderId: t })).map((s) => ({
2571
- id: j(s),
2763
+ id: N(s),
2572
2764
  name: String(s.name ?? "")
2573
2765
  }));
2574
- }, St = async function(t) {
2766
+ }, ut = async function(t) {
2575
2767
  try {
2576
- return (await a(this, y, Kt).call(this)).find((e) => e.name === t);
2768
+ return (await a(this, d, Zt).call(this)).find((e) => e.name === t);
2577
2769
  } catch {
2578
2770
  return;
2579
2771
  }
2580
- }, kt = async function() {
2772
+ }, et = async function() {
2581
2773
  try {
2582
- const t = await a(this, y, Kt).call(this);
2583
- return t.find((e) => e.name === He) ?? t.find(
2584
- (e) => e.name.endsWith(".frag") && !e.name.startsWith(Ge)
2774
+ const t = await a(this, d, Zt).call(this);
2775
+ return t.find((e) => e.name === ze) ?? t.find(
2776
+ (e) => e.name.endsWith(".frag") && !e.name.startsWith(Xe)
2585
2777
  );
2586
2778
  } catch {
2587
2779
  return;
2588
2780
  }
2589
- }, Xt = async function(t) {
2590
- const e = await a(this, y, St).call(this, t);
2781
+ }, te = async function(t) {
2782
+ const e = await a(this, d, ut).call(this, t);
2591
2783
  if (!e) return;
2592
2784
  const r = await (await this.client.downloadFile(e.id)).text();
2593
2785
  if (r.trim())
2594
2786
  return JSON.parse(r);
2595
- }, Ot = function() {
2596
- return a(this, y, Xt).call(this, Yt);
2597
- }, ht = function() {
2598
- return a(this, y, Xt).call(this, z);
2599
- }, At = async function(t, e, s) {
2787
+ }, At = function() {
2788
+ return a(this, d, te).call(this, Xt);
2789
+ }, dt = function() {
2790
+ return a(this, d, te).call(this, Q);
2791
+ }, xt = async function(t, e, s) {
2600
2792
  const r = new Blob([JSON.stringify(s)], {
2601
2793
  type: "application/json"
2602
- }), i = await a(this, y, St).call(this, e);
2794
+ }), i = await a(this, d, ut).call(this, e);
2603
2795
  return i ? (await this.client.updateFile(i.id, {
2604
2796
  file: r,
2605
- versionTag: _t()
2606
- }), i) : await a(this, y, zt).call(this, t, e, s);
2607
- }, zt = async function(t, e, s) {
2797
+ versionTag: St()
2798
+ }), i) : await a(this, d, ee).call(this, t, e, s);
2799
+ }, ee = async function(t, e, s) {
2608
2800
  const r = new Blob([JSON.stringify(s)], {
2609
2801
  type: "application/json"
2610
2802
  }), i = await this.client.createFile({
2611
2803
  file: r,
2612
2804
  name: e,
2613
- versionTag: _t(),
2805
+ versionTag: St(),
2614
2806
  parentFolderId: t,
2615
2807
  projectId: this.project.projectId
2616
2808
  }), o = i.item;
2617
- return { id: j(o ?? i), name: e };
2618
- }, Je = async function(t, e) {
2619
- const s = await a(this, y, kt).call(this);
2809
+ return { id: N(o ?? i), name: e };
2810
+ }, Ze = async function(t, e) {
2811
+ const s = await a(this, d, et).call(this);
2620
2812
  if (s)
2621
2813
  return await this.client.updateFile(s.id, {
2622
2814
  file: e,
2623
- versionTag: _t()
2815
+ versionTag: St()
2624
2816
  }), s;
2625
- const r = `${l(this, y, at)}.frag`, i = await this.client.createFile({
2817
+ const r = `${l(this, d, tt)}.frag`, i = await this.client.createFile({
2626
2818
  file: e,
2627
2819
  name: r,
2628
- versionTag: _t(),
2820
+ versionTag: St(),
2629
2821
  parentFolderId: t,
2630
2822
  projectId: this.project.projectId
2631
2823
  }), o = i.item;
2632
- return { id: j(o ?? i), name: r };
2824
+ return { id: N(o ?? i), name: r };
2633
2825
  };
2634
- function Qs(n) {
2826
+ function hn(n) {
2635
2827
  const t = { added: 0, modified: 0, removed: 0 };
2636
2828
  for (const e of n)
2637
2829
  e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
2638
2830
  return t;
2639
2831
  }
2640
- function Ye(n) {
2832
+ function ts(n) {
2641
2833
  var u;
2642
2834
  if (n.length <= 1)
2643
- return n.forEach((f, p) => f.ordinal = p), [...n];
2835
+ return n.forEach((f, y) => f.ordinal = y), [...n];
2644
2836
  const t = new Map(n.map((f) => [f.guid, f])), e = /* @__PURE__ */ new Map(), s = [];
2645
2837
  for (const f of n) {
2646
- const p = (u = f.parents) == null ? void 0 : u[0];
2647
- if (p && t.has(p)) {
2648
- const w = e.get(p) ?? [];
2649
- w.push(f), e.set(p, w);
2838
+ const y = (u = f.parents) == null ? void 0 : u[0];
2839
+ if (y && t.has(y)) {
2840
+ const w = e.get(y) ?? [];
2841
+ w.push(f), e.set(y, w);
2650
2842
  } else
2651
2843
  s.push(f);
2652
2844
  }
2653
- const r = (f, p) => String(f.timestamp).localeCompare(String(p.timestamp));
2845
+ const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
2654
2846
  s.sort(r);
2655
- const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
2847
+ const i = [], o = [...s].reverse(), c = /* @__PURE__ */ new Set();
2656
2848
  for (; o.length; ) {
2657
2849
  const f = o.pop();
2658
- if (h.has(f.guid)) continue;
2659
- h.add(f.guid), i.push(f);
2660
- const p = (e.get(f.guid) ?? []).sort(r);
2661
- for (let w = p.length - 1; w >= 0; w--) o.push(p[w]);
2850
+ if (c.has(f.guid)) continue;
2851
+ c.add(f.guid), i.push(f);
2852
+ const y = (e.get(f.guid) ?? []).sort(r);
2853
+ for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
2662
2854
  }
2663
2855
  for (const f of n)
2664
- h.has(f.guid) || i.push(f);
2665
- return i.forEach((f, p) => f.ordinal = p), i;
2856
+ c.has(f.guid) || i.push(f);
2857
+ return i.forEach((f, y) => f.ordinal = y), i;
2666
2858
  }
2667
- function Oe(n) {
2668
- const t = Ye(n);
2859
+ function Re(n) {
2860
+ const t = ts(n);
2669
2861
  return t[t.length - 1];
2670
2862
  }
2671
- function Qt() {
2863
+ function se() {
2672
2864
  const n = globalThis.crypto;
2673
2865
  return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2674
2866
  const e = Math.random() * 16 | 0;
2675
2867
  return (t === "x" ? e : e & 3 | 8).toString(16);
2676
2868
  });
2677
2869
  }
2678
- var M, ft, Zt;
2679
- class Zs {
2870
+ var H, gt, ne;
2871
+ class ln {
2680
2872
  constructor(t) {
2681
- b(this, ft);
2682
- b(this, M, /* @__PURE__ */ new Map());
2873
+ b(this, gt);
2874
+ b(this, H, /* @__PURE__ */ new Map());
2683
2875
  this.client = t;
2684
2876
  }
2685
2877
  /** Registers a recipe. One per name; a second with the same name throws. */
2686
2878
  register(t) {
2687
- if (l(this, M).has(t.name))
2879
+ if (l(this, H).has(t.name))
2688
2880
  throw new Error(`A recipe named "${t.name}" is already registered.`);
2689
- l(this, M).set(t.name, t);
2881
+ l(this, H).set(t.name, t);
2690
2882
  }
2691
2883
  /** The registered recipes, optionally filtered by target application. */
2692
2884
  list(t) {
2693
- return [...l(this, M).values()].filter(
2885
+ return [...l(this, H).values()].filter(
2694
2886
  (s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
2695
2887
  );
2696
2888
  }
2697
2889
  /** A registered recipe by name, or undefined. */
2698
2890
  get(t) {
2699
- return l(this, M).get(t);
2891
+ return l(this, H).get(t);
2700
2892
  }
2701
2893
  /**
2702
2894
  * Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
@@ -2705,7 +2897,7 @@ class Zs {
2705
2897
  * included, with no second run. Discard it and the plan never happened.
2706
2898
  */
2707
2899
  async plan(t, e) {
2708
- const { base: s, opId: r, result: i } = await a(this, ft, Zt).call(this, t, e);
2900
+ const { base: s, opId: r, result: i } = await a(this, gt, ne).call(this, t, e);
2709
2901
  return {
2710
2902
  opId: r,
2711
2903
  projectId: e.projectId,
@@ -2738,7 +2930,7 @@ class Zs {
2738
2930
  * to show the tallies before queueing.
2739
2931
  */
2740
2932
  async run(t, e) {
2741
- const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft, Zt).call(this, t, e);
2933
+ const { targetDoc: s, base: r, opId: i, result: o } = await a(this, gt, ne).call(this, t, e);
2742
2934
  return { suggestion: await s.suggest({
2743
2935
  opId: i,
2744
2936
  title: o.title,
@@ -2751,14 +2943,14 @@ class Zs {
2751
2943
  }), result: o };
2752
2944
  }
2753
2945
  }
2754
- M = new WeakMap(), ft = new WeakSet(), Zt = async function(t, e) {
2755
- const s = l(this, M).get(t);
2946
+ H = new WeakMap(), gt = new WeakSet(), ne = async function(t, e) {
2947
+ const s = l(this, H).get(t);
2756
2948
  if (!s) throw new Error(`No recipe named "${t}" is registered.`);
2757
2949
  if (s.to !== e.target.source)
2758
2950
  throw new Error(
2759
2951
  `Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
2760
2952
  );
2761
- const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = Qt(), h = await s.run({
2953
+ const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = se(), c = await s.run({
2762
2954
  client: this.client,
2763
2955
  projectId: e.projectId,
2764
2956
  targetDoc: r,
@@ -2766,10 +2958,10 @@ M = new WeakMap(), ft = new WeakSet(), Zt = async function(t, e) {
2766
2958
  input: e.input,
2767
2959
  settings: e.settings ?? {}
2768
2960
  });
2769
- return { recipe: s, targetDoc: r, base: i, opId: o, result: h };
2961
+ return { recipe: s, targetDoc: r, base: i, opId: o, result: c };
2770
2962
  };
2771
- const Ae = 100;
2772
- function tn(n) {
2963
+ const Ne = 100;
2964
+ function un(n) {
2773
2965
  try {
2774
2966
  const t = JSON.parse(n);
2775
2967
  if (t && typeof t == "object") {
@@ -2784,14 +2976,14 @@ function tn(n) {
2784
2976
  }
2785
2977
  return {};
2786
2978
  }
2787
- function en(n) {
2979
+ function dn(n) {
2788
2980
  if (!n || typeof n != "object") return;
2789
2981
  const t = n.retryAfter;
2790
2982
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
2791
2983
  }
2792
- class pe extends Error {
2984
+ class we extends Error {
2793
2985
  constructor(e, s, r, i) {
2794
- const o = tn(r);
2986
+ const o = un(r);
2795
2987
  super(o.message ?? `${s || "Request failed"} (${e})`);
2796
2988
  T(this, "status");
2797
2989
  T(this, "code");
@@ -2802,11 +2994,11 @@ class pe extends Error {
2802
2994
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
2803
2995
  */
2804
2996
  T(this, "retryAfter");
2805
- this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? en(o.details);
2997
+ this.name = "RequestError", this.status = e, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? dn(o.details);
2806
2998
  }
2807
2999
  }
2808
- const R = "item/folder", m = "item", U = "processor", sn = "npm-registry", B = "hidden", Ft = "FILE", Ut = "TOOL", Dt = "APP", nn = 500, Ie = 3e4, rn = 0.25, on = (n) => new Promise((t) => setTimeout(t, n));
2809
- function an(n) {
3000
+ const R = "item/folder", m = "item", j = "processor", fn = "npm-registry", L = "hidden", Ut = "FILE", jt = "TOOL", Mt = "APP", pn = 500, Pe = 3e4, yn = 0.25, mn = (n) => new Promise((t) => setTimeout(t, n));
3001
+ function gn(n) {
2810
3002
  var r, i;
2811
3003
  const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
2812
3004
  if (!t) return;
@@ -2816,18 +3008,18 @@ function an(n) {
2816
3008
  if (!Number.isNaN(s))
2817
3009
  return Math.max(0, (s - Date.now()) / 1e3);
2818
3010
  }
2819
- function cn(n) {
2820
- return n instanceof pe ? n.status === 429 || n.status >= 500 : !0;
3011
+ function wn(n) {
3012
+ return n instanceof we ? n.status === 429 || n.status >= 500 : !0;
2821
3013
  }
2822
- function hn(n, t) {
3014
+ function bn(n, t) {
2823
3015
  const e = Math.min(
2824
- nn * 2 ** t,
2825
- Ie
2826
- ), s = e * rn * Math.random(), r = n instanceof pe && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
2827
- return r != null ? Math.min(r, Ie) + s : e + s;
3016
+ pn * 2 ** t,
3017
+ Pe
3018
+ ), s = e * yn * Math.random(), r = n instanceof we && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
3019
+ return r != null ? Math.min(r, Pe) + s : e + s;
2828
3020
  }
2829
- var c, ee, d, D, pt, lt, It, xt, se, ne, We;
2830
- const ye = class ye {
3021
+ var h, ie, p, M, wt, ft, $t, Ct, oe, ae, es;
3022
+ const be = class be {
2831
3023
  /**
2832
3024
  * Creates a new EngineServicesClient instance.
2833
3025
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -2836,7 +3028,7 @@ const ye = class ye {
2836
3028
  * @param props - Optional configuration (retry count, auth mode, etc.).
2837
3029
  */
2838
3030
  constructor(t, e, s) {
2839
- b(this, c);
3031
+ b(this, h);
2840
3032
  T(this, "apiUrl");
2841
3033
  T(this, "accessToken");
2842
3034
  T(this, "wsUrl");
@@ -2855,10 +3047,10 @@ const ye = class ye {
2855
3047
  * Populated automatically when using {@link fromPlatformContext}.
2856
3048
  */
2857
3049
  T(this, "context");
2858
- b(this, pt);
3050
+ b(this, wt);
2859
3051
  const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
2860
- let h = e;
2861
- if (h.charAt(h.length - 1) === "/" && (h = h.slice(0, -1)), this.apiUrl = `${h}/api`, this.accessToken = t, this.wsUrl = h, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
3052
+ let c = e;
3053
+ if (c.charAt(c.length - 1) === "/" && (c = c.slice(0, -1)), this.apiUrl = `${c}/api`, this.accessToken = t, this.wsUrl = c, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, o) {
2862
3054
  let u = o;
2863
3055
  u.charAt(u.length - 1) === "/" && (u = u.slice(0, -1)), this.localServerUrl = u;
2864
3056
  }
@@ -2880,7 +3072,7 @@ const ye = class ye {
2880
3072
  * ```
2881
3073
  */
2882
3074
  static fromPlatformContext(t) {
2883
- const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ye(e.accessToken, e.apiUrl, {
3075
+ const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new be(e.accessToken, e.apiUrl, {
2884
3076
  ...t,
2885
3077
  useBearer: !0
2886
3078
  });
@@ -2956,7 +3148,7 @@ const ye = class ye {
2956
3148
  * cleaning logic is applied identically.
2957
3149
  */
2958
3150
  async request(t, e, s) {
2959
- return a(this, c, d).call(this, t, e, s);
3151
+ return a(this, h, p).call(this, t, e, s);
2960
3152
  }
2961
3153
  // ─── Files ───────────────────────────────────────────────────────
2962
3154
  /**
@@ -2966,9 +3158,9 @@ const ye = class ye {
2966
3158
  */
2967
3159
  async listFiles(t) {
2968
3160
  const { folderId: e, archived: s, projectId: r } = t || {};
2969
- return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, { query: { itemType: Ft, archived: s } }) : await a(this, c, d).call(this, "GET", `${m}`, {
3161
+ return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, { query: { itemType: Ut, archived: s } }) : await a(this, h, p).call(this, "GET", `${m}`, {
2970
3162
  query: {
2971
- itemType: Ft,
3163
+ itemType: Ut,
2972
3164
  archived: s,
2973
3165
  ...r && { projectId: r }
2974
3166
  }
@@ -2981,7 +3173,7 @@ const ye = class ye {
2981
3173
  * @returns The file item, optionally with version history.
2982
3174
  */
2983
3175
  async getFile(t, e) {
2984
- return await a(this, c, ne).call(this, t, e);
3176
+ return await a(this, h, ae).call(this, t, e);
2985
3177
  }
2986
3178
  /**
2987
3179
  * Uploads a new file.
@@ -2989,7 +3181,7 @@ const ye = class ye {
2989
3181
  * @returns The created item and its first version.
2990
3182
  */
2991
3183
  async createFile(t) {
2992
- return await a(this, c, xt).call(this, t, Ft);
3184
+ return await a(this, h, Ct).call(this, t, Ut);
2993
3185
  }
2994
3186
  /**
2995
3187
  * Updates an existing file. Can rename, move to a different folder,
@@ -2999,21 +3191,21 @@ const ye = class ye {
2999
3191
  * @returns The updated item and/or the new version.
3000
3192
  */
3001
3193
  async updateFile(t, e) {
3002
- return await a(this, c, se).call(this, t, e);
3194
+ return await a(this, h, oe).call(this, t, e);
3003
3195
  }
3004
3196
  /**
3005
3197
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
3006
3198
  * @param fileId - The file's unique identifier.
3007
3199
  */
3008
3200
  async archiveFile(t) {
3009
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3201
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3010
3202
  }
3011
3203
  /**
3012
3204
  * Recovers a previously archived file.
3013
3205
  * @param fileId - The file's unique identifier.
3014
3206
  */
3015
3207
  async recoverFile(t) {
3016
- return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
3208
+ return await a(this, h, p).call(this, "PUT", `${m}/${t}/recover`);
3017
3209
  }
3018
3210
  /**
3019
3211
  * Downloads a file's content. Returns the raw fetch Response.
@@ -3022,7 +3214,7 @@ const ye = class ye {
3022
3214
  * @returns A fetch Response containing the file data.
3023
3215
  */
3024
3216
  async downloadFile(t, e) {
3025
- return await a(this, c, It).call(this, t, e);
3217
+ return await a(this, h, $t).call(this, t, e);
3026
3218
  }
3027
3219
  /**
3028
3220
  * Retrieves the free-JSON metadata for a specific file version.
@@ -3033,7 +3225,7 @@ const ye = class ye {
3033
3225
  */
3034
3226
  async getFileVersionMetadata(t, e, s) {
3035
3227
  const { withDraft: r } = s || {};
3036
- return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3228
+ return await a(this, h, p).call(this, "GET", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3037
3229
  query: {
3038
3230
  ...r && { withDraft: "true" }
3039
3231
  }
@@ -3046,7 +3238,7 @@ const ye = class ye {
3046
3238
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
3047
3239
  */
3048
3240
  async updateFileVersionMetadata(t, e, s) {
3049
- return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3241
+ return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`, {
3050
3242
  body: JSON.stringify({ metadata: s }),
3051
3243
  contentType: "application/json"
3052
3244
  });
@@ -3057,7 +3249,7 @@ const ye = class ye {
3057
3249
  * @param versionTag - The version tag.
3058
3250
  */
3059
3251
  async deleteFileVersionMetadata(t, e) {
3060
- return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
3252
+ return await a(this, h, p).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/metadata`);
3061
3253
  }
3062
3254
  /**
3063
3255
  * Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
@@ -3074,7 +3266,7 @@ const ye = class ye {
3074
3266
  */
3075
3267
  async getFileVersionMetadataBatch(t, e) {
3076
3268
  const { withDraft: s } = e || {};
3077
- return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/version-metadata`, {
3269
+ return await a(this, h, ft).call(this, t, async (r) => (await a(this, h, p).call(this, "POST", `${m}/batch/version-metadata`, {
3078
3270
  body: JSON.stringify({
3079
3271
  entries: r,
3080
3272
  ...s !== void 0 && { withDraft: s }
@@ -3090,7 +3282,7 @@ const ye = class ye {
3090
3282
  */
3091
3283
  async listFolders(t) {
3092
3284
  const { archived: e, parentFolderId: s, projectId: r } = t || {};
3093
- return await a(this, c, d).call(this, "GET", R, {
3285
+ return await a(this, h, p).call(this, "GET", R, {
3094
3286
  query: {
3095
3287
  parentFolderId: s,
3096
3288
  archived: e,
@@ -3103,7 +3295,7 @@ const ye = class ye {
3103
3295
  * @param folderId - The folder's unique identifier.
3104
3296
  */
3105
3297
  async getFolder(t) {
3106
- return await a(this, c, d).call(this, "GET", `${R}/${t}`);
3298
+ return await a(this, h, p).call(this, "GET", `${R}/${t}`);
3107
3299
  }
3108
3300
  /**
3109
3301
  * Batch variant of {@link getFolder}. Resolves a known set of folder ids in
@@ -3119,7 +3311,7 @@ const ye = class ye {
3119
3311
  * @param folderIds - The folder ids to resolve.
3120
3312
  */
3121
3313
  async getFoldersBatch(t) {
3122
- return await a(this, c, lt).call(this, t, async (e) => (await a(this, c, d).call(this, "POST", `${m}/batch/folders`, {
3314
+ return await a(this, h, ft).call(this, t, async (e) => (await a(this, h, p).call(this, "POST", `${m}/batch/folders`, {
3123
3315
  body: JSON.stringify({ folderIds: e }),
3124
3316
  contentType: "application/json"
3125
3317
  })).results);
@@ -3131,7 +3323,7 @@ const ye = class ye {
3131
3323
  * @returns The created folder.
3132
3324
  */
3133
3325
  async createFolder(t, e, s) {
3134
- return await a(this, c, d).call(this, "POST", R, {
3326
+ return await a(this, h, p).call(this, "POST", R, {
3135
3327
  body: JSON.stringify({
3136
3328
  name: t,
3137
3329
  ...e && { parentId: e },
@@ -3148,7 +3340,7 @@ const ye = class ye {
3148
3340
  */
3149
3341
  async updateFolder(t, e) {
3150
3342
  const { name: s } = e;
3151
- return await a(this, c, d).call(this, "PUT", `${R}/${t}`, {
3343
+ return await a(this, h, p).call(this, "PUT", `${R}/${t}`, {
3152
3344
  body: JSON.stringify({ name: s }),
3153
3345
  contentType: "application/json"
3154
3346
  });
@@ -3158,14 +3350,14 @@ const ye = class ye {
3158
3350
  * @param folderId - The folder's unique identifier.
3159
3351
  */
3160
3352
  async archiveFolder(t) {
3161
- return await a(this, c, d).call(this, "DELETE", `${R}/${t}`);
3353
+ return await a(this, h, p).call(this, "DELETE", `${R}/${t}`);
3162
3354
  }
3163
3355
  /**
3164
3356
  * Recovers a previously archived folder.
3165
3357
  * @param folderId - The folder's unique identifier.
3166
3358
  */
3167
3359
  async recoverFolder(t) {
3168
- return await a(this, c, d).call(this, "PUT", `${R}/${t}/recover`);
3360
+ return await a(this, h, p).call(this, "PUT", `${R}/${t}/recover`);
3169
3361
  }
3170
3362
  /**
3171
3363
  * Downloads an entire folder as a ZIP archive.
@@ -3173,7 +3365,7 @@ const ye = class ye {
3173
3365
  * @returns A fetch Response containing the ZIP data.
3174
3366
  */
3175
3367
  async downloadFolder(t) {
3176
- return await a(this, c, D).call(this, `${R}/${t}/download`);
3368
+ return await a(this, h, M).call(this, `${R}/${t}/download`);
3177
3369
  }
3178
3370
  // ─── Components ──────────────────────────────────────────────────
3179
3371
  /**
@@ -3183,14 +3375,14 @@ const ye = class ye {
3183
3375
  */
3184
3376
  async listComponents(t) {
3185
3377
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3186
- return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
3378
+ return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3187
3379
  query: {
3188
- itemType: Ut,
3380
+ itemType: jt,
3189
3381
  ...s && { ShowVersions: s }
3190
3382
  }
3191
- }) : await a(this, c, d).call(this, "GET", `${m}`, {
3383
+ }) : await a(this, h, p).call(this, "GET", `${m}`, {
3192
3384
  query: {
3193
- itemType: Ut,
3385
+ itemType: jt,
3194
3386
  ...s && { ShowVersions: s },
3195
3387
  ...r && { projectId: r }
3196
3388
  }
@@ -3202,7 +3394,7 @@ const ye = class ye {
3202
3394
  * @param props - Options such as whether to include versions.
3203
3395
  */
3204
3396
  async getComponent(t, e) {
3205
- return await a(this, c, ne).call(this, t, e);
3397
+ return await a(this, h, ae).call(this, t, e);
3206
3398
  }
3207
3399
  /**
3208
3400
  * Creates a new component with the given file and version properties.
@@ -3211,7 +3403,7 @@ const ye = class ye {
3211
3403
  */
3212
3404
  async createComponent(t) {
3213
3405
  const { componentProps: e } = t;
3214
- return await a(this, c, xt).call(this, t, Ut, e);
3406
+ return await a(this, h, Ct).call(this, t, jt, e);
3215
3407
  }
3216
3408
  /**
3217
3409
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -3221,7 +3413,7 @@ const ye = class ye {
3221
3413
  */
3222
3414
  async updateComponent(t, e) {
3223
3415
  const { componentProps: s } = e;
3224
- return await a(this, c, se).call(this, t, e, s);
3416
+ return await a(this, h, oe).call(this, t, e, s);
3225
3417
  }
3226
3418
  /**
3227
3419
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -3230,7 +3422,7 @@ const ye = class ye {
3230
3422
  * @returns A fetch Response containing the ZIP data.
3231
3423
  */
3232
3424
  async downloadComponent(t, e) {
3233
- return await a(this, c, It).call(this, t, e);
3425
+ return await a(this, h, $t).call(this, t, e);
3234
3426
  }
3235
3427
  /**
3236
3428
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -3241,7 +3433,7 @@ const ye = class ye {
3241
3433
  */
3242
3434
  async downloadComponentBundle(t, e) {
3243
3435
  const { versionTag: s, withDraft: r } = e || {};
3244
- return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
3436
+ return await a(this, h, M).call(this, `${m}/${t}/download/bundle`, {
3245
3437
  query: {
3246
3438
  ...s && { versionTag: s },
3247
3439
  ...r && { withDraft: r }
@@ -3253,14 +3445,14 @@ const ye = class ye {
3253
3445
  * @param componentId - The component's unique identifier.
3254
3446
  */
3255
3447
  async archiveComponent(t) {
3256
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3448
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3257
3449
  }
3258
3450
  /**
3259
3451
  * Recovers a previously archived component.
3260
3452
  * @param componentId - The component's unique identifier.
3261
3453
  */
3262
3454
  async recoverComponent(t) {
3263
- return await a(this, c, d).call(this, "PUT", `${m}/${t}/recover`);
3455
+ return await a(this, h, p).call(this, "PUT", `${m}/${t}/recover`);
3264
3456
  }
3265
3457
  // ─── Built-in Components ─────────────────────────────────────────
3266
3458
  /**
@@ -3269,7 +3461,7 @@ const ye = class ye {
3269
3461
  * @returns The component's JavaScript source code as a string.
3270
3462
  */
3271
3463
  async getBuiltInComponent(t) {
3272
- return await (await a(this, c, D).call(this, `built-in/${t}/bundle`)).text();
3464
+ return await (await a(this, h, M).call(this, `built-in/${t}/bundle`)).text();
3273
3465
  }
3274
3466
  /**
3275
3467
  * Fetches a built-in component bundle, evaluates it, and registers it
@@ -3298,9 +3490,9 @@ const ye = class ye {
3298
3490
  * ```
3299
3491
  */
3300
3492
  async initBuiltInComponent(t, e, s) {
3301
- const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), h = o.map((w) => i[w]), f = new Function(...o, `${r}
3302
- return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3303
- e.get(p);
3493
+ const r = await this.getBuiltInComponent(t.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), c = o.map((w) => i[w]), f = new Function(...o, `${r}
3494
+ return main;`)(...c), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3495
+ e.get(y);
3304
3496
  }
3305
3497
  /**
3306
3498
  * Loads multiple built-in components in parallel.
@@ -3342,13 +3534,13 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3342
3534
  * ```
3343
3535
  */
3344
3536
  async setup(t, ...e) {
3345
- var o, h;
3537
+ var o, c;
3346
3538
  const s = t.OBC, r = t.BUI;
3347
3539
  if (!(s != null && s.Components))
3348
3540
  throw new Error("globals.OBC must include Components");
3349
3541
  if (!(r != null && r.Manager)) throw new Error("globals.BUI must include Manager");
3350
3542
  const i = new s.Components();
3351
- return r.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (h = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || h.call(o), { components: i };
3543
+ return r.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(i, ...e), i.init(), (c = (o = this.context.appEventOrchestrator) == null ? void 0 : o.appLoaded) == null || c.call(o), { components: i };
3352
3544
  }
3353
3545
  /**
3354
3546
  * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
@@ -3367,14 +3559,14 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3367
3559
  */
3368
3560
  async listApps(t) {
3369
3561
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3370
- return e ? await a(this, c, d).call(this, "GET", `${R}/${e}/items`, {
3562
+ return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3371
3563
  query: {
3372
- itemType: Dt,
3564
+ itemType: Mt,
3373
3565
  ...s && { ShowVersions: s }
3374
3566
  }
3375
- }) : await a(this, c, d).call(this, "GET", `${m}`, {
3567
+ }) : await a(this, h, p).call(this, "GET", `${m}`, {
3376
3568
  query: {
3377
- itemType: Dt,
3569
+ itemType: Mt,
3378
3570
  ...s && { ShowVersions: s },
3379
3571
  ...r && { projectId: r }
3380
3572
  }
@@ -3387,7 +3579,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3387
3579
  */
3388
3580
  async createApp(t) {
3389
3581
  const { appProps: e } = t;
3390
- return await a(this, c, xt).call(this, t, Dt, e);
3582
+ return await a(this, h, Ct).call(this, t, Mt, e);
3391
3583
  }
3392
3584
  /**
3393
3585
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -3396,7 +3588,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3396
3588
  * @returns A fetch Response containing the ZIP data.
3397
3589
  */
3398
3590
  async downloadApp(t, e) {
3399
- return await a(this, c, It).call(this, t, e);
3591
+ return await a(this, h, $t).call(this, t, e);
3400
3592
  }
3401
3593
  /**
3402
3594
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -3407,7 +3599,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3407
3599
  */
3408
3600
  async downloadAppBundle(t, e) {
3409
3601
  const { versionTag: s, withDraft: r } = e || {};
3410
- return await a(this, c, D).call(this, `${m}/${t}/download/bundle`, {
3602
+ return await a(this, h, M).call(this, `${m}/${t}/download/bundle`, {
3411
3603
  query: {
3412
3604
  ...s && { versionTag: s },
3413
3605
  ...r && { withDraft: r }
@@ -3419,7 +3611,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3419
3611
  * @param appId - The app's unique identifier.
3420
3612
  */
3421
3613
  async archiveApp(t) {
3422
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3614
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3423
3615
  }
3424
3616
  // ─── NPM Registry ────────────────────────────────────────────────
3425
3617
  /**
@@ -3431,7 +3623,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3431
3623
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
3432
3624
  */
3433
3625
  async getNpmCredentials() {
3434
- return await a(this, c, d).call(this, "GET", `${sn}/credentials`);
3626
+ return await a(this, h, p).call(this, "GET", `${fn}/credentials`);
3435
3627
  }
3436
3628
  // ─── Execution ───────────────────────────────────────────────────
3437
3629
  /**
@@ -3450,7 +3642,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3450
3642
  */
3451
3643
  async executeComponent(t, e, s) {
3452
3644
  if (this.localServerUrl) {
3453
- const r = `${this.localServerUrl}/api/${U}/${t}/execute`, i = await fetch(r, {
3645
+ const r = `${this.localServerUrl}/api/${j}/${t}/execute`, i = await fetch(r, {
3454
3646
  method: "POST",
3455
3647
  headers: { "Content-Type": "application/json" },
3456
3648
  body: JSON.stringify(e)
@@ -3463,7 +3655,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3463
3655
  }
3464
3656
  return await i.json();
3465
3657
  }
3466
- return await a(this, c, d).call(this, "POST", `${U}/${t}/execute`, {
3658
+ return await a(this, h, p).call(this, "POST", `${j}/${t}/execute`, {
3467
3659
  body: JSON.stringify(e),
3468
3660
  query: { ...s && { versionTag: s } },
3469
3661
  contentType: "application/json"
@@ -3475,7 +3667,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3475
3667
  */
3476
3668
  async abortExecution(t) {
3477
3669
  if (this.localServerUrl) {
3478
- const e = `${this.localServerUrl}/api/${U}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
3670
+ const e = `${this.localServerUrl}/api/${j}/progress/${t}/abort`, s = await fetch(e, { method: "POST" });
3479
3671
  if (!s.ok) {
3480
3672
  const r = await s.text().catch(() => "");
3481
3673
  throw new Error(
@@ -3484,7 +3676,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3484
3676
  }
3485
3677
  return await s.json();
3486
3678
  }
3487
- return await a(this, c, d).call(this, "POST", `${U}/progress/${t}/abort`);
3679
+ return await a(this, h, p).call(this, "POST", `${j}/progress/${t}/abort`);
3488
3680
  }
3489
3681
  /**
3490
3682
  * Lists all executions for a given component.
@@ -3501,7 +3693,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3501
3693
  */
3502
3694
  async listExecutions(t, e) {
3503
3695
  if (this.localServerUrl) {
3504
- const s = e ? `?projectId=${encodeURIComponent(e)}` : "", r = `${this.localServerUrl}/api/${U}/${t}/progress${s}`, i = await fetch(r);
3696
+ const s = e ? `?projectId=${encodeURIComponent(e)}` : "", r = `${this.localServerUrl}/api/${j}/${t}/progress${s}`, i = await fetch(r);
3505
3697
  if (!i.ok) {
3506
3698
  const o = await i.text().catch(() => "");
3507
3699
  throw new Error(
@@ -3510,7 +3702,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3510
3702
  }
3511
3703
  return await i.json();
3512
3704
  }
3513
- return await a(this, c, d).call(this, "GET", `${U}/${t}/progress`, { query: { ...e && { projectId: e } } });
3705
+ return await a(this, h, p).call(this, "GET", `${j}/${t}/progress`, { query: { ...e && { projectId: e } } });
3514
3706
  }
3515
3707
  /**
3516
3708
  * Gets details of a specific execution, including its messages.
@@ -3519,7 +3711,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3519
3711
  */
3520
3712
  async getExecution(t) {
3521
3713
  if (this.localServerUrl) {
3522
- const e = `${this.localServerUrl}/api/${U}/progress/${t}`, s = await fetch(e);
3714
+ const e = `${this.localServerUrl}/api/${j}/progress/${t}`, s = await fetch(e);
3523
3715
  if (!s.ok) {
3524
3716
  const r = await s.text().catch(() => "");
3525
3717
  throw new Error(
@@ -3528,7 +3720,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3528
3720
  }
3529
3721
  return await s.json();
3530
3722
  }
3531
- return await a(this, c, d).call(this, "GET", `${U}/progress/${t}`);
3723
+ return await a(this, h, p).call(this, "GET", `${j}/progress/${t}`);
3532
3724
  }
3533
3725
  /**
3534
3726
  * Subscribes to real-time execution progress via WebSocket.
@@ -3537,7 +3729,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3537
3729
  * @param onUpdateCallback - Callback invoked on each progress/result event.
3538
3730
  */
3539
3731
  async onExecutionProgress(t, e) {
3540
- const s = this.localServerUrl ?? this.wsUrl, r = await ut(s, {
3732
+ const s = this.localServerUrl ?? this.wsUrl, r = await pt(s, {
3541
3733
  auth: { accessToken: this.accessToken },
3542
3734
  transports: ["websocket"]
3543
3735
  });
@@ -3549,7 +3741,15 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3549
3741
  console.log(i);
3550
3742
  });
3551
3743
  }
3552
- // ─── History & Recipes ───────────────────────────────────────────
3744
+ // ─── Documents, History & Recipes ────────────────────────────────
3745
+ /**
3746
+ * A project's documents. Every document is a FOLDER holding its files plus
3747
+ * a `document.json` descriptor naming the document, its native form and its
3748
+ * renderable views. See `src/core/documents.ts` for the model and schema.
3749
+ */
3750
+ documents(t) {
3751
+ return new Ke(this, t);
3752
+ }
3553
3753
  /**
3554
3754
  * A project's history of connected documents (Revit models, AutoCAD
3555
3755
  * drawings…): their version timelines and their change requests. See
@@ -3557,14 +3757,14 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3557
3757
  * or write it; the storage underneath is private and will move.
3558
3758
  */
3559
3759
  history(t) {
3560
- return new Xs(this, t);
3760
+ return new an(this, t);
3561
3761
  }
3562
3762
  /**
3563
3763
  * The recipe registry and runner: scripts that write change requests in a
3564
3764
  * native application's language. See `src/core/recipes.ts`.
3565
3765
  */
3566
3766
  get recipes() {
3567
- return l(this, pt) ?? _(this, pt, new Zs(this)), l(this, pt);
3767
+ return l(this, wt) ?? _(this, wt, new ln(this)), l(this, wt);
3568
3768
  }
3569
3769
  // ─── Hidden Files ────────────────────────────────────────────────
3570
3770
  /**
@@ -3578,7 +3778,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3578
3778
  */
3579
3779
  async createHiddenFile(t, e, s) {
3580
3780
  const r = new FormData();
3581
- return r.append("file", t), r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, c, d).call(this, "POST", `${m}/${B}`, {
3781
+ return r.append("file", t), r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, h, p).call(this, "POST", `${m}/${L}`, {
3582
3782
  body: r
3583
3783
  });
3584
3784
  }
@@ -3596,7 +3796,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3596
3796
  const r = new FormData();
3597
3797
  for (const i of t)
3598
3798
  r.append("files", i);
3599
- return r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, c, d).call(this, "POST", `${m}/${B}/batch`, {
3799
+ return r.append("parentItemId", e), s != null && r.append("tag", s), await a(this, h, p).call(this, "POST", `${m}/${L}/batch`, {
3600
3800
  body: r
3601
3801
  });
3602
3802
  }
@@ -3605,21 +3805,21 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3605
3805
  * @param hiddenId - The hidden file's unique identifier.
3606
3806
  */
3607
3807
  async deleteHiddenFile(t) {
3608
- return await a(this, c, d).call(this, "DELETE", `${m}/${B}/${t}`);
3808
+ return await a(this, h, p).call(this, "DELETE", `${m}/${L}/${t}`);
3609
3809
  }
3610
3810
  /**
3611
3811
  * Gets metadata for a hidden file.
3612
3812
  * @param hiddenId - The hidden file's unique identifier.
3613
3813
  */
3614
3814
  async getHiddenFile(t) {
3615
- return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}`);
3815
+ return await a(this, h, p).call(this, "GET", `${m}/${L}/${t}`);
3616
3816
  }
3617
3817
  /**
3618
3818
  * Downloads a hidden file's content. Returns the raw fetch Response.
3619
3819
  * @param hiddenId - The hidden file's unique identifier.
3620
3820
  */
3621
3821
  async downloadHiddenFile(t) {
3622
- return await a(this, c, D).call(this, `${m}/${B}/${t}/download`);
3822
+ return await a(this, h, M).call(this, `${m}/${L}/${t}/download`);
3623
3823
  }
3624
3824
  /**
3625
3825
  * Mints a short-lived presigned URL for a hidden file so the browser can
@@ -3639,7 +3839,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3639
3839
  * an ISO timestamp when it stops working.
3640
3840
  */
3641
3841
  async getHiddenFileSignedUrl(t, e) {
3642
- return await a(this, c, d).call(this, "GET", `${m}/${B}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
3842
+ return await a(this, h, p).call(this, "GET", `${m}/${L}/${t}/signed-url`, { ...e != null && { query: { expiresIn: e } } });
3643
3843
  }
3644
3844
  /**
3645
3845
  * Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
@@ -3660,7 +3860,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3660
3860
  * 900 (15 min) server-side; values are clamped to that range.
3661
3861
  */
3662
3862
  async getHiddenFileSignedUrlsBatch(t, e) {
3663
- return await a(this, c, lt).call(this, t, async (s) => (await a(this, c, d).call(this, "POST", `${m}/${B}/signed-url/batch`, {
3863
+ return await a(this, h, ft).call(this, t, async (s) => (await a(this, h, p).call(this, "POST", `${m}/${L}/signed-url/batch`, {
3664
3864
  body: JSON.stringify({
3665
3865
  hiddenFileIds: s,
3666
3866
  ...e != null && { expiresIn: e }
@@ -3676,14 +3876,14 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3676
3876
  * @returns Array of hidden file entities.
3677
3877
  */
3678
3878
  async getHiddenFilesByParent(t, e) {
3679
- return await a(this, c, d).call(this, "GET", `${m}/${t}/${B}`, { ...e != null && { query: { tag: e } } });
3879
+ return await a(this, h, p).call(this, "GET", `${m}/${t}/${L}`, { ...e != null && { query: { tag: e } } });
3680
3880
  }
3681
3881
  /**
3682
3882
  * Deletes all hidden files attached to a parent item.
3683
3883
  * @param parentFileId - The parent item's unique identifier.
3684
3884
  */
3685
3885
  async deleteHiddenFilesByParent(t) {
3686
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}/${B}`);
3886
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}/${L}`);
3687
3887
  }
3688
3888
  // ─── Icons ───────────────────────────────────────────────────────
3689
3889
  /**
@@ -3695,7 +3895,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3695
3895
  */
3696
3896
  async uploadItemIcon(t, e) {
3697
3897
  const s = new FormData();
3698
- return s.append("icon", e), await a(this, c, d).call(this, "PUT", `${m}/${t}/icon`, {
3898
+ return s.append("icon", e), await a(this, h, p).call(this, "PUT", `${m}/${t}/icon`, {
3699
3899
  body: s
3700
3900
  });
3701
3901
  }
@@ -3705,7 +3905,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3705
3905
  * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
3706
3906
  */
3707
3907
  async getItemIcon(t) {
3708
- return await a(this, c, D).call(this, `${m}/${t}/icon`);
3908
+ return await a(this, h, M).call(this, `${m}/${t}/icon`);
3709
3909
  }
3710
3910
  /**
3711
3911
  * Removes the icon from an item.
@@ -3713,7 +3913,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3713
3913
  * @returns The updated item with icon fields removed.
3714
3914
  */
3715
3915
  async removeItemIcon(t) {
3716
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}/icon`);
3916
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}/icon`);
3717
3917
  }
3718
3918
  // ─── General Item Operations ─────────────────────────────────────
3719
3919
  /**
@@ -3723,7 +3923,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3723
3923
  * @returns The updated item.
3724
3924
  */
3725
3925
  async updateItem(t, e) {
3726
- return await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
3926
+ return await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
3727
3927
  body: JSON.stringify(e),
3728
3928
  contentType: "application/json"
3729
3929
  });
@@ -3740,7 +3940,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3740
3940
  */
3741
3941
  async createVersion(t, e, s, r, i) {
3742
3942
  const o = new FormData();
3743
- return o.append("file", e), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await a(this, c, d).call(this, "POST", `${m}/${t}/version`, { body: o });
3943
+ return o.append("file", e), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await a(this, h, p).call(this, "POST", `${m}/${t}/version`, { body: o });
3744
3944
  }
3745
3945
  /**
3746
3946
  * Lists versions of an item. Pass `archived: true` to fetch only archived
@@ -3750,7 +3950,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3750
3950
  * @returns Array of versions, sorted by creation date descending.
3751
3951
  */
3752
3952
  async listVersions(t, e = {}) {
3753
- return await a(this, c, d).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
3953
+ return await a(this, h, p).call(this, "GET", `${m}/${encodeURIComponent(t)}/versions`, { query: e });
3754
3954
  }
3755
3955
  /**
3756
3956
  * Batch variant of {@link listVersions}. Lists the versions of many items in
@@ -3769,7 +3969,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3769
3969
  */
3770
3970
  async listVersionsBatch(t, e = {}) {
3771
3971
  const { archived: s } = e;
3772
- return await a(this, c, lt).call(this, t, async (r) => (await a(this, c, d).call(this, "POST", `${m}/batch/versions`, {
3972
+ return await a(this, h, ft).call(this, t, async (r) => (await a(this, h, p).call(this, "POST", `${m}/batch/versions`, {
3773
3973
  body: JSON.stringify({
3774
3974
  itemIds: r,
3775
3975
  ...s !== void 0 && { archived: s }
@@ -3787,7 +3987,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3787
3987
  * @returns The archived version.
3788
3988
  */
3789
3989
  async archiveVersion(t, e) {
3790
- return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
3990
+ return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/archive`);
3791
3991
  }
3792
3992
  /**
3793
3993
  * Recovers a previously archived version, restoring it to the active list.
@@ -3796,7 +3996,7 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3796
3996
  * @returns The recovered version.
3797
3997
  */
3798
3998
  async recoverVersion(t, e) {
3799
- return await a(this, c, d).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
3999
+ return await a(this, h, p).call(this, "PUT", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}/recover`);
3800
4000
  }
3801
4001
  /**
3802
4002
  * Permanently deletes a version, including its file in object storage.
@@ -3805,19 +4005,19 @@ return main;`)(...h), p = (f == null ? void 0 : f.componentDefinition) ?? f;
3805
4005
  * @param versionTag - The version's tag (e.g. "v2").
3806
4006
  */
3807
4007
  async deleteVersion(t, e) {
3808
- return await a(this, c, d).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
4008
+ return await a(this, h, p).call(this, "DELETE", `${m}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
3809
4009
  }
3810
4010
  };
3811
- c = new WeakSet(), ee = function(t) {
4011
+ h = new WeakSet(), ie = function(t) {
3812
4012
  return `${this.apiUrl}/${t}`;
3813
- }, d = async function(t, e, s) {
3814
- const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, p = a(this, c, ee).call(this, e), w = a(this, c, We).call(this, i), C = await this.resolveAccessToken(), ts = {
4013
+ }, p = async function(t, e, s) {
4014
+ const { body: r, query: i, contentType: o, retries: c, responseType: u, retryAttempt: f } = s || {}, y = a(this, h, ie).call(this, e), w = a(this, h, es).call(this, i), C = await this.resolveAccessToken(), as = {
3815
4015
  ...w,
3816
4016
  ...this.useBearer ? {} : { accessToken: C }
3817
4017
  };
3818
4018
  try {
3819
- const I = await fetch(
3820
- p + "?" + new URLSearchParams(ts).toString(),
4019
+ const A = await fetch(
4020
+ y + "?" + new URLSearchParams(as).toString(),
3821
4021
  {
3822
4022
  method: t,
3823
4023
  headers: {
@@ -3828,31 +4028,31 @@ c = new WeakSet(), ee = function(t) {
3828
4028
  ...r && { body: r }
3829
4029
  }
3830
4030
  );
3831
- if (!I.ok) {
3832
- const K = await I.text().then((gt) => gt).catch(() => "");
3833
- throw new pe(
3834
- I.status,
3835
- I.statusText,
3836
- K,
3837
- an(I)
4031
+ if (!A.ok) {
4032
+ const z = await A.text().then((vt) => vt).catch(() => "");
4033
+ throw new we(
4034
+ A.status,
4035
+ A.statusText,
4036
+ z,
4037
+ gn(A)
3838
4038
  );
3839
4039
  }
3840
- return u === "blob" ? await I.blob() : I.json().then((K) => K).catch(() => {
4040
+ return u === "blob" ? await A.blob() : A.json().then((z) => z).catch(() => {
3841
4041
  });
3842
- } catch (I) {
3843
- const K = h ?? this.retries;
3844
- if (K > 0 && cn(I)) {
3845
- const gt = f ?? 0;
3846
- return await on(hn(I, gt)), await a(this, c, d).call(this, t, e, {
4042
+ } catch (A) {
4043
+ const z = c ?? this.retries;
4044
+ if (z > 0 && wn(A)) {
4045
+ const vt = f ?? 0;
4046
+ return await mn(bn(A, vt)), await a(this, h, p).call(this, t, e, {
3847
4047
  ...s,
3848
- retries: K - 1,
3849
- retryAttempt: gt + 1
4048
+ retries: z - 1,
4049
+ retryAttempt: vt + 1
3850
4050
  });
3851
4051
  }
3852
- throw I;
4052
+ throw A;
3853
4053
  }
3854
- }, D = async function(t, e) {
3855
- const { query: s } = e || {}, r = a(this, c, ee).call(this, t), i = await this.resolveAccessToken(), o = {
4054
+ }, M = async function(t, e) {
4055
+ const { query: s } = e || {}, r = a(this, h, ie).call(this, t), i = await this.resolveAccessToken(), o = {
3856
4056
  ...s,
3857
4057
  ...this.useBearer ? {} : { accessToken: i }
3858
4058
  };
@@ -3865,31 +4065,31 @@ c = new WeakSet(), ee = function(t) {
3865
4065
  }
3866
4066
  }
3867
4067
  );
3868
- }, pt = new WeakMap(), lt = async function(t, e) {
4068
+ }, wt = new WeakMap(), ft = async function(t, e) {
3869
4069
  if (!t.length) return [];
3870
4070
  const s = [];
3871
- for (let i = 0; i < t.length; i += Ae)
3872
- s.push(t.slice(i, i + Ae));
4071
+ for (let i = 0; i < t.length; i += Ne)
4072
+ s.push(t.slice(i, i + Ne));
3873
4073
  return (await Promise.all(s.map(e))).flat();
3874
- }, It = async function(t, e) {
4074
+ }, $t = async function(t, e) {
3875
4075
  const { versionTag: s, withDraft: r } = e || {};
3876
- return await a(this, c, D).call(this, `${m}/${t}/download`, {
4076
+ return await a(this, h, M).call(this, `${m}/${t}/download`, {
3877
4077
  query: {
3878
4078
  ...s && { versionTag: s },
3879
4079
  ...r && { withDraft: r }
3880
4080
  }
3881
4081
  });
3882
- }, xt = async function(t, e, s) {
3883
- const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, p = new FormData();
3884
- return p.append("file", u), p.append("name", r), p.append("versionTag", i), p.append("itemType", e), o && p.append("folderId", o), h && p.append("projectId", h), s && p.append("extraProps", JSON.stringify(s)), f && p.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
3885
- body: p
4082
+ }, Ct = async function(t, e, s) {
4083
+ const { name: r, versionTag: i, parentFolderId: o, projectId: c, file: u, metadata: f } = t, y = new FormData();
4084
+ return y.append("file", u), y.append("name", r), y.append("versionTag", i), y.append("itemType", e), o && y.append("folderId", o), c && y.append("projectId", c), s && y.append("extraProps", JSON.stringify(s)), f && y.append("metadata", JSON.stringify(f)), await a(this, h, p).call(this, "POST", m, {
4085
+ body: y
3886
4086
  });
3887
- }, se = async function(t, e, s) {
3888
- const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
3889
- let f, p;
3890
- if (h) {
4087
+ }, oe = async function(t, e, s) {
4088
+ const { name: r, versionTag: i, parentFolderId: o, file: c, metadata: u } = e;
4089
+ let f, y;
4090
+ if (c) {
3891
4091
  const w = new FormData();
3892
- w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), p = await a(this, c, d).call(this, "POST", `${m}/${t}/version`, {
4092
+ w.append("file", c), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), y = await a(this, h, p).call(this, "POST", `${m}/${t}/version`, {
3893
4093
  body: w
3894
4094
  });
3895
4095
  }
@@ -3898,25 +4098,25 @@ c = new WeakSet(), ee = function(t) {
3898
4098
  ...r && { name: r },
3899
4099
  ...o && { folderId: o }
3900
4100
  }, C = JSON.stringify(w);
3901
- f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
4101
+ f = await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
3902
4102
  body: C,
3903
4103
  contentType: "application/json"
3904
4104
  });
3905
4105
  }
3906
- return { item: f, version: p };
3907
- }, ne = async function(t, e) {
4106
+ return { item: f, version: y };
4107
+ }, ae = async function(t, e) {
3908
4108
  const { showVersions: s = !1 } = e || {};
3909
- return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
4109
+ return await a(this, h, p).call(this, "GET", `${m}/${t}`, {
3910
4110
  query: { showVersions: s }
3911
4111
  });
3912
- }, We = function(t) {
4112
+ }, es = function(t) {
3913
4113
  return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
3914
4114
  (e, [s, r]) => (e[s] = r, e),
3915
4115
  {}
3916
4116
  );
3917
4117
  };
3918
- let te = ye;
3919
- function ln() {
4118
+ let re = be;
4119
+ function _n() {
3920
4120
  if (typeof window > "u" || window.parent === window)
3921
4121
  throw new Error(
3922
4122
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
@@ -3931,29 +4131,29 @@ function ln() {
3931
4131
  }
3932
4132
  };
3933
4133
  }
3934
- const re = "channel:", un = 1e4;
3935
- function $t(n) {
4134
+ const ce = "channel:", vn = 1e4;
4135
+ function Rt(n) {
3936
4136
  try {
3937
4137
  n();
3938
4138
  } catch (t) {
3939
4139
  console.error("[channel] a listener threw:", t);
3940
4140
  }
3941
4141
  }
3942
- var q, k, O, Z, tt, et, S, ie, oe, Q;
3943
- class Ke {
4142
+ var D, k, O, nt, rt, it, S, he, le, st;
4143
+ class ss {
3944
4144
  constructor(t, e) {
3945
4145
  b(this, S);
3946
- b(this, q, !1);
4146
+ b(this, D, !1);
3947
4147
  b(this, k, []);
3948
4148
  b(this, O, []);
3949
- b(this, Z, /* @__PURE__ */ new Set());
3950
- b(this, tt, /* @__PURE__ */ new Set());
3951
- b(this, et, /* @__PURE__ */ new Set());
4149
+ b(this, nt, /* @__PURE__ */ new Set());
4150
+ b(this, rt, /* @__PURE__ */ new Set());
4151
+ b(this, it, /* @__PURE__ */ new Set());
3952
4152
  this.transport = t, this.controls = e;
3953
4153
  }
3954
4154
  /** Whether the platform has confirmed this tab is in the room. */
3955
4155
  get joined() {
3956
- return l(this, q);
4156
+ return l(this, D);
3957
4157
  }
3958
4158
  /** Who else is in the room right now, as the platform last reported. */
3959
4159
  get peers() {
@@ -3964,42 +4164,42 @@ class Ke {
3964
4164
  * refuses or does not answer in time. Joining twice is harmless.
3965
4165
  */
3966
4166
  join() {
3967
- return l(this, q) ? Promise.resolve() : a(this, S, ie).call(this, "joined", this.controls.join);
4167
+ return l(this, D) ? Promise.resolve() : a(this, S, he).call(this, "joined", this.controls.join);
3968
4168
  }
3969
4169
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
3970
4170
  leave() {
3971
- return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, ie).call(this, "left", this.controls.leave);
4171
+ return !l(this, D) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, he).call(this, "left", this.controls.leave);
3972
4172
  }
3973
4173
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
3974
4174
  onChange(t) {
3975
- return l(this, Z).add(t), () => void l(this, Z).delete(t);
4175
+ return l(this, nt).add(t), () => void l(this, nt).delete(t);
3976
4176
  }
3977
4177
  onPeerJoined(t) {
3978
- return l(this, tt).add(t), () => void l(this, tt).delete(t);
4178
+ return l(this, rt).add(t), () => void l(this, rt).delete(t);
3979
4179
  }
3980
4180
  onPeerLeft(t) {
3981
- return l(this, et).add(t), () => void l(this, et).delete(t);
4181
+ return l(this, it).add(t), () => void l(this, it).delete(t);
3982
4182
  }
3983
4183
  /** @internal */
3984
4184
  applyJoined() {
3985
- _(this, q, !0), a(this, S, oe).call(this, "joined"), a(this, S, Q).call(this);
4185
+ _(this, D, !0), a(this, S, le).call(this, "joined"), a(this, S, st).call(this);
3986
4186
  }
3987
4187
  /** @internal */
3988
4188
  applyLeft() {
3989
- _(this, q, !1), _(this, k, []), a(this, S, oe).call(this, "left"), a(this, S, Q).call(this);
4189
+ _(this, D, !1), _(this, k, []), a(this, S, le).call(this, "left"), a(this, S, st).call(this);
3990
4190
  }
3991
4191
  /** @internal */
3992
4192
  applyPeers(t) {
3993
- _(this, k, t), a(this, S, Q).call(this);
4193
+ _(this, k, t), a(this, S, st).call(this);
3994
4194
  }
3995
4195
  /** @internal */
3996
4196
  applyPeerJoined(t) {
3997
- !l(this, q) || l(this, k).some((e) => e.from === t.from) || (_(this, k, [...l(this, k), t]), l(this, tt).forEach((e) => $t(() => e(t))), a(this, S, Q).call(this));
4197
+ !l(this, D) || l(this, k).some((e) => e.from === t.from) || (_(this, k, [...l(this, k), t]), l(this, rt).forEach((e) => Rt(() => e(t))), a(this, S, st).call(this));
3998
4198
  }
3999
4199
  /** @internal */
4000
4200
  applyPeerLeft(t) {
4001
4201
  const e = l(this, k).find((s) => s.from === t);
4002
- e && (_(this, k, l(this, k).filter((s) => s.from !== t)), l(this, et).forEach((s) => $t(() => s(e))), a(this, S, Q).call(this));
4202
+ e && (_(this, k, l(this, k).filter((s) => s.from !== t)), l(this, it).forEach((s) => Rt(() => s(e))), a(this, S, st).call(this));
4003
4203
  }
4004
4204
  /** @internal */
4005
4205
  failPending(t) {
@@ -4012,7 +4212,7 @@ class Ke {
4012
4212
  this.transport.post(t);
4013
4213
  }
4014
4214
  }
4015
- q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), S = new WeakSet(), ie = function(t, e) {
4215
+ D = new WeakMap(), k = new WeakMap(), O = new WeakMap(), nt = new WeakMap(), rt = new WeakMap(), it = new WeakMap(), S = new WeakSet(), he = function(t, e) {
4016
4216
  return new Promise((s, r) => {
4017
4217
  const i = {
4018
4218
  want: t,
@@ -4024,65 +4224,65 @@ q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Z = new WeakMap(), tt =
4024
4224
  `The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
4025
4225
  )
4026
4226
  );
4027
- }, un)
4227
+ }, vn)
4028
4228
  };
4029
4229
  l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
4030
4230
  });
4031
- }, oe = function(t) {
4231
+ }, le = function(t) {
4032
4232
  const e = l(this, O).filter((s) => s.want === t);
4033
4233
  _(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
4034
4234
  clearTimeout(s.timer), s.resolve();
4035
4235
  });
4036
- }, Q = function() {
4037
- l(this, Z).forEach((t) => $t(t));
4236
+ }, st = function() {
4237
+ l(this, nt).forEach((t) => Rt(t));
4038
4238
  };
4039
- var st;
4040
- class dn extends Ke {
4239
+ var ot;
4240
+ class En extends ss {
4041
4241
  /** @internal Use `client.channel.collab()`. */
4042
4242
  constructor(e) {
4043
4243
  super(e, {
4044
4244
  join: { action: "joinCollab" },
4045
4245
  leave: { action: "leaveCollab" }
4046
4246
  });
4047
- b(this, st, /* @__PURE__ */ new Map());
4247
+ b(this, ot, /* @__PURE__ */ new Map());
4048
4248
  }
4049
4249
  /**
4050
4250
  * Listens for an event other tabs send. Any number of listeners per event.
4051
4251
  * @returns a function that removes the listener.
4052
4252
  */
4053
4253
  on(e, s) {
4054
- const r = l(this, st).get(e) ?? /* @__PURE__ */ new Set();
4055
- return r.add(s), l(this, st).set(e, r), () => void r.delete(s);
4254
+ const r = l(this, ot).get(e) ?? /* @__PURE__ */ new Set();
4255
+ return r.add(s), l(this, ot).set(e, r), () => void r.delete(s);
4056
4256
  }
4057
4257
  /**
4058
4258
  * Sends an event to the other tabs in the room. Does nothing while this tab
4059
4259
  * is not in it, matching what the platform does with a message from outside.
4060
4260
  */
4061
4261
  send(e, s) {
4062
- if (e.startsWith(re))
4063
- throw new Error(`Message types starting with '${re}' are reserved.`);
4262
+ if (e.startsWith(ce))
4263
+ throw new Error(`Message types starting with '${ce}' are reserved.`);
4064
4264
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
4065
4265
  }
4066
4266
  accepts(e) {
4067
4267
  return e === void 0 || e === "collab";
4068
4268
  }
4069
4269
  async handle(e) {
4070
- const s = l(this, st).get(e.type);
4270
+ const s = l(this, ot).get(e.type);
4071
4271
  if (!(s != null && s.size)) return { handled: !1 };
4072
- const r = Xe(e);
4073
- return s.forEach((i) => $t(() => i(e.payload, r))), { handled: !0 };
4272
+ const r = ns(e);
4273
+ return s.forEach((i) => Rt(() => i(e.payload, r))), { handled: !0 };
4074
4274
  }
4075
4275
  }
4076
- st = new WeakMap();
4077
- var H;
4078
- class fn extends Ke {
4276
+ ot = new WeakMap();
4277
+ var G;
4278
+ class Tn extends ss {
4079
4279
  /** @internal Use `client.channel.external(kind)`. */
4080
4280
  constructor(e, s) {
4081
4281
  super(e, {
4082
4282
  join: { action: "joinExternal", kind: s },
4083
4283
  leave: { action: "leaveExternal", kind: s }
4084
4284
  });
4085
- b(this, H, /* @__PURE__ */ new Map());
4285
+ b(this, G, /* @__PURE__ */ new Map());
4086
4286
  this.kind = s;
4087
4287
  }
4088
4288
  /**
@@ -4096,24 +4296,24 @@ class fn extends Ke {
4096
4296
  * @returns a function that removes the handler.
4097
4297
  */
4098
4298
  on(e, s) {
4099
- if (l(this, H).has(e))
4299
+ if (l(this, G).has(e))
4100
4300
  throw new Error(
4101
4301
  `"${e}" already has a handler in this room. Remove it first.`
4102
4302
  );
4103
- return l(this, H).set(e, s), () => void l(this, H).delete(e);
4303
+ return l(this, G).set(e, s), () => void l(this, G).delete(e);
4104
4304
  }
4105
4305
  accepts(e, s) {
4106
4306
  return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
4107
4307
  }
4108
4308
  /** @internal Whether this room has any handler at all. */
4109
4309
  get hasHandlers() {
4110
- return l(this, H).size > 0;
4310
+ return l(this, G).size > 0;
4111
4311
  }
4112
4312
  async handle(e) {
4113
- const s = l(this, H).get(e.type);
4313
+ const s = l(this, G).get(e.type);
4114
4314
  if (!s) return { handled: !1 };
4115
4315
  try {
4116
- return { handled: !0, value: await s(e.payload, Xe(e)) };
4316
+ return { handled: !0, value: await s(e.payload, ns(e)) };
4117
4317
  } catch (r) {
4118
4318
  return {
4119
4319
  handled: !0,
@@ -4122,8 +4322,8 @@ class fn extends Ke {
4122
4322
  }
4123
4323
  }
4124
4324
  }
4125
- H = new WeakMap();
4126
- function Xe(n) {
4325
+ G = new WeakMap();
4326
+ function ns(n) {
4127
4327
  return {
4128
4328
  from: n.from,
4129
4329
  at: n.at,
@@ -4131,7 +4331,7 @@ function Xe(n) {
4131
4331
  kind: n.kind
4132
4332
  };
4133
4333
  }
4134
- function pn(n) {
4334
+ function Sn(n) {
4135
4335
  const t = n;
4136
4336
  if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
4137
4337
  const e = t.message;
@@ -4145,20 +4345,20 @@ function pn(n) {
4145
4345
  kind: typeof e.kind == "string" ? e.kind : void 0
4146
4346
  };
4147
4347
  }
4148
- var W, yt, F, G, V, v, ae, Ct, ze, Qe, Ze, ce;
4149
- class yn {
4348
+ var K, bt, U, V, J, E, ue, Nt, rs, is, os, de;
4349
+ class kn {
4150
4350
  constructor(t) {
4151
- b(this, v);
4152
- b(this, W);
4153
- b(this, yt);
4154
- b(this, F);
4155
- b(this, G, /* @__PURE__ */ new Map());
4156
- b(this, V, /* @__PURE__ */ new Set());
4157
- _(this, W, t), _(this, yt, t.listen((e) => void a(this, v, ze).call(this, e)));
4351
+ b(this, E);
4352
+ b(this, K);
4353
+ b(this, bt);
4354
+ b(this, U);
4355
+ b(this, V, /* @__PURE__ */ new Map());
4356
+ b(this, J, /* @__PURE__ */ new Set());
4357
+ _(this, K, t), _(this, bt, t.listen((e) => void a(this, E, rs).call(this, e)));
4158
4358
  }
4159
4359
  /** The collaboration room for this app. Always the same instance. */
4160
4360
  collab() {
4161
- return l(this, F) ?? _(this, F, new dn(l(this, W))), l(this, F);
4361
+ return l(this, U) ?? _(this, U, new En(l(this, K))), l(this, U);
4162
4362
  }
4163
4363
  /**
4164
4364
  * The room for commands from this account's external tools of one `kind`
@@ -4167,71 +4367,71 @@ class yn {
4167
4367
  */
4168
4368
  external(t) {
4169
4369
  const e = t ?? "";
4170
- let s = l(this, G).get(e);
4171
- return s || (s = new fn(l(this, W), t), l(this, G).set(e, s)), s;
4370
+ let s = l(this, V).get(e);
4371
+ return s || (s = new Tn(l(this, K), t), l(this, V).set(e, s)), s;
4172
4372
  }
4173
4373
  /** Stops listening. For tests and teardown; an app normally never calls it. */
4174
4374
  dispose() {
4175
- l(this, yt).call(this);
4375
+ l(this, bt).call(this);
4176
4376
  }
4177
4377
  }
4178
- W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), G = new WeakMap(), V = new WeakMap(), v = new WeakSet(), ae = function() {
4179
- return [...l(this, F) ? [l(this, F)] : [], ...l(this, G).values()];
4180
- }, Ct = function(t, e) {
4181
- if (t === "collab") return l(this, F);
4378
+ K = new WeakMap(), bt = new WeakMap(), U = new WeakMap(), V = new WeakMap(), J = new WeakMap(), E = new WeakSet(), ue = function() {
4379
+ return [...l(this, U) ? [l(this, U)] : [], ...l(this, V).values()];
4380
+ }, Nt = function(t, e) {
4381
+ if (t === "collab") return l(this, U);
4182
4382
  if (t === "external")
4183
- return l(this, G).get(typeof e == "string" ? e : "");
4184
- }, ze = async function(t) {
4185
- const e = pn(t);
4383
+ return l(this, V).get(typeof e == "string" ? e : "");
4384
+ }, rs = async function(t) {
4385
+ const e = Sn(t);
4186
4386
  if (e) {
4187
- if (e.type.startsWith(re)) {
4188
- a(this, v, Qe).call(this, e);
4387
+ if (e.type.startsWith(ce)) {
4388
+ a(this, E, is).call(this, e);
4189
4389
  return;
4190
4390
  }
4191
- await a(this, v, Ze).call(this, e);
4391
+ await a(this, E, os).call(this, e);
4192
4392
  }
4193
- }, Qe = function(t) {
4393
+ }, is = function(t) {
4194
4394
  var s, r, i;
4195
4395
  const e = t.payload ?? {};
4196
4396
  switch (t.type) {
4197
4397
  case "channel:joined":
4198
- (s = a(this, v, Ct).call(this, e.scope, e.kind)) == null || s.applyJoined();
4398
+ (s = a(this, E, Nt).call(this, e.scope, e.kind)) == null || s.applyJoined();
4199
4399
  break;
4200
4400
  case "channel:left":
4201
- (r = a(this, v, Ct).call(this, e.scope, e.kind)) == null || r.applyLeft();
4401
+ (r = a(this, E, Nt).call(this, e.scope, e.kind)) == null || r.applyLeft();
4202
4402
  break;
4203
4403
  case "channel:peers":
4204
- (i = a(this, v, Ct).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4404
+ (i = a(this, E, Nt).call(this, e.scope, e.kind)) == null || i.applyPeers(e.peers ?? []);
4205
4405
  break;
4206
4406
  case "channel:peer-joined":
4207
4407
  case "channel:peer-left": {
4208
4408
  if (!e.from) break;
4209
- const o = e.scope === "collab" ? [l(this, F)] : [...l(this, G).values()].filter(
4210
- (h) => h.accepts("external", e.kind)
4409
+ const o = e.scope === "collab" ? [l(this, U)] : [...l(this, V).values()].filter(
4410
+ (c) => c.accepts("external", e.kind)
4211
4411
  );
4212
- for (const h of o)
4213
- t.type === "channel:peer-joined" ? h == null || h.applyPeerJoined({ from: e.from, kind: e.kind }) : h == null || h.applyPeerLeft(e.from);
4412
+ for (const c of o)
4413
+ t.type === "channel:peer-joined" ? c == null || c.applyPeerJoined({ from: e.from, kind: e.kind }) : c == null || c.applyPeerLeft(e.from);
4214
4414
  break;
4215
4415
  }
4216
4416
  case "channel:error": {
4217
4417
  const o = new Error(String(t.payload));
4218
- a(this, v, ae).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4418
+ a(this, E, ue).call(this).map((u) => u.failPending(o)).some(Boolean) || console.error("[channel] error:", t.payload);
4219
4419
  break;
4220
4420
  }
4221
4421
  }
4222
- }, Ze = async function(t) {
4223
- const e = a(this, v, ae).call(this).filter((i) => i.accepts(t.scope, t.kind));
4422
+ }, os = async function(t) {
4423
+ const e = a(this, E, ue).call(this).filter((i) => i.accepts(t.scope, t.kind));
4224
4424
  let s = !1;
4225
4425
  for (const i of e) {
4226
4426
  const o = await i.handle(t);
4227
- o.handled && (s = !0, t.requestId && a(this, v, ce).call(this, t.requestId, o));
4427
+ o.handled && (s = !0, t.requestId && a(this, E, de).call(this, t.requestId, o));
4228
4428
  }
4229
- t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ce).call(this, t.requestId, {
4429
+ t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, E, de).call(this, t.requestId, {
4230
4430
  handled: !0,
4231
4431
  error: `No handler for "${t.type}".`
4232
4432
  });
4233
- }, ce = function(t, e) {
4234
- l(this, V).has(t) || (l(this, V).add(t), l(this, V).size > 500 && l(this, V).delete(l(this, V).values().next().value), l(this, W).post({
4433
+ }, de = function(t, e) {
4434
+ l(this, J).has(t) || (l(this, J).add(t), l(this, J).size > 500 && l(this, J).delete(l(this, J).values().next().value), l(this, K).post({
4235
4435
  type: "APP_CHANNEL_PUBLISH",
4236
4436
  message: {
4237
4437
  type: e.error === void 0 ? "reply" : "reply-error",
@@ -4240,9 +4440,9 @@ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), G = new WeakMap(), V =
4240
4440
  }
4241
4441
  }));
4242
4442
  };
4243
- const Y = "project", X = "notifications";
4244
- var nt, mt;
4245
- const me = class me extends te {
4443
+ const W = "project", X = "notifications";
4444
+ var at, _t;
4445
+ const _e = class _e extends re {
4246
4446
  /**
4247
4447
  * @param token - A bearer JWT, OR a function returning the current JWT
4248
4448
  * (sync or async). When a function is passed, it's invoked before every
@@ -4253,12 +4453,12 @@ const me = class me extends te {
4253
4453
  */
4254
4454
  constructor(e, s, r) {
4255
4455
  super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
4256
- b(this, nt);
4257
- b(this, mt);
4258
- typeof e == "function" && _(this, nt, e);
4456
+ b(this, at);
4457
+ b(this, _t);
4458
+ typeof e == "function" && _(this, at, e);
4259
4459
  }
4260
4460
  async resolveAccessToken() {
4261
- return l(this, nt) ? await l(this, nt).call(this) : super.resolveAccessToken();
4461
+ return l(this, at) ? await l(this, at).call(this) : super.resolveAccessToken();
4262
4462
  }
4263
4463
  /**
4264
4464
  * Creates a client from the platform context injected into
@@ -4267,7 +4467,7 @@ const me = class me extends te {
4267
4467
  * carries a fresh JWT on every navigation.
4268
4468
  */
4269
4469
  static fromPlatformContext(e) {
4270
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new me(s.accessToken, s.apiUrl, e);
4470
+ const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new _e(s.accessToken, s.apiUrl, e);
4271
4471
  return r.context = s, r;
4272
4472
  }
4273
4473
  /**
@@ -4295,7 +4495,7 @@ const me = class me extends te {
4295
4495
  * ```
4296
4496
  */
4297
4497
  get channel() {
4298
- return l(this, mt) ?? _(this, mt, new yn(ln())), l(this, mt);
4498
+ return l(this, _t) ?? _(this, _t, new kn(_n())), l(this, _t);
4299
4499
  }
4300
4500
  // ─── Projects (JWT-only backend routes) ──────────────────────────
4301
4501
  /**
@@ -4314,14 +4514,14 @@ const me = class me extends te {
4314
4514
  * ```
4315
4515
  */
4316
4516
  async listProjects() {
4317
- return await this.request("GET", Y);
4517
+ return await this.request("GET", W);
4318
4518
  }
4319
4519
  /**
4320
4520
  * Gets a project by ID. JWT-only — lives here because
4321
4521
  * `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
4322
4522
  */
4323
4523
  async getProject(e) {
4324
- return await this.request("GET", `${Y}/${e}`);
4524
+ return await this.request("GET", `${W}/${e}`);
4325
4525
  }
4326
4526
  /**
4327
4527
  * Gets the full project data (users, roles, files, folders) for a project.
@@ -4330,7 +4530,7 @@ const me = class me extends te {
4330
4530
  async getProjectData(e) {
4331
4531
  return await this.request(
4332
4532
  "GET",
4333
- `${Y}/${e}/data`
4533
+ `${W}/${e}/data`
4334
4534
  );
4335
4535
  }
4336
4536
  // ─── Account ──────────────────────────────────────────────────────
@@ -4355,7 +4555,7 @@ const me = class me extends te {
4355
4555
  async checkPermission(e) {
4356
4556
  return await this.request(
4357
4557
  "GET",
4358
- `${Y}/permissions/check`,
4558
+ `${W}/permissions/check`,
4359
4559
  { query: e }
4360
4560
  );
4361
4561
  }
@@ -4364,7 +4564,7 @@ const me = class me extends te {
4364
4564
  * single round-trip; results come back in the same order as `checks`.
4365
4565
  */
4366
4566
  async checkPermissionBatch(e) {
4367
- return (await this.request("POST", `${Y}/permissions/check/batch`, {
4567
+ return (await this.request("POST", `${W}/permissions/check/batch`, {
4368
4568
  body: JSON.stringify({ checks: e }),
4369
4569
  contentType: "application/json"
4370
4570
  })).results;
@@ -4476,7 +4676,7 @@ const me = class me extends te {
4476
4676
  async subscribeToAutomation(e, s, r) {
4477
4677
  return await this.request(
4478
4678
  "POST",
4479
- `${Y}/${e}/events/hooks/${s}/subscription`,
4679
+ `${W}/${e}/events/hooks/${s}/subscription`,
4480
4680
  {
4481
4681
  body: JSON.stringify(r ?? {}),
4482
4682
  contentType: "application/json"
@@ -4493,7 +4693,7 @@ const me = class me extends te {
4493
4693
  async updateAutomationSubscription(e, s, r) {
4494
4694
  return await this.request(
4495
4695
  "PATCH",
4496
- `${Y}/${e}/events/hooks/${s}/subscription`,
4696
+ `${W}/${e}/events/hooks/${s}/subscription`,
4497
4697
  {
4498
4698
  body: JSON.stringify(r),
4499
4699
  contentType: "application/json"
@@ -4527,7 +4727,7 @@ const me = class me extends te {
4527
4727
  * ```
4528
4728
  */
4529
4729
  async onNotification(e) {
4530
- const s = await this.resolveAccessToken(), r = ut(`${this.socketOrigin}/notifications`, {
4730
+ const s = await this.resolveAccessToken(), r = pt(`${this.socketOrigin}/notifications`, {
4531
4731
  auth: { accessToken: s },
4532
4732
  transports: ["websocket"]
4533
4733
  });
@@ -4543,38 +4743,41 @@ const me = class me extends te {
4543
4743
  ), () => r.disconnect();
4544
4744
  }
4545
4745
  };
4546
- nt = new WeakMap(), mt = new WeakMap();
4547
- let xe = me;
4548
- const wn = {
4746
+ at = new WeakMap(), _t = new WeakMap();
4747
+ let Be = _e;
4748
+ const An = {
4549
4749
  MAX_FIELDS: 200,
4550
4750
  MAX_KEY_LENGTH: 50,
4551
4751
  MAX_VALUE_LENGTH: 50
4552
- }, bn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, _n = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, En = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, vn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Tn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Sn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, kn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, On = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, An = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
4752
+ }, xn = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, $n = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, Cn = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, Rn = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, Nn = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Pn = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, Bn = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Ln = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Fn = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
4553
4753
  export {
4554
- bn as CDEManager,
4555
- yn as ChannelClient,
4556
- Ke as ChannelRoom,
4557
- _n as ClashesManager,
4558
- dn as CollabRoom,
4559
- te as EngineServicesClient,
4560
- fn as ExternalRoom,
4561
- En as FileList,
4562
- zs as FlowDoc,
4563
- vn as GISManager,
4564
- Tn as GitHistoryManager,
4565
- Sn as HelloWorld,
4566
- wn as METADATA_LIMITS,
4567
- xe as PlatformClient,
4568
- Xs as ProjectHistory,
4569
- kn as ProjectManager,
4570
- Zs as Recipes,
4571
- pe as RequestError,
4572
- Ae as STORAGE_BATCH_MAX,
4573
- Te as StaleHistoryError,
4574
- On as TopicsManager,
4575
- An as UIManager,
4576
- Qt as mintGuid,
4577
- Ye as orderByGraph,
4578
- ln as windowTransport
4754
+ xn as CDEManager,
4755
+ kn as ChannelClient,
4756
+ ss as ChannelRoom,
4757
+ $n as ClashesManager,
4758
+ En as CollabRoom,
4759
+ Ie as DOCUMENT_FILE,
4760
+ Kt as DOCUMENT_SCHEMA,
4761
+ re as EngineServicesClient,
4762
+ Tn as ExternalRoom,
4763
+ Cn as FileList,
4764
+ cn as FlowDoc,
4765
+ Rn as GISManager,
4766
+ Nn as GitHistoryManager,
4767
+ Pn as HelloWorld,
4768
+ An as METADATA_LIMITS,
4769
+ Be as PlatformClient,
4770
+ Ke as ProjectDocuments,
4771
+ an as ProjectHistory,
4772
+ Bn as ProjectManager,
4773
+ ln as Recipes,
4774
+ we as RequestError,
4775
+ Ne as STORAGE_BATCH_MAX,
4776
+ xe as StaleHistoryError,
4777
+ Ln as TopicsManager,
4778
+ Fn as UIManager,
4779
+ se as mintGuid,
4780
+ ts as orderByGraph,
4781
+ _n as windowTransport
4579
4782
  };
4580
4783
  //# sourceMappingURL=index.es.js.map