@thatopen/services 0.3.4 → 0.3.6

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/cli.js CHANGED
@@ -7740,6 +7740,30 @@ return main;`);
7740
7740
  `${ITEM_PATH}/${HIDDEN_PATH}/${hiddenId}/download`
7741
7741
  );
7742
7742
  }
7743
+ /**
7744
+ * Mints a short-lived presigned URL for a hidden file so the browser can
7745
+ * stream it directly from storage with native HTTP `Range` requests (e.g. a
7746
+ * point-cloud `octree.bin`), instead of proxying the whole object through the
7747
+ * API. Re-call to re-mint when the URL nears/passes `expiresAt`; coalesce
7748
+ * concurrent re-mints into a single in-flight call.
7749
+ *
7750
+ * The storage bucket's CORS must allow the `Range` request header and expose
7751
+ * `Content-Range`, `Accept-Ranges` and `Content-Length` for the ranged fetch
7752
+ * to succeed cross-origin.
7753
+ *
7754
+ * @param hiddenId - The hidden file's unique identifier.
7755
+ * @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
7756
+ * 900 (15 min) server-side; values are clamped to that range.
7757
+ * @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
7758
+ * an ISO timestamp when it stops working.
7759
+ */
7760
+ async getHiddenFileSignedUrl(hiddenId, expiresIn) {
7761
+ return await this.#requestApi(
7762
+ "GET",
7763
+ `${ITEM_PATH}/${HIDDEN_PATH}/${hiddenId}/signed-url`,
7764
+ { ...expiresIn != null && { query: { expiresIn } } }
7765
+ );
7766
+ }
7743
7767
  /**
7744
7768
  * Lists all hidden files attached to a parent item.
7745
7769
  * @param parentFileId - The parent item's unique identifier.
@@ -10886,6 +10910,36 @@ const serveCommand = new Command2("serve").description(
10886
10910
  ".webp": "dataurl"
10887
10911
  },
10888
10912
  plugins: [
10913
+ {
10914
+ // Some three.js example loaders (e.g. TTFLoader) import their deps from
10915
+ // a jsdelivr `/+esm` CDN URL. esbuild can't put a URL import in an IIFE
10916
+ // — it degrades to a runtime `require("https://…")` that throws — so
10917
+ // rewrite any such URL back to the bare package name and resolve it
10918
+ // from the project's node_modules.
10919
+ name: "cdn-esm-to-local",
10920
+ setup(build) {
10921
+ const CDN_ESM = /^https:\/\/cdn\.jsdelivr\.net\/npm\/((?:@[^/]+\/)?[^@/]+)(?:@[^/]+)?\/\+esm$/;
10922
+ build.onResolve(
10923
+ { filter: /^https:\/\/cdn\.jsdelivr\.net\/npm\// },
10924
+ async (args) => {
10925
+ const match = args.path.match(CDN_ESM);
10926
+ if (!match) return null;
10927
+ const resolved = await build.resolve(match[1], {
10928
+ kind: args.kind,
10929
+ resolveDir: args.resolveDir
10930
+ });
10931
+ if (resolved.errors.length > 0) {
10932
+ return { errors: resolved.errors };
10933
+ }
10934
+ return {
10935
+ path: resolved.path,
10936
+ external: resolved.external,
10937
+ sideEffects: resolved.sideEffects
10938
+ };
10939
+ }
10940
+ );
10941
+ }
10942
+ },
10889
10943
  {
10890
10944
  name: "reload",
10891
10945
  setup(build) {
@@ -10981,9 +11035,15 @@ function buildEngineScript(bundleCode, accessToken, apiUrl, executionParams) {
10981
11035
  return `/* eslint-disable */
10982
11036
  const { EngineServicesClient } = require('@thatopen/services');
10983
11037
 
10984
- const OBC = require('@thatopen/components');
10985
- const THREE = require('three');
10986
- let WEBIFC; try { WEBIFC = require('web-ifc'); } catch {}
11038
+ // Engine globals are BEST-EFFORT: a cloud component that doesn't touch the 3D
11039
+ // engine (e.g. one that only uses thatOpenServices) must still run. Each is
11040
+ // optional, and @thatopen/components also resolves the beta package — under
11041
+ // --beta the dep is installed as @thatopen-platform/components-beta, so a hard
11042
+ // require('@thatopen/components') would throw before main() runs.
11043
+ const tryRequire = (...names) => { for (const n of names) { try { return require(n); } catch {} } return undefined; };
11044
+ const OBC = tryRequire('@thatopen/components', '@thatopen-platform/components-beta');
11045
+ const THREE = tryRequire('three');
11046
+ const WEBIFC = tryRequire('web-ifc');
10987
11047
  const fs = require('fs');
10988
11048
 
10989
11049
  const executionReporter = {
@@ -610,6 +610,27 @@ export declare class EngineServicesClient {
610
610
  * @param hiddenId - The hidden file's unique identifier.
611
611
  */
612
612
  downloadHiddenFile(hiddenId: string): Promise<Response>;
613
+ /**
614
+ * Mints a short-lived presigned URL for a hidden file so the browser can
615
+ * stream it directly from storage with native HTTP `Range` requests (e.g. a
616
+ * point-cloud `octree.bin`), instead of proxying the whole object through the
617
+ * API. Re-call to re-mint when the URL nears/passes `expiresAt`; coalesce
618
+ * concurrent re-mints into a single in-flight call.
619
+ *
620
+ * The storage bucket's CORS must allow the `Range` request header and expose
621
+ * `Content-Range`, `Accept-Ranges` and `Content-Length` for the ranged fetch
622
+ * to succeed cross-origin.
623
+ *
624
+ * @param hiddenId - The hidden file's unique identifier.
625
+ * @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
626
+ * 900 (15 min) server-side; values are clamped to that range.
627
+ * @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
628
+ * an ISO timestamp when it stops working.
629
+ */
630
+ getHiddenFileSignedUrl(hiddenId: string, expiresIn?: number): Promise<{
631
+ url: string;
632
+ expiresAt: string;
633
+ }>;
613
634
  /**
614
635
  * Lists all hidden files attached to a parent item.
615
636
  * @param parentFileId - The parent item's unique identifier.
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Me=Object.defineProperty;var we=n=>{throw TypeError(n)};var Ve=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>Ve(n,typeof e!="symbol"?e+"":e,t),J=(n,e,t)=>e.has(n)||we("Cannot "+t);var Y=(n,e,t)=>(J(n,e,"read from private field"),t?t.call(n):e.get(n)),K=(n,e,t)=>e.has(n)?we("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),_e=(n,e,t,s)=>(J(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),c=(n,e,t)=>(J(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=Object.create(null);k.open="0";k.close="1";k.ping="2";k.pong="3";k.message="4";k.upgrade="5";k.noop="6";const q=Object.create(null);Object.keys(k).forEach(n=>{q[k[n]]=n});const te={type:"error",data:"parser error"},Ae=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Se=typeof ArrayBuffer=="function",Oe=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,le=({type:n,data:e},t,s)=>Ae&&e instanceof Blob?t?s(e):Ee(e,s):Se&&(e instanceof ArrayBuffer||Oe(e))?t?s(e):Ee(new Blob([e]),s):s(k[n]+(e||"")),Ee=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function be(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let W;function He(n,e){if(Ae&&n.data instanceof Blob)return n.data.arrayBuffer().then(be).then(e);if(Se&&(n.data instanceof ArrayBuffer||Oe(n.data)))return e(be(n.data));le(n,!1,t=>{W||(W=new TextEncoder),e(W.encode(t))})}const Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",N=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Te.length;n++)N[Te.charCodeAt(n)]=n;const Ge=n=>{let e=n.length*.75,t=n.length,s,r=0,i,o,h,l;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const y=new ArrayBuffer(e),d=new Uint8Array(y);for(s=0;s<t;s+=4)i=N[n.charCodeAt(s)],o=N[n.charCodeAt(s+1)],h=N[n.charCodeAt(s+2)],l=N[n.charCodeAt(s+3)],d[r++]=i<<2|o>>4,d[r++]=(o&15)<<4|h>>2,d[r++]=(h&3)<<6|l&63;return y},je=typeof ArrayBuffer=="function",fe=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ce(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:Je(n.substring(1),e)}:q[t]?n.length>1?{type:q[t],data:n.substring(1)}:{type:q[t]}:te},Je=(n,e)=>{if(je){const t=Ge(n);return Ce(t,e)}else return{base64:!0,data:n}},Ce=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Re="",Ye=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{le(i,!1,h=>{s[o]=h,++r===t&&e(s.join(Re))})})},Ke=(n,e)=>{const t=n.split(Re),s=[];for(let r=0;r<t.length;r++){const i=fe(t[r],e);if(s.push(i),i.type==="error")break}return s};function We(){return new TransformStream({transform(n,e){He(n,t=>{const s=t.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let z;function P(n){return n.reduce((e,t)=>e+t.length,0)}function L(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)t[r]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function ze(n,e){z||(z=new TextDecoder);const t=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,h){for(t.push(o);;){if(s===0){if(P(t)<1)break;const l=L(t,1);i=(l[0]&128)===128,r=l[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(P(t)<2)break;const l=L(t,2);r=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),s=3}else if(s===2){if(P(t)<8)break;const l=L(t,8),y=new DataView(l.buffer,l.byteOffset,l.length),d=y.getUint32(0);if(d>Math.pow(2,21)-1){h.enqueue(te);break}r=d*Math.pow(2,32)+y.getUint32(4),s=3}else{if(P(t)<r)break;const l=L(t,r);h.enqueue(fe(i?l:z.decode(l),e)),s=0}if(r===0||r>n){h.enqueue(te);break}}}})}const $e=4;function g(n){if(n)return Xe(n)}function Xe(n){for(var e in g.prototype)n[e]=g.prototype[e];return n}g.prototype.on=g.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};g.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};g.prototype.off=g.prototype.removeListener=g.prototype.removeAllListeners=g.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,r=0;r<t.length;r++)if(s=t[r],s===e||s.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};g.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,r=t.length;s<r;++s)t[s].apply(this,e)}return this};g.prototype.emitReserved=g.prototype.emit;g.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};g.prototype.hasListeners=function(n){return!!this.listeners(n).length};const G=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),E=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Qe="arraybuffer";function Be(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const Ze=E.setTimeout,et=E.clearTimeout;function j(n,e){e.useNativeTimers?(n.setTimeoutFn=Ze.bind(E),n.clearTimeoutFn=et.bind(E)):(n.setTimeoutFn=E.setTimeout.bind(E),n.clearTimeoutFn=E.clearTimeout.bind(E))}const tt=1.33;function st(n){return typeof n=="string"?nt(n):Math.ceil((n.byteLength||n.size)*tt)}function nt(n){let e=0,t=0;for(let s=0,r=n.length;s<r;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function xe(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function rt(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function it(n){let e={},t=n.split("&");for(let s=0,r=t.length;s<r;s++){let i=t[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class ot extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class pe extends g{constructor(e){super(),this.writable=!1,j(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new ot(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=fe(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=rt(e);return t.length?"?"+t:""}}class at extends pe{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Ke(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Ye(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=xe()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Ne=!1;try{Ne=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const ct=Ne;function ht(){}class ut extends at{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}class v extends g{constructor(e,t,s){super(),this.createRequest=e,j(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=Be(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=v.requestsCount++,v.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=ht,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete v.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}v.requestsCount=0;v.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ve);else if(typeof addEventListener=="function"){const n="onpagehide"in E?"pagehide":"unload";addEventListener(n,ve,!1)}}function ve(){for(let n in v.requests)v.requests.hasOwnProperty(n)&&v.requests[n].abort()}const lt=function(){const n=Pe({xdomain:!1});return n&&n.responseType!==null}();class ft extends ut{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=lt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new v(Pe,this.uri(),e)}}function Pe(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||ct))return new XMLHttpRequest}catch{}if(!e)try{return new E[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Le=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class pt extends pe{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Le?{}:Be(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;le(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&G(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=xe()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const X=E.WebSocket||E.MozWebSocket;class dt extends pt{createSocket(e,t,s){return Le?new X(e,t,s):t?new X(e,t):new X(e)}doWrite(e,t){this.ws.send(t)}}class yt extends pe{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=ze(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=We();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:h,value:l})=>{h||(this.onPacket(l),i())}).catch(h=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&G(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const mt={websocket:dt,webtransport:yt,polling:ft},gt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,wt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function se(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let r=gt.exec(n||""),i={},o=14;for(;o--;)i[wt[o]]=r[o]||"";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=_t(i,i.path),i.queryKey=Et(i,i.query),i}function _t(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Et(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(t[r]=i)}),t}const ne=typeof addEventListener=="function"&&typeof removeEventListener=="function",U=[];ne&&addEventListener("offline",()=>{U.forEach(n=>n())},!1);class C extends g{constructor(e,t){if(super(),this.binaryType=Qe,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){const s=se(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=se(t.host).host);j(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=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=it(this.opts.query)),ne&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},U.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=$e,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&C.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",C.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(t+=st(r)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,G(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,r){if(typeof t=="function"&&(r=t,t=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:t,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(C.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ne&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=U.indexOf(this._offlineEventListener);s!==-1&&U.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}C.protocol=$e;class bt extends C{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;C.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",m=>{if(!s)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;C.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const w=new Error("probe error");w.transport=t.name,this.emitReserved("upgradeError",w)}}))};function i(){s||(s=!0,d(),t.close(),t=null)}const o=m=>{const w=new Error("probe error: "+m);w.transport=t.name,i(),this.emitReserved("upgradeError",w)};function h(){o("transport closed")}function l(){o("socket closed")}function y(m){t&&m.name!==t.name&&i()}const d=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",h),this.off("close",l),this.off("upgrading",y)};t.once("open",r),t.once("error",o),t.once("close",h),this.once("close",l),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let Tt=class extends bt{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>mt[r]).filter(r=>!!r)),super(e,s)}};function vt(n,e="",t){let s=n;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=se(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(t&&t.port===s.port?"":":"+s.port),s}const kt=typeof ArrayBuffer=="function",At=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Ie=Object.prototype.toString,St=typeof Blob=="function"||typeof Blob<"u"&&Ie.call(Blob)==="[object BlobConstructor]",Ot=typeof File=="function"||typeof File<"u"&&Ie.call(File)==="[object FileConstructor]";function de(n){return kt&&(n instanceof ArrayBuffer||At(n))||St&&n instanceof Blob||Ot&&n instanceof File}function D(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(D(n[t]))return!0;return!1}if(de(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return D(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&D(n[t]))return!0;return!1}function Ct(n){const e=[],t=n.data,s=n;return s.data=re(t,e),s.attachments=e.length,{packet:s,buffers:e}}function re(n,e){if(!n)return n;if(de(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=re(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=re(n[s],e));return t}return n}function Rt(n,e){return n.data=ie(n.data,e),delete n.attachments,n}function ie(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=ie(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=ie(n[t],e));return n}const $t=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var f;(function(n){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"})(f||(f={}));class Bt{constructor(e){this.replacer=e}encode(e){return(e.type===f.EVENT||e.type===f.ACK)&&D(e)?this.encodeAsBinary({type:e.type===f.EVENT?f.BINARY_EVENT:f.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===f.BINARY_EVENT||e.type===f.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Ct(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}class ye extends g{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===f.BINARY_EVENT;s||t.type===f.BINARY_ACK?(t.type=s?f.EVENT:f.ACK,this.reconstructor=new xt(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(de(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(f[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===f.BINARY_EVENT||s.type===f.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(i,t)}else s.nsp="/";const r=e.charAt(t+1);if(r!==""&&Number(r)==r){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(ye.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case f.CONNECT:return ke(t);case f.DISCONNECT:return t===void 0;case f.CONNECT_ERROR:return typeof t=="string"||ke(t);case f.EVENT:case f.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&$t.indexOf(t[0])===-1);case f.ACK:case f.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class xt{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Rt(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function ke(n){return Object.prototype.toString.call(n)==="[object Object]"}const Nt=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ye,Encoder:Bt,get PacketType(){return f}},Symbol.toStringTag,{value:"Module"}));function b(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const Pt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class qe extends g{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[b(e,"open",this.onopen.bind(this)),b(e,"packet",this.onpacket.bind(this)),b(e,"error",this.onerror.bind(this)),b(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,r,i;if(Pt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:f.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const d=this.ids++,m=t.pop();this._registerAckCallback(d,m),o.id=d}const h=(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());return this.flags.volatile&&!h||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===e&&this.sendBuffer.splice(h,1);t.call(this,new Error("operation has timed out"))},r),o=(...h)=>{this.io.clearTimeoutFn(i),t.apply(this,h)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,r)=>{const i=(o,h)=>o?r(o):s(h);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:f.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case f.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case f.EVENT:case f.BINARY_EVENT:this.onevent(e);break;case f.ACK:case f.BINARY_ACK:this.onack(e);break;case f.DISCONNECT:this.ondisconnect();break;case f.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,t.packet({type:f.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:f.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function B(n){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}B.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=Math.floor(e*10)&1?n+t:n-t}return Math.min(n,this.max)|0};B.prototype.reset=function(){this.attempts=0};B.prototype.setMin=function(n){this.ms=n};B.prototype.setMax=function(n){this.max=n};B.prototype.setJitter=function(n){this.jitter=n};class oe extends g{constructor(e,t){var s;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,j(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:.5),this.backoff=new B({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Nt;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Tt(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=b(t,"open",function(){s.onopen(),e&&e()}),i=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),e?e(h):this.maybeReconnectOnOpen()},o=b(t,"error",i);if(this._timeout!==!1){const h=this._timeout,l=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),t.close()},h);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(b(e,"ping",this.onping.bind(this)),b(e,"data",this.ondata.bind(this)),b(e,"error",this.onerror.bind(this)),b(e,"close",this.onclose.bind(this)),b(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){G(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new qe(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const x={};function F(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=vt(n,e.path||"/socket.io"),s=t.source,r=t.id,i=t.path,o=x[r]&&i in x[r].nsps,h=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return h?l=new oe(s,e):(x[r]||(x[r]=new oe(s,e)),l=x[r]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(F,{Manager:oe,Socket:qe,io:F,connect:F});function Lt(n){try{const e=JSON.parse(n);if(e&&typeof e=="object"){const t=e;return{message:typeof t.message=="string"?t.message:void 0,code:typeof t.code=="string"?t.code:void 0,details:t.details}}}catch{}return{}}class Ue extends Error{constructor(t,s,r){const i=Lt(r);super(i.message??`${s||"Request failed"} (${t})`);_(this,"status");_(this,"code");_(this,"details");_(this,"body");this.name="RequestError",this.status=t,this.code=i.code,this.details=i.details,this.body=r}}const T="item/folder",p="item",S="processor",It="npm-registry",R="hidden",Q="FILE",Z="TOOL",ee="APP";var a,ae,u,O,M,V,ce,he,De;const me=class me{constructor(e,t,s){K(this,a);_(this,"apiUrl");_(this,"accessToken");_(this,"wsUrl");_(this,"retries");_(this,"useBearer");_(this,"builtInGlobals",null);_(this,"localServerUrl",null);_(this,"context");const{retries:r=0,useBearer:i=!1,localServerUrl:o}=s||{};let h=t;if(h.charAt(h.length-1)==="/"&&(h=h.slice(0,-1)),this.apiUrl=`${h}/api`,this.accessToken=e,this.wsUrl=`${h}?accessToken=${e}`,this.retries=r,this.useBearer=i,this.context={appId:"",projectId:"",accessToken:e,apiUrl:t},o){let l=o;l.charAt(l.length-1)==="/"&&(l=l.slice(0,-1)),this.localServerUrl=l}}static fromPlatformContext(e){const t=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},s=new me(t.accessToken,t.apiUrl,{...e,useBearer:!0});return s.context=t,s}setRetries(e){this.retries=e}setBuiltInGlobals(e){this.builtInGlobals=e}async resolveAccessToken(){return this.accessToken}async request(e,t,s){return c(this,a,u).call(this,e,t,s)}async listFiles(e){const{folderId:t,archived:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:Q,archived:s}}):await c(this,a,u).call(this,"GET",`${p}`,{query:{itemType:Q,archived:s,...r&&{projectId:r}}})}async getFile(e,t){return await c(this,a,he).call(this,e,t)}async createFile(e){return await c(this,a,V).call(this,e,Q)}async updateFile(e,t){return await c(this,a,ce).call(this,e,t)}async archiveFile(e){return await c(this,a,u).call(this,"DELETE",`${p}/${e}`)}async recoverFile(e){return await c(this,a,u).call(this,"PUT",`${p}/${e}/recover`)}async downloadFile(e,t){return await c(this,a,M).call(this,e,t)}async getFileVersionMetadata(e,t,s){const{withDraft:r}=s||{};return await c(this,a,u).call(this,"GET",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`,{query:{...r&&{withDraft:"true"}}})}async updateFileVersionMetadata(e,t,s){return await c(this,a,u).call(this,"PUT",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`,{body:JSON.stringify({metadata:s}),contentType:"application/json"})}async deleteFileVersionMetadata(e,t){return await c(this,a,u).call(this,"DELETE",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`)}async listFolders(e){const{archived:t,parentFolderId:s,projectId:r}=e||{};return await c(this,a,u).call(this,"GET",T,{query:{parentFolderId:s,archived:t,...r&&{projectId:r}}})}async getFolder(e){return await c(this,a,u).call(this,"GET",`${T}/${e}`)}async createFolder(e,t,s){return await c(this,a,u).call(this,"POST",T,{body:JSON.stringify({name:e,...t&&{parentId:t},...s&&{projectId:s}}),contentType:"application/json"})}async updateFolder(e,t){const{name:s}=t;return await c(this,a,u).call(this,"PUT",`${T}/${e}`,{body:JSON.stringify({name:s}),contentType:"application/json"})}async archiveFolder(e){return await c(this,a,u).call(this,"DELETE",`${T}/${e}`)}async recoverFolder(e){return await c(this,a,u).call(this,"PUT",`${T}/${e}/recover`)}async downloadFolder(e){return await c(this,a,O).call(this,`${T}/${e}/download`)}async listComponents(e){const{folderId:t,ShowVersions:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:Z,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${p}`,{query:{itemType:Z,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async getComponent(e,t){return await c(this,a,he).call(this,e,t)}async createComponent(e){const{componentProps:t}=e;return await c(this,a,V).call(this,e,Z,t)}async updateComponent(e,t){const{componentProps:s}=t;return await c(this,a,ce).call(this,e,t,s)}async downloadComponent(e,t){return await c(this,a,M).call(this,e,t)}async downloadComponentBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,O).call(this,`${p}/${e}/download/bundle`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})}async archiveComponent(e){return await c(this,a,u).call(this,"DELETE",`${p}/${e}`)}async recoverComponent(e){return await c(this,a,u).call(this,"PUT",`${p}/${e}/recover`)}async getBuiltInComponent(e){return await(await c(this,a,O).call(this,`built-in/${e}/bundle`)).text()}async initBuiltInComponent(e,t,s){const r=await this.getBuiltInComponent(e.uuid),i=s??this.builtInGlobals??(typeof window<"u"?window.ThatOpenCompany:{})??{},o=Object.keys(i),h=o.map(m=>i[m]),y=new Function(...o,`${r}
2
- return main;`)(...h),d=(y==null?void 0:y.componentDefinition)??y;t.get(d)}async initBuiltInComponents(e,...t){await Promise.all(t.map(s=>this.initBuiltInComponent(s,e)))}async setup(e,...t){var o,h;const s=e.OBC,r=e.BUI;if(!(s!=null&&s.Components))throw new Error("globals.OBC must include Components");if(!(r!=null&&r.Manager))throw new Error("globals.BUI must include Manager");const i=new s.Components;return r.Manager.init(),this.setBuiltInGlobals(e),await this.initBuiltInComponents(i,...t),i.init(),(h=(o=this.context.appEventOrchestrator)==null?void 0:o.appLoaded)==null||h.call(o),{components:i}}throwError(e,t){var s,r;(r=(s=this.context.appEventOrchestrator)==null?void 0:s.appError)==null||r.call(s,e,t)}async listApps(e){const{folderId:t,ShowVersions:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:ee,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${p}`,{query:{itemType:ee,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async createApp(e){const{appProps:t}=e;return await c(this,a,V).call(this,e,ee,t)}async downloadApp(e,t){return await c(this,a,M).call(this,e,t)}async downloadAppBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,O).call(this,`${p}/${e}/download/bundle`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})}async archiveApp(e){return await c(this,a,u).call(this,"DELETE",`${p}/${e}`)}async getNpmCredentials(){return await c(this,a,u).call(this,"GET",`${It}/credentials`)}async executeComponent(e,t,s){if(this.localServerUrl){const r=`${this.localServerUrl}/api/${S}/${e}/execute`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){const o=await i.text().catch(()=>"");throw new Error(`Local server request failed: ${i.status} - ${o}`)}return await i.json()}return await c(this,a,u).call(this,"POST",`${S}/${e}/execute`,{body:JSON.stringify(t),query:{...s&&{versionTag:s}},contentType:"application/json"})}async abortExecution(e){if(this.localServerUrl){const t=`${this.localServerUrl}/api/${S}/progress/${e}/abort`,s=await fetch(t,{method:"POST"});if(!s.ok){const r=await s.text().catch(()=>"");throw new Error(`Local server request failed: ${s.status} - ${r}`)}return await s.json()}return await c(this,a,u).call(this,"POST",`${S}/progress/${e}/abort`)}async listExecutions(e,t){if(this.localServerUrl){const s=t?`?projectId=${encodeURIComponent(t)}`:"",r=`${this.localServerUrl}/api/${S}/${e}/progress${s}`,i=await fetch(r);if(!i.ok){const o=await i.text().catch(()=>"");throw new Error(`Local server request failed: ${i.status} - ${o}`)}return await i.json()}return await c(this,a,u).call(this,"GET",`${S}/${e}/progress`,{query:{...t&&{projectId:t}}})}async getExecution(e){if(this.localServerUrl){const t=`${this.localServerUrl}/api/${S}/progress/${e}`,s=await fetch(t);if(!s.ok){const r=await s.text().catch(()=>"");throw new Error(`Local server request failed: ${s.status} - ${r}`)}return await s.json()}return await c(this,a,u).call(this,"GET",`${S}/progress/${e}`)}async onExecutionProgress(e,t){const s=this.localServerUrl?`${this.localServerUrl}?accessToken=${this.accessToken}`:this.wsUrl,r=await F(s,{...this.localServerUrl&&{transports:["websocket"]}});r.on("connect",function(){r.emit("executionSubscription",JSON.stringify({executionId:e})),r.on("execution",i=>{t(i)})}),r.on("connect_error",function(i){console.log(i)})}async createHiddenFile(e,t){const s=new FormData;return s.append("file",e),s.append("parentItemId",t),await c(this,a,u).call(this,"POST",`${p}/${R}`,{body:s})}async createHiddenFilesBatch(e,t){const s=new FormData;for(const r of e)s.append("files",r);return s.append("parentItemId",t),await c(this,a,u).call(this,"POST",`${p}/${R}/batch`,{body:s})}async deleteHiddenFile(e){return await c(this,a,u).call(this,"DELETE",`${p}/${R}/${e}`)}async getHiddenFile(e){return await c(this,a,u).call(this,"GET",`${p}/${R}/${e}`)}async downloadHiddenFile(e){return await c(this,a,O).call(this,`${p}/${R}/${e}/download`)}async getHiddenFilesByParent(e){return await c(this,a,u).call(this,"GET",`${p}/${e}/${R}`)}async deleteHiddenFilesByParent(e){return await c(this,a,u).call(this,"DELETE",`${p}/${e}/${R}`)}async uploadItemIcon(e,t){const s=new FormData;return s.append("icon",t),await c(this,a,u).call(this,"PUT",`${p}/${e}/icon`,{body:s})}async getItemIcon(e){return await c(this,a,O).call(this,`${p}/${e}/icon`)}async removeItemIcon(e){return await c(this,a,u).call(this,"DELETE",`${p}/${e}/icon`)}async updateItem(e,t){return await c(this,a,u).call(this,"PUT",`${p}/${e}`,{body:JSON.stringify(t),contentType:"application/json"})}async createVersion(e,t,s,r,i){const o=new FormData;return o.append("file",t),o.append("versionTag",s),r&&o.append("extraProps",JSON.stringify(r)),i&&o.append("metadata",JSON.stringify(i)),await c(this,a,u).call(this,"POST",`${p}/${e}/version`,{body:o})}async listVersions(e,t={}){return await c(this,a,u).call(this,"GET",`${p}/${encodeURIComponent(e)}/versions`,{query:t})}async archiveVersion(e,t){return await c(this,a,u).call(this,"PUT",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`)}async recoverVersion(e,t){return await c(this,a,u).call(this,"PUT",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`)}async deleteVersion(e,t){return await c(this,a,u).call(this,"DELETE",`${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`)}};a=new WeakSet,ae=function(e){return`${this.apiUrl}/${e}`},u=async function(e,t,s){const{body:r,query:i,contentType:o,retries:h}=s||{},l=c(this,a,ae).call(this,t),y=c(this,a,De).call(this,i),d=await this.resolveAccessToken(),m={...y,...this.useBearer?{}:{accessToken:d}};try{const w=await fetch(l+"?"+new URLSearchParams(m).toString(),{method:e,headers:{Accept:"application/json",...o&&{"Content-Type":o},...this.useBearer&&{Authorization:`Bearer ${d}`}},...r&&{body:r}});if(!w.ok){const A=await w.text().then(Fe=>Fe).catch(()=>"");throw new Ue(w.status,w.statusText,A)}return w.json().then(A=>A).catch(()=>{})}catch(w){let A=h??this.retries;if(A)return A=A-1,await c(this,a,u).call(this,e,t,{...s,retries:A});throw w}},O=async function(e,t){const{query:s}=t||{},r=c(this,a,ae).call(this,e),i=await this.resolveAccessToken(),o={...s,...this.useBearer?{}:{accessToken:i}};return await fetch(r+"?"+new URLSearchParams(o).toString(),{method:"GET",...this.useBearer&&{headers:{Authorization:`Bearer ${i}`}}})},M=async function(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,O).call(this,`${p}/${e}/download`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})},V=async function(e,t,s){const{name:r,versionTag:i,parentFolderId:o,projectId:h,file:l,metadata:y}=e,d=new FormData;return d.append("file",l),d.append("name",r),d.append("versionTag",i),d.append("itemType",t),o&&d.append("folderId",o),h&&d.append("projectId",h),s&&d.append("extraProps",JSON.stringify(s)),y&&d.append("metadata",JSON.stringify(y)),await c(this,a,u).call(this,"POST",p,{body:d})},ce=async function(e,t,s){const{name:r,versionTag:i,parentFolderId:o,file:h,metadata:l}=t;let y,d;if(h){const m=new FormData;m.append("file",h),i&&m.append("versionTag",i),s&&m.append("extraProps",JSON.stringify(s)),l&&m.append("metadata",JSON.stringify(l)),d=await c(this,a,u).call(this,"POST",`${p}/${e}/version`,{body:m})}if(r||o){const m={...r&&{name:r},...o&&{folderId:o}},w=JSON.stringify(m);y=await c(this,a,u).call(this,"PUT",`${p}/${e}`,{body:w,contentType:"application/json"})}return{item:y,version:d}},he=async function(e,t){const{showVersions:s=!1}=t||{};return await c(this,a,u).call(this,"GET",`${p}/${e}`,{query:{showVersions:s}})},De=function(e){return e&&Object.entries(e).filter(([,t])=>t!==void 0).reduce((t,[s,r])=>(t[s]=r,t),{})};let H=me;const I="project";var $;const ge=class ge extends H{constructor(t,s,r){super(typeof t=="string"?t:"",s,{...r,useBearer:!0});K(this,$);typeof t=="function"&&_e(this,$,t)}async resolveAccessToken(){return Y(this,$)?await Y(this,$).call(this):super.resolveAccessToken()}static fromPlatformContext(t){const s=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},r=new ge(s.accessToken,s.apiUrl,t);return r.context=s,r}async getProject(t){return await this.request("GET",`${I}/${t}`)}async getProjectData(t){return await this.request("GET",`${I}/${t}/data`)}async checkPermission(t){return await this.request("GET",`${I}/permissions/check`,{query:t})}async checkPermissionBatch(t){return(await this.request("POST",`${I}/permissions/check/batch`,{body:JSON.stringify({checks:t}),contentType:"application/json"})).results}};$=new WeakMap;let ue=ge;const qt={MAX_FIELDS:200,MAX_KEY_LENGTH:50,MAX_VALUE_LENGTH:50},Ut={uuid:"a3f82c1d-5b74-4e9a-bc30-d7e12f894a61"},Dt={uuid:"b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c"},Ft={uuid:"2c4ae432-fc24-43e9-9783-0c960c674e96"},Mt={uuid:"234f1416-528d-452a-9cc9-a16c5239b2eb"};exports.CDEManager=Ut;exports.EngineServicesClient=H;exports.FileList=Dt;exports.HelloWorld=Ft;exports.METADATA_LIMITS=qt;exports.PlatformClient=ue;exports.RequestError=Ue;exports.UIManager=Mt;
1
+ "use strict";var Me=Object.defineProperty;var we=n=>{throw TypeError(n)};var Ve=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e,t)=>Ve(n,typeof e!="symbol"?e+"":e,t),J=(n,e,t)=>e.has(n)||we("Cannot "+t);var Y=(n,e,t)=>(J(n,e,"read from private field"),t?t.call(n):e.get(n)),K=(n,e,t)=>e.has(n)?we("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),_e=(n,e,t,s)=>(J(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),c=(n,e,t)=>(J(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=Object.create(null);k.open="0";k.close="1";k.ping="2";k.pong="3";k.message="4";k.upgrade="5";k.noop="6";const q=Object.create(null);Object.keys(k).forEach(n=>{q[k[n]]=n});const te={type:"error",data:"parser error"},Ae=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Se=typeof ArrayBuffer=="function",Oe=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,le=({type:n,data:e},t,s)=>Ae&&e instanceof Blob?t?s(e):Ee(e,s):Se&&(e instanceof ArrayBuffer||Oe(e))?t?s(e):Ee(new Blob([e]),s):s(k[n]+(e||"")),Ee=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function be(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let W;function He(n,e){if(Ae&&n.data instanceof Blob)return n.data.arrayBuffer().then(be).then(e);if(Se&&(n.data instanceof ArrayBuffer||Oe(n.data)))return e(be(n.data));le(n,!1,t=>{W||(W=new TextEncoder),e(W.encode(t))})}const Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",N=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Te.length;n++)N[Te.charCodeAt(n)]=n;const Ge=n=>{let e=n.length*.75,t=n.length,s,r=0,i,o,h,l;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const y=new ArrayBuffer(e),d=new Uint8Array(y);for(s=0;s<t;s+=4)i=N[n.charCodeAt(s)],o=N[n.charCodeAt(s+1)],h=N[n.charCodeAt(s+2)],l=N[n.charCodeAt(s+3)],d[r++]=i<<2|o>>4,d[r++]=(o&15)<<4|h>>2,d[r++]=(h&3)<<6|l&63;return y},je=typeof ArrayBuffer=="function",fe=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ce(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:Je(n.substring(1),e)}:q[t]?n.length>1?{type:q[t],data:n.substring(1)}:{type:q[t]}:te},Je=(n,e)=>{if(je){const t=Ge(n);return Ce(t,e)}else return{base64:!0,data:n}},Ce=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},$e="",Ye=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{le(i,!1,h=>{s[o]=h,++r===t&&e(s.join($e))})})},Ke=(n,e)=>{const t=n.split($e),s=[];for(let r=0;r<t.length;r++){const i=fe(t[r],e);if(s.push(i),i.type==="error")break}return s};function We(){return new TransformStream({transform(n,e){He(n,t=>{const s=t.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let z;function P(n){return n.reduce((e,t)=>e+t.length,0)}function L(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)t[r]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function ze(n,e){z||(z=new TextDecoder);const t=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,h){for(t.push(o);;){if(s===0){if(P(t)<1)break;const l=L(t,1);i=(l[0]&128)===128,r=l[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(P(t)<2)break;const l=L(t,2);r=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),s=3}else if(s===2){if(P(t)<8)break;const l=L(t,8),y=new DataView(l.buffer,l.byteOffset,l.length),d=y.getUint32(0);if(d>Math.pow(2,21)-1){h.enqueue(te);break}r=d*Math.pow(2,32)+y.getUint32(4),s=3}else{if(P(t)<r)break;const l=L(t,r);h.enqueue(fe(i?l:z.decode(l),e)),s=0}if(r===0||r>n){h.enqueue(te);break}}}})}const Re=4;function g(n){if(n)return Xe(n)}function Xe(n){for(var e in g.prototype)n[e]=g.prototype[e];return n}g.prototype.on=g.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};g.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};g.prototype.off=g.prototype.removeListener=g.prototype.removeAllListeners=g.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,r=0;r<t.length;r++)if(s=t[r],s===e||s.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};g.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,r=t.length;s<r;++s)t[s].apply(this,e)}return this};g.prototype.emitReserved=g.prototype.emit;g.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};g.prototype.hasListeners=function(n){return!!this.listeners(n).length};const G=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),E=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Qe="arraybuffer";function Be(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const Ze=E.setTimeout,et=E.clearTimeout;function j(n,e){e.useNativeTimers?(n.setTimeoutFn=Ze.bind(E),n.clearTimeoutFn=et.bind(E)):(n.setTimeoutFn=E.setTimeout.bind(E),n.clearTimeoutFn=E.clearTimeout.bind(E))}const tt=1.33;function st(n){return typeof n=="string"?nt(n):Math.ceil((n.byteLength||n.size)*tt)}function nt(n){let e=0,t=0;for(let s=0,r=n.length;s<r;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function xe(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function rt(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function it(n){let e={},t=n.split("&");for(let s=0,r=t.length;s<r;s++){let i=t[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class ot extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class pe extends g{constructor(e){super(),this.writable=!1,j(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new ot(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=fe(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=rt(e);return t.length?"?"+t:""}}class at extends pe{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Ke(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Ye(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=xe()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Ne=!1;try{Ne=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const ct=Ne;function ht(){}class ut extends at{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}class v extends g{constructor(e,t,s){super(),this.createRequest=e,j(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=Be(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=v.requestsCount++,v.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=ht,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete v.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}v.requestsCount=0;v.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ve);else if(typeof addEventListener=="function"){const n="onpagehide"in E?"pagehide":"unload";addEventListener(n,ve,!1)}}function ve(){for(let n in v.requests)v.requests.hasOwnProperty(n)&&v.requests[n].abort()}const lt=function(){const n=Pe({xdomain:!1});return n&&n.responseType!==null}();class ft extends ut{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=lt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new v(Pe,this.uri(),e)}}function Pe(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||ct))return new XMLHttpRequest}catch{}if(!e)try{return new E[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Le=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class pt extends pe{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Le?{}:Be(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;le(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&G(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=xe()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const X=E.WebSocket||E.MozWebSocket;class dt extends pt{createSocket(e,t,s){return Le?new X(e,t,s):t?new X(e,t):new X(e)}doWrite(e,t){this.ws.send(t)}}class yt extends pe{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=ze(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=We();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:h,value:l})=>{h||(this.onPacket(l),i())}).catch(h=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&G(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const mt={websocket:dt,webtransport:yt,polling:ft},gt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,wt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function se(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let r=gt.exec(n||""),i={},o=14;for(;o--;)i[wt[o]]=r[o]||"";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=_t(i,i.path),i.queryKey=Et(i,i.query),i}function _t(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Et(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(t[r]=i)}),t}const ne=typeof addEventListener=="function"&&typeof removeEventListener=="function",U=[];ne&&addEventListener("offline",()=>{U.forEach(n=>n())},!1);class $ extends g{constructor(e,t){if(super(),this.binaryType=Qe,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){const s=se(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=se(t.host).host);j(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=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=it(this.opts.query)),ne&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},U.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=Re,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&$.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",$.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(t+=st(r)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,G(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,r){if(typeof t=="function"&&(r=t,t=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:t,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if($.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ne&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=U.indexOf(this._offlineEventListener);s!==-1&&U.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}$.protocol=Re;class bt extends ${constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;$.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",m=>{if(!s)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;$.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const w=new Error("probe error");w.transport=t.name,this.emitReserved("upgradeError",w)}}))};function i(){s||(s=!0,d(),t.close(),t=null)}const o=m=>{const w=new Error("probe error: "+m);w.transport=t.name,i(),this.emitReserved("upgradeError",w)};function h(){o("transport closed")}function l(){o("socket closed")}function y(m){t&&m.name!==t.name&&i()}const d=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",h),this.off("close",l),this.off("upgrading",y)};t.once("open",r),t.once("error",o),t.once("close",h),this.once("close",l),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let Tt=class extends bt{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>mt[r]).filter(r=>!!r)),super(e,s)}};function vt(n,e="",t){let s=n;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=se(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(t&&t.port===s.port?"":":"+s.port),s}const kt=typeof ArrayBuffer=="function",At=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Ie=Object.prototype.toString,St=typeof Blob=="function"||typeof Blob<"u"&&Ie.call(Blob)==="[object BlobConstructor]",Ot=typeof File=="function"||typeof File<"u"&&Ie.call(File)==="[object FileConstructor]";function de(n){return kt&&(n instanceof ArrayBuffer||At(n))||St&&n instanceof Blob||Ot&&n instanceof File}function D(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(D(n[t]))return!0;return!1}if(de(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return D(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&D(n[t]))return!0;return!1}function Ct(n){const e=[],t=n.data,s=n;return s.data=re(t,e),s.attachments=e.length,{packet:s,buffers:e}}function re(n,e){if(!n)return n;if(de(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=re(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=re(n[s],e));return t}return n}function $t(n,e){return n.data=ie(n.data,e),delete n.attachments,n}function ie(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=ie(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=ie(n[t],e));return n}const Rt=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var p;(function(n){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"})(p||(p={}));class Bt{constructor(e){this.replacer=e}encode(e){return(e.type===p.EVENT||e.type===p.ACK)&&D(e)?this.encodeAsBinary({type:e.type===p.EVENT?p.BINARY_EVENT:p.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===p.BINARY_EVENT||e.type===p.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Ct(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}class ye extends g{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===p.BINARY_EVENT;s||t.type===p.BINARY_ACK?(t.type=s?p.EVENT:p.ACK,this.reconstructor=new xt(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(de(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(p[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===p.BINARY_EVENT||s.type===p.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(i,t)}else s.nsp="/";const r=e.charAt(t+1);if(r!==""&&Number(r)==r){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(ye.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case p.CONNECT:return ke(t);case p.DISCONNECT:return t===void 0;case p.CONNECT_ERROR:return typeof t=="string"||ke(t);case p.EVENT:case p.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Rt.indexOf(t[0])===-1);case p.ACK:case p.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class xt{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=$t(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function ke(n){return Object.prototype.toString.call(n)==="[object Object]"}const Nt=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ye,Encoder:Bt,get PacketType(){return p}},Symbol.toStringTag,{value:"Module"}));function b(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const Pt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class qe extends g{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[b(e,"open",this.onopen.bind(this)),b(e,"packet",this.onpacket.bind(this)),b(e,"error",this.onerror.bind(this)),b(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,r,i;if(Pt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:p.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const d=this.ids++,m=t.pop();this._registerAckCallback(d,m),o.id=d}const h=(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());return this.flags.volatile&&!h||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let h=0;h<this.sendBuffer.length;h++)this.sendBuffer[h].id===e&&this.sendBuffer.splice(h,1);t.call(this,new Error("operation has timed out"))},r),o=(...h)=>{this.io.clearTimeoutFn(i),t.apply(this,h)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,r)=>{const i=(o,h)=>o?r(o):s(h);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:p.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case p.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case p.EVENT:case p.BINARY_EVENT:this.onevent(e);break;case p.ACK:case p.BINARY_ACK:this.onack(e);break;case p.DISCONNECT:this.ondisconnect();break;case p.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,t.packet({type:p.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:p.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function B(n){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}B.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=Math.floor(e*10)&1?n+t:n-t}return Math.min(n,this.max)|0};B.prototype.reset=function(){this.attempts=0};B.prototype.setMin=function(n){this.ms=n};B.prototype.setMax=function(n){this.max=n};B.prototype.setJitter=function(n){this.jitter=n};class oe extends g{constructor(e,t){var s;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,j(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:.5),this.backoff=new B({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Nt;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Tt(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=b(t,"open",function(){s.onopen(),e&&e()}),i=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),e?e(h):this.maybeReconnectOnOpen()},o=b(t,"error",i);if(this._timeout!==!1){const h=this._timeout,l=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),t.close()},h);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(b(e,"ping",this.onping.bind(this)),b(e,"data",this.ondata.bind(this)),b(e,"error",this.onerror.bind(this)),b(e,"close",this.onclose.bind(this)),b(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){G(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new qe(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const x={};function F(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=vt(n,e.path||"/socket.io"),s=t.source,r=t.id,i=t.path,o=x[r]&&i in x[r].nsps,h=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return h?l=new oe(s,e):(x[r]||(x[r]=new oe(s,e)),l=x[r]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(F,{Manager:oe,Socket:qe,io:F,connect:F});function Lt(n){try{const e=JSON.parse(n);if(e&&typeof e=="object"){const t=e;return{message:typeof t.message=="string"?t.message:void 0,code:typeof t.code=="string"?t.code:void 0,details:t.details}}}catch{}return{}}class Ue extends Error{constructor(t,s,r){const i=Lt(r);super(i.message??`${s||"Request failed"} (${t})`);_(this,"status");_(this,"code");_(this,"details");_(this,"body");this.name="RequestError",this.status=t,this.code=i.code,this.details=i.details,this.body=r}}const T="item/folder",f="item",S="processor",It="npm-registry",O="hidden",Q="FILE",Z="TOOL",ee="APP";var a,ae,u,C,M,V,ce,he,De;const me=class me{constructor(e,t,s){K(this,a);_(this,"apiUrl");_(this,"accessToken");_(this,"wsUrl");_(this,"retries");_(this,"useBearer");_(this,"builtInGlobals",null);_(this,"localServerUrl",null);_(this,"context");const{retries:r=0,useBearer:i=!1,localServerUrl:o}=s||{};let h=t;if(h.charAt(h.length-1)==="/"&&(h=h.slice(0,-1)),this.apiUrl=`${h}/api`,this.accessToken=e,this.wsUrl=`${h}?accessToken=${e}`,this.retries=r,this.useBearer=i,this.context={appId:"",projectId:"",accessToken:e,apiUrl:t},o){let l=o;l.charAt(l.length-1)==="/"&&(l=l.slice(0,-1)),this.localServerUrl=l}}static fromPlatformContext(e){const t=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},s=new me(t.accessToken,t.apiUrl,{...e,useBearer:!0});return s.context=t,s}setRetries(e){this.retries=e}setBuiltInGlobals(e){this.builtInGlobals=e}async resolveAccessToken(){return this.accessToken}async request(e,t,s){return c(this,a,u).call(this,e,t,s)}async listFiles(e){const{folderId:t,archived:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:Q,archived:s}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:Q,archived:s,...r&&{projectId:r}}})}async getFile(e,t){return await c(this,a,he).call(this,e,t)}async createFile(e){return await c(this,a,V).call(this,e,Q)}async updateFile(e,t){return await c(this,a,ce).call(this,e,t)}async archiveFile(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}`)}async recoverFile(e){return await c(this,a,u).call(this,"PUT",`${f}/${e}/recover`)}async downloadFile(e,t){return await c(this,a,M).call(this,e,t)}async getFileVersionMetadata(e,t,s){const{withDraft:r}=s||{};return await c(this,a,u).call(this,"GET",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`,{query:{...r&&{withDraft:"true"}}})}async updateFileVersionMetadata(e,t,s){return await c(this,a,u).call(this,"PUT",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`,{body:JSON.stringify({metadata:s}),contentType:"application/json"})}async deleteFileVersionMetadata(e,t){return await c(this,a,u).call(this,"DELETE",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`)}async listFolders(e){const{archived:t,parentFolderId:s,projectId:r}=e||{};return await c(this,a,u).call(this,"GET",T,{query:{parentFolderId:s,archived:t,...r&&{projectId:r}}})}async getFolder(e){return await c(this,a,u).call(this,"GET",`${T}/${e}`)}async createFolder(e,t,s){return await c(this,a,u).call(this,"POST",T,{body:JSON.stringify({name:e,...t&&{parentId:t},...s&&{projectId:s}}),contentType:"application/json"})}async updateFolder(e,t){const{name:s}=t;return await c(this,a,u).call(this,"PUT",`${T}/${e}`,{body:JSON.stringify({name:s}),contentType:"application/json"})}async archiveFolder(e){return await c(this,a,u).call(this,"DELETE",`${T}/${e}`)}async recoverFolder(e){return await c(this,a,u).call(this,"PUT",`${T}/${e}/recover`)}async downloadFolder(e){return await c(this,a,C).call(this,`${T}/${e}/download`)}async listComponents(e){const{folderId:t,ShowVersions:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:Z,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:Z,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async getComponent(e,t){return await c(this,a,he).call(this,e,t)}async createComponent(e){const{componentProps:t}=e;return await c(this,a,V).call(this,e,Z,t)}async updateComponent(e,t){const{componentProps:s}=t;return await c(this,a,ce).call(this,e,t,s)}async downloadComponent(e,t){return await c(this,a,M).call(this,e,t)}async downloadComponentBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,C).call(this,`${f}/${e}/download/bundle`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})}async archiveComponent(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}`)}async recoverComponent(e){return await c(this,a,u).call(this,"PUT",`${f}/${e}/recover`)}async getBuiltInComponent(e){return await(await c(this,a,C).call(this,`built-in/${e}/bundle`)).text()}async initBuiltInComponent(e,t,s){const r=await this.getBuiltInComponent(e.uuid),i=s??this.builtInGlobals??(typeof window<"u"?window.ThatOpenCompany:{})??{},o=Object.keys(i),h=o.map(m=>i[m]),y=new Function(...o,`${r}
2
+ return main;`)(...h),d=(y==null?void 0:y.componentDefinition)??y;t.get(d)}async initBuiltInComponents(e,...t){await Promise.all(t.map(s=>this.initBuiltInComponent(s,e)))}async setup(e,...t){var o,h;const s=e.OBC,r=e.BUI;if(!(s!=null&&s.Components))throw new Error("globals.OBC must include Components");if(!(r!=null&&r.Manager))throw new Error("globals.BUI must include Manager");const i=new s.Components;return r.Manager.init(),this.setBuiltInGlobals(e),await this.initBuiltInComponents(i,...t),i.init(),(h=(o=this.context.appEventOrchestrator)==null?void 0:o.appLoaded)==null||h.call(o),{components:i}}throwError(e,t){var s,r;(r=(s=this.context.appEventOrchestrator)==null?void 0:s.appError)==null||r.call(s,e,t)}async listApps(e){const{folderId:t,ShowVersions:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${T}/${t}/items`,{query:{itemType:ee,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:ee,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async createApp(e){const{appProps:t}=e;return await c(this,a,V).call(this,e,ee,t)}async downloadApp(e,t){return await c(this,a,M).call(this,e,t)}async downloadAppBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,C).call(this,`${f}/${e}/download/bundle`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})}async archiveApp(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}`)}async getNpmCredentials(){return await c(this,a,u).call(this,"GET",`${It}/credentials`)}async executeComponent(e,t,s){if(this.localServerUrl){const r=`${this.localServerUrl}/api/${S}/${e}/execute`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){const o=await i.text().catch(()=>"");throw new Error(`Local server request failed: ${i.status} - ${o}`)}return await i.json()}return await c(this,a,u).call(this,"POST",`${S}/${e}/execute`,{body:JSON.stringify(t),query:{...s&&{versionTag:s}},contentType:"application/json"})}async abortExecution(e){if(this.localServerUrl){const t=`${this.localServerUrl}/api/${S}/progress/${e}/abort`,s=await fetch(t,{method:"POST"});if(!s.ok){const r=await s.text().catch(()=>"");throw new Error(`Local server request failed: ${s.status} - ${r}`)}return await s.json()}return await c(this,a,u).call(this,"POST",`${S}/progress/${e}/abort`)}async listExecutions(e,t){if(this.localServerUrl){const s=t?`?projectId=${encodeURIComponent(t)}`:"",r=`${this.localServerUrl}/api/${S}/${e}/progress${s}`,i=await fetch(r);if(!i.ok){const o=await i.text().catch(()=>"");throw new Error(`Local server request failed: ${i.status} - ${o}`)}return await i.json()}return await c(this,a,u).call(this,"GET",`${S}/${e}/progress`,{query:{...t&&{projectId:t}}})}async getExecution(e){if(this.localServerUrl){const t=`${this.localServerUrl}/api/${S}/progress/${e}`,s=await fetch(t);if(!s.ok){const r=await s.text().catch(()=>"");throw new Error(`Local server request failed: ${s.status} - ${r}`)}return await s.json()}return await c(this,a,u).call(this,"GET",`${S}/progress/${e}`)}async onExecutionProgress(e,t){const s=this.localServerUrl?`${this.localServerUrl}?accessToken=${this.accessToken}`:this.wsUrl,r=await F(s,{...this.localServerUrl&&{transports:["websocket"]}});r.on("connect",function(){r.emit("executionSubscription",JSON.stringify({executionId:e})),r.on("execution",i=>{t(i)})}),r.on("connect_error",function(i){console.log(i)})}async createHiddenFile(e,t){const s=new FormData;return s.append("file",e),s.append("parentItemId",t),await c(this,a,u).call(this,"POST",`${f}/${O}`,{body:s})}async createHiddenFilesBatch(e,t){const s=new FormData;for(const r of e)s.append("files",r);return s.append("parentItemId",t),await c(this,a,u).call(this,"POST",`${f}/${O}/batch`,{body:s})}async deleteHiddenFile(e){return await c(this,a,u).call(this,"DELETE",`${f}/${O}/${e}`)}async getHiddenFile(e){return await c(this,a,u).call(this,"GET",`${f}/${O}/${e}`)}async downloadHiddenFile(e){return await c(this,a,C).call(this,`${f}/${O}/${e}/download`)}async getHiddenFileSignedUrl(e,t){return await c(this,a,u).call(this,"GET",`${f}/${O}/${e}/signed-url`,{...t!=null&&{query:{expiresIn:t}}})}async getHiddenFilesByParent(e){return await c(this,a,u).call(this,"GET",`${f}/${e}/${O}`)}async deleteHiddenFilesByParent(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}/${O}`)}async uploadItemIcon(e,t){const s=new FormData;return s.append("icon",t),await c(this,a,u).call(this,"PUT",`${f}/${e}/icon`,{body:s})}async getItemIcon(e){return await c(this,a,C).call(this,`${f}/${e}/icon`)}async removeItemIcon(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}/icon`)}async updateItem(e,t){return await c(this,a,u).call(this,"PUT",`${f}/${e}`,{body:JSON.stringify(t),contentType:"application/json"})}async createVersion(e,t,s,r,i){const o=new FormData;return o.append("file",t),o.append("versionTag",s),r&&o.append("extraProps",JSON.stringify(r)),i&&o.append("metadata",JSON.stringify(i)),await c(this,a,u).call(this,"POST",`${f}/${e}/version`,{body:o})}async listVersions(e,t={}){return await c(this,a,u).call(this,"GET",`${f}/${encodeURIComponent(e)}/versions`,{query:t})}async archiveVersion(e,t){return await c(this,a,u).call(this,"PUT",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`)}async recoverVersion(e,t){return await c(this,a,u).call(this,"PUT",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`)}async deleteVersion(e,t){return await c(this,a,u).call(this,"DELETE",`${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`)}};a=new WeakSet,ae=function(e){return`${this.apiUrl}/${e}`},u=async function(e,t,s){const{body:r,query:i,contentType:o,retries:h}=s||{},l=c(this,a,ae).call(this,t),y=c(this,a,De).call(this,i),d=await this.resolveAccessToken(),m={...y,...this.useBearer?{}:{accessToken:d}};try{const w=await fetch(l+"?"+new URLSearchParams(m).toString(),{method:e,headers:{Accept:"application/json",...o&&{"Content-Type":o},...this.useBearer&&{Authorization:`Bearer ${d}`}},...r&&{body:r}});if(!w.ok){const A=await w.text().then(Fe=>Fe).catch(()=>"");throw new Ue(w.status,w.statusText,A)}return w.json().then(A=>A).catch(()=>{})}catch(w){let A=h??this.retries;if(A)return A=A-1,await c(this,a,u).call(this,e,t,{...s,retries:A});throw w}},C=async function(e,t){const{query:s}=t||{},r=c(this,a,ae).call(this,e),i=await this.resolveAccessToken(),o={...s,...this.useBearer?{}:{accessToken:i}};return await fetch(r+"?"+new URLSearchParams(o).toString(),{method:"GET",...this.useBearer&&{headers:{Authorization:`Bearer ${i}`}}})},M=async function(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,C).call(this,`${f}/${e}/download`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})},V=async function(e,t,s){const{name:r,versionTag:i,parentFolderId:o,projectId:h,file:l,metadata:y}=e,d=new FormData;return d.append("file",l),d.append("name",r),d.append("versionTag",i),d.append("itemType",t),o&&d.append("folderId",o),h&&d.append("projectId",h),s&&d.append("extraProps",JSON.stringify(s)),y&&d.append("metadata",JSON.stringify(y)),await c(this,a,u).call(this,"POST",f,{body:d})},ce=async function(e,t,s){const{name:r,versionTag:i,parentFolderId:o,file:h,metadata:l}=t;let y,d;if(h){const m=new FormData;m.append("file",h),i&&m.append("versionTag",i),s&&m.append("extraProps",JSON.stringify(s)),l&&m.append("metadata",JSON.stringify(l)),d=await c(this,a,u).call(this,"POST",`${f}/${e}/version`,{body:m})}if(r||o){const m={...r&&{name:r},...o&&{folderId:o}},w=JSON.stringify(m);y=await c(this,a,u).call(this,"PUT",`${f}/${e}`,{body:w,contentType:"application/json"})}return{item:y,version:d}},he=async function(e,t){const{showVersions:s=!1}=t||{};return await c(this,a,u).call(this,"GET",`${f}/${e}`,{query:{showVersions:s}})},De=function(e){return e&&Object.entries(e).filter(([,t])=>t!==void 0).reduce((t,[s,r])=>(t[s]=r,t),{})};let H=me;const I="project";var R;const ge=class ge extends H{constructor(t,s,r){super(typeof t=="string"?t:"",s,{...r,useBearer:!0});K(this,R);typeof t=="function"&&_e(this,R,t)}async resolveAccessToken(){return Y(this,R)?await Y(this,R).call(this):super.resolveAccessToken()}static fromPlatformContext(t){const s=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},r=new ge(s.accessToken,s.apiUrl,t);return r.context=s,r}async getProject(t){return await this.request("GET",`${I}/${t}`)}async getProjectData(t){return await this.request("GET",`${I}/${t}/data`)}async checkPermission(t){return await this.request("GET",`${I}/permissions/check`,{query:t})}async checkPermissionBatch(t){return(await this.request("POST",`${I}/permissions/check/batch`,{body:JSON.stringify({checks:t}),contentType:"application/json"})).results}};R=new WeakMap;let ue=ge;const qt={MAX_FIELDS:200,MAX_KEY_LENGTH:50,MAX_VALUE_LENGTH:50},Ut={uuid:"a3f82c1d-5b74-4e9a-bc30-d7e12f894a61"},Dt={uuid:"b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c"},Ft={uuid:"2c4ae432-fc24-43e9-9783-0c960c674e96"},Mt={uuid:"234f1416-528d-452a-9cc9-a16c5239b2eb"};exports.CDEManager=Ut;exports.EngineServicesClient=H;exports.FileList=Dt;exports.HelloWorld=Ft;exports.METADATA_LIMITS=qt;exports.PlatformClient=ue;exports.RequestError=Ue;exports.UIManager=Mt;
package/dist/index.es.js CHANGED
@@ -24,22 +24,22 @@ const ee = { type: "error", data: "parser error" }, Ae = typeof Blob == "functio
24
24
  e("b" + (s || ""));
25
25
  }, t.readAsDataURL(n);
26
26
  };
27
- function be(n) {
27
+ function Ee(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
30
  let K;
31
31
  function Me(n, e) {
32
32
  if (Ae && n.data instanceof Blob)
33
- return n.data.arrayBuffer().then(be).then(e);
33
+ return n.data.arrayBuffer().then(Ee).then(e);
34
34
  if (Oe && (n.data instanceof ArrayBuffer || Se(n.data)))
35
- return e(be(n.data));
35
+ return e(Ee(n.data));
36
36
  ue(n, !1, (t) => {
37
37
  K || (K = new TextEncoder()), e(K.encode(t));
38
38
  });
39
39
  }
40
- const Ee = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", N = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
- for (let n = 0; n < Ee.length; n++)
42
- N[Ee.charCodeAt(n)] = n;
40
+ const be = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", N = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
41
+ for (let n = 0; n < be.length; n++)
42
+ N[be.charCodeAt(n)] = n;
43
43
  const He = (n) => {
44
44
  let e = n.length * 0.75, t = n.length, s, r = 0, i, o, h, l;
45
45
  n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
@@ -77,16 +77,16 @@ const He = (n) => {
77
77
  default:
78
78
  return n instanceof ArrayBuffer ? n : n.buffer;
79
79
  }
80
- }, Re = "", je = (n, e) => {
80
+ }, $e = "", je = (n, e) => {
81
81
  const t = n.length, s = new Array(t);
82
82
  let r = 0;
83
83
  n.forEach((i, o) => {
84
84
  ue(i, !1, (h) => {
85
- s[o] = h, ++r === t && e(s.join(Re));
85
+ s[o] = h, ++r === t && e(s.join($e));
86
86
  });
87
87
  });
88
88
  }, Ye = (n, e) => {
89
- const t = n.split(Re), s = [];
89
+ const t = n.split($e), s = [];
90
90
  for (let r = 0; r < t.length; r++) {
91
91
  const i = le(t[r], e);
92
92
  if (s.push(i), i.type === "error")
@@ -169,7 +169,7 @@ function We(n, e) {
169
169
  }
170
170
  });
171
171
  }
172
- const $e = 4;
172
+ const Re = 4;
173
173
  function g(n) {
174
174
  if (n) return ze(n);
175
175
  }
@@ -219,13 +219,13 @@ g.prototype.listeners = function(n) {
219
219
  g.prototype.hasListeners = function(n) {
220
220
  return !!this.listeners(n).length;
221
221
  };
222
- const H = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), b = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Xe = "arraybuffer";
222
+ const H = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), E = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Xe = "arraybuffer";
223
223
  function Be(n, ...e) {
224
224
  return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
225
225
  }
226
- const Qe = b.setTimeout, Ze = b.clearTimeout;
226
+ const Qe = E.setTimeout, Ze = E.clearTimeout;
227
227
  function G(n, e) {
228
- e.useNativeTimers ? (n.setTimeoutFn = Qe.bind(b), n.clearTimeoutFn = Ze.bind(b)) : (n.setTimeoutFn = b.setTimeout.bind(b), n.clearTimeoutFn = b.clearTimeout.bind(b));
228
+ e.useNativeTimers ? (n.setTimeoutFn = Qe.bind(E), n.clearTimeoutFn = Ze.bind(E)) : (n.setTimeoutFn = E.setTimeout.bind(E), n.clearTimeoutFn = E.clearTimeout.bind(E));
229
229
  }
230
230
  const et = 1.33;
231
231
  function tt(n) {
@@ -602,7 +602,7 @@ if (typeof document < "u") {
602
602
  if (typeof attachEvent == "function")
603
603
  attachEvent("onunload", Te);
604
604
  else if (typeof addEventListener == "function") {
605
- const n = "onpagehide" in b ? "pagehide" : "unload";
605
+ const n = "onpagehide" in E ? "pagehide" : "unload";
606
606
  addEventListener(n, Te, !1);
607
607
  }
608
608
  }
@@ -635,7 +635,7 @@ function Pe(n) {
635
635
  }
636
636
  if (!e)
637
637
  try {
638
- return new b[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
638
+ return new E[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
639
639
  } catch {
640
640
  }
641
641
  }
@@ -696,7 +696,7 @@ class ft extends fe {
696
696
  return this.opts.timestampRequests && (t[this.opts.timestampParam] = xe()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
697
697
  }
698
698
  }
699
- const z = b.WebSocket || b.MozWebSocket;
699
+ const z = E.WebSocket || E.MozWebSocket;
700
700
  class pt extends ft {
701
701
  createSocket(e, t, s) {
702
702
  return Le ? new z(e, t, s) : t ? new z(e, t) : new z(e);
@@ -795,7 +795,7 @@ const se = typeof addEventListener == "function" && typeof removeEventListener =
795
795
  se && addEventListener("offline", () => {
796
796
  U.forEach((n) => n());
797
797
  }, !1);
798
- class C extends g {
798
+ class $ extends g {
799
799
  /**
800
800
  * Socket constructor.
801
801
  *
@@ -841,7 +841,7 @@ class C extends g {
841
841
  */
842
842
  createTransport(e) {
843
843
  const t = Object.assign({}, this.opts.query);
844
- t.EIO = $e, t.transport = e, this.id && (t.sid = this.id);
844
+ t.EIO = Re, 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,
@@ -863,7 +863,7 @@ class C extends g {
863
863
  }, 0);
864
864
  return;
865
865
  }
866
- const e = this.opts.rememberUpgrade && C.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
866
+ const e = this.opts.rememberUpgrade && $.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
867
867
  this.readyState = "opening";
868
868
  const t = this.createTransport(e);
869
869
  t.open(), this.setTransport(t);
@@ -882,7 +882,7 @@ class C extends g {
882
882
  * @private
883
883
  */
884
884
  onOpen() {
885
- this.readyState = "open", C.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
885
+ this.readyState = "open", $.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
886
886
  }
887
887
  /**
888
888
  * Handles a packet.
@@ -1046,7 +1046,7 @@ class C extends g {
1046
1046
  * @private
1047
1047
  */
1048
1048
  _onError(e) {
1049
- if (C.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1049
+ if ($.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1050
1050
  return this.transports.shift(), this._open();
1051
1051
  this.emitReserved("error", e), this._onClose("transport error", e);
1052
1052
  }
@@ -1065,8 +1065,8 @@ class C extends g {
1065
1065
  }
1066
1066
  }
1067
1067
  }
1068
- C.protocol = $e;
1069
- class bt extends C {
1068
+ $.protocol = Re;
1069
+ class Et extends $ {
1070
1070
  constructor() {
1071
1071
  super(...arguments), this._upgrades = [];
1072
1072
  }
@@ -1083,14 +1083,14 @@ class bt extends C {
1083
1083
  */
1084
1084
  _probe(e) {
1085
1085
  let t = this.createTransport(e), s = !1;
1086
- C.priorWebsocketSuccess = !1;
1086
+ $.priorWebsocketSuccess = !1;
1087
1087
  const r = () => {
1088
1088
  s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (m) => {
1089
1089
  if (!s)
1090
1090
  if (m.type === "pong" && m.data === "probe") {
1091
1091
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
1092
1092
  return;
1093
- C.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1093
+ $.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1094
1094
  s || this.readyState !== "closed" && (d(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1095
1095
  });
1096
1096
  } else {
@@ -1138,7 +1138,7 @@ class bt extends C {
1138
1138
  return t;
1139
1139
  }
1140
1140
  }
1141
- let Et = class extends bt {
1141
+ let bt = class extends Et {
1142
1142
  constructor(e, t = {}) {
1143
1143
  const s = typeof e == "object" ? e : t;
1144
1144
  (!s.transports || s.transports && typeof s.transports[0] == "string") && (s.transports = (s.transports || ["polling", "websocket", "webtransport"]).map((r) => yt[r]).filter((r) => !!r)), super(e, s);
@@ -1213,7 +1213,7 @@ function re(n, e) {
1213
1213
  Object.prototype.hasOwnProperty.call(n, t) && (n[t] = re(n[t], e));
1214
1214
  return n;
1215
1215
  }
1216
- const Rt = [
1216
+ const $t = [
1217
1217
  "connect",
1218
1218
  // used on the client side
1219
1219
  "connect_error",
@@ -1227,11 +1227,11 @@ const Rt = [
1227
1227
  "removeListener"
1228
1228
  // used by the Node.js EventEmitter
1229
1229
  ];
1230
- var f;
1230
+ var p;
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
- })(f || (f = {}));
1234
- class $t {
1233
+ })(p || (p = {}));
1234
+ class Rt {
1235
1235
  /**
1236
1236
  * Encoder constructor
1237
1237
  *
@@ -1247,8 +1247,8 @@ class $t {
1247
1247
  * @param {Object} obj - packet object
1248
1248
  */
1249
1249
  encode(e) {
1250
- return (e.type === f.EVENT || e.type === f.ACK) && D(e) ? this.encodeAsBinary({
1251
- type: e.type === f.EVENT ? f.BINARY_EVENT : f.BINARY_ACK,
1250
+ return (e.type === p.EVENT || e.type === p.ACK) && D(e) ? this.encodeAsBinary({
1251
+ type: e.type === p.EVENT ? p.BINARY_EVENT : p.BINARY_ACK,
1252
1252
  nsp: e.nsp,
1253
1253
  data: e.data,
1254
1254
  id: e.id
@@ -1259,7 +1259,7 @@ class $t {
1259
1259
  */
1260
1260
  encodeAsString(e) {
1261
1261
  let t = "" + e.type;
1262
- return (e.type === f.BINARY_EVENT || e.type === f.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1262
+ return (e.type === p.BINARY_EVENT || e.type === p.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1263
1263
  }
1264
1264
  /**
1265
1265
  * Encode packet as 'buffer sequence' by removing blobs, and
@@ -1291,8 +1291,8 @@ class de extends g {
1291
1291
  if (this.reconstructor)
1292
1292
  throw new Error("got plaintext data when reconstructing a packet");
1293
1293
  t = this.decodeString(e);
1294
- const s = t.type === f.BINARY_EVENT;
1295
- s || t.type === f.BINARY_ACK ? (t.type = s ? f.EVENT : f.ACK, this.reconstructor = new Bt(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1294
+ const s = t.type === p.BINARY_EVENT;
1295
+ s || t.type === p.BINARY_ACK ? (t.type = s ? p.EVENT : p.ACK, this.reconstructor = new Bt(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1296
1296
  } else if (pe(e) || e.base64)
1297
1297
  if (this.reconstructor)
1298
1298
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
@@ -1312,9 +1312,9 @@ class de extends g {
1312
1312
  const s = {
1313
1313
  type: Number(e.charAt(0))
1314
1314
  };
1315
- if (f[s.type] === void 0)
1315
+ if (p[s.type] === void 0)
1316
1316
  throw new Error("unknown packet type " + s.type);
1317
- if (s.type === f.BINARY_EVENT || s.type === f.BINARY_ACK) {
1317
+ if (s.type === p.BINARY_EVENT || s.type === p.BINARY_ACK) {
1318
1318
  const i = t + 1;
1319
1319
  for (; e.charAt(++t) !== "-" && t != e.length; )
1320
1320
  ;
@@ -1362,17 +1362,17 @@ class de extends g {
1362
1362
  }
1363
1363
  static isPayloadValid(e, t) {
1364
1364
  switch (e) {
1365
- case f.CONNECT:
1365
+ case p.CONNECT:
1366
1366
  return ve(t);
1367
- case f.DISCONNECT:
1367
+ case p.DISCONNECT:
1368
1368
  return t === void 0;
1369
- case f.CONNECT_ERROR:
1369
+ case p.CONNECT_ERROR:
1370
1370
  return typeof t == "string" || ve(t);
1371
- case f.EVENT:
1372
- case f.BINARY_EVENT:
1373
- return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && Rt.indexOf(t[0]) === -1);
1374
- case f.ACK:
1375
- case f.BINARY_ACK:
1371
+ case p.EVENT:
1372
+ case p.BINARY_EVENT:
1373
+ return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && $t.indexOf(t[0]) === -1);
1374
+ case p.ACK:
1375
+ case p.BINARY_ACK:
1376
1376
  return Array.isArray(t);
1377
1377
  }
1378
1378
  }
@@ -1415,12 +1415,12 @@ function ve(n) {
1415
1415
  const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1416
1416
  __proto__: null,
1417
1417
  Decoder: de,
1418
- Encoder: $t,
1418
+ Encoder: Rt,
1419
1419
  get PacketType() {
1420
- return f;
1420
+ return p;
1421
1421
  }
1422
1422
  }, Symbol.toStringTag, { value: "Module" }));
1423
- function E(n, e, t) {
1423
+ function b(n, e, t) {
1424
1424
  return n.on(e, t), function() {
1425
1425
  n.off(e, t);
1426
1426
  };
@@ -1468,10 +1468,10 @@ class qe extends g {
1468
1468
  return;
1469
1469
  const e = this.io;
1470
1470
  this.subs = [
1471
- E(e, "open", this.onopen.bind(this)),
1472
- E(e, "packet", this.onpacket.bind(this)),
1473
- E(e, "error", this.onerror.bind(this)),
1474
- E(e, "close", this.onclose.bind(this))
1471
+ b(e, "open", this.onopen.bind(this)),
1472
+ b(e, "packet", this.onpacket.bind(this)),
1473
+ b(e, "error", this.onerror.bind(this)),
1474
+ b(e, "close", this.onclose.bind(this))
1475
1475
  ];
1476
1476
  }
1477
1477
  /**
@@ -1555,7 +1555,7 @@ class qe extends g {
1555
1555
  if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1556
1556
  return this._addToQueue(t), this;
1557
1557
  const o = {
1558
- type: f.EVENT,
1558
+ type: p.EVENT,
1559
1559
  data: t
1560
1560
  };
1561
1561
  if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
@@ -1663,7 +1663,7 @@ class qe extends g {
1663
1663
  */
1664
1664
  _sendConnectPacket(e) {
1665
1665
  this.packet({
1666
- type: f.CONNECT,
1666
+ type: p.CONNECT,
1667
1667
  data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
1668
1668
  });
1669
1669
  }
@@ -1709,21 +1709,21 @@ class qe extends g {
1709
1709
  onpacket(e) {
1710
1710
  if (e.nsp === this.nsp)
1711
1711
  switch (e.type) {
1712
- case f.CONNECT:
1712
+ case p.CONNECT:
1713
1713
  e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
1714
1714
  break;
1715
- case f.EVENT:
1716
- case f.BINARY_EVENT:
1715
+ case p.EVENT:
1716
+ case p.BINARY_EVENT:
1717
1717
  this.onevent(e);
1718
1718
  break;
1719
- case f.ACK:
1720
- case f.BINARY_ACK:
1719
+ case p.ACK:
1720
+ case p.BINARY_ACK:
1721
1721
  this.onack(e);
1722
1722
  break;
1723
- case f.DISCONNECT:
1723
+ case p.DISCONNECT:
1724
1724
  this.ondisconnect();
1725
1725
  break;
1726
- case f.CONNECT_ERROR:
1726
+ case p.CONNECT_ERROR:
1727
1727
  this.destroy();
1728
1728
  const s = new Error(e.data.message);
1729
1729
  s.data = e.data.data, this.emitReserved("connect_error", s);
@@ -1758,7 +1758,7 @@ class qe extends g {
1758
1758
  let s = !1;
1759
1759
  return function(...r) {
1760
1760
  s || (s = !0, t.packet({
1761
- type: f.ACK,
1761
+ type: p.ACK,
1762
1762
  id: e,
1763
1763
  data: r
1764
1764
  }));
@@ -1827,7 +1827,7 @@ class qe extends g {
1827
1827
  * @return self
1828
1828
  */
1829
1829
  disconnect() {
1830
- return this.connected && this.packet({ type: f.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1830
+ return this.connected && this.packet({ type: p.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1831
1831
  }
1832
1832
  /**
1833
1833
  * Alias for {@link disconnect()}.
@@ -2100,14 +2100,14 @@ class ie extends g {
2100
2100
  open(e) {
2101
2101
  if (~this._readyState.indexOf("open"))
2102
2102
  return this;
2103
- this.engine = new Et(this.uri, this.opts);
2103
+ this.engine = new bt(this.uri, this.opts);
2104
2104
  const t = this.engine, s = this;
2105
2105
  this._readyState = "opening", this.skipReconnect = !1;
2106
- const r = E(t, "open", function() {
2106
+ const r = b(t, "open", function() {
2107
2107
  s.onopen(), e && e();
2108
2108
  }), i = (h) => {
2109
2109
  this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), e ? e(h) : this.maybeReconnectOnOpen();
2110
- }, o = E(t, "error", i);
2110
+ }, o = b(t, "error", i);
2111
2111
  if (this._timeout !== !1) {
2112
2112
  const h = this._timeout, l = this.setTimeoutFn(() => {
2113
2113
  r(), i(new Error("timeout")), t.close();
@@ -2136,12 +2136,12 @@ class ie extends g {
2136
2136
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2137
2137
  const e = this.engine;
2138
2138
  this.subs.push(
2139
- E(e, "ping", this.onping.bind(this)),
2140
- E(e, "data", this.ondata.bind(this)),
2141
- E(e, "error", this.onerror.bind(this)),
2142
- E(e, "close", this.onclose.bind(this)),
2139
+ b(e, "ping", this.onping.bind(this)),
2140
+ b(e, "data", this.ondata.bind(this)),
2141
+ b(e, "error", this.onerror.bind(this)),
2142
+ b(e, "close", this.onclose.bind(this)),
2143
2143
  // @ts-ignore
2144
- E(this.decoder, "decoded", this.ondecoded.bind(this))
2144
+ b(this.decoder, "decoded", this.ondecoded.bind(this))
2145
2145
  );
2146
2146
  }
2147
2147
  /**
@@ -2326,8 +2326,8 @@ class Lt extends Error {
2326
2326
  this.name = "RequestError", this.status = t, this.code = i.code, this.details = i.details, this.body = r;
2327
2327
  }
2328
2328
  }
2329
- const T = "item/folder", p = "item", O = "processor", It = "npm-registry", R = "hidden", X = "FILE", Q = "TOOL", Z = "APP";
2330
- var a, ae, u, S, V, M, ce, he, Ue;
2329
+ const T = "item/folder", f = "item", O = "processor", It = "npm-registry", S = "hidden", X = "FILE", Q = "TOOL", Z = "APP";
2330
+ var a, ae, u, C, V, M, ce, he, Ue;
2331
2331
  const ye = class ye {
2332
2332
  /**
2333
2333
  * Creates a new EngineServicesClient instance.
@@ -2452,7 +2452,7 @@ const ye = class ye {
2452
2452
  */
2453
2453
  async listFiles(e) {
2454
2454
  const { folderId: t, archived: s, projectId: r } = e || {};
2455
- return t ? await c(this, a, u).call(this, "GET", `${T}/${t}/items`, { query: { itemType: X, archived: s } }) : await c(this, a, u).call(this, "GET", `${p}`, {
2455
+ return t ? await c(this, a, u).call(this, "GET", `${T}/${t}/items`, { query: { itemType: X, archived: s } }) : await c(this, a, u).call(this, "GET", `${f}`, {
2456
2456
  query: {
2457
2457
  itemType: X,
2458
2458
  archived: s,
@@ -2492,14 +2492,14 @@ const ye = class ye {
2492
2492
  * @param fileId - The file's unique identifier.
2493
2493
  */
2494
2494
  async archiveFile(e) {
2495
- return await c(this, a, u).call(this, "DELETE", `${p}/${e}`);
2495
+ return await c(this, a, u).call(this, "DELETE", `${f}/${e}`);
2496
2496
  }
2497
2497
  /**
2498
2498
  * Recovers a previously archived file.
2499
2499
  * @param fileId - The file's unique identifier.
2500
2500
  */
2501
2501
  async recoverFile(e) {
2502
- return await c(this, a, u).call(this, "PUT", `${p}/${e}/recover`);
2502
+ return await c(this, a, u).call(this, "PUT", `${f}/${e}/recover`);
2503
2503
  }
2504
2504
  /**
2505
2505
  * Downloads a file's content. Returns the raw fetch Response.
@@ -2519,7 +2519,7 @@ const ye = class ye {
2519
2519
  */
2520
2520
  async getFileVersionMetadata(e, t, s) {
2521
2521
  const { withDraft: r } = s || {};
2522
- return await c(this, a, u).call(this, "GET", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
2522
+ return await c(this, a, u).call(this, "GET", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
2523
2523
  query: {
2524
2524
  ...r && { withDraft: "true" }
2525
2525
  }
@@ -2532,7 +2532,7 @@ const ye = class ye {
2532
2532
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
2533
2533
  */
2534
2534
  async updateFileVersionMetadata(e, t, s) {
2535
- return await c(this, a, u).call(this, "PUT", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
2535
+ return await c(this, a, u).call(this, "PUT", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`, {
2536
2536
  body: JSON.stringify({ metadata: s }),
2537
2537
  contentType: "application/json"
2538
2538
  });
@@ -2543,7 +2543,7 @@ const ye = class ye {
2543
2543
  * @param versionTag - The version tag.
2544
2544
  */
2545
2545
  async deleteFileVersionMetadata(e, t) {
2546
- return await c(this, a, u).call(this, "DELETE", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`);
2546
+ return await c(this, a, u).call(this, "DELETE", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/metadata`);
2547
2547
  }
2548
2548
  // ─── Folders ─────────────────────────────────────────────────────
2549
2549
  /**
@@ -2617,7 +2617,7 @@ const ye = class ye {
2617
2617
  * @returns A fetch Response containing the ZIP data.
2618
2618
  */
2619
2619
  async downloadFolder(e) {
2620
- return await c(this, a, S).call(this, `${T}/${e}/download`);
2620
+ return await c(this, a, C).call(this, `${T}/${e}/download`);
2621
2621
  }
2622
2622
  // ─── Components ──────────────────────────────────────────────────
2623
2623
  /**
@@ -2632,7 +2632,7 @@ const ye = class ye {
2632
2632
  itemType: Q,
2633
2633
  ...s && { ShowVersions: s }
2634
2634
  }
2635
- }) : await c(this, a, u).call(this, "GET", `${p}`, {
2635
+ }) : await c(this, a, u).call(this, "GET", `${f}`, {
2636
2636
  query: {
2637
2637
  itemType: Q,
2638
2638
  ...s && { ShowVersions: s },
@@ -2685,7 +2685,7 @@ const ye = class ye {
2685
2685
  */
2686
2686
  async downloadComponentBundle(e, t) {
2687
2687
  const { versionTag: s, withDraft: r } = t || {};
2688
- return await c(this, a, S).call(this, `${p}/${e}/download/bundle`, {
2688
+ return await c(this, a, C).call(this, `${f}/${e}/download/bundle`, {
2689
2689
  query: {
2690
2690
  ...s && { versionTag: s },
2691
2691
  ...r && { withDraft: r }
@@ -2697,14 +2697,14 @@ const ye = class ye {
2697
2697
  * @param componentId - The component's unique identifier.
2698
2698
  */
2699
2699
  async archiveComponent(e) {
2700
- return await c(this, a, u).call(this, "DELETE", `${p}/${e}`);
2700
+ return await c(this, a, u).call(this, "DELETE", `${f}/${e}`);
2701
2701
  }
2702
2702
  /**
2703
2703
  * Recovers a previously archived component.
2704
2704
  * @param componentId - The component's unique identifier.
2705
2705
  */
2706
2706
  async recoverComponent(e) {
2707
- return await c(this, a, u).call(this, "PUT", `${p}/${e}/recover`);
2707
+ return await c(this, a, u).call(this, "PUT", `${f}/${e}/recover`);
2708
2708
  }
2709
2709
  // ─── Built-in Components ─────────────────────────────────────────
2710
2710
  /**
@@ -2713,7 +2713,7 @@ const ye = class ye {
2713
2713
  * @returns The component's JavaScript source code as a string.
2714
2714
  */
2715
2715
  async getBuiltInComponent(e) {
2716
- return await (await c(this, a, S).call(this, `built-in/${e}/bundle`)).text();
2716
+ return await (await c(this, a, C).call(this, `built-in/${e}/bundle`)).text();
2717
2717
  }
2718
2718
  /**
2719
2719
  * Fetches a built-in component bundle, evaluates it, and registers it
@@ -2816,7 +2816,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
2816
2816
  itemType: Z,
2817
2817
  ...s && { ShowVersions: s }
2818
2818
  }
2819
- }) : await c(this, a, u).call(this, "GET", `${p}`, {
2819
+ }) : await c(this, a, u).call(this, "GET", `${f}`, {
2820
2820
  query: {
2821
2821
  itemType: Z,
2822
2822
  ...s && { ShowVersions: s },
@@ -2851,7 +2851,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
2851
2851
  */
2852
2852
  async downloadAppBundle(e, t) {
2853
2853
  const { versionTag: s, withDraft: r } = t || {};
2854
- return await c(this, a, S).call(this, `${p}/${e}/download/bundle`, {
2854
+ return await c(this, a, C).call(this, `${f}/${e}/download/bundle`, {
2855
2855
  query: {
2856
2856
  ...s && { versionTag: s },
2857
2857
  ...r && { withDraft: r }
@@ -2863,7 +2863,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
2863
2863
  * @param appId - The app's unique identifier.
2864
2864
  */
2865
2865
  async archiveApp(e) {
2866
- return await c(this, a, u).call(this, "DELETE", `${p}/${e}`);
2866
+ return await c(this, a, u).call(this, "DELETE", `${f}/${e}`);
2867
2867
  }
2868
2868
  // ─── NPM Registry ────────────────────────────────────────────────
2869
2869
  /**
@@ -2995,7 +2995,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
2995
2995
  */
2996
2996
  async createHiddenFile(e, t) {
2997
2997
  const s = new FormData();
2998
- return s.append("file", e), s.append("parentItemId", t), await c(this, a, u).call(this, "POST", `${p}/${R}`, {
2998
+ return s.append("file", e), s.append("parentItemId", t), await c(this, a, u).call(this, "POST", `${f}/${S}`, {
2999
2999
  body: s
3000
3000
  });
3001
3001
  }
@@ -3011,7 +3011,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3011
3011
  const s = new FormData();
3012
3012
  for (const r of e)
3013
3013
  s.append("files", r);
3014
- return s.append("parentItemId", t), await c(this, a, u).call(this, "POST", `${p}/${R}/batch`, {
3014
+ return s.append("parentItemId", t), await c(this, a, u).call(this, "POST", `${f}/${S}/batch`, {
3015
3015
  body: s
3016
3016
  });
3017
3017
  }
@@ -3020,21 +3020,41 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3020
3020
  * @param hiddenId - The hidden file's unique identifier.
3021
3021
  */
3022
3022
  async deleteHiddenFile(e) {
3023
- return await c(this, a, u).call(this, "DELETE", `${p}/${R}/${e}`);
3023
+ return await c(this, a, u).call(this, "DELETE", `${f}/${S}/${e}`);
3024
3024
  }
3025
3025
  /**
3026
3026
  * Gets metadata for a hidden file.
3027
3027
  * @param hiddenId - The hidden file's unique identifier.
3028
3028
  */
3029
3029
  async getHiddenFile(e) {
3030
- return await c(this, a, u).call(this, "GET", `${p}/${R}/${e}`);
3030
+ return await c(this, a, u).call(this, "GET", `${f}/${S}/${e}`);
3031
3031
  }
3032
3032
  /**
3033
3033
  * Downloads a hidden file's content. Returns the raw fetch Response.
3034
3034
  * @param hiddenId - The hidden file's unique identifier.
3035
3035
  */
3036
3036
  async downloadHiddenFile(e) {
3037
- return await c(this, a, S).call(this, `${p}/${R}/${e}/download`);
3037
+ return await c(this, a, C).call(this, `${f}/${S}/${e}/download`);
3038
+ }
3039
+ /**
3040
+ * Mints a short-lived presigned URL for a hidden file so the browser can
3041
+ * stream it directly from storage with native HTTP `Range` requests (e.g. a
3042
+ * point-cloud `octree.bin`), instead of proxying the whole object through the
3043
+ * API. Re-call to re-mint when the URL nears/passes `expiresAt`; coalesce
3044
+ * concurrent re-mints into a single in-flight call.
3045
+ *
3046
+ * The storage bucket's CORS must allow the `Range` request header and expose
3047
+ * `Content-Range`, `Accept-Ranges` and `Content-Length` for the ranged fetch
3048
+ * to succeed cross-origin.
3049
+ *
3050
+ * @param hiddenId - The hidden file's unique identifier.
3051
+ * @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
3052
+ * 900 (15 min) server-side; values are clamped to that range.
3053
+ * @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
3054
+ * an ISO timestamp when it stops working.
3055
+ */
3056
+ async getHiddenFileSignedUrl(e, t) {
3057
+ return await c(this, a, u).call(this, "GET", `${f}/${S}/${e}/signed-url`, { ...t != null && { query: { expiresIn: t } } });
3038
3058
  }
3039
3059
  /**
3040
3060
  * Lists all hidden files attached to a parent item.
@@ -3042,14 +3062,14 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3042
3062
  * @returns Array of hidden file entities.
3043
3063
  */
3044
3064
  async getHiddenFilesByParent(e) {
3045
- return await c(this, a, u).call(this, "GET", `${p}/${e}/${R}`);
3065
+ return await c(this, a, u).call(this, "GET", `${f}/${e}/${S}`);
3046
3066
  }
3047
3067
  /**
3048
3068
  * Deletes all hidden files attached to a parent item.
3049
3069
  * @param parentFileId - The parent item's unique identifier.
3050
3070
  */
3051
3071
  async deleteHiddenFilesByParent(e) {
3052
- return await c(this, a, u).call(this, "DELETE", `${p}/${e}/${R}`);
3072
+ return await c(this, a, u).call(this, "DELETE", `${f}/${e}/${S}`);
3053
3073
  }
3054
3074
  // ─── Icons ───────────────────────────────────────────────────────
3055
3075
  /**
@@ -3061,7 +3081,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3061
3081
  */
3062
3082
  async uploadItemIcon(e, t) {
3063
3083
  const s = new FormData();
3064
- return s.append("icon", t), await c(this, a, u).call(this, "PUT", `${p}/${e}/icon`, { body: s });
3084
+ return s.append("icon", t), await c(this, a, u).call(this, "PUT", `${f}/${e}/icon`, { body: s });
3065
3085
  }
3066
3086
  /**
3067
3087
  * Downloads the icon for an item as a binary stream.
@@ -3069,7 +3089,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3069
3089
  * @returns The raw Response (use `.blob()`, `.arrayBuffer()`, or pipe the body).
3070
3090
  */
3071
3091
  async getItemIcon(e) {
3072
- return await c(this, a, S).call(this, `${p}/${e}/icon`);
3092
+ return await c(this, a, C).call(this, `${f}/${e}/icon`);
3073
3093
  }
3074
3094
  /**
3075
3095
  * Removes the icon from an item.
@@ -3077,7 +3097,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3077
3097
  * @returns The updated item with icon fields removed.
3078
3098
  */
3079
3099
  async removeItemIcon(e) {
3080
- return await c(this, a, u).call(this, "DELETE", `${p}/${e}/icon`);
3100
+ return await c(this, a, u).call(this, "DELETE", `${f}/${e}/icon`);
3081
3101
  }
3082
3102
  // ─── General Item Operations ─────────────────────────────────────
3083
3103
  /**
@@ -3087,7 +3107,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3087
3107
  * @returns The updated item.
3088
3108
  */
3089
3109
  async updateItem(e, t) {
3090
- return await c(this, a, u).call(this, "PUT", `${p}/${e}`, {
3110
+ return await c(this, a, u).call(this, "PUT", `${f}/${e}`, {
3091
3111
  body: JSON.stringify(t),
3092
3112
  contentType: "application/json"
3093
3113
  });
@@ -3104,7 +3124,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3104
3124
  */
3105
3125
  async createVersion(e, t, s, r, i) {
3106
3126
  const o = new FormData();
3107
- return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await c(this, a, u).call(this, "POST", `${p}/${e}/version`, { body: o });
3127
+ return o.append("file", t), o.append("versionTag", s), r && o.append("extraProps", JSON.stringify(r)), i && o.append("metadata", JSON.stringify(i)), await c(this, a, u).call(this, "POST", `${f}/${e}/version`, { body: o });
3108
3128
  }
3109
3129
  /**
3110
3130
  * Lists versions of an item. Pass `archived: true` to fetch only archived
@@ -3114,7 +3134,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3114
3134
  * @returns Array of versions, sorted by creation date descending.
3115
3135
  */
3116
3136
  async listVersions(e, t = {}) {
3117
- return await c(this, a, u).call(this, "GET", `${p}/${encodeURIComponent(e)}/versions`, { query: t });
3137
+ return await c(this, a, u).call(this, "GET", `${f}/${encodeURIComponent(e)}/versions`, { query: t });
3118
3138
  }
3119
3139
  /**
3120
3140
  * Archives a version of an item. Archived versions remain available via
@@ -3126,7 +3146,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3126
3146
  * @returns The archived version.
3127
3147
  */
3128
3148
  async archiveVersion(e, t) {
3129
- return await c(this, a, u).call(this, "PUT", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`);
3149
+ return await c(this, a, u).call(this, "PUT", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/archive`);
3130
3150
  }
3131
3151
  /**
3132
3152
  * Recovers a previously archived version, restoring it to the active list.
@@ -3135,7 +3155,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3135
3155
  * @returns The recovered version.
3136
3156
  */
3137
3157
  async recoverVersion(e, t) {
3138
- return await c(this, a, u).call(this, "PUT", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`);
3158
+ return await c(this, a, u).call(this, "PUT", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}/recover`);
3139
3159
  }
3140
3160
  /**
3141
3161
  * Permanently deletes a version, including its file in object storage.
@@ -3144,7 +3164,7 @@ return main;`)(...h), d = (y == null ? void 0 : y.componentDefinition) ?? y;
3144
3164
  * @param versionTag - The version's tag (e.g. "v2").
3145
3165
  */
3146
3166
  async deleteVersion(e, t) {
3147
- return await c(this, a, u).call(this, "DELETE", `${p}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`);
3167
+ return await c(this, a, u).call(this, "DELETE", `${f}/${encodeURIComponent(e)}/version/${encodeURIComponent(t)}`);
3148
3168
  }
3149
3169
  };
3150
3170
  a = new WeakSet(), ae = function(e) {
@@ -3186,7 +3206,7 @@ a = new WeakSet(), ae = function(e) {
3186
3206
  });
3187
3207
  throw w;
3188
3208
  }
3189
- }, S = async function(e, t) {
3209
+ }, C = async function(e, t) {
3190
3210
  const { query: s } = t || {}, r = c(this, a, ae).call(this, e), i = await this.resolveAccessToken(), o = {
3191
3211
  ...s,
3192
3212
  ...this.useBearer ? {} : { accessToken: i }
@@ -3202,7 +3222,7 @@ a = new WeakSet(), ae = function(e) {
3202
3222
  );
3203
3223
  }, V = async function(e, t) {
3204
3224
  const { versionTag: s, withDraft: r } = t || {};
3205
- return await c(this, a, S).call(this, `${p}/${e}/download`, {
3225
+ return await c(this, a, C).call(this, `${f}/${e}/download`, {
3206
3226
  query: {
3207
3227
  ...s && { versionTag: s },
3208
3228
  ...r && { withDraft: r }
@@ -3210,7 +3230,7 @@ a = new WeakSet(), ae = function(e) {
3210
3230
  });
3211
3231
  }, M = async function(e, t, s) {
3212
3232
  const { name: r, versionTag: i, parentFolderId: o, projectId: h, file: l, metadata: y } = e, d = new FormData();
3213
- return d.append("file", l), d.append("name", r), d.append("versionTag", i), d.append("itemType", t), o && d.append("folderId", o), h && d.append("projectId", h), s && d.append("extraProps", JSON.stringify(s)), y && d.append("metadata", JSON.stringify(y)), await c(this, a, u).call(this, "POST", p, {
3233
+ return d.append("file", l), d.append("name", r), d.append("versionTag", i), d.append("itemType", t), o && d.append("folderId", o), h && d.append("projectId", h), s && d.append("extraProps", JSON.stringify(s)), y && d.append("metadata", JSON.stringify(y)), await c(this, a, u).call(this, "POST", f, {
3214
3234
  body: d
3215
3235
  });
3216
3236
  }, ce = async function(e, t, s) {
@@ -3218,7 +3238,7 @@ a = new WeakSet(), ae = function(e) {
3218
3238
  let y, d;
3219
3239
  if (h) {
3220
3240
  const m = new FormData();
3221
- m.append("file", h), i && m.append("versionTag", i), s && m.append("extraProps", JSON.stringify(s)), l && m.append("metadata", JSON.stringify(l)), d = await c(this, a, u).call(this, "POST", `${p}/${e}/version`, {
3241
+ m.append("file", h), i && m.append("versionTag", i), s && m.append("extraProps", JSON.stringify(s)), l && m.append("metadata", JSON.stringify(l)), d = await c(this, a, u).call(this, "POST", `${f}/${e}/version`, {
3222
3242
  body: m
3223
3243
  });
3224
3244
  }
@@ -3227,7 +3247,7 @@ a = new WeakSet(), ae = function(e) {
3227
3247
  ...r && { name: r },
3228
3248
  ...o && { folderId: o }
3229
3249
  }, w = JSON.stringify(m);
3230
- y = await c(this, a, u).call(this, "PUT", `${p}/${e}`, {
3250
+ y = await c(this, a, u).call(this, "PUT", `${f}/${e}`, {
3231
3251
  body: w,
3232
3252
  contentType: "application/json"
3233
3253
  });
@@ -3235,7 +3255,7 @@ a = new WeakSet(), ae = function(e) {
3235
3255
  return { item: y, version: d };
3236
3256
  }, he = async function(e, t) {
3237
3257
  const { showVersions: s = !1 } = t || {};
3238
- return await c(this, a, u).call(this, "GET", `${p}/${e}`, {
3258
+ return await c(this, a, u).call(this, "GET", `${f}/${e}`, {
3239
3259
  query: { showVersions: s }
3240
3260
  });
3241
3261
  }, Ue = function(e) {
@@ -3246,7 +3266,7 @@ a = new WeakSet(), ae = function(e) {
3246
3266
  };
3247
3267
  let oe = ye;
3248
3268
  const I = "project";
3249
- var $;
3269
+ var R;
3250
3270
  const me = class me extends oe {
3251
3271
  /**
3252
3272
  * @param token - A bearer JWT, OR a function returning the current JWT
@@ -3258,11 +3278,11 @@ const me = class me extends oe {
3258
3278
  */
3259
3279
  constructor(t, s, r) {
3260
3280
  super(typeof t == "string" ? t : "", s, { ...r, useBearer: !0 });
3261
- Y(this, $);
3262
- typeof t == "function" && we(this, $, t);
3281
+ Y(this, R);
3282
+ typeof t == "function" && we(this, R, t);
3263
3283
  }
3264
3284
  async resolveAccessToken() {
3265
- return j(this, $) ? await j(this, $).call(this) : super.resolveAccessToken();
3285
+ return j(this, R) ? await j(this, R).call(this) : super.resolveAccessToken();
3266
3286
  }
3267
3287
  /**
3268
3288
  * Creates a client from the platform context injected into
@@ -3317,7 +3337,7 @@ const me = class me extends oe {
3317
3337
  })).results;
3318
3338
  }
3319
3339
  };
3320
- $ = new WeakMap();
3340
+ R = new WeakMap();
3321
3341
  let ke = me;
3322
3342
  const Dt = {
3323
3343
  MAX_FIELDS: 200,
@@ -114,6 +114,11 @@ Builds, zips (`dist/bundle.zip`), and uploads a new version to the platform —
114
114
  or a **component** (a component also ships its `declarations.json`). Re-run it any time to
115
115
  push a new version.
116
116
 
117
+ Once published, it shows up at **https://platform.thatopen.com/dashboard/data** — an **app**
118
+ under **Apps**, a **cloud component** under **Components**. Either way it isn't running
119
+ anywhere yet: to actually use it, **add it to one of your projects** from there. (A cloud
120
+ component, once added to a project, is then triggered by an app or an automation in it.)
121
+
117
122
  ---
118
123
 
119
124
  ## Rules for you, the assistant
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "access": "public"
16
16
  },
17
17
  "private": false,
18
- "version": "0.3.4",
18
+ "version": "0.3.6",
19
19
  "main": "dist/index.cjs.js",
20
20
  "module": "dist/index.es.js",
21
21
  "types": "dist/index.d.ts",
@@ -39,11 +39,6 @@
39
39
  "build:cli": "vite build --config vite.config.cli.mts",
40
40
  "preview": "vite preview",
41
41
  "test:ui": "vite --config test/vite.config.mts",
42
- "test:cli-build-app": "npm run build:cli && node test/setup-test-app.mjs",
43
- "test:cli-serve-app": "cd temp/test-app && thatopen serve",
44
- "test:cli-build-component": "npm run build:cli && node test/setup-test-component.mjs",
45
- "test:cli-run-component": "cd temp/test-component && thatopen run --skip-build",
46
- "test:cli-serve-component": "cd temp/test-component && thatopen local-server",
47
42
  "template:app": "cd src/cli/templates/app && npm install && cd ../../../.. && node scripts/generate-template-tsconfig.mjs",
48
43
  "template:app:dev": "cd src/cli/templates/app && npm run dev",
49
44
  "changeset": "changeset",
@@ -17,10 +17,11 @@
17
17
  "@thatopen/fragments": "~3.4.0",
18
18
  "@thatopen/services": "file:../../../..",
19
19
  "@thatopen/ui": "~3.4.4",
20
- "three": ">=0.182.0",
20
+ "three": "0.185.0",
21
21
  "@sparkjsdev/spark": "^0.1.10",
22
22
  "3d-tiles-renderer": "^0.4.28",
23
23
  "camera-controls": "^3.1.2",
24
+ "opentype.js": "1.3.4",
24
25
  "web-ifc": "^0.0.77"
25
26
  },
26
27
  "devDependencies": {
@@ -23,9 +23,21 @@ function getBetaAliases() {
23
23
  }
24
24
  }
25
25
 
26
+ // Some three.js example loaders (e.g. TTFLoader) import their deps from a
27
+ // jsdelivr `/+esm` CDN URL. A bundler can't put a URL import in an IIFE — it
28
+ // degrades to a runtime `require("https://…")` that throws — so rewrite any such
29
+ // URL back to the bare package name and let it resolve from node_modules.
30
+ const CDN_ESM = /^https:\/\/cdn\.jsdelivr\.net\/npm\/((?:@[^/]+\/)?[^@/]+)(?:@[^/]+)?\/\+esm$/;
31
+
26
32
  export default defineConfig({
27
33
  resolve: {
28
- alias: getBetaAliases(),
34
+ alias: [
35
+ { find: CDN_ESM, replacement: '$1' },
36
+ ...Object.entries(getBetaAliases()).map(([find, replacement]) => ({
37
+ find,
38
+ replacement,
39
+ })),
40
+ ],
29
41
  },
30
42
  build: {
31
43
  lib: {