@thatopen/services 0.21.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 Ze = Object.defineProperty;
2
- var me = (n) => {
1
+ var cs = Object.defineProperty;
2
+ var ve = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var ts = (n, t, e) => t in n ? Ze(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var T = (n, t, e) => ts(n, typeof t != "symbol" ? t + "" : t, e), Pt = (n, t, e) => t.has(n) || me("Cannot " + e);
7
- var l = (n, t, e) => (Pt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), _ = (n, t, e) => t.has(n) ? me("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), b = (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]", Re = typeof ArrayBuffer == "function", Ce = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, ce = ({ type: n, data: t }, e, s) => $e && t instanceof Blob ? e ? s(t) : ge(t, s) : Re && (t instanceof ArrayBuffer || Ce(t)) ? e ? s(t) : ge(new Blob([t]), s) : s(P[n] + (t || "")), ge = (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 we(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 es(n, t) {
32
- if ($e && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(we).then(t);
34
- if (Re && (n.data instanceof ArrayBuffer || Ce(n.data)))
35
- return t(we(n.data));
36
- ce(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 ss = (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
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)], y[r++] = i << 2 | o >> 4, y[r++] = (o & 15) << 4 | h >> 2, y[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
- }, ns = typeof ArrayBuffer == "function", he = (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: rs(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
- }, rs = (n, t) => {
67
- if (ns) {
68
- const e = ss(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 ss = (n) => {
77
77
  default:
78
78
  return n instanceof ArrayBuffer ? n : n.buffer;
79
79
  }
80
- }, Pe = "", is = (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
- ce(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
- }, os = (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 = he(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 as() {
97
+ function ms() {
98
98
  return new TransformStream({
99
99
  transform(n, t) {
100
- es(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 as() {
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 _t(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 _t(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 cs(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 = _t(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 = _t(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 = _t(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
152
+ const u = Tt(e, 8), f = new DataView(u.buffer, u.byteOffset, u.length), y = f.getUint32(0);
153
153
  if (y > Math.pow(2, 21) - 1) {
154
- h.enqueue(jt);
154
+ c.enqueue(Ht);
155
155
  break;
156
156
  }
157
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 = _t(e, r);
162
- h.enqueue(he(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 hs(n);
172
+ const je = 4;
173
+ function v(n) {
174
+ if (n) return ws(n);
175
175
  }
176
- function hs(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 Ct = 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")(), ls = "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 us = A.setTimeout, ds = A.clearTimeout;
227
- function Nt(n, t) {
228
- t.useNativeTimers ? (n.setTimeoutFn = us.bind(A), n.clearTimeoutFn = ds.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 fs = 1.33;
231
- function ps(n) {
232
- return typeof n == "string" ? ys(n) : Math.ceil((n.byteLength || n.size) * fs);
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 ys(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 ms(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 gs(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 gs(n) {
254
254
  }
255
255
  return t;
256
256
  }
257
- class ws 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 le extends E {
262
+ class ye extends v {
263
263
  /**
264
264
  * Transport abstract constructor.
265
265
  *
@@ -267,7 +267,7 @@ class le 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 le extends E {
279
279
  * @protected
280
280
  */
281
281
  onError(t, e, s) {
282
- return super.emitReserved("error", new ws(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 le extends E {
316
316
  * @protected
317
317
  */
318
318
  onData(t) {
319
- const e = he(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 le 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 = ms(t);
356
+ const e = ks(t);
357
357
  return e.length ? "?" + e : "";
358
358
  }
359
359
  }
360
- class _s extends le {
360
+ class As extends ye {
361
361
  constructor() {
362
362
  super(...arguments), this._polling = !1;
363
363
  }
@@ -413,7 +413,7 @@ class _s extends le {
413
413
  return this.onClose({ description: "transport closed by the server" }), !1;
414
414
  this.onPacket(s);
415
415
  };
416
- os(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 _s extends le {
433
433
  * @protected
434
434
  */
435
435
  write(t) {
436
- this.writable = !1, is(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 _s extends le {
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 bs = Fe;
458
- function Es() {
457
+ const xs = Ge;
458
+ function $s() {
459
459
  }
460
- class vs extends _s {
460
+ class Cs extends As {
461
461
  /**
462
462
  * XHR Polling constructor.
463
463
  *
@@ -499,7 +499,7 @@ class vs extends _s {
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 = Es, 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", be);
603
+ attachEvent("onunload", ke);
604
604
  else if (typeof addEventListener == "function") {
605
- const n = "onpagehide" in A ? "pagehide" : "unload";
606
- addEventListener(n, be, !1);
605
+ const n = "onpagehide" in I ? "pagehide" : "unload";
606
+ addEventListener(n, ke, !1);
607
607
  }
608
608
  }
609
- function be() {
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 Ts = 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 Ss extends vs {
619
+ class Ns extends Cs {
620
620
  constructor(t) {
621
621
  super(t);
622
622
  const e = t && t.forceBase64;
623
- this.supportsBinary = Ts && !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 || bs))
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 ks extends le {
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 ks extends le {
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
- ce(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 && Ct(() => {
679
+ r && Pt(() => {
680
680
  this.writable = !0, this.emitReserved("drain");
681
681
  }, this.setTimeoutFn);
682
682
  });
@@ -693,19 +693,19 @@ class ks extends le {
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 Os extends ks {
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 As extends le {
708
+ class Ls extends ye {
709
709
  get name() {
710
710
  return "webtransport";
711
711
  }
@@ -721,12 +721,12 @@ class As extends le {
721
721
  this.onError("webtransport error", t);
722
722
  }), this._transport.ready.then(() => {
723
723
  this._transport.createBidirectionalStream().then((t) => {
724
- const e = cs(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), r = as();
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 As extends le {
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 && Ct(() => {
743
+ r && Pt(() => {
744
744
  this.writable = !0, this.emitReserved("drain");
745
745
  }, this.setTimeoutFn);
746
746
  });
@@ -751,11 +751,11 @@ class As extends le {
751
751
  (t = this._transport) === null || t === void 0 || t.close();
752
752
  }
753
753
  }
754
- const Is = {
755
- websocket: Os,
756
- webtransport: As,
757
- polling: Ss
758
- }, xs = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, $s = [
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 Is = {
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 = xs.exec(n || ""), i = {}, o = 14;
779
+ let r = qs.exec(n || ""), i = {}, o = 14;
780
780
  for (; o--; )
781
- i[$s[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 = Rs(i, i.path), i.queryKey = Cs(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 Rs(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 Cs(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 V extends E {
798
+ class Y extends v {
799
799
  /**
800
800
  * Socket constructor.
801
801
  *
@@ -803,11 +803,11 @@ class V extends E {
803
803
  * @param {Object} opts - options
804
804
  */
805
805
  constructor(t, e) {
806
- if (super(), this.binaryType = ls, 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 V 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 = gs(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 V 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 V extends E {
863
863
  }, 0);
864
864
  return;
865
865
  }
866
- const t = this.opts.rememberUpgrade && V.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 V extends E {
882
882
  * @private
883
883
  */
884
884
  onOpen() {
885
- this.readyState = "open", V.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 V 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 += ps(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 V 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, Ct(() => {
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 V extends E {
1046
1046
  * @private
1047
1047
  */
1048
1048
  _onError(t) {
1049
- if (V.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 V 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
- V.protocol = Be;
1069
- class Ns extends V {
1068
+ Y.protocol = je;
1069
+ class Ms extends Y {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1083,19 +1083,19 @@ class Ns extends V {
1083
1083
  */
1084
1084
  _probe(t) {
1085
1085
  let e = this.createTransport(t), s = !1;
1086
- V.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
- V.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1093
+ Y.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1094
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
- const R = new Error("probe error");
1098
- R.transport = e.name, this.emitReserved("upgradeError", R);
1097
+ const C = new Error("probe error");
1098
+ C.transport = e.name, this.emitReserved("upgradeError", C);
1099
1099
  }
1100
1100
  }));
1101
1101
  };
@@ -1103,10 +1103,10 @@ class Ns extends V {
1103
1103
  s || (s = !0, y(), e.close(), e = null);
1104
1104
  }
1105
1105
  const o = (w) => {
1106
- const R = new Error("probe error: " + w);
1107
- R.transport = e.name, i(), this.emitReserved("upgradeError", R);
1106
+ const C = new Error("probe error: " + w);
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() {
@@ -1116,9 +1116,9 @@ class Ns extends V {
1116
1116
  e && w.name !== e.name && i();
1117
1117
  }
1118
1118
  const y = () => {
1119
- e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", h), this.off("close", u), this.off("upgrading", f);
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 Ns extends V {
1138
1138
  return e;
1139
1139
  }
1140
1140
  }
1141
- let Ps = class extends Ns {
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) => Is[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 Bs(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 Ls = typeof ArrayBuffer == "function", qs = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, je = Object.prototype.toString, Fs = typeof Blob == "function" || typeof Blob < "u" && je.call(Blob) === "[object BlobConstructor]", Us = typeof File == "function" || typeof File < "u" && je.call(File) === "[object FileConstructor]";
1154
- function ue(n) {
1155
- return Ls && (n instanceof ArrayBuffer || qs(n)) || Fs && n instanceof Blob || Us && 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 (ue(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 Ds(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 (ue(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 js(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 Ms = [
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 Hs {
1234
+ class Qs {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,7 +1247,7 @@ class Hs {
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 Hs {
1267
1267
  * a list of buffers.
1268
1268
  */
1269
1269
  encodeAsBinary(t) {
1270
- const e = Ds(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 de extends E {
1274
+ class ge extends v {
1275
1275
  /**
1276
1276
  * Decoder constructor
1277
1277
  */
@@ -1293,8 +1293,8 @@ class de 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 Gs(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1297
- } else if (ue(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 de 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 (!Vs(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 de extends E {
1352
1352
  }
1353
1353
  if (t.charAt(++e)) {
1354
1354
  const i = this.tryParse(t.substr(e));
1355
- if (de.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 de extends E {
1369
1369
  static isPayloadValid(t, e) {
1370
1370
  switch (t) {
1371
1371
  case g.CONNECT:
1372
- return Ee(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" || Ee(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" && Ms.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 de extends E {
1389
1389
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1390
1390
  }
1391
1391
  }
1392
- class Gs {
1392
+ class Zs {
1393
1393
  constructor(t) {
1394
1394
  this.packet = t, this.buffers = [], this.reconPack = t;
1395
1395
  }
@@ -1403,7 +1403,7 @@ class Gs {
1403
1403
  */
1404
1404
  takeBinaryData(t) {
1405
1405
  if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1406
- const e = js(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 Gs {
1415
1415
  this.reconPack = null, this.buffers = [];
1416
1416
  }
1417
1417
  }
1418
- const Vs = 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 Ee(n) {
1421
+ function Oe(n) {
1422
1422
  return Object.prototype.toString.call(n) === "[object Object]";
1423
1423
  }
1424
- const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1424
+ const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1425
1425
  __proto__: null,
1426
- Decoder: de,
1427
- Encoder: Hs,
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 Ys = 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 Ys = 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 (Ys.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;
@@ -1571,8 +1571,8 @@ class Me extends E {
1571
1571
  const y = this.ids++, w = e.pop();
1572
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 nt(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
- nt.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 @@ nt.prototype.duration = function() {
2046
2046
  }
2047
2047
  return Math.min(n, this.max) | 0;
2048
2048
  };
2049
- nt.prototype.reset = function() {
2049
+ ct.prototype.reset = function() {
2050
2050
  this.attempts = 0;
2051
2051
  };
2052
- nt.prototype.setMin = function(n) {
2052
+ ct.prototype.setMin = function(n) {
2053
2053
  this.ms = n;
2054
2054
  };
2055
- nt.prototype.setMax = function(n) {
2055
+ ct.prototype.setMax = function(n) {
2056
2056
  this.max = n;
2057
2057
  };
2058
- nt.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 nt({
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 || Js;
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 Ps(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
- Ct(() => {
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,90 +2296,204 @@ class Jt extends E {
2296
2296
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2297
2297
  }
2298
2298
  }
2299
- const rt = {};
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 = Bs(n, t.path || "/socket.io"), s = e.source, r = e.id, i = e.path, o = rt[r] && i in rt[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) : (rt[r] || (rt[r] = new Jt(s, t)), u = rt[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 ve 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 Te = "bimterop", Se = "revitflow_history.json", it = "revitflow_ops.json", ke = "revitflow/ops@1", Ws = "revitflow_model.frag", Ks = "revitflow_", bt = () => `v-${Date.now()}`;
2320
- function He(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 Y(n) {
2427
+ function N(n) {
2324
2428
  return String(n._id ?? n.id ?? "");
2325
2429
  }
2326
- var x, dt, Yt;
2327
- class Xs {
2430
+ var x, mt, Qt;
2431
+ class an {
2328
2432
  constructor(t, e) {
2329
- _(this, dt);
2330
- _(this, x);
2433
+ b(this, mt);
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, Yt).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 He(e, t)) {
2445
+ for (const r of Qe(e, t)) {
2342
2446
  const i = String(r.name ?? ""), o = i.indexOf("-");
2343
- o <= 0 || s.push({
2447
+ if (o <= 0) continue;
2448
+ const u = (await this.client.listFiles({
2449
+ folderId: N(r)
2450
+ })).map(
2451
+ (w) => String(w.name ?? "")
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;
2455
+ s.push({
2344
2456
  source: i.slice(0, o),
2345
2457
  docId: i.slice(o + 1),
2346
- modelName: void 0
2458
+ folderId: N(r),
2459
+ modelName: f,
2460
+ ...y ? {} : { empty: !0 }
2347
2461
  });
2348
2462
  }
2349
2463
  return s;
2350
2464
  }
2351
2465
  /** One document's history. `source` and `docId` as {@link docs} lists them. */
2352
2466
  doc(t, e) {
2353
- return new zs(this.client, this, t, e);
2467
+ return new cn(this.client, this, t, e);
2354
2468
  }
2355
2469
  /** @internal The `bimterop` folder id, resolved once. */
2356
2470
  async rootFolderId(t = !1) {
2357
2471
  if (l(this, x)) return l(this, x);
2358
- const e = await a(this, dt, Yt).call(this);
2472
+ const e = await a(this, mt, Qt).call(this);
2359
2473
  if (e) return e;
2360
2474
  if (!t) return;
2361
2475
  const s = await this.client.createFolder(
2362
- Te,
2476
+ $e,
2363
2477
  void 0,
2364
2478
  this.projectId
2365
2479
  );
2366
- return b(this, x, Y(s)), l(this, x);
2480
+ return _(this, x, N(s)), l(this, x);
2367
2481
  }
2368
2482
  }
2369
- x = new WeakMap(), dt = new WeakSet(), Yt = async function() {
2483
+ x = new WeakMap(), mt = new WeakSet(), Qt = async function() {
2370
2484
  if (l(this, x)) return l(this, x);
2371
2485
  const e = (await this.client.listFolders({
2372
2486
  projectId: this.projectId
2373
2487
  })).find(
2374
- (s) => String(s.name ?? "") === Te && !s.parentId
2488
+ (s) => String(s.name ?? "") === $e && !s.parentId
2375
2489
  );
2376
- return e && b(this, x, Y(e)), l(this, x);
2490
+ return e && _(this, x, N(e)), l(this, x);
2377
2491
  };
2378
- var L, p, at, ct, Wt, St, kt, Kt, Ot, ht, At, Xt, Ge;
2379
- class zs {
2492
+ var q, d, Z, tt, F, Zt, ut, et, te, At, dt, xt, ee, Ze;
2493
+ class cn {
2380
2494
  constructor(t, e, s, r) {
2381
- _(this, p);
2382
- _(this, L);
2495
+ b(this, d);
2496
+ b(this, q);
2383
2497
  this.client = t, this.project = e, this.source = s, this.docId = r;
2384
2498
  }
2385
2499
  // ─── Reading ───────────────────────────────────────────────────────────────
@@ -2389,8 +2503,8 @@ class zs {
2389
2503
  * Each version gets its `ordinal` filled in.
2390
2504
  */
2391
2505
  async timeline() {
2392
- const t = await a(this, p, Ot).call(this);
2393
- return Ve((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) ?? []);
2394
2508
  }
2395
2509
  /** The head of the timeline, or null before the first sync. */
2396
2510
  async latest() {
@@ -2410,13 +2524,97 @@ class zs {
2410
2524
  }
2411
2525
  /** The visible model .frag as last fully exported. */
2412
2526
  async model() {
2413
- const t = await a(this, p, kt).call(this);
2527
+ const t = await a(this, d, et).call(this);
2414
2528
  if (!t)
2415
2529
  throw new Error(
2416
2530
  `Document ${this.source}-${this.docId} has no model file yet.`
2417
2531
  );
2418
2532
  return await (await this.client.downloadFile(t.id)).blob();
2419
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
+ }
2420
2618
  // ─── Writing versions ─────────────────────────────────────────────────────
2421
2619
  /**
2422
2620
  * Appends one version: uploads the geometry it carries, then the updated
@@ -2425,29 +2623,29 @@ class zs {
2425
2623
  * silent fork.
2426
2624
  */
2427
2625
  async sync(t) {
2428
- var h;
2429
- const e = await a(this, p, ct).call(this, !0);
2430
- let s = await a(this, p, 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) ?? {
2431
2629
  model: this.docId,
2432
2630
  commits: []
2433
2631
  };
2434
- const r = Oe(s.commits);
2632
+ const r = Re(s.commits);
2435
2633
  if (t.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== t.expectedLatestGuid)
2436
- throw new ve(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2634
+ throw new xe(t.expectedLatestGuid, r == null ? void 0 : r.guid);
2437
2635
  const i = {
2438
- guid: zt(),
2636
+ guid: se(),
2439
2637
  ...r ? { parents: [r.guid] } : {},
2440
2638
  author: t.author,
2441
2639
  source: t.source,
2442
2640
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2443
2641
  ...t.message ? { message: t.message } : {},
2444
2642
  ...t.userId ? { userId: t.userId } : {},
2445
- ...(h = t.appliedOps) != null && h.length ? { appliedOps: t.appliedOps } : {},
2643
+ ...(c = t.appliedOps) != null && c.length ? { appliedOps: t.appliedOps } : {},
2446
2644
  changes: t.changes,
2447
- counts: Qs(t.changes)
2645
+ counts: hn(t.changes)
2448
2646
  };
2449
- if (t.model && (await a(this, p, Ge).call(this, e, t.model), i.full = !0), t.delta) {
2450
- const u = await a(this, p, 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);
2451
2649
  if (!u)
2452
2650
  throw new Error(
2453
2651
  "A delta needs the model file to hang from: sync a full model first."
@@ -2460,20 +2658,20 @@ class zs {
2460
2658
  f._id ?? f.id
2461
2659
  );
2462
2660
  }
2463
- const o = await a(this, p, Ot).call(this);
2661
+ const o = await a(this, d, At).call(this);
2464
2662
  if (o) {
2465
2663
  s = o;
2466
- const u = Oe(s.commits);
2664
+ const u = Re(s.commits);
2467
2665
  if (t.expectedLatestGuid !== void 0 && (u == null ? void 0 : u.guid) !== t.expectedLatestGuid)
2468
- throw new ve(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2666
+ throw new xe(t.expectedLatestGuid, u == null ? void 0 : u.guid);
2469
2667
  u && !i.parents && (i.parents = [u.guid]);
2470
2668
  }
2471
- return s.commits.push(i), await a(this, p, At).call(this, e, Se, s), i;
2669
+ return s.commits.push(i), await a(this, d, xt).call(this, e, Xt, s), i;
2472
2670
  }
2473
2671
  // ─── Suggestions (change requests) ────────────────────────────────────────
2474
2672
  /** Every suggestion in the document's queue, pending or resolved. */
2475
2673
  async suggestions() {
2476
- const t = await a(this, p, ht).call(this);
2674
+ const t = await a(this, d, dt).call(this);
2477
2675
  return (t == null ? void 0 : t.ops) ?? [];
2478
2676
  }
2479
2677
  /** The suggestions still waiting for the owner, oldest first. */
@@ -2485,8 +2683,9 @@ class zs {
2485
2683
  * uploaded as a hidden file under the suggestions index.
2486
2684
  */
2487
2685
  async suggest(t) {
2488
- const e = await a(this, p, ct).call(this, !0), s = await a(this, p, ht).call(this) ?? { schema: ke, ops: [] }, r = await a(this, p, St).call(this, it), i = {
2489
- opId: t.opId ?? zt(),
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,
2490
2689
  title: t.title,
2491
2690
  verb: t.verb,
2492
2691
  author: t.author,
@@ -2498,16 +2697,16 @@ class zs {
2498
2697
  ...t.baseCommitGuid ? { baseCommitGuid: t.baseCommitGuid } : {}
2499
2698
  };
2500
2699
  if (t.payload) {
2501
- const h = r ?? await a(this, p, Xt).call(this, e, it, 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(
2502
2701
  t.payload,
2503
- h.id
2702
+ c.id
2504
2703
  );
2505
2704
  i.fragId = String(
2506
2705
  u._id ?? u.id
2507
2706
  );
2508
2707
  }
2509
- const o = await a(this, p, ht).call(this) ?? s;
2510
- return o.schema ?? (o.schema = ke), o.ops.push(i), await a(this, p, At).call(this, e, it, 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;
2511
2710
  }
2512
2711
  /** A suggestion's .frag payload. */
2513
2712
  async suggestionPayload(t) {
@@ -2521,18 +2720,20 @@ class zs {
2521
2720
  * use it for `discarded`.
2522
2721
  */
2523
2722
  async resolveSuggestion(t, e) {
2524
- const s = await a(this, p, ct).call(this, !1);
2723
+ const s = await a(this, d, F).call(this, !1);
2525
2724
  if (!s) throw new Error("This document has no suggestion queue.");
2526
- const r = await a(this, p, 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);
2527
2726
  if (!r || !i)
2528
2727
  throw new Error(`No suggestion ${t} in this document's queue.`);
2529
- return Object.assign(i, e), await a(this, p, At).call(this, s, it, r), i;
2728
+ return Object.assign(i, e), await a(this, d, xt).call(this, s, Q, r), i;
2530
2729
  }
2531
2730
  }
2532
- L = new WeakMap(), p = 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() {
2533
2734
  return `${this.source}-${this.docId}`;
2534
- }, ct = async function(t) {
2535
- if (l(this, L)) return l(this, L);
2735
+ }, F = async function(t) {
2736
+ if (l(this, q)) return l(this, q);
2536
2737
  const e = await this.project.rootFolderId(t);
2537
2738
  if (!e)
2538
2739
  throw new Error(
@@ -2541,94 +2742,94 @@ L = new WeakMap(), p = new WeakSet(), at = function() {
2541
2742
  const s = await this.client.listFolders({
2542
2743
  parentFolderId: e,
2543
2744
  projectId: this.project.projectId
2544
- }), r = He(s, e).find(
2545
- (o) => String(o.name ?? "") === l(this, p, at)
2745
+ }), r = Qe(s, e).find(
2746
+ (o) => String(o.name ?? "") === l(this, d, tt)
2546
2747
  );
2547
2748
  if (r)
2548
- return b(this, L, Y(r)), l(this, L);
2749
+ return _(this, q, N(r)), l(this, q);
2549
2750
  if (!t)
2550
2751
  throw new Error(
2551
- `Document ${l(this, p, at)} does not exist in this project.`
2752
+ `Document ${l(this, d, tt)} does not exist in this project.`
2552
2753
  );
2553
2754
  const i = await this.client.createFolder(
2554
- l(this, p, at),
2755
+ l(this, d, tt),
2555
2756
  e,
2556
2757
  this.project.projectId
2557
2758
  );
2558
- return b(this, L, Y(i)), l(this, L);
2559
- }, Wt = async function() {
2560
- const t = await a(this, p, 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);
2561
2762
  return (await this.client.listFiles({ folderId: t })).map((s) => ({
2562
- id: Y(s),
2763
+ id: N(s),
2563
2764
  name: String(s.name ?? "")
2564
2765
  }));
2565
- }, St = async function(t) {
2766
+ }, ut = async function(t) {
2566
2767
  try {
2567
- return (await a(this, p, Wt).call(this)).find((e) => e.name === t);
2768
+ return (await a(this, d, Zt).call(this)).find((e) => e.name === t);
2568
2769
  } catch {
2569
2770
  return;
2570
2771
  }
2571
- }, kt = async function() {
2772
+ }, et = async function() {
2572
2773
  try {
2573
- const t = await a(this, p, Wt).call(this);
2574
- return t.find((e) => e.name === Ws) ?? t.find(
2575
- (e) => e.name.endsWith(".frag") && !e.name.startsWith(Ks)
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)
2576
2777
  );
2577
2778
  } catch {
2578
2779
  return;
2579
2780
  }
2580
- }, Kt = async function(t) {
2581
- const e = await a(this, p, St).call(this, t);
2781
+ }, te = async function(t) {
2782
+ const e = await a(this, d, ut).call(this, t);
2582
2783
  if (!e) return;
2583
2784
  const r = await (await this.client.downloadFile(e.id)).text();
2584
2785
  if (r.trim())
2585
2786
  return JSON.parse(r);
2586
- }, Ot = function() {
2587
- return a(this, p, Kt).call(this, Se);
2588
- }, ht = function() {
2589
- return a(this, p, Kt).call(this, it);
2590
- }, 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) {
2591
2792
  const r = new Blob([JSON.stringify(s)], {
2592
2793
  type: "application/json"
2593
- }), i = await a(this, p, St).call(this, e);
2794
+ }), i = await a(this, d, ut).call(this, e);
2594
2795
  return i ? (await this.client.updateFile(i.id, {
2595
2796
  file: r,
2596
- versionTag: bt()
2597
- }), i) : await a(this, p, Xt).call(this, t, e, s);
2598
- }, Xt = 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) {
2599
2800
  const r = new Blob([JSON.stringify(s)], {
2600
2801
  type: "application/json"
2601
2802
  }), i = await this.client.createFile({
2602
2803
  file: r,
2603
2804
  name: e,
2604
- versionTag: bt(),
2805
+ versionTag: St(),
2605
2806
  parentFolderId: t,
2606
2807
  projectId: this.project.projectId
2607
2808
  }), o = i.item;
2608
- return { id: Y(o ?? i), name: e };
2609
- }, Ge = async function(t, e) {
2610
- const s = await a(this, p, 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);
2611
2812
  if (s)
2612
2813
  return await this.client.updateFile(s.id, {
2613
2814
  file: e,
2614
- versionTag: bt()
2815
+ versionTag: St()
2615
2816
  }), s;
2616
- const r = `${l(this, p, at)}.frag`, i = await this.client.createFile({
2817
+ const r = `${l(this, d, tt)}.frag`, i = await this.client.createFile({
2617
2818
  file: e,
2618
2819
  name: r,
2619
- versionTag: bt(),
2820
+ versionTag: St(),
2620
2821
  parentFolderId: t,
2621
2822
  projectId: this.project.projectId
2622
2823
  }), o = i.item;
2623
- return { id: Y(o ?? i), name: r };
2824
+ return { id: N(o ?? i), name: r };
2624
2825
  };
2625
- function Qs(n) {
2826
+ function hn(n) {
2626
2827
  const t = { added: 0, modified: 0, removed: 0 };
2627
2828
  for (const e of n)
2628
2829
  e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
2629
2830
  return t;
2630
2831
  }
2631
- function Ve(n) {
2832
+ function ts(n) {
2632
2833
  var u;
2633
2834
  if (n.length <= 1)
2634
2835
  return n.forEach((f, y) => f.ordinal = y), [...n];
@@ -2643,61 +2844,84 @@ function Ve(n) {
2643
2844
  }
2644
2845
  const r = (f, y) => String(f.timestamp).localeCompare(String(y.timestamp));
2645
2846
  s.sort(r);
2646
- const i = [], o = [...s].reverse(), h = /* @__PURE__ */ new Set();
2847
+ const i = [], o = [...s].reverse(), c = /* @__PURE__ */ new Set();
2647
2848
  for (; o.length; ) {
2648
2849
  const f = o.pop();
2649
- if (h.has(f.guid)) continue;
2650
- h.add(f.guid), i.push(f);
2850
+ if (c.has(f.guid)) continue;
2851
+ c.add(f.guid), i.push(f);
2651
2852
  const y = (e.get(f.guid) ?? []).sort(r);
2652
2853
  for (let w = y.length - 1; w >= 0; w--) o.push(y[w]);
2653
2854
  }
2654
2855
  for (const f of n)
2655
- h.has(f.guid) || i.push(f);
2856
+ c.has(f.guid) || i.push(f);
2656
2857
  return i.forEach((f, y) => f.ordinal = y), i;
2657
2858
  }
2658
- function Oe(n) {
2659
- const t = Ve(n);
2859
+ function Re(n) {
2860
+ const t = ts(n);
2660
2861
  return t[t.length - 1];
2661
2862
  }
2662
- function zt() {
2863
+ function se() {
2663
2864
  const n = globalThis.crypto;
2664
2865
  return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2665
2866
  const e = Math.random() * 16 | 0;
2666
2867
  return (t === "x" ? e : e & 3 | 8).toString(16);
2667
2868
  });
2668
2869
  }
2669
- var j, ft, Qt;
2670
- class Zs {
2870
+ var H, gt, ne;
2871
+ class ln {
2671
2872
  constructor(t) {
2672
- _(this, ft);
2673
- _(this, j, /* @__PURE__ */ new Map());
2873
+ b(this, gt);
2874
+ b(this, H, /* @__PURE__ */ new Map());
2674
2875
  this.client = t;
2675
2876
  }
2676
2877
  /** Registers a recipe. One per name; a second with the same name throws. */
2677
2878
  register(t) {
2678
- if (l(this, j).has(t.name))
2879
+ if (l(this, H).has(t.name))
2679
2880
  throw new Error(`A recipe named "${t.name}" is already registered.`);
2680
- l(this, j).set(t.name, t);
2881
+ l(this, H).set(t.name, t);
2681
2882
  }
2682
2883
  /** The registered recipes, optionally filtered by target application. */
2683
2884
  list(t) {
2684
- return [...l(this, j).values()].filter(
2885
+ return [...l(this, H).values()].filter(
2685
2886
  (s) => (!(t != null && t.to) || s.to === t.to) && (!(t != null && t.input) || s.inputs.includes(t.input))
2686
2887
  );
2687
2888
  }
2688
2889
  /** A registered recipe by name, or undefined. */
2689
2890
  get(t) {
2690
- return l(this, j).get(t);
2891
+ return l(this, H).get(t);
2691
2892
  }
2692
2893
  /**
2693
- * Runs a recipe WITHOUT queueing anything: the dry pass. Returns the
2694
- * recipe's result — title, tallies per rule, targets — so an app can show
2695
- * what would be proposed before anybody confirms. The payload it may have
2696
- * built is discarded along with its opId.
2894
+ * Runs a recipe WITHOUT queueing anything: the dry pass. Returns a
2895
+ * {@link RecipePlan} — the result to show (title, tallies, targets) plus
2896
+ * everything {@link queue} needs to queue EXACTLY this, payload and opId
2897
+ * included, with no second run. Discard it and the plan never happened.
2697
2898
  */
2698
2899
  async plan(t, e) {
2699
- const { result: s } = await a(this, ft, Qt).call(this, t, e);
2700
- return s;
2900
+ const { base: s, opId: r, result: i } = await a(this, gt, ne).call(this, t, e);
2901
+ return {
2902
+ opId: r,
2903
+ projectId: e.projectId,
2904
+ target: e.target,
2905
+ ...s != null && s.guid ? { baseCommitGuid: s.guid } : {},
2906
+ result: i
2907
+ };
2908
+ }
2909
+ /**
2910
+ * Queues exactly what {@link plan} planned: same opId, same payload, no
2911
+ * second execution. The pair plan → confirm → queue is the UI flow; `run`
2912
+ * is the one-shot shortcut.
2913
+ */
2914
+ async queue(t, e) {
2915
+ return { suggestion: await this.client.history(t.projectId).doc(t.target.source, t.target.docId).suggest({
2916
+ opId: t.opId,
2917
+ title: t.result.title,
2918
+ verb: t.result.verb,
2919
+ author: e.author,
2920
+ payload: t.result.payload,
2921
+ targets: t.result.targets,
2922
+ userId: e.userId,
2923
+ baseCommitGuid: t.baseCommitGuid
2924
+ }), result: t.result };
2701
2925
  }
2702
2926
  /**
2703
2927
  * Runs a recipe and queues its suggestion on the target document. Safe to
@@ -2706,7 +2930,7 @@ class Zs {
2706
2930
  * to show the tallies before queueing.
2707
2931
  */
2708
2932
  async run(t, e) {
2709
- const { targetDoc: s, base: r, opId: i, result: o } = await a(this, ft, Qt).call(this, t, e);
2933
+ const { targetDoc: s, base: r, opId: i, result: o } = await a(this, gt, ne).call(this, t, e);
2710
2934
  return { suggestion: await s.suggest({
2711
2935
  opId: i,
2712
2936
  title: o.title,
@@ -2719,14 +2943,14 @@ class Zs {
2719
2943
  }), result: o };
2720
2944
  }
2721
2945
  }
2722
- j = new WeakMap(), ft = new WeakSet(), Qt = async function(t, e) {
2723
- const s = l(this, j).get(t);
2946
+ H = new WeakMap(), gt = new WeakSet(), ne = async function(t, e) {
2947
+ const s = l(this, H).get(t);
2724
2948
  if (!s) throw new Error(`No recipe named "${t}" is registered.`);
2725
2949
  if (s.to !== e.target.source)
2726
2950
  throw new Error(
2727
2951
  `Recipe "${t}" writes ${s.to}, but the target document belongs to ${e.target.source}.`
2728
2952
  );
2729
- const r = this.client.history(e.projectId).doc(e.target.source, e.target.docId), i = await r.latest(), o = zt(), 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({
2730
2954
  client: this.client,
2731
2955
  projectId: e.projectId,
2732
2956
  targetDoc: r,
@@ -2734,10 +2958,10 @@ j = new WeakMap(), ft = new WeakSet(), Qt = async function(t, e) {
2734
2958
  input: e.input,
2735
2959
  settings: e.settings ?? {}
2736
2960
  });
2737
- return { recipe: s, targetDoc: r, base: i, opId: o, result: h };
2961
+ return { recipe: s, targetDoc: r, base: i, opId: o, result: c };
2738
2962
  };
2739
- const Ae = 100;
2740
- function tn(n) {
2963
+ const Ne = 100;
2964
+ function un(n) {
2741
2965
  try {
2742
2966
  const t = JSON.parse(n);
2743
2967
  if (t && typeof t == "object") {
@@ -2752,14 +2976,14 @@ function tn(n) {
2752
2976
  }
2753
2977
  return {};
2754
2978
  }
2755
- function en(n) {
2979
+ function dn(n) {
2756
2980
  if (!n || typeof n != "object") return;
2757
2981
  const t = n.retryAfter;
2758
2982
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
2759
2983
  }
2760
- class fe extends Error {
2984
+ class we extends Error {
2761
2985
  constructor(e, s, r, i) {
2762
- const o = tn(r);
2986
+ const o = un(r);
2763
2987
  super(o.message ?? `${s || "Request failed"} (${e})`);
2764
2988
  T(this, "status");
2765
2989
  T(this, "code");
@@ -2770,11 +2994,11 @@ class fe extends Error {
2770
2994
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
2771
2995
  */
2772
2996
  T(this, "retryAfter");
2773
- 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);
2774
2998
  }
2775
2999
  }
2776
- const C = "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));
2777
- 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) {
2778
3002
  var r, i;
2779
3003
  const t = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
2780
3004
  if (!t) return;
@@ -2784,18 +3008,18 @@ function an(n) {
2784
3008
  if (!Number.isNaN(s))
2785
3009
  return Math.max(0, (s - Date.now()) / 1e3);
2786
3010
  }
2787
- function cn(n) {
2788
- return n instanceof fe ? n.status === 429 || n.status >= 500 : !0;
3011
+ function wn(n) {
3012
+ return n instanceof we ? n.status === 429 || n.status >= 500 : !0;
2789
3013
  }
2790
- function hn(n, t) {
3014
+ function bn(n, t) {
2791
3015
  const e = Math.min(
2792
- nn * 2 ** t,
2793
- Ie
2794
- ), s = e * rn * Math.random(), r = n instanceof fe && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
2795
- 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;
2796
3020
  }
2797
- var c, te, d, D, pt, lt, It, xt, ee, se, Je;
2798
- const pe = class pe {
3021
+ var h, ie, p, M, wt, ft, $t, Ct, oe, ae, es;
3022
+ const be = class be {
2799
3023
  /**
2800
3024
  * Creates a new EngineServicesClient instance.
2801
3025
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -2804,7 +3028,7 @@ const pe = class pe {
2804
3028
  * @param props - Optional configuration (retry count, auth mode, etc.).
2805
3029
  */
2806
3030
  constructor(t, e, s) {
2807
- _(this, c);
3031
+ b(this, h);
2808
3032
  T(this, "apiUrl");
2809
3033
  T(this, "accessToken");
2810
3034
  T(this, "wsUrl");
@@ -2823,10 +3047,10 @@ const pe = class pe {
2823
3047
  * Populated automatically when using {@link fromPlatformContext}.
2824
3048
  */
2825
3049
  T(this, "context");
2826
- _(this, pt);
3050
+ b(this, wt);
2827
3051
  const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
2828
- let h = e;
2829
- 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) {
2830
3054
  let u = o;
2831
3055
  u.charAt(u.length - 1) === "/" && (u = u.slice(0, -1)), this.localServerUrl = u;
2832
3056
  }
@@ -2848,7 +3072,7 @@ const pe = class pe {
2848
3072
  * ```
2849
3073
  */
2850
3074
  static fromPlatformContext(t) {
2851
- const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new pe(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, {
2852
3076
  ...t,
2853
3077
  useBearer: !0
2854
3078
  });
@@ -2924,7 +3148,7 @@ const pe = class pe {
2924
3148
  * cleaning logic is applied identically.
2925
3149
  */
2926
3150
  async request(t, e, s) {
2927
- return a(this, c, d).call(this, t, e, s);
3151
+ return a(this, h, p).call(this, t, e, s);
2928
3152
  }
2929
3153
  // ─── Files ───────────────────────────────────────────────────────
2930
3154
  /**
@@ -2934,9 +3158,9 @@ const pe = class pe {
2934
3158
  */
2935
3159
  async listFiles(t) {
2936
3160
  const { folderId: e, archived: s, projectId: r } = t || {};
2937
- return e ? await a(this, c, d).call(this, "GET", `${C}/${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}`, {
2938
3162
  query: {
2939
- itemType: Ft,
3163
+ itemType: Ut,
2940
3164
  archived: s,
2941
3165
  ...r && { projectId: r }
2942
3166
  }
@@ -2949,7 +3173,7 @@ const pe = class pe {
2949
3173
  * @returns The file item, optionally with version history.
2950
3174
  */
2951
3175
  async getFile(t, e) {
2952
- return await a(this, c, se).call(this, t, e);
3176
+ return await a(this, h, ae).call(this, t, e);
2953
3177
  }
2954
3178
  /**
2955
3179
  * Uploads a new file.
@@ -2957,7 +3181,7 @@ const pe = class pe {
2957
3181
  * @returns The created item and its first version.
2958
3182
  */
2959
3183
  async createFile(t) {
2960
- return await a(this, c, xt).call(this, t, Ft);
3184
+ return await a(this, h, Ct).call(this, t, Ut);
2961
3185
  }
2962
3186
  /**
2963
3187
  * Updates an existing file. Can rename, move to a different folder,
@@ -2967,21 +3191,21 @@ const pe = class pe {
2967
3191
  * @returns The updated item and/or the new version.
2968
3192
  */
2969
3193
  async updateFile(t, e) {
2970
- return await a(this, c, ee).call(this, t, e);
3194
+ return await a(this, h, oe).call(this, t, e);
2971
3195
  }
2972
3196
  /**
2973
3197
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
2974
3198
  * @param fileId - The file's unique identifier.
2975
3199
  */
2976
3200
  async archiveFile(t) {
2977
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3201
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
2978
3202
  }
2979
3203
  /**
2980
3204
  * Recovers a previously archived file.
2981
3205
  * @param fileId - The file's unique identifier.
2982
3206
  */
2983
3207
  async recoverFile(t) {
2984
- 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`);
2985
3209
  }
2986
3210
  /**
2987
3211
  * Downloads a file's content. Returns the raw fetch Response.
@@ -2990,7 +3214,7 @@ const pe = class pe {
2990
3214
  * @returns A fetch Response containing the file data.
2991
3215
  */
2992
3216
  async downloadFile(t, e) {
2993
- return await a(this, c, It).call(this, t, e);
3217
+ return await a(this, h, $t).call(this, t, e);
2994
3218
  }
2995
3219
  /**
2996
3220
  * Retrieves the free-JSON metadata for a specific file version.
@@ -3001,7 +3225,7 @@ const pe = class pe {
3001
3225
  */
3002
3226
  async getFileVersionMetadata(t, e, s) {
3003
3227
  const { withDraft: r } = s || {};
3004
- 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`, {
3005
3229
  query: {
3006
3230
  ...r && { withDraft: "true" }
3007
3231
  }
@@ -3014,7 +3238,7 @@ const pe = class pe {
3014
3238
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
3015
3239
  */
3016
3240
  async updateFileVersionMetadata(t, e, s) {
3017
- 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`, {
3018
3242
  body: JSON.stringify({ metadata: s }),
3019
3243
  contentType: "application/json"
3020
3244
  });
@@ -3025,7 +3249,7 @@ const pe = class pe {
3025
3249
  * @param versionTag - The version tag.
3026
3250
  */
3027
3251
  async deleteFileVersionMetadata(t, e) {
3028
- 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`);
3029
3253
  }
3030
3254
  /**
3031
3255
  * Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
@@ -3042,7 +3266,7 @@ const pe = class pe {
3042
3266
  */
3043
3267
  async getFileVersionMetadataBatch(t, e) {
3044
3268
  const { withDraft: s } = e || {};
3045
- 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`, {
3046
3270
  body: JSON.stringify({
3047
3271
  entries: r,
3048
3272
  ...s !== void 0 && { withDraft: s }
@@ -3058,7 +3282,7 @@ const pe = class pe {
3058
3282
  */
3059
3283
  async listFolders(t) {
3060
3284
  const { archived: e, parentFolderId: s, projectId: r } = t || {};
3061
- return await a(this, c, d).call(this, "GET", C, {
3285
+ return await a(this, h, p).call(this, "GET", R, {
3062
3286
  query: {
3063
3287
  parentFolderId: s,
3064
3288
  archived: e,
@@ -3071,7 +3295,7 @@ const pe = class pe {
3071
3295
  * @param folderId - The folder's unique identifier.
3072
3296
  */
3073
3297
  async getFolder(t) {
3074
- return await a(this, c, d).call(this, "GET", `${C}/${t}`);
3298
+ return await a(this, h, p).call(this, "GET", `${R}/${t}`);
3075
3299
  }
3076
3300
  /**
3077
3301
  * Batch variant of {@link getFolder}. Resolves a known set of folder ids in
@@ -3087,7 +3311,7 @@ const pe = class pe {
3087
3311
  * @param folderIds - The folder ids to resolve.
3088
3312
  */
3089
3313
  async getFoldersBatch(t) {
3090
- 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`, {
3091
3315
  body: JSON.stringify({ folderIds: e }),
3092
3316
  contentType: "application/json"
3093
3317
  })).results);
@@ -3099,7 +3323,7 @@ const pe = class pe {
3099
3323
  * @returns The created folder.
3100
3324
  */
3101
3325
  async createFolder(t, e, s) {
3102
- return await a(this, c, d).call(this, "POST", C, {
3326
+ return await a(this, h, p).call(this, "POST", R, {
3103
3327
  body: JSON.stringify({
3104
3328
  name: t,
3105
3329
  ...e && { parentId: e },
@@ -3116,7 +3340,7 @@ const pe = class pe {
3116
3340
  */
3117
3341
  async updateFolder(t, e) {
3118
3342
  const { name: s } = e;
3119
- return await a(this, c, d).call(this, "PUT", `${C}/${t}`, {
3343
+ return await a(this, h, p).call(this, "PUT", `${R}/${t}`, {
3120
3344
  body: JSON.stringify({ name: s }),
3121
3345
  contentType: "application/json"
3122
3346
  });
@@ -3126,14 +3350,14 @@ const pe = class pe {
3126
3350
  * @param folderId - The folder's unique identifier.
3127
3351
  */
3128
3352
  async archiveFolder(t) {
3129
- return await a(this, c, d).call(this, "DELETE", `${C}/${t}`);
3353
+ return await a(this, h, p).call(this, "DELETE", `${R}/${t}`);
3130
3354
  }
3131
3355
  /**
3132
3356
  * Recovers a previously archived folder.
3133
3357
  * @param folderId - The folder's unique identifier.
3134
3358
  */
3135
3359
  async recoverFolder(t) {
3136
- return await a(this, c, d).call(this, "PUT", `${C}/${t}/recover`);
3360
+ return await a(this, h, p).call(this, "PUT", `${R}/${t}/recover`);
3137
3361
  }
3138
3362
  /**
3139
3363
  * Downloads an entire folder as a ZIP archive.
@@ -3141,7 +3365,7 @@ const pe = class pe {
3141
3365
  * @returns A fetch Response containing the ZIP data.
3142
3366
  */
3143
3367
  async downloadFolder(t) {
3144
- return await a(this, c, D).call(this, `${C}/${t}/download`);
3368
+ return await a(this, h, M).call(this, `${R}/${t}/download`);
3145
3369
  }
3146
3370
  // ─── Components ──────────────────────────────────────────────────
3147
3371
  /**
@@ -3151,14 +3375,14 @@ const pe = class pe {
3151
3375
  */
3152
3376
  async listComponents(t) {
3153
3377
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3154
- return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
3378
+ return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3155
3379
  query: {
3156
- itemType: Ut,
3380
+ itemType: jt,
3157
3381
  ...s && { ShowVersions: s }
3158
3382
  }
3159
- }) : await a(this, c, d).call(this, "GET", `${m}`, {
3383
+ }) : await a(this, h, p).call(this, "GET", `${m}`, {
3160
3384
  query: {
3161
- itemType: Ut,
3385
+ itemType: jt,
3162
3386
  ...s && { ShowVersions: s },
3163
3387
  ...r && { projectId: r }
3164
3388
  }
@@ -3170,7 +3394,7 @@ const pe = class pe {
3170
3394
  * @param props - Options such as whether to include versions.
3171
3395
  */
3172
3396
  async getComponent(t, e) {
3173
- return await a(this, c, se).call(this, t, e);
3397
+ return await a(this, h, ae).call(this, t, e);
3174
3398
  }
3175
3399
  /**
3176
3400
  * Creates a new component with the given file and version properties.
@@ -3179,7 +3403,7 @@ const pe = class pe {
3179
3403
  */
3180
3404
  async createComponent(t) {
3181
3405
  const { componentProps: e } = t;
3182
- return await a(this, c, xt).call(this, t, Ut, e);
3406
+ return await a(this, h, Ct).call(this, t, jt, e);
3183
3407
  }
3184
3408
  /**
3185
3409
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -3189,7 +3413,7 @@ const pe = class pe {
3189
3413
  */
3190
3414
  async updateComponent(t, e) {
3191
3415
  const { componentProps: s } = e;
3192
- return await a(this, c, ee).call(this, t, e, s);
3416
+ return await a(this, h, oe).call(this, t, e, s);
3193
3417
  }
3194
3418
  /**
3195
3419
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -3198,7 +3422,7 @@ const pe = class pe {
3198
3422
  * @returns A fetch Response containing the ZIP data.
3199
3423
  */
3200
3424
  async downloadComponent(t, e) {
3201
- return await a(this, c, It).call(this, t, e);
3425
+ return await a(this, h, $t).call(this, t, e);
3202
3426
  }
3203
3427
  /**
3204
3428
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -3209,7 +3433,7 @@ const pe = class pe {
3209
3433
  */
3210
3434
  async downloadComponentBundle(t, e) {
3211
3435
  const { versionTag: s, withDraft: r } = e || {};
3212
- 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`, {
3213
3437
  query: {
3214
3438
  ...s && { versionTag: s },
3215
3439
  ...r && { withDraft: r }
@@ -3221,14 +3445,14 @@ const pe = class pe {
3221
3445
  * @param componentId - The component's unique identifier.
3222
3446
  */
3223
3447
  async archiveComponent(t) {
3224
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3448
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3225
3449
  }
3226
3450
  /**
3227
3451
  * Recovers a previously archived component.
3228
3452
  * @param componentId - The component's unique identifier.
3229
3453
  */
3230
3454
  async recoverComponent(t) {
3231
- 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`);
3232
3456
  }
3233
3457
  // ─── Built-in Components ─────────────────────────────────────────
3234
3458
  /**
@@ -3237,7 +3461,7 @@ const pe = class pe {
3237
3461
  * @returns The component's JavaScript source code as a string.
3238
3462
  */
3239
3463
  async getBuiltInComponent(t) {
3240
- 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();
3241
3465
  }
3242
3466
  /**
3243
3467
  * Fetches a built-in component bundle, evaluates it, and registers it
@@ -3266,8 +3490,8 @@ const pe = class pe {
3266
3490
  * ```
3267
3491
  */
3268
3492
  async initBuiltInComponent(t, e, s) {
3269
- 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}
3270
- return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
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;
3271
3495
  e.get(y);
3272
3496
  }
3273
3497
  /**
@@ -3310,13 +3534,13 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3310
3534
  * ```
3311
3535
  */
3312
3536
  async setup(t, ...e) {
3313
- var o, h;
3537
+ var o, c;
3314
3538
  const s = t.OBC, r = t.BUI;
3315
3539
  if (!(s != null && s.Components))
3316
3540
  throw new Error("globals.OBC must include Components");
3317
3541
  if (!(r != null && r.Manager)) throw new Error("globals.BUI must include Manager");
3318
3542
  const i = new s.Components();
3319
- 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 };
3320
3544
  }
3321
3545
  /**
3322
3546
  * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
@@ -3335,14 +3559,14 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3335
3559
  */
3336
3560
  async listApps(t) {
3337
3561
  const { folderId: e, ShowVersions: s, projectId: r } = t || {};
3338
- return e ? await a(this, c, d).call(this, "GET", `${C}/${e}/items`, {
3562
+ return e ? await a(this, h, p).call(this, "GET", `${R}/${e}/items`, {
3339
3563
  query: {
3340
- itemType: Dt,
3564
+ itemType: Mt,
3341
3565
  ...s && { ShowVersions: s }
3342
3566
  }
3343
- }) : await a(this, c, d).call(this, "GET", `${m}`, {
3567
+ }) : await a(this, h, p).call(this, "GET", `${m}`, {
3344
3568
  query: {
3345
- itemType: Dt,
3569
+ itemType: Mt,
3346
3570
  ...s && { ShowVersions: s },
3347
3571
  ...r && { projectId: r }
3348
3572
  }
@@ -3355,7 +3579,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3355
3579
  */
3356
3580
  async createApp(t) {
3357
3581
  const { appProps: e } = t;
3358
- return await a(this, c, xt).call(this, t, Dt, e);
3582
+ return await a(this, h, Ct).call(this, t, Mt, e);
3359
3583
  }
3360
3584
  /**
3361
3585
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -3364,7 +3588,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3364
3588
  * @returns A fetch Response containing the ZIP data.
3365
3589
  */
3366
3590
  async downloadApp(t, e) {
3367
- return await a(this, c, It).call(this, t, e);
3591
+ return await a(this, h, $t).call(this, t, e);
3368
3592
  }
3369
3593
  /**
3370
3594
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -3375,7 +3599,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3375
3599
  */
3376
3600
  async downloadAppBundle(t, e) {
3377
3601
  const { versionTag: s, withDraft: r } = e || {};
3378
- 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`, {
3379
3603
  query: {
3380
3604
  ...s && { versionTag: s },
3381
3605
  ...r && { withDraft: r }
@@ -3387,7 +3611,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3387
3611
  * @param appId - The app's unique identifier.
3388
3612
  */
3389
3613
  async archiveApp(t) {
3390
- return await a(this, c, d).call(this, "DELETE", `${m}/${t}`);
3614
+ return await a(this, h, p).call(this, "DELETE", `${m}/${t}`);
3391
3615
  }
3392
3616
  // ─── NPM Registry ────────────────────────────────────────────────
3393
3617
  /**
@@ -3399,7 +3623,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3399
3623
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
3400
3624
  */
3401
3625
  async getNpmCredentials() {
3402
- return await a(this, c, d).call(this, "GET", `${sn}/credentials`);
3626
+ return await a(this, h, p).call(this, "GET", `${fn}/credentials`);
3403
3627
  }
3404
3628
  // ─── Execution ───────────────────────────────────────────────────
3405
3629
  /**
@@ -3418,7 +3642,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3418
3642
  */
3419
3643
  async executeComponent(t, e, s) {
3420
3644
  if (this.localServerUrl) {
3421
- 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, {
3422
3646
  method: "POST",
3423
3647
  headers: { "Content-Type": "application/json" },
3424
3648
  body: JSON.stringify(e)
@@ -3431,7 +3655,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3431
3655
  }
3432
3656
  return await i.json();
3433
3657
  }
3434
- 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`, {
3435
3659
  body: JSON.stringify(e),
3436
3660
  query: { ...s && { versionTag: s } },
3437
3661
  contentType: "application/json"
@@ -3443,7 +3667,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3443
3667
  */
3444
3668
  async abortExecution(t) {
3445
3669
  if (this.localServerUrl) {
3446
- 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" });
3447
3671
  if (!s.ok) {
3448
3672
  const r = await s.text().catch(() => "");
3449
3673
  throw new Error(
@@ -3452,7 +3676,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3452
3676
  }
3453
3677
  return await s.json();
3454
3678
  }
3455
- 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`);
3456
3680
  }
3457
3681
  /**
3458
3682
  * Lists all executions for a given component.
@@ -3469,7 +3693,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3469
3693
  */
3470
3694
  async listExecutions(t, e) {
3471
3695
  if (this.localServerUrl) {
3472
- 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);
3473
3697
  if (!i.ok) {
3474
3698
  const o = await i.text().catch(() => "");
3475
3699
  throw new Error(
@@ -3478,7 +3702,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3478
3702
  }
3479
3703
  return await i.json();
3480
3704
  }
3481
- 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 } } });
3482
3706
  }
3483
3707
  /**
3484
3708
  * Gets details of a specific execution, including its messages.
@@ -3487,7 +3711,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3487
3711
  */
3488
3712
  async getExecution(t) {
3489
3713
  if (this.localServerUrl) {
3490
- 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);
3491
3715
  if (!s.ok) {
3492
3716
  const r = await s.text().catch(() => "");
3493
3717
  throw new Error(
@@ -3496,7 +3720,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3496
3720
  }
3497
3721
  return await s.json();
3498
3722
  }
3499
- 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}`);
3500
3724
  }
3501
3725
  /**
3502
3726
  * Subscribes to real-time execution progress via WebSocket.
@@ -3505,7 +3729,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3505
3729
  * @param onUpdateCallback - Callback invoked on each progress/result event.
3506
3730
  */
3507
3731
  async onExecutionProgress(t, e) {
3508
- const s = this.localServerUrl ?? this.wsUrl, r = await ut(s, {
3732
+ const s = this.localServerUrl ?? this.wsUrl, r = await pt(s, {
3509
3733
  auth: { accessToken: this.accessToken },
3510
3734
  transports: ["websocket"]
3511
3735
  });
@@ -3517,7 +3741,15 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3517
3741
  console.log(i);
3518
3742
  });
3519
3743
  }
3520
- // ─── 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
+ }
3521
3753
  /**
3522
3754
  * A project's history of connected documents (Revit models, AutoCAD
3523
3755
  * drawings…): their version timelines and their change requests. See
@@ -3525,14 +3757,14 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3525
3757
  * or write it; the storage underneath is private and will move.
3526
3758
  */
3527
3759
  history(t) {
3528
- return new Xs(this, t);
3760
+ return new an(this, t);
3529
3761
  }
3530
3762
  /**
3531
3763
  * The recipe registry and runner: scripts that write change requests in a
3532
3764
  * native application's language. See `src/core/recipes.ts`.
3533
3765
  */
3534
3766
  get recipes() {
3535
- return l(this, pt) ?? b(this, pt, new Zs(this)), l(this, pt);
3767
+ return l(this, wt) ?? _(this, wt, new ln(this)), l(this, wt);
3536
3768
  }
3537
3769
  // ─── Hidden Files ────────────────────────────────────────────────
3538
3770
  /**
@@ -3546,7 +3778,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3546
3778
  */
3547
3779
  async createHiddenFile(t, e, s) {
3548
3780
  const r = new FormData();
3549
- 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}`, {
3550
3782
  body: r
3551
3783
  });
3552
3784
  }
@@ -3564,7 +3796,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3564
3796
  const r = new FormData();
3565
3797
  for (const i of t)
3566
3798
  r.append("files", i);
3567
- 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`, {
3568
3800
  body: r
3569
3801
  });
3570
3802
  }
@@ -3573,21 +3805,21 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3573
3805
  * @param hiddenId - The hidden file's unique identifier.
3574
3806
  */
3575
3807
  async deleteHiddenFile(t) {
3576
- 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}`);
3577
3809
  }
3578
3810
  /**
3579
3811
  * Gets metadata for a hidden file.
3580
3812
  * @param hiddenId - The hidden file's unique identifier.
3581
3813
  */
3582
3814
  async getHiddenFile(t) {
3583
- 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}`);
3584
3816
  }
3585
3817
  /**
3586
3818
  * Downloads a hidden file's content. Returns the raw fetch Response.
3587
3819
  * @param hiddenId - The hidden file's unique identifier.
3588
3820
  */
3589
3821
  async downloadHiddenFile(t) {
3590
- 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`);
3591
3823
  }
3592
3824
  /**
3593
3825
  * Mints a short-lived presigned URL for a hidden file so the browser can
@@ -3607,7 +3839,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3607
3839
  * an ISO timestamp when it stops working.
3608
3840
  */
3609
3841
  async getHiddenFileSignedUrl(t, e) {
3610
- 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 } } });
3611
3843
  }
3612
3844
  /**
3613
3845
  * Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
@@ -3628,7 +3860,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3628
3860
  * 900 (15 min) server-side; values are clamped to that range.
3629
3861
  */
3630
3862
  async getHiddenFileSignedUrlsBatch(t, e) {
3631
- 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`, {
3632
3864
  body: JSON.stringify({
3633
3865
  hiddenFileIds: s,
3634
3866
  ...e != null && { expiresIn: e }
@@ -3644,14 +3876,14 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3644
3876
  * @returns Array of hidden file entities.
3645
3877
  */
3646
3878
  async getHiddenFilesByParent(t, e) {
3647
- 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 } } });
3648
3880
  }
3649
3881
  /**
3650
3882
  * Deletes all hidden files attached to a parent item.
3651
3883
  * @param parentFileId - The parent item's unique identifier.
3652
3884
  */
3653
3885
  async deleteHiddenFilesByParent(t) {
3654
- 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}`);
3655
3887
  }
3656
3888
  // ─── Icons ───────────────────────────────────────────────────────
3657
3889
  /**
@@ -3663,7 +3895,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3663
3895
  */
3664
3896
  async uploadItemIcon(t, e) {
3665
3897
  const s = new FormData();
3666
- 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`, {
3667
3899
  body: s
3668
3900
  });
3669
3901
  }
@@ -3673,7 +3905,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3673
3905
  * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
3674
3906
  */
3675
3907
  async getItemIcon(t) {
3676
- return await a(this, c, D).call(this, `${m}/${t}/icon`);
3908
+ return await a(this, h, M).call(this, `${m}/${t}/icon`);
3677
3909
  }
3678
3910
  /**
3679
3911
  * Removes the icon from an item.
@@ -3681,7 +3913,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3681
3913
  * @returns The updated item with icon fields removed.
3682
3914
  */
3683
3915
  async removeItemIcon(t) {
3684
- 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`);
3685
3917
  }
3686
3918
  // ─── General Item Operations ─────────────────────────────────────
3687
3919
  /**
@@ -3691,7 +3923,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3691
3923
  * @returns The updated item.
3692
3924
  */
3693
3925
  async updateItem(t, e) {
3694
- return await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
3926
+ return await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
3695
3927
  body: JSON.stringify(e),
3696
3928
  contentType: "application/json"
3697
3929
  });
@@ -3708,7 +3940,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3708
3940
  */
3709
3941
  async createVersion(t, e, s, r, i) {
3710
3942
  const o = new FormData();
3711
- 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 });
3712
3944
  }
3713
3945
  /**
3714
3946
  * Lists versions of an item. Pass `archived: true` to fetch only archived
@@ -3718,7 +3950,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3718
3950
  * @returns Array of versions, sorted by creation date descending.
3719
3951
  */
3720
3952
  async listVersions(t, e = {}) {
3721
- 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 });
3722
3954
  }
3723
3955
  /**
3724
3956
  * Batch variant of {@link listVersions}. Lists the versions of many items in
@@ -3737,7 +3969,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3737
3969
  */
3738
3970
  async listVersionsBatch(t, e = {}) {
3739
3971
  const { archived: s } = e;
3740
- 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`, {
3741
3973
  body: JSON.stringify({
3742
3974
  itemIds: r,
3743
3975
  ...s !== void 0 && { archived: s }
@@ -3755,7 +3987,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3755
3987
  * @returns The archived version.
3756
3988
  */
3757
3989
  async archiveVersion(t, e) {
3758
- 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`);
3759
3991
  }
3760
3992
  /**
3761
3993
  * Recovers a previously archived version, restoring it to the active list.
@@ -3764,7 +3996,7 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3764
3996
  * @returns The recovered version.
3765
3997
  */
3766
3998
  async recoverVersion(t, e) {
3767
- 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`);
3768
4000
  }
3769
4001
  /**
3770
4002
  * Permanently deletes a version, including its file in object storage.
@@ -3773,54 +4005,54 @@ return main;`)(...h), y = (f == null ? void 0 : f.componentDefinition) ?? f;
3773
4005
  * @param versionTag - The version's tag (e.g. "v2").
3774
4006
  */
3775
4007
  async deleteVersion(t, e) {
3776
- 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)}`);
3777
4009
  }
3778
4010
  };
3779
- c = new WeakSet(), te = function(t) {
4011
+ h = new WeakSet(), ie = function(t) {
3780
4012
  return `${this.apiUrl}/${t}`;
3781
- }, d = async function(t, e, s) {
3782
- const { body: r, query: i, contentType: o, retries: h, responseType: u, retryAttempt: f } = s || {}, y = a(this, c, te).call(this, e), w = a(this, c, Je).call(this, i), R = await this.resolveAccessToken(), Qe = {
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 = {
3783
4015
  ...w,
3784
- ...this.useBearer ? {} : { accessToken: R }
4016
+ ...this.useBearer ? {} : { accessToken: C }
3785
4017
  };
3786
4018
  try {
3787
- const I = await fetch(
3788
- y + "?" + new URLSearchParams(Qe).toString(),
4019
+ const A = await fetch(
4020
+ y + "?" + new URLSearchParams(as).toString(),
3789
4021
  {
3790
4022
  method: t,
3791
4023
  headers: {
3792
4024
  Accept: "application/json",
3793
4025
  ...o && { "Content-Type": o },
3794
- ...this.useBearer && { Authorization: `Bearer ${R}` }
4026
+ ...this.useBearer && { Authorization: `Bearer ${C}` }
3795
4027
  },
3796
4028
  ...r && { body: r }
3797
4029
  }
3798
4030
  );
3799
- if (!I.ok) {
3800
- const K = await I.text().then((gt) => gt).catch(() => "");
3801
- throw new fe(
3802
- I.status,
3803
- I.statusText,
3804
- K,
3805
- 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)
3806
4038
  );
3807
4039
  }
3808
- 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(() => {
3809
4041
  });
3810
- } catch (I) {
3811
- const K = h ?? this.retries;
3812
- if (K > 0 && cn(I)) {
3813
- const gt = f ?? 0;
3814
- 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, {
3815
4047
  ...s,
3816
- retries: K - 1,
3817
- retryAttempt: gt + 1
4048
+ retries: z - 1,
4049
+ retryAttempt: vt + 1
3818
4050
  });
3819
4051
  }
3820
- throw I;
4052
+ throw A;
3821
4053
  }
3822
- }, D = async function(t, e) {
3823
- const { query: s } = e || {}, r = a(this, c, te).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 = {
3824
4056
  ...s,
3825
4057
  ...this.useBearer ? {} : { accessToken: i }
3826
4058
  };
@@ -3833,31 +4065,31 @@ c = new WeakSet(), te = function(t) {
3833
4065
  }
3834
4066
  }
3835
4067
  );
3836
- }, pt = new WeakMap(), lt = async function(t, e) {
4068
+ }, wt = new WeakMap(), ft = async function(t, e) {
3837
4069
  if (!t.length) return [];
3838
4070
  const s = [];
3839
- for (let i = 0; i < t.length; i += Ae)
3840
- 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));
3841
4073
  return (await Promise.all(s.map(e))).flat();
3842
- }, It = async function(t, e) {
4074
+ }, $t = async function(t, e) {
3843
4075
  const { versionTag: s, withDraft: r } = e || {};
3844
- return await a(this, c, D).call(this, `${m}/${t}/download`, {
4076
+ return await a(this, h, M).call(this, `${m}/${t}/download`, {
3845
4077
  query: {
3846
4078
  ...s && { versionTag: s },
3847
4079
  ...r && { withDraft: r }
3848
4080
  }
3849
4081
  });
3850
- }, xt = async function(t, e, s) {
3851
- const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: u, metadata: f } = t, y = new FormData();
3852
- return y.append("file", u), y.append("name", r), y.append("versionTag", i), y.append("itemType", e), o && y.append("folderId", o), h && y.append("projectId", h), s && y.append("extraProps", JSON.stringify(s)), f && y.append("metadata", JSON.stringify(f)), await a(this, c, d).call(this, "POST", m, {
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, {
3853
4085
  body: y
3854
4086
  });
3855
- }, ee = async function(t, e, s) {
3856
- const { name: r, versionTag: i, parentFolderId: o, file: h, metadata: u } = e;
4087
+ }, oe = async function(t, e, s) {
4088
+ const { name: r, versionTag: i, parentFolderId: o, file: c, metadata: u } = e;
3857
4089
  let f, y;
3858
- if (h) {
4090
+ if (c) {
3859
4091
  const w = new FormData();
3860
- w.append("file", h), i && w.append("versionTag", i), s && w.append("extraProps", JSON.stringify(s)), u && w.append("metadata", JSON.stringify(u)), y = 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`, {
3861
4093
  body: w
3862
4094
  });
3863
4095
  }
@@ -3865,26 +4097,26 @@ c = new WeakSet(), te = function(t) {
3865
4097
  const w = {
3866
4098
  ...r && { name: r },
3867
4099
  ...o && { folderId: o }
3868
- }, R = JSON.stringify(w);
3869
- f = await a(this, c, d).call(this, "PUT", `${m}/${t}`, {
3870
- body: R,
4100
+ }, C = JSON.stringify(w);
4101
+ f = await a(this, h, p).call(this, "PUT", `${m}/${t}`, {
4102
+ body: C,
3871
4103
  contentType: "application/json"
3872
4104
  });
3873
4105
  }
3874
4106
  return { item: f, version: y };
3875
- }, se = async function(t, e) {
4107
+ }, ae = async function(t, e) {
3876
4108
  const { showVersions: s = !1 } = e || {};
3877
- return await a(this, c, d).call(this, "GET", `${m}/${t}`, {
4109
+ return await a(this, h, p).call(this, "GET", `${m}/${t}`, {
3878
4110
  query: { showVersions: s }
3879
4111
  });
3880
- }, Je = function(t) {
4112
+ }, es = function(t) {
3881
4113
  return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
3882
4114
  (e, [s, r]) => (e[s] = r, e),
3883
4115
  {}
3884
4116
  );
3885
4117
  };
3886
- let Zt = pe;
3887
- function ln() {
4118
+ let re = be;
4119
+ function _n() {
3888
4120
  if (typeof window > "u" || window.parent === window)
3889
4121
  throw new Error(
3890
4122
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
@@ -3899,29 +4131,29 @@ function ln() {
3899
4131
  }
3900
4132
  };
3901
4133
  }
3902
- const ne = "channel:", un = 1e4;
3903
- function $t(n) {
4134
+ const ce = "channel:", vn = 1e4;
4135
+ function Rt(n) {
3904
4136
  try {
3905
4137
  n();
3906
4138
  } catch (t) {
3907
4139
  console.error("[channel] a listener threw:", t);
3908
4140
  }
3909
4141
  }
3910
- var q, k, O, Q, Z, tt, S, re, ie, z;
3911
- class Ye {
4142
+ var D, k, O, nt, rt, it, S, he, le, st;
4143
+ class ss {
3912
4144
  constructor(t, e) {
3913
- _(this, S);
3914
- _(this, q, !1);
3915
- _(this, k, []);
3916
- _(this, O, []);
3917
- _(this, Q, /* @__PURE__ */ new Set());
3918
- _(this, Z, /* @__PURE__ */ new Set());
3919
- _(this, tt, /* @__PURE__ */ new Set());
4145
+ b(this, S);
4146
+ b(this, D, !1);
4147
+ b(this, k, []);
4148
+ b(this, O, []);
4149
+ b(this, nt, /* @__PURE__ */ new Set());
4150
+ b(this, rt, /* @__PURE__ */ new Set());
4151
+ b(this, it, /* @__PURE__ */ new Set());
3920
4152
  this.transport = t, this.controls = e;
3921
4153
  }
3922
4154
  /** Whether the platform has confirmed this tab is in the room. */
3923
4155
  get joined() {
3924
- return l(this, q);
4156
+ return l(this, D);
3925
4157
  }
3926
4158
  /** Who else is in the room right now, as the platform last reported. */
3927
4159
  get peers() {
@@ -3932,47 +4164,47 @@ class Ye {
3932
4164
  * refuses or does not answer in time. Joining twice is harmless.
3933
4165
  */
3934
4166
  join() {
3935
- return l(this, q) ? Promise.resolve() : a(this, S, re).call(this, "joined", this.controls.join);
4167
+ return l(this, D) ? Promise.resolve() : a(this, S, he).call(this, "joined", this.controls.join);
3936
4168
  }
3937
4169
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
3938
4170
  leave() {
3939
- return !l(this, q) && !l(this, O).some((t) => t.want === "joined") ? Promise.resolve() : a(this, S, re).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);
3940
4172
  }
3941
4173
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
3942
4174
  onChange(t) {
3943
- return l(this, Q).add(t), () => void l(this, Q).delete(t);
4175
+ return l(this, nt).add(t), () => void l(this, nt).delete(t);
3944
4176
  }
3945
4177
  onPeerJoined(t) {
3946
- return l(this, Z).add(t), () => void l(this, Z).delete(t);
4178
+ return l(this, rt).add(t), () => void l(this, rt).delete(t);
3947
4179
  }
3948
4180
  onPeerLeft(t) {
3949
- return l(this, tt).add(t), () => void l(this, tt).delete(t);
4181
+ return l(this, it).add(t), () => void l(this, it).delete(t);
3950
4182
  }
3951
4183
  /** @internal */
3952
4184
  applyJoined() {
3953
- b(this, q, !0), a(this, S, ie).call(this, "joined"), a(this, S, z).call(this);
4185
+ _(this, D, !0), a(this, S, le).call(this, "joined"), a(this, S, st).call(this);
3954
4186
  }
3955
4187
  /** @internal */
3956
4188
  applyLeft() {
3957
- b(this, q, !1), b(this, k, []), a(this, S, ie).call(this, "left"), a(this, S, z).call(this);
4189
+ _(this, D, !1), _(this, k, []), a(this, S, le).call(this, "left"), a(this, S, st).call(this);
3958
4190
  }
3959
4191
  /** @internal */
3960
4192
  applyPeers(t) {
3961
- b(this, k, t), a(this, S, z).call(this);
4193
+ _(this, k, t), a(this, S, st).call(this);
3962
4194
  }
3963
4195
  /** @internal */
3964
4196
  applyPeerJoined(t) {
3965
- !l(this, q) || l(this, k).some((e) => e.from === t.from) || (b(this, k, [...l(this, k), t]), l(this, Z).forEach((e) => $t(() => e(t))), a(this, S, z).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));
3966
4198
  }
3967
4199
  /** @internal */
3968
4200
  applyPeerLeft(t) {
3969
4201
  const e = l(this, k).find((s) => s.from === t);
3970
- e && (b(this, k, l(this, k).filter((s) => s.from !== t)), l(this, tt).forEach((s) => $t(() => s(e))), a(this, S, z).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));
3971
4203
  }
3972
4204
  /** @internal */
3973
4205
  failPending(t) {
3974
4206
  const e = l(this, O);
3975
- return b(this, O, []), e.forEach((s) => {
4207
+ return _(this, O, []), e.forEach((s) => {
3976
4208
  clearTimeout(s.timer), s.reject(t);
3977
4209
  }), e.length > 0;
3978
4210
  }
@@ -3980,77 +4212,77 @@ class Ye {
3980
4212
  this.transport.post(t);
3981
4213
  }
3982
4214
  }
3983
- q = new WeakMap(), k = new WeakMap(), O = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), S = new WeakSet(), re = 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) {
3984
4216
  return new Promise((s, r) => {
3985
4217
  const i = {
3986
4218
  want: t,
3987
4219
  resolve: s,
3988
4220
  reject: r,
3989
4221
  timer: setTimeout(() => {
3990
- b(this, O, l(this, O).filter((o) => o !== i)), r(
4222
+ _(this, O, l(this, O).filter((o) => o !== i)), r(
3991
4223
  new Error(
3992
4224
  `The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
3993
4225
  )
3994
4226
  );
3995
- }, un)
4227
+ }, vn)
3996
4228
  };
3997
4229
  l(this, O).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
3998
4230
  });
3999
- }, ie = function(t) {
4231
+ }, le = function(t) {
4000
4232
  const e = l(this, O).filter((s) => s.want === t);
4001
- b(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
4233
+ _(this, O, l(this, O).filter((s) => s.want !== t)), e.forEach((s) => {
4002
4234
  clearTimeout(s.timer), s.resolve();
4003
4235
  });
4004
- }, z = function() {
4005
- l(this, Q).forEach((t) => $t(t));
4236
+ }, st = function() {
4237
+ l(this, nt).forEach((t) => Rt(t));
4006
4238
  };
4007
- var et;
4008
- class dn extends Ye {
4239
+ var ot;
4240
+ class En extends ss {
4009
4241
  /** @internal Use `client.channel.collab()`. */
4010
4242
  constructor(e) {
4011
4243
  super(e, {
4012
4244
  join: { action: "joinCollab" },
4013
4245
  leave: { action: "leaveCollab" }
4014
4246
  });
4015
- _(this, et, /* @__PURE__ */ new Map());
4247
+ b(this, ot, /* @__PURE__ */ new Map());
4016
4248
  }
4017
4249
  /**
4018
4250
  * Listens for an event other tabs send. Any number of listeners per event.
4019
4251
  * @returns a function that removes the listener.
4020
4252
  */
4021
4253
  on(e, s) {
4022
- const r = l(this, et).get(e) ?? /* @__PURE__ */ new Set();
4023
- return r.add(s), l(this, et).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);
4024
4256
  }
4025
4257
  /**
4026
4258
  * Sends an event to the other tabs in the room. Does nothing while this tab
4027
4259
  * is not in it, matching what the platform does with a message from outside.
4028
4260
  */
4029
4261
  send(e, s) {
4030
- if (e.startsWith(ne))
4031
- throw new Error(`Message types starting with '${ne}' are reserved.`);
4262
+ if (e.startsWith(ce))
4263
+ throw new Error(`Message types starting with '${ce}' are reserved.`);
4032
4264
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
4033
4265
  }
4034
4266
  accepts(e) {
4035
4267
  return e === void 0 || e === "collab";
4036
4268
  }
4037
4269
  async handle(e) {
4038
- const s = l(this, et).get(e.type);
4270
+ const s = l(this, ot).get(e.type);
4039
4271
  if (!(s != null && s.size)) return { handled: !1 };
4040
- const r = We(e);
4041
- 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 };
4042
4274
  }
4043
4275
  }
4044
- et = new WeakMap();
4045
- var M;
4046
- class fn extends Ye {
4276
+ ot = new WeakMap();
4277
+ var G;
4278
+ class Tn extends ss {
4047
4279
  /** @internal Use `client.channel.external(kind)`. */
4048
4280
  constructor(e, s) {
4049
4281
  super(e, {
4050
4282
  join: { action: "joinExternal", kind: s },
4051
4283
  leave: { action: "leaveExternal", kind: s }
4052
4284
  });
4053
- _(this, M, /* @__PURE__ */ new Map());
4285
+ b(this, G, /* @__PURE__ */ new Map());
4054
4286
  this.kind = s;
4055
4287
  }
4056
4288
  /**
@@ -4064,24 +4296,24 @@ class fn extends Ye {
4064
4296
  * @returns a function that removes the handler.
4065
4297
  */
4066
4298
  on(e, s) {
4067
- if (l(this, M).has(e))
4299
+ if (l(this, G).has(e))
4068
4300
  throw new Error(
4069
4301
  `"${e}" already has a handler in this room. Remove it first.`
4070
4302
  );
4071
- return l(this, M).set(e, s), () => void l(this, M).delete(e);
4303
+ return l(this, G).set(e, s), () => void l(this, G).delete(e);
4072
4304
  }
4073
4305
  accepts(e, s) {
4074
4306
  return e !== void 0 && e !== "external" ? !1 : this.kind === void 0 || e === void 0 || this.kind === s;
4075
4307
  }
4076
4308
  /** @internal Whether this room has any handler at all. */
4077
4309
  get hasHandlers() {
4078
- return l(this, M).size > 0;
4310
+ return l(this, G).size > 0;
4079
4311
  }
4080
4312
  async handle(e) {
4081
- const s = l(this, M).get(e.type);
4313
+ const s = l(this, G).get(e.type);
4082
4314
  if (!s) return { handled: !1 };
4083
4315
  try {
4084
- return { handled: !0, value: await s(e.payload, We(e)) };
4316
+ return { handled: !0, value: await s(e.payload, ns(e)) };
4085
4317
  } catch (r) {
4086
4318
  return {
4087
4319
  handled: !0,
@@ -4090,8 +4322,8 @@ class fn extends Ye {
4090
4322
  }
4091
4323
  }
4092
4324
  }
4093
- M = new WeakMap();
4094
- function We(n) {
4325
+ G = new WeakMap();
4326
+ function ns(n) {
4095
4327
  return {
4096
4328
  from: n.from,
4097
4329
  at: n.at,
@@ -4099,7 +4331,7 @@ function We(n) {
4099
4331
  kind: n.kind
4100
4332
  };
4101
4333
  }
4102
- function pn(n) {
4334
+ function Sn(n) {
4103
4335
  const t = n;
4104
4336
  if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
4105
4337
  const e = t.message;
@@ -4113,20 +4345,20 @@ function pn(n) {
4113
4345
  kind: typeof e.kind == "string" ? e.kind : void 0
4114
4346
  };
4115
4347
  }
4116
- var W, yt, F, H, G, v, oe, Rt, Ke, Xe, ze, ae;
4117
- class yn {
4348
+ var K, bt, U, V, J, E, ue, Nt, rs, is, os, de;
4349
+ class kn {
4118
4350
  constructor(t) {
4119
- _(this, v);
4120
- _(this, W);
4121
- _(this, yt);
4122
- _(this, F);
4123
- _(this, H, /* @__PURE__ */ new Map());
4124
- _(this, G, /* @__PURE__ */ new Set());
4125
- b(this, W, t), b(this, yt, t.listen((e) => void a(this, v, Ke).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)));
4126
4358
  }
4127
4359
  /** The collaboration room for this app. Always the same instance. */
4128
4360
  collab() {
4129
- return l(this, F) ?? b(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);
4130
4362
  }
4131
4363
  /**
4132
4364
  * The room for commands from this account's external tools of one `kind`
@@ -4135,71 +4367,71 @@ class yn {
4135
4367
  */
4136
4368
  external(t) {
4137
4369
  const e = t ?? "";
4138
- let s = l(this, H).get(e);
4139
- return s || (s = new fn(l(this, W), t), l(this, H).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;
4140
4372
  }
4141
4373
  /** Stops listening. For tests and teardown; an app normally never calls it. */
4142
4374
  dispose() {
4143
- l(this, yt).call(this);
4375
+ l(this, bt).call(this);
4144
4376
  }
4145
4377
  }
4146
- W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G = new WeakMap(), v = new WeakSet(), oe = function() {
4147
- return [...l(this, F) ? [l(this, F)] : [], ...l(this, H).values()];
4148
- }, Rt = function(t, e) {
4149
- 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);
4150
4382
  if (t === "external")
4151
- return l(this, H).get(typeof e == "string" ? e : "");
4152
- }, Ke = async function(t) {
4153
- const e = pn(t);
4383
+ return l(this, V).get(typeof e == "string" ? e : "");
4384
+ }, rs = async function(t) {
4385
+ const e = Sn(t);
4154
4386
  if (e) {
4155
- if (e.type.startsWith(ne)) {
4156
- a(this, v, Xe).call(this, e);
4387
+ if (e.type.startsWith(ce)) {
4388
+ a(this, E, is).call(this, e);
4157
4389
  return;
4158
4390
  }
4159
- await a(this, v, ze).call(this, e);
4391
+ await a(this, E, os).call(this, e);
4160
4392
  }
4161
- }, Xe = function(t) {
4393
+ }, is = function(t) {
4162
4394
  var s, r, i;
4163
4395
  const e = t.payload ?? {};
4164
4396
  switch (t.type) {
4165
4397
  case "channel:joined":
4166
- (s = a(this, v, Rt).call(this, e.scope, e.kind)) == null || s.applyJoined();
4398
+ (s = a(this, E, Nt).call(this, e.scope, e.kind)) == null || s.applyJoined();
4167
4399
  break;
4168
4400
  case "channel:left":
4169
- (r = a(this, v, Rt).call(this, e.scope, e.kind)) == null || r.applyLeft();
4401
+ (r = a(this, E, Nt).call(this, e.scope, e.kind)) == null || r.applyLeft();
4170
4402
  break;
4171
4403
  case "channel:peers":
4172
- (i = a(this, v, Rt).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 ?? []);
4173
4405
  break;
4174
4406
  case "channel:peer-joined":
4175
4407
  case "channel:peer-left": {
4176
4408
  if (!e.from) break;
4177
- const o = e.scope === "collab" ? [l(this, F)] : [...l(this, H).values()].filter(
4178
- (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)
4179
4411
  );
4180
- for (const h of o)
4181
- 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);
4182
4414
  break;
4183
4415
  }
4184
4416
  case "channel:error": {
4185
4417
  const o = new Error(String(t.payload));
4186
- a(this, v, oe).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);
4187
4419
  break;
4188
4420
  }
4189
4421
  }
4190
- }, ze = async function(t) {
4191
- const e = a(this, v, oe).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));
4192
4424
  let s = !1;
4193
4425
  for (const i of e) {
4194
4426
  const o = await i.handle(t);
4195
- o.handled && (s = !0, t.requestId && a(this, v, ae).call(this, t.requestId, o));
4427
+ o.handled && (s = !0, t.requestId && a(this, E, de).call(this, t.requestId, o));
4196
4428
  }
4197
- t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, v, ae).call(this, t.requestId, {
4429
+ t.requestId && t.scope === "external" && e.length > 0 && !s && a(this, E, de).call(this, t.requestId, {
4198
4430
  handled: !0,
4199
4431
  error: `No handler for "${t.type}".`
4200
4432
  });
4201
- }, ae = function(t, e) {
4202
- l(this, G).has(t) || (l(this, G).add(t), l(this, G).size > 500 && l(this, G).delete(l(this, G).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({
4203
4435
  type: "APP_CHANNEL_PUBLISH",
4204
4436
  message: {
4205
4437
  type: e.error === void 0 ? "reply" : "reply-error",
@@ -4208,9 +4440,9 @@ W = new WeakMap(), yt = new WeakMap(), F = new WeakMap(), H = new WeakMap(), G =
4208
4440
  }
4209
4441
  }));
4210
4442
  };
4211
- const J = "project", X = "notifications";
4212
- var st, mt;
4213
- const ye = class ye extends Zt {
4443
+ const W = "project", X = "notifications";
4444
+ var at, _t;
4445
+ const _e = class _e extends re {
4214
4446
  /**
4215
4447
  * @param token - A bearer JWT, OR a function returning the current JWT
4216
4448
  * (sync or async). When a function is passed, it's invoked before every
@@ -4221,12 +4453,12 @@ const ye = class ye extends Zt {
4221
4453
  */
4222
4454
  constructor(e, s, r) {
4223
4455
  super(typeof e == "string" ? e : "", s, { ...r, useBearer: !0 });
4224
- _(this, st);
4225
- _(this, mt);
4226
- typeof e == "function" && b(this, st, e);
4456
+ b(this, at);
4457
+ b(this, _t);
4458
+ typeof e == "function" && _(this, at, e);
4227
4459
  }
4228
4460
  async resolveAccessToken() {
4229
- return l(this, st) ? await l(this, st).call(this) : super.resolveAccessToken();
4461
+ return l(this, at) ? await l(this, at).call(this) : super.resolveAccessToken();
4230
4462
  }
4231
4463
  /**
4232
4464
  * Creates a client from the platform context injected into
@@ -4235,7 +4467,7 @@ const ye = class ye extends Zt {
4235
4467
  * carries a fresh JWT on every navigation.
4236
4468
  */
4237
4469
  static fromPlatformContext(e) {
4238
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new ye(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);
4239
4471
  return r.context = s, r;
4240
4472
  }
4241
4473
  /**
@@ -4263,7 +4495,7 @@ const ye = class ye extends Zt {
4263
4495
  * ```
4264
4496
  */
4265
4497
  get channel() {
4266
- return l(this, mt) ?? b(this, mt, new yn(ln())), l(this, mt);
4498
+ return l(this, _t) ?? _(this, _t, new kn(_n())), l(this, _t);
4267
4499
  }
4268
4500
  // ─── Projects (JWT-only backend routes) ──────────────────────────
4269
4501
  /**
@@ -4282,14 +4514,14 @@ const ye = class ye extends Zt {
4282
4514
  * ```
4283
4515
  */
4284
4516
  async listProjects() {
4285
- return await this.request("GET", J);
4517
+ return await this.request("GET", W);
4286
4518
  }
4287
4519
  /**
4288
4520
  * Gets a project by ID. JWT-only — lives here because
4289
4521
  * `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
4290
4522
  */
4291
4523
  async getProject(e) {
4292
- return await this.request("GET", `${J}/${e}`);
4524
+ return await this.request("GET", `${W}/${e}`);
4293
4525
  }
4294
4526
  /**
4295
4527
  * Gets the full project data (users, roles, files, folders) for a project.
@@ -4298,7 +4530,7 @@ const ye = class ye extends Zt {
4298
4530
  async getProjectData(e) {
4299
4531
  return await this.request(
4300
4532
  "GET",
4301
- `${J}/${e}/data`
4533
+ `${W}/${e}/data`
4302
4534
  );
4303
4535
  }
4304
4536
  // ─── Account ──────────────────────────────────────────────────────
@@ -4323,7 +4555,7 @@ const ye = class ye extends Zt {
4323
4555
  async checkPermission(e) {
4324
4556
  return await this.request(
4325
4557
  "GET",
4326
- `${J}/permissions/check`,
4558
+ `${W}/permissions/check`,
4327
4559
  { query: e }
4328
4560
  );
4329
4561
  }
@@ -4332,7 +4564,7 @@ const ye = class ye extends Zt {
4332
4564
  * single round-trip; results come back in the same order as `checks`.
4333
4565
  */
4334
4566
  async checkPermissionBatch(e) {
4335
- return (await this.request("POST", `${J}/permissions/check/batch`, {
4567
+ return (await this.request("POST", `${W}/permissions/check/batch`, {
4336
4568
  body: JSON.stringify({ checks: e }),
4337
4569
  contentType: "application/json"
4338
4570
  })).results;
@@ -4444,7 +4676,7 @@ const ye = class ye extends Zt {
4444
4676
  async subscribeToAutomation(e, s, r) {
4445
4677
  return await this.request(
4446
4678
  "POST",
4447
- `${J}/${e}/events/hooks/${s}/subscription`,
4679
+ `${W}/${e}/events/hooks/${s}/subscription`,
4448
4680
  {
4449
4681
  body: JSON.stringify(r ?? {}),
4450
4682
  contentType: "application/json"
@@ -4461,7 +4693,7 @@ const ye = class ye extends Zt {
4461
4693
  async updateAutomationSubscription(e, s, r) {
4462
4694
  return await this.request(
4463
4695
  "PATCH",
4464
- `${J}/${e}/events/hooks/${s}/subscription`,
4696
+ `${W}/${e}/events/hooks/${s}/subscription`,
4465
4697
  {
4466
4698
  body: JSON.stringify(r),
4467
4699
  contentType: "application/json"
@@ -4495,7 +4727,7 @@ const ye = class ye extends Zt {
4495
4727
  * ```
4496
4728
  */
4497
4729
  async onNotification(e) {
4498
- const s = await this.resolveAccessToken(), r = ut(`${this.socketOrigin}/notifications`, {
4730
+ const s = await this.resolveAccessToken(), r = pt(`${this.socketOrigin}/notifications`, {
4499
4731
  auth: { accessToken: s },
4500
4732
  transports: ["websocket"]
4501
4733
  });
@@ -4511,38 +4743,41 @@ const ye = class ye extends Zt {
4511
4743
  ), () => r.disconnect();
4512
4744
  }
4513
4745
  };
4514
- st = new WeakMap(), mt = new WeakMap();
4515
- let xe = ye;
4516
- const wn = {
4746
+ at = new WeakMap(), _t = new WeakMap();
4747
+ let Be = _e;
4748
+ const An = {
4517
4749
  MAX_FIELDS: 200,
4518
4750
  MAX_KEY_LENGTH: 50,
4519
4751
  MAX_VALUE_LENGTH: 50
4520
- }, _n = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, bn = { 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" };
4521
4753
  export {
4522
- _n as CDEManager,
4523
- yn as ChannelClient,
4524
- Ye as ChannelRoom,
4525
- bn as ClashesManager,
4526
- dn as CollabRoom,
4527
- Zt as EngineServicesClient,
4528
- fn as ExternalRoom,
4529
- En as FileList,
4530
- zs as FlowDoc,
4531
- vn as GISManager,
4532
- Tn as GitHistoryManager,
4533
- Sn as HelloWorld,
4534
- wn as METADATA_LIMITS,
4535
- xe as PlatformClient,
4536
- Xs as ProjectHistory,
4537
- kn as ProjectManager,
4538
- Zs as Recipes,
4539
- fe as RequestError,
4540
- Ae as STORAGE_BATCH_MAX,
4541
- ve as StaleHistoryError,
4542
- On as TopicsManager,
4543
- An as UIManager,
4544
- zt as mintGuid,
4545
- Ve as orderByGraph,
4546
- 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
4547
4782
  };
4548
4783
  //# sourceMappingURL=index.es.js.map