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E,EAAUuE,EAClD,CAoBO,IAAIS,EAAmBrB,EAAkBmB,GAWbb,EAAuBa,GAUvBZ,EAAuBY,E,oCCxE1D,IA4CIG,EAAS,CAACC,EAAO,KACnBC,OAAOC,gBAAgB,IAAIC,WAAWH,IAAOI,QAAO,CAACC,EAAIC,IASrDD,IAHFC,GAAQ,IACG,GAEHA,EAAK5F,SAAS,IACX4F,EAAO,IAETA,EAAO,IAAI5F,SAAS,IAAI6F,cACtBD,EAAO,GACV,IAEA,KAGP,G","sources":["file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/await.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/debug.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/internal/state.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/event.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/internal/constants.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/base.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/itemProcessor.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/asyncPromise.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/nativePromise.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/@nevware21+ts-async@0.4.0/node_modules/@nevware21/ts-async/dist-es5/promise/promise.js","file:////home/runner/work/platform/platform/common/temp/node_modules/.pnpm/nanoid@3.3.8/node_modules/nanoid/index.browser.js"],"sourcesContent":["/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { isPromiseLike } from \"@nevware21/ts-utils\";\r\n/**\r\n * Helper to coallesce the promise resolved / reject into a single callback to simplify error handling.\r\n * @group Await Helper\r\n * @param value - The value or promise like value to wait to be resolved or rejected.\r\n * @param cb - The callback function to call with the resulting value, if the value is not a\r\n * promise like value then the callback is called synchronously, if the value is a promise then\r\n * the callback will be called once the promise completes the resulting value will be passed as an\r\n * IAwaitResponse instance, it will be called whether any promise resolves or rejects.\r\n * @returns The value returned by the `cb` callback function, if the value is a promise then the return value\r\n * of the callback will be returned as a promise whether the callback returns a promise or not.\r\n * @example\r\n * ```ts\r\n * let promise = createPromise((resolve, reject) => {\r\n * resolve(42);\r\n * });\r\n *\r\n * // Handle via doAwaitResponse\r\n * doAwaitResponse(promise, (value) => {\r\n * if (!value.rejected) {\r\n * // Do something with the value\r\n * } else {\r\n * // Do something with the reason\r\n * }\r\n * });\r\n *\r\n * // It can also handle the raw value, so you could process the result of either a\r\n * // synchrounous return of the value or a Promise\r\n * doAwaitResponse(42, (value) => {\r\n * if (!value.rejected) {\r\n * // Do something with the value\r\n * } else {\r\n * // This will never be true as the value is not a promise\r\n * }\r\n * });\r\n * ```\r\n */\r\nexport function doAwaitResponse(value, cb) {\r\n return doAwait(value, function (value) {\r\n return cb ? cb({\r\n value: value,\r\n rejected: false\r\n }) : value;\r\n }, function (reason) {\r\n return cb ? cb({\r\n rejected: true,\r\n reason: reason\r\n }) : reason;\r\n });\r\n}\r\n/**\r\n * Wait for the promise to resolve or reject, if resolved the callback function will be called with it's value and if\r\n * rejected the rejectFn will be called with the reason. If the passed promise argument is not a promise the callback\r\n * will be called synchronously with the value.\r\n * @group Await Helper\r\n * @param value - The value or promise like value to wait for\r\n * @param resolveFn - The callback to call on the promise successful resolving.\r\n * @param rejectFn - The callback to call when the promise rejects\r\n * @returns The passed value, if it is a promise and there is either a resolve or reject handler\r\n * then it will return a chained promise with the value from the resolve or reject handler (depending\r\n * whether it resolve or rejects)\r\n * @example\r\n * ```ts\r\n * let promise = createPromise((resolve, reject) => {\r\n * resolve(42);\r\n * });\r\n *\r\n * // Handle via a chained promise\r\n * let chainedPromise = promise.then((value) => {\r\n * // Do something with the value\r\n * });\r\n *\r\n * // Handle via doAwait\r\n * doAwait(promise, (value) => {\r\n * // Do something with the value\r\n * });\r\n *\r\n * // It can also handle the raw value, so you could process the result of either a\r\n * // synchrounous return of the value or a Promise\r\n * doAwait(42, (value) => {\r\n * // Do something with the value\r\n * });\r\n * ```\r\n */\r\nexport function doAwait(value, resolveFn, rejectFn, finallyFn) {\r\n var result = value;\r\n if (isPromiseLike(value)) {\r\n if (resolveFn || rejectFn) {\r\n result = value.then(resolveFn, rejectFn);\r\n }\r\n }\r\n else {\r\n if (resolveFn) {\r\n result = resolveFn(value);\r\n }\r\n }\r\n if (finallyFn) {\r\n doFinally(result, finallyFn);\r\n }\r\n return result;\r\n}\r\n/**\r\n * Wait for the promise to resolve or reject and then call the finallyFn. If the passed promise argument is not a promise the callback\r\n * will be called synchronously with the value. If the passed promise doesn't implement finally then a finally implementation will be\r\n * simulated using then(..., ...).\r\n * @group Await Helper\r\n * @param value - The value or promise like value to wait for\r\n * @param finallyFn - The finally function to call once the promise has resolved or rejected\r\n */\r\nexport function doFinally(value, finallyFn) {\r\n var result = value;\r\n if (finallyFn) {\r\n if (isPromiseLike(value)) {\r\n if (value.finally) {\r\n result = value.finally(finallyFn);\r\n }\r\n else {\r\n // Simulate finally if not available\r\n result = value.then(function (value) {\r\n finallyFn();\r\n return value;\r\n }, function (reason) {\r\n finallyFn();\r\n throw reason;\r\n });\r\n }\r\n }\r\n else {\r\n finallyFn();\r\n }\r\n }\r\n return result;\r\n}\r\n//# sourceMappingURL=await.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { objDefineProp } from \"@nevware21/ts-utils\";\r\nvar _debugState;\r\nvar _debugResult;\r\nvar _debugHandled;\r\n/**\r\n * @internal\r\n * @ignore\r\n */\r\nexport var _promiseDebugEnabled = false;\r\nvar _theLogger = null;\r\n/**\r\n * @internal\r\n * @ignore Internal function enable logging the internal state of the promise during execution, this code and references are\r\n * removed from the production artifacts\r\n */\r\nexport function _debugLog(id, message) {\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) if (_theLogger) {\r\n //#:(!DEBUG) _theLogger(id, message);\r\n //#:(!DEBUG) }\r\n //#endif\r\n}\r\n/**\r\n * @internal\r\n * @ignore\r\n * Internal function to add the debug state to the promise so that it provides simular visibility as you would\r\n * see from native promises\r\n * @param thePromise - The Promise implementation\r\n * @param stateFn - The function to return the state of the promise\r\n * @param resultFn - The function to return the result (settled value) of the promise\r\n * @param handledFn - The function to return whether the promise has been handled (used for throwing\r\n * unhandled rejection events)\r\n */\r\nexport function _addDebugState(thePromise, stateFn, resultFn, handledFn) {\r\n // While the IPromise implementations provide a `state` property, keeping the `[[PromiseState]]`\r\n // as native promises also have a non-enumerable property of the same name\r\n _debugState = _debugState || { toString: function () { return \"[[PromiseState]]\"; } };\r\n _debugResult = _debugResult || { toString: function () { return \"[[PromiseResult]]\"; } };\r\n _debugHandled = _debugHandled || { toString: function () { return \"[[PromiseIsHandled]]\"; } };\r\n objDefineProp(thePromise, _debugState, { get: stateFn });\r\n objDefineProp(thePromise, _debugResult, { get: resultFn });\r\n objDefineProp(thePromise, _debugHandled, { get: handledFn });\r\n}\r\n/**\r\n * Debug helper to enable internal debugging of the promise implementations. Disabled by default.\r\n * For the generated packages included in the npm package the `logger` will not be called as the\r\n * `_debugLog` function that uses this logger is removed during packaging.\r\n *\r\n * It is available directly from the repository for unit testing.\r\n *\r\n * @group Debug\r\n * @param enabled - Should debugging be enabled (defaults `false`, when `true` promises will have\r\n * additional debug properties and the `toString` will include extra details.\r\n * @param logger - Optional logger that will log internal state changes, only called in debug\r\n * builds as the calling function is removed is the production artifacts.\r\n * @example\r\n * ```ts\r\n * // The Id is the id of the promise\r\n * // The message is the internal debug message\r\n * function promiseDebugLogger(id: string, message: string) {\r\n * if (console && console.log) {\r\n * console.log(id, message);\r\n * }\r\n * }\r\n *\r\n * setPromiseDebugState(true, promiseDebugLogger);\r\n *\r\n * // While the logger will not be called for the production packages\r\n * // Setting the `enabled` flag to tru will cause each promise to have\r\n * // the following additional properties added\r\n * // [[PromiseState]]; => Same as the `state` property\r\n * // [[PromiseResult]]; => The settled value\r\n * // [[PromiseIsHandled]] => Identifies if the promise has been handled\r\n * // It will also cause the `toString` for the promise to include additional\r\n * // debugging information\r\n * ```\r\n */\r\nexport function setPromiseDebugState(enabled, logger) {\r\n _promiseDebugEnabled = enabled;\r\n _theLogger = logger;\r\n}\r\n//# sourceMappingURL=debug.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\n/**\r\n * @ignore -- Don't include in the generated documentation\r\n * @internal\r\n */\r\nexport var STRING_STATES = [\r\n \"pending\", \"resolving\", \"resolved\", \"rejected\"\r\n];\r\n//# sourceMappingURL=state.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { dumpObj, getDocument, safeGetLazy, getInst } from \"@nevware21/ts-utils\";\r\nvar DISPATCH_EVENT = \"dispatchEvent\";\r\nvar _hasInitEvent;\r\n/**\r\n * @internal\r\n * @ignore\r\n * @param target\r\n * @param evtName\r\n * @param populateEvent\r\n * @param useNewEvent\r\n */\r\nexport function emitEvent(target, evtName, populateEvent, useNewEvent) {\r\n var doc = getDocument();\r\n !_hasInitEvent && (_hasInitEvent = safeGetLazy(function () {\r\n var evt;\r\n if (doc && doc.createEvent) {\r\n evt = doc.createEvent(\"Event\");\r\n }\r\n return (!!evt && evt.initEvent);\r\n }, null));\r\n var theEvt = _hasInitEvent.v ? doc.createEvent(\"Event\") : (useNewEvent ? new Event(evtName) : {});\r\n populateEvent && populateEvent(theEvt);\r\n if (_hasInitEvent.v) {\r\n theEvt.initEvent(evtName, false, true);\r\n }\r\n if (theEvt && target[DISPATCH_EVENT]) {\r\n target[DISPATCH_EVENT](theEvt);\r\n }\r\n else {\r\n var handler = target[\"on\" + evtName];\r\n if (handler) {\r\n handler(theEvt);\r\n }\r\n else {\r\n var theConsole = getInst(\"console\");\r\n theConsole && (theConsole[\"error\"] || theConsole[\"log\"])(evtName, dumpObj(theEvt));\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=event.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2023 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nexport var STR_PROMISE = \"Promise\";\r\n//# sourceMappingURL=constants.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { arrForEach, arrSlice, dumpObj, getKnownSymbol, hasSymbol, isFunction, isPromiseLike, isUndefined, throwTypeError, objToString, scheduleTimeout, getWindow, isNode, getGlobal, objDefine, objDefineProp, lazySafeGetInst } from \"@nevware21/ts-utils\";\r\nimport { doAwait } from \"./await\";\r\nimport { _addDebugState, _promiseDebugEnabled } from \"./debug\";\r\nimport { STRING_STATES } from \"../internal/state\";\r\nimport { emitEvent } from \"./event\";\r\nimport { STR_PROMISE } from \"../internal/constants\";\r\nvar NODE_UNHANDLED_REJECTION = \"unhandledRejection\";\r\nvar UNHANDLED_REJECTION = NODE_UNHANDLED_REJECTION.toLowerCase();\r\nvar _currentPromiseId = [];\r\nvar _uniquePromiseId = 0;\r\nvar _unhandledRejectionTimeout = 10;\r\nvar _hasPromiseRejectionEvent;\r\nfunction dumpFnObj(value) {\r\n if (isFunction(value)) {\r\n return value.toString();\r\n }\r\n return dumpObj(value);\r\n}\r\nexport function _createPromise(newPromise, processor, executor) {\r\n var additionalArgs = arrSlice(arguments, 3);\r\n var _state = 0 /* ePromiseState.Pending */;\r\n var _hasResolved = false;\r\n var _settledValue;\r\n var _queue = [];\r\n var _id = _uniquePromiseId++;\r\n var _parentId = _currentPromiseId.length > 0 ? _currentPromiseId[_currentPromiseId.length - 1] : undefined;\r\n var _handled = false;\r\n var _unHandledRejectionHandler = null;\r\n var _thePromise;\r\n !_hasPromiseRejectionEvent && (_hasPromiseRejectionEvent = lazySafeGetInst(STR_PROMISE + \"RejectionEvent\"));\r\n // https://tc39.es/ecma262/#sec-promise.prototype.then\r\n var _then = function (onResolved, onRejected) {\r\n try {\r\n _currentPromiseId.push(_id);\r\n _handled = true;\r\n _unHandledRejectionHandler && _unHandledRejectionHandler.cancel();\r\n _unHandledRejectionHandler = null;\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"then(\" + dumpFnObj(onResolved)+ \", \" + dumpFnObj(onResolved) + \")\");\r\n //#endif\r\n var thenPromise = newPromise(function (resolve, reject) {\r\n // Queue the new promise returned to be resolved or rejected\r\n // when this promise settles.\r\n _queue.push(function () {\r\n // https://tc39.es/ecma262/#sec-newpromisereactionjob\r\n //let value: any;\r\n try {\r\n // First call the onFulfilled or onRejected handler, on the settled value\r\n // of this promise. If the corresponding `handler` does not exist, simply\r\n // pass through the settled value.\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Handling settled value \" + dumpFnObj(_settledValue));\r\n //#endif\r\n var handler = _state === 2 /* ePromiseState.Resolved */ ? onResolved : onRejected;\r\n var value = isUndefined(handler) ? _settledValue : (isFunction(handler) ? handler(_settledValue) : handler);\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Handling Result \" + dumpFnObj(value));\r\n //#endif\r\n if (isPromiseLike(value)) {\r\n // The called handlers returned a new promise, so the chained promise\r\n // will follow the state of this promise.\r\n value.then(resolve, reject);\r\n }\r\n else if (handler) {\r\n // If we have a handler then chained promises are always \"resolved\" with the result returned\r\n resolve(value);\r\n }\r\n else if (_state === 3 /* ePromiseState.Rejected */) {\r\n // If this promise is rejected then the chained promise should be rejected\r\n // with either the settled value of this promise or the return value of the handler.\r\n reject(value);\r\n }\r\n else {\r\n // If this promise is fulfilled, then the chained promise is also fulfilled\r\n // with either the settled value of this promise or the return value of the handler.\r\n resolve(value);\r\n }\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n });\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Added to Queue \" + _queue.length);\r\n //#endif\r\n // If this promise is already settled, then immediately process the callback we\r\n // just added to the queue.\r\n if (_hasResolved) {\r\n _processQueue();\r\n }\r\n }, additionalArgs);\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Created -> \" + thenPromise.toString());\r\n //#endif\r\n return thenPromise;\r\n }\r\n finally {\r\n _currentPromiseId.pop();\r\n }\r\n };\r\n // https://tc39.es/ecma262/#sec-promise.prototype.catch\r\n var _catch = function (onRejected) {\r\n // Reuse then onRejected to support rejection\r\n return _then(undefined, onRejected);\r\n };\r\n // https://tc39.es/ecma262/#sec-promise.prototype.finally\r\n var _finally = function (onFinally) {\r\n var thenFinally = onFinally;\r\n var catchFinally = onFinally;\r\n if (isFunction(onFinally)) {\r\n thenFinally = function (value) {\r\n onFinally && onFinally();\r\n return value;\r\n };\r\n catchFinally = function (reason) {\r\n onFinally && onFinally();\r\n throw reason;\r\n };\r\n }\r\n return _then(thenFinally, catchFinally);\r\n };\r\n var _strState = function () {\r\n return STRING_STATES[_state];\r\n };\r\n var _processQueue = function () {\r\n if (_queue.length > 0) {\r\n // The onFulfilled and onRejected handlers must be called asynchronously. Thus,\r\n // we make a copy of the queue and work on it once the current call stack unwinds.\r\n var pending = _queue.slice();\r\n _queue = [];\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Processing queue \" + pending.length);\r\n //#endif\r\n _handled = true;\r\n processor(pending);\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Processing done\");\r\n //#endif\r\n _unHandledRejectionHandler && _unHandledRejectionHandler.cancel();\r\n _unHandledRejectionHandler = null;\r\n }\r\n else {\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Empty Processing queue \");\r\n //#endif\r\n }\r\n };\r\n var _createSettleIfFn = function (newState, allowState) {\r\n return function (theValue) {\r\n if (_state === allowState) {\r\n if (newState === 2 /* ePromiseState.Resolved */ && isPromiseLike(theValue)) {\r\n _state = 1 /* ePromiseState.Resolving */;\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Resolving\");\r\n //#endif\r\n theValue.then(_createSettleIfFn(2 /* ePromiseState.Resolved */, 1 /* ePromiseState.Resolving */), _createSettleIfFn(3 /* ePromiseState.Rejected */, 1 /* ePromiseState.Resolving */));\r\n return;\r\n }\r\n _state = newState;\r\n _hasResolved = true;\r\n _settledValue = theValue;\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), _strState());\r\n //#endif\r\n _processQueue();\r\n if (!_handled && newState === 3 /* ePromiseState.Rejected */ && !_unHandledRejectionHandler) {\r\n _unHandledRejectionHandler = scheduleTimeout(_notifyUnhandledRejection, _unhandledRejectionTimeout);\r\n }\r\n }\r\n else {\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Already \" + _strState());\r\n //#endif\r\n }\r\n };\r\n };\r\n var _notifyUnhandledRejection = function () {\r\n if (!_handled) {\r\n if (isNode()) {\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Emitting \" + NODE_UNHANDLED_REJECTION);\r\n //#endif\r\n process.emit(NODE_UNHANDLED_REJECTION, _settledValue, _thePromise);\r\n }\r\n else {\r\n var gbl = getWindow() || getGlobal();\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Emitting \" + UNHANDLED_REJECTION);\r\n //#endif\r\n emitEvent(gbl, UNHANDLED_REJECTION, function (theEvt) {\r\n objDefine(theEvt, \"promise\", { g: function () { return _thePromise; } });\r\n theEvt.reason = _settledValue;\r\n return theEvt;\r\n }, !!_hasPromiseRejectionEvent.v);\r\n }\r\n }\r\n };\r\n _thePromise = {\r\n then: _then,\r\n \"catch\": _catch,\r\n finally: _finally\r\n };\r\n objDefineProp(_thePromise, \"state\", {\r\n get: _strState\r\n });\r\n if (_promiseDebugEnabled) {\r\n // eslint-disable-next-line brace-style\r\n _addDebugState(_thePromise, _strState, function () { return objToString(_settledValue); }, function () { return _handled; });\r\n }\r\n if (hasSymbol()) {\r\n _thePromise[getKnownSymbol(11 /* WellKnownSymbols.toStringTag */)] = \"IPromise\";\r\n }\r\n var _toString = function () {\r\n return \"IPromise\" + (_promiseDebugEnabled ? \"[\" + _id + (!isUndefined(_parentId) ? (\":\" + _parentId) : \"\") + \"]\" : \"\") + \" \" + _strState() + (_hasResolved ? (\" - \" + dumpFnObj(_settledValue)) : \"\");\r\n };\r\n _thePromise.toString = _toString;\r\n (function _initialize() {\r\n if (!isFunction(executor)) {\r\n throwTypeError(STR_PROMISE + \": executor is not a function - \" + dumpFnObj(executor));\r\n }\r\n var _rejectFn = _createSettleIfFn(3 /* ePromiseState.Rejected */, 0 /* ePromiseState.Pending */);\r\n try {\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Executing\");\r\n //#endif\r\n executor.call(_thePromise, _createSettleIfFn(2 /* ePromiseState.Resolved */, 0 /* ePromiseState.Pending */), _rejectFn);\r\n }\r\n catch (e) {\r\n _rejectFn(e);\r\n }\r\n })();\r\n //#ifdef DEBUG\r\n //#:(!DEBUG) _debugLog(_toString(), \"Returning\");\r\n //#endif\r\n return _thePromise;\r\n}\r\n/**\r\n * @ignore\r\n * @internal\r\n * Returns a function which when called will return a new Promise object that resolves to an array of the\r\n * results from the input promises. The returned promise will resolve when all of the inputs' promises have\r\n * resolved, or if the input contains no promises. It rejects immediately upon any of the input promises\r\n * rejected or non-promises throwing an error, and will reject with this first rejection message / error.\r\n * @param newPromise - The delegate function used to create a new promise object the new promise instance.\r\n * @returns A function to create a promise that will be resolved when all arguments are resolved.\r\n */\r\nexport function _createAllPromise(newPromise) {\r\n return function (input) {\r\n var additionalArgs = arrSlice(arguments, 1);\r\n return newPromise(function (resolve, reject) {\r\n try {\r\n var values_1 = [];\r\n var pending_1 = 1; // Prefix to 1 so we finish iterating over all of the input promises first\r\n arrForEach(input, function (item, idx) {\r\n if (item) {\r\n pending_1++;\r\n doAwait(item, function (value) {\r\n // Set the result values\r\n values_1[idx] = value;\r\n if (--pending_1 === 0) {\r\n resolve(values_1);\r\n }\r\n }, reject);\r\n }\r\n });\r\n // Now decrement the pending so that we finish correctly\r\n pending_1--;\r\n if (pending_1 === 0) {\r\n // All promises were either resolved or where not a promise\r\n resolve(values_1);\r\n }\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n }, additionalArgs);\r\n };\r\n}\r\n/**\r\n * @ignore\r\n * @internal\r\n * The createResolvedPromise returns a PromiseLike object that is resolved with a given value. If the value is\r\n * PromiseLike (i.e. has a \"then\" method), the returned promise will \"follow\" that thenable, adopting its eventual\r\n * state; otherwise the returned promise will be fulfilled with the value. This function flattens nested layers\r\n * of promise-like objects (e.g. a promise that resolves to a promise that resolves to something) into a single layer.\r\n * @param newPromise - The delegate function used to create a new promise object\r\n * @param value Argument to be resolved by this Promise. Can also be a Promise or a thenable to resolve.\r\n * @param additionalArgs - Any additional arguments that should be passed to the delegate to assist with the creation of\r\n * the new promise instance.\r\n */\r\nexport function _createResolvedPromise(newPromise) {\r\n return function (value) {\r\n var additionalArgs = arrSlice(arguments, 1);\r\n if (isPromiseLike(value)) {\r\n return value;\r\n }\r\n return newPromise(function (resolve) {\r\n resolve(value);\r\n }, additionalArgs);\r\n };\r\n}\r\n/**\r\n * @ignore\r\n * @internal\r\n * Return a promise like object that is rejected with the given reason.\r\n * @param newPromise - The delegate function used to create a new promise object\r\n * @param reason - The rejection reason\r\n * @param additionalArgs - Any additional arguments that should be passed to the delegate to assist with the creation of\r\n * the new promise instance.\r\n */\r\nexport function _createRejectedPromise(newPromise) {\r\n return function (reason) {\r\n var additionalArgs = arrSlice(arguments, 1);\r\n return newPromise(function (_resolve, reject) {\r\n reject(reason);\r\n }, additionalArgs);\r\n };\r\n}\r\n//# sourceMappingURL=base.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { arrForEach, isNumber, scheduleIdleCallback, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nvar _processPendingItems = function (pending) {\r\n arrForEach(pending, function (fn) {\r\n try {\r\n fn();\r\n }\r\n catch (e) {\r\n // Don't let 1 failing handler break all others\r\n // TODO: Add some form of error reporting (i.e. Call any registered JS error handler so the error is reported)\r\n }\r\n });\r\n};\r\n/**\r\n * @internal\r\n * @ignore\r\n * Return an item processor that processes all of the pending items synchronously\r\n * @return An item processor\r\n */\r\nexport function syncItemProcessor() {\r\n return _processPendingItems;\r\n}\r\n/**\r\n * @internal\r\n * @ignore\r\n * Return an item processor that processes all of the pending items asynchronously using the optional timeout.\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n * @return An item processor\r\n */\r\nexport function timeoutItemProcessor(timeout) {\r\n var callbackTimeout = isNumber(timeout) ? timeout : 0;\r\n return function (pending) {\r\n scheduleTimeout(function () {\r\n _processPendingItems(pending);\r\n }, callbackTimeout);\r\n };\r\n}\r\n/**\r\n * @internal\r\n * @ignore\r\n * Return an item processor that processes all of the pending items using an idle callback (if available) or based on\r\n * a timeout (when `requestIdenCallback` is not supported) using the optional timeout.\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n * @return An item processor\r\n */\r\nexport function idleItemProcessor(timeout) {\r\n var options;\r\n if (timeout >= 0) {\r\n options = {\r\n timeout: +timeout\r\n };\r\n }\r\n return function (pending) {\r\n scheduleIdleCallback(function (deadline) {\r\n _processPendingItems(pending);\r\n }, options);\r\n };\r\n}\r\n//# sourceMappingURL=itemProcessor.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { _createAllPromise, _createPromise, _createRejectedPromise, _createResolvedPromise } from \"./base\";\r\nimport { timeoutItemProcessor } from \"./itemProcessor\";\r\n/**\r\n * Creates an asynchronous Promise instance that when resolved or rejected will execute it's pending chained operations\r\n * __asynchronously__ using the optional provided timeout value to schedule when the chained items will be ececuted.\r\n * @group Async\r\n * @group Promise\r\n * @param executor - The function to be executed during the creation of the promise. Any errors thrown in the executor will\r\n * cause the promise to be rejected. The return value of the executor is always ignored\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport function createAsyncPromise(executor, timeout) {\r\n return _createPromise(createAsyncPromise, timeoutItemProcessor(timeout), executor, timeout);\r\n}\r\n/**\r\n * Returns a single asynchronous Promise instance that resolves to an array of the results from the input promises.\r\n * This returned promise will resolve and execute it's pending chained operations __asynchronously__ using the optional\r\n * provided timeout value to schedule when the chained items will be executed, or if the input contains no promises.\r\n * It rejects immediately upon any of the input promises rejected or non-promises throwing an error,\r\n * and will reject with this first rejection message / error.\r\n * When resolved or rejected any additional chained operations will execute __asynchronously__ using the optional\r\n * timeout value to schedul when the chained item will be executed (eg. `then()`; `catch()`; `finally()`).\r\n * @group Async\r\n * @group All\r\n * @param input - The array of promises to wait to be resolved / rejected before resolving or rejecting the new promise\r\n * @param timeout\r\n * @returns\r\n * \r\n */\r\nexport var createAsyncAllPromise = _createAllPromise(createAsyncPromise);\r\n// /**\r\n// * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved\r\n// * or rejected.\r\n// * @param values An array of Promises.\r\n// * @returns A new Promise.\r\n// */\r\n// race(values: T): Promise>;\r\n//export const createAsyncRacePromise: (values: T): IPromise;\r\n/**\r\n * Returns a single asynchronous Promise instance that is already resolved with the given value. If the value passed is\r\n * a promise then that promise is returned instead of creating a new asynchronous promise instance.\r\n * If a new instance is returned then any chained operations will execute __asynchronously__ using the optional\r\n * timeout value to schedule when the chained items will be executed.(eg. `then()`; `finally()`).\r\n * @group Async\r\n * @group Resolved\r\n * @param value - The value to be used by this `Promise`. Can also be a `Promise` or a thenable to resolve.\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createAsyncResolvedPromise = _createResolvedPromise(createAsyncPromise);\r\n/**\r\n * Returns a single asynchronous Promise instance that is already rejected with the given reason.\r\n * Any chained operations will execute __asynchronously__ using the optional timeout value to schedule\r\n * when then chained items will be executed. (eg. `catch()`; `finally()`).\r\n * @group Async\r\n * @group Rejected\r\n * @param reason - The rejection reason\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createAsyncRejectedPromise = _createRejectedPromise(createAsyncPromise);\r\n//# sourceMappingURL=asyncPromise.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { createAsyncPromise } from \"./asyncPromise\";\r\nimport { _createAllPromise, _createRejectedPromise, _createResolvedPromise } from \"./base\";\r\nimport { STRING_STATES } from \"../internal/state\";\r\nimport { dumpObj, lazySafeGetInst, isFunction, objDefineProp, throwTypeError } from \"@nevware21/ts-utils\";\r\nimport { STR_PROMISE } from \"../internal/constants\";\r\nvar _isPromiseSupported;\r\n/**\r\n * Creates a Promise instance that when resolved or rejected will execute it's pending chained operations using the\r\n * available native Promise implementation.\r\n * If runtime does not support native `Promise` class (or no polyfill is available) this function will fallback to using\r\n * `createAsyncPromise` which will resolve them __asynchronously__ using the optional provided timeout value to\r\n * schedule when the chained items will be executed.\r\n * @group Alias\r\n * @group Promise\r\n * @group Native\r\n * @param executor - The function to be executed during the creation of the promise. Any errors thrown in the executor will\r\n * cause the promise to be rejected. The return value of the executor is always ignored\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport function createNativePromise(executor, timeout) {\r\n !_isPromiseSupported && (_isPromiseSupported = lazySafeGetInst(STR_PROMISE));\r\n var PrmCls = _isPromiseSupported.v;\r\n if (!PrmCls) {\r\n return createAsyncPromise(executor);\r\n }\r\n if (!isFunction(executor)) {\r\n throwTypeError(STR_PROMISE + \": executor is not a function - \" + dumpObj(executor));\r\n }\r\n var _state = 0 /* ePromiseState.Pending */;\r\n function _strState() {\r\n return STRING_STATES[_state];\r\n }\r\n var thePromise = new PrmCls(function (resolve, reject) {\r\n function _resolve(value) {\r\n _state = 2 /* ePromiseState.Resolved */;\r\n resolve(value);\r\n }\r\n function _reject(reason) {\r\n _state = 3 /* ePromiseState.Rejected */;\r\n reject(reason);\r\n }\r\n executor(_resolve, _reject);\r\n });\r\n objDefineProp(thePromise, \"state\", {\r\n get: _strState\r\n });\r\n return thePromise;\r\n}\r\n/**\r\n * Returns a single asynchronous Promise instance that resolves to an array of the results from the input promises.\r\n * This returned promise will resolve and execute it's pending chained operations __asynchronously__ using the optional\r\n * provided timeout value to schedule when the chained items will be executed, or if the input contains no promises.\r\n * It rejects immediately upon any of the input promises rejected or non-promises throwing an error,\r\n * and will reject with this first rejection message / error.\r\n * If the runtime doesn't support the Promise.all it will fallback back to an asynchronous Promise implementation.\r\n * @group Alias\r\n * @group All\r\n * @group Native\r\n * @param input - The array of promises to wait to be resolved / rejected before resolving or rejecting the new promise\r\n * @param timeout\r\n * @returns\r\n *
    \r\n *
  • An already resolved `Promise`, if the input passed is empty.\r\n *
  • A pending `Promise` in all other cases. This returned promise is then resolved/rejected __synchronously__\r\n * (as soon as the pending items is empty) when all the promises in the given input have resolved, or if any of the\r\n * promises reject.\r\n *
\r\n */\r\nexport var createNativeAllPromise = _createAllPromise(createNativePromise);\r\n/**\r\n * Returns a single asynchronous Promise instance that is already resolved with the given value. If the value passed is\r\n * a promise then that promise is returned instead of creating a new asynchronous promise instance.\r\n * If a new instance is returned then any chained operations will execute __asynchronously__ using the optional\r\n * timeout value to schedule when the chained items will be executed.(eg. `then()`; `finally()`).\r\n * @group Alias\r\n * @group Resolved\r\n * @group Native\r\n * @param value - The value to be used by this `Promise`. Can also be a `Promise` or a thenable to resolve.\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createNativeResolvedPromise = _createResolvedPromise(createNativePromise);\r\n/**\r\n * Returns a single asynchronous Promise instance that is already rejected with the given reason.\r\n * Any chained operations will execute __asynchronously__ using the optional timeout value to schedule\r\n * when then chained items will be executed. (eg. `catch()`; `finally()`).\r\n * @group Alias\r\n * @group Rejected\r\n * @group Native\r\n * @param reason - The rejection reason\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createNativeRejectedPromise = _createRejectedPromise(createNativePromise);\r\n//# sourceMappingURL=nativePromise.js.map","/*\r\n * @nevware21/ts-async\r\n * https://github.com/nevware21/ts-async\r\n *\r\n * Copyright (c) 2022 Nevware21\r\n * Licensed under the MIT license.\r\n */\r\nimport { getLazy } from \"@nevware21/ts-utils\";\r\nimport { _createAllPromise, _createRejectedPromise, _createResolvedPromise } from \"./base\";\r\nimport { createNativePromise } from \"./nativePromise\";\r\nvar _promiseCreator;\r\n/**\r\n * Set the default promise implementation to use when calling `createPromise`; `createAllPromise`; `createResolvedPromise`\r\n * and `createRejectedPromise`. This is effective a global value and changing this will affect ALL callers of these\r\n * functions, as such these functions should only be used when switching implementations would have not unexpected\r\n * consequences like switching from a `createSyncPromise` to `createIdlePromise` where idle promises have a possibility\r\n * of never getting called during application shutdown or during an expected timeframe.\r\n * @group Alias\r\n * @group Promise\r\n * @param creator - The creator function to call when a new promise is required.\r\n */\r\nexport function setCreatePromiseImpl(creator) {\r\n _promiseCreator = creator ? getLazy(function () { return creator; }) : null;\r\n}\r\n/**\r\n * Creates a Promise instance using the current default promise creator that when resolved or rejected will execute\r\n * it's pending chained operations.\r\n * @group Alias\r\n * @group Promise\r\n * @param executor - The function to be executed during the creation of the promise. Any errors thrown in the executor will\r\n * cause the promise to be rejected. The return value of the executor is always ignored\r\n * @param timeout - [Optional] timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport function createPromise(executor, timeout) {\r\n !_promiseCreator && (_promiseCreator = getLazy(function () { return createNativePromise; }));\r\n return _promiseCreator.v.call(this, executor, timeout);\r\n}\r\n/**\r\n * Returns a single asynchronous Promise instance that resolves to an array of the results from the input promises.\r\n * This returned promise will resolve and execute it's pending chained operations __asynchronously__ using the optional\r\n * provided timeout value to schedule when the chained items will be executed, or if the input contains no promises.\r\n * It rejects immediately upon any of the input promises rejected or non-promises throwing an error,\r\n * and will reject with this first rejection message / error.\r\n * If the runtime doesn't support the Promise.all it will fallback back to an asynchronous Promise implementation.\r\n * @group Alias\r\n * @group All\r\n * @param input - The array of promises to wait to be resolved / rejected before resolving or rejecting the new promise\r\n * @param timeout\r\n * @returns\r\n *
    \r\n *
  • An already resolved `Promise`, if the input passed is empty.\r\n *
  • A pending `Promise` in all other cases. This returned promise is then resolved/rejected __synchronously__\r\n * (as soon as the pending items is empty) when all the promises in the given input have resolved, or if any of the\r\n * promises reject.\r\n *
\r\n */\r\nexport var createAllPromise = _createAllPromise(createPromise);\r\n/**\r\n * Returns a single asynchronous Promise instance that is already resolved with the given value. If the value passed is\r\n * a promise then that promise is returned instead of creating a new asynchronous promise instance.\r\n * If a new instance is returned then any chained operations will execute __asynchronously__ using the optional\r\n * timeout value to schedule when the chained items will be executed.(eg. `then()`; `finally()`).\r\n * @group Alias\r\n * @group Resolved\r\n * @param value - The value to be used by this `Promise`. Can also be a `Promise` or a thenable to resolve.\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createResolvedPromise = _createResolvedPromise(createPromise);\r\n/**\r\n * Returns a single asynchronous Promise instance that is already rejected with the given reason.\r\n * Any chained operations will execute __asynchronously__ using the optional timeout value to schedule\r\n * when then chained items will be executed. (eg. `catch()`; `finally()`).\r\n * @group Alias\r\n * @group Rejected\r\n * @param reason - The rejection reason\r\n * @param timeout - Optional timeout to wait before processing the items, defaults to zero.\r\n */\r\nexport var createRejectedPromise = _createRejectedPromise(createPromise);\r\n//# sourceMappingURL=promise.js.map","// This file replaces `index.js` in bundlers like webpack or Rollup,\n// according to `browser` config in `package.json`.\n\nimport { urlAlphabet } from './url-alphabet/index.js'\n\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n // First, a bitmask is necessary to generate the ID. The bitmask makes bytes\n // values closer to the alphabet size. The bitmask calculates the closest\n // `2^31 - 1` number, which exceeds the alphabet size.\n // For example, the bitmask for the alphabet size 30 is 31 (00011111).\n // `Math.clz32` is not used, because it is not available in browsers.\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n // Though, the bitmask solution is not perfect since the bytes exceeding\n // the alphabet size are refused. Therefore, to reliably generate the ID,\n // the random bytes redundancy has to be satisfied.\n\n // Note: every hardware random generator call is performance expensive,\n // because the system call for entropy collection takes a lot of time.\n // So, to avoid additional system calls, extra bytes are requested in advance.\n\n // Next, a step determines how many random bytes to generate.\n // The number of random bytes gets decided upon the ID size, mask,\n // alphabet size, and magic number 1.6 (using 1.6 peaks at performance\n // according to benchmarks).\n\n // `-~f => Math.ceil(f)` if f is a float\n // `-~i => i + 1` if i is an integer\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n // A compact alternative for `for (var i = 0; i < step; i++)`.\n let j = step | 0\n while (j--) {\n // Adding `|| ''` refuses a random byte that exceeds the alphabet size.\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\n\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\n\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unneccessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63\n if (byte < 36) {\n // `0-9a-z`\n id += byte.toString(36)\n } else if (byte < 62) {\n // `A-Z`\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["doAwaitResponse","value","cb","doAwait","rejected","reason","resolveFn","rejectFn","finallyFn","result","then","finally","doFinally","_debugState","_debugResult","_debugHandled","_promiseDebugEnabled","_hasInitEvent","STRING_STATES","DISPATCH_EVENT","_hasPromiseRejectionEvent","STR_PROMISE","NODE_UNHANDLED_REJECTION","UNHANDLED_REJECTION","toLowerCase","_currentPromiseId","_uniquePromiseId","_unhandledRejectionTimeout","dumpFnObj","toString","_createPromise","newPromise","processor","executor","_settledValue","_thePromise","additionalArgs","arguments","_state","_hasResolved","_queue","_id","_parentId","length","undefined","_handled","_unHandledRejectionHandler","thePromise","stateFn","resultFn","handledFn","_then","onResolved","onRejected","push","cancel","resolve","reject","handler","e","_processQueue","pop","_strState","pending","slice","_createSettleIfFn","newState","allowState","theValue","_notifyUnhandledRejection","process","emit","target","evtName","populateEvent","useNewEvent","doc","evt","createEvent","initEvent","theEvt","v","Event","theConsole","emitEvent","g","onFinally","thenFinally","catchFinally","get","_rejectFn","call","_createAllPromise","input","values_1","pending_1","item","idx","_createResolvedPromise","_createRejectedPromise","_resolve","_processPendingItems","fn","createAsyncPromise","timeout","callbackTimeout","timeoutItemProcessor","_isPromiseSupported","createNativePromise","PrmCls","_promiseCreator","createPromise","this","createAllPromise","nanoid","size","crypto","getRandomValues","Uint8Array","reduce","id","byte","toUpperCase"],"sourceRoot":""}