drill.define(async e=>{await e("./aes","./jsencrypt");let t="gt916wxhyfvc8f93",r="262te1454r9qyaac";const n=()=>(Math.random().toString(36).substr(2)+Math.random().toString(36).substr(2)).slice(0,16);let o=CryptoJS.enc.Utf8.parse(t),a=CryptoJS.enc.Utf8.parse(r);const s=e=>(e=>{let t=CryptoJS.AES.encrypt(e,o,{iv:a,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t=t.toString()})(JSON.stringify(e)),c=e=>JSON.parse((e=>{let t=CryptoJS.AES.decrypt(e,o,{iv:a,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return t=CryptoJS.enc.Utf8.stringify(t)})(e));return async function(e){let p,d,i=1,y=[],l={oncmd(e){},onmsg(e,t){},get isUpToServer(){return i},set isUpToServer(e){i=e},get allow(){return y}},S=l.socket=new WebSocket(e);S.onclose=(e=>{console.log("close =>",e),l.onmsg("close",{event:e})}),S.onerror=(e=>{console.log("error =>",e),l.onmsg("error",{event:e})}),Object.defineProperties(l,{commonData:{get:()=>p}}),await new Promise(e=>{S.onmessage=(d=>{let g=c(d.data);switch(g.type){case"beforeInit":let c=n(),d=n(),u=CryptoJS.enc.Utf8.parse(t),C=CryptoJS.enc.Utf8.parse(r);var m=new JSEncrypt;m.setPublicKey(g.p);let f=m.encrypt(c+d);t=c,r=d,o=u,a=C,S.send(s({type:"init",c:f}));break;case"start":p=$.xdata(g.data),l.onmsg("start",{commonData:p}),p.on("update",e=>{let{trend:t}=e;"change"==t.genre&&t.oldVal==t.value||(i||y.includes(t.fromKey))&&S.send(s({type:"update",trend:t}))}),e();break;case"update":p.entrend(g.trend);break;case"pong":break;case"cmd":l.oncmd(g.data)}})});const g=()=>{clearTimeout(d),d=setTimeout(()=>{1==S.readyState&&(S.send(s({type:"ping"})),g())},2e4)};return g(),l}});