mayu-live 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js +1 -0
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.br +0 -0
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.map +1 -0
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.map.br +0 -0
- data/lib/mayu/client/dist/custom-elements/mayu-alert-cd7ad2a4.js.map +1 -1
- data/lib/mayu/client/dist/custom-elements/mayu-disconnected-9f349f46.js.map +1 -1
- data/lib/mayu/client/dist/custom-elements/mayu-exception-63df4e8c.js.map +1 -1
- data/lib/mayu/client/dist/custom-elements/mayu-ping-f7c763db.js +1 -0
- data/lib/mayu/client/dist/custom-elements/mayu-ping-f7c763db.js.map +1 -0
- data/lib/mayu/client/dist/custom-elements/mayu-progress-bar-eb3e1ac8.js.map +1 -1
- data/lib/mayu/client/dist/entries.json +1 -1
- data/lib/mayu/client/dist/main-b7403aa1.js +1 -0
- data/lib/mayu/client/dist/main-b7403aa1.js.br +0 -0
- data/lib/mayu/client/dist/main-b7403aa1.js.map +1 -0
- data/lib/mayu/client/dist/main-b7403aa1.js.map.br +0 -0
- data/lib/mayu/client/package.json +12 -12
- data/lib/mayu/client/src/custom-elements/mayu-ping.html +2 -3
- data/lib/mayu/client/src/custom-elements/mayu-ping.ts +56 -14
- data/lib/mayu/client/src/main.ts +9 -11
- data/lib/mayu/resources/transformers/haml.rb +4 -4
- data/lib/mayu/version.rb +1 -1
- metadata +12 -12
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js +0 -1
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.br +0 -0
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.map +0 -1
- data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.map.br +0 -0
- data/lib/mayu/client/dist/custom-elements/mayu-ping-c498c2a6.js +0 -1
- data/lib/mayu/client/dist/custom-elements/mayu-ping-c498c2a6.js.map +0 -1
- data/lib/mayu/client/dist/main-8506b35d.js +0 -1
- data/lib/mayu/client/dist/main-8506b35d.js.br +0 -0
- data/lib/mayu/client/dist/main-8506b35d.js.map +0 -1
- data/lib/mayu/client/dist/main-8506b35d.js.map.br +0 -0
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mayu-live
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Alin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -391,25 +391,25 @@ files:
|
|
391
391
|
- lib/mayu/app_metrics.rb
|
392
392
|
- lib/mayu/banner.rb
|
393
393
|
- lib/mayu/client/README.md
|
394
|
-
- lib/mayu/client/dist/DecompressionStreamPolyfill-
|
395
|
-
- lib/mayu/client/dist/DecompressionStreamPolyfill-
|
396
|
-
- lib/mayu/client/dist/DecompressionStreamPolyfill-
|
397
|
-
- lib/mayu/client/dist/DecompressionStreamPolyfill-
|
394
|
+
- lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js
|
395
|
+
- lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.br
|
396
|
+
- lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.map
|
397
|
+
- lib/mayu/client/dist/DecompressionStreamPolyfill-0710fe09.js.map.br
|
398
398
|
- lib/mayu/client/dist/custom-elements/mayu-alert-cd7ad2a4.js
|
399
399
|
- lib/mayu/client/dist/custom-elements/mayu-alert-cd7ad2a4.js.map
|
400
400
|
- lib/mayu/client/dist/custom-elements/mayu-disconnected-9f349f46.js
|
401
401
|
- lib/mayu/client/dist/custom-elements/mayu-disconnected-9f349f46.js.map
|
402
402
|
- lib/mayu/client/dist/custom-elements/mayu-exception-63df4e8c.js
|
403
403
|
- lib/mayu/client/dist/custom-elements/mayu-exception-63df4e8c.js.map
|
404
|
-
- lib/mayu/client/dist/custom-elements/mayu-ping-
|
405
|
-
- lib/mayu/client/dist/custom-elements/mayu-ping-
|
404
|
+
- lib/mayu/client/dist/custom-elements/mayu-ping-f7c763db.js
|
405
|
+
- lib/mayu/client/dist/custom-elements/mayu-ping-f7c763db.js.map
|
406
406
|
- lib/mayu/client/dist/custom-elements/mayu-progress-bar-eb3e1ac8.js
|
407
407
|
- lib/mayu/client/dist/custom-elements/mayu-progress-bar-eb3e1ac8.js.map
|
408
408
|
- lib/mayu/client/dist/entries.json
|
409
|
-
- lib/mayu/client/dist/main-
|
410
|
-
- lib/mayu/client/dist/main-
|
411
|
-
- lib/mayu/client/dist/main-
|
412
|
-
- lib/mayu/client/dist/main-
|
409
|
+
- lib/mayu/client/dist/main-b7403aa1.js
|
410
|
+
- lib/mayu/client/dist/main-b7403aa1.js.br
|
411
|
+
- lib/mayu/client/dist/main-b7403aa1.js.map
|
412
|
+
- lib/mayu/client/dist/main-b7403aa1.js.map.br
|
413
413
|
- lib/mayu/client/package.json
|
414
414
|
- lib/mayu/client/rollup.config.js
|
415
415
|
- lib/mayu/client/src/DecompressionStream.ts
|
@@ -1 +0,0 @@
|
|
1
|
-
var r={},e=Uint8Array,n=Uint16Array,t=Uint32Array,a=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=function(r,e){for(var a=new n(31),i=0;i<31;++i)a[i]=e+=1<<r[i-1];var o=new t(a[30]);for(i=1;i<30;++i)for(var f=a[i];f<a[i+1];++f)o[f]=f-a[i]<<5|i;return[a,o]},s=f(a,2),u=s[0],c=s[1];u[28]=258,c[258]=28;for(var l=f(i,0)[0],v=new n(32768),h=0;h<32768;++h){var d=(43690&h)>>>1|(21845&h)<<1;d=(61680&(d=(52428&d)>>>2|(13107&d)<<2))>>>4|(3855&d)<<4,v[h]=((65280&d)>>>8|(255&d)<<8)>>>1}var p=function(r,e,t){for(var a=r.length,i=0,o=new n(e);i<a;++i)r[i]&&++o[r[i]-1];var f,s=new n(e);for(i=0;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;if(t){f=new n(1<<e);var u=15-e;for(i=0;i<a;++i)if(r[i])for(var c=i<<4|r[i],l=e-r[i],h=s[r[i]-1]++<<l,d=h|(1<<l)-1;h<=d;++h)f[v[h]>>>u]=c}else for(f=new n(a),i=0;i<a;++i)r[i]&&(f[i]=v[s[r[i]-1]++]>>>15-r[i]);return f},w=new e(288);for(h=0;h<144;++h)w[h]=8;for(h=144;h<256;++h)w[h]=9;for(h=256;h<280;++h)w[h]=7;for(h=280;h<288;++h)w[h]=8;var g=new e(32);for(h=0;h<32;++h)g[h]=5;var b=p(w,9,1),m=p(g,5,1),y=function(r){for(var e=r[0],n=1;n<r.length;++n)r[n]>e&&(e=r[n]);return e},E=function(r,e,n){var t=e/8|0;return(r[t]|r[t+1]<<8)>>(7&e)&n},k=function(r,e){var n=e/8|0;return(r[n]|r[n+1]<<8|r[n+2]<<16)>>(7&e)},x=function(r){return(r+7)/8|0},S=function(r,a,i){(null==a||a<0)&&(a=0),(null==i||i>r.length)&&(i=r.length);var o=new(2==r.BYTES_PER_ELEMENT?n:4==r.BYTES_PER_ELEMENT?t:e)(i-a);return o.set(r.subarray(a,i)),o},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],M=function(r,e,n){var t=new Error(e||T[r]);if(t.code=r,Error.captureStackTrace&&Error.captureStackTrace(t,M),!n)throw t;return t},O=function(r,n,t){var f=r.length;if(!f||t&&t.f&&!t.l)return n||new e(0);var s=!n||t,c=!t||t.i;t||(t={}),n||(n=new e(3*f));var v=function(r){var t=n.length;if(r>t){var a=new e(Math.max(2*t,r));a.set(n),n=a}},h=t.f||0,d=t.p||0,w=t.b||0,g=t.l,T=t.d,O=t.m,U=t.n,L=8*f;do{if(!g){h=E(r,d,1);var $=E(r,d+1,3);if(d+=3,!$){var A=r[(q=x(d)+4)-4]|r[q-3]<<8,R=q+A;if(R>f){c&&M(0);break}s&&v(w+A),n.set(r.subarray(q,R),w),t.b=w+=A,t.p=d=8*R,t.f=h;continue}if(1==$)g=b,T=m,O=9,U=5;else if(2==$){var _=E(r,d,31)+257,z=E(r,d+10,15)+4,B=_+E(r,d+5,31)+1;d+=14;for(var D=new e(B),P=new e(19),j=0;j<z;++j)P[o[j]]=E(r,d+3*j,7);d+=3*z;var F=y(P),N=(1<<F)-1,Y=p(P,F,1);for(j=0;j<B;){var q,I=Y[E(r,d,N)];if(d+=15&I,(q=I>>>4)<16)D[j++]=q;else{var W=0,C=0;for(16==q?(C=3+E(r,d,3),d+=2,W=D[j-1]):17==q?(C=3+E(r,d,7),d+=3):18==q&&(C=11+E(r,d,127),d+=7);C--;)D[j++]=W}}var G=D.subarray(0,_),H=D.subarray(_);O=y(G),U=y(H),g=p(G,O,1),T=p(H,U,1)}else M(1);if(d>L){c&&M(0);break}}s&&v(w+131072);for(var J=(1<<O)-1,K=(1<<U)-1,Q=d;;Q=d){var V=(W=g[k(r,d)&J])>>>4;if((d+=15&W)>L){c&&M(0);break}if(W||M(2),V<256)n[w++]=V;else{if(256==V){Q=d,g=null;break}var X=V-254;if(V>264){var Z=a[j=V-257];X=E(r,d,(1<<Z)-1)+u[j],d+=Z}var rr=T[k(r,d)&K],er=rr>>>4;rr||M(3),d+=15&rr;H=l[er];if(er>3){Z=i[er];H+=k(r,d)&(1<<Z)-1,d+=Z}if(d>L){c&&M(0);break}s&&v(w+131072);for(var nr=w+X;w<nr;w+=4)n[w]=n[w-H],n[w+1]=n[w+1-H],n[w+2]=n[w+2-H],n[w+3]=n[w+3-H];w=nr}}t.l=g,t.p=Q,t.b=w,t.f=h,g&&(h=1,t.m=O,t.d=T,t.n=U)}while(!h);return w==n.length?n:S(n,0,w)},U=new e(0),L=function(r,e,n){for(var t=r(),a=r.toString(),i=a.slice(a.indexOf("[")+1,a.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<t.length;++o){var f=t[o],s=i[o];if("function"==typeof f){e+=";"+s+"=";var u=f.toString();if(f.prototype)if(-1!=u.indexOf("[native code]")){var c=u.indexOf(" ",8)+1;e+=u.slice(c,u.indexOf("(",c))}else for(var l in e+=u,f.prototype)e+=";"+s+".prototype."+l+"="+f.prototype[l].toString();else e+=u}else n[s]=f}return[e,n]},$=[],A=function(e,n,t,a){var i;if(!$[t]){for(var o="",f={},s=e.length-1,u=0;u<s;++u)o=(i=L(e[u],o,f))[0],f=i[1];$[t]=L(e[s],o,f)}var c=function(r,e){var n={};for(var t in r)n[t]=r[t];for(var t in e)n[t]=e[t];return n}({},$[t][1]);return function(e,n,t,a,i){var o=new Worker(r[n]||(r[n]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(r){var e=r.data,n=e.$e$;if(n){var t=new Error(n[0]);t.code=n[1],t.stack=n[2],i(t,null)}else i(null,e)},o.postMessage(t,a),o}($[t][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",t,c,function(r){var e=[];for(var n in r)r[n].buffer&&e.push((r[n]=new r[n].constructor(r[n])).buffer);return e}(c),a)},R=function(){return[e,n,t,a,i,o,u,l,b,m,v,T,p,y,E,k,x,S,M,O,j,_,z]},_=function(r){return postMessage(r,[r.buffer])},z=function(r){return r&&r.size&&new e(r.size)},B=function(r){return r.ondata=function(r,e){return postMessage([r,e],[r.buffer])},function(e){return r.push(e.data[0],e.data[1])}},D=function(){function r(r){this.s={},this.p=new e(0),this.ondata=r}return r.prototype.e=function(r){this.ondata||M(5),this.d&&M(4);var n=this.p.length,t=new e(n+r.length);t.set(this.p),t.set(r,n),this.p=t},r.prototype.c=function(r){this.d=this.s.i=r||!1;var e=this.s.b,n=O(this.p,this.o,this.s);this.ondata(S(n,e,this.s.b),this.d),this.o=S(n,this.s.b-32768),this.s.b=this.o.length,this.p=S(this.p,this.s.p/8|0),this.s.p&=7},r.prototype.push=function(r,e){this.e(r),this.c(e)},r}(),P=function(){return function(r){var e,n,t,a;this.ondata=r,e=this,n=0,a=A([R,function(){return[B,D]}],(function(){var r=new D;onmessage=B(r)}),7,(function(r,n){r?(a.terminate(),e.ondata.call(e,r)):(n[1]&&a.terminate(),e.ondata.call(e,r,n[0],n[1]))})),a.postMessage(n),e.push=function(r,n){e.ondata||M(5),t&&e.ondata(M(4,0,1),null,!!n),a.postMessage([r,t=n],[r.buffer])},e.terminate=function(){a.terminate()}}}();function j(r,e){return O(r,e)}var F="undefined"!=typeof TextDecoder&&new TextDecoder;try{F.decode(U,{stream:!0}),1}catch(r){}class N extends TransformStream{constructor(r){let e;super({start(r){e=new P,e.ondata=(e,n,t)=>{e?r.error(e):t?r.terminate():r.enqueue(n)}},transform(r,n){try{e.push(r,!1)}catch(r){n.error(new Error(`DecompressionStreamPolyfill inflation failure: ${r}`))}},flush(){e.push(new Uint8Array,!0)}})}}export{N as default};//# sourceMappingURL=DecompressionStreamPolyfill-3ceba43e.js.map
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DecompressionStreamPolyfill-3ceba43e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
const t=document.createElement("template");t.innerHTML='<style>.mayu-ping{position:fixed;bottom:0;left:0;z-index:10000;background:#0003;border:0 solid #0003;border-width:1px 1px 0 0;font-size:.9em;padding:.2em .5em;border-top-right-radius:3px;pointer-events:none;text-shadow:0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000;color:#fff;font-weight:700;font-family:monospace;transition:background .5s 0s ease-in-out}.status-disconnected{background:#d0060699}.status-connected{background:#44f70899}.status-transferring{background:#0866f799}</style><div class="mayu-ping">Ping: <span class="ping">N/A</span> (<span class="region">N/A</span>)</div>';class e extends HTMLElement{div;ping;region;static observedAttributes=["ping","region","status"];connectedCallback(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(t.content.cloneNode(!0)),this.div=this.shadowRoot.querySelector(".mayu-ping"),this.ping=this.shadowRoot.querySelector(".ping"),this.region=this.shadowRoot.querySelector(".region")}attributeChangedCallback(t,e,s){switch(t){case"ping":if(!this.ping)break;this.ping.textContent=s;break;case"region":if(!this.region)break;this.region.textContent=s;break;case"status":if(!this.div)break;e&&e!==s&&this.div.classList.remove(`status-${e}`),s&&this.div.classList.add(`status-${s}`)}}}window.customElements.define("mayu-ping",e);export{e as default};//# sourceMappingURL=mayu-ping-c498c2a6.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mayu-ping-c498c2a6.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
var e,t,n,r=4294967295;function o(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var i=("undefined"==typeof process||"never"!==(null===(e=null===process||void 0===process?void 0:process.env)||void 0===e?void 0:e.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder,s=i?new TextEncoder:void 0;i&&"undefined"!=typeof process&&(null===(t=null===process||void 0===process?void 0:process.env)||void 0===t||t.TEXT_ENCODING),null==s||s.encodeInto;function a(e,t,n){for(var r=t,o=r+n,i=[],s="";r<o;){var a=e[r++];if(0==(128&a))i.push(a);else if(192==(224&a)){var c=63&e[r++];i.push((31&a)<<6|c)}else if(224==(240&a)){c=63&e[r++];var u=63&e[r++];i.push((31&a)<<12|c<<6|u)}else if(240==(248&a)){var h=(7&a)<<18|(c=63&e[r++])<<12|(u=63&e[r++])<<6|63&e[r++];h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h)}else i.push(a);i.length>=4096&&(s+=String.fromCharCode.apply(String,i),i.length=0)}return i.length>0&&(s+=String.fromCharCode.apply(String,i)),s}var c=i?new TextDecoder:null,u=i?"undefined"!=typeof process&&"force"!==(null===(n=null===process||void 0===process?void 0:process.env)||void 0===n?void 0:n.TEXT_DECODER)?200:0:r;var h,d=function(e,t){this.type=e,this.data=t},l=(h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},h(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e){function t(n){var r=e.call(this,n)||this,o=Object.create(t.prototype);return Object.setPrototypeOf(r,o),Object.defineProperty(r,"name",{configurable:!0,enumerable:!1,value:t.name}),r}return l(t,e),t}(Error);function p(e){var t=e.sec,n=e.nsec;if(t>=0&&n>=0&&t<=17179869183){if(0===n&&t<=4294967295){var r=new Uint8Array(4);return(s=new DataView(r.buffer)).setUint32(0,t),r}var o=t/4294967296,i=4294967295&t;r=new Uint8Array(8);return(s=new DataView(r.buffer)).setUint32(0,n<<2|3&o),s.setUint32(4,i),r}var s;r=new Uint8Array(12);return(s=new DataView(r.buffer)).setUint32(0,n),function(e,t,n){var r=Math.floor(n/4294967296),o=n;e.setUint32(t,r),e.setUint32(t+4,o)}(s,4,t),r}var y={type:-1,encode:function(e){var t,n,r,o;return e instanceof Date?p((t=e.getTime(),n=Math.floor(t/1e3),r=1e6*(t-1e3*n),o=Math.floor(r/1e9),{sec:n+o,nsec:r-1e9*o})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:o(t,4),nsec:t.getUint32(0)};default:throw new f("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},m=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(y)}return e.prototype.register=function(e){var t=e.type,n=e.encode,r=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=r;else{var o=1+t;this.builtInEncoders[o]=n,this.builtInDecoders[o]=r}},e.prototype.tryToEncode=function(e,t){for(var n=0;n<this.builtInEncoders.length;n++){if(null!=(r=this.builtInEncoders[n]))if(null!=(o=r(e,t)))return new d(-1-n,o)}for(n=0;n<this.encoders.length;n++){var r,o;if(null!=(r=this.encoders[n]))if(null!=(o=r(e,t)))return new d(n,o)}return e instanceof d?e:null},e.prototype.decode=function(e,t,n){var r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new d(t,e)},e.defaultCodec=new e,e}();function g(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}function v(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}var b,w=function(){function e(e,t){void 0===e&&(e=16),void 0===t&&(t=16),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var n=0;n<this.maxKeyLength;n++)this.caches.push([])}return e.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var r=0,o=this.caches[n-1];r<o.length;r++){for(var i=o[r],s=i.bytes,a=0;a<n;a++)if(s[a]!==e[t+a])continue e;return i.str}return null},e.prototype.store=function(e,t){var n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)},e.prototype.decode=function(e,t,n){var r=this.find(e,t,n);if(null!=r)return this.hit++,r;this.miss++;var o=a(e,t,n),i=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(i,o),o},e}(),x=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},E=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},S=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},U=function(e){return this instanceof U?(this.v=e,this):new U(e)},k=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof U?Promise.resolve(n.value.v).then(c,u):h(i[0][2],n)}catch(e){h(i[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}},T=new DataView(new ArrayBuffer(0)),A=new Uint8Array(T.buffer),I=function(){try{T.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),_=new I("Insufficient data"),L=new w,M=function(){function e(e,t,n,o,i,s,a,c){void 0===e&&(e=m.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=r),void 0===o&&(o=r),void 0===i&&(i=r),void 0===s&&(s=r),void 0===a&&(a=r),void 0===c&&(c=L),this.extensionCodec=e,this.context=t,this.maxStrLength=n,this.maxBinLength=o,this.maxArrayLength=i,this.maxMapLength=s,this.maxExtLength=a,this.keyDecoder=c,this.totalPos=0,this.pos=0,this.view=T,this.bytes=A,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1,this.stack.length=0},e.prototype.setBuffer=function(e){this.bytes=g(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=g(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining(1)){var t=this.bytes.subarray(this.pos),n=g(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return E(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,r,o;return x(this,void 0,void 0,(function(){var i,s,a,c,u,h,d,l;return E(this,(function(f){switch(f.label){case 0:i=!1,f.label=1;case 1:f.trys.push([1,6,7,12]),t=S(e),f.label=2;case 2:return[4,t.next()];case 3:if((n=f.sent()).done)return[3,5];if(a=n.value,i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{s=this.doDecodeSync(),i=!0}catch(e){if(!(e instanceof I))throw e}this.totalPos+=this.pos,f.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return c=f.sent(),r={error:c},[3,12];case 7:return f.trys.push([7,,10,11]),n&&!n.done&&(o=t.return)?[4,o.call(t)]:[3,9];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,s]}throw h=(u=this).headByte,d=u.pos,l=u.totalPos,new RangeError("Insufficient data in parsing ".concat(v(h)," at ").concat(l," (").concat(d," in the current buffer)"))}}))}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return k(this,arguments,(function(){var n,r,o,i,s,a,c,u,h;return E(this,(function(d){switch(d.label){case 0:n=t,r=-1,d.label=1;case 1:d.trys.push([1,13,14,19]),o=S(e),d.label=2;case 2:return[4,U(o.next())];case 3:if((i=d.sent()).done)return[3,12];if(s=i.value,t&&0===r)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(r=this.readArraySize(),n=!1,this.complete()),d.label=4;case 4:d.trys.push([4,9,,10]),d.label=5;case 5:return[4,U(this.doDecodeSync())];case 6:return[4,d.sent()];case 7:return d.sent(),0==--r?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=d.sent())instanceof I))throw a;return[3,10];case 10:this.totalPos+=this.pos,d.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c=d.sent(),u={error:c},[3,19];case 14:return d.trys.push([14,,17,18]),i&&!i.done&&(h=o.return)?[4,U(h.call(o))]:[3,16];case 15:d.sent(),d.label=16;case 16:return[3,18];case 17:if(u)throw u.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!==(r=e-128)){this.pushMapState(r),this.complete();continue e}t={}}else if(e<160){if(0!==(r=e-144)){this.pushArrayState(r),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e){n=this.lookU8();t=this.decodeUtf8String(n,1)}else if(218===e){n=this.lookU16();t=this.decodeUtf8String(n,2)}else if(219===e){n=this.lookU32();t=this.decodeUtf8String(n,4)}else if(220===e){if(0!==(r=this.readU16())){this.pushArrayState(r),this.complete();continue e}t=[]}else if(221===e){if(0!==(r=this.readU32())){this.pushArrayState(r),this.complete();continue e}t=[]}else if(222===e){if(0!==(r=this.readU16())){this.pushMapState(r),this.complete();continue e}t={}}else if(223===e){if(0!==(r=this.readU32())){this.pushMapState(r),this.complete();continue e}t={}}else if(196===e){var r=this.lookU8();t=this.decodeBinary(r,1)}else if(197===e){r=this.lookU16();t=this.decodeBinary(r,2)}else if(198===e){r=this.lookU32();t=this.decodeBinary(r,4)}else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e){r=this.lookU8();t=this.decodeExtension(r,1)}else if(200===e){r=this.lookU16();t=this.decodeExtension(r,2)}else{if(201!==e)throw new f("Unrecognized type byte: ".concat(v(e)));r=this.lookU32();t=this.decodeExtension(r,4)}this.complete();for(var o=this.stack;o.length>0;){var i=o[o.length-1];if(0===i.type){if(i.array[i.position]=t,i.position++,i.position!==i.size)continue e;o.pop(),t=i.array}else{if(1===i.type){if(s=void 0,"string"!==(s=typeof t)&&"number"!==s)throw new f("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new f("The key __proto__ is not allowed");i.key=t,i.type=2;continue e}if(i.map[i.key]=t,i.readCount++,i.readCount!==i.size){i.key=null,i.type=1;continue e}o.pop(),t=i.map}}return t}var s},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new f("Unrecognized array type byte: ".concat(v(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new f("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new f("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new f("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+t+e)throw _;var r,o=this.pos+t;return r=this.stateIsMapKey()&&(null===(n=this.keyDecoder)||void 0===n?void 0:n.canBeCached(e))?this.keyDecoder.decode(this.bytes,o,e):e>u?function(e,t,n){var r=e.subarray(t,t+n);return c.decode(r)}(this.bytes,o,e):a(this.bytes,o,e),this.pos+=t+e,r},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new f("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw _;var n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new f("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=o(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),C={},D=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},N=function(e){return this instanceof N?(this.v=e,this):new N(e)},B=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof N?Promise.resolve(n.value.v).then(c,u):h(i[0][2],n)}catch(e){h(i[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}};function P(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function O(e){return null!=e[Symbol.asyncIterator]?e:function(e){return B(this,arguments,(function(){var t,n,r,o;return D(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,N(t.read())];case 3:return n=i.sent(),r=n.done,o=n.value,r?[4,N(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return P(o),[4,N(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}function $(e,t){void 0===t&&(t=C);var n=O(e);return new M(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(n)}async function j(e=1e3){return new Promise((t=>{setTimeout(t,e)}))}class R extends Error{}async function F(e){let t=0;for(;;)try{return await e()}catch(e){if(e instanceof R)throw e;if(t>=10)throw console.error("Reached the maximum number of attempts!"),e;const n=t+Math.random();console.error(`Got error (attempts: ${t}, wait: ${n.toFixed(2)})`,e);const r=Math.ceil(n),o=n/r;for(let e=0;e<r;e++)console.warn(`Retrying in ${(n-e*o).toFixed(2)} seconds`),await j(1e3*o);t++}}function H(e){return[`background: ${e}`,"border: 1px solid rgba(0, 0, 0, 0.5)","border-radius: 2px","padding: 0 2px","color: #000","font-weight: bold"].join(";")}!function(e){e.MAYU_SESSION="application/vnd.mayu.session",e.MAYU_STREAM="application/vnd.mayu.eventstream"}(b||(b={}));var z=function(e="mayu/"){return{info:console.info.bind(console,`%c${e}info`,H("#35baf6")),log:console.info.bind(console,`%c${e}log`,H("#ccc")),error:console.error.bind(console,`%c${e}error`,H("#f6685e")),warn:console.warn.bind(console,`%c${e}warn`,H("#ffc107")),success:console.info.bind(console,`%c${e}success`,H("#a2cf6e")),group:console.group.bind(console),groupEnd:console.groupEnd.bind(console)}}();const V=new Promise((async e=>{if("undefined"!=typeof DecompressionStream)return z.success("Using standard DecompressionStream"),e(DecompressionStream);z.warn("Using DecompressionStream polyfill"),e((await import("./DecompressionStreamPolyfill-3ceba43e.js")).default)}));var K=await V;async function q(e,t){const n=await function(e,t){if(!t)return F((()=>fetch(`/__mayu/session/${e}/init`,{method:"POST"})));return F((()=>fetch(`/__mayu/session/${e}/resume`,{method:"POST",headers:{"content-type":b.MAYU_SESSION},body:t})))}(e,t);if(!n.ok){const e=await n.text();if(503==n.status)throw new Error(`${n.status}: ${e}`);throw new R(`${n.status}: ${e}`)}if(!n.body)throw new R("body is null");const r=new K("deflate-raw");return n.body.pipeThrough(r)}function Y(e){return e instanceof Error?e.message:"string"==typeof e?e:String(e)}async function*X(e){let t,n=!0,r=!1;const o=function(){const e=new m;return e.register({type:1,encode(){throw new Error("Not implemented")},decode:e=>new Blob([e],{type:"application/vnd.mayu.session"})}),e}();let i;for(;n;)try{const s=await F((()=>q(e,t)));try{for await(const n of $(s,{extensionCodec:o})){const[o,s,a]=n;r||(r=!0,yield["system.connected",{}]),t&&(z.info("Clearing encryptedState"),t=void 0);try{switch(s){case"session.transfer":yield["session.transfer",{}],t=a,z.info("Setting encryptedState",a);break;case"pong":yield["ping",{values:{client:performance.now()-Number(a.pong),server:a.server},region:a.region,instance:a.instance}];break;case"ping":G(e,"ping",{pong:a,ping:performance.now()});break;default:yield[s,a]}}catch(e){i=Y(e),z.error(e)}}}catch(e){i=Y(e),z.error(e)}r=!1,n&&(i||="Stream ended unexpectedly"),yield["system.disconnected",{transferring:!!t,reason:i}]}catch(e){if(z.error(e),e instanceof R)return n=!1,r=!1,void(yield["system.disconnected",{reason:e.message}]);await j(1e3)}}async function G(e,t,n){return fetch(`/__mayu/session/${e}/${t}`,{method:"POST",headers:{"content-type":"application/json"},body:(r=n,JSON.stringify(r,((e,t)=>"bigint"==typeof t?Number(t):t instanceof Blob?`Blob{type: ${t.type}, size: ${t.size}}`:t),o))});var r,o}const J=function(){const e=(...e)=>{};return{info:e,log:e,warn:e,error:e,success:e,group:e,groupEnd:e}}();function Q(e,t){if("SCRIPT"!==t.tagName)for(const e of t.childNodes)Q(t,e);else e.replaceChild(function(e){const t=document.createElement("script");t.text=e.innerHTML;for(const n of e.attributes)t.setAttribute(n.name,n.value);return t}(t),t)}function W(e){if(e instanceof HTMLInputElement&&e.autofocus)e.focus();else for(const t of e.childNodes)W(t)}class Z{#e=new Map;constructor(e,t=document.documentElement){this.updateCache(t,e)}apply(e){for(const t of e)this.applyPatch(t)}applyPatch(e){switch(e.type){case"insert":return void this.insert(e);case"move":this.move(e);break;case"remove":this.remove(e.id);break;case"css":{const t=this.#t(e.id).node;e.value?t.style.setProperty(e.attr,e.value):t.style.removeProperty(e.attr)}case"text":"text"in e&&this.updateText(e.id,e.text),"append"in e&&this.appendText(e.id,e.append);break;case"attr":void 0!==e.value?this.setAttribute(e.id,e.name,e.value):this.removeAttribute(e.id,e.name);break;case"stylesheet":for(const t of e.paths){if(document.querySelector(`link[href="${t}"]`))continue;const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.head.insertAdjacentElement("beforeend",e)}break;default:console.error("Unknown patch",e)}}updateText(e,t){const n=this.#t(e).node;if(n.nodeType!==n.TEXT_NODE)throw new Error("Trying to update text on a non text node");n.textContent=t}appendText(e,t){const n=this.#t(e).node;if(n.nodeType!==n.TEXT_NODE)throw new Error("Trying to update text on a non text node");n.textContent+=t}setAttribute(e,t,n){const r=this.#t(e).node;"open"===t&&r instanceof HTMLDialogElement?r.showModal():r instanceof HTMLInputElement&&("value"===t&&(r.value=n),"checked"===t&&(r.checked=!0),"indeterminate"===t)?r.indeterminate=!0:(t="initial_value"===t?"value":t.replaceAll(/_/g,""),r.setAttribute(t,n))}removeAttribute(e,t){const n=this.#t(e).node;"open"===t&&n instanceof HTMLDialogElement&&(n.open=!1,n.close()),n instanceof HTMLInputElement&&("value"===t&&(n.value=""),"checked"===t&&(n.checked=!1),"indeterminate"===t)?n.indeterminate=!1:n.removeAttribute(t)}insert({parent:e,before:t,after:n,ids:r,html:o}){J.group("Trying to insert html into",e);const i=this.#t(e),s=t||n,a=s&&this.#e.get(s),c=document.createRange().createContextualFragment(`<template>${o}</template>`).firstElementChild.content,u=Array.from(c.childNodes).reverse();[r].flat().forEach(((e,t)=>{i.childIds.add(e.id);const r=this.#e.get(e.id),o=r?.node||u[t],s=a?n?a.node.nextSibling:a.node:null,c=i.node.insertBefore(o,s);r&&(r.node.outerHTML=o.outerHTML),requestIdleCallback((()=>{W(c)})),requestIdleCallback((()=>{Q(i.node,c)})),this.updateCache(c,e)})),J.groupEnd()}#t(e){const t=this.#e.get(e);if(!t)throw J.error("Could not find",e,"in cache!"),J.error(Array.from(this.#e.keys())),new Error(`Could not find ${e} in cache!`);return t}remove(e){J.info("Trying to remove",e);try{const t=this.#t(e),n=t.node.parentNode;if(n){const r=n.__MAYU_ID,o=this.#e.get(r);J.log("Removing child",t.node.textContent),n.removeChild(t.node),o&&o.childIds.delete(e)}else J.warn("Node",t.node.__MAYU_ID,"has no parent??");this.#n(e,!1)}catch(e){J.warn(e)}}move({id:e,parent:t,before:n,after:r}){const o=this.#t(e),i=this.#t(t),s=n||r,a=s&&this.#e.get(s),c=a?a.node:null;J.log("Moving",o.node.textContent,n?"before":r?"after":"last",c?.textContent||i.node.__MAYU_ID),J.log({before:n,after:r}),J.log(c?.textContent),i.node.insertBefore(o.node,c)}#n(e,t=!1){const n=this.#e.get(e);if(n){if(J.group("Removing from cache",e),t){this.#e.get(n.node.parentNode.__MAYU_ID)?.childIds?.delete(e)}this.#e.delete(e),n.childIds.forEach((e=>{this.#n(e,!1)})),n.childIds.delete(e),J.groupEnd()}}isIgnoredNode(e){if(e.nodeType===e.TEXT_NODE)return!1;if(e.nodeType===e.COMMENT_NODE)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof e.dataset.mayuId)return!1}return!0}updateCache(e,t){if(!e)throw J.error(t),new Error("No node found for idTreeNode");const n=new Set((t.ch||[]).map((e=>e.id)));this.#n(t.id),this.#e.set(t.id,{node:e,childIds:n}),e.__MAYU_ID=t.id,J.group("Add to cache",t.id,"type",e.nodeName,t.type);let r=0;const o=t.ch||[];e.childNodes.forEach((e=>{if(this.isIgnoredNode(e))return void J.warn("Ignored:",e);const n=o[r++];n?this.updateCache(e,n):J.error("No childIdNode at index",r,"on node",null,"with parent id",t.id,"and child node",null)})),o.length,J.groupEnd()}}function ee(e,t=[],n={}){const r=document.createElement(e);for(const[e,t]of Object.entries(n))t&&(!0===t?r.setAttribute(e,e):r.setAttribute(e,t));return t.forEach((e=>{e instanceof Node?r.appendChild(e):e&&r.appendChild(document.createTextNode(String(e)))})),r}function te(e){if(e instanceof HTMLFormElement){const t=Object.fromEntries(new FormData(e).entries());return{tagName:e.tagName,id:e.id,method:e.method,target:e.target,name:e.name,formData:t}}return e instanceof HTMLSelectElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value}:e instanceof HTMLDetailsElement?{tagName:e.tagName,id:e.id,open:e.open}:e instanceof HTMLInputElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value,checked:e.checked}:e instanceof HTMLButtonElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value}:e instanceof HTMLElement?{tagName:e.tagName,id:e.id}:{}}const ne=new Promise((e=>{if("loading"!==document.readyState)return e();window.addEventListener("DOMContentLoaded",(()=>e()))}));async function re({type:e,message:t,backtrace:n}){await import("./custom-elements/mayu-exception-63df4e8c.js");const r=n.filter((e=>!/\/vendor\/bundle\//.test(e))).join("\n"),o=ee("mayu-exception",[ee("span",[`${e}: ${t}`],{slot:"title"}),ee("span",[r],{slot:"backtrace"})]);document.body.appendChild(o)}class oe{#r;constructor(e){this.#r=e,ne.then((()=>{window.addEventListener("popstate",(()=>ie(this.#r,location.pathname)))}))}async handle(e,t){(function(e){return!("undefined"!=typeof TouchEvent&&e instanceof TouchEvent)})(e)&&e.preventDefault();const n=function(e){const t={};return t.type=e.constructor.name,e.currentTarget&&(t.currentTarget=te(e.currentTarget)),e.target&&(t.target=te(e.target)),e instanceof MouseEvent&&(t.buttons=e.buttons),e instanceof SubmitEvent&&e.submitter instanceof HTMLElement&&(t.submitter=te(e.submitter)),t}(e);console.log(n),await function(e,t,n){return fetch(`/__mayu/session/${e}/callback/${t}`,{method:"POST",headers:{"content-type":"application/json","x-request-time":performance.now()},body:JSON.stringify(n)}).then(se)}(this.#r,t,n);const r=setTimeout((()=>{}),1);clearTimeout(r)}async navigate(e){if(e.metaKey||e.ctrlKey)return;e.preventDefault();const t=e.target.closest("a");if(!t)return void z.error("Could not find anchor element for",e.target);const n=new URL(t.href);return ie(this.#r,n.pathname+n.search)}}async function ie(e,t){return fetch(`/__mayu/session/${e}/navigate`,{method:"POST",headers:{"content-type":"text/plain; charset=utf-8","x-request-time":performance.now()},body:t}).then(se)}function se(e){const t=e.headers.get("x-request-time");return t&&console.log("Pong:",performance.now()-Number(t),"ms"),e}var ae=async function(e){const t=function(e){const t=e.lastIndexOf("#");if(-1===t)throw new Error(`No # found in script url: ${e}`);return e.slice(t+1)}(e),n=new oe(t);let r;window.Mayu=n;const o=document.createElement("mayu-disconnected"),i=document.createElement("mayu-ping");i.setAttribute("region","Connecting..."),i.setAttribute("status","connecting"),document.body.appendChild(i);for await(const[e,n]of X(t))switch(e){case"system.connected":import("./custom-elements/mayu-ping-c498c2a6.js"),import("./custom-elements/mayu-disconnected-9f349f46.js"),import("./custom-elements/mayu-progress-bar-eb3e1ac8.js"),import("./custom-elements/mayu-exception-63df4e8c.js"),import("./custom-elements/mayu-alert-cd7ad2a4.js"),i.setAttribute("region","Connected!"),i.setAttribute("status","connected"),z.success("Connected!"),document.body.querySelectorAll("mayu-disconnected").forEach((e=>e.remove()));break;case"system.disconnected":if(n.transferring){i.setAttribute("region","Transferring…"),i.setAttribute("status","transferring");break}i.setAttribute("region","Disconnected"),i.setAttribute("status","disconnected"),z.error("Disconnected"),o.setAttribute("reason",n.reason),o.parentElement!==document.body&&document.body.appendChild(o);break;case"session.init":await ne,r=new Z(n.ids);break;case"session.patch":r?.apply(n);break;case"session.navigate":const t=n.path;t!==location.pathname&&(z.info("Navigating to",t),history.pushState({},"",t));break;case"session.action":s(n.type,n.payload);break;case"session.keep_alive":break;case"session.transfer":i.setAttribute("region","Transferring"),i.setAttribute("status","transferring");break;case"session.exception":re(n);break;case"ping":const a=Object.values(n.values),c=a.reduce(((e,t)=>e+t),0)/a.length;i.setAttribute("ping",`${c.toFixed(2)} ms`),i.setAttribute("region",`${n.instance} @ ${n.region}`),i.setAttribute("status","ping");break;default:z.warn("Unhandled event:",e,n)}function s(e,t){switch(e){case"scroll_into_view":!function(e,t){const n=document.querySelector(e);n?n.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth",...t}):console.error("Could not find element to scrollIntoView, selector:",e)}(t.selector,t.options||{});break;case"alert":!async function(e){await import("./custom-elements/mayu-alert-cd7ad2a4.js");const t=document.createElement("mayu-alert");t.setAttribute("message",e),document.body.appendChild(t)}(t);break;default:z.error("Unhandled action:",e,t)}}}(import.meta.url);export{ae as default};//# sourceMappingURL=main-8506b35d.js.map
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"main-8506b35d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
Binary file
|