express-sequelize-traffic 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -188,4 +188,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
188
188
|
`);return u===-1?"":i.stack.slice(u+1)})();try{if(!n.stack)n.stack=o;else if(o){const u=o.indexOf(`
|
|
189
189
|
`),l=u===-1?-1:o.indexOf(`
|
|
190
190
|
`,u+1),f=l===-1?"":o.slice(l+1);String(n.stack).endsWith(f)||(n.stack+=`
|
|
191
|
-
`+o)}}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Ki(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&fc.assertOptions(n,{silentJSONParsing:xr.transitional(xr.boolean),forcedJSONParsing:xr.transitional(xr.boolean),clarifyTimeoutError:xr.transitional(xr.boolean),legacyInterceptorReqResOrdering:xr.transitional(xr.boolean)},!1),i!=null&&(V.isFunction(i)?r.paramsSerializer={serialize:i}:fc.assertOptions(i,{encode:xr.function,serialize:xr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fc.assertOptions(r,{baseUrl:xr.spelling("baseURL"),withXsrfToken:xr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let u=o&&V.merge(o.common,o[r.method]);o&&V.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete o[_]}),r.headers=Ht.concat(u,o);const l=[];let f=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;f=f&&b.synchronous;const g=r.transitional||sx;g&&g.legacyInterceptorReqResOrdering?l.unshift(b.fulfilled,b.rejected):l.push(b.fulfilled,b.rejected)});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let h,y=0,v;if(!f){const _=[CC.bind(this),void 0];for(_.unshift(...l),_.push(...d),v=_.length,h=Promise.resolve(r);y<v;)h=h.then(_[y++],_[y++]);return h}v=l.length;let x=r;for(;y<v;){const _=l[y++],b=l[y++];try{x=_(x)}catch(g){b.call(this,g);break}}try{h=CC.call(this,x)}catch(_){return Promise.reject(_)}for(y=0,v=d.length;y<v;)h=h.then(d[y++],d[y++]);return h}getUri(e){e=Ki(this.defaults,e);const r=IN(e.baseURL,e.url,e.allowAbsoluteUrls);return jN(r,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){qi.prototype[e]=function(r,n){return this.request(Ki(n||{},{method:e,url:r,data:(n||{}).data}))}});V.forEach(["post","put","patch","query"],function(e){function r(n){return function(o,u,l){return this.request(Ki(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:u}))}}qi.prototype[e]=r(),e!=="query"&&(qi.prototype[e+"Form"]=r(!0))});let rX=class BN{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const u=new Promise(l=>{n.subscribe(l),o=l}).then(i);return u.cancel=function(){n.unsubscribe(o)},u},e(function(o,u,l){n.reason||(n.reason=new Ru(o,u,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new BN(function(i){e=i}),cancel:e}}};function nX(t){return function(r){return t.apply(null,r)}}function iX(t){return V.isObject(t)&&t.isAxiosError===!0}const H0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(H0).forEach(([t,e])=>{H0[e]=t});function qN(t){const e=new qi(t),r=xN(qi.prototype.request,e);return V.extend(r,qi.prototype,e,{allOwnKeys:!0}),V.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return qN(Ki(t,i))},r}const ft=qN(ju);ft.Axios=qi;ft.CanceledError=Ru;ft.CancelToken=rX;ft.isCancel=NN;ft.VERSION=lx;ft.toFormData=ld;ft.AxiosError=ge;ft.Cancel=ft.CanceledError;ft.all=function(e){return Promise.all(e)};ft.spread=nX;ft.isAxiosError=iX;ft.mergeConfig=Ki;ft.AxiosHeaders=Ht;ft.formToJSON=t=>RN(V.isHTMLForm(t)?new FormData(t):t);ft.getAdapter=LN.getAdapter;ft.HttpStatusCode=H0;ft.default=ft;const{Axios:mY,AxiosError:gY,CanceledError:bY,isCancel:xY,CancelToken:wY,VERSION:_Y,all:SY,Cancel:OY,isAxiosError:AY,spread:PY,toFormData:EY,AxiosHeaders:TY,HttpStatusCode:CY,formToJSON:kY,getAdapter:jY,mergeConfig:RY,create:NY}=ft,aX=new Set(["live-traffic","routes","users","errors"]);function fx(t=window.location.pathname){const e=t.split("/").filter(Boolean),r=e.at(-1);return aX.has(r)&&e.pop(),`/${e.join("/")}`.replace(/\/$/,"")||"/"}const Nu=ft.create({baseURL:`${fx()}/api`});async function oX(){const{data:t}=await Nu.get("/overview");return t}async function FN(){const{data:t}=await Nu.get("/live");return t}async function sX(){const{data:t}=await Nu.get("/routes");return t}async function uX(){const{data:t}=await Nu.get("/users");return t}async function lX(){const{data:t}=await Nu.get("/errors");return t}function cX(t){return`${Number(t||0).toFixed(1)} ms`}function fX(){const[t,e]=F.useState(null),[r,n]=F.useState([]),[i,o]=F.useState("");return F.useEffect(()=>{let u=!1;async function l(){try{const[f,d]=await Promise.all([oX(),FN()]);u||(e(f),n(d.slice(0,8)))}catch(f){u||o(f.message||"Failed to load dashboard data.")}}return l(),()=>{u=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Overview"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Application traffic at a glance"}),N.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-slate-500",children:"Response times, error volume, and route pressure are collected in your own Sequelize database and updated in realtime."})]}),i?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:i}):null,N.jsxs("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[N.jsx(Wl,{title:"Total Requests",value:(t==null?void 0:t.totalRequests)??"—",hint:"All tracked requests"}),N.jsx(Wl,{title:"Average Response",value:t?cX(t.averageDurationMs):"—",hint:"Across all tracked routes",tone:"success"}),N.jsx(Wl,{title:"Slow Requests",value:(t==null?void 0:t.slowRequestCount)??"—",hint:"Above your slow threshold",tone:"warning"}),N.jsx(Wl,{title:"Error Requests",value:(t==null?void 0:t.errorRequestCount)??"—",hint:"Status code 400 and above",tone:"danger"})]}),N.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,0.9fr)]",children:[N.jsx(pK,{data:(t==null?void 0:t.requestsTimeline)||[]}),N.jsx(yK,{data:(t==null?void 0:t.statusCodeSummary)||[]})]}),N.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]",children:[N.jsx(vK,{routes:(t==null?void 0:t.slowestRoutes)||[]}),N.jsx(bN,{requests:r})]})]})}const an=Object.create(null);an.open="0";an.close="1";an.ping="2";an.pong="3";an.message="4";an.upgrade="5";an.noop="6";const dc=Object.create(null);Object.keys(an).forEach(t=>{dc[an[t]]=t});const V0={type:"error",data:"parser error"},UN=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",zN=typeof ArrayBuffer=="function",WN=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,dx=({type:t,data:e},r,n)=>UN&&e instanceof Blob?r?n(e):jC(e,n):zN&&(e instanceof ArrayBuffer||WN(e))?r?n(e):jC(new Blob([e]),n):n(an[t]+(e||"")),jC=(t,e)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];e("b"+(n||""))},r.readAsDataURL(t)};function RC(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let pg;function dX(t,e){if(UN&&t.data instanceof Blob)return t.data.arrayBuffer().then(RC).then(e);if(zN&&(t.data instanceof ArrayBuffer||WN(t.data)))return e(RC(t.data));dx(t,!1,r=>{pg||(pg=new TextEncoder),e(pg.encode(r))})}const NC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<NC.length;t++)Cs[NC.charCodeAt(t)]=t;const hX=t=>{let e=t.length*.75,r=t.length,n,i=0,o,u,l,f;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const d=new ArrayBuffer(e),h=new Uint8Array(d);for(n=0;n<r;n+=4)o=Cs[t.charCodeAt(n)],u=Cs[t.charCodeAt(n+1)],l=Cs[t.charCodeAt(n+2)],f=Cs[t.charCodeAt(n+3)],h[i++]=o<<2|u>>4,h[i++]=(u&15)<<4|l>>2,h[i++]=(l&3)<<6|f&63;return d},pX=typeof ArrayBuffer=="function",hx=(t,e)=>{if(typeof t!="string")return{type:"message",data:HN(t,e)};const r=t.charAt(0);return r==="b"?{type:"message",data:yX(t.substring(1),e)}:dc[r]?t.length>1?{type:dc[r],data:t.substring(1)}:{type:dc[r]}:V0},yX=(t,e)=>{if(pX){const r=hX(t);return HN(r,e)}else return{base64:!0,data:t}},HN=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},VN="",vX=(t,e)=>{const r=t.length,n=new Array(r);let i=0;t.forEach((o,u)=>{dx(o,!1,l=>{n[u]=l,++i===r&&e(n.join(VN))})})},mX=(t,e)=>{const r=t.split(VN),n=[];for(let i=0;i<r.length;i++){const o=hx(r[i],e);if(n.push(o),o.type==="error")break}return n};function gX(){return new TransformStream({transform(t,e){dX(t,r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,n)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(n))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(r)})}})}let yg;function oc(t){return t.reduce((e,r)=>e+r.length,0)}function sc(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)r[i]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),r}function bX(t,e){yg||(yg=new TextDecoder);const r=[];let n=0,i=-1,o=!1;return new TransformStream({transform(u,l){for(r.push(u);;){if(n===0){if(oc(r)<1)break;const f=sc(r,1);o=(f[0]&128)===128,i=f[0]&127,i<126?n=3:i===126?n=1:n=2}else if(n===1){if(oc(r)<2)break;const f=sc(r,2);i=new DataView(f.buffer,f.byteOffset,f.length).getUint16(0),n=3}else if(n===2){if(oc(r)<8)break;const f=sc(r,8),d=new DataView(f.buffer,f.byteOffset,f.length),h=d.getUint32(0);if(h>Math.pow(2,21)-1){l.enqueue(V0);break}i=h*Math.pow(2,32)+d.getUint32(4),n=3}else{if(oc(r)<i)break;const f=sc(r,i);l.enqueue(hx(o?f:yg.decode(f),e)),n=0}if(i===0||i>t){l.enqueue(V0);break}}}})}const KN=4;function pt(t){if(t)return xX(t)}function xX(t){for(var e in pt.prototype)t[e]=pt.prototype[e];return t}pt.prototype.on=pt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};pt.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this};pt.prototype.off=pt.prototype.removeListener=pt.prototype.removeAllListeners=pt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return r.length===0&&delete this._callbacks["$"+t],this};pt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,e)}return this};pt.prototype.emitReserved=pt.prototype.emit;pt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};pt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const fd=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,r)=>r(e,0),_r=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),wX="arraybuffer";function GN(t,...e){return e.reduce((r,n)=>(t.hasOwnProperty(n)&&(r[n]=t[n]),r),{})}const _X=_r.setTimeout,SX=_r.clearTimeout;function dd(t,e){e.useNativeTimers?(t.setTimeoutFn=_X.bind(_r),t.clearTimeoutFn=SX.bind(_r)):(t.setTimeoutFn=_r.setTimeout.bind(_r),t.clearTimeoutFn=_r.clearTimeout.bind(_r))}const OX=1.33;function AX(t){return typeof t=="string"?PX(t):Math.ceil((t.byteLength||t.size)*OX)}function PX(t){let e=0,r=0;for(let n=0,i=t.length;n<i;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}function XN(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function EX(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}function TX(t){let e={},r=t.split("&");for(let n=0,i=r.length;n<i;n++){let o=r[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class CX extends Error{constructor(e,r,n){super(e),this.description=r,this.context=n,this.type="TransportError"}}class px extends pt{constructor(e){super(),this.writable=!1,dd(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,r,n){return super.emitReserved("error",new CX(e,r,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const r=hx(e,this.socket.binaryType);this.onPacket(r)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,r={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const r=EX(e);return r.length?"?"+r:""}}class kX extends px{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const r=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};mX(e,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vX(e,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=XN()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(e,r)}}let YN=!1;try{YN=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const jX=YN;function RX(){}class NX extends kX{constructor(e){if(super(e),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,r){const n=this.request({method:"POST",data:e});n.on("success",r),n.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=e}}class tn extends pt{constructor(e,r,n){super(),this.createRequest=e,dd(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;const r=GN(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=tn.requestsCount++,tn.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=RX,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete tn.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}tn.requestsCount=0;tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",MC);else if(typeof addEventListener=="function"){const t="onpagehide"in _r?"pagehide":"unload";addEventListener(t,MC,!1)}}function MC(){for(let t in tn.requests)tn.requests.hasOwnProperty(t)&&tn.requests[t].abort()}const MX=(function(){const t=QN({xdomain:!1});return t&&t.responseType!==null})();class IX extends NX{constructor(e){super(e);const r=e&&e.forceBase64;this.supportsBinary=MX&&!r}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new tn(QN,this.uri(),e)}}function QN(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||jX))return new XMLHttpRequest}catch{}if(!e)try{return new _r[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const JN=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class $X extends px{get name(){return"websocket"}doOpen(){const e=this.uri(),r=this.opts.protocols,n=JN?{}:GN(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,r,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],i=r===e.length-1;dx(n,this.supportsBinary,o=>{try{this.doWrite(n,o)}catch{}i&&fd(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=XN()),this.supportsBinary||(r.b64=1),this.createUri(e,r)}}const vg=_r.WebSocket||_r.MozWebSocket;class DX extends $X{createSocket(e,r,n){return JN?new vg(e,r,n):r?new vg(e,r):new vg(e)}doWrite(e,r){this.ws.send(r)}}class LX extends px{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const r=bX(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(r).getReader(),i=gX();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const o=()=>{n.read().then(({done:l,value:f})=>{l||(this.onPacket(f),o())}).catch(l=>{})};o();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],i=r===e.length-1;this._writer.write(n).then(()=>{i&&fd(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const BX={websocket:DX,webtransport:LX,polling:IX},qX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,FX=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function K0(t){if(t.length>8e3)throw"URI too long";const e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let i=qX.exec(t||""),o={},u=14;for(;u--;)o[FX[u]]=i[u]||"";return r!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=UX(o,o.path),o.queryKey=zX(o,o.query),o}function UX(t,e){const r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function zX(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,o){i&&(r[i]=o)}),r}const G0=typeof addEventListener=="function"&&typeof removeEventListener=="function",hc=[];G0&&addEventListener("offline",()=>{hc.forEach(t=>t())},!1);class ii extends pt{constructor(e,r){if(super(),this.binaryType=wX,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(r=e,e=null),e){const n=K0(e);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=K0(r.host).host);dd(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const i=n.prototype.name;this.transports.push(i),this._transportsByName[i]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=TX(this.opts.query)),G0&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},hc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const r=Object.assign({},this.opts.query);r.EIO=KN,r.transport=e,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&ii.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(e);r.open(),this.setTransport(r)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",ii.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=e.data,this._onError(r);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(r+=AX(i)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,fd(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,r,n){return this._sendPacket("message",e,r,n),this}send(e,r,n){return this._sendPacket("message",e,r,n),this}_sendPacket(e,r,n,i){if(typeof r=="function"&&(i=r,r=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:e,data:r,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),e()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(ii.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),G0&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=hc.indexOf(this._offlineEventListener);n!==-1&&hc.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,r),this.writeBuffer=[],this._prevBufferLen=0}}}ii.protocol=KN;class WX extends ii{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let r=this.createTransport(e),n=!1;ii.priorWebsocketSuccess=!1;const i=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",y=>{if(!n)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;ii.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(h(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=r.name,this.emitReserved("upgradeError",v)}}))};function o(){n||(n=!0,h(),r.close(),r=null)}const u=y=>{const v=new Error("probe error: "+y);v.transport=r.name,o(),this.emitReserved("upgradeError",v)};function l(){u("transport closed")}function f(){u("socket closed")}function d(y){r&&y.name!==r.name&&o()}const h=()=>{r.removeListener("open",i),r.removeListener("error",u),r.removeListener("close",l),this.off("close",f),this.off("upgrading",d)};r.once("open",i),r.once("error",u),r.once("close",l),this.once("close",f),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const r=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&r.push(e[n]);return r}}let HX=class extends WX{constructor(e,r={}){const n=typeof e=="object"?e:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(i=>BX[i]).filter(i=>!!i)),super(e,n)}};function VX(t,e="",r){let n=t;r=r||typeof location<"u"&&location,t==null&&(t=r.protocol+"//"+r.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=r.protocol+t:t=r.host+t),/^(https?|wss?):\/\//.test(t)||(typeof r<"u"?t=r.protocol+"//"+t:t="https://"+t),n=K0(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+e,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}const KX=typeof ArrayBuffer=="function",GX=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,ZN=Object.prototype.toString,XX=typeof Blob=="function"||typeof Blob<"u"&&ZN.call(Blob)==="[object BlobConstructor]",YX=typeof File=="function"||typeof File<"u"&&ZN.call(File)==="[object FileConstructor]";function yx(t){return KX&&(t instanceof ArrayBuffer||GX(t))||XX&&t instanceof Blob||YX&&t instanceof File}function pc(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(pc(t[r]))return!0;return!1}if(yx(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return pc(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&pc(t[r]))return!0;return!1}function QX(t){const e=[],r=t.data,n=t;return n.data=X0(r,e),n.attachments=e.length,{packet:n,buffers:e}}function X0(t,e){if(!t)return t;if(yx(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=X0(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=X0(t[n],e));return r}return t}function JX(t,e){return t.data=Y0(t.data,e),delete t.attachments,t}function Y0(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=Y0(t[r],e);else if(typeof t=="object")for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=Y0(t[r],e));return t}const ZX=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ie;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Ie||(Ie={}));class eY{constructor(e){this.replacer=e}encode(e){return(e.type===Ie.EVENT||e.type===Ie.ACK)&&pc(e)?this.encodeAsBinary({type:e.type===Ie.EVENT?Ie.BINARY_EVENT:Ie.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===Ie.BINARY_EVENT||e.type===Ie.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),r}encodeAsBinary(e){const r=QX(e),n=this.encodeAsString(r.packet),i=r.buffers;return i.unshift(n),i}}class vx extends pt{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e);const n=r.type===Ie.BINARY_EVENT;n||r.type===Ie.BINARY_ACK?(r.type=n?Ie.EVENT:Ie.ACK,this.reconstructor=new tY(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(yx(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0;const n={type:Number(e.charAt(0))};if(Ie[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ie.BINARY_EVENT||n.type===Ie.BINARY_ACK){const o=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);const u=e.substring(o,r);if(u!=Number(u)||e.charAt(r)!=="-")throw new Error("Illegal attachments");const l=Number(u);if(!rY(l)||l<0)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=l}if(e.charAt(r+1)==="/"){const o=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(o,r)}else n.nsp="/";const i=e.charAt(r+1);if(i!==""&&Number(i)==i){const o=r+1;for(;++r;){const u=e.charAt(r);if(u==null||Number(u)!=u){--r;break}if(r===e.length)break}n.id=Number(e.substring(o,r+1))}if(e.charAt(++r)){const o=this.tryParse(e.substr(r));if(vx.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case Ie.CONNECT:return IC(r);case Ie.DISCONNECT:return r===void 0;case Ie.CONNECT_ERROR:return typeof r=="string"||IC(r);case Ie.EVENT:case Ie.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&ZX.indexOf(r[0])===-1);case Ie.ACK:case Ie.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class tY{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const r=JX(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const rY=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function IC(t){return Object.prototype.toString.call(t)==="[object Object]"}const nY=Object.freeze(Object.defineProperty({__proto__:null,Decoder:vx,Encoder:eY,get PacketType(){return Ie}},Symbol.toStringTag,{value:"Module"}));function Br(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const iY=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class e2 extends pt{constructor(e,r,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Br(e,"open",this.onopen.bind(this)),Br(e,"packet",this.onpacket.bind(this)),Br(e,"error",this.onerror.bind(this)),Br(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...r){var n,i,o;if(iY.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(r.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const u={type:Ie.EVENT,data:r};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const h=this.ids++,y=r.pop();this._registerAckCallback(h,y),u.id=h}const l=(i=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||i===void 0?void 0:i.writable,f=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!l||(f?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(e,r){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[e]=r;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===e&&this.sendBuffer.splice(l,1);r.call(this,new Error("operation has timed out"))},i),u=(...l)=>{this.io.clearTimeoutFn(o),r.apply(this,l)};u.withError=!0,this.acks[e]=u}emitWithAck(e,...r){return new Promise((n,i)=>{const o=(u,l)=>u?i(u):n(l);o.withError=!0,r.push(o),this.emit(e,...r)})}_addToQueue(e){let r;typeof e[e.length-1]=="function"&&(r=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>(this._queue[0],i!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(i)):(this._queue.shift(),r&&r(null,...o)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!e||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ie.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){const n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ie.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ie.EVENT:case Ie.BINARY_EVENT:this.onevent(e);break;case Ie.ACK:case Ie.BINARY_ACK:this.onack(e);break;case Ie.DISCONNECT:this.ondisconnect();break;case Ie.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const r=e.data||[];e.id!=null&&r.push(this.ack(e.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const r=this;let n=!1;return function(...i){n||(n=!0,r.packet({type:Ie.ACK,id:e,data:i}))}}onack(e){const r=this.acks[e.id];typeof r=="function"&&(delete this.acks[e.id],r.withError&&e.data.unshift(null),r.apply(this,e.data))}onconnect(e,r){this.id=e,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ie.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,e.data)}}}function Eo(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Eo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-r:t+r}return Math.min(t,this.max)|0};Eo.prototype.reset=function(){this.attempts=0};Eo.prototype.setMin=function(t){this.ms=t};Eo.prototype.setMax=function(t){this.max=t};Eo.prototype.setJitter=function(t){this.jitter=t};class Q0 extends pt{constructor(e,r){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(r=e,e=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,dd(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new Eo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=e;const i=r.parser||nY;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var r;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(r=this.backoff)===null||r===void 0||r.setMin(e),this)}randomizationFactor(e){var r;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(r=this.backoff)===null||r===void 0||r.setJitter(e),this)}reconnectionDelayMax(e){var r;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(r=this.backoff)===null||r===void 0||r.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new HX(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=Br(r,"open",function(){n.onopen(),e&&e()}),o=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),e?e(l):this.maybeReconnectOnOpen()},u=Br(r,"error",o);if(this._timeout!==!1){const l=this._timeout,f=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),r.close()},l);this.opts.autoUnref&&f.unref(),this.subs.push(()=>{this.clearTimeoutFn(f)})}return this.subs.push(i),this.subs.push(u),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Br(e,"ping",this.onping.bind(this)),Br(e,"data",this.ondata.bind(this)),Br(e,"error",this.onerror.bind(this)),Br(e,"close",this.onclose.bind(this)),Br(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(r){this.onclose("parse error",r)}}ondecoded(e){fd(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,r){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new e2(this,e,r),this.nsps[e]=n),n}_destroy(e){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(e){const r=this.encoder.encode(e);for(let n=0;n<r.length;n++)this.engine.write(r[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const As={};function yc(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const r=VX(t,e.path||"/socket.io"),n=r.source,i=r.id,o=r.path,u=As[i]&&o in As[i].nsps,l=e.forceNew||e["force new connection"]||e.multiplex===!1||u;let f;return l?f=new Q0(n,e):(As[i]||(As[i]=new Q0(n,e)),f=As[i]),r.query&&!e.query&&(e.query=r.queryKey),f.socket(r.path,e)}Object.assign(yc,{Manager:Q0,Socket:e2,io:yc,connect:yc});function aY(){return yc({path:`${fx()}/socket.io`,transports:["websocket","polling"]})}function oY(){const[t,e]=F.useState([]),[r,n]=F.useState("Connecting to realtime stream..."),[i,o]=F.useState("");return F.useEffect(()=>{let u=!0;const l=aY();async function f(){try{const d=await FN();u&&e(d)}catch(d){u&&o(d.message||"Failed to load live traffic.")}}return f(),l.on("connect",()=>{u&&n("Realtime updates are active.")}),l.on("connect_error",d=>{u&&(n("Realtime stream unavailable."),o(d.message||"Socket connection failed."))}),l.on("traffic:new-request",d=>{u&&e(h=>[d,...h].slice(0,100))}),()=>{u=!1,l.disconnect()}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Live Traffic"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Realtime request feed"})]}),N.jsx("div",{className:"rounded-full bg-white/80 px-4 py-2 text-sm text-slate-600 shadow-sm",children:r})]}),i?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:i}):null,N.jsx(bN,{requests:t,emptyMessage:"No live traffic received yet."})]})}function sY({data:t=[]}){return N.jsxs("div",{className:"surface-border surface-glow rounded-[28px] bg-white p-5",children:[N.jsxs("div",{className:"mb-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Route Duration"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Average duration by route."})]}),N.jsx("div",{className:"h-80",children:N.jsx(_b,{width:"100%",height:"100%",children:N.jsxs(fK,{data:t,children:[N.jsx(ix,{stroke:"#e2e8f0",strokeDasharray:"3 3"}),N.jsx(Oo,{dataKey:"route",tick:{fill:"#64748b",fontSize:12},interval:0,angle:-16,textAnchor:"end",height:80}),N.jsx(Ao,{tick:{fill:"#64748b",fontSize:12}}),N.jsx(wr,{formatter:e=>[`${e} ms`,"Avg Duration"]}),N.jsx(Zi,{dataKey:"averageDurationMs",fill:"#ef7d57",radius:[10,10,0,0]})]})})})]})}function uY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await sX();i||e(u)}catch(u){i||n(u.message||"Failed to load routes analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Routes"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Route performance"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsx(sY,{data:t.slice(0,8)}),N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Route Table"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Sorted by average duration."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"Route"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Method"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Requests"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Average"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Max"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Errors"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Slow"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.route}),N.jsx("td",{className:"px-5 py-3",children:i.method}),N.jsx("td",{className:"px-5 py-3",children:i.totalRequests}),N.jsxs("td",{className:"px-5 py-3 font-semibold text-amber-600",children:[i.averageDurationMs," ms"]}),N.jsxs("td",{className:"px-5 py-3",children:[i.maxDurationMs," ms"]}),N.jsx("td",{className:"px-5 py-3",children:i.errorCount}),N.jsx("td",{className:"px-5 py-3",children:i.slowCount})]},`${i.route}-${i.method}`))})]})})]})]})}function lY(t){return t?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"n/a"}function cY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await uX();i||e(u)}catch(u){i||n(u.message||"Failed to load users analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Users"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"User activity"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"User Table"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Request volume and recency by resolved user id."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"User Id"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Requests"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Last Seen"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Average Duration"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.userId}),N.jsx("td",{className:"px-5 py-3",children:i.totalRequests}),N.jsx("td",{className:"px-5 py-3",children:lY(i.lastSeenAt)}),N.jsxs("td",{className:"px-5 py-3",children:[i.averageDurationMs," ms"]})]},i.userId))})]})})]})]})}function fY(t){return t?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t)):"n/a"}function dY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await lX();i||e(u)}catch(u){i||n(u.message||"Failed to load error analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Errors"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Failed requests"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Recent Errors"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Requests with HTTP status codes of 400 and above."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"Route"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Method"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Status"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Duration"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Created"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.route}),N.jsx("td",{className:"px-5 py-3",children:i.method}),N.jsx("td",{className:"px-5 py-3",children:N.jsx("span",{className:"rounded-full bg-rose-100 px-2.5 py-1 text-xs font-semibold text-rose-700",children:i.statusCode})}),N.jsxs("td",{className:"px-5 py-3",children:[i.durationMs," ms"]}),N.jsx("td",{className:"px-5 py-3",children:fY(i.createdAt)})]},`${i.id}-${i.createdAt}`))})]})})]})]})}function hY(){return N.jsx(l$,{basename:fx(),children:N.jsx(t$,{children:N.jsxs(Ti,{element:N.jsx(N$,{}),children:[N.jsx(Ti,{path:"/",element:N.jsx(fX,{})}),N.jsx(Ti,{path:"/live-traffic",element:N.jsx(oY,{})}),N.jsx(Ti,{path:"/routes",element:N.jsx(uY,{})}),N.jsx(Ti,{path:"/users",element:N.jsx(cY,{})}),N.jsx(Ti,{path:"/errors",element:N.jsx(dY,{})})]})})})}sI.createRoot(document.getElementById("root")).render(N.jsx(I.StrictMode,{children:N.jsx(hY,{})}));
|
|
191
|
+
`+o)}}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Ki(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&fc.assertOptions(n,{silentJSONParsing:xr.transitional(xr.boolean),forcedJSONParsing:xr.transitional(xr.boolean),clarifyTimeoutError:xr.transitional(xr.boolean),legacyInterceptorReqResOrdering:xr.transitional(xr.boolean)},!1),i!=null&&(V.isFunction(i)?r.paramsSerializer={serialize:i}:fc.assertOptions(i,{encode:xr.function,serialize:xr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),fc.assertOptions(r,{baseUrl:xr.spelling("baseURL"),withXsrfToken:xr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let u=o&&V.merge(o.common,o[r.method]);o&&V.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete o[_]}),r.headers=Ht.concat(u,o);const l=[];let f=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;f=f&&b.synchronous;const g=r.transitional||sx;g&&g.legacyInterceptorReqResOrdering?l.unshift(b.fulfilled,b.rejected):l.push(b.fulfilled,b.rejected)});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let h,y=0,v;if(!f){const _=[CC.bind(this),void 0];for(_.unshift(...l),_.push(...d),v=_.length,h=Promise.resolve(r);y<v;)h=h.then(_[y++],_[y++]);return h}v=l.length;let x=r;for(;y<v;){const _=l[y++],b=l[y++];try{x=_(x)}catch(g){b.call(this,g);break}}try{h=CC.call(this,x)}catch(_){return Promise.reject(_)}for(y=0,v=d.length;y<v;)h=h.then(d[y++],d[y++]);return h}getUri(e){e=Ki(this.defaults,e);const r=IN(e.baseURL,e.url,e.allowAbsoluteUrls);return jN(r,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){qi.prototype[e]=function(r,n){return this.request(Ki(n||{},{method:e,url:r,data:(n||{}).data}))}});V.forEach(["post","put","patch","query"],function(e){function r(n){return function(o,u,l){return this.request(Ki(l||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:u}))}}qi.prototype[e]=r(),e!=="query"&&(qi.prototype[e+"Form"]=r(!0))});let rX=class BN{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const u=new Promise(l=>{n.subscribe(l),o=l}).then(i);return u.cancel=function(){n.unsubscribe(o)},u},e(function(o,u,l){n.reason||(n.reason=new Ru(o,u,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new BN(function(i){e=i}),cancel:e}}};function nX(t){return function(r){return t.apply(null,r)}}function iX(t){return V.isObject(t)&&t.isAxiosError===!0}const H0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(H0).forEach(([t,e])=>{H0[e]=t});function qN(t){const e=new qi(t),r=xN(qi.prototype.request,e);return V.extend(r,qi.prototype,e,{allOwnKeys:!0}),V.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return qN(Ki(t,i))},r}const ft=qN(ju);ft.Axios=qi;ft.CanceledError=Ru;ft.CancelToken=rX;ft.isCancel=NN;ft.VERSION=lx;ft.toFormData=ld;ft.AxiosError=ge;ft.Cancel=ft.CanceledError;ft.all=function(e){return Promise.all(e)};ft.spread=nX;ft.isAxiosError=iX;ft.mergeConfig=Ki;ft.AxiosHeaders=Ht;ft.formToJSON=t=>RN(V.isHTMLForm(t)?new FormData(t):t);ft.getAdapter=LN.getAdapter;ft.HttpStatusCode=H0;ft.default=ft;const{Axios:mY,AxiosError:gY,CanceledError:bY,isCancel:xY,CancelToken:wY,VERSION:_Y,all:SY,Cancel:OY,isAxiosError:AY,spread:PY,toFormData:EY,AxiosHeaders:TY,HttpStatusCode:CY,formToJSON:kY,getAdapter:jY,mergeConfig:RY,create:NY}=ft,aX=new Set(["live-traffic","routes","users","errors"]);function fx(t=window.location.pathname){const e=t.split("/").filter(Boolean),r=e.at(-1);return aX.has(r)&&e.pop(),`/${e.join("/")}`.replace(/\/$/,"")||"/"}const Nu=ft.create({baseURL:`${fx()}/api`});async function oX(){const{data:t}=await Nu.get("/overview");return t}async function FN(){const{data:t}=await Nu.get("/live");return t}async function sX(){const{data:t}=await Nu.get("/routes");return t}async function uX(){const{data:t}=await Nu.get("/users");return t}async function lX(){const{data:t}=await Nu.get("/errors");return t}function cX(t){return`${Number(t||0).toFixed(1)} ms`}function fX(){const[t,e]=F.useState(null),[r,n]=F.useState([]),[i,o]=F.useState("");return F.useEffect(()=>{let u=!1;async function l(){try{const[f,d]=await Promise.all([oX(),FN()]);u||(e(f),n(d.slice(0,8)))}catch(f){u||o(f.message||"Failed to load dashboard data.")}}return l(),()=>{u=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Overview"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Application traffic at a glance"}),N.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-slate-500",children:"Response times, error volume, and route pressure are collected in your own Sequelize database and updated in realtime."})]}),i?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:i}):null,N.jsxs("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[N.jsx(Wl,{title:"Total Requests",value:(t==null?void 0:t.totalRequests)??"—",hint:"All tracked requests"}),N.jsx(Wl,{title:"Average Response",value:t?cX(t.averageDurationMs):"—",hint:"Across all tracked routes",tone:"success"}),N.jsx(Wl,{title:"Slow Requests",value:(t==null?void 0:t.slowRequestCount)??"—",hint:"Above your slow threshold",tone:"warning"}),N.jsx(Wl,{title:"Error Requests",value:(t==null?void 0:t.errorRequestCount)??"—",hint:"Status code 400 and above",tone:"danger"})]}),N.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.5fr)_minmax(320px,0.9fr)]",children:[N.jsx(pK,{data:(t==null?void 0:t.requestsTimeline)||[]}),N.jsx(yK,{data:(t==null?void 0:t.statusCodeSummary)||[]})]}),N.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]",children:[N.jsx(vK,{routes:(t==null?void 0:t.slowestRoutes)||[]}),N.jsx(bN,{requests:r})]})]})}const an=Object.create(null);an.open="0";an.close="1";an.ping="2";an.pong="3";an.message="4";an.upgrade="5";an.noop="6";const dc=Object.create(null);Object.keys(an).forEach(t=>{dc[an[t]]=t});const V0={type:"error",data:"parser error"},UN=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",zN=typeof ArrayBuffer=="function",WN=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,dx=({type:t,data:e},r,n)=>UN&&e instanceof Blob?r?n(e):jC(e,n):zN&&(e instanceof ArrayBuffer||WN(e))?r?n(e):jC(new Blob([e]),n):n(an[t]+(e||"")),jC=(t,e)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];e("b"+(n||""))},r.readAsDataURL(t)};function RC(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let pg;function dX(t,e){if(UN&&t.data instanceof Blob)return t.data.arrayBuffer().then(RC).then(e);if(zN&&(t.data instanceof ArrayBuffer||WN(t.data)))return e(RC(t.data));dx(t,!1,r=>{pg||(pg=new TextEncoder),e(pg.encode(r))})}const NC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<NC.length;t++)Cs[NC.charCodeAt(t)]=t;const hX=t=>{let e=t.length*.75,r=t.length,n,i=0,o,u,l,f;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const d=new ArrayBuffer(e),h=new Uint8Array(d);for(n=0;n<r;n+=4)o=Cs[t.charCodeAt(n)],u=Cs[t.charCodeAt(n+1)],l=Cs[t.charCodeAt(n+2)],f=Cs[t.charCodeAt(n+3)],h[i++]=o<<2|u>>4,h[i++]=(u&15)<<4|l>>2,h[i++]=(l&3)<<6|f&63;return d},pX=typeof ArrayBuffer=="function",hx=(t,e)=>{if(typeof t!="string")return{type:"message",data:HN(t,e)};const r=t.charAt(0);return r==="b"?{type:"message",data:yX(t.substring(1),e)}:dc[r]?t.length>1?{type:dc[r],data:t.substring(1)}:{type:dc[r]}:V0},yX=(t,e)=>{if(pX){const r=hX(t);return HN(r,e)}else return{base64:!0,data:t}},HN=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},VN="",vX=(t,e)=>{const r=t.length,n=new Array(r);let i=0;t.forEach((o,u)=>{dx(o,!1,l=>{n[u]=l,++i===r&&e(n.join(VN))})})},mX=(t,e)=>{const r=t.split(VN),n=[];for(let i=0;i<r.length;i++){const o=hx(r[i],e);if(n.push(o),o.type==="error")break}return n};function gX(){return new TransformStream({transform(t,e){dX(t,r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,n)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(n))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(r)})}})}let yg;function oc(t){return t.reduce((e,r)=>e+r.length,0)}function sc(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)r[i]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),r}function bX(t,e){yg||(yg=new TextDecoder);const r=[];let n=0,i=-1,o=!1;return new TransformStream({transform(u,l){for(r.push(u);;){if(n===0){if(oc(r)<1)break;const f=sc(r,1);o=(f[0]&128)===128,i=f[0]&127,i<126?n=3:i===126?n=1:n=2}else if(n===1){if(oc(r)<2)break;const f=sc(r,2);i=new DataView(f.buffer,f.byteOffset,f.length).getUint16(0),n=3}else if(n===2){if(oc(r)<8)break;const f=sc(r,8),d=new DataView(f.buffer,f.byteOffset,f.length),h=d.getUint32(0);if(h>Math.pow(2,21)-1){l.enqueue(V0);break}i=h*Math.pow(2,32)+d.getUint32(4),n=3}else{if(oc(r)<i)break;const f=sc(r,i);l.enqueue(hx(o?f:yg.decode(f),e)),n=0}if(i===0||i>t){l.enqueue(V0);break}}}})}const KN=4;function pt(t){if(t)return xX(t)}function xX(t){for(var e in pt.prototype)t[e]=pt.prototype[e];return t}pt.prototype.on=pt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};pt.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this};pt.prototype.off=pt.prototype.removeListener=pt.prototype.removeAllListeners=pt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return r.length===0&&delete this._callbacks["$"+t],this};pt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,e)}return this};pt.prototype.emitReserved=pt.prototype.emit;pt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};pt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const fd=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,r)=>r(e,0),_r=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),wX="arraybuffer";function GN(t,...e){return e.reduce((r,n)=>(t.hasOwnProperty(n)&&(r[n]=t[n]),r),{})}const _X=_r.setTimeout,SX=_r.clearTimeout;function dd(t,e){e.useNativeTimers?(t.setTimeoutFn=_X.bind(_r),t.clearTimeoutFn=SX.bind(_r)):(t.setTimeoutFn=_r.setTimeout.bind(_r),t.clearTimeoutFn=_r.clearTimeout.bind(_r))}const OX=1.33;function AX(t){return typeof t=="string"?PX(t):Math.ceil((t.byteLength||t.size)*OX)}function PX(t){let e=0,r=0;for(let n=0,i=t.length;n<i;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}function XN(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function EX(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}function TX(t){let e={},r=t.split("&");for(let n=0,i=r.length;n<i;n++){let o=r[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class CX extends Error{constructor(e,r,n){super(e),this.description=r,this.context=n,this.type="TransportError"}}class px extends pt{constructor(e){super(),this.writable=!1,dd(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,r,n){return super.emitReserved("error",new CX(e,r,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const r=hx(e,this.socket.binaryType);this.onPacket(r)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,r={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const r=EX(e);return r.length?"?"+r:""}}class kX extends px{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const r=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};mX(e,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vX(e,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=XN()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(e,r)}}let YN=!1;try{YN=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const jX=YN;function RX(){}class NX extends kX{constructor(e){if(super(e),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,r){const n=this.request({method:"POST",data:e});n.on("success",r),n.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=e}}class tn extends pt{constructor(e,r,n){super(),this.createRequest=e,dd(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;const r=GN(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=tn.requestsCount++,tn.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=RX,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete tn.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}tn.requestsCount=0;tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",MC);else if(typeof addEventListener=="function"){const t="onpagehide"in _r?"pagehide":"unload";addEventListener(t,MC,!1)}}function MC(){for(let t in tn.requests)tn.requests.hasOwnProperty(t)&&tn.requests[t].abort()}const MX=(function(){const t=QN({xdomain:!1});return t&&t.responseType!==null})();class IX extends NX{constructor(e){super(e);const r=e&&e.forceBase64;this.supportsBinary=MX&&!r}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new tn(QN,this.uri(),e)}}function QN(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||jX))return new XMLHttpRequest}catch{}if(!e)try{return new _r[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const JN=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class $X extends px{get name(){return"websocket"}doOpen(){const e=this.uri(),r=this.opts.protocols,n=JN?{}:GN(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,r,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],i=r===e.length-1;dx(n,this.supportsBinary,o=>{try{this.doWrite(n,o)}catch{}i&&fd(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=XN()),this.supportsBinary||(r.b64=1),this.createUri(e,r)}}const vg=_r.WebSocket||_r.MozWebSocket;class DX extends $X{createSocket(e,r,n){return JN?new vg(e,r,n):r?new vg(e,r):new vg(e)}doWrite(e,r){this.ws.send(r)}}class LX extends px{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const r=bX(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(r).getReader(),i=gX();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const o=()=>{n.read().then(({done:l,value:f})=>{l||(this.onPacket(f),o())}).catch(l=>{})};o();const u={type:"open"};this.query.sid&&(u.data=`{"sid":"${this.query.sid}"}`),this._writer.write(u).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],i=r===e.length-1;this._writer.write(n).then(()=>{i&&fd(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const BX={websocket:DX,webtransport:LX,polling:IX},qX=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,FX=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function K0(t){if(t.length>8e3)throw"URI too long";const e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let i=qX.exec(t||""),o={},u=14;for(;u--;)o[FX[u]]=i[u]||"";return r!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=UX(o,o.path),o.queryKey=zX(o,o.query),o}function UX(t,e){const r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function zX(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,o){i&&(r[i]=o)}),r}const G0=typeof addEventListener=="function"&&typeof removeEventListener=="function",hc=[];G0&&addEventListener("offline",()=>{hc.forEach(t=>t())},!1);class ii extends pt{constructor(e,r){if(super(),this.binaryType=wX,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(r=e,e=null),e){const n=K0(e);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=K0(r.host).host);dd(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const i=n.prototype.name;this.transports.push(i),this._transportsByName[i]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=TX(this.opts.query)),G0&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},hc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const r=Object.assign({},this.opts.query);r.EIO=KN,r.transport=e,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&ii.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(e);r.open(),this.setTransport(r)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",ii.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=e.data,this._onError(r);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(r+=AX(i)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,fd(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,r,n){return this._sendPacket("message",e,r,n),this}send(e,r,n){return this._sendPacket("message",e,r,n),this}_sendPacket(e,r,n,i){if(typeof r=="function"&&(i=r,r=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:e,data:r,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),e()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(ii.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),G0&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=hc.indexOf(this._offlineEventListener);n!==-1&&hc.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,r),this.writeBuffer=[],this._prevBufferLen=0}}}ii.protocol=KN;class WX extends ii{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let r=this.createTransport(e),n=!1;ii.priorWebsocketSuccess=!1;const i=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",y=>{if(!n)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;ii.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(h(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=r.name,this.emitReserved("upgradeError",v)}}))};function o(){n||(n=!0,h(),r.close(),r=null)}const u=y=>{const v=new Error("probe error: "+y);v.transport=r.name,o(),this.emitReserved("upgradeError",v)};function l(){u("transport closed")}function f(){u("socket closed")}function d(y){r&&y.name!==r.name&&o()}const h=()=>{r.removeListener("open",i),r.removeListener("error",u),r.removeListener("close",l),this.off("close",f),this.off("upgrading",d)};r.once("open",i),r.once("error",u),r.once("close",l),this.once("close",f),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const r=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&r.push(e[n]);return r}}let HX=class extends WX{constructor(e,r={}){const n=typeof e=="object"?e:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(i=>BX[i]).filter(i=>!!i)),super(e,n)}};function VX(t,e="",r){let n=t;r=r||typeof location<"u"&&location,t==null&&(t=r.protocol+"//"+r.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=r.protocol+t:t=r.host+t),/^(https?|wss?):\/\//.test(t)||(typeof r<"u"?t=r.protocol+"//"+t:t="https://"+t),n=K0(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+e,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}const KX=typeof ArrayBuffer=="function",GX=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,ZN=Object.prototype.toString,XX=typeof Blob=="function"||typeof Blob<"u"&&ZN.call(Blob)==="[object BlobConstructor]",YX=typeof File=="function"||typeof File<"u"&&ZN.call(File)==="[object FileConstructor]";function yx(t){return KX&&(t instanceof ArrayBuffer||GX(t))||XX&&t instanceof Blob||YX&&t instanceof File}function pc(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(pc(t[r]))return!0;return!1}if(yx(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return pc(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&pc(t[r]))return!0;return!1}function QX(t){const e=[],r=t.data,n=t;return n.data=X0(r,e),n.attachments=e.length,{packet:n,buffers:e}}function X0(t,e){if(!t)return t;if(yx(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=X0(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=X0(t[n],e));return r}return t}function JX(t,e){return t.data=Y0(t.data,e),delete t.attachments,t}function Y0(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=Y0(t[r],e);else if(typeof t=="object")for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=Y0(t[r],e));return t}const ZX=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ie;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Ie||(Ie={}));class eY{constructor(e){this.replacer=e}encode(e){return(e.type===Ie.EVENT||e.type===Ie.ACK)&&pc(e)?this.encodeAsBinary({type:e.type===Ie.EVENT?Ie.BINARY_EVENT:Ie.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===Ie.BINARY_EVENT||e.type===Ie.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),r}encodeAsBinary(e){const r=QX(e),n=this.encodeAsString(r.packet),i=r.buffers;return i.unshift(n),i}}class vx extends pt{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e);const n=r.type===Ie.BINARY_EVENT;n||r.type===Ie.BINARY_ACK?(r.type=n?Ie.EVENT:Ie.ACK,this.reconstructor=new tY(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(yx(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0;const n={type:Number(e.charAt(0))};if(Ie[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ie.BINARY_EVENT||n.type===Ie.BINARY_ACK){const o=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);const u=e.substring(o,r);if(u!=Number(u)||e.charAt(r)!=="-")throw new Error("Illegal attachments");const l=Number(u);if(!rY(l)||l<0)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=l}if(e.charAt(r+1)==="/"){const o=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(o,r)}else n.nsp="/";const i=e.charAt(r+1);if(i!==""&&Number(i)==i){const o=r+1;for(;++r;){const u=e.charAt(r);if(u==null||Number(u)!=u){--r;break}if(r===e.length)break}n.id=Number(e.substring(o,r+1))}if(e.charAt(++r)){const o=this.tryParse(e.substr(r));if(vx.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case Ie.CONNECT:return IC(r);case Ie.DISCONNECT:return r===void 0;case Ie.CONNECT_ERROR:return typeof r=="string"||IC(r);case Ie.EVENT:case Ie.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&ZX.indexOf(r[0])===-1);case Ie.ACK:case Ie.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class tY{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const r=JX(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const rY=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function IC(t){return Object.prototype.toString.call(t)==="[object Object]"}const nY=Object.freeze(Object.defineProperty({__proto__:null,Decoder:vx,Encoder:eY,get PacketType(){return Ie}},Symbol.toStringTag,{value:"Module"}));function Br(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const iY=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class e2 extends pt{constructor(e,r,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Br(e,"open",this.onopen.bind(this)),Br(e,"packet",this.onpacket.bind(this)),Br(e,"error",this.onerror.bind(this)),Br(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...r){var n,i,o;if(iY.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(r.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const u={type:Ie.EVENT,data:r};if(u.options={},u.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const h=this.ids++,y=r.pop();this._registerAckCallback(h,y),u.id=h}const l=(i=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||i===void 0?void 0:i.writable,f=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!l||(f?(this.notifyOutgoingListeners(u),this.packet(u)):this.sendBuffer.push(u)),this.flags={},this}_registerAckCallback(e,r){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[e]=r;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===e&&this.sendBuffer.splice(l,1);r.call(this,new Error("operation has timed out"))},i),u=(...l)=>{this.io.clearTimeoutFn(o),r.apply(this,l)};u.withError=!0,this.acks[e]=u}emitWithAck(e,...r){return new Promise((n,i)=>{const o=(u,l)=>u?i(u):n(l);o.withError=!0,r.push(o),this.emit(e,...r)})}_addToQueue(e){let r;typeof e[e.length-1]=="function"&&(r=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>(this._queue[0],i!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(i)):(this._queue.shift(),r&&r(null,...o)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!e||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ie.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){const n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ie.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ie.EVENT:case Ie.BINARY_EVENT:this.onevent(e);break;case Ie.ACK:case Ie.BINARY_ACK:this.onack(e);break;case Ie.DISCONNECT:this.ondisconnect();break;case Ie.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const r=e.data||[];e.id!=null&&r.push(this.ack(e.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const r=this;let n=!1;return function(...i){n||(n=!0,r.packet({type:Ie.ACK,id:e,data:i}))}}onack(e){const r=this.acks[e.id];typeof r=="function"&&(delete this.acks[e.id],r.withError&&e.data.unshift(null),r.apply(this,e.data))}onconnect(e,r){this.id=e,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ie.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,e.data)}}}function Eo(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Eo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-r:t+r}return Math.min(t,this.max)|0};Eo.prototype.reset=function(){this.attempts=0};Eo.prototype.setMin=function(t){this.ms=t};Eo.prototype.setMax=function(t){this.max=t};Eo.prototype.setJitter=function(t){this.jitter=t};class Q0 extends pt{constructor(e,r){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(r=e,e=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,dd(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new Eo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=e;const i=r.parser||nY;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var r;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(r=this.backoff)===null||r===void 0||r.setMin(e),this)}randomizationFactor(e){var r;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(r=this.backoff)===null||r===void 0||r.setJitter(e),this)}reconnectionDelayMax(e){var r;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(r=this.backoff)===null||r===void 0||r.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new HX(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=Br(r,"open",function(){n.onopen(),e&&e()}),o=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),e?e(l):this.maybeReconnectOnOpen()},u=Br(r,"error",o);if(this._timeout!==!1){const l=this._timeout,f=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),r.close()},l);this.opts.autoUnref&&f.unref(),this.subs.push(()=>{this.clearTimeoutFn(f)})}return this.subs.push(i),this.subs.push(u),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Br(e,"ping",this.onping.bind(this)),Br(e,"data",this.ondata.bind(this)),Br(e,"error",this.onerror.bind(this)),Br(e,"close",this.onclose.bind(this)),Br(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(r){this.onclose("parse error",r)}}ondecoded(e){fd(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,r){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new e2(this,e,r),this.nsps[e]=n),n}_destroy(e){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(e){const r=this.encoder.encode(e);for(let n=0;n<r.length;n++)this.engine.write(r[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const As={};function yc(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const r=VX(t,e.path||"/socket.io"),n=r.source,i=r.id,o=r.path,u=As[i]&&o in As[i].nsps,l=e.forceNew||e["force new connection"]||e.multiplex===!1||u;let f;return l?f=new Q0(n,e):(As[i]||(As[i]=new Q0(n,e)),f=As[i]),r.query&&!e.query&&(e.query=r.queryKey),f.socket(r.path,e)}Object.assign(yc,{Manager:Q0,Socket:e2,io:yc,connect:yc});function aY(){return yc({path:`${fx()}/socket.io`})}function oY(){const[t,e]=F.useState([]),[r,n]=F.useState("Connecting to realtime stream..."),[i,o]=F.useState("");return F.useEffect(()=>{let u=!0;const l=aY();async function f(){try{const d=await FN();u&&e(d)}catch(d){u&&o(d.message||"Failed to load live traffic.")}}return f(),l.on("connect",()=>{u&&n("Realtime updates are active.")}),l.on("connect_error",d=>{u&&(n("Realtime stream unavailable."),o(d.message||"Socket connection failed."))}),l.on("traffic:new-request",d=>{u&&e(h=>[d,...h].slice(0,100))}),()=>{u=!1,l.disconnect()}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Live Traffic"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Realtime request feed"})]}),N.jsx("div",{className:"rounded-full bg-white/80 px-4 py-2 text-sm text-slate-600 shadow-sm",children:r})]}),i?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:i}):null,N.jsx(bN,{requests:t,emptyMessage:"No live traffic received yet."})]})}function sY({data:t=[]}){return N.jsxs("div",{className:"surface-border surface-glow rounded-[28px] bg-white p-5",children:[N.jsxs("div",{className:"mb-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Route Duration"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Average duration by route."})]}),N.jsx("div",{className:"h-80",children:N.jsx(_b,{width:"100%",height:"100%",children:N.jsxs(fK,{data:t,children:[N.jsx(ix,{stroke:"#e2e8f0",strokeDasharray:"3 3"}),N.jsx(Oo,{dataKey:"route",tick:{fill:"#64748b",fontSize:12},interval:0,angle:-16,textAnchor:"end",height:80}),N.jsx(Ao,{tick:{fill:"#64748b",fontSize:12}}),N.jsx(wr,{formatter:e=>[`${e} ms`,"Avg Duration"]}),N.jsx(Zi,{dataKey:"averageDurationMs",fill:"#ef7d57",radius:[10,10,0,0]})]})})})]})}function uY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await sX();i||e(u)}catch(u){i||n(u.message||"Failed to load routes analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Routes"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Route performance"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsx(sY,{data:t.slice(0,8)}),N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Route Table"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Sorted by average duration."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"Route"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Method"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Requests"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Average"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Max"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Errors"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Slow"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.route}),N.jsx("td",{className:"px-5 py-3",children:i.method}),N.jsx("td",{className:"px-5 py-3",children:i.totalRequests}),N.jsxs("td",{className:"px-5 py-3 font-semibold text-amber-600",children:[i.averageDurationMs," ms"]}),N.jsxs("td",{className:"px-5 py-3",children:[i.maxDurationMs," ms"]}),N.jsx("td",{className:"px-5 py-3",children:i.errorCount}),N.jsx("td",{className:"px-5 py-3",children:i.slowCount})]},`${i.route}-${i.method}`))})]})})]})]})}function lY(t){return t?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"n/a"}function cY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await uX();i||e(u)}catch(u){i||n(u.message||"Failed to load users analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Users"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"User activity"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"User Table"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Request volume and recency by resolved user id."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"User Id"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Requests"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Last Seen"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Average Duration"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.userId}),N.jsx("td",{className:"px-5 py-3",children:i.totalRequests}),N.jsx("td",{className:"px-5 py-3",children:lY(i.lastSeenAt)}),N.jsxs("td",{className:"px-5 py-3",children:[i.averageDurationMs," ms"]})]},i.userId))})]})})]})]})}function fY(t){return t?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t)):"n/a"}function dY(){const[t,e]=F.useState([]),[r,n]=F.useState("");return F.useEffect(()=>{let i=!1;async function o(){try{const u=await lX();i||e(u)}catch(u){i||n(u.message||"Failed to load error analytics.")}}return o(),()=>{i=!0}},[]),N.jsxs("div",{className:"space-y-6",children:[N.jsxs("div",{children:[N.jsx("p",{className:"text-sm font-medium uppercase tracking-[0.24em] text-slate-500",children:"Errors"}),N.jsx("h2",{className:"mt-2 text-3xl font-semibold tracking-tight text-slate-950",children:"Failed requests"})]}),r?N.jsx("div",{className:"surface-border rounded-[24px] bg-rose-50 px-5 py-4 text-sm text-rose-700",children:r}):null,N.jsxs("div",{className:"surface-border surface-glow overflow-hidden rounded-[28px] bg-white",children:[N.jsxs("div",{className:"border-b border-slate-200/70 px-5 py-4",children:[N.jsx("h3",{className:"text-lg font-semibold text-slate-950",children:"Recent Errors"}),N.jsx("p",{className:"text-sm text-slate-500",children:"Requests with HTTP status codes of 400 and above."})]}),N.jsx("div",{className:"overflow-x-auto",children:N.jsxs("table",{className:"min-w-full text-left text-sm",children:[N.jsx("thead",{className:"bg-slate-50 text-slate-500",children:N.jsxs("tr",{children:[N.jsx("th",{className:"px-5 py-3 font-medium",children:"Route"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Method"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Status"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Duration"}),N.jsx("th",{className:"px-5 py-3 font-medium",children:"Created"})]})}),N.jsx("tbody",{children:t.map(i=>N.jsxs("tr",{className:"border-t border-slate-200/70 text-slate-700",children:[N.jsx("td",{className:"px-5 py-3 font-medium text-slate-900",children:i.route}),N.jsx("td",{className:"px-5 py-3",children:i.method}),N.jsx("td",{className:"px-5 py-3",children:N.jsx("span",{className:"rounded-full bg-rose-100 px-2.5 py-1 text-xs font-semibold text-rose-700",children:i.statusCode})}),N.jsxs("td",{className:"px-5 py-3",children:[i.durationMs," ms"]}),N.jsx("td",{className:"px-5 py-3",children:fY(i.createdAt)})]},`${i.id}-${i.createdAt}`))})]})})]})]})}function hY(){return N.jsx(l$,{basename:fx(),children:N.jsx(t$,{children:N.jsxs(Ti,{element:N.jsx(N$,{}),children:[N.jsx(Ti,{path:"/",element:N.jsx(fX,{})}),N.jsx(Ti,{path:"/live-traffic",element:N.jsx(oY,{})}),N.jsx(Ti,{path:"/routes",element:N.jsx(uY,{})}),N.jsx(Ti,{path:"/users",element:N.jsx(cY,{})}),N.jsx(Ti,{path:"/errors",element:N.jsx(dY,{})})]})})})}sI.createRoot(document.getElementById("root")).render(N.jsx(I.StrictMode,{children:N.jsx(hY,{})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Express Sequelize Traffic</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-mksq8XpA.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-iT93XJlh.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED