{"version":3,"file":"normalizeAsyncQueue.cjs","names":["isAsyncStore"],"sources":["../../../../src/createReduxAsyncStore/temp/createAsyncStore/normalizeAsyncQueue.ts"],"sourcesContent":["import { isAsyncStore } from './isAsyncStore';\nimport type { Wait, AsyncStore } from './types';\n\n/**\n * Normalizes an array of asynchronous operations into an array of promises.\n * \n * @param {Wait | Wait[]} wait - A single or an array of asynchronous operations.\n *                                Each operation can be a promise, a function returning a promise,\n *                                or an object representing an asynchronous store.\n * @returns {Promise<any>[]} An array of promises.\n *\n * @throws {Error} Throws an error if an invalid type is encountered in the wait array.\n *\n * @example\n * // Single promise\n * const singlePromise = Promise.resolve('done');\n * normalizeAsyncQueue(singlePromise); // [singlePromise]\n * \n * @example\n * // Array of promises and functions\n * const promise1 = Promise.resolve('done');\n * const promise2 = () => Promise.resolve('done');\n * normalizeAsyncQueue([promise1, promise2]); // [promise1, promise2()]\n * \n * @example\n * // Async store\n * const asyncStore = createAsyncStore({ storeName: 'myStore' });;\n * normalizeAsyncQueue(asyncStore); // [asyncStore.isReady]\n */\nexport function normalizeAsyncQueue(wait: Wait | Wait[] ): Promise<any>[] {\n  return (Array.isArray(wait) ? wait : [ wait ] as Wait[]).map((wait: Wait) => {\n    if (isAsyncStore(wait)) {\n      if (!(wait as AsyncStore<any>).isStoreReady) {\n        (wait as AsyncStore<any>).init();\n      }\n\n      return (wait as unknown as AsyncStore<any>).isReady;\n    } else if (typeof wait === 'function') {\n      return wait();\n    }\n\n    return wait as Promise<any>;\n  }) as Promise<any>[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,MAAsC;CACxE,QAAQ,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAE,IAAK,EAAA,CAAa,KAAK,SAAe;EAC3E,IAAIA,iEAAAA,aAAa,IAAI,GAAG;GACtB,IAAI,CAAE,KAAyB,cAC7B,KAA0B,KAAK;GAGjC,OAAQ,KAAoC;EAC9C,OAAO,IAAI,OAAO,SAAS,YACzB,OAAO,KAAK;EAGd,OAAO;CACT,CAAC;AACH"}