@thatopen/services 0.28.2 → 0.29.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 un = Object.defineProperty;
2
- var as = (n) => {
1
+ var Tn = Object.defineProperty;
2
+ var ys = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var fn = (n, e, t) => e in n ? un(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
- var B = (n, e, t) => fn(n, typeof e != "symbol" ? e + "" : e, t), Tt = (n, e, t) => e.has(n) || as("Cannot " + t);
7
- var u = (n, e, t) => (Tt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), S = (n, e, t) => e.has(n) ? as("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), R = (n, e, t, s) => (Tt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t), h = (n, e, t) => (Tt(n, e, "access private method"), t);
8
- const ne = /* @__PURE__ */ Object.create(null);
9
- ne.open = "0";
10
- ne.close = "1";
11
- ne.ping = "2";
12
- ne.pong = "3";
13
- ne.message = "4";
14
- ne.upgrade = "5";
15
- ne.noop = "6";
16
- const lt = /* @__PURE__ */ Object.create(null);
17
- Object.keys(ne).forEach((n) => {
18
- lt[ne[n]] = n;
5
+ var _n = (n, e, t) => e in n ? Tn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var L = (n, e, t) => _n(n, typeof e != "symbol" ? e + "" : e, t), $t = (n, e, t) => e.has(n) || ys("Cannot " + t);
7
+ var u = (n, e, t) => ($t(n, e, "read from private field"), t ? t.call(n) : e.get(n)), S = (n, e, t) => e.has(n) ? ys("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), $ = (n, e, t, s) => ($t(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t), h = (n, e, t) => ($t(n, e, "access private method"), t);
8
+ const re = /* @__PURE__ */ Object.create(null);
9
+ re.open = "0";
10
+ re.close = "1";
11
+ re.ping = "2";
12
+ re.pong = "3";
13
+ re.message = "4";
14
+ re.upgrade = "5";
15
+ re.noop = "6";
16
+ const gt = /* @__PURE__ */ Object.create(null);
17
+ Object.keys(re).forEach((n) => {
18
+ gt[re[n]] = n;
19
19
  });
20
- const Ct = { type: "error", data: "parser error" }, Cs = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", $s = typeof ArrayBuffer == "function", xs = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, Zt = ({ type: n, data: e }, t, s) => Cs && e instanceof Blob ? t ? s(e) : cs(e, s) : $s && (e instanceof ArrayBuffer || xs(e)) ? t ? s(e) : cs(new Blob([e]), s) : s(ne[n] + (e || "")), cs = (n, e) => {
20
+ const Lt = { type: "error", data: "parser error" }, js = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Us = typeof ArrayBuffer == "function", Ms = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, cs = ({ type: n, data: e }, t, s) => js && e instanceof Blob ? t ? s(e) : gs(e, s) : Us && (e instanceof ArrayBuffer || Ms(e)) ? t ? s(e) : gs(new Blob([e]), s) : s(re[n] + (e || "")), gs = (n, e) => {
21
21
  const t = new FileReader();
22
22
  return t.onload = function() {
23
23
  const s = t.result.split(",")[1];
24
24
  e("b" + (s || ""));
25
25
  }, t.readAsDataURL(n);
26
26
  };
27
- function hs(n) {
27
+ function ws(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 _t;
31
- function pn(n, e) {
32
- if (Cs && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(hs).then(e);
34
- if ($s && (n.data instanceof ArrayBuffer || xs(n.data)))
35
- return e(hs(n.data));
36
- Zt(n, !1, (t) => {
37
- _t || (_t = new TextEncoder()), e(_t.encode(t));
30
+ let Ct;
31
+ function In(n, e) {
32
+ if (js && n.data instanceof Blob)
33
+ return n.data.arrayBuffer().then(ws).then(e);
34
+ if (Us && (n.data instanceof ArrayBuffer || Ms(n.data)))
35
+ return e(ws(n.data));
36
+ cs(n, !1, (t) => {
37
+ Ct || (Ct = new TextEncoder()), e(Ct.encode(t));
38
38
  });
39
39
  }
40
- const ls = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Je = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
- for (let n = 0; n < ls.length; n++)
42
- Je[ls.charCodeAt(n)] = n;
43
- const mn = (n) => {
40
+ const vs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Xe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
+ for (let n = 0; n < vs.length; n++)
42
+ Xe[vs.charCodeAt(n)] = n;
43
+ const Sn = (n) => {
44
44
  let e = n.length * 0.75, t = n.length, s, r = 0, i, o, a, l;
45
45
  n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
46
46
  const d = new ArrayBuffer(e), c = new Uint8Array(d);
47
47
  for (s = 0; s < t; s += 4)
48
- i = Je[n.charCodeAt(s)], o = Je[n.charCodeAt(s + 1)], a = Je[n.charCodeAt(s + 2)], l = Je[n.charCodeAt(s + 3)], c[r++] = i << 2 | o >> 4, c[r++] = (o & 15) << 4 | a >> 2, c[r++] = (a & 3) << 6 | l & 63;
48
+ i = Xe[n.charCodeAt(s)], o = Xe[n.charCodeAt(s + 1)], a = Xe[n.charCodeAt(s + 2)], l = Xe[n.charCodeAt(s + 3)], c[r++] = i << 2 | o >> 4, c[r++] = (o & 15) << 4 | a >> 2, c[r++] = (a & 3) << 6 | l & 63;
49
49
  return d;
50
- }, yn = typeof ArrayBuffer == "function", es = (n, e) => {
50
+ }, An = typeof ArrayBuffer == "function", hs = (n, e) => {
51
51
  if (typeof n != "string")
52
52
  return {
53
53
  type: "message",
54
- data: Ns(n, e)
54
+ data: Vs(n, e)
55
55
  };
56
56
  const t = n.charAt(0);
57
57
  return t === "b" ? {
58
58
  type: "message",
59
- data: gn(n.substring(1), e)
60
- } : lt[t] ? n.length > 1 ? {
61
- type: lt[t],
59
+ data: On(n.substring(1), e)
60
+ } : gt[t] ? n.length > 1 ? {
61
+ type: gt[t],
62
62
  data: n.substring(1)
63
63
  } : {
64
- type: lt[t]
65
- } : Ct;
66
- }, gn = (n, e) => {
67
- if (yn) {
68
- const t = mn(n);
69
- return Ns(t, e);
64
+ type: gt[t]
65
+ } : Lt;
66
+ }, On = (n, e) => {
67
+ if (An) {
68
+ const t = Sn(n);
69
+ return Vs(t, e);
70
70
  } else
71
71
  return { base64: !0, data: n };
72
- }, Ns = (n, e) => {
72
+ }, Vs = (n, e) => {
73
73
  switch (e) {
74
74
  case "blob":
75
75
  return n instanceof Blob ? n : new Blob([n]);
@@ -77,27 +77,27 @@ const mn = (n) => {
77
77
  default:
78
78
  return n instanceof ArrayBuffer ? n : n.buffer;
79
79
  }
80
- }, Ps = "", wn = (n, e) => {
80
+ }, Hs = "", kn = (n, e) => {
81
81
  const t = n.length, s = new Array(t);
82
82
  let r = 0;
83
83
  n.forEach((i, o) => {
84
- Zt(i, !1, (a) => {
85
- s[o] = a, ++r === t && e(s.join(Ps));
84
+ cs(i, !1, (a) => {
85
+ s[o] = a, ++r === t && e(s.join(Hs));
86
86
  });
87
87
  });
88
- }, bn = (n, e) => {
89
- const t = n.split(Ps), s = [];
88
+ }, Rn = (n, e) => {
89
+ const t = n.split(Hs), s = [];
90
90
  for (let r = 0; r < t.length; r++) {
91
- const i = es(t[r], e);
91
+ const i = hs(t[r], e);
92
92
  if (s.push(i), i.type === "error")
93
93
  break;
94
94
  }
95
95
  return s;
96
96
  };
97
- function vn() {
97
+ function $n() {
98
98
  return new TransformStream({
99
99
  transform(n, e) {
100
- pn(n, (t) => {
100
+ In(n, (t) => {
101
101
  const s = t.length;
102
102
  let r;
103
103
  if (s < 126)
@@ -116,11 +116,11 @@ function vn() {
116
116
  }
117
117
  });
118
118
  }
119
- let It;
120
- function it(n) {
119
+ let xt;
120
+ function ut(n) {
121
121
  return n.reduce((e, t) => e + t.length, 0);
122
122
  }
123
- function ot(n, e) {
123
+ function ft(n, e) {
124
124
  if (n[0].length === e)
125
125
  return n.shift();
126
126
  const t = new Uint8Array(e);
@@ -129,51 +129,51 @@ function ot(n, e) {
129
129
  t[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)), t;
131
131
  }
132
- function En(n, e) {
133
- It || (It = new TextDecoder());
132
+ function Cn(n, e) {
133
+ xt || (xt = new TextDecoder());
134
134
  const t = [];
135
135
  let s = 0, r = -1, i = !1;
136
136
  return new TransformStream({
137
137
  transform(o, a) {
138
138
  for (t.push(o); ; ) {
139
139
  if (s === 0) {
140
- if (it(t) < 1)
140
+ if (ut(t) < 1)
141
141
  break;
142
- const l = ot(t, 1);
142
+ const l = ft(t, 1);
143
143
  i = (l[0] & 128) === 128, r = l[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
144
144
  } else if (s === 1) {
145
- if (it(t) < 2)
145
+ if (ut(t) < 2)
146
146
  break;
147
- const l = ot(t, 2);
147
+ const l = ft(t, 2);
148
148
  r = new DataView(l.buffer, l.byteOffset, l.length).getUint16(0), s = 3;
149
149
  } else if (s === 2) {
150
- if (it(t) < 8)
150
+ if (ut(t) < 8)
151
151
  break;
152
- const l = ot(t, 8), d = new DataView(l.buffer, l.byteOffset, l.length), c = d.getUint32(0);
152
+ const l = ft(t, 8), d = new DataView(l.buffer, l.byteOffset, l.length), c = d.getUint32(0);
153
153
  if (c > Math.pow(2, 21) - 1) {
154
- a.enqueue(Ct);
154
+ a.enqueue(Lt);
155
155
  break;
156
156
  }
157
157
  r = c * Math.pow(2, 32) + d.getUint32(4), s = 3;
158
158
  } else {
159
- if (it(t) < r)
159
+ if (ut(t) < r)
160
160
  break;
161
- const l = ot(t, r);
162
- a.enqueue(es(i ? l : It.decode(l), e)), s = 0;
161
+ const l = ft(t, r);
162
+ a.enqueue(hs(i ? l : xt.decode(l), e)), s = 0;
163
163
  }
164
164
  if (r === 0 || r > n) {
165
- a.enqueue(Ct);
165
+ a.enqueue(Lt);
166
166
  break;
167
167
  }
168
168
  }
169
169
  }
170
170
  });
171
171
  }
172
- const Bs = 4;
172
+ const Gs = 4;
173
173
  function C(n) {
174
- if (n) return Tn(n);
174
+ if (n) return xn(n);
175
175
  }
176
- function Tn(n) {
176
+ function xn(n) {
177
177
  for (var e in C.prototype)
178
178
  n[e] = C.prototype[e];
179
179
  return n;
@@ -219,34 +219,34 @@ C.prototype.listeners = function(n) {
219
219
  C.prototype.hasListeners = function(n) {
220
220
  return !!this.listeners(n).length;
221
221
  };
222
- const vt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), H = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), _n = "arraybuffer";
223
- function Fs(n, ...e) {
222
+ const kt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), J = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Nn = "arraybuffer";
223
+ function Js(n, ...e) {
224
224
  return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
225
225
  }
226
- const In = H.setTimeout, Sn = H.clearTimeout;
227
- function Et(n, e) {
228
- e.useNativeTimers ? (n.setTimeoutFn = In.bind(H), n.clearTimeoutFn = Sn.bind(H)) : (n.setTimeoutFn = H.setTimeout.bind(H), n.clearTimeoutFn = H.clearTimeout.bind(H));
226
+ const Fn = J.setTimeout, Pn = J.clearTimeout;
227
+ function Rt(n, e) {
228
+ e.useNativeTimers ? (n.setTimeoutFn = Fn.bind(J), n.clearTimeoutFn = Pn.bind(J)) : (n.setTimeoutFn = J.setTimeout.bind(J), n.clearTimeoutFn = J.clearTimeout.bind(J));
229
229
  }
230
- const kn = 1.33;
231
- function On(n) {
232
- return typeof n == "string" ? An(n) : Math.ceil((n.byteLength || n.size) * kn);
230
+ const Bn = 1.33;
231
+ function Ln(n) {
232
+ return typeof n == "string" ? Dn(n) : Math.ceil((n.byteLength || n.size) * Bn);
233
233
  }
234
- function An(n) {
234
+ function Dn(n) {
235
235
  let e = 0, t = 0;
236
236
  for (let s = 0, r = n.length; s < r; s++)
237
237
  e = n.charCodeAt(s), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (s++, t += 4);
238
238
  return t;
239
239
  }
240
- function Ls() {
240
+ function Ws() {
241
241
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
242
242
  }
243
- function Rn(n) {
243
+ function qn(n) {
244
244
  let e = "";
245
245
  for (let t in n)
246
246
  n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
247
247
  return e;
248
248
  }
249
- function Cn(n) {
249
+ function jn(n) {
250
250
  let e = {}, t = n.split("&");
251
251
  for (let s = 0, r = t.length; s < r; s++) {
252
252
  let i = t[s].split("=");
@@ -254,12 +254,12 @@ function Cn(n) {
254
254
  }
255
255
  return e;
256
256
  }
257
- class $n extends Error {
257
+ class Un extends Error {
258
258
  constructor(e, t, s) {
259
259
  super(e), this.description = t, this.context = s, this.type = "TransportError";
260
260
  }
261
261
  }
262
- class ts extends C {
262
+ class ls extends C {
263
263
  /**
264
264
  * Transport abstract constructor.
265
265
  *
@@ -267,7 +267,7 @@ class ts extends C {
267
267
  * @protected
268
268
  */
269
269
  constructor(e) {
270
- super(), this.writable = !1, Et(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
270
+ super(), this.writable = !1, Rt(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
271
271
  }
272
272
  /**
273
273
  * Emits an error.
@@ -279,7 +279,7 @@ class ts extends C {
279
279
  * @protected
280
280
  */
281
281
  onError(e, t, s) {
282
- return super.emitReserved("error", new $n(e, t, s)), this;
282
+ return super.emitReserved("error", new Un(e, t, s)), this;
283
283
  }
284
284
  /**
285
285
  * Opens the transport.
@@ -316,7 +316,7 @@ class ts extends C {
316
316
  * @protected
317
317
  */
318
318
  onData(e) {
319
- const t = es(e, this.socket.binaryType);
319
+ const t = hs(e, this.socket.binaryType);
320
320
  this.onPacket(t);
321
321
  }
322
322
  /**
@@ -353,11 +353,11 @@ class ts extends C {
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(e) {
356
- const t = Rn(e);
356
+ const t = qn(e);
357
357
  return t.length ? "?" + t : "";
358
358
  }
359
359
  }
360
- class xn extends ts {
360
+ class Mn extends ls {
361
361
  constructor() {
362
362
  super(...arguments), this._polling = !1;
363
363
  }
@@ -413,7 +413,7 @@ class xn extends ts {
413
413
  return this.onClose({ description: "transport closed by the server" }), !1;
414
414
  this.onPacket(s);
415
415
  };
416
- bn(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
416
+ Rn(e, this.socket.binaryType).forEach(t), 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 xn extends ts {
433
433
  * @protected
434
434
  */
435
435
  write(e) {
436
- this.writable = !1, wn(e, (t) => {
436
+ this.writable = !1, kn(e, (t) => {
437
437
  this.doWrite(t, () => {
438
438
  this.writable = !0, this.emitReserved("drain");
439
439
  });
@@ -446,18 +446,18 @@ class xn extends ts {
446
446
  */
447
447
  uri() {
448
448
  const e = this.opts.secure ? "https" : "http", t = this.query || {};
449
- return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = Ls()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
449
+ return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = Ws()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
450
450
  }
451
451
  }
452
- let Ds = !1;
452
+ let Ys = !1;
453
453
  try {
454
- Ds = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
454
+ Ys = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
455
455
  } catch {
456
456
  }
457
- const Nn = Ds;
458
- function Pn() {
457
+ const Vn = Ys;
458
+ function Hn() {
459
459
  }
460
- class Bn extends xn {
460
+ class Gn extends Mn {
461
461
  /**
462
462
  * XHR Polling constructor.
463
463
  *
@@ -499,7 +499,7 @@ class Bn extends xn {
499
499
  }), this.pollXhr = e;
500
500
  }
501
501
  }
502
- class se extends C {
502
+ class ne extends C {
503
503
  /**
504
504
  * Request constructor
505
505
  *
@@ -507,7 +507,7 @@ class se extends C {
507
507
  * @package
508
508
  */
509
509
  constructor(e, t, s) {
510
- super(), this.createRequest = e, Et(this, s), this._opts = s, this._method = s.method || "GET", this._uri = t, this._data = s.data !== void 0 ? s.data : null, this._create();
510
+ super(), this.createRequest = e, Rt(this, s), this._opts = s, this._method = s.method || "GET", this._uri = t, 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 se extends C {
516
516
  */
517
517
  _create() {
518
518
  var e;
519
- const t = Fs(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
519
+ const t = Js(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
520
520
  t.xdomain = !!this._opts.xd;
521
521
  const s = this._xhr = this.createRequest(t);
522
522
  try {
@@ -553,7 +553,7 @@ class se extends C {
553
553
  }, 0);
554
554
  return;
555
555
  }
556
- typeof document < "u" && (this._index = se.requestsCount++, se.requests[this._index] = this);
556
+ typeof document < "u" && (this._index = ne.requestsCount++, ne.requests[this._index] = this);
557
557
  }
558
558
  /**
559
559
  * Called upon error.
@@ -570,12 +570,12 @@ class se extends C {
570
570
  */
571
571
  _cleanup(e) {
572
572
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
573
- if (this._xhr.onreadystatechange = Pn, e)
573
+ if (this._xhr.onreadystatechange = Hn, e)
574
574
  try {
575
575
  this._xhr.abort();
576
576
  } catch {
577
577
  }
578
- typeof document < "u" && delete se.requests[this._index], this._xhr = null;
578
+ typeof document < "u" && delete ne.requests[this._index], this._xhr = null;
579
579
  }
580
580
  }
581
581
  /**
@@ -596,56 +596,56 @@ class se extends C {
596
596
  this._cleanup();
597
597
  }
598
598
  }
599
- se.requestsCount = 0;
600
- se.requests = {};
599
+ ne.requestsCount = 0;
600
+ ne.requests = {};
601
601
  if (typeof document < "u") {
602
602
  if (typeof attachEvent == "function")
603
- attachEvent("onunload", ds);
603
+ attachEvent("onunload", bs);
604
604
  else if (typeof addEventListener == "function") {
605
- const n = "onpagehide" in H ? "pagehide" : "unload";
606
- addEventListener(n, ds, !1);
605
+ const n = "onpagehide" in J ? "pagehide" : "unload";
606
+ addEventListener(n, bs, !1);
607
607
  }
608
608
  }
609
- function ds() {
610
- for (let n in se.requests)
611
- se.requests.hasOwnProperty(n) && se.requests[n].abort();
609
+ function bs() {
610
+ for (let n in ne.requests)
611
+ ne.requests.hasOwnProperty(n) && ne.requests[n].abort();
612
612
  }
613
- const Fn = function() {
614
- const n = qs({
613
+ const Jn = function() {
614
+ const n = zs({
615
615
  xdomain: !1
616
616
  });
617
617
  return n && n.responseType !== null;
618
618
  }();
619
- class Ln extends Bn {
619
+ class Wn extends Gn {
620
620
  constructor(e) {
621
621
  super(e);
622
622
  const t = e && e.forceBase64;
623
- this.supportsBinary = Fn && !t;
623
+ this.supportsBinary = Jn && !t;
624
624
  }
625
625
  request(e = {}) {
626
- return Object.assign(e, { xd: this.xd }, this.opts), new se(qs, this.uri(), e);
626
+ return Object.assign(e, { xd: this.xd }, this.opts), new ne(zs, this.uri(), e);
627
627
  }
628
628
  }
629
- function qs(n) {
629
+ function zs(n) {
630
630
  const e = n.xdomain;
631
631
  try {
632
- if (typeof XMLHttpRequest < "u" && (!e || Nn))
632
+ if (typeof XMLHttpRequest < "u" && (!e || Vn))
633
633
  return new XMLHttpRequest();
634
634
  } catch {
635
635
  }
636
636
  if (!e)
637
637
  try {
638
- return new H[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
638
+ return new J[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
639
639
  } catch {
640
640
  }
641
641
  }
642
- const js = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
- class Dn extends ts {
642
+ const Ks = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
643
+ class Yn extends ls {
644
644
  get name() {
645
645
  return "websocket";
646
646
  }
647
647
  doOpen() {
648
- const e = this.uri(), t = this.opts.protocols, s = js ? {} : Fs(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
648
+ const e = this.uri(), t = this.opts.protocols, s = Ks ? {} : Js(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(e, t, s);
@@ -671,12 +671,12 @@ class Dn extends ts {
671
671
  this.writable = !1;
672
672
  for (let t = 0; t < e.length; t++) {
673
673
  const s = e[t], r = t === e.length - 1;
674
- Zt(s, this.supportsBinary, (i) => {
674
+ cs(s, this.supportsBinary, (i) => {
675
675
  try {
676
676
  this.doWrite(s, i);
677
677
  } catch {
678
678
  }
679
- r && vt(() => {
679
+ r && kt(() => {
680
680
  this.writable = !0, this.emitReserved("drain");
681
681
  }, this.setTimeoutFn);
682
682
  });
@@ -693,19 +693,19 @@ class Dn extends ts {
693
693
  */
694
694
  uri() {
695
695
  const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
696
- return this.opts.timestampRequests && (t[this.opts.timestampParam] = Ls()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
696
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = Ws()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
697
697
  }
698
698
  }
699
- const St = H.WebSocket || H.MozWebSocket;
700
- class qn extends Dn {
699
+ const Nt = J.WebSocket || J.MozWebSocket;
700
+ class zn extends Yn {
701
701
  createSocket(e, t, s) {
702
- return js ? new St(e, t, s) : t ? new St(e, t) : new St(e);
702
+ return Ks ? new Nt(e, t, s) : t ? new Nt(e, t) : new Nt(e);
703
703
  }
704
704
  doWrite(e, t) {
705
705
  this.ws.send(t);
706
706
  }
707
707
  }
708
- class jn extends ts {
708
+ class Kn extends ls {
709
709
  get name() {
710
710
  return "webtransport";
711
711
  }
@@ -721,7 +721,7 @@ class jn extends ts {
721
721
  this.onError("webtransport error", e);
722
722
  }), this._transport.ready.then(() => {
723
723
  this._transport.createBidirectionalStream().then((e) => {
724
- const t = En(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), r = vn();
724
+ const t = Cn(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), r = $n();
725
725
  r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
726
726
  const i = () => {
727
727
  s.read().then(({ done: a, value: l }) => {
@@ -740,7 +740,7 @@ class jn extends ts {
740
740
  for (let t = 0; t < e.length; t++) {
741
741
  const s = e[t], r = t === e.length - 1;
742
742
  this._writer.write(s).then(() => {
743
- r && vt(() => {
743
+ r && kt(() => {
744
744
  this.writable = !0, this.emitReserved("drain");
745
745
  }, this.setTimeoutFn);
746
746
  });
@@ -751,11 +751,11 @@ class jn extends ts {
751
751
  (e = this._transport) === null || e === void 0 || e.close();
752
752
  }
753
753
  }
754
- const Un = {
755
- websocket: qn,
756
- webtransport: jn,
757
- polling: Ln
758
- }, Mn = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Vn = [
754
+ const Xn = {
755
+ websocket: zn,
756
+ webtransport: Kn,
757
+ polling: Wn
758
+ }, Qn = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Zn = [
759
759
  "source",
760
760
  "protocol",
761
761
  "authority",
@@ -771,29 +771,29 @@ const Un = {
771
771
  "query",
772
772
  "anchor"
773
773
  ];
774
- function $t(n) {
774
+ function Dt(n) {
775
775
  if (n.length > 8e3)
776
776
  throw "URI too long";
777
777
  const e = n, t = n.indexOf("["), s = n.indexOf("]");
778
778
  t != -1 && s != -1 && (n = n.substring(0, t) + n.substring(t, s).replace(/:/g, ";") + n.substring(s, n.length));
779
- let r = Mn.exec(n || ""), i = {}, o = 14;
779
+ let r = Qn.exec(n || ""), i = {}, o = 14;
780
780
  for (; o--; )
781
- i[Vn[o]] = r[o] || "";
782
- return t != -1 && s != -1 && (i.source = e, 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 = Hn(i, i.path), i.queryKey = Gn(i, i.query), i;
781
+ i[Zn[o]] = r[o] || "";
782
+ return t != -1 && s != -1 && (i.source = e, 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 = er(i, i.path), i.queryKey = tr(i, i.query), i;
783
783
  }
784
- function Hn(n, e) {
784
+ function er(n, e) {
785
785
  const t = /\/{2,9}/g, s = e.replace(t, "/").split("/");
786
786
  return (e.slice(0, 1) == "/" || e.length === 0) && s.splice(0, 1), e.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
787
787
  }
788
- function Gn(n, e) {
788
+ function tr(n, e) {
789
789
  const t = {};
790
790
  return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
791
791
  r && (t[r] = i);
792
792
  }), t;
793
793
  }
794
- const xt = typeof addEventListener == "function" && typeof removeEventListener == "function", dt = [];
795
- xt && addEventListener("offline", () => {
796
- dt.forEach((n) => n());
794
+ const qt = typeof addEventListener == "function" && typeof removeEventListener == "function", wt = [];
795
+ qt && addEventListener("offline", () => {
796
+ wt.forEach((n) => n());
797
797
  }, !1);
798
798
  class we extends C {
799
799
  /**
@@ -803,11 +803,11 @@ class we extends C {
803
803
  * @param {Object} opts - options
804
804
  */
805
805
  constructor(e, t) {
806
- if (super(), this.binaryType = _n, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
807
- const s = $t(e);
806
+ if (super(), this.binaryType = Nn, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
807
+ const s = Dt(e);
808
808
  t.hostname = s.host, t.secure = s.protocol === "https" || s.protocol === "wss", t.port = s.port, s.query && (t.query = s.query);
809
- } else t.host && (t.hostname = $t(t.host).host);
810
- Et(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((s) => {
809
+ } else t.host && (t.hostname = Dt(t.host).host);
810
+ Rt(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.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 we extends C {
824
824
  },
825
825
  transportOptions: {},
826
826
  closeOnBeforeunload: !1
827
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Cn(this.opts.query)), xt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
827
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = jn(this.opts.query)), qt && (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
- }, dt.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
833
+ }, wt.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 we extends C {
841
841
  */
842
842
  createTransport(e) {
843
843
  const t = Object.assign({}, this.opts.query);
844
- t.EIO = Bs, t.transport = e, this.id && (t.sid = this.id);
844
+ t.EIO = Gs, t.transport = e, this.id && (t.sid = this.id);
845
845
  const s = Object.assign({}, this.opts, {
846
846
  query: t,
847
847
  socket: this,
@@ -959,7 +959,7 @@ class we extends C {
959
959
  let t = 1;
960
960
  for (let s = 0; s < this.writeBuffer.length; s++) {
961
961
  const r = this.writeBuffer[s].data;
962
- if (r && (t += On(r)), s > 0 && t > this._maxPayload)
962
+ if (r && (t += Ln(r)), s > 0 && t > this._maxPayload)
963
963
  return this.writeBuffer.slice(0, s);
964
964
  t += 2;
965
965
  }
@@ -979,7 +979,7 @@ class we extends C {
979
979
  if (!this._pingTimeoutTime)
980
980
  return !0;
981
981
  const e = Date.now() > this._pingTimeoutTime;
982
- return e && (this._pingTimeoutTime = 0, vt(() => {
982
+ return e && (this._pingTimeoutTime = 0, kt(() => {
983
983
  this._onClose("ping timeout");
984
984
  }, this.setTimeoutFn)), e;
985
985
  }
@@ -1057,16 +1057,16 @@ class we extends C {
1057
1057
  */
1058
1058
  _onClose(e, t) {
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(), xt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
- const s = dt.indexOf(this._offlineEventListener);
1062
- s !== -1 && dt.splice(s, 1);
1060
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), qt && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1061
+ const s = wt.indexOf(this._offlineEventListener);
1062
+ s !== -1 && wt.splice(s, 1);
1063
1063
  }
1064
1064
  this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
1065
1065
  }
1066
1066
  }
1067
1067
  }
1068
- we.protocol = Bs;
1069
- class Jn extends we {
1068
+ we.protocol = Gs;
1069
+ class sr extends we {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1085,9 +1085,9 @@ class Jn extends we {
1085
1085
  let t = this.createTransport(e), s = !1;
1086
1086
  we.priorWebsocketSuccess = !1;
1087
1087
  const r = () => {
1088
- s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (m) => {
1088
+ s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (y) => {
1089
1089
  if (!s)
1090
- if (m.type === "pong" && m.data === "probe") {
1090
+ if (y.type === "pong" && y.data === "probe") {
1091
1091
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
1092
1092
  return;
1093
1093
  we.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
@@ -1102,8 +1102,8 @@ class Jn extends we {
1102
1102
  function i() {
1103
1103
  s || (s = !0, c(), t.close(), t = null);
1104
1104
  }
1105
- const o = (m) => {
1106
- const T = new Error("probe error: " + m);
1105
+ const o = (y) => {
1106
+ const T = new Error("probe error: " + y);
1107
1107
  T.transport = t.name, i(), this.emitReserved("upgradeError", T);
1108
1108
  };
1109
1109
  function a() {
@@ -1112,8 +1112,8 @@ class Jn extends we {
1112
1112
  function l() {
1113
1113
  o("socket closed");
1114
1114
  }
1115
- function d(m) {
1116
- t && m.name !== t.name && i();
1115
+ function d(y) {
1116
+ t && y.name !== t.name && i();
1117
1117
  }
1118
1118
  const c = () => {
1119
1119
  t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", a), this.off("close", l), this.off("upgrading", d);
@@ -1138,67 +1138,67 @@ class Jn extends we {
1138
1138
  return t;
1139
1139
  }
1140
1140
  }
1141
- let Wn = class extends Jn {
1141
+ let nr = class extends sr {
1142
1142
  constructor(e, t = {}) {
1143
1143
  const s = typeof e == "object", r = s ? { ...e } : { ...t };
1144
- (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Un[i]).filter((i) => !!i)), super(s ? r : e, r);
1144
+ (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Xn[i]).filter((i) => !!i)), super(s ? r : e, r);
1145
1145
  }
1146
1146
  };
1147
- function Yn(n, e = "", t) {
1147
+ function rr(n, e = "", t) {
1148
1148
  let s = n;
1149
- t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = $t(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
+ t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = Dt(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 + e, s.href = s.protocol + "://" + i + (t && t.port === s.port ? "" : ":" + s.port), s;
1152
1152
  }
1153
- const zn = typeof ArrayBuffer == "function", Kn = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Us = Object.prototype.toString, Xn = typeof Blob == "function" || typeof Blob < "u" && Us.call(Blob) === "[object BlobConstructor]", Qn = typeof File == "function" || typeof File < "u" && Us.call(File) === "[object FileConstructor]";
1154
- function ss(n) {
1155
- return zn && (n instanceof ArrayBuffer || Kn(n)) || Xn && n instanceof Blob || Qn && n instanceof File;
1153
+ const ir = typeof ArrayBuffer == "function", or = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, Xs = Object.prototype.toString, ar = typeof Blob == "function" || typeof Blob < "u" && Xs.call(Blob) === "[object BlobConstructor]", cr = typeof File == "function" || typeof File < "u" && Xs.call(File) === "[object FileConstructor]";
1154
+ function ds(n) {
1155
+ return ir && (n instanceof ArrayBuffer || or(n)) || ar && n instanceof Blob || cr && n instanceof File;
1156
1156
  }
1157
- function ut(n, e) {
1157
+ function vt(n, e) {
1158
1158
  if (!n || typeof n != "object")
1159
1159
  return !1;
1160
1160
  if (Array.isArray(n)) {
1161
1161
  for (let t = 0, s = n.length; t < s; t++)
1162
- if (ut(n[t]))
1162
+ if (vt(n[t]))
1163
1163
  return !0;
1164
1164
  return !1;
1165
1165
  }
1166
- if (ss(n))
1166
+ if (ds(n))
1167
1167
  return !0;
1168
1168
  if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1169
- return ut(n.toJSON(), !0);
1169
+ return vt(n.toJSON(), !0);
1170
1170
  for (const t in n)
1171
- if (Object.prototype.hasOwnProperty.call(n, t) && ut(n[t]))
1171
+ if (Object.prototype.hasOwnProperty.call(n, t) && vt(n[t]))
1172
1172
  return !0;
1173
1173
  return !1;
1174
1174
  }
1175
- function Zn(n) {
1175
+ function hr(n) {
1176
1176
  const e = [], t = n.data, s = n;
1177
- return s.data = Nt(t, e), s.attachments = e.length, { packet: s, buffers: e };
1177
+ return s.data = jt(t, e), s.attachments = e.length, { packet: s, buffers: e };
1178
1178
  }
1179
- function Nt(n, e) {
1179
+ function jt(n, e) {
1180
1180
  if (!n)
1181
1181
  return n;
1182
- if (ss(n)) {
1182
+ if (ds(n)) {
1183
1183
  const t = { _placeholder: !0, num: e.length };
1184
1184
  return e.push(n), t;
1185
1185
  } else if (Array.isArray(n)) {
1186
1186
  const t = new Array(n.length);
1187
1187
  for (let s = 0; s < n.length; s++)
1188
- t[s] = Nt(n[s], e);
1188
+ t[s] = jt(n[s], e);
1189
1189
  return t;
1190
1190
  } else if (typeof n == "object" && !(n instanceof Date)) {
1191
1191
  const t = {};
1192
1192
  for (const s in n)
1193
- Object.prototype.hasOwnProperty.call(n, s) && (t[s] = Nt(n[s], e));
1193
+ Object.prototype.hasOwnProperty.call(n, s) && (t[s] = jt(n[s], e));
1194
1194
  return t;
1195
1195
  }
1196
1196
  return n;
1197
1197
  }
1198
- function er(n, e) {
1199
- return n.data = Pt(n.data, e), delete n.attachments, n;
1198
+ function lr(n, e) {
1199
+ return n.data = Ut(n.data, e), delete n.attachments, n;
1200
1200
  }
1201
- function Pt(n, e) {
1201
+ function Ut(n, e) {
1202
1202
  if (!n)
1203
1203
  return n;
1204
1204
  if (n && n._placeholder === !0) {
@@ -1207,13 +1207,13 @@ function Pt(n, e) {
1207
1207
  throw new Error("illegal attachments");
1208
1208
  } else if (Array.isArray(n))
1209
1209
  for (let t = 0; t < n.length; t++)
1210
- n[t] = Pt(n[t], e);
1210
+ n[t] = Ut(n[t], e);
1211
1211
  else if (typeof n == "object")
1212
1212
  for (const t in n)
1213
- Object.prototype.hasOwnProperty.call(n, t) && (n[t] = Pt(n[t], e));
1213
+ Object.prototype.hasOwnProperty.call(n, t) && (n[t] = Ut(n[t], e));
1214
1214
  return n;
1215
1215
  }
1216
- const tr = [
1216
+ const dr = [
1217
1217
  "connect",
1218
1218
  // used on the client side
1219
1219
  "connect_error",
@@ -1231,7 +1231,7 @@ var E;
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
  })(E || (E = {}));
1234
- class sr {
1234
+ class ur {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,7 +1247,7 @@ class sr {
1247
1247
  * @param {Object} obj - packet object
1248
1248
  */
1249
1249
  encode(e) {
1250
- return (e.type === E.EVENT || e.type === E.ACK) && ut(e) ? this.encodeAsBinary({
1250
+ return (e.type === E.EVENT || e.type === E.ACK) && vt(e) ? this.encodeAsBinary({
1251
1251
  type: e.type === E.EVENT ? E.BINARY_EVENT : E.BINARY_ACK,
1252
1252
  nsp: e.nsp,
1253
1253
  data: e.data,
@@ -1267,11 +1267,11 @@ class sr {
1267
1267
  * a list of buffers.
1268
1268
  */
1269
1269
  encodeAsBinary(e) {
1270
- const t = Zn(e), s = this.encodeAsString(t.packet), r = t.buffers;
1270
+ const t = hr(e), s = this.encodeAsString(t.packet), r = t.buffers;
1271
1271
  return r.unshift(s), r;
1272
1272
  }
1273
1273
  }
1274
- class ns extends C {
1274
+ class us extends C {
1275
1275
  /**
1276
1276
  * Decoder constructor
1277
1277
  */
@@ -1293,8 +1293,8 @@ class ns extends C {
1293
1293
  throw new Error("got plaintext data when reconstructing a packet");
1294
1294
  t = this.decodeString(e);
1295
1295
  const s = t.type === E.BINARY_EVENT;
1296
- s || t.type === E.BINARY_ACK ? (t.type = s ? E.EVENT : E.ACK, this.reconstructor = new nr(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1297
- } else if (ss(e) || e.base64)
1296
+ s || t.type === E.BINARY_ACK ? (t.type = s ? E.EVENT : E.ACK, this.reconstructor = new fr(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1297
+ } else if (ds(e) || e.base64)
1298
1298
  if (this.reconstructor)
1299
1299
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
1300
1300
  else
@@ -1323,7 +1323,7 @@ class ns extends C {
1323
1323
  if (o != Number(o) || e.charAt(t) !== "-")
1324
1324
  throw new Error("Illegal attachments");
1325
1325
  const a = Number(o);
1326
- if (!rr(a) || a < 0)
1326
+ if (!pr(a) || a < 0)
1327
1327
  throw new Error("Illegal attachments");
1328
1328
  if (a > this.opts.maxAttachments)
1329
1329
  throw new Error("too many attachments");
@@ -1352,7 +1352,7 @@ class ns extends C {
1352
1352
  }
1353
1353
  if (e.charAt(++t)) {
1354
1354
  const i = this.tryParse(e.substr(t));
1355
- if (ns.isPayloadValid(s.type, i))
1355
+ if (us.isPayloadValid(s.type, i))
1356
1356
  s.data = i;
1357
1357
  else
1358
1358
  throw new Error("invalid payload");
@@ -1369,14 +1369,14 @@ class ns extends C {
1369
1369
  static isPayloadValid(e, t) {
1370
1370
  switch (e) {
1371
1371
  case E.CONNECT:
1372
- return us(t);
1372
+ return Es(t);
1373
1373
  case E.DISCONNECT:
1374
1374
  return t === void 0;
1375
1375
  case E.CONNECT_ERROR:
1376
- return typeof t == "string" || us(t);
1376
+ return typeof t == "string" || Es(t);
1377
1377
  case E.EVENT:
1378
1378
  case E.BINARY_EVENT:
1379
- return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && tr.indexOf(t[0]) === -1);
1379
+ return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && dr.indexOf(t[0]) === -1);
1380
1380
  case E.ACK:
1381
1381
  case E.BINARY_ACK:
1382
1382
  return Array.isArray(t);
@@ -1389,7 +1389,7 @@ class ns extends C {
1389
1389
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1390
1390
  }
1391
1391
  }
1392
- class nr {
1392
+ class fr {
1393
1393
  constructor(e) {
1394
1394
  this.packet = e, this.buffers = [], this.reconPack = e;
1395
1395
  }
@@ -1403,7 +1403,7 @@ class nr {
1403
1403
  */
1404
1404
  takeBinaryData(e) {
1405
1405
  if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
1406
- const t = er(this.reconPack, this.buffers);
1406
+ const t = lr(this.reconPack, this.buffers);
1407
1407
  return this.finishedReconstruction(), t;
1408
1408
  }
1409
1409
  return null;
@@ -1415,26 +1415,26 @@ class nr {
1415
1415
  this.reconPack = null, this.buffers = [];
1416
1416
  }
1417
1417
  }
1418
- const rr = Number.isInteger || function(n) {
1418
+ const pr = Number.isInteger || function(n) {
1419
1419
  return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1420
1420
  };
1421
- function us(n) {
1421
+ function Es(n) {
1422
1422
  return Object.prototype.toString.call(n) === "[object Object]";
1423
1423
  }
1424
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1424
+ const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1425
1425
  __proto__: null,
1426
- Decoder: ns,
1427
- Encoder: sr,
1426
+ Decoder: us,
1427
+ Encoder: ur,
1428
1428
  get PacketType() {
1429
1429
  return E;
1430
1430
  }
1431
1431
  }, Symbol.toStringTag, { value: "Module" }));
1432
- function Y(n, e, t) {
1432
+ function z(n, e, t) {
1433
1433
  return n.on(e, t), function() {
1434
1434
  n.off(e, t);
1435
1435
  };
1436
1436
  }
1437
- const or = Object.freeze({
1437
+ const yr = Object.freeze({
1438
1438
  connect: 1,
1439
1439
  connect_error: 1,
1440
1440
  disconnect: 1,
@@ -1443,7 +1443,7 @@ const or = Object.freeze({
1443
1443
  newListener: 1,
1444
1444
  removeListener: 1
1445
1445
  });
1446
- class Ms extends C {
1446
+ class Qs extends C {
1447
1447
  /**
1448
1448
  * `Socket` constructor.
1449
1449
  */
@@ -1477,10 +1477,10 @@ class Ms extends C {
1477
1477
  return;
1478
1478
  const e = this.io;
1479
1479
  this.subs = [
1480
- Y(e, "open", this.onopen.bind(this)),
1481
- Y(e, "packet", this.onpacket.bind(this)),
1482
- Y(e, "error", this.onerror.bind(this)),
1483
- Y(e, "close", this.onclose.bind(this))
1480
+ z(e, "open", this.onopen.bind(this)),
1481
+ z(e, "packet", this.onpacket.bind(this)),
1482
+ z(e, "error", this.onerror.bind(this)),
1483
+ z(e, "close", this.onclose.bind(this))
1484
1484
  ];
1485
1485
  }
1486
1486
  /**
@@ -1559,7 +1559,7 @@ class Ms extends C {
1559
1559
  */
1560
1560
  emit(e, ...t) {
1561
1561
  var s, r, i;
1562
- if (or.hasOwnProperty(e))
1562
+ if (yr.hasOwnProperty(e))
1563
1563
  throw new Error('"' + e.toString() + '" is a reserved event name');
1564
1564
  if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1565
1565
  return this._addToQueue(t), this;
@@ -1568,8 +1568,8 @@ class Ms extends C {
1568
1568
  data: t
1569
1569
  };
1570
1570
  if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
1571
- const c = this.ids++, m = t.pop();
1572
- this._registerAckCallback(c, m), o.id = c;
1571
+ const c = this.ids++, y = t.pop();
1572
+ this._registerAckCallback(c, y), o.id = c;
1573
1573
  }
1574
1574
  const a = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, l = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
1575
1575
  return this.flags.volatile && !a || (l ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
@@ -2035,10 +2035,10 @@ class Ms extends C {
2035
2035
  }
2036
2036
  }
2037
2037
  }
2038
- function Le(n) {
2038
+ function Me(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
- Le.prototype.duration = function() {
2041
+ Me.prototype.duration = function() {
2042
2042
  var n = this.ms * Math.pow(this.factor, this.attempts++);
2043
2043
  if (this.jitter) {
2044
2044
  var e = Math.random(), t = Math.floor(e * this.jitter * n);
@@ -2046,27 +2046,27 @@ Le.prototype.duration = function() {
2046
2046
  }
2047
2047
  return Math.min(n, this.max) | 0;
2048
2048
  };
2049
- Le.prototype.reset = function() {
2049
+ Me.prototype.reset = function() {
2050
2050
  this.attempts = 0;
2051
2051
  };
2052
- Le.prototype.setMin = function(n) {
2052
+ Me.prototype.setMin = function(n) {
2053
2053
  this.ms = n;
2054
2054
  };
2055
- Le.prototype.setMax = function(n) {
2055
+ Me.prototype.setMax = function(n) {
2056
2056
  this.max = n;
2057
2057
  };
2058
- Le.prototype.setJitter = function(n) {
2058
+ Me.prototype.setJitter = function(n) {
2059
2059
  this.jitter = n;
2060
2060
  };
2061
- class Bt extends C {
2061
+ class Mt extends C {
2062
2062
  constructor(e, t) {
2063
2063
  var s;
2064
- super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, Et(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new Le({
2064
+ super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, Rt(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new Me({
2065
2065
  min: this.reconnectionDelay(),
2066
2066
  max: this.reconnectionDelayMax(),
2067
2067
  jitter: this.randomizationFactor()
2068
2068
  }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
2069
- const r = t.parser || ir;
2069
+ const r = t.parser || mr;
2070
2070
  this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
2071
2071
  }
2072
2072
  reconnection(e) {
@@ -2109,14 +2109,14 @@ class Bt extends C {
2109
2109
  open(e) {
2110
2110
  if (~this._readyState.indexOf("open"))
2111
2111
  return this;
2112
- this.engine = new Wn(this.uri, this.opts);
2112
+ this.engine = new nr(this.uri, this.opts);
2113
2113
  const t = this.engine, s = this;
2114
2114
  this._readyState = "opening", this.skipReconnect = !1;
2115
- const r = Y(t, "open", function() {
2115
+ const r = z(t, "open", function() {
2116
2116
  s.onopen(), e && e();
2117
2117
  }), i = (a) => {
2118
2118
  this.cleanup(), this._readyState = "closed", this.emitReserved("error", a), e ? e(a) : this.maybeReconnectOnOpen();
2119
- }, o = Y(t, "error", i);
2119
+ }, o = z(t, "error", i);
2120
2120
  if (this._timeout !== !1) {
2121
2121
  const a = this._timeout, l = this.setTimeoutFn(() => {
2122
2122
  r(), i(new Error("timeout")), t.close();
@@ -2145,12 +2145,12 @@ class Bt extends C {
2145
2145
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2146
2146
  const e = this.engine;
2147
2147
  this.subs.push(
2148
- Y(e, "ping", this.onping.bind(this)),
2149
- Y(e, "data", this.ondata.bind(this)),
2150
- Y(e, "error", this.onerror.bind(this)),
2151
- Y(e, "close", this.onclose.bind(this)),
2148
+ z(e, "ping", this.onping.bind(this)),
2149
+ z(e, "data", this.ondata.bind(this)),
2150
+ z(e, "error", this.onerror.bind(this)),
2151
+ z(e, "close", this.onclose.bind(this)),
2152
2152
  // @ts-ignore
2153
- Y(this.decoder, "decoded", this.ondecoded.bind(this))
2153
+ z(this.decoder, "decoded", this.ondecoded.bind(this))
2154
2154
  );
2155
2155
  }
2156
2156
  /**
@@ -2179,7 +2179,7 @@ class Bt extends C {
2179
2179
  * @private
2180
2180
  */
2181
2181
  ondecoded(e) {
2182
- vt(() => {
2182
+ kt(() => {
2183
2183
  this.emitReserved("packet", e);
2184
2184
  }, this.setTimeoutFn);
2185
2185
  }
@@ -2199,7 +2199,7 @@ class Bt extends C {
2199
2199
  */
2200
2200
  socket(e, t) {
2201
2201
  let s = this.nsps[e];
2202
- return s ? this._autoConnect && !s.active && s.connect() : (s = new Ms(this, e, t), this.nsps[e] = s), s;
2202
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new Qs(this, e, t), this.nsps[e] = s), s;
2203
2203
  }
2204
2204
  /**
2205
2205
  * Called upon a socket close.
@@ -2296,20 +2296,20 @@ class Bt extends C {
2296
2296
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
2297
2297
  }
2298
2298
  }
2299
- const Ge = {};
2300
- function Ke(n, e) {
2299
+ const Ke = {};
2300
+ function st(n, e) {
2301
2301
  typeof n == "object" && (e = n, n = void 0), e = e || {};
2302
- const t = Yn(n, e.path || "/socket.io"), s = t.source, r = t.id, i = t.path, o = Ge[r] && i in Ge[r].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2302
+ const t = rr(n, e.path || "/socket.io"), s = t.source, r = t.id, i = t.path, o = Ke[r] && i in Ke[r].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2303
2303
  let l;
2304
- return a ? l = new Bt(s, e) : (Ge[r] || (Ge[r] = new Bt(s, e)), l = Ge[r]), t.query && !e.query && (e.query = t.queryKey), l.socket(t.path, e);
2304
+ return a ? l = new Mt(s, e) : (Ke[r] || (Ke[r] = new Mt(s, e)), l = Ke[r]), t.query && !e.query && (e.query = t.queryKey), l.socket(t.path, e);
2305
2305
  }
2306
- Object.assign(Ke, {
2307
- Manager: Bt,
2308
- Socket: Ms,
2309
- io: Ke,
2310
- connect: Ke
2306
+ Object.assign(st, {
2307
+ Manager: Mt,
2308
+ Socket: Qs,
2309
+ io: st,
2310
+ connect: st
2311
2311
  });
2312
- const bt = "thatopen/document@1", fs = "document.json", ar = [
2312
+ const Ot = "thatopen/document@1", Ts = "document.json", gr = [
2313
2313
  "pdf",
2314
2314
  "txt",
2315
2315
  "md",
@@ -2317,14 +2317,14 @@ const bt = "thatopen/document@1", fs = "document.json", ar = [
2317
2317
  "csv",
2318
2318
  "tsv",
2319
2319
  "frag"
2320
- ], ps = () => `v-${Date.now()}`;
2321
- function at(n) {
2320
+ ], _s = () => `v-${Date.now()}`;
2321
+ function pt(n) {
2322
2322
  return String(n._id ?? n.id ?? "");
2323
2323
  }
2324
- var ke, Hs, Ft;
2325
- class Vs {
2324
+ var ve, en, bt;
2325
+ class Zs {
2326
2326
  constructor(e, t) {
2327
- S(this, ke);
2327
+ S(this, ve);
2328
2328
  this.client = e, this.projectId = t;
2329
2329
  }
2330
2330
  /**
@@ -2339,7 +2339,7 @@ class Vs {
2339
2339
  });
2340
2340
  return (await Promise.all(
2341
2341
  e.map(async (s) => {
2342
- const r = at(s), i = await this.descriptor(r);
2342
+ const r = pt(s), i = await this.descriptor(r);
2343
2343
  return i ? { folderId: r, descriptor: i } : null;
2344
2344
  })
2345
2345
  )).filter((s) => s !== null);
@@ -2357,25 +2357,25 @@ class Vs {
2357
2357
  * document is born ready to visualize and the link concept retires.
2358
2358
  */
2359
2359
  async fromFile(e, t) {
2360
- const s = await this.client.getFile(e), r = String(s.name ?? ""), i = ms(r, s.fileExtension), o = (t == null ? void 0 : t.name) ?? r.replace(/\.[^.]+$/, "") ?? r, a = await this.client.createFolder(
2360
+ const s = await this.client.getFile(e), r = String(s.name ?? ""), i = Ss(r, s.fileExtension), o = (t == null ? void 0 : t.name) ?? r.replace(/\.[^.]+$/, "") ?? r, a = await this.client.createFolder(
2361
2361
  o,
2362
2362
  s.folderId ? String(s.folderId) : void 0,
2363
2363
  this.projectId
2364
- ), l = at(a);
2364
+ ), l = pt(a);
2365
2365
  await this.client.updateFile(e, { parentFolderId: l });
2366
- const d = [], c = await h(this, ke, Hs).call(this, s);
2366
+ const d = [], c = await h(this, ve, en).call(this, s);
2367
2367
  if (c)
2368
2368
  try {
2369
- const A = await this.client.getFile(c);
2369
+ const R = await this.client.getFile(c);
2370
2370
  await this.client.updateFile(c, { parentFolderId: l }), d.push({
2371
2371
  fileId: c,
2372
- format: ms(String(A.name ?? ""), A.fileExtension)
2372
+ format: Ss(String(R.name ?? ""), R.fileExtension)
2373
2373
  });
2374
2374
  } catch {
2375
2375
  }
2376
- ((t == null ? void 0 : t.selfView) ?? ar.includes(i)) && d.push({ fileId: e, format: i });
2376
+ ((t == null ? void 0 : t.selfView) ?? gr.includes(i)) && d.push({ fileId: e, format: i });
2377
2377
  const T = {
2378
- schema: bt,
2378
+ schema: Ot,
2379
2379
  name: o,
2380
2380
  native: { fileId: e, format: i },
2381
2381
  views: d
@@ -2387,7 +2387,7 @@ class Vs {
2387
2387
  * has none yet (an old folder, or a plain folder that is not a document).
2388
2388
  */
2389
2389
  async descriptor(e) {
2390
- const t = await h(this, ke, Ft).call(this, e);
2390
+ const t = await h(this, ve, bt).call(this, e);
2391
2391
  if (!t) return null;
2392
2392
  const r = await (await this.client.downloadFile(t.id)).text();
2393
2393
  if (!r.trim()) return null;
@@ -2397,7 +2397,7 @@ class Vs {
2397
2397
  } catch {
2398
2398
  return null;
2399
2399
  }
2400
- return cr(i);
2400
+ return Tr(i);
2401
2401
  }
2402
2402
  /**
2403
2403
  * The first view whose format appears in `formats` — searched in the ORDER
@@ -2435,78 +2435,183 @@ class Vs {
2435
2435
  async setDescriptor(e, t) {
2436
2436
  const s = {
2437
2437
  ...t,
2438
- schema: bt,
2438
+ schema: Ot,
2439
2439
  views: t.views ?? []
2440
2440
  }, r = new Blob([JSON.stringify(s)], {
2441
2441
  type: "application/json"
2442
- }), i = await h(this, ke, Ft).call(this, e);
2442
+ }), i = await h(this, ve, bt).call(this, e);
2443
2443
  if (i) {
2444
2444
  await this.client.updateFile(i.id, {
2445
2445
  file: r,
2446
- versionTag: ps()
2446
+ versionTag: _s()
2447
2447
  });
2448
2448
  return;
2449
2449
  }
2450
2450
  await this.client.createFile({
2451
2451
  file: r,
2452
- name: fs,
2453
- versionTag: ps(),
2452
+ name: Ts,
2453
+ versionTag: _s(),
2454
2454
  parentFolderId: e,
2455
2455
  projectId: this.projectId
2456
2456
  });
2457
2457
  }
2458
+ /**
2459
+ * The document's DRAFTS: each user's working copy, kept so that closing the
2460
+ * browser never loses work. A draft is not a version — it never enters the
2461
+ * history and never shows in the CDE. See {@link DocumentDrafts}.
2462
+ */
2463
+ drafts(e) {
2464
+ return new wr(this.client, () => h(this, ve, bt).call(this, e));
2465
+ }
2458
2466
  }
2459
- ke = new WeakSet(), Hs = async function(e) {
2467
+ ve = new WeakSet(), en = async function(e) {
2460
2468
  const t = [...e.versions ?? []].sort(
2461
2469
  (s, r) => String(r.createdAt ?? "").localeCompare(String(s.createdAt ?? ""))
2462
2470
  );
2463
2471
  for (const s of t)
2464
2472
  try {
2465
2473
  const r = await this.client.getFileVersionMetadata(
2466
- at(e),
2474
+ pt(e),
2467
2475
  s.tag
2468
2476
  ), i = r == null ? void 0 : r.derivedFileId;
2469
2477
  if (typeof i == "string" && i) return i;
2470
2478
  } catch {
2471
2479
  }
2472
- }, Ft = async function(e) {
2480
+ }, bt = async function(e) {
2473
2481
  const s = (await this.client.listFiles({ folderId: e })).find(
2474
- (r) => String(r.name ?? "") === fs
2482
+ (r) => String(r.name ?? "") === Ts
2475
2483
  );
2476
- return s ? { id: at(s) } : void 0;
2484
+ return s ? { id: pt(s) } : void 0;
2485
+ };
2486
+ const Vt = "draft:", Ne = "TODRAFT1";
2487
+ var se, Qe, Ht;
2488
+ class wr {
2489
+ constructor(e, t) {
2490
+ S(this, se);
2491
+ this.client = e, this.holder = t;
2492
+ }
2493
+ /** Every user's latest draft, without downloading any. Newest first. */
2494
+ async list() {
2495
+ const e = await this.holder();
2496
+ if (!e) return [];
2497
+ const t = /* @__PURE__ */ new Map();
2498
+ for (const s of await h(this, se, Qe).call(this, e.id)) {
2499
+ const r = t.get(s.userId);
2500
+ (!r || s.savedAt > r.savedAt) && t.set(s.userId, { userId: s.userId, savedAt: s.savedAt });
2501
+ }
2502
+ return [...t.values()].sort((s, r) => +r.savedAt - +s.savedAt);
2503
+ }
2504
+ /**
2505
+ * One user's draft, downloaded — or, without `userId`, the newest of anyone.
2506
+ * Null when there is none.
2507
+ */
2508
+ async get(e) {
2509
+ const t = await this.holder();
2510
+ if (!t) return null;
2511
+ const r = (await h(this, se, Qe).call(this, t.id)).filter((l) => !(e != null && e.userId) || l.userId === e.userId).sort((l, d) => +d.savedAt - +l.savedAt)[0];
2512
+ if (!r) return null;
2513
+ const i = await this.client.downloadHiddenFile(r.hiddenId), { meta: o, blob: a } = await Er(await i.blob());
2514
+ return { userId: r.userId, savedAt: r.savedAt, meta: o, blob: a };
2515
+ }
2516
+ /**
2517
+ * Stores this user's draft, replacing their previous one: only the latest is
2518
+ * kept. Needs the document to have a descriptor (convert loose files first
2519
+ * with `fromFile`).
2520
+ */
2521
+ async put(e, t) {
2522
+ const s = await this.holder();
2523
+ if (!s)
2524
+ throw new Error("This folder is not a document (no document.json): drafts need one.");
2525
+ const r = vr(t.userId), i = (await h(this, se, Qe).call(this, s.id)).filter((l) => l.userId === t.userId), a = (await this.client.createHiddenFile(
2526
+ await br(e, t.meta ?? {}),
2527
+ s.id,
2528
+ r
2529
+ )).hiddenFileId;
2530
+ if (!a) throw new Error("The draft upload answered without a hiddenFileId.");
2531
+ return await h(this, se, Ht).call(this, i.map((l) => l.hiddenId)), { userId: t.userId, savedAt: Is(a) };
2532
+ }
2533
+ /** Deletes every draft of this user (on an explicit save, typically). */
2534
+ async delete(e) {
2535
+ const t = await this.holder();
2536
+ if (!t) return;
2537
+ const s = (await h(this, se, Qe).call(this, t.id)).filter((r) => r.userId === e.userId);
2538
+ await h(this, se, Ht).call(this, s.map((r) => r.hiddenId));
2539
+ }
2540
+ }
2541
+ se = new WeakSet(), Qe = async function(e) {
2542
+ return (await this.client.getHiddenFilesByParent(e)).filter((s) => typeof s.tag == "string" && s.tag.startsWith(Vt)).map((s) => {
2543
+ const r = String(s._id);
2544
+ return {
2545
+ hiddenId: r,
2546
+ userId: s.tag.slice(Vt.length),
2547
+ savedAt: Is(r)
2548
+ };
2549
+ });
2550
+ }, Ht = async function(e) {
2551
+ for (const t of e)
2552
+ try {
2553
+ await this.client.deleteHiddenFile(t);
2554
+ } catch {
2555
+ }
2477
2556
  };
2478
- function ms(n, e) {
2557
+ function vr(n) {
2558
+ const e = `${Vt}${n}`;
2559
+ if (!/^[A-Za-z0-9][A-Za-z0-9:._-]{0,49}$/.test(e))
2560
+ throw new Error(`A draft cannot be tagged for user "${n}": ids must be letters, digits or :._- and short.`);
2561
+ return e;
2562
+ }
2563
+ function Is(n) {
2564
+ const e = parseInt(n.slice(0, 8), 16);
2565
+ return new Date(Number.isFinite(e) ? e * 1e3 : 0);
2566
+ }
2567
+ async function br(n, e) {
2568
+ const t = new TextEncoder().encode(JSON.stringify(e)), s = new Uint8Array(4);
2569
+ return new DataView(s.buffer).setUint32(0, t.length, !0), new Blob([new TextEncoder().encode(Ne), s, t, n]);
2570
+ }
2571
+ async function Er(n) {
2572
+ const e = new Uint8Array(await n.slice(0, Ne.length + 4).arrayBuffer());
2573
+ if (new TextDecoder().decode(e.slice(0, Ne.length)) !== Ne)
2574
+ return { meta: {}, blob: n };
2575
+ const t = new DataView(e.buffer).getUint32(Ne.length, !0), s = Ne.length + 4, r = await n.slice(s, s + t).text();
2576
+ let i = {};
2577
+ try {
2578
+ i = JSON.parse(r);
2579
+ } catch {
2580
+ }
2581
+ return { meta: i, blob: n.slice(s + t) };
2582
+ }
2583
+ function Ss(n, e) {
2479
2584
  const t = (e ?? "").replace(/^\./, "").toLowerCase();
2480
2585
  if (t) return t;
2481
2586
  const s = n.lastIndexOf(".");
2482
2587
  return s > 0 ? n.slice(s + 1).toLowerCase() : "";
2483
2588
  }
2484
- function cr(n) {
2589
+ function Tr(n) {
2485
2590
  if (!n || typeof n != "object") return null;
2486
2591
  const e = n;
2487
- if (e.schema !== bt || typeof e.name != "string") return null;
2592
+ if (e.schema !== Ot || typeof e.name != "string") return null;
2488
2593
  const t = Array.isArray(e.views) ? e.views.filter(
2489
2594
  (i) => !!i && typeof i == "object" && typeof i.fileId == "string" && typeof i.format == "string"
2490
2595
  ) : [], s = e.native, r = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string";
2491
2596
  return {
2492
- schema: bt,
2597
+ schema: Ot,
2493
2598
  name: e.name,
2494
2599
  ...r ? { native: { fileId: s.fileId, format: s.format } } : {},
2495
2600
  views: t
2496
2601
  };
2497
2602
  }
2498
- class ys extends Error {
2603
+ class As extends Error {
2499
2604
  constructor(e, t) {
2500
2605
  super(
2501
2606
  `The document history advanced while this version was being prepared: expected head ${e}, found ${t ?? "none"}. Read the timeline again and rebuild on the new head.`
2502
2607
  ), this.expectedGuid = e, this.actualGuid = t, this.name = "StaleHistoryError";
2503
2608
  }
2504
2609
  }
2505
- const gs = "bimterop", Lt = "revitflow_history.json", Re = "revitflow_ops.json", ws = "revitflow/ops@1", Gs = "revitflow_model.frag", Js = "revitflow_", hr = "bimterop-locks-anchor", ct = () => `v-${Date.now()}`;
2506
- function Ws(n, e) {
2610
+ const Os = "bimterop", Gt = "revitflow_history.json", Fe = "revitflow_ops.json", ks = "revitflow/ops@1", tn = "revitflow_model.frag", sn = "revitflow_", _r = "bimterop-locks-anchor", mt = () => `v-${Date.now()}`;
2611
+ function nn(n, e) {
2507
2612
  return n.filter((t) => String(t.parentId ?? "") === e);
2508
2613
  }
2509
- function bs(n) {
2614
+ function Rs(n) {
2510
2615
  const e = n == null ? void 0 : n.hiddenFileId;
2511
2616
  if (typeof e != "string" || !e)
2512
2617
  throw new Error("The hidden-file upload answered without a hiddenFileId.");
@@ -2515,31 +2620,31 @@ function bs(n) {
2515
2620
  function te(n) {
2516
2621
  return String(n._id ?? n.id ?? "");
2517
2622
  }
2518
- var W, Xe, Dt;
2519
- class lr {
2623
+ var Y, nt, Jt;
2624
+ class Ir {
2520
2625
  constructor(e, t) {
2521
- S(this, Xe);
2522
- S(this, W);
2626
+ S(this, nt);
2627
+ S(this, Y);
2523
2628
  this.client = e, this.projectId = t;
2524
2629
  }
2525
2630
  /** The project's connected documents. */
2526
2631
  async docs() {
2527
- const e = await h(this, Xe, Dt).call(this);
2632
+ const e = await h(this, nt, Jt).call(this);
2528
2633
  if (!e) return [];
2529
2634
  const t = await this.client.listFolders({
2530
2635
  parentFolderId: e,
2531
2636
  projectId: this.projectId
2532
2637
  }), s = [];
2533
- for (const r of Ws(t, e)) {
2638
+ for (const r of nn(t, e)) {
2534
2639
  const i = String(r.name ?? ""), o = i.indexOf("-");
2535
2640
  if (o <= 0) continue;
2536
2641
  const l = (await this.client.listFiles({
2537
2642
  folderId: te(r)
2538
2643
  })).map(
2539
- (m) => String(m.name ?? "")
2540
- ), d = l.find((m) => m === Gs) ?? l.find(
2541
- (m) => m.endsWith(".frag") && !m.startsWith(Js)
2542
- ), c = l.includes(Lt) || l.includes(Re) || !!d;
2644
+ (y) => String(y.name ?? "")
2645
+ ), d = l.find((y) => y === tn) ?? l.find(
2646
+ (y) => y.endsWith(".frag") && !y.startsWith(sn)
2647
+ ), c = l.includes(Gt) || l.includes(Fe) || !!d;
2543
2648
  s.push({
2544
2649
  source: i.slice(0, o),
2545
2650
  docId: i.slice(o + 1),
@@ -2552,36 +2657,36 @@ class lr {
2552
2657
  }
2553
2658
  /** One document's history. `source` and `docId` as {@link docs} lists them. */
2554
2659
  doc(e, t) {
2555
- return new dr(this.client, this, e, t);
2660
+ return new Sr(this.client, this, e, t);
2556
2661
  }
2557
2662
  /** @internal The `bimterop` folder id, resolved once. */
2558
2663
  async rootFolderId(e = !1) {
2559
- if (u(this, W)) return u(this, W);
2560
- const t = await h(this, Xe, Dt).call(this);
2664
+ if (u(this, Y)) return u(this, Y);
2665
+ const t = await h(this, nt, Jt).call(this);
2561
2666
  if (t) return t;
2562
2667
  if (!e) return;
2563
2668
  const s = await this.client.createFolder(
2564
- gs,
2669
+ Os,
2565
2670
  void 0,
2566
2671
  this.projectId
2567
2672
  );
2568
- return R(this, W, te(s)), u(this, W);
2673
+ return $(this, Y, te(s)), u(this, Y);
2569
2674
  }
2570
2675
  }
2571
- W = new WeakMap(), Xe = new WeakSet(), Dt = async function() {
2572
- if (u(this, W)) return u(this, W);
2676
+ Y = new WeakMap(), nt = new WeakSet(), Jt = async function() {
2677
+ if (u(this, Y)) return u(this, Y);
2573
2678
  const t = (await this.client.listFolders({
2574
2679
  projectId: this.projectId
2575
2680
  })).find(
2576
- (s) => String(s.name ?? "") === gs && !s.parentId
2681
+ (s) => String(s.name ?? "") === Os && !s.parentId
2577
2682
  );
2578
- return t && R(this, W, te(t)), u(this, W);
2683
+ return t && $(this, Y, te(t)), u(this, Y);
2579
2684
  };
2580
- var ae, p, oe, Ce, ee, qt, We, ue, jt, ft, Ye, pt, Ut, Ys;
2581
- class dr {
2685
+ var ce, p, ae, Pe, ee, Wt, Ze, ue, Yt, Et, et, Tt, zt, rn;
2686
+ class Sr {
2582
2687
  constructor(e, t, s, r) {
2583
2688
  S(this, p);
2584
- S(this, ae);
2689
+ S(this, ce);
2585
2690
  this.client = e, this.project = t, this.source = s, this.docId = r;
2586
2691
  }
2587
2692
  // ─── Reading ───────────────────────────────────────────────────────────────
@@ -2591,8 +2696,8 @@ class dr {
2591
2696
  * Each version gets its `ordinal` filled in.
2592
2697
  */
2593
2698
  async timeline() {
2594
- const e = await h(this, p, ft).call(this);
2595
- return zs((e == null ? void 0 : e.commits) ?? []);
2699
+ const e = await h(this, p, Et).call(this);
2700
+ return on((e == null ? void 0 : e.commits) ?? []);
2596
2701
  }
2597
2702
  /** The head of the timeline, or null before the first sync. */
2598
2703
  async latest() {
@@ -2668,7 +2773,7 @@ class dr {
2668
2773
  const a = t[i], l = t.slice(r + 1).some((c) => c.full), d = t.slice(i + 1, r + 1).map((c) => ({
2669
2774
  guid: c.guid,
2670
2775
  ...c.deltaId ? { deltaId: c.deltaId } : {},
2671
- removedUniqueIds: c.changes.filter((m) => m.type === "delete").map((m) => m.uniqueId)
2776
+ removedUniqueIds: c.changes.filter((y) => y.type === "delete").map((y) => y.uniqueId)
2672
2777
  }));
2673
2778
  return {
2674
2779
  baseline: {
@@ -2691,7 +2796,7 @@ class dr {
2691
2796
  * not carry one yet — an old folder from before descriptors existed.
2692
2797
  */
2693
2798
  async descriptor() {
2694
- return await u(this, p, oe).descriptor(await h(this, p, ee).call(this, !1));
2799
+ return await u(this, p, ae).descriptor(await h(this, p, ee).call(this, !1));
2695
2800
  }
2696
2801
  /**
2697
2802
  * The first view whose format appears in `formats`, searched in the order
@@ -2699,7 +2804,7 @@ class dr {
2699
2804
  * model .frag on a descriptor-less folder, so old documents keep viewing.
2700
2805
  */
2701
2806
  async view(e) {
2702
- const t = await h(this, p, ee).call(this, !1), s = await u(this, p, oe).descriptor(t);
2807
+ const t = await h(this, p, ee).call(this, !1), s = await u(this, p, ae).descriptor(t);
2703
2808
  if (s) {
2704
2809
  for (const i of e) {
2705
2810
  const o = s.views.find((a) => a.format === i);
@@ -2718,13 +2823,13 @@ class dr {
2718
2823
  */
2719
2824
  async addView(e) {
2720
2825
  const t = await h(this, p, ee).call(this, !0);
2721
- if (await u(this, p, oe).descriptor(t)) {
2722
- await u(this, p, oe).addView(t, e);
2826
+ if (await u(this, p, ae).descriptor(t)) {
2827
+ await u(this, p, ae).addView(t, e);
2723
2828
  return;
2724
2829
  }
2725
2830
  const r = await h(this, p, ue).call(this);
2726
- await u(this, p, oe).setDescriptor(t, {
2727
- name: (r == null ? void 0 : r.name.replace(/\.frag$/, "")) ?? u(this, p, Ce),
2831
+ await u(this, p, ae).setDescriptor(t, {
2832
+ name: (r == null ? void 0 : r.name.replace(/\.frag$/, "")) ?? u(this, p, Pe),
2728
2833
  views: [e]
2729
2834
  });
2730
2835
  }
@@ -2737,7 +2842,7 @@ class dr {
2737
2842
  * model file).
2738
2843
  */
2739
2844
  async ensureDescriptor() {
2740
- const e = await h(this, p, ee).call(this, !1), t = await u(this, p, oe).descriptor(e);
2845
+ const e = await h(this, p, ee).call(this, !1), t = await u(this, p, ae).descriptor(e);
2741
2846
  if (t) return t;
2742
2847
  const s = await h(this, p, ue).call(this);
2743
2848
  if (!s) return null;
@@ -2745,7 +2850,7 @@ class dr {
2745
2850
  name: s.name.replace(/\.frag$/, ""),
2746
2851
  views: [{ fileId: s.id, format: "frag" }]
2747
2852
  };
2748
- return await u(this, p, oe).setDescriptor(e, r), await u(this, p, oe).descriptor(e);
2853
+ return await u(this, p, ae).setDescriptor(e, r), await u(this, p, ae).descriptor(e);
2749
2854
  }
2750
2855
  // ─── Ownership (element locks) ─────────────────────────────────────────────
2751
2856
  /**
@@ -2756,7 +2861,7 @@ class dr {
2756
2861
  * claims counts only for the earliest one, matching the plugins' rule.
2757
2862
  */
2758
2863
  async ownership() {
2759
- const e = await h(this, p, We).call(this, hr);
2864
+ const e = await h(this, p, Ze).call(this, _r);
2760
2865
  if (!e) return [];
2761
2866
  const t = await this.client.getHiddenFilesByParent(e.id), s = await Promise.all(
2762
2867
  t.map(async (o) => {
@@ -2794,15 +2899,15 @@ class dr {
2794
2899
  async sync(e) {
2795
2900
  var a;
2796
2901
  const t = await h(this, p, ee).call(this, !0);
2797
- let s = await h(this, p, ft).call(this) ?? {
2902
+ let s = await h(this, p, Et).call(this) ?? {
2798
2903
  model: this.docId,
2799
2904
  commits: []
2800
2905
  };
2801
- const r = vs(s.commits);
2906
+ const r = $s(s.commits);
2802
2907
  if (e.expectedLatestGuid !== void 0 && (r == null ? void 0 : r.guid) !== e.expectedLatestGuid)
2803
- throw new ys(e.expectedLatestGuid, r == null ? void 0 : r.guid);
2908
+ throw new As(e.expectedLatestGuid, r == null ? void 0 : r.guid);
2804
2909
  const i = {
2805
- guid: Mt(),
2910
+ guid: Kt(),
2806
2911
  ...r ? { parents: [r.guid] } : {},
2807
2912
  author: e.author,
2808
2913
  source: e.source,
@@ -2811,9 +2916,9 @@ class dr {
2811
2916
  ...e.userId ? { userId: e.userId } : {},
2812
2917
  ...(a = e.appliedOps) != null && a.length ? { appliedOps: e.appliedOps } : {},
2813
2918
  changes: e.changes,
2814
- counts: ur(e.changes)
2919
+ counts: Ar(e.changes)
2815
2920
  };
2816
- if (e.model && (await h(this, p, Ys).call(this, t, e.model), i.full = !0), e.delta) {
2921
+ if (e.model && (await h(this, p, rn).call(this, t, e.model), i.full = !0), e.delta) {
2817
2922
  const l = await h(this, p, ue).call(this);
2818
2923
  if (!l)
2819
2924
  throw new Error(
@@ -2823,22 +2928,22 @@ class dr {
2823
2928
  e.delta,
2824
2929
  l.id
2825
2930
  );
2826
- i.deltaId = bs(d);
2931
+ i.deltaId = Rs(d);
2827
2932
  }
2828
- const o = await h(this, p, ft).call(this);
2933
+ const o = await h(this, p, Et).call(this);
2829
2934
  if (o) {
2830
2935
  s = o;
2831
- const l = vs(s.commits);
2936
+ const l = $s(s.commits);
2832
2937
  if (e.expectedLatestGuid !== void 0 && (l == null ? void 0 : l.guid) !== e.expectedLatestGuid)
2833
- throw new ys(e.expectedLatestGuid, l == null ? void 0 : l.guid);
2938
+ throw new As(e.expectedLatestGuid, l == null ? void 0 : l.guid);
2834
2939
  l && !i.parents && (i.parents = [l.guid]);
2835
2940
  }
2836
- return s.commits.push(i), await h(this, p, pt).call(this, t, Lt, s), i;
2941
+ return s.commits.push(i), await h(this, p, Tt).call(this, t, Gt, s), i;
2837
2942
  }
2838
2943
  // ─── Suggestions (change requests) ────────────────────────────────────────
2839
2944
  /** Every suggestion in the document's queue, pending or resolved. */
2840
2945
  async suggestions() {
2841
- const e = await h(this, p, Ye).call(this);
2946
+ const e = await h(this, p, et).call(this);
2842
2947
  return (e == null ? void 0 : e.ops) ?? [];
2843
2948
  }
2844
2949
  /** The suggestions still waiting for the owner, oldest first. */
@@ -2850,8 +2955,8 @@ class dr {
2850
2955
  * uploaded as a hidden file under the suggestions index.
2851
2956
  */
2852
2957
  async suggest(e) {
2853
- const t = await h(this, p, ee).call(this, !0), s = await h(this, p, Ye).call(this) ?? { schema: ws, ops: [] }, r = await h(this, p, We).call(this, Re), i = {
2854
- opId: e.opId ?? Mt(),
2958
+ const t = await h(this, p, ee).call(this, !0), s = await h(this, p, et).call(this) ?? { schema: ks, ops: [] }, r = await h(this, p, Ze).call(this, Fe), i = {
2959
+ opId: e.opId ?? Kt(),
2855
2960
  to: e.to ?? this.source,
2856
2961
  title: e.title,
2857
2962
  verb: e.verb,
@@ -2864,14 +2969,14 @@ class dr {
2864
2969
  ...e.baseCommitGuid ? { baseCommitGuid: e.baseCommitGuid } : {}
2865
2970
  };
2866
2971
  if (e.payload) {
2867
- const a = r ?? await h(this, p, Ut).call(this, t, Re, s), l = await this.client.createHiddenFile(
2972
+ const a = r ?? await h(this, p, zt).call(this, t, Fe, s), l = await this.client.createHiddenFile(
2868
2973
  e.payload,
2869
2974
  a.id
2870
2975
  );
2871
- i.fragId = bs(l);
2976
+ i.fragId = Rs(l);
2872
2977
  }
2873
- const o = await h(this, p, Ye).call(this) ?? s;
2874
- return o.schema ?? (o.schema = ws), o.ops.push(i), await h(this, p, pt).call(this, t, Re, o), i;
2978
+ const o = await h(this, p, et).call(this) ?? s;
2979
+ return o.schema ?? (o.schema = ks), o.ops.push(i), await h(this, p, Tt).call(this, t, Fe, o), i;
2875
2980
  }
2876
2981
  /** A suggestion's .frag payload. */
2877
2982
  async suggestionPayload(e) {
@@ -2887,18 +2992,18 @@ class dr {
2887
2992
  async resolveSuggestion(e, t) {
2888
2993
  const s = await h(this, p, ee).call(this, !1);
2889
2994
  if (!s) throw new Error("This document has no suggestion queue.");
2890
- const r = await h(this, p, Ye).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === e);
2995
+ const r = await h(this, p, et).call(this), i = r == null ? void 0 : r.ops.find((o) => o.opId === e);
2891
2996
  if (!r || !i)
2892
2997
  throw new Error(`No suggestion ${e} in this document's queue.`);
2893
- return Object.assign(i, t), await h(this, p, pt).call(this, s, Re, r), i;
2998
+ return Object.assign(i, t), await h(this, p, Tt).call(this, s, Fe, r), i;
2894
2999
  }
2895
3000
  }
2896
- ae = new WeakMap(), p = new WeakSet(), oe = function() {
2897
- return new Vs(this.client, this.project.projectId);
2898
- }, Ce = function() {
3001
+ ce = new WeakMap(), p = new WeakSet(), ae = function() {
3002
+ return new Zs(this.client, this.project.projectId);
3003
+ }, Pe = function() {
2899
3004
  return `${this.source}-${this.docId}`;
2900
3005
  }, ee = async function(e) {
2901
- if (u(this, ae)) return u(this, ae);
3006
+ if (u(this, ce)) return u(this, ce);
2902
3007
  const t = await this.project.rootFolderId(e);
2903
3008
  if (!t)
2904
3009
  throw new Error(
@@ -2907,94 +3012,94 @@ ae = new WeakMap(), p = new WeakSet(), oe = function() {
2907
3012
  const s = await this.client.listFolders({
2908
3013
  parentFolderId: t,
2909
3014
  projectId: this.project.projectId
2910
- }), r = Ws(s, t).find(
2911
- (o) => String(o.name ?? "") === u(this, p, Ce)
3015
+ }), r = nn(s, t).find(
3016
+ (o) => String(o.name ?? "") === u(this, p, Pe)
2912
3017
  );
2913
3018
  if (r)
2914
- return R(this, ae, te(r)), u(this, ae);
3019
+ return $(this, ce, te(r)), u(this, ce);
2915
3020
  if (!e)
2916
3021
  throw new Error(
2917
- `Document ${u(this, p, Ce)} does not exist in this project.`
3022
+ `Document ${u(this, p, Pe)} does not exist in this project.`
2918
3023
  );
2919
3024
  const i = await this.client.createFolder(
2920
- u(this, p, Ce),
3025
+ u(this, p, Pe),
2921
3026
  t,
2922
3027
  this.project.projectId
2923
3028
  );
2924
- return R(this, ae, te(i)), u(this, ae);
2925
- }, qt = async function() {
3029
+ return $(this, ce, te(i)), u(this, ce);
3030
+ }, Wt = async function() {
2926
3031
  const e = await h(this, p, ee).call(this, !1);
2927
3032
  return (await this.client.listFiles({ folderId: e })).map((s) => ({
2928
3033
  id: te(s),
2929
3034
  name: String(s.name ?? "")
2930
3035
  }));
2931
- }, We = async function(e) {
3036
+ }, Ze = async function(e) {
2932
3037
  try {
2933
- return (await h(this, p, qt).call(this)).find((t) => t.name === e);
3038
+ return (await h(this, p, Wt).call(this)).find((t) => t.name === e);
2934
3039
  } catch {
2935
3040
  return;
2936
3041
  }
2937
3042
  }, ue = async function() {
2938
3043
  try {
2939
- const e = await h(this, p, qt).call(this);
2940
- return e.find((t) => t.name === Gs) ?? e.find(
2941
- (t) => t.name.endsWith(".frag") && !t.name.startsWith(Js)
3044
+ const e = await h(this, p, Wt).call(this);
3045
+ return e.find((t) => t.name === tn) ?? e.find(
3046
+ (t) => t.name.endsWith(".frag") && !t.name.startsWith(sn)
2942
3047
  );
2943
3048
  } catch {
2944
3049
  return;
2945
3050
  }
2946
- }, jt = async function(e) {
2947
- const t = await h(this, p, We).call(this, e);
3051
+ }, Yt = async function(e) {
3052
+ const t = await h(this, p, Ze).call(this, e);
2948
3053
  if (!t) return;
2949
3054
  const r = await (await this.client.downloadFile(t.id)).text();
2950
3055
  if (r.trim())
2951
3056
  return JSON.parse(r);
2952
- }, ft = function() {
2953
- return h(this, p, jt).call(this, Lt);
2954
- }, Ye = function() {
2955
- return h(this, p, jt).call(this, Re);
2956
- }, pt = async function(e, t, s) {
3057
+ }, Et = function() {
3058
+ return h(this, p, Yt).call(this, Gt);
3059
+ }, et = function() {
3060
+ return h(this, p, Yt).call(this, Fe);
3061
+ }, Tt = async function(e, t, s) {
2957
3062
  const r = new Blob([JSON.stringify(s)], {
2958
3063
  type: "application/json"
2959
- }), i = await h(this, p, We).call(this, t);
3064
+ }), i = await h(this, p, Ze).call(this, t);
2960
3065
  return i ? (await this.client.updateFile(i.id, {
2961
3066
  file: r,
2962
- versionTag: ct()
2963
- }), i) : await h(this, p, Ut).call(this, e, t, s);
2964
- }, Ut = async function(e, t, s) {
3067
+ versionTag: mt()
3068
+ }), i) : await h(this, p, zt).call(this, e, t, s);
3069
+ }, zt = async function(e, t, s) {
2965
3070
  const r = new Blob([JSON.stringify(s)], {
2966
3071
  type: "application/json"
2967
3072
  }), i = await this.client.createFile({
2968
3073
  file: r,
2969
3074
  name: t,
2970
- versionTag: ct(),
3075
+ versionTag: mt(),
2971
3076
  parentFolderId: e,
2972
3077
  projectId: this.project.projectId
2973
3078
  }), o = i.item;
2974
3079
  return { id: te(o ?? i), name: t };
2975
- }, Ys = async function(e, t) {
3080
+ }, rn = async function(e, t) {
2976
3081
  const s = await h(this, p, ue).call(this);
2977
3082
  if (s)
2978
3083
  return await this.client.updateFile(s.id, {
2979
3084
  file: t,
2980
- versionTag: ct()
3085
+ versionTag: mt()
2981
3086
  }), s;
2982
- const r = `${u(this, p, Ce)}.frag`, i = await this.client.createFile({
3087
+ const r = `${u(this, p, Pe)}.frag`, i = await this.client.createFile({
2983
3088
  file: t,
2984
3089
  name: r,
2985
- versionTag: ct(),
3090
+ versionTag: mt(),
2986
3091
  parentFolderId: e,
2987
3092
  projectId: this.project.projectId
2988
3093
  }), o = i.item;
2989
3094
  return { id: te(o ?? i), name: r };
2990
3095
  };
2991
- function ur(n) {
3096
+ function Ar(n) {
2992
3097
  const e = { added: 0, modified: 0, removed: 0 };
2993
3098
  for (const t of n)
2994
3099
  t.type === "create" ? e.added++ : t.type === "delete" ? e.removed++ : e.modified++;
2995
3100
  return e;
2996
3101
  }
2997
- function zs(n) {
3102
+ function on(n) {
2998
3103
  var l;
2999
3104
  if (n.length <= 1)
3000
3105
  return n.forEach((d, c) => d.ordinal = c), [...n];
@@ -3002,8 +3107,8 @@ function zs(n) {
3002
3107
  for (const d of n) {
3003
3108
  const c = (l = d.parents) == null ? void 0 : l[0];
3004
3109
  if (c && e.has(c)) {
3005
- const m = t.get(c) ?? [];
3006
- m.push(d), t.set(c, m);
3110
+ const y = t.get(c) ?? [];
3111
+ y.push(d), t.set(c, y);
3007
3112
  } else
3008
3113
  s.push(d);
3009
3114
  }
@@ -3015,27 +3120,27 @@ function zs(n) {
3015
3120
  if (a.has(d.guid)) continue;
3016
3121
  a.add(d.guid), i.push(d);
3017
3122
  const c = (t.get(d.guid) ?? []).sort(r);
3018
- for (let m = c.length - 1; m >= 0; m--) o.push(c[m]);
3123
+ for (let y = c.length - 1; y >= 0; y--) o.push(c[y]);
3019
3124
  }
3020
3125
  for (const d of n)
3021
3126
  a.has(d.guid) || i.push(d);
3022
3127
  return i.forEach((d, c) => d.ordinal = c), i;
3023
3128
  }
3024
- function vs(n) {
3025
- const e = zs(n);
3129
+ function $s(n) {
3130
+ const e = on(n);
3026
3131
  return e[e.length - 1];
3027
3132
  }
3028
- function Mt() {
3133
+ function Kt() {
3029
3134
  const n = globalThis.crypto;
3030
3135
  return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
3031
3136
  const t = Math.random() * 16 | 0;
3032
3137
  return (e === "x" ? t : t & 3 | 8).toString(16);
3033
3138
  });
3034
3139
  }
3035
- var pe, Qe, Vt;
3036
- class fr {
3140
+ var pe, rt, Xt;
3141
+ class Or {
3037
3142
  constructor(e) {
3038
- S(this, Qe);
3143
+ S(this, rt);
3039
3144
  S(this, pe, /* @__PURE__ */ new Map());
3040
3145
  this.client = e;
3041
3146
  }
@@ -3062,7 +3167,7 @@ class fr {
3062
3167
  * included, with no second run. Discard it and the plan never happened.
3063
3168
  */
3064
3169
  async plan(e, t) {
3065
- const { base: s, opId: r, result: i } = await h(this, Qe, Vt).call(this, e, t);
3170
+ const { base: s, opId: r, result: i } = await h(this, rt, Xt).call(this, e, t);
3066
3171
  return {
3067
3172
  opId: r,
3068
3173
  projectId: t.projectId,
@@ -3095,7 +3200,7 @@ class fr {
3095
3200
  * to show the tallies before queueing.
3096
3201
  */
3097
3202
  async run(e, t) {
3098
- const { targetDoc: s, base: r, opId: i, result: o } = await h(this, Qe, Vt).call(this, e, t);
3203
+ const { targetDoc: s, base: r, opId: i, result: o } = await h(this, rt, Xt).call(this, e, t);
3099
3204
  return { suggestion: await s.suggest({
3100
3205
  opId: i,
3101
3206
  title: o.title,
@@ -3108,14 +3213,14 @@ class fr {
3108
3213
  }), result: o };
3109
3214
  }
3110
3215
  }
3111
- pe = new WeakMap(), Qe = new WeakSet(), Vt = async function(e, t) {
3216
+ pe = new WeakMap(), rt = new WeakSet(), Xt = async function(e, t) {
3112
3217
  const s = u(this, pe).get(e);
3113
3218
  if (!s) throw new Error(`No recipe named "${e}" is registered.`);
3114
3219
  if (s.to !== t.target.source)
3115
3220
  throw new Error(
3116
3221
  `Recipe "${e}" writes ${s.to}, but the target document belongs to ${t.target.source}.`
3117
3222
  );
3118
- const r = this.client.history(t.projectId).doc(t.target.source, t.target.docId), i = await r.latest(), o = Mt(), a = await s.run({
3223
+ const r = this.client.history(t.projectId).doc(t.target.source, t.target.docId), i = await r.latest(), o = Kt(), a = await s.run({
3119
3224
  client: this.client,
3120
3225
  projectId: t.projectId,
3121
3226
  targetDoc: r,
@@ -3125,8 +3230,8 @@ pe = new WeakMap(), Qe = new WeakSet(), Vt = async function(e, t) {
3125
3230
  });
3126
3231
  return { recipe: s, targetDoc: r, base: i, opId: o, result: a };
3127
3232
  };
3128
- const Es = 100;
3129
- function pr(n) {
3233
+ const Cs = 100;
3234
+ function kr(n) {
3130
3235
  try {
3131
3236
  const e = JSON.parse(n);
3132
3237
  if (e && typeof e == "object") {
@@ -3141,29 +3246,29 @@ function pr(n) {
3141
3246
  }
3142
3247
  return {};
3143
3248
  }
3144
- function mr(n) {
3249
+ function Rr(n) {
3145
3250
  if (!n || typeof n != "object") return;
3146
3251
  const e = n.retryAfter;
3147
3252
  return typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : void 0;
3148
3253
  }
3149
- class rs extends Error {
3254
+ class fs extends Error {
3150
3255
  constructor(t, s, r, i) {
3151
- const o = pr(r);
3256
+ const o = kr(r);
3152
3257
  super(o.message ?? `${s || "Request failed"} (${t})`);
3153
- B(this, "status");
3154
- B(this, "code");
3155
- B(this, "details");
3156
- B(this, "body");
3258
+ L(this, "status");
3259
+ L(this, "code");
3260
+ L(this, "details");
3261
+ L(this, "body");
3157
3262
  /**
3158
3263
  * Seconds to wait before retrying, taken from the `Retry-After` header or
3159
3264
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
3160
3265
  */
3161
- B(this, "retryAfter");
3162
- this.name = "RequestError", this.status = t, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? mr(o.details);
3266
+ L(this, "retryAfter");
3267
+ this.name = "RequestError", this.status = t, this.code = o.code, this.details = o.details, this.body = r, this.retryAfter = i ?? Rr(o.details);
3163
3268
  }
3164
3269
  }
3165
- const Z = "item/folder", b = "item", de = "processor", yr = "npm-registry", ie = "hidden", kt = "FILE", Ot = "TOOL", At = "APP", gr = 500, Ts = 3e4, wr = 0.25, br = (n) => new Promise((e) => setTimeout(e, n));
3166
- function vr(n) {
3270
+ const Z = "item/folder", v = "item", de = "processor", $r = "npm-registry", oe = "hidden", Ft = "FILE", Pt = "TOOL", Bt = "APP", Cr = 500, xs = 3e4, xr = 0.25, Nr = (n) => new Promise((e) => setTimeout(e, n));
3271
+ function Fr(n) {
3167
3272
  var r, i;
3168
3273
  const e = (i = (r = n.headers) == null ? void 0 : r.get) == null ? void 0 : i.call(r, "Retry-After");
3169
3274
  if (!e) return;
@@ -3173,18 +3278,18 @@ function vr(n) {
3173
3278
  if (!Number.isNaN(s))
3174
3279
  return Math.max(0, (s - Date.now()) / 1e3);
3175
3280
  }
3176
- function Er(n) {
3177
- return n instanceof rs ? n.status === 429 || n.status >= 500 : !0;
3281
+ function Pr(n) {
3282
+ return n instanceof fs ? n.status === 429 || n.status >= 500 : !0;
3178
3283
  }
3179
- function Tr(n, e) {
3284
+ function Br(n, e) {
3180
3285
  const t = Math.min(
3181
- gr * 2 ** e,
3182
- Ts
3183
- ), s = t * wr * Math.random(), r = n instanceof rs && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
3184
- return r != null ? Math.min(r, Ts) + s : t + s;
3286
+ Cr * 2 ** e,
3287
+ xs
3288
+ ), s = t * xr * Math.random(), r = n instanceof fs && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
3289
+ return r != null ? Math.min(r, xs) + s : t + s;
3185
3290
  }
3186
- var f, Gt, w, fe, Ze, ze, mt, yt, Jt, Wt, Ks;
3187
- const is = class is {
3291
+ var f, Zt, g, fe, it, tt, _t, It, es, ts, an;
3292
+ const ps = class ps {
3188
3293
  /**
3189
3294
  * Creates a new EngineServicesClient instance.
3190
3295
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -3194,25 +3299,25 @@ const is = class is {
3194
3299
  */
3195
3300
  constructor(e, t, s) {
3196
3301
  S(this, f);
3197
- B(this, "apiUrl");
3198
- B(this, "accessToken");
3199
- B(this, "wsUrl");
3200
- B(this, "retries");
3201
- B(this, "useBearer");
3202
- B(this, "builtInGlobals", null);
3302
+ L(this, "apiUrl");
3303
+ L(this, "accessToken");
3304
+ L(this, "wsUrl");
3305
+ L(this, "retries");
3306
+ L(this, "useBearer");
3307
+ L(this, "builtInGlobals", null);
3203
3308
  /**
3204
3309
  * URL of a local execution server (e.g. `http://localhost:4001`).
3205
3310
  * When set, execution methods are routed to this server instead of the cloud API.
3206
3311
  * Set to `null` to disable local routing and use the cloud API.
3207
3312
  */
3208
- B(this, "localServerUrl", null);
3313
+ L(this, "localServerUrl", null);
3209
3314
  /**
3210
3315
  * The platform context this client was created with.
3211
3316
  * Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
3212
3317
  * Populated automatically when using {@link fromPlatformContext}.
3213
3318
  */
3214
- B(this, "context");
3215
- S(this, Ze);
3319
+ L(this, "context");
3320
+ S(this, it);
3216
3321
  const { retries: r = 0, useBearer: i = !1, localServerUrl: o } = s || {};
3217
3322
  let a = t;
3218
3323
  if (a.charAt(a.length - 1) === "/" && (a = a.slice(0, -1)), this.apiUrl = `${a}/api`, this.accessToken = e, this.wsUrl = a, this.retries = r, this.useBearer = i, this.context = { appId: "", projectId: "", accessToken: e, apiUrl: t }, o) {
@@ -3237,7 +3342,7 @@ const is = class is {
3237
3342
  * ```
3238
3343
  */
3239
3344
  static fromPlatformContext(e) {
3240
- const t = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new is(t.accessToken, t.apiUrl, {
3345
+ const t = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new ps(t.accessToken, t.apiUrl, {
3241
3346
  ...e,
3242
3347
  useBearer: !0
3243
3348
  });
@@ -3313,7 +3418,7 @@ const is = class is {
3313
3418
  * cleaning logic is applied identically.
3314
3419
  */
3315
3420
  async request(e, t, s) {
3316
- return h(this, f, w).call(this, e, t, s);
3421
+ return h(this, f, g).call(this, e, t, s);
3317
3422
  }
3318
3423
  // ─── Files ───────────────────────────────────────────────────────
3319
3424
  /**
@@ -3323,9 +3428,9 @@ const is = class is {
3323
3428
  */
3324
3429
  async listFiles(e) {
3325
3430
  const { folderId: t, archived: s, projectId: r } = e || {};
3326
- return t ? await h(this, f, w).call(this, "GET", `${Z}/${t}/items`, { query: { itemType: kt, archived: s } }) : await h(this, f, w).call(this, "GET", `${b}`, {
3431
+ return t ? await h(this, f, g).call(this, "GET", `${Z}/${t}/items`, { query: { itemType: Ft, archived: s } }) : await h(this, f, g).call(this, "GET", `${v}`, {
3327
3432
  query: {
3328
- itemType: kt,
3433
+ itemType: Ft,
3329
3434
  archived: s,
3330
3435
  ...r && { projectId: r }
3331
3436
  }
@@ -3338,7 +3443,7 @@ const is = class is {
3338
3443
  * @returns The file item, optionally with version history.
3339
3444
  */
3340
3445
  async getFile(e, t) {
3341
- return await h(this, f, Wt).call(this, e, t);
3446
+ return await h(this, f, ts).call(this, e, t);
3342
3447
  }
3343
3448
  /**
3344
3449
  * Uploads a new file.
@@ -3346,7 +3451,7 @@ const is = class is {
3346
3451
  * @returns The created item and its first version.
3347
3452
  */
3348
3453
  async createFile(e) {
3349
- return await h(this, f, yt).call(this, e, kt);
3454
+ return await h(this, f, It).call(this, e, Ft);
3350
3455
  }
3351
3456
  /**
3352
3457
  * Updates an existing file. Can rename, move to a different folder,
@@ -3356,21 +3461,21 @@ const is = class is {
3356
3461
  * @returns The updated item and/or the new version.
3357
3462
  */
3358
3463
  async updateFile(e, t) {
3359
- return await h(this, f, Jt).call(this, e, t);
3464
+ return await h(this, f, es).call(this, e, t);
3360
3465
  }
3361
3466
  /**
3362
3467
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
3363
3468
  * @param fileId - The file's unique identifier.
3364
3469
  */
3365
3470
  async archiveFile(e) {
3366
- return await h(this, f, w).call(this, "DELETE", `${b}/${e}`);
3471
+ return await h(this, f, g).call(this, "DELETE", `${v}/${e}`);
3367
3472
  }
3368
3473
  /**
3369
3474
  * Recovers a previously archived file.
3370
3475
  * @param fileId - The file's unique identifier.
3371
3476
  */
3372
3477
  async recoverFile(e) {
3373
- return await h(this, f, w).call(this, "PUT", `${b}/${e}/recover`);
3478
+ return await h(this, f, g).call(this, "PUT", `${v}/${e}/recover`);
3374
3479
  }
3375
3480
  /**
3376
3481
  * Downloads a file's content. Returns the raw fetch Response.
@@ -3379,7 +3484,7 @@ const is = class is {
3379
3484
  * @returns A fetch Response containing the file data.
3380
3485
  */
3381
3486
  async downloadFile(e, t) {
3382
- return await h(this, f, mt).call(this, e, t);
3487
+ return await h(this, f, _t).call(this, e, t);
3383
3488
  }
3384
3489
  /**
3385
3490
  * Retrieves the free-JSON metadata for a specific file version.
@@ -3390,7 +3495,7 @@ const is = class is {
3390
3495
  */
3391
3496
  async getFileVersionMetadata(e, t, s) {
3392
3497
  const { withDraft: r } = s || {};
3393
- return await h(this, f, w).call(this, "GET", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
3498
+ return await h(this, f, g).call(this, "GET", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
3394
3499
  query: {
3395
3500
  ...r && { withDraft: "true" }
3396
3501
  }
@@ -3403,7 +3508,7 @@ const is = class is {
3403
3508
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
3404
3509
  */
3405
3510
  async updateFileVersionMetadata(e, t, s) {
3406
- return await h(this, f, w).call(this, "PUT", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
3511
+ return await h(this, f, g).call(this, "PUT", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
3407
3512
  body: JSON.stringify({ metadata: s }),
3408
3513
  contentType: "application/json"
3409
3514
  });
@@ -3414,7 +3519,7 @@ const is = class is {
3414
3519
  * @param versionTag - The version tag.
3415
3520
  */
3416
3521
  async deleteFileVersionMetadata(e, t) {
3417
- return await h(this, f, w).call(this, "DELETE", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`);
3522
+ return await h(this, f, g).call(this, "DELETE", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`);
3418
3523
  }
3419
3524
  /**
3420
3525
  * Batch variant of {@link getFileVersionMetadata}. Reads the metadata of
@@ -3431,7 +3536,7 @@ const is = class is {
3431
3536
  */
3432
3537
  async getFileVersionMetadataBatch(e, t) {
3433
3538
  const { withDraft: s } = t || {};
3434
- return await h(this, f, ze).call(this, e, async (r) => (await h(this, f, w).call(this, "POST", `${b}/batch/version-metadata`, {
3539
+ return await h(this, f, tt).call(this, e, async (r) => (await h(this, f, g).call(this, "POST", `${v}/batch/version-metadata`, {
3435
3540
  body: JSON.stringify({
3436
3541
  entries: r,
3437
3542
  ...s !== void 0 && { withDraft: s }
@@ -3447,7 +3552,7 @@ const is = class is {
3447
3552
  */
3448
3553
  async listFolders(e) {
3449
3554
  const { archived: t, parentFolderId: s, projectId: r } = e || {};
3450
- return await h(this, f, w).call(this, "GET", Z, {
3555
+ return await h(this, f, g).call(this, "GET", Z, {
3451
3556
  query: {
3452
3557
  parentFolderId: s,
3453
3558
  archived: t,
@@ -3460,7 +3565,7 @@ const is = class is {
3460
3565
  * @param folderId - The folder's unique identifier.
3461
3566
  */
3462
3567
  async getFolder(e) {
3463
- return await h(this, f, w).call(this, "GET", `${Z}/${e}`);
3568
+ return await h(this, f, g).call(this, "GET", `${Z}/${e}`);
3464
3569
  }
3465
3570
  /**
3466
3571
  * Batch variant of {@link getFolder}. Resolves a known set of folder ids in
@@ -3476,7 +3581,7 @@ const is = class is {
3476
3581
  * @param folderIds - The folder ids to resolve.
3477
3582
  */
3478
3583
  async getFoldersBatch(e) {
3479
- return await h(this, f, ze).call(this, e, async (t) => (await h(this, f, w).call(this, "POST", `${b}/batch/folders`, {
3584
+ return await h(this, f, tt).call(this, e, async (t) => (await h(this, f, g).call(this, "POST", `${v}/batch/folders`, {
3480
3585
  body: JSON.stringify({ folderIds: t }),
3481
3586
  contentType: "application/json"
3482
3587
  })).results);
@@ -3488,7 +3593,7 @@ const is = class is {
3488
3593
  * @returns The created folder.
3489
3594
  */
3490
3595
  async createFolder(e, t, s) {
3491
- return await h(this, f, w).call(this, "POST", Z, {
3596
+ return await h(this, f, g).call(this, "POST", Z, {
3492
3597
  body: JSON.stringify({
3493
3598
  name: e,
3494
3599
  ...t && { parentId: t },
@@ -3505,7 +3610,7 @@ const is = class is {
3505
3610
  */
3506
3611
  async updateFolder(e, t) {
3507
3612
  const { name: s } = t;
3508
- return await h(this, f, w).call(this, "PUT", `${Z}/${e}`, {
3613
+ return await h(this, f, g).call(this, "PUT", `${Z}/${e}`, {
3509
3614
  body: JSON.stringify({ name: s }),
3510
3615
  contentType: "application/json"
3511
3616
  });
@@ -3515,14 +3620,14 @@ const is = class is {
3515
3620
  * @param folderId - The folder's unique identifier.
3516
3621
  */
3517
3622
  async archiveFolder(e) {
3518
- return await h(this, f, w).call(this, "DELETE", `${Z}/${e}`);
3623
+ return await h(this, f, g).call(this, "DELETE", `${Z}/${e}`);
3519
3624
  }
3520
3625
  /**
3521
3626
  * Recovers a previously archived folder.
3522
3627
  * @param folderId - The folder's unique identifier.
3523
3628
  */
3524
3629
  async recoverFolder(e) {
3525
- return await h(this, f, w).call(this, "PUT", `${Z}/${e}/recover`);
3630
+ return await h(this, f, g).call(this, "PUT", `${Z}/${e}/recover`);
3526
3631
  }
3527
3632
  /**
3528
3633
  * Downloads an entire folder as a ZIP archive.
@@ -3540,14 +3645,14 @@ const is = class is {
3540
3645
  */
3541
3646
  async listComponents(e) {
3542
3647
  const { folderId: t, ShowVersions: s, projectId: r } = e || {};
3543
- return t ? await h(this, f, w).call(this, "GET", `${Z}/${t}/items`, {
3648
+ return t ? await h(this, f, g).call(this, "GET", `${Z}/${t}/items`, {
3544
3649
  query: {
3545
- itemType: Ot,
3650
+ itemType: Pt,
3546
3651
  ...s && { ShowVersions: s }
3547
3652
  }
3548
- }) : await h(this, f, w).call(this, "GET", `${b}`, {
3653
+ }) : await h(this, f, g).call(this, "GET", `${v}`, {
3549
3654
  query: {
3550
- itemType: Ot,
3655
+ itemType: Pt,
3551
3656
  ...s && { ShowVersions: s },
3552
3657
  ...r && { projectId: r }
3553
3658
  }
@@ -3559,7 +3664,7 @@ const is = class is {
3559
3664
  * @param props - Options such as whether to include versions.
3560
3665
  */
3561
3666
  async getComponent(e, t) {
3562
- return await h(this, f, Wt).call(this, e, t);
3667
+ return await h(this, f, ts).call(this, e, t);
3563
3668
  }
3564
3669
  /**
3565
3670
  * Creates a new component with the given file and version properties.
@@ -3568,7 +3673,7 @@ const is = class is {
3568
3673
  */
3569
3674
  async createComponent(e) {
3570
3675
  const { componentProps: t } = e;
3571
- return await h(this, f, yt).call(this, e, Ot, t);
3676
+ return await h(this, f, It).call(this, e, Pt, t);
3572
3677
  }
3573
3678
  /**
3574
3679
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -3578,7 +3683,7 @@ const is = class is {
3578
3683
  */
3579
3684
  async updateComponent(e, t) {
3580
3685
  const { componentProps: s } = t;
3581
- return await h(this, f, Jt).call(this, e, t, s);
3686
+ return await h(this, f, es).call(this, e, t, s);
3582
3687
  }
3583
3688
  /**
3584
3689
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -3587,7 +3692,7 @@ const is = class is {
3587
3692
  * @returns A fetch Response containing the ZIP data.
3588
3693
  */
3589
3694
  async downloadComponent(e, t) {
3590
- return await h(this, f, mt).call(this, e, t);
3695
+ return await h(this, f, _t).call(this, e, t);
3591
3696
  }
3592
3697
  /**
3593
3698
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -3598,7 +3703,7 @@ const is = class is {
3598
3703
  */
3599
3704
  async downloadComponentBundle(e, t) {
3600
3705
  const { versionTag: s, withDraft: r } = t || {};
3601
- return await h(this, f, fe).call(this, `${b}/${e}/download/bundle`, {
3706
+ return await h(this, f, fe).call(this, `${v}/${e}/download/bundle`, {
3602
3707
  query: {
3603
3708
  ...s && { versionTag: s },
3604
3709
  ...r && { withDraft: r }
@@ -3610,14 +3715,14 @@ const is = class is {
3610
3715
  * @param componentId - The component's unique identifier.
3611
3716
  */
3612
3717
  async archiveComponent(e) {
3613
- return await h(this, f, w).call(this, "DELETE", `${b}/${e}`);
3718
+ return await h(this, f, g).call(this, "DELETE", `${v}/${e}`);
3614
3719
  }
3615
3720
  /**
3616
3721
  * Recovers a previously archived component.
3617
3722
  * @param componentId - The component's unique identifier.
3618
3723
  */
3619
3724
  async recoverComponent(e) {
3620
- return await h(this, f, w).call(this, "PUT", `${b}/${e}/recover`);
3725
+ return await h(this, f, g).call(this, "PUT", `${v}/${e}/recover`);
3621
3726
  }
3622
3727
  // ─── Built-in Components ─────────────────────────────────────────
3623
3728
  /**
@@ -3655,7 +3760,7 @@ const is = class is {
3655
3760
  * ```
3656
3761
  */
3657
3762
  async initBuiltInComponent(e, t, s) {
3658
- const r = await this.getBuiltInComponent(e.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), a = o.map((m) => i[m]), d = new Function(...o, `${r}
3763
+ const r = await this.getBuiltInComponent(e.uuid), i = s ?? this.builtInGlobals ?? (typeof window < "u" ? window.ThatOpenCompany : {}) ?? {}, o = Object.keys(i), a = o.map((y) => i[y]), d = new Function(...o, `${r}
3659
3764
  return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3660
3765
  t.get(c);
3661
3766
  }
@@ -3724,14 +3829,14 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3724
3829
  */
3725
3830
  async listApps(e) {
3726
3831
  const { folderId: t, ShowVersions: s, projectId: r } = e || {};
3727
- return t ? await h(this, f, w).call(this, "GET", `${Z}/${t}/items`, {
3832
+ return t ? await h(this, f, g).call(this, "GET", `${Z}/${t}/items`, {
3728
3833
  query: {
3729
- itemType: At,
3834
+ itemType: Bt,
3730
3835
  ...s && { ShowVersions: s }
3731
3836
  }
3732
- }) : await h(this, f, w).call(this, "GET", `${b}`, {
3837
+ }) : await h(this, f, g).call(this, "GET", `${v}`, {
3733
3838
  query: {
3734
- itemType: At,
3839
+ itemType: Bt,
3735
3840
  ...s && { ShowVersions: s },
3736
3841
  ...r && { projectId: r }
3737
3842
  }
@@ -3744,7 +3849,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3744
3849
  */
3745
3850
  async createApp(e) {
3746
3851
  const { appProps: t } = e;
3747
- return await h(this, f, yt).call(this, e, At, t);
3852
+ return await h(this, f, It).call(this, e, Bt, t);
3748
3853
  }
3749
3854
  /**
3750
3855
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -3753,7 +3858,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3753
3858
  * @returns A fetch Response containing the ZIP data.
3754
3859
  */
3755
3860
  async downloadApp(e, t) {
3756
- return await h(this, f, mt).call(this, e, t);
3861
+ return await h(this, f, _t).call(this, e, t);
3757
3862
  }
3758
3863
  /**
3759
3864
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -3764,7 +3869,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3764
3869
  */
3765
3870
  async downloadAppBundle(e, t) {
3766
3871
  const { versionTag: s, withDraft: r } = t || {};
3767
- return await h(this, f, fe).call(this, `${b}/${e}/download/bundle`, {
3872
+ return await h(this, f, fe).call(this, `${v}/${e}/download/bundle`, {
3768
3873
  query: {
3769
3874
  ...s && { versionTag: s },
3770
3875
  ...r && { withDraft: r }
@@ -3776,7 +3881,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3776
3881
  * @param appId - The app's unique identifier.
3777
3882
  */
3778
3883
  async archiveApp(e) {
3779
- return await h(this, f, w).call(this, "DELETE", `${b}/${e}`);
3884
+ return await h(this, f, g).call(this, "DELETE", `${v}/${e}`);
3780
3885
  }
3781
3886
  // ─── NPM Registry ────────────────────────────────────────────────
3782
3887
  /**
@@ -3788,7 +3893,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3788
3893
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
3789
3894
  */
3790
3895
  async getNpmCredentials() {
3791
- return await h(this, f, w).call(this, "GET", `${yr}/credentials`);
3896
+ return await h(this, f, g).call(this, "GET", `${$r}/credentials`);
3792
3897
  }
3793
3898
  // ─── Execution ───────────────────────────────────────────────────
3794
3899
  /**
@@ -3820,7 +3925,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3820
3925
  }
3821
3926
  return await i.json();
3822
3927
  }
3823
- return await h(this, f, w).call(this, "POST", `${de}/${e}/execute`, {
3928
+ return await h(this, f, g).call(this, "POST", `${de}/${e}/execute`, {
3824
3929
  body: JSON.stringify(t),
3825
3930
  query: { ...s && { versionTag: s } },
3826
3931
  contentType: "application/json"
@@ -3841,7 +3946,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3841
3946
  }
3842
3947
  return await s.json();
3843
3948
  }
3844
- return await h(this, f, w).call(this, "POST", `${de}/progress/${e}/abort`);
3949
+ return await h(this, f, g).call(this, "POST", `${de}/progress/${e}/abort`);
3845
3950
  }
3846
3951
  /**
3847
3952
  * Lists all executions for a given component.
@@ -3867,7 +3972,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3867
3972
  }
3868
3973
  return await i.json();
3869
3974
  }
3870
- return await h(this, f, w).call(this, "GET", `${de}/${e}/progress`, { query: { ...t && { projectId: t } } });
3975
+ return await h(this, f, g).call(this, "GET", `${de}/${e}/progress`, { query: { ...t && { projectId: t } } });
3871
3976
  }
3872
3977
  /**
3873
3978
  * Gets details of a specific execution, including its messages.
@@ -3885,7 +3990,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3885
3990
  }
3886
3991
  return await s.json();
3887
3992
  }
3888
- return await h(this, f, w).call(this, "GET", `${de}/progress/${e}`);
3993
+ return await h(this, f, g).call(this, "GET", `${de}/progress/${e}`);
3889
3994
  }
3890
3995
  /**
3891
3996
  * Subscribes to real-time execution progress via WebSocket.
@@ -3894,7 +3999,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3894
3999
  * @param onUpdateCallback - Callback invoked on each progress/result event.
3895
4000
  */
3896
4001
  async onExecutionProgress(e, t) {
3897
- const s = this.localServerUrl ?? this.wsUrl, r = await Ke(s, {
4002
+ const s = this.localServerUrl ?? this.wsUrl, r = await st(s, {
3898
4003
  auth: { accessToken: this.accessToken },
3899
4004
  transports: ["websocket"]
3900
4005
  });
@@ -3913,7 +4018,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3913
4018
  * renderable views. See `src/core/documents.ts` for the model and schema.
3914
4019
  */
3915
4020
  documents(e) {
3916
- return new Vs(this, e);
4021
+ return new Zs(this, e);
3917
4022
  }
3918
4023
  /**
3919
4024
  * A project's history of connected documents (Revit models, AutoCAD
@@ -3922,14 +4027,14 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3922
4027
  * or write it; the storage underneath is private and will move.
3923
4028
  */
3924
4029
  history(e) {
3925
- return new lr(this, e);
4030
+ return new Ir(this, e);
3926
4031
  }
3927
4032
  /**
3928
4033
  * The recipe registry and runner: scripts that write change requests in a
3929
4034
  * native application's language. See `src/core/recipes.ts`.
3930
4035
  */
3931
4036
  get recipes() {
3932
- return u(this, Ze) ?? R(this, Ze, new fr(this)), u(this, Ze);
4037
+ return u(this, it) ?? $(this, it, new Or(this)), u(this, it);
3933
4038
  }
3934
4039
  // ─── Hidden Files ────────────────────────────────────────────────
3935
4040
  /**
@@ -3943,7 +4048,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3943
4048
  */
3944
4049
  async createHiddenFile(e, t, s) {
3945
4050
  const r = new FormData();
3946
- return r.append("file", e), r.append("parentItemId", t), s != null && r.append("tag", s), await h(this, f, w).call(this, "POST", `${b}/${ie}`, {
4051
+ return r.append("file", e), r.append("parentItemId", t), s != null && r.append("tag", s), await h(this, f, g).call(this, "POST", `${v}/${oe}`, {
3947
4052
  body: r
3948
4053
  });
3949
4054
  }
@@ -3961,7 +4066,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3961
4066
  const r = new FormData();
3962
4067
  for (const i of e)
3963
4068
  r.append("files", i);
3964
- return r.append("parentItemId", t), s != null && r.append("tag", s), await h(this, f, w).call(this, "POST", `${b}/${ie}/batch`, {
4069
+ return r.append("parentItemId", t), s != null && r.append("tag", s), await h(this, f, g).call(this, "POST", `${v}/${oe}/batch`, {
3965
4070
  body: r
3966
4071
  });
3967
4072
  }
@@ -3970,21 +4075,21 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
3970
4075
  * @param hiddenId - The hidden file's unique identifier.
3971
4076
  */
3972
4077
  async deleteHiddenFile(e) {
3973
- return await h(this, f, w).call(this, "DELETE", `${b}/${ie}/${e}`);
4078
+ return await h(this, f, g).call(this, "DELETE", `${v}/${oe}/${e}`);
3974
4079
  }
3975
4080
  /**
3976
4081
  * Gets metadata for a hidden file.
3977
4082
  * @param hiddenId - The hidden file's unique identifier.
3978
4083
  */
3979
4084
  async getHiddenFile(e) {
3980
- return await h(this, f, w).call(this, "GET", `${b}/${ie}/${e}`);
4085
+ return await h(this, f, g).call(this, "GET", `${v}/${oe}/${e}`);
3981
4086
  }
3982
4087
  /**
3983
4088
  * Downloads a hidden file's content. Returns the raw fetch Response.
3984
4089
  * @param hiddenId - The hidden file's unique identifier.
3985
4090
  */
3986
4091
  async downloadHiddenFile(e) {
3987
- return await h(this, f, fe).call(this, `${b}/${ie}/${e}/download`);
4092
+ return await h(this, f, fe).call(this, `${v}/${oe}/${e}/download`);
3988
4093
  }
3989
4094
  /**
3990
4095
  * Mints a short-lived presigned URL for a hidden file so the browser can
@@ -4004,7 +4109,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4004
4109
  * an ISO timestamp when it stops working.
4005
4110
  */
4006
4111
  async getHiddenFileSignedUrl(e, t) {
4007
- return await h(this, f, w).call(this, "GET", `${b}/${ie}/${e}/signed-url`, { ...t != null && { query: { expiresIn: t } } });
4112
+ return await h(this, f, g).call(this, "GET", `${v}/${oe}/${e}/signed-url`, { ...t != null && { query: { expiresIn: t } } });
4008
4113
  }
4009
4114
  /**
4010
4115
  * Batch variant of {@link getHiddenFileSignedUrl}. Mints presigned URLs for
@@ -4025,7 +4130,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4025
4130
  * 900 (15 min) server-side; values are clamped to that range.
4026
4131
  */
4027
4132
  async getHiddenFileSignedUrlsBatch(e, t) {
4028
- return await h(this, f, ze).call(this, e, async (s) => (await h(this, f, w).call(this, "POST", `${b}/${ie}/signed-url/batch`, {
4133
+ return await h(this, f, tt).call(this, e, async (s) => (await h(this, f, g).call(this, "POST", `${v}/${oe}/signed-url/batch`, {
4029
4134
  body: JSON.stringify({
4030
4135
  hiddenFileIds: s,
4031
4136
  ...t != null && { expiresIn: t }
@@ -4041,14 +4146,14 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4041
4146
  * @returns Array of hidden file entities.
4042
4147
  */
4043
4148
  async getHiddenFilesByParent(e, t) {
4044
- return await h(this, f, w).call(this, "GET", `${b}/${e}/${ie}`, { ...t != null && { query: { tag: t } } });
4149
+ return await h(this, f, g).call(this, "GET", `${v}/${e}/${oe}`, { ...t != null && { query: { tag: t } } });
4045
4150
  }
4046
4151
  /**
4047
4152
  * Deletes all hidden files attached to a parent item.
4048
4153
  * @param parentFileId - The parent item's unique identifier.
4049
4154
  */
4050
4155
  async deleteHiddenFilesByParent(e) {
4051
- return await h(this, f, w).call(this, "DELETE", `${b}/${e}/${ie}`);
4156
+ return await h(this, f, g).call(this, "DELETE", `${v}/${e}/${oe}`);
4052
4157
  }
4053
4158
  // ─── Icons ───────────────────────────────────────────────────────
4054
4159
  /**
@@ -4060,7 +4165,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4060
4165
  */
4061
4166
  async uploadItemIcon(e, t) {
4062
4167
  const s = new FormData();
4063
- return s.append("icon", t), await h(this, f, w).call(this, "PUT", `${b}/${e}/icon`, {
4168
+ return s.append("icon", t), await h(this, f, g).call(this, "PUT", `${v}/${e}/icon`, {
4064
4169
  body: s
4065
4170
  });
4066
4171
  }
@@ -4070,7 +4175,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4070
4175
  * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
4071
4176
  */
4072
4177
  async getItemIcon(e) {
4073
- return await h(this, f, fe).call(this, `${b}/${e}/icon`);
4178
+ return await h(this, f, fe).call(this, `${v}/${e}/icon`);
4074
4179
  }
4075
4180
  /**
4076
4181
  * Removes the icon from an item.
@@ -4078,7 +4183,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4078
4183
  * @returns The updated item with icon fields removed.
4079
4184
  */
4080
4185
  async removeItemIcon(e) {
4081
- return await h(this, f, w).call(this, "DELETE", `${b}/${e}/icon`);
4186
+ return await h(this, f, g).call(this, "DELETE", `${v}/${e}/icon`);
4082
4187
  }
4083
4188
  // ─── General Item Operations ─────────────────────────────────────
4084
4189
  /**
@@ -4088,7 +4193,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4088
4193
  * @returns The updated item.
4089
4194
  */
4090
4195
  async updateItem(e, t) {
4091
- return await h(this, f, w).call(this, "PUT", `${b}/${e}`, {
4196
+ return await h(this, f, g).call(this, "PUT", `${v}/${e}`, {
4092
4197
  body: JSON.stringify(t),
4093
4198
  contentType: "application/json"
4094
4199
  });
@@ -4105,7 +4210,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4105
4210
  */
4106
4211
  async createVersion(e, t, s, r, i) {
4107
4212
  const o = new FormData();
4108
- return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await h(this, f, w).call(this, "POST", `${b}/${e}/version`, { body: o });
4213
+ return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await h(this, f, g).call(this, "POST", `${v}/${e}/version`, { body: o });
4109
4214
  }
4110
4215
  /**
4111
4216
  * Lists versions of an item. Pass `archived: true` to fetch only archived
@@ -4115,7 +4220,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4115
4220
  * @returns Array of versions, sorted by creation date descending.
4116
4221
  */
4117
4222
  async listVersions(e, t = {}) {
4118
- return await h(this, f, w).call(this, "GET", `${b}/${encodeURIComponent(e)}/versions`, { query: t });
4223
+ return await h(this, f, g).call(this, "GET", `${v}/${encodeURIComponent(e)}/versions`, { query: t });
4119
4224
  }
4120
4225
  /**
4121
4226
  * Batch variant of {@link listVersions}. Lists the versions of many items in
@@ -4134,7 +4239,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4134
4239
  */
4135
4240
  async listVersionsBatch(e, t = {}) {
4136
4241
  const { archived: s } = t;
4137
- return await h(this, f, ze).call(this, e, async (r) => (await h(this, f, w).call(this, "POST", `${b}/batch/versions`, {
4242
+ return await h(this, f, tt).call(this, e, async (r) => (await h(this, f, g).call(this, "POST", `${v}/batch/versions`, {
4138
4243
  body: JSON.stringify({
4139
4244
  itemIds: r,
4140
4245
  ...s !== void 0 && { archived: s }
@@ -4152,7 +4257,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4152
4257
  * @returns The archived version.
4153
4258
  */
4154
4259
  async archiveVersion(e, t) {
4155
- return await h(this, f, w).call(this, "PUT", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`);
4260
+ return await h(this, f, g).call(this, "PUT", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`);
4156
4261
  }
4157
4262
  /**
4158
4263
  * Recovers a previously archived version, restoring it to the active list.
@@ -4161,7 +4266,7 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4161
4266
  * @returns The recovered version.
4162
4267
  */
4163
4268
  async recoverVersion(e, t) {
4164
- return await h(this, f, w).call(this, "PUT", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`);
4269
+ return await h(this, f, g).call(this, "PUT", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`);
4165
4270
  }
4166
4271
  /**
4167
4272
  * Permanently deletes a version, including its file in object storage.
@@ -4170,19 +4275,19 @@ return main;`)(...a), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4170
4275
  * @param versionTag - The version's tag (e.g. "v2").
4171
4276
  */
4172
4277
  async deleteVersion(e, t) {
4173
- return await h(this, f, w).call(this, "DELETE", `${b}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`);
4278
+ return await h(this, f, g).call(this, "DELETE", `${v}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`);
4174
4279
  }
4175
4280
  };
4176
- f = new WeakSet(), Gt = function(e) {
4281
+ f = new WeakSet(), Zt = function(e) {
4177
4282
  return `${this.apiUrl}/${e}`;
4178
- }, w = async function(e, t, s) {
4179
- const { body: r, query: i, contentType: o, retries: a, responseType: l, retryAttempt: d } = s || {}, c = h(this, f, Gt).call(this, t), m = h(this, f, Ks).call(this, i), T = await this.resolveAccessToken(), A = {
4180
- ...m,
4283
+ }, g = async function(e, t, s) {
4284
+ const { body: r, query: i, contentType: o, retries: a, responseType: l, retryAttempt: d } = s || {}, c = h(this, f, Zt).call(this, t), y = h(this, f, an).call(this, i), T = await this.resolveAccessToken(), R = {
4285
+ ...y,
4181
4286
  ...this.useBearer ? {} : { accessToken: T }
4182
4287
  };
4183
4288
  try {
4184
4289
  const _ = await fetch(
4185
- c + "?" + new URLSearchParams(A).toString(),
4290
+ c + "?" + new URLSearchParams(R).toString(),
4186
4291
  {
4187
4292
  method: e,
4188
4293
  headers: {
@@ -4194,30 +4299,30 @@ f = new WeakSet(), Gt = function(e) {
4194
4299
  }
4195
4300
  );
4196
4301
  if (!_.ok) {
4197
- const v = await _.text().then((N) => N).catch(() => "");
4198
- throw new rs(
4302
+ const b = await _.text().then((B) => B).catch(() => "");
4303
+ throw new fs(
4199
4304
  _.status,
4200
4305
  _.statusText,
4201
- v,
4202
- vr(_)
4306
+ b,
4307
+ Fr(_)
4203
4308
  );
4204
4309
  }
4205
- return l === "blob" ? await _.blob() : _.json().then((v) => v).catch(() => {
4310
+ return l === "blob" ? await _.blob() : _.json().then((b) => b).catch(() => {
4206
4311
  });
4207
4312
  } catch (_) {
4208
- const v = a ?? this.retries;
4209
- if (v > 0 && Er(_)) {
4210
- const N = d ?? 0;
4211
- return await br(Tr(_, N)), await h(this, f, w).call(this, e, t, {
4313
+ const b = a ?? this.retries;
4314
+ if (b > 0 && Pr(_)) {
4315
+ const B = d ?? 0;
4316
+ return await Nr(Br(_, B)), await h(this, f, g).call(this, e, t, {
4212
4317
  ...s,
4213
- retries: v - 1,
4214
- retryAttempt: N + 1
4318
+ retries: b - 1,
4319
+ retryAttempt: B + 1
4215
4320
  });
4216
4321
  }
4217
4322
  throw _;
4218
4323
  }
4219
4324
  }, fe = async function(e, t) {
4220
- const { query: s } = t || {}, r = h(this, f, Gt).call(this, e), i = await this.resolveAccessToken(), o = {
4325
+ const { query: s } = t || {}, r = h(this, f, Zt).call(this, e), i = await this.resolveAccessToken(), o = {
4221
4326
  ...s,
4222
4327
  ...this.useBearer ? {} : { accessToken: i }
4223
4328
  };
@@ -4230,58 +4335,58 @@ f = new WeakSet(), Gt = function(e) {
4230
4335
  }
4231
4336
  }
4232
4337
  );
4233
- }, Ze = new WeakMap(), ze = async function(e, t) {
4338
+ }, it = new WeakMap(), tt = async function(e, t) {
4234
4339
  if (!e.length) return [];
4235
4340
  const s = [];
4236
- for (let i = 0; i < e.length; i += Es)
4237
- s.push(e.slice(i, i + Es));
4341
+ for (let i = 0; i < e.length; i += Cs)
4342
+ s.push(e.slice(i, i + Cs));
4238
4343
  return (await Promise.all(s.map(t))).flat();
4239
- }, mt = async function(e, t) {
4344
+ }, _t = async function(e, t) {
4240
4345
  const { versionTag: s, withDraft: r } = t || {};
4241
- return await h(this, f, fe).call(this, `${b}/${e}/download`, {
4346
+ return await h(this, f, fe).call(this, `${v}/${e}/download`, {
4242
4347
  query: {
4243
4348
  ...s && { versionTag: s },
4244
4349
  ...r && { withDraft: r }
4245
4350
  }
4246
4351
  });
4247
- }, yt = async function(e, t, s) {
4352
+ }, It = async function(e, t, s) {
4248
4353
  const { name: r, versionTag: i, parentFolderId: o, projectId: a, file: l, metadata: d } = e, c = new FormData();
4249
- return c.append("file", l), c.append("name", r), c.append("versionTag", i), c.append("itemType", t), o && c.append("folderId", o), a && c.append("projectId", a), s && c.append("extraProps", JSON.stringify(s)), d && c.append("metadata", JSON.stringify(d)), await h(this, f, w).call(this, "POST", b, {
4354
+ return c.append("file", l), c.append("name", r), c.append("versionTag", i), c.append("itemType", t), o && c.append("folderId", o), a && c.append("projectId", a), s && c.append("extraProps", JSON.stringify(s)), d && c.append("metadata", JSON.stringify(d)), await h(this, f, g).call(this, "POST", v, {
4250
4355
  body: c
4251
4356
  });
4252
- }, Jt = async function(e, t, s) {
4357
+ }, es = async function(e, t, s) {
4253
4358
  const { name: r, versionTag: i, parentFolderId: o, file: a, metadata: l } = t;
4254
4359
  let d, c;
4255
4360
  if (a) {
4256
- const m = new FormData();
4257
- m.append("file", a), i && m.append("versionTag", i), s && m.append("extraProps", JSON.stringify(s)), l && m.append("metadata", JSON.stringify(l)), c = await h(this, f, w).call(this, "POST", `${b}/${e}/version`, {
4258
- body: m
4361
+ const y = new FormData();
4362
+ y.append("file", a), i && y.append("versionTag", i), s && y.append("extraProps", JSON.stringify(s)), l && y.append("metadata", JSON.stringify(l)), c = await h(this, f, g).call(this, "POST", `${v}/${e}/version`, {
4363
+ body: y
4259
4364
  });
4260
4365
  }
4261
4366
  if (r || o) {
4262
- const m = {
4367
+ const y = {
4263
4368
  ...r && { name: r },
4264
4369
  ...o && { folderId: o }
4265
- }, T = JSON.stringify(m);
4266
- d = await h(this, f, w).call(this, "PUT", `${b}/${e}`, {
4370
+ }, T = JSON.stringify(y);
4371
+ d = await h(this, f, g).call(this, "PUT", `${v}/${e}`, {
4267
4372
  body: T,
4268
4373
  contentType: "application/json"
4269
4374
  });
4270
4375
  }
4271
4376
  return { item: d, version: c };
4272
- }, Wt = async function(e, t) {
4377
+ }, ts = async function(e, t) {
4273
4378
  const { showVersions: s = !1 } = t || {};
4274
- return await h(this, f, w).call(this, "GET", `${b}/${e}`, {
4379
+ return await h(this, f, g).call(this, "GET", `${v}/${e}`, {
4275
4380
  query: { showVersions: s }
4276
4381
  });
4277
- }, Ks = function(e) {
4382
+ }, an = function(e) {
4278
4383
  return e && Object.entries(e).filter(([, t]) => t !== void 0).reduce(
4279
4384
  (t, [s, r]) => (t[s] = r, t),
4280
4385
  {}
4281
4386
  );
4282
4387
  };
4283
- let Ht = is;
4284
- function _r() {
4388
+ let Qt = ps;
4389
+ function Lr() {
4285
4390
  if (typeof window > "u" || window.parent === window)
4286
4391
  throw new Error(
4287
4392
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
@@ -4296,80 +4401,80 @@ function _r() {
4296
4401
  }
4297
4402
  };
4298
4403
  }
4299
- const Yt = "channel:", Ir = 1e4;
4300
- function gt(n) {
4404
+ const ss = "channel:", Dr = 1e4;
4405
+ function St(n) {
4301
4406
  try {
4302
4407
  n();
4303
4408
  } catch (e) {
4304
4409
  console.error("[channel] a listener threw:", e);
4305
4410
  }
4306
4411
  }
4307
- var ce, M, V, xe, Ne, Pe, L, zt, Kt, $e;
4308
- class Xs {
4412
+ var he, H, G, Le, De, qe, U, ns, rs, Be;
4413
+ class cn {
4309
4414
  constructor(e, t) {
4310
- S(this, L);
4311
- S(this, ce, !1);
4312
- S(this, M, []);
4313
- S(this, V, []);
4314
- S(this, xe, /* @__PURE__ */ new Set());
4315
- S(this, Ne, /* @__PURE__ */ new Set());
4316
- S(this, Pe, /* @__PURE__ */ new Set());
4415
+ S(this, U);
4416
+ S(this, he, !1);
4417
+ S(this, H, []);
4418
+ S(this, G, []);
4419
+ S(this, Le, /* @__PURE__ */ new Set());
4420
+ S(this, De, /* @__PURE__ */ new Set());
4421
+ S(this, qe, /* @__PURE__ */ new Set());
4317
4422
  this.transport = e, this.controls = t;
4318
4423
  }
4319
4424
  /** Whether the platform has confirmed this tab is in the room. */
4320
4425
  get joined() {
4321
- return u(this, ce);
4426
+ return u(this, he);
4322
4427
  }
4323
4428
  /** Who else is in the room right now, as the platform last reported. */
4324
4429
  get peers() {
4325
- return u(this, M);
4430
+ return u(this, H);
4326
4431
  }
4327
4432
  /**
4328
4433
  * Enters the room. Resolves when the platform confirms; rejects if it
4329
4434
  * refuses or does not answer in time. Joining twice is harmless.
4330
4435
  */
4331
4436
  join() {
4332
- return u(this, ce) ? Promise.resolve() : h(this, L, zt).call(this, "joined", this.controls.join);
4437
+ return u(this, he) ? Promise.resolve() : h(this, U, ns).call(this, "joined", this.controls.join);
4333
4438
  }
4334
4439
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
4335
4440
  leave() {
4336
- return !u(this, ce) && !u(this, V).some((e) => e.want === "joined") ? Promise.resolve() : h(this, L, zt).call(this, "left", this.controls.leave);
4441
+ return !u(this, he) && !u(this, G).some((e) => e.want === "joined") ? Promise.resolve() : h(this, U, ns).call(this, "left", this.controls.leave);
4337
4442
  }
4338
4443
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
4339
4444
  onChange(e) {
4340
- return u(this, xe).add(e), () => void u(this, xe).delete(e);
4445
+ return u(this, Le).add(e), () => void u(this, Le).delete(e);
4341
4446
  }
4342
4447
  onPeerJoined(e) {
4343
- return u(this, Ne).add(e), () => void u(this, Ne).delete(e);
4448
+ return u(this, De).add(e), () => void u(this, De).delete(e);
4344
4449
  }
4345
4450
  onPeerLeft(e) {
4346
- return u(this, Pe).add(e), () => void u(this, Pe).delete(e);
4451
+ return u(this, qe).add(e), () => void u(this, qe).delete(e);
4347
4452
  }
4348
4453
  /** @internal */
4349
4454
  applyJoined() {
4350
- R(this, ce, !0), h(this, L, Kt).call(this, "joined"), h(this, L, $e).call(this);
4455
+ $(this, he, !0), h(this, U, rs).call(this, "joined"), h(this, U, Be).call(this);
4351
4456
  }
4352
4457
  /** @internal */
4353
4458
  applyLeft() {
4354
- R(this, ce, !1), R(this, M, []), h(this, L, Kt).call(this, "left"), h(this, L, $e).call(this);
4459
+ $(this, he, !1), $(this, H, []), h(this, U, rs).call(this, "left"), h(this, U, Be).call(this);
4355
4460
  }
4356
4461
  /** @internal */
4357
4462
  applyPeers(e) {
4358
- R(this, M, e), h(this, L, $e).call(this);
4463
+ $(this, H, e), h(this, U, Be).call(this);
4359
4464
  }
4360
4465
  /** @internal */
4361
4466
  applyPeerJoined(e) {
4362
- !u(this, ce) || u(this, M).some((t) => t.from === e.from) || (R(this, M, [...u(this, M), e]), u(this, Ne).forEach((t) => gt(() => t(e))), h(this, L, $e).call(this));
4467
+ !u(this, he) || u(this, H).some((t) => t.from === e.from) || ($(this, H, [...u(this, H), e]), u(this, De).forEach((t) => St(() => t(e))), h(this, U, Be).call(this));
4363
4468
  }
4364
4469
  /** @internal */
4365
4470
  applyPeerLeft(e) {
4366
- const t = u(this, M).find((s) => s.from === e);
4367
- t && (R(this, M, u(this, M).filter((s) => s.from !== e)), u(this, Pe).forEach((s) => gt(() => s(t))), h(this, L, $e).call(this));
4471
+ const t = u(this, H).find((s) => s.from === e);
4472
+ t && ($(this, H, u(this, H).filter((s) => s.from !== e)), u(this, qe).forEach((s) => St(() => s(t))), h(this, U, Be).call(this));
4368
4473
  }
4369
4474
  /** @internal */
4370
4475
  failPending(e) {
4371
- const t = u(this, V);
4372
- return R(this, V, []), t.forEach((s) => {
4476
+ const t = u(this, G);
4477
+ return $(this, G, []), t.forEach((s) => {
4373
4478
  clearTimeout(s.timer), s.reject(e);
4374
4479
  }), t.length > 0;
4375
4480
  }
@@ -4377,70 +4482,70 @@ class Xs {
4377
4482
  this.transport.post(e);
4378
4483
  }
4379
4484
  }
4380
- ce = new WeakMap(), M = new WeakMap(), V = new WeakMap(), xe = new WeakMap(), Ne = new WeakMap(), Pe = new WeakMap(), L = new WeakSet(), zt = function(e, t) {
4485
+ he = new WeakMap(), H = new WeakMap(), G = new WeakMap(), Le = new WeakMap(), De = new WeakMap(), qe = new WeakMap(), U = new WeakSet(), ns = function(e, t) {
4381
4486
  return new Promise((s, r) => {
4382
4487
  const i = {
4383
4488
  want: e,
4384
4489
  resolve: s,
4385
4490
  reject: r,
4386
4491
  timer: setTimeout(() => {
4387
- R(this, V, u(this, V).filter((o) => o !== i)), r(
4492
+ $(this, G, u(this, G).filter((o) => o !== i)), r(
4388
4493
  new Error(
4389
4494
  `The platform did not confirm ${e === "joined" ? "joining" : "leaving"} in time.`
4390
4495
  )
4391
4496
  );
4392
- }, Ir)
4497
+ }, Dr)
4393
4498
  };
4394
- u(this, V).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...t });
4499
+ u(this, G).push(i), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...t });
4395
4500
  });
4396
- }, Kt = function(e) {
4397
- const t = u(this, V).filter((s) => s.want === e);
4398
- R(this, V, u(this, V).filter((s) => s.want !== e)), t.forEach((s) => {
4501
+ }, rs = function(e) {
4502
+ const t = u(this, G).filter((s) => s.want === e);
4503
+ $(this, G, u(this, G).filter((s) => s.want !== e)), t.forEach((s) => {
4399
4504
  clearTimeout(s.timer), s.resolve();
4400
4505
  });
4401
- }, $e = function() {
4402
- u(this, xe).forEach((e) => gt(e));
4506
+ }, Be = function() {
4507
+ u(this, Le).forEach((e) => St(e));
4403
4508
  };
4404
- var Be;
4405
- class Sr extends Xs {
4509
+ var je;
4510
+ class qr extends cn {
4406
4511
  /** @internal Use `client.channel.collab()`. */
4407
4512
  constructor(t) {
4408
4513
  super(t, {
4409
4514
  join: { action: "joinCollab" },
4410
4515
  leave: { action: "leaveCollab" }
4411
4516
  });
4412
- S(this, Be, /* @__PURE__ */ new Map());
4517
+ S(this, je, /* @__PURE__ */ new Map());
4413
4518
  }
4414
4519
  /**
4415
4520
  * Listens for an event other tabs send. Any number of listeners per event.
4416
4521
  * @returns a function that removes the listener.
4417
4522
  */
4418
4523
  on(t, s) {
4419
- const r = u(this, Be).get(t) ?? /* @__PURE__ */ new Set();
4420
- return r.add(s), u(this, Be).set(t, r), () => void r.delete(s);
4524
+ const r = u(this, je).get(t) ?? /* @__PURE__ */ new Set();
4525
+ return r.add(s), u(this, je).set(t, r), () => void r.delete(s);
4421
4526
  }
4422
4527
  /**
4423
4528
  * Sends an event to the other tabs in the room. Does nothing while this tab
4424
4529
  * is not in it, matching what the platform does with a message from outside.
4425
4530
  */
4426
4531
  send(t, s) {
4427
- if (t.startsWith(Yt))
4428
- throw new Error(`Message types starting with '${Yt}' are reserved.`);
4532
+ if (t.startsWith(ss))
4533
+ throw new Error(`Message types starting with '${ss}' are reserved.`);
4429
4534
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: t, payload: s } });
4430
4535
  }
4431
4536
  accepts(t) {
4432
4537
  return t === void 0 || t === "collab";
4433
4538
  }
4434
4539
  async handle(t) {
4435
- const s = u(this, Be).get(t.type);
4540
+ const s = u(this, je).get(t.type);
4436
4541
  if (!(s != null && s.size)) return { handled: !1 };
4437
- const r = Qs(t);
4438
- return s.forEach((i) => gt(() => i(t.payload, r))), { handled: !0 };
4542
+ const r = hn(t);
4543
+ return s.forEach((i) => St(() => i(t.payload, r))), { handled: !0 };
4439
4544
  }
4440
4545
  }
4441
- Be = new WeakMap();
4546
+ je = new WeakMap();
4442
4547
  var me;
4443
- class kr extends Xs {
4548
+ class jr extends cn {
4444
4549
  /** @internal Use `client.channel.external(kind)`. */
4445
4550
  constructor(t, s) {
4446
4551
  super(t, {
@@ -4478,7 +4583,7 @@ class kr extends Xs {
4478
4583
  const s = u(this, me).get(t.type);
4479
4584
  if (!s) return { handled: !1 };
4480
4585
  try {
4481
- return { handled: !0, value: await s(t.payload, Qs(t)) };
4586
+ return { handled: !0, value: await s(t.payload, hn(t)) };
4482
4587
  } catch (r) {
4483
4588
  return {
4484
4589
  handled: !0,
@@ -4488,7 +4593,7 @@ class kr extends Xs {
4488
4593
  }
4489
4594
  }
4490
4595
  me = new WeakMap();
4491
- function Qs(n) {
4596
+ function hn(n) {
4492
4597
  return {
4493
4598
  from: n.from,
4494
4599
  at: n.at,
@@ -4496,7 +4601,7 @@ function Qs(n) {
4496
4601
  kind: n.kind
4497
4602
  };
4498
4603
  }
4499
- function Or(n) {
4604
+ function Ur(n) {
4500
4605
  const e = n;
4501
4606
  if ((e == null ? void 0 : e.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
4502
4607
  const t = e.message;
@@ -4510,20 +4615,20 @@ function Or(n) {
4510
4615
  kind: typeof t.kind == "string" ? t.kind : void 0
4511
4616
  };
4512
4617
  }
4513
- var Se, et, he, ye, ge, $, Xt, wt, Zs, en, tn, Qt;
4514
- class Ar {
4618
+ var ke, ot, le, ye, ge, N, is, At, ln, dn, un, os;
4619
+ class Mr {
4515
4620
  constructor(e) {
4516
- S(this, $);
4517
- S(this, Se);
4518
- S(this, et);
4519
- S(this, he);
4621
+ S(this, N);
4622
+ S(this, ke);
4623
+ S(this, ot);
4624
+ S(this, le);
4520
4625
  S(this, ye, /* @__PURE__ */ new Map());
4521
4626
  S(this, ge, /* @__PURE__ */ new Set());
4522
- R(this, Se, e), R(this, et, e.listen((t) => void h(this, $, Zs).call(this, t)));
4627
+ $(this, ke, e), $(this, ot, e.listen((t) => void h(this, N, ln).call(this, t)));
4523
4628
  }
4524
4629
  /** The collaboration room for this app. Always the same instance. */
4525
4630
  collab() {
4526
- return u(this, he) ?? R(this, he, new Sr(u(this, Se))), u(this, he);
4631
+ return u(this, le) ?? $(this, le, new qr(u(this, ke))), u(this, le);
4527
4632
  }
4528
4633
  /**
4529
4634
  * The room for commands from this account's external tools of one `kind`
@@ -4533,45 +4638,45 @@ class Ar {
4533
4638
  external(e) {
4534
4639
  const t = e ?? "";
4535
4640
  let s = u(this, ye).get(t);
4536
- return s || (s = new kr(u(this, Se), e), u(this, ye).set(t, s)), s;
4641
+ return s || (s = new jr(u(this, ke), e), u(this, ye).set(t, s)), s;
4537
4642
  }
4538
4643
  /** Stops listening. For tests and teardown; an app normally never calls it. */
4539
4644
  dispose() {
4540
- u(this, et).call(this);
4645
+ u(this, ot).call(this);
4541
4646
  }
4542
4647
  }
4543
- Se = new WeakMap(), et = new WeakMap(), he = new WeakMap(), ye = new WeakMap(), ge = new WeakMap(), $ = new WeakSet(), Xt = function() {
4544
- return [...u(this, he) ? [u(this, he)] : [], ...u(this, ye).values()];
4545
- }, wt = function(e, t) {
4546
- if (e === "collab") return u(this, he);
4648
+ ke = new WeakMap(), ot = new WeakMap(), le = new WeakMap(), ye = new WeakMap(), ge = new WeakMap(), N = new WeakSet(), is = function() {
4649
+ return [...u(this, le) ? [u(this, le)] : [], ...u(this, ye).values()];
4650
+ }, At = function(e, t) {
4651
+ if (e === "collab") return u(this, le);
4547
4652
  if (e === "external")
4548
4653
  return u(this, ye).get(typeof t == "string" ? t : "");
4549
- }, Zs = async function(e) {
4550
- const t = Or(e);
4654
+ }, ln = async function(e) {
4655
+ const t = Ur(e);
4551
4656
  if (t) {
4552
- if (t.type.startsWith(Yt)) {
4553
- h(this, $, en).call(this, t);
4657
+ if (t.type.startsWith(ss)) {
4658
+ h(this, N, dn).call(this, t);
4554
4659
  return;
4555
4660
  }
4556
- await h(this, $, tn).call(this, t);
4661
+ await h(this, N, un).call(this, t);
4557
4662
  }
4558
- }, en = function(e) {
4663
+ }, dn = function(e) {
4559
4664
  var s, r, i;
4560
4665
  const t = e.payload ?? {};
4561
4666
  switch (e.type) {
4562
4667
  case "channel:joined":
4563
- (s = h(this, $, wt).call(this, t.scope, t.kind)) == null || s.applyJoined();
4668
+ (s = h(this, N, At).call(this, t.scope, t.kind)) == null || s.applyJoined();
4564
4669
  break;
4565
4670
  case "channel:left":
4566
- (r = h(this, $, wt).call(this, t.scope, t.kind)) == null || r.applyLeft();
4671
+ (r = h(this, N, At).call(this, t.scope, t.kind)) == null || r.applyLeft();
4567
4672
  break;
4568
4673
  case "channel:peers":
4569
- (i = h(this, $, wt).call(this, t.scope, t.kind)) == null || i.applyPeers(t.peers ?? []);
4674
+ (i = h(this, N, At).call(this, t.scope, t.kind)) == null || i.applyPeers(t.peers ?? []);
4570
4675
  break;
4571
4676
  case "channel:peer-joined":
4572
4677
  case "channel:peer-left": {
4573
4678
  if (!t.from) break;
4574
- const o = t.scope === "collab" ? [u(this, he)] : [...u(this, ye).values()].filter(
4679
+ const o = t.scope === "collab" ? [u(this, le)] : [...u(this, ye).values()].filter(
4575
4680
  (a) => a.accepts("external", t.kind)
4576
4681
  );
4577
4682
  for (const a of o)
@@ -4580,23 +4685,23 @@ Se = new WeakMap(), et = new WeakMap(), he = new WeakMap(), ye = new WeakMap(),
4580
4685
  }
4581
4686
  case "channel:error": {
4582
4687
  const o = new Error(String(e.payload));
4583
- h(this, $, Xt).call(this).map((l) => l.failPending(o)).some(Boolean) || console.error("[channel] error:", e.payload);
4688
+ h(this, N, is).call(this).map((l) => l.failPending(o)).some(Boolean) || console.error("[channel] error:", e.payload);
4584
4689
  break;
4585
4690
  }
4586
4691
  }
4587
- }, tn = async function(e) {
4588
- const t = h(this, $, Xt).call(this).filter((i) => i.accepts(e.scope, e.kind));
4692
+ }, un = async function(e) {
4693
+ const t = h(this, N, is).call(this).filter((i) => i.accepts(e.scope, e.kind));
4589
4694
  let s = !1;
4590
4695
  for (const i of t) {
4591
4696
  const o = await i.handle(e);
4592
- o.handled && (s = !0, e.requestId && h(this, $, Qt).call(this, e.requestId, o));
4697
+ o.handled && (s = !0, e.requestId && h(this, N, os).call(this, e.requestId, o));
4593
4698
  }
4594
- e.requestId && e.scope === "external" && t.length > 0 && !s && h(this, $, Qt).call(this, e.requestId, {
4699
+ e.requestId && e.scope === "external" && t.length > 0 && !s && h(this, N, os).call(this, e.requestId, {
4595
4700
  handled: !0,
4596
4701
  error: `No handler for "${e.type}".`
4597
4702
  });
4598
- }, Qt = function(e, t) {
4599
- u(this, ge).has(e) || (u(this, ge).add(e), u(this, ge).size > 500 && u(this, ge).delete(u(this, ge).values().next().value), u(this, Se).post({
4703
+ }, os = function(e, t) {
4704
+ u(this, ge).has(e) || (u(this, ge).add(e), u(this, ge).size > 500 && u(this, ge).delete(u(this, ge).values().next().value), u(this, ke).post({
4600
4705
  type: "APP_CHANNEL_PUBLISH",
4601
4706
  message: {
4602
4707
  type: t.error === void 0 ? "reply" : "reply-error",
@@ -4605,9 +4710,9 @@ Se = new WeakMap(), et = new WeakMap(), he = new WeakMap(), ye = new WeakMap(),
4605
4710
  }
4606
4711
  }));
4607
4712
  };
4608
- const Ie = "project", Ae = "notifications";
4609
- var Fe, tt;
4610
- const os = class os extends Ht {
4713
+ const Oe = "project", Ce = "notifications";
4714
+ var Ue, at;
4715
+ const ms = class ms extends Qt {
4611
4716
  /**
4612
4717
  * @param token - A bearer JWT, OR a function returning the current JWT
4613
4718
  * (sync or async). When a function is passed, it's invoked before every
@@ -4618,12 +4723,12 @@ const os = class os extends Ht {
4618
4723
  */
4619
4724
  constructor(t, s, r) {
4620
4725
  super(typeof t == "string" ? t : "", s, { ...r, useBearer: !0 });
4621
- S(this, Fe);
4622
- S(this, tt);
4623
- typeof t == "function" && R(this, Fe, t);
4726
+ S(this, Ue);
4727
+ S(this, at);
4728
+ typeof t == "function" && $(this, Ue, t);
4624
4729
  }
4625
4730
  async resolveAccessToken() {
4626
- return u(this, Fe) ? await u(this, Fe).call(this) : super.resolveAccessToken();
4731
+ return u(this, Ue) ? await u(this, Ue).call(this) : super.resolveAccessToken();
4627
4732
  }
4628
4733
  /**
4629
4734
  * Creates a client from the platform context injected into
@@ -4632,7 +4737,7 @@ const os = class os extends Ht {
4632
4737
  * carries a fresh JWT on every navigation.
4633
4738
  */
4634
4739
  static fromPlatformContext(t) {
4635
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new os(s.accessToken, s.apiUrl, t);
4740
+ const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, r = new ms(s.accessToken, s.apiUrl, t);
4636
4741
  return r.context = s, r;
4637
4742
  }
4638
4743
  /**
@@ -4660,7 +4765,7 @@ const os = class os extends Ht {
4660
4765
  * ```
4661
4766
  */
4662
4767
  get channel() {
4663
- return u(this, tt) ?? R(this, tt, new Ar(_r())), u(this, tt);
4768
+ return u(this, at) ?? $(this, at, new Mr(Lr())), u(this, at);
4664
4769
  }
4665
4770
  // ─── Projects (JWT-only backend routes) ──────────────────────────
4666
4771
  /**
@@ -4679,14 +4784,14 @@ const os = class os extends Ht {
4679
4784
  * ```
4680
4785
  */
4681
4786
  async listProjects() {
4682
- return await this.request("GET", Ie);
4787
+ return await this.request("GET", Oe);
4683
4788
  }
4684
4789
  /**
4685
4790
  * Gets a project by ID. JWT-only — lives here because
4686
4791
  * `GET /project/:id` is guarded by `AccountActiveGuard + ProjectAccessGuard`.
4687
4792
  */
4688
4793
  async getProject(t) {
4689
- return await this.request("GET", `${Ie}/${t}`);
4794
+ return await this.request("GET", `${Oe}/${t}`);
4690
4795
  }
4691
4796
  /**
4692
4797
  * Gets the full project data (users, roles, files, folders) for a project.
@@ -4695,7 +4800,7 @@ const os = class os extends Ht {
4695
4800
  async getProjectData(t) {
4696
4801
  return await this.request(
4697
4802
  "GET",
4698
- `${Ie}/${t}/data`
4803
+ `${Oe}/${t}/data`
4699
4804
  );
4700
4805
  }
4701
4806
  // ─── Account ──────────────────────────────────────────────────────
@@ -4720,7 +4825,7 @@ const os = class os extends Ht {
4720
4825
  async checkPermission(t) {
4721
4826
  return await this.request(
4722
4827
  "GET",
4723
- `${Ie}/permissions/check`,
4828
+ `${Oe}/permissions/check`,
4724
4829
  { query: t }
4725
4830
  );
4726
4831
  }
@@ -4729,7 +4834,7 @@ const os = class os extends Ht {
4729
4834
  * single round-trip; results come back in the same order as `checks`.
4730
4835
  */
4731
4836
  async checkPermissionBatch(t) {
4732
- return (await this.request("POST", `${Ie}/permissions/check/batch`, {
4837
+ return (await this.request("POST", `${Oe}/permissions/check/batch`, {
4733
4838
  body: JSON.stringify({ checks: t }),
4734
4839
  contentType: "application/json"
4735
4840
  })).results;
@@ -4757,7 +4862,7 @@ const os = class os extends Ht {
4757
4862
  * ```
4758
4863
  */
4759
4864
  async getNotifications(t) {
4760
- return await this.request("GET", Ae, {
4865
+ return await this.request("GET", Ce, {
4761
4866
  query: {
4762
4867
  ...(t == null ? void 0 : t.cursor) !== void 0 && { cursor: t.cursor },
4763
4868
  ...(t == null ? void 0 : t.limit) !== void 0 && { limit: String(t.limit) }
@@ -4771,7 +4876,7 @@ const os = class os extends Ht {
4771
4876
  async getUnreadNotificationCount() {
4772
4877
  return (await this.request(
4773
4878
  "GET",
4774
- `${Ae}/unread-count`
4879
+ `${Ce}/unread-count`
4775
4880
  )).count;
4776
4881
  }
4777
4882
  /**
@@ -4782,7 +4887,7 @@ const os = class os extends Ht {
4782
4887
  async markNotificationsRead(t) {
4783
4888
  return await this.request(
4784
4889
  "POST",
4785
- `${Ae}/mark-read`,
4890
+ `${Ce}/mark-read`,
4786
4891
  {
4787
4892
  body: JSON.stringify({ ids: t }),
4788
4893
  contentType: "application/json"
@@ -4793,7 +4898,7 @@ const os = class os extends Ht {
4793
4898
  async markAllNotificationsRead() {
4794
4899
  return await this.request(
4795
4900
  "POST",
4796
- `${Ae}/mark-all-read`
4901
+ `${Ce}/mark-all-read`
4797
4902
  );
4798
4903
  }
4799
4904
  /**
@@ -4803,7 +4908,7 @@ const os = class os extends Ht {
4803
4908
  async getNotificationSubscriptions() {
4804
4909
  return await this.request(
4805
4910
  "GET",
4806
- `${Ae}/subscriptions`
4911
+ `${Ce}/subscriptions`
4807
4912
  );
4808
4913
  }
4809
4914
  /**
@@ -4817,7 +4922,7 @@ const os = class os extends Ht {
4817
4922
  async unsubscribeFromAutomation(t) {
4818
4923
  return await this.request(
4819
4924
  "DELETE",
4820
- `${Ae}/subscriptions/${t}`
4925
+ `${Ce}/subscriptions/${t}`
4821
4926
  );
4822
4927
  }
4823
4928
  /**
@@ -4841,7 +4946,7 @@ const os = class os extends Ht {
4841
4946
  async subscribeToAutomation(t, s, r) {
4842
4947
  return await this.request(
4843
4948
  "POST",
4844
- `${Ie}/${t}/events/hooks/${s}/subscription`,
4949
+ `${Oe}/${t}/events/hooks/${s}/subscription`,
4845
4950
  {
4846
4951
  body: JSON.stringify(r ?? {}),
4847
4952
  contentType: "application/json"
@@ -4858,7 +4963,7 @@ const os = class os extends Ht {
4858
4963
  async updateAutomationSubscription(t, s, r) {
4859
4964
  return await this.request(
4860
4965
  "PATCH",
4861
- `${Ie}/${t}/events/hooks/${s}/subscription`,
4966
+ `${Oe}/${t}/events/hooks/${s}/subscription`,
4862
4967
  {
4863
4968
  body: JSON.stringify(r),
4864
4969
  contentType: "application/json"
@@ -4892,7 +4997,7 @@ const os = class os extends Ht {
4892
4997
  * ```
4893
4998
  */
4894
4999
  async onNotification(t) {
4895
- const s = await this.resolveAccessToken(), r = Ke(`${this.socketOrigin}/notifications`, {
5000
+ const s = await this.resolveAccessToken(), r = st(`${this.socketOrigin}/notifications`, {
4896
5001
  auth: { accessToken: s },
4897
5002
  transports: ["websocket"]
4898
5003
  });
@@ -4908,11 +5013,11 @@ const os = class os extends Ht {
4908
5013
  ), () => r.disconnect();
4909
5014
  }
4910
5015
  };
4911
- Fe = new WeakMap(), tt = new WeakMap();
4912
- let _s = os;
4913
- async function sn(n) {
4914
- const [e, t] = await Rr(), s = t.Model.getRootAsModel(
4915
- new e.ByteBuffer(await Cr(n))
5016
+ Ue = new WeakMap(), at = new WeakMap();
5017
+ let Ns = ms;
5018
+ async function fn(n) {
5019
+ const [e, t] = await Vr(), s = t.Model.getRootAsModel(
5020
+ new e.ByteBuffer(await Hr(n))
4916
5021
  );
4917
5022
  let r = {};
4918
5023
  try {
@@ -4929,12 +5034,12 @@ async function sn(n) {
4929
5034
  const l = s.localIds(a);
4930
5035
  if (l === null) continue;
4931
5036
  const d = {}, c = s.attributes(a);
4932
- for (let m = 0; m < ((c == null ? void 0 : c.dataLength()) ?? 0); m++) {
4933
- const T = c.data(m);
5037
+ for (let y = 0; y < ((c == null ? void 0 : c.dataLength()) ?? 0); y++) {
5038
+ const T = c.data(y);
4934
5039
  if (T)
4935
5040
  try {
4936
- const [A, _] = JSON.parse(T);
4937
- d[A] = _;
5041
+ const [R, _] = JSON.parse(T);
5042
+ d[R] = _;
4938
5043
  } catch {
4939
5044
  }
4940
5045
  }
@@ -4947,7 +5052,7 @@ async function sn(n) {
4947
5052
  }
4948
5053
  return { metadata: r, items: o };
4949
5054
  }
4950
- async function Rr() {
5055
+ async function Vr() {
4951
5056
  try {
4952
5057
  return await Promise.all([
4953
5058
  import("flatbuffers"),
@@ -4959,14 +5064,14 @@ async function Rr() {
4959
5064
  );
4960
5065
  }
4961
5066
  }
4962
- async function Cr(n) {
5067
+ async function Hr(n) {
4963
5068
  const e = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate"));
4964
5069
  return new Uint8Array(await new Response(e).arrayBuffer());
4965
5070
  }
4966
- const $r = "flow:", xr = "flow:op", Nr = "flow:source", Pr = "revitflow/op@2", Is = "REVITFLOWCHANGE", Ss = "REVITFLOWOPERATION";
4967
- class nn {
5071
+ const Gr = "flow:", Jr = "flow:op", Wr = "flow:source", Yr = "revitflow/op@2", Fs = "REVITFLOWCHANGE", Ps = "REVITFLOWOPERATION";
5072
+ class pn {
4968
5073
  constructor(e) {
4969
- B(this, "changes", []);
5074
+ L(this, "changes", []);
4970
5075
  this.target = e;
4971
5076
  }
4972
5077
  /** How many changes are queued. An operation with none is refused by `build`. */
@@ -5032,7 +5137,7 @@ class nn {
5032
5137
  "An operation with no changes is not an operation. Add at least one."
5033
5138
  );
5034
5139
  const t = {
5035
- schema: Pr,
5140
+ schema: Yr,
5036
5141
  opId: e,
5037
5142
  // Through the getters, so the envelope and the queue entry cannot drift
5038
5143
  // into disagreeing about the same operation.
@@ -5044,8 +5149,8 @@ class nn {
5044
5149
  ...this.userId ? { userId: this.userId } : {},
5045
5150
  title: this.title,
5046
5151
  summary: this.summary
5047
- }, [s, r] = await Br();
5048
- return Fr(
5152
+ }, [s, r] = await zr();
5153
+ return Kr(
5049
5154
  this.flatbuffer(s, r, e, JSON.stringify(t))
5050
5155
  );
5051
5156
  }
@@ -5054,8 +5159,8 @@ class nn {
5054
5159
  pack(e, t) {
5055
5160
  const s = {};
5056
5161
  for (const [r, i] of Object.entries(e ?? {}))
5057
- r.startsWith($r) || (s[r] = String(i));
5058
- return t.position && (s.Position = t.position.map(ks).join(",")), t.rotationDeg !== void 0 && (s.Rotation = ks(t.rotationDeg)), t.source && (s[Nr] = t.source), s;
5162
+ r.startsWith(Gr) || (s[r] = String(i));
5163
+ return t.position && (s.Position = t.position.map(Bs).join(",")), t.rotationDeg !== void 0 && (s.Rotation = Bs(t.rotationDeg)), t.source && (s[Wr] = t.source), s;
5059
5164
  }
5060
5165
  requireId(e, t) {
5061
5166
  if (!e || !e.trim())
@@ -5077,61 +5182,61 @@ class nn {
5077
5182
  * and rejects a falsy one.
5078
5183
  */
5079
5184
  flatbuffer(e, t, s, r) {
5080
- const { Attribute: i, Meshes: o, Model: a, SpatialStructure: l, Transform: d } = t, c = new e.Builder(1024), m = this.changes.length, T = new Uint32Array(m);
5081
- let A = 1;
5082
- for (let I = 0; I < m; I++) T[I] = A++;
5083
- const _ = A++, v = (I) => (I(c, 0), c.endVector()), N = o.createShellsVector(c, []), be = o.createCircleExtrusionsVector(c, []), G = v(o.startSamplesVector), z = v(o.startRepresentationsVector), De = v(o.startMaterialsVector), K = v(o.startLocalTransformsVector), O = v(o.startGlobalTransformsVector), q = o.createMeshesItemsVector(c, []), X = o.createMaterialIdsVector(c, []), ve = o.createRepresentationIdsVector(c, []), Ee = o.createSampleIdsVector(c, []), Te = o.createLocalTransformIdsVector(c, []), qe = o.createGlobalTransformIdsVector(c, []);
5084
- o.startMeshes(c), o.addCoordinates(c, d.createTransform(c, 0, 0, 0, 1, 0, 0, 0, 1, 0)), o.addGlobalTransforms(c, O), o.addShells(c, N), o.addRepresentations(c, z), o.addSamples(c, G), o.addLocalTransforms(c, K), o.addMaterials(c, De), o.addCircleExtrusions(c, be), o.addMeshesItems(c, q), o.addRepresentationIds(c, ve), o.addSampleIds(c, Ee), o.addMaterialIds(c, X), o.addLocalTransformIds(c, Te), o.addGlobalTransformIds(c, qe);
5085
- const je = o.endMeshes(c), _e = c.createString(r), Ue = /* @__PURE__ */ new Set(), Oe = [];
5086
- for (const I of this.changes) {
5087
- const F = [], re = {
5088
- [xr]: I.op,
5089
- ...I.attrs
5185
+ const { Attribute: i, Meshes: o, Model: a, SpatialStructure: l, Transform: d } = t, c = new e.Builder(1024), y = this.changes.length, T = new Uint32Array(y);
5186
+ let R = 1;
5187
+ for (let O = 0; O < y; O++) T[O] = R++;
5188
+ const _ = R++, b = (O) => (O(c, 0), c.endVector()), B = o.createShellsVector(c, []), be = o.createCircleExtrusionsVector(c, []), W = b(o.startSamplesVector), K = b(o.startRepresentationsVector), Ve = b(o.startMaterialsVector), X = b(o.startLocalTransformsVector), k = b(o.startGlobalTransformsVector), M = o.createMeshesItemsVector(c, []), Q = o.createMaterialIdsVector(c, []), Ee = o.createRepresentationIdsVector(c, []), Te = o.createSampleIdsVector(c, []), _e = o.createLocalTransformIdsVector(c, []), He = o.createGlobalTransformIdsVector(c, []);
5189
+ o.startMeshes(c), o.addCoordinates(c, d.createTransform(c, 0, 0, 0, 1, 0, 0, 0, 1, 0)), o.addGlobalTransforms(c, k), o.addShells(c, B), o.addRepresentations(c, K), o.addSamples(c, W), o.addLocalTransforms(c, X), o.addMaterials(c, Ve), o.addCircleExtrusions(c, be), o.addMeshesItems(c, M), o.addRepresentationIds(c, Ee), o.addSampleIds(c, Te), o.addMaterialIds(c, Q), o.addLocalTransformIds(c, _e), o.addGlobalTransformIds(c, He);
5190
+ const Ge = o.endMeshes(c), Ie = c.createString(r), Je = /* @__PURE__ */ new Set(), Re = [];
5191
+ for (const O of this.changes) {
5192
+ const x = [], $e = {
5193
+ [Jr]: O.op,
5194
+ ...O.attrs
5090
5195
  };
5091
- for (const [j, J] of Object.entries(re)) {
5092
- const Q = JSON.stringify([j, J, "IFCTEXT"]);
5093
- Ue.add(Q), F.push(c.createString(Q));
5196
+ for (const [Se, ie] of Object.entries($e)) {
5197
+ const V = JSON.stringify([Se, ie, "IFCTEXT"]);
5198
+ Je.add(V), x.push(c.createString(V));
5094
5199
  }
5095
- Oe.push(
5096
- i.createAttribute(c, i.createDataVector(c, F))
5200
+ Re.push(
5201
+ i.createAttribute(c, i.createDataVector(c, x))
5097
5202
  );
5098
5203
  }
5099
5204
  {
5100
- const I = JSON.stringify(["Name", s, "IFCLABEL"]);
5101
- Ue.add(I);
5102
- const F = i.createDataVector(c, [c.createString(I)]);
5103
- Oe.push(i.createAttribute(c, F));
5205
+ const O = JSON.stringify(["Name", s, "IFCLABEL"]);
5206
+ Je.add(O);
5207
+ const x = i.createDataVector(c, [c.createString(O)]);
5208
+ Re.push(i.createAttribute(c, x));
5104
5209
  }
5105
- const st = a.createAttributesVector(c, Oe), nt = a.createUniqueAttributesVector(
5210
+ const ct = a.createAttributesVector(c, Re), ht = a.createUniqueAttributesVector(
5106
5211
  c,
5107
- [...Ue].map((I) => c.createString(I))
5108
- ), Me = this.changes.map(
5109
- () => c.createString(Is)
5212
+ [...Je].map((O) => c.createString(O))
5213
+ ), We = this.changes.map(
5214
+ () => c.createString(Fs)
5110
5215
  );
5111
- Me.push(c.createString(Ss));
5112
- const rt = a.createCategoriesVector(c, Me), Ve = [], He = [];
5113
- this.changes.forEach((I, F) => {
5114
- I.item && (Ve.push(c.createString(I.item)), He.push(T[F]));
5216
+ We.push(c.createString(Ps));
5217
+ const lt = a.createCategoriesVector(c, We), Ye = [], ze = [];
5218
+ this.changes.forEach((O, x) => {
5219
+ O.item && (Ye.push(c.createString(O.item)), ze.push(T[x]));
5115
5220
  });
5116
- const g = a.createGuidsVector(c, Ve), y = a.createGuidsItemsVector(c, He), k = a.createLocalIdsVector(c, [...T, _]), x = this.changes.map(
5117
- (I, F) => l.createSpatialStructure(
5221
+ const dt = a.createGuidsVector(c, Ye), m = a.createGuidsItemsVector(c, ze), w = a.createLocalIdsVector(c, [...T, _]), I = this.changes.map(
5222
+ (O, x) => l.createSpatialStructure(
5118
5223
  c,
5119
- T[F],
5120
- c.createString(Is),
5224
+ T[x],
5225
+ c.createString(Fs),
5121
5226
  0
5122
5227
  )
5123
- ), P = l.createSpatialStructure(
5228
+ ), A = l.createSpatialStructure(
5124
5229
  c,
5125
5230
  _,
5126
- c.createString(Ss),
5127
- l.createChildrenVector(c, x)
5128
- ), D = c.createString(s);
5129
- a.startModel(c), a.addMeshes(c, je), a.addMetadata(c, _e), a.addAttributes(c, st), a.addUniqueAttributes(c, nt), a.addLocalIds(c, k), a.addCategories(c, rt), a.addGuidsItems(c, y), a.addGuids(c, g), a.addGuid(c, D), a.addSpatialStructure(c, P), a.addMaxLocalId(c, A);
5130
- const le = a.endModel(c);
5131
- return a.finishModelBuffer(c, le), c.asUint8Array();
5231
+ c.createString(Ps),
5232
+ l.createChildrenVector(c, I)
5233
+ ), F = c.createString(s);
5234
+ a.startModel(c), a.addMeshes(c, Ge), a.addMetadata(c, Ie), a.addAttributes(c, ct), a.addUniqueAttributes(c, ht), a.addLocalIds(c, w), a.addCategories(c, lt), a.addGuidsItems(c, m), a.addGuids(c, dt), a.addGuid(c, F), a.addSpatialStructure(c, A), a.addMaxLocalId(c, R);
5235
+ const D = a.endModel(c);
5236
+ return a.finishModelBuffer(c, D), c.asUint8Array();
5132
5237
  }
5133
5238
  }
5134
- async function Br() {
5239
+ async function zr() {
5135
5240
  try {
5136
5241
  return await Promise.all([
5137
5242
  import("flatbuffers"),
@@ -5143,18 +5248,18 @@ async function Br() {
5143
5248
  );
5144
5249
  }
5145
5250
  }
5146
- function ks(n) {
5251
+ function Bs(n) {
5147
5252
  return Number.isFinite(n) ? String(n) : "0";
5148
5253
  }
5149
- async function Fr(n) {
5254
+ async function Kr(n) {
5150
5255
  const e = new Blob([n]).stream().pipeThrough(new CompressionStream("deflate"));
5151
5256
  return new Uint8Array(await new Response(e).arrayBuffer());
5152
5257
  }
5153
- const Lr = "Element", Dr = "Carried", rn = 1 / 0.3048;
5154
- function qr(n) {
5258
+ const Xr = "Element", Qr = "Carried", mn = 1 / 0.3048;
5259
+ function Zr(n) {
5155
5260
  const e = [];
5156
5261
  for (const t of n)
5157
- for (const s of [Lr, Dr]) {
5262
+ for (const s of [Xr, Qr]) {
5158
5263
  const r = t.attrs[s];
5159
5264
  if (r)
5160
5265
  try {
@@ -5173,7 +5278,7 @@ function qr(n) {
5173
5278
  }
5174
5279
  return e;
5175
5280
  }
5176
- function ht(n, e) {
5281
+ function yt(n, e) {
5177
5282
  const t = n.params[e];
5178
5283
  if (typeof t != "string") return null;
5179
5284
  try {
@@ -5182,7 +5287,7 @@ function ht(n, e) {
5182
5287
  return null;
5183
5288
  }
5184
5289
  }
5185
- function jr(n) {
5290
+ function ei(n) {
5186
5291
  const e = /* @__PURE__ */ new Map();
5187
5292
  for (const t of n) {
5188
5293
  if (t.kind !== "datum" || t.params.of !== "level") continue;
@@ -5191,7 +5296,7 @@ function jr(n) {
5191
5296
  }
5192
5297
  return e;
5193
5298
  }
5194
- function Ur(n) {
5299
+ function ti(n) {
5195
5300
  const e = /* @__PURE__ */ new Map();
5196
5301
  for (const t of n) {
5197
5302
  if (!t.kind.endsWith("Style")) continue;
@@ -5200,7 +5305,7 @@ function Ur(n) {
5200
5305
  }
5201
5306
  return e;
5202
5307
  }
5203
- async function on(n, e) {
5308
+ async function yn(n, e) {
5204
5309
  const t = /* @__PURE__ */ new Map(), s = (await n.targetDoc.suggestions()).filter(
5205
5310
  (r) => {
5206
5311
  var i;
@@ -5209,7 +5314,7 @@ async function on(n, e) {
5209
5314
  ).sort((r, i) => String(r.createdAt).localeCompare(String(i.createdAt)));
5210
5315
  for (const r of s)
5211
5316
  try {
5212
- const i = await n.targetDoc.suggestionPayload(r), { items: o } = await sn(
5317
+ const i = await n.targetDoc.suggestionPayload(r), { items: o } = await fn(
5213
5318
  new Uint8Array(await i.arrayBuffer())
5214
5319
  ), a = o.filter((d) => d.attrs["flow:op"]), l = r.affectedIds ?? [];
5215
5320
  for (let d = 0; d < a.length && d < l.length; d++) {
@@ -5220,31 +5325,47 @@ async function on(n, e) {
5220
5325
  }
5221
5326
  return t;
5222
5327
  }
5223
- async function an(n, e) {
5328
+ async function gn(n, e) {
5224
5329
  if (!(e != null && e.fileId)) throw new Error("Choose the model file to read.");
5225
5330
  const t = new Uint8Array(
5226
5331
  await (await n.client.downloadFile(e.fileId)).arrayBuffer()
5227
5332
  );
5228
- return { picked: e, contents: await sn(t) };
5333
+ return { picked: e, contents: await fn(t) };
5229
5334
  }
5230
- const Rt = {
5335
+ const xe = {
5231
5336
  levels: "-2000240",
5232
5337
  walls: "-2000011",
5233
- floors: "-2000032"
5234
- }, Os = 180 / Math.PI;
5235
- function As(n) {
5338
+ floors: "-2000032",
5339
+ roofs: "-2000035",
5340
+ ceilings: "-2000038",
5341
+ structuralFoundations: "-2001300"
5342
+ };
5343
+ function as(n) {
5344
+ const e = n.item.attrs.Name;
5345
+ if (typeof e != "string") return null;
5346
+ const t = e.indexOf(":"), s = e.lastIndexOf(":");
5347
+ if (t <= 0 || s <= t) return null;
5348
+ const r = e.slice(t + 1, s).trim();
5349
+ return r ? { family: e.slice(0, t).trim(), type: r } : null;
5350
+ }
5351
+ function si(n) {
5352
+ const e = as(n), t = n.item.attrs.PredefinedType;
5353
+ return e ? /escalera|stair|landing|descansillo/i.test(e.family) || t === "LANDING" || /plataforma|^pad\b|building pad/i.test(e.family) ? "other" : /cubierta|roof/i.test(e.family) || t === "ROOF" ? "roof" : /cimentaci|foundation/i.test(e.family) || t === "BASESLAB" ? "foundation" : "floor" : "floor";
5354
+ }
5355
+ const Ls = 180 / Math.PI;
5356
+ function Ds(n) {
5236
5357
  if (typeof n != "string") return null;
5237
5358
  const e = n.indexOf(":");
5238
5359
  return e <= 0 || e === n.length - 1 ? null : { family: n.slice(0, e), type: n.slice(e + 1) };
5239
5360
  }
5240
- const U = (n) => String(n);
5241
- function cn(n) {
5361
+ const j = (n) => String(n);
5362
+ function wn(n) {
5242
5363
  return async (e) => {
5243
- var Oe, st, nt, Me, rt, Ve, He;
5244
- const { picked: t, contents: s } = await an(
5364
+ var Re, ct, ht, We, lt, Ye, ze, dt;
5365
+ const { picked: t, contents: s } = await gn(
5245
5366
  e,
5246
5367
  e.input
5247
- ), r = qr(s.items);
5368
+ ), r = Zr(s.items);
5248
5369
  if (r.length === 0)
5249
5370
  throw new Error(
5250
5371
  n === "ifc" ? `"${t.name}" carries no platform records: it was imported without the editable converter. Process the IFC with the editable converter first; a plain import only has IFC attributes, and guessing geometry is not this recipe.` : `"${t.name}" carries no platform records, so there is nothing semantic to convert.`
@@ -5254,158 +5375,169 @@ function cn(n) {
5254
5375
  throw new Error(
5255
5376
  "Free-standing instances can only be proposed by their style names: turn trustStyleNames on."
5256
5377
  );
5257
- const d = jr(r), c = Ur(r), m = `recipe:${n}-to-revit`, T = await on(e, m), A = await e.targetDoc.latest(), _ = new nn({
5378
+ const d = ei(r), c = ti(r), y = `recipe:${n}-to-revit`, T = await yn(e, y), R = await e.targetDoc.latest(), _ = new pn({
5258
5379
  project: e.projectId,
5259
5380
  document: e.targetDoc.docId,
5260
- baseCommit: (A == null ? void 0 : A.version) ?? 0,
5261
- author: m
5262
- }), v = rn, N = (g) => `${t.fileId}:${g}`, be = /* @__PURE__ */ new Set();
5263
- let G = 0;
5264
- const z = (g, y, k) => (be.add(g), T.has(g) ? (G++, !1) : (_.add(y, { ...k, source: g }), !0)), De = (g) => {
5265
- const y = typeof g == "string" ? c.get(g) : void 0, k = y == null ? void 0 : y.params.thickness;
5266
- return typeof k == "number" && k > 0 ? k * v : void 0;
5381
+ baseCommit: (R == null ? void 0 : R.version) ?? 0,
5382
+ author: y
5383
+ }), b = mn, B = (m) => `${t.fileId}:${m}`, be = /* @__PURE__ */ new Set();
5384
+ let W = 0;
5385
+ const K = (m, w, I) => (be.add(m), T.has(m) ? (W++, !1) : (_.add(w, { ...I, source: m }), !0)), Ve = (m) => {
5386
+ const w = typeof m == "string" ? c.get(m) : void 0, I = w == null ? void 0 : w.params.thickness;
5387
+ return typeof I == "number" && I > 0 ? I * b : void 0;
5267
5388
  };
5268
- let K = 0;
5389
+ let X = 0;
5269
5390
  if (l)
5270
- for (const [g, y] of d)
5271
- z(N(g), {
5272
- CategoryId: Rt.levels,
5273
- Name: y.name,
5274
- Elevation: U(y.at * v)
5275
- }), K++;
5276
- let O = 0, q = 0;
5277
- for (const g of r) {
5278
- if (g.kind !== "run" || g.params.of !== "wall") continue;
5279
- const y = ht(g, "run"), k = ((st = (Oe = y == null ? void 0 : y.run) == null ? void 0 : Oe.line) == null ? void 0 : st.curves) ?? [], x = typeof (y == null ? void 0 : y.base) == "number" ? y.base : 0, P = y == null ? void 0 : y.height, D = d.get(String((y == null ? void 0 : y.level) ?? g.params.level ?? "")), le = g.params.lookRef;
5280
- if (typeof le != "string" || typeof P != "number" || !D) {
5281
- q++;
5391
+ for (const [m, w] of d)
5392
+ K(B(m), {
5393
+ CategoryId: xe.levels,
5394
+ Name: w.name,
5395
+ Elevation: j(w.at * b)
5396
+ }), X++;
5397
+ let k = 0, M = 0;
5398
+ for (const m of r) {
5399
+ if (m.kind !== "run" || m.params.of !== "wall") continue;
5400
+ const w = yt(m, "run"), I = ((ct = (Re = w == null ? void 0 : w.run) == null ? void 0 : Re.line) == null ? void 0 : ct.curves) ?? [], A = typeof (w == null ? void 0 : w.base) == "number" ? w.base : 0, F = w == null ? void 0 : w.height, D = d.get(String((w == null ? void 0 : w.level) ?? m.params.level ?? "")), O = m.params.lookRef;
5401
+ if (typeof O != "string" || typeof F != "number" || !D) {
5402
+ M++;
5282
5403
  continue;
5283
5404
  }
5284
- k.forEach((I, F) => {
5285
- if (I.kind !== "segment" || !I.from || !I.to) {
5286
- q++;
5405
+ I.forEach((x, $e) => {
5406
+ var Ae;
5407
+ if (x.kind !== "segment" || !x.from || !x.to) {
5408
+ M++;
5287
5409
  return;
5288
5410
  }
5289
- const re = (D.at + x) * v, j = `${U(I.from[0] * v)},${U(I.from[1] * v)},${U(re)};${U(I.to[0] * v)},${U(I.to[1] * v)},${U(re)}`, J = {
5290
- CategoryId: Rt.walls,
5291
- Type: le,
5292
- LocationLine: j,
5411
+ const Se = (D.at + A) * b, ie = `${j(x.from[0] * b)},${j(x.from[1] * b)},${j(Se)};${j(x.to[0] * b)},${j(x.to[1] * b)},${j(Se)}`, V = {
5412
+ CategoryId: xe.walls,
5413
+ Type: ((Ae = as(m)) == null ? void 0 : Ae.type) ?? O,
5414
+ LocationLine: ie,
5293
5415
  Level: D.name,
5294
- BaseOffset: U(x * v),
5295
- Height: U(P * v)
5296
- }, Q = De(le);
5297
- Q && (J["Type.Width"] = U(Q)), z(`${N(g.id)}#${F}`, J) && O++;
5416
+ BaseOffset: j(A * b),
5417
+ Height: j(F * b)
5418
+ }, P = d.get(String(m.params.topLevel ?? ""));
5419
+ P && (V.TopLevel = P.name, V.TopOffset = j((D.at + A + F - P.at) * b));
5420
+ const q = Ve(O);
5421
+ q && (V["Type.Width"] = j(q)), K(`${B(m.id)}#${$e}`, V) && k++;
5298
5422
  });
5299
5423
  }
5300
- let X = 0, ve = 0;
5301
- for (const g of r) {
5302
- if (g.kind !== "extrusion" || g.params.of !== "slab") continue;
5303
- const y = ht(g, "extrusion"), k = typeof g.params.base == "number" ? g.params.base : 0, x = d.get(String((y == null ? void 0 : y.level) ?? g.params.level ?? "")), P = g.params.lookRef, D = (j) => {
5304
- if (!(j != null && j.length)) return null;
5305
- const J = [];
5306
- for (const Q of j) {
5307
- if (Q.kind !== "segment" || !Q.from) return null;
5308
- J.push(Q.from[0] * v, Q.from[1] * v, k * v);
5424
+ let Q = 0, Ee = 0;
5425
+ for (const m of r) {
5426
+ const w = m.params.of;
5427
+ if (m.kind !== "extrusion" || w !== "slab" && w !== "roof" && w !== "covering") continue;
5428
+ const I = w === "covering" ? "ceiling" : w === "roof" ? "roof" : si(m);
5429
+ if (I === "other") continue;
5430
+ const A = yt(m, "extrusion"), F = typeof m.params.base == "number" ? m.params.base : 0, D = d.get(String((A == null ? void 0 : A.level) ?? m.params.level ?? "")), O = m.params.lookRef, x = (P) => {
5431
+ if (!(P != null && P.length)) return null;
5432
+ const q = [];
5433
+ for (const Ae of P) {
5434
+ if (Ae.kind !== "segment" || !Ae.from) return null;
5435
+ q.push(Ae.from[0] * b, Ae.from[1] * b, F * b);
5309
5436
  }
5310
- return J.length >= 9 ? J : null;
5311
- }, le = D((Me = (nt = y == null ? void 0 : y.profile) == null ? void 0 : nt.outline) == null ? void 0 : Me.curves);
5312
- if (typeof P != "string" || !x || !le) {
5313
- ve++;
5437
+ return q.length >= 9 ? q : null;
5438
+ }, $e = x((We = (ht = A == null ? void 0 : A.profile) == null ? void 0 : ht.outline) == null ? void 0 : We.curves);
5439
+ if (typeof O != "string" || !D || !$e) {
5440
+ Ee++;
5314
5441
  continue;
5315
5442
  }
5316
- const I = [le];
5317
- for (const j of ((rt = y == null ? void 0 : y.profile) == null ? void 0 : rt.holes) ?? []) {
5318
- const J = D(j == null ? void 0 : j.curves);
5319
- J && I.push(J);
5443
+ const Se = [$e];
5444
+ for (const P of ((lt = A == null ? void 0 : A.profile) == null ? void 0 : lt.holes) ?? []) {
5445
+ const q = x(P == null ? void 0 : P.curves);
5446
+ q && Se.push(q);
5320
5447
  }
5321
- const F = {
5322
- CategoryId: Rt.floors,
5323
- Type: P,
5324
- Profile: JSON.stringify(I),
5325
- Level: x.name
5326
- }, re = De(P);
5327
- re && (F["Type.Width"] = U(re)), re && (F.HeightOffset = U(k * v + re)), z(N(g.id), F) && X++;
5448
+ const ie = {
5449
+ CategoryId: I === "roof" ? xe.roofs : I === "ceiling" ? xe.ceilings : I === "foundation" ? xe.structuralFoundations : xe.floors,
5450
+ Type: ((Ye = as(m)) == null ? void 0 : Ye.type) ?? O,
5451
+ Profile: JSON.stringify(Se),
5452
+ Level: D.name
5453
+ }, V = Ve(O);
5454
+ if (V && (ie["Type.Width"] = j(V)), I === "roof" || I === "ceiling") {
5455
+ ie.BaseOffset = j(F * b);
5456
+ const P = A == null ? void 0 : A.slopes;
5457
+ I === "roof" && Array.isArray(P) && P.some((q) => typeof q == "number") && (ie.Slopes = JSON.stringify(P.map((q) => typeof q == "number" ? q : null)));
5458
+ } else V && (ie.HeightOffset = j(F * b + V));
5459
+ K(B(m.id), ie) && Q++;
5328
5460
  }
5329
- let Ee = 0;
5330
- for (const g of r) {
5331
- if (g.kind !== "member" || g.params.of !== "column") continue;
5332
- const y = ht(g, "member"), k = y == null ? void 0 : y.start;
5333
- if (!k || k.length !== 3) continue;
5334
- const x = o ? As(g.params.lookRef) : null;
5335
- if (o && !x || !x && !i) continue;
5336
- const P = x ?? {
5461
+ let Te = 0;
5462
+ for (const m of r) {
5463
+ if (m.kind !== "member" || m.params.of !== "column") continue;
5464
+ const w = yt(m, "member"), I = w == null ? void 0 : w.start;
5465
+ if (!I || I.length !== 3) continue;
5466
+ const A = o ? Ds(m.params.lookRef) : null;
5467
+ if (o && !A || !A && !i) continue;
5468
+ const F = A ?? {
5337
5469
  family: i.family,
5338
5470
  type: i.type
5339
- }, D = d.get(String((y == null ? void 0 : y.level) ?? ""));
5340
- z(
5341
- N(g.id),
5471
+ }, D = d.get(String((w == null ? void 0 : w.level) ?? ""));
5472
+ K(
5473
+ B(m.id),
5342
5474
  {
5343
- ...i && !x ? { CategoryId: i.categoryId } : {},
5344
- Family: P.family,
5345
- Type: P.type,
5475
+ ...i && !A ? { CategoryId: i.categoryId } : {},
5476
+ Family: F.family,
5477
+ Type: F.type,
5346
5478
  ...D ? { Level: D.name } : {}
5347
5479
  },
5348
5480
  {
5349
- position: [k[0] * v, k[1] * v, k[2] * v],
5350
- rotationDeg: (Number((y == null ? void 0 : y.roll) ?? 0) || 0) * Os
5481
+ position: [I[0] * b, I[1] * b, I[2] * b],
5482
+ rotationDeg: (Number((w == null ? void 0 : w.roll) ?? 0) || 0) * Ls
5351
5483
  }
5352
- ) && Ee++;
5484
+ ) && Te++;
5353
5485
  }
5354
- let Te = 0, qe = 0;
5355
- for (const g of r) {
5356
- if (g.kind !== "familyInstance") continue;
5357
- if (g.params.host) {
5358
- qe++;
5486
+ let _e = 0, He = 0;
5487
+ for (const m of r) {
5488
+ if (m.kind !== "familyInstance") continue;
5489
+ if (m.params.host) {
5490
+ He++;
5359
5491
  continue;
5360
5492
  }
5361
5493
  if (!a) continue;
5362
- const y = ht(g, "instance"), k = (Ve = y == null ? void 0 : y.placement) == null ? void 0 : Ve.at;
5363
- if (!k || k.length !== 3) continue;
5364
- const x = As(g.params.type);
5365
- if (!x) continue;
5366
- const P = (He = y == null ? void 0 : y.placement) == null ? void 0 : He.right, D = P ? Math.atan2(P[1], P[0]) * Os : 0;
5367
- z(
5368
- N(g.id),
5369
- { Family: x.family, Type: x.type },
5370
- { position: [k[0] * v, k[1] * v, k[2] * v], rotationDeg: D }
5371
- ) && Te++;
5494
+ const w = yt(m, "instance"), I = (ze = w == null ? void 0 : w.placement) == null ? void 0 : ze.at;
5495
+ if (!I || I.length !== 3) continue;
5496
+ const A = Ds(m.params.type);
5497
+ if (!A) continue;
5498
+ const F = (dt = w == null ? void 0 : w.placement) == null ? void 0 : dt.right, D = F ? Math.atan2(F[1], F[0]) * Ls : 0;
5499
+ K(
5500
+ B(m.id),
5501
+ { Family: A.family, Type: A.type },
5502
+ { position: [I[0] * b, I[1] * b, I[2] * b], rotationDeg: D }
5503
+ ) && _e++;
5372
5504
  }
5373
- let je = 0;
5374
- for (const g of r)
5375
- (g.kind === "stair" || g.kind === "footing" || g.kind === "ramp" || g.kind === "extrusion" && g.params.of !== "slab" || g.kind === "run" && g.params.of !== "wall") && je++;
5376
- let _e = 0;
5377
- for (const [g, y] of T)
5378
- !g.startsWith(`${t.fileId}:`) || be.has(g) || (_.remove(y), _e++);
5505
+ let Ge = 0;
5506
+ for (const m of r)
5507
+ (m.kind === "stair" || m.kind === "footing" || m.kind === "ramp" || m.kind === "extrusion" && m.params.of !== "slab" || m.kind === "run" && m.params.of !== "wall") && Ge++;
5508
+ let Ie = 0;
5509
+ for (const [m, w] of T)
5510
+ !m.startsWith(`${t.fileId}:`) || be.has(m) || (_.remove(w), Ie++);
5379
5511
  if (_.length === 0)
5380
5512
  throw new Error(
5381
- `Nothing new to ask for: "${t.name}" holds ${G} element(s) this recipe already made, ${qe + je} waiting on the applier, and nothing is left to remove.`
5513
+ `Nothing new to ask for: "${t.name}" holds ${W} element(s) this recipe already made, ${He + Ge} waiting on the applier, and nothing is left to remove.`
5382
5514
  );
5383
- const Ue = [
5384
- K ? `${K} level(s)` : "",
5385
- O ? `${O} wall(s)` : "",
5386
- X ? `${X} floor(s)` : "",
5387
- Ee ? `${Ee} column(s)` : "",
5388
- Te ? `${Te} instance(s)` : "",
5389
- _e ? `${_e} gone` : ""
5515
+ const Je = [
5516
+ X ? `${X} level(s)` : "",
5517
+ k ? `${k} wall(s)` : "",
5518
+ Q ? `${Q} floor(s)` : "",
5519
+ Te ? `${Te} column(s)` : "",
5520
+ _e ? `${_e} instance(s)` : "",
5521
+ Ie ? `${Ie} gone` : ""
5390
5522
  ].filter(Boolean);
5391
5523
  return {
5392
- title: `${n === "ifc" ? "IFC" : "Model"} to Revit: ${Ue.join(", ")}`,
5524
+ title: `${n === "ifc" ? "IFC" : "Model"} to Revit: ${Je.join(", ")}`,
5393
5525
  verb: _.summary,
5394
5526
  targets: _.length,
5395
5527
  payload: new Blob([await _.build(e.opId)]),
5396
5528
  ruleTallies: [
5397
- { read: d.size, proposed: K },
5398
- { read: O + q, proposed: O },
5399
- { read: X + ve, proposed: X },
5400
- { read: Ee, proposed: Ee },
5529
+ { read: d.size, proposed: X },
5530
+ { read: k + M, proposed: k },
5531
+ { read: Q + Ee, proposed: Q },
5401
5532
  { read: Te, proposed: Te },
5402
5533
  { read: _e, proposed: _e },
5403
- { read: qe + je, proposed: 0 }
5534
+ { read: Ie, proposed: Ie },
5535
+ { read: He + Ge, proposed: 0 }
5404
5536
  ]
5405
5537
  };
5406
5538
  };
5407
5539
  }
5408
- const Mr = {
5540
+ const ni = {
5409
5541
  type: "object",
5410
5542
  properties: {
5411
5543
  columnType: {
@@ -5435,7 +5567,7 @@ const Mr = {
5435
5567
  default: !0
5436
5568
  }
5437
5569
  }
5438
- }, Vr = [
5570
+ }, ri = [
5439
5571
  { reads: "Levels (datums)", proposes: "The same level on the target, ensured by name" },
5440
5572
  { reads: "Wall runs, one per straight segment", proposes: "A native wall: curve, type (made from its width when missing), level, height" },
5441
5573
  { reads: "Slabs with their boundary", proposes: "A native floor from the profile, holes included" },
@@ -5443,7 +5575,7 @@ const Mr = {
5443
5575
  { reads: "Free-standing family instances (when turned on)", proposes: "A new instance of the same-named type, placed and turned" },
5444
5576
  { reads: "Things this recipe made whose record is gone", proposes: "That element removed" },
5445
5577
  { reads: "Hosted doors/windows, stairs, roofs, footings, curtain pieces", proposes: "Nothing yet - each waits on the applier or the converter growing" }
5446
- ], hn = `
5578
+ ], vn = `
5447
5579
  ## What it does
5448
5580
 
5449
5581
  It reads the platform's records out of a .frag and asks a Revit document for
@@ -5482,7 +5614,7 @@ Records are metres and radians, Z up; proposals are written in Revit's feet
5482
5614
  and degrees. Types are matched exactly by name; Revit refuses the whole
5483
5615
  request when a loadable type is missing (system types are created from their
5484
5616
  width instead).
5485
- `, ln = {
5617
+ `, bn = {
5486
5618
  name: "frag-to-revit",
5487
5619
  title: "Platform model to Revit",
5488
5620
  description: "Turns the platform records of a .frag - levels, walls, floors, columns, instances - into change requests for a Revit document.",
@@ -5490,12 +5622,12 @@ width instead).
5490
5622
  inputs: ["frag-model"],
5491
5623
  source: { kind: "project-file", extensions: ["frag"] },
5492
5624
  runtime: "browser",
5493
- settingsSchema: Mr,
5494
- rules: Vr,
5495
- doc: hn,
5496
- run: cn("frag")
5497
- }, Hr = {
5498
- ...ln,
5625
+ settingsSchema: ni,
5626
+ rules: ri,
5627
+ doc: vn,
5628
+ run: wn("frag")
5629
+ }, ii = {
5630
+ ...bn,
5499
5631
  name: "ifc-to-revit",
5500
5632
  title: "IFC to Revit",
5501
5633
  description: "Turns an IFC - through the frag the platform converted it into - into native Revit change requests: levels, walls, floors, columns, instances.",
@@ -5506,9 +5638,9 @@ width instead).
5506
5638
  It reads the .frag your IFC was PROCESSED into (the IFC document's view). A
5507
5639
  plain IFC import carries only IFC attributes and is refused by name - the
5508
5640
  editable converter is what gives an IFC real records.
5509
- ` + hn,
5510
- run: cn("ifc")
5511
- }, Gr = {
5641
+ ` + vn,
5642
+ run: wn("ifc")
5643
+ }, oi = {
5512
5644
  millimeters: 1e-3,
5513
5645
  millimetres: 1e-3,
5514
5646
  mm: 1e-3,
@@ -5522,13 +5654,13 @@ editable converter is what gives an IFC real records.
5522
5654
  in: 0.0254,
5523
5655
  feet: 0.3048,
5524
5656
  ft: 0.3048
5525
- }, dn = "rhino-to-revit", Rs = `recipe:${dn}`;
5526
- function Jr(n) {
5657
+ }, En = "rhino-to-revit", qs = `recipe:${En}`;
5658
+ function ai(n) {
5527
5659
  const e = (n.attrs.Position ?? "").split(",").map((t) => Number(t.trim()));
5528
5660
  return e.length !== 3 || e.some((t) => !Number.isFinite(t)) ? null : [e[0], e[1], e[2]];
5529
5661
  }
5530
- const Wr = {
5531
- name: dn,
5662
+ const ci = {
5663
+ name: En,
5532
5664
  title: "Rhino to Revit",
5533
5665
  description: "Turns the placed objects of a Rhino layer into change requests for Revit instances of a chosen type.",
5534
5666
  to: "revit",
@@ -5597,14 +5729,14 @@ at or below the point. For a level-based family the level wins over the
5597
5729
  point's height.
5598
5730
  `,
5599
5731
  async run(n) {
5600
- var K;
5601
- const { picked: e, contents: t } = await an(
5732
+ var X;
5733
+ const { picked: e, contents: t } = await gn(
5602
5734
  n,
5603
5735
  n.input
5604
5736
  ), { layer: s, instanceType: r } = n.settings;
5605
5737
  if (!s || !r)
5606
5738
  throw new Error("Choose the layer and the Revit type.");
5607
- const i = (K = t.metadata) == null ? void 0 : K.data, o = i == null ? void 0 : i.units, a = typeof o == "string" ? Gr[o.trim().toLowerCase()] : void 0;
5739
+ const i = (X = t.metadata) == null ? void 0 : X.data, o = i == null ? void 0 : i.units, a = typeof o == "string" ? oi[o.trim().toLowerCase()] : void 0;
5608
5740
  if (!a)
5609
5741
  throw new Error(
5610
5742
  `"${e.name}" does not say what units its data is in${o ? ` ("${String(o)}" is not one this recipe knows)` : ""}, so nothing can be converted from it.`
@@ -5614,114 +5746,115 @@ point's height.
5614
5746
  throw new Error(
5615
5747
  `"${e.name}" declares its data as "${l}"; this recipe only converts Z up.`
5616
5748
  );
5617
- const d = a * rn, c = await on(n, Rs), m = await n.targetDoc.latest(), T = new nn({
5749
+ const d = a * mn, c = await yn(n, qs), y = await n.targetDoc.latest(), T = new pn({
5618
5750
  project: n.projectId,
5619
5751
  document: n.targetDoc.docId,
5620
- baseCommit: (m == null ? void 0 : m.version) ?? 0,
5621
- author: Rs
5752
+ baseCommit: (y == null ? void 0 : y.version) ?? 0,
5753
+ author: qs
5622
5754
  });
5623
- let A = 0, _ = 0, v = 0;
5624
- const N = /* @__PURE__ */ new Set(), be = [];
5625
- for (const O of t.items) {
5626
- if (!O.guid || Object.keys(O.attrs).length === 0) continue;
5627
- if ((O.attrs.Layer ?? "") !== s) {
5628
- v++;
5755
+ let R = 0, _ = 0, b = 0;
5756
+ const B = /* @__PURE__ */ new Set(), be = [];
5757
+ for (const k of t.items) {
5758
+ if (!k.guid || Object.keys(k.attrs).length === 0) continue;
5759
+ if ((k.attrs.Layer ?? "") !== s) {
5760
+ b++;
5629
5761
  continue;
5630
5762
  }
5631
- const q = Jr(O);
5632
- if (!q) continue;
5633
- N.add(O.guid);
5634
- const X = [
5635
- q[0] * d,
5636
- q[1] * d,
5637
- q[2] * d
5638
- ], ve = c.get(O.guid);
5639
- ve ? be.push({ instance: ve, object: O.guid, position: X }) : (T.add(
5763
+ const M = ai(k);
5764
+ if (!M) continue;
5765
+ B.add(k.guid);
5766
+ const Q = [
5767
+ M[0] * d,
5768
+ M[1] * d,
5769
+ M[2] * d
5770
+ ], Ee = c.get(k.guid);
5771
+ Ee ? be.push({ instance: Ee, object: k.guid, position: Q }) : (T.add(
5640
5772
  {
5641
5773
  CategoryId: r.categoryId,
5642
5774
  Family: r.family,
5643
5775
  Type: r.type
5644
5776
  },
5645
- { position: X, source: O.guid }
5646
- ), A++);
5777
+ { position: Q, source: k.guid }
5778
+ ), R++);
5647
5779
  }
5648
- for (const O of be)
5649
- T.set(O.instance, {}, { position: O.position, source: O.object }), _++;
5650
- let G = 0;
5651
- for (const [O, q] of c)
5652
- N.has(O) || (T.remove(q), G++);
5653
- const z = A + _ + G;
5654
- if (z === 0)
5780
+ for (const k of be)
5781
+ T.set(k.instance, {}, { position: k.position, source: k.object }), _++;
5782
+ let W = 0;
5783
+ for (const [k, M] of c)
5784
+ B.has(k) || (T.remove(M), W++);
5785
+ const K = R + _ + W;
5786
+ if (K === 0)
5655
5787
  throw new Error(
5656
5788
  `Nothing to ask for: layer "${s}" of "${e.name}" has no placed object, and nothing of this recipe is left to remove.`
5657
5789
  );
5658
5790
  return {
5659
5791
  title: `From Rhino: ${[
5660
- A ? `${A} new` : "",
5792
+ R ? `${R} new` : "",
5661
5793
  _ ? `${_} moved` : "",
5662
- G ? `${G} gone` : ""
5794
+ W ? `${W} gone` : ""
5663
5795
  ].filter(Boolean).join(", ")}`,
5664
5796
  verb: T.summary,
5665
- targets: z,
5797
+ targets: K,
5666
5798
  payload: new Blob([await T.build(n.opId)]),
5667
5799
  ruleTallies: [
5668
- { read: A, proposed: A },
5800
+ { read: R, proposed: R },
5669
5801
  { read: _, proposed: _ },
5670
- { read: G, proposed: G },
5671
- { read: v, proposed: 0 }
5802
+ { read: W, proposed: W },
5803
+ { read: b, proposed: 0 }
5672
5804
  ]
5673
5805
  };
5674
5806
  }
5675
- }, Yr = [
5676
- Wr,
5677
- Hr,
5678
- ln
5807
+ }, hi = [
5808
+ ci,
5809
+ ii,
5810
+ bn
5679
5811
  ];
5680
- function Xr(n) {
5681
- for (const e of Yr) n.recipes.register(e);
5812
+ function ui(n) {
5813
+ for (const e of hi) n.recipes.register(e);
5682
5814
  }
5683
- const Qr = {
5815
+ const fi = {
5684
5816
  MAX_FIELDS: 200,
5685
5817
  MAX_KEY_LENGTH: 50,
5686
5818
  MAX_VALUE_LENGTH: 50
5687
- }, Zr = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, ei = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, ti = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, si = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, ni = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, ri = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, ii = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, oi = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, ai = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
5819
+ }, pi = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, mi = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, yi = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, gi = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, wi = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, vi = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, bi = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, Ei = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Ti = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
5688
5820
  export {
5689
- Zr as CDEManager,
5690
- Ar as ChannelClient,
5691
- Xs as ChannelRoom,
5692
- ei as ClashesManager,
5693
- Sr as CollabRoom,
5694
- fs as DOCUMENT_FILE,
5695
- bt as DOCUMENT_SCHEMA,
5696
- Ht as EngineServicesClient,
5697
- kr as ExternalRoom,
5698
- ti as FileList,
5699
- dr as FlowDoc,
5700
- si as GISManager,
5701
- ni as GitHistoryManager,
5702
- ri as HelloWorld,
5703
- Qr as METADATA_LIMITS,
5704
- Pr as OP_SCHEMA,
5705
- nn as OperationBuilder,
5706
- _s as PlatformClient,
5707
- Vs as ProjectDocuments,
5708
- lr as ProjectHistory,
5709
- ii as ProjectManager,
5710
- fr as Recipes,
5711
- rs as RequestError,
5712
- ar as SELF_VIEWING_FORMATS,
5713
- Es as STORAGE_BATCH_MAX,
5714
- ys as StaleHistoryError,
5715
- oi as TopicsManager,
5716
- ai as UIManager,
5717
- Yr as builtinRecipes,
5718
- ln as fragToRevit,
5719
- Hr as ifcToRevit,
5720
- Mt as mintGuid,
5721
- zs as orderByGraph,
5722
- sn as readFrag,
5723
- Xr as registerBuiltinRecipes,
5724
- Wr as rhinoToRevit,
5725
- _r as windowTransport
5821
+ pi as CDEManager,
5822
+ Mr as ChannelClient,
5823
+ cn as ChannelRoom,
5824
+ mi as ClashesManager,
5825
+ qr as CollabRoom,
5826
+ Ts as DOCUMENT_FILE,
5827
+ Ot as DOCUMENT_SCHEMA,
5828
+ wr as DocumentDrafts,
5829
+ Qt as EngineServicesClient,
5830
+ jr as ExternalRoom,
5831
+ yi as FileList,
5832
+ Sr as FlowDoc,
5833
+ gi as GISManager,
5834
+ wi as GitHistoryManager,
5835
+ vi as HelloWorld,
5836
+ fi as METADATA_LIMITS,
5837
+ Yr as OP_SCHEMA,
5838
+ pn as OperationBuilder,
5839
+ Ns as PlatformClient,
5840
+ Zs as ProjectDocuments,
5841
+ Ir as ProjectHistory,
5842
+ bi as ProjectManager,
5843
+ Or as Recipes,
5844
+ fs as RequestError,
5845
+ gr as SELF_VIEWING_FORMATS,
5846
+ Cs as STORAGE_BATCH_MAX,
5847
+ As as StaleHistoryError,
5848
+ Ei as TopicsManager,
5849
+ Ti as UIManager,
5850
+ hi as builtinRecipes,
5851
+ bn as fragToRevit,
5852
+ ii as ifcToRevit,
5853
+ Kt as mintGuid,
5854
+ on as orderByGraph,
5855
+ fn as readFrag,
5856
+ ui as registerBuiltinRecipes,
5857
+ ci as rhinoToRevit,
5858
+ Lr as windowTransport
5726
5859
  };
5727
5860
  //# sourceMappingURL=index.es.js.map