From 02a553e3fd4df923a66c2abea0e13ec0b3823aea Mon Sep 17 00:00:00 2001 From: sophie Date: Thu, 28 Nov 2024 02:01:25 +0200 Subject: [PATCH] add web version --- package.json | 3 ++- pb.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 pb.js diff --git a/package.json b/package.json index 55d0f13..c452060 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "bugs": "https://git.sad.ovh/sophie/pianoverse/issues", "author": "Sophie", "scripts": { - "build-proto": "protoc -I . --plugin ./node_modules/.bin/protoc-gen-es --es_out . --es_opt target=ts pianoverse.proto" + "build-proto": "protoc -I . --plugin ./node_modules/.bin/protoc-gen-es --es_out . --es_opt target=ts pianoverse.proto", + "build-web": "esbuild pianoverse_pb.ts --bundle --outfile=pb.js --format=iife --global-name=pianoverse --minify" }, "devDependencies": { "@types/bun": "latest" diff --git a/pb.js b/pb.js new file mode 100644 index 0000000..7f63c35 --- /dev/null +++ b/pb.js @@ -0,0 +1,2 @@ +"use strict";var pianoverse=(()=>{var de=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ft=Object.prototype.hasOwnProperty;var lt=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},mt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ct(e))!ft.call(t,r)&&r!==n&&de(t,r,{get:()=>e[r],enumerable:!(s=ut(e,r))||s.enumerable});return t};var dt=t=>mt(de({},"__esModule",{value:!0}),t);var Lt={};lt(Lt,{ClientMessage:()=>Oe,ClientMessage_Ban:()=>ae,ClientMessage_EventType:()=>le,ClientMessage_Heartbeat:()=>L,ClientMessage_Room:()=>oe,Move:()=>D,Press:()=>$,Profile:()=>F,Release:()=>C,Role:()=>q,ServerMessage:()=>Fe,ServerMessage_Chat:()=>V,ServerMessage_EventType:()=>me,ServerMessage_Room:()=>ue,ServerMessage_Sustain:()=>fe,ServerMessage_Welcome:()=>ce});function g(t,e){if(!t)throw new Error(e)}var pt=34028234663852886e22,ht=-34028234663852886e22,gt=4294967295,bt=2147483647,yt=-2147483648;function E(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>bt||tgt||t<0)throw new Error("invalid uint 32: "+t)}function G(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>pt||t({no:r.no,name:r.name,localName:t[r.no]})),s)}function he(t,e,n){let s=Object.create(null),r=Object.create(null),i=[];for(let o of e){let a=Me(o);i.push(a),s[o.name]=a,r[o.no]=a}return{typeName:t,values:i,findName(o){return s[o]},findNumber(o){return r[o]}}}function Be(t,e,n){let s={};for(let r of e){let i=Me(r);s[i.localName]=i.no,s[i.no]=i.localName}return pe(s,t,e,n),s}function Me(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}var k=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){let s=this.getType(),r=s.runtime.bin,i=r.makeReadOptions(n);return r.readMessage(this,i.readerFactory(e),e.byteLength,i),this}fromJson(e,n){let s=this.getType(),r=s.runtime.json,i=r.makeReadOptions(n);return r.readMessage(s,e,i,this),this}fromJsonString(e,n){let s;try{s=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(s,n)}toBinary(e){let n=this.getType(),s=n.runtime.bin,r=s.makeWriteOptions(e),i=r.writerFactory();return s.writeMessage(this,i,r),i.finish()}toJson(e){let n=this.getType(),s=n.runtime.json,r=s.makeWriteOptions(e);return s.writeMessage(this,r)}toJsonString(e){var n;let s=this.toJson(e);return JSON.stringify(s,null,(n=e?.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function Je(t,e,n,s){var r;let i=(r=s?.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),o={[i]:function(a){t.util.initFields(this),t.util.initPartial(a,this)}}[i];return Object.setPrototypeOf(o.prototype,new k),Object.assign(o,{runtime:t,typeName:e,fields:t.util.newFieldList(n),fromBinary(a,c){return new o().fromBinary(a,c)},fromJson(a,c){return new o().fromJson(a,c)},fromJsonString(a,c){return new o().fromJsonString(a,c)},equals(a,c){return t.util.equals(o,a,c)}}),o}function Ue(){let t=0,e=0;for(let s=0;s<28;s+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>4,!(n&128))return this.assertBounds(),[t,e];for(let s=3;s<=31;s+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>>i,a=!(!(o>>>7)&&e==0),c=(a?o|128:o)&255;if(n.push(c),!a)return}let s=t>>>28&15|(e&7)<<4,r=!!(e>>3);if(n.push((r?s|128:s)&255),!!r){for(let i=3;i<31;i=i+7){let o=e>>>i,a=!!(o>>>7),c=(a?o|128:o)&255;if(n.push(c),!a)return}n.push(e>>>31&1)}}var X=4294967296;function ge(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,s=0,r=0;function i(o,a){let c=Number(t.slice(o,a));r*=n,s=s*n+c,s>=X&&(r=r+(s/X|0),s=s%X)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?Le(s,r):ye(s,r)}function Ae(t,e){let n=ye(t,e),s=n.hi&2147483648;s&&(n=Le(n.lo,n.hi));let r=be(n.lo,n.hi);return s?"-"+r:r}function be(t,e){if({lo:t,hi:e}=kt(t,e),e<=2097151)return String(X*e+t);let n=t&16777215,s=(t>>>24|e<<8)&16777215,r=e>>16&65535,i=n+s*6777216+r*6710656,o=s+r*8147497,a=r*2,c=1e7;return i>=c&&(o+=Math.floor(i/c),i%=c),o>=c&&(a+=Math.floor(o/c),o%=c),a.toString()+Re(o)+Re(i)}function kt(t,e){return{lo:t>>>0,hi:e>>>0}}function ye(t,e){return{lo:t|0,hi:e|0}}function Le(t,e){return e=~e,t?t=~t+1:e+=1,ye(t,e)}var Re=t=>{let e=String(t);return"0000000".slice(e.length)+e};function ke(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function Ve(){let t=this.buf[this.pos++],e=t&127;if(!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,!(t&128))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,!(t&128))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;t&128&&n<10;n++)t=this.buf[this.pos++];if(t&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function wt(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){let l=typeof c=="bigint"?c:BigInt(c);if(l>i||la||lg(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),s=r=>g(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),s(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),n(r),ge(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),s(r),ge(r)},dec(r,i){return Ae(r,i)},uDec(r,i){return be(r,i)}}}var w=wt();var u;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(u||(u={}));var N;(function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"})(N||(N={}));function x(t,e,n){if(e===n)return!0;if(t==u.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let s=0;s>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(J(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return E(e),ke(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){G(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){J(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){E(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return E(e),e=(e<<1^e>>31)>>>0,ke(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=w.enc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),s=new DataView(n.buffer),r=w.uEnc(e);return s.setInt32(0,r.lo,!0),s.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=w.enc(e);return W(n.lo,n.hi,this.buf),this}sint64(e){let n=w.enc(e),s=n.hi>>31,r=n.lo<<1^s,i=(n.hi<<1|n.lo>>>31)^s;return W(r,i,this.buf),this}uint64(e){let n=w.uEnc(e);return W(n.lo,n.hi,this.buf),this}},Y=class{constructor(e,n){this.varint64=Ue,this.uint32=Ve,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,s=e&7;if(n<=0||s<0||s>5)throw new Error("illegal tag: field no "+n+" wire type "+s);return[n,s]}skip(e,n){let s=this.pos;switch(e){case y.Varint:for(;this.buf[this.pos++]&128;);break;case y.Bit64:this.pos+=4;case y.Bit32:this.pos+=4;break;case y.LengthDelimited:let r=this.uint32();this.pos+=r;break;case y.StartGroup:for(;;){let[i,o]=this.tag();if(o===y.EndGroup){if(n!==void 0&&i!==n)throw new Error("invalid end group tag");break}this.skip(o,i)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(s,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return w.dec(...this.varint64())}uint64(){return w.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),s=-(e&1);return e=(e>>>1|(n&1)<<31)^s,n=n>>>1^s,w.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return w.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return w.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}};function De(t,e,n,s){let r;return{typeName:e,extendee:n,get field(){if(!r){let i=typeof s=="function"?s():s;i.name=e.split(".").pop(),i.jsonName=`[${e}]`,r=t.util.newFieldList([i]).list()[0]}return r},runtime:t}}function j(t){let e=t.field.localName,n=Object.create(null);return n[e]=Nt(t),[n,()=>n[e]]}function Nt(t){let e=t.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return T(e.T,e.L);case"message":let n=e.T,s=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(s):s;case"map":throw"map fields are not allowed to be extensions"}}function $e(t,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=t.length-1;n>=0;--n)if(t[n].no==e.no)return[t[n]];return[]}return t.filter(n=>n.no===e.no)}var O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),K=[];for(let t=0;t>4,o=i,r=2;break;case 2:n[s++]=(o&15)<<4|(i&60)>>2,o=i,r=3;break;case 3:n[s++]=(o&3)<<6|i,r=0;break}}if(r==1)throw Error("invalid base64 string.");return n.subarray(0,s)},enc(t){let e="",n=0,s,r=0;for(let i=0;i>2],r=(s&3)<<4,n=1;break;case 1:e+=O[r|s>>4],r=(s&15)<<2,n=2;break;case 2:e+=O[r|s>>6],e+=O[s&63],n=0;break}return n&&(e+=O[r],e+="=",n==1&&(e+="=")),e}};function Ce(t,e,n){Ge(e,t);let s=e.runtime.bin.makeReadOptions(n),r=$e(t.getType().runtime.bin.listUnknownFields(t),e.field),[i,o]=j(e);for(let a of r)e.runtime.bin.readField(i,s.readerFactory(a.data),e.field,a.wireType,s);return o()}function qe(t,e,n,s){Ge(e,t);let r=e.runtime.bin.makeReadOptions(s),i=e.runtime.bin.makeWriteOptions(s);if(Ne(t,e)){let l=t.getType().runtime.bin.listUnknownFields(t).filter(f=>f.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(let f of l)t.getType().runtime.bin.onUnknownField(t,f.no,f.wireType,f.data)}let o=i.writerFactory(),a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,n,o,i);let c=r.readerFactory(o.finish());for(;c.poss.no==e.field.no)}function Ge(t,e){g(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function Z(t,e){let n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!v(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function Te(t,e){let n=t.localName,s=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=s?t.T.values[0].no:void 0;break;case"scalar":e[n]=s?T(t.T,t.L):void 0;break;case"message":e[n]=void 0;break}}function I(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(k.prototype).every(s=>s in t&&typeof t[s]=="function"))return!1;let n=t.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:e===void 0?!0:n.typeName==e.typeName}function z(t,e){return I(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}var gn={"google.protobuf.DoubleValue":u.DOUBLE,"google.protobuf.FloatValue":u.FLOAT,"google.protobuf.Int64Value":u.INT64,"google.protobuf.UInt64Value":u.UINT64,"google.protobuf.Int32Value":u.INT32,"google.protobuf.UInt32Value":u.UINT32,"google.protobuf.BoolValue":u.BOOL,"google.protobuf.StringValue":u.STRING,"google.protobuf.BytesValue":u.BYTES};var Xe={ignoreUnknownFields:!1},We={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Tt(t){return t?Object.assign(Object.assign({},Xe),t):Xe}function It(t){return t?Object.assign(Object.assign({},We),t):We}var ee=Symbol(),Q=Symbol();function Ye(){return{makeReadOptions:Tt,makeWriteOptions:It,readMessage(t,e,n,s){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${S(e)}`);s=s??new t;let r=new Map,i=n.typeRegistry;for(let[o,a]of Object.entries(e)){let c=t.fields.findJsonName(o);if(c){if(c.oneof){if(a===null&&c.kind=="scalar")continue;let l=r.get(c.oneof);if(l!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${c.oneof.name}" present: "${l}", "${o}"`);r.set(c.oneof,o)}ve(s,a,c,n,t)}else{let l=!1;if(i?.findExtension&&o.startsWith("[")&&o.endsWith("]")){let f=i.findExtension(o.substring(1,o.length-1));if(f&&f.extendee.typeName==t.typeName){l=!0;let[p,b]=j(f);ve(p,a,f.field,n,f),qe(s,f,b(),n)}}if(!l&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${o}" is unknown`)}}return s},writeMessage(t,e){let n=t.getType(),s={},r;try{for(r of n.fields.byNumber()){if(!Z(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!xt(r))continue}let o=r.oneof?t[r.oneof.localName].value:t[r.localName],a=He(r,o,e);a!==void 0&&(s[e.useProtoFieldName?r.name:r.jsonName]=a)}let i=e.typeRegistry;if(i?.findExtensionFor)for(let o of n.runtime.bin.listUnknownFields(t)){let a=i.findExtensionFor(n.typeName,o.no);if(a&&Ne(t,a)){let c=Ce(t,a,e),l=He(a.field,c,e);l!==void 0&&(s[a.field.jsonName]=l)}}}catch(i){let o=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,a=i instanceof Error?i.message:String(i);throw new Error(o+(a.length>0?`: ${a}`:""))}return s},readScalar(t,e,n){return R(t,e,n??N.BIGINT,!0)},writeScalar(t,e,n){if(e!==void 0&&(n||v(t,e)))return _(t,e)},debug:S}}function S(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function ve(t,e,n,s,r){let i=n.localName;if(n.repeated){if(g(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${S(e)}`);let o=t[i];for(let a of e){if(a===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${S(a)}`);switch(n.kind){case"message":o.push(n.T.fromJson(a,s));break;case"enum":let c=Ie(n.T,a,s.ignoreUnknownFields,!0);c!==Q&&o.push(c);break;case"scalar":try{o.push(R(n.T,a,n.L,!0))}catch(l){let f=`cannot decode field ${r.typeName}.${n.name} from JSON: ${S(a)}`;throw l instanceof Error&&l.message.length>0&&(f+=`: ${l.message}`),new Error(f)}break}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${S(e)}`);let o=t[i];for(let[a,c]of Object.entries(e)){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;try{l=St(n.K,a)}catch(f){let p=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${S(e)}`;throw f instanceof Error&&f.message.length>0&&(p+=`: ${f.message}`),new Error(p)}switch(n.V.kind){case"message":o[l]=n.V.T.fromJson(c,s);break;case"enum":let f=Ie(n.V.T,c,s.ignoreUnknownFields,!0);f!==Q&&(o[l]=f);break;case"scalar":try{o[l]=R(n.V.T,c,N.BIGINT,!0)}catch(p){let b=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${S(e)}`;throw p instanceof Error&&p.message.length>0&&(b+=`: ${p.message}`),new Error(b)}break}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:i},i="value"),n.kind){case"message":let o=n.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=t[i];I(a)?a.fromJson(e,s):(t[i]=a=o.fromJson(e,s),o.fieldWrapper&&!n.oneof&&(t[i]=o.fieldWrapper.unwrapField(a)));break;case"enum":let c=Ie(n.T,e,s.ignoreUnknownFields,!1);switch(c){case ee:Te(n,t);break;case Q:break;default:t[i]=c;break}break;case"scalar":try{let l=R(n.T,e,n.L,!1);switch(l){case ee:Te(n,t);break;default:t[i]=l;break}}catch(l){let f=`cannot decode field ${r.typeName}.${n.name} from JSON: ${S(e)}`;throw l instanceof Error&&l.message.length>0&&(f+=`: ${l.message}`),new Error(f)}break}}function St(t,e){if(t===u.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return R(t,e,N.BIGINT,!0).toString()}function R(t,e,n,s){if(e===null)return s?T(t,n):ee;switch(t){case u.DOUBLE:case u.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;let r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==u.FLOAT&&G(r),r;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:let i;if(typeof e=="number"?i=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(i=Number(e)),i===void 0)break;return t==u.UINT32||t==u.FIXED32?J(i):E(i),i;case u.INT64:case u.SFIXED64:case u.SINT64:if(typeof e!="number"&&typeof e!="string")break;let o=w.parse(e);return n?o.toString():o;case u.FIXED64:case u.UINT64:if(typeof e!="number"&&typeof e!="string")break;let a=w.uParse(e);return n?a.toString():a;case u.BOOL:if(typeof e!="boolean")break;return e;case u.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case u.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return we.dec(e)}throw new Error}function Ie(t,e,n,s){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:s?t.values[0].no:ee;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":let r=t.findName(e);if(r!==void 0)return r.no;if(n)return Q;break}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${S(e)}`)}function xt(t){return t.repeated||t.kind=="map"?!0:!(t.oneof||t.kind=="message"||t.opt||t.req)}function He(t,e,n){if(t.kind=="map"){g(typeof e=="object"&&e!=null);let s={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(let[o,a]of r)s[o.toString()]=_(t.V.T,a);break;case"message":for(let[o,a]of r)s[o.toString()]=a.toJson(n);break;case"enum":let i=t.V.T;for(let[o,a]of r)s[o.toString()]=Se(i,a,n.enumAsInteger);break}return n.emitDefaultValues||r.length>0?s:void 0}if(t.repeated){g(Array.isArray(e));let s=[];switch(t.kind){case"scalar":for(let r=0;r0?s:void 0}switch(t.kind){case"scalar":return _(t.T,e);case"enum":return Se(t.T,e,n.enumAsInteger);case"message":return z(t.T,e).toJson(n)}}function Se(t,e,n){var s;if(g(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;let r=t.findNumber(e);return(s=r?.name)!==null&&s!==void 0?s:e}function _(t,e){switch(t){case u.INT32:case u.SFIXED32:case u.SINT32:case u.FIXED32:case u.UINT32:return g(typeof e=="number"),e;case u.FLOAT:case u.DOUBLE:return g(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case u.STRING:return g(typeof e=="string"),e;case u.BOOL:return g(typeof e=="boolean"),e;case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:return g(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case u.BYTES:return g(e instanceof Uint8Array),we.enc(e)}}var B=Symbol("@bufbuild/protobuf/unknown-fields"),je={readUnknownFields:!0,readerFactory:t=>new Y(t)},Ke={writeUnknownFields:!0,writerFactory:()=>new H};function Ot(t){return t?Object.assign(Object.assign({},je),t):je}function Ft(t){return t?Object.assign(Object.assign({},Ke),t):Ke}function _e(){return{makeReadOptions:Ot,makeWriteOptions:Ft,listUnknownFields(t){var e;return(e=t[B])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[B]},writeUnknownFields(t,e){let s=t[B];if(s)for(let r of s)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(t,e,n,s){let r=t;Array.isArray(r[B])||(r[B]=[]),r[B].push({no:e,wireType:n,data:s})},readMessage(t,e,n,s,r){let i=t.getType(),o=r?e.len:e.pos+n,a,c;for(;e.pos0&&(c=Et),i){let b=t[o];if(s==y.LengthDelimited&&a!=u.STRING&&a!=u.BYTES){let P=e.uint32()+e.pos;for(;e.posI(b,p)?b:new p(b));else{let b=o[r];p.fieldWrapper?p.typeName==="google.protobuf.BytesValue"?i[r]=A(b):i[r]=b:i[r]=I(b,p)?b:new p(b)}break}}},equals(t,e,n){return e===n?!0:!e||!n?!1:t.fields.byMember().every(s=>{let r=e[s.localName],i=n[s.localName];if(s.repeated){if(r.length!==i.length)return!1;switch(s.kind){case"message":return r.every((o,a)=>s.T.equals(o,i[a]));case"scalar":return r.every((o,a)=>x(s.T,o,i[a]));case"enum":return r.every((o,a)=>x(u.INT32,o,i[a]))}throw new Error(`repeated cannot contain ${s.kind}`)}switch(s.kind){case"message":return s.T.equals(r,i);case"enum":return x(u.INT32,r,i);case"scalar":return x(s.T,r,i);case"oneof":if(r.case!==i.case)return!1;let o=s.findField(r.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(r.value,i.value);case"enum":return x(u.INT32,r.value,i.value);case"scalar":return x(o.T,r.value,i.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":let a=Object.keys(r).concat(Object.keys(i));switch(s.V.kind){case"message":let c=s.V.T;return a.every(f=>c.equals(r[f],i[f]));case"enum":return a.every(f=>x(u.INT32,r[f],i[f]));case"scalar":let l=s.V.T;return a.every(f=>x(l,r[f],i[f]))}break}})},clone(t){let e=t.getType(),n=new e,s=n;for(let r of e.fields.byMember()){let i=t[r.localName],o;if(r.repeated)o=i.map(re);else if(r.kind=="map"){o=s[r.localName];for(let[a,c]of Object.entries(i))o[a]=re(c)}else r.kind=="oneof"?o=r.findField(i.case)?{case:i.case,value:re(i.value)}:{case:void 0}:o=re(i);s[r.localName]=o}for(let r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(s,r.no,r.wireType,r.data);return n}}}function re(t){if(t===void 0)return t;if(I(t))return t.clone();if(t instanceof Uint8Array){let e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function A(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function nt(t,e,n){return{syntax:t,json:Ye(),bin:_e(),util:Object.assign(Object.assign({},tt()),{newFieldList:e,initFields:n}),makeMessageType(s,r,i){return Je(this,s,r,i)},makeEnum:Be,makeEnumType:he,getEnumType:Ee,makeExtension(s,r,i){return De(this,s,r,i)}}}var se=class{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){let n={};for(let s of this.list())n[s.jsonName]=n[s.name]=s;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){let n={};for(let s of this.list())n[s.no]=s;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,n;for(let s of this.list())s.oneof?s.oneof!==n&&(n=s.oneof,e.push(n)):e.push(s)}return this.members}};function xe(t,e){let n=it(t);return e?n:At(Ut(n))}function rt(t){return xe(t,!1)}var st=it;function it(t){let e=!1,n=[];for(let s=0;s`${t}$`,Ut=t=>Rt.has(t)?ot(t):t,At=t=>Jt.has(t)?ot(t):t;var ie=class{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=rt(e)}addField(e){g(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;nnew se(t,e=>at(e,!0)),t=>{for(let e of t.getType().fields.byMember()){if(e.opt)continue;let n=e.localName,s=t;if(e.repeated){s[n]=[];continue}switch(e.kind){case"oneof":s[n]={case:void 0};break;case"enum":s[n]=0;break;case"map":s[n]={};break;case"scalar":s[n]=T(e.T,e.L);break;case"message":break}}});var q=(s=>(s[s.USER=0]="USER",s[s.MODERATOR=1]="MODERATOR",s[s.DEVELOPER=2]="DEVELOPER",s))(q||{});m.util.setEnumType(q,"pianoverse.Role",[{no:0,name:"USER"},{no:1,name:"MODERATOR"},{no:2,name:"DEVELOPER"}]);var Oe=class t extends k{chown="";event=0;ping;room;profile;chat="";move;mute="";unmute="";kick="";press;release;sustain=!1;heartbeat;ban;ipban="";mod="";unmod="";constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ClientMessage";static fields=m.util.newFieldList(()=>[{no:1,name:"chown",kind:"scalar",T:9},{no:2,name:"event",kind:"enum",T:m.getEnumType(le)},{no:3,name:"ping",kind:"message",T:L},{no:4,name:"room",kind:"message",T:oe},{no:5,name:"profile",kind:"message",T:F},{no:6,name:"chat",kind:"scalar",T:9},{no:7,name:"move",kind:"message",T:D},{no:8,name:"mute",kind:"scalar",T:9},{no:9,name:"unmute",kind:"scalar",T:9},{no:10,name:"kick",kind:"scalar",T:9},{no:11,name:"press",kind:"message",T:$},{no:12,name:"release",kind:"message",T:C},{no:13,name:"sustain",kind:"scalar",T:8},{no:14,name:"heartbeat",kind:"message",T:L},{no:15,name:"ban",kind:"message",T:ae},{no:16,name:"ipban",kind:"scalar",T:9},{no:17,name:"mod",kind:"scalar",T:9},{no:18,name:"unmod",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},le=(d=>(d[d.CHOWN=0]="CHOWN",d[d.PING=1]="PING",d[d.ROOM=2]="ROOM",d[d.PROFILE=3]="PROFILE",d[d.CHAT=4]="CHAT",d[d.MOVE=5]="MOVE",d[d.MUTE=6]="MUTE",d[d.UNMUTE=7]="UNMUTE",d[d.KICK=8]="KICK",d[d.PRESS=9]="PRESS",d[d.RELEASE=10]="RELEASE",d[d.SUSTAIN=11]="SUSTAIN",d[d.HEARTBEAT=12]="HEARTBEAT",d[d.BAN=13]="BAN",d[d.IPBAN=14]="IPBAN",d[d.MOD=15]="MOD",d[d.UNMOD=16]="UNMOD",d))(le||{});m.util.setEnumType(le,"pianoverse.ClientMessage.EventType",[{no:0,name:"CHOWN"},{no:1,name:"PING"},{no:2,name:"ROOM"},{no:3,name:"PROFILE"},{no:4,name:"CHAT"},{no:5,name:"MOVE"},{no:6,name:"MUTE"},{no:7,name:"UNMUTE"},{no:8,name:"KICK"},{no:9,name:"PRESS"},{no:10,name:"RELEASE"},{no:11,name:"SUSTAIN"},{no:12,name:"HEARTBEAT"},{no:13,name:"BAN"},{no:14,name:"IPBAN"},{no:15,name:"MOD"},{no:16,name:"UNMOD"}]);var oe=class t extends k{room="";private=!1;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ClientMessage.Room";static fields=m.util.newFieldList(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"private",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},L=class t extends k{constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ClientMessage.Heartbeat";static fields=m.util.newFieldList(()=>[]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},ae=class t extends k{id="";minutes=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ClientMessage.Ban";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"minutes",kind:"scalar",T:13}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},Fe=class t extends k{clear;event=0;pong;chat;rooms=[];welcome;move;press;release;sustain;profile;join;leave="";ratelimit=0;message="";chown="";constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ServerMessage";static fields=m.util.newFieldList(()=>[{no:1,name:"clear",kind:"message",T:F},{no:2,name:"event",kind:"enum",T:m.getEnumType(me)},{no:3,name:"pong",kind:"message",T:F},{no:4,name:"chat",kind:"message",T:V},{no:5,name:"rooms",kind:"message",T:ue,repeated:!0},{no:6,name:"welcome",kind:"message",T:ce},{no:7,name:"move",kind:"message",T:D},{no:8,name:"press",kind:"message",T:$},{no:9,name:"release",kind:"message",T:C},{no:10,name:"sustain",kind:"message",T:fe},{no:11,name:"profile",kind:"message",T:F},{no:12,name:"join",kind:"message",T:F},{no:13,name:"leave",kind:"scalar",T:9},{no:14,name:"ratelimit",kind:"scalar",T:13},{no:15,name:"message",kind:"scalar",T:9},{no:16,name:"chown",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},me=(h=>(h[h.CLEAR=0]="CLEAR",h[h.PONG=1]="PONG",h[h.CHAT=2]="CHAT",h[h.ROOMS=3]="ROOMS",h[h.WELCOME=4]="WELCOME",h[h.MOVE=5]="MOVE",h[h.PRESS=6]="PRESS",h[h.RELEASE=7]="RELEASE",h[h.SUSTAIN=8]="SUSTAIN",h[h.PROFILE=9]="PROFILE",h[h.JOIN=10]="JOIN",h[h.LEAVE=11]="LEAVE",h[h.RATELIMIT=12]="RATELIMIT",h[h.MESSAGE=13]="MESSAGE",h[h.CHOWN=14]="CHOWN",h))(me||{});m.util.setEnumType(me,"pianoverse.ServerMessage.EventType",[{no:0,name:"CLEAR"},{no:1,name:"PONG"},{no:2,name:"CHAT"},{no:3,name:"ROOMS"},{no:4,name:"WELCOME"},{no:5,name:"MOVE"},{no:6,name:"PRESS"},{no:7,name:"RELEASE"},{no:8,name:"SUSTAIN"},{no:9,name:"PROFILE"},{no:10,name:"JOIN"},{no:11,name:"LEAVE"},{no:12,name:"RATELIMIT"},{no:13,name:"MESSAGE"},{no:14,name:"CHOWN"}]);var V=class t extends k{id="";content="";name="";color="";constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ServerMessage.Chat";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"content",kind:"scalar",T:9},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"color",kind:"scalar",T:9}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},ue=class t extends k{room="";count=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ServerMessage.Room";static fields=m.util.newFieldList(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"count",kind:"scalar",T:13}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},ce=class t extends k{id="";name="";color="";room="";owner="";chat=[];role=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ServerMessage.Welcome";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"color",kind:"scalar",T:9},{no:4,name:"room",kind:"scalar",T:9},{no:5,name:"owner",kind:"scalar",T:9},{no:6,name:"chat",kind:"message",T:V,repeated:!0},{no:7,name:"role",kind:"enum",T:m.getEnumType(q)}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},fe=class t extends k{id="";enabled=!1;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.ServerMessage.Sustain";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},F=class t extends k{id="";name="";color="";role=0;muted=!1;x=0;y=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.Profile";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"color",kind:"scalar",T:9},{no:4,name:"role",kind:"enum",T:m.getEnumType(q)},{no:5,name:"muted",kind:"scalar",T:8},{no:6,name:"x",kind:"scalar",T:2},{no:7,name:"y",kind:"scalar",T:2}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},D=class t extends k{id="";x=0;y=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.Move";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"x",kind:"scalar",T:2},{no:3,name:"y",kind:"scalar",T:2}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},$=class t extends k{id="";key=0;vel=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.Press";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:13},{no:3,name:"vel",kind:"scalar",T:13}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}},C=class t extends k{id="";key=0;constructor(e){super(),m.util.initPartial(e,this)}static runtime=m;static typeName="pianoverse.Release";static fields=m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:13}]);static fromBinary(e,n){return new t().fromBinary(e,n)}static fromJson(e,n){return new t().fromJson(e,n)}static fromJsonString(e,n){return new t().fromJsonString(e,n)}static equals(e,n){return m.util.equals(t,e,n)}};return dt(Lt);})();