chatroom-cli 1.145.1 → 1.146.0

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.
@@ -101,7 +101,7 @@ Error generating stack: `+a.message+`
101
101
  *
102
102
  * This source code is licensed under the ISC license.
103
103
  * See the LICENSE file in the root directory of this source tree.
104
- */const Nw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],S0=hr("x",Nw);function Dw({status:n}){return C.jsxs("header",{className:"flex items-center justify-between border-b border-chatroom-border px-6 py-4",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(y0,{className:"size-5 text-chatroom-text-muted","aria-hidden":!0}),C.jsx("h1",{className:"text-sm font-semibold uppercase tracking-widest",children:"Chatroom Daemon"})]}),n]})}function zw({children:n}){return C.jsx("nav",{className:"flex gap-1 border-b border-chatroom-border px-6 py-2",children:n})}function Ob({active:n=!1,children:i,onClick:r}){return C.jsx("span",{className:n?"bg-chatroom-bg-secondary px-3 py-1.5 text-xs font-medium uppercase tracking-wide":"px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-chatroom-text-muted",onClick:r,role:r?"button":void 0,children:i})}function Cb(n){return new URLSearchParams(n.startsWith("?")?n.slice(1):n).get("tab")==="event-stream"?"event-stream":"logs"}function kw(n){const i=new URLSearchParams(window.location.search);n.tab!==void 0&&(n.tab==="event-stream"?i.set("tab","event-stream"):i.delete("tab")),n.chatroomId!==void 0&&(n.chatroomId?i.set("chatroomId",n.chatroomId):i.delete("chatroomId"));const r=i.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}`)}function jw(){const[n,i]=w.useState(()=>Cb(window.location.search)),r=w.useCallback(o=>{i(o),kw({tab:o})},[]);return w.useEffect(()=>{const o=()=>i(Cb(window.location.search));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{activeTab:n,setActiveTab:r}}const mi=Object.create(null);mi.open="0";mi.close="1";mi.ping="2";mi.pong="3";mi.message="4";mi.upgrade="5";mi.noop="6";const Mc=Object.create(null);Object.keys(mi).forEach(n=>{Mc[mi[n]]=n});const ah={type:"error",data:"parser error"},x0=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",E0=typeof ArrayBuffer=="function",T0=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,zh=({type:n,data:i},r,o)=>x0&&i instanceof Blob?r?o(i):Ab(i,o):E0&&(i instanceof ArrayBuffer||T0(i))?r?o(i):Ab(new Blob([i]),o):o(mi[n]+(i||"")),Ab=(n,i)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];i("b"+(o||""))},r.readAsDataURL(n)};function _b(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Ad;function Lw(n,i){if(x0&&n.data instanceof Blob)return n.data.arrayBuffer().then(_b).then(i);if(E0&&(n.data instanceof ArrayBuffer||T0(n.data)))return i(_b(n.data));zh(n,!1,r=>{Ad||(Ad=new TextEncoder),i(Ad.encode(r))})}const Mb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",No=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Mb.length;n++)No[Mb.charCodeAt(n)]=n;const Uw=n=>{let i=n.length*.75,r=n.length,o,c=0,f,d,m,g;n[n.length-1]==="="&&(i--,n[n.length-2]==="="&&i--);const p=new ArrayBuffer(i),y=new Uint8Array(p);for(o=0;o<r;o+=4)f=No[n.charCodeAt(o)],d=No[n.charCodeAt(o+1)],m=No[n.charCodeAt(o+2)],g=No[n.charCodeAt(o+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|g&63;return p},Bw=typeof ArrayBuffer=="function",kh=(n,i)=>{if(typeof n!="string")return{type:"message",data:w0(n,i)};const r=n.charAt(0);return r==="b"?{type:"message",data:Hw(n.substring(1),i)}:Mc[r]?n.length>1?{type:Mc[r],data:n.substring(1)}:{type:Mc[r]}:ah},Hw=(n,i)=>{if(Bw){const r=Uw(n);return w0(r,i)}else return{base64:!0,data:n}},w0=(n,i)=>{switch(i){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},R0="",qw=(n,i)=>{const r=n.length,o=new Array(r);let c=0;n.forEach((f,d)=>{zh(f,!1,m=>{o[d]=m,++c===r&&i(o.join(R0))})})},Yw=(n,i)=>{const r=n.split(R0),o=[];for(let c=0;c<r.length;c++){const f=kh(r[c],i);if(o.push(f),f.type==="error")break}return o};function Vw(){return new TransformStream({transform(n,i){Lw(n,r=>{const o=r.length;let c;if(o<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,o);else if(o<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(c[0]|=128),i.enqueue(c),i.enqueue(r)})}})}let _d;function vc(n){return n.reduce((i,r)=>i+r.length,0)}function Sc(n,i){if(n[0].length===i)return n.shift();const r=new Uint8Array(i);let o=0;for(let c=0;c<i;c++)r[c]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function Gw(n,i){_d||(_d=new TextDecoder);const r=[];let o=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(o===0){if(vc(r)<1)break;const g=Sc(r,1);f=(g[0]&128)===128,c=g[0]&127,c<126?o=3:c===126?o=1:o=2}else if(o===1){if(vc(r)<2)break;const g=Sc(r,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(vc(r)<8)break;const g=Sc(r,8),p=new DataView(g.buffer,g.byteOffset,g.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(ah);break}c=y*Math.pow(2,32)+p.getUint32(4),o=3}else{if(vc(r)<c)break;const g=Sc(r,c);m.enqueue(kh(f?g:_d.decode(g),i)),o=0}if(c===0||c>n){m.enqueue(ah);break}}}})}const O0=4;function zt(n){if(n)return Qw(n)}function Qw(n){for(var i in zt.prototype)n[i]=zt.prototype[i];return n}zt.prototype.on=zt.prototype.addEventListener=function(n,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(i),this};zt.prototype.once=function(n,i){function r(){this.off(n,r),i.apply(this,arguments)}return r.fn=i,this.on(n,r),this};zt.prototype.off=zt.prototype.removeListener=zt.prototype.removeAllListeners=zt.prototype.removeEventListener=function(n,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,c=0;c<r.length;c++)if(o=r[c],o===i||o.fn===i){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};zt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)i[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,c=r.length;o<c;++o)r[o].apply(this,i)}return this};zt.prototype.emitReserved=zt.prototype.emit;zt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};zt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const $c=typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,r)=>r(i,0),Xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Xw="arraybuffer";function C0(n,...i){return i.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const Fw=Xn.setTimeout,Kw=Xn.clearTimeout;function eu(n,i){i.useNativeTimers?(n.setTimeoutFn=Fw.bind(Xn),n.clearTimeoutFn=Kw.bind(Xn)):(n.setTimeoutFn=Xn.setTimeout.bind(Xn),n.clearTimeoutFn=Xn.clearTimeout.bind(Xn))}const Zw=1.33;function Pw(n){return typeof n=="string"?Iw(n):Math.ceil((n.byteLength||n.size)*Zw)}function Iw(n){let i=0,r=0;for(let o=0,c=n.length;o<c;o++)i=n.charCodeAt(o),i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(o++,r+=4);return r}function A0(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Jw(n){let i="";for(let r in n)n.hasOwnProperty(r)&&(i.length&&(i+="&"),i+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return i}function Ww(n){let i={},r=n.split("&");for(let o=0,c=r.length;o<c;o++){let f=r[o].split("=");i[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return i}class $w extends Error{constructor(i,r,o){super(i),this.description=r,this.context=o,this.type="TransportError"}}class jh extends zt{constructor(i){super(),this.writable=!1,eu(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,r,o){return super.emitReserved("error",new $w(i,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(i){this.readyState==="open"&&this.write(i)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(i){const r=kh(i,this.socket.binaryType);this.onPacket(r)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,r={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_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(i){const r=Jw(i);return r.length?"?"+r:""}}class eR extends jh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const r=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};Yw(i,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const i=()=>{this.write([{type:"close"}])};this.readyState==="open"?i():this.once("open",i)}write(i){this.writable=!1,qw(i,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=A0()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(i,r)}}let _0=!1;try{_0=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const tR=_0;function nR(){}class iR extends eR{constructor(i){if(super(i),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||o!==i.port}}doWrite(i,r){const o=this.request({method:"POST",data:i});o.on("success",r),o.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=i}}class hi extends zt{constructor(i,r,o){super(),this.createRequest=i,eu(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var i;const r=C0(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&o.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var c;o.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=hi.requestsCount++,hi.requests[this._index]=this)}_onError(i){this.emitReserved("error",i,this._xhr),this._cleanup(!0)}_cleanup(i){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=nR,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete hi.requests[this._index],this._xhr=null}}_onLoad(){const i=this._xhr.responseText;i!==null&&(this.emitReserved("data",i),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}hi.requestsCount=0;hi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Nb);else if(typeof addEventListener=="function"){const n="onpagehide"in Xn?"pagehide":"unload";addEventListener(n,Nb,!1)}}function Nb(){for(let n in hi.requests)hi.requests.hasOwnProperty(n)&&hi.requests[n].abort()}const sR=function(){const n=M0({xdomain:!1});return n&&n.responseType!==null}();class rR extends iR{constructor(i){super(i);const r=i&&i.forceBase64;this.supportsBinary=sR&&!r}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new hi(M0,this.uri(),i)}}function M0(n){const i=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||tR))return new XMLHttpRequest}catch{}if(!i)try{return new Xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const N0=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class aR extends jh{get name(){return"websocket"}doOpen(){const i=this.uri(),r=this.opts.protocols,o=N0?{}:C0(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,r,o)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=i=>this.onClose({description:"websocket connection closed",context:i}),this.ws.onmessage=i=>this.onData(i.data),this.ws.onerror=i=>this.onError("websocket error",i)}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;zh(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}c&&$c(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const i=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=A0()),this.supportsBinary||(r.b64=1),this.createUri(i,r)}}const Md=Xn.WebSocket||Xn.MozWebSocket;class oR extends aR{createSocket(i,r,o){return N0?new Md(i,r,o):r?new Md(i,r):new Md(i)}doWrite(i,r){this.ws.send(r)}}class lR extends jh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(i){return this.emitReserved("error",i)}this._transport.closed.then(()=>{this.onClose()}).catch(i=>{this.onError("webtransport error",i)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(i=>{const r=Gw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=i.readable.pipeThrough(r).getReader(),c=Vw();c.readable.pipeTo(i.writable),this._writer=c.writable.getWriter();const f=()=>{o.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;this._writer.write(o).then(()=>{c&&$c(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const cR={websocket:oR,webtransport:lR,polling:rR},uR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,fR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function oh(n){if(n.length>8e3)throw"URI too long";const i=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let c=uR.exec(n||""),f={},d=14;for(;d--;)f[fR[d]]=c[d]||"";return r!=-1&&o!=-1&&(f.source=i,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=dR(f,f.path),f.queryKey=hR(f,f.query),f}function dR(n,i){const r=/\/{2,9}/g,o=i.replace(r,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&o.splice(0,1),i.slice(-1)=="/"&&o.splice(o.length-1,1),o}function hR(n,i){const r={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,c,f){c&&(r[c]=f)}),r}const lh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Nc=[];lh&&addEventListener("offline",()=>{Nc.forEach(n=>n())},!1);class Cs extends zt{constructor(i,r){if(super(),this.binaryType=Xw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(r=i,i=null),i){const o=oh(i);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=oh(r.host).host);eu(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(o=>{const c=o.prototype.name;this.transports.push(c),this._transportsByName[c]=o}),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=Ww(this.opts.query)),lh&&(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"})},Nc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const r=Object.assign({},this.opts.query);r.EIO=O0,r.transport=i,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Cs.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(i);r.open(),this.setTransport(r)}setTransport(i){this.transport&&this.transport.removeAllListeners(),this.transport=i,i.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",Cs.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",i),this.emitReserved("heartbeat"),i.type){case"open":this.onHandshake(JSON.parse(i.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=i.data,this._onError(r);break;case"message":this.emitReserved("data",i.data),this.emitReserved("message",i.data);break}}onHandshake(i){this.emitReserved("handshake",i),this.id=i.sid,this.transport.query.sid=i.sid,this._pingInterval=i.pingInterval,this._pingTimeout=i.pingTimeout,this._maxPayload=i.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const i=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+i,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},i),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 i=this._getWritablePackets();this.transport.send(i),this._prevBufferLen=i.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const c=this.writeBuffer[o].data;if(c&&(r+=Pw(c)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,$c(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,r,o){return this._sendPacket("message",i,r,o),this}send(i,r,o){return this._sendPacket("message",i,r,o),this}_sendPacket(i,r,o,c){if(typeof r=="function"&&(c=r,r=void 0),typeof o=="function"&&(c=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:i,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),i()},o=()=>{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?o():i()}):this.upgrading?o():i()),this}_onError(i){if(Cs.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",i),this._onClose("transport error",i)}_onClose(i,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(),lh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Nc.indexOf(this._offlineEventListener);o!==-1&&Nc.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,r),this.writeBuffer=[],this._prevBufferLen=0}}}Cs.protocol=O0;class mR extends Cs{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let i=0;i<this._upgrades.length;i++)this._probe(this._upgrades[i])}_probe(i){let r=this.createTransport(i),o=!1;Cs.priorWebsocketSuccess=!1;const c=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Cs.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,y(),r.close(),r=null)}const d=v=>{const S=new Error("probe error: "+v);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function m(){d("transport closed")}function g(){d("socket closed")}function p(v){r&&v.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",g),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",g),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const r=[];for(let o=0;o<i.length;o++)~this.transports.indexOf(i[o])&&r.push(i[o]);return r}}let pR=class extends mR{constructor(i,r={}){const o=typeof i=="object",c=o?{...i}:{...r};(!c.transports||c.transports&&typeof c.transports[0]=="string")&&(c.transports=(c.transports||["polling","websocket","webtransport"]).map(f=>cR[f]).filter(f=>!!f)),super(o?c:i,c)}};function gR(n,i="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=oh(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+i,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const yR=typeof ArrayBuffer=="function",bR=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,D0=Object.prototype.toString,vR=typeof Blob=="function"||typeof Blob<"u"&&D0.call(Blob)==="[object BlobConstructor]",SR=typeof File=="function"||typeof File<"u"&&D0.call(File)==="[object FileConstructor]";function Lh(n){return yR&&(n instanceof ArrayBuffer||bR(n))||vR&&n instanceof Blob||SR&&n instanceof File}function Dc(n,i){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(Dc(n[r]))return!0;return!1}if(Lh(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Dc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Dc(n[r]))return!0;return!1}function xR(n){const i=[],r=n.data,o=n;return o.data=zc(r,i),o.attachments=i.length,{packet:o,buffers:i}}function zc(n,i,r){if(!n)return n;if(Lh(n)){const o={_placeholder:!0,num:i.length};return i.push(n),o}else if(Array.isArray(n)){const o=new Array(n.length);for(let c=0;c<n.length;c++)o[c]=zc(n[c],i);return o}else if(typeof n=="object"&&!(n instanceof Date)){if(n.toJSON&&typeof n.toJSON=="function"&&!r)return zc(n.toJSON(),i,!0);const o={};for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(o[c]=zc(n[c],i));return o}return n}function ER(n,i){return n.data=ch(n.data,i),delete n.attachments,n}function ch(n,i){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<i.length)return i[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=ch(n[r],i);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=ch(n[r],i));return n}const z0=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],TR=5;var Ne;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ne||(Ne={}));class wR{constructor(i){this.replacer=i}encode(i){return(i.type===Ne.EVENT||i.type===Ne.ACK)&&Dc(i)?this.encodeAsBinary({type:i.type===Ne.EVENT?Ne.BINARY_EVENT:Ne.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let r=""+i.type;return(i.type===Ne.BINARY_EVENT||i.type===Ne.BINARY_ACK)&&(r+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(r+=i.nsp+","),i.id!=null&&(r+=i.id),i.data!=null&&(r+=JSON.stringify(i.data,this.replacer)),r}encodeAsBinary(i){const r=xR(i),o=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(o),c}}class Uh extends zt{constructor(i){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof i=="function"?{reviver:i}:i)}add(i){let r;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(i);const o=r.type===Ne.BINARY_EVENT;o||r.type===Ne.BINARY_ACK?(r.type=o?Ne.EVENT:Ne.ACK,this.reconstructor=new RR(r)):super.emitReserved("decoded",r)}else if(Lh(i)||i.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(i),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: "+i)}decodeString(i){let r=0;const o={type:Number(i.charAt(0))};if(Ne[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Ne.BINARY_EVENT||o.type===Ne.BINARY_ACK){const f=r+1;for(;i.charAt(++r)!=="-"&&r!=i.length;);const d=i.substring(f,r);if(d!=Number(d)||i.charAt(r)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!k0(m)||m<1)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");o.attachments=m}if(i.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(i.charAt(r)===","||r===i.length););o.nsp=i.substring(f,r)}else o.nsp="/";const c=i.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=i.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===i.length)break}o.id=Number(i.substring(f,r+1))}if(i.charAt(++r)){const f=this.tryParse(i.substr(r));if(Uh.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(i){try{return JSON.parse(i,this.opts.reviver)}catch{return!1}}static isPayloadValid(i,r){switch(i){case Ne.CONNECT:return Vc(r);case Ne.DISCONNECT:return r===void 0;case Ne.CONNECT_ERROR:return typeof r=="string"||Vc(r);case Ne.EVENT:case Ne.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&z0.indexOf(r[0])===-1);case Ne.ACK:case Ne.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class RR{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const r=ER(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function OR(n){return typeof n=="string"}const k0=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function CR(n){return n===void 0||k0(n)}function Vc(n){return Object.prototype.toString.call(n)==="[object Object]"}function AR(n,i){switch(n){case Ne.CONNECT:return i===void 0||Vc(i);case Ne.DISCONNECT:return i===void 0;case Ne.EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&z0.indexOf(i[0])===-1);case Ne.ACK:return Array.isArray(i);case Ne.CONNECT_ERROR:return typeof i=="string"||Vc(i);default:return!1}}function _R(n){return OR(n.nsp)&&CR(n.id)&&AR(n.type,n.data)}const MR=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Uh,Encoder:wR,get PacketType(){return Ne},isPacketValid:_R,protocol:TR},Symbol.toStringTag,{value:"Module"}));function Wn(n,i,r){return n.on(i,r),function(){n.off(i,r)}}const NR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class j0 extends zt{constructor(i,r,o){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=i,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[Wn(i,"open",this.onopen.bind(this)),Wn(i,"packet",this.onpacket.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"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(...i){return i.unshift("message"),this.emit.apply(this,i),this}emit(i,...r){var o,c,f;if(NR.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(r.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:Ne.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,v=r.pop();this._registerAckCallback(y,v),d.id=y}const m=(c=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(i,r){var o;const c=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(c===void 0){this.acks[i]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===i&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[i]=d}emitWithAck(i,...r){return new Promise((o,c)=>{const f=(d,m)=>d?c(d):o(m);f.withError=!0,r.push(f),this.emit(i,...r)})}_addToQueue(i){let r;typeof i[i.length-1]=="function"&&(r=i.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((c,...f)=>(this._queue[0],c!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!i||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(i){i.nsp=this.nsp,this.io._packet(i)}onopen(){typeof this.auth=="function"?this.auth(i=>{this._sendConnectPacket(i)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(i){this.packet({type:Ne.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},i):i})}onerror(i){this.connected||this.emitReserved("connect_error",i)}onclose(i,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(o=>String(o.id)===i)){const o=this.acks[i];delete this.acks[i],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case Ne.CONNECT:i.data&&i.data.sid?this.onconnect(i.data.sid,i.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 Ne.EVENT:case Ne.BINARY_EVENT:this.onevent(i);break;case Ne.ACK:case Ne.BINARY_ACK:this.onack(i);break;case Ne.DISCONNECT:this.ondisconnect();break;case Ne.CONNECT_ERROR:this.destroy();const o=new Error(i.data.message);o.data=i.data.data,this.emitReserved("connect_error",o);break}}onevent(i){const r=i.data||[];i.id!=null&&r.push(this.ack(i.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,i)}super.emit.apply(this,i),this._pid&&i.length&&typeof i[i.length-1]=="string"&&(this._lastOffset=i[i.length-1])}ack(i){const r=this;let o=!1;return function(...c){o||(o=!0,r.packet({type:Ne.ACK,id:i,data:c}))}}onack(i){const r=this.acks[i.id];typeof r=="function"&&(delete this.acks[i.id],r.withError&&i.data.unshift(null),r.apply(this,i.data))}onconnect(i,r){this.id=i,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(i=>this.emitEvent(i)),this.receiveBuffer=[],this.sendBuffer.forEach(i=>{this.notifyOutgoingListeners(i),this.packet(i)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(i=>i()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ne.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(i){return this.flags.compress=i,this}get volatile(){return this.flags.volatile=!0,this}timeout(i){return this.flags.timeout=i,this}onAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(i),this}prependAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(i),this}offAny(i){if(!this._anyListeners)return this;if(i){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(i),this}prependAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(i),this}offAnyOutgoing(i){if(!this._anyOutgoingListeners)return this;if(i){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,i.data)}}}function Aa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Aa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),r=Math.floor(i*this.jitter*n);n=(Math.floor(i*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Aa.prototype.reset=function(){this.attempts=0};Aa.prototype.setMin=function(n){this.ms=n};Aa.prototype.setMax=function(n){this.max=n};Aa.prototype.setJitter=function(n){this.jitter=n};class uh extends zt{constructor(i,r){var o;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(r=i,i=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,eu(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new Aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=i;const c=r.parser||MR;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(i){return arguments.length?(this._reconnection=!!i,i||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(i){return i===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=i,this)}reconnectionDelay(i){var r;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(r=this.backoff)===null||r===void 0||r.setMin(i),this)}randomizationFactor(i){var r;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(r=this.backoff)===null||r===void 0||r.setJitter(i),this)}reconnectionDelayMax(i){var r;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(r=this.backoff)===null||r===void 0||r.setMax(i),this)}timeout(i){return arguments.length?(this._timeout=i,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(i){if(~this._readyState.indexOf("open"))return this;this.engine=new pR(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const c=Wn(r,"open",function(){o.onopen(),i&&i()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),i?i(m):this.maybeReconnectOnOpen()},d=Wn(r,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(d),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(Wn(i,"ping",this.onping.bind(this)),Wn(i,"data",this.ondata.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(r){this.onclose("parse error",r)}}ondecoded(i){$c(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,r){let o=this.nsps[i];return o?this._autoConnect&&!o.active&&o.connect():(o=new j0(this,i,r),this.nsps[i]=o),o}_destroy(i){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(i){const r=this.encoder.encode(i);for(let o=0;o<r.length;o++)this.engine.write(r[o],i.options)}cleanup(){this.subs.forEach(i=>i()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(i,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const i=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 o=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(c=>{c?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",c)):i.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Oo={};function kc(n,i){typeof n=="object"&&(i=n,n=void 0),i=i||{};const r=gR(n,i.path||"/socket.io"),o=r.source,c=r.id,f=r.path,d=Oo[c]&&f in Oo[c].nsps,m=i.forceNew||i["force new connection"]||i.multiplex===!1||d;let g;return m?g=new uh(o,i):(Oo[c]||(Oo[c]=new uh(o,i)),g=Oo[c]),r.query&&!i.query&&(i.query=r.queryKey),g.socket(r.path,i)}Object.assign(kc,{Manager:uh,Socket:j0,io:kc,connect:kc});let Nd=null;function mr(){return Nd||(Nd=kc({transports:["websocket"],autoConnect:!0})),Nd}async function DR(){const n=mr();return await Zo(n),n.emitWithAck("health.get")}async function Zo(n){n.connected||await new Promise((i,r)=>{const o=()=>{f(),i()},c=d=>{f(),r(d)},f=()=>{n.off("connect",o),n.off("connect_error",c)};n.on("connect",o),n.on("connect_error",c),n.connect()})}async function zR(n){const i=mr();return await Zo(i),i.emitWithAck("logs.history",n)}async function kR(n,i){const r=mr();return await Zo(r),r.emitWithAck("logs.dimensions",{chatroomId:n,limit:i})}async function jR(){const n=mr();return await Zo(n),n.emitWithAck("chatrooms.list")}async function LR(n){const i=mr();return await Zo(i),i.emitWithAck("eventStream.history",n??{})}function UR(n){const i=mr();return i.connect(),i.emit("eventStream.stream.subscribe"),i.on("eventStream.stream",n),()=>i.off("eventStream.stream",n)}function BR(n){const i=mr();return i.connect(),i.emit("logs.stream.subscribe"),i.on("logs.stream",n),()=>i.off("logs.stream",n)}function HR(){return Qv({queryKey:["daemon","health"],queryFn:async()=>{const n=await DR();if(!n.ok)throw new Error(n.error.message);return n.data},retry:2})}const qR={info:{badge:"bg-chatroom-status-info/15 text-chatroom-status-info"},success:{badge:"bg-chatroom-status-success/15 text-chatroom-status-success"},warning:{badge:"bg-chatroom-status-warning/15 text-chatroom-status-warning"},error:{badge:"bg-chatroom-status-error/15 text-chatroom-status-error"},muted:{badge:"bg-chatroom-text-muted/15 text-chatroom-text-muted"},purple:{badge:"bg-chatroom-status-purple/15 text-chatroom-status-purple"}};function YR(n){return qR[n]}const VR={"agent.started":["Agent Started","success"],"agent.exited":["Agent Exited","error"],"agent.circuitOpen":["Circuit Open","warning"],"agent.requestStart":["Agent Request Start","warning"],"agent.registered":["Agent Registered","success"],"agent.waiting":["Agent Waiting","success"],"agent.startFailed":["Agent Start Failed","error"],"agent.providerUnavailable":["Provider Unavailable","warning"],"agent.sessionResumeRequested":["Session Reconnect Requested","info"],"agent.sessionResumed":["Session Reconnected","success"],"agent.sessionResumeFailed":["Session Reconnect Failed","warning"],"agent.sessionReopenRetry":["Session Reopen Retry","info"],"agent.sessionCompacted":["Session Compacted","info"],"agent.sessionAugmented":["Session Augmented","info"],"agent.restart":["Agent Restarting","info"],"agent.restartCompleted":["Agent Restarted","success"],"agent.restartPhase":["Agent Restart Progress","info"],"agent.restartLimitReached":["Agent Restart Limit","error"],"agent.stopTimeout":["Agent Stop Timeout","warning"],"agent.harnessSessionIdUpdated":["Harness Session ID Updated","info"],"agent.awaitingHandoff":["Awaiting Handoff","warning"],"agent.taskDelivered":["Task Delivered","success"],"agent.taskDeliveryFailed":["Task Delivery Failed","error"],"machine.switched":["Machine Switched","info"],"connection.terminated":["Connection Terminated","muted"],"workflow.started":["Workflow Started","info"],"workflow.stepCompleted":["Workflow Step Completed","success"],"workflow.stepCancelled":["Workflow Step Cancelled","warning"],"workflow.completed":["Workflow Completed","success"],"workflow.created":["Workflow Created","info"],"workflow.specified":["Workflow Specified","info"],"workflow.stepStarted":["Workflow Step Started","info"],"task.activated":["Task Activated","success"],"task.acknowledged":["Task Acknowledged","success"],"task.inProgress":["Task In Progress","info"],"task.completed":["Task Completed","success"],"skill.activated":["Skill Activated","purple"],"daemon.ping":["Daemon Ping","muted"],"daemon.pong":["Daemon Pong","muted"],"daemon.gitRefresh":["Git Refresh","muted"],"daemon.refreshCapabilities":["Capabilities Refresh","muted"],"daemon.pickFolder":["Pick Folder","muted"],"daemon.localAction":["Local Action","muted"],"config.requestRemoval":["Config Request Removal","warning"],"command.run":["Command Run","warning"],"command.stop":["Command Stop","error"]},GR=Object.fromEntries(Object.entries(VR).map(([n,[i,r]])=>[n,{label:i,classification:r}]));function QR(n){const i=n.toLowerCase();return i.includes("failed")||i.includes("error")||i.includes("timeout")?"error":n.startsWith("task.")?"success":n.startsWith("agent.")||n.startsWith("workflow.")?"info":n.startsWith("daemon.")?"muted":n.startsWith("command.")?"warning":n.startsWith("skill.")?"purple":"muted"}function XR(n){return GR[n]??{label:n,classification:QR(n)}}function L0({type:n,className:i}){const r=XR(n);return C.jsx("span",{className:un("shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider",YR(r.classification).badge,i),children:r.label})}function tu(){return typeof window<"u"}function $t(n){return Bh(n)?(n.nodeName||"").toLowerCase():"#document"}function kt(n){var i;return(n==null||(i=n.ownerDocument)==null?void 0:i.defaultView)||window}function Xi(n){var i;return(i=(Bh(n)?n.ownerDocument:n.document)||window.document)==null?void 0:i.documentElement}function Bh(n){return tu()?n instanceof Node||n instanceof kt(n).Node:!1}function Je(n){return tu()?n instanceof Element||n instanceof kt(n).Element:!1}function Rt(n){return tu()?n instanceof HTMLElement||n instanceof kt(n).HTMLElement:!1}function Ta(n){return!tu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof kt(n).ShadowRoot}function pr(n){const{overflow:i,overflowX:r,overflowY:o,display:c}=zn(n);return/auto|scroll|overlay|hidden|clip/.test(i+o+r)&&c!=="inline"&&c!=="contents"}function FR(n){return/^(table|td|th)$/.test($t(n))}function nu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const KR=/transform|translate|scale|rotate|perspective|filter/,ZR=/paint|layout|strict|content/,$s=n=>!!n&&n!=="none";let Dd;function Hh(n){const i=Je(n)?zn(n):n;return $s(i.transform)||$s(i.translate)||$s(i.scale)||$s(i.rotate)||$s(i.perspective)||!qh()&&($s(i.backdropFilter)||$s(i.filter))||KR.test(i.willChange||"")||ZR.test(i.contain||"")}function PR(n){let i=_s(n);for(;Rt(i)&&!As(i);){if(Hh(i))return i;if(nu(i))return null;i=_s(i)}return null}function qh(){return Dd==null&&(Dd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Dd}function As(n){return/^(html|body|#document)$/.test($t(n))}function zn(n){return kt(n).getComputedStyle(n)}function iu(n){return Je(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function _s(n){if($t(n)==="html")return n;const i=n.assignedSlot||n.parentNode||Ta(n)&&n.host||Xi(n);return Ta(i)?i.host:i}function U0(n){const i=_s(n);return As(i)?(n.ownerDocument||n).body:Rt(i)&&pr(i)?i:U0(i)}function ko(n,i,r){var o;i===void 0&&(i=[]),r===void 0&&(r=!0);const c=U0(n),f=c===((o=n.ownerDocument)==null?void 0:o.body),d=kt(c);if(f){const m=fh(d);return i.concat(d,d.visualViewport||[],pr(c)?c:[],m&&r?ko(m):[])}else return i.concat(c,ko(c,[],r))}function fh(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Yh={...m1},zd=Yh.useInsertionEffect,IR=zd&&zd!==Yh.useLayoutEffect?zd:n=>n();function $e(n){const i=Qi(JR).current;return i.next=n,IR(i.effect),i.trampoline}function JR(){const n={next:void 0,callback:WR,trampoline:(...i)=>{var r;return(r=n.callback)==null?void 0:r.call(n,...i)},effect:()=>{n.callback=n.next}};return n}function WR(){}const $R=()=>{},Xe=typeof document<"u"?w.useLayoutEffect:$R,eO=w.createContext(void 0);function tO(n=!1){const i=w.useContext(eO);if(i===void 0&&!n)throw new Error(fr(16));return i}function nO(n){const{focusableWhenDisabled:i,disabled:r,composite:o=!1,tabIndex:c=0,isNativeButton:f}=n,d=o&&i!==!1,m=o&&i===!1;return{props:w.useMemo(()=>{const p={onKeyDown(y){r&&i&&y.key!=="Tab"&&y.preventDefault()}};return o||(p.tabIndex=c,!f&&r&&(p.tabIndex=i?c:-1)),(f&&(i||d)||!f&&r)&&(p["aria-disabled"]=r),f&&(!i||m)&&(p.disabled=r),p},[o,r,i,d,m,f,c])}}function B0(n={}){const{disabled:i=!1,focusableWhenDisabled:r,tabIndex:o=0,native:c=!0,composite:f}=n,d=w.useRef(null),m=tO(!0),g=f??m!==void 0,{props:p}=nO({focusableWhenDisabled:r,disabled:i,composite:g,tabIndex:o,isNativeButton:c}),y=w.useCallback(()=>{const E=d.current;kd(E)&&g&&i&&p.disabled===void 0&&E.disabled&&(E.disabled=!1)},[i,p.disabled,g]);Xe(y,[y]);const v=w.useCallback((E={})=>{const{onClick:x,onMouseDown:R,onKeyUp:_,onKeyDown:D,onPointerDown:A,...j}=E;return Ko({onClick(k){if(i){k.preventDefault();return}x==null||x(k)},onMouseDown(k){i||R==null||R(k)},onKeyDown(k){if(i||(Hc(k),D==null||D(k),k.baseUIHandlerPrevented))return;const q=k.target===k.currentTarget,F=k.currentTarget,B=kd(F),L=!c&&iO(F),K=q&&(c?B:!L),se=k.key==="Enter",pe=k.key===" ",ae=F.getAttribute("role"),W=(ae==null?void 0:ae.startsWith("menuitem"))||ae==="option"||ae==="gridcell";if(q&&g&&pe){if(k.defaultPrevented&&W)return;k.preventDefault(),L||c&&B?(F.click(),k.preventBaseUIHandler()):K&&(x==null||x(k),k.preventBaseUIHandler());return}K&&(!c&&(pe||se)&&k.preventDefault(),!c&&se&&(x==null||x(k)))},onKeyUp(k){if(!i){if(Hc(k),_==null||_(k),k.target===k.currentTarget&&c&&g&&kd(k.currentTarget)&&k.key===" "){k.preventDefault();return}k.baseUIHandlerPrevented||k.target===k.currentTarget&&!c&&!g&&k.key===" "&&(x==null||x(k))}},onPointerDown(k){if(i){k.preventDefault();return}A==null||A(k)}},c?{type:"button"}:{role:"button"},p,j)},[i,p,g,c]),S=$e(E=>{d.current=E,y()});return{getButtonProps:v,buttonRef:S}}function kd(n){return Rt(n)&&n.tagName==="BUTTON"}function iO(n){return!!((n==null?void 0:n.tagName)==="A"&&(n!=null&&n.href))}const sO=w.forwardRef(function(i,r){const{render:o,className:c,disabled:f=!1,focusableWhenDisabled:d=!1,nativeButton:m=!0,style:g,...p}=i,{getButtonProps:y,buttonRef:v}=B0({disabled:f,focusableWhenDisabled:d,native:m});return Ca("button",i,{state:{disabled:f},ref:[r,v],props:[p,y]})}),rO=t0("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input",ghost:"hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2",sm:"h-8 px-3"}},defaultVariants:{variant:"default",size:"default"}});function dh({className:n,variant:i="default",size:r="default",...o}){return C.jsx(sO,{"data-slot":"button",className:un(rO({variant:i,size:r,className:n})),...o})}function aO(n,i){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:i==null?void 0:i.timeZone})}function H0(n,i){return new Date(n).toLocaleString(void 0,{timeZone:i==null?void 0:i.timeZone})}function oO({entry:n,onClose:i}){const r=n.payload;return C.jsxs("aside",{className:"flex w-96 max-w-[40%] shrink-0 flex-col border-l border-chatroom-border bg-chatroom-bg-primary",role:"dialog","aria-modal":"true","aria-label":"Event detail",children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-chatroom-border px-4 py-3",children:[C.jsx("h3",{className:"text-sm font-medium",children:"Event detail"}),C.jsx(dh,{variant:"ghost",size:"sm",onClick:i,"aria-label":"Close detail panel",children:C.jsx(S0,{className:"size-4"})})]}),C.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 text-xs",children:[C.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[C.jsx(L0,{type:n.type}),C.jsx("span",{className:"text-chatroom-text-muted",children:H0(n.timestamp)})]}),C.jsxs("div",{className:"space-y-1 text-chatroom-text-muted",children:[C.jsxs("div",{children:["Type: ",C.jsx("span",{className:"text-chatroom-text-primary",children:n.type})]}),C.jsxs("div",{children:["ID: ",C.jsx("span",{className:"text-chatroom-text-primary",children:n.id})]}),typeof r.chatroomId=="string"&&C.jsxs("div",{children:["Chatroom: ",C.jsx("span",{className:"text-chatroom-text-primary",children:r.chatroomId})]})]}),C.jsxs("div",{children:[C.jsx("p",{className:"mb-1 text-chatroom-text-muted",children:"Payload"}),C.jsx("pre",{className:"whitespace-pre-wrap border border-chatroom-border bg-chatroom-bg-secondary p-2 font-mono text-[11px]",children:JSON.stringify(r,null,2)})]})]})]})}function lO(n,i,r){const o=i.trim().toLowerCase();return o?n.filter(c=>r(c).toLowerCase().includes(o)):[...n]}function Gc({children:n,selected:i,onSelect:r,disabled:o,className:c,endAdornment:f,trailingActions:d,multiline:m=!1}){const g=un("min-w-0 px-3 py-2 text-xs text-left flex justify-between gap-2",m?"items-start":"items-center","cursor-pointer hover:bg-chatroom-bg-hover transition-colors","outline-none focus-visible:outline-none focus-visible:bg-chatroom-bg-hover","disabled:opacity-50 disabled:cursor-not-allowed",i&&"bg-chatroom-bg-hover",d?"flex-1 rounded-none":"w-full",!d&&c),p=C.jsxs("button",{type:"button",role:"option","aria-selected":i??!1,disabled:o,onClick:r,className:g,children:[C.jsx("span",{className:un("min-w-0 flex-1",m?"overflow-hidden":"truncate"),children:n}),f,i&&!d?C.jsx(b0,{size:12,className:"shrink-0 text-chatroom-accent"}):null]});return d?C.jsxs("div",{className:un("flex items-center w-full min-w-0",c),children:[p,d]}):p}function cO({children:n,className:i,maxHeightClassName:r="max-h-[60vh]"}){return C.jsx("div",{"data-picker-scroll-body":!0,className:un("min-h-0 overflow-y-auto overscroll-contain",r,i),children:n})}function uO({value:n,onChange:i,placeholder:r="Search…",autoFocus:o,className:c}){const f=o??!0;return C.jsx("div",{className:un("px-3 py-1.5 border-b border-chatroom-border shrink-0",c),"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),onClick:d=>{const m=d.currentTarget.querySelector("input");m==null||m.focus()},children:C.jsx("input",{type:"search",enterKeyHint:"search",value:n,onChange:d=>i(d.target.value),placeholder:r,autoFocus:f,"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),className:"w-full bg-chatroom-bg-tertiary border border-chatroom-border px-2 py-1 text-[11px] text-chatroom-text-primary placeholder:text-chatroom-text-muted focus:outline-none focus:border-chatroom-accent rounded-none"})})}const q0="min-w-[8rem] max-w-[14rem] border border-chatroom-border bg-chatroom-bg-secondary text-xs text-chatroom-text-primary px-2 py-1.5 h-[28px] cursor-pointer hover:border-chatroom-border-strong focus:outline-none focus:border-chatroom-accent disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between gap-1",Y0="shrink-0 text-chatroom-text-muted";function fO(n){const[i,r]=w.useState(""),o=w.useCallback(c=>{c||r(""),n(c)},[n]);return{searchTerm:i,setSearchTerm:r,handleOpenChange:o}}const dO=[];function Vh(n){w.useEffect(n,dO)}const Co=0;class ei{constructor(){tt(this,"currentId",Co);tt(this,"clear",()=>{this.currentId!==Co&&(clearTimeout(this.currentId),this.currentId=Co)});tt(this,"disposeEffect",()=>this.clear)}static create(){return new ei}start(i,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Co,r()},i)}isStarted(){return this.currentId!==Co}}function wa(){const n=Qi(ei.create).current;return Vh(n.disposeEffect),n}function hO(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:mO,platform:pO,maxTouchPoints:gO}=hO(),su=mO.toLowerCase(),jo=pO.toLowerCase(),ru=/^i(os$|p)/.test(jo)||jo==="macintel"&&gO>1,Db="android",hh=jo===Db||su.includes(Db),yO=!ru&&jo.startsWith("mac");jo.startsWith("win");const bO=yO||ru;var Dv;const _a=typeof CSS<"u"&&!!((Dv=CSS.supports)!=null&&Dv.call(CSS,"-webkit-backdrop-filter:none"));!_a&&su.includes("firefox");!_a&&su.includes("chrom");const vO=bO,SO=/jsdom|happydom/.test(su);function xO(n){n.preventDefault(),n.stopPropagation()}function EO(n){return"nativeEvent"in n}function TO(n){return n.pointerType===""&&n.isTrusted?!0:hh&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function wO(n){return SO?!1:!hh&&n.width===0&&n.height===0||hh&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function Lo(n,i){const r=["mouse","pen"];return i||r.push("",void 0),r.includes(n)}function RO(n){const i=n.type;return i==="click"||i==="mousedown"||i==="keydown"||i==="keyup"}const mh="data-base-ui-focusable",V0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Li(n){var r;let i=n.activeElement;for(;((r=i==null?void 0:i.shadowRoot)==null?void 0:r.activeElement)!=null;)i=i.shadowRoot.activeElement;return i}function Me(n,i){var o;if(!n||!i)return!1;const r=(o=i.getRootNode)==null?void 0:o.call(i);if(n.contains(i))return!0;if(r&&Ta(r)){let c=i;for(;c;){if(n===c)return!0;c=c.parentNode||c.host}}return!1}function $n(n){return"composedPath"in n?n.composedPath()[0]:n.target}function G0(n,i){if(!Je(n))return!1;const r=n;if(i.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,o]of i.entries())if(Me(o,r))return!o.hasAttribute("data-trigger-disabled");return!1}function jd(n,i){if(i==null)return!1;if("composedPath"in n)return n.composedPath().includes(i);const r=n;return r.target!=null&&i.contains(r.target)}function OO(n){return n.matches("html,body")}function Gh(n){return Rt(n)&&n.matches(V0)}function CO(n){return(n==null?void 0:n.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${V0}`))!=null}function zb(n){return n?n.getAttribute("role")==="combobox"&&Gh(n):!1}function kb(n){return n?n.hasAttribute(mh)?n:n.querySelector(`[${mh}]`)||n:null}function AO(n,i){return i!=null&&!Lo(i)?0:typeof n=="function"?n():n}function ph(n,i,r){const o=AO(n,r);return typeof o=="number"?o:o==null?void 0:o[i]}function jb(n){return typeof n=="function"?n():n}function Q0(n,i){return i||n==="click"||n==="mousedown"}function _O(n){return(n==null?void 0:n.includes("mouse"))&&n!=="mousedown"}const MO="none",Uo="trigger-press",xn="trigger-hover",X0="outside-press",NO="close-press",Bo="focus-out",F0="escape-key",DO="imperative-action";function Xt(n,i,r,o){let c=!1,f=!1;const d=Wt;return{reason:n,event:i??new Event("base-ui"),cancel(){c=!0},allowPropagation(){f=!0},get isCanceled(){return c},get isPropagationAllowed(){return f},trigger:r,...d}}function Ke(n,i,r,o){return n.addEventListener(i,r,o),()=>{n.removeEventListener(i,r,o)}}function qi(...n){return()=>{for(let i=0;i<n.length;i+=1){const r=n[i];r&&r()}}}function En(n){const i=Qi(zO,n).current;return i.next=n,Xe(i.effect),i}function zO(n){const i={current:n,next:n,effect:()=>{i.current=i.next}};return i}const xc=null;class kO{constructor(){tt(this,"callbacks",[]);tt(this,"callbacksCount",0);tt(this,"nextId",1);tt(this,"startId",1);tt(this,"isScheduled",!1);tt(this,"tick",i=>{var c;this.isScheduled=!1;const r=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let f=0;f<r.length;f+=1)(c=r[f])==null||c.call(r,i)})}request(i){const r=this.nextId;return this.nextId+=1,this.callbacks.push(i),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(i){const r=i-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const Ec=new kO;class di{constructor(){tt(this,"currentId",xc);tt(this,"cancel",()=>{this.currentId!==xc&&(Ec.cancel(this.currentId),this.currentId=xc)});tt(this,"disposeEffect",()=>this.cancel)}static create(){return new di}static request(i){return Ec.request(i)}static cancel(i){return Ec.cancel(i)}request(i){this.cancel(),this.currentId=Ec.request(()=>{this.currentId=xc,i()})}}function Qh(){const n=Qi(di.create).current;return Vh(n.disposeEffect),n}function ut(n){return(n==null?void 0:n.ownerDocument)||document}const jO={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},LO={...jO,position:"fixed",top:0,left:0},Ra=w.forwardRef(function(i,r){const[o,c]=w.useState();Xe(()=>{vO&&_a&&c("button")},[]);const f={tabIndex:0,role:o};return C.jsx("span",{...i,ref:r,style:LO,"aria-hidden":o?void 0:!0,...f,"data-base-ui-focus-guard":""})}),UO=["top","right","bottom","left"],Oa=Math.min,Yi=Math.max,Qc=Math.round,Tc=Math.floor,Vi=n=>({x:n,y:n}),BO={left:"right",right:"left",bottom:"top",top:"bottom"};function K0(n,i,r){return Yi(n,Oa(i,r))}function Gi(n,i){return typeof n=="function"?n(i):n}function Dn(n){return n.split("-")[0]}function zs(n){return n.split("-")[1]}function Xh(n){return n==="x"?"y":"x"}function Fh(n){return n==="y"?"height":"width"}function Fn(n){const i=n[0];return i==="t"||i==="b"?"y":"x"}function Kh(n){return Xh(Fn(n))}function HO(n,i,r){r===void 0&&(r=!1);const o=zs(n),c=Kh(n),f=Fh(c);let d=c==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return i.reference[f]>i.floating[f]&&(d=Xc(d)),[d,Xc(d)]}function qO(n){const i=Xc(n);return[gh(n),i,gh(i)]}function gh(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Lb=["left","right"],Ub=["right","left"],YO=["top","bottom"],VO=["bottom","top"];function GO(n,i,r){switch(n){case"top":case"bottom":return r?i?Ub:Lb:i?Lb:Ub;case"left":case"right":return i?YO:VO;default:return[]}}function QO(n,i,r,o){const c=zs(n);let f=GO(Dn(n),r==="start",o);return c&&(f=f.map(d=>d+"-"+c),i&&(f=f.concat(f.map(gh)))),f}function Xc(n){const i=Dn(n);return BO[i]+n.slice(i.length)}function XO(n){var i,r,o,c;return{top:(i=n.top)!=null?i:0,right:(r=n.right)!=null?r:0,bottom:(o=n.bottom)!=null?o:0,left:(c=n.left)!=null?c:0}}function Z0(n){return typeof n!="number"?XO(n):{top:n,right:n,bottom:n,left:n}}function Fc(n){const{x:i,y:r,width:o,height:c}=n;return{width:o,height:c,top:r,left:i,right:i+o,bottom:r+c,x:i,y:r}}function FO(n){return n.visibility==="hidden"||n.visibility==="collapse"}function P0(n,i=n?zn(n):null){return!n||!n.isConnected||!i||FO(i)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():i.display!=="none"&&i.display!=="contents"}const KO='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function ZO(n){const i=n.assignedSlot;if(i)return i;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return Ta(r)?r.host:null}function yh(n){for(const i of Array.from(n.children))if($t(i)==="summary")return i;return null}function PO(n,i){const r=yh(i);return!!r&&(n===r||Me(r,n))}function I0(n){const i=n?$t(n):"";return n!=null&&n.matches(KO)&&(i!=="summary"||n.parentElement!=null&&$t(n.parentElement)==="details"&&yh(n.parentElement)===n)&&(i!=="details"||yh(n)==null)&&(i!=="input"||n.type!=="hidden")}function J0(n){if(!I0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let i=n;i;i=ZO(i)){const r=i!==n,o=$t(i)==="slot";if(i.hasAttribute("inert")||r&&$t(i)==="details"&&!i.open&&!PO(n,i)||i.hasAttribute("hidden")||!o&&!IO(i,r))return!1}return!0}function IO(n,i){const r=zn(n);return i?r.display!=="none":P0(n,r)}function W0(n){const i=n.tabIndex;if(i<0){const r=$t(n);if(r==="details"||r==="audio"||r==="video"||Rt(n)&&n.isContentEditable)return 0}return i}function Ld(n){if($t(n)!=="input")return null;const i=n;return i.type==="radio"&&i.name!==""?i:null}function JO(n,i){const r=Ld(n);if(!r)return!0;const o=i.find(c=>{const f=Ld(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form&&f.checked});return o?o===r:i.find(c=>{const f=Ld(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form})===r}function $0(n){if(Rt(n)&&$t(n)==="slot"){const i=n.assignedElements({flatten:!0});if(i.length>0)return i}return Rt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function eS(n,i){$0(n).forEach(r=>{I0(r)&&i.push(r),eS(r,i)})}function tS(n,i,r){$0(n).forEach(o=>{Rt(o)&&o.matches(i)&&r.push(o),tS(o,i,r)})}function Zh(n){return J0(n)&&W0(n)>=0}function nS(n){const i=[];return eS(n,i),i.filter(J0)}function Po(n){const i=nS(n);return i.filter(r=>W0(r)>=0&&JO(r,i))}function iS(n,i){const r=Po(n),o=r.length;if(o===0)return;const c=Li(ut(n)),f=r.indexOf(c),d=f===-1?i===1?0:o-1:f+i;return r[d]}function Ph(n){return iS(ut(n).body,1)||n}function sS(n){return iS(ut(n).body,-1)||n}function rS(n,i){if(!n)return null;const r=Po(ut(n).body),o=r.length;if(o===0)return null;const c=r.indexOf(n);if(c===-1)return null;const f=(c+i+o)%o;return r[f]}function WO(n){return rS(n,1)}function $O(n){return rS(n,-1)}function oa(n,i){const r=i||n.currentTarget,o=n.relatedTarget;return!o||!Me(r,o)}function eC(n){Po(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function Bb(n){const i=[];tS(n,"[data-tabindex]",i),i.forEach(r=>{const o=r.dataset.tabindex;delete r.dataset.tabindex,o?r.setAttribute("tabindex",o):r.removeAttribute("tabindex")})}function Ms(n,i,r=!0){return n.filter(c=>c.parentId===i).flatMap(c=>{var f;return[...!r||(f=c.context)!=null&&f.open?[c]:[],...Ms(n,c.id,r)]})}function Hb(n,i){var c;let r=[],o=(c=n.find(f=>f.id===i))==null?void 0:c.parentId;for(;o;){const f=n.find(d=>d.id===o);o=f==null?void 0:f.parentId,f&&(r=r.concat(f))}return r}function Kc(n){return`data-base-ui-${n}`}let wc=0;function Ud(n,i={}){const{preventScroll:r=!1,sync:o=!1,shouldFocus:c}=i;cancelAnimationFrame(wc);function f(){c&&!c()||n==null||n.focus({preventScroll:r})}if(o)return f(),Mh;const d=requestAnimationFrame(f);return wc=d,()=>{wc===d&&(cancelAnimationFrame(d),wc=0)}}const Bd={inert:new WeakMap,"aria-hidden":new WeakMap},qb="data-base-ui-inert",bh={inert:new WeakSet,"aria-hidden":new WeakSet};let Ao=new WeakMap,Hd=0;function tC(n){return bh[n]}function aS(n){return n?Ta(n)?n.host:aS(n.parentNode):null}const Yb=(n,i)=>i.map(r=>{if(n.contains(r))return r;const o=aS(r);return n.contains(o)?o:null}).filter(r=>r!=null),Vb=n=>{const i=new Set;return n.forEach(r=>{let o=r;for(;o&&!i.has(o);)i.add(o),o=o.parentNode}),i},Gb=(n,i,r)=>{const o=[],c=f=>{!f||r.has(f)||Array.from(f.children).forEach(d=>{$t(d)!=="script"&&(i.has(d)?c(d):o.push(d))})};return c(n),o};function nC(n,i,r,o,{mark:c=!0}){let f=null;o?f="inert":r&&(f="aria-hidden");let d=null,m=null;const g=Yb(i,n),p=c?Gb(i,Vb(g),new Set(g)):[],y=[],v=[];if(f){const S=Bd[f],E=tC(f);m=E,d=S;const x=Yb(i,Array.from(i.querySelectorAll("[aria-live]"))),R=g.concat(x);Gb(i,Vb(R),new Set(R)).forEach(D=>{const A=D.getAttribute(f),j=A!==null&&A!=="false",k=(S.get(D)||0)+1;S.set(D,k),y.push(D),k===1&&j&&E.add(D),j||D.setAttribute(f,f==="inert"?"":"true")})}return c&&p.forEach(S=>{const E=(Ao.get(S)||0)+1;Ao.set(S,E),v.push(S),E===1&&S.setAttribute(qb,"")}),Hd+=1,()=>{d&&y.forEach(S=>{const x=(d.get(S)||0)-1;d.set(S,x),x||(!(m!=null&&m.has(S))&&f&&S.removeAttribute(f),m==null||m.delete(S))}),c&&v.forEach(S=>{const E=(Ao.get(S)||0)-1;Ao.set(S,E),E||S.removeAttribute(qb)}),Hd-=1,Hd||(Bd.inert=new WeakMap,Bd["aria-hidden"]=new WeakMap,bh.inert=new WeakSet,bh["aria-hidden"]=new WeakSet,Ao=new WeakMap)}}function Qb(n,i={}){const{ariaHidden:r=!1,inert:o=!1,mark:c=!0}=i,f=ut(n[0]).body;return nC(n,f,r,o,{mark:c})}var Ns=Xv();let Xb=0;function iC(n,i="mui"){const[r,o]=w.useState(n),c=n||r;return w.useEffect(()=>{r==null&&(Xb+=1,o(`${i}-${Xb}`))},[r,i]),c}const Fb=Yh.useId;function Io(n,i){if(Fb!==void 0){const r=Fb();return n??(i?`${i}-${r}`:r)}return iC(n,i)}const sC=500,rC={style:{transition:"none"}},oS="data-base-ui-click-trigger",aC={fallbackAxisSide:"end"},oC={clipPath:"inset(50%)",position:"fixed",top:0,left:0},lS=w.createContext(null),cS=()=>w.useContext(lS),lC=Kc("portal");function cC(n={}){const{ref:i,container:r,componentProps:o=Wt,elementProps:c}=n,f=Io(),d=cS(),m=d==null?void 0:d.portalNode,[g,p]=w.useState(null),[y,v]=w.useState(null),S=$e(_=>{_!==null&&v(_)}),E=w.useRef(null);Xe(()=>{if(r===null){E.current&&(E.current=null,v(null),p(null));return}if(f==null)return;const _=(r&&(Bh(r)?r:r.current))??m??document.body;if(_==null){E.current&&(E.current=null,v(null),p(null));return}E.current!==_&&(E.current=_,v(null),p(_))},[r,m,f]);const x=Ca("div",o,{ref:[i,S],props:[{id:f,[lC]:""},c]});return{portalNode:y,portalSubtree:g&&x?Ns.createPortal(x,g):null}}const uC=w.forwardRef(function(i,r){const{render:o,className:c,style:f,children:d,container:m,renderGuards:g,...p}=i,{portalNode:y,portalSubtree:v}=cC({container:m,ref:r,componentProps:i,elementProps:p}),S=w.useRef(null),E=w.useRef(null),x=w.useRef(null),R=w.useRef(null),[_,D]=w.useState(null),A=w.useRef(!1),j=_==null?void 0:_.modal,k=_==null?void 0:_.open,q=typeof g=="boolean"?g:!!_&&!_.modal&&_.open&&!!y;w.useEffect(()=>{if(!y||j)return;function B(L){y&&L.relatedTarget&&oa(L)&&(L.type==="focusin"?A.current&&(Bb(y),A.current=!1):(eC(y),A.current=!0))}return qi(Ke(y,"focusin",B,!0),Ke(y,"focusout",B,!0))},[y,j]),Xe(()=>{!y||k!==!0||!A.current||(Bb(y),A.current=!1)},[k,y]);const F=w.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:E,beforeInsideRef:x,afterInsideRef:R,portalNode:y,setFocusManagerState:D}),[y]);return C.jsxs(w.Fragment,{children:[v,C.jsxs(lS.Provider,{value:F,children:[q&&y&&C.jsx(Ra,{"data-type":"outside",ref:S,onFocus:B=>{var L;if(oa(B,y))(L=x.current)==null||L.focus();else{const K=_?_.domReference:null,se=sS(K);se==null||se.focus()}}}),q&&y&&C.jsx("span",{"aria-owns":y.id,style:oC}),y&&Ns.createPortal(d,y),q&&y&&C.jsx(Ra,{"data-type":"outside",ref:E,onFocus:B=>{var L;if(oa(B,y))(L=R.current)==null||L.focus();else{const K=_?_.domReference:null,se=Ph(K);se==null||se.focus(),_!=null&&_.closeOnFocusOut&&(_==null||_.onOpenChange(!1,Xt(Bo,B.nativeEvent)))}}})]})]})});function uS(){const n=new Map;return{emit(i,r){var o;(o=n.get(i))==null||o.forEach(c=>c(r))},on(i,r){n.has(i)||n.set(i,new Set),n.get(i).add(r)},off(i,r){var o;(o=n.get(i))==null||o.delete(r)}}}class fC{constructor(){tt(this,"nodesRef",{current:[]});tt(this,"events",uS())}addNode(i){this.nodesRef.current.push(i)}removeNode(i){const r=this.nodesRef.current.findIndex(o=>o===i);r!==-1&&this.nodesRef.current.splice(r,1)}}const fS=w.createContext(null),dS=w.createContext(null),Ma=()=>{var n;return((n=w.useContext(fS))==null?void 0:n.id)||null},Na=n=>{const i=w.useContext(dS);return n??i};function dC(n){const i=Io(),r=Na(n),o=Ma();return Xe(()=>{if(!i)return;const c={id:i,parentId:o};return r==null||r.addNode(c),()=>{r==null||r.removeNode(c)}},[r,i,o]),i}function hC(n){const{children:i,id:r}=n,o=Ma();return C.jsx(fS.Provider,{value:w.useMemo(()=>({id:r,parentId:o}),[r,o]),children:i})}function mC(n){const{children:i,externalTree:r}=n,o=Qi(()=>r??new fC).current;return C.jsx(dS.Provider,{value:o,children:i})}function Ui(n){return n==null?n:"current"in n?n.current:n}function pC(n,i){const r=kt($n(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?i||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?i||(n.detail===0?"keyboard":"mouse"):""}const gC=20;let Os=[];function Ih(){Os=Os.filter(n=>{var i;return(i=n.deref())==null?void 0:i.isConnected})}function Kb(n){Ih(),n&&$t(n)!=="body"&&(Os.push(new WeakRef(n)),Os.length>gC&&(Os=Os.slice(-20)))}function Zb(){var n;return Ih(),(n=Os[Os.length-1])==null?void 0:n.deref()}function yC(n){return n?Zh(n)?n:Po(n)[0]||n:null}function Pb(n){var c;if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!((c=n.getAttribute("role"))!=null&&c.includes("dialog")))return;const r=nS(n).filter(f=>{const d=f.getAttribute("data-tabindex")||"";return Zh(f)||f.hasAttribute("data-tabindex")&&!d.startsWith("-")}),o=n.getAttribute("tabindex");r.length===0?o!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(o!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function bC(n){const{context:i,children:r,disabled:o=!1,initialFocus:c=!0,returnFocus:f=!0,restoreFocus:d=!1,modal:m=!0,closeOnFocusOut:g=!0,openInteractionType:p="",nextFocusableElement:y,previousFocusableElement:v,beforeContentFocusGuardRef:S,externalTree:E,getInsideElements:x}=n,R="rootStore"in i?i.rootStore:i,_=R.useState("open"),D=R.useState("domReferenceElement"),A=R.useState("floatingElement"),{events:j,dataRef:k}=R.context,q=$e(()=>{var ve;return(ve=k.current.floatingContext)==null?void 0:ve.nodeId}),F=c===!1,B=zb(D)&&F,L=En(c),K=En(f),se=En(p),pe=En(_),ae=Na(E),W=cS(),le=w.useRef(!1),ie=w.useRef(!1),N=w.useRef(!1),Q=w.useRef(null),I=w.useRef(""),oe=w.useRef(""),Y=w.useRef(null),T=w.useRef(null),H=qc(Y,S,W==null?void 0:W.beforeInsideRef),te=qc(T,W==null?void 0:W.afterInsideRef),ne=wa(),re=wa(),ee=Qh(),ge=W!=null,ce=kb(A),fe=$e((ve=ce)=>ve?Po(ve):[]),Ze=$e(()=>(x==null?void 0:x().filter(ve=>ve!=null))??[]);w.useEffect(()=>{if(o||!m)return;function ve(Oe){Oe.key==="Tab"&&Me(ce,Li(ut(ce)))&&fe().length===0&&!B&&xO(Oe)}const ze=ut(ce);return Ke(ze,"keydown",ve)},[o,ce,m,B,fe]),w.useEffect(()=>{if(o||!_)return;const ve=ut(ce);function ze(){N.current=!1}function Oe(vt){const Re=$n(vt),ke=Ze(),Ee=Me(A,Re)||Me(D,Re)||Me(W==null?void 0:W.portalNode,Re)||ke.some(mt=>mt===Re||Me(mt,Re));N.current=!Ee,oe.current=vt.pointerType||"keyboard",Re!=null&&Re.closest(`[${oS}]`)&&(ie.current=!0,re.start(0,()=>{ie.current=!1}))}function ft(){oe.current="keyboard"}return qi(Ke(ve,"pointerdown",Oe,!0),Ke(ve,"pointerup",ze,!0),Ke(ve,"pointercancel",ze,!0),Ke(ve,"keydown",ft,!0),ze)},[o,A,D,ce,_,W,re,Ze]),w.useEffect(()=>{if(o||!g)return;const ve=ut(ce);function ze(){ie.current=!0,re.start(0,()=>{ie.current=!1})}function Oe(ke){const Ee=$n(ke);Zh(Ee)&&(Q.current=Ee)}function ft(ke){const Ee=ke.relatedTarget,mt=ke.currentTarget,dt=$n(ke);m&&Ee==null&&dt!=null&&Me(A,dt)&&Kb(dt),queueMicrotask(()=>{const je=q(),xt=R.context.triggerElements,ue=Ze(),xe=(Ee==null?void 0:Ee.hasAttribute(Kc("focus-guard")))&&[Y.current,T.current,W==null?void 0:W.beforeInsideRef.current,W==null?void 0:W.afterInsideRef.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,Ui(v),Ui(y)].includes(Ee),ht=!(Me(D,Ee)||Me(A,Ee)||Me(Ee,A)||Me(W==null?void 0:W.portalNode,Ee)||ue.some(Be=>Be===Ee||Me(Be,Ee))||Ee!=null&&xt.hasElement(Ee)||xt.hasMatchingElement(Be=>Me(Be,Ee))||xe||ae&&(Ms(ae.nodesRef.current,je).find(Be=>{var pt,jt;return Me((pt=Be.context)==null?void 0:pt.elements.floating,Ee)||Me((jt=Be.context)==null?void 0:jt.elements.domReference,Ee)})||Hb(ae.nodesRef.current,je).find(Be=>{var pt,jt,sn;return[(pt=Be.context)==null?void 0:pt.elements.floating,kb((jt=Be.context)==null?void 0:jt.elements.floating)].includes(Ee)||((sn=Be.context)==null?void 0:sn.elements.domReference)===Ee})));if(mt===D&&ce&&Pb(ce),d&&mt!==D&&!P0(dt)&&Li(ve)===ve.body){if(Rt(ce)&&(ce.focus(),d==="popup")){ee.request(()=>{ce.focus()});return}const Be=fe(),pt=Q.current,jt=(pt&&Be.includes(pt)?pt:null)||Be[Be.length-1]||ce;Rt(jt)&&jt.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(B||!m)&&Ee&&ht&&!ie.current&&(B||Ee!==Zb())&&(le.current=!0,R.setOpen(!1,Xt(Bo,ke)))})}function vt(){N.current||(k.current.insideReactTree=!0,ne.start(0,()=>{k.current.insideReactTree=!1}))}const Re=Rt(D)?D:null;if(!(!A&&!Re))return qi(Re&&Ke(Re,"focusout",ft),Re&&Ke(Re,"pointerdown",ze),A&&Ke(A,"focusin",Oe),A&&Ke(A,"focusout",ft),A&&W&&Ke(A,"focusout",vt,!0))},[o,D,A,ce,m,ae,W,R,g,d,fe,B,q,k,ne,re,ee,y,v,Ze]),w.useEffect(()=>{var mt,dt,je;if(o||!A||!_)return;const ve=Array.from(((mt=W==null?void 0:W.portalNode)==null?void 0:mt.querySelectorAll(`[${Kc("portal")}]`))||[]),Oe=(je=(dt=(ae?Hb(ae.nodesRef.current,q()):[]).find(xt=>{var ue;return zb(((ue=xt.context)==null?void 0:ue.elements.domReference)||null)}))==null?void 0:dt.context)==null?void 0:je.elements.domReference,vt=[...[A,...ve,Y.current,T.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,...Ze()],Oe,Ui(v),Ui(y),B?D:null].filter(xt=>xt!=null),Re=Qb(vt,{ariaHidden:m||B,mark:!1}),ke=[A,...ve].filter(xt=>xt!=null),Ee=Qb(ke);return()=>{Ee(),Re()}},[_,o,D,A,m,W,B,ae,q,y,v,Ze]),Xe(()=>{if(!_||o||!Rt(ce))return;const ve=ut(ce),ze=Li(ve);queueMicrotask(()=>{const Oe=L.current,ft=typeof Oe=="function"?Oe(se.current||""):Oe;if(ft===void 0||ft===!1||Me(ce,ze))return;let Re=null;const ke=()=>(Re==null&&(Re=fe(ce)),Re[0]||ce);let Ee;ft===!0||ft===null?Ee=ke():Ee=Ui(ft),Ee=Ee||ke();const mt=Me(ce,Li(ve));Ud(Ee,{preventScroll:Ee===ce,shouldFocus(){if(!pe.current)return!1;if(mt)return!0;const dt=Li(ve);return!(dt!==Ee&&Me(ce,dt))}})})},[o,_,ce,fe,L,se,pe]),Xe(()=>{if(o||!ce)return;const ve=ut(ce),ze=Li(ve),Oe=se.current==null;Kb(ze);function ft(Re){if(Re.open||(I.current=pC(Re.nativeEvent,oe.current)),Re.reason===xn&&Re.nativeEvent.type==="mouseleave"&&(le.current=!0),Re.reason===X0)if(Re.nested)le.current=!1;else if(TO(Re.nativeEvent)||wO(Re.nativeEvent))le.current=!1;else{let ke=!1;ut(ce).createElement("div").focus({get preventScroll(){return ke=!0,!1}}),ke?le.current=!1:le.current=!0}}j.on("openchange",ft);function vt(){const Re=K.current;let ke=typeof Re=="function"?Re(I.current):Re;if(ke===void 0||ke===!1)return null;ke===null&&(ke=!0);const Ee=D!=null&&D.isConnected?D:null,mt=ze!=null&&ze.isConnected&&$t(ze)!=="body"?ze:null;let dt=Oe?mt||Ee:Ee||mt;return dt||(dt=Zb()||null),typeof ke=="boolean"?dt:Ui(ke)||dt||null}return()=>{j.off("openchange",ft);const Re=Li(ve),ke=Ze(),Ee=Me(A,Re)||ke.some(je=>je===Re||Me(je,Re))||ae&&Ms(ae.nodesRef.current,q(),!1).some(je=>{var xt;return Me((xt=je.context)==null?void 0:xt.elements.floating,Re)}),mt=K.current,dt=vt();queueMicrotask(()=>{const je=yC(dt),xt=typeof mt!="boolean";mt&&!le.current&&Rt(je)&&(!(!xt&&je!==Re&&Re!==ve.body)||Ee)&&je.focus({preventScroll:!0}),le.current=!1})}},[o,A,ce,K,se,j,ae,D,q,Ze]),Xe(()=>{if(!_a||_||!A)return;const ve=Li(ut(A));!Rt(ve)||!Gh(ve)||Me(A,ve)&&ve.blur()},[_,A]),Xe(()=>{if(!(o||!W))return W.setFocusManagerState({modal:m,closeOnFocusOut:g,open:_,onOpenChange:R.setOpen,domReference:D}),()=>{W.setFocusManagerState(null)}},[o,W,m,_,R,g,D]),Xe(()=>{if(!(o||!ce))return Pb(ce),()=>{queueMicrotask(Ih)}},[o,ce]);const nt=!o&&(m?!B:!0)&&(ge||m);return C.jsxs(w.Fragment,{children:[nt&&C.jsx(Ra,{"data-type":"inside",ref:H,onFocus:ve=>{var ze;if(m){const Oe=fe();Ud(Oe[Oe.length-1])}else if(W!=null&&W.portalNode)if(le.current=!1,oa(ve,W.portalNode)){const Oe=Ph(D);Oe==null||Oe.focus()}else(ze=Ui(v??W.beforeOutsideRef))==null||ze.focus()}}),r,nt&&C.jsx(Ra,{"data-type":"inside",ref:te,onFocus:ve=>{var ze;if(m)Ud(fe()[0]);else if(W!=null&&W.portalNode)if(g&&(le.current=!0),oa(ve,W.portalNode)){const Oe=sS(D);Oe==null||Oe.focus()}else(ze=Ui(y??W.afterOutsideRef))==null||ze.focus()}})]})}function vC(n,i={}){const{enabled:r=!0,event:o="click",toggle:c=!0,ignoreMouse:f=!1,stickIfOpen:d=!0,touchOpenDelay:m=0,reason:g=Uo}=i,p="rootStore"in n?n.rootStore:n,y=p.context.dataRef,v=w.useRef(void 0),S=Qh(),E=wa(),x=w.useMemo(()=>{function R(D,A,j,k){const q=Xt(g,A,j);D&&k==="touch"&&m>0?E.start(m,()=>{p.setOpen(!0,q)}):p.setOpen(D,q)}function _(D,A,j){const k=y.current.openEvent,q=p.select("domReferenceElement")!==A;return D&&q||!D||!c?!0:k&&d?!j(k.type):!1}return{onPointerDown(D){v.current=D.pointerType},onMouseDown(D){const A=v.current,j=D.nativeEvent,k=p.select("open");if(D.button!==0||o==="click"||Lo(A,!0)&&f)return;const q=_(k,D.currentTarget,L=>L==="click"||L==="mousedown"),F=$n(j);if(Gh(F)){R(q,j,F,A);return}const B=D.currentTarget;S.request(()=>{R(q,j,B,A)})},onClick(D){if(o==="mousedown-only")return;const A=v.current;if(o==="mousedown"&&A){v.current=void 0;return}if(Lo(A,!0)&&f)return;const j=p.select("open"),k=_(j,D.currentTarget,q=>q==="click"||q==="mousedown"||q==="keydown"||q==="keyup");R(k,D.nativeEvent,D.currentTarget,A)},onKeyDown(){v.current=void 0}}},[y,o,f,g,p,d,c,S,E,m]);return w.useMemo(()=>r?{reference:x}:Wt,[r,x])}function SC(){return!1}function xC(n){return{escapeKey:typeof n=="boolean"?n:(n==null?void 0:n.escapeKey)??!1,outsidePress:typeof n=="boolean"?n:(n==null?void 0:n.outsidePress)??!0}}function EC(n,i={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:c=!0,outsidePressEvent:f="sloppy",referencePress:d=SC,bubbles:m,externalTree:g}=i,p="rootStore"in n?n.rootStore:n,y=p.useState("open"),v=p.useState("floatingElement"),{dataRef:S}=p.context,E=Na(g),x=$e(typeof c=="function"?c:()=>!1),R=typeof c=="function"?x:c,_=R!==!1,D=$e(()=>f),{escapeKey:A,outsidePress:j}=xC(m),k=w.useRef(!1),q=w.useRef(!1),F=w.useRef(!1),B=w.useRef(!1),L=w.useRef(""),K=w.useRef(null),se=wa(),pe=wa(),ae=$e(()=>{pe.clear(),S.current.insideReactTree=!1}),W=$e(H=>{var re;const te=(re=S.current.floatingContext)==null?void 0:re.nodeId;return(E?Ms(E.nodesRef.current,te):[]).some(ee=>{var ge;return((ge=ee.context)==null?void 0:ge.open)&&!ee.context.dataRef.current[H]})}),le=$e(H=>jd(H,p.select("floatingElement"))||jd(H,p.select("domReferenceElement"))),ie=$e(H=>{d()&&p.setOpen(!1,Xt(Uo,H.nativeEvent))}),N=$e(H=>{if(!y||!r||!o||H.key!=="Escape"||B.current||!A&&W("__escapeKeyBubbles"))return;const te=EO(H)?H.nativeEvent:H,ne=Xt(F0,te);p.setOpen(!1,ne),ne.isCanceled||H.preventDefault(),!A&&!ne.isPropagationAllowed&&H.stopPropagation()}),Q=$e(()=>{S.current.insideReactTree=!0,pe.start(0,ae)}),I=$e(H=>{if(!y||!r||H.button!==0)return;const te=$n(H.nativeEvent);Me(p.select("floatingElement"),te)&&(k.current||(k.current=!0,q.current=!1))}),oe=$e(H=>{!y||!r||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&k.current&&(q.current=!0)});w.useEffect(()=>{if(!y||!r)return;S.current.__escapeKeyBubbles=A,S.current.__outsidePressBubbles=j;const H=new ei,te=new ei;function ne(){H.clear(),B.current=!0}function re(){H.start(_a?5:0,()=>{B.current=!1})}function ee(){F.current=!0,te.start(0,()=>{F.current=!1})}function ge(){k.current=!1,q.current=!1}function ce(){const ue=L.current,xe=ue==="pen"||!ue?"mouse":ue,ht=D(),Be=typeof ht=="function"?ht():ht;return typeof Be=="string"?Be:Be[xe]}function fe(ue){const xe=ce();return xe==="intentional"&&ue.type!=="click"||xe==="sloppy"&&ue.type==="click"}function Ze(ue){var Be;const xe=(Be=S.current.floatingContext)==null?void 0:Be.nodeId,ht=E&&Ms(E.nodesRef.current,xe).some(pt=>{var jt;return jd(ue,(jt=pt.context)==null?void 0:jt.elements.floating)});return le(ue)||ht}function nt(ue){if(fe(ue)){ue.type!=="click"&&!le(ue)&&(te.clear(),F.current=!1),ae();return}if(S.current.insideReactTree){ae();return}const xe=$n(ue),ht=`[${Kc("inert")}]`,Be=Je(xe)?xe.getRootNode():null,pt=Array.from((Ta(Be)?Be:ut(p.select("floatingElement"))).querySelectorAll(ht)),jt=p.context.triggerElements;if(xe&&(jt.hasElement(xe)||jt.hasMatchingElement(rn=>Me(rn,xe))))return;let sn=Je(xe)?xe:null;for(;sn&&!As(sn);){const rn=_s(sn);if(As(rn)||!Je(rn))break;sn=rn}if(!(pt.length&&Je(xe)&&!OO(xe)&&!Me(xe,p.select("floatingElement"))&&pt.every(rn=>!Me(sn,rn)))){if(Rt(xe)&&!("touches"in ue)){const rn=As(xe),ti=zn(xe),fn=/auto|scroll/,qt=rn||fn.test(ti.overflowX),Tn=rn||fn.test(ti.overflowY),Yt=qt&&xe.clientWidth>0&&xe.scrollWidth>xe.clientWidth,gr=Tn&&xe.clientHeight>0&&xe.scrollHeight>xe.clientHeight,yr=ti.direction==="rtl",br=gr&&(yr?ue.offsetX<=xe.offsetWidth-xe.clientWidth:ue.offsetX>xe.clientWidth),pi=Yt&&ue.offsetY>xe.clientHeight;if(br||pi)return}if(!Ze(ue)){if(ce()==="intentional"&&F.current){te.clear(),F.current=!1;return}typeof R=="function"&&!R(ue)||W("__outsidePressBubbles")||(p.setOpen(!1,Xt(X0,ue)),ae())}}}function ve(ue){ce()!=="sloppy"||ue.pointerType==="touch"||!p.select("open")||!r||le(ue)||nt(ue)}function ze(ue){if(ce()!=="sloppy"||!p.select("open")||!r||le(ue))return;const xe=ue.touches[0];xe&&(K.current={startTime:Date.now(),startX:xe.clientX,startY:xe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},se.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function Oe(ue,xe){const ht=$n(ue);if(!ht)return;const Be=Ke(ht,ue.type,()=>{xe(ue),Be()})}function ft(ue){L.current="touch",Oe(ue,ze)}function vt(ue){se.clear(),ue.type==="pointerdown"&&(L.current=ue.pointerType),!(ue.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&Oe(ue,xe=>{xe.type==="pointerdown"?ve(xe):nt(xe)})}function Re(ue){if(!k.current)return;const xe=q.current;if(ge(),ce()==="intentional"){if(ue.type==="pointercancel"){xe&&ee();return}if(!Ze(ue)){if(xe){ee();return}typeof R=="function"&&!R(ue)||(te.clear(),F.current=!0,ae())}}}function ke(ue){if(ce()!=="sloppy"||!K.current||le(ue))return;const xe=ue.touches[0];if(!xe)return;const ht=Math.abs(xe.clientX-K.current.startX),Be=Math.abs(xe.clientY-K.current.startY),pt=Math.sqrt(ht*ht+Be*Be);pt>5&&(K.current.dismissOnTouchEnd=!0),pt>10&&(nt(ue),se.clear(),K.current=null)}function Ee(ue){Oe(ue,ke)}function mt(ue){ce()!=="sloppy"||!K.current||le(ue)||(K.current.dismissOnTouchEnd&&nt(ue),se.clear(),K.current=null)}function dt(ue){Oe(ue,mt)}const je=ut(v),xt=qi(o&&qi(Ke(je,"keydown",N),Ke(je,"compositionstart",ne),Ke(je,"compositionend",re)),_&&qi(Ke(je,"click",vt,!0),Ke(je,"pointerdown",vt,!0),Ke(je,"pointerup",Re,!0),Ke(je,"pointercancel",Re,!0),Ke(je,"mousedown",vt,!0),Ke(je,"mouseup",Re,!0),Ke(je,"touchstart",ft,!0),Ke(je,"touchmove",Ee,!0),Ke(je,"touchend",dt,!0)));return()=>{xt(),H.clear(),te.clear(),ge(),F.current=!1}},[S,v,o,_,R,y,r,A,j,N,ae,D,W,le,E,p,se]),w.useEffect(ae,[R,ae]);const Y=w.useMemo(()=>({onKeyDown:N,onPointerDown:ie,onClick:ie}),[N,ie]),T=w.useMemo(()=>({onKeyDown:N,onPointerDown:oe,onMouseDown:oe,onClickCapture:Q,onMouseDownCapture(H){Q(),I(H)},onPointerDownCapture(H){Q(),I(H)},onMouseUpCapture:Q,onTouchEndCapture:Q,onTouchMoveCapture:Q}),[N,Q,I,oe]);return w.useMemo(()=>r?{reference:Y,floating:T,trigger:Y}:{},[r,Y,T])}function Ib(n,i,r){let{reference:o,floating:c}=n;const f=Fn(i),d=Kh(i),m=Fh(d),g=Dn(i),p=f==="y",y=o.x+o.width/2-c.width/2,v=o.y+o.height/2-c.height/2,S=o[m]/2-c[m]/2;let E;switch(g){case"top":E={x:y,y:o.y-c.height};break;case"bottom":E={x:y,y:o.y+o.height};break;case"right":E={x:o.x+o.width,y:v};break;case"left":E={x:o.x-c.width,y:v};break;default:E={x:o.x,y:o.y}}const x=zs(i);return x&&(E[d]+=S*(x==="end"?1:-1)*(r&&p?-1:1)),E}async function TC(n,i){var r;i===void 0&&(i={});const{x:o,y:c,platform:f,rects:d,elements:m,strategy:g}=n,{boundary:p="clippingAncestors",rootBoundary:y="viewport",elementContext:v="floating",altBoundary:S=!1,padding:E=0}=Gi(i,n),x=Z0(E),_=m[S?v==="floating"?"reference":"floating":v],D=Fc(await f.getClippingRect({element:(r=await(f.isElement==null?void 0:f.isElement(_)))==null||r?_:_.contextElement||await(f.getDocumentElement==null?void 0:f.getDocumentElement(m.floating)),boundary:p,rootBoundary:y,strategy:g})),A=v==="floating"?{x:o,y:c,width:d.floating.width,height:d.floating.height}:d.reference,j=await(f.getOffsetParent==null?void 0:f.getOffsetParent(m.floating)),k=await(f.isElement==null?void 0:f.isElement(j))&&await(f.getScale==null?void 0:f.getScale(j))||{x:1,y:1},q=Fc(f.convertOffsetParentRelativeRectToViewportRelativeRect?await f.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:A,offsetParent:j,strategy:g}):A);return{top:(D.top-q.top+x.top)/k.y,bottom:(q.bottom-D.bottom+x.bottom)/k.y,left:(D.left-q.left+x.left)/k.x,right:(q.right-D.right+x.right)/k.x}}const wC=50,RC=async(n,i,r)=>{const{placement:o="bottom",strategy:c="absolute",middleware:f=[],platform:d}=r,m=d.detectOverflow?d:{...d,detectOverflow:TC},g=await(d.isRTL==null?void 0:d.isRTL(i));let p=await d.getElementRects({reference:n,floating:i,strategy:c}),{x:y,y:v}=Ib(p,o,g),S=o,E=0;const x={};for(let R=0;R<f.length;R++){const _=f[R];if(!_)continue;const{name:D,fn:A}=_,{x:j,y:k,data:q,reset:F}=await A({x:y,y:v,initialPlacement:o,placement:S,strategy:c,middlewareData:x,rects:p,platform:m,elements:{reference:n,floating:i}});y=j??y,v=k??v,x[D]={...x[D],...q},F&&E<wC&&(E++,typeof F=="object"&&(F.placement&&(S=F.placement),F.rects&&(p=F.rects===!0?await d.getElementRects({reference:n,floating:i,strategy:c}):F.rects),{x:y,y:v}=Ib(p,S,g)),R=-1)}return{x:y,y:v,placement:S,strategy:c,middlewareData:x}},OC=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(i){var r,o;const{placement:c,middlewareData:f,rects:d,initialPlacement:m,platform:g,elements:p}=i,{mainAxis:y=!0,crossAxis:v=!0,fallbackPlacements:S,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:R=!0,..._}=Gi(n,i);if((r=f.arrow)!=null&&r.alignmentOffset)return{};const D=Dn(c),A=Fn(m),j=Dn(m)===m,k=await(g.isRTL==null?void 0:g.isRTL(p.floating)),q=S||(j||!R?[Xc(m)]:qO(m)),F=x!=="none";!S&&F&&q.push(...QO(m,R,x,k));const B=[m,...q],L=await g.detectOverflow(i,_),K=[];let se=((o=f.flip)==null?void 0:o.overflows)||[];if(y&&K.push(L[D]),v){const le=HO(c,d,k);K.push(L[le[0]],L[le[1]])}if(se=[...se,{placement:c,overflows:K}],!K.every(le=>le<=0)){var pe,ae;const le=(((pe=f.flip)==null?void 0:pe.index)||0)+1,ie=B[le];if(ie&&(!(v==="alignment"?A!==Fn(ie):!1)||se.every(I=>Fn(I.placement)===A?I.overflows[0]>0:!0)))return{data:{index:le,overflows:se},reset:{placement:ie}};let N=(ae=se.filter(Q=>Q.overflows[0]<=0).sort((Q,I)=>Q.overflows[1]-I.overflows[1])[0])==null?void 0:ae.placement;if(!N)switch(E){case"bestFit":{var W;const Q=(W=se.filter(I=>{if(F){const oe=Fn(I.placement);return oe===A||oe==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(oe=>oe>0).reduce((oe,Y)=>oe+Y,0)]).sort((I,oe)=>I[1]-oe[1])[0])==null?void 0:W[0];Q&&(N=Q);break}case"initialPlacement":N=m;break}if(c!==N)return{reset:{placement:N}}}return{}}}};function Jb(n,i){return{top:n.top-i.height,right:n.right-i.width,bottom:n.bottom-i.height,left:n.left-i.width}}function Wb(n){return UO.some(i=>n[i]>=0)}const CC=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(i){const{rects:r,platform:o}=i,{strategy:c="referenceHidden",...f}=Gi(n,i);switch(c){case"referenceHidden":{const d=await o.detectOverflow(i,{...f,elementContext:"reference"}),m=Jb(d,r.reference);return{data:{referenceHiddenOffsets:m,referenceHidden:Wb(m)}}}case"escaped":{const d=await o.detectOverflow(i,{...f,altBoundary:!0}),m=Jb(d,r.floating);return{data:{escapedOffsets:m,escaped:Wb(m)}}}default:return{}}}}},hS=new Set(["left","top"]);async function AC(n,i){const{placement:r,platform:o,elements:c}=n,f=await(o.isRTL==null?void 0:o.isRTL(c.floating)),d=Dn(r),m=zs(r),g=Fn(r)==="y",p=hS.has(d)?-1:1,y=f&&g?-1:1,v=Gi(i,n);let{mainAxis:S,crossAxis:E,alignmentAxis:x}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return m&&typeof x=="number"&&(E=m==="end"?x*-1:x),g?{x:E*y,y:S*p}:{x:S*p,y:E*y}}const _C=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(i){var r,o;const{x:c,y:f,placement:d,middlewareData:m}=i,g=await AC(i,n);return d===((r=m.offset)==null?void 0:r.placement)&&(o=m.arrow)!=null&&o.alignmentOffset?{}:{x:c+g.x,y:f+g.y,data:{...g,placement:d}}}}},MC=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(i){const{x:r,y:o,placement:c,platform:f}=i,{mainAxis:d=!0,crossAxis:m=!1,limiter:g={fn:A=>{let{x:j,y:k}=A;return{x:j,y:k}}},...p}=Gi(n,i),y={x:r,y:o},v=await f.detectOverflow(i,p),S=Fn(c),E=Xh(S);let x=y[E],R=y[S];const _=(A,j)=>K0(j+v[A==="y"?"top":"left"],j,j-v[A==="y"?"bottom":"right"]);d&&(x=_(E,x)),m&&(R=_(S,R));const D=g.fn({...i,[E]:x,[S]:R});return{...D,data:{x:D.x-r,y:D.y-o,enabled:{[E]:d,[S]:m}}}}}},NC=function(n){return n===void 0&&(n={}),{options:n,fn(i){var r,o;const{x:c,y:f,placement:d,rects:m,middlewareData:g}=i,{offset:p=0,mainAxis:y=!0,crossAxis:v=!0}=Gi(n,i),S={x:c,y:f},E=Fn(d),x=Xh(E);let R=S[x],_=S[E];const D=Gi(p,i),A=typeof D=="number"?{mainAxis:D,crossAxis:0}:{mainAxis:(r=D.mainAxis)!=null?r:0,crossAxis:(o=D.crossAxis)!=null?o:0};if(y){const q=x==="y"?"height":"width",F=m.reference[x]-m.floating[q]+A.mainAxis,B=m.reference[x]+m.reference[q]-A.mainAxis;R<F?R=F:R>B&&(R=B)}if(v){var j,k;const q=x==="y"?"width":"height",F=hS.has(Dn(d)),B=m.reference[E]-m.floating[q]+(F&&((j=g.offset)==null?void 0:j[E])||0)+(F?0:A.crossAxis),L=m.reference[E]+m.reference[q]+(F?0:((k=g.offset)==null?void 0:k[E])||0)-(F?A.crossAxis:0);_<B?_=B:_>L&&(_=L)}return{[x]:R,[E]:_}}}},DC=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(i){const{placement:r,rects:o,platform:c,elements:f}=i,{apply:d=()=>{},...m}=Gi(n,i),g=await c.detectOverflow(i,m),p=Dn(r),y=zs(r),v=Fn(r)==="y",{width:S,height:E}=o.floating;let x,R;p==="top"||p==="bottom"?(x=p,R=y===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(R=p,x=y==="end"?"top":"bottom");const _=E-g.top-g.bottom,D=S-g.left-g.right,A=Oa(E-g[x],_),j=Oa(S-g[R],D),k=i.middlewareData.shift,q=!k;let F=A,B=j;k!=null&&k.enabled.x&&(B=D),k!=null&&k.enabled.y&&(F=_),q&&!y&&(v?B=S-2*Yi(g.left,g.right):F=E-2*Yi(g.top,g.bottom)),await d({...i,availableWidth:B,availableHeight:F});const L=await c.getDimensions(f.floating);return S!==L.width||E!==L.height?{reset:{rects:!0}}:{}}}};function mS(n){const i=zn(n);let r=parseFloat(i.width)||0,o=parseFloat(i.height)||0;const c=Rt(n),f=c?n.offsetWidth:r,d=c?n.offsetHeight:o,m=Qc(r)!==f||Qc(o)!==d;return m&&(r=f,o=d),{width:r,height:o,$:m}}function Jh(n){return Je(n)?n:n.contextElement}function la(n){const i=Jh(n);if(!Rt(i))return Vi(1);const r=i.getBoundingClientRect(),{width:o,height:c,$:f}=mS(i);let d=(f?Qc(r.width):r.width)/o,m=(f?Qc(r.height):r.height)/c;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const zC=Vi(0);function pS(n){const i=kt(n);return!qh()||!i.visualViewport?zC:{x:i.visualViewport.offsetLeft,y:i.visualViewport.offsetTop}}function kC(n,i,r){return i===void 0&&(i=!1),!!r&&i&&r===kt(n)}function ur(n,i,r,o){i===void 0&&(i=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),f=Jh(n);let d=Vi(1);i&&(o?Je(o)&&(d=la(o)):d=la(n));const m=kC(f,r,o)?pS(f):Vi(0);let g=(c.left+m.x)/d.x,p=(c.top+m.y)/d.y,y=c.width/d.x,v=c.height/d.y;if(f&&o){const S=kt(f),E=Je(o)?kt(o):o;let x=S,R=fh(x);for(;R&&E!==x;){const _=la(R),D=R.getBoundingClientRect(),A=zn(R),j=D.left+(R.clientLeft+parseFloat(A.paddingLeft))*_.x,k=D.top+(R.clientTop+parseFloat(A.paddingTop))*_.y;g*=_.x,p*=_.y,y*=_.x,v*=_.y,g+=j,p+=k,x=kt(R),R=fh(x)}}return Fc({width:y,height:v,x:g,y:p})}function au(n,i){const r=iu(n).scrollLeft;return i?i.left+r:ur(Xi(n)).left+r}function gS(n,i){const r=n.getBoundingClientRect(),o=r.left+i.scrollLeft-au(n,r),c=r.top+i.scrollTop;return{x:o,y:c}}function jC(n){let{elements:i,rect:r,offsetParent:o,strategy:c}=n;const f=c==="fixed",d=Xi(o),m=i?nu(i.floating):!1;if(o===d||m&&f)return r;let g={scrollLeft:0,scrollTop:0},p=Vi(1);const y=Vi(0),v=Rt(o);if((v||!f)&&(($t(o)!=="body"||pr(d))&&(g=iu(o)),v)){const E=ur(o);p=la(o),y.x=E.x+o.clientLeft,y.y=E.y+o.clientTop}const S=d&&!v&&!f?gS(d,g):Vi(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-g.scrollLeft*p.x+y.x+S.x,y:r.y*p.y-g.scrollTop*p.y+y.y+S.y}}function LC(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function UC(n){const i=iu(n),r=n.ownerDocument.body,o=Yi(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=Yi(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let f=-i.scrollLeft+au(n);const d=-i.scrollTop;return zn(r).direction==="rtl"&&(f+=Yi(n.clientWidth,r.clientWidth)-o),{width:o,height:c,x:f,y:d}}const BC=25;function HC(n,i,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",c=kt(n),f=Xi(n),d=c.visualViewport;let m=f.clientWidth,g=f.clientHeight,p=0,y=0;if(d){const S=!qh()||i==="fixed";o?S||(p=-d.offsetLeft,y=-d.offsetTop):(m=d.width,g=d.height,S&&(p=d.offsetLeft,y=d.offsetTop))}if(au(f)<=0){const S=f.ownerDocument,E=S.body,x=getComputedStyle(E),R=S.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,_=Math.abs(f.clientWidth-E.clientWidth-R),D=getComputedStyle(f).scrollbarGutter==="stable both-edges"?_/2:_;D<=BC&&(m-=D)}return{width:m,height:g,x:p,y}}function qC(n,i){const r=ur(n,!0,i==="fixed"),o=r.top+n.clientTop,c=r.left+n.clientLeft,f=la(n),d=n.clientWidth*f.x,m=n.clientHeight*f.y,g=c*f.x,p=o*f.y;return{width:d,height:m,x:g,y:p}}function $b(n,i,r){let o;if(i==="viewport"||i==="layoutViewport")o=HC(n,r,i);else if(i==="document")o=UC(Xi(n));else if(Je(i))o=qC(i,r);else{const c=pS(n);o={x:i.x-c.x,y:i.y-c.y,width:i.width,height:i.height}}return Fc(o)}function YC(n,i){const r=i.get(n);if(r)return r;let o=ko(n,[],!1).filter(m=>Je(m)&&$t(m)!=="body"),c=null;const f=zn(n).position==="fixed";let d=f?_s(n):n;for(;Je(d)&&!As(d);){const m=zn(d),g=Hh(d),p=c?c.position:f?"fixed":"";!g&&(p==="fixed"||p==="absolute"&&m.position==="static")?o=o.filter(v=>v!==d):c=m,d=_s(d)}return i.set(n,o),o}function VC(n){let{element:i,boundary:r,rootBoundary:o,strategy:c}=n;const d=[...r==="clippingAncestors"?nu(i)?[]:YC(i,this._c):[].concat(r),o],m=$b(i,d[0],c);let g=m.top,p=m.right,y=m.bottom,v=m.left;for(let S=1;S<d.length;S++){const E=$b(i,d[S],c);g=Yi(E.top,g),p=Oa(E.right,p),y=Oa(E.bottom,y),v=Yi(E.left,v)}return{width:p-v,height:y-g,x:v,y:g}}function GC(n){const{width:i,height:r}=mS(n);return{width:i,height:r}}function QC(n,i,r){const o=Rt(i),c=Xi(i),f=r==="fixed",d=ur(n,!0,f,i);let m={scrollLeft:0,scrollTop:0};const g=Vi(0);if((o||!f)&&(($t(i)!=="body"||pr(c))&&(m=iu(i)),o)){const S=ur(i,!0,f,i);g.x=S.x+i.clientLeft,g.y=S.y+i.clientTop}!o&&c&&(g.x=au(c));const p=c&&!o&&!f?gS(c,m):Vi(0),y=d.left+m.scrollLeft-g.x-p.x,v=d.top+m.scrollTop-g.y-p.y;return{x:y,y:v,width:d.width,height:d.height}}function qd(n){return zn(n).position==="static"}function ev(n,i){if(!Rt(n)||zn(n).position==="fixed")return null;if(i)return i(n);let r=n.offsetParent;return Xi(n)===r&&(r=r.ownerDocument.body),r}function yS(n,i){const r=kt(n);if(nu(n))return r;if(!Rt(n)){let c=_s(n);for(;c&&!As(c);){if(Je(c)&&!qd(c))return c;c=_s(c)}return r}let o=ev(n,i);for(;o&&FR(o)&&qd(o);)o=ev(o,i);return o&&As(o)&&qd(o)&&!Hh(o)?r:o||PR(n)||r}const XC=async function(n){const i=this.getOffsetParent||yS,r=this.getDimensions,o=await r(n.floating);return{reference:QC(n.reference,await i(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function FC(n){return zn(n).direction==="rtl"}const KC={convertOffsetParentRelativeRectToViewportRelativeRect:jC,getDocumentElement:Xi,getClippingRect:VC,getOffsetParent:yS,getElementRects:XC,getClientRects:LC,getDimensions:GC,getScale:la,isElement:Je,isRTL:FC};function bS(n,i){return n.x===i.x&&n.y===i.y&&n.width===i.width&&n.height===i.height}function ZC(n,i,r){let o=null,c;const f=Xi(n);function d(){var y;clearTimeout(c),(y=o)==null||y.disconnect(),o=null}function m(y,v){y===void 0&&(y=!1),v===void 0&&(v=1),d();const S=n.getBoundingClientRect(),{left:E,top:x,width:R,height:_}=S;if(y||i(),!R||!_)return;const D=Tc(x),A=Tc(f.clientWidth-(E+R)),j=Tc(f.clientHeight-(x+_)),k=Tc(E),F={rootMargin:-D+"px "+-A+"px "+-j+"px "+-k+"px",threshold:Yi(0,Oa(1,v))||1};let B=!0;function L(K){const se=K[0].intersectionRatio;if(!bS(S,n.getBoundingClientRect()))return m();if(se!==v){if(!B)return m();se?m(!1,se):c=setTimeout(()=>{m(!1,1e-7)},1e3)}B=!1}try{o=new IntersectionObserver(L,{...F,root:f.ownerDocument})}catch{o=new IntersectionObserver(L,F)}o.observe(n)}const g=kt(n),p=()=>m(r);return g.addEventListener("resize",p),m(!0),()=>{g.removeEventListener("resize",p),d()}}function tv(n,i,r,o){o===void 0&&(o={});const{ancestorScroll:c=!0,ancestorResize:f=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:g=!1}=o,p=Jh(n),y=c||f?[...p?ko(p):[],...i?ko(i):[]]:[];y.forEach(D=>{c&&D.addEventListener("scroll",r),f&&D.addEventListener("resize",r)});const v=p&&m?ZC(p,r,f):null;let S=-1,E=null;d&&(E=new ResizeObserver(D=>{let[A]=D;A&&A.target===p&&E&&i&&(E.unobserve(i),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var j;(j=E)==null||j.observe(i)})),r()}),p&&!g&&E.observe(p),i&&E.observe(i));let x,R=g?ur(n):null;g&&_();function _(){const D=ur(n);R&&!bS(R,D)&&r(),R=D,x=requestAnimationFrame(_)}return r(),()=>{var D;y.forEach(A=>{c&&A.removeEventListener("scroll",r),f&&A.removeEventListener("resize",r)}),v==null||v(),(D=E)==null||D.disconnect(),E=null,g&&cancelAnimationFrame(x)}}const PC=_C,IC=MC,JC=OC,WC=DC,$C=CC,eA=NC,tA=(n,i,r)=>{const o=new Map,c=r??{},f={...KC,...c.platform,_c:o};return RC(n,i,{...c,platform:f})};var nA=typeof document<"u",iA=function(){},jc=nA?w.useLayoutEffect:iA;function Zc(n,i){if(n===i)return!0;if(typeof n!=typeof i)return!1;if(typeof n=="function"&&n.toString()===i.toString())return!0;let r,o,c;if(n&&i&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==i.length)return!1;for(o=r;o--!==0;)if(!Zc(n[o],i[o]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(i).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(i,c[o]))return!1;for(o=r;o--!==0;){const f=c[o];if(!(f==="_owner"&&n.$$typeof)&&!Zc(n[f],i[f]))return!1}return!0}return n!==n&&i!==i}function vS(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function nv(n,i){const r=vS(n);return Math.round(i*r)/r}function Yd(n){const i=w.useRef(n);return jc(()=>{i.current=n}),i}function sA(n){n===void 0&&(n={});const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:c,elements:{reference:f,floating:d}={},transform:m=!0,whileElementsMounted:g,open:p}=n,[y,v]=w.useState({x:0,y:0,strategy:r,placement:i,middlewareData:{},isPositioned:!1}),[S,E]=w.useState(o);Zc(S,o)||E(o);const[x,R]=w.useState(null),[_,D]=w.useState(null),A=w.useCallback(I=>{I!==F.current&&(F.current=I,R(I))},[]),j=w.useCallback(I=>{I!==B.current&&(B.current=I,D(I))},[]),k=f||x,q=d||_,F=w.useRef(null),B=w.useRef(null),L=w.useRef(y),K=g!=null,se=Yd(g),pe=Yd(c),ae=Yd(p),W=w.useCallback(()=>{if(!F.current||!B.current)return;const I={placement:i,strategy:r,middleware:S};pe.current&&(I.platform=pe.current),tA(F.current,B.current,I).then(oe=>{const Y={...oe,isPositioned:ae.current!==!1};le.current&&!Zc(L.current,Y)&&(L.current=Y,Ns.flushSync(()=>{v(Y)}))})},[S,i,r,pe,ae]);jc(()=>{p===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,v(I=>({...I,isPositioned:!1})))},[p]);const le=w.useRef(!1);jc(()=>(le.current=!0,()=>{le.current=!1}),[]),jc(()=>{if(k&&(F.current=k),q&&(B.current=q),k&&q){if(se.current)return se.current(k,q,W);W()}},[k,q,W,se,K]);const ie=w.useMemo(()=>({reference:F,floating:B,setReference:A,setFloating:j}),[A,j]),N=w.useMemo(()=>({reference:k,floating:q}),[k,q]),Q=w.useMemo(()=>{const I={position:r,left:0,top:0};if(!N.floating)return I;const oe=nv(N.floating,y.x),Y=nv(N.floating,y.y);return m?{...I,transform:"translate("+oe+"px, "+Y+"px)",...vS(N.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:oe,top:Y}},[r,m,N.floating,y.x,y.y]);return w.useMemo(()=>({...y,update:W,refs:ie,elements:N,floatingStyles:Q}),[y,W,ie,N,Q])}const rA=(n,i)=>{const r=PC(n);return{name:r.name,fn:r.fn,options:[n,i]}},aA=(n,i)=>{const r=IC(n);return{name:r.name,fn:r.fn,options:[n,i]}},oA=(n,i)=>({fn:eA(n).fn,options:[n,i]}),lA=(n,i)=>{const r=JC(n);return{name:r.name,fn:r.fn,options:[n,i]}},cA=(n,i)=>{const r=WC(n);return{name:r.name,fn:r.fn,options:[n,i]}},uA=(n,i)=>{const r=$C(n);return{name:r.name,fn:r.fn,options:[n,i]}};function fA(n){const i=w.useRef(!0);i.current&&(i.current=!1,n())}const Ve=(n,i,r,o,c,f,...d)=>{if(d.length>0)throw new Error(fr(1));let m;if(n)m=n;else throw new Error("Missing arguments");return m};var Vd={exports:{}},Gd={};/**
104
+ */const Nw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],S0=hr("x",Nw);function Dw({status:n}){return C.jsxs("header",{className:"flex items-center justify-between border-b border-chatroom-border px-6 py-4",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(y0,{className:"size-5 text-chatroom-text-muted","aria-hidden":!0}),C.jsx("h1",{className:"text-sm font-semibold uppercase tracking-widest",children:"Chatroom Daemon"})]}),n]})}function zw({children:n}){return C.jsx("nav",{className:"flex gap-1 border-b border-chatroom-border px-6 py-2",children:n})}function Ob({active:n=!1,children:i,onClick:r}){return C.jsx("span",{className:n?"bg-chatroom-bg-secondary px-3 py-1.5 text-xs font-medium uppercase tracking-wide":"px-3 py-1.5 text-xs font-medium uppercase tracking-wide text-chatroom-text-muted",onClick:r,role:r?"button":void 0,children:i})}function Cb(n){return new URLSearchParams(n.startsWith("?")?n.slice(1):n).get("tab")==="event-stream"?"event-stream":"logs"}function kw(n){const i=new URLSearchParams(window.location.search);n.tab!==void 0&&(n.tab==="event-stream"?i.set("tab","event-stream"):i.delete("tab")),n.chatroomId!==void 0&&(n.chatroomId?i.set("chatroomId",n.chatroomId):i.delete("chatroomId"));const r=i.toString();window.history.replaceState(null,"",`${window.location.pathname}${r?`?${r}`:""}`)}function jw(){const[n,i]=w.useState(()=>Cb(window.location.search)),r=w.useCallback(o=>{i(o),kw({tab:o})},[]);return w.useEffect(()=>{const o=()=>i(Cb(window.location.search));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]),{activeTab:n,setActiveTab:r}}const mi=Object.create(null);mi.open="0";mi.close="1";mi.ping="2";mi.pong="3";mi.message="4";mi.upgrade="5";mi.noop="6";const Mc=Object.create(null);Object.keys(mi).forEach(n=>{Mc[mi[n]]=n});const ah={type:"error",data:"parser error"},x0=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",E0=typeof ArrayBuffer=="function",T0=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,zh=({type:n,data:i},r,o)=>x0&&i instanceof Blob?r?o(i):Ab(i,o):E0&&(i instanceof ArrayBuffer||T0(i))?r?o(i):Ab(new Blob([i]),o):o(mi[n]+(i||"")),Ab=(n,i)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];i("b"+(o||""))},r.readAsDataURL(n)};function _b(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let Ad;function Lw(n,i){if(x0&&n.data instanceof Blob)return n.data.arrayBuffer().then(_b).then(i);if(E0&&(n.data instanceof ArrayBuffer||T0(n.data)))return i(_b(n.data));zh(n,!1,r=>{Ad||(Ad=new TextEncoder),i(Ad.encode(r))})}const Mb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",No=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Mb.length;n++)No[Mb.charCodeAt(n)]=n;const Uw=n=>{let i=n.length*.75,r=n.length,o,c=0,f,d,m,g;n[n.length-1]==="="&&(i--,n[n.length-2]==="="&&i--);const p=new ArrayBuffer(i),y=new Uint8Array(p);for(o=0;o<r;o+=4)f=No[n.charCodeAt(o)],d=No[n.charCodeAt(o+1)],m=No[n.charCodeAt(o+2)],g=No[n.charCodeAt(o+3)],y[c++]=f<<2|d>>4,y[c++]=(d&15)<<4|m>>2,y[c++]=(m&3)<<6|g&63;return p},Bw=typeof ArrayBuffer=="function",kh=(n,i)=>{if(typeof n!="string")return{type:"message",data:w0(n,i)};const r=n.charAt(0);return r==="b"?{type:"message",data:Hw(n.substring(1),i)}:Mc[r]?n.length>1?{type:Mc[r],data:n.substring(1)}:{type:Mc[r]}:ah},Hw=(n,i)=>{if(Bw){const r=Uw(n);return w0(r,i)}else return{base64:!0,data:n}},w0=(n,i)=>{switch(i){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},R0="",qw=(n,i)=>{const r=n.length,o=new Array(r);let c=0;n.forEach((f,d)=>{zh(f,!1,m=>{o[d]=m,++c===r&&i(o.join(R0))})})},Yw=(n,i)=>{const r=n.split(R0),o=[];for(let c=0;c<r.length;c++){const f=kh(r[c],i);if(o.push(f),f.type==="error")break}return o};function Vw(){return new TransformStream({transform(n,i){Lw(n,r=>{const o=r.length;let c;if(o<126)c=new Uint8Array(1),new DataView(c.buffer).setUint8(0,o);else if(o<65536){c=new Uint8Array(3);const f=new DataView(c.buffer);f.setUint8(0,126),f.setUint16(1,o)}else{c=new Uint8Array(9);const f=new DataView(c.buffer);f.setUint8(0,127),f.setBigUint64(1,BigInt(o))}n.data&&typeof n.data!="string"&&(c[0]|=128),i.enqueue(c),i.enqueue(r)})}})}let _d;function vc(n){return n.reduce((i,r)=>i+r.length,0)}function Sc(n,i){if(n[0].length===i)return n.shift();const r=new Uint8Array(i);let o=0;for(let c=0;c<i;c++)r[c]=n[0][o++],o===n[0].length&&(n.shift(),o=0);return n.length&&o<n[0].length&&(n[0]=n[0].slice(o)),r}function Gw(n,i){_d||(_d=new TextDecoder);const r=[];let o=0,c=-1,f=!1;return new TransformStream({transform(d,m){for(r.push(d);;){if(o===0){if(vc(r)<1)break;const g=Sc(r,1);f=(g[0]&128)===128,c=g[0]&127,c<126?o=3:c===126?o=1:o=2}else if(o===1){if(vc(r)<2)break;const g=Sc(r,2);c=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),o=3}else if(o===2){if(vc(r)<8)break;const g=Sc(r,8),p=new DataView(g.buffer,g.byteOffset,g.length),y=p.getUint32(0);if(y>Math.pow(2,21)-1){m.enqueue(ah);break}c=y*Math.pow(2,32)+p.getUint32(4),o=3}else{if(vc(r)<c)break;const g=Sc(r,c);m.enqueue(kh(f?g:_d.decode(g),i)),o=0}if(c===0||c>n){m.enqueue(ah);break}}}})}const O0=4;function zt(n){if(n)return Qw(n)}function Qw(n){for(var i in zt.prototype)n[i]=zt.prototype[i];return n}zt.prototype.on=zt.prototype.addEventListener=function(n,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(i),this};zt.prototype.once=function(n,i){function r(){this.off(n,r),i.apply(this,arguments)}return r.fn=i,this.on(n,r),this};zt.prototype.off=zt.prototype.removeListener=zt.prototype.removeAllListeners=zt.prototype.removeEventListener=function(n,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+n];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,c=0;c<r.length;c++)if(o=r[c],o===i||o.fn===i){r.splice(c,1);break}return r.length===0&&delete this._callbacks["$"+n],this};zt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),r=this._callbacks["$"+n],o=1;o<arguments.length;o++)i[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,c=r.length;o<c;++o)r[o].apply(this,i)}return this};zt.prototype.emitReserved=zt.prototype.emit;zt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};zt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const $c=typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,r)=>r(i,0),Xn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Xw="arraybuffer";function C0(n,...i){return i.reduce((r,o)=>(n.hasOwnProperty(o)&&(r[o]=n[o]),r),{})}const Fw=Xn.setTimeout,Kw=Xn.clearTimeout;function eu(n,i){i.useNativeTimers?(n.setTimeoutFn=Fw.bind(Xn),n.clearTimeoutFn=Kw.bind(Xn)):(n.setTimeoutFn=Xn.setTimeout.bind(Xn),n.clearTimeoutFn=Xn.clearTimeout.bind(Xn))}const Zw=1.33;function Pw(n){return typeof n=="string"?Iw(n):Math.ceil((n.byteLength||n.size)*Zw)}function Iw(n){let i=0,r=0;for(let o=0,c=n.length;o<c;o++)i=n.charCodeAt(o),i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(o++,r+=4);return r}function A0(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Jw(n){let i="";for(let r in n)n.hasOwnProperty(r)&&(i.length&&(i+="&"),i+=encodeURIComponent(r)+"="+encodeURIComponent(n[r]));return i}function Ww(n){let i={},r=n.split("&");for(let o=0,c=r.length;o<c;o++){let f=r[o].split("=");i[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return i}class $w extends Error{constructor(i,r,o){super(i),this.description=r,this.context=o,this.type="TransportError"}}class jh extends zt{constructor(i){super(),this.writable=!1,eu(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,r,o){return super.emitReserved("error",new $w(i,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(i){this.readyState==="open"&&this.write(i)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(i){const r=kh(i,this.socket.binaryType);this.onPacket(r)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,r={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_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(i){const r=Jw(i);return r.length?"?"+r:""}}class eR extends jh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const r=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};Yw(i,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const i=()=>{this.write([{type:"close"}])};this.readyState==="open"?i():this.once("open",i)}write(i){this.writable=!1,qw(i,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=A0()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(i,r)}}let _0=!1;try{_0=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const tR=_0;function nR(){}class iR extends eR{constructor(i){if(super(i),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||o!==i.port}}doWrite(i,r){const o=this.request({method:"POST",data:i});o.on("success",r),o.on("error",(c,f)=>{this.onError("xhr post error",c,f)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=i}}class hi extends zt{constructor(i,r,o){super(),this.createRequest=i,eu(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var i;const r=C0(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let c in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(c)&&o.setRequestHeader(c,this._opts.extraHeaders[c])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var c;o.readyState===3&&((c=this._opts.cookieJar)===null||c===void 0||c.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(c){this.setTimeoutFn(()=>{this._onError(c)},0);return}typeof document<"u"&&(this._index=hi.requestsCount++,hi.requests[this._index]=this)}_onError(i){this.emitReserved("error",i,this._xhr),this._cleanup(!0)}_cleanup(i){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=nR,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete hi.requests[this._index],this._xhr=null}}_onLoad(){const i=this._xhr.responseText;i!==null&&(this.emitReserved("data",i),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}hi.requestsCount=0;hi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Nb);else if(typeof addEventListener=="function"){const n="onpagehide"in Xn?"pagehide":"unload";addEventListener(n,Nb,!1)}}function Nb(){for(let n in hi.requests)hi.requests.hasOwnProperty(n)&&hi.requests[n].abort()}const sR=function(){const n=M0({xdomain:!1});return n&&n.responseType!==null}();class rR extends iR{constructor(i){super(i);const r=i&&i.forceBase64;this.supportsBinary=sR&&!r}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new hi(M0,this.uri(),i)}}function M0(n){const i=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||tR))return new XMLHttpRequest}catch{}if(!i)try{return new Xn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const N0=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class aR extends jh{get name(){return"websocket"}doOpen(){const i=this.uri(),r=this.opts.protocols,o=N0?{}:C0(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,r,o)}catch(c){return this.emitReserved("error",c)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=i=>this.onClose({description:"websocket connection closed",context:i}),this.ws.onmessage=i=>this.onData(i.data),this.ws.onerror=i=>this.onError("websocket error",i)}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;zh(o,this.supportsBinary,f=>{try{this.doWrite(o,f)}catch{}c&&$c(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const i=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=A0()),this.supportsBinary||(r.b64=1),this.createUri(i,r)}}const Md=Xn.WebSocket||Xn.MozWebSocket;class oR extends aR{createSocket(i,r,o){return N0?new Md(i,r,o):r?new Md(i,r):new Md(i)}doWrite(i,r){this.ws.send(r)}}class lR extends jh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(i){return this.emitReserved("error",i)}this._transport.closed.then(()=>{this.onClose()}).catch(i=>{this.onError("webtransport error",i)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(i=>{const r=Gw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=i.readable.pipeThrough(r).getReader(),c=Vw();c.readable.pipeTo(i.writable),this._writer=c.writable.getWriter();const f=()=>{o.read().then(({done:m,value:g})=>{m||(this.onPacket(g),f())}).catch(m=>{})};f();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let r=0;r<i.length;r++){const o=i[r],c=r===i.length-1;this._writer.write(o).then(()=>{c&&$c(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const cR={websocket:oR,webtransport:lR,polling:rR},uR=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,fR=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function oh(n){if(n.length>8e3)throw"URI too long";const i=n,r=n.indexOf("["),o=n.indexOf("]");r!=-1&&o!=-1&&(n=n.substring(0,r)+n.substring(r,o).replace(/:/g,";")+n.substring(o,n.length));let c=uR.exec(n||""),f={},d=14;for(;d--;)f[fR[d]]=c[d]||"";return r!=-1&&o!=-1&&(f.source=i,f.host=f.host.substring(1,f.host.length-1).replace(/;/g,":"),f.authority=f.authority.replace("[","").replace("]","").replace(/;/g,":"),f.ipv6uri=!0),f.pathNames=dR(f,f.path),f.queryKey=hR(f,f.query),f}function dR(n,i){const r=/\/{2,9}/g,o=i.replace(r,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&o.splice(0,1),i.slice(-1)=="/"&&o.splice(o.length-1,1),o}function hR(n,i){const r={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,c,f){c&&(r[c]=f)}),r}const lh=typeof addEventListener=="function"&&typeof removeEventListener=="function",Nc=[];lh&&addEventListener("offline",()=>{Nc.forEach(n=>n())},!1);class Cs extends zt{constructor(i,r){if(super(),this.binaryType=Xw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(r=i,i=null),i){const o=oh(i);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=oh(r.host).host);eu(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(o=>{const c=o.prototype.name;this.transports.push(c),this._transportsByName[c]=o}),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=Ww(this.opts.query)),lh&&(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"})},Nc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const r=Object.assign({},this.opts.query);r.EIO=O0,r.transport=i,this.id&&(r.sid=this.id);const o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Cs.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(i);r.open(),this.setTransport(r)}setTransport(i){this.transport&&this.transport.removeAllListeners(),this.transport=i,i.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",Cs.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",i),this.emitReserved("heartbeat"),i.type){case"open":this.onHandshake(JSON.parse(i.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=i.data,this._onError(r);break;case"message":this.emitReserved("data",i.data),this.emitReserved("message",i.data);break}}onHandshake(i){this.emitReserved("handshake",i),this.id=i.sid,this.transport.query.sid=i.sid,this._pingInterval=i.pingInterval,this._pingTimeout=i.pingTimeout,this._maxPayload=i.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const i=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+i,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},i),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 i=this._getWritablePackets();this.transport.send(i),this._prevBufferLen=i.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const c=this.writeBuffer[o].data;if(c&&(r+=Pw(c)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,$c(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,r,o){return this._sendPacket("message",i,r,o),this}send(i,r,o){return this._sendPacket("message",i,r,o),this}_sendPacket(i,r,o,c){if(typeof r=="function"&&(c=r,r=void 0),typeof o=="function"&&(c=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const f={type:i,data:r,options:o};this.emitReserved("packetCreate",f),this.writeBuffer.push(f),c&&this.once("flush",c),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),i()},o=()=>{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?o():i()}):this.upgrading?o():i()),this}_onError(i){if(Cs.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",i),this._onClose("transport error",i)}_onClose(i,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(),lh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Nc.indexOf(this._offlineEventListener);o!==-1&&Nc.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,r),this.writeBuffer=[],this._prevBufferLen=0}}}Cs.protocol=O0;class mR extends Cs{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let i=0;i<this._upgrades.length;i++)this._probe(this._upgrades[i])}_probe(i){let r=this.createTransport(i),o=!1;Cs.priorWebsocketSuccess=!1;const c=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Cs.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(y(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=r.name,this.emitReserved("upgradeError",S)}}))};function f(){o||(o=!0,y(),r.close(),r=null)}const d=v=>{const S=new Error("probe error: "+v);S.transport=r.name,f(),this.emitReserved("upgradeError",S)};function m(){d("transport closed")}function g(){d("socket closed")}function p(v){r&&v.name!==r.name&&f()}const y=()=>{r.removeListener("open",c),r.removeListener("error",d),r.removeListener("close",m),this.off("close",g),this.off("upgrading",p)};r.once("open",c),r.once("error",d),r.once("close",m),this.once("close",g),this.once("upgrading",p),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const r=[];for(let o=0;o<i.length;o++)~this.transports.indexOf(i[o])&&r.push(i[o]);return r}}let pR=class extends mR{constructor(i,r={}){const o=typeof i=="object",c=o?{...i}:{...r};(!c.transports||c.transports&&typeof c.transports[0]=="string")&&(c.transports=(c.transports||["polling","websocket","webtransport"]).map(f=>cR[f]).filter(f=>!!f)),super(o?c:i,c)}};function gR(n,i="",r){let o=n;r=r||typeof location<"u"&&location,n==null&&(n=r.protocol+"//"+r.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=r.protocol+n:n=r.host+n),/^(https?|wss?):\/\//.test(n)||(typeof r<"u"?n=r.protocol+"//"+n:n="https://"+n),o=oh(n)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const f=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+f+":"+o.port+i,o.href=o.protocol+"://"+f+(r&&r.port===o.port?"":":"+o.port),o}const yR=typeof ArrayBuffer=="function",bR=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,D0=Object.prototype.toString,vR=typeof Blob=="function"||typeof Blob<"u"&&D0.call(Blob)==="[object BlobConstructor]",SR=typeof File=="function"||typeof File<"u"&&D0.call(File)==="[object FileConstructor]";function Lh(n){return yR&&(n instanceof ArrayBuffer||bR(n))||vR&&n instanceof Blob||SR&&n instanceof File}function Dc(n,i){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let r=0,o=n.length;r<o;r++)if(Dc(n[r]))return!0;return!1}if(Lh(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Dc(n.toJSON(),!0);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&Dc(n[r]))return!0;return!1}function xR(n){const i=[],r=n.data,o=n;return o.data=zc(r,i),o.attachments=i.length,{packet:o,buffers:i}}function zc(n,i,r){if(!n)return n;if(Lh(n)){const o={_placeholder:!0,num:i.length};return i.push(n),o}else if(Array.isArray(n)){const o=new Array(n.length);for(let c=0;c<n.length;c++)o[c]=zc(n[c],i);return o}else if(typeof n=="object"&&!(n instanceof Date)){if(n.toJSON&&typeof n.toJSON=="function"&&!r)return zc(n.toJSON(),i,!0);const o={};for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(o[c]=zc(n[c],i));return o}return n}function ER(n,i){return n.data=ch(n.data,i),delete n.attachments,n}function ch(n,i){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<i.length)return i[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let r=0;r<n.length;r++)n[r]=ch(n[r],i);else if(typeof n=="object")for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=ch(n[r],i));return n}const z0=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],TR=5;var Ne;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ne||(Ne={}));class wR{constructor(i){this.replacer=i}encode(i){return(i.type===Ne.EVENT||i.type===Ne.ACK)&&Dc(i)?this.encodeAsBinary({type:i.type===Ne.EVENT?Ne.BINARY_EVENT:Ne.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let r=""+i.type;return(i.type===Ne.BINARY_EVENT||i.type===Ne.BINARY_ACK)&&(r+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(r+=i.nsp+","),i.id!=null&&(r+=i.id),i.data!=null&&(r+=JSON.stringify(i.data,this.replacer)),r}encodeAsBinary(i){const r=xR(i),o=this.encodeAsString(r.packet),c=r.buffers;return c.unshift(o),c}}class Uh extends zt{constructor(i){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof i=="function"?{reviver:i}:i)}add(i){let r;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(i);const o=r.type===Ne.BINARY_EVENT;o||r.type===Ne.BINARY_ACK?(r.type=o?Ne.EVENT:Ne.ACK,this.reconstructor=new RR(r)):super.emitReserved("decoded",r)}else if(Lh(i)||i.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(i),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: "+i)}decodeString(i){let r=0;const o={type:Number(i.charAt(0))};if(Ne[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Ne.BINARY_EVENT||o.type===Ne.BINARY_ACK){const f=r+1;for(;i.charAt(++r)!=="-"&&r!=i.length;);const d=i.substring(f,r);if(d!=Number(d)||i.charAt(r)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!k0(m)||m<1)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");o.attachments=m}if(i.charAt(r+1)==="/"){const f=r+1;for(;++r&&!(i.charAt(r)===","||r===i.length););o.nsp=i.substring(f,r)}else o.nsp="/";const c=i.charAt(r+1);if(c!==""&&Number(c)==c){const f=r+1;for(;++r;){const d=i.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===i.length)break}o.id=Number(i.substring(f,r+1))}if(i.charAt(++r)){const f=this.tryParse(i.substr(r));if(Uh.isPayloadValid(o.type,f))o.data=f;else throw new Error("invalid payload")}return o}tryParse(i){try{return JSON.parse(i,this.opts.reviver)}catch{return!1}}static isPayloadValid(i,r){switch(i){case Ne.CONNECT:return Vc(r);case Ne.DISCONNECT:return r===void 0;case Ne.CONNECT_ERROR:return typeof r=="string"||Vc(r);case Ne.EVENT:case Ne.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&z0.indexOf(r[0])===-1);case Ne.ACK:case Ne.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class RR{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const r=ER(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function OR(n){return typeof n=="string"}const k0=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function CR(n){return n===void 0||k0(n)}function Vc(n){return Object.prototype.toString.call(n)==="[object Object]"}function AR(n,i){switch(n){case Ne.CONNECT:return i===void 0||Vc(i);case Ne.DISCONNECT:return i===void 0;case Ne.EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&z0.indexOf(i[0])===-1);case Ne.ACK:return Array.isArray(i);case Ne.CONNECT_ERROR:return typeof i=="string"||Vc(i);default:return!1}}function _R(n){return OR(n.nsp)&&CR(n.id)&&AR(n.type,n.data)}const MR=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Uh,Encoder:wR,get PacketType(){return Ne},isPacketValid:_R,protocol:TR},Symbol.toStringTag,{value:"Module"}));function Wn(n,i,r){return n.on(i,r),function(){n.off(i,r)}}const NR=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class j0 extends zt{constructor(i,r,o){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=i,this.nsp=r,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[Wn(i,"open",this.onopen.bind(this)),Wn(i,"packet",this.onpacket.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"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(...i){return i.unshift("message"),this.emit.apply(this,i),this}emit(i,...r){var o,c,f;if(NR.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(r.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:Ne.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const y=this.ids++,v=r.pop();this._registerAckCallback(y,v),d.id=y}const m=(c=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||c===void 0?void 0:c.writable,g=this.connected&&!(!((f=this.io.engine)===null||f===void 0)&&f._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(i,r){var o;const c=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(c===void 0){this.acks[i]=r;return}const f=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===i&&this.sendBuffer.splice(m,1);r.call(this,new Error("operation has timed out"))},c),d=(...m)=>{this.io.clearTimeoutFn(f),r.apply(this,m)};d.withError=!0,this.acks[i]=d}emitWithAck(i,...r){return new Promise((o,c)=>{const f=(d,m)=>d?c(d):o(m);f.withError=!0,r.push(f),this.emit(i,...r)})}_addToQueue(i){let r;typeof i[i.length-1]=="function"&&(r=i.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((c,...f)=>(this._queue[0],c!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(c)):(this._queue.shift(),r&&r(null,...f)),o.pending=!1,this._drainQueue())),this._queue.push(o),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!i||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(i){i.nsp=this.nsp,this.io._packet(i)}onopen(){typeof this.auth=="function"?this.auth(i=>{this._sendConnectPacket(i)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(i){this.packet({type:Ne.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},i):i})}onerror(i){this.connected||this.emitReserved("connect_error",i)}onclose(i,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(o=>String(o.id)===i)){const o=this.acks[i];delete this.acks[i],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case Ne.CONNECT:i.data&&i.data.sid?this.onconnect(i.data.sid,i.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 Ne.EVENT:case Ne.BINARY_EVENT:this.onevent(i);break;case Ne.ACK:case Ne.BINARY_ACK:this.onack(i);break;case Ne.DISCONNECT:this.ondisconnect();break;case Ne.CONNECT_ERROR:this.destroy();const o=new Error(i.data.message);o.data=i.data.data,this.emitReserved("connect_error",o);break}}onevent(i){const r=i.data||[];i.id!=null&&r.push(this.ack(i.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const o of r)o.apply(this,i)}super.emit.apply(this,i),this._pid&&i.length&&typeof i[i.length-1]=="string"&&(this._lastOffset=i[i.length-1])}ack(i){const r=this;let o=!1;return function(...c){o||(o=!0,r.packet({type:Ne.ACK,id:i,data:c}))}}onack(i){const r=this.acks[i.id];typeof r=="function"&&(delete this.acks[i.id],r.withError&&i.data.unshift(null),r.apply(this,i.data))}onconnect(i,r){this.id=i,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(i=>this.emitEvent(i)),this.receiveBuffer=[],this.sendBuffer.forEach(i=>{this.notifyOutgoingListeners(i),this.packet(i)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(i=>i()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ne.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(i){return this.flags.compress=i,this}get volatile(){return this.flags.volatile=!0,this}timeout(i){return this.flags.timeout=i,this}onAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(i),this}prependAny(i){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(i),this}offAny(i){if(!this._anyListeners)return this;if(i){const r=this._anyListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(i),this}prependAnyOutgoing(i){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(i),this}offAnyOutgoing(i){if(!this._anyOutgoingListeners)return this;if(i){const r=this._anyOutgoingListeners;for(let o=0;o<r.length;o++)if(i===r[o])return r.splice(o,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const o of r)o.apply(this,i.data)}}}function Aa(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Aa.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),r=Math.floor(i*this.jitter*n);n=(Math.floor(i*10)&1)==0?n-r:n+r}return Math.min(n,this.max)|0};Aa.prototype.reset=function(){this.attempts=0};Aa.prototype.setMin=function(n){this.ms=n};Aa.prototype.setMax=function(n){this.max=n};Aa.prototype.setJitter=function(n){this.jitter=n};class uh extends zt{constructor(i,r){var o;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(r=i,i=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,eu(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new Aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=i;const c=r.parser||MR;this.encoder=new c.Encoder,this.decoder=new c.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(i){return arguments.length?(this._reconnection=!!i,i||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(i){return i===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=i,this)}reconnectionDelay(i){var r;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(r=this.backoff)===null||r===void 0||r.setMin(i),this)}randomizationFactor(i){var r;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(r=this.backoff)===null||r===void 0||r.setJitter(i),this)}reconnectionDelayMax(i){var r;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(r=this.backoff)===null||r===void 0||r.setMax(i),this)}timeout(i){return arguments.length?(this._timeout=i,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(i){if(~this._readyState.indexOf("open"))return this;this.engine=new pR(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const c=Wn(r,"open",function(){o.onopen(),i&&i()}),f=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),i?i(m):this.maybeReconnectOnOpen()},d=Wn(r,"error",f);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{c(),f(new Error("timeout")),r.close()},m);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(c),this.subs.push(d),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(Wn(i,"ping",this.onping.bind(this)),Wn(i,"data",this.ondata.bind(this)),Wn(i,"error",this.onerror.bind(this)),Wn(i,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(r){this.onclose("parse error",r)}}ondecoded(i){$c(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,r){let o=this.nsps[i];return o?this._autoConnect&&!o.active&&o.connect():(o=new j0(this,i,r),this.nsps[i]=o),o}_destroy(i){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(i){const r=this.encoder.encode(i);for(let o=0;o<r.length;o++)this.engine.write(r[o],i.options)}cleanup(){this.subs.forEach(i=>i()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(i,r){var o;this.cleanup(),(o=this.engine)===null||o===void 0||o.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const i=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 o=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(c=>{c?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",c)):i.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Oo={};function kc(n,i){typeof n=="object"&&(i=n,n=void 0),i=i||{};const r=gR(n,i.path||"/socket.io"),o=r.source,c=r.id,f=r.path,d=Oo[c]&&f in Oo[c].nsps,m=i.forceNew||i["force new connection"]||i.multiplex===!1||d;let g;return m?g=new uh(o,i):(Oo[c]||(Oo[c]=new uh(o,i)),g=Oo[c]),r.query&&!i.query&&(i.query=r.queryKey),g.socket(r.path,i)}Object.assign(kc,{Manager:uh,Socket:j0,io:kc,connect:kc});let Nd=null;function mr(){return Nd||(Nd=kc({transports:["websocket"],autoConnect:!0})),Nd}async function DR(){const n=mr();return await Zo(n),n.emitWithAck("health.get")}async function Zo(n){n.connected||await new Promise((i,r)=>{const o=()=>{f(),i()},c=d=>{f(),r(d)},f=()=>{n.off("connect",o),n.off("connect_error",c)};n.on("connect",o),n.on("connect_error",c),n.connect()})}async function zR(n){const i=mr();return await Zo(i),i.emitWithAck("logs.history",n)}async function kR(n,i){const r=mr();return await Zo(r),r.emitWithAck("logs.dimensions",{chatroomId:n,limit:i})}async function jR(){const n=mr();return await Zo(n),n.emitWithAck("chatrooms.list")}async function LR(n){const i=mr();return await Zo(i),i.emitWithAck("eventStream.history",n??{})}function UR(n){const i=mr();return i.connect(),i.emit("eventStream.stream.subscribe"),i.on("eventStream.stream",n),()=>i.off("eventStream.stream",n)}function BR(n){const i=mr();return i.connect(),i.emit("logs.stream.subscribe"),i.on("logs.stream",n),()=>i.off("logs.stream",n)}function HR(){return Qv({queryKey:["daemon","health"],queryFn:async()=>{const n=await DR();if(!n.ok)throw new Error(n.error.message);return n.data},retry:2})}const qR={info:{badge:"bg-chatroom-status-info/15 text-chatroom-status-info"},success:{badge:"bg-chatroom-status-success/15 text-chatroom-status-success"},warning:{badge:"bg-chatroom-status-warning/15 text-chatroom-status-warning"},error:{badge:"bg-chatroom-status-error/15 text-chatroom-status-error"},muted:{badge:"bg-chatroom-text-muted/15 text-chatroom-text-muted"},purple:{badge:"bg-chatroom-status-purple/15 text-chatroom-status-purple"}};function YR(n){return qR[n]}const VR={"agent.started":["Agent Started","success"],"agent.exited":["Agent Exited","error"],"agent.circuitOpen":["Circuit Open","warning"],"agent.requestStart":["Agent Request Start","warning"],"agent.registered":["Agent Registered","success"],"agent.waiting":["Agent Waiting","success"],"agent.startFailed":["Agent Start Failed","error"],"agent.providerUnavailable":["Provider Unavailable","warning"],"agent.sessionResumeRequested":["Session Reconnect Requested","info"],"agent.sessionResumed":["Session Reconnected","success"],"agent.sessionResumeFailed":["Session Reconnect Failed","warning"],"agent.sessionReopenRetry":["Session Reopen Retry","info"],"agent.sessionCompacted":["Session Compacted","info"],"agent.sessionAugmented":["Session Augmented","info"],"agent.restart":["Agent Restarting","info"],"agent.restartCompleted":["Agent Restarted","success"],"agent.restartPhase":["Agent Restart Progress","info"],"agent.restartLimitReached":["Agent Restart Limit","error"],"agent.stopTimeout":["Agent Stop Timeout","warning"],"agent.harnessSessionIdUpdated":["Harness Session ID Updated","info"],"agent.awaitingHandoff":["Awaiting Handoff","warning"],"agent.taskDelivered":["Task Delivered","success"],"agent.taskDeliveryFailed":["Task Delivery Failed","error"],"machine.switched":["Machine Switched","info"],"connection.terminated":["Connection Terminated","muted"],"workflow.started":["Workflow Started","info"],"workflow.stepCompleted":["Workflow Step Completed","success"],"workflow.stepCancelled":["Workflow Step Cancelled","warning"],"workflow.completed":["Workflow Completed","success"],"workflow.created":["Workflow Created","info"],"workflow.specified":["Workflow Specified","info"],"workflow.stepStarted":["Workflow Step Started","info"],"task.activated":["Task Activated","success"],"task.acknowledged":["Task Acknowledged","success"],"task.inProgress":["Task In Progress","info"],"task.completed":["Task Completed","success"],"skill.activated":["Skill Activated","purple"],"daemon.ping":["Daemon Ping","muted"],"daemon.pong":["Daemon Pong","muted"],"daemon.gitRefresh":["Git Refresh","muted"],"daemon.refreshCapabilities":["Capabilities Refresh","muted"],"daemon.pickFolder":["Pick Folder","muted"],"daemon.localAction":["Local Action","muted"],"daemon.syncProjectRoots":["Project Roots Sync","muted"],"daemon.reportRepositoryLedger":["Repository Ledger Report","muted"],"config.requestRemoval":["Config Request Removal","warning"],"command.run":["Command Run","warning"],"command.stop":["Command Stop","error"]},GR=Object.fromEntries(Object.entries(VR).map(([n,[i,r]])=>[n,{label:i,classification:r}]));function QR(n){const i=n.toLowerCase();return i.includes("failed")||i.includes("error")||i.includes("timeout")?"error":n.startsWith("task.")?"success":n.startsWith("agent.")||n.startsWith("workflow.")?"info":n.startsWith("daemon.")?"muted":n.startsWith("command.")?"warning":n.startsWith("skill.")?"purple":"muted"}function XR(n){return GR[n]??{label:n,classification:QR(n)}}function L0({type:n,className:i}){const r=XR(n);return C.jsx("span",{className:un("shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider",YR(r.classification).badge,i),children:r.label})}function tu(){return typeof window<"u"}function $t(n){return Bh(n)?(n.nodeName||"").toLowerCase():"#document"}function kt(n){var i;return(n==null||(i=n.ownerDocument)==null?void 0:i.defaultView)||window}function Xi(n){var i;return(i=(Bh(n)?n.ownerDocument:n.document)||window.document)==null?void 0:i.documentElement}function Bh(n){return tu()?n instanceof Node||n instanceof kt(n).Node:!1}function Je(n){return tu()?n instanceof Element||n instanceof kt(n).Element:!1}function Rt(n){return tu()?n instanceof HTMLElement||n instanceof kt(n).HTMLElement:!1}function Ta(n){return!tu()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof kt(n).ShadowRoot}function pr(n){const{overflow:i,overflowX:r,overflowY:o,display:c}=zn(n);return/auto|scroll|overlay|hidden|clip/.test(i+o+r)&&c!=="inline"&&c!=="contents"}function FR(n){return/^(table|td|th)$/.test($t(n))}function nu(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const KR=/transform|translate|scale|rotate|perspective|filter/,ZR=/paint|layout|strict|content/,$s=n=>!!n&&n!=="none";let Dd;function Hh(n){const i=Je(n)?zn(n):n;return $s(i.transform)||$s(i.translate)||$s(i.scale)||$s(i.rotate)||$s(i.perspective)||!qh()&&($s(i.backdropFilter)||$s(i.filter))||KR.test(i.willChange||"")||ZR.test(i.contain||"")}function PR(n){let i=_s(n);for(;Rt(i)&&!As(i);){if(Hh(i))return i;if(nu(i))return null;i=_s(i)}return null}function qh(){return Dd==null&&(Dd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Dd}function As(n){return/^(html|body|#document)$/.test($t(n))}function zn(n){return kt(n).getComputedStyle(n)}function iu(n){return Je(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function _s(n){if($t(n)==="html")return n;const i=n.assignedSlot||n.parentNode||Ta(n)&&n.host||Xi(n);return Ta(i)?i.host:i}function U0(n){const i=_s(n);return As(i)?(n.ownerDocument||n).body:Rt(i)&&pr(i)?i:U0(i)}function ko(n,i,r){var o;i===void 0&&(i=[]),r===void 0&&(r=!0);const c=U0(n),f=c===((o=n.ownerDocument)==null?void 0:o.body),d=kt(c);if(f){const m=fh(d);return i.concat(d,d.visualViewport||[],pr(c)?c:[],m&&r?ko(m):[])}else return i.concat(c,ko(c,[],r))}function fh(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Yh={...m1},zd=Yh.useInsertionEffect,IR=zd&&zd!==Yh.useLayoutEffect?zd:n=>n();function $e(n){const i=Qi(JR).current;return i.next=n,IR(i.effect),i.trampoline}function JR(){const n={next:void 0,callback:WR,trampoline:(...i)=>{var r;return(r=n.callback)==null?void 0:r.call(n,...i)},effect:()=>{n.callback=n.next}};return n}function WR(){}const $R=()=>{},Xe=typeof document<"u"?w.useLayoutEffect:$R,eO=w.createContext(void 0);function tO(n=!1){const i=w.useContext(eO);if(i===void 0&&!n)throw new Error(fr(16));return i}function nO(n){const{focusableWhenDisabled:i,disabled:r,composite:o=!1,tabIndex:c=0,isNativeButton:f}=n,d=o&&i!==!1,m=o&&i===!1;return{props:w.useMemo(()=>{const p={onKeyDown(y){r&&i&&y.key!=="Tab"&&y.preventDefault()}};return o||(p.tabIndex=c,!f&&r&&(p.tabIndex=i?c:-1)),(f&&(i||d)||!f&&r)&&(p["aria-disabled"]=r),f&&(!i||m)&&(p.disabled=r),p},[o,r,i,d,m,f,c])}}function B0(n={}){const{disabled:i=!1,focusableWhenDisabled:r,tabIndex:o=0,native:c=!0,composite:f}=n,d=w.useRef(null),m=tO(!0),g=f??m!==void 0,{props:p}=nO({focusableWhenDisabled:r,disabled:i,composite:g,tabIndex:o,isNativeButton:c}),y=w.useCallback(()=>{const E=d.current;kd(E)&&g&&i&&p.disabled===void 0&&E.disabled&&(E.disabled=!1)},[i,p.disabled,g]);Xe(y,[y]);const v=w.useCallback((E={})=>{const{onClick:x,onMouseDown:R,onKeyUp:_,onKeyDown:D,onPointerDown:A,...j}=E;return Ko({onClick(k){if(i){k.preventDefault();return}x==null||x(k)},onMouseDown(k){i||R==null||R(k)},onKeyDown(k){if(i||(Hc(k),D==null||D(k),k.baseUIHandlerPrevented))return;const q=k.target===k.currentTarget,F=k.currentTarget,B=kd(F),L=!c&&iO(F),K=q&&(c?B:!L),se=k.key==="Enter",pe=k.key===" ",ae=F.getAttribute("role"),W=(ae==null?void 0:ae.startsWith("menuitem"))||ae==="option"||ae==="gridcell";if(q&&g&&pe){if(k.defaultPrevented&&W)return;k.preventDefault(),L||c&&B?(F.click(),k.preventBaseUIHandler()):K&&(x==null||x(k),k.preventBaseUIHandler());return}K&&(!c&&(pe||se)&&k.preventDefault(),!c&&se&&(x==null||x(k)))},onKeyUp(k){if(!i){if(Hc(k),_==null||_(k),k.target===k.currentTarget&&c&&g&&kd(k.currentTarget)&&k.key===" "){k.preventDefault();return}k.baseUIHandlerPrevented||k.target===k.currentTarget&&!c&&!g&&k.key===" "&&(x==null||x(k))}},onPointerDown(k){if(i){k.preventDefault();return}A==null||A(k)}},c?{type:"button"}:{role:"button"},p,j)},[i,p,g,c]),S=$e(E=>{d.current=E,y()});return{getButtonProps:v,buttonRef:S}}function kd(n){return Rt(n)&&n.tagName==="BUTTON"}function iO(n){return!!((n==null?void 0:n.tagName)==="A"&&(n!=null&&n.href))}const sO=w.forwardRef(function(i,r){const{render:o,className:c,disabled:f=!1,focusableWhenDisabled:d=!1,nativeButton:m=!0,style:g,...p}=i,{getButtonProps:y,buttonRef:v}=B0({disabled:f,focusableWhenDisabled:d,native:m});return Ca("button",i,{state:{disabled:f},ref:[r,v],props:[p,y]})}),rO=t0("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-none text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input",ghost:"hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-4 py-2",sm:"h-8 px-3"}},defaultVariants:{variant:"default",size:"default"}});function dh({className:n,variant:i="default",size:r="default",...o}){return C.jsx(sO,{"data-slot":"button",className:un(rO({variant:i,size:r,className:n})),...o})}function aO(n,i){return new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:i==null?void 0:i.timeZone})}function H0(n,i){return new Date(n).toLocaleString(void 0,{timeZone:i==null?void 0:i.timeZone})}function oO({entry:n,onClose:i}){const r=n.payload;return C.jsxs("aside",{className:"flex w-96 max-w-[40%] shrink-0 flex-col border-l border-chatroom-border bg-chatroom-bg-primary",role:"dialog","aria-modal":"true","aria-label":"Event detail",children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-chatroom-border px-4 py-3",children:[C.jsx("h3",{className:"text-sm font-medium",children:"Event detail"}),C.jsx(dh,{variant:"ghost",size:"sm",onClick:i,"aria-label":"Close detail panel",children:C.jsx(S0,{className:"size-4"})})]}),C.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4 text-xs",children:[C.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[C.jsx(L0,{type:n.type}),C.jsx("span",{className:"text-chatroom-text-muted",children:H0(n.timestamp)})]}),C.jsxs("div",{className:"space-y-1 text-chatroom-text-muted",children:[C.jsxs("div",{children:["Type: ",C.jsx("span",{className:"text-chatroom-text-primary",children:n.type})]}),C.jsxs("div",{children:["ID: ",C.jsx("span",{className:"text-chatroom-text-primary",children:n.id})]}),typeof r.chatroomId=="string"&&C.jsxs("div",{children:["Chatroom: ",C.jsx("span",{className:"text-chatroom-text-primary",children:r.chatroomId})]})]}),C.jsxs("div",{children:[C.jsx("p",{className:"mb-1 text-chatroom-text-muted",children:"Payload"}),C.jsx("pre",{className:"whitespace-pre-wrap border border-chatroom-border bg-chatroom-bg-secondary p-2 font-mono text-[11px]",children:JSON.stringify(r,null,2)})]})]})]})}function lO(n,i,r){const o=i.trim().toLowerCase();return o?n.filter(c=>r(c).toLowerCase().includes(o)):[...n]}function Gc({children:n,selected:i,onSelect:r,disabled:o,className:c,endAdornment:f,trailingActions:d,multiline:m=!1}){const g=un("min-w-0 px-3 py-2 text-xs text-left flex justify-between gap-2",m?"items-start":"items-center","cursor-pointer hover:bg-chatroom-bg-hover transition-colors","outline-none focus-visible:outline-none focus-visible:bg-chatroom-bg-hover","disabled:opacity-50 disabled:cursor-not-allowed",i&&"bg-chatroom-bg-hover",d?"flex-1 rounded-none":"w-full",!d&&c),p=C.jsxs("button",{type:"button",role:"option","aria-selected":i??!1,disabled:o,onClick:r,className:g,children:[C.jsx("span",{className:un("min-w-0 flex-1",m?"overflow-hidden":"truncate"),children:n}),f,i&&!d?C.jsx(b0,{size:12,className:"shrink-0 text-chatroom-accent"}):null]});return d?C.jsxs("div",{className:un("flex items-center w-full min-w-0",c),children:[p,d]}):p}function cO({children:n,className:i,maxHeightClassName:r="max-h-[60vh]"}){return C.jsx("div",{"data-picker-scroll-body":!0,className:un("min-h-0 overflow-y-auto overscroll-contain",r,i),children:n})}function uO({value:n,onChange:i,placeholder:r="Search…",autoFocus:o,className:c}){const f=o??!0;return C.jsx("div",{className:un("px-3 py-1.5 border-b border-chatroom-border shrink-0",c),"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),onClick:d=>{const m=d.currentTarget.querySelector("input");m==null||m.focus()},children:C.jsx("input",{type:"search",enterKeyHint:"search",value:n,onChange:d=>i(d.target.value),placeholder:r,autoFocus:f,"data-vaul-no-drag":"",onPointerDown:d=>d.stopPropagation(),className:"w-full bg-chatroom-bg-tertiary border border-chatroom-border px-2 py-1 text-[11px] text-chatroom-text-primary placeholder:text-chatroom-text-muted focus:outline-none focus:border-chatroom-accent rounded-none"})})}const q0="min-w-[8rem] max-w-[14rem] border border-chatroom-border bg-chatroom-bg-secondary text-xs text-chatroom-text-primary px-2 py-1.5 h-[28px] cursor-pointer hover:border-chatroom-border-strong focus:outline-none focus:border-chatroom-accent disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-between gap-1",Y0="shrink-0 text-chatroom-text-muted";function fO(n){const[i,r]=w.useState(""),o=w.useCallback(c=>{c||r(""),n(c)},[n]);return{searchTerm:i,setSearchTerm:r,handleOpenChange:o}}const dO=[];function Vh(n){w.useEffect(n,dO)}const Co=0;class ei{constructor(){tt(this,"currentId",Co);tt(this,"clear",()=>{this.currentId!==Co&&(clearTimeout(this.currentId),this.currentId=Co)});tt(this,"disposeEffect",()=>this.clear)}static create(){return new ei}start(i,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Co,r()},i)}isStarted(){return this.currentId!==Co}}function wa(){const n=Qi(ei.create).current;return Vh(n.disposeEffect),n}function hO(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:mO,platform:pO,maxTouchPoints:gO}=hO(),su=mO.toLowerCase(),jo=pO.toLowerCase(),ru=/^i(os$|p)/.test(jo)||jo==="macintel"&&gO>1,Db="android",hh=jo===Db||su.includes(Db),yO=!ru&&jo.startsWith("mac");jo.startsWith("win");const bO=yO||ru;var Dv;const _a=typeof CSS<"u"&&!!((Dv=CSS.supports)!=null&&Dv.call(CSS,"-webkit-backdrop-filter:none"));!_a&&su.includes("firefox");!_a&&su.includes("chrom");const vO=bO,SO=/jsdom|happydom/.test(su);function xO(n){n.preventDefault(),n.stopPropagation()}function EO(n){return"nativeEvent"in n}function TO(n){return n.pointerType===""&&n.isTrusted?!0:hh&&n.pointerType?n.type==="click"&&n.buttons===1:n.detail===0&&!n.pointerType}function wO(n){return SO?!1:!hh&&n.width===0&&n.height===0||hh&&n.width===1&&n.height===1&&n.pressure===0&&n.detail===0&&n.pointerType==="mouse"||n.width<1&&n.height<1&&n.pressure===0&&n.detail===0&&n.pointerType==="touch"}function Lo(n,i){const r=["mouse","pen"];return i||r.push("",void 0),r.includes(n)}function RO(n){const i=n.type;return i==="click"||i==="mousedown"||i==="keydown"||i==="keyup"}const mh="data-base-ui-focusable",V0="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Li(n){var r;let i=n.activeElement;for(;((r=i==null?void 0:i.shadowRoot)==null?void 0:r.activeElement)!=null;)i=i.shadowRoot.activeElement;return i}function Me(n,i){var o;if(!n||!i)return!1;const r=(o=i.getRootNode)==null?void 0:o.call(i);if(n.contains(i))return!0;if(r&&Ta(r)){let c=i;for(;c;){if(n===c)return!0;c=c.parentNode||c.host}}return!1}function $n(n){return"composedPath"in n?n.composedPath()[0]:n.target}function G0(n,i){if(!Je(n))return!1;const r=n;if(i.hasElement(r))return!r.hasAttribute("data-trigger-disabled");for(const[,o]of i.entries())if(Me(o,r))return!o.hasAttribute("data-trigger-disabled");return!1}function jd(n,i){if(i==null)return!1;if("composedPath"in n)return n.composedPath().includes(i);const r=n;return r.target!=null&&i.contains(r.target)}function OO(n){return n.matches("html,body")}function Gh(n){return Rt(n)&&n.matches(V0)}function CO(n){return(n==null?void 0:n.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${V0}`))!=null}function zb(n){return n?n.getAttribute("role")==="combobox"&&Gh(n):!1}function kb(n){return n?n.hasAttribute(mh)?n:n.querySelector(`[${mh}]`)||n:null}function AO(n,i){return i!=null&&!Lo(i)?0:typeof n=="function"?n():n}function ph(n,i,r){const o=AO(n,r);return typeof o=="number"?o:o==null?void 0:o[i]}function jb(n){return typeof n=="function"?n():n}function Q0(n,i){return i||n==="click"||n==="mousedown"}function _O(n){return(n==null?void 0:n.includes("mouse"))&&n!=="mousedown"}const MO="none",Uo="trigger-press",xn="trigger-hover",X0="outside-press",NO="close-press",Bo="focus-out",F0="escape-key",DO="imperative-action";function Xt(n,i,r,o){let c=!1,f=!1;const d=Wt;return{reason:n,event:i??new Event("base-ui"),cancel(){c=!0},allowPropagation(){f=!0},get isCanceled(){return c},get isPropagationAllowed(){return f},trigger:r,...d}}function Ke(n,i,r,o){return n.addEventListener(i,r,o),()=>{n.removeEventListener(i,r,o)}}function qi(...n){return()=>{for(let i=0;i<n.length;i+=1){const r=n[i];r&&r()}}}function En(n){const i=Qi(zO,n).current;return i.next=n,Xe(i.effect),i}function zO(n){const i={current:n,next:n,effect:()=>{i.current=i.next}};return i}const xc=null;class kO{constructor(){tt(this,"callbacks",[]);tt(this,"callbacksCount",0);tt(this,"nextId",1);tt(this,"startId",1);tt(this,"isScheduled",!1);tt(this,"tick",i=>{var c;this.isScheduled=!1;const r=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let f=0;f<r.length;f+=1)(c=r[f])==null||c.call(r,i)})}request(i){const r=this.nextId;return this.nextId+=1,this.callbacks.push(i),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(i){const r=i-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const Ec=new kO;class di{constructor(){tt(this,"currentId",xc);tt(this,"cancel",()=>{this.currentId!==xc&&(Ec.cancel(this.currentId),this.currentId=xc)});tt(this,"disposeEffect",()=>this.cancel)}static create(){return new di}static request(i){return Ec.request(i)}static cancel(i){return Ec.cancel(i)}request(i){this.cancel(),this.currentId=Ec.request(()=>{this.currentId=xc,i()})}}function Qh(){const n=Qi(di.create).current;return Vh(n.disposeEffect),n}function ut(n){return(n==null?void 0:n.ownerDocument)||document}const jO={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},LO={...jO,position:"fixed",top:0,left:0},Ra=w.forwardRef(function(i,r){const[o,c]=w.useState();Xe(()=>{vO&&_a&&c("button")},[]);const f={tabIndex:0,role:o};return C.jsx("span",{...i,ref:r,style:LO,"aria-hidden":o?void 0:!0,...f,"data-base-ui-focus-guard":""})}),UO=["top","right","bottom","left"],Oa=Math.min,Yi=Math.max,Qc=Math.round,Tc=Math.floor,Vi=n=>({x:n,y:n}),BO={left:"right",right:"left",bottom:"top",top:"bottom"};function K0(n,i,r){return Yi(n,Oa(i,r))}function Gi(n,i){return typeof n=="function"?n(i):n}function Dn(n){return n.split("-")[0]}function zs(n){return n.split("-")[1]}function Xh(n){return n==="x"?"y":"x"}function Fh(n){return n==="y"?"height":"width"}function Fn(n){const i=n[0];return i==="t"||i==="b"?"y":"x"}function Kh(n){return Xh(Fn(n))}function HO(n,i,r){r===void 0&&(r=!1);const o=zs(n),c=Kh(n),f=Fh(c);let d=c==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return i.reference[f]>i.floating[f]&&(d=Xc(d)),[d,Xc(d)]}function qO(n){const i=Xc(n);return[gh(n),i,gh(i)]}function gh(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const Lb=["left","right"],Ub=["right","left"],YO=["top","bottom"],VO=["bottom","top"];function GO(n,i,r){switch(n){case"top":case"bottom":return r?i?Ub:Lb:i?Lb:Ub;case"left":case"right":return i?YO:VO;default:return[]}}function QO(n,i,r,o){const c=zs(n);let f=GO(Dn(n),r==="start",o);return c&&(f=f.map(d=>d+"-"+c),i&&(f=f.concat(f.map(gh)))),f}function Xc(n){const i=Dn(n);return BO[i]+n.slice(i.length)}function XO(n){var i,r,o,c;return{top:(i=n.top)!=null?i:0,right:(r=n.right)!=null?r:0,bottom:(o=n.bottom)!=null?o:0,left:(c=n.left)!=null?c:0}}function Z0(n){return typeof n!="number"?XO(n):{top:n,right:n,bottom:n,left:n}}function Fc(n){const{x:i,y:r,width:o,height:c}=n;return{width:o,height:c,top:r,left:i,right:i+o,bottom:r+c,x:i,y:r}}function FO(n){return n.visibility==="hidden"||n.visibility==="collapse"}function P0(n,i=n?zn(n):null){return!n||!n.isConnected||!i||FO(i)?!1:typeof n.checkVisibility=="function"?n.checkVisibility():i.display!=="none"&&i.display!=="contents"}const KO='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function ZO(n){const i=n.assignedSlot;if(i)return i;if(n.parentElement)return n.parentElement;const r=n.getRootNode();return Ta(r)?r.host:null}function yh(n){for(const i of Array.from(n.children))if($t(i)==="summary")return i;return null}function PO(n,i){const r=yh(i);return!!r&&(n===r||Me(r,n))}function I0(n){const i=n?$t(n):"";return n!=null&&n.matches(KO)&&(i!=="summary"||n.parentElement!=null&&$t(n.parentElement)==="details"&&yh(n.parentElement)===n)&&(i!=="details"||yh(n)==null)&&(i!=="input"||n.type!=="hidden")}function J0(n){if(!I0(n)||!n.isConnected||n.matches(":disabled"))return!1;for(let i=n;i;i=ZO(i)){const r=i!==n,o=$t(i)==="slot";if(i.hasAttribute("inert")||r&&$t(i)==="details"&&!i.open&&!PO(n,i)||i.hasAttribute("hidden")||!o&&!IO(i,r))return!1}return!0}function IO(n,i){const r=zn(n);return i?r.display!=="none":P0(n,r)}function W0(n){const i=n.tabIndex;if(i<0){const r=$t(n);if(r==="details"||r==="audio"||r==="video"||Rt(n)&&n.isContentEditable)return 0}return i}function Ld(n){if($t(n)!=="input")return null;const i=n;return i.type==="radio"&&i.name!==""?i:null}function JO(n,i){const r=Ld(n);if(!r)return!0;const o=i.find(c=>{const f=Ld(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form&&f.checked});return o?o===r:i.find(c=>{const f=Ld(c);return(f==null?void 0:f.name)===r.name&&f.form===r.form})===r}function $0(n){if(Rt(n)&&$t(n)==="slot"){const i=n.assignedElements({flatten:!0});if(i.length>0)return i}return Rt(n)&&n.shadowRoot?Array.from(n.shadowRoot.children):Array.from(n.children)}function eS(n,i){$0(n).forEach(r=>{I0(r)&&i.push(r),eS(r,i)})}function tS(n,i,r){$0(n).forEach(o=>{Rt(o)&&o.matches(i)&&r.push(o),tS(o,i,r)})}function Zh(n){return J0(n)&&W0(n)>=0}function nS(n){const i=[];return eS(n,i),i.filter(J0)}function Po(n){const i=nS(n);return i.filter(r=>W0(r)>=0&&JO(r,i))}function iS(n,i){const r=Po(n),o=r.length;if(o===0)return;const c=Li(ut(n)),f=r.indexOf(c),d=f===-1?i===1?0:o-1:f+i;return r[d]}function Ph(n){return iS(ut(n).body,1)||n}function sS(n){return iS(ut(n).body,-1)||n}function rS(n,i){if(!n)return null;const r=Po(ut(n).body),o=r.length;if(o===0)return null;const c=r.indexOf(n);if(c===-1)return null;const f=(c+i+o)%o;return r[f]}function WO(n){return rS(n,1)}function $O(n){return rS(n,-1)}function oa(n,i){const r=i||n.currentTarget,o=n.relatedTarget;return!o||!Me(r,o)}function eC(n){Po(n).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function Bb(n){const i=[];tS(n,"[data-tabindex]",i),i.forEach(r=>{const o=r.dataset.tabindex;delete r.dataset.tabindex,o?r.setAttribute("tabindex",o):r.removeAttribute("tabindex")})}function Ms(n,i,r=!0){return n.filter(c=>c.parentId===i).flatMap(c=>{var f;return[...!r||(f=c.context)!=null&&f.open?[c]:[],...Ms(n,c.id,r)]})}function Hb(n,i){var c;let r=[],o=(c=n.find(f=>f.id===i))==null?void 0:c.parentId;for(;o;){const f=n.find(d=>d.id===o);o=f==null?void 0:f.parentId,f&&(r=r.concat(f))}return r}function Kc(n){return`data-base-ui-${n}`}let wc=0;function Ud(n,i={}){const{preventScroll:r=!1,sync:o=!1,shouldFocus:c}=i;cancelAnimationFrame(wc);function f(){c&&!c()||n==null||n.focus({preventScroll:r})}if(o)return f(),Mh;const d=requestAnimationFrame(f);return wc=d,()=>{wc===d&&(cancelAnimationFrame(d),wc=0)}}const Bd={inert:new WeakMap,"aria-hidden":new WeakMap},qb="data-base-ui-inert",bh={inert:new WeakSet,"aria-hidden":new WeakSet};let Ao=new WeakMap,Hd=0;function tC(n){return bh[n]}function aS(n){return n?Ta(n)?n.host:aS(n.parentNode):null}const Yb=(n,i)=>i.map(r=>{if(n.contains(r))return r;const o=aS(r);return n.contains(o)?o:null}).filter(r=>r!=null),Vb=n=>{const i=new Set;return n.forEach(r=>{let o=r;for(;o&&!i.has(o);)i.add(o),o=o.parentNode}),i},Gb=(n,i,r)=>{const o=[],c=f=>{!f||r.has(f)||Array.from(f.children).forEach(d=>{$t(d)!=="script"&&(i.has(d)?c(d):o.push(d))})};return c(n),o};function nC(n,i,r,o,{mark:c=!0}){let f=null;o?f="inert":r&&(f="aria-hidden");let d=null,m=null;const g=Yb(i,n),p=c?Gb(i,Vb(g),new Set(g)):[],y=[],v=[];if(f){const S=Bd[f],E=tC(f);m=E,d=S;const x=Yb(i,Array.from(i.querySelectorAll("[aria-live]"))),R=g.concat(x);Gb(i,Vb(R),new Set(R)).forEach(D=>{const A=D.getAttribute(f),j=A!==null&&A!=="false",k=(S.get(D)||0)+1;S.set(D,k),y.push(D),k===1&&j&&E.add(D),j||D.setAttribute(f,f==="inert"?"":"true")})}return c&&p.forEach(S=>{const E=(Ao.get(S)||0)+1;Ao.set(S,E),v.push(S),E===1&&S.setAttribute(qb,"")}),Hd+=1,()=>{d&&y.forEach(S=>{const x=(d.get(S)||0)-1;d.set(S,x),x||(!(m!=null&&m.has(S))&&f&&S.removeAttribute(f),m==null||m.delete(S))}),c&&v.forEach(S=>{const E=(Ao.get(S)||0)-1;Ao.set(S,E),E||S.removeAttribute(qb)}),Hd-=1,Hd||(Bd.inert=new WeakMap,Bd["aria-hidden"]=new WeakMap,bh.inert=new WeakSet,bh["aria-hidden"]=new WeakSet,Ao=new WeakMap)}}function Qb(n,i={}){const{ariaHidden:r=!1,inert:o=!1,mark:c=!0}=i,f=ut(n[0]).body;return nC(n,f,r,o,{mark:c})}var Ns=Xv();let Xb=0;function iC(n,i="mui"){const[r,o]=w.useState(n),c=n||r;return w.useEffect(()=>{r==null&&(Xb+=1,o(`${i}-${Xb}`))},[r,i]),c}const Fb=Yh.useId;function Io(n,i){if(Fb!==void 0){const r=Fb();return n??(i?`${i}-${r}`:r)}return iC(n,i)}const sC=500,rC={style:{transition:"none"}},oS="data-base-ui-click-trigger",aC={fallbackAxisSide:"end"},oC={clipPath:"inset(50%)",position:"fixed",top:0,left:0},lS=w.createContext(null),cS=()=>w.useContext(lS),lC=Kc("portal");function cC(n={}){const{ref:i,container:r,componentProps:o=Wt,elementProps:c}=n,f=Io(),d=cS(),m=d==null?void 0:d.portalNode,[g,p]=w.useState(null),[y,v]=w.useState(null),S=$e(_=>{_!==null&&v(_)}),E=w.useRef(null);Xe(()=>{if(r===null){E.current&&(E.current=null,v(null),p(null));return}if(f==null)return;const _=(r&&(Bh(r)?r:r.current))??m??document.body;if(_==null){E.current&&(E.current=null,v(null),p(null));return}E.current!==_&&(E.current=_,v(null),p(_))},[r,m,f]);const x=Ca("div",o,{ref:[i,S],props:[{id:f,[lC]:""},c]});return{portalNode:y,portalSubtree:g&&x?Ns.createPortal(x,g):null}}const uC=w.forwardRef(function(i,r){const{render:o,className:c,style:f,children:d,container:m,renderGuards:g,...p}=i,{portalNode:y,portalSubtree:v}=cC({container:m,ref:r,componentProps:i,elementProps:p}),S=w.useRef(null),E=w.useRef(null),x=w.useRef(null),R=w.useRef(null),[_,D]=w.useState(null),A=w.useRef(!1),j=_==null?void 0:_.modal,k=_==null?void 0:_.open,q=typeof g=="boolean"?g:!!_&&!_.modal&&_.open&&!!y;w.useEffect(()=>{if(!y||j)return;function B(L){y&&L.relatedTarget&&oa(L)&&(L.type==="focusin"?A.current&&(Bb(y),A.current=!1):(eC(y),A.current=!0))}return qi(Ke(y,"focusin",B,!0),Ke(y,"focusout",B,!0))},[y,j]),Xe(()=>{!y||k!==!0||!A.current||(Bb(y),A.current=!1)},[k,y]);const F=w.useMemo(()=>({beforeOutsideRef:S,afterOutsideRef:E,beforeInsideRef:x,afterInsideRef:R,portalNode:y,setFocusManagerState:D}),[y]);return C.jsxs(w.Fragment,{children:[v,C.jsxs(lS.Provider,{value:F,children:[q&&y&&C.jsx(Ra,{"data-type":"outside",ref:S,onFocus:B=>{var L;if(oa(B,y))(L=x.current)==null||L.focus();else{const K=_?_.domReference:null,se=sS(K);se==null||se.focus()}}}),q&&y&&C.jsx("span",{"aria-owns":y.id,style:oC}),y&&Ns.createPortal(d,y),q&&y&&C.jsx(Ra,{"data-type":"outside",ref:E,onFocus:B=>{var L;if(oa(B,y))(L=R.current)==null||L.focus();else{const K=_?_.domReference:null,se=Ph(K);se==null||se.focus(),_!=null&&_.closeOnFocusOut&&(_==null||_.onOpenChange(!1,Xt(Bo,B.nativeEvent)))}}})]})]})});function uS(){const n=new Map;return{emit(i,r){var o;(o=n.get(i))==null||o.forEach(c=>c(r))},on(i,r){n.has(i)||n.set(i,new Set),n.get(i).add(r)},off(i,r){var o;(o=n.get(i))==null||o.delete(r)}}}class fC{constructor(){tt(this,"nodesRef",{current:[]});tt(this,"events",uS())}addNode(i){this.nodesRef.current.push(i)}removeNode(i){const r=this.nodesRef.current.findIndex(o=>o===i);r!==-1&&this.nodesRef.current.splice(r,1)}}const fS=w.createContext(null),dS=w.createContext(null),Ma=()=>{var n;return((n=w.useContext(fS))==null?void 0:n.id)||null},Na=n=>{const i=w.useContext(dS);return n??i};function dC(n){const i=Io(),r=Na(n),o=Ma();return Xe(()=>{if(!i)return;const c={id:i,parentId:o};return r==null||r.addNode(c),()=>{r==null||r.removeNode(c)}},[r,i,o]),i}function hC(n){const{children:i,id:r}=n,o=Ma();return C.jsx(fS.Provider,{value:w.useMemo(()=>({id:r,parentId:o}),[r,o]),children:i})}function mC(n){const{children:i,externalTree:r}=n,o=Qi(()=>r??new fC).current;return C.jsx(dS.Provider,{value:o,children:i})}function Ui(n){return n==null?n:"current"in n?n.current:n}function pC(n,i){const r=kt($n(n));return n instanceof r.KeyboardEvent?"keyboard":n instanceof r.FocusEvent?i||"keyboard":"pointerType"in n?n.pointerType||"keyboard":"touches"in n?"touch":n instanceof r.MouseEvent?i||(n.detail===0?"keyboard":"mouse"):""}const gC=20;let Os=[];function Ih(){Os=Os.filter(n=>{var i;return(i=n.deref())==null?void 0:i.isConnected})}function Kb(n){Ih(),n&&$t(n)!=="body"&&(Os.push(new WeakRef(n)),Os.length>gC&&(Os=Os.slice(-20)))}function Zb(){var n;return Ih(),(n=Os[Os.length-1])==null?void 0:n.deref()}function yC(n){return n?Zh(n)?n:Po(n)[0]||n:null}function Pb(n){var c;if(n.hasAttribute("tabindex")&&!n.hasAttribute("data-tabindex")||!((c=n.getAttribute("role"))!=null&&c.includes("dialog")))return;const r=nS(n).filter(f=>{const d=f.getAttribute("data-tabindex")||"";return Zh(f)||f.hasAttribute("data-tabindex")&&!d.startsWith("-")}),o=n.getAttribute("tabindex");r.length===0?o!=="0"&&(n.setAttribute("tabindex","0"),n.setAttribute("data-tabindex","0")):(o!=="-1"||n.hasAttribute("data-tabindex")&&n.getAttribute("data-tabindex")!=="-1")&&(n.setAttribute("tabindex","-1"),n.setAttribute("data-tabindex","-1"))}function bC(n){const{context:i,children:r,disabled:o=!1,initialFocus:c=!0,returnFocus:f=!0,restoreFocus:d=!1,modal:m=!0,closeOnFocusOut:g=!0,openInteractionType:p="",nextFocusableElement:y,previousFocusableElement:v,beforeContentFocusGuardRef:S,externalTree:E,getInsideElements:x}=n,R="rootStore"in i?i.rootStore:i,_=R.useState("open"),D=R.useState("domReferenceElement"),A=R.useState("floatingElement"),{events:j,dataRef:k}=R.context,q=$e(()=>{var ve;return(ve=k.current.floatingContext)==null?void 0:ve.nodeId}),F=c===!1,B=zb(D)&&F,L=En(c),K=En(f),se=En(p),pe=En(_),ae=Na(E),W=cS(),le=w.useRef(!1),ie=w.useRef(!1),N=w.useRef(!1),Q=w.useRef(null),I=w.useRef(""),oe=w.useRef(""),Y=w.useRef(null),T=w.useRef(null),H=qc(Y,S,W==null?void 0:W.beforeInsideRef),te=qc(T,W==null?void 0:W.afterInsideRef),ne=wa(),re=wa(),ee=Qh(),ge=W!=null,ce=kb(A),fe=$e((ve=ce)=>ve?Po(ve):[]),Ze=$e(()=>(x==null?void 0:x().filter(ve=>ve!=null))??[]);w.useEffect(()=>{if(o||!m)return;function ve(Oe){Oe.key==="Tab"&&Me(ce,Li(ut(ce)))&&fe().length===0&&!B&&xO(Oe)}const ze=ut(ce);return Ke(ze,"keydown",ve)},[o,ce,m,B,fe]),w.useEffect(()=>{if(o||!_)return;const ve=ut(ce);function ze(){N.current=!1}function Oe(vt){const Re=$n(vt),ke=Ze(),Ee=Me(A,Re)||Me(D,Re)||Me(W==null?void 0:W.portalNode,Re)||ke.some(mt=>mt===Re||Me(mt,Re));N.current=!Ee,oe.current=vt.pointerType||"keyboard",Re!=null&&Re.closest(`[${oS}]`)&&(ie.current=!0,re.start(0,()=>{ie.current=!1}))}function ft(){oe.current="keyboard"}return qi(Ke(ve,"pointerdown",Oe,!0),Ke(ve,"pointerup",ze,!0),Ke(ve,"pointercancel",ze,!0),Ke(ve,"keydown",ft,!0),ze)},[o,A,D,ce,_,W,re,Ze]),w.useEffect(()=>{if(o||!g)return;const ve=ut(ce);function ze(){ie.current=!0,re.start(0,()=>{ie.current=!1})}function Oe(ke){const Ee=$n(ke);Zh(Ee)&&(Q.current=Ee)}function ft(ke){const Ee=ke.relatedTarget,mt=ke.currentTarget,dt=$n(ke);m&&Ee==null&&dt!=null&&Me(A,dt)&&Kb(dt),queueMicrotask(()=>{const je=q(),xt=R.context.triggerElements,ue=Ze(),xe=(Ee==null?void 0:Ee.hasAttribute(Kc("focus-guard")))&&[Y.current,T.current,W==null?void 0:W.beforeInsideRef.current,W==null?void 0:W.afterInsideRef.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,Ui(v),Ui(y)].includes(Ee),ht=!(Me(D,Ee)||Me(A,Ee)||Me(Ee,A)||Me(W==null?void 0:W.portalNode,Ee)||ue.some(Be=>Be===Ee||Me(Be,Ee))||Ee!=null&&xt.hasElement(Ee)||xt.hasMatchingElement(Be=>Me(Be,Ee))||xe||ae&&(Ms(ae.nodesRef.current,je).find(Be=>{var pt,jt;return Me((pt=Be.context)==null?void 0:pt.elements.floating,Ee)||Me((jt=Be.context)==null?void 0:jt.elements.domReference,Ee)})||Hb(ae.nodesRef.current,je).find(Be=>{var pt,jt,sn;return[(pt=Be.context)==null?void 0:pt.elements.floating,kb((jt=Be.context)==null?void 0:jt.elements.floating)].includes(Ee)||((sn=Be.context)==null?void 0:sn.elements.domReference)===Ee})));if(mt===D&&ce&&Pb(ce),d&&mt!==D&&!P0(dt)&&Li(ve)===ve.body){if(Rt(ce)&&(ce.focus(),d==="popup")){ee.request(()=>{ce.focus()});return}const Be=fe(),pt=Q.current,jt=(pt&&Be.includes(pt)?pt:null)||Be[Be.length-1]||ce;Rt(jt)&&jt.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(B||!m)&&Ee&&ht&&!ie.current&&(B||Ee!==Zb())&&(le.current=!0,R.setOpen(!1,Xt(Bo,ke)))})}function vt(){N.current||(k.current.insideReactTree=!0,ne.start(0,()=>{k.current.insideReactTree=!1}))}const Re=Rt(D)?D:null;if(!(!A&&!Re))return qi(Re&&Ke(Re,"focusout",ft),Re&&Ke(Re,"pointerdown",ze),A&&Ke(A,"focusin",Oe),A&&Ke(A,"focusout",ft),A&&W&&Ke(A,"focusout",vt,!0))},[o,D,A,ce,m,ae,W,R,g,d,fe,B,q,k,ne,re,ee,y,v,Ze]),w.useEffect(()=>{var mt,dt,je;if(o||!A||!_)return;const ve=Array.from(((mt=W==null?void 0:W.portalNode)==null?void 0:mt.querySelectorAll(`[${Kc("portal")}]`))||[]),Oe=(je=(dt=(ae?Hb(ae.nodesRef.current,q()):[]).find(xt=>{var ue;return zb(((ue=xt.context)==null?void 0:ue.elements.domReference)||null)}))==null?void 0:dt.context)==null?void 0:je.elements.domReference,vt=[...[A,...ve,Y.current,T.current,W==null?void 0:W.beforeOutsideRef.current,W==null?void 0:W.afterOutsideRef.current,...Ze()],Oe,Ui(v),Ui(y),B?D:null].filter(xt=>xt!=null),Re=Qb(vt,{ariaHidden:m||B,mark:!1}),ke=[A,...ve].filter(xt=>xt!=null),Ee=Qb(ke);return()=>{Ee(),Re()}},[_,o,D,A,m,W,B,ae,q,y,v,Ze]),Xe(()=>{if(!_||o||!Rt(ce))return;const ve=ut(ce),ze=Li(ve);queueMicrotask(()=>{const Oe=L.current,ft=typeof Oe=="function"?Oe(se.current||""):Oe;if(ft===void 0||ft===!1||Me(ce,ze))return;let Re=null;const ke=()=>(Re==null&&(Re=fe(ce)),Re[0]||ce);let Ee;ft===!0||ft===null?Ee=ke():Ee=Ui(ft),Ee=Ee||ke();const mt=Me(ce,Li(ve));Ud(Ee,{preventScroll:Ee===ce,shouldFocus(){if(!pe.current)return!1;if(mt)return!0;const dt=Li(ve);return!(dt!==Ee&&Me(ce,dt))}})})},[o,_,ce,fe,L,se,pe]),Xe(()=>{if(o||!ce)return;const ve=ut(ce),ze=Li(ve),Oe=se.current==null;Kb(ze);function ft(Re){if(Re.open||(I.current=pC(Re.nativeEvent,oe.current)),Re.reason===xn&&Re.nativeEvent.type==="mouseleave"&&(le.current=!0),Re.reason===X0)if(Re.nested)le.current=!1;else if(TO(Re.nativeEvent)||wO(Re.nativeEvent))le.current=!1;else{let ke=!1;ut(ce).createElement("div").focus({get preventScroll(){return ke=!0,!1}}),ke?le.current=!1:le.current=!0}}j.on("openchange",ft);function vt(){const Re=K.current;let ke=typeof Re=="function"?Re(I.current):Re;if(ke===void 0||ke===!1)return null;ke===null&&(ke=!0);const Ee=D!=null&&D.isConnected?D:null,mt=ze!=null&&ze.isConnected&&$t(ze)!=="body"?ze:null;let dt=Oe?mt||Ee:Ee||mt;return dt||(dt=Zb()||null),typeof ke=="boolean"?dt:Ui(ke)||dt||null}return()=>{j.off("openchange",ft);const Re=Li(ve),ke=Ze(),Ee=Me(A,Re)||ke.some(je=>je===Re||Me(je,Re))||ae&&Ms(ae.nodesRef.current,q(),!1).some(je=>{var xt;return Me((xt=je.context)==null?void 0:xt.elements.floating,Re)}),mt=K.current,dt=vt();queueMicrotask(()=>{const je=yC(dt),xt=typeof mt!="boolean";mt&&!le.current&&Rt(je)&&(!(!xt&&je!==Re&&Re!==ve.body)||Ee)&&je.focus({preventScroll:!0}),le.current=!1})}},[o,A,ce,K,se,j,ae,D,q,Ze]),Xe(()=>{if(!_a||_||!A)return;const ve=Li(ut(A));!Rt(ve)||!Gh(ve)||Me(A,ve)&&ve.blur()},[_,A]),Xe(()=>{if(!(o||!W))return W.setFocusManagerState({modal:m,closeOnFocusOut:g,open:_,onOpenChange:R.setOpen,domReference:D}),()=>{W.setFocusManagerState(null)}},[o,W,m,_,R,g,D]),Xe(()=>{if(!(o||!ce))return Pb(ce),()=>{queueMicrotask(Ih)}},[o,ce]);const nt=!o&&(m?!B:!0)&&(ge||m);return C.jsxs(w.Fragment,{children:[nt&&C.jsx(Ra,{"data-type":"inside",ref:H,onFocus:ve=>{var ze;if(m){const Oe=fe();Ud(Oe[Oe.length-1])}else if(W!=null&&W.portalNode)if(le.current=!1,oa(ve,W.portalNode)){const Oe=Ph(D);Oe==null||Oe.focus()}else(ze=Ui(v??W.beforeOutsideRef))==null||ze.focus()}}),r,nt&&C.jsx(Ra,{"data-type":"inside",ref:te,onFocus:ve=>{var ze;if(m)Ud(fe()[0]);else if(W!=null&&W.portalNode)if(g&&(le.current=!0),oa(ve,W.portalNode)){const Oe=sS(D);Oe==null||Oe.focus()}else(ze=Ui(y??W.afterOutsideRef))==null||ze.focus()}})]})}function vC(n,i={}){const{enabled:r=!0,event:o="click",toggle:c=!0,ignoreMouse:f=!1,stickIfOpen:d=!0,touchOpenDelay:m=0,reason:g=Uo}=i,p="rootStore"in n?n.rootStore:n,y=p.context.dataRef,v=w.useRef(void 0),S=Qh(),E=wa(),x=w.useMemo(()=>{function R(D,A,j,k){const q=Xt(g,A,j);D&&k==="touch"&&m>0?E.start(m,()=>{p.setOpen(!0,q)}):p.setOpen(D,q)}function _(D,A,j){const k=y.current.openEvent,q=p.select("domReferenceElement")!==A;return D&&q||!D||!c?!0:k&&d?!j(k.type):!1}return{onPointerDown(D){v.current=D.pointerType},onMouseDown(D){const A=v.current,j=D.nativeEvent,k=p.select("open");if(D.button!==0||o==="click"||Lo(A,!0)&&f)return;const q=_(k,D.currentTarget,L=>L==="click"||L==="mousedown"),F=$n(j);if(Gh(F)){R(q,j,F,A);return}const B=D.currentTarget;S.request(()=>{R(q,j,B,A)})},onClick(D){if(o==="mousedown-only")return;const A=v.current;if(o==="mousedown"&&A){v.current=void 0;return}if(Lo(A,!0)&&f)return;const j=p.select("open"),k=_(j,D.currentTarget,q=>q==="click"||q==="mousedown"||q==="keydown"||q==="keyup");R(k,D.nativeEvent,D.currentTarget,A)},onKeyDown(){v.current=void 0}}},[y,o,f,g,p,d,c,S,E,m]);return w.useMemo(()=>r?{reference:x}:Wt,[r,x])}function SC(){return!1}function xC(n){return{escapeKey:typeof n=="boolean"?n:(n==null?void 0:n.escapeKey)??!1,outsidePress:typeof n=="boolean"?n:(n==null?void 0:n.outsidePress)??!0}}function EC(n,i={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:c=!0,outsidePressEvent:f="sloppy",referencePress:d=SC,bubbles:m,externalTree:g}=i,p="rootStore"in n?n.rootStore:n,y=p.useState("open"),v=p.useState("floatingElement"),{dataRef:S}=p.context,E=Na(g),x=$e(typeof c=="function"?c:()=>!1),R=typeof c=="function"?x:c,_=R!==!1,D=$e(()=>f),{escapeKey:A,outsidePress:j}=xC(m),k=w.useRef(!1),q=w.useRef(!1),F=w.useRef(!1),B=w.useRef(!1),L=w.useRef(""),K=w.useRef(null),se=wa(),pe=wa(),ae=$e(()=>{pe.clear(),S.current.insideReactTree=!1}),W=$e(H=>{var re;const te=(re=S.current.floatingContext)==null?void 0:re.nodeId;return(E?Ms(E.nodesRef.current,te):[]).some(ee=>{var ge;return((ge=ee.context)==null?void 0:ge.open)&&!ee.context.dataRef.current[H]})}),le=$e(H=>jd(H,p.select("floatingElement"))||jd(H,p.select("domReferenceElement"))),ie=$e(H=>{d()&&p.setOpen(!1,Xt(Uo,H.nativeEvent))}),N=$e(H=>{if(!y||!r||!o||H.key!=="Escape"||B.current||!A&&W("__escapeKeyBubbles"))return;const te=EO(H)?H.nativeEvent:H,ne=Xt(F0,te);p.setOpen(!1,ne),ne.isCanceled||H.preventDefault(),!A&&!ne.isPropagationAllowed&&H.stopPropagation()}),Q=$e(()=>{S.current.insideReactTree=!0,pe.start(0,ae)}),I=$e(H=>{if(!y||!r||H.button!==0)return;const te=$n(H.nativeEvent);Me(p.select("floatingElement"),te)&&(k.current||(k.current=!0,q.current=!1))}),oe=$e(H=>{!y||!r||(H.defaultPrevented||H.nativeEvent.defaultPrevented)&&k.current&&(q.current=!0)});w.useEffect(()=>{if(!y||!r)return;S.current.__escapeKeyBubbles=A,S.current.__outsidePressBubbles=j;const H=new ei,te=new ei;function ne(){H.clear(),B.current=!0}function re(){H.start(_a?5:0,()=>{B.current=!1})}function ee(){F.current=!0,te.start(0,()=>{F.current=!1})}function ge(){k.current=!1,q.current=!1}function ce(){const ue=L.current,xe=ue==="pen"||!ue?"mouse":ue,ht=D(),Be=typeof ht=="function"?ht():ht;return typeof Be=="string"?Be:Be[xe]}function fe(ue){const xe=ce();return xe==="intentional"&&ue.type!=="click"||xe==="sloppy"&&ue.type==="click"}function Ze(ue){var Be;const xe=(Be=S.current.floatingContext)==null?void 0:Be.nodeId,ht=E&&Ms(E.nodesRef.current,xe).some(pt=>{var jt;return jd(ue,(jt=pt.context)==null?void 0:jt.elements.floating)});return le(ue)||ht}function nt(ue){if(fe(ue)){ue.type!=="click"&&!le(ue)&&(te.clear(),F.current=!1),ae();return}if(S.current.insideReactTree){ae();return}const xe=$n(ue),ht=`[${Kc("inert")}]`,Be=Je(xe)?xe.getRootNode():null,pt=Array.from((Ta(Be)?Be:ut(p.select("floatingElement"))).querySelectorAll(ht)),jt=p.context.triggerElements;if(xe&&(jt.hasElement(xe)||jt.hasMatchingElement(rn=>Me(rn,xe))))return;let sn=Je(xe)?xe:null;for(;sn&&!As(sn);){const rn=_s(sn);if(As(rn)||!Je(rn))break;sn=rn}if(!(pt.length&&Je(xe)&&!OO(xe)&&!Me(xe,p.select("floatingElement"))&&pt.every(rn=>!Me(sn,rn)))){if(Rt(xe)&&!("touches"in ue)){const rn=As(xe),ti=zn(xe),fn=/auto|scroll/,qt=rn||fn.test(ti.overflowX),Tn=rn||fn.test(ti.overflowY),Yt=qt&&xe.clientWidth>0&&xe.scrollWidth>xe.clientWidth,gr=Tn&&xe.clientHeight>0&&xe.scrollHeight>xe.clientHeight,yr=ti.direction==="rtl",br=gr&&(yr?ue.offsetX<=xe.offsetWidth-xe.clientWidth:ue.offsetX>xe.clientWidth),pi=Yt&&ue.offsetY>xe.clientHeight;if(br||pi)return}if(!Ze(ue)){if(ce()==="intentional"&&F.current){te.clear(),F.current=!1;return}typeof R=="function"&&!R(ue)||W("__outsidePressBubbles")||(p.setOpen(!1,Xt(X0,ue)),ae())}}}function ve(ue){ce()!=="sloppy"||ue.pointerType==="touch"||!p.select("open")||!r||le(ue)||nt(ue)}function ze(ue){if(ce()!=="sloppy"||!p.select("open")||!r||le(ue))return;const xe=ue.touches[0];xe&&(K.current={startTime:Date.now(),startX:xe.clientX,startY:xe.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},se.start(1e3,()=>{K.current&&(K.current.dismissOnTouchEnd=!1,K.current.dismissOnMouseDown=!1)}))}function Oe(ue,xe){const ht=$n(ue);if(!ht)return;const Be=Ke(ht,ue.type,()=>{xe(ue),Be()})}function ft(ue){L.current="touch",Oe(ue,ze)}function vt(ue){se.clear(),ue.type==="pointerdown"&&(L.current=ue.pointerType),!(ue.type==="mousedown"&&K.current&&!K.current.dismissOnMouseDown)&&Oe(ue,xe=>{xe.type==="pointerdown"?ve(xe):nt(xe)})}function Re(ue){if(!k.current)return;const xe=q.current;if(ge(),ce()==="intentional"){if(ue.type==="pointercancel"){xe&&ee();return}if(!Ze(ue)){if(xe){ee();return}typeof R=="function"&&!R(ue)||(te.clear(),F.current=!0,ae())}}}function ke(ue){if(ce()!=="sloppy"||!K.current||le(ue))return;const xe=ue.touches[0];if(!xe)return;const ht=Math.abs(xe.clientX-K.current.startX),Be=Math.abs(xe.clientY-K.current.startY),pt=Math.sqrt(ht*ht+Be*Be);pt>5&&(K.current.dismissOnTouchEnd=!0),pt>10&&(nt(ue),se.clear(),K.current=null)}function Ee(ue){Oe(ue,ke)}function mt(ue){ce()!=="sloppy"||!K.current||le(ue)||(K.current.dismissOnTouchEnd&&nt(ue),se.clear(),K.current=null)}function dt(ue){Oe(ue,mt)}const je=ut(v),xt=qi(o&&qi(Ke(je,"keydown",N),Ke(je,"compositionstart",ne),Ke(je,"compositionend",re)),_&&qi(Ke(je,"click",vt,!0),Ke(je,"pointerdown",vt,!0),Ke(je,"pointerup",Re,!0),Ke(je,"pointercancel",Re,!0),Ke(je,"mousedown",vt,!0),Ke(je,"mouseup",Re,!0),Ke(je,"touchstart",ft,!0),Ke(je,"touchmove",Ee,!0),Ke(je,"touchend",dt,!0)));return()=>{xt(),H.clear(),te.clear(),ge(),F.current=!1}},[S,v,o,_,R,y,r,A,j,N,ae,D,W,le,E,p,se]),w.useEffect(ae,[R,ae]);const Y=w.useMemo(()=>({onKeyDown:N,onPointerDown:ie,onClick:ie}),[N,ie]),T=w.useMemo(()=>({onKeyDown:N,onPointerDown:oe,onMouseDown:oe,onClickCapture:Q,onMouseDownCapture(H){Q(),I(H)},onPointerDownCapture(H){Q(),I(H)},onMouseUpCapture:Q,onTouchEndCapture:Q,onTouchMoveCapture:Q}),[N,Q,I,oe]);return w.useMemo(()=>r?{reference:Y,floating:T,trigger:Y}:{},[r,Y,T])}function Ib(n,i,r){let{reference:o,floating:c}=n;const f=Fn(i),d=Kh(i),m=Fh(d),g=Dn(i),p=f==="y",y=o.x+o.width/2-c.width/2,v=o.y+o.height/2-c.height/2,S=o[m]/2-c[m]/2;let E;switch(g){case"top":E={x:y,y:o.y-c.height};break;case"bottom":E={x:y,y:o.y+o.height};break;case"right":E={x:o.x+o.width,y:v};break;case"left":E={x:o.x-c.width,y:v};break;default:E={x:o.x,y:o.y}}const x=zs(i);return x&&(E[d]+=S*(x==="end"?1:-1)*(r&&p?-1:1)),E}async function TC(n,i){var r;i===void 0&&(i={});const{x:o,y:c,platform:f,rects:d,elements:m,strategy:g}=n,{boundary:p="clippingAncestors",rootBoundary:y="viewport",elementContext:v="floating",altBoundary:S=!1,padding:E=0}=Gi(i,n),x=Z0(E),_=m[S?v==="floating"?"reference":"floating":v],D=Fc(await f.getClippingRect({element:(r=await(f.isElement==null?void 0:f.isElement(_)))==null||r?_:_.contextElement||await(f.getDocumentElement==null?void 0:f.getDocumentElement(m.floating)),boundary:p,rootBoundary:y,strategy:g})),A=v==="floating"?{x:o,y:c,width:d.floating.width,height:d.floating.height}:d.reference,j=await(f.getOffsetParent==null?void 0:f.getOffsetParent(m.floating)),k=await(f.isElement==null?void 0:f.isElement(j))&&await(f.getScale==null?void 0:f.getScale(j))||{x:1,y:1},q=Fc(f.convertOffsetParentRelativeRectToViewportRelativeRect?await f.convertOffsetParentRelativeRectToViewportRelativeRect({elements:m,rect:A,offsetParent:j,strategy:g}):A);return{top:(D.top-q.top+x.top)/k.y,bottom:(q.bottom-D.bottom+x.bottom)/k.y,left:(D.left-q.left+x.left)/k.x,right:(q.right-D.right+x.right)/k.x}}const wC=50,RC=async(n,i,r)=>{const{placement:o="bottom",strategy:c="absolute",middleware:f=[],platform:d}=r,m=d.detectOverflow?d:{...d,detectOverflow:TC},g=await(d.isRTL==null?void 0:d.isRTL(i));let p=await d.getElementRects({reference:n,floating:i,strategy:c}),{x:y,y:v}=Ib(p,o,g),S=o,E=0;const x={};for(let R=0;R<f.length;R++){const _=f[R];if(!_)continue;const{name:D,fn:A}=_,{x:j,y:k,data:q,reset:F}=await A({x:y,y:v,initialPlacement:o,placement:S,strategy:c,middlewareData:x,rects:p,platform:m,elements:{reference:n,floating:i}});y=j??y,v=k??v,x[D]={...x[D],...q},F&&E<wC&&(E++,typeof F=="object"&&(F.placement&&(S=F.placement),F.rects&&(p=F.rects===!0?await d.getElementRects({reference:n,floating:i,strategy:c}):F.rects),{x:y,y:v}=Ib(p,S,g)),R=-1)}return{x:y,y:v,placement:S,strategy:c,middlewareData:x}},OC=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(i){var r,o;const{placement:c,middlewareData:f,rects:d,initialPlacement:m,platform:g,elements:p}=i,{mainAxis:y=!0,crossAxis:v=!0,fallbackPlacements:S,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:R=!0,..._}=Gi(n,i);if((r=f.arrow)!=null&&r.alignmentOffset)return{};const D=Dn(c),A=Fn(m),j=Dn(m)===m,k=await(g.isRTL==null?void 0:g.isRTL(p.floating)),q=S||(j||!R?[Xc(m)]:qO(m)),F=x!=="none";!S&&F&&q.push(...QO(m,R,x,k));const B=[m,...q],L=await g.detectOverflow(i,_),K=[];let se=((o=f.flip)==null?void 0:o.overflows)||[];if(y&&K.push(L[D]),v){const le=HO(c,d,k);K.push(L[le[0]],L[le[1]])}if(se=[...se,{placement:c,overflows:K}],!K.every(le=>le<=0)){var pe,ae;const le=(((pe=f.flip)==null?void 0:pe.index)||0)+1,ie=B[le];if(ie&&(!(v==="alignment"?A!==Fn(ie):!1)||se.every(I=>Fn(I.placement)===A?I.overflows[0]>0:!0)))return{data:{index:le,overflows:se},reset:{placement:ie}};let N=(ae=se.filter(Q=>Q.overflows[0]<=0).sort((Q,I)=>Q.overflows[1]-I.overflows[1])[0])==null?void 0:ae.placement;if(!N)switch(E){case"bestFit":{var W;const Q=(W=se.filter(I=>{if(F){const oe=Fn(I.placement);return oe===A||oe==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(oe=>oe>0).reduce((oe,Y)=>oe+Y,0)]).sort((I,oe)=>I[1]-oe[1])[0])==null?void 0:W[0];Q&&(N=Q);break}case"initialPlacement":N=m;break}if(c!==N)return{reset:{placement:N}}}return{}}}};function Jb(n,i){return{top:n.top-i.height,right:n.right-i.width,bottom:n.bottom-i.height,left:n.left-i.width}}function Wb(n){return UO.some(i=>n[i]>=0)}const CC=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(i){const{rects:r,platform:o}=i,{strategy:c="referenceHidden",...f}=Gi(n,i);switch(c){case"referenceHidden":{const d=await o.detectOverflow(i,{...f,elementContext:"reference"}),m=Jb(d,r.reference);return{data:{referenceHiddenOffsets:m,referenceHidden:Wb(m)}}}case"escaped":{const d=await o.detectOverflow(i,{...f,altBoundary:!0}),m=Jb(d,r.floating);return{data:{escapedOffsets:m,escaped:Wb(m)}}}default:return{}}}}},hS=new Set(["left","top"]);async function AC(n,i){const{placement:r,platform:o,elements:c}=n,f=await(o.isRTL==null?void 0:o.isRTL(c.floating)),d=Dn(r),m=zs(r),g=Fn(r)==="y",p=hS.has(d)?-1:1,y=f&&g?-1:1,v=Gi(i,n);let{mainAxis:S,crossAxis:E,alignmentAxis:x}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return m&&typeof x=="number"&&(E=m==="end"?x*-1:x),g?{x:E*y,y:S*p}:{x:S*p,y:E*y}}const _C=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(i){var r,o;const{x:c,y:f,placement:d,middlewareData:m}=i,g=await AC(i,n);return d===((r=m.offset)==null?void 0:r.placement)&&(o=m.arrow)!=null&&o.alignmentOffset?{}:{x:c+g.x,y:f+g.y,data:{...g,placement:d}}}}},MC=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(i){const{x:r,y:o,placement:c,platform:f}=i,{mainAxis:d=!0,crossAxis:m=!1,limiter:g={fn:A=>{let{x:j,y:k}=A;return{x:j,y:k}}},...p}=Gi(n,i),y={x:r,y:o},v=await f.detectOverflow(i,p),S=Fn(c),E=Xh(S);let x=y[E],R=y[S];const _=(A,j)=>K0(j+v[A==="y"?"top":"left"],j,j-v[A==="y"?"bottom":"right"]);d&&(x=_(E,x)),m&&(R=_(S,R));const D=g.fn({...i,[E]:x,[S]:R});return{...D,data:{x:D.x-r,y:D.y-o,enabled:{[E]:d,[S]:m}}}}}},NC=function(n){return n===void 0&&(n={}),{options:n,fn(i){var r,o;const{x:c,y:f,placement:d,rects:m,middlewareData:g}=i,{offset:p=0,mainAxis:y=!0,crossAxis:v=!0}=Gi(n,i),S={x:c,y:f},E=Fn(d),x=Xh(E);let R=S[x],_=S[E];const D=Gi(p,i),A=typeof D=="number"?{mainAxis:D,crossAxis:0}:{mainAxis:(r=D.mainAxis)!=null?r:0,crossAxis:(o=D.crossAxis)!=null?o:0};if(y){const q=x==="y"?"height":"width",F=m.reference[x]-m.floating[q]+A.mainAxis,B=m.reference[x]+m.reference[q]-A.mainAxis;R<F?R=F:R>B&&(R=B)}if(v){var j,k;const q=x==="y"?"width":"height",F=hS.has(Dn(d)),B=m.reference[E]-m.floating[q]+(F&&((j=g.offset)==null?void 0:j[E])||0)+(F?0:A.crossAxis),L=m.reference[E]+m.reference[q]+(F?0:((k=g.offset)==null?void 0:k[E])||0)-(F?A.crossAxis:0);_<B?_=B:_>L&&(_=L)}return{[x]:R,[E]:_}}}},DC=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(i){const{placement:r,rects:o,platform:c,elements:f}=i,{apply:d=()=>{},...m}=Gi(n,i),g=await c.detectOverflow(i,m),p=Dn(r),y=zs(r),v=Fn(r)==="y",{width:S,height:E}=o.floating;let x,R;p==="top"||p==="bottom"?(x=p,R=y===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(R=p,x=y==="end"?"top":"bottom");const _=E-g.top-g.bottom,D=S-g.left-g.right,A=Oa(E-g[x],_),j=Oa(S-g[R],D),k=i.middlewareData.shift,q=!k;let F=A,B=j;k!=null&&k.enabled.x&&(B=D),k!=null&&k.enabled.y&&(F=_),q&&!y&&(v?B=S-2*Yi(g.left,g.right):F=E-2*Yi(g.top,g.bottom)),await d({...i,availableWidth:B,availableHeight:F});const L=await c.getDimensions(f.floating);return S!==L.width||E!==L.height?{reset:{rects:!0}}:{}}}};function mS(n){const i=zn(n);let r=parseFloat(i.width)||0,o=parseFloat(i.height)||0;const c=Rt(n),f=c?n.offsetWidth:r,d=c?n.offsetHeight:o,m=Qc(r)!==f||Qc(o)!==d;return m&&(r=f,o=d),{width:r,height:o,$:m}}function Jh(n){return Je(n)?n:n.contextElement}function la(n){const i=Jh(n);if(!Rt(i))return Vi(1);const r=i.getBoundingClientRect(),{width:o,height:c,$:f}=mS(i);let d=(f?Qc(r.width):r.width)/o,m=(f?Qc(r.height):r.height)/c;return(!d||!Number.isFinite(d))&&(d=1),(!m||!Number.isFinite(m))&&(m=1),{x:d,y:m}}const zC=Vi(0);function pS(n){const i=kt(n);return!qh()||!i.visualViewport?zC:{x:i.visualViewport.offsetLeft,y:i.visualViewport.offsetTop}}function kC(n,i,r){return i===void 0&&(i=!1),!!r&&i&&r===kt(n)}function ur(n,i,r,o){i===void 0&&(i=!1),r===void 0&&(r=!1);const c=n.getBoundingClientRect(),f=Jh(n);let d=Vi(1);i&&(o?Je(o)&&(d=la(o)):d=la(n));const m=kC(f,r,o)?pS(f):Vi(0);let g=(c.left+m.x)/d.x,p=(c.top+m.y)/d.y,y=c.width/d.x,v=c.height/d.y;if(f&&o){const S=kt(f),E=Je(o)?kt(o):o;let x=S,R=fh(x);for(;R&&E!==x;){const _=la(R),D=R.getBoundingClientRect(),A=zn(R),j=D.left+(R.clientLeft+parseFloat(A.paddingLeft))*_.x,k=D.top+(R.clientTop+parseFloat(A.paddingTop))*_.y;g*=_.x,p*=_.y,y*=_.x,v*=_.y,g+=j,p+=k,x=kt(R),R=fh(x)}}return Fc({width:y,height:v,x:g,y:p})}function au(n,i){const r=iu(n).scrollLeft;return i?i.left+r:ur(Xi(n)).left+r}function gS(n,i){const r=n.getBoundingClientRect(),o=r.left+i.scrollLeft-au(n,r),c=r.top+i.scrollTop;return{x:o,y:c}}function jC(n){let{elements:i,rect:r,offsetParent:o,strategy:c}=n;const f=c==="fixed",d=Xi(o),m=i?nu(i.floating):!1;if(o===d||m&&f)return r;let g={scrollLeft:0,scrollTop:0},p=Vi(1);const y=Vi(0),v=Rt(o);if((v||!f)&&(($t(o)!=="body"||pr(d))&&(g=iu(o)),v)){const E=ur(o);p=la(o),y.x=E.x+o.clientLeft,y.y=E.y+o.clientTop}const S=d&&!v&&!f?gS(d,g):Vi(0);return{width:r.width*p.x,height:r.height*p.y,x:r.x*p.x-g.scrollLeft*p.x+y.x+S.x,y:r.y*p.y-g.scrollTop*p.y+y.y+S.y}}function LC(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function UC(n){const i=iu(n),r=n.ownerDocument.body,o=Yi(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),c=Yi(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let f=-i.scrollLeft+au(n);const d=-i.scrollTop;return zn(r).direction==="rtl"&&(f+=Yi(n.clientWidth,r.clientWidth)-o),{width:o,height:c,x:f,y:d}}const BC=25;function HC(n,i,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",c=kt(n),f=Xi(n),d=c.visualViewport;let m=f.clientWidth,g=f.clientHeight,p=0,y=0;if(d){const S=!qh()||i==="fixed";o?S||(p=-d.offsetLeft,y=-d.offsetTop):(m=d.width,g=d.height,S&&(p=d.offsetLeft,y=d.offsetTop))}if(au(f)<=0){const S=f.ownerDocument,E=S.body,x=getComputedStyle(E),R=S.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,_=Math.abs(f.clientWidth-E.clientWidth-R),D=getComputedStyle(f).scrollbarGutter==="stable both-edges"?_/2:_;D<=BC&&(m-=D)}return{width:m,height:g,x:p,y}}function qC(n,i){const r=ur(n,!0,i==="fixed"),o=r.top+n.clientTop,c=r.left+n.clientLeft,f=la(n),d=n.clientWidth*f.x,m=n.clientHeight*f.y,g=c*f.x,p=o*f.y;return{width:d,height:m,x:g,y:p}}function $b(n,i,r){let o;if(i==="viewport"||i==="layoutViewport")o=HC(n,r,i);else if(i==="document")o=UC(Xi(n));else if(Je(i))o=qC(i,r);else{const c=pS(n);o={x:i.x-c.x,y:i.y-c.y,width:i.width,height:i.height}}return Fc(o)}function YC(n,i){const r=i.get(n);if(r)return r;let o=ko(n,[],!1).filter(m=>Je(m)&&$t(m)!=="body"),c=null;const f=zn(n).position==="fixed";let d=f?_s(n):n;for(;Je(d)&&!As(d);){const m=zn(d),g=Hh(d),p=c?c.position:f?"fixed":"";!g&&(p==="fixed"||p==="absolute"&&m.position==="static")?o=o.filter(v=>v!==d):c=m,d=_s(d)}return i.set(n,o),o}function VC(n){let{element:i,boundary:r,rootBoundary:o,strategy:c}=n;const d=[...r==="clippingAncestors"?nu(i)?[]:YC(i,this._c):[].concat(r),o],m=$b(i,d[0],c);let g=m.top,p=m.right,y=m.bottom,v=m.left;for(let S=1;S<d.length;S++){const E=$b(i,d[S],c);g=Yi(E.top,g),p=Oa(E.right,p),y=Oa(E.bottom,y),v=Yi(E.left,v)}return{width:p-v,height:y-g,x:v,y:g}}function GC(n){const{width:i,height:r}=mS(n);return{width:i,height:r}}function QC(n,i,r){const o=Rt(i),c=Xi(i),f=r==="fixed",d=ur(n,!0,f,i);let m={scrollLeft:0,scrollTop:0};const g=Vi(0);if((o||!f)&&(($t(i)!=="body"||pr(c))&&(m=iu(i)),o)){const S=ur(i,!0,f,i);g.x=S.x+i.clientLeft,g.y=S.y+i.clientTop}!o&&c&&(g.x=au(c));const p=c&&!o&&!f?gS(c,m):Vi(0),y=d.left+m.scrollLeft-g.x-p.x,v=d.top+m.scrollTop-g.y-p.y;return{x:y,y:v,width:d.width,height:d.height}}function qd(n){return zn(n).position==="static"}function ev(n,i){if(!Rt(n)||zn(n).position==="fixed")return null;if(i)return i(n);let r=n.offsetParent;return Xi(n)===r&&(r=r.ownerDocument.body),r}function yS(n,i){const r=kt(n);if(nu(n))return r;if(!Rt(n)){let c=_s(n);for(;c&&!As(c);){if(Je(c)&&!qd(c))return c;c=_s(c)}return r}let o=ev(n,i);for(;o&&FR(o)&&qd(o);)o=ev(o,i);return o&&As(o)&&qd(o)&&!Hh(o)?r:o||PR(n)||r}const XC=async function(n){const i=this.getOffsetParent||yS,r=this.getDimensions,o=await r(n.floating);return{reference:QC(n.reference,await i(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function FC(n){return zn(n).direction==="rtl"}const KC={convertOffsetParentRelativeRectToViewportRelativeRect:jC,getDocumentElement:Xi,getClippingRect:VC,getOffsetParent:yS,getElementRects:XC,getClientRects:LC,getDimensions:GC,getScale:la,isElement:Je,isRTL:FC};function bS(n,i){return n.x===i.x&&n.y===i.y&&n.width===i.width&&n.height===i.height}function ZC(n,i,r){let o=null,c;const f=Xi(n);function d(){var y;clearTimeout(c),(y=o)==null||y.disconnect(),o=null}function m(y,v){y===void 0&&(y=!1),v===void 0&&(v=1),d();const S=n.getBoundingClientRect(),{left:E,top:x,width:R,height:_}=S;if(y||i(),!R||!_)return;const D=Tc(x),A=Tc(f.clientWidth-(E+R)),j=Tc(f.clientHeight-(x+_)),k=Tc(E),F={rootMargin:-D+"px "+-A+"px "+-j+"px "+-k+"px",threshold:Yi(0,Oa(1,v))||1};let B=!0;function L(K){const se=K[0].intersectionRatio;if(!bS(S,n.getBoundingClientRect()))return m();if(se!==v){if(!B)return m();se?m(!1,se):c=setTimeout(()=>{m(!1,1e-7)},1e3)}B=!1}try{o=new IntersectionObserver(L,{...F,root:f.ownerDocument})}catch{o=new IntersectionObserver(L,F)}o.observe(n)}const g=kt(n),p=()=>m(r);return g.addEventListener("resize",p),m(!0),()=>{g.removeEventListener("resize",p),d()}}function tv(n,i,r,o){o===void 0&&(o={});const{ancestorScroll:c=!0,ancestorResize:f=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:m=typeof IntersectionObserver=="function",animationFrame:g=!1}=o,p=Jh(n),y=c||f?[...p?ko(p):[],...i?ko(i):[]]:[];y.forEach(D=>{c&&D.addEventListener("scroll",r),f&&D.addEventListener("resize",r)});const v=p&&m?ZC(p,r,f):null;let S=-1,E=null;d&&(E=new ResizeObserver(D=>{let[A]=D;A&&A.target===p&&E&&i&&(E.unobserve(i),cancelAnimationFrame(S),S=requestAnimationFrame(()=>{var j;(j=E)==null||j.observe(i)})),r()}),p&&!g&&E.observe(p),i&&E.observe(i));let x,R=g?ur(n):null;g&&_();function _(){const D=ur(n);R&&!bS(R,D)&&r(),R=D,x=requestAnimationFrame(_)}return r(),()=>{var D;y.forEach(A=>{c&&A.removeEventListener("scroll",r),f&&A.removeEventListener("resize",r)}),v==null||v(),(D=E)==null||D.disconnect(),E=null,g&&cancelAnimationFrame(x)}}const PC=_C,IC=MC,JC=OC,WC=DC,$C=CC,eA=NC,tA=(n,i,r)=>{const o=new Map,c=r??{},f={...KC,...c.platform,_c:o};return RC(n,i,{...c,platform:f})};var nA=typeof document<"u",iA=function(){},jc=nA?w.useLayoutEffect:iA;function Zc(n,i){if(n===i)return!0;if(typeof n!=typeof i)return!1;if(typeof n=="function"&&n.toString()===i.toString())return!0;let r,o,c;if(n&&i&&typeof n=="object"){if(Array.isArray(n)){if(r=n.length,r!==i.length)return!1;for(o=r;o--!==0;)if(!Zc(n[o],i[o]))return!1;return!0}if(c=Object.keys(n),r=c.length,r!==Object.keys(i).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(i,c[o]))return!1;for(o=r;o--!==0;){const f=c[o];if(!(f==="_owner"&&n.$$typeof)&&!Zc(n[f],i[f]))return!1}return!0}return n!==n&&i!==i}function vS(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function nv(n,i){const r=vS(n);return Math.round(i*r)/r}function Yd(n){const i=w.useRef(n);return jc(()=>{i.current=n}),i}function sA(n){n===void 0&&(n={});const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:c,elements:{reference:f,floating:d}={},transform:m=!0,whileElementsMounted:g,open:p}=n,[y,v]=w.useState({x:0,y:0,strategy:r,placement:i,middlewareData:{},isPositioned:!1}),[S,E]=w.useState(o);Zc(S,o)||E(o);const[x,R]=w.useState(null),[_,D]=w.useState(null),A=w.useCallback(I=>{I!==F.current&&(F.current=I,R(I))},[]),j=w.useCallback(I=>{I!==B.current&&(B.current=I,D(I))},[]),k=f||x,q=d||_,F=w.useRef(null),B=w.useRef(null),L=w.useRef(y),K=g!=null,se=Yd(g),pe=Yd(c),ae=Yd(p),W=w.useCallback(()=>{if(!F.current||!B.current)return;const I={placement:i,strategy:r,middleware:S};pe.current&&(I.platform=pe.current),tA(F.current,B.current,I).then(oe=>{const Y={...oe,isPositioned:ae.current!==!1};le.current&&!Zc(L.current,Y)&&(L.current=Y,Ns.flushSync(()=>{v(Y)}))})},[S,i,r,pe,ae]);jc(()=>{p===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,v(I=>({...I,isPositioned:!1})))},[p]);const le=w.useRef(!1);jc(()=>(le.current=!0,()=>{le.current=!1}),[]),jc(()=>{if(k&&(F.current=k),q&&(B.current=q),k&&q){if(se.current)return se.current(k,q,W);W()}},[k,q,W,se,K]);const ie=w.useMemo(()=>({reference:F,floating:B,setReference:A,setFloating:j}),[A,j]),N=w.useMemo(()=>({reference:k,floating:q}),[k,q]),Q=w.useMemo(()=>{const I={position:r,left:0,top:0};if(!N.floating)return I;const oe=nv(N.floating,y.x),Y=nv(N.floating,y.y);return m?{...I,transform:"translate("+oe+"px, "+Y+"px)",...vS(N.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:oe,top:Y}},[r,m,N.floating,y.x,y.y]);return w.useMemo(()=>({...y,update:W,refs:ie,elements:N,floatingStyles:Q}),[y,W,ie,N,Q])}const rA=(n,i)=>{const r=PC(n);return{name:r.name,fn:r.fn,options:[n,i]}},aA=(n,i)=>{const r=IC(n);return{name:r.name,fn:r.fn,options:[n,i]}},oA=(n,i)=>({fn:eA(n).fn,options:[n,i]}),lA=(n,i)=>{const r=JC(n);return{name:r.name,fn:r.fn,options:[n,i]}},cA=(n,i)=>{const r=WC(n);return{name:r.name,fn:r.fn,options:[n,i]}},uA=(n,i)=>{const r=$C(n);return{name:r.name,fn:r.fn,options:[n,i]}};function fA(n){const i=w.useRef(!0);i.current&&(i.current=!1,n())}const Ve=(n,i,r,o,c,f,...d)=>{if(d.length>0)throw new Error(fr(1));let m;if(n)m=n;else throw new Error("Missing arguments");return m};var Vd={exports:{}},Gd={};/**
105
105
  * @license React
106
106
  * use-sync-external-store-shim.production.js
107
107
  *