diff --git a/assets/index-80aa88ce.js b/assets/index-1b0cd671.js similarity index 99% rename from assets/index-80aa88ce.js rename to assets/index-1b0cd671.js index 4a183d5..963cc03 100644 --- a/assets/index-80aa88ce.js +++ b/assets/index-1b0cd671.js @@ -119,4 +119,4 @@ Error generating stack: `+s.message+` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[sw]=this[sw]={accessors:{}}).accessors,i=this.prototype;function s(o){const l=hl(o);r[l]||(IX(i,o),r[l]=!0)}return I.isArray(e)?e.forEach(s):s(e),this}}Cf.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);I.reduceDescriptors(Cf.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});I.freezeMethods(Cf);const Ur=Cf;function tp(t,e){const n=this||y0,r=e||n,i=Ur.from(r.headers);let s=r.data;return I.forEach(t,function(l){s=l.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function j$(t){return!!(t&&t.__CANCEL__)}function Wa(t,e,n){be.call(this,t??"canceled",be.ERR_CANCELED,e,n),this.name="CanceledError"}I.inherits(Wa,be,{__CANCEL__:!0});function NX(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new be("Request failed with status code "+n.status,[be.ERR_BAD_REQUEST,be.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const BX=br.hasStandardBrowserEnv?function(){return{write:function(n,r,i,s,o,l){const a=[];a.push(n+"="+encodeURIComponent(r)),I.isNumber(i)&&a.push("expires="+new Date(i).toGMTString()),I.isString(s)&&a.push("path="+s),I.isString(o)&&a.push("domain="+o),l===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function zX(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function jX(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}function Y$(t,e){return t&&!zX(e)?jX(t,e):e}const YX=br.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function i(s){let o=s;return e&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=i(window.location.href),function(o){const l=I.isString(o)?i(o):o;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}();function UX(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function XX(t,e){t=t||10;const n=new Array(t),r=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(a){const u=Date.now(),c=r[s];o||(o=u),n[i]=a,r[i]=u;let h=s,f=0;for(;h!==i;)f+=n[h++],h=h%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),u-o{const s=i.loaded,o=i.lengthComputable?i.total:void 0,l=s-n,a=r(l),u=s<=o;n=s;const c={loaded:s,total:o,progress:o?s/o:void 0,bytes:l,rate:a||void 0,estimated:a&&o&&u?(o-s)/a:void 0,event:i};c[e?"download":"upload"]=!0,t(c)}}const WX=typeof XMLHttpRequest<"u",FX=WX&&function(t){return new Promise(function(n,r){let i=t.data;const s=Ur.from(t.headers).normalize(),o=t.responseType;let l;function a(){t.cancelToken&&t.cancelToken.unsubscribe(l),t.signal&&t.signal.removeEventListener("abort",l)}let u;if(I.isFormData(i)){if(br.hasStandardBrowserEnv||br.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((u=s.getContentType())!==!1){const[p,...m]=u?u.split(";").map(y=>y.trim()).filter(Boolean):[];s.setContentType([p||"multipart/form-data",...m].join("; "))}}let c=new XMLHttpRequest;if(t.auth){const p=t.auth.username||"",m=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";s.set("Authorization","Basic "+btoa(p+":"+m))}const h=Y$(t.baseURL,t.url);c.open(t.method.toUpperCase(),I$(h,t.params,t.paramsSerializer),!0),c.timeout=t.timeout;function f(){if(!c)return;const p=Ur.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),y={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:p,config:t,request:c};NX(function(O){n(O),a()},function(O){r(O),a()},y),c=null}if("onloadend"in c?c.onloadend=f:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(f)},c.onabort=function(){c&&(r(new be("Request aborted",be.ECONNABORTED,t,c)),c=null)},c.onerror=function(){r(new be("Network Error",be.ERR_NETWORK,t,c)),c=null},c.ontimeout=function(){let m=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const y=t.transitional||N$;t.timeoutErrorMessage&&(m=t.timeoutErrorMessage),r(new be(m,y.clarifyTimeoutError?be.ETIMEDOUT:be.ECONNABORTED,t,c)),c=null},br.hasStandardBrowserEnv){const p=YX(h)&&t.xsrfCookieName&&BX.read(t.xsrfCookieName);p&&s.set(t.xsrfHeaderName,p)}i===void 0&&s.setContentType(null),"setRequestHeader"in c&&I.forEach(s.toJSON(),function(m,y){c.setRequestHeader(y,m)}),I.isUndefined(t.withCredentials)||(c.withCredentials=!!t.withCredentials),o&&o!=="json"&&(c.responseType=t.responseType),typeof t.onDownloadProgress=="function"&&c.addEventListener("progress",ow(t.onDownloadProgress,!0)),typeof t.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ow(t.onUploadProgress)),(t.cancelToken||t.signal)&&(l=p=>{c&&(r(!p||p.type?new Wa(null,t,c):p),c.abort(),c=null)},t.cancelToken&&t.cancelToken.subscribe(l),t.signal&&(t.signal.aborted?l():t.signal.addEventListener("abort",l)));const d=UX(h);if(d&&br.protocols.indexOf(d)===-1){r(new be("Unsupported protocol "+d+":",be.ERR_BAD_REQUEST,t));return}c.send(i||null)})},ug={http:OX,xhr:FX};I.forEach(ug,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const lw=t=>`- ${t}`,VX=t=>I.isFunction(t)||t===null||t===!1,U$={getAdapter:t=>{t=I.isArray(t)?t:[t];const{length:e}=t;let n,r;const i={};for(let s=0;s`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let o=e?s.length>1?`since : `+s.map(lw).join(` `):" "+lw(s[0]):"as no adapter specified";throw new be("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:ug};function np(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Wa(null,t)}function aw(t){return np(t),t.headers=Ur.from(t.headers),t.data=tp.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),U$.getAdapter(t.adapter||y0.adapter)(t).then(function(r){return np(t),r.data=tp.call(t,t.transformResponse,r),r.headers=Ur.from(r.headers),r},function(r){return j$(r)||(np(t),r&&r.response&&(r.response.data=tp.call(t,t.transformResponse,r.response),r.response.headers=Ur.from(r.response.headers))),Promise.reject(r)})}const uw=t=>t instanceof Ur?t.toJSON():t;function To(t,e){e=e||{};const n={};function r(u,c,h){return I.isPlainObject(u)&&I.isPlainObject(c)?I.merge.call({caseless:h},u,c):I.isPlainObject(c)?I.merge({},c):I.isArray(c)?c.slice():c}function i(u,c,h){if(I.isUndefined(c)){if(!I.isUndefined(u))return r(void 0,u,h)}else return r(u,c,h)}function s(u,c){if(!I.isUndefined(c))return r(void 0,c)}function o(u,c){if(I.isUndefined(c)){if(!I.isUndefined(u))return r(void 0,u)}else return r(void 0,c)}function l(u,c,h){if(h in e)return r(u,c);if(h in t)return r(void 0,u)}const a={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l,headers:(u,c)=>i(uw(u),uw(c),!0)};return I.forEach(Object.keys(Object.assign({},t,e)),function(c){const h=a[c]||i,f=h(t[c],e[c],c);I.isUndefined(f)&&h!==l||(n[c]=f)}),n}const X$="1.6.1",S0={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{S0[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const cw={};S0.transitional=function(e,n,r){function i(s,o){return"[Axios v"+X$+"] Transitional option '"+s+"'"+o+(r?". "+r:"")}return(s,o,l)=>{if(e===!1)throw new be(i(o," has been removed"+(n?" in "+n:"")),be.ERR_DEPRECATED);return n&&!cw[o]&&(cw[o]=!0,console.warn(i(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,o,l):!0}};function qX(t,e,n){if(typeof t!="object")throw new be("options must be an object",be.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const s=r[i],o=e[s];if(o){const l=t[s],a=l===void 0||o(l,s,t);if(a!==!0)throw new be("option "+s+" must be "+a,be.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new be("Unknown option "+s,be.ERR_BAD_OPTION)}}const cg={assertOptions:qX,validators:S0},ai=cg.validators;class Zh{constructor(e){this.defaults=e,this.interceptors={request:new iw,response:new iw}}request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=To(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&cg.assertOptions(r,{silentJSONParsing:ai.transitional(ai.boolean),forcedJSONParsing:ai.transitional(ai.boolean),clarifyTimeoutError:ai.transitional(ai.boolean)},!1),i!=null&&(I.isFunction(i)?n.paramsSerializer={serialize:i}:cg.assertOptions(i,{encode:ai.function,serialize:ai.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&I.merge(s.common,s[n.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),n.headers=Ur.concat(o,s);const l=[];let a=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(a=a&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let c,h=0,f;if(!a){const p=[aw.bind(this),void 0];for(p.unshift.apply(p,l),p.push.apply(p,u),f=p.length,c=Promise.resolve(n);h{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(l=>{r.subscribe(l),s=l}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},e(function(s,o,l){r.reason||(r.reason=new Wa(s,o,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}static source(){let e;return{token:new x0(function(i){e=i}),cancel:e}}}const HX=x0;function GX(t){return function(n){return t.apply(null,n)}}function KX(t){return I.isObject(t)&&t.isAxiosError===!0}const hg={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(hg).forEach(([t,e])=>{hg[e]=t});const JX=hg;function W$(t){const e=new vc(t),n=P$(vc.prototype.request,e);return I.extend(n,vc.prototype,e,{allOwnKeys:!0}),I.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return W$(To(t,i))},n}const ht=W$(y0);ht.Axios=vc;ht.CanceledError=Wa;ht.CancelToken=HX;ht.isCancel=j$;ht.VERSION=X$;ht.toFormData=bf;ht.AxiosError=be;ht.Cancel=ht.CanceledError;ht.all=function(e){return Promise.all(e)};ht.spread=GX;ht.isAxiosError=KX;ht.mergeConfig=To;ht.AxiosHeaders=Ur;ht.formToJSON=t=>z$(I.isHTMLForm(t)?new FormData(t):t);ht.getAdapter=U$.getAdapter;ht.HttpStatusCode=JX;ht.default=ht;const w0=ht,Fa=w0.create({baseURL:"http://101.101.208.240:3000"});async function eW(t){try{const{data:e}=await Fa.get(`/competitions/${t}`);return e}catch(e){return console.error("Error fetching competition data:",e),null}}async function tW(t){const{name:e,detail:n,maxParticipants:r,startsAt:i,endsAt:s,problems:o}=t;try{const l={name:e,detail:n,maxParticipants:r,startsAt:i,endsAt:s,problems:o},{data:a}=await Fa.post("/competitions",l);return a}catch(l){return console.error(l),null}}const $r=Object.create(null);$r.open="0";$r.close="1";$r.ping="2";$r.pong="3";$r.message="4";$r.upgrade="5";$r.noop="6";const bc=Object.create(null);Object.keys($r).forEach(t=>{bc[$r[t]]=t});const fg={type:"error",data:"parser error"},F$=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",V$=typeof ArrayBuffer=="function",q$=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,k0=({type:t,data:e},n,r)=>F$&&e instanceof Blob?n?r(e):hw(e,r):V$&&(e instanceof ArrayBuffer||q$(e))?n?r(e):hw(new Blob([e]),r):r($r[t]+(e||"")),hw=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function fw(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let rp;function nW(t,e){if(F$&&t.data instanceof Blob)return t.data.arrayBuffer().then(fw).then(e);if(V$&&(t.data instanceof ArrayBuffer||q$(t.data)))return e(fw(t.data));k0(t,!1,n=>{rp||(rp=new TextEncoder),e(rp.encode(n))})}const dw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bl=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t{let e=t.length*.75,n=t.length,r,i=0,s,o,l,a;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const u=new ArrayBuffer(e),c=new Uint8Array(u);for(r=0;r>4,c[i++]=(o&15)<<4|l>>2,c[i++]=(l&3)<<6|a&63;return u},iW=typeof ArrayBuffer=="function",v0=(t,e)=>{if(typeof t!="string")return{type:"message",data:H$(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:sW(t.substring(1),e)}:bc[n]?t.length>1?{type:bc[n],data:t.substring(1)}:{type:bc[n]}:fg},sW=(t,e)=>{if(iW){const n=rW(t);return H$(n,e)}else return{base64:!0,data:t}},H$=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},G$=String.fromCharCode(30),oW=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((s,o)=>{k0(s,!1,l=>{r[o]=l,++i===n&&e(r.join(G$))})})},lW=(t,e)=>{const n=t.split(G$),r=[];for(let i=0;i{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const s=new DataView(i.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{i=new Uint8Array(9);const s=new DataView(i.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let ip;function Uu(t){return t.reduce((e,n)=>e+n.length,0)}function Xu(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;iMath.pow(2,53-32)-1){l.enqueue(fg);break}i=c*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Uu(n)t){l.enqueue(fg);break}}}})}const K$=4;function ct(t){if(t)return cW(t)}function cW(t){for(var e in ct.prototype)t[e]=ct.prototype[e];return t}ct.prototype.on=ct.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};ct.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};ct.prototype.off=ct.prototype.removeListener=ct.prototype.removeAllListeners=ct.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;itypeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function J$(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const hW=_n.setTimeout,fW=_n.clearTimeout;function Pf(t,e){e.useNativeTimers?(t.setTimeoutFn=hW.bind(_n),t.clearTimeoutFn=fW.bind(_n)):(t.setTimeoutFn=_n.setTimeout.bind(_n),t.clearTimeoutFn=_n.clearTimeout.bind(_n))}const dW=1.33;function pW(t){return typeof t=="string"?mW(t):Math.ceil((t.byteLength||t.size)*dW)}function mW(t){let e=0,n=0;for(let r=0,i=t.length;r=57344?n+=3:(r++,n+=4);return n}function gW(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function OW(t){let e={},n=t.split("&");for(let r=0,i=n.length;r0);return e}function tQ(){const t=gw(+new Date);return t!==mw?(pw=0,mw=t):t+"."+gw(pw++)}for(;Wu{this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};lW(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,oW(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=tQ()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new po(this.uri(),e)}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}let po=class Cc extends ct{constructor(e,n){super(),Pf(this,n),this.opts=n,this.method=n.method||"GET",this.uri=e,this.data=n.data!==void 0?n.data:null,this.create()}create(){var e;const n=J$(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;const r=this.xhr=new rQ(n);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this.opts.extraHeaders[i])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this.opts.cookieJar)===null||i===void 0||i.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(i){this.setTimeoutFn(()=>{this.onError(i)},0);return}typeof document<"u"&&(this.index=Cc.requestsCount++,Cc.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=wW,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Cc.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};po.requestsCount=0;po.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Ow);else if(typeof addEventListener=="function"){const t="onpagehide"in _n?"pagehide":"unload";addEventListener(t,Ow,!1)}}function Ow(){for(let t in po.requests)po.requests.hasOwnProperty(t)&&po.requests[t].abort()}const C0=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0))(),Fu=_n.WebSocket||_n.MozWebSocket,yw=!0,bW="arraybuffer",Sw=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class CW extends b0{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),n=this.opts.protocols,r=Sw?{}:J$(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=yw&&!Sw?n?new Fu(e,n):new Fu(e):new Fu(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n{const o={};try{yw&&this.ws.send(s)}catch{}i&&C0(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=tQ()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}check(){return!!Fu}}class PW extends b0{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const n=uW(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=aW();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const s=()=>{r.read().then(({done:l,value:a})=>{l||(this.onPacket(a),s())}).catch(l=>{})};s();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let n=0;n{i&&C0(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const TW={websocket:CW,webtransport:PW,polling:vW},$W=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,QW=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function pg(t){if(t.length>2e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=$W.exec(t||""),s={},o=14;for(;o--;)s[QW[o]]=i[o]||"";return n!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=EW(s,s.path),s.queryKey=AW(s,s.query),s}function EW(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function AW(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,s){i&&(n[i]=s)}),n}let iQ=class Zs extends ct{constructor(e,n={}){super(),this.binaryType=bW,this.writeBuffer=[],e&&typeof e=="object"&&(n=e,e=null),e?(e=pg(e),n.hostname=e.host,n.secure=e.protocol==="https"||e.protocol==="wss",n.port=e.port,e.query&&(n.query=e.query)):n.host&&(n.hostname=pg(n.host).host),Pf(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=n.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,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},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=OW(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(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"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=K$,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new TW[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Zs.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",n=>this.onClose("transport close",n))}probe(e){let n=this.createTransport(e),r=!1;Zs.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Zs.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(c(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function s(){r||(r=!0,c(),n.close(),n=null)}const o=h=>{const f=new Error("probe error: "+h);f.transport=n.name,s(),this.emitReserved("upgradeError",f)};function l(){o("transport closed")}function a(){o("socket closed")}function u(h){n&&h.name!==n.name&&s()}const c=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",l),this.off("close",a),this.off("upgrading",u)};n.once("open",i),n.once("error",o),n.once("close",l),this.once("close",a),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onOpen(){if(this.readyState="open",Zs.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const n=this.upgrades.length;for(;e{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r0&&n>this.maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}write(e,n,r){return this.sendPacket("message",e,n,r),this}send(e,n,r){return this.sendPacket("message",e,n,r),this}sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:e,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){Zs.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,n){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const n=[];let r=0;const i=e.length;for(;rtypeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,sQ=Object.prototype.toString,ZW=typeof Blob=="function"||typeof Blob<"u"&&sQ.call(Blob)==="[object BlobConstructor]",MW=typeof File=="function"||typeof File<"u"&&sQ.call(File)==="[object FileConstructor]";function P0(t){return _W&&(t instanceof ArrayBuffer||DW(t))||ZW&&t instanceof Blob||MW&&t instanceof File}function Pc(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n=0&&t.num{delete this.acks[e];for(let o=0;o{this.io.clearTimeoutFn(s),n.apply(this,[null,...o])}}emitWithAck(e,...n){const r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((i,s)=>{n.push((o,l)=>r?o?s(o):i(l):i(o)),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...s)=>r!==this._queue[0]?void 0:(i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:xe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case xe.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case xe.EVENT:case xe.BINARY_EVENT:this.onevent(e);break;case xe.ACK:case xe.BINARY_ACK:this.onack(e);break;case xe.DISCONNECT:this.ondisconnect();break;case xe.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:xe.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(n.apply(this,e.data),delete this.acks[e.id])}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r0&&t.jitter<=1?t.jitter:0,this.attempts=0}zo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+n:t-n}return Math.min(t,this.max)|0};zo.prototype.reset=function(){this.attempts=0};zo.prototype.setMin=function(t){this.ms=t};zo.prototype.setMax=function(t){this.max=t};zo.prototype.setJitter=function(t){this.jitter=t};class Og extends ct{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Pf(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new zo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||YW;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new iQ(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Hn(n,"open",function(){r.onopen(),e&&e()}),s=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),e?e(l):this.maybeReconnectOnOpen()},o=Hn(n,"error",s);if(this._timeout!==!1){const l=this._timeout,a=this.setTimeoutFn(()=>{i(),s(new Error("timeout")),n.close()},l);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Hn(e,"ping",this.onping.bind(this)),Hn(e,"data",this.ondata.bind(this)),Hn(e,"error",this.onerror.bind(this)),Hn(e,"close",this.onclose.bind(this)),Hn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){C0(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new oQ(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;re()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,n){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const fl={};function Tc(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=RW(t,e.path||"/socket.io"),r=n.source,i=n.id,s=n.path,o=fl[i]&&s in fl[i].nsps,l=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let a;return l?a=new Og(r,e):(fl[i]||(fl[i]=new Og(r,e)),a=fl[i]),n.query&&!e.query&&(e.query=n.queryKey),a.socket(n.path,e)}Object.assign(Tc,{Manager:Og,Socket:oQ,io:Tc,connect:Tc});const XW="http://101.101.208.240:3000";function WW(t,e={}){return Tc(`${XW}${t}`,e)}const Ca=t=>!!(Object.is(t,null)||Object.is(t,void 0)),FW={id:0,name:"Competition Not Found",detail:"Competition Not Found",maxParticipants:0,startsAt:"Competition Not Found",endsAt:"Competition Not Found",createdAt:"Competition Not Found",updatedAt:"Competition Not Found"},VW=t=>{const[e,n]=R.useState(FW),r=R.useRef(WW("/competitions",{transports:["websocket"],query:{competitionId:t},auth:{token:`${localStorage.getItem("accessToken")}`}})),i=()=>{console.log("connected!")},s=()=>{console.log("disconnected!")};R.useEffect(()=>{r.current.hasListeners("connect")||r.current.on("connect",i),r.current.hasListeners("disconnect")||r.current.on("disconnect",s)},[]);function o(a){r.current.emit("submissions",{...a})}async function l(a){const u=await eW(a);if(Ca(u)){alert("대회 정보 패치에 실패했습니다.");return}n(u)}return R.useEffect(()=>{l(t)},[t]),{socket:r,competition:e,submitSolution:o}},qW=1e3,HW=60*qW;function GW(t){const e=t.getTimezoneOffset()*HW;return new Date(t.getTime()-e)}const KW=(t,e)=>e==="YYYY-MM-DDThh:mm"?t.toISOString().slice(0,16):"",JW=5*60*1e3,dl={needLongName:"이름은 1글자 이상이어야합니다",needMoreParticipants:"최대 참여 인원은 1명 이상이어야 합니다",tooEarlyStartTime:"대회 시작 시간은 현재보다 5분 늦은 시간부터 가능합니다",tooEarlyEndTime:"대회 종료 시간은 대회 시작시간보다 늦게 끝나야합니다",needMoreProblems:"대회 문제는 1개 이상이어야합니다"};function eF(t={}){const[e,n]=R.useState(t.name??""),[r,i]=R.useState(t.detail??""),[s,o]=R.useState(t.maxParticipants??1),l=GW(new Date),a=KW(l,"YYYY-MM-DDThh:mm"),[u,c]=R.useState(t.startsAt??a),[h,f]=R.useState(t.endsAt??a),[d,p]=R.useState([]);function m(S){d.includes(S)?p(x=>x.filter(v=>v!==S).sort()):p(x=>[...x,S].sort())}function y(){return{name:e,detail:r,maxParticipants:s,startsAt:new Date(u).toISOString(),endsAt:new Date(h).toISOString(),problems:d}}async function g(S){return await tW(S)}function O(S){const{name:x,maxParticipants:v,startsAt:k,endsAt:T,problems:E}=S;return x.length<=0?{isValid:!1,message:dl.needLongName}:v<=0?{isValid:!1,message:dl.needMoreParticipants}:new Date(k)<=new Date(Date.now()+JW)?{isValid:!1,message:dl.tooEarlyStartTime}:new Date(T)<=new Date(k)?{isValid:!1,message:dl.tooEarlyEndTime}:E.length<=0?{isValid:!1,message:dl.needMoreProblems}:{isValid:!0}}return{name:e,detail:r,maxParticipants:s,startsAt:u,endsAt:h,problems:d,setName:n,setDetail:i,setMaxParticipants:o,setStartsAt:c,setEndsAt:f,togglePickedProblem:m,getAllFormData:y,submitCompetition:g,validateForm:O}}async function tF(){try{const{data:t}=await Fa.get("/problems");return t}catch(t){return console.error(t),[]}}async function nF(t){try{const{data:e}=await Fa.get(`/competitions/${t}/problems`);return e}catch(e){return console.error(e),[]}}async function rF(t){try{const{data:e}=await Fa.get(`/competitions/problems/${t}/`);return e}catch(e){return console.error(e),null}}function iF(t){const[e,n]=R.useState([]);async function r(i){const s=await nF(i);n(s)}return R.useEffect(()=>{r(t)},[t]),{problemList:e}}const sF={id:0,title:"Problem Not Found",timeLimit:0,memoryLimit:0,content:"The requested problem could not be found.",solutionCode:"",testcases:[""],createdAt:new Date().toISOString()},oF=t=>{const[e,n]=R.useState(sF);async function r(i){if(i<0)return;const s=await rF(i);if(Ca(s)){alert("문제를 가져오는데 실패했습니다.");return}n(s)}return R.useEffect(()=>{r(t)},[t]),{problem:e}};function lF(){const[t,e]=R.useState([]);async function n(){const r=await tF();e(r)}return R.useEffect(()=>{n()},[]),{problemList:t}}function aF(t=[]){function e(r){t.forEach(i=>i(r))}function n(r){return t.push(r),()=>{t=t.filter(i=>i!==r)}}return{subscribe:n,notify:e}}function uF(t,e,n){return{type:"EVAL",clientId:t,code:e,param:n}}function cF(){return new Worker("/web12-algo-with-me/assets/eval.worker-5e5bbfd4.js",{type:"module"})}const lQ=()=>({isIdle:!0,worker:new cF,currentTask:null});class hF{constructor(e,n){tu(this,"queuedTasks",[]);tu(this,"evaluators",[]);tu(this,"taskEndNotifier");this.taskEndNotifier=e,this.evaluators=n,this.setupEvaluators()}setupEvaluators(){this.evaluators.forEach(e=>{const{worker:n}=e,r=({data:i})=>{this.receiveTaskEnd(i,e)};n.addEventListener("message",r)})}queueTasks(e){this.queuedTasks.push(...e)}isWorking(){const e=this.queuedTasks.length>0,n=this.evaluators.some(r=>!r.isIdle);return e||n}popTask(){return this.queuedTasks.shift()}deployTask(){const e=this.evaluators.find(r=>r.isIdle);if(!e)return;const n=this.queuedTasks.shift();n&&(e.isIdle=!1,e.currentTask=n,e.worker.postMessage(n),this.queuedTasks.length>0&&this.deployTask())}receiveTaskEnd({result:e,error:n},r){this.taskEndNotifier.notify({result:e,error:n,task:r.currentTask}),r.isIdle=!0,r.currentTask=null,this.deployTask()}notifyTaskCanceled(e){this.taskEndNotifier.notify({result:void 0,error:{name:"Error",message:"실행 중단",stack:""},task:e})}cancelTasks(){const e=[...this.queuedTasks],n=this.evaluators.map(({currentTask:r})=>r);[...e,...n].forEach(r=>{this.notifyTaskCanceled(r)}),this.queuedTasks=[]}setNewWorkers(e){this.evaluators=e,this.setupEvaluators()}}const aQ=3,uQ=aF(),cQ=p0(0,aQ).map(lQ),jl=new hF(uQ,cQ);function fF(t){return jl.isWorking()?!1:(console.log("input tasks"),jl.queueTasks(t),jl.deployTask(),!0)}function dF(){cQ.forEach(({worker:e})=>e.terminate()),jl.cancelTasks();const t=p0(0,aQ).map(lQ);jl.setNewWorkers(t)}function pF(t){uQ.subscribe(t)}const Vu={evaluate:fF,cancelEvaluation:dF,subscribe:pF,createEvalMessage:uF},mF=()=>{const[t,e]=R.useState([{id:1,input:""},{id:2,input:""},{id:3,input:""},{id:4,input:""},{id:5,input:""}]),[n,r]=R.useState([{id:1,isDone:!0,input:"",output:""},{id:2,isDone:!0,input:"",output:""},{id:3,isDone:!0,input:"",output:""},{id:4,isDone:!0,input:"",output:""},{id:5,isDone:!0,input:"",output:""}]),i=R.useMemo(()=>n.some(a=>!a.isDone),[n]);R.useEffect(()=>Vu.subscribe(({result:a,error:u,task:c})=>{console.log("receive tasks",a,c),c&&r(h=>h.map(f=>f.id!==c.clientId?f:u?{...f,isDone:!0,output:`${u.name}: ${u.message} -${u.stack}`}:{...f,isDone:!0,output:a}))}),[]);function s(a){const u=t.map(({id:h,input:f})=>Vu.createEvalMessage(h,a,f));Vu.evaluate(u)&&r(h=>h.map((f,d)=>({...f,input:t[d].input})).map(gF))}function o(a,u){const c=t.find(({id:h})=>h===a);c&&(c.input=u),e([...t])}function l(){Vu.cancelEvaluation()}return{simulationInputs:t,simulationResults:n,isSimulating:i,runSimulation:s,cancelSimulation:l,changeInput:o}},gF=t=>({...t,output:"계산중...",isDone:!1}),OF="테스트 실행",yF="실행 취소";function SF(){const{id:t}=qv(),e=t?parseInt(t,10):-1,[n,r]=R.useState(0),{simulationInputs:i,simulationResults:s,isSimulating:o,runSimulation:l,changeInput:a,cancelSimulation:u}=mF(),{socket:c,competition:h,submitSolution:f}=VW(e),{problemList:d}=iF(e),p=R.useMemo(()=>d.length>0?d[n]:null,[d,n]),{problem:m}=oF((p==null?void 0:p.id)??-1),[y,g]=R.useState(m.solutionCode);R.useEffect(()=>{g(m.solutionCode)},[m.solutionCode]);const O=[og.NAME,h.name,m.title],S=_=>{g(_)},x=()=>{l(y)},v=()=>{u()},k=(_,C)=>{a(_,C)},T=()=>{r(n+1)};function E(){if(Ca(p)){console.error("존재하지 않는 문제입니다.");return}const _={problemId:p.id,code:y,competitionId:e};f(_)}return Q.jsxs("main",{className:xF,children:[Q.jsx("button",{onClick:T,children:"다음 문제"}),Q.jsx(XR,{crumbs:O}),Q.jsx("section",{children:Q.jsx("span",{className:vF,children:m.title})}),Q.jsxs("section",{className:wF,children:[Q.jsx(C$,{content:m.content}),Q.jsxs("div",{className:kF,children:[Q.jsx(qN,{code:m.solutionCode,onChangeCode:S}),Q.jsx($U,{inputList:i,onChangeInput:k}),Q.jsx(RU,{resultList:s}),o?Q.jsx("button",{className:ww,onClick:v,children:yF}):Q.jsx("button",{className:ww,onClick:x,children:OF})]})]}),Q.jsxs("section",{children:[Q.jsx(ZU,{socket:c.current}),Q.jsx("button",{onClick:E,children:"제출하기"})]})]})}const xF=Re({backgroundColor:"#1e1e1e",color:"#ffffff"}),wF=Re({display:"flex"}),kF=Re({display:"flex",flexDirection:"column"}),vF=Re({display:"inline-block",height:"50px",padding:"10px",borderBottom:"2px solid white"}),ww=Re({color:"black"});function Jt({id:t,label:e,children:n,...r}){const i=R.Children.only(n);return Q.jsxs("div",{...r,children:[Q.jsx("label",{htmlFor:t,children:e}),R.cloneElement(i,{id:t,...i.props})]})}Jt.TextField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"text",ref:n,...e}));const Tf=Re({border:"1px solid black",width:"20rem"});Jt.TextArea=R.forwardRef(({className:t,...e},n)=>Q.jsx("textarea",{className:nf(Tf,t),ref:n,...e}));Jt.NumberField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"number",ref:n,...e}));Jt.DateTimeField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"datetime-local",ref:n,...e}));const bF=({problemList:t,pickedProblemIds:e,onSelectProblem:n})=>{function r(i){const s=i.target;if(s.tagName!=="BUTTON")return;const o=s.closest("li");if(!o)return;const l=Number(o.dataset.problemId);n(l)}return Q.jsx("ul",{onClick:r,children:t.map(({id:i,title:s})=>Q.jsxs("li",{"data-problem-id":i,children:[Q.jsxs("span",{children:[i,": ",s]}),Q.jsx(CF,{isPicked:e.includes(i)})]},i))})},CF=({isPicked:t})=>t?Q.jsx("button",{children:"취소"}):Q.jsx("button",{children:"선택"});function PF(){const t=gO(),e=eF(),{problemList:n}=lF();function r(c){const h=c.target.value;e.setName(h)}function i(c){const h=c.target.value;e.setDetail(h)}function s(c){const h=Number(c.target.value);e.setMaxParticipants(h)}function o(c){const h=c.target.value;e.setStartsAt(h)}function l(c){const h=c.target.value;e.setEndsAt(h)}function a(c){e.togglePickedProblem(c)}async function u(){const c=e.getAllFormData(),{isValid:h,message:f}=e.validateForm(c);if(!h){Ca(f)||alert(f);return}const d=await e.submitCompetition(c);if(Ca(d)){alert("Oops... 대회 생성에 실패했습니다");return}const p=`/contest/detail/${d.id}`;t(p)}return Q.jsxs("main",{children:[Q.jsx("h1",{children:"대회 생성 하기"}),Q.jsxs("fieldset",{className:TF,children:[Q.jsx(Jt,{label:"대회 이름",children:Q.jsx(Jt.TextField,{name:"name",value:e.name,onChange:r,placeholder:"대회 이름을 입력해주세요",required:!0})}),Q.jsx(Jt,{label:"대회 설명",children:Q.jsx(Jt.TextArea,{name:"detail",value:e.detail,onChange:i,placeholder:"대회 설명을 입력해주세요",required:!0})}),Q.jsx(Jt,{label:"최대 참여 인원 (1명 이상)",children:Q.jsx(Jt.NumberField,{name:"max-participants",value:e.maxParticipants,min:"1",onChange:s,required:!0})}),Q.jsx(Jt,{label:"대회 시작 시간 (현재 시간보다 5분 늦은 시간부터 가능합니다)",children:Q.jsx(Jt.DateTimeField,{name:"starts-at",value:e.startsAt,onChange:o,required:!0})}),Q.jsx(Jt,{label:"대회 종료 시간",children:Q.jsx(Jt.DateTimeField,{name:"ends-at",value:e.endsAt,onChange:l,required:!0})}),Q.jsx(bF,{problemList:n,pickedProblemIds:e.problems,onSelectProblem:a}),Q.jsxs("div",{children:["선택된 문제: ",[...e.problems].join(",")]})]}),Q.jsx("button",{onClick:u,children:"대회 생성"})]})}const TF=Re({display:"flex",flexDirection:"column"});function $F({onClickLogin:t}){return Q.jsxs("section",{className:QF,children:[Q.jsx("header",{className:EF,children:"Algo With Me"}),Q.jsx("button",{onClick:t,children:"Github으로 로그인"})]})}const QF=Re({border:"1px solid white",borderRadius:"10px",width:"100%",height:"100%",maxWidth:"500px",maxHeight:"200px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),EF=Re({fontSize:"3rem",fontWeight:"bold",textAlign:"center",padding:"1rem"}),AF="http://101.101.208.240:3000/auths/github";function RF(){const t=()=>{try{window.location.href=AF}catch(e){console.error(e.message)}};return Q.jsx($F,{onClickLogin:t})}function _F({size:t}){return Q.jsx("img",{src:"./algo.png",alt:"logo",width:t,height:t})}const qu="accessToken",DF="http://101.101.208.240:3000",ZF="/auths/tests",MF=`${DF}${ZF}`,LF=async t=>{try{const e=await w0.get(MF,{headers:{Authorization:`Bearer ${t}`}}),n=await e.data;if(console.log(n,"인증 받음."),e.status===200)return!0}catch(e){return console.log("인증 받지 못함.",e),!1}};function IF(){const{isLoggedin:t,login:e,logout:n}=R.useContext(Jv),r=Ra(),i=gO();R.useEffect(()=>{if(t)return;const h=new URLSearchParams(r.search).get(qu)||localStorage.getItem(qu);h&&s(h)},[]);const s=async c=>{await LF(c)?o(c):l()},o=c=>{localStorage.setItem(qu,c),e()},l=()=>{localStorage.removeItem(qu),n()};return{changeLoginInfo:()=>{l(),i("/login")},changeLogoutInfo:()=>{l()},isLoggedin:t}}function NF(){const{changeLoginInfo:t,changeLogoutInfo:e,isLoggedin:n}=IF(),r=()=>{t()},i=()=>{e()};return Q.jsxs("header",{className:BF,children:[Q.jsx(_F,{size:"36px"}),n?Q.jsx("button",{onClick:i,children:" 로그아웃 "}):Q.jsx("button",{onClick:r,children:" 로그인 "})]})}const BF=Re({width:"100%",height:"40px",display:"flex",alignItems:"center",justifyContent:"space-between"});function zF(){return Q.jsx(eh,{to:"/contest/create",children:Q.jsx("button",{children:"대회 생성"})})}function jF(){return Q.jsx("button",{children:"참여하기"})}function YF(t){const e=`/contest/dashboard/${t.id}`;return Q.jsx(eh,{to:e,children:Q.jsx("button",{children:"대시보드 보기"})})}function UF(t){const e=Math.floor(t/864e5),n=Math.floor(t%(1e3*60*60*24)/(1e3*60*60)),r=Math.floor(t%(1e3*60*60)/(1e3*60)),i=Math.floor(t%(1e3*60)/1e3);return{days:e,hours:n,minutes:r,seconds:i}}const XF=()=>[{id:1,name:"테스트 대회 이름",detail:"테스트 대회 설명",maxParticipants:70,startsAt:"2023-11-14T08:35:24.358Z",endsAt:"2023-11-20T12:13:04.005Z",createdAt:"2023-11-14T08:35:24.358Z",updatedAt:"2023-11-21T02:28:43.955Z"},{id:2,name:"ICPC 서울",detail:"이거슨 아이씨피씨입니다",maxParticipants:1e3,startsAt:"2023-11-21T07:10:44.456Z",endsAt:"2023-11-21T10:10:44.456Z",createdAt:"2023-11-21T07:50:58.686Z",updatedAt:"2023-11-21T07:50:58.686Z"},{id:3,name:"천하제일코딩대회",detail:"^오^",maxParticipants:10,startsAt:"2023-11-21T07:10:44.456Z",endsAt:"2023-11-21T10:10:44.456Z",createdAt:"2023-11-21T07:57:07.563Z",updatedAt:"2023-11-21T07:57:07.563Z"},{id:4,name:"fe테스트대회",detail:"가나다라마바사",maxParticipants:3,startsAt:"2023-11-22T01:20:00.000Z",endsAt:"2023-11-23T01:20:00.000Z",createdAt:"2023-11-22T10:22:03.723Z",updatedAt:"2023-11-22T10:22:03.723Z"},{id:5,name:"가나다라",detail:"마바사아자차카타파하",maxParticipants:3,startsAt:"2023-11-23T03:00:00.000Z",endsAt:"2023-11-23T04:00:00.000Z",createdAt:"2023-11-22T12:00:46.942Z",updatedAt:"2023-11-22T12:00:46.942Z"}],WF=t=>`/contest/detail/${t}`;function FF(t,e){const n=new Date,r=new Date(t);if(new Date(e).getTime()n.getTime()){const s=r.getTime()-n.getTime(),{days:o,hours:l,minutes:a,seconds:u}=UF(s);return`시작까지 ${o}일 ${l}:${a}:${u}`}else return"진행중"}function VF(){const[t,e]=R.useState([]);return R.useEffect(()=>{const n=XF();e(n)},[]),Q.jsx("div",{children:Q.jsxs("table",{children:[Q.jsx("thead",{children:Q.jsxs("tr",{children:[Q.jsx("th",{children:"대회 이름"}),Q.jsx("th",{children:"시작 시간"}),Q.jsx("th",{children:"종료 시간"}),Q.jsx("th",{children:"상태"}),Q.jsx("th",{children:"참여"}),Q.jsx("th",{children:"대시보드"})]})}),Q.jsx("tbody",{children:t.map(n=>Q.jsxs("tr",{children:[Q.jsx("td",{children:Q.jsx(eh,{to:WF(n.id),children:n.name})}),Q.jsx("td",{children:new Date(n.startsAt).toLocaleString()}),Q.jsx("td",{children:new Date(n.endsAt).toLocaleString()}),Q.jsx("td",{children:FF(n.startsAt,n.endsAt)}),Q.jsx("td",{children:n.startsAt>new Date().toISOString()&&Q.jsx(jF,{})}),Q.jsx("td",{children:Q.jsx(YF,{id:n.id})}),Q.jsx("td",{children:Q.jsx(eh,{to:`/contest/${n.id}`,children:"대회 참여"})})]},n.id))})]})})}function qF(){return Q.jsxs(Q.Fragment,{children:[Q.jsx(NF,{}),Q.jsxs("main",{className:GF,children:[Q.jsxs("span",{className:HF,children:[og.NAME," "]}),Q.jsxs("span",{children:[og.PAGE_DESCRIPTION," "]}),Q.jsx(zF,{}),Q.jsx(VF,{})]})]})}const HF=Re({fontSize:"70px"}),GF=Re({display:"grid",placeItems:"center",height:"500px"}),KF="http://101.101.208.240:3000/problems/",JF=async(t,e,n)=>{try{const i=(await w0.get(`${KF}${t}`)).data;e(i)}catch(r){console.error("Error fetching problem:",r.message)}finally{n(!1)}};function e9(){const{id:t}=qv(),e=t?parseInt(t,10):-1,[n,r]=R.useState(null),[i,s]=R.useState(!0);return R.useEffect(()=>{JF(e,r,s)},[e]),i?Q.jsx("p",{children:"Loading..."}):n?Q.jsxs("main",{className:t9,children:[Q.jsx("span",{className:n9,children:n.title}),Q.jsx(C$,{content:n.content})]}):Q.jsx("p",{children:"Error loading problem data"})}const t9=Re({backgroundColor:"#1e1e1e",color:"#ffffff"}),n9=Re({display:"inline-block",height:"50px",padding:"10px",borderBottom:"2px solid white"});function r9(){return Q.jsx(qA,{})}const i9=nR([{path:"/",element:Q.jsx(r9,{}),children:[{index:!0,element:Q.jsx(qF,{})},{path:"/contest/:id",element:Q.jsx(SF,{})},{path:"/problem/:id",element:Q.jsx(e9,{})},{path:"/contest/create",element:Q.jsx(PF,{})},{path:"/login",element:Q.jsx(RF,{})}]}],{basename:"/web12-Algo-With-Me"});sp.createRoot(document.getElementById("root")).render(Q.jsx(Rw.StrictMode,{children:Q.jsx(gR,{children:Q.jsx(hR,{router:i9})})})); +${u.stack}`}:{...f,isDone:!0,output:a}))}),[]);function s(a){const u=t.map(({id:h,input:f})=>Vu.createEvalMessage(h,a,f));Vu.evaluate(u)&&r(h=>h.map((f,d)=>({...f,input:t[d].input})).map(gF))}function o(a,u){const c=t.find(({id:h})=>h===a);c&&(c.input=u),e([...t])}function l(){Vu.cancelEvaluation()}return{simulationInputs:t,simulationResults:n,isSimulating:i,runSimulation:s,cancelSimulation:l,changeInput:o}},gF=t=>({...t,output:"계산중...",isDone:!1}),OF="테스트 실행",yF="실행 취소";function SF(){const{id:t}=qv(),e=t?parseInt(t,10):-1,[n,r]=R.useState(0),{simulationInputs:i,simulationResults:s,isSimulating:o,runSimulation:l,changeInput:a,cancelSimulation:u}=mF(),{socket:c,competition:h,submitSolution:f}=VW(e),{problemList:d}=iF(e),p=R.useMemo(()=>d.length>0?d[n]:null,[d,n]),{problem:m}=oF((p==null?void 0:p.id)??-1),[y,g]=R.useState(m.solutionCode);R.useEffect(()=>{g(m.solutionCode)},[m.solutionCode]);const O=[og.NAME,h.name,m.title],S=_=>{g(_)},x=()=>{l(y)},v=()=>{u()},k=(_,C)=>{a(_,C)},T=()=>{r(n+1)};function E(){if(Ca(p)){console.error("존재하지 않는 문제입니다.");return}const _={problemId:p.id,code:y,competitionId:e};f(_)}return Q.jsxs("main",{className:xF,children:[Q.jsx("button",{onClick:T,children:"다음 문제"}),Q.jsx(XR,{crumbs:O}),Q.jsx("section",{children:Q.jsx("span",{className:vF,children:m.title})}),Q.jsxs("section",{className:wF,children:[Q.jsx(C$,{content:m.content}),Q.jsxs("div",{className:kF,children:[Q.jsx(qN,{code:m.solutionCode,onChangeCode:S}),Q.jsx($U,{inputList:i,onChangeInput:k}),Q.jsx(RU,{resultList:s}),o?Q.jsx("button",{className:ww,onClick:v,children:yF}):Q.jsx("button",{className:ww,onClick:x,children:OF})]})]}),Q.jsxs("section",{children:[Q.jsx(ZU,{socket:c.current}),Q.jsx("button",{onClick:E,children:"제출하기"})]})]})}const xF=Re({backgroundColor:"#1e1e1e",color:"#ffffff"}),wF=Re({display:"flex"}),kF=Re({display:"flex",flexDirection:"column"}),vF=Re({display:"inline-block",height:"50px",padding:"10px",borderBottom:"2px solid white"}),ww=Re({color:"black"});function Jt({id:t,label:e,children:n,...r}){const i=R.Children.only(n);return Q.jsxs("div",{...r,children:[Q.jsx("label",{htmlFor:t,children:e}),R.cloneElement(i,{id:t,...i.props})]})}Jt.TextField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"text",ref:n,...e}));const Tf=Re({border:"1px solid black",width:"20rem"});Jt.TextArea=R.forwardRef(({className:t,...e},n)=>Q.jsx("textarea",{className:nf(Tf,t),ref:n,...e}));Jt.NumberField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"number",ref:n,...e}));Jt.DateTimeField=R.forwardRef(({className:t,...e},n)=>Q.jsx("input",{className:nf(Tf,t),type:"datetime-local",ref:n,...e}));const bF=({problemList:t,pickedProblemIds:e,onSelectProblem:n})=>{function r(i){const s=i.target;if(s.tagName!=="BUTTON")return;const o=s.closest("li");if(!o)return;const l=Number(o.dataset.problemId);n(l)}return Q.jsx("ul",{onClick:r,children:t.map(({id:i,title:s})=>Q.jsxs("li",{"data-problem-id":i,children:[Q.jsxs("span",{children:[i,": ",s]}),Q.jsx(CF,{isPicked:e.includes(i)})]},i))})},CF=({isPicked:t})=>t?Q.jsx("button",{children:"취소"}):Q.jsx("button",{children:"선택"});function PF(){const t=gO(),e=eF(),{problemList:n}=lF();function r(c){const h=c.target.value;e.setName(h)}function i(c){const h=c.target.value;e.setDetail(h)}function s(c){const h=Number(c.target.value);e.setMaxParticipants(h)}function o(c){const h=c.target.value;e.setStartsAt(h)}function l(c){const h=c.target.value;e.setEndsAt(h)}function a(c){e.togglePickedProblem(c)}async function u(){const c=e.getAllFormData(),{isValid:h,message:f}=e.validateForm(c);if(!h){Ca(f)||alert(f);return}const d=await e.submitCompetition(c);if(Ca(d)){alert("Oops... 대회 생성에 실패했습니다");return}const p=`/contest/detail/${d.id}`;t(p)}return Q.jsxs("main",{children:[Q.jsx("h1",{children:"대회 생성 하기"}),Q.jsxs("fieldset",{className:TF,children:[Q.jsx(Jt,{label:"대회 이름",children:Q.jsx(Jt.TextField,{name:"name",value:e.name,onChange:r,placeholder:"대회 이름을 입력해주세요",required:!0})}),Q.jsx(Jt,{label:"대회 설명",children:Q.jsx(Jt.TextArea,{name:"detail",value:e.detail,onChange:i,placeholder:"대회 설명을 입력해주세요",required:!0})}),Q.jsx(Jt,{label:"최대 참여 인원 (1명 이상)",children:Q.jsx(Jt.NumberField,{name:"max-participants",value:e.maxParticipants,min:"1",onChange:s,required:!0})}),Q.jsx(Jt,{label:"대회 시작 시간 (현재 시간보다 5분 늦은 시간부터 가능합니다)",children:Q.jsx(Jt.DateTimeField,{name:"starts-at",value:e.startsAt,onChange:o,required:!0})}),Q.jsx(Jt,{label:"대회 종료 시간",children:Q.jsx(Jt.DateTimeField,{name:"ends-at",value:e.endsAt,onChange:l,required:!0})}),Q.jsx(bF,{problemList:n,pickedProblemIds:e.problems,onSelectProblem:a}),Q.jsxs("div",{children:["선택된 문제: ",[...e.problems].join(",")]})]}),Q.jsx("button",{onClick:u,children:"대회 생성"})]})}const TF=Re({display:"flex",flexDirection:"column"});function $F({onClickLogin:t}){return Q.jsxs("section",{className:QF,children:[Q.jsx("header",{className:EF,children:"Algo With Me"}),Q.jsx("button",{onClick:t,children:"Github으로 로그인"})]})}const QF=Re({border:"1px solid white",borderRadius:"10px",width:"100%",height:"100%",maxWidth:"500px",maxHeight:"200px",display:"flex",flexDirection:"column",justifyContent:"space-between"}),EF=Re({fontSize:"3rem",fontWeight:"bold",textAlign:"center",padding:"1rem"}),AF="http://101.101.208.240:3000/auths/github";function RF(){const t=()=>{try{window.location.href=AF}catch(e){console.error(e.message)}};return Q.jsx($F,{onClickLogin:t})}function _F({size:t}){return Q.jsx("img",{src:"./algo.png",alt:"logo",width:t,height:t})}const qu="accessToken",DF="http://101.101.208.240:3000",ZF="/auths/tests",MF=`${DF}${ZF}`,LF=async t=>{try{const e=await w0.get(MF,{headers:{Authorization:`Bearer ${t}`}}),n=await e.data;if(console.log(n,"인증 받음."),e.status===200)return!0}catch(e){return console.log("인증 받지 못함.",e),!1}};function IF(){const{isLoggedin:t,login:e,logout:n}=R.useContext(Jv),r=Ra(),i=gO();R.useEffect(()=>{if(t)return;const h=new URLSearchParams(r.search).get(qu)||localStorage.getItem(qu);h&&s(h)},[]);const s=async c=>{await LF(c)?o(c):l()},o=c=>{localStorage.setItem(qu,c),e()},l=()=>{localStorage.removeItem(qu),n()};return{changeLoginInfo:()=>{l(),i("/login")},changeLogoutInfo:()=>{l()},isLoggedin:t}}function NF(){const{changeLoginInfo:t,changeLogoutInfo:e,isLoggedin:n}=IF(),r=()=>{t()},i=()=>{e()};return Q.jsxs("header",{className:BF,children:[Q.jsx(_F,{size:"36px"}),n?Q.jsx("button",{onClick:i,children:" 로그아웃 "}):Q.jsx("button",{onClick:r,children:" 로그인 "})]})}const BF=Re({width:"100%",height:"40px",display:"flex",alignItems:"center",justifyContent:"space-between"});function zF(){return Q.jsx(eh,{to:"/contest/create",children:Q.jsx("button",{children:"대회 생성"})})}function jF(){return Q.jsx("button",{children:"참여하기"})}function YF(t){const e=`/contest/dashboard/${t.id}`;return Q.jsx(eh,{to:e,children:Q.jsx("button",{children:"대시보드 보기"})})}function UF(t){const e=Math.floor(t/864e5),n=Math.floor(t%(1e3*60*60*24)/(1e3*60*60)),r=Math.floor(t%(1e3*60*60)/(1e3*60)),i=Math.floor(t%(1e3*60)/1e3);return{days:e,hours:n,minutes:r,seconds:i}}const XF=()=>[{id:1,name:"테스트 대회 이름",detail:"테스트 대회 설명",maxParticipants:70,startsAt:"2023-11-14T08:35:24.358Z",endsAt:"2023-11-20T12:13:04.005Z",createdAt:"2023-11-14T08:35:24.358Z",updatedAt:"2023-11-21T02:28:43.955Z"},{id:2,name:"ICPC 서울",detail:"이거슨 아이씨피씨입니다",maxParticipants:1e3,startsAt:"2023-11-21T07:10:44.456Z",endsAt:"2023-11-21T10:10:44.456Z",createdAt:"2023-11-21T07:50:58.686Z",updatedAt:"2023-11-21T07:50:58.686Z"},{id:3,name:"천하제일코딩대회",detail:"^오^",maxParticipants:10,startsAt:"2023-11-21T07:10:44.456Z",endsAt:"2023-11-21T10:10:44.456Z",createdAt:"2023-11-21T07:57:07.563Z",updatedAt:"2023-11-21T07:57:07.563Z"},{id:4,name:"fe테스트대회",detail:"가나다라마바사",maxParticipants:3,startsAt:"2023-11-22T01:20:00.000Z",endsAt:"2023-11-23T01:20:00.000Z",createdAt:"2023-11-22T10:22:03.723Z",updatedAt:"2023-11-22T10:22:03.723Z"},{id:5,name:"가나다라",detail:"마바사아자차카타파하",maxParticipants:3,startsAt:"2023-11-23T03:00:00.000Z",endsAt:"2023-11-23T04:00:00.000Z",createdAt:"2023-11-22T12:00:46.942Z",updatedAt:"2023-11-22T12:00:46.942Z"}],WF=t=>`/contest/detail/${t}`;function FF(t,e){const n=new Date,r=new Date(t);if(new Date(e).getTime()n.getTime()){const s=r.getTime()-n.getTime(),{days:o,hours:l,minutes:a,seconds:u}=UF(s);return`시작까지 ${o}일 ${l}:${a}:${u}`}else return"진행중"}function VF(){const[t,e]=R.useState([]);return R.useEffect(()=>{const n=XF();e(n)},[]),Q.jsx("div",{children:Q.jsxs("table",{children:[Q.jsx("thead",{children:Q.jsxs("tr",{children:[Q.jsx("th",{children:"대회 이름"}),Q.jsx("th",{children:"시작 시간"}),Q.jsx("th",{children:"종료 시간"}),Q.jsx("th",{children:"상태"}),Q.jsx("th",{children:"참여"}),Q.jsx("th",{children:"대시보드"})]})}),Q.jsx("tbody",{children:t.map(n=>Q.jsxs("tr",{children:[Q.jsx("td",{children:Q.jsx(eh,{to:WF(n.id),children:n.name})}),Q.jsx("td",{children:new Date(n.startsAt).toLocaleString()}),Q.jsx("td",{children:new Date(n.endsAt).toLocaleString()}),Q.jsx("td",{children:FF(n.startsAt,n.endsAt)}),Q.jsx("td",{children:n.startsAt>new Date().toISOString()&&Q.jsx(jF,{})}),Q.jsx("td",{children:Q.jsx(YF,{id:n.id})}),Q.jsx("td",{children:Q.jsx(eh,{to:`/contest/${n.id}`,children:"대회 참여"})})]},n.id))})]})})}function qF(){return Q.jsxs(Q.Fragment,{children:[Q.jsx(NF,{}),Q.jsxs("main",{className:GF,children:[Q.jsxs("span",{className:HF,children:[og.NAME," "]}),Q.jsxs("span",{children:[og.PAGE_DESCRIPTION," "]}),Q.jsx(zF,{}),Q.jsx(VF,{})]})]})}const HF=Re({fontSize:"70px"}),GF=Re({display:"grid",placeItems:"center",height:"500px"}),KF="http://101.101.208.240:3000/problems/",JF=async(t,e,n)=>{try{const i=(await w0.get(`${KF}${t}`)).data;e(i)}catch(r){console.error("Error fetching problem:",r.message)}finally{n(!1)}};function e9(){const{id:t}=qv(),e=t?parseInt(t,10):-1,[n,r]=R.useState(null),[i,s]=R.useState(!0);return R.useEffect(()=>{JF(e,r,s)},[e]),i?Q.jsx("p",{children:"Loading..."}):n?Q.jsxs("main",{className:t9,children:[Q.jsx("span",{className:n9,children:n.title}),Q.jsx(C$,{content:n.content})]}):Q.jsx("p",{children:"Error loading problem data"})}const t9=Re({backgroundColor:"#1e1e1e",color:"#ffffff"}),n9=Re({display:"inline-block",height:"50px",padding:"10px",borderBottom:"2px solid white"});function r9(){return Q.jsx(qA,{})}const i9=nR([{path:"/",element:Q.jsx(r9,{}),children:[{index:!0,element:Q.jsx(qF,{})},{path:"/contest/:id",element:Q.jsx(SF,{})},{path:"/problem/:id",element:Q.jsx(e9,{})},{path:"/contest/create",element:Q.jsx(PF,{})},{path:"/login",element:Q.jsx(RF,{})}]}],{basename:"/web12-algo-with-me"});sp.createRoot(document.getElementById("root")).render(Q.jsx(Rw.StrictMode,{children:Q.jsx(gR,{children:Q.jsx(hR,{router:i9})})})); diff --git a/index.html b/index.html index 25a042c..39a6e56 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Algo With Me - +