import{_ as v,a as w,f as b,g as M,l as _}from"./index-DdpkWn6R.js";function j(s,p,h){var i;return v(this,void 0,void 0,function(){var o,l,c,d,a,g=this;return w(this,function(u){switch(u.label){case 0:return b()?[2,[]]:(o=M(),l=(i=p.enabledMiddleware)!==null&&i!==void 0?i:{},c=Object.entries(l).filter(function(r){r[0];var e=r[1];return e}).map(function(r){var e=r[0];return e}),d=c.map(function(r){return v(g,void 0,void 0,function(){var e,n,m,f;return w(this,function(t){switch(t.label){case 0:e=r.replace("@segment/",""),n=e,h&&(n=btoa(e).replace(/=/g,"")),m="".concat(o,"/middleware/").concat(n,"/latest/").concat(n,".js.gz"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,_(m)];case 2:return t.sent(),[2,window["".concat(e,"Middleware")]];case 3:return f=t.sent(),s.log("error",f),s.stats.increment("failed_remote_middleware"),[3,4];case 4:return[2]}})})}),[4,Promise.all(d)]);case 1:return a=u.sent(),a=a.filter(Boolean),[2,a]}})})}export{j as remoteMiddlewares};
