@thatopen/services 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -941,6 +941,190 @@ export type FileList = InstanceType<typeof _FileList>;
941
941
  export declare const FileList: typeof _FileList & {
942
942
  uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c";
943
943
  };
944
+ /** One element mutation inside a revit-flow commit. */
945
+ export interface RevitFlowChange {
946
+ /** create → element added, update → geometry/data changed, delete → removed. */
947
+ type: "create" | "update" | "delete" | string;
948
+ /** Revit UniqueId (GUID). Resolves to a fragments localId via getLocalIdsByGuids. */
949
+ uniqueId: string;
950
+ }
951
+ /** Per-commit change tallies, mirrored from the add-in's `counts` block. */
952
+ export interface RevitFlowCounts {
953
+ added: number;
954
+ modified: number;
955
+ removed: number;
956
+ }
957
+ /**
958
+ * A revit-flow commit — one push of changes from the Revit add-in. `id` is a
959
+ * monotonic integer; `parent` points at the previous commit (null for the
960
+ * root). The commit whose scan was full (earliest with a .frag) carries the
961
+ * WHOLE model in `revitflow_frag_<id>.frag`; later frags are incremental.
962
+ */
963
+ export interface RevitFlowCommit {
964
+ id: number;
965
+ parent: number | null;
966
+ author: string;
967
+ source: string;
968
+ timestamp: string;
969
+ changes: RevitFlowChange[];
970
+ counts: RevitFlowCounts;
971
+ }
972
+ /** Shape of `revitflow_history.json`. */
973
+ export interface RevitFlowHistory {
974
+ model: string;
975
+ commits: RevitFlowCommit[];
976
+ }
977
+ /** Dominant change type of a commit, used to color its timeline node. */
978
+ export type DominantChange = "create" | "update" | "delete";
979
+ /** Dominant change type of a commit: delete → create → update. */
980
+ export declare function dominantChange(commit: RevitFlowCommit): DominantChange;
981
+ /**
982
+ * GitHistoryManager — headless engine for the revit-flow git-history built-in.
983
+ *
984
+ * Owns ALL viewer mutation: it fetches the commit history + fragment artifacts
985
+ * from project storage, loads the baseline (full-model) .frag into the shared
986
+ * viewer, and colors a commit's changed elements (create → green, update →
987
+ * blue, delete → red) via named Highlighter styles. The Lit panel
988
+ * (`top-git-history`) is intent-only: it calls these methods and subscribes to
989
+ * the events below, and never touches the Highlighter / FragmentsManager
990
+ * directly.
991
+ *
992
+ * Data model (per model, in `bimterop/revit-<docId>/`):
993
+ * - revitflow_history.json — { model, commits: [{ id, parent, author,
994
+ * source, timestamp, changes:[{type,uniqueId}], counts }] }
995
+ * - revitflow_frag_<N>.frag — fragments file for commit N. The earliest
996
+ * commit with a frag is the FULL model (baseline); later frags are
997
+ * incremental (only that commit's created+modified geometry).
998
+ */
999
+ declare class _GitHistoryManager extends OBC.Component {
1000
+ static readonly uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81";
1001
+ enabled: boolean;
1002
+ readonly onCommitsChanged: OBC.Event<RevitFlowCommit[]>;
1003
+ readonly onCommitChanged: OBC.Event<number | null>;
1004
+ readonly onLoadingChanged: OBC.Event<boolean>;
1005
+ readonly onError: OBC.Event<string>;
1006
+ world?: OBC.World;
1007
+ /** When true, showCommit() ghosts (dims) every non-changed element. */
1008
+ isolateChanges: boolean;
1009
+ /** Green — created elements. */
1010
+ readonly STYLE_CREATED = "#22c55e";
1011
+ /** Blue — modified elements. */
1012
+ readonly STYLE_MODIFIED = "#3b82f6";
1013
+ /** Red — deleted elements. */
1014
+ readonly STYLE_DELETED = "#ef4444";
1015
+ private _client?;
1016
+ private _projectId?;
1017
+ private _docFolderId?;
1018
+ private _modelName;
1019
+ private _commits;
1020
+ private _currentCommitId;
1021
+ /** filename(lowercase) → fileId, for the doc folder's current listing. */
1022
+ private _fileIndex;
1023
+ /** modelIds (== frag fileIds) already loaded into the viewer. */
1024
+ private _loadedFrags;
1025
+ /** Ghosted localIds per modelId, so isolate can be cleared/re-applied. */
1026
+ private _ghosted;
1027
+ private _baselineCommitId?;
1028
+ private _stylesRegistered;
1029
+ private _loading;
1030
+ constructor(components: OBC.Components);
1031
+ get ready(): boolean;
1032
+ get loading(): boolean;
1033
+ get commits(): RevitFlowCommit[];
1034
+ get currentCommitId(): number | null;
1035
+ get modelName(): string;
1036
+ get baselineCommitId(): number | undefined;
1037
+ /** True if commit `id` has a fragments file available in storage. */
1038
+ hasFrag(commitId: number): boolean;
1039
+ /**
1040
+ * Wire the platform client and load the commit history. Resolves the
1041
+ * viewer world in the background (it may not exist until <top-viewer>
1042
+ * mounts). Consumer panels call this once on connect.
1043
+ */
1044
+ init(client: PlatformClient): Promise<void>;
1045
+ /**
1046
+ * (Re)fetch `revitflow_history.json` from the project's
1047
+ * `bimterop/revit-*` folder and publish the commit list. Also indexes the
1048
+ * folder's files so frag lookups are a local map hit.
1049
+ */
1050
+ loadHistory(): Promise<void>;
1051
+ /**
1052
+ * Show commit `commitId`: ensure the baseline (full-model) .frag is loaded,
1053
+ * load the commit's own incremental frag (so created elements are present),
1054
+ * then color its changed elements. Deleted elements that no longer exist in
1055
+ * any loaded model are skipped. Fires onCommitChanged.
1056
+ */
1057
+ showCommit(commitId: number): Promise<void>;
1058
+ /** Remove all revit-flow coloring + ghosting and reset the selection. */
1059
+ clear(): Promise<void>;
1060
+ /** Toggle isolate mode; re-applies to the current commit if one is shown. */
1061
+ setIsolateChanges(on: boolean): Promise<void>;
1062
+ private _colorStyle;
1063
+ private _registerStyles;
1064
+ private _clearHighlights;
1065
+ /**
1066
+ * Resolve each change bucket's GUIDs to localIds across every loaded model
1067
+ * and paint them with the matching named style.
1068
+ */
1069
+ private _colorCommit;
1070
+ /** GUIDs → { modelId: Set<localId> } across the given models. */
1071
+ private _buildMap;
1072
+ private _mergeMaps;
1073
+ private _ghostAllExcept;
1074
+ private _clearGhost;
1075
+ private _ensureBaselineLoaded;
1076
+ /** Load commit `commitId`'s .frag into the viewer under modelId == fileId. */
1077
+ private _ensureFragLoaded;
1078
+ /**
1079
+ * Resolve (and cache) the `bimterop/revit-*` doc subfolder id. Filters the
1080
+ * project-wide folder list locally by parentId + name prefix, mirroring the
1081
+ * SnapshotList prototype (the server-side parentFolderId filter is
1082
+ * unreliable). Returns null if the project hasn't been pushed to yet.
1083
+ */
1084
+ private _resolveDocFolderId;
1085
+ private _setLoading;
1086
+ private _firstWorld;
1087
+ }
1088
+ /**
1089
+ * GitHistoryManager — headless engine for the revit-flow git-history built-in.
1090
+ *
1091
+ * Owns ALL viewer mutation: it fetches the commit history + fragment artifacts
1092
+ * from project storage, loads the baseline (full-model) .frag into the shared
1093
+ * viewer, and colors a commit's changed elements (create → green, update →
1094
+ * blue, delete → red) via named Highlighter styles. The Lit panel
1095
+ * (`top-git-history`) is intent-only: it calls these methods and subscribes to
1096
+ * the events below, and never touches the Highlighter / FragmentsManager
1097
+ * directly.
1098
+ *
1099
+ * Data model (per model, in `bimterop/revit-<docId>/`):
1100
+ * - revitflow_history.json — { model, commits: [{ id, parent, author,
1101
+ * source, timestamp, changes:[{type,uniqueId}], counts }] }
1102
+ * - revitflow_frag_<N>.frag — fragments file for commit N. The earliest
1103
+ * commit with a frag is the FULL model (baseline); later frags are
1104
+ * incremental (only that commit's created+modified geometry).
1105
+ */
1106
+ export type GitHistoryManager = InstanceType<typeof _GitHistoryManager>;
1107
+ /**
1108
+ * GitHistoryManager — headless engine for the revit-flow git-history built-in.
1109
+ *
1110
+ * Owns ALL viewer mutation: it fetches the commit history + fragment artifacts
1111
+ * from project storage, loads the baseline (full-model) .frag into the shared
1112
+ * viewer, and colors a commit's changed elements (create → green, update →
1113
+ * blue, delete → red) via named Highlighter styles. The Lit panel
1114
+ * (`top-git-history`) is intent-only: it calls these methods and subscribes to
1115
+ * the events below, and never touches the Highlighter / FragmentsManager
1116
+ * directly.
1117
+ *
1118
+ * Data model (per model, in `bimterop/revit-<docId>/`):
1119
+ * - revitflow_history.json — { model, commits: [{ id, parent, author,
1120
+ * source, timestamp, changes:[{type,uniqueId}], counts }] }
1121
+ * - revitflow_frag_<N>.frag — fragments file for commit N. The earliest
1122
+ * commit with a frag is the FULL model (baseline); later frags are
1123
+ * incremental (only that commit's created+modified geometry).
1124
+ */
1125
+ export declare const GitHistoryManager: typeof _GitHistoryManager & {
1126
+ uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81";
1127
+ };
944
1128
  /**
945
1129
  * A simple test component to validate the built-in component pipeline.
946
1130
  * Replace this with real components once the infrastructure is verified.
@@ -0,0 +1,11 @@
1
+ import { Command } from 'commander';
2
+
3
+ /**
4
+ * `thatopen rhino ...` — installs the That Open Rhino plug-in.
5
+ *
6
+ * Deliberately much smaller than the Revit group. The Rhino plug-in's whole job in the
7
+ * interoperability layer is to PUBLISH what Rhino has; it applies nothing, so there is nothing to
8
+ * drive from here. Everything that turns a Rhino model into a change in somebody else's model lives
9
+ * in the platform, not in a plug-in.
10
+ */
11
+ export declare const rhinoCommand: Command;
@@ -0,0 +1,24 @@
1
+ import { EngineServicesClient } from '../../core/client';
2
+
3
+ /**
4
+ * Downloads a private plug-in package and hands back the folder it unpacked into.
5
+ *
6
+ * npm does the work on purpose. It resolves what "latest" means, it authenticates against the
7
+ * restricted scope, and it verifies the tarball's integrity — three things this would otherwise
8
+ * hand-roll over HTTP and get subtly wrong. The only thing we add is the platform token, which
9
+ * `setupNpmrc` trades for registry credentials exactly as the `--beta` flows do. No npm account is
10
+ * involved and no npm token is ever asked for.
11
+ */
12
+ export declare function fetchPluginPackage(client: EngineServicesClient, pkg: string, version?: string): Promise<{
13
+ dir: string;
14
+ cleanup: () => void;
15
+ }>;
16
+ /**
17
+ * Refuses to install while the host application is running.
18
+ *
19
+ * This is not caution, it is the difference between a failed install and a broken one. Both Revit
20
+ * and Rhino hold their plug-in assemblies open for the whole session, so a copy over a running host
21
+ * fails on the first locked file — AFTER copying the ones it reached. The result is a folder holding
22
+ * some new DLLs and some old, which loads, misbehaves, and looks like a bug in the product.
23
+ */
24
+ export declare function assertHostClosed(processName: string, friendly: string): void;
package/dist/cli.js CHANGED
@@ -11686,6 +11686,60 @@ const swapCommand = new Command2("swap").description("Toggle between stable publ
11686
11686
  console.error("Failed to install dependencies. Run `npm install` manually.");
11687
11687
  }
11688
11688
  });
11689
+ async function fetchPluginPackage(client, pkg2, version = "latest") {
11690
+ const work = require$$3.mkdtempSync(require$$2.join(node_os.tmpdir(), "thatopen-plugin-"));
11691
+ const cleanup = () => {
11692
+ try {
11693
+ require$$3.rmSync(work, { recursive: true, force: true });
11694
+ } catch {
11695
+ }
11696
+ };
11697
+ try {
11698
+ const creds = await setupNpmrc(client, work);
11699
+ if (creds.status === "forbidden") {
11700
+ throw new Error(
11701
+ "Your account does not have access to the private plug-in packages. They need Founding access, the same as the beta engine libraries."
11702
+ );
11703
+ }
11704
+ if (creds.status === "error") {
11705
+ throw new Error(`Could not get registry credentials: ${creds.message}`);
11706
+ }
11707
+ require$$1.execFileSync("npm", ["pack", `${pkg2}@${version}`, "--silent"], {
11708
+ cwd: work,
11709
+ stdio: ["ignore", "ignore", "inherit"],
11710
+ shell: process.platform === "win32"
11711
+ });
11712
+ const tgz = require$$3.readdirSync(work).find((f) => f.endsWith(".tgz"));
11713
+ if (!tgz) throw new Error(`npm pack produced no tarball for ${pkg2}@${version}.`);
11714
+ require$$1.execFileSync("tar", ["-xzf", tgz], { cwd: work, stdio: "inherit" });
11715
+ const dir = require$$2.join(work, "package");
11716
+ if (!require$$3.existsSync(dir)) throw new Error(`${tgz} did not unpack into a package/ folder.`);
11717
+ return { dir, cleanup };
11718
+ } catch (err) {
11719
+ cleanup();
11720
+ throw err;
11721
+ }
11722
+ }
11723
+ function assertHostClosed(processName, friendly) {
11724
+ let running = false;
11725
+ try {
11726
+ const out = require$$1.execFileSync(
11727
+ "powershell",
11728
+ ["-NoProfile", "-Command", `if (Get-Process -Name ${processName} -ErrorAction SilentlyContinue) { 'yes' }`],
11729
+ { encoding: "utf-8" }
11730
+ );
11731
+ running = out.trim() === "yes";
11732
+ } catch {
11733
+ return;
11734
+ }
11735
+ if (running) {
11736
+ throw new Error(
11737
+ `${friendly} is running. Close it and run this again.
11738
+
11739
+ Its plug-in files are locked while it is open, so installing now would replace some of them and not others.`
11740
+ );
11741
+ }
11742
+ }
11689
11743
  function discoveryFile() {
11690
11744
  const appData = process.env.APPDATA || require$$2.join(node_os.homedir(), "AppData", "Roaming");
11691
11745
  return require$$2.join(appData, "ThatOpen", "revit-addin.json");
@@ -11746,6 +11800,7 @@ async function configureAddin(apiUrl, accessToken) {
11746
11800
  key: accessToken
11747
11801
  });
11748
11802
  }
11803
+ const REVIT_ADDIN_PACKAGE = "@thatopen-platform/flow-revit";
11749
11804
  const revitCommand = new Command2("revit").description(
11750
11805
  "Revit collaboration — drive the That Open Revit add-in from the CLI"
11751
11806
  );
@@ -11829,6 +11884,70 @@ revitCommand.command("untake").description("Release a workset you own so teammat
11829
11884
  const r = await callAddin("untake", { workset: opts.workset });
11830
11885
  console.log(`Released workset "${r.released}".`);
11831
11886
  });
11887
+ revitCommand.command("install").alias("update").description("Install or update the That Open Revit add-in (Revit must be closed)").option("--version <version>", "A specific version instead of the latest", "latest").action(async (opts) => {
11888
+ const cfg = requireResolvedConfig();
11889
+ assertHostClosed("Revit", "Revit");
11890
+ const client = new EngineServicesClient(cfg.accessToken, cfg.apiUrl);
11891
+ console.log(`Fetching ${REVIT_ADDIN_PACKAGE}@${opts.version}...`);
11892
+ const { dir, cleanup } = await fetchPluginPackage(
11893
+ client,
11894
+ REVIT_ADDIN_PACKAGE,
11895
+ opts.version
11896
+ );
11897
+ try {
11898
+ const installer = require$$2.join(dir, "install.ps1");
11899
+ if (!require$$3.existsSync(installer)) {
11900
+ throw new Error(`The package has no install.ps1. Got: ${require$$3.readdirSync(dir).join(", ")}`);
11901
+ }
11902
+ require$$1.execFileSync("powershell", ["-ExecutionPolicy", "Bypass", "-File", installer], {
11903
+ stdio: "inherit"
11904
+ });
11905
+ console.log("\nStart Revit. The That Open tab will be there.");
11906
+ } finally {
11907
+ cleanup();
11908
+ }
11909
+ });
11910
+ const RHINO_PLUGIN_PACKAGE = "@thatopen-platform/flow-rhino";
11911
+ const rhinoCommand = new Command2("rhino").description(
11912
+ "Rhino interoperability — install the That Open Rhino plug-in"
11913
+ );
11914
+ rhinoCommand.command("install").alias("update").description("Install or update the That Open Rhino plug-in (Rhino must be closed)").option("--version <version>", "A specific version instead of the latest", "latest").action(async (opts) => {
11915
+ const cfg = requireResolvedConfig();
11916
+ assertHostClosed("Rhino", "Rhino");
11917
+ const yak = findYak();
11918
+ if (!yak) {
11919
+ throw new Error(
11920
+ "Could not find Yak.exe. It ships with Rhino, at C:\\Program Files\\Rhino 8\\System\\Yak.exe. Is Rhino 8 installed?"
11921
+ );
11922
+ }
11923
+ const client = new EngineServicesClient(cfg.accessToken, cfg.apiUrl);
11924
+ console.log(`Fetching ${RHINO_PLUGIN_PACKAGE}@${opts.version}...`);
11925
+ const { dir, cleanup } = await fetchPluginPackage(client, RHINO_PLUGIN_PACKAGE, opts.version);
11926
+ try {
11927
+ const pkgDir = require$$2.join(dir, "pkg");
11928
+ const yakFile = require$$3.existsSync(pkgDir) ? require$$3.readdirSync(pkgDir).find((f) => f.endsWith(".yak")) : void 0;
11929
+ if (!yakFile) {
11930
+ throw new Error(`The package has no .yak under pkg/. Got: ${require$$3.readdirSync(dir).join(", ")}`);
11931
+ }
11932
+ require$$1.execFileSync(yak, ["install", "--source", ".", "rhino-flow"], {
11933
+ cwd: pkgDir,
11934
+ stdio: "inherit"
11935
+ });
11936
+ console.log(`
11937
+ Installed ${yakFile}.`);
11938
+ console.log("Start Rhino. The plug-in loads at startup, so its local server comes up with it.");
11939
+ } finally {
11940
+ cleanup();
11941
+ }
11942
+ });
11943
+ function findYak() {
11944
+ const candidates = [
11945
+ "C:\\Program Files\\Rhino 8\\System\\Yak.exe",
11946
+ "C:\\Program Files\\Rhino 9\\System\\Yak.exe",
11947
+ "C:\\Program Files\\Rhino 8 WIP\\System\\Yak.exe"
11948
+ ];
11949
+ return candidates.find((p) => require$$3.existsSync(p));
11950
+ }
11832
11951
  const pkg = JSON.parse(
11833
11952
  require$$3.readFileSync(require$$2.join(__dirname, "..", "package.json"), "utf-8")
11834
11953
  );
@@ -11857,4 +11976,5 @@ program.addCommand(runCommand);
11857
11976
  program.addCommand(localServerCommand);
11858
11977
  program.addCommand(swapCommand);
11859
11978
  program.addCommand(revitCommand);
11979
+ program.addCommand(rhinoCommand);
11860
11980
  program.parse(process.argv);
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use strict";var Ve=Object.defineProperty;var _e=n=>{throw TypeError(n)};var He=(n,e,t)=>e in n?Ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t),Y=(n,e,t)=>e.has(n)||_e("Cannot "+t);var K=(n,e,t)=>(Y(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>e.has(n)?_e("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),be=(n,e,t,s)=>(Y(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t),c=(n,e,t)=>(Y(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=Object.create(null);v.open="0";v.close="1";v.ping="2";v.pong="3";v.message="4";v.upgrade="5";v.noop="6";const U=Object.create(null);Object.keys(v).forEach(n=>{U[v[n]]=n});const se={type:"error",data:"parser error"},Oe=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Se=typeof ArrayBuffer=="function",Ce=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,fe=({type:n,data:e},t,s)=>Oe&&e instanceof Blob?t?s(e):Ee(e,s):Se&&(e instanceof ArrayBuffer||Ce(e))?t?s(e):Ee(new Blob([e]),s):s(v[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 Te(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let z;function Ge(n,e){if(Oe&&n.data instanceof Blob)return n.data.arrayBuffer().then(Te).then(e);if(Se&&(n.data instanceof ArrayBuffer||Ce(n.data)))return e(Te(n.data));fe(n,!1,t=>{z||(z=new TextEncoder),e(z.encode(t))})}const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<ve.length;n++)P[ve.charCodeAt(n)]=n;const je=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=P[n.charCodeAt(s)],o=P[n.charCodeAt(s+1)],h=P[n.charCodeAt(s+2)],l=P[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",pe=(n,e)=>{if(typeof n!="string")return{type:"message",data:$e(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:Ye(n.substring(1),e)}:U[t]?n.length>1?{type:U[t],data:n.substring(1)}:{type:U[t]}:se},Ye=(n,e)=>{if(Je){const t=je(n);return $e(t,e)}else return{base64:!0,data:n}},$e=(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="",Ke=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{fe(i,!1,h=>{s[o]=h,++r===t&&e(s.join(Re))})})},We=(n,e)=>{const t=n.split(Re),s=[];for(let r=0;r<t.length;r++){const i=pe(t[r],e);if(s.push(i),i.type==="error")break}return s};function ze(){return new TransformStream({transform(n,e){Ge(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 X;function I(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 Xe(n,e){X||(X=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(I(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(I(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(I(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(se);break}r=d*Math.pow(2,32)+y.getUint32(4),s=3}else{if(I(t)<r)break;const l=L(t,r);h.enqueue(pe(i?l:X.decode(l),e)),s=0}if(r===0||r>n){h.enqueue(se);break}}}})}const Be=4;function g(n){if(n)return Qe(n)}function Qe(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 j=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),_=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Ze="arraybuffer";function xe(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const et=_.setTimeout,tt=_.clearTimeout;function J(n,e){e.useNativeTimers?(n.setTimeoutFn=et.bind(_),n.clearTimeoutFn=tt.bind(_)):(n.setTimeoutFn=_.setTimeout.bind(_),n.clearTimeoutFn=_.clearTimeout.bind(_))}const st=1.33;function nt(n){return typeof n=="string"?rt(n):Math.ceil((n.byteLength||n.size)*st)}function rt(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 Ne(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function it(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function ot(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 at extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class de 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 at(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=pe(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=it(e);return t.length?"?"+t:""}}class ct extends de{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)};We(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,Ke(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]=Ne()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Pe=!1;try{Pe=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const ht=Pe;function ut(){}class lt extends ct{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 T 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=xe(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=T.requestsCount++,T.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=ut,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete T.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()}}T.requestsCount=0;T.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ke);else if(typeof addEventListener=="function"){const n="onpagehide"in _?"pagehide":"unload";addEventListener(n,ke,!1)}}function ke(){for(let n in T.requests)T.requests.hasOwnProperty(n)&&T.requests[n].abort()}const ft=function(){const n=Ie({xdomain:!1});return n&&n.responseType!==null}();class pt extends lt{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=ft&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new T(Ie,this.uri(),e)}}function Ie(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||ht))return new XMLHttpRequest}catch{}if(!e)try{return new _[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Le=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class dt extends de{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Le?{}:xe(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;fe(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&j(()=>{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]=Ne()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const Q=_.WebSocket||_.MozWebSocket;class yt extends dt{createSocket(e,t,s){return Le?new Q(e,t,s):t?new Q(e,t):new Q(e)}doWrite(e,t){this.ws.send(t)}}class mt extends de{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=Xe(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=ze();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&&j(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const gt={websocket:yt,webtransport:mt,polling:pt},wt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,_t=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ne(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=wt.exec(n||""),i={},o=14;for(;o--;)i[_t[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=bt(i,i.path),i.queryKey=Et(i,i.query),i}function bt(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 re=typeof addEventListener=="function"&&typeof removeEventListener=="function",D=[];re&&addEventListener("offline",()=>{D.forEach(n=>n())},!1);class R extends g{constructor(e,t){if(super(),this.binaryType=Ze,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=ne(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=ne(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=ot(this.opts.query)),re&&(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"})},D.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=Be,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&&R.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",R.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+=nt(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,j(()=>{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(R.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(),re&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=D.indexOf(this._offlineEventListener);s!==-1&&D.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}R.protocol=Be;class Tt extends R{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;R.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;R.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 k=new Error("probe error");k.transport=t.name,this.emitReserved("upgradeError",k)}}))};function i(){s||(s=!0,d(),t.close(),t=null)}const o=m=>{const k=new Error("probe error: "+m);k.transport=t.name,i(),this.emitReserved("upgradeError",k)};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 vt=class extends Tt{constructor(e,t={}){const s=typeof e=="object",r=s?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>gt[i]).filter(i=>!!i)),super(s?r:e,r)}};function kt(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=ne(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 At=typeof ArrayBuffer=="function",Ot=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,qe=Object.prototype.toString,St=typeof Blob=="function"||typeof Blob<"u"&&qe.call(Blob)==="[object BlobConstructor]",Ct=typeof File=="function"||typeof File<"u"&&qe.call(File)==="[object FileConstructor]";function ye(n){return At&&(n instanceof ArrayBuffer||Ot(n))||St&&n instanceof Blob||Ct&&n instanceof File}function F(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(F(n[t]))return!0;return!1}if(ye(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return F(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&F(n[t]))return!0;return!1}function $t(n){const e=[],t=n.data,s=n;return s.data=ie(t,e),s.attachments=e.length,{packet:s,buffers:e}}function ie(n,e){if(!n)return n;if(ye(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]=ie(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]=ie(n[s],e));return t}return n}function Rt(n,e){return n.data=oe(n.data,e),delete n.attachments,n}function oe(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]=oe(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=oe(n[t],e));return n}const Bt=["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 xt{constructor(e){this.replacer=e}encode(e){return(e.type===p.EVENT||e.type===p.ACK)&&F(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=$t(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}class me extends g{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}: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 Nt(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ye(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");const h=Number(o);if(!Pt(h)||h<0)throw new Error("Illegal attachments");if(h>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=h}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(me.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case p.CONNECT:return Ae(t);case p.DISCONNECT:return t===void 0;case p.CONNECT_ERROR:return typeof t=="string"||Ae(t);case p.EVENT:case p.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Bt.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 Nt{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=[]}}const Pt=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function Ae(n){return Object.prototype.toString.call(n)==="[object Object]"}const It=Object.freeze(Object.defineProperty({__proto__:null,Decoder:me,Encoder:xt,get PacketType(){return p}},Symbol.toStringTag,{value:"Module"}));function b(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const Lt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ue 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(Lt.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 x(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}x.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};x.prototype.reset=function(){this.attempts=0};x.prototype.setMin=function(n){this.ms=n};x.prototype.setMax=function(n){this.max=n};x.prototype.setJitter=function(n){this.jitter=n};class ae 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 x({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||It;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 vt(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){j(()=>{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 Ue(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 N={};function M(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=kt(n,e.path||"/socket.io"),s=t.source,r=t.id,i=t.path,o=N[r]&&i in N[r].nsps,h=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return h?l=new ae(s,e):(N[r]||(N[r]=new ae(s,e)),l=N[r]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(M,{Manager:ae,Socket:Ue,io:M,connect:M});function qt(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 De extends Error{constructor(t,s,r){const i=qt(r);super(i.message??`${s||"Request failed"} (${t})`);w(this,"status");w(this,"code");w(this,"details");w(this,"body");this.name="RequestError",this.status=t,this.code=i.code,this.details=i.details,this.body=r}}const E="item/folder",f="item",S="processor",Ut="npm-registry",C="hidden",Z="FILE",ee="TOOL",te="APP";var a,ce,u,$,V,H,he,ue,Fe;const ge=class ge{constructor(e,t,s){W(this,a);w(this,"apiUrl");w(this,"accessToken");w(this,"wsUrl");w(this,"retries");w(this,"useBearer");w(this,"builtInGlobals",null);w(this,"localServerUrl",null);w(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 ge(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",`${E}/${t}/items`,{query:{itemType:Z,archived:s}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:Z,archived:s,...r&&{projectId:r}}})}async getFile(e,t){return await c(this,a,ue).call(this,e,t)}async createFile(e){return await c(this,a,H).call(this,e,Z)}async updateFile(e,t){return await c(this,a,he).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,V).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",E,{query:{parentFolderId:s,archived:t,...r&&{projectId:r}}})}async getFolder(e){return await c(this,a,u).call(this,"GET",`${E}/${e}`)}async createFolder(e,t,s){return await c(this,a,u).call(this,"POST",E,{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",`${E}/${e}`,{body:JSON.stringify({name:s}),contentType:"application/json"})}async archiveFolder(e){return await c(this,a,u).call(this,"DELETE",`${E}/${e}`)}async recoverFolder(e){return await c(this,a,u).call(this,"PUT",`${E}/${e}/recover`)}async downloadFolder(e){return await c(this,a,$).call(this,`${E}/${e}/download`)}async listComponents(e){const{folderId:t,ShowVersions:s,projectId:r}=e||{};return t?await c(this,a,u).call(this,"GET",`${E}/${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 getComponent(e,t){return await c(this,a,ue).call(this,e,t)}async createComponent(e){const{componentProps:t}=e;return await c(this,a,H).call(this,e,ee,t)}async updateComponent(e,t){const{componentProps:s}=t;return await c(this,a,he).call(this,e,t,s)}async downloadComponent(e,t){return await c(this,a,V).call(this,e,t)}async downloadComponentBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,$).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,$).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",`${E}/${t}/items`,{query:{itemType:te,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:te,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async createApp(e){const{appProps:t}=e;return await c(this,a,H).call(this,e,te,t)}async downloadApp(e,t){return await c(this,a,V).call(this,e,t)}async downloadAppBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,$).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",`${Ut}/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 M(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}/${C}`,{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}/${C}/batch`,{body:s})}async deleteHiddenFile(e){return await c(this,a,u).call(this,"DELETE",`${f}/${C}/${e}`)}async getHiddenFile(e){return await c(this,a,u).call(this,"GET",`${f}/${C}/${e}`)}async downloadHiddenFile(e){return await c(this,a,$).call(this,`${f}/${C}/${e}/download`)}async getHiddenFileSignedUrl(e,t){return await c(this,a,u).call(this,"GET",`${f}/${C}/${e}/signed-url`,{...t!=null&&{query:{expiresIn:t}}})}async getHiddenFilesByParent(e){return await c(this,a,u).call(this,"GET",`${f}/${e}/${C}`)}async deleteHiddenFilesByParent(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}/${C}`)}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,$).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,ce=function(e){return`${this.apiUrl}/${e}`},u=async function(e,t,s){const{body:r,query:i,contentType:o,retries:h,responseType:l}=s||{},y=c(this,a,ce).call(this,t),d=c(this,a,Fe).call(this,i),m=await this.resolveAccessToken(),k={...d,...this.useBearer?{}:{accessToken:m}};try{const A=await fetch(y+"?"+new URLSearchParams(k).toString(),{method:e,headers:{Accept:"application/json",...o&&{"Content-Type":o},...this.useBearer&&{Authorization:`Bearer ${m}`}},...r&&{body:r}});if(!A.ok){const O=await A.text().then(Me=>Me).catch(()=>"");throw new De(A.status,A.statusText,O)}return l==="blob"?await A.blob():A.json().then(O=>O).catch(()=>{})}catch(A){let O=h??this.retries;if(O)return O=O-1,await c(this,a,u).call(this,e,t,{...s,retries:O});throw A}},$=async function(e,t){const{query:s}=t||{},r=c(this,a,ce).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}`}}})},V=async function(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,$).call(this,`${f}/${e}/download`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})},H=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})},he=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}},k=JSON.stringify(m);y=await c(this,a,u).call(this,"PUT",`${f}/${e}`,{body:k,contentType:"application/json"})}return{item:y,version:d}},ue=async function(e,t){const{showVersions:s=!1}=t||{};return await c(this,a,u).call(this,"GET",`${f}/${e}`,{query:{showVersions:s}})},Fe=function(e){return e&&Object.entries(e).filter(([,t])=>t!==void 0).reduce((t,[s,r])=>(t[s]=r,t),{})};let G=ge;const q="project";var B;const we=class we extends G{constructor(t,s,r){super(typeof t=="string"?t:"",s,{...r,useBearer:!0});W(this,B);typeof t=="function"&&be(this,B,t)}async resolveAccessToken(){return K(this,B)?await K(this,B).call(this):super.resolveAccessToken()}static fromPlatformContext(t){const s=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},r=new we(s.accessToken,s.apiUrl,t);return r.context=s,r}async getProject(t){return await this.request("GET",`${q}/${t}`)}async getProjectData(t){return await this.request("GET",`${q}/${t}/data`)}async getAvatar(t){return await this.request("GET",`account/${t}/avatar`,{responseType:"blob"})}async checkPermission(t){return await this.request("GET",`${q}/permissions/check`,{query:t})}async checkPermissionBatch(t){return(await this.request("POST",`${q}/permissions/check/batch`,{body:JSON.stringify({checks:t}),contentType:"application/json"})).results}};B=new WeakMap;let le=we;const Dt={MAX_FIELDS:200,MAX_KEY_LENGTH:50,MAX_VALUE_LENGTH:50},Ft={uuid:"a3f82c1d-5b74-4e9a-bc30-d7e12f894a61"},Mt={uuid:"2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f"},Vt={uuid:"b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c"},Ht={uuid:"2c4ae432-fc24-43e9-9783-0c960c674e96"},Gt={uuid:"69af63aa-19ba-4fc7-b17b-75647bac1d76"},jt={uuid:"234f1416-528d-452a-9cc9-a16c5239b2eb"};exports.CDEManager=Ft;exports.ClashesManager=Mt;exports.EngineServicesClient=G;exports.FileList=Vt;exports.HelloWorld=Ht;exports.METADATA_LIMITS=Dt;exports.PlatformClient=le;exports.RequestError=De;exports.TopicsManager=Gt;exports.UIManager=jt;
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",`${E}/${t}/items`,{query:{itemType:te,...s&&{ShowVersions:s}}}):await c(this,a,u).call(this,"GET",`${f}`,{query:{itemType:te,...s&&{ShowVersions:s},...r&&{projectId:r}}})}async createApp(e){const{appProps:t}=e;return await c(this,a,H).call(this,e,te,t)}async downloadApp(e,t){return await c(this,a,V).call(this,e,t)}async downloadAppBundle(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,$).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",`${Ut}/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 M(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}/${C}`,{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}/${C}/batch`,{body:s})}async deleteHiddenFile(e){return await c(this,a,u).call(this,"DELETE",`${f}/${C}/${e}`)}async getHiddenFile(e){return await c(this,a,u).call(this,"GET",`${f}/${C}/${e}`)}async downloadHiddenFile(e){return await c(this,a,$).call(this,`${f}/${C}/${e}/download`)}async getHiddenFileSignedUrl(e,t){return await c(this,a,u).call(this,"GET",`${f}/${C}/${e}/signed-url`,{...t!=null&&{query:{expiresIn:t}}})}async getHiddenFilesByParent(e){return await c(this,a,u).call(this,"GET",`${f}/${e}/${C}`)}async deleteHiddenFilesByParent(e){return await c(this,a,u).call(this,"DELETE",`${f}/${e}/${C}`)}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,$).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,ce=function(e){return`${this.apiUrl}/${e}`},u=async function(e,t,s){const{body:r,query:i,contentType:o,retries:h,responseType:l}=s||{},y=c(this,a,ce).call(this,t),d=c(this,a,Fe).call(this,i),m=await this.resolveAccessToken(),k={...d,...this.useBearer?{}:{accessToken:m}};try{const A=await fetch(y+"?"+new URLSearchParams(k).toString(),{method:e,headers:{Accept:"application/json",...o&&{"Content-Type":o},...this.useBearer&&{Authorization:`Bearer ${m}`}},...r&&{body:r}});if(!A.ok){const O=await A.text().then(Me=>Me).catch(()=>"");throw new De(A.status,A.statusText,O)}return l==="blob"?await A.blob():A.json().then(O=>O).catch(()=>{})}catch(A){let O=h??this.retries;if(O)return O=O-1,await c(this,a,u).call(this,e,t,{...s,retries:O});throw A}},$=async function(e,t){const{query:s}=t||{},r=c(this,a,ce).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}`}}})},V=async function(e,t){const{versionTag:s,withDraft:r}=t||{};return await c(this,a,$).call(this,`${f}/${e}/download`,{query:{...s&&{versionTag:s},...r&&{withDraft:r}}})},H=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})},he=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}},k=JSON.stringify(m);y=await c(this,a,u).call(this,"PUT",`${f}/${e}`,{body:k,contentType:"application/json"})}return{item:y,version:d}},ue=async function(e,t){const{showVersions:s=!1}=t||{};return await c(this,a,u).call(this,"GET",`${f}/${e}`,{query:{showVersions:s}})},Fe=function(e){return e&&Object.entries(e).filter(([,t])=>t!==void 0).reduce((t,[s,r])=>(t[s]=r,t),{})};let G=ge;const q="project";var B;const we=class we extends G{constructor(t,s,r){super(typeof t=="string"?t:"",s,{...r,useBearer:!0});W(this,B);typeof t=="function"&&be(this,B,t)}async resolveAccessToken(){return K(this,B)?await K(this,B).call(this):super.resolveAccessToken()}static fromPlatformContext(t){const s=(typeof window<"u"?window.__THATOPEN_CONTEXT__:null)||{appId:"",projectId:"",accessToken:"",apiUrl:""},r=new we(s.accessToken,s.apiUrl,t);return r.context=s,r}async getProject(t){return await this.request("GET",`${q}/${t}`)}async getProjectData(t){return await this.request("GET",`${q}/${t}/data`)}async getAvatar(t){return await this.request("GET",`account/${t}/avatar`,{responseType:"blob"})}async checkPermission(t){return await this.request("GET",`${q}/permissions/check`,{query:t})}async checkPermissionBatch(t){return(await this.request("POST",`${q}/permissions/check/batch`,{body:JSON.stringify({checks:t}),contentType:"application/json"})).results}};B=new WeakMap;let le=we;const Dt={MAX_FIELDS:200,MAX_KEY_LENGTH:50,MAX_VALUE_LENGTH:50},Ft={uuid:"a3f82c1d-5b74-4e9a-bc30-d7e12f894a61"},Mt={uuid:"2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f"},Vt={uuid:"b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c"},Ht={uuid:"3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81"},Gt={uuid:"2c4ae432-fc24-43e9-9783-0c960c674e96"},jt={uuid:"69af63aa-19ba-4fc7-b17b-75647bac1d76"},Jt={uuid:"234f1416-528d-452a-9cc9-a16c5239b2eb"};exports.CDEManager=Ft;exports.ClashesManager=Mt;exports.EngineServicesClient=G;exports.FileList=Vt;exports.GitHistoryManager=Ht;exports.HelloWorld=Gt;exports.METADATA_LIMITS=Dt;exports.PlatformClient=le;exports.RequestError=De;exports.TopicsManager=jt;exports.UIManager=Jt;
package/dist/index.es.js CHANGED
@@ -3364,16 +3364,17 @@ const Mt = {
3364
3364
  MAX_FIELDS: 200,
3365
3365
  MAX_KEY_LENGTH: 50,
3366
3366
  MAX_VALUE_LENGTH: 50
3367
- }, Vt = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, Ht = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, Gt = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, jt = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, Jt = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Yt = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
3367
+ }, Vt = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, Ht = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, Gt = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, jt = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, Jt = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, Yt = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, Kt = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
3368
3368
  export {
3369
3369
  Vt as CDEManager,
3370
3370
  Ht as ClashesManager,
3371
3371
  ae as EngineServicesClient,
3372
3372
  Gt as FileList,
3373
- jt as HelloWorld,
3373
+ jt as GitHistoryManager,
3374
+ Jt as HelloWorld,
3374
3375
  Mt as METADATA_LIMITS,
3375
3376
  Ae as PlatformClient,
3376
3377
  qt as RequestError,
3377
- Jt as TopicsManager,
3378
- Yt as UIManager
3378
+ Yt as TopicsManager,
3379
+ Kt as UIManager
3379
3380
  };
@@ -9,6 +9,28 @@ on the [That Open Platform](https://platform.thatopen.com) from scratch, using
9
9
 
10
10
  ---
11
11
 
12
+ > **Not building anything — here to work in Revit?** If what the user actually wants is to share a
13
+ > Revit model with their team, join one a colleague uploaded, or review a change some other tool
14
+ > proposed to their model, this is the wrong guide and nothing below applies. Go to
15
+ > **[the Revit collaboration quickstart](./revit-collab-quickstart.md)** and follow that instead.
16
+ > It is the same shape as this one: ask first, then drive the CLI.
17
+ >
18
+ > Phrases that mean that guide, not this one: *"I want to collaborate on a Revit project"*, *"share
19
+ > my central"*, *"join my team's model"*, *"someone sent me a change to approve"*, *"work on the
20
+ > same model as my colleague"*.
21
+
22
+ > **Making another application talk to this one?** If the user wants their own tool — Rhino, Blender,
23
+ > a script, an in-house app — to send changes into somebody's model or to show a model it did not
24
+ > author, that is a third thing again: **[Writing a flow plugin](./flow-plugin-guide.md)** is the
25
+ > byte contract, and **[the architecture notes](./flow-architecture.md)** say why it is shaped that
26
+ > way. Start at its section 0, which sorts the work into three sizes; most integrations are the
27
+ > smallest one and need no ownership, no history and no collaboration layer.
28
+ >
29
+ > Phrases that mean those: *"export my model to the platform"*, *"send my geometry to Revit"*,
30
+ > *"write a plugin for X"*, *"read a .frag in my app"*.
31
+
32
+ ---
33
+
12
34
  ## First — what are you building? (ask if the user hasn't said)
13
35
 
14
36
  There are two kinds of project. **If the user hasn't told you which they want, ASK them
@@ -83,6 +83,10 @@
83
83
  "path": "src/built-in/UIManager/src/clashes-panel/example.ts",
84
84
  "description": "clashes-panel — BIM coordinators need a dedicated review environment where they can see all detected clashes, filter by status, navigate to each issue in the 3D viewer, and mark items as resolved — without writing any UI code themselves."
85
85
  },
86
+ {
87
+ "path": "src/built-in/UIManager/src/git-history-panel/example.ts",
88
+ "description": "git-history-panel — `top-git-history` is a GitKraken-style commit timeline for the **revit-flow** feature. It lists the commits pushed by the Revit add-in (newest first) and, when you click a commit, drives the shared 3D viewer to color that commit's changed elements — created green, modified blue, deleted red — on the loaded baseline model."
89
+ },
86
90
  {
87
91
  "path": "src/built-in/UIManager/src/models-list/example.ts",
88
92
  "description": "top-models-list — top-models-list is the project's 3D-viewable-files tree: it mirrors the real storage folder structure, converts IFC to fragments, and loads `.frag`/`.potree`/`.splat` models into the 3D scene. Its loaders are PLUGGABLE — the panel owns the UI and the orchestration (progress, refresh, association), but the HOST decides how each extra file format is loaded, so you can teach it new formats without forking the built-in."