const S=require("./chunk-BAUY9lu4.cjs");var T=S.__exportAll({default:()=>g,pMapSkip:()=>f});async function g(n,m,{concurrency:o=Number.POSITIVE_INFINITY,stopOnError:b=!0,signal:i}={}){return new Promise((E,M)=>{if(n[Symbol.iterator]===void 0&&n[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof n})`);if(typeof m!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(o)&&o>=1||o===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${o}\` (${typeof o})`);const c=[],l=[],d=new Map;let I=!1,s=!1,v=!1,p=0,w=0;const k=n[Symbol.iterator]===void 0?n[Symbol.asyncIterator]():n[Symbol.iterator](),_=()=>{a(i.reason)},x=()=>{i?.removeEventListener("abort",_)},h=e=>{E(e),x()},a=e=>{I=!0,s=!0,M(e),x()};i&&(i.aborted&&a(i.reason),i.addEventListener("abort",_,{once:!0}));const y=async()=>{if(s)return;const e=await k.next(),u=w;if(w++,e.done){if(v=!0,p===0&&!s){if(!b&&l.length>0){a(new AggregateError(l));return}if(s=!0,d.size===0){h(c);return}const t=[];for(const[r,N]of c.entries())d.get(r)!==f&&t.push(N);h(t)}return}p++,(async()=>{try{const t=await e.value;if(s)return;const r=await m(t,u);r===f&&d.set(u,r),c[u]=r,p--,await y()}catch(t){if(b)a(t);else{l.push(t),p--;try{await y()}catch(r){a(r)}}}})()};(async()=>{for(let e=0;e<o;e++){try{await y()}catch(u){a(u);break}if(v||I)break}})()})}var f,P=S.__esmMin((()=>{f=Symbol("skip")}));Object.defineProperty(exports,"init_p_map",{enumerable:!0,get:function(){return P}});Object.defineProperty(exports,"pMap",{enumerable:!0,get:function(){return g}});Object.defineProperty(exports,"p_map_exports",{enumerable:!0,get:function(){return T}});

//# sourceMappingURL=p-map-Le4OxzRU.cjs.map