gearboxdownloadmodal 8.5.1 → 8.5.11

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.
package/dist/index.umd.js CHANGED
@@ -89,7 +89,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof e.getDerivedStat
89
89
  0% { transform: rotate(0deg); }
90
90
  100% { transform: rotate(360deg); }
91
91
  }
92
- `}),m.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f6f6f6",height:"60px",color:"#737373"},children:[m.jsx("div",{style:{width:"66px",height:"100%",borderRight:"1px solid #e1e1e1",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:m.jsx(Jn,{})}),m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",position:"relative",maxWidth:"68%"},children:m.jsx("a",{style:{textAlign:"center",overflow:"hidden",textOverflow:"ellipsis"},href:i,target:"_blank",children:i||"No CDN link generated"})}),m.jsx("button",{onClick:()=>{if(!i||r)return;Xe(i)&&(s(!0),setTimeout(()=>s(!1),2e3))},style:{cursor:!i||r?"default":"pointer",borderRadius:"0.375rem",backgroundColor:r?"#16A34A":i?n:"lightgray",color:"white",transition:"all 0.15s ease-linear",width:"100px",height:"46px",marginRight:"10px",flexShrink:0},children:r?pi.t("common:link_copied"):pi.t("common:copy")})]})]})})]})},Au=({onClose:e,url:i,typeOfProduct:t="Playable"})=>{const[a,o]=y.useState(!1),r=t&&qi[t]?qi[t]:qi.Playable;return m.jsxs("div",{style:{position:"fixed",top:0,left:0,zIndex:50,display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.2)"},onClick:e,children:[m.jsx("div",{onClick:e,style:{position:"absolute",zIndex:30,height:"100%",width:"100%",pointerEvents:"none"}}),m.jsx("div",{style:{position:"absolute",zIndex:50,display:"flex",flexDirection:"column",gap:"5px",minWidth:"500px",maxWidth:"728px",width:"90%",minHeight:"150px",borderRadius:"10px",backgroundColor:"white",padding:"40px 30px 50px",pointerEvents:"auto"},onClick:s=>{s.stopPropagation()},children:m.jsx("div",{style:{display:"flex",gap:"5px",flexDirection:"column"},children:m.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f6f6f6",height:"60px",color:"#737373"},children:[m.jsx("div",{style:{width:"66px",height:"100%",borderRight:"1px solid #e1e1e1",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:m.jsx(Jn,{})}),m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",position:"relative",maxWidth:"68%"},children:m.jsx("a",{style:{textAlign:"center",overflow:"hidden",textOverflow:"ellipsis"},href:i,target:"_blank",children:i||m.jsx("img",{width:"30px",src:De,alt:"pf-logo-gif"})})}),m.jsx("button",{onClick:()=>{if(!i||a)return;Xe(i)&&(o(!0),setTimeout(()=>o(!1),2e3))},style:{cursor:!i||a?"default":"pointer",borderRadius:"0.375rem",backgroundColor:a?"#16A34A":i?r:"lightgray",color:"white",transition:"all 0.15s ease-linear",width:"100px",height:"46px",marginRight:"10px",flexShrink:0},children:a?pi.t("common:link_copied"):pi.t("common:copy")})]})})})]})},qu=({playable:e,creditDownload:i,visible:t,versionId:a,typeOfProduct:o,api:r,user:s,handleDownloadError:n,fetchFileUrl:l,urls:A,game:q,getDownloadCount:p,disabled:u,setSafariCopyLink:I,isTest:c,urlType:Z,allNetworksSelected:K,cdnModal:S,setCdnModal:W,cdnUrl:U,setCdnUrl:k,customer:h,selectedVersionIds:b})=>{const[F,N]=y.useState([]),[v,oi]=y.useState([]),[X,P]=y.useState(!1),[f,g]=y.useState(""),[L,Y]=y.useState(!1),[C,M]=y.useState(!1),[D,J]=y.useState("download"),[E,O]=y.useState(!1),[B,z]=y.useState(!1),[H,Q]=y.useState(!1),[w,ei]=Qi(Bs),[si,ai]=Qi(Ds),[Zi]=Qi(na),[G,Wi]=Qi(dt),ji=o==="Playable"?G:!0,Mi=async(T=!1)=>{T&&U||H||(Q(!0),fe(a,"cdn",ji?A:null,null,!1,{}).then(_=>{k(_.url),Q(!1)}).catch(_=>{n(_.message,_),Q(!1)}))},Gi=async T=>{if(T==="adikteev"||T==="cdn")return;const _=[...F];if(F.includes(T)){const Ci=_.findIndex(ui=>ui===T);_.splice(Ci,1),N(_)}else _.push(T),N([...F,T]);Zi.filter(Ci=>[..._].includes(Ci.id)).map(Ci=>Ci.name)},_i=async()=>new Promise(async(T,_)=>{const Ci=Zi.filter(ui=>[...F].includes(ui.id)).map(ui=>ui.name);if(Y(!0),b&&b.length>0)try{if(!q||!q._id)throw new Error("Game data is required for multi-version download");const ui=await Vn(r,q._id,{networks:Ci,versions:b}),Ti=l+"/"+ui.url,ce=await(await fetch(Ti)).blob(),Ze=window.URL.createObjectURL(ce),bi=document.createElement("a");bi.href=Ze,bi.download=ui.url.split("/").pop()||"download.zip",document.body.appendChild(bi),bi.click(),window.URL.revokeObjectURL(Ze),document.body.removeChild(bi),Y(!1),T(ui.url)}catch(ui){console.log("multi-version download error",ui),Y(!1),n(ui.message,ui),_(ui)}else kq(a,A,Ci,{urlType:Z}).then(ui=>{Y(!1),T(ui)}).catch(ui=>{console.log("get multi download err"),Y(!1),n(ui.message,ui),_(ui)})}),j=async()=>{A.iosUrl,A.googleUrl,i&&i.willSpendCredit?(M(!0),J("download"),O(!0)):(O(!1),await _i())};return y.useEffect(()=>{const T=Zi.filter(_=>{var Ci;return b&&b.length>0?!0:i&&((Ci=i==null?void 0:i.networks)==null?void 0:Ci.length)>0?typeof _=="string"?i==null?void 0:i.networks.includes(_):i==null?void 0:i.networks.includes(_.name):o==="Import"?e==null?void 0:e.networks.filter(ui=>ui.status==="paid").some(ui=>ui.name===_.name):_?!0:e==null?void 0:e.networks.includes(_)}).filter(_=>_.name==="voodoo"?s.customer==="customer:20":!0).filter(_=>_.id!=="adikteev"&&_.id!=="cdn").map(_=>_.id);console.log("networks",T),N(K?T:[])},[K,b,Zi,i,o,e,q,s.customer]),m.jsxs("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column",overflow:"hidden",paddingRight:o==="Flex"?"0.25rem":void 0},children:[m.jsx("div",{style:{flex:1,overflowY:C?"hidden":"auto",padding:"1.5rem",paddingTop:"0",paddingBottom:F.length>0?"5rem":"1.5rem"},children:m.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:"0.75rem",maxWidth:"100%"},children:t&&Zi.filter(T=>{var _;if(b&&b.length>0)return!0;if(i&&((_=i==null?void 0:i.networks)==null?void 0:_.length)>0)return typeof T=="string"?i==null?void 0:i.networks.includes(T):i==null?void 0:i.networks.includes(T.name);if(o==="Import")return e==null?void 0:e.networks.filter(Ci=>Ci.status==="paid").some(Ci=>Ci.name===T.name);if(!T)e==null||e.networks.includes(T);else return T}).filter(T=>T.name==="voodoo"?s.customer==="customer:20":!0).map(T=>{let _=T.imageSrc;if(T.name==="web"){let Ci="web_"+o.toLowerCase()+".png";_=_.replace("web.png",Ci)}return m.jsx(su,{id:T.id,name:T.name,imageUrl:_,selected:F.includes(T.id),handleCardClick:Gi,networkVersionSize:v,fileSizeLoading:X,showCheckBox:T.id!=="adikteev"&&T.id!=="cdn",typeOfProduct:o,versionId:a,api:r,handleDownloadError:n,fetchFileUrl:l,urls:A,game:q,creditDownload:i,setIsConfirmActive:M,getDownloadCount:p,disabled:u,user:s,setSafariCopyLink:I,isTest:c,urlType:Z,setCdnModal:W,generateCDN:Mi,cdnUrl:U,selectedVersionIds:b},T.id)})})}),F.length>0&&(o==="Playable"||o==="Ready"||o==="Flex")&&m.jsx("div",{style:{position:"absolute",bottom:"1rem",left:"50%",transform:"translateX(-50%)",display:"flex",flexDirection:"column",zIndex:20},children:m.jsx(nu,{onClickMultiDownload:j,networksVersionTotalSize:f,typeOfProduct:o,multiDownloading:L,selectedCount:F.length})}),S&&m.jsx(lu,{onClose:()=>{W(!1),p()},versionId:a,urls:A,handleDownloadError:n,cdnUrl:U,setCdnUrl:k,generateCDN:async()=>{if(!H){if(!(i!=null&&i.willSpendCredit)){Mi();return}if(s.customer==="playableFactoryInternal"){Mi();return}z(!0)}},cdnUploading:H,typeOfProduct:o}),si&&m.jsx(Au,{onClose:()=>{ai(!1)},url:w,typeOfProduct:o}),B&&m.jsx(jo,{width:"100%",height:"100%",creditConfirmType:D,handleCopyLink:async()=>{},download:async()=>{O(!1),z(!1),Mi()},onClose:()=>{O(!1),z(!1),Q(!1)},getDownloadCount:p,typeOfProduct:o}),E&&m.jsx(jo,{creditConfirmType:D,handleCopyLink:async()=>{},download:async()=>{O(!1),M(!1),await _i()},onClose:()=>{O(!1),M(!1)},getDownloadCount:p,typeOfProduct:o})]})};async function mu(e,i){return(await Ki.post(i+"/getFlexDownloadCount",e)).data}async function pu(e,i){try{return(await Ki.post(i+"/findGame",{_id:e})).data}catch{}}async function uu(e,i){return(await Ki.post(i+"/getPlayableVersionMarketLink",{_id:e})).data}async function Iu(e,i){return(await Ki.post(i+"/getFlexData",{_id:e})).data}async function Ku(e,i){return(await Ki.post(i+"/getImportedPlayable",{id:e})).data}async function cu(e,i){return(await Ki.post(i+"/getReadyDownloadCount",e)).data}async function du(e,i){try{return(await Ki.post(i+"/findCustomer",{_id:e})).data}catch{}}const kn=["web","adcolony","applovin","chartboost","crossinstall","fb","google","google360","ironsource","lifestreet","liftoff","mobvista","nucleo","tapjoy","toutiao","unity","vungle","moloco","cdn"];let Wn=null;const Zu=({playableId:e,versionId:i,gameId:t,typeOfProduct:a,visible:o,api:r,user:s,title:n,handleDownloadError:l,fetchFileUrl:A,fileSize:q,setFileSize:p,setSafariCopyLink:u,iosLink:I,androidLink:c,setIosLink:Z,setAndroidLink:K,urlType:S,setUrlType:W,selectedVersionIds:U})=>{const[k,h]=y.useState(null),[b,F]=y.useState(null),[N,v]=y.useState(null),[oi,X]=y.useState(!1),[P,f]=y.useState(!0),[g,L]=y.useState(window.innerWidth),[Y,C]=y.useState(!1),[M,D]=y.useState(!1),[J,E]=y.useState("");Qi(Bs),Qi(Ds);const[O,B]=Qi(Xs),[z,H]=Qi(dt);y.useEffect(()=>{!J&&a!=="Fusion"&&Mq(i).then(j=>{j!=null&&j.exist&&E(j.uploadPath)})},[J]);const[Q,w]=y.useState(!1);y.useEffect(()=>{},[Q]),y.useEffect(()=>{const j=()=>{L(window.innerWidth)};return window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}},[]);const ei=async()=>{X(!0);const j=await Ss(e,r);return j!=null&&j.networks||(j.networks=kn),h(j),j},si=(j,T)=>{clearTimeout(Wn),Wn=setTimeout(()=>{a==="Playable"&&!z||qo(i,{iosUrl:j,googleUrl:T},{urlType:S})},1e3)},ai=j=>{Z(j),si(j,c)},Zi=j=>{K(j),si(I,j)},G=async(j,T)=>{var _,Ci;try{let ui;if(a==="Playable"||a==="Ready"){const Ti=await uu(i,r);if(Ti){Z(Ti.iosLink),K(Ti.androidLink),X(!1);return}if(j&&(j.iosUrl||j.googleUrl)){Z(j.iosUrl),K(j.googleUrl),X(!1);return}if(T&&T.html){const Mt=`${A}/${T.html}?t=${Date.now()}`;let ce=await fetch(Mt).then(le=>le.text());const Ze=((_=ce.match(/var\s+iosLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:_.at(1))||"";Z(Ze);const bi=((Ci=ce.match(/var\s+androidLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:Ci.at(1))||"";K(bi),X(!1)}else K(""),Z(""),X(!1)}else if(a==="Flex"){const Ti=await Iu(i,r);if(Ti.googleUrl||Ti.iosUrl){K(Ti.googleUrl),Z(Ti.iosUrl),X(!1);return}j&&(j.iosUrl||j.googleUrl)?(Z(j.iosUrl),K(j.googleUrl),X(!1)):(K(""),Z(""),X(!1))}else a==="Fusion"&&(j&&(j.iosUrl||j.googleUrl)?(Z(j.iosUrl),K(j.googleUrl),X(!1)):(K(""),Z(""),X(!1)))}catch(ui){l(ui.response.data.error.msg)}},Wi=async()=>{X(!0);let j;a==="Flex"?j=await mu({_id:i},r):a==="Ready"&&(j=await cu({_id:i},r)),j&&(["admin","pm","tester","sales"].includes(s.role)?v({...j,networks:O}):(console.log("result",j),a==="Ready"&&!j.canDownload?v({...j,networks:kn}):(console.log("result",j),v({...j,networks:j.networks})))),X(!1)},ji=async()=>await pu(t,r),[Mi,Gi]=y.useState(null),_i=async j=>await du(j,r);return y.useEffect(()=>{o||(h(null),F(null),v(null),p(null),Gi(null)),o&&(a==="Playable"?ji().then(j=>{F(j),j&&_i(j.customer).then(T=>{Gi(T||null)}),ei().then(T=>{G(null,T)}),f(!1)}):a==="Ready"?Wi().then(j=>{ei().then(T=>{G(null,T),f(!1),T!=null&&T.customer&&_i(T.customer).then(_=>{Gi(_||null)})})}):a==="Flex"?Wi().then(j=>{f(!1),ji().then(T=>{o&&(G(T,null),f(!1),F(T),T&&_i(T.customer).then(_=>{Gi(_||null)}))})}):a==="Import"?Ku(i,r).then(j=>{h(j),Z(j.iosUrl||""),K(j.googleUrl||""),X(!1),f(!1)}):a==="Fusion"&&(f(!1),ji().then(j=>{o&&(G(j,null),f(!1),F({...j,networks:O.filter(T=>T!=="cdn")}),j&&_i(j.customer).then(T=>{Gi(T||null)}))})))},[t,e,i,o]),m.jsxs("div",{style:{position:"relative",display:"flex",height:g>1440?"650px":g<768?"auto":"600px",width:g>1440?"695px":g<768?"100%":"700px",flex:1,flexDirection:"column",borderRadius:"rounded",paddingTop:"0px"},children:[g>=768&&m.jsx("div",{style:{position:"absolute",left:0,top:"1.5rem",bottom:"1.5rem",width:"1px",backgroundColor:"#D1D5DB"}}),m.jsx($p,{title:n,typeOfProduct:a,fileSize:q,urls:{iosUrl:I,googleUrl:c},handleIosChange:ai,handleGoogleChange:Zi,disabled:P,api:r,creditDownload:N,user:s,isTest:Y,setIsTest:C,urlType:S,setUrlType:W,allNetworksSelected:Q,setAllNetworksSelected:w,versionId:i,customerId:(Mi==null?void 0:Mi._id)||""}),oi?m.jsx("div",{style:{height:"100%",width:"100%",display:"flex",justifyContent:"center"},children:m.jsx(Jt,{isNetworksLoading:!0,isLight:!1})}):(k||N||a==="Fusion")&&(a==="Flex"?b:!0)&&!oi&&I!=="Loading..."&&c!=="Loading..."&&m.jsx(qu,{playable:k,creditDownload:N,visible:o,versionId:i,typeOfProduct:a,api:r,user:s,handleDownloadError:l,fetchFileUrl:A,urls:{iosUrl:I,googleUrl:c},game:b,getDownloadCount:Wi,disabled:P,setSafariCopyLink:u,isTest:Y,urlType:S,allNetworksSelected:Q,cdnModal:M,setCdnModal:D,cdnUrl:J,setCdnUrl:E,customer:Mi??void 0,selectedVersionIds:U})]})};async function Su(e,i=!1,t){return(await Ki.post(e+"/getPlayableVersionNames",{isFlex:i,versionIds:t})).data}const hu=({selectedVersionIds:e,api:i,fetchFileUrl:t})=>{const[a,o]=y.useState([]);return y.useEffect(()=>{const r=e.map(n=>({versionId:n,versionName:"Loading...",size:null,status:"loading"}));o(r),(async()=>{try{const n=await Su(i,!1,e);o(l=>l.map((A,q)=>{var p;return{...A,versionName:((p=n[q])==null?void 0:p.name)||`Version ${A.versionId}`}})),e.forEach(async(l,A)=>{try{const q=await fe(l,"preview",null,null,!1);o(p=>{const u=[...p];return u[A]={...u[A],size:q.size,status:q.size>=5?"exceeded":"ok"},u})}catch(q){console.error(`Error checking version ${l}:`,q),o(p=>{const u=[...p];return u[A]={...u[A],status:"ok"},u})}})}catch(n){console.error("Error fetching version names:",n)}})()},[e,i]),m.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"300px",height:"100%",padding:"1rem",paddingTop:"3.5rem",overflowY:"auto"},children:[m.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:"600",marginBottom:"0.75rem",color:"#1F2937"},children:"Versions"}),m.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(r=>m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0.625rem 0.75rem",backgroundColor:"#F9FAFB",borderRadius:"0.5rem",border:"1px solid #E5E7EB"},children:[m.jsx("span",{style:{fontSize:"0.875rem",color:"#374151",fontWeight:"500"},children:r.versionName}),r.status==="loading"?m.jsx("img",{width:"20px",height:"20px",src:De,alt:"loading"}):r.status==="exceeded"?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[m.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#EF4444",display:"flex",alignItems:"center",justifyContent:"center"},children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M9 3L3 9M3 3l6 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})})}),m.jsx("span",{style:{fontSize:"0.75rem",color:"#EF4444",marginTop:"0.25rem"},children:"Exceeds 5 MB"})]}):m.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#10B981",display:"flex",alignItems:"center",justifyContent:"center"},children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M2.5 6.5L4.5 8.5L9.5 3.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},r.versionId))})]})},kK="",Ie=Object.create(null);Ie.open="0",Ie.close="1",Ie.ping="2",Ie.pong="3",Ie.message="4",Ie.upgrade="5",Ie.noop="6";const Ca=Object.create(null);Object.keys(Ie).forEach(e=>{Ca[Ie[e]]=e});const Fo={type:"error",data:"parser error"},Mn=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",En=typeof ArrayBuffer=="function",Rn=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,No=({type:e,data:i},t,a)=>Mn&&i instanceof Blob?t?a(i):Un(i,a):En&&(i instanceof ArrayBuffer||Rn(i))?t?a(i):Un(new Blob([i]),a):a(Ie[e]+(i||"")),Un=(e,i)=>{const t=new FileReader;return t.onload=function(){const a=t.result.split(",")[1];i("b"+(a||""))},t.readAsDataURL(e)};function Ln(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let xo;function Cu(e,i){if(Mn&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ln).then(i);if(En&&(e.data instanceof ArrayBuffer||Rn(e.data)))return i(Ln(e.data));No(e,!1,t=>{xo||(xo=new TextEncoder),i(xo.encode(t))})}const Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",kt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Yn.length;e++)kt[Yn.charCodeAt(e)]=e;const yu=e=>{let i=e.length*.75,t=e.length,a,o=0,r,s,n,l;e[e.length-1]==="="&&(i--,e[e.length-2]==="="&&i--);const A=new ArrayBuffer(i),q=new Uint8Array(A);for(a=0;a<t;a+=4)r=kt[e.charCodeAt(a)],s=kt[e.charCodeAt(a+1)],n=kt[e.charCodeAt(a+2)],l=kt[e.charCodeAt(a+3)],q[o++]=r<<2|s>>4,q[o++]=(s&15)<<4|n>>2,q[o++]=(n&3)<<6|l&63;return A},gu=typeof ArrayBuffer=="function",Oo=(e,i)=>{if(typeof e!="string")return{type:"message",data:Gn(e,i)};const t=e.charAt(0);return t==="b"?{type:"message",data:Vu(e.substring(1),i)}:Ca[t]?e.length>1?{type:Ca[t],data:e.substring(1)}:{type:Ca[t]}:Fo},Vu=(e,i)=>{if(gu){const t=yu(e);return Gn(t,i)}else return{base64:!0,data:e}},Gn=(e,i)=>{switch(i){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bn=String.fromCharCode(30),Ju=(e,i)=>{const t=e.length,a=new Array(t);let o=0;e.forEach((r,s)=>{No(r,!1,n=>{a[s]=n,++o===t&&i(a.join(bn))})})},ku=(e,i)=>{const t=e.split(bn),a=[];for(let o=0;o<t.length;o++){const r=Oo(t[o],i);if(a.push(r),r.type==="error")break}return a};function Wu(){return new TransformStream({transform(e,i){Cu(e,t=>{const a=t.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const r=new DataView(o.buffer);r.setUint8(0,126),r.setUint16(1,a)}else{o=new Uint8Array(9);const r=new DataView(o.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(o[0]|=128),i.enqueue(o),i.enqueue(t)})}})}let zo;function ya(e){return e.reduce((i,t)=>i+t.length,0)}function ga(e,i){if(e[0].length===i)return e.shift();const t=new Uint8Array(i);let a=0;for(let o=0;o<i;o++)t[o]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),t}function Mu(e,i){zo||(zo=new TextDecoder);const t=[];let a=0,o=-1,r=!1;return new TransformStream({transform(s,n){for(t.push(s);;){if(a===0){if(ya(t)<1)break;const l=ga(t,1);r=(l[0]&128)===128,o=l[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(ya(t)<2)break;const l=ga(t,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),a=3}else if(a===2){if(ya(t)<8)break;const l=ga(t,8),A=new DataView(l.buffer,l.byteOffset,l.length),q=A.getUint32(0);if(q>Math.pow(2,53-32)-1){n.enqueue(Fo);break}o=q*Math.pow(2,32)+A.getUint32(4),a=3}else{if(ya(t)<o)break;const l=ga(t,o);n.enqueue(Oo(r?l:zo.decode(l),i)),a=0}if(o===0||o>e){n.enqueue(Fo);break}}}})}const Qn=4;function Vi(e){if(e)return Eu(e)}function Eu(e){for(var i in Vi.prototype)e[i]=Vi.prototype[i];return e}Vi.prototype.on=Vi.prototype.addEventListener=function(e,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(i),this},Vi.prototype.once=function(e,i){function t(){this.off(e,t),i.apply(this,arguments)}return t.fn=i,this.on(e,t),this},Vi.prototype.off=Vi.prototype.removeListener=Vi.prototype.removeAllListeners=Vi.prototype.removeEventListener=function(e,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,o=0;o<t.length;o++)if(a=t[o],a===i||a.fn===i){t.splice(o,1);break}return t.length===0&&delete this._callbacks["$"+e],this},Vi.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),t=this._callbacks["$"+e],a=1;a<arguments.length;a++)i[a-1]=arguments[a];if(t){t=t.slice(0);for(var a=0,o=t.length;a<o;++a)t[a].apply(this,i)}return this},Vi.prototype.emitReserved=Vi.prototype.emit,Vi.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Vi.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Va=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,t)=>t(i,0))(),Pi=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())(),Ru="arraybuffer";function WK(){}function jn(e,...i){return i.reduce((t,a)=>(e.hasOwnProperty(a)&&(t[a]=e[a]),t),{})}const Uu=Pi.setTimeout,Lu=Pi.clearTimeout;function Ja(e,i){i.useNativeTimers?(e.setTimeoutFn=Uu.bind(Pi),e.clearTimeoutFn=Lu.bind(Pi)):(e.setTimeoutFn=Pi.setTimeout.bind(Pi),e.clearTimeoutFn=Pi.clearTimeout.bind(Pi))}const Yu=1.33;function Gu(e){return typeof e=="string"?bu(e):Math.ceil((e.byteLength||e.size)*Yu)}function bu(e){let i=0,t=0;for(let a=0,o=e.length;a<o;a++)i=e.charCodeAt(a),i<128?t+=1:i<2048?t+=2:i<55296||i>=57344?t+=3:(a++,t+=4);return t}function Fn(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Qu(e){let i="";for(let t in e)e.hasOwnProperty(t)&&(i.length&&(i+="&"),i+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return i}function ju(e){let i={},t=e.split("&");for(let a=0,o=t.length;a<o;a++){let r=t[a].split("=");i[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return i}class Fu extends Error{constructor(i,t,a){super(i),this.description=t,this.context=a,this.type="TransportError"}}class To extends Vi{constructor(i){super(),this.writable=!1,Ja(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,t,a){return super.emitReserved("error",new Fu(i,t,a)),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 t=Oo(i,this.socket.binaryType);this.onPacket(t)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,t={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(i){const t=Qu(i);return t.length?"?"+t:""}}class Nu extends To{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const t=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||t()})),this.writable||(a++,this.once("drain",function(){--a||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const t=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};ku(i,this.socket.binaryType).forEach(t),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,Ju(i,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Fn()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(i,t)}}let Nn=!1;try{Nn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xu=Nn;function Ou(){}class zu extends Nu{constructor(i){if(super(i),typeof location<"u"){const t=location.protocol==="https:";let a=location.port;a||(a=t?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||a!==i.port}}doWrite(i,t){const a=this.request({method:"POST",data:i});a.on("success",t),a.on("error",(o,r)=>{this.onError("xhr post error",o,r)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(t,a)=>{this.onError("xhr poll error",t,a)}),this.pollXhr=i}}class Ke extends Vi{constructor(i,t,a){super(),this.createRequest=i,Ja(this,a),this._opts=a,this._method=a.method||"GET",this._uri=t,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var i;const t=jn(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(t);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Ke.requestsCount++,Ke.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=Ou,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ke.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()}}if(Ke.requestsCount=0,Ke.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",xn);else if(typeof addEventListener=="function"){const e="onpagehide"in Pi?"pagehide":"unload";addEventListener(e,xn,!1)}}function xn(){for(let e in Ke.requests)Ke.requests.hasOwnProperty(e)&&Ke.requests[e].abort()}const Tu=function(){const e=On({xdomain:!1});return e&&e.responseType!==null}();class wu extends zu{constructor(i){super(i);const t=i&&i.forceBase64;this.supportsBinary=Tu&&!t}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new Ke(On,this.uri(),i)}}function On(e){const i=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||xu))return new XMLHttpRequest}catch{}if(!i)try{return new Pi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const zn=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Bu extends To{get name(){return"websocket"}doOpen(){const i=this.uri(),t=this.opts.protocols,a=zn?{}:jn(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,t,a)}catch(o){return this.emitReserved("error",o)}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 t=0;t<i.length;t++){const a=i[t],o=t===i.length-1;No(a,this.supportsBinary,r=>{try{this.doWrite(a,r)}catch{}o&&Va(()=>{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",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Fn()),this.supportsBinary||(t.b64=1),this.createUri(i,t)}}const wo=Pi.WebSocket||Pi.MozWebSocket;class Du extends Bu{createSocket(i,t,a){return zn?new wo(i,t,a):t?new wo(i,t):new wo(i)}doWrite(i,t){this.ws.send(t)}}class Xu extends To{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 t=Mu(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=i.readable.pipeThrough(t).getReader(),o=Wu();o.readable.pipeTo(i.writable),this._writer=o.writable.getWriter();const r=()=>{a.read().then(({done:n,value:l})=>{n||(this.onPacket(l),r())}).catch(n=>{})};r();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let t=0;t<i.length;t++){const a=i[t],o=t===i.length-1;this._writer.write(a).then(()=>{o&&Va(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const fu={websocket:Du,webtransport:Xu,polling:wu},vu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hu=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Bo(e){if(e.length>8e3)throw"URI too long";const i=e,t=e.indexOf("["),a=e.indexOf("]");t!=-1&&a!=-1&&(e=e.substring(0,t)+e.substring(t,a).replace(/:/g,";")+e.substring(a,e.length));let o=vu.exec(e||""),r={},s=14;for(;s--;)r[Hu[s]]=o[s]||"";return t!=-1&&a!=-1&&(r.source=i,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Pu(r,r.path),r.queryKey=_u(r,r.query),r}function Pu(e,i){const t=/\/{2,9}/g,a=i.replace(t,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&a.splice(0,1),i.slice(-1)=="/"&&a.splice(a.length-1,1),a}function _u(e,i){const t={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,r){o&&(t[o]=r)}),t}const Do=typeof addEventListener=="function"&&typeof removeEventListener=="function",ka=[];Do&&addEventListener("offline",()=>{ka.forEach(e=>e())},!1);class Me extends Vi{constructor(i,t){if(super(),this.binaryType=Ru,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(t=i,i=null),i){const a=Bo(i);t.hostname=a.host,t.secure=a.protocol==="https"||a.protocol==="wss",t.port=a.port,a.query&&(t.query=a.query)}else t.host&&(t.hostname=Bo(t.host).host);Ja(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ju(this.opts.query)),Do&&(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"})},ka.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const t=Object.assign({},this.opts.query);t.EIO=Qn,t.transport=i,this.id&&(t.sid=this.id);const a=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Me.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(i);t.open(),this.setTransport(t)}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",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Me.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 t=new Error("server error");t.code=i.data,this._onError(t);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 t=1;for(let a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(t+=Gu(o)),a>0&&t>this._maxPayload)return this.writeBuffer.slice(0,a);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,Va(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,t,a){return this._sendPacket("message",i,t,a),this}send(i,t,a){return this._sendPacket("message",i,t,a),this}_sendPacket(i,t,a,o){if(typeof t=="function"&&(o=t,t=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const r={type:i,data:t,options:a};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),o&&this.once("flush",o),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),i()},a=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():i()}):this.upgrading?a():i()),this}_onError(i){if(Me.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,t){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(),Do&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=ka.indexOf(this._offlineEventListener);a!==-1&&ka.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,t),this.writeBuffer=[],this._prevBufferLen=0}}}Me.protocol=Qn;class $u extends Me{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 t=this.createTransport(i),a=!1;Me.priorWebsocketSuccess=!1;const o=()=>{a||(t.send([{type:"ping",data:"probe"}]),t.once("packet",p=>{if(!a)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Me.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(q(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function r(){a||(a=!0,q(),t.close(),t=null)}const s=p=>{const u=new Error("probe error: "+p);u.transport=t.name,r(),this.emitReserved("upgradeError",u)};function n(){s("transport closed")}function l(){s("socket closed")}function A(p){t&&p.name!==t.name&&r()}const q=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",n),this.off("close",l),this.off("upgrading",A)};t.once("open",o),t.once("error",s),t.once("close",n),this.once("close",l),this.once("upgrading",A),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{a||t.open()},200):t.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const t=[];for(let a=0;a<i.length;a++)~this.transports.indexOf(i[a])&&t.push(i[a]);return t}}let iI=class extends $u{constructor(i,t={}){const a=typeof i=="object"?i:t;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>fu[o]).filter(o=>!!o)),super(i,a)}};function eI(e,i="",t){let a=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),a=Bo(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const r=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+r+":"+a.port+i,a.href=a.protocol+"://"+r+(t&&t.port===a.port?"":":"+a.port),a}const tI=typeof ArrayBuffer=="function",aI=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Tn=Object.prototype.toString,oI=typeof Blob=="function"||typeof Blob<"u"&&Tn.call(Blob)==="[object BlobConstructor]",rI=typeof File=="function"||typeof File<"u"&&Tn.call(File)==="[object FileConstructor]";function Xo(e){return tI&&(e instanceof ArrayBuffer||aI(e))||oI&&e instanceof Blob||rI&&e instanceof File}function Wa(e,i){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,a=e.length;t<a;t++)if(Wa(e[t]))return!0;return!1}if(Xo(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Wa(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Wa(e[t]))return!0;return!1}function sI(e){const i=[],t=e.data,a=e;return a.data=fo(t,i),a.attachments=i.length,{packet:a,buffers:i}}function fo(e,i){if(!e)return e;if(Xo(e)){const t={_placeholder:!0,num:i.length};return i.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let a=0;a<e.length;a++)t[a]=fo(e[a],i);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=fo(e[a],i));return t}return e}function nI(e,i){return e.data=vo(e.data,i),delete e.attachments,e}function vo(e,i){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<i.length)return i[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=vo(e[t],i);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=vo(e[t],i));return e}const lI=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],AI=5;var li;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(li||(li={}));class qI{constructor(i){this.replacer=i}encode(i){return(i.type===li.EVENT||i.type===li.ACK)&&Wa(i)?this.encodeAsBinary({type:i.type===li.EVENT?li.BINARY_EVENT:li.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let t=""+i.type;return(i.type===li.BINARY_EVENT||i.type===li.BINARY_ACK)&&(t+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(t+=i.nsp+","),i.id!=null&&(t+=i.id),i.data!=null&&(t+=JSON.stringify(i.data,this.replacer)),t}encodeAsBinary(i){const t=sI(i),a=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(a),o}}function wn(e){return Object.prototype.toString.call(e)==="[object Object]"}class Ho extends Vi{constructor(i){super(),this.reviver=i}add(i){let t;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(i);const a=t.type===li.BINARY_EVENT;a||t.type===li.BINARY_ACK?(t.type=a?li.EVENT:li.ACK,this.reconstructor=new mI(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Xo(i)||i.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(i),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+i)}decodeString(i){let t=0;const a={type:Number(i.charAt(0))};if(li[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===li.BINARY_EVENT||a.type===li.BINARY_ACK){const r=t+1;for(;i.charAt(++t)!=="-"&&t!=i.length;);const s=i.substring(r,t);if(s!=Number(s)||i.charAt(t)!=="-")throw new Error("Illegal attachments");a.attachments=Number(s)}if(i.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(i.charAt(t)===","||t===i.length););a.nsp=i.substring(r,t)}else a.nsp="/";const o=i.charAt(t+1);if(o!==""&&Number(o)==o){const r=t+1;for(;++t;){const s=i.charAt(t);if(s==null||Number(s)!=s){--t;break}if(t===i.length)break}a.id=Number(i.substring(r,t+1))}if(i.charAt(++t)){const r=this.tryParse(i.substr(t));if(Ho.isPayloadValid(a.type,r))a.data=r;else throw new Error("invalid payload")}return a}tryParse(i){try{return JSON.parse(i,this.reviver)}catch{return!1}}static isPayloadValid(i,t){switch(i){case li.CONNECT:return wn(t);case li.DISCONNECT:return t===void 0;case li.CONNECT_ERROR:return typeof t=="string"||wn(t);case li.EVENT:case li.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&lI.indexOf(t[0])===-1);case li.ACK:case li.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mI{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const t=nI(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const pI=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ho,Encoder:qI,get PacketType(){return li},protocol:AI},Symbol.toStringTag,{value:"Module"}));function ne(e,i,t){return e.on(i,t),function(){e.off(i,t)}}const uI=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Bn extends Vi{constructor(i,t,a){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=t,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[ne(i,"open",this.onopen.bind(this)),ne(i,"packet",this.onpacket.bind(this)),ne(i,"error",this.onerror.bind(this)),ne(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,...t){var a,o,r;if(uI.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(t.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:li.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const q=this.ids++,p=t.pop();this._registerAckCallback(q,p),s.id=q}const n=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,l=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!n||(l?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(i,t){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[i]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let n=0;n<this.sendBuffer.length;n++)this.sendBuffer[n].id===i&&this.sendBuffer.splice(n,1);t.call(this,new Error("operation has timed out"))},o),s=(...n)=>{this.io.clearTimeoutFn(r),t.apply(this,n)};s.withError=!0,this.acks[i]=s}emitWithAck(i,...t){return new Promise((a,o)=>{const r=(s,n)=>s?o(s):a(n);r.withError=!0,t.push(r),this.emit(i,...t)})}_addToQueue(i){let t;typeof i[i.length-1]=="function"&&(t=i.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((o,...r)=>a!==this._queue[0]?void 0:(o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...r)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!i||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.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:li.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,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(a=>String(a.id)===i)){const a=this.acks[i];delete this.acks[i],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case li.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 li.EVENT:case li.BINARY_EVENT:this.onevent(i);break;case li.ACK:case li.BINARY_ACK:this.onack(i);break;case li.DISCONNECT:this.ondisconnect();break;case li.CONNECT_ERROR:this.destroy();const a=new Error(i.data.message);a.data=i.data.data,this.emitReserved("connect_error",a);break}}onevent(i){const t=i.data||[];i.id!=null&&t.push(this.ack(i.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const a of t)a.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 t=this;let a=!1;return function(...o){a||(a=!0,t.packet({type:li.ACK,id:i,data:o}))}}onack(i){const t=this.acks[i.id];typeof t=="function"&&(delete this.acks[i.id],t.withError&&i.data.unshift(null),t.apply(this,i.data))}onconnect(i,t){this.id=i,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}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:li.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 t=this._anyListeners;for(let a=0;a<t.length;a++)if(i===t[a])return t.splice(a,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 t=this._anyOutgoingListeners;for(let a=0;a<t.length;a++)if(i===t[a])return t.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const a of t)a.apply(this,i.data)}}}function et(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}et.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),t=Math.floor(i*this.jitter*e);e=Math.floor(i*10)&1?e+t:e-t}return Math.min(e,this.max)|0},et.prototype.reset=function(){this.attempts=0},et.prototype.setMin=function(e){this.ms=e},et.prototype.setMax=function(e){this.max=e},et.prototype.setJitter=function(e){this.jitter=e};class Po extends Vi{constructor(i,t){var a;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(t=i,i=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ja(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((a=t.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new et({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=i;const o=t.parser||pI;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.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 t;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(t=this.backoff)===null||t===void 0||t.setMin(i),this)}randomizationFactor(i){var t;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(t=this.backoff)===null||t===void 0||t.setJitter(i),this)}reconnectionDelayMax(i){var t;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(t=this.backoff)===null||t===void 0||t.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 iI(this.uri,this.opts);const t=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=ne(t,"open",function(){a.onopen(),i&&i()}),r=n=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",n),i?i(n):this.maybeReconnectOnOpen()},s=ne(t,"error",r);if(this._timeout!==!1){const n=this._timeout,l=this.setTimeoutFn(()=>{o(),r(new Error("timeout")),t.close()},n);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(o),this.subs.push(s),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(ne(i,"ping",this.onping.bind(this)),ne(i,"data",this.ondata.bind(this)),ne(i,"error",this.onerror.bind(this)),ne(i,"close",this.onclose.bind(this)),ne(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(t){this.onclose("parse error",t)}}ondecoded(i){Va(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,t){let a=this.nsps[i];return a?this._autoConnect&&!a.active&&a.connect():(a=new Bn(this,i,t),this.nsps[i]=a),a}_destroy(i){const t=Object.keys(this.nsps);for(const a of t)if(this.nsps[a].active)return;this._close()}_packet(i){const t=this.encoder.encode(i);for(let a=0;a<t.length;a++)this.engine.write(t[a],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,t){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,t),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 t=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(o=>{o?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",o)):i.onreconnect()}))},t);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Wt={};function Ma(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};const t=eI(e,i.path||"/socket.io"),a=t.source,o=t.id,r=t.path,s=Wt[o]&&r in Wt[o].nsps,n=i.forceNew||i["force new connection"]||i.multiplex===!1||s;let l;return n?l=new Po(a,i):(Wt[o]||(Wt[o]=new Po(a,i)),l=Wt[o]),t.query&&!i.query&&(i.query=t.queryKey),l.socket(t.path,i)}Object.assign(Ma,{Manager:Po,Socket:Bn,io:Ma,connect:Ma});async function II(e,i,t){return(await Ki.post(t,{versionId:e,fileSize:i})).data}async function KI(e,i){return(await Ki.post(i+"/getFileSize",e)).data}const Ea=5,cI=({setIsExceedingFileSizeAccepted:e,closeModal:i,setLoading:t,typeOfProduct:a,versionId:o,fileSize:r,setFileSize:s,user:n,compressApi:l,producerApi:A,api:q})=>{const[p,u]=y.useState(!1),[I,c]=y.useState(!1);y.useEffect(()=>{const h=Ma(l,{path:"/socket.io"});return h.on("connect",()=>{console.log("Connected to the socket server")}),h.on("video-compressing",async b=>{if(console.log(b),b.userId===n._id&&b.isSuccess){console.log("Video compress successfull");const F=await KI({_id:o},q);s(F.size),e(!1)}}),h.on("error",b=>{console.error("Socket error:",b)}),()=>{h.disconnect()}},[o]);const Z=()=>{i(),e(!1),t(!0)},K=async()=>{try{u(!0);const h=await II(o,r,`${A}/videos/compressByDiff`);console.log("Compression result:",h),t(!1)}catch(h){console.error("Error compressing video:",h),t(!1),i()}},S=qi[a],W=Vt[a],U=r-Ea,k=Ea/r*100;return m.jsxs(ua,{isOpen:!0,ariaHideApp:!1,onRequestClose:Z,style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"1.5rem",backgroundColor:"white",zIndex:50,maxWidth:"32rem",width:"100%",height:"100%",maxHeight:"34.5rem",overflow:"hidden",padding:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(12px)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Size Exceeding Modal",shouldCloseOnOverlayClick:!0,children:[m.jsx("button",{onClick:Z,style:{position:"absolute",top:"1.25rem",right:"1.25rem",padding:"0.5rem",borderRadius:"9999px",transition:"all 0.3s",zIndex:10,border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="#f1f5f9"},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"#94a3b8",transition:"color 0.3s"},onMouseEnter:h=>{h.currentTarget.style.color="#0f172a"},onMouseLeave:h=>{h.currentTarget.style.color="#94a3b8"},children:[m.jsx("path",{d:"M18 6 6 18"}),m.jsx("path",{d:"m6 6 12 12"})]})}),m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",gap:"8px",paddingLeft:"2rem",paddingRight:"2rem",paddingTop:"2.5rem",paddingBottom:"2.5rem",height:"100%",width:"100%"},children:[m.jsxs("div",{style:{position:"relative",marginBottom:"1.5rem"},children:[m.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"9999px",filter:"blur(24px)",opacity:.4,animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",backgroundColor:S}}),m.jsx("div",{style:{position:"relative",width:"80px",height:"80px",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",backgroundColor:S},children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"44",height:"44",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("circle",{cx:"12",cy:"12",r:"10"}),m.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),m.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})})]}),m.jsx("h2",{style:{fontSize:"24px",fontWeight:"bold",color:"#0f172a",marginBottom:"0.5rem",letterSpacing:"-0.025em"},children:"Playable Size Too Large"}),m.jsxs("div",{style:{backgroundColor:"#f8fafc",borderRadius:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",marginBottom:"1rem",width:"100%",border:"1px solid #e2e8f0"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"0.875rem"},children:[m.jsx("span",{style:{color:"#475569"},children:"Current size:"}),m.jsxs("span",{style:{fontWeight:"bold",fontSize:"18px",color:S},children:[r.toFixed(1)," MB"]})]}),m.jsxs("div",{style:{marginTop:"0.5rem",width:"100%",position:"relative"},children:[m.jsx("div",{style:{width:"100%",backgroundColor:"#e2e8f0",borderRadius:"9999px",height:"0.5rem",overflow:"hidden"},children:m.jsx("div",{style:{height:"100%",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",width:`${k}%`,backgroundColor:S}})}),m.jsx("div",{style:{position:"absolute",top:0,width:"0.125rem",height:"0.5rem",backgroundColor:"#334155",zIndex:10,left:`${k}%`}}),m.jsx("div",{style:{position:"absolute",top:0,height:"0.5rem",overflow:"hidden",left:`${k}%`,width:`${100-k}%`},children:m.jsx("div",{style:{height:"100%",borderTopRightRadius:"9999px",borderBottomRightRadius:"9999px",opacity:.6,backgroundColor:S,backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,0.3) 3px, rgba(255,255,255,0.3) 6px)"}})})]}),m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"0.75rem",marginTop:"0.25rem"},children:[m.jsxs("span",{style:{color:"#64748b"},children:["Limit: ",Ea," MB"]}),m.jsxs("span",{style:{fontWeight:500,fontSize:"12px",color:S},children:["+",U.toFixed(1)," MB over"]})]})]}),p?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:"2rem",paddingBottom:"2rem"},children:[m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:S,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite",marginBottom:"1rem"},children:m.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),m.jsx("style",{children:`
92
+ `}),m.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f6f6f6",height:"60px",color:"#737373"},children:[m.jsx("div",{style:{width:"66px",height:"100%",borderRight:"1px solid #e1e1e1",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:m.jsx(Jn,{})}),m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",position:"relative",maxWidth:"68%"},children:m.jsx("a",{style:{textAlign:"center",overflow:"hidden",textOverflow:"ellipsis"},href:i,target:"_blank",children:i||"No CDN link generated"})}),m.jsx("button",{onClick:()=>{if(!i||r)return;Xe(i)&&(s(!0),setTimeout(()=>s(!1),2e3))},style:{cursor:!i||r?"default":"pointer",borderRadius:"0.375rem",backgroundColor:r?"#16A34A":i?n:"lightgray",color:"white",transition:"all 0.15s ease-linear",width:"100px",height:"46px",marginRight:"10px",flexShrink:0},children:r?pi.t("common:link_copied"):pi.t("common:copy")})]})]})})]})},Au=({onClose:e,url:i,typeOfProduct:t="Playable"})=>{const[a,o]=y.useState(!1),r=t&&qi[t]?qi[t]:qi.Playable;return m.jsxs("div",{style:{position:"fixed",top:0,left:0,zIndex:50,display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.2)"},onClick:e,children:[m.jsx("div",{onClick:e,style:{position:"absolute",zIndex:30,height:"100%",width:"100%",pointerEvents:"none"}}),m.jsx("div",{style:{position:"absolute",zIndex:50,display:"flex",flexDirection:"column",gap:"5px",minWidth:"500px",maxWidth:"728px",width:"90%",minHeight:"150px",borderRadius:"10px",backgroundColor:"white",padding:"40px 30px 50px",pointerEvents:"auto"},onClick:s=>{s.stopPropagation()},children:m.jsx("div",{style:{display:"flex",gap:"5px",flexDirection:"column"},children:m.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f6f6f6",height:"60px",color:"#737373"},children:[m.jsx("div",{style:{width:"66px",height:"100%",borderRight:"1px solid #e1e1e1",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:m.jsx(Jn,{})}),m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",position:"relative",maxWidth:"68%"},children:m.jsx("a",{style:{textAlign:"center",overflow:"hidden",textOverflow:"ellipsis"},href:i,target:"_blank",children:i||m.jsx("img",{width:"30px",src:De,alt:"pf-logo-gif"})})}),m.jsx("button",{onClick:()=>{if(!i||a)return;Xe(i)&&(o(!0),setTimeout(()=>o(!1),2e3))},style:{cursor:!i||a?"default":"pointer",borderRadius:"0.375rem",backgroundColor:a?"#16A34A":i?r:"lightgray",color:"white",transition:"all 0.15s ease-linear",width:"100px",height:"46px",marginRight:"10px",flexShrink:0},children:a?pi.t("common:link_copied"):pi.t("common:copy")})]})})})]})},qu=({playable:e,creditDownload:i,visible:t,versionId:a,typeOfProduct:o,api:r,user:s,handleDownloadError:n,fetchFileUrl:l,urls:A,game:q,getDownloadCount:p,disabled:u,setSafariCopyLink:I,isTest:c,urlType:Z,allNetworksSelected:K,cdnModal:S,setCdnModal:W,cdnUrl:U,setCdnUrl:k,customer:h,selectedVersionIds:b})=>{const[F,N]=y.useState([]),[v,oi]=y.useState([]),[X,P]=y.useState(!1),[f,g]=y.useState(""),[L,Y]=y.useState(!1),[C,M]=y.useState(!1),[D,J]=y.useState("download"),[E,O]=y.useState(!1),[B,z]=y.useState(!1),[H,Q]=y.useState(!1),[w,ei]=Qi(Bs),[si,ai]=Qi(Ds),[Zi]=Qi(na),[G,Wi]=Qi(dt),ji=o==="Playable"?G:!0,Mi=async(T=!1)=>{T&&U||H||(Q(!0),fe(a,"cdn",ji?A:null,null,!1,{}).then(_=>{k(_.url),Q(!1)}).catch(_=>{n(_.message,_),Q(!1)}))},Gi=async T=>{if(T==="adikteev"||T==="cdn")return;const _=[...F];if(F.includes(T)){const Ci=_.findIndex(ui=>ui===T);_.splice(Ci,1),N(_)}else _.push(T),N([...F,T]);Zi.filter(Ci=>[..._].includes(Ci.id)).map(Ci=>Ci.name)},_i=async()=>new Promise(async(T,_)=>{const Ci=Zi.filter(ui=>[...F].includes(ui.id)).map(ui=>ui.name);if(Y(!0),b&&b.length>0)try{if(!q||!q._id)throw new Error("Game data is required for multi-version download");const ui=await Vn(r,q._id,{networks:Ci,versions:b}),Ti=l+"/"+ui.url,ce=await(await fetch(Ti)).blob(),Ze=window.URL.createObjectURL(ce),bi=document.createElement("a");bi.href=Ze,bi.download=ui.url.split("/").pop()||"download.zip",document.body.appendChild(bi),bi.click(),window.URL.revokeObjectURL(Ze),document.body.removeChild(bi),Y(!1),T(ui.url)}catch(ui){console.log("multi-version download error",ui),Y(!1),n(ui.message,ui),_(ui)}else kq(a,A,Ci,{urlType:Z}).then(ui=>{Y(!1),T(ui)}).catch(ui=>{console.log("get multi download err"),Y(!1),n(ui.message,ui),_(ui)})}),j=async()=>{A.iosUrl,A.googleUrl,i&&i.willSpendCredit?(M(!0),J("download"),O(!0)):(O(!1),await _i())};return y.useEffect(()=>{const T=Zi.filter(_=>{var Ci;return b&&b.length>0?!0:i&&((Ci=i==null?void 0:i.networks)==null?void 0:Ci.length)>0?typeof _=="string"?i==null?void 0:i.networks.includes(_):i==null?void 0:i.networks.includes(_.name):o==="Import"?e==null?void 0:e.networks.filter(ui=>ui.status==="paid").some(ui=>ui.name===_.name):_?!0:e==null?void 0:e.networks.includes(_)}).filter(_=>_.name==="voodoo"?s.customer==="customer:20":!0).filter(_=>_.id!=="adikteev"&&_.id!=="cdn").map(_=>_.id);console.log("networks",T),N(K?T:[])},[K,b,Zi,i,o,e,q,s.customer]),m.jsxs("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column",overflow:"hidden",paddingRight:o==="Flex"?"0.25rem":void 0},children:[m.jsx("div",{style:{flex:1,overflowY:C?"hidden":"auto",padding:"1.5rem",paddingTop:"0",paddingBottom:F.length>0?"5rem":"1.5rem"},children:m.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:"0.75rem",maxWidth:"100%"},children:t&&Zi.filter(T=>{var _;if(b&&b.length>0)return!0;if(i&&((_=i==null?void 0:i.networks)==null?void 0:_.length)>0)return typeof T=="string"?i==null?void 0:i.networks.includes(T):i==null?void 0:i.networks.includes(T.name);if(o==="Import")return e==null?void 0:e.networks.filter(Ci=>Ci.status==="paid").some(Ci=>Ci.name===T.name);if(!T)e==null||e.networks.includes(T);else return T}).filter(T=>T.name==="voodoo"?s.customer==="customer:20":!0).map(T=>{let _=T.imageSrc;if(T.name==="web"){let Ci="web_"+o.toLowerCase()+".png";_=_.replace("web.png",Ci)}return m.jsx(su,{id:T.id,name:T.name,imageUrl:_,selected:F.includes(T.id),handleCardClick:Gi,networkVersionSize:v,fileSizeLoading:X,showCheckBox:T.id!=="adikteev"&&T.id!=="cdn",typeOfProduct:o,versionId:a,api:r,handleDownloadError:n,fetchFileUrl:l,urls:A,game:q,creditDownload:i,setIsConfirmActive:M,getDownloadCount:p,disabled:u,user:s,setSafariCopyLink:I,isTest:c,urlType:Z,setCdnModal:W,generateCDN:Mi,cdnUrl:U,selectedVersionIds:b},T.id)})})}),F.length>0&&(o==="Playable"||o==="Ready"||o==="Flex")&&m.jsx("div",{style:{position:"absolute",bottom:"1rem",left:"50%",transform:"translateX(-50%)",display:"flex",flexDirection:"column",zIndex:20},children:m.jsx(nu,{onClickMultiDownload:j,networksVersionTotalSize:f,typeOfProduct:o,multiDownloading:L,selectedCount:F.length})}),S&&m.jsx(lu,{onClose:()=>{W(!1),p()},versionId:a,urls:A,handleDownloadError:n,cdnUrl:U,setCdnUrl:k,generateCDN:async()=>{if(!H){if(!(i!=null&&i.willSpendCredit)){Mi();return}if(s.customer==="playableFactoryInternal"){Mi();return}z(!0)}},cdnUploading:H,typeOfProduct:o}),si&&m.jsx(Au,{onClose:()=>{ai(!1)},url:w,typeOfProduct:o}),B&&m.jsx(jo,{width:"100%",height:"100%",creditConfirmType:D,handleCopyLink:async()=>{},download:async()=>{O(!1),z(!1),Mi()},onClose:()=>{O(!1),z(!1),Q(!1)},getDownloadCount:p,typeOfProduct:o}),E&&m.jsx(jo,{creditConfirmType:D,handleCopyLink:async()=>{},download:async()=>{O(!1),M(!1),await _i()},onClose:()=>{O(!1),M(!1)},getDownloadCount:p,typeOfProduct:o})]})};async function mu(e,i){return(await Ki.post(i+"/getFlexDownloadCount",e)).data}async function pu(e,i){try{return(await Ki.post(i+"/findGame",{_id:e})).data}catch{}}async function uu(e,i){return(await Ki.post(i+"/getPlayableVersionMarketLink",{_id:e})).data}async function Iu(e,i){return(await Ki.post(i+"/getFlexData",{_id:e})).data}async function Ku(e,i){return(await Ki.post(i+"/getImportedPlayable",{id:e})).data}async function cu(e,i){return(await Ki.post(i+"/getReadyDownloadCount",e)).data}async function du(e,i){try{return(await Ki.post(i+"/findCustomer",{_id:e})).data}catch{}}const kn=["web","adcolony","applovin","chartboost","crossinstall","fb","google","google360","ironsource","lifestreet","liftoff","mobvista","nucleo","tapjoy","toutiao","unity","vungle","moloco","cdn"];let Wn=null;const Zu=({playableId:e,versionId:i,gameId:t,typeOfProduct:a,visible:o,api:r,user:s,title:n,handleDownloadError:l,fetchFileUrl:A,fileSize:q,setFileSize:p,setSafariCopyLink:u,iosLink:I,androidLink:c,setIosLink:Z,setAndroidLink:K,urlType:S,setUrlType:W,selectedVersionIds:U})=>{const[k,h]=y.useState(null),[b,F]=y.useState(null),[N,v]=y.useState(null),[oi,X]=y.useState(!1),[P,f]=y.useState(!0),[g,L]=y.useState(window.innerWidth),[Y,C]=y.useState(!1),[M,D]=y.useState(!1),[J,E]=y.useState("");Qi(Bs),Qi(Ds);const[O,B]=Qi(Xs),[z,H]=Qi(dt);y.useEffect(()=>{!J&&a!=="Fusion"&&Mq(i).then(j=>{j!=null&&j.exist&&E(j.uploadPath)})},[J]);const[Q,w]=y.useState(!1);y.useEffect(()=>{},[Q]),y.useEffect(()=>{const j=()=>{L(window.innerWidth)};return window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}},[]);const ei=async()=>{X(!0);const j=await Ss(e,r);return j!=null&&j.networks||(j.networks=kn),h(j),j},si=(j,T)=>{clearTimeout(Wn),Wn=setTimeout(()=>{a==="Playable"&&!z||qo(i,{iosUrl:j,googleUrl:T},{urlType:S})},1e3)},ai=j=>{Z(j),si(j,c)},Zi=j=>{K(j),si(I,j)},G=async(j,T)=>{var _,Ci;try{let ui;if(a==="Playable"||a==="Ready"){const Ti=await uu(i,r);if(Ti){Z(Ti.iosLink),K(Ti.androidLink),X(!1);return}if(j&&(j.iosUrl||j.googleUrl)){Z(j.iosUrl),K(j.googleUrl),X(!1);return}if(T&&T.html){const Mt=`${A}/${T.html}?t=${Date.now()}`;let ce=await fetch(Mt).then(le=>le.text());const Ze=((_=ce.match(/var\s+iosLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:_.at(1))||"";Z(Ze);const bi=((Ci=ce.match(/var\s+androidLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:Ci.at(1))||"";K(bi),X(!1)}else K(""),Z(""),X(!1)}else if(a==="Flex"){const Ti=await Iu(i,r);if(Ti.googleUrl||Ti.iosUrl){K(Ti.googleUrl),Z(Ti.iosUrl),X(!1);return}j&&(j.iosUrl||j.googleUrl)?(Z(j.iosUrl),K(j.googleUrl),X(!1)):(K(""),Z(""),X(!1))}else a==="Fusion"&&(j&&(j.iosUrl||j.googleUrl)?(Z(j.iosUrl),K(j.googleUrl),X(!1)):(K(""),Z(""),X(!1)))}catch(ui){l(ui.response.data.error.msg)}},Wi=async()=>{X(!0);let j;a==="Flex"?j=await mu({_id:i},r):a==="Ready"&&(j=await cu({_id:i},r)),j&&(["admin","pm","tester","sales"].includes(s.role)?v({...j,networks:O}):(console.log("result",j),a==="Ready"&&!j.canDownload?v({...j,networks:kn}):(console.log("result",j),v({...j,networks:j.networks})))),X(!1)},ji=async()=>await pu(t,r),[Mi,Gi]=y.useState(null),_i=async j=>await du(j,r);return y.useEffect(()=>{o||(h(null),F(null),v(null),p(null),Gi(null)),o&&(a==="Playable"?ji().then(j=>{F(j),j&&_i(j.customer).then(T=>{Gi(T||null)}),ei().then(T=>{G(null,T)}),f(!1)}):a==="Ready"?Wi().then(j=>{ei().then(T=>{G(null,T),f(!1),T!=null&&T.customer&&_i(T.customer).then(_=>{Gi(_||null)})})}):a==="Flex"?Wi().then(j=>{f(!1),ji().then(T=>{o&&(G(T,null),f(!1),F(T),T&&_i(T.customer).then(_=>{Gi(_||null)}))})}):a==="Import"?Ku(i,r).then(j=>{h(j),Z(j.iosUrl||""),K(j.googleUrl||""),X(!1),f(!1)}):a==="Fusion"&&(f(!1),ji().then(j=>{o&&(G(j,null),f(!1),F({...j,networks:O.filter(T=>T!=="cdn")}),j&&_i(j.customer).then(T=>{Gi(T||null)}))})))},[t,e,i,o]),m.jsxs("div",{style:{position:"relative",display:"flex",height:g>1440?"650px":g<768?"auto":"600px",width:g>1440?"695px":g<768?"100%":"700px",flex:1,flexDirection:"column",borderRadius:"rounded",paddingTop:"0px"},children:[g>=768&&m.jsx("div",{style:{position:"absolute",left:0,top:"1.5rem",bottom:"1.5rem",width:"1px",backgroundColor:"#D1D5DB"}}),m.jsx($p,{title:n,typeOfProduct:a,fileSize:q,urls:{iosUrl:I,googleUrl:c},handleIosChange:ai,handleGoogleChange:Zi,disabled:P,api:r,creditDownload:N,user:s,isTest:Y,setIsTest:C,urlType:S,setUrlType:W,allNetworksSelected:Q,setAllNetworksSelected:w,versionId:i,customerId:(Mi==null?void 0:Mi._id)||""}),oi?m.jsx("div",{style:{height:"100%",width:"100%",display:"flex",justifyContent:"center"},children:m.jsx(Jt,{isNetworksLoading:!0,isLight:!1})}):(k||N||a==="Fusion")&&(a==="Flex"?b:!0)&&!oi&&I!=="Loading..."&&c!=="Loading..."&&m.jsx(qu,{playable:k,creditDownload:N,visible:o,versionId:i,typeOfProduct:a,api:r,user:s,handleDownloadError:l,fetchFileUrl:A,urls:{iosUrl:I,googleUrl:c},game:b,getDownloadCount:Wi,disabled:P,setSafariCopyLink:u,isTest:Y,urlType:S,allNetworksSelected:Q,cdnModal:M,setCdnModal:D,cdnUrl:J,setCdnUrl:E,customer:Mi??void 0,selectedVersionIds:U})]})};async function Su(e,i=!1,t){return(await Ki.post(e+"/getPlayableVersionNames",{isFlex:i,versionIds:t})).data}const hu=({selectedVersionIds:e,api:i,fetchFileUrl:t})=>{const[a,o]=y.useState([]);return y.useEffect(()=>{const r=e.map(n=>({versionId:n,versionName:"Loading...",size:null,status:"loading"}));o(r),(async()=>{try{const n=await Su(i,!1,e);o(l=>l.map((A,q)=>{var p;return{...A,versionName:((p=n[q])==null?void 0:p.name)||`Version ${A.versionId}`}})),e.forEach(async(l,A)=>{try{const q=await fe(l,"preview",null,null,!1);o(p=>{const u=[...p];return u[A]={...u[A],size:q.size,status:q.size>=5?"exceeded":"ok"},u})}catch(q){console.error(`Error checking version ${l}:`,q),o(p=>{const u=[...p];return u[A]={...u[A],status:"ok"},u})}})}catch(n){console.error("Error fetching version names:",n)}})()},[e,i]),m.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"300px",height:"100%",padding:"1rem",paddingTop:"3.5rem",overflowY:"auto"},children:[m.jsx("h2",{style:{fontSize:"1.125rem",fontWeight:"600",marginBottom:"0.75rem",color:"#1F2937"},children:"Versions"}),m.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(r=>m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0.625rem 0.75rem",backgroundColor:"#F9FAFB",borderRadius:"0.5rem",border:"1px solid #E5E7EB"},children:[m.jsx("span",{style:{fontSize:"0.875rem",color:"#374151",fontWeight:"500"},children:r.versionName}),r.status==="loading"?m.jsx("img",{width:"20px",height:"20px",src:De,alt:"loading"}):r.status==="exceeded"?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[m.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#EF4444",display:"flex",alignItems:"center",justifyContent:"center"},children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M9 3L3 9M3 3l6 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})})}),m.jsx("span",{style:{fontSize:"0.75rem",color:"#EF4444",marginTop:"0.25rem"},children:"Exceeds 5 MB"})]}):m.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#10B981",display:"flex",alignItems:"center",justifyContent:"center"},children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:m.jsx("path",{d:"M2.5 6.5L4.5 8.5L9.5 3.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},r.versionId))})]})},kK="",Ie=Object.create(null);Ie.open="0",Ie.close="1",Ie.ping="2",Ie.pong="3",Ie.message="4",Ie.upgrade="5",Ie.noop="6";const Ca=Object.create(null);Object.keys(Ie).forEach(e=>{Ca[Ie[e]]=e});const Fo={type:"error",data:"parser error"},Mn=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",En=typeof ArrayBuffer=="function",Rn=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,No=({type:e,data:i},t,a)=>Mn&&i instanceof Blob?t?a(i):Un(i,a):En&&(i instanceof ArrayBuffer||Rn(i))?t?a(i):Un(new Blob([i]),a):a(Ie[e]+(i||"")),Un=(e,i)=>{const t=new FileReader;return t.onload=function(){const a=t.result.split(",")[1];i("b"+(a||""))},t.readAsDataURL(e)};function Ln(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let xo;function Cu(e,i){if(Mn&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ln).then(i);if(En&&(e.data instanceof ArrayBuffer||Rn(e.data)))return i(Ln(e.data));No(e,!1,t=>{xo||(xo=new TextEncoder),i(xo.encode(t))})}const Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",kt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Yn.length;e++)kt[Yn.charCodeAt(e)]=e;const yu=e=>{let i=e.length*.75,t=e.length,a,o=0,r,s,n,l;e[e.length-1]==="="&&(i--,e[e.length-2]==="="&&i--);const A=new ArrayBuffer(i),q=new Uint8Array(A);for(a=0;a<t;a+=4)r=kt[e.charCodeAt(a)],s=kt[e.charCodeAt(a+1)],n=kt[e.charCodeAt(a+2)],l=kt[e.charCodeAt(a+3)],q[o++]=r<<2|s>>4,q[o++]=(s&15)<<4|n>>2,q[o++]=(n&3)<<6|l&63;return A},gu=typeof ArrayBuffer=="function",Oo=(e,i)=>{if(typeof e!="string")return{type:"message",data:Gn(e,i)};const t=e.charAt(0);return t==="b"?{type:"message",data:Vu(e.substring(1),i)}:Ca[t]?e.length>1?{type:Ca[t],data:e.substring(1)}:{type:Ca[t]}:Fo},Vu=(e,i)=>{if(gu){const t=yu(e);return Gn(t,i)}else return{base64:!0,data:e}},Gn=(e,i)=>{switch(i){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},bn=String.fromCharCode(30),Ju=(e,i)=>{const t=e.length,a=new Array(t);let o=0;e.forEach((r,s)=>{No(r,!1,n=>{a[s]=n,++o===t&&i(a.join(bn))})})},ku=(e,i)=>{const t=e.split(bn),a=[];for(let o=0;o<t.length;o++){const r=Oo(t[o],i);if(a.push(r),r.type==="error")break}return a};function Wu(){return new TransformStream({transform(e,i){Cu(e,t=>{const a=t.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const r=new DataView(o.buffer);r.setUint8(0,126),r.setUint16(1,a)}else{o=new Uint8Array(9);const r=new DataView(o.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(a))}e.data&&typeof e.data!="string"&&(o[0]|=128),i.enqueue(o),i.enqueue(t)})}})}let zo;function ya(e){return e.reduce((i,t)=>i+t.length,0)}function ga(e,i){if(e[0].length===i)return e.shift();const t=new Uint8Array(i);let a=0;for(let o=0;o<i;o++)t[o]=e[0][a++],a===e[0].length&&(e.shift(),a=0);return e.length&&a<e[0].length&&(e[0]=e[0].slice(a)),t}function Mu(e,i){zo||(zo=new TextDecoder);const t=[];let a=0,o=-1,r=!1;return new TransformStream({transform(s,n){for(t.push(s);;){if(a===0){if(ya(t)<1)break;const l=ga(t,1);r=(l[0]&128)===128,o=l[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(ya(t)<2)break;const l=ga(t,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),a=3}else if(a===2){if(ya(t)<8)break;const l=ga(t,8),A=new DataView(l.buffer,l.byteOffset,l.length),q=A.getUint32(0);if(q>Math.pow(2,53-32)-1){n.enqueue(Fo);break}o=q*Math.pow(2,32)+A.getUint32(4),a=3}else{if(ya(t)<o)break;const l=ga(t,o);n.enqueue(Oo(r?l:zo.decode(l),i)),a=0}if(o===0||o>e){n.enqueue(Fo);break}}}})}const Qn=4;function Vi(e){if(e)return Eu(e)}function Eu(e){for(var i in Vi.prototype)e[i]=Vi.prototype[i];return e}Vi.prototype.on=Vi.prototype.addEventListener=function(e,i){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(i),this},Vi.prototype.once=function(e,i){function t(){this.off(e,t),i.apply(this,arguments)}return t.fn=i,this.on(e,t),this},Vi.prototype.off=Vi.prototype.removeListener=Vi.prototype.removeAllListeners=Vi.prototype.removeEventListener=function(e,i){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var a,o=0;o<t.length;o++)if(a=t[o],a===i||a.fn===i){t.splice(o,1);break}return t.length===0&&delete this._callbacks["$"+e],this},Vi.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var i=new Array(arguments.length-1),t=this._callbacks["$"+e],a=1;a<arguments.length;a++)i[a-1]=arguments[a];if(t){t=t.slice(0);for(var a=0,o=t.length;a<o;++a)t[a].apply(this,i)}return this},Vi.prototype.emitReserved=Vi.prototype.emit,Vi.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Vi.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Va=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?i=>Promise.resolve().then(i):(i,t)=>t(i,0))(),Pi=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())(),Ru="arraybuffer";function WK(){}function jn(e,...i){return i.reduce((t,a)=>(e.hasOwnProperty(a)&&(t[a]=e[a]),t),{})}const Uu=Pi.setTimeout,Lu=Pi.clearTimeout;function Ja(e,i){i.useNativeTimers?(e.setTimeoutFn=Uu.bind(Pi),e.clearTimeoutFn=Lu.bind(Pi)):(e.setTimeoutFn=Pi.setTimeout.bind(Pi),e.clearTimeoutFn=Pi.clearTimeout.bind(Pi))}const Yu=1.33;function Gu(e){return typeof e=="string"?bu(e):Math.ceil((e.byteLength||e.size)*Yu)}function bu(e){let i=0,t=0;for(let a=0,o=e.length;a<o;a++)i=e.charCodeAt(a),i<128?t+=1:i<2048?t+=2:i<55296||i>=57344?t+=3:(a++,t+=4);return t}function Fn(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Qu(e){let i="";for(let t in e)e.hasOwnProperty(t)&&(i.length&&(i+="&"),i+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return i}function ju(e){let i={},t=e.split("&");for(let a=0,o=t.length;a<o;a++){let r=t[a].split("=");i[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return i}class Fu extends Error{constructor(i,t,a){super(i),this.description=t,this.context=a,this.type="TransportError"}}class To extends Vi{constructor(i){super(),this.writable=!1,Ja(this,i),this.opts=i,this.query=i.query,this.socket=i.socket,this.supportsBinary=!i.forceBase64}onError(i,t,a){return super.emitReserved("error",new Fu(i,t,a)),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 t=Oo(i,this.socket.binaryType);this.onPacket(t)}onPacket(i){super.emitReserved("packet",i)}onClose(i){this.readyState="closed",super.emitReserved("close",i)}pause(i){}createUri(i,t={}){return i+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const i=this.opts.hostname;return i.indexOf(":")===-1?i:"["+i+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(i){const t=Qu(i);return t.length?"?"+t:""}}class Nu extends To{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(i){this.readyState="pausing";const t=()=>{this.readyState="paused",i()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||t()})),this.writable||(a++,this.once("drain",function(){--a||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(i){const t=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};ku(i,this.socket.binaryType).forEach(t),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,Ju(i,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const i=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Fn()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(i,t)}}let Nn=!1;try{Nn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xu=Nn;function Ou(){}class zu extends Nu{constructor(i){if(super(i),typeof location<"u"){const t=location.protocol==="https:";let a=location.port;a||(a=t?"443":"80"),this.xd=typeof location<"u"&&i.hostname!==location.hostname||a!==i.port}}doWrite(i,t){const a=this.request({method:"POST",data:i});a.on("success",t),a.on("error",(o,r)=>{this.onError("xhr post error",o,r)})}doPoll(){const i=this.request();i.on("data",this.onData.bind(this)),i.on("error",(t,a)=>{this.onError("xhr poll error",t,a)}),this.pollXhr=i}}class Ke extends Vi{constructor(i,t,a){super(),this.createRequest=i,Ja(this,a),this._opts=a,this._method=a.method||"GET",this._uri=t,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var i;const t=jn(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(t);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(i=this._opts.cookieJar)===null||i===void 0||i.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Ke.requestsCount++,Ke.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=Ou,i)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ke.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()}}if(Ke.requestsCount=0,Ke.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",xn);else if(typeof addEventListener=="function"){const e="onpagehide"in Pi?"pagehide":"unload";addEventListener(e,xn,!1)}}function xn(){for(let e in Ke.requests)Ke.requests.hasOwnProperty(e)&&Ke.requests[e].abort()}const Tu=function(){const e=On({xdomain:!1});return e&&e.responseType!==null}();class wu extends zu{constructor(i){super(i);const t=i&&i.forceBase64;this.supportsBinary=Tu&&!t}request(i={}){return Object.assign(i,{xd:this.xd},this.opts),new Ke(On,this.uri(),i)}}function On(e){const i=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!i||xu))return new XMLHttpRequest}catch{}if(!i)try{return new Pi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const zn=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Bu extends To{get name(){return"websocket"}doOpen(){const i=this.uri(),t=this.opts.protocols,a=zn?{}:jn(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(i,t,a)}catch(o){return this.emitReserved("error",o)}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 t=0;t<i.length;t++){const a=i[t],o=t===i.length-1;No(a,this.supportsBinary,r=>{try{this.doWrite(a,r)}catch{}o&&Va(()=>{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",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Fn()),this.supportsBinary||(t.b64=1),this.createUri(i,t)}}const wo=Pi.WebSocket||Pi.MozWebSocket;class Du extends Bu{createSocket(i,t,a){return zn?new wo(i,t,a):t?new wo(i,t):new wo(i)}doWrite(i,t){this.ws.send(t)}}class Xu extends To{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 t=Mu(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=i.readable.pipeThrough(t).getReader(),o=Wu();o.readable.pipeTo(i.writable),this._writer=o.writable.getWriter();const r=()=>{a.read().then(({done:n,value:l})=>{n||(this.onPacket(l),r())}).catch(n=>{})};r();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(i){this.writable=!1;for(let t=0;t<i.length;t++){const a=i[t],o=t===i.length-1;this._writer.write(a).then(()=>{o&&Va(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var i;(i=this._transport)===null||i===void 0||i.close()}}const fu={websocket:Du,webtransport:Xu,polling:wu},vu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hu=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Bo(e){if(e.length>8e3)throw"URI too long";const i=e,t=e.indexOf("["),a=e.indexOf("]");t!=-1&&a!=-1&&(e=e.substring(0,t)+e.substring(t,a).replace(/:/g,";")+e.substring(a,e.length));let o=vu.exec(e||""),r={},s=14;for(;s--;)r[Hu[s]]=o[s]||"";return t!=-1&&a!=-1&&(r.source=i,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Pu(r,r.path),r.queryKey=_u(r,r.query),r}function Pu(e,i){const t=/\/{2,9}/g,a=i.replace(t,"/").split("/");return(i.slice(0,1)=="/"||i.length===0)&&a.splice(0,1),i.slice(-1)=="/"&&a.splice(a.length-1,1),a}function _u(e,i){const t={};return i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,r){o&&(t[o]=r)}),t}const Do=typeof addEventListener=="function"&&typeof removeEventListener=="function",ka=[];Do&&addEventListener("offline",()=>{ka.forEach(e=>e())},!1);class Me extends Vi{constructor(i,t){if(super(),this.binaryType=Ru,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,i&&typeof i=="object"&&(t=i,i=null),i){const a=Bo(i);t.hostname=a.host,t.secure=a.protocol==="https"||a.protocol==="wss",t.port=a.port,a.query&&(t.query=a.query)}else t.host&&(t.hostname=Bo(t.host).host);Ja(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ju(this.opts.query)),Do&&(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"})},ka.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(i){const t=Object.assign({},this.opts.query);t.EIO=Qn,t.transport=i,this.id&&(t.sid=this.id);const a=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[i]);return new this._transportsByName[i](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const i=this.opts.rememberUpgrade&&Me.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(i);t.open(),this.setTransport(t)}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",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Me.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 t=new Error("server error");t.code=i.data,this._onError(t);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 t=1;for(let a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(t+=Gu(o)),a>0&&t>this._maxPayload)return this.writeBuffer.slice(0,a);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const i=Date.now()>this._pingTimeoutTime;return i&&(this._pingTimeoutTime=0,Va(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),i}write(i,t,a){return this._sendPacket("message",i,t,a),this}send(i,t,a){return this._sendPacket("message",i,t,a),this}_sendPacket(i,t,a,o){if(typeof t=="function"&&(o=t,t=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const r={type:i,data:t,options:a};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),o&&this.once("flush",o),this.flush()}close(){const i=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),i()},a=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():i()}):this.upgrading?a():i()),this}_onError(i){if(Me.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,t){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(),Do&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=ka.indexOf(this._offlineEventListener);a!==-1&&ka.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",i,t),this.writeBuffer=[],this._prevBufferLen=0}}}Me.protocol=Qn;class $u extends Me{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 t=this.createTransport(i),a=!1;Me.priorWebsocketSuccess=!1;const o=()=>{a||(t.send([{type:"ping",data:"probe"}]),t.once("packet",p=>{if(!a)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Me.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(q(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function r(){a||(a=!0,q(),t.close(),t=null)}const s=p=>{const u=new Error("probe error: "+p);u.transport=t.name,r(),this.emitReserved("upgradeError",u)};function n(){s("transport closed")}function l(){s("socket closed")}function A(p){t&&p.name!==t.name&&r()}const q=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",n),this.off("close",l),this.off("upgrading",A)};t.once("open",o),t.once("error",s),t.once("close",n),this.once("close",l),this.once("upgrading",A),this._upgrades.indexOf("webtransport")!==-1&&i!=="webtransport"?this.setTimeoutFn(()=>{a||t.open()},200):t.open()}onHandshake(i){this._upgrades=this._filterUpgrades(i.upgrades),super.onHandshake(i)}_filterUpgrades(i){const t=[];for(let a=0;a<i.length;a++)~this.transports.indexOf(i[a])&&t.push(i[a]);return t}}let iI=class extends $u{constructor(i,t={}){const a=typeof i=="object"?i:t;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>fu[o]).filter(o=>!!o)),super(i,a)}};function eI(e,i="",t){let a=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),a=Bo(e)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const r=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+r+":"+a.port+i,a.href=a.protocol+"://"+r+(t&&t.port===a.port?"":":"+a.port),a}const tI=typeof ArrayBuffer=="function",aI=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Tn=Object.prototype.toString,oI=typeof Blob=="function"||typeof Blob<"u"&&Tn.call(Blob)==="[object BlobConstructor]",rI=typeof File=="function"||typeof File<"u"&&Tn.call(File)==="[object FileConstructor]";function Xo(e){return tI&&(e instanceof ArrayBuffer||aI(e))||oI&&e instanceof Blob||rI&&e instanceof File}function Wa(e,i){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,a=e.length;t<a;t++)if(Wa(e[t]))return!0;return!1}if(Xo(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Wa(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Wa(e[t]))return!0;return!1}function sI(e){const i=[],t=e.data,a=e;return a.data=fo(t,i),a.attachments=i.length,{packet:a,buffers:i}}function fo(e,i){if(!e)return e;if(Xo(e)){const t={_placeholder:!0,num:i.length};return i.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let a=0;a<e.length;a++)t[a]=fo(e[a],i);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=fo(e[a],i));return t}return e}function nI(e,i){return e.data=vo(e.data,i),delete e.attachments,e}function vo(e,i){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<i.length)return i[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=vo(e[t],i);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=vo(e[t],i));return e}const lI=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],AI=5;var li;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(li||(li={}));class qI{constructor(i){this.replacer=i}encode(i){return(i.type===li.EVENT||i.type===li.ACK)&&Wa(i)?this.encodeAsBinary({type:i.type===li.EVENT?li.BINARY_EVENT:li.BINARY_ACK,nsp:i.nsp,data:i.data,id:i.id}):[this.encodeAsString(i)]}encodeAsString(i){let t=""+i.type;return(i.type===li.BINARY_EVENT||i.type===li.BINARY_ACK)&&(t+=i.attachments+"-"),i.nsp&&i.nsp!=="/"&&(t+=i.nsp+","),i.id!=null&&(t+=i.id),i.data!=null&&(t+=JSON.stringify(i.data,this.replacer)),t}encodeAsBinary(i){const t=sI(i),a=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(a),o}}function wn(e){return Object.prototype.toString.call(e)==="[object Object]"}class Ho extends Vi{constructor(i){super(),this.reviver=i}add(i){let t;if(typeof i=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(i);const a=t.type===li.BINARY_EVENT;a||t.type===li.BINARY_ACK?(t.type=a?li.EVENT:li.ACK,this.reconstructor=new mI(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Xo(i)||i.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(i),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+i)}decodeString(i){let t=0;const a={type:Number(i.charAt(0))};if(li[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===li.BINARY_EVENT||a.type===li.BINARY_ACK){const r=t+1;for(;i.charAt(++t)!=="-"&&t!=i.length;);const s=i.substring(r,t);if(s!=Number(s)||i.charAt(t)!=="-")throw new Error("Illegal attachments");a.attachments=Number(s)}if(i.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(i.charAt(t)===","||t===i.length););a.nsp=i.substring(r,t)}else a.nsp="/";const o=i.charAt(t+1);if(o!==""&&Number(o)==o){const r=t+1;for(;++t;){const s=i.charAt(t);if(s==null||Number(s)!=s){--t;break}if(t===i.length)break}a.id=Number(i.substring(r,t+1))}if(i.charAt(++t)){const r=this.tryParse(i.substr(t));if(Ho.isPayloadValid(a.type,r))a.data=r;else throw new Error("invalid payload")}return a}tryParse(i){try{return JSON.parse(i,this.reviver)}catch{return!1}}static isPayloadValid(i,t){switch(i){case li.CONNECT:return wn(t);case li.DISCONNECT:return t===void 0;case li.CONNECT_ERROR:return typeof t=="string"||wn(t);case li.EVENT:case li.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&lI.indexOf(t[0])===-1);case li.ACK:case li.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class mI{constructor(i){this.packet=i,this.buffers=[],this.reconPack=i}takeBinaryData(i){if(this.buffers.push(i),this.buffers.length===this.reconPack.attachments){const t=nI(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const pI=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ho,Encoder:qI,get PacketType(){return li},protocol:AI},Symbol.toStringTag,{value:"Module"}));function ne(e,i,t){return e.on(i,t),function(){e.off(i,t)}}const uI=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Bn extends Vi{constructor(i,t,a){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=t,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const i=this.io;this.subs=[ne(i,"open",this.onopen.bind(this)),ne(i,"packet",this.onpacket.bind(this)),ne(i,"error",this.onerror.bind(this)),ne(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,...t){var a,o,r;if(uI.hasOwnProperty(i))throw new Error('"'+i.toString()+'" is a reserved event name');if(t.unshift(i),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:li.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const q=this.ids++,p=t.pop();this._registerAckCallback(q,p),s.id=q}const n=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,l=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!n||(l?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(i,t){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[i]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[i];for(let n=0;n<this.sendBuffer.length;n++)this.sendBuffer[n].id===i&&this.sendBuffer.splice(n,1);t.call(this,new Error("operation has timed out"))},o),s=(...n)=>{this.io.clearTimeoutFn(r),t.apply(this,n)};s.withError=!0,this.acks[i]=s}emitWithAck(i,...t){return new Promise((a,o)=>{const r=(s,n)=>s?o(s):a(n);r.withError=!0,t.push(r),this.emit(i,...t)})}_addToQueue(i){let t;typeof i[i.length-1]=="function"&&(t=i.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:i,flags:Object.assign({fromQueue:!0},this.flags)};i.push((o,...r)=>a!==this._queue[0]?void 0:(o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...r)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(i=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!i||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.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:li.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,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",i,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(i=>{if(!this.sendBuffer.some(a=>String(a.id)===i)){const a=this.acks[i];delete this.acks[i],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(i){if(i.nsp===this.nsp)switch(i.type){case li.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 li.EVENT:case li.BINARY_EVENT:this.onevent(i);break;case li.ACK:case li.BINARY_ACK:this.onack(i);break;case li.DISCONNECT:this.ondisconnect();break;case li.CONNECT_ERROR:this.destroy();const a=new Error(i.data.message);a.data=i.data.data,this.emitReserved("connect_error",a);break}}onevent(i){const t=i.data||[];i.id!=null&&t.push(this.ack(i.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(i){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const a of t)a.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 t=this;let a=!1;return function(...o){a||(a=!0,t.packet({type:li.ACK,id:i,data:o}))}}onack(i){const t=this.acks[i.id];typeof t=="function"&&(delete this.acks[i.id],t.withError&&i.data.unshift(null),t.apply(this,i.data))}onconnect(i,t){this.id=i,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}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:li.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 t=this._anyListeners;for(let a=0;a<t.length;a++)if(i===t[a])return t.splice(a,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 t=this._anyOutgoingListeners;for(let a=0;a<t.length;a++)if(i===t[a])return t.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(i){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const a of t)a.apply(this,i.data)}}}function et(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}et.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),t=Math.floor(i*this.jitter*e);e=Math.floor(i*10)&1?e+t:e-t}return Math.min(e,this.max)|0},et.prototype.reset=function(){this.attempts=0},et.prototype.setMin=function(e){this.ms=e},et.prototype.setMax=function(e){this.max=e},et.prototype.setJitter=function(e){this.jitter=e};class Po extends Vi{constructor(i,t){var a;super(),this.nsps={},this.subs=[],i&&typeof i=="object"&&(t=i,i=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ja(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((a=t.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new et({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=i;const o=t.parser||pI;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.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 t;return i===void 0?this._reconnectionDelay:(this._reconnectionDelay=i,(t=this.backoff)===null||t===void 0||t.setMin(i),this)}randomizationFactor(i){var t;return i===void 0?this._randomizationFactor:(this._randomizationFactor=i,(t=this.backoff)===null||t===void 0||t.setJitter(i),this)}reconnectionDelayMax(i){var t;return i===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=i,(t=this.backoff)===null||t===void 0||t.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 iI(this.uri,this.opts);const t=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=ne(t,"open",function(){a.onopen(),i&&i()}),r=n=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",n),i?i(n):this.maybeReconnectOnOpen()},s=ne(t,"error",r);if(this._timeout!==!1){const n=this._timeout,l=this.setTimeoutFn(()=>{o(),r(new Error("timeout")),t.close()},n);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(o),this.subs.push(s),this}connect(i){return this.open(i)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const i=this.engine;this.subs.push(ne(i,"ping",this.onping.bind(this)),ne(i,"data",this.ondata.bind(this)),ne(i,"error",this.onerror.bind(this)),ne(i,"close",this.onclose.bind(this)),ne(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(i){try{this.decoder.add(i)}catch(t){this.onclose("parse error",t)}}ondecoded(i){Va(()=>{this.emitReserved("packet",i)},this.setTimeoutFn)}onerror(i){this.emitReserved("error",i)}socket(i,t){let a=this.nsps[i];return a?this._autoConnect&&!a.active&&a.connect():(a=new Bn(this,i,t),this.nsps[i]=a),a}_destroy(i){const t=Object.keys(this.nsps);for(const a of t)if(this.nsps[a].active)return;this._close()}_packet(i){const t=this.encoder.encode(i);for(let a=0;a<t.length;a++)this.engine.write(t[a],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,t){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",i,t),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 t=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{i.skipReconnect||(this.emitReserved("reconnect_attempt",i.backoff.attempts),!i.skipReconnect&&i.open(o=>{o?(i._reconnecting=!1,i.reconnect(),this.emitReserved("reconnect_error",o)):i.onreconnect()}))},t);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const i=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",i)}}const Wt={};function Ma(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};const t=eI(e,i.path||"/socket.io"),a=t.source,o=t.id,r=t.path,s=Wt[o]&&r in Wt[o].nsps,n=i.forceNew||i["force new connection"]||i.multiplex===!1||s;let l;return n?l=new Po(a,i):(Wt[o]||(Wt[o]=new Po(a,i)),l=Wt[o]),t.query&&!i.query&&(i.query=t.queryKey),l.socket(t.path,i)}Object.assign(Ma,{Manager:Po,Socket:Bn,io:Ma,connect:Ma});async function II(e,i,t){return(await Ki.post(t,{versionId:e,fileSize:i})).data}async function KI(e,i){return(await Ki.post(i+"/getFileSize",e)).data}const Ea=5,cI=({setIsExceedingFileSizeAccepted:e,closeModal:i,setLoading:t,typeOfProduct:a,versionId:o,fileSize:r,setFileSize:s,user:n,compressApi:l,producerApi:A,api:q})=>{const[p,u]=y.useState(!1),[I,c]=y.useState(!1);y.useEffect(()=>{const h=Ma(l,{path:"/socket.io"});return h.on("connect",()=>{console.log("Connected to the socket server")}),h.on("video-compressing",async b=>{if(console.log(b),b.userId===n._id&&b.isSuccess){console.log("Video compress successfull");const F=await KI({_id:o},q);s(F.size),e(!1)}}),h.on("error",b=>{console.error("Socket error:",b)}),()=>{h.disconnect()}},[o]);const Z=()=>{i(),e(!1),t(!0)},K=async()=>{try{u(!0);const h=await II(o,r,`${A}/videos/compressByDiff`);console.log("Compression result:",h),t(!1)}catch(h){console.error("Error compressing video:",h),t(!1),i()}},S=qi[a],W=Vt[a],U=r-Ea,k=Ea/r*100;return m.jsxs(ua,{isOpen:!0,ariaHideApp:!1,onRequestClose:Z,style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"1.5rem",backgroundColor:"white",zIndex:50,maxWidth:"32rem",width:"100%",height:"100%",maxHeight:"34.5rem",overflow:"hidden",padding:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Size Exceeding Modal",shouldCloseOnOverlayClick:!0,children:[m.jsx("button",{onClick:Z,style:{position:"absolute",top:"1.25rem",right:"1.25rem",padding:"0.5rem",borderRadius:"9999px",transition:"all 0.3s",zIndex:10,border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="#f1f5f9"},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"#94a3b8",transition:"color 0.3s"},onMouseEnter:h=>{h.currentTarget.style.color="#0f172a"},onMouseLeave:h=>{h.currentTarget.style.color="#94a3b8"},children:[m.jsx("path",{d:"M18 6 6 18"}),m.jsx("path",{d:"m6 6 12 12"})]})}),m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",gap:"8px",paddingLeft:"2rem",paddingRight:"2rem",paddingTop:"2.5rem",paddingBottom:"2.5rem",height:"100%",width:"100%"},children:[m.jsxs("div",{style:{position:"relative",marginBottom:"1.5rem"},children:[m.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"9999px",filter:"blur(24px)",opacity:.4,animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",backgroundColor:S}}),m.jsx("div",{style:{position:"relative",width:"80px",height:"80px",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",backgroundColor:S},children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"44",height:"44",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("circle",{cx:"12",cy:"12",r:"10"}),m.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),m.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})})]}),m.jsx("h2",{style:{fontSize:"24px",fontWeight:"bold",color:"#0f172a",marginBottom:"0.5rem",letterSpacing:"-0.025em"},children:"Playable Size Too Large"}),m.jsxs("div",{style:{backgroundColor:"#f8fafc",borderRadius:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",marginBottom:"1rem",width:"100%",border:"1px solid #e2e8f0"},children:[m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"0.875rem"},children:[m.jsx("span",{style:{color:"#475569"},children:"Current size:"}),m.jsxs("span",{style:{fontWeight:"bold",fontSize:"18px",color:S},children:[r.toFixed(1)," MB"]})]}),m.jsxs("div",{style:{marginTop:"0.5rem",width:"100%",position:"relative"},children:[m.jsx("div",{style:{width:"100%",backgroundColor:"#e2e8f0",borderRadius:"9999px",height:"0.5rem",overflow:"hidden"},children:m.jsx("div",{style:{height:"100%",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",width:`${k}%`,backgroundColor:S}})}),m.jsx("div",{style:{position:"absolute",top:0,width:"0.125rem",height:"0.5rem",backgroundColor:"#334155",zIndex:10,left:`${k}%`}}),m.jsx("div",{style:{position:"absolute",top:0,height:"0.5rem",overflow:"hidden",left:`${k}%`,width:`${100-k}%`},children:m.jsx("div",{style:{height:"100%",borderTopRightRadius:"9999px",borderBottomRightRadius:"9999px",opacity:.6,backgroundColor:S,backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,0.3) 3px, rgba(255,255,255,0.3) 6px)"}})})]}),m.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"0.75rem",marginTop:"0.25rem"},children:[m.jsxs("span",{style:{color:"#64748b"},children:["Limit: ",Ea," MB"]}),m.jsxs("span",{style:{fontWeight:500,fontSize:"12px",color:S},children:["+",U.toFixed(1)," MB over"]})]})]}),p?m.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingTop:"2rem",paddingBottom:"2rem"},children:[m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:S,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"spin 1s linear infinite",marginBottom:"1rem"},children:m.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),m.jsx("style",{children:`
93
93
  @keyframes spin {
94
94
  from {
95
95
  transform: rotate(0deg);