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Content":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/async-flow-control@1.2.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","(function (asyncFlowControlFactory) {\n    const isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined';\n\n    if (isNode) {\n        module.exports = asyncFlowControlFactory();\n    } else {\n        window.asyncFlowControl = asyncFlowControlFactory();\n    }\n\n})(function () {\n\n    function lastIndexOf(values) {\n        return values.length - 1;\n    }\n\n    function last(values) {\n        return values[lastIndexOf(values)];\n    }\n\n    function promiseHandler(promiseToHandle, callback) {\n        if (typeof promiseToHandle === 'object'\n            && typeof promiseToHandle.then === 'function') {\n            promiseToHandle\n                .then((...args) => callback.apply(null, [null].concat(args)))\n                .catch((error) => callback(error, null));\n        }\n    }\n\n    function processConditional(conditionalItem, continuation) {\n\n        function testAndCallCurrentBehavior(behaviors) {\n            const currentBehavior = behaviors[0];\n\n            function ifResolver(error, testResult) {\n                if (error) {\n                    continuation(error, null);\n                } else if (testResult) {\n                    const thenPromise = currentBehavior.then(continuation);\n                    promiseHandler(thenPromise, continuation);\n                } else if (behaviors.length > 1) {\n                    testAndCallCurrentBehavior(behaviors.slice(1));\n                } else {\n                    continuation();\n                }\n            }\n\n            try {\n                const ifPromise = currentBehavior.if(ifResolver);\n                promiseHandler(ifPromise, ifResolver);\n            } catch (error) {\n                continuation(error);\n            }\n        }\n\n        testAndCallCurrentBehavior(conditionalItem.behaviors);\n    }\n\n    function processLoop(loopItem, continuation) {\n        function testAndCallCurrentBehavior(behaviors) {\n            const currentBehavior = behaviors[0];\n\n            function loopResolver(error, testResult) {\n                if (error) {\n                    continuation(error, null);\n                } else if (testResult) {\n                    const repeatAction = () => testAndCallCurrentBehavior(behaviors);\n                    const thenPromise = currentBehavior.then(repeatAction);\n\n                    promiseHandler(thenPromise, repeatAction);\n                } else {\n                    continuation();\n                }\n            }\n\n            try {\n                const loopPromise = currentBehavior.if(loopResolver);\n                promiseHandler(loopPromise, loopResolver);\n            } catch (error) {\n                continuation(error);\n            }\n        }\n\n        testAndCallCurrentBehavior(loopItem.behaviors);\n    }\n\n    function asyncify(fn) {\n        return function (...args) {\n            const continuation = args.pop();\n\n            try {\n                const result = fn(...args);\n                continuation(null, result);\n            } catch (error) {\n                continuation(error);\n            }\n        }\n    }\n    function asyncCompose(original, newAsync) {\n        return function (...args) {\n            const callback = args.pop();\n\n            function callNext(error, ...nextArgs) {\n                if (error) {\n                    callback(error);\n                } else {\n                    const maybePromise = newAsync(...(nextArgs.concat(callback)));\n                    promiseHandler(maybePromise, callback);\n                }\n            }\n\n            const maybePromise = original(...(args.concat(callNext)));\n            promiseHandler(maybePromise, callNext);\n        }\n    }\n\n    function getAndRegisterNewExecPromise(instance) {\n        return new Promise(function (resolve, reject) {\n            instance.addResolver(function (error, data) {\n                if (error) {\n                    reject(error);\n                } else {\n                    resolve(data);\n                }\n            });\n        });\n    }\n\n    function defaultAction(callback) {\n        callback(null);\n    }\n\n    function AsyncFlowControl() {\n        this.callSequence = [];\n        this.resolvers = [];\n        this.resultSet = [];\n    }\n\n    AsyncFlowControl.prototype = {\n        attachBehavior: function ({\n            predicate = asyncify(() => true),\n            action = defaultAction\n        }) {\n            const currentCallItem = last(this.callSequence);\n\n            currentCallItem.behaviors.push({\n                if: predicate,\n                then: action\n            });\n\n            return this;\n\n        },\n        addSequence: function (type) {\n            this.callSequence.push({\n                type: type,\n                behaviors: []\n            });\n            return this;\n        },\n        chain: function (...initialValues) {\n            const initialAction = (callback) =>\n                callback(...([null].concat(initialValues)));\n\n            return this\n                .addSequence('chain')\n                .attachBehavior({\n                    action: initialAction\n                })\n        },\n        while: function (asyncPredicate) {\n            return this\n                .addSequence('loop')\n                .attachBehavior({\n                    predicate: asyncPredicate\n                });\n        },\n        whileSync: function (predicate) {\n            return this.while(asyncify(predicate));\n        },\n        if: function (asyncPredicate) {\n            return this\n                .addSequence('condition')\n                .attachBehavior({\n                    predicate: asyncPredicate\n                });\n        },\n\n        ifSync: function (predicate) {\n            return this.if(asyncify(predicate));\n        },\n\n        else: function (asyncFunction) {\n            return this.attachBehavior({\n                predicate: asyncify(() => true),\n                action: asyncFunction\n            });\n        },\n\n        elseSync: function (action) {\n            return this.else(asyncify(action));\n        },\n\n        elseIf: function (asyncPredicate) {\n            return this.attachBehavior({\n                predicate: asyncPredicate,\n                action: defaultAction\n            });\n        },\n\n        elseIfSync: function (predicate) {\n            return this.elseIf(asyncify(predicate));\n        },\n\n        then: function (asyncFunction) {\n            const currentCallItem = last(this.callSequence);\n            const currentBehaviorItem = last(currentCallItem.behaviors);\n\n            const originalThen = currentBehaviorItem.then;\n            currentBehaviorItem.then = asyncCompose(\n                originalThen,\n                asyncFunction\n            );\n\n            return this;\n        },\n\n        thenSync: function (action) {\n            return this.then(asyncify(action));\n        },\n\n        runAllCallItems: function (continuation) {\n            function processNextCallItem(callSequence) {\n                const currentCallItem = callSequence[0];\n\n                function postProcessContinuation(error, result) {\n                    if (typeof result !== 'undefined') {\n                        this.resultSet.push(result);\n                    }\n                    if (error) {\n                        continuation(error);\n                    } else if (callSequence.length > 1) {\n                        processNextCallItem.call(this, callSequence.slice(1));\n                    } else {\n                        continuation();\n                    }\n                }\n\n                if(currentCallItem.type !== 'loop'){\n                    processConditional(currentCallItem, postProcessContinuation.bind(this));\n                } else {\n                    processLoop(currentCallItem, postProcessContinuation.bind(this));\n                }\n            }\n\n            processNextCallItem.call(this, this.callSequence);\n\n        },\n\n        exec: function (resolver) {\n            let returnablePromise;\n\n            if (typeof resolver === 'function') {\n                this.addResolver(resolver);\n            } else {\n                returnablePromise = getAndRegisterNewExecPromise(this);\n            }\n\n            this.runAllCallItems(\n                (error) =>\n                    this.resolvers.forEach(\n                        (resolver) =>\n                            resolver(error, this.resultSet)\n                    )\n            );\n\n            return returnablePromise;\n        },\n\n        addResolver: function (action) {\n            this.resolvers.push(action);\n        }\n    }\n\n    function ifAsync(asyncPredicate) {\n        const flowControlInstance = new AsyncFlowControl();\n\n        return flowControlInstance.if(asyncPredicate);\n    }\n\n    function chain(...args) {\n        const flowControlInstance = new AsyncFlowControl();\n\n        return flowControlInstance.chain(...args);\n    }\n\n    function ifSync(predicate) {\n        return ifAsync(asyncify(predicate));\n    }\n\n    function doWhile(predicate) {\n        const flowControlInstance = new AsyncFlowControl();\n\n        return flowControlInstance.while(predicate);\n    }\n\n    function doWhileSync(predicate) {\n        const flowControlInstance = new AsyncFlowControl();\n\n        return flowControlInstance.whileSync(predicate);\n    }\n\n    function newInstance() {\n        return new AsyncFlowControl();\n    }\n\n    return {\n        asyncify: asyncify,\n        chain: chain,\n        if: ifAsync,\n        ifSync: ifSync,\n        new: newInstance,\n        while: doWhile,\n        whileSync: doWhileSync\n    };\n});"]}