UNPKG

@convo-lang/convo-lang-cli

Version:
1,463 lines (1,441 loc) 30.4 MB
#!/usr/bin/env node "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from2, except, desc) => { if (from2 && typeof from2 === "object" || typeof from2 === "function") { for (let key2 of __getOwnPropNames(from2)) if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp(to, key2, { get: () => from2[key2], enumerable: !(desc = __getOwnPropDesc(from2, key2)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/@iyio/common/src/lib/AuthDependentClient.js var init_AuthDependentClient = __esm({ "../../node_modules/@iyio/common/src/lib/AuthDependentClient.js"() { } }); // ../../node_modules/@iyio/common/src/lib/array.js var aryRemoveItem, aryRemoveFirst, aryDuplicateRemoveItem, asArray, asArrayItem, aryRandomize, uint32ArrayToNumberArray, aryUnique; var init_array = __esm({ "../../node_modules/@iyio/common/src/lib/array.js"() { aryRemoveItem = (ary, item) => { if (!ary) { return false; } for (let i3 = 0; i3 < ary.length; i3++) { if (ary[i3] === item) { ary.splice(i3, 1); return true; } } return false; }; aryRemoveFirst = (ary, condition) => { if (!ary) { return false; } for (let i3 = 0; i3 < ary.length; i3++) { if (condition(ary[i3])) { ary.splice(i3, 1); return true; } } return false; }; aryDuplicateRemoveItem = (ary, item) => { if (!ary) { return []; } ary = [...ary]; for (let i3 = 0; i3 < ary.length; i3++) { if (ary[i3] === item) { ary.splice(i3, 1); return ary; } } return ary; }; asArray = (value) => { if (!value) { return void 0; } if (Array.isArray(value)) { return value; } else { return [value]; } }; asArrayItem = (value) => { if (!value) { return void 0; } if (Array.isArray(value)) { return value[0]; } else { return value; } }; aryRandomize = (ary) => { const newAry = []; if (!ary || !ary.length) { return newAry; } newAry.push(ary[0]); for (let i3 = 1; i3 < ary.length; i3++) { const index = Math.round(Math.random() * i3); newAry.splice(index, 0, ary[i3]); } return newAry; }; uint32ArrayToNumberArray = (input, length = input.length) => { const ary = Array(length * 4); for (let i3 = 0; i3 < length; i3++) { const n3 = input[i3]; ary[i3 * 4] = n3 & 255; ary[i3 * 4 + 1] = n3 >> 8 & 255; ary[i3 * 4 + 2] = n3 >> 16 & 255; ary[i3 * 4 + 3] = n3 >> 24 & 255; } return ary; }; aryUnique = (ary) => { const unique = []; for (let i3 = 0; i3 < ary.length; i3++) { const item = ary[i3]; if (!unique.includes(item)) { unique.push(item); } } return unique; }; } }); // ../../node_modules/@iyio/common/src/lib/errors.js var ErrorType, BaseError, DisposedError, CanceledError, UnsupportedError, TypeProviderNotFoundError, ScopeInitedError, HttpBaseUrlPrefixNotFoundError, NotFoundError, UnauthorizedError; var init_errors = __esm({ "../../node_modules/@iyio/common/src/lib/errors.js"() { (function(ErrorType2) { ErrorType2[ErrorType2["unknown"] = 1] = "unknown"; ErrorType2[ErrorType2["disposed"] = 2] = "disposed"; ErrorType2[ErrorType2["canceled"] = 3] = "canceled"; ErrorType2[ErrorType2["unsupported"] = 4] = "unsupported"; ErrorType2[ErrorType2["configValueNotFound"] = 5] = "configValueNotFound"; ErrorType2[ErrorType2["dependencyNotFound"] = 6] = "dependencyNotFound"; ErrorType2[ErrorType2["invalidOverloadCall"] = 7] = "invalidOverloadCall"; ErrorType2[ErrorType2["typeProviderNotFoundError"] = 8] = "typeProviderNotFoundError"; ErrorType2[ErrorType2["scopeInited"] = 9] = "scopeInited"; ErrorType2[ErrorType2["httpBaseUrlPrefixNotFoundError"] = 10] = "httpBaseUrlPrefixNotFoundError"; ErrorType2[ErrorType2["invalidStoreKeyError"] = 11] = "invalidStoreKeyError"; ErrorType2[ErrorType2["badRequest"] = 400] = "badRequest"; ErrorType2[ErrorType2["unauthorized"] = 401] = "unauthorized"; ErrorType2[ErrorType2["paymentRequired"] = 402] = "paymentRequired"; ErrorType2[ErrorType2["forbidden"] = 403] = "forbidden"; ErrorType2[ErrorType2["notFound"] = 404] = "notFound"; ErrorType2[ErrorType2["methodNotAllowed"] = 405] = "methodNotAllowed"; ErrorType2[ErrorType2["notAcceptable"] = 406] = "notAcceptable"; ErrorType2[ErrorType2["proxyAuthenticationRequired"] = 407] = "proxyAuthenticationRequired"; ErrorType2[ErrorType2["requestTimeout"] = 408] = "requestTimeout"; ErrorType2[ErrorType2["conflict"] = 409] = "conflict"; ErrorType2[ErrorType2["gone"] = 410] = "gone"; ErrorType2[ErrorType2["lengthRequired"] = 411] = "lengthRequired"; ErrorType2[ErrorType2["preconditionFailed"] = 412] = "preconditionFailed"; ErrorType2[ErrorType2["contentTooLarge"] = 413] = "contentTooLarge"; ErrorType2[ErrorType2["uRITooLong"] = 414] = "uRITooLong"; ErrorType2[ErrorType2["unsupportedMediaType"] = 415] = "unsupportedMediaType"; ErrorType2[ErrorType2["rangeNotSatisfiable"] = 416] = "rangeNotSatisfiable"; ErrorType2[ErrorType2["expectationFailed"] = 417] = "expectationFailed"; ErrorType2[ErrorType2["misdirectedRequest"] = 421] = "misdirectedRequest"; ErrorType2[ErrorType2["unprocessableContent"] = 422] = "unprocessableContent"; ErrorType2[ErrorType2["locked"] = 423] = "locked"; ErrorType2[ErrorType2["failedDependency"] = 424] = "failedDependency"; ErrorType2[ErrorType2["tooEarly"] = 425] = "tooEarly"; ErrorType2[ErrorType2["upgradeRequired"] = 426] = "upgradeRequired"; ErrorType2[ErrorType2["preconditionRequired"] = 428] = "preconditionRequired"; ErrorType2[ErrorType2["tooManyRequests"] = 429] = "tooManyRequests"; ErrorType2[ErrorType2["requestHeaderFieldsTooLarge"] = 431] = "requestHeaderFieldsTooLarge"; ErrorType2[ErrorType2["unavailableForLegalReasons"] = 451] = "unavailableForLegalReasons"; ErrorType2[ErrorType2["internalServerError"] = 500] = "internalServerError"; ErrorType2[ErrorType2["notImplemented"] = 501] = "notImplemented"; ErrorType2[ErrorType2["badGateway"] = 502] = "badGateway"; ErrorType2[ErrorType2["serviceUnavailable"] = 503] = "serviceUnavailable"; ErrorType2[ErrorType2["gatewayTimeout"] = 504] = "gatewayTimeout"; ErrorType2[ErrorType2["hTTPVersionNotSupported"] = 505] = "hTTPVersionNotSupported"; ErrorType2[ErrorType2["variantAlsoNegotiates"] = 506] = "variantAlsoNegotiates"; ErrorType2[ErrorType2["insufficientStorage"] = 507] = "insufficientStorage"; ErrorType2[ErrorType2["loopDetected"] = 508] = "loopDetected"; ErrorType2[ErrorType2["networkAuthenticationRequired"] = 511] = "networkAuthenticationRequired"; })(ErrorType || (ErrorType = {})); BaseError = class extends Error { constructor(type, message2) { super(ErrorType[type] + (message2 ? " - " + message2 : "")); this.cErrT = type; } }; DisposedError = class extends BaseError { constructor(message2) { super(ErrorType.disposed, message2); } }; CanceledError = class extends BaseError { constructor(message2) { super(ErrorType.canceled, message2); } }; UnsupportedError = class extends BaseError { constructor(message2) { super(ErrorType.unsupported, message2); } }; TypeProviderNotFoundError = class extends BaseError { constructor(message2) { super(ErrorType.typeProviderNotFoundError, message2); } }; ScopeInitedError = class extends BaseError { constructor(message2) { super(ErrorType.scopeInited, message2); } }; HttpBaseUrlPrefixNotFoundError = class extends BaseError { constructor(message2) { super(ErrorType.httpBaseUrlPrefixNotFoundError, message2); } }; NotFoundError = class extends BaseError { constructor(message2) { super(ErrorType.notFound, message2); } }; UnauthorizedError = class extends BaseError { constructor(message2) { super(ErrorType.unauthorized, message2); } }; } }); // ../../node_modules/@iyio/common/src/lib/CancelToken.js var CancelToken; var init_CancelToken = __esm({ "../../node_modules/@iyio/common/src/lib/CancelToken.js"() { init_array(); init_errors(); CancelToken = class { constructor() { this._isCanceled = false; this.listeners = []; this.cancelNow = () => { if (this._isCanceled) { return; } this._isCanceled = true; const listeners2 = this.listeners; this.listeners = null; if (listeners2) { for (const l3 of listeners2) { try { l3(); } catch { } } } }; } get isCanceled() { return this._isCanceled; } dispose() { this.cancelNow(); } /** * The same as onCancel except an unsubscribe callback is returned that can be used to remove * the listener */ subscribe(listener) { if (this._isCanceled || !this.listeners) { return () => { }; } this.listeners.push(listener); return () => { if (this.listeners) { aryRemoveItem(this.listeners, listener); } }; } /** * The same as onCancelOrNextTick except an unsubscribe callback is returned that can be used * to remove the listener */ subscribeOrNextTick(listener) { if (this._isCanceled || !this.listeners) { setTimeout(listener, 0); return () => { }; } this.listeners.push(listener); return () => { if (this.listeners) { aryRemoveItem(this.listeners, listener); } }; } /** * Adds the listener to the collection of listeners to be called when the token is canceled. * If the token is already canceled the listener will not be called and is not added to the * collection of listeners. */ onCancel(listener) { if (this._isCanceled || !this.listeners) { return; } this.listeners.push(listener); } /** * Adds the listener to the collection of listeners to be called when the token is canceled. * If the token is already canceled the listener will be called on the next pass of the event * loop and is not added to the collection of listeners. */ onCancelOrNextTick(listener) { if (this._isCanceled || !this.listeners) { setTimeout(listener, 0); return; } this.listeners.push(listener); } removeListener(listener) { if (!this.listeners) { return; } aryRemoveItem(this.listeners, listener); } /** * Cancels the token after the given number of milliseconds */ cancelAfter(ms) { if (this._isCanceled) { return; } setTimeout(this.cancelNow, ms); } throwIfCanceled(cancelMessage) { if (this._isCanceled) { throw new CanceledError(cancelMessage); } } /** * Returns a promise that resolves when the token is canceled. If the token is already canceled * the promise is resolved immediately. */ toPromise() { if (this.asPromise) { return this.asPromise; } return this.asPromise = new Promise((resolve7) => { if (this._isCanceled || !this.listeners) { resolve7(); return; } this.listeners.push(resolve7); }); } }; } }); // ../../node_modules/@iyio/common/src/lib/DisposeContainer.js var DisposeContainer; var init_DisposeContainer = __esm({ "../../node_modules/@iyio/common/src/lib/DisposeContainer.js"() { DisposeContainer = class { constructor() { this._isDisposing = false; this.subs = []; this.cbs = []; this.disposables = []; } get isDisposing() { return this._isDisposing; } add(disposable) { if (!disposable.dispose) { return this; } if (this._isDisposing) { try { disposable.dispose?.(); } catch (ex) { console.warn("Dispose failed", ex); } return this; } this.disposables.push(disposable); return this; } addSub(sub) { if (this._isDisposing) { try { sub.unsubscribe(); } catch (ex) { console.warn("Unsubscribe failed", ex); } return this; } this.subs.push(sub); return this; } createSub(create) { if (this._isDisposing) { return; } const sub = create(); if (!sub) { return; } this.addSub(sub); } addCb(cb) { if (this._isDisposing) { try { cb(); } catch (ex) { console.warn("Dispose callback failed", ex); } return this; } this.cbs.push(cb); return this; } createCb(create) { if (this._isDisposing) { return; } const cb = create(); if (!cb) { return; } this.addCb(cb); } dispose() { if (this._isDisposing) { return; } this._isDisposing = true; for (const sub of this.subs) { try { sub.unsubscribe(); } catch (ex) { console.warn("Unsubscribe failed", ex); } } for (const cb of this.cbs) { try { cb(); } catch (ex) { console.warn("Dispose callback failed", ex); } } for (const d3 of this.disposables) { try { d3.dispose(); } catch (ex) { console.warn("Dispose failed", ex); } } } }; } }); // ../../node_modules/@iyio/common/src/lib/object.js var deepCompare, deepClone, dupDeleteUndefined, deleteUndefined, deleteUndefinedOrNull, setValueByPath, getValueByPath, getValueByAryPath, getObjKeyCount, objGetFirstValue, queryParamsToObject, isClassInstanceObject; var init_object = __esm({ "../../node_modules/@iyio/common/src/lib/object.js"() { deepCompare = (a3, b3, keyComparerOrOptions, keyComparerState, maxDepth2 = 200, depth = 0) => { let keyComparer; let options; if (keyComparerOrOptions) { if (typeof keyComparerOrOptions === "function") { keyComparer = keyComparerOrOptions; } else { options = keyComparerOrOptions; keyComparer = options.keyComparer; keyComparerState = options.keyComparerState; } } if (maxDepth2 < 0) { throw new Error("deepCompare max depth reached"); } maxDepth2--; const type = typeof a3; if (type !== typeof b3) { return false; } if (type !== "object") { return a3 === b3; } if (a3 === null) { return a3 === b3; } else if (b3 === null) { return false; } if (Array.isArray(a3)) { if (a3.length !== b3.length) { return false; } for (let i3 = 0; i3 < a3.length; i3++) { if (!deepCompare(a3[i3], b3[i3], keyComparerOrOptions, keyComparerState, maxDepth2, depth + 1)) { return false; } } } else { let ac = 0; for (const e3 in a3) { ac++; if (keyComparer) { const r3 = keyComparer(e3, depth, a3, b3, keyComparerState); if (r3 === false) { return false; } else if (r3 === true) { continue; } } if (!deepCompare(a3[e3], b3[e3], keyComparerOrOptions, keyComparerState, maxDepth2, depth + 1)) { return false; } } if (!options || !options.ignoreExtraBKeys) { let dc = 0; for (const e3 in b3) { dc++; } if (ac !== dc) { return false; } } } return true; }; deepClone = (obj, maxDepth2 = 20) => { if (maxDepth2 < 0) { throw new Error("deepClone max depth reached"); } maxDepth2--; if (!obj || typeof obj !== "object") { return obj; } if (Array.isArray(obj)) { const clone = []; for (let i3 = 0; i3 < obj.length; i3++) { clone.push(deepClone(obj[i3], maxDepth2)); } return clone; } else { const clone = {}; for (const e3 in obj) { clone[e3] = deepClone(obj[e3], maxDepth2); } return clone; } }; dupDeleteUndefined = (obj) => { return deleteUndefined({ ...obj }); }; deleteUndefined = (obj) => { if (!obj) { return obj; } for (const e3 in obj) { if (obj[e3] === void 0) { delete obj[e3]; } } return obj; }; deleteUndefinedOrNull = (obj) => { if (!obj) { return obj; } for (const e3 in obj) { const v6 = obj[e3]; if (v6 === void 0 || v6 === null) { delete obj[e3]; } } return obj; }; setValueByPath = (target, path11, value, rootGetter) => { const parts = path11.split("."); const setterKey = parts.pop(); if (!setterKey) { return false; } if (parts.length) { target = getValueByAryPath(target, parts, void 0, void 0, rootGetter); } if (!target || typeof target !== "object") { return false; } if (value === void 0) { delete target[setterKey]; } else { target[setterKey] = value; } return true; }; getValueByPath = (value, path11, defaultValue = void 0, rootGetter) => { const parts = path11.split("."); for (let i3 = 0; i3 < parts.length; i3++) { const p3 = parts[i3].trim(); if (!p3) { continue; } if (i3 === 0 && rootGetter && value?.[p3] === void 0) { value = rootGetter(p3); } else { value = value?.[p3]; } if (value === void 0) { return defaultValue; } } return value === void 0 ? defaultValue : value; }; getValueByAryPath = (value, path11, defaultValue = void 0, pathLength = path11.length, rootGetter) => { for (let i3 = 0; i3 < pathLength; i3++) { const p3 = path11[i3]; if (p3 === void 0) { return defaultValue; } else if (p3 === null) { continue; } if (i3 === 0 && rootGetter && value?.[p3] === void 0) { value = rootGetter(p3); } else { value = value?.[p3]; } if (value === void 0) { return defaultValue; } } return value === void 0 ? defaultValue : value; }; getObjKeyCount = (obj) => { if (!obj) { return 0; } let c4 = 0; for (const _2 in obj) { c4++; } return c4; }; objGetFirstValue = (obj) => { if (!obj) { return void 0; } for (const e3 in obj) { return obj[e3]; } return void 0; }; queryParamsToObject = (query) => { if (!query) { return {}; } let q3 = query.indexOf("?"); if (q3 !== -1) { query = query.substring(q3 + 1); } const obj = {}; const parts = query.split("&"); for (const p3 of parts) { const [name, value] = p3.split("=", 2); const n3 = decodeURIComponent(name).trim(); if (!n3) { continue; } obj[n3] = decodeURIComponent(value?.trim() ?? ""); } return obj; }; isClassInstanceObject = (value) => { return value && typeof value === "object" && Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value); }; } }); // ../../node_modules/@iyio/common/src/lib/base64.js var defaultBase64Chars, fsBase64Chars, toBase64Native, markdownDecReg, base64EncodeMarkdownImage, base64EncodeUrl, base64Encode, base64EncodeAry, base64EncodeUint32Array, _utf8_encode; var init_base64 = __esm({ "../../node_modules/@iyio/common/src/lib/base64.js"() { init_array(); defaultBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; fsBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; toBase64Native = (data) => { const ca = data; if (typeof ca.toBase64 === "function") { return ca.toBase64(); } if (typeof globalThis.Buffer?.from === "function") { return globalThis.Buffer.from(data).toString("base64"); } if (typeof globalThis.btoa === "function" && globalThis.TextDecoder) { const ary = []; for (let i3 = 0, l3 = data.length; i3 < l3; i3++) { ary.push(String.fromCharCode(data[i3])); } return globalThis.btoa(ary.join("")); } return base64EncodeUint32Array(new Uint32Array(data.buffer, data.byteOffset, Math.floor(data.byteLength / 4))); }; markdownDecReg = /(\s+|\[|\])/g; base64EncodeMarkdownImage = (description, contentType, data) => { return `![${description.replace(markdownDecReg, " ")}](data:${contentType};base64,${toBase64Native(data)})`; }; base64EncodeUrl = (contentType, data) => { return `data:${contentType};base64,${toBase64Native(data)}`; }; base64Encode = (input, keyStr = defaultBase64Chars) => { let output = ""; let chr1, chr2, chr3, enc1, enc2, enc3, enc4; let i3 = 0; input = _utf8_encode(input); while (i3 < input.length) { chr1 = input.charCodeAt(i3++); chr2 = input.charCodeAt(i3++); chr3 = input.charCodeAt(i3++); enc1 = chr1 >> 2; enc2 = (chr1 & 3) << 4 | chr2 >> 4; enc3 = (chr2 & 15) << 2 | chr3 >> 6; enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } return output; }; base64EncodeAry = (input, keyStr = defaultBase64Chars) => { let output = ""; let chr1, chr2, chr3, enc1, enc2, enc3, enc4; let i3 = 0; while (i3 < input.length) { chr1 = input[i3++]; chr2 = input[i3++]; chr3 = input[i3++]; enc1 = chr1 >> 2; enc2 = (chr1 & 3) << 4 | chr2 >> 4; enc3 = (chr2 & 15) << 2 | chr3 >> 6; enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } return output; }; base64EncodeUint32Array = (input, keyStr = defaultBase64Chars, aryLength = input.length) => { return base64EncodeAry(uint32ArrayToNumberArray(input, aryLength), keyStr); }; _utf8_encode = (str) => { str = str.replace(/\r\n/g, "\n"); let utfText = ""; for (let n3 = 0; n3 < str.length; n3++) { const c4 = str.charCodeAt(n3); if (c4 < 128) { utfText += String.fromCharCode(c4); } else if (c4 > 127 && c4 < 2048) { utfText += String.fromCharCode(c4 >> 6 | 192); utfText += String.fromCharCode(c4 & 63 | 128); } else { utfText += String.fromCharCode(c4 >> 12 | 224); utfText += String.fromCharCode(c4 >> 6 & 63 | 128); utfText += String.fromCharCode(c4 & 63 | 128); } } return utfText; }; } }); // ../../node_modules/@iyio/common/src/lib/uuid.js function uuid() { if (_uuid) { return _uuid(); } if (typeof crypto?.randomUUID === "function") { _uuid = () => { return crypto.randomUUID(); }; } else if (typeof crypto?.getRandomValues === "function") { _uuid = rnd; } else { throw new Error("crypto.randomUUID and crypto.getRandomValues not defined in global scope"); } return _uuid(); } function shortUuid() { if (typeof crypto?.getRandomValues !== "function") { throw new Error("crypto.getRandomValues not defined in global scope"); } crypto.getRandomValues(randomBytes); randomBytes[6] = randomBytes[6] & 15 | 64; randomBytes[8] = randomBytes[8] & 63 | 128; return base64EncodeAry(randomBytes, fsBase64Chars); } function unsafeStringify(arr, offset = 0) { if (!byteToHex) { byteToHex = []; for (let i3 = 0; i3 < 256; ++i3) { byteToHex.push((i3 + 256).toString(16).slice(1)); } } return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); } var _uuid, g, crypto, randomBytes, rnd, byteToHex; var init_uuid = __esm({ "../../node_modules/@iyio/common/src/lib/uuid.js"() { init_base64(); g = globalThis; crypto = g.crypto; randomBytes = new Uint8Array(16); rnd = () => { crypto.getRandomValues(randomBytes); randomBytes[6] = randomBytes[6] & 15 | 64; randomBytes[8] = randomBytes[8] & 63 | 128; return unsafeStringify(randomBytes); }; } }); // ../../node_modules/@iyio/common/src/lib/PopupWindow.js var popupWindowMessagePrefix, sendPopupWindowMessage, getPopupWindowMessageAsync, PopupWindow; var init_PopupWindow = __esm({ "../../node_modules/@iyio/common/src/lib/PopupWindow.js"() { init_CancelToken(); init_object(); init_uuid(); popupWindowMessagePrefix = "<PopupWindow>:"; sendPopupWindowMessage = (id, value) => { globalThis.window.postMessage(`${popupWindowMessagePrefix}${id}::` + JSON.stringify(value ?? null)); }; getPopupWindowMessageAsync = (options, cancel = new CancelToken()) => { return new Promise((resolve7, reject) => { try { const win = new PopupWindow({ disposeOnTrigger: true, ...options, callback: (value) => { resolve7(value); } }); cancel.onCancel(() => { resolve7(void 0); win.dispose(); }); } catch (ex) { reject(ex); } }); }; PopupWindow = class { constructor(options) { this._isDisposed = false; this.messageListener = (evt) => { if (typeof evt.data !== "string" || !evt.data.startsWith(this.messageId)) { return; } const data = JSON.parse(evt.data.substring(this.messageId.length)); this.trigger(data); }; this.closeListener = () => { this.trigger(void 0); }; this.messageId = popupWindowMessagePrefix + (options.messageId ?? uuid()) + "::"; this.options = options; const win = globalThis.window?.open?.(options.url, options.target ?? "_blank", options.features); if (!win) { throw new Error("Unable to open Popup window"); } this.window = win; this.window.addEventListener("message", this.messageListener); this.window.addEventListener("close", this.closeListener); if (options.locationTriggerReg || options.queryParamTrigger || options.triggerOnSameHost) { let lastLocationTrigger = null; this.iv = setInterval(() => { try { if (this.isWindowClosed()) { this.trigger(void 0); this.dispose(); } const location = this.getWindowLocation(); if (!location || lastLocationTrigger === location) { return; } lastLocationTrigger = location; if (options.locationTriggerReg) { const match3 = options.locationTriggerReg.exec(location); if (match3) { this.trigger(match3[this.options.locationTriggerRegValueIndex ?? 0] ?? ""); return; } } const qi = location.indexOf("?"); if (options.queryParamTrigger && qi !== -1) { const query = queryParamsToObject(location.substring(qi)); const v6 = query[options.queryParamTrigger]; if (v6 !== void 0) { this.trigger(v6); return; } } if (options.triggerOnSameHost && globalThis.location && this.window.location.host === globalThis.location?.host) { this.trigger(""); return; } } catch { } }, options.pollingIntervalMs ?? 100); } if (options.timeoutMs) { this.timeoutIv = setTimeout(() => { this.trigger(""); }, options.timeoutMs); } } getWindowLocation() { try { return this.window.location.toString(); } catch { return void 0; } } isWindowClosed() { try { return this.window.closed; } catch { return void 0; } } get isDisposed() { return this._isDisposed; } dispose() { if (this._isDisposed) { return; } this._isDisposed = true; clearTimeout(this.timeoutIv); clearInterval(this.iv); if (this.window) { try { this.window.removeEventListener("message", this.messageListener); } catch { } try { this.window.removeEventListener("close", this.closeListener); } catch { } if (!this.options.keepOpen) { try { this.window.close(); } catch { } } } } trigger(value) { if (this.isDisposed) { return; } clearTimeout(this.timeoutIv); if (this.options.disposeOnTrigger) { this.dispose(); } this.options.callback?.(value); } }; } }); // ../../node_modules/@iyio/common/src/lib/ValueCache.js var ValueCache; var init_ValueCache = __esm({ "../../node_modules/@iyio/common/src/lib/ValueCache.js"() { ValueCache = class { constructor() { this.values = {}; } clear() { const keys = Object.keys(this.values); const symbols = Object.getOwnPropertySymbols(this.values); for (const key2 of keys) { delete this.values[key2]; } for (const key2 of symbols) { delete this.values[key2]; } } getOrCreate(key2, create) { const value = this.values[key2]; if (value !== void 0) { return value; } const v6 = create(key2); this.values[key2] = v6; return v6; } get(key2) { return this.values[key2]; } set(key2, value) { this.values[key2] = value; } remove(key2) { delete this.values[key2]; } }; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/isFunction.js var require_isFunction = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/isFunction.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.isFunction = void 0; function isFunction2(value) { return typeof value === "function"; } exports2.isFunction = isFunction2; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/createErrorClass.js var require_createErrorClass = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/createErrorClass.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.createErrorClass = void 0; function createErrorClass2(createImpl) { var _super = function(instance) { Error.call(instance); instance.stack = new Error().stack; }; var ctorFunc = createImpl(_super); ctorFunc.prototype = Object.create(Error.prototype); ctorFunc.prototype.constructor = ctorFunc; return ctorFunc; } exports2.createErrorClass = createErrorClass2; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/UnsubscriptionError.js var require_UnsubscriptionError = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/UnsubscriptionError.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UnsubscriptionError = void 0; var createErrorClass_1 = require_createErrorClass(); exports2.UnsubscriptionError = createErrorClass_1.createErrorClass(function(_super) { return function UnsubscriptionErrorImpl(errors) { _super(this); this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i3) { return i3 + 1 + ") " + err.toString(); }).join("\n ") : ""; this.name = "UnsubscriptionError"; this.errors = errors; }; }); } }); // ../../node_modules/rxjs/dist/cjs/internal/util/arrRemove.js var require_arrRemove = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/arrRemove.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.arrRemove = void 0; function arrRemove2(arr, item) { if (arr) { var index = arr.indexOf(item); 0 <= index && arr.splice(index, 1); } } exports2.arrRemove = arrRemove2; } }); // ../../node_modules/rxjs/dist/cjs/internal/Subscription.js var require_Subscription = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/Subscription.js"(exports2) { "use strict"; var __values3 = exports2 && exports2.__values || function(o3) { var s3 = typeof Symbol === "function" && Symbol.iterator, m4 = s3 && o3[s3], i3 = 0; if (m4) return m4.call(o3); if (o3 && typeof o3.length === "number") return { next: function() { if (o3 && i3 >= o3.length) o3 = void 0; return { value: o3 && o3[i3++], done: !o3 }; } }; throw new TypeError(s3 ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read3 = exports2 && exports2.__read || function(o3, n3) { var m4 = typeof Symbol === "function" && o3[Symbol.iterator]; if (!m4) return o3; var i3 = m4.call(o3), r3, ar = [], e3; try { while ((n3 === void 0 || n3-- > 0) && !(r3 = i3.next()).done) ar.push(r3.value); } catch (error2) { e3 = { error: error2 }; } finally { try { if (r3 && !r3.done && (m4 = i3["return"])) m4.call(i3); } finally { if (e3) throw e3.error; } } return ar; }; var __spreadArray3 = exports2 && exports2.__spreadArray || function(to, from2) { for (var i3 = 0, il = from2.length, j3 = to.length; i3 < il; i3++, j3++) to[j3] = from2[i3]; return to; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.isSubscription = exports2.EMPTY_SUBSCRIPTION = exports2.Subscription = void 0; var isFunction_1 = require_isFunction(); var UnsubscriptionError_1 = require_UnsubscriptionError(); var arrRemove_1 = require_arrRemove(); var Subscription3 = function() { function Subscription4(initialTeardown) { this.initialTeardown = initialTeardown; this.closed = false; this._parentage = null; this._finalizers = null; } Subscription4.prototype.unsubscribe = function() { var e_1, _a5, e_2, _b2; var errors; if (!this.closed) { this.closed = true; var _parentage = this._parentage; if (_parentage) { this._parentage = null; if (Array.isArray(_parentage)) { try { for (var _parentage_1 = __values3(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) { var parent_1 = _parentage_1_1.value; parent_1.remove(this); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_parentage_1_1 && !_parentage_1_1.done && (_a5 = _parentage_1.return)) _a5.call(_parentage_1); } finally { if (e_1) throw e_1.error; } } } else { _parentage.remove(this); } } var initialFinalizer = this.initialTeardown; if (isFunction_1.isFunction(initialFinalizer)) { try { initialFinalizer(); } catch (e3) { errors = e3 instanceof UnsubscriptionError_1.UnsubscriptionError ? e3.errors : [e3]; } } var _finalizers = this._finalizers; if (_finalizers) { this._finalizers = null; try { for (var _finalizers_1 = __values3(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) { var finalizer = _finalizers_1_1.value; try { execFinalizer2(finalizer); } catch (err) { errors = errors !== null && errors !== void 0 ? errors : []; if (err instanceof UnsubscriptionError_1.UnsubscriptionError) { errors = __spreadArray3(__spreadArray3([], __read3(errors)), __read3(err.errors)); } else { errors.push(err); } } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_finalizers_1_1 && !_finalizers_1_1.done && (_b2 = _finalizers_1.return)) _b2.call(_finalizers_1); } finally { if (e_2) throw e_2.error; } } } if (errors) { throw new UnsubscriptionError_1.UnsubscriptionError(errors); } } }; Subscription4.prototype.add = function(teardown) { var _a5; if (teardown && teardown !== this) { if (this.closed) { execFinalizer2(teardown); } else { if (teardown instanceof Subscription4) { if (teardown.closed || teardown._hasParent(this)) { return; } teardown._addParent(this); } (this._finalizers = (_a5 = this._finalizers) !== null && _a5 !== void 0 ? _a5 : []).push(teardown); } } }; Subscription4.prototype._hasParent = function(parent) { var _parentage = this._parentage; return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent); }; Subscription4.prototype._addParent = function(parent) { var _parentage = this._parentage; this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent; }; Subscription4.prototype._removeParent = function(parent) { var _parentage = this._parentage; if (_parentage === parent) { this._parentage = null; } else if (Array.isArray(_parentage)) { arrRemove_1.arrRemove(_parentage, parent); } }; Subscription4.prototype.remove = function(teardown) { var _finalizers = this._finalizers; _finalizers && arrRemove_1.arrRemove(_finalizers, teardown); if (teardown instanceof Subscription4) { teardown._removeParent(this); } }; Subscription4.EMPTY = function() { var empty = new Subscription4(); empty.closed = true; return empty; }(); return Subscription4; }(); exports2.Subscription = Subscription3; exports2.EMPTY_SUBSCRIPTION = Subscription3.EMPTY; function isSubscription2(value) { return value instanceof Subscription3 || value && "closed" in value && isFunction_1.isFunction(value.remove) && isFunction_1.isFunction(value.add) && isFunction_1.isFunction(value.unsubscribe); } exports2.isSubscription = isSubscription2; function execFinalizer2(finalizer) { if (isFunction_1.isFunction(finalizer)) { finalizer(); } else { finalizer.unsubscribe(); } } } }); // ../../node_modules/rxjs/dist/cjs/internal/config.js var require_config = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/config.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.config = void 0; exports2.config = { onUnhandledError: null, onStoppedNotification: null, Promise: void 0, useDeprecatedSynchronousErrorHandling: false, useDeprecatedNextContext: false }; } }); // ../../node_modules/rxjs/dist/cjs/internal/scheduler/timeoutProvider.js var require_timeoutProvider = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/scheduler/timeoutProvider.js"(exports2) { "use strict"; var __read3 = exports2 && exports2.__read || function(o3, n3) { var m4 = typeof Symbol === "function" && o3[Symbol.iterator]; if (!m4) return o3; var i3 = m4.call(o3), r3, ar = [], e3; try { while ((n3 === void 0 || n3-- > 0) && !(r3 = i3.next()).done) ar.push(r3.value); } catch (error2) { e3 = { error: error2 }; } finally { try { if (r3 && !r3.done && (m4 = i3["return"])) m4.call(i3); } finally { if (e3) throw e3.error; } } return ar; }; var __spreadArray3 = exports2 && exports2.__spreadArray || function(to, from2) { for (var i3 = 0, il = from2.length, j3 = to.length; i3 < il; i3++, j3++) to[j3] = from2[i3]; return to; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.timeoutProvider = void 0; exports2.timeoutProvider = { setTimeout: function(handler, timeout2) { var args2 = []; for (var _i = 2; _i < arguments.length; _i++) { args2[_i - 2] = arguments[_i]; } var delegate = exports2.timeoutProvider.delegate; if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) { return delegate.setTimeout.apply(delegate, __spreadArray3([handler, timeout2], __read3(args2))); } return setTimeout.apply(void 0, __spreadArray3([handler, timeout2], __read3(args2))); }, clearTimeout: function(handle) { var delegate = exports2.timeoutProvider.delegate; return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle); }, delegate: void 0 }; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/reportUnhandledError.js var require_reportUnhandledError = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/reportUnhandledError.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.reportUnhandledError = void 0; var config_1 = require_config(); var timeoutProvider_1 = require_timeoutProvider(); function reportUnhandledError2(err) { timeoutProvider_1.timeoutProvider.setTimeout(function() { var onUnhandledError = config_1.config.onUnhandledError; if (onUnhandledError) { onUnhandledError(err); } else { throw err; } }); } exports2.reportUnhandledError = reportUnhandledError2; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/noop.js var require_noop = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/noop.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.noop = void 0; function noop2() { } exports2.noop = noop2; } }); // ../../node_modules/rxjs/dist/cjs/internal/NotificationFactories.js var require_NotificationFactories = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/NotificationFactories.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.createNotification = exports2.nextNotification = exports2.errorNotification = exports2.COMPLETE_NOTIFICATION = void 0; exports2.COMPLETE_NOTIFICATION = function() { return createNotification2("C", void 0, void 0); }(); function errorNotification2(error2) { return createNotification2("E", void 0, error2); } exports2.errorNotification = errorNotification2; function nextNotification2(value) { return createNotification2("N", value, void 0); } exports2.nextNotification = nextNotification2; function createNotification2(kind, value, error2) { return { kind, value, error: error2 }; } exports2.createNotification = createNotification2; } }); // ../../node_modules/rxjs/dist/cjs/internal/util/errorContext.js var require_errorContext = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/util/errorContext.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.captureError = exports2.errorContext = void 0; var config_1 = require_config(); var context2 = null; function errorContext2(cb) { if (config_1.config.useDeprecatedSynchronousErrorHandling) { var isRoot = !context2; if (isRoot) { context2 = { errorThrown: false, error: null }; } cb(); if (isRoot) { var _a5 = context2, errorThrown = _a5.errorThrown, error2 = _a5.error; context2 = null; if (errorThrown) { throw error2; } } } else { cb(); } } exports2.errorContext = errorContext2; function captureError2(err) { if (config_1.config.useDeprecatedSynchronousErrorHandling && context2) { context2.errorThrown = true; context2.error = err; } } exports2.captureError = captureError2; } }); // ../../node_modules/rxjs/dist/cjs/internal/Subscriber.js var require_Subscriber = __commonJS({ "../../node_modules/rxjs/dist/cjs/internal/Subscriber.js"(exports2) { "use strict"; var __extends3 = exports2 && exports2.__extends || /* @__PURE__ */ function() { var extendStatics3 = function(d3, b3) { extendStatics3 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b4) { d4.__proto__ = b4; } || function(d4, b4) { for (var p3 in b4) if (Object.prototype.hasOwnProperty.call(b4, p3)) d4[p3] = b4[p3]; }; return extendStatics3(d3, b3); }; return function(d3, b3) { if (typeof b3 !== "function" && b3 !== null) throw new TypeError("Class extends value " + String(b3) + " is not a constructor or null"); extendStatics3(d3, b3); function __() { this.constructor = d3; } d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __()); }; }(); Object.defineProp