UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

1,637 lines 2.84 MB
var F4 = Object.defineProperty; var U4 = (t, e, r) => e in t ? F4(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; var E = (t, e, r) => U4(t, typeof e != "symbol" ? e + "" : e, r); import { jsxs as te, jsx as B, Fragment as dt } from "react/jsx-runtime"; import * as it from "react"; import M, { useLayoutEffect as gm, useEffect as me, cloneElement as Oi, createElement as jt, createContext as ur, useState as ue, useRef as Me, useMemo as Re, useImperativeHandle as FS, useCallback as Ee, Component as bs, useContext as cr, forwardRef as j4, Fragment as vr, isValidElement as US, useId as ys, useSyncExternalStore as z4, useReducer as H4, createRef as W4, PureComponent as qa, Children as jS, Suspense as V4 } from "react"; import X4, { createPortal as K4 } from "react-dom"; import he, { checkPropTypes as zS } from "prop-types"; const zs = globalThis || void 0 || self; function lu(t, e) { if (!t) throw new Error(e || "loader assertion failed."); } function Z4(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } var HS = { exports: {} }, yt = HS.exports = {}, tn, rn; function z0() { throw new Error("setTimeout has not been defined"); } function H0() { throw new Error("clearTimeout has not been defined"); } (function() { try { typeof setTimeout == "function" ? tn = setTimeout : tn = z0; } catch { tn = z0; } try { typeof clearTimeout == "function" ? rn = clearTimeout : rn = H0; } catch { rn = H0; } })(); function WS(t) { if (tn === setTimeout) return setTimeout(t, 0); if ((tn === z0 || !tn) && setTimeout) return tn = setTimeout, setTimeout(t, 0); try { return tn(t, 0); } catch { try { return tn.call(null, t, 0); } catch { return tn.call(this, t, 0); } } } function G4(t) { if (rn === clearTimeout) return clearTimeout(t); if ((rn === H0 || !rn) && clearTimeout) return rn = clearTimeout, clearTimeout(t); try { return rn(t); } catch { try { return rn.call(null, t); } catch { return rn.call(this, t); } } } var Tn = [], Qo = !1, Ri, Ul = -1; function Y4() { !Qo || !Ri || (Qo = !1, Ri.length ? Tn = Ri.concat(Tn) : Ul = -1, Tn.length && VS()); } function VS() { if (!Qo) { var t = WS(Y4); Qo = !0; for (var e = Tn.length; e; ) { for (Ri = Tn, Tn = []; ++Ul < e; ) Ri && Ri[Ul].run(); Ul = -1, e = Tn.length; } Ri = null, Qo = !1, G4(t); } } yt.nextTick = function(t) { var e = new Array(arguments.length - 1); if (arguments.length > 1) for (var r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]; Tn.push(new XS(t, e)), Tn.length === 1 && !Qo && WS(VS); }; function XS(t, e) { this.fun = t, this.array = e; } XS.prototype.run = function() { this.fun.apply(null, this.array); }; yt.title = "browser"; yt.browser = !0; yt.env = {}; yt.argv = []; yt.version = ""; yt.versions = {}; function On() { } yt.on = On; yt.addListener = On; yt.once = On; yt.off = On; yt.removeListener = On; yt.removeAllListeners = On; yt.emit = On; yt.prependListener = On; yt.prependOnceListener = On; yt.listeners = function(t) { return []; }; yt.binding = function(t) { throw new Error("process.binding is not supported"); }; yt.cwd = function() { return "/"; }; yt.chdir = function(t) { throw new Error("process.chdir is not supported"); }; yt.umask = function() { return 0; }; var J4 = HS.exports; const Ie = /* @__PURE__ */ Z4(J4), mm = ( // @ts-ignore process does not exist on browser !!(typeof Ie != "object" || String(Ie) !== "[object process]" || Ie.browser) ), Eb = typeof Ie < "u" && Ie.version && /v([0-9]*)/.exec(Ie.version); Eb && parseFloat(Eb[1]); const il = globalThis, co = globalThis.process || {}, Q4 = globalThis.navigator || {}; function KS(t) { var n, i; if (typeof window < "u" && ((n = window.process) == null ? void 0 : n.type) === "renderer" || typeof Ie < "u" && ((i = Ie.versions) != null && i.electron)) return !0; const r = typeof navigator < "u" && navigator.userAgent; return !!(r && r.indexOf("Electron") >= 0); } function Gi() { return !// @ts-expect-error (typeof Ie == "object" && String(Ie) === "[object process]" && !(Ie != null && Ie.browser)) || KS(); } function e8(t) { return Gi() ? KS() ? "Electron" : (Q4.userAgent || "").indexOf("Edge") > -1 ? "Edge" : globalThis.chrome ? "Chrome" : globalThis.safari ? "Safari" : globalThis.mozInnerScreenX ? "Firefox" : "Unknown" : "Node"; } const ZS = "4.1.0"; function t8(t) { try { const e = window[t], r = "__storage_test__"; return e.setItem(r, r), e.removeItem(r), e; } catch { return null; } } class r8 { constructor(e, r, n = "sessionStorage") { this.storage = t8(n), this.id = e, this.config = r, this._loadConfiguration(); } getConfiguration() { return this.config; } setConfiguration(e) { if (Object.assign(this.config, e), this.storage) { const r = JSON.stringify(this.config); this.storage.setItem(this.id, r); } } // Get config from persistent store, if available _loadConfiguration() { let e = {}; if (this.storage) { const r = this.storage.getItem(this.id); e = r ? JSON.parse(r) : {}; } return Object.assign(this.config, e), this; } } function n8(t) { let e; return t < 10 ? e = `${t.toFixed(2)}ms` : t < 100 ? e = `${t.toFixed(1)}ms` : t < 1e3 ? e = `${t.toFixed(0)}ms` : e = `${(t / 1e3).toFixed(2)}s`, e; } function i8(t, e = 8) { const r = Math.max(e - t.length, 0); return `${" ".repeat(r)}${t}`; } var uu; (function(t) { t[t.BLACK = 30] = "BLACK", t[t.RED = 31] = "RED", t[t.GREEN = 32] = "GREEN", t[t.YELLOW = 33] = "YELLOW", t[t.BLUE = 34] = "BLUE", t[t.MAGENTA = 35] = "MAGENTA", t[t.CYAN = 36] = "CYAN", t[t.WHITE = 37] = "WHITE", t[t.BRIGHT_BLACK = 90] = "BRIGHT_BLACK", t[t.BRIGHT_RED = 91] = "BRIGHT_RED", t[t.BRIGHT_GREEN = 92] = "BRIGHT_GREEN", t[t.BRIGHT_YELLOW = 93] = "BRIGHT_YELLOW", t[t.BRIGHT_BLUE = 94] = "BRIGHT_BLUE", t[t.BRIGHT_MAGENTA = 95] = "BRIGHT_MAGENTA", t[t.BRIGHT_CYAN = 96] = "BRIGHT_CYAN", t[t.BRIGHT_WHITE = 97] = "BRIGHT_WHITE"; })(uu || (uu = {})); const o8 = 10; function Mb(t) { return typeof t != "string" ? t : (t = t.toUpperCase(), uu[t] || uu.WHITE); } function s8(t, e, r) { return !Gi && typeof t == "string" && (e && (t = `\x1B[${Mb(e)}m${t}\x1B[39m`), r && (t = `\x1B[${Mb(r) + o8}m${t}\x1B[49m`)), t; } function a8(t, e = ["constructor"]) { const r = Object.getPrototypeOf(t), n = Object.getOwnPropertyNames(r), i = t; for (const o of n) { const s = i[o]; typeof s == "function" && (e.find((a) => o === a) || (i[o] = s.bind(t))); } } function bm(t, e) { if (!t) throw new Error("Assertion failed"); } function fo() { var e, r, n; let t; if (Gi() && il.performance) t = (r = (e = il == null ? void 0 : il.performance) == null ? void 0 : e.now) == null ? void 0 : r.call(e); else if ("hrtime" in co) { const i = (n = co == null ? void 0 : co.hrtime) == null ? void 0 : n.call(co); t = i[0] * 1e3 + i[1] / 1e6; } else t = Date.now(); return t; } const ho = { debug: Gi() && console.debug || console.log, log: console.log, info: console.info, warn: console.warn, error: console.error }, l8 = { enabled: !0, level: 0 }; function po() { } const Ab = {}, Rb = { once: !0 }; class La { constructor({ id: e } = { id: "" }) { this.VERSION = ZS, this._startTs = fo(), this._deltaTs = fo(), this.userData = {}, this.LOG_THROTTLE_TIMEOUT = 0, this.id = e, this.userData = {}, this._storage = new r8(`__probe-${this.id}__`, l8), this.timeStamp(`${this.id} started`), a8(this), Object.seal(this); } set level(e) { this.setLevel(e); } get level() { return this.getLevel(); } isEnabled() { return this._storage.config.enabled; } getLevel() { return this._storage.config.level; } /** @return milliseconds, with fractions */ getTotal() { return Number((fo() - this._startTs).toPrecision(10)); } /** @return milliseconds, with fractions */ getDelta() { return Number((fo() - this._deltaTs).toPrecision(10)); } /** @deprecated use logLevel */ set priority(e) { this.level = e; } /** @deprecated use logLevel */ get priority() { return this.level; } /** @deprecated use logLevel */ getPriority() { return this.level; } // Configure enable(e = !0) { return this._storage.setConfiguration({ enabled: e }), this; } setLevel(e) { return this._storage.setConfiguration({ level: e }), this; } /** return the current status of the setting */ get(e) { return this._storage.config[e]; } // update the status of the setting set(e, r) { this._storage.setConfiguration({ [e]: r }); } /** Logs the current settings as a table */ settings() { console.table ? console.table(this._storage.config) : console.log(this._storage.config); } // Unconditional logging assert(e, r) { if (!e) throw new Error(r || "Assertion failed"); } warn(e) { return this._getLogFunction(0, e, ho.warn, arguments, Rb); } error(e) { return this._getLogFunction(0, e, ho.error, arguments); } /** Print a deprecation warning */ deprecated(e, r) { return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`); } /** Print a removal warning */ removed(e, r) { return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`); } probe(e, r) { return this._getLogFunction(e, r, ho.log, arguments, { time: !0, once: !0 }); } log(e, r) { return this._getLogFunction(e, r, ho.debug, arguments); } info(e, r) { return this._getLogFunction(e, r, console.info, arguments); } once(e, r) { return this._getLogFunction(e, r, ho.debug || ho.info, arguments, Rb); } /** Logs an object as a table */ table(e, r, n) { return r ? this._getLogFunction(e, r, console.table || po, n && [n], { tag: c8(r) }) : po; } time(e, r) { return this._getLogFunction(e, r, console.time ? console.time : console.info); } timeEnd(e, r) { return this._getLogFunction(e, r, console.timeEnd ? console.timeEnd : console.info); } timeStamp(e, r) { return this._getLogFunction(e, r, console.timeStamp || po); } group(e, r, n = { collapsed: !1 }) { const i = Tb({ logLevel: e, message: r, opts: n }), { collapsed: o } = n; return i.method = (o ? console.groupCollapsed : console.group) || console.info, this._getLogFunction(i); } groupCollapsed(e, r, n = {}) { return this.group(e, r, Object.assign({}, n, { collapsed: !0 })); } groupEnd(e) { return this._getLogFunction(e, "", console.groupEnd || po); } // EXPERIMENTAL withGroup(e, r, n) { this.group(e, r)(); try { n(); } finally { this.groupEnd(e)(); } } trace() { console.trace && console.trace(); } // PRIVATE METHODS /** Deduces log level from a variety of arguments */ _shouldLog(e) { return this.isEnabled() && this.getLevel() >= GS(e); } _getLogFunction(e, r, n, i, o) { if (this._shouldLog(e)) { o = Tb({ logLevel: e, message: r, args: i, opts: o }), n = n || o.method, bm(n), o.total = this.getTotal(), o.delta = this.getDelta(), this._deltaTs = fo(); const s = o.tag || o.message; if (o.once && s) if (!Ab[s]) Ab[s] = fo(); else return po; return r = u8(this.id, o.message, o), n.bind(console, r, ...o.args); } return po; } } La.VERSION = ZS; function GS(t) { if (!t) return 0; let e; switch (typeof t) { case "number": e = t; break; case "object": e = t.logLevel || t.priority || 0; break; default: return 0; } return bm(Number.isFinite(e) && e >= 0), e; } function Tb(t) { const { logLevel: e, message: r } = t; t.logLevel = GS(e); const n = t.args ? Array.from(t.args) : []; for (; n.length && n.shift() !== r; ) ; switch (typeof e) { case "string": case "function": r !== void 0 && n.unshift(r), t.message = e; break; case "object": Object.assign(t, e); break; } typeof t.message == "function" && (t.message = t.message()); const i = typeof t.message; return bm(i === "string" || i === "object"), Object.assign(t, { args: n }, t.opts); } function u8(t, e, r) { if (typeof e == "string") { const n = r.time ? i8(n8(r.total)) : ""; e = r.time ? `${t}: ${n} ${e}` : `${t}: ${e}`, e = s8(e, r.color, r.background); } return e; } function c8(t) { for (const e in t) for (const r in t[e]) return r || "untitled"; return "empty"; } const Cf = "4.3.2", f8 = Cf[0] >= "0" && Cf[0] <= "9" ? `v${Cf}` : ""; function h8() { const t = new La({ id: "loaders.gl" }); return globalThis.loaders = globalThis.loaders || {}, globalThis.loaders.log = t, globalThis.loaders.version = f8, globalThis.probe = globalThis.probe || {}, globalThis.probe.loaders = t, t; } const d8 = h8(); function p8(t, e) { return YS(t || {}, e); } function YS(t, e, r = 0) { if (r > 3) return e; const n = { ...t }; for (const [i, o] of Object.entries(e)) o && typeof o == "object" && !Array.isArray(o) ? n[i] = YS(n[i] || {}, e[i], r + 1) : n[i] = e[i]; return n; } const g8 = "latest"; function m8() { var t; return (t = globalThis._loadersgl_) != null && t.version || (globalThis._loadersgl_ = globalThis._loadersgl_ || {}, globalThis._loadersgl_.version = "4.3.2"), globalThis._loadersgl_.version; } const b8 = m8(); function li(t, e) { if (!t) throw new Error(e || "loaders.gl assertion failed."); } const Bi = ( // @ts-ignore process.browser typeof Ie != "object" || String(Ie) !== "[object process]" || Ie.browser ), y8 = typeof window < "u" && typeof window.orientation < "u", Cb = typeof Ie < "u" && Ie.version && /v([0-9]*)/.exec(Ie.version); Cb && parseFloat(Cb[1]); class v8 { constructor(e, r) { E(this, "name"); E(this, "workerThread"); E(this, "isRunning", !0); /** Promise that resolves when Job is done */ E(this, "result"); E(this, "_resolve", () => { }); E(this, "_reject", () => { }); this.name = e, this.workerThread = r, this.result = new Promise((n, i) => { this._resolve = n, this._reject = i; }); } /** * Send a message to the job's worker thread * @param data any data structure, ideally consisting mostly of transferrable objects */ postMessage(e, r) { this.workerThread.postMessage({ source: "loaders.gl", // Lets worker ignore unrelated messages type: e, payload: r }); } /** * Call to resolve the `result` Promise with the supplied value */ done(e) { li(this.isRunning), this.isRunning = !1, this._resolve(e); } /** * Call to reject the `result` Promise with the supplied error */ error(e) { li(this.isRunning), this.isRunning = !1, this._reject(e); } } class If { terminate() { } } const kf = /* @__PURE__ */ new Map(); function _8(t) { li(t.source && !t.url || !t.source && t.url); let e = kf.get(t.source || t.url); return e || (t.url && (e = w8(t.url), kf.set(t.url, e)), t.source && (e = JS(t.source), kf.set(t.source, e))), li(e), e; } function w8(t) { if (!t.startsWith("http")) return t; const e = x8(t); return JS(e); } function JS(t) { const e = new Blob([t], { type: "application/javascript" }); return URL.createObjectURL(e); } function x8(t) { return `try { importScripts('${t}'); } catch (error) { console.error(error); throw error; }`; } function QS(t, e = !0, r) { const n = r || /* @__PURE__ */ new Set(); if (t) { if (Ib(t)) n.add(t); else if (Ib(t.buffer)) n.add(t.buffer); else if (!ArrayBuffer.isView(t)) { if (e && typeof t == "object") for (const i in t) QS(t[i], e, n); } } return r === void 0 ? Array.from(n) : []; } function Ib(t) { return t ? t instanceof ArrayBuffer || typeof MessagePort < "u" && t instanceof MessagePort || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas : !1; } const Pf = () => { }; class W0 { constructor(e) { E(this, "name"); E(this, "source"); E(this, "url"); E(this, "terminated", !1); E(this, "worker"); E(this, "onMessage"); E(this, "onError"); E(this, "_loadableURL", ""); const { name: r, source: n, url: i } = e; li(n || i), this.name = r, this.source = n, this.url = i, this.onMessage = Pf, this.onError = (o) => console.log(o), this.worker = Bi ? this._createBrowserWorker() : this._createNodeWorker(); } /** Checks if workers are supported on this platform */ static isSupported() { return typeof Worker < "u" && Bi || typeof If < "u" && !Bi; } /** * Terminate this worker thread * @note Can free up significant memory */ destroy() { this.onMessage = Pf, this.onError = Pf, this.worker.terminate(), this.terminated = !0; } get isRunning() { return !!this.onMessage; } /** * Send a message to this worker thread * @param data any data structure, ideally consisting mostly of transferrable objects * @param transferList If not supplied, calculated automatically by traversing data */ postMessage(e, r) { r = r || QS(e), this.worker.postMessage(e, r); } // PRIVATE /** * Generate a standard Error from an ErrorEvent * @param event */ _getErrorFromErrorEvent(e) { let r = "Failed to load "; return r += `worker ${this.name} from ${this.url}. `, e.message && (r += `${e.message} in `), e.lineno && (r += `:${e.lineno}:${e.colno}`), new Error(r); } /** * Creates a worker thread on the browser */ _createBrowserWorker() { this._loadableURL = _8({ source: this.source, url: this.url }); const e = new Worker(this._loadableURL, { name: this.name }); return e.onmessage = (r) => { r.data ? this.onMessage(r.data) : this.onError(new Error("No data received")); }, e.onerror = (r) => { this.onError(this._getErrorFromErrorEvent(r)), this.terminated = !0; }, e.onmessageerror = (r) => console.error(r), e; } /** * Creates a worker thread in node.js * @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool */ _createNodeWorker() { let e; if (this.url) { const n = this.url.includes(":/") || this.url.startsWith("/") ? this.url : `./${this.url}`; e = new If(n, { eval: !1 }); } else if (this.source) e = new If(this.source, { eval: !0 }); else throw new Error("no worker"); return e.on("message", (r) => { this.onMessage(r); }), e.on("error", (r) => { this.onError(r); }), e.on("exit", (r) => { }), e; } } class S8 { /** * @param processor - worker function * @param maxConcurrency - max count of workers */ constructor(e) { E(this, "name", "unnamed"); E(this, "source"); // | Function; E(this, "url"); E(this, "maxConcurrency", 1); E(this, "maxMobileConcurrency", 1); E(this, "onDebug", () => { }); E(this, "reuseWorkers", !0); E(this, "props", {}); E(this, "jobQueue", []); E(this, "idleQueue", []); E(this, "count", 0); E(this, "isDestroyed", !1); this.source = e.source, this.url = e.url, this.setProps(e); } /** Checks if workers are supported on this platform */ static isSupported() { return W0.isSupported(); } /** * Terminates all workers in the pool * @note Can free up significant memory */ destroy() { this.idleQueue.forEach((e) => e.destroy()), this.isDestroyed = !0; } setProps(e) { this.props = { ...this.props, ...e }, e.name !== void 0 && (this.name = e.name), e.maxConcurrency !== void 0 && (this.maxConcurrency = e.maxConcurrency), e.maxMobileConcurrency !== void 0 && (this.maxMobileConcurrency = e.maxMobileConcurrency), e.reuseWorkers !== void 0 && (this.reuseWorkers = e.reuseWorkers), e.onDebug !== void 0 && (this.onDebug = e.onDebug); } async startJob(e, r = (i, o, s) => i.done(s), n = (i, o) => i.error(o)) { const i = new Promise((o) => (this.jobQueue.push({ name: e, onMessage: r, onError: n, onStart: o }), this)); return this._startQueuedJob(), await i; } // PRIVATE /** * Starts first queued job if worker is available or can be created * Called when job is started and whenever a worker returns to the idleQueue */ async _startQueuedJob() { if (!this.jobQueue.length) return; const e = this._getAvailableWorker(); if (!e) return; const r = this.jobQueue.shift(); if (r) { this.onDebug({ message: "Starting job", name: r.name, workerThread: e, backlog: this.jobQueue.length }); const n = new v8(r.name, e); e.onMessage = (i) => r.onMessage(n, i.type, i.payload), e.onError = (i) => r.onError(n, i), r.onStart(n); try { await n.result; } catch (i) { console.error(`Worker exception: ${i}`); } finally { this.returnWorkerToQueue(e); } } } /** * Returns a worker to the idle queue * Destroys the worker if * - pool is destroyed * - if this pool doesn't reuse workers * - if maxConcurrency has been lowered * @param worker */ returnWorkerToQueue(e) { // Workers on Node.js prevent the process from exiting. // Until we figure out how to close them before exit, we always destroy them !Bi || // If the pool is destroyed, there is no reason to keep the worker around this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed !this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements this.count > this._getMaxConcurrency() ? (e.destroy(), this.count--) : this.idleQueue.push(e), this.isDestroyed || this._startQueuedJob(); } /** * Returns idle worker or creates new worker if maxConcurrency has not been reached */ _getAvailableWorker() { if (this.idleQueue.length > 0) return this.idleQueue.shift() || null; if (this.count < this._getMaxConcurrency()) { this.count++; const e = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`; return new W0({ name: e, source: this.source, url: this.url }); } return null; } _getMaxConcurrency() { return y8 ? this.maxMobileConcurrency : this.maxConcurrency; } } const E8 = { maxConcurrency: 3, maxMobileConcurrency: 1, reuseWorkers: !0, onDebug: () => { } }, Xn = class Xn { /** get global instance with WorkerFarm.getWorkerFarm() */ constructor(e) { E(this, "props"); E(this, "workerPools", /* @__PURE__ */ new Map()); this.props = { ...E8 }, this.setProps(e), this.workerPools = /* @__PURE__ */ new Map(); } /** Checks if workers are supported on this platform */ static isSupported() { return W0.isSupported(); } /** Get the singleton instance of the global worker farm */ static getWorkerFarm(e = {}) { return Xn._workerFarm = Xn._workerFarm || new Xn({}), Xn._workerFarm.setProps(e), Xn._workerFarm; } /** * Terminate all workers in the farm * @note Can free up significant memory */ destroy() { for (const e of this.workerPools.values()) e.destroy(); this.workerPools = /* @__PURE__ */ new Map(); } /** * Set props used when initializing worker pools * @param props */ setProps(e) { this.props = { ...this.props, ...e }; for (const r of this.workerPools.values()) r.setProps(this._getWorkerPoolProps()); } /** * Returns a worker pool for the specified worker * @param options - only used first time for a specific worker name * @param options.name - the name of the worker - used to identify worker pool * @param options.url - * @param options.source - * @example * const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...); */ getWorkerPool(e) { const { name: r, source: n, url: i } = e; let o = this.workerPools.get(r); return o || (o = new S8({ name: r, source: n, url: i }), o.setProps(this._getWorkerPoolProps()), this.workerPools.set(r, o)), o; } _getWorkerPoolProps() { return { maxConcurrency: this.props.maxConcurrency, maxMobileConcurrency: this.props.maxMobileConcurrency, reuseWorkers: this.props.reuseWorkers, onDebug: this.props.onDebug }; } }; // singleton E(Xn, "_workerFarm"); let cu = Xn; function M8(t, e = {}) { const r = e[t.id] || {}, n = Bi ? `${t.id}-worker.js` : `${t.id}-worker-node.js`; let i = r.workerUrl; if (!i && t.id === "compression" && (i = e.workerUrl), e._workerType === "test" && (Bi ? i = `modules/${t.module}/dist/${n}` : i = `modules/${t.module}/src/workers/${t.id}-worker-node.ts`), !i) { let o = t.version; o === "latest" && (o = g8); const s = o ? `@${o}` : ""; i = `https://unpkg.com/@loaders.gl/${t.module}${s}/dist/${n}`; } return li(i), i; } function A8(t, e = b8) { li(t, "no worker provided"); const r = t.version; return !(!e || !r); } function R8(t, e) { return !cu.isSupported() || !Bi && !(e != null && e._nodeWorkers) ? !1 : t.worker && (e == null ? void 0 : e.worker); } async function T8(t, e, r, n, i) { const o = t.id, s = M8(t, r), l = cu.getWorkerFarm(r).getWorkerPool({ name: o, url: s }); r = JSON.parse(JSON.stringify(r)), n = JSON.parse(JSON.stringify(n || {})); const u = await l.startJob( "process-on-worker", // @ts-expect-error C8.bind(null, i) // eslint-disable-line @typescript-eslint/no-misused-promises ); return u.postMessage("process", { // @ts-ignore input: e, options: r, context: n }), await (await u.result).result; } async function C8(t, e, r, n) { switch (r) { case "done": e.done(n); break; case "error": e.error(new Error(n.error)); break; case "process": const { id: i, input: o, options: s } = n; try { const a = await t(o, s); e.postMessage("done", { id: i, result: a }); } catch (a) { const l = a instanceof Error ? a.message : "unknown error"; e.postMessage("error", { id: i, error: l }); } break; default: console.warn(`parse-with-worker unknown message ${r}`); } } function I8(t, e, r) { if (r = r || t.byteLength, t.byteLength < r || e.byteLength < r) return !1; const n = new Uint8Array(t), i = new Uint8Array(e); for (let o = 0; o < n.length; ++o) if (n[o] !== i[o]) return !1; return !0; } function k8(...t) { return P8(t); } function P8(t) { const e = t.map((o) => o instanceof ArrayBuffer ? new Uint8Array(o) : o), r = e.reduce((o, s) => o + s.byteLength, 0), n = new Uint8Array(r); let i = 0; for (const o of e) n.set(o, i), i += o.byteLength; return n.buffer; } async function O8(t) { const e = []; for await (const r of t) e.push(r); return k8(...e); } function kb() { let t; if (typeof window < "u" && window.performance) t = window.performance.now(); else if (typeof Ie < "u" && Ie.hrtime) { const e = Ie.hrtime(); t = e[0] * 1e3 + e[1] / 1e6; } else t = Date.now(); return t; } class Pb { constructor(e, r) { this.sampleSize = 1, this.time = 0, this.count = 0, this.samples = 0, this.lastTiming = 0, this.lastSampleTime = 0, this.lastSampleCount = 0, this._count = 0, this._time = 0, this._samples = 0, this._startTime = 0, this._timerPending = !1, this.name = e, this.type = r, this.reset(); } reset() { return this.time = 0, this.count = 0, this.samples = 0, this.lastTiming = 0, this.lastSampleTime = 0, this.lastSampleCount = 0, this._count = 0, this._time = 0, this._samples = 0, this._startTime = 0, this._timerPending = !1, this; } setSampleSize(e) { return this.sampleSize = e, this; } /** Call to increment count (+1) */ incrementCount() { return this.addCount(1), this; } /** Call to decrement count (-1) */ decrementCount() { return this.subtractCount(1), this; } /** Increase count */ addCount(e) { return this._count += e, this._samples++, this._checkSampling(), this; } /** Decrease count */ subtractCount(e) { return this._count -= e, this._samples++, this._checkSampling(), this; } /** Add an arbitrary timing and bump the count */ addTime(e) { return this._time += e, this.lastTiming = e, this._samples++, this._checkSampling(), this; } /** Start a timer */ timeStart() { return this._startTime = kb(), this._timerPending = !0, this; } /** End a timer. Adds to time and bumps the timing count. */ timeEnd() { return this._timerPending ? (this.addTime(kb() - this._startTime), this._timerPending = !1, this._checkSampling(), this) : this; } getSampleAverageCount() { return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; } /** Calculate average time / count for the previous window */ getSampleAverageTime() { return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; } /** Calculate counts per second for the previous window */ getSampleHz() { return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0; } getAverageCount() { return this.samples > 0 ? this.count / this.samples : 0; } /** Calculate average time / count */ getAverageTime() { return this.samples > 0 ? this.time / this.samples : 0; } /** Calculate counts per second */ getHz() { return this.time > 0 ? this.samples / (this.time / 1e3) : 0; } _checkSampling() { this._samples === this.sampleSize && (this.lastSampleTime = this._time, this.lastSampleCount = this._count, this.count += this._count, this.time += this._time, this.samples += this._samples, this._time = 0, this._count = 0, this._samples = 0); } } class Ic { constructor(e) { this.stats = {}, this.id = e.id, this.stats = {}, this._initializeStats(e.stats), Object.seal(this); } /** Acquire a stat. Create if it doesn't exist. */ get(e, r = "count") { return this._getOrCreate({ name: e, type: r }); } get size() { return Object.keys(this.stats).length; } /** Reset all stats */ reset() { for (const e of Object.values(this.stats)) e.reset(); return this; } forEach(e) { for (const r of Object.values(this.stats)) e(r); } getTable() { const e = {}; return this.forEach((r) => { e[r.name] = { time: r.time || 0, count: r.count || 0, average: r.getAverageTime() || 0, hz: r.getHz() || 0 }; }), e; } _initializeStats(e = []) { e.forEach((r) => this._getOrCreate(r)); } _getOrCreate(e) { const { name: r, type: n } = e; let i = this.stats[r]; return i || (e instanceof Pb ? i = e : i = new Pb(r, n), this.stats[r] = i), i; } } let B8 = ""; const Ob = {}; function N8(t) { for (const e in Ob) if (t.startsWith(e)) { const r = Ob[e]; t = t.replace(e, r); } return !t.startsWith("http://") && !t.startsWith("https://") && (t = `${B8}${t}`), t; } function D8(t) { return t && typeof t == "object" && t.isBuffer; } function eE(t) { if (D8(t)) return t; if (t instanceof ArrayBuffer) return t; if (ArrayBuffer.isView(t)) return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength); if (typeof t == "string") { const e = t; return new TextEncoder().encode(e).buffer; } if (t && typeof t == "object" && t._toArrayBuffer) return t._toArrayBuffer(); throw new Error("toArrayBuffer"); } function tE(t) { const e = t ? t.lastIndexOf("/") : -1; return e >= 0 ? t.substr(e + 1) : ""; } function q8(t) { const e = t ? t.lastIndexOf("/") : -1; return e >= 0 ? t.substr(0, e) : ""; } const L8 = (t) => typeof t == "boolean", ua = (t) => typeof t == "function", $a = (t) => t !== null && typeof t == "object", Bb = (t) => $a(t) && t.constructor === {}.constructor, $8 = (t) => !!t && typeof t[Symbol.iterator] == "function", F8 = (t) => t && typeof t[Symbol.asyncIterator] == "function", Yi = (t) => typeof Response < "u" && t instanceof Response || t && t.arrayBuffer && t.text && t.json, Ji = (t) => typeof Blob < "u" && t instanceof Blob, U8 = (t) => t && typeof t == "object" && t.isBuffer, j8 = (t) => typeof ReadableStream < "u" && t instanceof ReadableStream || $a(t) && ua(t.tee) && ua(t.cancel) && ua(t.getReader), z8 = (t) => $a(t) && ua(t.read) && ua(t.pipe) && L8(t.readable), rE = (t) => j8(t) || z8(t); class H8 extends Error { constructor(r, n) { super(r); /** A best effort reason for why the fetch failed */ E(this, "reason"); /** The URL that failed to load. Empty string if not available. */ E(this, "url"); /** The Response object, if any. */ E(this, "response"); this.reason = n.reason, this.url = n.url, this.response = n.response; } } const W8 = /^data:([-\w.]+\/[-\w.+]+)(;|,)/, V8 = /^([-\w.]+\/[-\w.+]+)/; function Nb(t, e) { return t.toLowerCase() === e.toLowerCase(); } function X8(t) { const e = V8.exec(t); return e ? e[1] : t; } function Db(t) { const e = W8.exec(t); return e ? e[1] : ""; } const nE = /\?.*/; function K8(t) { const e = t.match(nE); return e && e[0]; } function ym(t) { return t.replace(nE, ""); } function Z8(t) { if (t.length < 50) return t; const e = t.slice(t.length - 15); return `${t.substr(0, 32)}...${e}`; } function kc(t) { return Yi(t) ? t.url : Ji(t) ? t.name || "" : typeof t == "string" ? t : ""; } function vm(t) { if (Yi(t)) { const e = t, r = e.headers.get("content-type") || "", n = ym(e.url); return X8(r) || Db(n); } return Ji(t) ? t.type || "" : typeof t == "string" ? Db(t) : ""; } function G8(t) { return Yi(t) ? t.headers["content-length"] || -1 : Ji(t) ? t.size : typeof t == "string" ? t.length : t instanceof ArrayBuffer || ArrayBuffer.isView(t) ? t.byteLength : -1; } async function iE(t) { if (Yi(t)) return t; const e = {}, r = G8(t); r >= 0 && (e["content-length"] = String(r)); const n = kc(t), i = vm(t); i && (e["content-type"] = i); const o = await Q8(t); o && (e["x-first-bytes"] = o), typeof t == "string" && (t = new TextEncoder().encode(t)); const s = new Response(t, { headers: e }); return Object.defineProperty(s, "url", { value: n }), s; } async function Y8(t) { if (!t.ok) throw await J8(t); } async function J8(t) { const e = Z8(t.url); let r = `Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`; r = r.length > 100 ? `${r.slice(0, 100)}...` : r; const n = { reason: t.statusText, url: t.url, response: t }; try { const i = t.headers.get("Content-Type"); n.reason = !t.bodyUsed && (i != null && i.includes("application/json")) ? await t.json() : await t.text(); } catch { } return new H8(r, n); } async function Q8(t) { if (typeof t == "string") return `data:,${t.slice(0, 5)}`; if (t instanceof Blob) { const r = t.slice(0, 5); return await new Promise((n) => { const i = new FileReader(); i.onload = (o) => { var s; return n((s = o == null ? void 0 : o.target) == null ? void 0 : s.result); }, i.readAsDataURL(r); }); } if (t instanceof ArrayBuffer) { const r = t.slice(0, 5); return `data:base64,${eT(r)}`; } return null; } function eT(t) { let e = ""; const r = new Uint8Array(t); for (let n = 0; n < r.byteLength; n++) e += String.fromCharCode(r[n]); return btoa(e); } function tT(t) { return !rT(t) && !nT(t); } function rT(t) { return t.startsWith("http:") || t.startsWith("https:"); } function nT(t) { return t.startsWith("data:"); } async function qb(t, e) { var r, n; if (typeof t == "string") { const i = N8(t); return tT(i) && (r = globalThis.loaders) != null && r.fetchNode ? (n = globalThis.loaders) == null ? void 0 : n.fetchNode(i, e) : await fetch(i, e); } return await iE(t); } const Lb = new La({ id: "loaders.gl" }); class iT { log() { return () => { }; } info() { return () => { }; } warn() { return () => { }; } error() { return () => { }; } } class oT { constructor() { E(this, "console"); this.console = console; } log(...e) { return this.console.log.bind(this.console, ...e); } info(...e) { return this.console.info.bind(this.console, ...e); } warn(...e) { return this.console.warn.bind(this.console, ...e); } error(...e) { return this.console.error.bind(this.console, ...e); } } const oE = { // baseUri fetch: null, mimeType: void 0, nothrow: !1, log: new oT(), // A probe.gl compatible (`log.log()()` syntax) that just logs to console useLocalLibraries: !1, CDN: "https://unpkg.com/@loaders.gl", worker: !0, // By default, use worker if provided by loader. maxConcurrency: 3, // How many worker instances should be created for each loader. maxMobileConcurrency: 1, // How many worker instances should be created for each loader on mobile devices. reuseWorkers: mm, // By default reuse workers in browser (Node.js refuses to terminate if browsers are running) _nodeWorkers: !1, // By default do not support node workers _workerType: "", // 'test' to use locally generated workers limit: 0, _limitMB: 0, batchSize: "auto", batchDebounceMs: 0, metadata: !1, // TODO - currently only implemented for parseInBatches, adds initial metadata batch, transforms: [] }, sT = { throws: "nothrow", dataType: "(no longer used)", uri: "baseUri", // Warn if fetch options are used on top-level method: "fetch.method", headers: "fetch.headers", body: "fetch.body", mode: "fetch.mode", credentials: "fetch.credentials", cache: "fetch.cache", redirect: "fetch.redirect", referrer: "fetch.referrer", referrerPolicy: "fetch.referrerPolicy", integrity: "fetch.integrity", keepalive: "fetch.keepalive", signal: "fetch.signal" }; function sE() { globalThis.loaders = globalThis.loaders || {}; const { loaders: t } = globalThis; return t._state || (t._state = {}), t._state; } function aE() { const t = sE(); return t.globalOptions = t.globalOptions || { ...oE }, t.globalOptions; } function aT(t, e, r, n) { return r = r || [], r = Array.isArray(r) ? r : [r], lT(t, r), cT(e, t, n); } function lT(t, e) { $b(t, null, oE, sT, e); for (const r of e) { const n = t && t[r.id] || {}, i = r.options && r.options[r.id] || {}, o = r.deprecatedOptions && r.deprecatedOptions[r.id] || {}; $b(n, r.id, i, o, e); } } function $b(t, e, r, n, i) { const o = e || "Top level", s = e ? `${e}.` : ""; for (const a in t) { const l = !e && $a(t[a]), u = a === "baseUri" && !e, c = a === "workerUrl" && e; if (!(a in r) && !u && !c) { if (a in n) Lb.warn(`${o} loader option '${s}${a}' no longer supported, use '${n[a]}'`)(); else if (!l) { const f = uT(a, i); Lb.warn(`${o} loader option '${s}${a}' not recognized. ${f}`)(); } } } } function uT(t, e) { const r = t.toLowerCase(); let n = ""; for (const i of e) for (const o in i.options) { if (t === o) return `Did you mean '${i.id}.${o}'?`; const s = o.toLowerCase(); (r.startsWith(s) || s.startsWith(r)) && (n = n || `Did you mean '${i.id}.${o}'?`); } return n; } function cT(t, e, r) { const i = { ...t.options || {} }; return fT(i, r), i.log === null && (i.log = new iT()), Fb(i, aE()), Fb(i, e), i; } function Fb(t, e) { for (const r in e) if (r in e) { const n = e[r]; Bb(n) && Bb(t[r]) ? t[r] = { ...t[r], ...e[r] } : t[r] = e[r]; } } function fT(t, e) { e && !("baseUri" in t) && (t.baseUri = e); } function _m(t) { return t ? (Array.isArray(t) && (t = t[0]), Array.isArray(t == null ? void 0 : t.extensions)) : !1; } function wm(t) { lu(t, "null loader"), lu(_m(t), "invalid loader"); let e; return Array.isArray(t) && (e = t[1], t = t[0], t = { ...t, options: { ...t.options, ...e } }), (t != null && t.parseTextSync || t != null && t.parseText) && (t.text = !0), t.text || (t.binary = !0), t; } const lE = () => { const t = sE(); return t.loaderRegistry = t.loaderRegistry || [], t.loaderRegistry; }; function hT(t) { const e = lE(); t = Array.isArray(t) ? t : [t]; for (const r of t) { const n = wm(r); e.find((i) => n === i) || e.unshift(n); } } function dT() { return lE(); } const pT = /\.([^.]+)$/; async function gT(t, e = [], r, n) { if (!uE(t)) return null; let i = Ub(t, e, { ...r, nothrow: !0 }, n); if (i) return i; if (Ji(t) && (t = await t.slice(0, 10).arrayBuffer(), i = Ub(t, e, r, n)), !i && !(r != null && r.nothrow)) throw new Error(cE(t)); return i; } function Ub(t, e = [], r, n) { if (!uE(t)) return null; if (e && !Array.isArray(e)) return wm(e); let i = []; e && (i = i.concat(e)), r != null && r.ignoreRegisteredLoaders || i.push(...dT()), bT(i); const o = mT(t, i, r, n); if (!o && !(r != null && r.nothrow)) throw new Error(cE(t)); return o; } function mT(t, e, r, n) { const i = kc(t), o = vm(t), s = ym(i) || (n == null ? void 0 : n.url); let a = null, l = ""; return r != null && r.mimeType && (a = Of(e, r == null ? void 0 : r.mimeType), l = `match forced by supplied MIME type ${r == null ? void 0 : r.mimeType}`), a = a || yT(e, s), l = l || (a ? `matched url ${s}` : ""), a = a || Of(e, o), l = l || (a ? `matched MIME type ${o}` : ""), a = a || _T(e, t), l = l || (a ? `matched initial data ${fE(t)}` : ""), r != null && r.fallbackMimeType && (a = a || Of(e, r == null ? void 0 : r.fallbackMimeType), l = l || (a ? `matched fallback MIME type ${o}` : "")), l && d8.log(1, `selectLoader selected ${a == null ? void 0 : a.name}: ${l}.`), a; } function uE(t) { return !(t instanceof Response && t.status === 204); } function cE(t) { const e = kc(t), r = vm(t); let n = "No valid loader found ("; n += e ? `${tE(e)}, ` : "no url provided, ", n += `MIME type: ${r ? `"${r}"` : "not provided"}, `; const i = t ? fE(t) : ""; return n += i ? ` first bytes: "${i}"` : "first bytes: not available", n += ")", n; } function bT(t) { for (const e of t) wm(e); } function yT(t, e) { const r = e && pT.exec(e), n = r && r[1]; return n ? vT(t, n) : null; } function vT(t, e) { e = e.toLowerCase(); for (const r of t) for (const n of r.extensions) if (n.toLowerCase() === e) return r; return null; } function Of(t, e) { var r; for (const n of t) if ((r = n.mimeTypes) != null && r.some((i) => Nb(e, i)) || Nb(e, `application/x.${n.id}`)) return n; return null; } function _T(t, e) { if (!e) return null; for (const r of t) if (typeof e == "string") { if (wT(e, r)) return r; } else if (ArrayBuffer.isView(e)) { if (jb(e.buffer, e.byteOffset, r)) return r; } else if (e instanceof ArrayBuffer && jb(e, 0, r)) return r; return null; } function wT(t, e) { return e.testText ? e.testText(t) : (Array.isArray(e.tests) ? e.tests : [e.tests]).some((n) => t.startsWith(n)); } function jb(t, e, r) { return (Array.isArray(r.tests) ? r.tests : [r.tests]).some((i) => xT(t, e, r, i)); } function xT(t, e, r, n) { if (n instanceof ArrayBuffer) return I8(n, t, n.byteLength); switch (typeof n) { case "function": return n(t); case "string": const i = V0(t, e, n.length); return n === i; default: return !1; } } function fE(t, e = 5) { return typeof t == "string" ? t.slice(0, e) : ArrayBuffer.isView(t) ? V0(t.buffer, t.byteOffset, e) : t instanceof ArrayBuffer ? V0(t, 0, e) : ""; } function V0(t, e, r) { if (t.byteLength < e + r) return ""; const n = new DataView(t); let i = ""; for (let o = 0; o < r; o++) i += String.fromCharCode(n.getUint8(e + o)); return i; } const ST = 256 * 1024; function* ET(t, e) { const r = (e == null ? void 0 : e.chunkSize) || ST; let n = 0; const i = new TextEncoder(); for (; n < t.length; ) { const o = Math.min(t.length - n, r), s = t.slice(n, n + o); n += o, yield i.encode(s); } } const MT = 256 * 1024; function* AT(t, e = {}) { const { chunkSize: r = MT } = e; let n = 0; for (; n < t.byteLength; ) { const i = Math.min(t.byteLength - n, r), o = new ArrayBuffer(i), s = new Uint8Array(t, n, i); new Uint8Array(o).set(s), n += i, yield o; } } const RT = 1024 * 1024; async function* TT(t, e) { const r = (e == null ? void 0 : e.chunkSize) || RT; let n = 0; for (; n < t.size; ) { const i = n + r, o = await t.slice(n, i).arrayBuffer(); n = i, yield o; } } function zb(t, e) { return mm ? CT(t, e) : IT(t); } async function* CT(t, e) { const r = t.getReader(); let n; try { for (; ; ) { const i = n || r.read(); e != null && e._streamReadAhead && (n = r.read()); const { done: o, value: s } = await i; if (o) return; yield eE(s); } } catch { r.releaseLock(); } } async function* IT(t, e) { for await (const r of t) yield eE(r); } function kT(t, e) { if (typeof t == "string") return ET(t, e); if (t instanceof ArrayBuffer) return AT(t, e); if (Ji(t)) return TT(t, e); if (rE(t)) return zb(t, e); if (Yi(t)) return zb(t.body, e); throw new Error("makeIterator"); } const hE = "Cannot convert supplied data type"; function PT(t, e, r) { if (e.text && typeof t == "string") return t; if (U8(t) && (t = t.buffer), t instanceof ArrayBuffer) { const n = t; return e.text && !e.binary ? new TextDecoder("utf8").decode(n) : n; } if (ArrayBuffer.isView(t)) { if (e.text && !e.binary) return new TextDecoder("utf8").decode(t); let n = t.buffer; const i = t.byteLength || t.length; return (t.byteOffset !== 0 || i !== n.byteLength) && (n = n.slice(t.byteOffset, t.byteOffset + i)), n; } throw new Error(hE); } async function OT(t, e, r) { const n = t instanceof ArrayBuffer || ArrayBuffer.isView(t); if (typeof t == "string" || n) return PT(t, e); if (Ji(t) && (t = await iE(t)), Yi(t)) { const i = t; return await Y8(i), e.binary ? await i.arrayBuffer() : await i.text(); } if (rE(t) && (t = kT(t, r)), $8(t) || F8(t)) return O8(t); throw new Error(hE); } function dE(t, e) { const r = aE(), n = t || r; return typeof n.fetch == "function" ? n.fetch : $a(n.fetch) ? (i) => qb(i, n.fetch) : e != null && e.fetch ? e == null ? void 0 : e.fetch : qb; } function BT(t, e, r) { if (r) return r; const n = { fetch: dE(e, t), ...t }; if (n.url) { const i = ym(n.url); n.baseUrl = i, n.queryString = K8(n.url), n.filename = tE(i), n.baseUrl = q8(i); } return Array.isArray(n.loaders) || (n.loaders = null), n; } function NT(t, e) { if (t && !Array.isArray(t)) return t; let r; if (t && (r = Array.isArray(t) ? t : [t]), e && e.loaders) { const n = Array.isArray(e.loaders) ? e.loaders : [e.loaders]; r = r ? [...r, ...n] : n; } return r && r.length ? r : void 0; } async function fu(t, e, r, n) { e && !Array.isArray(e) && !_m(e) && (n = void 0, r = e, e = void 0), t = await t, r = r || {}; const i = kc(t), s = NT(e, n), a = await gT(t, s, r); return a ? (r = aT(r, a, s, i), n = BT( // @ts-expect-error { url: i, _parse: fu, loaders: s }, r, n || null ), await DT(a, t, r, n)) : null; } async function DT(t, e, r, n) { if (A8(t), r = p8(t.options, r), Yi(e)) { const o = e, { ok: s, redirected: a, status: l, statusText: u, type: c, url: f } = o, h = Object.fromEntries(o.headers.entries()); n.response = { headers: h, ok: s, redirected: a, status: l, statusText: u, type: c, url: f }; } e = await OT(e, t, r); const i = t; if (i.parseTextSync && typeof e == "string") return i.parseTextSync(e, r, n); if (R8(t, r)) return await T8(t, e, r, n, fu); if (i.parseText && typeof e == "string") return await i.parseText(e, r, n); if (i.parse) return await i.parse(e, r, n); throw li(!i.parseSync), new Error(`${t.id} loader - no parser found and worker is disabled`); } async function hu(t, e, r, n) { let i, o; !Array.isArray(e) && !_m(e) ? (i = [], o = e) : (i = e, o = r); const s = dE(o); let a = t; return typeof t == "string" && (a = await s(t)), Ji(t) && (a = await s(t)), Array.isArray(i) ? await fu(a, i, o) : await fu(a, i, o); } const qT = "4.3.2"; var $S; const LT = ($S = globalThis.loaders) == null ? void 0 : $S.parseImageNode, X0 = typeof Image < "u", K0 = typeof ImageBitmap < "u", $T = !!LT, Z0 = mm ? !0 : $T; function FT(t) { switch (t) { case "auto": return K0 || X0 || Z0; case "imagebitmap": return K0; case "image": return X0; case "data": return Z0; default: throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`); } } function UT() { if (K0) return "imagebitmap"; if (X0) return "image"; if (Z0) return "data"; throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js"); } function jT(t) { const e = HT(t); if (!e) throw new Error("Not an image"); return e; } function zT(t) { switch (jT(t)) { case "data": return t; case "image": case "imagebitmap": const e = document.createElement("canvas"), r = e.getContext("2d"); if (!r) throw new Error("getImageData"); return e.width = t.width, e.height = t.height, r.drawImage(t, 0, 0), r.getImageData(0, 0, t.width, t.height); default: throw new Error("getImageData"); } } function HT(t) { return typeof ImageBitmap < "u" && t instanceof ImageBitmap ? "im