esp-idf-provisioning-web 0.0.3 → 0.0.6
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/LICENSE +0 -0
- package/README.md +84 -21
- package/dist/ESPDevice.d.ts +4 -19
- package/dist/ESPDevice.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +4623 -3094
- package/dist/security/Security0.d.ts.map +1 -1
- package/dist/security/Security1.d.ts +17 -0
- package/dist/security/Security1.d.ts.map +1 -0
- package/dist/types.d.ts +15 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/crypto.d.ts +9 -0
- package/dist/utils/crypto.d.ts.map +1 -1
- package/package.json +26 -24
- package/src/ESPDevice.ts +79 -74
- package/src/ESPProvisionManager.ts +0 -0
- package/src/constants.ts +0 -0
- package/src/generated/.gitkeep +0 -0
- package/src/generated/proto.d.ts +0 -0
- package/src/generated/proto.js +1864 -659
- package/src/index.ts +9 -4
- package/src/proto/constants.proto +0 -0
- package/src/proto/sec0.proto +0 -0
- package/src/proto/sec1.proto +0 -0
- package/src/proto/sec2.proto +0 -0
- package/src/proto/session.proto +0 -0
- package/src/proto/wifi_config.proto +0 -0
- package/src/proto/wifi_constants.proto +0 -0
- package/src/proto/wifi_ctrl.proto +0 -0
- package/src/proto/wifi_scan.proto +0 -0
- package/src/protocol/protocol.ts +0 -0
- package/src/protocol/wifiConfig.ts +6 -6
- package/src/protocol/wifiScan.ts +4 -4
- package/src/security/Security.ts +0 -0
- package/src/security/Security0.ts +5 -3
- package/src/security/Security1.ts +110 -0
- package/src/transport/BLETransport.ts +0 -0
- package/src/transport/SoftAPTransport.ts +2 -2
- package/src/transport/Transport.ts +0 -0
- package/src/types.ts +17 -1
- package/src/utils/crypto.ts +43 -9
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Transport{}function bytesToHex(i){return Array.from(i).map(n=>n.toString(16).padStart(2,"0")).join("")}function stringToBytes(i){return new TextEncoder().encode(i)}function bytesToString(i){return new TextDecoder().decode(i)}class BLETransport extends Transport{constructor(n,t,e){super(),this.connected=!1,this.device=n,this.serviceUUID=t,this.nuLookup=e}async connect(){var n;if(!this.isConnected())try{if(this.server=await((n=this.device.gatt)==null?void 0:n.connect()),!this.server)throw new Error("Failed to connect to GATT server");try{const e=await this.server.getPrimaryServices(this.serviceUUID);if(e.length>1){const r=e.find(o=>o.uuid===this.serviceUUID);if(!r)throw new Error(`Service with UUID ${this.serviceUUID} not found`);this.service=r}else this.service=e[0]}catch(e){throw new Error(`Failed to get primary services: ${e}`)}const t=await this.service.getCharacteristics();for(const e of t){const r=await e.getDescriptors();for(const o of r){if(o.uuid.slice(4,8)!=="2901")continue;const s=await o.readValue();this.nuLookup.set(bytesToString(new Uint8Array(s.buffer)).toLowerCase(),e.uuid)}}console.debug("BLE discovered characteristics:",this.nuLookup),this.connected=!0}catch(t){throw this.connected=!1,new Error(`BLE connection failed: ${t}`)}}disconnect(){var n;(n=this.server)!=null&&n.connected&&this.server.disconnect(),this.server=void 0,this.service=void 0,this.connected=!1}async sendData(n,t){var c;if(!this.isConnected())throw new Error("Not connected to device");const e=this.nuLookup.get(n.toLowerCase());if(!e)throw new Error(`Characteristic UUID for endpoint ${n} not found`);const r=await((c=this.service)==null?void 0:c.getCharacteristic(e));if(!r)throw new Error(`Characteristic for UUID ${e} not found`);const o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);await r.writeValueWithResponse(o);const s=await r.readValue();return new Uint8Array(s.buffer)}isConnected(){var n;return this.connected&&((n=this.server)==null?void 0:n.connected)===!0}getDevice(){return this.device}}class SoftAPTransport extends Transport{constructor(n){super(),this.connected=!1,this.baseUrl=n}async connect(){try{const n=await fetch(`${this.baseUrl}/proto-ver`,{method:"GET",mode:"cors"});if(!n.ok)throw new Error(`HTTP ${n.status}`);this.connected=!0}catch(n){throw this.connected=!1,new Error(`SoftAP connection failed. Please ensure you are connected to the device's WiFi network. Error: ${n}`)}}disconnect(){this.connected=!1}async sendData(n,t){if(!this.connected)throw new Error("Not connected to device");try{const e=await fetch(`${this.baseUrl}/${n}`,{method:"POST",headers:{Accept:"text/plain","Content-Type":"application/x-www-form-urlencoded"},body:t.buffer,mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const r=await e.arrayBuffer();return new Uint8Array(r)}catch(e){throw new Error(`SoftAP communication failed: ${e}`)}}isConnected(){return this.connected}setBaseUrl(n){this.baseUrl=n}getBaseUrl(){return this.baseUrl}}class Security{}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise=asPromise;function asPromise(i,n){for(var t=new Array(arguments.length-1),e=0,r=2,o=!0;r<arguments.length;)t[e++]=arguments[r++];return new Promise(function(c,u){t[e]=function(a){if(o)if(o=!1,a)u(a);else{for(var f=new Array(arguments.length-1),d=0;d<f.length;)f[d++]=arguments[d];c.apply(null,f)}};try{i.apply(n||null,t)}catch(l){o&&(o=!1,u(l))}})}var base64$1={};(function(i){var n=i;n.length=function(c){var u=c.length;if(!u)return 0;for(var l=0;--u%4>1&&c.charAt(u)==="=";)++l;return Math.ceil(c.length*3)/4-l};for(var t=new Array(64),e=new Array(123),r=0;r<64;)e[t[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;n.encode=function(c,u,l){for(var a=null,f=[],d=0,y=0,p;u<l;){var h=c[u++];switch(y){case 0:f[d++]=t[h>>2],p=(h&3)<<4,y=1;break;case 1:f[d++]=t[p|h>>4],p=(h&15)<<2,y=2;break;case 2:f[d++]=t[p|h>>6],f[d++]=t[h&63],y=0;break}d>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,f)),d=0)}return y&&(f[d++]=t[p],f[d++]=61,y===1&&(f[d++]=61)),a?(d&&a.push(String.fromCharCode.apply(String,f.slice(0,d))),a.join("")):String.fromCharCode.apply(String,f.slice(0,d))};var o="invalid encoding";n.decode=function(c,u,l){for(var a=l,f=0,d,y=0;y<c.length;){var p=c.charCodeAt(y++);if(p===61&&f>1)break;if((p=e[p])===void 0)throw Error(o);switch(f){case 0:d=p,f=1;break;case 1:u[l++]=d<<2|(p&48)>>4,d=p,f=2;break;case 2:u[l++]=(d&15)<<4|(p&60)>>2,d=p,f=3;break;case 3:u[l++]=(d&3)<<6|p,f=0;break}}if(f===1)throw Error(o);return l-a},n.test=function(c){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(n,t,e){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:t,ctx:e||this}),this};EventEmitter.prototype.off=function(n,t){if(n===void 0)this._listeners={};else if(t===void 0)this._listeners[n]=[];else for(var e=this._listeners[n],r=0;r<e.length;)e[r].fn===t?e.splice(r,1):++r;return this};EventEmitter.prototype.emit=function(n){var t=this._listeners[n];if(t){for(var e=[],r=1;r<arguments.length;)e.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,e)}return this};var float=factory(factory);function factory(i){return typeof Float32Array<"u"?function(){var n=new Float32Array([-0]),t=new Uint8Array(n.buffer),e=t[3]===128;function r(u,l,a){n[0]=u,l[a]=t[0],l[a+1]=t[1],l[a+2]=t[2],l[a+3]=t[3]}function o(u,l,a){n[0]=u,l[a]=t[3],l[a+1]=t[2],l[a+2]=t[1],l[a+3]=t[0]}i.writeFloatLE=e?r:o,i.writeFloatBE=e?o:r;function s(u,l){return t[0]=u[l],t[1]=u[l+1],t[2]=u[l+2],t[3]=u[l+3],n[0]}function c(u,l){return t[3]=u[l],t[2]=u[l+1],t[1]=u[l+2],t[0]=u[l+3],n[0]}i.readFloatLE=e?s:c,i.readFloatBE=e?c:s}():function(){function n(e,r,o,s){var c=r<0?1:0;if(c&&(r=-r),r===0)e(1/r>0?0:2147483648,o,s);else if(isNaN(r))e(2143289344,o,s);else if(r>34028234663852886e22)e((c<<31|2139095040)>>>0,o,s);else if(r<11754943508222875e-54)e((c<<31|Math.round(r/1401298464324817e-60))>>>0,o,s);else{var u=Math.floor(Math.log(r)/Math.LN2),l=Math.round(r*Math.pow(2,-u)*8388608)&8388607;e((c<<31|u+127<<23|l)>>>0,o,s)}}i.writeFloatLE=n.bind(null,writeUintLE),i.writeFloatBE=n.bind(null,writeUintBE);function t(e,r,o){var s=e(r,o),c=(s>>31)*2+1,u=s>>>23&255,l=s&8388607;return u===255?l?NaN:c*(1/0):u===0?c*1401298464324817e-60*l:c*Math.pow(2,u-150)*(l+8388608)}i.readFloatLE=t.bind(null,readUintLE),i.readFloatBE=t.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var n=new Float64Array([-0]),t=new Uint8Array(n.buffer),e=t[7]===128;function r(u,l,a){n[0]=u,l[a]=t[0],l[a+1]=t[1],l[a+2]=t[2],l[a+3]=t[3],l[a+4]=t[4],l[a+5]=t[5],l[a+6]=t[6],l[a+7]=t[7]}function o(u,l,a){n[0]=u,l[a]=t[7],l[a+1]=t[6],l[a+2]=t[5],l[a+3]=t[4],l[a+4]=t[3],l[a+5]=t[2],l[a+6]=t[1],l[a+7]=t[0]}i.writeDoubleLE=e?r:o,i.writeDoubleBE=e?o:r;function s(u,l){return t[0]=u[l],t[1]=u[l+1],t[2]=u[l+2],t[3]=u[l+3],t[4]=u[l+4],t[5]=u[l+5],t[6]=u[l+6],t[7]=u[l+7],n[0]}function c(u,l){return t[7]=u[l],t[6]=u[l+1],t[5]=u[l+2],t[4]=u[l+3],t[3]=u[l+4],t[2]=u[l+5],t[1]=u[l+6],t[0]=u[l+7],n[0]}i.readDoubleLE=e?s:c,i.readDoubleBE=e?c:s}():function(){function n(e,r,o,s,c,u){var l=s<0?1:0;if(l&&(s=-s),s===0)e(0,c,u+r),e(1/s>0?0:2147483648,c,u+o);else if(isNaN(s))e(0,c,u+r),e(2146959360,c,u+o);else if(s>17976931348623157e292)e(0,c,u+r),e((l<<31|2146435072)>>>0,c,u+o);else{var a;if(s<22250738585072014e-324)a=s/5e-324,e(a>>>0,c,u+r),e((l<<31|a/4294967296)>>>0,c,u+o);else{var f=Math.floor(Math.log(s)/Math.LN2);f===1024&&(f=1023),a=s*Math.pow(2,-f),e(a*4503599627370496>>>0,c,u+r),e((l<<31|f+1023<<20|a*1048576&1048575)>>>0,c,u+o)}}}i.writeDoubleLE=n.bind(null,writeUintLE,0,4),i.writeDoubleBE=n.bind(null,writeUintBE,4,0);function t(e,r,o,s,c){var u=e(s,c+r),l=e(s,c+o),a=(l>>31)*2+1,f=l>>>20&2047,d=4294967296*(l&1048575)+u;return f===2047?d?NaN:a*(1/0):f===0?a*5e-324*d:a*Math.pow(2,f-1075)*(d+4503599627370496)}i.readDoubleLE=t.bind(null,readUintLE,0,4),i.readDoubleBE=t.bind(null,readUintBE,4,0)}(),i}function writeUintLE(i,n,t){n[t]=i&255,n[t+1]=i>>>8&255,n[t+2]=i>>>16&255,n[t+3]=i>>>24}function writeUintBE(i,n,t){n[t]=i>>>24,n[t+1]=i>>>16&255,n[t+2]=i>>>8&255,n[t+3]=i&255}function readUintLE(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}function readUintBE(i,n){return(i[n]<<24|i[n+1]<<16|i[n+2]<<8|i[n+3])>>>0}var inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(i){}return null}var utf8$2={};(function(i){var n=i;n.length=function(e){for(var r=0,o=0,s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?r+=1:o<2048?r+=2:(o&64512)===55296&&(e.charCodeAt(s+1)&64512)===56320?(++s,r+=4):r+=3;return r},n.read=function(e,r,o){var s=o-r;if(s<1)return"";for(var c=null,u=[],l=0,a;r<o;)a=e[r++],a<128?u[l++]=a:a>191&&a<224?u[l++]=(a&31)<<6|e[r++]&63:a>239&&a<365?(a=((a&7)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,u[l++]=55296+(a>>10),u[l++]=56320+(a&1023)):u[l++]=(a&15)<<12|(e[r++]&63)<<6|e[r++]&63,l>8191&&((c||(c=[])).push(String.fromCharCode.apply(String,u)),l=0);return c?(l&&c.push(String.fromCharCode.apply(String,u.slice(0,l))),c.join("")):String.fromCharCode.apply(String,u.slice(0,l))},n.write=function(e,r,o){for(var s=o,c,u,l=0;l<e.length;++l)c=e.charCodeAt(l),c<128?r[o++]=c:c<2048?(r[o++]=c>>6|192,r[o++]=c&63|128):(c&64512)===55296&&((u=e.charCodeAt(l+1))&64512)===56320?(c=65536+((c&1023)<<10)+(u&1023),++l,r[o++]=c>>18|240,r[o++]=c>>12&63|128,r[o++]=c>>6&63|128,r[o++]=c&63|128):(r[o++]=c>>12|224,r[o++]=c>>6&63|128,r[o++]=c&63|128);return o-s}})(utf8$2);var pool_1=pool;function pool(i,n,t){var e=t||8192,r=e>>>1,o=null,s=e;return function(u){if(u<1||u>r)return i(u);s+u>e&&(o=i(e),s=0);var l=n.call(o,s,s+=u);return s&7&&(s=(s|7)+1),l}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=n;var i=requireMinimal();function n(o,s){this.lo=o>>>0,this.hi=s>>>0}var t=n.zero=new n(0,0);t.toNumber=function(){return 0},t.zzEncode=t.zzDecode=function(){return this},t.length=function(){return 1};var e=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(s){if(s===0)return t;var c=s<0;c&&(s=-s);var u=s>>>0,l=(s-u)/4294967296>>>0;return c&&(l=~l>>>0,u=~u>>>0,++u>4294967295&&(u=0,++l>4294967295&&(l=0))),new n(u,l)},n.from=function(s){if(typeof s=="number")return n.fromNumber(s);if(i.isString(s))if(i.Long)s=i.Long.fromString(s);else return n.fromNumber(parseInt(s,10));return s.low||s.high?new n(s.low>>>0,s.high>>>0):t},n.prototype.toNumber=function(s){if(!s&&this.hi>>>31){var c=~this.lo+1>>>0,u=~this.hi>>>0;return c||(u=u+1>>>0),-(c+u*4294967296)}return this.lo+this.hi*4294967296},n.prototype.toLong=function(s){return i.Long?new i.Long(this.lo|0,this.hi|0,!!s):{low:this.lo|0,high:this.hi|0,unsigned:!!s}};var r=String.prototype.charCodeAt;return n.fromHash=function(s){return s===e?t:new n((r.call(s,0)|r.call(s,1)<<8|r.call(s,2)<<16|r.call(s,3)<<24)>>>0,(r.call(s,4)|r.call(s,5)<<8|r.call(s,6)<<16|r.call(s,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var s=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^s)>>>0,this.lo=(this.lo<<1^s)>>>0,this},n.prototype.zzDecode=function(){var s=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^s)>>>0,this.hi=(this.hi>>>1^s)>>>0,this},n.prototype.length=function(){var s=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?c===0?s<16384?s<128?1:2:s<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:u<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(i){var n=i;n.asPromise=aspromise,n.base64=base64$1,n.EventEmitter=eventemitter,n.float=float,n.inquire=inquire_1,n.utf8=utf8$2,n.pool=pool_1,n.LongBits=requireLongbits(),n.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),n.global=n.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},n.isString=function(o){return typeof o=="string"||o instanceof String},n.isObject=function(o){return o&&typeof o=="object"},n.isset=n.isSet=function(o,s){var c=o[s];return c!=null&&o.hasOwnProperty(s)?typeof c!="object"||(Array.isArray(c)?c.length:Object.keys(c).length)>0:!1},n.Buffer=function(){try{var r=n.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(o){return typeof o=="number"?n.Buffer?n._Buffer_allocUnsafe(o):new n.Array(o):n.Buffer?n._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(o){return o?n.LongBits.from(o).toHash():n.LongBits.zeroHash},n.longFromHash=function(o,s){var c=n.LongBits.fromHash(o);return n.Long?n.Long.fromBits(c.lo,c.hi,s):c.toNumber(!!s)};function t(r,o,s){for(var c=Object.keys(o),u=0;u<c.length;++u)(r[c[u]]===void 0||!s)&&(r[c[u]]=o[c[u]]);return r}n.merge=t,n.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function e(r){function o(s,c){if(!(this instanceof o))return new o(s,c);Object.defineProperty(this,"message",{get:function(){return s}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),c&&t(this,c)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}n.newError=e,n.ProtocolError=e("ProtocolError"),n.oneOfGetter=function(o){for(var s={},c=0;c<o.length;++c)s[o[c]]=1;return function(){for(var u=Object.keys(this),l=u.length-1;l>-1;--l)if(s[u[l]]===1&&this[u[l]]!==void 0&&this[u[l]]!==null)return u[l]}},n.oneOfSetter=function(o){return function(s){for(var c=0;c<o.length;++c)o[c]!==s&&delete this[o[c]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var r=n.Buffer;if(!r){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=r.from!==Uint8Array.from&&r.from||function(s,c){return new r(s,c)},n._Buffer_allocUnsafe=r.allocUnsafe||function(s){return new r(s)}}}(minimal$1)),minimal$1}var writer=Writer$1,util$4=requireMinimal(),BufferWriter$1,LongBits$1=util$4.LongBits,base64=util$4.base64,utf8$1=util$4.utf8;function Op(i,n,t){this.fn=i,this.len=n,this.next=void 0,this.val=t}function noop(){}function State(i){this.head=i.head,this.tail=i.tail,this.len=i.len,this.next=i.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function i(){return util$4.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1();Writer$1.alloc=function i(n){return new util$4.Array(n)};util$4.Array!==Array&&(Writer$1.alloc=util$4.pool(Writer$1.alloc,util$4.Array.prototype.subarray));Writer$1.prototype._push=function i(n,t,e){return this.tail=this.tail.next=new Op(n,t,e),this.len+=t,this};function writeByte(i,n,t){n[t]=i&255}function writeVarint32(i,n,t){for(;i>127;)n[t++]=i&127|128,i>>>=7;n[t]=i}function VarintOp(i,n){this.len=i,this.next=void 0,this.val=n}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer$1.prototype.uint32=function i(n){return this.len+=(this.tail=this.tail.next=new VarintOp((n=n>>>0)<128?1:n<16384?2:n<2097152?3:n<268435456?4:5,n)).len,this};Writer$1.prototype.int32=function i(n){return n<0?this._push(writeVarint64,10,LongBits$1.fromNumber(n)):this.uint32(n)};Writer$1.prototype.sint32=function i(n){return this.uint32((n<<1^n>>31)>>>0)};function writeVarint64(i,n,t){for(;i.hi;)n[t++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)n[t++]=i.lo&127|128,i.lo=i.lo>>>7;n[t++]=i.lo}Writer$1.prototype.uint64=function i(n){var t=LongBits$1.from(n);return this._push(writeVarint64,t.length(),t)};Writer$1.prototype.int64=Writer$1.prototype.uint64;Writer$1.prototype.sint64=function i(n){var t=LongBits$1.from(n).zzEncode();return this._push(writeVarint64,t.length(),t)};Writer$1.prototype.bool=function i(n){return this._push(writeByte,1,n?1:0)};function writeFixed32(i,n,t){n[t]=i&255,n[t+1]=i>>>8&255,n[t+2]=i>>>16&255,n[t+3]=i>>>24}Writer$1.prototype.fixed32=function i(n){return this._push(writeFixed32,4,n>>>0)};Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32;Writer$1.prototype.fixed64=function i(n){var t=LongBits$1.from(n);return this._push(writeFixed32,4,t.lo)._push(writeFixed32,4,t.hi)};Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64;Writer$1.prototype.float=function i(n){return this._push(util$4.float.writeFloatLE,4,n)};Writer$1.prototype.double=function i(n){return this._push(util$4.float.writeDoubleLE,8,n)};var writeBytes=util$4.Array.prototype.set?function i(n,t,e){t.set(n,e)}:function i(n,t,e){for(var r=0;r<n.length;++r)t[e+r]=n[r]};Writer$1.prototype.bytes=function i(n){var t=n.length>>>0;if(!t)return this._push(writeByte,1,0);if(util$4.isString(n)){var e=Writer$1.alloc(t=base64.length(n));base64.decode(n,e,0),n=e}return this.uint32(t)._push(writeBytes,t,n)};Writer$1.prototype.string=function i(n){var t=utf8$1.length(n);return t?this.uint32(t)._push(utf8$1.write,t,n):this._push(writeByte,1,0)};Writer$1.prototype.fork=function i(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this};Writer$1.prototype.reset=function i(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this};Writer$1.prototype.ldelim=function i(){var n=this.head,t=this.tail,e=this.len;return this.reset().uint32(e),e&&(this.tail.next=n.next,this.tail=t,this.len+=e),this};Writer$1.prototype.finish=function i(){for(var n=this.head.next,t=this.constructor.alloc(this.len),e=0;n;)n.fn(n.val,t,e),e+=n.len,n=n.next;return t};Writer$1._configure=function(i){BufferWriter$1=i,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$3=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$3._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$3.Buffer&&util$3.Buffer.prototype instanceof Uint8Array&&util$3.Buffer.prototype.set.name==="set"?function(n,t,e){t.set(n,e)}:function(n,t,e){if(n.copy)n.copy(t,e,0,n.length);else for(var r=0;r<n.length;)t[e++]=n[r++]}};BufferWriter.prototype.bytes=function i(n){util$3.isString(n)&&(n=util$3._Buffer_from(n,"base64"));var t=n.length>>>0;return this.uint32(t),t&&this._push(BufferWriter.writeBytesBuffer,t,n),this};function writeStringBuffer(i,n,t){i.length<40?util$3.utf8.write(i,n,t):n.utf8Write?n.utf8Write(i,t):n.write(i,t)}BufferWriter.prototype.string=function i(n){var t=util$3.Buffer.byteLength(n);return this.uint32(t),t&&this._push(writeStringBuffer,t,n),this};BufferWriter._configure();var reader=Reader$1,util$2=requireMinimal(),BufferReader$1,LongBits=util$2.LongBits,utf8=util$2.utf8;function indexOutOfRange(i,n){return RangeError("index out of range: "+i.pos+" + "+(n||1)+" > "+i.len)}function Reader$1(i){this.buf=i,this.pos=0,this.len=i.length}var create_array=typeof Uint8Array<"u"?function i(n){if(n instanceof Uint8Array||Array.isArray(n))return new Reader$1(n);throw Error("illegal buffer")}:function i(n){if(Array.isArray(n))return new Reader$1(n);throw Error("illegal buffer")},create=function i(){return util$2.Buffer?function(t){return(Reader$1.create=function(r){return util$2.Buffer.isBuffer(r)?new BufferReader$1(r):create_array(r)})(t)}:create_array};Reader$1.create=create();Reader$1.prototype._slice=util$2.Array.prototype.subarray||util$2.Array.prototype.slice;Reader$1.prototype.uint32=function i(){var n=4294967295;return function(){if(n=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(n=(n|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return n;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return n}}();Reader$1.prototype.int32=function i(){return this.uint32()|0};Reader$1.prototype.sint32=function i(){var n=this.uint32();return n>>>1^-(n&1)|0};function readLongVarint(){var i=new LongBits(0,0),n=0;if(this.len-this.pos>4){for(;n<4;++n)if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i;if(i.lo=(i.lo|(this.buf[this.pos]&127)<<28)>>>0,i.hi=(i.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return i;n=0}else{for(;n<3;++n){if(this.pos>=this.len)throw indexOutOfRange(this);if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i}return i.lo=(i.lo|(this.buf[this.pos++]&127)<<n*7)>>>0,i}if(this.len-this.pos>4){for(;n<5;++n)if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}else for(;n<5;++n){if(this.pos>=this.len)throw indexOutOfRange(this);if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function i(){return this.uint32()!==0};function readFixed32_end(i,n){return(i[n-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0}Reader$1.prototype.fixed32=function i(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader$1.prototype.sfixed32=function i(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function i(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var n=util$2.float.readFloatLE(this.buf,this.pos);return this.pos+=4,n};Reader$1.prototype.double=function i(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var n=util$2.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,n};Reader$1.prototype.bytes=function i(){var n=this.uint32(),t=this.pos,e=this.pos+n;if(e>this.len)throw indexOutOfRange(this,n);if(this.pos+=n,Array.isArray(this.buf))return this.buf.slice(t,e);if(t===e){var r=util$2.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,e)};Reader$1.prototype.string=function i(){var n=this.bytes();return utf8.read(n,0,n.length)};Reader$1.prototype.skip=function i(n){if(typeof n=="number"){if(this.pos+n>this.len)throw indexOutOfRange(this,n);this.pos+=n}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this};Reader$1.prototype.skipType=function(i){switch(i){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(i=this.uint32()&7)!==4;)this.skipType(i);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+i+" at offset "+this.pos)}return this};Reader$1._configure=function(i){BufferReader$1=i,Reader$1.create=create(),BufferReader$1._configure();var n=util$2.Long?"toLong":"toNumber";util$2.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[n](!1)},uint64:function(){return readLongVarint.call(this)[n](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[n](!1)},fixed64:function(){return readFixed64.call(this)[n](!0)},sfixed64:function(){return readFixed64.call(this)[n](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$1=requireMinimal();function BufferReader(i){Reader.call(this,i)}BufferReader._configure=function(){util$1.Buffer&&(BufferReader.prototype._slice=util$1.Buffer.prototype.slice)};BufferReader.prototype.string=function i(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))};BufferReader._configure();var rpc={},service=Service,util=requireMinimal();(Service.prototype=Object.create(util.EventEmitter.prototype)).constructor=Service;function Service(i,n,t){if(typeof i!="function")throw TypeError("rpcImpl must be a function");util.EventEmitter.call(this),this.rpcImpl=i,this.requestDelimited=!!n,this.responseDelimited=!!t}Service.prototype.rpcCall=function i(n,t,e,r,o){if(!r)throw TypeError("request must be specified");var s=this;if(!o)return util.asPromise(i,s,n,t,e,r);if(!s.rpcImpl){setTimeout(function(){o(Error("already ended"))},0);return}try{return s.rpcImpl(n,t[s.requestDelimited?"encodeDelimited":"encode"](r).finish(),function(u,l){if(u)return s.emit("error",u,n),o(u);if(l===null){s.end(!0);return}if(!(l instanceof e))try{l=e[s.responseDelimited?"decodeDelimited":"decode"](l)}catch(a){return s.emit("error",a,n),o(a)}return s.emit("data",l,n),o(null,l)})}catch(c){s.emit("error",c,n),setTimeout(function(){o(c)},0);return}};Service.prototype.end=function i(n){return this.rpcImpl&&(n||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};(function(i){var n=i;n.Service=service})(rpc);var roots={};(function(i){var n=i;n.build="minimal",n.Writer=writer,n.BufferWriter=writer_buffer,n.Reader=reader,n.BufferReader=reader_buffer,n.util=requireMinimal(),n.rpc=rpc,n.roots=roots,n.configure=t;function t(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}t()})(indexMinimal);var minimal=indexMinimal;const $Reader=minimal.Reader,$Writer=minimal.Writer,$util=minimal.util,$root=minimal.roots.default||(minimal.roots.default={}),Status=$root.Status=(()=>{const i={},n=Object.create(i);return n[i[0]="Success"]=0,n[i[1]="InvalidSecScheme"]=1,n[i[2]="InvalidProto"]=2,n[i[3]="TooManySessions"]=3,n[i[4]="InvalidArgument"]=4,n[i[5]="InternalError"]=5,n[i[6]="CryptoError"]=6,n[i[7]="InvalidSession"]=7,n})(),S0SessionCmd=$root.S0SessionCmd=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S0SessionCmd;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.S0SessionCmd?t:new $root.S0SessionCmd},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S0SessionCmd"},i})();$root.S0SessionResp=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S0SessionResp;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},i.fromObject=function(t){if(t instanceof $root.S0SessionResp)return t;let e=new $root.S0SessionResp;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S0SessionResp"},i})();const Sec0MsgType=$root.Sec0MsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="S0_Session_Command"]=0,n[i[1]="S0_Session_Response"]=1,n})(),Sec0Payload=$root.Sec0Payload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.sc=null,i.prototype.sr=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["sc","sr"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.sc!=null&&Object.hasOwnProperty.call(e,"sc")&&$root.S0SessionCmd.encode(e.sc,r.uint32(162).fork()).ldelim(),e.sr!=null&&Object.hasOwnProperty.call(e,"sr")&&$root.S0SessionResp.encode(e.sr,r.uint32(170).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.Sec0Payload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 20:{c.sc=$root.S0SessionCmd.decode(e,e.uint32());break}case 21:{c.sr=$root.S0SessionResp.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:break}if(e.sc!=null&&e.hasOwnProperty("sc")){r.payload=1;{let o=$root.S0SessionCmd.verify(e.sc);if(o)return"sc."+o}}if(e.sr!=null&&e.hasOwnProperty("sr")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.S0SessionResp.verify(e.sr);if(o)return"sr."+o}}return null},i.fromObject=function(e){if(e instanceof $root.Sec0Payload)return e;let r=new $root.Sec0Payload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"S0_Session_Command":case 0:r.msg=0;break;case"S0_Session_Response":case 1:r.msg=1;break}if(e.sc!=null){if(typeof e.sc!="object")throw TypeError(".Sec0Payload.sc: object expected");r.sc=$root.S0SessionCmd.fromObject(e.sc)}if(e.sr!=null){if(typeof e.sr!="object")throw TypeError(".Sec0Payload.sr: object expected");r.sr=$root.S0SessionResp.fromObject(e.sr)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"S0_Session_Command":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.Sec0MsgType[e.msg]===void 0?e.msg:$root.Sec0MsgType[e.msg]:e.msg),e.sc!=null&&e.hasOwnProperty("sc")&&(o.sc=$root.S0SessionCmd.toObject(e.sc,r),r.oneofs&&(o.payload="sc")),e.sr!=null&&e.hasOwnProperty("sr")&&(o.sr=$root.S0SessionResp.toObject(e.sr,r),r.oneofs&&(o.payload="sr")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/Sec0Payload"},i})();$root.SessionCmd1=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.clientVerifyData=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.clientVerifyData!=null&&Object.hasOwnProperty.call(t,"clientVerifyData")&&e.uint32(18).bytes(t.clientVerifyData),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.SessionCmd1;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 2:{s.clientVerifyData=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.clientVerifyData!=null&&t.hasOwnProperty("clientVerifyData")&&!(t.clientVerifyData&&typeof t.clientVerifyData.length=="number"||$util.isString(t.clientVerifyData))?"clientVerifyData: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.SessionCmd1)return t;let e=new $root.SessionCmd1;return t.clientVerifyData!=null&&(typeof t.clientVerifyData=="string"?$util.base64.decode(t.clientVerifyData,e.clientVerifyData=$util.newBuffer($util.base64.length(t.clientVerifyData)),0):t.clientVerifyData.length>=0&&(e.clientVerifyData=t.clientVerifyData)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.clientVerifyData="":(r.clientVerifyData=[],e.bytes!==Array&&(r.clientVerifyData=$util.newBuffer(r.clientVerifyData)))),t.clientVerifyData!=null&&t.hasOwnProperty("clientVerifyData")&&(r.clientVerifyData=e.bytes===String?$util.base64.encode(t.clientVerifyData,0,t.clientVerifyData.length):e.bytes===Array?Array.prototype.slice.call(t.clientVerifyData):t.clientVerifyData),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/SessionCmd1"},i})();$root.SessionResp1=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.prototype.deviceVerifyData=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),t.deviceVerifyData!=null&&Object.hasOwnProperty.call(t,"deviceVerifyData")&&e.uint32(26).bytes(t.deviceVerifyData),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.SessionResp1;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}case 3:{s.deviceVerifyData=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return t.deviceVerifyData!=null&&t.hasOwnProperty("deviceVerifyData")&&!(t.deviceVerifyData&&typeof t.deviceVerifyData.length=="number"||$util.isString(t.deviceVerifyData))?"deviceVerifyData: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.SessionResp1)return t;let e=new $root.SessionResp1;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return t.deviceVerifyData!=null&&(typeof t.deviceVerifyData=="string"?$util.base64.decode(t.deviceVerifyData,e.deviceVerifyData=$util.newBuffer($util.base64.length(t.deviceVerifyData)),0):t.deviceVerifyData.length>=0&&(e.deviceVerifyData=t.deviceVerifyData)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0,e.bytes===String?r.deviceVerifyData="":(r.deviceVerifyData=[],e.bytes!==Array&&(r.deviceVerifyData=$util.newBuffer(r.deviceVerifyData)))),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),t.deviceVerifyData!=null&&t.hasOwnProperty("deviceVerifyData")&&(r.deviceVerifyData=e.bytes===String?$util.base64.encode(t.deviceVerifyData,0,t.deviceVerifyData.length):e.bytes===Array?Array.prototype.slice.call(t.deviceVerifyData):t.deviceVerifyData),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/SessionResp1"},i})();$root.SessionCmd0=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.clientPubkey=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.clientPubkey!=null&&Object.hasOwnProperty.call(t,"clientPubkey")&&e.uint32(10).bytes(t.clientPubkey),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.SessionCmd0;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.clientPubkey=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.clientPubkey!=null&&t.hasOwnProperty("clientPubkey")&&!(t.clientPubkey&&typeof t.clientPubkey.length=="number"||$util.isString(t.clientPubkey))?"clientPubkey: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.SessionCmd0)return t;let e=new $root.SessionCmd0;return t.clientPubkey!=null&&(typeof t.clientPubkey=="string"?$util.base64.decode(t.clientPubkey,e.clientPubkey=$util.newBuffer($util.base64.length(t.clientPubkey)),0):t.clientPubkey.length>=0&&(e.clientPubkey=t.clientPubkey)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.clientPubkey="":(r.clientPubkey=[],e.bytes!==Array&&(r.clientPubkey=$util.newBuffer(r.clientPubkey)))),t.clientPubkey!=null&&t.hasOwnProperty("clientPubkey")&&(r.clientPubkey=e.bytes===String?$util.base64.encode(t.clientPubkey,0,t.clientPubkey.length):e.bytes===Array?Array.prototype.slice.call(t.clientPubkey):t.clientPubkey),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/SessionCmd0"},i})();$root.SessionResp0=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.prototype.devicePubkey=$util.newBuffer([]),i.prototype.deviceRandom=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),t.devicePubkey!=null&&Object.hasOwnProperty.call(t,"devicePubkey")&&e.uint32(18).bytes(t.devicePubkey),t.deviceRandom!=null&&Object.hasOwnProperty.call(t,"deviceRandom")&&e.uint32(26).bytes(t.deviceRandom),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.SessionResp0;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}case 2:{s.devicePubkey=t.bytes();break}case 3:{s.deviceRandom=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return t.devicePubkey!=null&&t.hasOwnProperty("devicePubkey")&&!(t.devicePubkey&&typeof t.devicePubkey.length=="number"||$util.isString(t.devicePubkey))?"devicePubkey: buffer expected":t.deviceRandom!=null&&t.hasOwnProperty("deviceRandom")&&!(t.deviceRandom&&typeof t.deviceRandom.length=="number"||$util.isString(t.deviceRandom))?"deviceRandom: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.SessionResp0)return t;let e=new $root.SessionResp0;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return t.devicePubkey!=null&&(typeof t.devicePubkey=="string"?$util.base64.decode(t.devicePubkey,e.devicePubkey=$util.newBuffer($util.base64.length(t.devicePubkey)),0):t.devicePubkey.length>=0&&(e.devicePubkey=t.devicePubkey)),t.deviceRandom!=null&&(typeof t.deviceRandom=="string"?$util.base64.decode(t.deviceRandom,e.deviceRandom=$util.newBuffer($util.base64.length(t.deviceRandom)),0):t.deviceRandom.length>=0&&(e.deviceRandom=t.deviceRandom)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0,e.bytes===String?r.devicePubkey="":(r.devicePubkey=[],e.bytes!==Array&&(r.devicePubkey=$util.newBuffer(r.devicePubkey))),e.bytes===String?r.deviceRandom="":(r.deviceRandom=[],e.bytes!==Array&&(r.deviceRandom=$util.newBuffer(r.deviceRandom)))),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),t.devicePubkey!=null&&t.hasOwnProperty("devicePubkey")&&(r.devicePubkey=e.bytes===String?$util.base64.encode(t.devicePubkey,0,t.devicePubkey.length):e.bytes===Array?Array.prototype.slice.call(t.devicePubkey):t.devicePubkey),t.deviceRandom!=null&&t.hasOwnProperty("deviceRandom")&&(r.deviceRandom=e.bytes===String?$util.base64.encode(t.deviceRandom,0,t.deviceRandom.length):e.bytes===Array?Array.prototype.slice.call(t.deviceRandom):t.deviceRandom),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/SessionResp0"},i})();$root.Sec1MsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="Session_Command0"]=0,n[i[1]="Session_Response0"]=1,n[i[2]="Session_Command1"]=2,n[i[3]="Session_Response1"]=3,n})();$root.Sec1Payload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.sc0=null,i.prototype.sr0=null,i.prototype.sc1=null,i.prototype.sr1=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["sc0","sr0","sc1","sr1"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.sc0!=null&&Object.hasOwnProperty.call(e,"sc0")&&$root.SessionCmd0.encode(e.sc0,r.uint32(162).fork()).ldelim(),e.sr0!=null&&Object.hasOwnProperty.call(e,"sr0")&&$root.SessionResp0.encode(e.sr0,r.uint32(170).fork()).ldelim(),e.sc1!=null&&Object.hasOwnProperty.call(e,"sc1")&&$root.SessionCmd1.encode(e.sc1,r.uint32(178).fork()).ldelim(),e.sr1!=null&&Object.hasOwnProperty.call(e,"sr1")&&$root.SessionResp1.encode(e.sr1,r.uint32(186).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.Sec1Payload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 20:{c.sc0=$root.SessionCmd0.decode(e,e.uint32());break}case 21:{c.sr0=$root.SessionResp0.decode(e,e.uint32());break}case 22:{c.sc1=$root.SessionCmd1.decode(e,e.uint32());break}case 23:{c.sr1=$root.SessionResp1.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:break}if(e.sc0!=null&&e.hasOwnProperty("sc0")){r.payload=1;{let o=$root.SessionCmd0.verify(e.sc0);if(o)return"sc0."+o}}if(e.sr0!=null&&e.hasOwnProperty("sr0")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.SessionResp0.verify(e.sr0);if(o)return"sr0."+o}}if(e.sc1!=null&&e.hasOwnProperty("sc1")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.SessionCmd1.verify(e.sc1);if(o)return"sc1."+o}}if(e.sr1!=null&&e.hasOwnProperty("sr1")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.SessionResp1.verify(e.sr1);if(o)return"sr1."+o}}return null},i.fromObject=function(e){if(e instanceof $root.Sec1Payload)return e;let r=new $root.Sec1Payload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"Session_Command0":case 0:r.msg=0;break;case"Session_Response0":case 1:r.msg=1;break;case"Session_Command1":case 2:r.msg=2;break;case"Session_Response1":case 3:r.msg=3;break}if(e.sc0!=null){if(typeof e.sc0!="object")throw TypeError(".Sec1Payload.sc0: object expected");r.sc0=$root.SessionCmd0.fromObject(e.sc0)}if(e.sr0!=null){if(typeof e.sr0!="object")throw TypeError(".Sec1Payload.sr0: object expected");r.sr0=$root.SessionResp0.fromObject(e.sr0)}if(e.sc1!=null){if(typeof e.sc1!="object")throw TypeError(".Sec1Payload.sc1: object expected");r.sc1=$root.SessionCmd1.fromObject(e.sc1)}if(e.sr1!=null){if(typeof e.sr1!="object")throw TypeError(".Sec1Payload.sr1: object expected");r.sr1=$root.SessionResp1.fromObject(e.sr1)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"Session_Command0":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.Sec1MsgType[e.msg]===void 0?e.msg:$root.Sec1MsgType[e.msg]:e.msg),e.sc0!=null&&e.hasOwnProperty("sc0")&&(o.sc0=$root.SessionCmd0.toObject(e.sc0,r),r.oneofs&&(o.payload="sc0")),e.sr0!=null&&e.hasOwnProperty("sr0")&&(o.sr0=$root.SessionResp0.toObject(e.sr0,r),r.oneofs&&(o.payload="sr0")),e.sc1!=null&&e.hasOwnProperty("sc1")&&(o.sc1=$root.SessionCmd1.toObject(e.sc1,r),r.oneofs&&(o.payload="sc1")),e.sr1!=null&&e.hasOwnProperty("sr1")&&(o.sr1=$root.SessionResp1.toObject(e.sr1,r),r.oneofs&&(o.payload="sr1")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/Sec1Payload"},i})();$root.Sec2MsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="S2Session_Command0"]=0,n[i[1]="S2Session_Response0"]=1,n[i[2]="S2Session_Command1"]=2,n[i[3]="S2Session_Response1"]=3,n})();$root.S2SessionCmd0=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.clientUsername=$util.newBuffer([]),i.prototype.clientPubkey=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.clientUsername!=null&&Object.hasOwnProperty.call(t,"clientUsername")&&e.uint32(10).bytes(t.clientUsername),t.clientPubkey!=null&&Object.hasOwnProperty.call(t,"clientPubkey")&&e.uint32(18).bytes(t.clientPubkey),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S2SessionCmd0;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.clientUsername=t.bytes();break}case 2:{s.clientPubkey=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.clientUsername!=null&&t.hasOwnProperty("clientUsername")&&!(t.clientUsername&&typeof t.clientUsername.length=="number"||$util.isString(t.clientUsername))?"clientUsername: buffer expected":t.clientPubkey!=null&&t.hasOwnProperty("clientPubkey")&&!(t.clientPubkey&&typeof t.clientPubkey.length=="number"||$util.isString(t.clientPubkey))?"clientPubkey: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.S2SessionCmd0)return t;let e=new $root.S2SessionCmd0;return t.clientUsername!=null&&(typeof t.clientUsername=="string"?$util.base64.decode(t.clientUsername,e.clientUsername=$util.newBuffer($util.base64.length(t.clientUsername)),0):t.clientUsername.length>=0&&(e.clientUsername=t.clientUsername)),t.clientPubkey!=null&&(typeof t.clientPubkey=="string"?$util.base64.decode(t.clientPubkey,e.clientPubkey=$util.newBuffer($util.base64.length(t.clientPubkey)),0):t.clientPubkey.length>=0&&(e.clientPubkey=t.clientPubkey)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.clientUsername="":(r.clientUsername=[],e.bytes!==Array&&(r.clientUsername=$util.newBuffer(r.clientUsername))),e.bytes===String?r.clientPubkey="":(r.clientPubkey=[],e.bytes!==Array&&(r.clientPubkey=$util.newBuffer(r.clientPubkey)))),t.clientUsername!=null&&t.hasOwnProperty("clientUsername")&&(r.clientUsername=e.bytes===String?$util.base64.encode(t.clientUsername,0,t.clientUsername.length):e.bytes===Array?Array.prototype.slice.call(t.clientUsername):t.clientUsername),t.clientPubkey!=null&&t.hasOwnProperty("clientPubkey")&&(r.clientPubkey=e.bytes===String?$util.base64.encode(t.clientPubkey,0,t.clientPubkey.length):e.bytes===Array?Array.prototype.slice.call(t.clientPubkey):t.clientPubkey),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S2SessionCmd0"},i})();$root.S2SessionResp0=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.prototype.devicePubkey=$util.newBuffer([]),i.prototype.deviceSalt=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),t.devicePubkey!=null&&Object.hasOwnProperty.call(t,"devicePubkey")&&e.uint32(18).bytes(t.devicePubkey),t.deviceSalt!=null&&Object.hasOwnProperty.call(t,"deviceSalt")&&e.uint32(26).bytes(t.deviceSalt),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S2SessionResp0;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}case 2:{s.devicePubkey=t.bytes();break}case 3:{s.deviceSalt=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return t.devicePubkey!=null&&t.hasOwnProperty("devicePubkey")&&!(t.devicePubkey&&typeof t.devicePubkey.length=="number"||$util.isString(t.devicePubkey))?"devicePubkey: buffer expected":t.deviceSalt!=null&&t.hasOwnProperty("deviceSalt")&&!(t.deviceSalt&&typeof t.deviceSalt.length=="number"||$util.isString(t.deviceSalt))?"deviceSalt: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.S2SessionResp0)return t;let e=new $root.S2SessionResp0;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return t.devicePubkey!=null&&(typeof t.devicePubkey=="string"?$util.base64.decode(t.devicePubkey,e.devicePubkey=$util.newBuffer($util.base64.length(t.devicePubkey)),0):t.devicePubkey.length>=0&&(e.devicePubkey=t.devicePubkey)),t.deviceSalt!=null&&(typeof t.deviceSalt=="string"?$util.base64.decode(t.deviceSalt,e.deviceSalt=$util.newBuffer($util.base64.length(t.deviceSalt)),0):t.deviceSalt.length>=0&&(e.deviceSalt=t.deviceSalt)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0,e.bytes===String?r.devicePubkey="":(r.devicePubkey=[],e.bytes!==Array&&(r.devicePubkey=$util.newBuffer(r.devicePubkey))),e.bytes===String?r.deviceSalt="":(r.deviceSalt=[],e.bytes!==Array&&(r.deviceSalt=$util.newBuffer(r.deviceSalt)))),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),t.devicePubkey!=null&&t.hasOwnProperty("devicePubkey")&&(r.devicePubkey=e.bytes===String?$util.base64.encode(t.devicePubkey,0,t.devicePubkey.length):e.bytes===Array?Array.prototype.slice.call(t.devicePubkey):t.devicePubkey),t.deviceSalt!=null&&t.hasOwnProperty("deviceSalt")&&(r.deviceSalt=e.bytes===String?$util.base64.encode(t.deviceSalt,0,t.deviceSalt.length):e.bytes===Array?Array.prototype.slice.call(t.deviceSalt):t.deviceSalt),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S2SessionResp0"},i})();$root.S2SessionCmd1=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.clientProof=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.clientProof!=null&&Object.hasOwnProperty.call(t,"clientProof")&&e.uint32(10).bytes(t.clientProof),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S2SessionCmd1;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.clientProof=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.clientProof!=null&&t.hasOwnProperty("clientProof")&&!(t.clientProof&&typeof t.clientProof.length=="number"||$util.isString(t.clientProof))?"clientProof: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.S2SessionCmd1)return t;let e=new $root.S2SessionCmd1;return t.clientProof!=null&&(typeof t.clientProof=="string"?$util.base64.decode(t.clientProof,e.clientProof=$util.newBuffer($util.base64.length(t.clientProof)),0):t.clientProof.length>=0&&(e.clientProof=t.clientProof)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.clientProof="":(r.clientProof=[],e.bytes!==Array&&(r.clientProof=$util.newBuffer(r.clientProof)))),t.clientProof!=null&&t.hasOwnProperty("clientProof")&&(r.clientProof=e.bytes===String?$util.base64.encode(t.clientProof,0,t.clientProof.length):e.bytes===Array?Array.prototype.slice.call(t.clientProof):t.clientProof),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S2SessionCmd1"},i})();$root.S2SessionResp1=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.prototype.deviceProof=$util.newBuffer([]),i.prototype.deviceNonce=$util.newBuffer([]),i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),t.deviceProof!=null&&Object.hasOwnProperty.call(t,"deviceProof")&&e.uint32(18).bytes(t.deviceProof),t.deviceNonce!=null&&Object.hasOwnProperty.call(t,"deviceNonce")&&e.uint32(26).bytes(t.deviceNonce),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.S2SessionResp1;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}case 2:{s.deviceProof=t.bytes();break}case 3:{s.deviceNonce=t.bytes();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return t.deviceProof!=null&&t.hasOwnProperty("deviceProof")&&!(t.deviceProof&&typeof t.deviceProof.length=="number"||$util.isString(t.deviceProof))?"deviceProof: buffer expected":t.deviceNonce!=null&&t.hasOwnProperty("deviceNonce")&&!(t.deviceNonce&&typeof t.deviceNonce.length=="number"||$util.isString(t.deviceNonce))?"deviceNonce: buffer expected":null},i.fromObject=function(t){if(t instanceof $root.S2SessionResp1)return t;let e=new $root.S2SessionResp1;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return t.deviceProof!=null&&(typeof t.deviceProof=="string"?$util.base64.decode(t.deviceProof,e.deviceProof=$util.newBuffer($util.base64.length(t.deviceProof)),0):t.deviceProof.length>=0&&(e.deviceProof=t.deviceProof)),t.deviceNonce!=null&&(typeof t.deviceNonce=="string"?$util.base64.decode(t.deviceNonce,e.deviceNonce=$util.newBuffer($util.base64.length(t.deviceNonce)),0):t.deviceNonce.length>=0&&(e.deviceNonce=t.deviceNonce)),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0,e.bytes===String?r.deviceProof="":(r.deviceProof=[],e.bytes!==Array&&(r.deviceProof=$util.newBuffer(r.deviceProof))),e.bytes===String?r.deviceNonce="":(r.deviceNonce=[],e.bytes!==Array&&(r.deviceNonce=$util.newBuffer(r.deviceNonce)))),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),t.deviceProof!=null&&t.hasOwnProperty("deviceProof")&&(r.deviceProof=e.bytes===String?$util.base64.encode(t.deviceProof,0,t.deviceProof.length):e.bytes===Array?Array.prototype.slice.call(t.deviceProof):t.deviceProof),t.deviceNonce!=null&&t.hasOwnProperty("deviceNonce")&&(r.deviceNonce=e.bytes===String?$util.base64.encode(t.deviceNonce,0,t.deviceNonce.length):e.bytes===Array?Array.prototype.slice.call(t.deviceNonce):t.deviceNonce),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/S2SessionResp1"},i})();$root.Sec2Payload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.sc0=null,i.prototype.sr0=null,i.prototype.sc1=null,i.prototype.sr1=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["sc0","sr0","sc1","sr1"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.sc0!=null&&Object.hasOwnProperty.call(e,"sc0")&&$root.S2SessionCmd0.encode(e.sc0,r.uint32(162).fork()).ldelim(),e.sr0!=null&&Object.hasOwnProperty.call(e,"sr0")&&$root.S2SessionResp0.encode(e.sr0,r.uint32(170).fork()).ldelim(),e.sc1!=null&&Object.hasOwnProperty.call(e,"sc1")&&$root.S2SessionCmd1.encode(e.sc1,r.uint32(178).fork()).ldelim(),e.sr1!=null&&Object.hasOwnProperty.call(e,"sr1")&&$root.S2SessionResp1.encode(e.sr1,r.uint32(186).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.Sec2Payload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 20:{c.sc0=$root.S2SessionCmd0.decode(e,e.uint32());break}case 21:{c.sr0=$root.S2SessionResp0.decode(e,e.uint32());break}case 22:{c.sc1=$root.S2SessionCmd1.decode(e,e.uint32());break}case 23:{c.sr1=$root.S2SessionResp1.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:break}if(e.sc0!=null&&e.hasOwnProperty("sc0")){r.payload=1;{let o=$root.S2SessionCmd0.verify(e.sc0);if(o)return"sc0."+o}}if(e.sr0!=null&&e.hasOwnProperty("sr0")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.S2SessionResp0.verify(e.sr0);if(o)return"sr0."+o}}if(e.sc1!=null&&e.hasOwnProperty("sc1")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.S2SessionCmd1.verify(e.sc1);if(o)return"sc1."+o}}if(e.sr1!=null&&e.hasOwnProperty("sr1")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.S2SessionResp1.verify(e.sr1);if(o)return"sr1."+o}}return null},i.fromObject=function(e){if(e instanceof $root.Sec2Payload)return e;let r=new $root.Sec2Payload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"S2Session_Command0":case 0:r.msg=0;break;case"S2Session_Response0":case 1:r.msg=1;break;case"S2Session_Command1":case 2:r.msg=2;break;case"S2Session_Response1":case 3:r.msg=3;break}if(e.sc0!=null){if(typeof e.sc0!="object")throw TypeError(".Sec2Payload.sc0: object expected");r.sc0=$root.S2SessionCmd0.fromObject(e.sc0)}if(e.sr0!=null){if(typeof e.sr0!="object")throw TypeError(".Sec2Payload.sr0: object expected");r.sr0=$root.S2SessionResp0.fromObject(e.sr0)}if(e.sc1!=null){if(typeof e.sc1!="object")throw TypeError(".Sec2Payload.sc1: object expected");r.sc1=$root.S2SessionCmd1.fromObject(e.sc1)}if(e.sr1!=null){if(typeof e.sr1!="object")throw TypeError(".Sec2Payload.sr1: object expected");r.sr1=$root.S2SessionResp1.fromObject(e.sr1)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"S2Session_Command0":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.Sec2MsgType[e.msg]===void 0?e.msg:$root.Sec2MsgType[e.msg]:e.msg),e.sc0!=null&&e.hasOwnProperty("sc0")&&(o.sc0=$root.S2SessionCmd0.toObject(e.sc0,r),r.oneofs&&(o.payload="sc0")),e.sr0!=null&&e.hasOwnProperty("sr0")&&(o.sr0=$root.S2SessionResp0.toObject(e.sr0,r),r.oneofs&&(o.payload="sr0")),e.sc1!=null&&e.hasOwnProperty("sc1")&&(o.sc1=$root.S2SessionCmd1.toObject(e.sc1,r),r.oneofs&&(o.payload="sc1")),e.sr1!=null&&e.hasOwnProperty("sr1")&&(o.sr1=$root.S2SessionResp1.toObject(e.sr1,r),r.oneofs&&(o.payload="sr1")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/Sec2Payload"},i})();const SecSchemeVersion=$root.SecSchemeVersion=(()=>{const i={},n=Object.create(i);return n[i[0]="SecScheme0"]=0,n[i[1]="SecScheme1"]=1,n[i[2]="SecScheme2"]=2,n})(),SessionData=$root.SessionData=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.secVer=0,i.prototype.sec0=null,i.prototype.sec1=null,i.prototype.sec2=null;let n;return Object.defineProperty(i.prototype,"proto",{get:$util.oneOfGetter(n=["sec0","sec1","sec2"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.secVer!=null&&Object.hasOwnProperty.call(e,"secVer")&&r.uint32(16).int32(e.secVer),e.sec0!=null&&Object.hasOwnProperty.call(e,"sec0")&&$root.Sec0Payload.encode(e.sec0,r.uint32(82).fork()).ldelim(),e.sec1!=null&&Object.hasOwnProperty.call(e,"sec1")&&$root.Sec1Payload.encode(e.sec1,r.uint32(90).fork()).ldelim(),e.sec2!=null&&Object.hasOwnProperty.call(e,"sec2")&&$root.Sec2Payload.encode(e.sec2,r.uint32(98).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.SessionData;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 2:{c.secVer=e.int32();break}case 10:{c.sec0=$root.Sec0Payload.decode(e,e.uint32());break}case 11:{c.sec1=$root.Sec1Payload.decode(e,e.uint32());break}case 12:{c.sec2=$root.Sec2Payload.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.secVer!=null&&e.hasOwnProperty("secVer"))switch(e.secVer){default:return"secVer: enum value expected";case 0:case 1:case 2:break}if(e.sec0!=null&&e.hasOwnProperty("sec0")){r.proto=1;{let o=$root.Sec0Payload.verify(e.sec0);if(o)return"sec0."+o}}if(e.sec1!=null&&e.hasOwnProperty("sec1")){if(r.proto===1)return"proto: multiple values";r.proto=1;{let o=$root.Sec1Payload.verify(e.sec1);if(o)return"sec1."+o}}if(e.sec2!=null&&e.hasOwnProperty("sec2")){if(r.proto===1)return"proto: multiple values";r.proto=1;{let o=$root.Sec2Payload.verify(e.sec2);if(o)return"sec2."+o}}return null},i.fromObject=function(e){if(e instanceof $root.SessionData)return e;let r=new $root.SessionData;switch(e.secVer){default:if(typeof e.secVer=="number"){r.secVer=e.secVer;break}break;case"SecScheme0":case 0:r.secVer=0;break;case"SecScheme1":case 1:r.secVer=1;break;case"SecScheme2":case 2:r.secVer=2;break}if(e.sec0!=null){if(typeof e.sec0!="object")throw TypeError(".SessionData.sec0: object expected");r.sec0=$root.Sec0Payload.fromObject(e.sec0)}if(e.sec1!=null){if(typeof e.sec1!="object")throw TypeError(".SessionData.sec1: object expected");r.sec1=$root.Sec1Payload.fromObject(e.sec1)}if(e.sec2!=null){if(typeof e.sec2!="object")throw TypeError(".SessionData.sec2: object expected");r.sec2=$root.Sec2Payload.fromObject(e.sec2)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.secVer=r.enums===String?"SecScheme0":0),e.secVer!=null&&e.hasOwnProperty("secVer")&&(o.secVer=r.enums===String?$root.SecSchemeVersion[e.secVer]===void 0?e.secVer:$root.SecSchemeVersion[e.secVer]:e.secVer),e.sec0!=null&&e.hasOwnProperty("sec0")&&(o.sec0=$root.Sec0Payload.toObject(e.sec0,r),r.oneofs&&(o.proto="sec0")),e.sec1!=null&&e.hasOwnProperty("sec1")&&(o.sec1=$root.Sec1Payload.toObject(e.sec1,r),r.oneofs&&(o.proto="sec1")),e.sec2!=null&&e.hasOwnProperty("sec2")&&(o.sec2=$root.Sec2Payload.toObject(e.sec2,r),r.oneofs&&(o.proto="sec2")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/SessionData"},i})(),CmdGetStatus=$root.CmdGetStatus=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdGetStatus;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.CmdGetStatus?t:new $root.CmdGetStatus},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdGetStatus"},i})();$root.RespGetStatus=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.status=0,i.prototype.staState=0,i.prototype.failReason=null,i.prototype.connected=null;let n;return Object.defineProperty(i.prototype,"state",{get:$util.oneOfGetter(n=["failReason","connected"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&r.uint32(8).int32(e.status),e.staState!=null&&Object.hasOwnProperty.call(e,"staState")&&r.uint32(16).int32(e.staState),e.failReason!=null&&Object.hasOwnProperty.call(e,"failReason")&&r.uint32(80).int32(e.failReason),e.connected!=null&&Object.hasOwnProperty.call(e,"connected")&&$root.WifiConnectedState.encode(e.connected,r.uint32(90).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.RespGetStatus;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.status=e.int32();break}case 2:{c.staState=e.int32();break}case 10:{c.failReason=e.int32();break}case 11:{c.connected=$root.WifiConnectedState.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.status!=null&&e.hasOwnProperty("status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(e.staState!=null&&e.hasOwnProperty("staState"))switch(e.staState){default:return"staState: enum value expected";case 0:case 1:case 2:case 3:break}if(e.failReason!=null&&e.hasOwnProperty("failReason"))switch(r.state=1,e.failReason){default:return"failReason: enum value expected";case 0:case 1:break}if(e.connected!=null&&e.hasOwnProperty("connected")){if(r.state===1)return"state: multiple values";r.state=1;{let o=$root.WifiConnectedState.verify(e.connected);if(o)return"connected."+o}}return null},i.fromObject=function(e){if(e instanceof $root.RespGetStatus)return e;let r=new $root.RespGetStatus;switch(e.status){default:if(typeof e.status=="number"){r.status=e.status;break}break;case"Success":case 0:r.status=0;break;case"InvalidSecScheme":case 1:r.status=1;break;case"InvalidProto":case 2:r.status=2;break;case"TooManySessions":case 3:r.status=3;break;case"InvalidArgument":case 4:r.status=4;break;case"InternalError":case 5:r.status=5;break;case"CryptoError":case 6:r.status=6;break;case"InvalidSession":case 7:r.status=7;break}switch(e.staState){default:if(typeof e.staState=="number"){r.staState=e.staState;break}break;case"Connected":case 0:r.staState=0;break;case"Connecting":case 1:r.staState=1;break;case"Disconnected":case 2:r.staState=2;break;case"ConnectionFailed":case 3:r.staState=3;break}switch(e.failReason){default:if(typeof e.failReason=="number"){r.failReason=e.failReason;break}break;case"AuthError":case 0:r.failReason=0;break;case"NetworkNotFound":case 1:r.failReason=1;break}if(e.connected!=null){if(typeof e.connected!="object")throw TypeError(".RespGetStatus.connected: object expected");r.connected=$root.WifiConnectedState.fromObject(e.connected)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.status=r.enums===String?"Success":0,o.staState=r.enums===String?"Connected":0),e.status!=null&&e.hasOwnProperty("status")&&(o.status=r.enums===String?$root.Status[e.status]===void 0?e.status:$root.Status[e.status]:e.status),e.staState!=null&&e.hasOwnProperty("staState")&&(o.staState=r.enums===String?$root.WifiStationState[e.staState]===void 0?e.staState:$root.WifiStationState[e.staState]:e.staState),e.failReason!=null&&e.hasOwnProperty("failReason")&&(o.failReason=r.enums===String?$root.WifiConnectFailedReason[e.failReason]===void 0?e.failReason:$root.WifiConnectFailedReason[e.failReason]:e.failReason,r.oneofs&&(o.state="failReason")),e.connected!=null&&e.hasOwnProperty("connected")&&(o.connected=$root.WifiConnectedState.toObject(e.connected,r),r.oneofs&&(o.state="connected")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespGetStatus"},i})();const CmdSetConfig=$root.CmdSetConfig=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.ssid=$util.newBuffer([]),i.prototype.passphrase=$util.newBuffer([]),i.prototype.bssid=$util.newBuffer([]),i.prototype.channel=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.ssid!=null&&Object.hasOwnProperty.call(t,"ssid")&&e.uint32(10).bytes(t.ssid),t.passphrase!=null&&Object.hasOwnProperty.call(t,"passphrase")&&e.uint32(18).bytes(t.passphrase),t.bssid!=null&&Object.hasOwnProperty.call(t,"bssid")&&e.uint32(26).bytes(t.bssid),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(32).int32(t.channel),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdSetConfig;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.ssid=t.bytes();break}case 2:{s.passphrase=t.bytes();break}case 3:{s.bssid=t.bytes();break}case 4:{s.channel=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.ssid!=null&&t.hasOwnProperty("ssid")&&!(t.ssid&&typeof t.ssid.length=="number"||$util.isString(t.ssid))?"ssid: buffer expected":t.passphrase!=null&&t.hasOwnProperty("passphrase")&&!(t.passphrase&&typeof t.passphrase.length=="number"||$util.isString(t.passphrase))?"passphrase: buffer expected":t.bssid!=null&&t.hasOwnProperty("bssid")&&!(t.bssid&&typeof t.bssid.length=="number"||$util.isString(t.bssid))?"bssid: buffer expected":t.channel!=null&&t.hasOwnProperty("channel")&&!$util.isInteger(t.channel)?"channel: integer expected":null},i.fromObject=function(t){if(t instanceof $root.CmdSetConfig)return t;let e=new $root.CmdSetConfig;return t.ssid!=null&&(typeof t.ssid=="string"?$util.base64.decode(t.ssid,e.ssid=$util.newBuffer($util.base64.length(t.ssid)),0):t.ssid.length>=0&&(e.ssid=t.ssid)),t.passphrase!=null&&(typeof t.passphrase=="string"?$util.base64.decode(t.passphrase,e.passphrase=$util.newBuffer($util.base64.length(t.passphrase)),0):t.passphrase.length>=0&&(e.passphrase=t.passphrase)),t.bssid!=null&&(typeof t.bssid=="string"?$util.base64.decode(t.bssid,e.bssid=$util.newBuffer($util.base64.length(t.bssid)),0):t.bssid.length>=0&&(e.bssid=t.bssid)),t.channel!=null&&(e.channel=t.channel|0),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.ssid="":(r.ssid=[],e.bytes!==Array&&(r.ssid=$util.newBuffer(r.ssid))),e.bytes===String?r.passphrase="":(r.passphrase=[],e.bytes!==Array&&(r.passphrase=$util.newBuffer(r.passphrase))),e.bytes===String?r.bssid="":(r.bssid=[],e.bytes!==Array&&(r.bssid=$util.newBuffer(r.bssid))),r.channel=0),t.ssid!=null&&t.hasOwnProperty("ssid")&&(r.ssid=e.bytes===String?$util.base64.encode(t.ssid,0,t.ssid.length):e.bytes===Array?Array.prototype.slice.call(t.ssid):t.ssid),t.passphrase!=null&&t.hasOwnProperty("passphrase")&&(r.passphrase=e.bytes===String?$util.base64.encode(t.passphrase,0,t.passphrase.length):e.bytes===Array?Array.prototype.slice.call(t.passphrase):t.passphrase),t.bssid!=null&&t.hasOwnProperty("bssid")&&(r.bssid=e.bytes===String?$util.base64.encode(t.bssid,0,t.bssid.length):e.bytes===Array?Array.prototype.slice.call(t.bssid):t.bssid),t.channel!=null&&t.hasOwnProperty("channel")&&(r.channel=t.channel),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdSetConfig"},i})();$root.RespSetConfig=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespSetConfig;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},i.fromObject=function(t){if(t instanceof $root.RespSetConfig)return t;let e=new $root.RespSetConfig;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespSetConfig"},i})();const CmdApplyConfig=$root.CmdApplyConfig=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdApplyConfig;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.CmdApplyConfig?t:new $root.CmdApplyConfig},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdApplyConfig"},i})();$root.RespApplyConfig=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.status=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&e.uint32(8).int32(t.status),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespApplyConfig;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.status=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.status!=null&&t.hasOwnProperty("status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},i.fromObject=function(t){if(t instanceof $root.RespApplyConfig)return t;let e=new $root.RespApplyConfig;switch(t.status){default:if(typeof t.status=="number"){e.status=t.status;break}break;case"Success":case 0:e.status=0;break;case"InvalidSecScheme":case 1:e.status=1;break;case"InvalidProto":case 2:e.status=2;break;case"TooManySessions":case 3:e.status=3;break;case"InvalidArgument":case 4:e.status=4;break;case"InternalError":case 5:e.status=5;break;case"CryptoError":case 6:e.status=6;break;case"InvalidSession":case 7:e.status=7;break}return e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.status=e.enums===String?"Success":0),t.status!=null&&t.hasOwnProperty("status")&&(r.status=e.enums===String?$root.Status[t.status]===void 0?t.status:$root.Status[t.status]:t.status),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespApplyConfig"},i})();const WiFiConfigMsgType=$root.WiFiConfigMsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="TypeCmdGetStatus"]=0,n[i[1]="TypeRespGetStatus"]=1,n[i[2]="TypeCmdSetConfig"]=2,n[i[3]="TypeRespSetConfig"]=3,n[i[4]="TypeCmdApplyConfig"]=4,n[i[5]="TypeRespApplyConfig"]=5,n})(),WiFiConfigPayload=$root.WiFiConfigPayload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.cmdGetStatus=null,i.prototype.respGetStatus=null,i.prototype.cmdSetConfig=null,i.prototype.respSetConfig=null,i.prototype.cmdApplyConfig=null,i.prototype.respApplyConfig=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["cmdGetStatus","respGetStatus","cmdSetConfig","respSetConfig","cmdApplyConfig","respApplyConfig"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.cmdGetStatus!=null&&Object.hasOwnProperty.call(e,"cmdGetStatus")&&$root.CmdGetStatus.encode(e.cmdGetStatus,r.uint32(82).fork()).ldelim(),e.respGetStatus!=null&&Object.hasOwnProperty.call(e,"respGetStatus")&&$root.RespGetStatus.encode(e.respGetStatus,r.uint32(90).fork()).ldelim(),e.cmdSetConfig!=null&&Object.hasOwnProperty.call(e,"cmdSetConfig")&&$root.CmdSetConfig.encode(e.cmdSetConfig,r.uint32(98).fork()).ldelim(),e.respSetConfig!=null&&Object.hasOwnProperty.call(e,"respSetConfig")&&$root.RespSetConfig.encode(e.respSetConfig,r.uint32(106).fork()).ldelim(),e.cmdApplyConfig!=null&&Object.hasOwnProperty.call(e,"cmdApplyConfig")&&$root.CmdApplyConfig.encode(e.cmdApplyConfig,r.uint32(114).fork()).ldelim(),e.respApplyConfig!=null&&Object.hasOwnProperty.call(e,"respApplyConfig")&&$root.RespApplyConfig.encode(e.respApplyConfig,r.uint32(122).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.WiFiConfigPayload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 10:{c.cmdGetStatus=$root.CmdGetStatus.decode(e,e.uint32());break}case 11:{c.respGetStatus=$root.RespGetStatus.decode(e,e.uint32());break}case 12:{c.cmdSetConfig=$root.CmdSetConfig.decode(e,e.uint32());break}case 13:{c.respSetConfig=$root.RespSetConfig.decode(e,e.uint32());break}case 14:{c.cmdApplyConfig=$root.CmdApplyConfig.decode(e,e.uint32());break}case 15:{c.respApplyConfig=$root.RespApplyConfig.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:break}if(e.cmdGetStatus!=null&&e.hasOwnProperty("cmdGetStatus")){r.payload=1;{let o=$root.CmdGetStatus.verify(e.cmdGetStatus);if(o)return"cmdGetStatus."+o}}if(e.respGetStatus!=null&&e.hasOwnProperty("respGetStatus")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespGetStatus.verify(e.respGetStatus);if(o)return"respGetStatus."+o}}if(e.cmdSetConfig!=null&&e.hasOwnProperty("cmdSetConfig")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.CmdSetConfig.verify(e.cmdSetConfig);if(o)return"cmdSetConfig."+o}}if(e.respSetConfig!=null&&e.hasOwnProperty("respSetConfig")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespSetConfig.verify(e.respSetConfig);if(o)return"respSetConfig."+o}}if(e.cmdApplyConfig!=null&&e.hasOwnProperty("cmdApplyConfig")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.CmdApplyConfig.verify(e.cmdApplyConfig);if(o)return"cmdApplyConfig."+o}}if(e.respApplyConfig!=null&&e.hasOwnProperty("respApplyConfig")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespApplyConfig.verify(e.respApplyConfig);if(o)return"respApplyConfig."+o}}return null},i.fromObject=function(e){if(e instanceof $root.WiFiConfigPayload)return e;let r=new $root.WiFiConfigPayload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"TypeCmdGetStatus":case 0:r.msg=0;break;case"TypeRespGetStatus":case 1:r.msg=1;break;case"TypeCmdSetConfig":case 2:r.msg=2;break;case"TypeRespSetConfig":case 3:r.msg=3;break;case"TypeCmdApplyConfig":case 4:r.msg=4;break;case"TypeRespApplyConfig":case 5:r.msg=5;break}if(e.cmdGetStatus!=null){if(typeof e.cmdGetStatus!="object")throw TypeError(".WiFiConfigPayload.cmdGetStatus: object expected");r.cmdGetStatus=$root.CmdGetStatus.fromObject(e.cmdGetStatus)}if(e.respGetStatus!=null){if(typeof e.respGetStatus!="object")throw TypeError(".WiFiConfigPayload.respGetStatus: object expected");r.respGetStatus=$root.RespGetStatus.fromObject(e.respGetStatus)}if(e.cmdSetConfig!=null){if(typeof e.cmdSetConfig!="object")throw TypeError(".WiFiConfigPayload.cmdSetConfig: object expected");r.cmdSetConfig=$root.CmdSetConfig.fromObject(e.cmdSetConfig)}if(e.respSetConfig!=null){if(typeof e.respSetConfig!="object")throw TypeError(".WiFiConfigPayload.respSetConfig: object expected");r.respSetConfig=$root.RespSetConfig.fromObject(e.respSetConfig)}if(e.cmdApplyConfig!=null){if(typeof e.cmdApplyConfig!="object")throw TypeError(".WiFiConfigPayload.cmdApplyConfig: object expected");r.cmdApplyConfig=$root.CmdApplyConfig.fromObject(e.cmdApplyConfig)}if(e.respApplyConfig!=null){if(typeof e.respApplyConfig!="object")throw TypeError(".WiFiConfigPayload.respApplyConfig: object expected");r.respApplyConfig=$root.RespApplyConfig.fromObject(e.respApplyConfig)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"TypeCmdGetStatus":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.WiFiConfigMsgType[e.msg]===void 0?e.msg:$root.WiFiConfigMsgType[e.msg]:e.msg),e.cmdGetStatus!=null&&e.hasOwnProperty("cmdGetStatus")&&(o.cmdGetStatus=$root.CmdGetStatus.toObject(e.cmdGetStatus,r),r.oneofs&&(o.payload="cmdGetStatus")),e.respGetStatus!=null&&e.hasOwnProperty("respGetStatus")&&(o.respGetStatus=$root.RespGetStatus.toObject(e.respGetStatus,r),r.oneofs&&(o.payload="respGetStatus")),e.cmdSetConfig!=null&&e.hasOwnProperty("cmdSetConfig")&&(o.cmdSetConfig=$root.CmdSetConfig.toObject(e.cmdSetConfig,r),r.oneofs&&(o.payload="cmdSetConfig")),e.respSetConfig!=null&&e.hasOwnProperty("respSetConfig")&&(o.respSetConfig=$root.RespSetConfig.toObject(e.respSetConfig,r),r.oneofs&&(o.payload="respSetConfig")),e.cmdApplyConfig!=null&&e.hasOwnProperty("cmdApplyConfig")&&(o.cmdApplyConfig=$root.CmdApplyConfig.toObject(e.cmdApplyConfig,r),r.oneofs&&(o.payload="cmdApplyConfig")),e.respApplyConfig!=null&&e.hasOwnProperty("respApplyConfig")&&(o.respApplyConfig=$root.RespApplyConfig.toObject(e.respApplyConfig,r),r.oneofs&&(o.payload="respApplyConfig")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/WiFiConfigPayload"},i})(),WifiStationState=$root.WifiStationState=(()=>{const i={},n=Object.create(i);return n[i[0]="Connected"]=0,n[i[1]="Connecting"]=1,n[i[2]="Disconnected"]=2,n[i[3]="ConnectionFailed"]=3,n})(),WifiConnectFailedReason=$root.WifiConnectFailedReason=(()=>{const i={},n=Object.create(i);return n[i[0]="AuthError"]=0,n[i[1]="NetworkNotFound"]=1,n})(),WifiAuthMode=$root.WifiAuthMode=(()=>{const i={},n=Object.create(i);return n[i[0]="Open"]=0,n[i[1]="WEP"]=1,n[i[2]="WPA_PSK"]=2,n[i[3]="WPA2_PSK"]=3,n[i[4]="WPA_WPA2_PSK"]=4,n[i[5]="WPA2_ENTERPRISE"]=5,n[i[6]="WPA3_PSK"]=6,n[i[7]="WPA2_WPA3_PSK"]=7,n})();$root.WifiConnectedState=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.ip4Addr="",i.prototype.authMode=0,i.prototype.ssid=$util.newBuffer([]),i.prototype.bssid=$util.newBuffer([]),i.prototype.channel=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.ip4Addr!=null&&Object.hasOwnProperty.call(t,"ip4Addr")&&e.uint32(10).string(t.ip4Addr),t.authMode!=null&&Object.hasOwnProperty.call(t,"authMode")&&e.uint32(16).int32(t.authMode),t.ssid!=null&&Object.hasOwnProperty.call(t,"ssid")&&e.uint32(26).bytes(t.ssid),t.bssid!=null&&Object.hasOwnProperty.call(t,"bssid")&&e.uint32(34).bytes(t.bssid),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(40).int32(t.channel),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.WifiConnectedState;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.ip4Addr=t.string();break}case 2:{s.authMode=t.int32();break}case 3:{s.ssid=t.bytes();break}case 4:{s.bssid=t.bytes();break}case 5:{s.channel=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.ip4Addr!=null&&t.hasOwnProperty("ip4Addr")&&!$util.isString(t.ip4Addr))return"ip4Addr: string expected";if(t.authMode!=null&&t.hasOwnProperty("authMode"))switch(t.authMode){default:return"authMode: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return t.ssid!=null&&t.hasOwnProperty("ssid")&&!(t.ssid&&typeof t.ssid.length=="number"||$util.isString(t.ssid))?"ssid: buffer expected":t.bssid!=null&&t.hasOwnProperty("bssid")&&!(t.bssid&&typeof t.bssid.length=="number"||$util.isString(t.bssid))?"bssid: buffer expected":t.channel!=null&&t.hasOwnProperty("channel")&&!$util.isInteger(t.channel)?"channel: integer expected":null},i.fromObject=function(t){if(t instanceof $root.WifiConnectedState)return t;let e=new $root.WifiConnectedState;switch(t.ip4Addr!=null&&(e.ip4Addr=String(t.ip4Addr)),t.authMode){default:if(typeof t.authMode=="number"){e.authMode=t.authMode;break}break;case"Open":case 0:e.authMode=0;break;case"WEP":case 1:e.authMode=1;break;case"WPA_PSK":case 2:e.authMode=2;break;case"WPA2_PSK":case 3:e.authMode=3;break;case"WPA_WPA2_PSK":case 4:e.authMode=4;break;case"WPA2_ENTERPRISE":case 5:e.authMode=5;break;case"WPA3_PSK":case 6:e.authMode=6;break;case"WPA2_WPA3_PSK":case 7:e.authMode=7;break}return t.ssid!=null&&(typeof t.ssid=="string"?$util.base64.decode(t.ssid,e.ssid=$util.newBuffer($util.base64.length(t.ssid)),0):t.ssid.length>=0&&(e.ssid=t.ssid)),t.bssid!=null&&(typeof t.bssid=="string"?$util.base64.decode(t.bssid,e.bssid=$util.newBuffer($util.base64.length(t.bssid)),0):t.bssid.length>=0&&(e.bssid=t.bssid)),t.channel!=null&&(e.channel=t.channel|0),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.ip4Addr="",r.authMode=e.enums===String?"Open":0,e.bytes===String?r.ssid="":(r.ssid=[],e.bytes!==Array&&(r.ssid=$util.newBuffer(r.ssid))),e.bytes===String?r.bssid="":(r.bssid=[],e.bytes!==Array&&(r.bssid=$util.newBuffer(r.bssid))),r.channel=0),t.ip4Addr!=null&&t.hasOwnProperty("ip4Addr")&&(r.ip4Addr=t.ip4Addr),t.authMode!=null&&t.hasOwnProperty("authMode")&&(r.authMode=e.enums===String?$root.WifiAuthMode[t.authMode]===void 0?t.authMode:$root.WifiAuthMode[t.authMode]:t.authMode),t.ssid!=null&&t.hasOwnProperty("ssid")&&(r.ssid=e.bytes===String?$util.base64.encode(t.ssid,0,t.ssid.length):e.bytes===Array?Array.prototype.slice.call(t.ssid):t.ssid),t.bssid!=null&&t.hasOwnProperty("bssid")&&(r.bssid=e.bytes===String?$util.base64.encode(t.bssid,0,t.bssid.length):e.bytes===Array?Array.prototype.slice.call(t.bssid):t.bssid),t.channel!=null&&t.hasOwnProperty("channel")&&(r.channel=t.channel),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/WifiConnectedState"},i})();$root.CmdCtrlReset=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdCtrlReset;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.CmdCtrlReset?t:new $root.CmdCtrlReset},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdCtrlReset"},i})();$root.RespCtrlReset=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespCtrlReset;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.RespCtrlReset?t:new $root.RespCtrlReset},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespCtrlReset"},i})();$root.CmdCtrlReprov=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdCtrlReprov;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.CmdCtrlReprov?t:new $root.CmdCtrlReprov},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdCtrlReprov"},i})();$root.RespCtrlReprov=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespCtrlReprov;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.RespCtrlReprov?t:new $root.RespCtrlReprov},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespCtrlReprov"},i})();$root.WiFiCtrlMsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="TypeCtrlReserved"]=0,n[i[1]="TypeCmdCtrlReset"]=1,n[i[2]="TypeRespCtrlReset"]=2,n[i[3]="TypeCmdCtrlReprov"]=3,n[i[4]="TypeRespCtrlReprov"]=4,n})();$root.WiFiCtrlPayload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.status=0,i.prototype.cmdCtrlReset=null,i.prototype.respCtrlReset=null,i.prototype.cmdCtrlReprov=null,i.prototype.respCtrlReprov=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["cmdCtrlReset","respCtrlReset","cmdCtrlReprov","respCtrlReprov"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&r.uint32(16).int32(e.status),e.cmdCtrlReset!=null&&Object.hasOwnProperty.call(e,"cmdCtrlReset")&&$root.CmdCtrlReset.encode(e.cmdCtrlReset,r.uint32(90).fork()).ldelim(),e.respCtrlReset!=null&&Object.hasOwnProperty.call(e,"respCtrlReset")&&$root.RespCtrlReset.encode(e.respCtrlReset,r.uint32(98).fork()).ldelim(),e.cmdCtrlReprov!=null&&Object.hasOwnProperty.call(e,"cmdCtrlReprov")&&$root.CmdCtrlReprov.encode(e.cmdCtrlReprov,r.uint32(106).fork()).ldelim(),e.respCtrlReprov!=null&&Object.hasOwnProperty.call(e,"respCtrlReprov")&&$root.RespCtrlReprov.encode(e.respCtrlReprov,r.uint32(114).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.WiFiCtrlPayload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 2:{c.status=e.int32();break}case 11:{c.cmdCtrlReset=$root.CmdCtrlReset.decode(e,e.uint32());break}case 12:{c.respCtrlReset=$root.RespCtrlReset.decode(e,e.uint32());break}case 13:{c.cmdCtrlReprov=$root.CmdCtrlReprov.decode(e,e.uint32());break}case 14:{c.respCtrlReprov=$root.RespCtrlReprov.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:break}if(e.status!=null&&e.hasOwnProperty("status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(e.cmdCtrlReset!=null&&e.hasOwnProperty("cmdCtrlReset")){r.payload=1;{let o=$root.CmdCtrlReset.verify(e.cmdCtrlReset);if(o)return"cmdCtrlReset."+o}}if(e.respCtrlReset!=null&&e.hasOwnProperty("respCtrlReset")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespCtrlReset.verify(e.respCtrlReset);if(o)return"respCtrlReset."+o}}if(e.cmdCtrlReprov!=null&&e.hasOwnProperty("cmdCtrlReprov")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.CmdCtrlReprov.verify(e.cmdCtrlReprov);if(o)return"cmdCtrlReprov."+o}}if(e.respCtrlReprov!=null&&e.hasOwnProperty("respCtrlReprov")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespCtrlReprov.verify(e.respCtrlReprov);if(o)return"respCtrlReprov."+o}}return null},i.fromObject=function(e){if(e instanceof $root.WiFiCtrlPayload)return e;let r=new $root.WiFiCtrlPayload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"TypeCtrlReserved":case 0:r.msg=0;break;case"TypeCmdCtrlReset":case 1:r.msg=1;break;case"TypeRespCtrlReset":case 2:r.msg=2;break;case"TypeCmdCtrlReprov":case 3:r.msg=3;break;case"TypeRespCtrlReprov":case 4:r.msg=4;break}switch(e.status){default:if(typeof e.status=="number"){r.status=e.status;break}break;case"Success":case 0:r.status=0;break;case"InvalidSecScheme":case 1:r.status=1;break;case"InvalidProto":case 2:r.status=2;break;case"TooManySessions":case 3:r.status=3;break;case"InvalidArgument":case 4:r.status=4;break;case"InternalError":case 5:r.status=5;break;case"CryptoError":case 6:r.status=6;break;case"InvalidSession":case 7:r.status=7;break}if(e.cmdCtrlReset!=null){if(typeof e.cmdCtrlReset!="object")throw TypeError(".WiFiCtrlPayload.cmdCtrlReset: object expected");r.cmdCtrlReset=$root.CmdCtrlReset.fromObject(e.cmdCtrlReset)}if(e.respCtrlReset!=null){if(typeof e.respCtrlReset!="object")throw TypeError(".WiFiCtrlPayload.respCtrlReset: object expected");r.respCtrlReset=$root.RespCtrlReset.fromObject(e.respCtrlReset)}if(e.cmdCtrlReprov!=null){if(typeof e.cmdCtrlReprov!="object")throw TypeError(".WiFiCtrlPayload.cmdCtrlReprov: object expected");r.cmdCtrlReprov=$root.CmdCtrlReprov.fromObject(e.cmdCtrlReprov)}if(e.respCtrlReprov!=null){if(typeof e.respCtrlReprov!="object")throw TypeError(".WiFiCtrlPayload.respCtrlReprov: object expected");r.respCtrlReprov=$root.RespCtrlReprov.fromObject(e.respCtrlReprov)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"TypeCtrlReserved":0,o.status=r.enums===String?"Success":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.WiFiCtrlMsgType[e.msg]===void 0?e.msg:$root.WiFiCtrlMsgType[e.msg]:e.msg),e.status!=null&&e.hasOwnProperty("status")&&(o.status=r.enums===String?$root.Status[e.status]===void 0?e.status:$root.Status[e.status]:e.status),e.cmdCtrlReset!=null&&e.hasOwnProperty("cmdCtrlReset")&&(o.cmdCtrlReset=$root.CmdCtrlReset.toObject(e.cmdCtrlReset,r),r.oneofs&&(o.payload="cmdCtrlReset")),e.respCtrlReset!=null&&e.hasOwnProperty("respCtrlReset")&&(o.respCtrlReset=$root.RespCtrlReset.toObject(e.respCtrlReset,r),r.oneofs&&(o.payload="respCtrlReset")),e.cmdCtrlReprov!=null&&e.hasOwnProperty("cmdCtrlReprov")&&(o.cmdCtrlReprov=$root.CmdCtrlReprov.toObject(e.cmdCtrlReprov,r),r.oneofs&&(o.payload="cmdCtrlReprov")),e.respCtrlReprov!=null&&e.hasOwnProperty("respCtrlReprov")&&(o.respCtrlReprov=$root.RespCtrlReprov.toObject(e.respCtrlReprov,r),r.oneofs&&(o.payload="respCtrlReprov")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/WiFiCtrlPayload"},i})();const CmdScanStart=$root.CmdScanStart=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.blocking=!1,i.prototype.passive=!1,i.prototype.groupChannels=0,i.prototype.periodMs=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.blocking!=null&&Object.hasOwnProperty.call(t,"blocking")&&e.uint32(8).bool(t.blocking),t.passive!=null&&Object.hasOwnProperty.call(t,"passive")&&e.uint32(16).bool(t.passive),t.groupChannels!=null&&Object.hasOwnProperty.call(t,"groupChannels")&&e.uint32(24).uint32(t.groupChannels),t.periodMs!=null&&Object.hasOwnProperty.call(t,"periodMs")&&e.uint32(32).uint32(t.periodMs),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdScanStart;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.blocking=t.bool();break}case 2:{s.passive=t.bool();break}case 3:{s.groupChannels=t.uint32();break}case 4:{s.periodMs=t.uint32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.blocking!=null&&t.hasOwnProperty("blocking")&&typeof t.blocking!="boolean"?"blocking: boolean expected":t.passive!=null&&t.hasOwnProperty("passive")&&typeof t.passive!="boolean"?"passive: boolean expected":t.groupChannels!=null&&t.hasOwnProperty("groupChannels")&&!$util.isInteger(t.groupChannels)?"groupChannels: integer expected":t.periodMs!=null&&t.hasOwnProperty("periodMs")&&!$util.isInteger(t.periodMs)?"periodMs: integer expected":null},i.fromObject=function(t){if(t instanceof $root.CmdScanStart)return t;let e=new $root.CmdScanStart;return t.blocking!=null&&(e.blocking=!!t.blocking),t.passive!=null&&(e.passive=!!t.passive),t.groupChannels!=null&&(e.groupChannels=t.groupChannels>>>0),t.periodMs!=null&&(e.periodMs=t.periodMs>>>0),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.blocking=!1,r.passive=!1,r.groupChannels=0,r.periodMs=0),t.blocking!=null&&t.hasOwnProperty("blocking")&&(r.blocking=t.blocking),t.passive!=null&&t.hasOwnProperty("passive")&&(r.passive=t.passive),t.groupChannels!=null&&t.hasOwnProperty("groupChannels")&&(r.groupChannels=t.groupChannels),t.periodMs!=null&&t.hasOwnProperty("periodMs")&&(r.periodMs=t.periodMs),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdScanStart"},i})();$root.RespScanStart=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespScanStart;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.RespScanStart?t:new $root.RespScanStart},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespScanStart"},i})();const CmdScanStatus=$root.CmdScanStatus=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdScanStatus;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":null},i.fromObject=function(t){return t instanceof $root.CmdScanStatus?t:new $root.CmdScanStatus},i.toObject=function(){return{}},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdScanStatus"},i})();$root.RespScanStatus=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.scanFinished=!1,i.prototype.resultCount=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.scanFinished!=null&&Object.hasOwnProperty.call(t,"scanFinished")&&e.uint32(8).bool(t.scanFinished),t.resultCount!=null&&Object.hasOwnProperty.call(t,"resultCount")&&e.uint32(16).uint32(t.resultCount),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespScanStatus;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.scanFinished=t.bool();break}case 2:{s.resultCount=t.uint32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.scanFinished!=null&&t.hasOwnProperty("scanFinished")&&typeof t.scanFinished!="boolean"?"scanFinished: boolean expected":t.resultCount!=null&&t.hasOwnProperty("resultCount")&&!$util.isInteger(t.resultCount)?"resultCount: integer expected":null},i.fromObject=function(t){if(t instanceof $root.RespScanStatus)return t;let e=new $root.RespScanStatus;return t.scanFinished!=null&&(e.scanFinished=!!t.scanFinished),t.resultCount!=null&&(e.resultCount=t.resultCount>>>0),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.scanFinished=!1,r.resultCount=0),t.scanFinished!=null&&t.hasOwnProperty("scanFinished")&&(r.scanFinished=t.scanFinished),t.resultCount!=null&&t.hasOwnProperty("resultCount")&&(r.resultCount=t.resultCount),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespScanStatus"},i})();const CmdScanResult=$root.CmdScanResult=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.startIndex=0,i.prototype.count=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.startIndex!=null&&Object.hasOwnProperty.call(t,"startIndex")&&e.uint32(8).uint32(t.startIndex),t.count!=null&&Object.hasOwnProperty.call(t,"count")&&e.uint32(16).uint32(t.count),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.CmdScanResult;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.startIndex=t.uint32();break}case 2:{s.count=t.uint32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){return typeof t!="object"||t===null?"object expected":t.startIndex!=null&&t.hasOwnProperty("startIndex")&&!$util.isInteger(t.startIndex)?"startIndex: integer expected":t.count!=null&&t.hasOwnProperty("count")&&!$util.isInteger(t.count)?"count: integer expected":null},i.fromObject=function(t){if(t instanceof $root.CmdScanResult)return t;let e=new $root.CmdScanResult;return t.startIndex!=null&&(e.startIndex=t.startIndex>>>0),t.count!=null&&(e.count=t.count>>>0),e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.startIndex=0,r.count=0),t.startIndex!=null&&t.hasOwnProperty("startIndex")&&(r.startIndex=t.startIndex),t.count!=null&&t.hasOwnProperty("count")&&(r.count=t.count),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/CmdScanResult"},i})();$root.WiFiScanResult=(()=>{function i(n){if(n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.ssid=$util.newBuffer([]),i.prototype.channel=0,i.prototype.rssi=0,i.prototype.bssid=$util.newBuffer([]),i.prototype.auth=0,i.create=function(t){return new i(t)},i.encode=function(t,e){return e||(e=$Writer.create()),t.ssid!=null&&Object.hasOwnProperty.call(t,"ssid")&&e.uint32(10).bytes(t.ssid),t.channel!=null&&Object.hasOwnProperty.call(t,"channel")&&e.uint32(16).uint32(t.channel),t.rssi!=null&&Object.hasOwnProperty.call(t,"rssi")&&e.uint32(24).int32(t.rssi),t.bssid!=null&&Object.hasOwnProperty.call(t,"bssid")&&e.uint32(34).bytes(t.bssid),t.auth!=null&&Object.hasOwnProperty.call(t,"auth")&&e.uint32(40).int32(t.auth),e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.WiFiScanResult;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.ssid=t.bytes();break}case 2:{s.channel=t.uint32();break}case 3:{s.rssi=t.int32();break}case 4:{s.bssid=t.bytes();break}case 5:{s.auth=t.int32();break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.ssid!=null&&t.hasOwnProperty("ssid")&&!(t.ssid&&typeof t.ssid.length=="number"||$util.isString(t.ssid)))return"ssid: buffer expected";if(t.channel!=null&&t.hasOwnProperty("channel")&&!$util.isInteger(t.channel))return"channel: integer expected";if(t.rssi!=null&&t.hasOwnProperty("rssi")&&!$util.isInteger(t.rssi))return"rssi: integer expected";if(t.bssid!=null&&t.hasOwnProperty("bssid")&&!(t.bssid&&typeof t.bssid.length=="number"||$util.isString(t.bssid)))return"bssid: buffer expected";if(t.auth!=null&&t.hasOwnProperty("auth"))switch(t.auth){default:return"auth: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},i.fromObject=function(t){if(t instanceof $root.WiFiScanResult)return t;let e=new $root.WiFiScanResult;switch(t.ssid!=null&&(typeof t.ssid=="string"?$util.base64.decode(t.ssid,e.ssid=$util.newBuffer($util.base64.length(t.ssid)),0):t.ssid.length>=0&&(e.ssid=t.ssid)),t.channel!=null&&(e.channel=t.channel>>>0),t.rssi!=null&&(e.rssi=t.rssi|0),t.bssid!=null&&(typeof t.bssid=="string"?$util.base64.decode(t.bssid,e.bssid=$util.newBuffer($util.base64.length(t.bssid)),0):t.bssid.length>=0&&(e.bssid=t.bssid)),t.auth){default:if(typeof t.auth=="number"){e.auth=t.auth;break}break;case"Open":case 0:e.auth=0;break;case"WEP":case 1:e.auth=1;break;case"WPA_PSK":case 2:e.auth=2;break;case"WPA2_PSK":case 3:e.auth=3;break;case"WPA_WPA2_PSK":case 4:e.auth=4;break;case"WPA2_ENTERPRISE":case 5:e.auth=5;break;case"WPA3_PSK":case 6:e.auth=6;break;case"WPA2_WPA3_PSK":case 7:e.auth=7;break}return e},i.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(e.bytes===String?r.ssid="":(r.ssid=[],e.bytes!==Array&&(r.ssid=$util.newBuffer(r.ssid))),r.channel=0,r.rssi=0,e.bytes===String?r.bssid="":(r.bssid=[],e.bytes!==Array&&(r.bssid=$util.newBuffer(r.bssid))),r.auth=e.enums===String?"Open":0),t.ssid!=null&&t.hasOwnProperty("ssid")&&(r.ssid=e.bytes===String?$util.base64.encode(t.ssid,0,t.ssid.length):e.bytes===Array?Array.prototype.slice.call(t.ssid):t.ssid),t.channel!=null&&t.hasOwnProperty("channel")&&(r.channel=t.channel),t.rssi!=null&&t.hasOwnProperty("rssi")&&(r.rssi=t.rssi),t.bssid!=null&&t.hasOwnProperty("bssid")&&(r.bssid=e.bytes===String?$util.base64.encode(t.bssid,0,t.bssid.length):e.bytes===Array?Array.prototype.slice.call(t.bssid):t.bssid),t.auth!=null&&t.hasOwnProperty("auth")&&(r.auth=e.enums===String?$root.WifiAuthMode[t.auth]===void 0?t.auth:$root.WifiAuthMode[t.auth]:t.auth),r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/WiFiScanResult"},i})();$root.RespScanResult=(()=>{function i(n){if(this.entries=[],n)for(let t=Object.keys(n),e=0;e<t.length;++e)n[t[e]]!=null&&(this[t[e]]=n[t[e]])}return i.prototype.entries=$util.emptyArray,i.create=function(t){return new i(t)},i.encode=function(t,e){if(e||(e=$Writer.create()),t.entries!=null&&t.entries.length)for(let r=0;r<t.entries.length;++r)$root.WiFiScanResult.encode(t.entries[r],e.uint32(10).fork()).ldelim();return e},i.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},i.decode=function(t,e,r){t instanceof $Reader||(t=$Reader.create(t));let o=e===void 0?t.len:t.pos+e,s=new $root.RespScanResult;for(;t.pos<o;){let c=t.uint32();if(c===r)break;switch(c>>>3){case 1:{s.entries&&s.entries.length||(s.entries=[]),s.entries.push($root.WiFiScanResult.decode(t,t.uint32()));break}default:t.skipType(c&7);break}}return s},i.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},i.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.entries!=null&&t.hasOwnProperty("entries")){if(!Array.isArray(t.entries))return"entries: array expected";for(let e=0;e<t.entries.length;++e){let r=$root.WiFiScanResult.verify(t.entries[e]);if(r)return"entries."+r}}return null},i.fromObject=function(t){if(t instanceof $root.RespScanResult)return t;let e=new $root.RespScanResult;if(t.entries){if(!Array.isArray(t.entries))throw TypeError(".RespScanResult.entries: array expected");e.entries=[];for(let r=0;r<t.entries.length;++r){if(typeof t.entries[r]!="object")throw TypeError(".RespScanResult.entries: object expected");e.entries[r]=$root.WiFiScanResult.fromObject(t.entries[r])}}return e},i.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.entries=[]),t.entries&&t.entries.length){r.entries=[];for(let o=0;o<t.entries.length;++o)r.entries[o]=$root.WiFiScanResult.toObject(t.entries[o],e)}return r},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespScanResult"},i})();const WiFiScanMsgType=$root.WiFiScanMsgType=(()=>{const i={},n=Object.create(i);return n[i[0]="TypeCmdScanStart"]=0,n[i[1]="TypeRespScanStart"]=1,n[i[2]="TypeCmdScanStatus"]=2,n[i[3]="TypeRespScanStatus"]=3,n[i[4]="TypeCmdScanResult"]=4,n[i[5]="TypeRespScanResult"]=5,n})(),WiFiScanPayload=$root.WiFiScanPayload=(()=>{function i(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)t[e[r]]!=null&&(this[e[r]]=t[e[r]])}i.prototype.msg=0,i.prototype.status=0,i.prototype.cmdScanStart=null,i.prototype.respScanStart=null,i.prototype.cmdScanStatus=null,i.prototype.respScanStatus=null,i.prototype.cmdScanResult=null,i.prototype.respScanResult=null;let n;return Object.defineProperty(i.prototype,"payload",{get:$util.oneOfGetter(n=["cmdScanStart","respScanStart","cmdScanStatus","respScanStatus","cmdScanResult","respScanResult"]),set:$util.oneOfSetter(n)}),i.create=function(e){return new i(e)},i.encode=function(e,r){return r||(r=$Writer.create()),e.msg!=null&&Object.hasOwnProperty.call(e,"msg")&&r.uint32(8).int32(e.msg),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&r.uint32(16).int32(e.status),e.cmdScanStart!=null&&Object.hasOwnProperty.call(e,"cmdScanStart")&&$root.CmdScanStart.encode(e.cmdScanStart,r.uint32(82).fork()).ldelim(),e.respScanStart!=null&&Object.hasOwnProperty.call(e,"respScanStart")&&$root.RespScanStart.encode(e.respScanStart,r.uint32(90).fork()).ldelim(),e.cmdScanStatus!=null&&Object.hasOwnProperty.call(e,"cmdScanStatus")&&$root.CmdScanStatus.encode(e.cmdScanStatus,r.uint32(98).fork()).ldelim(),e.respScanStatus!=null&&Object.hasOwnProperty.call(e,"respScanStatus")&&$root.RespScanStatus.encode(e.respScanStatus,r.uint32(106).fork()).ldelim(),e.cmdScanResult!=null&&Object.hasOwnProperty.call(e,"cmdScanResult")&&$root.CmdScanResult.encode(e.cmdScanResult,r.uint32(114).fork()).ldelim(),e.respScanResult!=null&&Object.hasOwnProperty.call(e,"respScanResult")&&$root.RespScanResult.encode(e.respScanResult,r.uint32(122).fork()).ldelim(),r},i.encodeDelimited=function(e,r){return this.encode(e,r).ldelim()},i.decode=function(e,r,o){e instanceof $Reader||(e=$Reader.create(e));let s=r===void 0?e.len:e.pos+r,c=new $root.WiFiScanPayload;for(;e.pos<s;){let u=e.uint32();if(u===o)break;switch(u>>>3){case 1:{c.msg=e.int32();break}case 2:{c.status=e.int32();break}case 10:{c.cmdScanStart=$root.CmdScanStart.decode(e,e.uint32());break}case 11:{c.respScanStart=$root.RespScanStart.decode(e,e.uint32());break}case 12:{c.cmdScanStatus=$root.CmdScanStatus.decode(e,e.uint32());break}case 13:{c.respScanStatus=$root.RespScanStatus.decode(e,e.uint32());break}case 14:{c.cmdScanResult=$root.CmdScanResult.decode(e,e.uint32());break}case 15:{c.respScanResult=$root.RespScanResult.decode(e,e.uint32());break}default:e.skipType(u&7);break}}return c},i.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},i.verify=function(e){if(typeof e!="object"||e===null)return"object expected";let r={};if(e.msg!=null&&e.hasOwnProperty("msg"))switch(e.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:break}if(e.status!=null&&e.hasOwnProperty("status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(e.cmdScanStart!=null&&e.hasOwnProperty("cmdScanStart")){r.payload=1;{let o=$root.CmdScanStart.verify(e.cmdScanStart);if(o)return"cmdScanStart."+o}}if(e.respScanStart!=null&&e.hasOwnProperty("respScanStart")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespScanStart.verify(e.respScanStart);if(o)return"respScanStart."+o}}if(e.cmdScanStatus!=null&&e.hasOwnProperty("cmdScanStatus")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.CmdScanStatus.verify(e.cmdScanStatus);if(o)return"cmdScanStatus."+o}}if(e.respScanStatus!=null&&e.hasOwnProperty("respScanStatus")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespScanStatus.verify(e.respScanStatus);if(o)return"respScanStatus."+o}}if(e.cmdScanResult!=null&&e.hasOwnProperty("cmdScanResult")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.CmdScanResult.verify(e.cmdScanResult);if(o)return"cmdScanResult."+o}}if(e.respScanResult!=null&&e.hasOwnProperty("respScanResult")){if(r.payload===1)return"payload: multiple values";r.payload=1;{let o=$root.RespScanResult.verify(e.respScanResult);if(o)return"respScanResult."+o}}return null},i.fromObject=function(e){if(e instanceof $root.WiFiScanPayload)return e;let r=new $root.WiFiScanPayload;switch(e.msg){default:if(typeof e.msg=="number"){r.msg=e.msg;break}break;case"TypeCmdScanStart":case 0:r.msg=0;break;case"TypeRespScanStart":case 1:r.msg=1;break;case"TypeCmdScanStatus":case 2:r.msg=2;break;case"TypeRespScanStatus":case 3:r.msg=3;break;case"TypeCmdScanResult":case 4:r.msg=4;break;case"TypeRespScanResult":case 5:r.msg=5;break}switch(e.status){default:if(typeof e.status=="number"){r.status=e.status;break}break;case"Success":case 0:r.status=0;break;case"InvalidSecScheme":case 1:r.status=1;break;case"InvalidProto":case 2:r.status=2;break;case"TooManySessions":case 3:r.status=3;break;case"InvalidArgument":case 4:r.status=4;break;case"InternalError":case 5:r.status=5;break;case"CryptoError":case 6:r.status=6;break;case"InvalidSession":case 7:r.status=7;break}if(e.cmdScanStart!=null){if(typeof e.cmdScanStart!="object")throw TypeError(".WiFiScanPayload.cmdScanStart: object expected");r.cmdScanStart=$root.CmdScanStart.fromObject(e.cmdScanStart)}if(e.respScanStart!=null){if(typeof e.respScanStart!="object")throw TypeError(".WiFiScanPayload.respScanStart: object expected");r.respScanStart=$root.RespScanStart.fromObject(e.respScanStart)}if(e.cmdScanStatus!=null){if(typeof e.cmdScanStatus!="object")throw TypeError(".WiFiScanPayload.cmdScanStatus: object expected");r.cmdScanStatus=$root.CmdScanStatus.fromObject(e.cmdScanStatus)}if(e.respScanStatus!=null){if(typeof e.respScanStatus!="object")throw TypeError(".WiFiScanPayload.respScanStatus: object expected");r.respScanStatus=$root.RespScanStatus.fromObject(e.respScanStatus)}if(e.cmdScanResult!=null){if(typeof e.cmdScanResult!="object")throw TypeError(".WiFiScanPayload.cmdScanResult: object expected");r.cmdScanResult=$root.CmdScanResult.fromObject(e.cmdScanResult)}if(e.respScanResult!=null){if(typeof e.respScanResult!="object")throw TypeError(".WiFiScanPayload.respScanResult: object expected");r.respScanResult=$root.RespScanResult.fromObject(e.respScanResult)}return r},i.toObject=function(e,r){r||(r={});let o={};return r.defaults&&(o.msg=r.enums===String?"TypeCmdScanStart":0,o.status=r.enums===String?"Success":0),e.msg!=null&&e.hasOwnProperty("msg")&&(o.msg=r.enums===String?$root.WiFiScanMsgType[e.msg]===void 0?e.msg:$root.WiFiScanMsgType[e.msg]:e.msg),e.status!=null&&e.hasOwnProperty("status")&&(o.status=r.enums===String?$root.Status[e.status]===void 0?e.status:$root.Status[e.status]:e.status),e.cmdScanStart!=null&&e.hasOwnProperty("cmdScanStart")&&(o.cmdScanStart=$root.CmdScanStart.toObject(e.cmdScanStart,r),r.oneofs&&(o.payload="cmdScanStart")),e.respScanStart!=null&&e.hasOwnProperty("respScanStart")&&(o.respScanStart=$root.RespScanStart.toObject(e.respScanStart,r),r.oneofs&&(o.payload="respScanStart")),e.cmdScanStatus!=null&&e.hasOwnProperty("cmdScanStatus")&&(o.cmdScanStatus=$root.CmdScanStatus.toObject(e.cmdScanStatus,r),r.oneofs&&(o.payload="cmdScanStatus")),e.respScanStatus!=null&&e.hasOwnProperty("respScanStatus")&&(o.respScanStatus=$root.RespScanStatus.toObject(e.respScanStatus,r),r.oneofs&&(o.payload="respScanStatus")),e.cmdScanResult!=null&&e.hasOwnProperty("cmdScanResult")&&(o.cmdScanResult=$root.CmdScanResult.toObject(e.cmdScanResult,r),r.oneofs&&(o.payload="cmdScanResult")),e.respScanResult!=null&&e.hasOwnProperty("respScanResult")&&(o.respScanResult=$root.RespScanResult.toObject(e.respScanResult,r),r.oneofs&&(o.payload="respScanResult")),o},i.prototype.toJSON=function(){return this.constructor.toObject(this,minimal.util.toJSONOptions)},i.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/WiFiScanPayload"},i})();class Security0 extends Security{constructor(){super(...arguments),this.established=!1}async encrypt(n){return n}async decrypt(n){return n}async getSessionSetupRequest(){let n=SessionData.create({});return n.secVer=SecSchemeVersion.SecScheme0,n.sec0=Sec0Payload.create({msg:Sec0MsgType.S0_Session_Command,sc:S0SessionCmd.create({})}),Sec0Payload.encode(n).finish()}async processSessionSetupResponse(n){const t=SessionData.decode(n);if(t.secVer===SecSchemeVersion.SecScheme0&&t.sec0)this.established=!0;else throw new Error("Invalid session setup response for Security0")}isEstablished(){return this.established}}const PROTO_ENDPOINTS={PROV_SESSION:"prov-session",PROV_SCAN:"prov-scan",PROV_CTRL:"prov-ctrl",PROV_CONFIG:"prov-config",PROTO_VER:"proto-ver"},DEFAULT_DEVICE_PREFIX="PROV_",FALLBACK_SERVICE_UUID="1775244d-6b43-439b-877c-060f2d9bed07",FALLBACK_NU_LOOKUP={"prov-session":"ff51","prov-config":"ff52","proto-ver":"ff53"},DEFAULT_BLE_DEVICE_OPTIONS={filters:[{namePrefix:DEFAULT_DEVICE_PREFIX},{services:[FALLBACK_SERVICE_UUID]}],optionalServices:[FALLBACK_SERVICE_UUID]};var ESPWifiAuthMode=(i=>(i[i.open=0]="open",i[i.wep=1]="wep",i[i.wpa2Enterprise=2]="wpa2Enterprise",i[i.wpa2Psk=3]="wpa2Psk",i[i.wpaPsk=4]="wpaPsk",i[i.wpaWpa2Psk=5]="wpaWpa2Psk",i[i.wpa3Psk=6]="wpa3Psk",i[i.wpa2Wpa3Psk=7]="wpa2Wpa3Psk",i))(ESPWifiAuthMode||{}),ESPWifiStaState=(i=>(i[i.connected=0]="connected",i[i.connecting=1]="connecting",i[i.disconnected=2]="disconnected",i[i.failed=3]="failed",i))(ESPWifiStaState||{}),ESPConnectFailReason=(i=>(i[i.authError=1]="authError",i[i.networkNotFound=2]="networkNotFound",i))(ESPConnectFailReason||{});function wifiAuthModeToESPWifiAuthMode(i){switch(i){case WifiAuthMode.Open:return ESPWifiAuthMode.open;case WifiAuthMode.WEP:return ESPWifiAuthMode.wep;case WifiAuthMode.WPA_PSK:return ESPWifiAuthMode.wpaPsk;case WifiAuthMode.WPA2_PSK:return ESPWifiAuthMode.wpa2Psk;case WifiAuthMode.WPA_WPA2_PSK:return ESPWifiAuthMode.wpaWpa2Psk;case WifiAuthMode.WPA2_ENTERPRISE:return ESPWifiAuthMode.wpa2Enterprise;case WifiAuthMode.WPA3_PSK:return ESPWifiAuthMode.wpa3Psk;case WifiAuthMode.WPA2_WPA3_PSK:return ESPWifiAuthMode.wpa2Wpa3Psk}}function getScanStartRequest(i=!0,n=!1,t=5,e=120){let r=CmdScanStart.create({});r.blocking=i,r.passive=n,r.groupChannels=t,r.periodMs=e;const o=WiFiScanPayload.create({msg:WiFiScanMsgType.TypeCmdScanStart,cmdScanStart:r});return WiFiScanPayload.encode(o).finish()}function processScanStartResponse(i){try{const n=WiFiScanPayload.decode(i);if(n.status!==Status.Success)throw new Error(`Scan start failed: ${n.status}`)}catch(n){console.error("Error processing scan start response:",n)}}function getScanStatusRequest(){const i=WiFiScanPayload.create({msg:WiFiScanMsgType.TypeCmdScanStatus,cmdScanStatus:CmdScanStatus.create({})});return WiFiScanPayload.encode(i).finish()}function processScanStatusResponse(i){try{const n=WiFiScanPayload.decode(i);if(n.status!==Status.Success)throw new Error(`Scan status failed: ${n.status}`);const t=n.respScanStatus;return{scanFinished:t.scanFinished,count:t.resultCount}}catch{throw new Error("Failed to decode scan status response")}}function getScanResultRequest(i,n){let t=CmdScanResult.create({});t.startIndex=i,t.count=n;const e=WiFiScanPayload.create({msg:WiFiScanMsgType.TypeCmdScanResult,cmdScanResult:t});return WiFiScanPayload.encode(e).finish()}function processScanResultResponse(i){try{const n=WiFiScanPayload.decode(i);if(n.status!==Status.Success)throw new Error(`Scan result failed: ${n.status}`);return n.respScanResult.entries.map(r=>{const o=r;return{ssid:bytesToString(o.ssid),rssi:o.rssi,auth:wifiAuthModeToESPWifiAuthMode(o.auth),bssid:bytesToHex(o.bssid),channel:o.channel}})}catch{throw new Error("Failed to decode scan result response")}}function getConfigStatusRequest(){let i=WiFiConfigPayload.create({});return i.msg=WiFiConfigMsgType.TypeCmdGetStatus,i.cmdGetStatus=CmdGetStatus.create({}),WiFiConfigPayload.encode(i).finish()}function processConfigStatusResponse(i){try{const t=WiFiConfigPayload.decode(i).respGetStatus;if(t.status!==Status.Success)throw new Error(`Config status failed: ${t.status}`);let e;switch(t.staState){case WifiStationState.Disconnected:e=ESPWifiStaState.disconnected;break;case WifiStationState.Connecting:e=ESPWifiStaState.connecting;break;case WifiStationState.Connected:e=ESPWifiStaState.connected;break;case WifiStationState.ConnectionFailed:e=ESPWifiStaState.failed;break}let r;switch(t.failReason){case WifiConnectFailedReason.AuthError:r=ESPConnectFailReason.authError;break;case WifiConnectFailedReason.NetworkNotFound:r=ESPConnectFailReason.networkNotFound;break;default:break}let o;return t.connected&&(o={ssid:bytesToString(t.connected.ssid),rssi:t.connected.rssi,auth:wifiAuthModeToESPWifiAuthMode(t.connected.auth),bssid:bytesToHex(t.connected.bssid),channel:t.connected.channel}),{staState:e,failedReason:r,connected:o}}catch{throw new Error("Failed to decode config status response")}}function getConfigUpdateRequest(i,n){let t=WiFiConfigPayload.create({});return t.msg=WiFiConfigMsgType.TypeCmdSetConfig,t.cmdSetConfig=CmdSetConfig.create({ssid:stringToBytes(i),passphrase:stringToBytes(n)}),WiFiConfigPayload.encode(t).finish()}function processConfigUpdateResponse(i){try{const t=WiFiConfigPayload.decode(i).respSetConfig;if(t.status!==Status.Success)throw new Error(`Config update failed: ${t.status}`)}catch{throw new Error("Failed to decode config update response")}}function getConfigApplyRequest(){let i=WiFiConfigPayload.create({});return i.msg=WiFiConfigMsgType.TypeCmdApplyConfig,i.cmdApplyConfig=CmdApplyConfig.create({}),WiFiConfigPayload.encode(i).finish()}function processConfigApplyResponse(i){try{const t=WiFiConfigPayload.decode(i).respApplyConfig;if(t.status!==Status.Success)throw new Error(`Config apply failed: ${t.status}`)}catch{throw new Error("Failed to decode config apply response")}}class ESPDevice{constructor(n){this.device=n}async connect(n){await this.initializeTransport(),this.initializeSecurity(n),n&&await this.establishSession()}async scanWifiList(){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const n=getScanStartRequest(),t=await this.sendData(PROTO_ENDPOINTS.PROV_SCAN,n);processScanStartResponse(t);const e=getScanStatusRequest(),r=await this.sendData(PROTO_ENDPOINTS.PROV_SCAN,e),{scanFinished:o,count:s}=processScanStatusResponse(r);if(!o)throw new Error("WiFi scan should have finished");let c=[];for(let u=0;u<s;u++){const l=getScanResultRequest(u,1),a=await this.sendData(PROTO_ENDPOINTS.PROV_SCAN,l),f=processScanResultResponse(a);c=c.concat(f)}return c}catch(n){throw new Error(`WiFi scan failed: ${n}`)}}async provision(n,t){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const e=getConfigUpdateRequest(n,t),r=await this.sendData(PROTO_ENDPOINTS.PROV_CONFIG,e);processConfigUpdateResponse(r);const o=getConfigApplyRequest(),s=await this.sendData(PROTO_ENDPOINTS.PROV_CONFIG,o);processConfigApplyResponse(s)}catch(e){throw new Error(`Provisioning failed: ${e}`)}}async fetchWifiStatus(){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const n=getConfigStatusRequest(),t=await this.sendData(PROTO_ENDPOINTS.PROV_CONFIG,n);return processConfigStatusResponse(t)}catch(n){throw new Error(`Fetching WiFi status failed: ${n}`)}}async sendData(n,t){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");const e=await this.securityImpl.encrypt(t);console.debug("Send encrypted data length:",e.length);const r=await this.transportImpl.sendData(n,e);return await this.securityImpl.decrypt(r)}disconnect(){this.transportImpl&&(this.transportImpl.disconnect(),this.transportImpl=void 0),this.securityImpl=void 0}getDevice(){return this.device}initializeSecurity(n){if(!n)this.securityImpl=new Security0;else throw new Error("Unsupported security configuration")}async establishSession(){if(!this.transportImpl||!this.securityImpl)throw new Error("Transport or security not initialized");const n=await this.securityImpl.getSessionSetupRequest(),t=await this.transportImpl.sendData(PROTO_ENDPOINTS.PROV_SESSION,n);await this.securityImpl.processSessionSetupResponse(t)}async initializeTransport(){this.device instanceof URL?this.transportImpl=new SoftAPTransport(this.device.toString()):this.transportImpl=new BLETransport(this.device,FALLBACK_SERVICE_UUID,new Map(Object.entries(FALLBACK_NU_LOOKUP))),await this.transportImpl.connect()}}class ESPProvisionManager{static async searchBLEDevice(n=DEFAULT_BLE_DEVICE_OPTIONS){if(!await ESPProvisionManager.getBluetoothAvailability())throw new Error("Web Bluetooth is not available.");try{const e=await navigator.bluetooth.requestDevice(n);if(!e.name)throw new Error("Device name not available");return new ESPDevice(e)}catch(e){if(e.name==="NotFoundError")return null;throw new Error(`Device search failed: ${e}`)}}static createSoftAPDevice(n){return new ESPDevice(n)}static isBluetoothSupported(){return typeof navigator<"u"&&"bluetooth"in navigator}static async getBluetoothAvailability(){if(!this.isBluetoothSupported())return!1;try{return await navigator.bluetooth.getAvailability()}catch(n){return console.error("Failed to get Bluetooth availability:",n),!1}}}exports.DEFAULT_DEVICE_PREFIX=DEFAULT_DEVICE_PREFIX;exports.ESPDevice=ESPDevice;exports.ESPProvisionManager=ESPProvisionManager;exports.ESPWifiAuthMode=ESPWifiAuthMode;exports.ESPWifiStaState=ESPWifiStaState;exports.FALLBACK_SERVICE_UUID=FALLBACK_SERVICE_UUID;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class nt{}function it(r){return Array.from(r).map(c=>c.toString(16).padStart(2,"0")).join("")}function se(r){return new TextEncoder().encode(r)}function le(r){return new TextDecoder().decode(r)}async function ft(r){const c=await crypto.subtle.digest("SHA-256",new Uint8Array(r));return new Uint8Array(c)}class je{constructor(c,e){this.key=c,this.counter=e,this.offset=0}static async create(c,e){if(c.length!==32||e.length!==16)throw new Error("Invalid AES-256-CTR parameters");const t=await crypto.subtle.importKey("raw",new Uint8Array(c),"AES-CTR",!1,["encrypt"]);return new je(t,new Uint8Array(e))}async update(c){const e=new Uint8Array(this.offset+c.length);e.set(c,this.offset);const t=await crypto.subtle.encrypt({name:"AES-CTR",counter:this.counter,length:128},this.key,e),n=new Uint8Array(t).slice(this.offset);let i=Math.floor(e.length/16);for(let o=this.counter.length-1;o>=0&&i>0;o--){const s=this.counter[o]+i;this.counter[o]=s&255,i=Math.floor(s/256)}return this.offset=e.length%16,n}}class lt extends nt{constructor(c,e,t){super(),this.connected=!1,this.device=c,this.serviceUUID=e,this.nuLookup=t}async connect(){if(!this.isConnected())try{if(this.server=await this.device.gatt?.connect(),!this.server)throw new Error("Failed to connect to GATT server");try{const e=await this.server.getPrimaryServices(this.serviceUUID);if(e.length>1){const t=e.find(n=>n.uuid===this.serviceUUID);if(!t)throw new Error(`Service with UUID ${this.serviceUUID} not found`);this.service=t}else this.service=e[0]}catch(e){throw new Error(`Failed to get primary services: ${e}`)}const c=await this.service.getCharacteristics();for(const e of c){const t=await e.getDescriptors();for(const n of t){if(n.uuid.slice(4,8)!=="2901")continue;const i=await n.readValue();this.nuLookup.set(le(new Uint8Array(i.buffer)).toLowerCase(),e.uuid)}}console.debug("BLE discovered characteristics:",this.nuLookup),this.connected=!0}catch(c){throw this.connected=!1,new Error(`BLE connection failed: ${c}`)}}disconnect(){this.server?.connected&&this.server.disconnect(),this.server=void 0,this.service=void 0,this.connected=!1}async sendData(c,e){if(!this.isConnected())throw new Error("Not connected to device");const t=this.nuLookup.get(c.toLowerCase());if(!t)throw new Error(`Characteristic UUID for endpoint ${c} not found`);const n=await this.service?.getCharacteristic(t);if(!n)throw new Error(`Characteristic for UUID ${t} not found`);const i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);await n.writeValueWithResponse(i);const o=await n.readValue();return new Uint8Array(o.buffer)}isConnected(){return this.connected&&this.server?.connected===!0}getDevice(){return this.device}}class at extends nt{constructor(c){super(),this.connected=!1,this.baseUrl=c.replace(/\/$/,"")}async connect(){try{const c=await fetch(`${this.baseUrl}/proto-ver`,{method:"GET",mode:"cors"});if(!c.ok)throw new Error(`HTTP ${c.status}`);this.connected=!0}catch(c){throw this.connected=!1,new Error(`SoftAP connection failed. Please ensure you are connected to the device's WiFi network. Error: ${c}`)}}disconnect(){this.connected=!1}async sendData(c,e){if(!this.connected)throw new Error("Not connected to device");try{const t=await fetch(`${this.baseUrl}/${c}`,{method:"POST",headers:{Accept:"text/plain","Content-Type":"application/x-www-form-urlencoded"},body:new Uint8Array(e),mode:"cors"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.arrayBuffer();return new Uint8Array(n)}catch(t){throw new Error(`SoftAP communication failed: ${t}`)}}isConnected(){return this.connected}setBaseUrl(c){this.baseUrl=c}getBaseUrl(){return this.baseUrl}}class rt{}var Y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},de={},re={},he,Ie;function dt(){if(Ie)return he;Ie=1,he=r;function r(c,e){for(var t=new Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)t[n++]=arguments[i++];return new Promise(function(u,p){t[n]=function(S){if(o)if(o=!1,S)p(S);else{for(var y=new Array(arguments.length-1),h=0;h<y.length;)y[h++]=arguments[h];u.apply(null,y)}};try{c.apply(e||null,t)}catch(w){o&&(o=!1,p(w))}})}return he}var pe={},Fe;function ht(){return Fe||(Fe=1,(function(r){var c=r;c.length=function(s){var u=s.length;if(!u)return 0;for(var p=0;--u%4>1&&s.charAt(u)==="=";)++p;return Math.ceil(s.length*3)/4-p};for(var e=new Array(64),t=new Array(123),n=0;n<64;)t[e[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;c.encode=function(s,u,p){for(var w=null,S=[],y=0,h=0,b;u<p;){var C=s[u++];switch(h){case 0:S[y++]=e[C>>2],b=(C&3)<<4,h=1;break;case 1:S[y++]=e[b|C>>4],b=(C&15)<<2,h=2;break;case 2:S[y++]=e[b|C>>6],S[y++]=e[C&63],h=0;break}y>8191&&((w||(w=[])).push(String.fromCharCode.apply(String,S)),y=0)}return h&&(S[y++]=e[b],S[y++]=61,h===1&&(S[y++]=61)),w?(y&&w.push(String.fromCharCode.apply(String,S.slice(0,y))),w.join("")):String.fromCharCode.apply(String,S.slice(0,y))};var i="invalid encoding";c.decode=function(s,u,p){for(var w=p,S=0,y,h=0;h<s.length;){var b=s.charCodeAt(h++);if(b===61&&S>1)break;if((b=t[b])===void 0)throw Error(i);switch(S){case 0:y=b,S=1;break;case 1:u[p++]=y<<2|(b&48)>>4,y=b,S=2;break;case 2:u[p++]=(y&15)<<4|(b&60)>>2,y=b,S=3;break;case 3:u[p++]=(y&3)<<6|b,S=0;break}}if(S===1)throw Error(i);return p-w},c.test=function(s){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s)}})(pe)),pe}var ye,Be;function pt(){if(Be)return ye;Be=1,ye=r;function r(){this._listeners=Object.create(null)}return r.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},r.prototype.off=function(e,t){if(e===void 0)this._listeners=Object.create(null);else if(t===void 0)this._listeners[e]=[];else{var n=this._listeners[e];if(!n)return this;for(var i=0;i<n.length;)n[i].fn===t?n.splice(i,1):++i}return this},r.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<t.length;)t[i].fn.apply(t[i++].ctx,n)}return this},ye}var be,We;function yt(){if(We)return be;We=1,be=r(r);function r(i){return typeof Float32Array<"u"?(function(){var o=new Float32Array([-0]),s=new Uint8Array(o.buffer),u=s[3]===128;function p(h,b,C){o[0]=h,b[C]=s[0],b[C+1]=s[1],b[C+2]=s[2],b[C+3]=s[3]}function w(h,b,C){o[0]=h,b[C]=s[3],b[C+1]=s[2],b[C+2]=s[1],b[C+3]=s[0]}i.writeFloatLE=u?p:w,i.writeFloatBE=u?w:p;function S(h,b){return s[0]=h[b],s[1]=h[b+1],s[2]=h[b+2],s[3]=h[b+3],o[0]}function y(h,b){return s[3]=h[b],s[2]=h[b+1],s[1]=h[b+2],s[0]=h[b+3],o[0]}i.readFloatLE=u?S:y,i.readFloatBE=u?y:S})():(function(){function o(u,p,w,S){var y=p<0?1:0;if(y&&(p=-p),p===0)u(1/p>0?0:2147483648,w,S);else if(isNaN(p))u(2143289344,w,S);else if(p>34028234663852886e22)u((y<<31|2139095040)>>>0,w,S);else if(p<11754943508222875e-54)u((y<<31|Math.round(p/1401298464324817e-60))>>>0,w,S);else{var h=Math.floor(Math.log(p)/Math.LN2),b=Math.round(p*Math.pow(2,-h)*8388608)&8388607;u((y<<31|h+127<<23|b)>>>0,w,S)}}i.writeFloatLE=o.bind(null,c),i.writeFloatBE=o.bind(null,e);function s(u,p,w){var S=u(p,w),y=(S>>31)*2+1,h=S>>>23&255,b=S&8388607;return h===255?b?NaN:y*(1/0):h===0?y*1401298464324817e-60*b:y*Math.pow(2,h-150)*(b+8388608)}i.readFloatLE=s.bind(null,t),i.readFloatBE=s.bind(null,n)})(),typeof Float64Array<"u"?(function(){var o=new Float64Array([-0]),s=new Uint8Array(o.buffer),u=s[7]===128;function p(h,b,C){o[0]=h,b[C]=s[0],b[C+1]=s[1],b[C+2]=s[2],b[C+3]=s[3],b[C+4]=s[4],b[C+5]=s[5],b[C+6]=s[6],b[C+7]=s[7]}function w(h,b,C){o[0]=h,b[C]=s[7],b[C+1]=s[6],b[C+2]=s[5],b[C+3]=s[4],b[C+4]=s[3],b[C+5]=s[2],b[C+6]=s[1],b[C+7]=s[0]}i.writeDoubleLE=u?p:w,i.writeDoubleBE=u?w:p;function S(h,b){return s[0]=h[b],s[1]=h[b+1],s[2]=h[b+2],s[3]=h[b+3],s[4]=h[b+4],s[5]=h[b+5],s[6]=h[b+6],s[7]=h[b+7],o[0]}function y(h,b){return s[7]=h[b],s[6]=h[b+1],s[5]=h[b+2],s[4]=h[b+3],s[3]=h[b+4],s[2]=h[b+5],s[1]=h[b+6],s[0]=h[b+7],o[0]}i.readDoubleLE=u?S:y,i.readDoubleBE=u?y:S})():(function(){function o(u,p,w,S,y,h){var b=S<0?1:0;if(b&&(S=-S),S===0)u(0,y,h+p),u(1/S>0?0:2147483648,y,h+w);else if(isNaN(S))u(0,y,h+p),u(2146959360,y,h+w);else if(S>17976931348623157e292)u(0,y,h+p),u((b<<31|2146435072)>>>0,y,h+w);else{var C;if(S<22250738585072014e-324)C=S/5e-324,u(C>>>0,y,h+p),u((b<<31|C/4294967296)>>>0,y,h+w);else{var R=Math.floor(Math.log(S)/Math.LN2);R===1024&&(R=1023),C=S*Math.pow(2,-R),u(C*4503599627370496>>>0,y,h+p),u((b<<31|R+1023<<20|C*1048576&1048575)>>>0,y,h+w)}}}i.writeDoubleLE=o.bind(null,c,0,4),i.writeDoubleBE=o.bind(null,e,4,0);function s(u,p,w,S,y){var h=u(S,y+p),b=u(S,y+w),C=(b>>31)*2+1,R=b>>>20&2047,v=4294967296*(b&1048575)+h;return R===2047?v?NaN:C*(1/0):R===0?C*5e-324*v:C*Math.pow(2,R-1075)*(v+4503599627370496)}i.readDoubleLE=s.bind(null,t,0,4),i.readDoubleBE=s.bind(null,n,4,0)})(),i}function c(i,o,s){o[s]=i&255,o[s+1]=i>>>8&255,o[s+2]=i>>>16&255,o[s+3]=i>>>24}function e(i,o,s){o[s]=i>>>24,o[s+1]=i>>>16&255,o[s+2]=i>>>8&255,o[s+3]=i&255}function t(i,o){return(i[o]|i[o+1]<<8|i[o+2]<<16|i[o+3]<<24)>>>0}function n(i,o){return(i[o]<<24|i[o+1]<<16|i[o+2]<<8|i[o+3])>>>0}return be}var Se={},Ve;function bt(){return Ve||(Ve=1,(function(r){var c=r,e=65533;c.length=function(n){for(var i=0,o=0,s=0;s<n.length;++s)o=n.charCodeAt(s),o<128?i+=1:o<2048?i+=2:(o&64512)===55296&&(n.charCodeAt(s+1)&64512)===56320?(++s,i+=4):i+=3;return i},c.read=function(n,i,o){if(o-i<1)return"";for(var s=null,u=[],p=0,w,S,y,h;i<o;)w=n[i++],w<=127?u[p++]=w:w>=192&&w<224?(y=(w&31)<<6|n[i++]&63,u[p++]=y>=128?y:e):w>=224&&w<240?(h=(w&15)<<12|(n[i++]&63)<<6|n[i++]&63,u[p++]=h>=2048?h:e):w>=240&&(S=(w&7)<<18|(n[i++]&63)<<12|(n[i++]&63)<<6|n[i++]&63,S<65536||S>1114111?u[p++]=e:(S-=65536,u[p++]=55296+(S>>10),u[p++]=56320+(S&1023))),p>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,u.slice(0,p))),p=0);return s?(p&&s.push(String.fromCharCode.apply(String,u.slice(0,p))),s.join("")):String.fromCharCode.apply(String,u.slice(0,p))},c.write=function(n,i,o){for(var s=o,u,p,w=0;w<n.length;++w)u=n.charCodeAt(w),u<128?i[o++]=u:u<2048?(i[o++]=u>>6|192,i[o++]=u&63|128):(u&64512)===55296&&((p=n.charCodeAt(w+1))&64512)===56320?(u=65536+((u&1023)<<10)+(p&1023),++w,i[o++]=u>>18|240,i[o++]=u>>12&63|128,i[o++]=u>>6&63|128,i[o++]=u&63|128):(i[o++]=u>>12|224,i[o++]=u>>6&63|128,i[o++]=u&63|128);return o-s}})(Se)),Se}var Oe,Me;function St(){if(Me)return Oe;Me=1,Oe=r;function r(c,e,t){var n=t||8192,i=n>>>1,o=null,s=n;return function(p){if(p<1||p>i)return c(p);s+p>n&&(o=c(n),s=0);var w=e.call(o,s,s+=p);return s&7&&(s=(s|7)+1),w}}return Oe}var me,Ue;function Ot(){if(Ue)return me;Ue=1,me=c;var r=X();function c(i,o){this.lo=i>>>0,this.hi=o>>>0}var e=c.zero=new c(0,0);e.toNumber=function(){return 0},e.zzEncode=e.zzDecode=function(){return this},e.length=function(){return 1};var t=c.zeroHash="\0\0\0\0\0\0\0\0";c.fromNumber=function(o){if(o===0)return e;var s=o<0;s&&(o=-o);var u=o>>>0,p=(o-u)/4294967296>>>0;return s&&(p=~p>>>0,u=~u>>>0,++u>4294967295&&(u=0,++p>4294967295&&(p=0))),new c(u,p)},c.from=function(o){if(typeof o=="number")return c.fromNumber(o);if(r.isString(o))if(r.Long)o=r.Long.fromString(o);else return c.fromNumber(parseInt(o,10));return o.low||o.high?new c(o.low>>>0,o.high>>>0):e},c.prototype.toNumber=function(o){if(!o&&this.hi>>>31){var s=~this.lo+1>>>0,u=~this.hi>>>0;return s||(u=u+1>>>0),-(s+u*4294967296)}return this.lo+this.hi*4294967296},c.prototype.toLong=function(o){return r.Long?new r.Long(this.lo|0,this.hi|0,!!o):{low:this.lo|0,high:this.hi|0,unsigned:!!o}};var n=String.prototype.charCodeAt;return c.fromHash=function(o){return o===t?e:new c((n.call(o,0)|n.call(o,1)<<8|n.call(o,2)<<16|n.call(o,3)<<24)>>>0,(n.call(o,4)|n.call(o,5)<<8|n.call(o,6)<<16|n.call(o,7)<<24)>>>0)},c.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},c.prototype.zzEncode=function(){var o=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^o)>>>0,this.lo=(this.lo<<1^o)>>>0,this},c.prototype.zzDecode=function(){var o=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^o)>>>0,this.hi=(this.hi>>>1^o)>>>0,this},c.prototype.length=function(){var o=this.lo,s=(this.lo>>>28|this.hi<<4)>>>0,u=this.hi>>>24;return u===0?s===0?o<16384?o<128?1:2:o<2097152?3:4:s<16384?s<128?5:6:s<2097152?7:8:u<128?9:10},me}var te={exports:{}},mt=te.exports,Je;function wt(){return Je||(Je=1,(function(r,c){(function(e,t){function n(i){return i.default||i}t(c),r.exports=n(c)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:mt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function n(O,a,k){this.low=O|0,this.high=a|0,this.unsigned=!!k}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0});function i(O){return(O&&O.__isLong__)===!0}function o(O){var a=Math.clz32(O&-O);return O?31-a:a}n.isLong=i;var s={},u={};function p(O,a){var k,_,g;return a?(O>>>=0,(g=0<=O&&O<256)&&(_=u[O],_)?_:(k=S(O,0,!0),g&&(u[O]=k),k)):(O|=0,(g=-128<=O&&O<128)&&(_=s[O],_)?_:(k=S(O,O<0?-1:0,!1),g&&(s[O]=k),k))}n.fromInt=p;function w(O,a){if(isNaN(O))return a?$:U;if(a){if(O<0)return $;if(O>=P)return Ne}else{if(O<=-j)return I;if(O+1>=j)return Le}return O<0?w(-O,a).neg():S(O%v|0,O/v|0,a)}n.fromNumber=w;function S(O,a,k){return new n(O,a,k)}n.fromBits=S;var y=Math.pow;function h(O,a,k){if(O.length===0)throw Error("empty string");if(typeof a=="number"?(k=a,a=!1):a=!!a,O==="NaN"||O==="Infinity"||O==="+Infinity"||O==="-Infinity")return a?$:U;if(k=k||10,k<2||36<k)throw RangeError("radix");var _;if((_=O.indexOf("-"))>0)throw Error("interior hyphen");if(_===0)return h(O.substring(1),a,k).neg();for(var g=w(y(k,8)),T=U,A=0;A<O.length;A+=8){var F=Math.min(8,O.length-A),W=parseInt(O.substring(A,A+F),k);if(F<8){var N=w(y(k,F));T=T.mul(N).add(w(W))}else T=T.mul(g),T=T.add(w(W))}return T.unsigned=a,T}n.fromString=h;function b(O,a){return typeof O=="number"?w(O,a):typeof O=="string"?h(O,a):S(O.low,O.high,typeof a=="boolean"?a:O.unsigned)}n.fromValue=b;var C=65536,R=1<<24,v=C*C,P=v*v,j=P/2,M=p(R),U=p(0);n.ZERO=U;var $=p(0,!0);n.UZERO=$;var Q=p(1);n.ONE=Q;var Ae=p(1,!0);n.UONE=Ae;var ae=p(-1);n.NEG_ONE=ae;var Le=S(-1,2147483647,!1);n.MAX_VALUE=Le;var Ne=S(-1,-1,!0);n.MAX_UNSIGNED_VALUE=Ne;var I=S(0,-2147483648,!1);n.MIN_VALUE=I;var m=n.prototype;m.toInt=function(){return this.unsigned?this.low>>>0:this.low},m.toNumber=function(){return this.unsigned?(this.high>>>0)*v+(this.low>>>0):this.high*v+(this.low>>>0)},m.toString=function(a){if(a=a||10,a<2||36<a)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(I)){var k=w(a),_=this.div(k),g=_.mul(k).sub(this);return _.toString(a)+g.toInt().toString(a)}else return"-"+this.neg().toString(a);for(var T=w(y(a,6),this.unsigned),A=this,F="";;){var W=A.div(T),N=A.sub(W.mul(T)).toInt()>>>0,D=N.toString(a);if(A=W,A.isZero())return D+F;for(;D.length<6;)D="0"+D;F=""+D+F}},m.getHighBits=function(){return this.high},m.getHighBitsUnsigned=function(){return this.high>>>0},m.getLowBits=function(){return this.low},m.getLowBitsUnsigned=function(){return this.low>>>0},m.getNumBitsAbs=function(){if(this.isNegative())return this.eq(I)?64:this.neg().getNumBitsAbs();for(var a=this.high!=0?this.high:this.low,k=31;k>0&&(a&1<<k)==0;k--);return this.high!=0?k+33:k+1},m.isSafeInteger=function(){var a=this.high>>21;return a?this.unsigned?!1:a===-1&&!(this.low===0&&this.high===-2097152):!0},m.isZero=function(){return this.high===0&&this.low===0},m.eqz=m.isZero,m.isNegative=function(){return!this.unsigned&&this.high<0},m.isPositive=function(){return this.unsigned||this.high>=0},m.isOdd=function(){return(this.low&1)===1},m.isEven=function(){return(this.low&1)===0},m.equals=function(a){return i(a)||(a=b(a)),this.unsigned!==a.unsigned&&this.high>>>31===1&&a.high>>>31===1?!1:this.high===a.high&&this.low===a.low},m.eq=m.equals,m.notEquals=function(a){return!this.eq(a)},m.neq=m.notEquals,m.ne=m.notEquals,m.lessThan=function(a){return this.comp(a)<0},m.lt=m.lessThan,m.lessThanOrEqual=function(a){return this.comp(a)<=0},m.lte=m.lessThanOrEqual,m.le=m.lessThanOrEqual,m.greaterThan=function(a){return this.comp(a)>0},m.gt=m.greaterThan,m.greaterThanOrEqual=function(a){return this.comp(a)>=0},m.gte=m.greaterThanOrEqual,m.ge=m.greaterThanOrEqual,m.compare=function(a){if(i(a)||(a=b(a)),this.eq(a))return 0;var k=this.isNegative(),_=a.isNegative();return k&&!_?-1:!k&&_?1:this.unsigned?a.high>>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.sub(a).isNegative()?-1:1},m.comp=m.compare,m.negate=function(){return!this.unsigned&&this.eq(I)?I:this.not().add(Q)},m.neg=m.negate,m.add=function(a){i(a)||(a=b(a));var k=this.high>>>16,_=this.high&65535,g=this.low>>>16,T=this.low&65535,A=a.high>>>16,F=a.high&65535,W=a.low>>>16,N=a.low&65535,D=0,V=0,L=0,B=0;return B+=T+N,L+=B>>>16,B&=65535,L+=g+W,V+=L>>>16,L&=65535,V+=_+F,D+=V>>>16,V&=65535,D+=k+A,D&=65535,S(L<<16|B,D<<16|V,this.unsigned)},m.subtract=function(a){return i(a)||(a=b(a)),this.add(a.neg())},m.sub=m.subtract,m.multiply=function(a){if(this.isZero())return this;if(i(a)||(a=b(a)),t){var k=t.mul(this.low,this.high,a.low,a.high);return S(k,t.get_high(),this.unsigned)}if(a.isZero())return this.unsigned?$:U;if(this.eq(I))return a.isOdd()?I:U;if(a.eq(I))return this.isOdd()?I:U;if(this.isNegative())return a.isNegative()?this.neg().mul(a.neg()):this.neg().mul(a).neg();if(a.isNegative())return this.mul(a.neg()).neg();if(this.lt(M)&&a.lt(M))return w(this.toNumber()*a.toNumber(),this.unsigned);var _=this.high>>>16,g=this.high&65535,T=this.low>>>16,A=this.low&65535,F=a.high>>>16,W=a.high&65535,N=a.low>>>16,D=a.low&65535,V=0,L=0,B=0,ie=0;return ie+=A*D,B+=ie>>>16,ie&=65535,B+=T*D,L+=B>>>16,B&=65535,B+=A*N,L+=B>>>16,B&=65535,L+=g*D,V+=L>>>16,L&=65535,L+=T*N,V+=L>>>16,L&=65535,L+=A*W,V+=L>>>16,L&=65535,V+=_*D+g*N+T*W+A*F,V&=65535,S(B<<16|ie,V<<16|L,this.unsigned)},m.mul=m.multiply,m.divide=function(a){if(i(a)||(a=b(a)),a.isZero())throw Error("division by zero");if(t){if(!this.unsigned&&this.high===-2147483648&&a.low===-1&&a.high===-1)return this;var k=(this.unsigned?t.div_u:t.div_s)(this.low,this.high,a.low,a.high);return S(k,t.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?$:U;var _,g,T;if(this.unsigned){if(a.unsigned||(a=a.toUnsigned()),a.gt(this))return $;if(a.gt(this.shru(1)))return Ae;T=$}else{if(this.eq(I)){if(a.eq(Q)||a.eq(ae))return I;if(a.eq(I))return Q;var A=this.shr(1);return _=A.div(a).shl(1),_.eq(U)?a.isNegative()?Q:ae:(g=this.sub(a.mul(_)),T=_.add(g.div(a)),T)}else if(a.eq(I))return this.unsigned?$:U;if(this.isNegative())return a.isNegative()?this.neg().div(a.neg()):this.neg().div(a).neg();if(a.isNegative())return this.div(a.neg()).neg();T=U}for(g=this;g.gte(a);){_=Math.max(1,Math.floor(g.toNumber()/a.toNumber()));for(var F=Math.ceil(Math.log(_)/Math.LN2),W=F<=48?1:y(2,F-48),N=w(_),D=N.mul(a);D.isNegative()||D.gt(g);)_-=W,N=w(_,this.unsigned),D=N.mul(a);N.isZero()&&(N=Q),T=T.add(N),g=g.sub(D)}return T},m.div=m.divide,m.modulo=function(a){if(i(a)||(a=b(a)),t){var k=(this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,a.low,a.high);return S(k,t.get_high(),this.unsigned)}return this.sub(this.div(a).mul(a))},m.mod=m.modulo,m.rem=m.modulo,m.not=function(){return S(~this.low,~this.high,this.unsigned)},m.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},m.clz=m.countLeadingZeros,m.countTrailingZeros=function(){return this.low?o(this.low):o(this.high)+32},m.ctz=m.countTrailingZeros,m.and=function(a){return i(a)||(a=b(a)),S(this.low&a.low,this.high&a.high,this.unsigned)},m.or=function(a){return i(a)||(a=b(a)),S(this.low|a.low,this.high|a.high,this.unsigned)},m.xor=function(a){return i(a)||(a=b(a)),S(this.low^a.low,this.high^a.high,this.unsigned)},m.shiftLeft=function(a){return i(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?S(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):S(0,this.low<<a-32,this.unsigned)},m.shl=m.shiftLeft,m.shiftRight=function(a){return i(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?S(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):S(this.high>>a-32,this.high>=0?0:-1,this.unsigned)},m.shr=m.shiftRight,m.shiftRightUnsigned=function(a){return i(a)&&(a=a.toInt()),(a&=63)===0?this:a<32?S(this.low>>>a|this.high<<32-a,this.high>>>a,this.unsigned):a===32?S(this.high,0,this.unsigned):S(this.high>>>a-32,0,this.unsigned)},m.shru=m.shiftRightUnsigned,m.shr_u=m.shiftRightUnsigned,m.rotateLeft=function(a){var k;return i(a)&&(a=a.toInt()),(a&=63)===0?this:a===32?S(this.high,this.low,this.unsigned):a<32?(k=32-a,S(this.low<<a|this.high>>>k,this.high<<a|this.low>>>k,this.unsigned)):(a-=32,k=32-a,S(this.high<<a|this.low>>>k,this.low<<a|this.high>>>k,this.unsigned))},m.rotl=m.rotateLeft,m.rotateRight=function(a){var k;return i(a)&&(a=a.toInt()),(a&=63)===0?this:a===32?S(this.high,this.low,this.unsigned):a<32?(k=32-a,S(this.high<<k|this.low>>>a,this.low<<k|this.high>>>a,this.unsigned)):(a-=32,k=32-a,S(this.low<<k|this.high>>>a,this.high<<k|this.low>>>a,this.unsigned))},m.rotr=m.rotateRight,m.toSigned=function(){return this.unsigned?S(this.low,this.high,!1):this},m.toUnsigned=function(){return this.unsigned?this:S(this.low,this.high,!0)},m.toBytes=function(a){return a?this.toBytesLE():this.toBytesBE()},m.toBytesLE=function(){var a=this.high,k=this.low;return[k&255,k>>>8&255,k>>>16&255,k>>>24,a&255,a>>>8&255,a>>>16&255,a>>>24]},m.toBytesBE=function(){var a=this.high,k=this.low;return[a>>>24,a>>>16&255,a>>>8&255,a&255,k>>>24,k>>>16&255,k>>>8&255,k&255]},n.fromBytes=function(a,k,_){return _?n.fromBytesLE(a,k):n.fromBytesBE(a,k)},n.fromBytesLE=function(a,k){return new n(a[0]|a[1]<<8|a[2]<<16|a[3]<<24,a[4]|a[5]<<8|a[6]<<16|a[7]<<24,k)},n.fromBytesBE=function(a,k){return new n(a[4]<<24|a[5]<<16|a[6]<<8|a[7],a[0]<<24|a[1]<<16|a[2]<<8|a[3],k)},typeof BigInt=="function"&&(n.fromBigInt=function(a,k){var _=Number(BigInt.asIntN(32,a)),g=Number(BigInt.asIntN(32,a>>BigInt(32)));return S(_,g,k)},n.fromValue=function(a,k){return typeof a=="bigint"?n.fromBigInt(a,k):b(a,k)},m.toBigInt=function(){var a=BigInt(this.low>>>0),k=BigInt(this.unsigned?this.high>>>0:this.high);return k<<BigInt(32)|a}),e.default=n})})(te,te.exports)),te.exports}var Ge;function X(){return Ge||(Ge=1,(function(r){var c=r;c.asPromise=dt(),c.base64=ht(),c.EventEmitter=pt(),c.float=yt(),c.utf8=bt(),c.pool=St(),c.LongBits=Ot();function e(i){return i==="__proto__"||i==="prototype"||i==="constructor"}c.isUnsafeProperty=e,c.isNode=!!(typeof Y<"u"&&Y&&Y.process&&Y.process.versions&&Y.process.versions.node),c.global=c.isNode&&Y||typeof window<"u"&&window||typeof self<"u"&&self||re,c.emptyArray=Object.freeze?Object.freeze([]):[],c.emptyObject=Object.freeze?Object.freeze({}):{},c.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},c.isString=function(o){return typeof o=="string"||o instanceof String},c.isObject=function(o){return o&&typeof o=="object"},c.isset=c.isSet=function(o,s){var u=o[s];return u!=null&&Object.hasOwnProperty.call(o,s)?typeof u!="object"||(Array.isArray(u)?u.length:Object.keys(u).length)>0:!1},c.Buffer=(function(){try{var i=c.global.Buffer;return i.prototype.utf8Write?i:null}catch{return null}})(),c._Buffer_from=null,c._Buffer_allocUnsafe=null,c.newBuffer=function(o){return typeof o=="number"?c.Buffer?c._Buffer_allocUnsafe(o):new c.Array(o):c.Buffer?c._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)},c.Array=typeof Uint8Array<"u"?Uint8Array:Array,c.Long=c.global.dcodeIO&&c.global.dcodeIO.Long||c.global.Long||(function(){try{var i=wt();return i&&i.isLong?i:null}catch{return null}})(),c.key2Re=/^true|false|0|1$/,c.key32Re=/^-?(?:0|[1-9][0-9]*)$/,c.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,c.longToHash=function(o){return o?c.LongBits.from(o).toHash():c.LongBits.zeroHash},c.longFromHash=function(o,s){var u=c.LongBits.fromHash(o);return c.Long?c.Long.fromBits(u.lo,u.hi,s):u.toNumber(!!s)};function t(i){var o=typeof arguments[arguments.length-1]=="boolean",s=o?arguments.length-1:arguments.length;o=o&&arguments[arguments.length-1];for(var u=1;u<s;++u){var p=arguments[u];if(p)for(var w=Object.keys(p),S=0;S<w.length;++S)!e(w[S])&&(i[w[S]]===void 0||!o)&&(i[w[S]]=p[w[S]])}return i}c.merge=t,c.nestingLimit=32,c.recursionLimit=100,c.makeProp=function(o,s){Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})},c.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function n(i){function o(s,u){if(!(this instanceof o))return new o(s,u);Object.defineProperty(this,"message",{get:function(){return s}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),u&&t(this,u)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return i},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}c.newError=n,c.ProtocolError=n("ProtocolError"),c.oneOfGetter=function(o){for(var s={},u=0;u<o.length;++u)s[o[u]]=1;return function(){for(var p=Object.keys(this),w=p.length-1;w>-1;--w)if(s[p[w]]===1&&this[p[w]]!==void 0&&this[p[w]]!==null)return p[w]}},c.oneOfSetter=function(o){return function(s){for(var u=0;u<o.length;++u)o[u]!==s&&delete this[o[u]]}},c.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},c._configure=function(){var i=c.Buffer;if(!i){c._Buffer_from=c._Buffer_allocUnsafe=null;return}c._Buffer_from=i.from!==Uint8Array.from&&i.from||function(s,u){return new i(s,u)},c._Buffer_allocUnsafe=i.allocUnsafe||function(s){return new i(s)}}})(re)),re}var we,$e;function ct(){if($e)return we;$e=1,we=u;var r=X(),c,e=r.LongBits,t=r.base64,n=r.utf8;function i(R,v,P){this.fn=R,this.len=v,this.next=void 0,this.val=P}function o(){}function s(R){this.head=R.head,this.tail=R.tail,this.len=R.len,this.next=R.states}function u(){this.len=0,this.head=new i(o,0,0),this.tail=this.head,this.states=null}var p=function(){return r.Buffer?function(){return(u.create=function(){return new c})()}:function(){return new u}};u.create=p(),u.alloc=function(v){return new r.Array(v)},r.Array!==Array&&(u.alloc=r.pool(u.alloc,r.Array.prototype.subarray)),u.prototype._push=function(v,P,j){return this.tail=this.tail.next=new i(v,P,j),this.len+=P,this};function w(R,v,P){v[P]=R&255}function S(R,v,P){for(;R>127;)v[P++]=R&127|128,R>>>=7;v[P]=R}function y(R,v){this.len=R,this.next=void 0,this.val=v}y.prototype=Object.create(i.prototype),y.prototype.fn=S,u.prototype.uint32=function(v){return this.len+=(this.tail=this.tail.next=new y((v=v>>>0)<128?1:v<16384?2:v<2097152?3:v<268435456?4:5,v)).len,this},u.prototype.int32=function(v){return(v|=0)<0?this._push(h,10,e.fromNumber(v)):this.uint32(v)},u.prototype.sint32=function(v){return this.uint32((v<<1^v>>31)>>>0)};function h(R,v,P){for(var j=R.lo,M=R.hi;M;)v[P++]=j&127|128,j=(j>>>7|M<<25)>>>0,M>>>=7;for(;j>127;)v[P++]=j&127|128,j=j>>>7;v[P++]=j}u.prototype.uint64=function(v){var P=e.from(v);return this._push(h,P.length(),P)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(v){var P=e.from(v).zzEncode();return this._push(h,P.length(),P)},u.prototype.bool=function(v){return this._push(w,1,v?1:0)};function b(R,v,P){v[P]=R&255,v[P+1]=R>>>8&255,v[P+2]=R>>>16&255,v[P+3]=R>>>24}u.prototype.fixed32=function(v){return this._push(b,4,v>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(v){var P=e.from(v);return this._push(b,4,P.lo)._push(b,4,P.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(v){return this._push(r.float.writeFloatLE,4,v)},u.prototype.double=function(v){return this._push(r.float.writeDoubleLE,8,v)};var C=r.Array.prototype.set?function(v,P,j){P.set(v,j)}:function(v,P,j){for(var M=0;M<v.length;++M)P[j+M]=v[M]};return u.prototype.bytes=function(v){var P=v.length>>>0;if(!P)return this._push(w,1,0);if(r.isString(v)){var j=u.alloc(P=t.length(v));t.decode(v,j,0),v=j}return this.uint32(P)._push(C,P,v)},u.prototype.string=function(v){var P=n.length(v);return P?this.uint32(P)._push(n.write,P,v):this._push(w,1,0)},u.prototype.fork=function(){return this.states=new s(this),this.head=this.tail=new i(o,0,0),this.len=0,this},u.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new i(o,0,0),this.len=0),this},u.prototype.ldelim=function(){var v=this.head,P=this.tail,j=this.len;return this.reset().uint32(j),j&&(this.tail.next=v.next,this.tail=P,this.len+=j),this},u.prototype.finish=function(){for(var v=this.head.next,P=this.constructor.alloc(this.len),j=0;v;)v.fn(v.val,P,j),j+=v.len,v=v.next;return P},u._configure=function(R){c=R,u.create=p(),c._configure()},we}var ve,Ke;function vt(){if(Ke)return ve;Ke=1,ve=e;var r=ct();(e.prototype=Object.create(r.prototype)).constructor=e;var c=X();function e(){r.call(this)}e._configure=function(){e.alloc=c._Buffer_allocUnsafe,e.writeBytesBuffer=c.Buffer&&c.Buffer.prototype instanceof Uint8Array&&c.Buffer.prototype.set.name==="set"?function(i,o,s){o.set(i,s)}:function(i,o,s){if(i.copy)i.copy(o,s,0,i.length);else for(var u=0;u<i.length;)o[s++]=i[u++]}},e.prototype.bytes=function(i){c.isString(i)&&(i=c._Buffer_from(i,"base64"));var o=i.length>>>0;return this.uint32(o),o&&this._push(e.writeBytesBuffer,o,i),this};function t(n,i,o){n.length<40?c.utf8.write(n,i,o):i.utf8Write?i.utf8Write(n,o):i.write(n,o)}return e.prototype.string=function(i){var o=c.Buffer.byteLength(i);return this.uint32(o),o&&this._push(t,o,i),this},e._configure(),ve}var ke,ze;function ot(){if(ze)return ke;ze=1,ke=i;var r=X(),c,e=r.LongBits,t=r.utf8;function n(y,h){return RangeError("index out of range: "+y.pos+" + "+(h||1)+" > "+y.len)}function i(y){this.buf=y,this.pos=0,this.len=y.length}var o=typeof Uint8Array<"u"?function(h){if(h instanceof Uint8Array||Array.isArray(h))return new i(h);throw Error("illegal buffer")}:function(h){if(Array.isArray(h))return new i(h);throw Error("illegal buffer")},s=function(){return r.Buffer?function(b){return(i.create=function(R){return r.Buffer.isBuffer(R)?new c(R):o(R)})(b)}:o};i.create=s(),i.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice;function u(y){for(var h=0,b=0;b<4;++b){if(y.pos>=y.len)throw n(y);var C=y.buf[y.pos++];if(h=(h|(C&127)<<b*7)>>>0,C<128)return h}throw n(y)}i.prototype.uint32=(function(){var h=4294967295;return function(){if(this.len-this.pos<5){if(this.pos>=this.len)throw n(this);if(this.buf[this.pos]>=128)return u(this)}if(h=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(h=(h|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(h=(h|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return h;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return h}})(),i.prototype.int32=function(){return this.uint32()|0},i.prototype.sint32=function(){var h=this.uint32();return h>>>1^-(h&1)|0};function p(){var y=new e(0,0),h=0;if(this.len-this.pos>4){for(;h<4;++h)if(y.lo=(y.lo|(this.buf[this.pos]&127)<<h*7)>>>0,this.buf[this.pos++]<128)return y;if(y.lo=(y.lo|(this.buf[this.pos]&127)<<28)>>>0,y.hi=(y.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return y;h=0}else{for(;h<3;++h){if(this.pos>=this.len)throw n(this);if(y.lo=(y.lo|(this.buf[this.pos]&127)<<h*7)>>>0,this.buf[this.pos++]<128)return y}return y.lo=(y.lo|(this.buf[this.pos++]&127)<<h*7)>>>0,y}if(this.len-this.pos>4){for(;h<5;++h)if(y.hi=(y.hi|(this.buf[this.pos]&127)<<h*7+3)>>>0,this.buf[this.pos++]<128)return y}else for(;h<5;++h){if(this.pos>=this.len)throw n(this);if(y.hi=(y.hi|(this.buf[this.pos]&127)<<h*7+3)>>>0,this.buf[this.pos++]<128)return y}throw Error("invalid varint encoding")}i.prototype.bool=function(){return this.uint32()!==0};function w(y,h){return(y[h-4]|y[h-3]<<8|y[h-2]<<16|y[h-1]<<24)>>>0}i.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return w(this.buf,this.pos+=4)},i.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return w(this.buf,this.pos+=4)|0};function S(){if(this.pos+8>this.len)throw n(this,8);return new e(w(this.buf,this.pos+=4),w(this.buf,this.pos+=4))}return i.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var h=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,h},i.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var h=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,h},i.prototype.bytes=function(){var h=this.uint32(),b=this.pos,C=this.pos+h;if(C>this.len)throw n(this,h);if(this.pos+=h,Array.isArray(this.buf))return this.buf.slice(b,C);if(b===C){var R=r.Buffer;return R?R.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,b,C)},i.prototype.string=function(){var h=this.bytes();return t.read(h,0,h.length)},i.prototype.skip=function(h){if(typeof h=="number"){if(this.pos+h>this.len)throw n(this,h);this.pos+=h}else do if(this.pos>=this.len)throw n(this);while(this.buf[this.pos++]&128);return this},i.recursionLimit=r.recursionLimit,i.prototype.skipType=function(y,h){if(h===void 0&&(h=0),h>i.recursionLimit)throw Error("maximum nesting depth exceeded");switch(y){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(y=this.uint32()&7)!==4;)this.skipType(y,h+1);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+y+" at offset "+this.pos)}return this},i._configure=function(y){c=y,i.create=s(),c._configure();var h=r.Long?"toLong":"toNumber";r.merge(i.prototype,{int64:function(){return p.call(this)[h](!1)},uint64:function(){return p.call(this)[h](!0)},sint64:function(){return p.call(this).zzDecode()[h](!1)},fixed64:function(){return S.call(this)[h](!0)},sfixed64:function(){return S.call(this)[h](!1)}})},ke}var Re,Ze;function kt(){if(Ze)return Re;Ze=1,Re=e;var r=ot();(e.prototype=Object.create(r.prototype)).constructor=e;var c=X();function e(t){r.call(this,t)}return e._configure=function(){c.Buffer&&(e.prototype._slice=c.Buffer.prototype.slice)},e.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))},e._configure(),Re}var Ce={},Pe,He;function Rt(){if(He)return Pe;He=1,Pe=c;var r=X();(c.prototype=Object.create(r.EventEmitter.prototype)).constructor=c;function c(e,t,n){if(typeof e!="function")throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}return c.prototype.rpcCall=function e(t,n,i,o,s){if(!o)throw TypeError("request must be specified");var u=this;if(!s)return r.asPromise(e,u,t,n,i,o);if(!u.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return u.rpcImpl(t,n[u.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(w,S){if(w)return u.emit("error",w,t),s(w);if(S===null){u.end(!0);return}if(!(S instanceof i))try{S=i[u.responseDelimited?"decodeDelimited":"decode"](S)}catch(y){return u.emit("error",y,t),s(y)}return u.emit("data",S,t),s(null,S)})}catch(p){u.emit("error",p,t),setTimeout(function(){s(p)},0);return}},c.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},Pe}var Xe;function Ct(){return Xe||(Xe=1,(function(r){var c=r;c.Service=Rt()})(Ce)),Ce}var xe,Qe;function Pt(){return Qe||(Qe=1,xe=Object.create(null)),xe}var Ye;function xt(){return Ye||(Ye=1,(function(r){var c=r;c.build="minimal",c.Writer=ct(),c.BufferWriter=vt(),c.Reader=ot(),c.BufferReader=kt(),c.util=X(),c.rpc=Ct(),c.roots=Pt(),c.configure=e;function e(){c.util._configure(),c.Writer._configure(c.BufferWriter),c.Reader._configure(c.BufferReader)}e()})(de)),de}var Ee,qe;function Et(){return qe||(qe=1,Ee=xt()),Ee}var x=Et();const d=x.Reader,E=x.Writer,l=x.util,f=x.roots.default||(x.roots.default={}),K=f.Status=(()=>{const r={},c=Object.create(r);return c[r[0]="Success"]=0,c[r[1]="InvalidSecScheme"]=1,c[r[2]="InvalidProto"]=2,c[r[3]="TooManySessions"]=3,c[r[4]="InvalidArgument"]=4,c[r[5]="InternalError"]=5,c[r[6]="CryptoError"]=6,c[r[7]="InvalidSession"]=7,c})(),_t=f.S0SessionCmd=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S0SessionCmd;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.S0SessionCmd?e:new f.S0SessionCmd},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S0SessionCmd"},r})();f.S0SessionResp=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S0SessionResp;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?s.status=e.int32():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},r.fromObject=function(e,t){if(e instanceof f.S0SessionResp)return e;if(!l.isObject(e))throw TypeError(".S0SessionResp: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.S0SessionResp;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S0SessionResp"},r})();const et=f.Sec0MsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="S0_Session_Command"]=0,c[r[1]="S0_Session_Response"]=1,c})(),jt=f.Sec0Payload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.sc=null,r.prototype.sr=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["sc","sr"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.sc!=null&&Object.hasOwnProperty.call(t,"sc")&&f.S0SessionCmd.encode(t.sc,n.uint32(162).fork(),i+1).ldelim(),t.sr!=null&&Object.hasOwnProperty.call(t,"sr")&&f.S0SessionResp.encode(t.sr,n.uint32(170).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.Sec0Payload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 20:{u.sc=f.S0SessionCmd.decode(t,t.uint32(),void 0,o+1);break}case 21:{u.sr=f.S0SessionResp.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:break}if(t.sc!=null&&Object.hasOwnProperty.call(t,"sc")){i.payload=1;{let o=f.S0SessionCmd.verify(t.sc,n+1);if(o)return"sc."+o}}if(t.sr!=null&&Object.hasOwnProperty.call(t,"sr")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.S0SessionResp.verify(t.sr,n+1);if(o)return"sr."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.Sec0Payload)return t;if(!l.isObject(t))throw TypeError(".Sec0Payload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.Sec0Payload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"S0_Session_Command":case 0:i.msg=0;break;case"S0_Session_Response":case 1:i.msg=1;break}if(t.sc!=null){if(!l.isObject(t.sc))throw TypeError(".Sec0Payload.sc: object expected");i.sc=f.S0SessionCmd.fromObject(t.sc,n+1)}if(t.sr!=null){if(!l.isObject(t.sr))throw TypeError(".Sec0Payload.sr: object expected");i.sr=f.S0SessionResp.fromObject(t.sr,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"S0_Session_Command":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.Sec0MsgType[t.msg]===void 0?t.msg:f.Sec0MsgType[t.msg]:t.msg),t.sc!=null&&Object.hasOwnProperty.call(t,"sc")&&(o.sc=f.S0SessionCmd.toObject(t.sc,n,i+1),n.oneofs&&(o.payload="sc")),t.sr!=null&&Object.hasOwnProperty.call(t,"sr")&&(o.sr=f.S0SessionResp.toObject(t.sr,n,i+1),n.oneofs&&(o.payload="sr")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Sec0Payload"},r})();f.SessionCmd1=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.clientVerifyData=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.clientVerifyData!=null&&Object.hasOwnProperty.call(e,"clientVerifyData")&&t.uint32(18).bytes(e.clientVerifyData),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.SessionCmd1;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===2?s.clientVerifyData=e.bytes():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.clientVerifyData!=null&&Object.hasOwnProperty.call(e,"clientVerifyData")&&!(e.clientVerifyData&&typeof e.clientVerifyData.length=="number"||l.isString(e.clientVerifyData))?"clientVerifyData: buffer expected":null)},r.fromObject=function(e,t){if(e instanceof f.SessionCmd1)return e;if(!l.isObject(e))throw TypeError(".SessionCmd1: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.SessionCmd1;return e.clientVerifyData!=null&&(typeof e.clientVerifyData=="string"?l.base64.decode(e.clientVerifyData,n.clientVerifyData=l.newBuffer(l.base64.length(e.clientVerifyData)),0):e.clientVerifyData.length>=0&&(n.clientVerifyData=e.clientVerifyData)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.clientVerifyData="":(i.clientVerifyData=[],t.bytes!==Array&&(i.clientVerifyData=l.newBuffer(i.clientVerifyData)))),e.clientVerifyData!=null&&Object.hasOwnProperty.call(e,"clientVerifyData")&&(i.clientVerifyData=t.bytes===String?l.base64.encode(e.clientVerifyData,0,e.clientVerifyData.length):t.bytes===Array?Array.prototype.slice.call(e.clientVerifyData):e.clientVerifyData),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/SessionCmd1"},r})();f.SessionResp1=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.prototype.deviceVerifyData=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),e.deviceVerifyData!=null&&Object.hasOwnProperty.call(e,"deviceVerifyData")&&t.uint32(26).bytes(e.deviceVerifyData),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.SessionResp1;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.status=e.int32();break}case 3:{s.deviceVerifyData=e.bytes();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return e.deviceVerifyData!=null&&Object.hasOwnProperty.call(e,"deviceVerifyData")&&!(e.deviceVerifyData&&typeof e.deviceVerifyData.length=="number"||l.isString(e.deviceVerifyData))?"deviceVerifyData: buffer expected":null},r.fromObject=function(e,t){if(e instanceof f.SessionResp1)return e;if(!l.isObject(e))throw TypeError(".SessionResp1: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.SessionResp1;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return e.deviceVerifyData!=null&&(typeof e.deviceVerifyData=="string"?l.base64.decode(e.deviceVerifyData,n.deviceVerifyData=l.newBuffer(l.base64.length(e.deviceVerifyData)),0):e.deviceVerifyData.length>=0&&(n.deviceVerifyData=e.deviceVerifyData)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0,t.bytes===String?i.deviceVerifyData="":(i.deviceVerifyData=[],t.bytes!==Array&&(i.deviceVerifyData=l.newBuffer(i.deviceVerifyData)))),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),e.deviceVerifyData!=null&&Object.hasOwnProperty.call(e,"deviceVerifyData")&&(i.deviceVerifyData=t.bytes===String?l.base64.encode(e.deviceVerifyData,0,e.deviceVerifyData.length):t.bytes===Array?Array.prototype.slice.call(e.deviceVerifyData):e.deviceVerifyData),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/SessionResp1"},r})();f.SessionCmd0=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.clientPubkey=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&t.uint32(10).bytes(e.clientPubkey),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.SessionCmd0;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?s.clientPubkey=e.bytes():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&!(e.clientPubkey&&typeof e.clientPubkey.length=="number"||l.isString(e.clientPubkey))?"clientPubkey: buffer expected":null)},r.fromObject=function(e,t){if(e instanceof f.SessionCmd0)return e;if(!l.isObject(e))throw TypeError(".SessionCmd0: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.SessionCmd0;return e.clientPubkey!=null&&(typeof e.clientPubkey=="string"?l.base64.decode(e.clientPubkey,n.clientPubkey=l.newBuffer(l.base64.length(e.clientPubkey)),0):e.clientPubkey.length>=0&&(n.clientPubkey=e.clientPubkey)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.clientPubkey="":(i.clientPubkey=[],t.bytes!==Array&&(i.clientPubkey=l.newBuffer(i.clientPubkey)))),e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&(i.clientPubkey=t.bytes===String?l.base64.encode(e.clientPubkey,0,e.clientPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.clientPubkey):e.clientPubkey),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/SessionCmd0"},r})();f.SessionResp0=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.prototype.devicePubkey=l.newBuffer([]),r.prototype.deviceRandom=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&t.uint32(18).bytes(e.devicePubkey),e.deviceRandom!=null&&Object.hasOwnProperty.call(e,"deviceRandom")&&t.uint32(26).bytes(e.deviceRandom),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.SessionResp0;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.status=e.int32();break}case 2:{s.devicePubkey=e.bytes();break}case 3:{s.deviceRandom=e.bytes();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&!(e.devicePubkey&&typeof e.devicePubkey.length=="number"||l.isString(e.devicePubkey))?"devicePubkey: buffer expected":e.deviceRandom!=null&&Object.hasOwnProperty.call(e,"deviceRandom")&&!(e.deviceRandom&&typeof e.deviceRandom.length=="number"||l.isString(e.deviceRandom))?"deviceRandom: buffer expected":null},r.fromObject=function(e,t){if(e instanceof f.SessionResp0)return e;if(!l.isObject(e))throw TypeError(".SessionResp0: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.SessionResp0;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return e.devicePubkey!=null&&(typeof e.devicePubkey=="string"?l.base64.decode(e.devicePubkey,n.devicePubkey=l.newBuffer(l.base64.length(e.devicePubkey)),0):e.devicePubkey.length>=0&&(n.devicePubkey=e.devicePubkey)),e.deviceRandom!=null&&(typeof e.deviceRandom=="string"?l.base64.decode(e.deviceRandom,n.deviceRandom=l.newBuffer(l.base64.length(e.deviceRandom)),0):e.deviceRandom.length>=0&&(n.deviceRandom=e.deviceRandom)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0,t.bytes===String?i.devicePubkey="":(i.devicePubkey=[],t.bytes!==Array&&(i.devicePubkey=l.newBuffer(i.devicePubkey))),t.bytes===String?i.deviceRandom="":(i.deviceRandom=[],t.bytes!==Array&&(i.deviceRandom=l.newBuffer(i.deviceRandom)))),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&(i.devicePubkey=t.bytes===String?l.base64.encode(e.devicePubkey,0,e.devicePubkey.length):t.bytes===Array?Array.prototype.slice.call(e.devicePubkey):e.devicePubkey),e.deviceRandom!=null&&Object.hasOwnProperty.call(e,"deviceRandom")&&(i.deviceRandom=t.bytes===String?l.base64.encode(e.deviceRandom,0,e.deviceRandom.length):t.bytes===Array?Array.prototype.slice.call(e.deviceRandom):e.deviceRandom),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/SessionResp0"},r})();const ce=f.Sec1MsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="Session_Command0"]=0,c[r[1]="Session_Response0"]=1,c[r[2]="Session_Command1"]=2,c[r[3]="Session_Response1"]=3,c})();f.Sec1Payload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.sc0=null,r.prototype.sr0=null,r.prototype.sc1=null,r.prototype.sr1=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["sc0","sr0","sc1","sr1"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")&&f.SessionCmd0.encode(t.sc0,n.uint32(162).fork(),i+1).ldelim(),t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")&&f.SessionResp0.encode(t.sr0,n.uint32(170).fork(),i+1).ldelim(),t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")&&f.SessionCmd1.encode(t.sc1,n.uint32(178).fork(),i+1).ldelim(),t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")&&f.SessionResp1.encode(t.sr1,n.uint32(186).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.Sec1Payload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 20:{u.sc0=f.SessionCmd0.decode(t,t.uint32(),void 0,o+1);break}case 21:{u.sr0=f.SessionResp0.decode(t,t.uint32(),void 0,o+1);break}case 22:{u.sc1=f.SessionCmd1.decode(t,t.uint32(),void 0,o+1);break}case 23:{u.sr1=f.SessionResp1.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:break}if(t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")){i.payload=1;{let o=f.SessionCmd0.verify(t.sc0,n+1);if(o)return"sc0."+o}}if(t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.SessionResp0.verify(t.sr0,n+1);if(o)return"sr0."+o}}if(t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.SessionCmd1.verify(t.sc1,n+1);if(o)return"sc1."+o}}if(t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.SessionResp1.verify(t.sr1,n+1);if(o)return"sr1."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.Sec1Payload)return t;if(!l.isObject(t))throw TypeError(".Sec1Payload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.Sec1Payload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"Session_Command0":case 0:i.msg=0;break;case"Session_Response0":case 1:i.msg=1;break;case"Session_Command1":case 2:i.msg=2;break;case"Session_Response1":case 3:i.msg=3;break}if(t.sc0!=null){if(!l.isObject(t.sc0))throw TypeError(".Sec1Payload.sc0: object expected");i.sc0=f.SessionCmd0.fromObject(t.sc0,n+1)}if(t.sr0!=null){if(!l.isObject(t.sr0))throw TypeError(".Sec1Payload.sr0: object expected");i.sr0=f.SessionResp0.fromObject(t.sr0,n+1)}if(t.sc1!=null){if(!l.isObject(t.sc1))throw TypeError(".Sec1Payload.sc1: object expected");i.sc1=f.SessionCmd1.fromObject(t.sc1,n+1)}if(t.sr1!=null){if(!l.isObject(t.sr1))throw TypeError(".Sec1Payload.sr1: object expected");i.sr1=f.SessionResp1.fromObject(t.sr1,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"Session_Command0":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.Sec1MsgType[t.msg]===void 0?t.msg:f.Sec1MsgType[t.msg]:t.msg),t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")&&(o.sc0=f.SessionCmd0.toObject(t.sc0,n,i+1),n.oneofs&&(o.payload="sc0")),t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")&&(o.sr0=f.SessionResp0.toObject(t.sr0,n,i+1),n.oneofs&&(o.payload="sr0")),t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")&&(o.sc1=f.SessionCmd1.toObject(t.sc1,n,i+1),n.oneofs&&(o.payload="sc1")),t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")&&(o.sr1=f.SessionResp1.toObject(t.sr1,n,i+1),n.oneofs&&(o.payload="sr1")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Sec1Payload"},r})();f.Sec2MsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="S2Session_Command0"]=0,c[r[1]="S2Session_Response0"]=1,c[r[2]="S2Session_Command1"]=2,c[r[3]="S2Session_Response1"]=3,c})();f.S2SessionCmd0=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.clientUsername=l.newBuffer([]),r.prototype.clientPubkey=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.clientUsername!=null&&Object.hasOwnProperty.call(e,"clientUsername")&&t.uint32(10).bytes(e.clientUsername),e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&t.uint32(18).bytes(e.clientPubkey),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S2SessionCmd0;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.clientUsername=e.bytes();break}case 2:{s.clientPubkey=e.bytes();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.clientUsername!=null&&Object.hasOwnProperty.call(e,"clientUsername")&&!(e.clientUsername&&typeof e.clientUsername.length=="number"||l.isString(e.clientUsername))?"clientUsername: buffer expected":e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&!(e.clientPubkey&&typeof e.clientPubkey.length=="number"||l.isString(e.clientPubkey))?"clientPubkey: buffer expected":null)},r.fromObject=function(e,t){if(e instanceof f.S2SessionCmd0)return e;if(!l.isObject(e))throw TypeError(".S2SessionCmd0: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.S2SessionCmd0;return e.clientUsername!=null&&(typeof e.clientUsername=="string"?l.base64.decode(e.clientUsername,n.clientUsername=l.newBuffer(l.base64.length(e.clientUsername)),0):e.clientUsername.length>=0&&(n.clientUsername=e.clientUsername)),e.clientPubkey!=null&&(typeof e.clientPubkey=="string"?l.base64.decode(e.clientPubkey,n.clientPubkey=l.newBuffer(l.base64.length(e.clientPubkey)),0):e.clientPubkey.length>=0&&(n.clientPubkey=e.clientPubkey)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.clientUsername="":(i.clientUsername=[],t.bytes!==Array&&(i.clientUsername=l.newBuffer(i.clientUsername))),t.bytes===String?i.clientPubkey="":(i.clientPubkey=[],t.bytes!==Array&&(i.clientPubkey=l.newBuffer(i.clientPubkey)))),e.clientUsername!=null&&Object.hasOwnProperty.call(e,"clientUsername")&&(i.clientUsername=t.bytes===String?l.base64.encode(e.clientUsername,0,e.clientUsername.length):t.bytes===Array?Array.prototype.slice.call(e.clientUsername):e.clientUsername),e.clientPubkey!=null&&Object.hasOwnProperty.call(e,"clientPubkey")&&(i.clientPubkey=t.bytes===String?l.base64.encode(e.clientPubkey,0,e.clientPubkey.length):t.bytes===Array?Array.prototype.slice.call(e.clientPubkey):e.clientPubkey),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S2SessionCmd0"},r})();f.S2SessionResp0=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.prototype.devicePubkey=l.newBuffer([]),r.prototype.deviceSalt=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&t.uint32(18).bytes(e.devicePubkey),e.deviceSalt!=null&&Object.hasOwnProperty.call(e,"deviceSalt")&&t.uint32(26).bytes(e.deviceSalt),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S2SessionResp0;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.status=e.int32();break}case 2:{s.devicePubkey=e.bytes();break}case 3:{s.deviceSalt=e.bytes();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&!(e.devicePubkey&&typeof e.devicePubkey.length=="number"||l.isString(e.devicePubkey))?"devicePubkey: buffer expected":e.deviceSalt!=null&&Object.hasOwnProperty.call(e,"deviceSalt")&&!(e.deviceSalt&&typeof e.deviceSalt.length=="number"||l.isString(e.deviceSalt))?"deviceSalt: buffer expected":null},r.fromObject=function(e,t){if(e instanceof f.S2SessionResp0)return e;if(!l.isObject(e))throw TypeError(".S2SessionResp0: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.S2SessionResp0;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return e.devicePubkey!=null&&(typeof e.devicePubkey=="string"?l.base64.decode(e.devicePubkey,n.devicePubkey=l.newBuffer(l.base64.length(e.devicePubkey)),0):e.devicePubkey.length>=0&&(n.devicePubkey=e.devicePubkey)),e.deviceSalt!=null&&(typeof e.deviceSalt=="string"?l.base64.decode(e.deviceSalt,n.deviceSalt=l.newBuffer(l.base64.length(e.deviceSalt)),0):e.deviceSalt.length>=0&&(n.deviceSalt=e.deviceSalt)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0,t.bytes===String?i.devicePubkey="":(i.devicePubkey=[],t.bytes!==Array&&(i.devicePubkey=l.newBuffer(i.devicePubkey))),t.bytes===String?i.deviceSalt="":(i.deviceSalt=[],t.bytes!==Array&&(i.deviceSalt=l.newBuffer(i.deviceSalt)))),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),e.devicePubkey!=null&&Object.hasOwnProperty.call(e,"devicePubkey")&&(i.devicePubkey=t.bytes===String?l.base64.encode(e.devicePubkey,0,e.devicePubkey.length):t.bytes===Array?Array.prototype.slice.call(e.devicePubkey):e.devicePubkey),e.deviceSalt!=null&&Object.hasOwnProperty.call(e,"deviceSalt")&&(i.deviceSalt=t.bytes===String?l.base64.encode(e.deviceSalt,0,e.deviceSalt.length):t.bytes===Array?Array.prototype.slice.call(e.deviceSalt):e.deviceSalt),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S2SessionResp0"},r})();f.S2SessionCmd1=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.clientProof=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.clientProof!=null&&Object.hasOwnProperty.call(e,"clientProof")&&t.uint32(10).bytes(e.clientProof),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S2SessionCmd1;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?s.clientProof=e.bytes():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.clientProof!=null&&Object.hasOwnProperty.call(e,"clientProof")&&!(e.clientProof&&typeof e.clientProof.length=="number"||l.isString(e.clientProof))?"clientProof: buffer expected":null)},r.fromObject=function(e,t){if(e instanceof f.S2SessionCmd1)return e;if(!l.isObject(e))throw TypeError(".S2SessionCmd1: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.S2SessionCmd1;return e.clientProof!=null&&(typeof e.clientProof=="string"?l.base64.decode(e.clientProof,n.clientProof=l.newBuffer(l.base64.length(e.clientProof)),0):e.clientProof.length>=0&&(n.clientProof=e.clientProof)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.clientProof="":(i.clientProof=[],t.bytes!==Array&&(i.clientProof=l.newBuffer(i.clientProof)))),e.clientProof!=null&&Object.hasOwnProperty.call(e,"clientProof")&&(i.clientProof=t.bytes===String?l.base64.encode(e.clientProof,0,e.clientProof.length):t.bytes===Array?Array.prototype.slice.call(e.clientProof):e.clientProof),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S2SessionCmd1"},r})();f.S2SessionResp1=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.prototype.deviceProof=l.newBuffer([]),r.prototype.deviceNonce=l.newBuffer([]),r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),e.deviceProof!=null&&Object.hasOwnProperty.call(e,"deviceProof")&&t.uint32(18).bytes(e.deviceProof),e.deviceNonce!=null&&Object.hasOwnProperty.call(e,"deviceNonce")&&t.uint32(26).bytes(e.deviceNonce),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.S2SessionResp1;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.status=e.int32();break}case 2:{s.deviceProof=e.bytes();break}case 3:{s.deviceNonce=e.bytes();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return e.deviceProof!=null&&Object.hasOwnProperty.call(e,"deviceProof")&&!(e.deviceProof&&typeof e.deviceProof.length=="number"||l.isString(e.deviceProof))?"deviceProof: buffer expected":e.deviceNonce!=null&&Object.hasOwnProperty.call(e,"deviceNonce")&&!(e.deviceNonce&&typeof e.deviceNonce.length=="number"||l.isString(e.deviceNonce))?"deviceNonce: buffer expected":null},r.fromObject=function(e,t){if(e instanceof f.S2SessionResp1)return e;if(!l.isObject(e))throw TypeError(".S2SessionResp1: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.S2SessionResp1;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return e.deviceProof!=null&&(typeof e.deviceProof=="string"?l.base64.decode(e.deviceProof,n.deviceProof=l.newBuffer(l.base64.length(e.deviceProof)),0):e.deviceProof.length>=0&&(n.deviceProof=e.deviceProof)),e.deviceNonce!=null&&(typeof e.deviceNonce=="string"?l.base64.decode(e.deviceNonce,n.deviceNonce=l.newBuffer(l.base64.length(e.deviceNonce)),0):e.deviceNonce.length>=0&&(n.deviceNonce=e.deviceNonce)),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0,t.bytes===String?i.deviceProof="":(i.deviceProof=[],t.bytes!==Array&&(i.deviceProof=l.newBuffer(i.deviceProof))),t.bytes===String?i.deviceNonce="":(i.deviceNonce=[],t.bytes!==Array&&(i.deviceNonce=l.newBuffer(i.deviceNonce)))),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),e.deviceProof!=null&&Object.hasOwnProperty.call(e,"deviceProof")&&(i.deviceProof=t.bytes===String?l.base64.encode(e.deviceProof,0,e.deviceProof.length):t.bytes===Array?Array.prototype.slice.call(e.deviceProof):e.deviceProof),e.deviceNonce!=null&&Object.hasOwnProperty.call(e,"deviceNonce")&&(i.deviceNonce=t.bytes===String?l.base64.encode(e.deviceNonce,0,e.deviceNonce.length):t.bytes===Array?Array.prototype.slice.call(e.deviceNonce):e.deviceNonce),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/S2SessionResp1"},r})();f.Sec2Payload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.sc0=null,r.prototype.sr0=null,r.prototype.sc1=null,r.prototype.sr1=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["sc0","sr0","sc1","sr1"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")&&f.S2SessionCmd0.encode(t.sc0,n.uint32(162).fork(),i+1).ldelim(),t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")&&f.S2SessionResp0.encode(t.sr0,n.uint32(170).fork(),i+1).ldelim(),t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")&&f.S2SessionCmd1.encode(t.sc1,n.uint32(178).fork(),i+1).ldelim(),t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")&&f.S2SessionResp1.encode(t.sr1,n.uint32(186).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.Sec2Payload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 20:{u.sc0=f.S2SessionCmd0.decode(t,t.uint32(),void 0,o+1);break}case 21:{u.sr0=f.S2SessionResp0.decode(t,t.uint32(),void 0,o+1);break}case 22:{u.sc1=f.S2SessionCmd1.decode(t,t.uint32(),void 0,o+1);break}case 23:{u.sr1=f.S2SessionResp1.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:break}if(t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")){i.payload=1;{let o=f.S2SessionCmd0.verify(t.sc0,n+1);if(o)return"sc0."+o}}if(t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.S2SessionResp0.verify(t.sr0,n+1);if(o)return"sr0."+o}}if(t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.S2SessionCmd1.verify(t.sc1,n+1);if(o)return"sc1."+o}}if(t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.S2SessionResp1.verify(t.sr1,n+1);if(o)return"sr1."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.Sec2Payload)return t;if(!l.isObject(t))throw TypeError(".Sec2Payload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.Sec2Payload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"S2Session_Command0":case 0:i.msg=0;break;case"S2Session_Response0":case 1:i.msg=1;break;case"S2Session_Command1":case 2:i.msg=2;break;case"S2Session_Response1":case 3:i.msg=3;break}if(t.sc0!=null){if(!l.isObject(t.sc0))throw TypeError(".Sec2Payload.sc0: object expected");i.sc0=f.S2SessionCmd0.fromObject(t.sc0,n+1)}if(t.sr0!=null){if(!l.isObject(t.sr0))throw TypeError(".Sec2Payload.sr0: object expected");i.sr0=f.S2SessionResp0.fromObject(t.sr0,n+1)}if(t.sc1!=null){if(!l.isObject(t.sc1))throw TypeError(".Sec2Payload.sc1: object expected");i.sc1=f.S2SessionCmd1.fromObject(t.sc1,n+1)}if(t.sr1!=null){if(!l.isObject(t.sr1))throw TypeError(".Sec2Payload.sr1: object expected");i.sr1=f.S2SessionResp1.fromObject(t.sr1,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"S2Session_Command0":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.Sec2MsgType[t.msg]===void 0?t.msg:f.Sec2MsgType[t.msg]:t.msg),t.sc0!=null&&Object.hasOwnProperty.call(t,"sc0")&&(o.sc0=f.S2SessionCmd0.toObject(t.sc0,n,i+1),n.oneofs&&(o.payload="sc0")),t.sr0!=null&&Object.hasOwnProperty.call(t,"sr0")&&(o.sr0=f.S2SessionResp0.toObject(t.sr0,n,i+1),n.oneofs&&(o.payload="sr0")),t.sc1!=null&&Object.hasOwnProperty.call(t,"sc1")&&(o.sc1=f.S2SessionCmd1.toObject(t.sc1,n,i+1),n.oneofs&&(o.payload="sc1")),t.sr1!=null&&Object.hasOwnProperty.call(t,"sr1")&&(o.sr1=f.S2SessionResp1.toObject(t.sr1,n,i+1),n.oneofs&&(o.payload="sr1")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Sec2Payload"},r})();const ne=f.SecSchemeVersion=(()=>{const r={},c=Object.create(r);return c[r[0]="SecScheme0"]=0,c[r[1]="SecScheme1"]=1,c[r[2]="SecScheme2"]=2,c})(),ee=f.SessionData=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.secVer=0,r.prototype.sec0=null,r.prototype.sec1=null,r.prototype.sec2=null;let c;return Object.defineProperty(r.prototype,"proto",{get:l.oneOfGetter(c=["sec0","sec1","sec2"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.secVer!=null&&Object.hasOwnProperty.call(t,"secVer")&&n.uint32(16).int32(t.secVer),t.sec0!=null&&Object.hasOwnProperty.call(t,"sec0")&&f.Sec0Payload.encode(t.sec0,n.uint32(82).fork(),i+1).ldelim(),t.sec1!=null&&Object.hasOwnProperty.call(t,"sec1")&&f.Sec1Payload.encode(t.sec1,n.uint32(90).fork(),i+1).ldelim(),t.sec2!=null&&Object.hasOwnProperty.call(t,"sec2")&&f.Sec2Payload.encode(t.sec2,n.uint32(98).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.SessionData;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 2:{u.secVer=t.int32();break}case 10:{u.sec0=f.Sec0Payload.decode(t,t.uint32(),void 0,o+1);break}case 11:{u.sec1=f.Sec1Payload.decode(t,t.uint32(),void 0,o+1);break}case 12:{u.sec2=f.Sec2Payload.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.secVer!=null&&Object.hasOwnProperty.call(t,"secVer"))switch(t.secVer){default:return"secVer: enum value expected";case 0:case 1:case 2:break}if(t.sec0!=null&&Object.hasOwnProperty.call(t,"sec0")){i.proto=1;{let o=f.Sec0Payload.verify(t.sec0,n+1);if(o)return"sec0."+o}}if(t.sec1!=null&&Object.hasOwnProperty.call(t,"sec1")){if(i.proto===1)return"proto: multiple values";i.proto=1;{let o=f.Sec1Payload.verify(t.sec1,n+1);if(o)return"sec1."+o}}if(t.sec2!=null&&Object.hasOwnProperty.call(t,"sec2")){if(i.proto===1)return"proto: multiple values";i.proto=1;{let o=f.Sec2Payload.verify(t.sec2,n+1);if(o)return"sec2."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.SessionData)return t;if(!l.isObject(t))throw TypeError(".SessionData: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.SessionData;switch(t.secVer){default:if(typeof t.secVer=="number"){i.secVer=t.secVer;break}break;case"SecScheme0":case 0:i.secVer=0;break;case"SecScheme1":case 1:i.secVer=1;break;case"SecScheme2":case 2:i.secVer=2;break}if(t.sec0!=null){if(!l.isObject(t.sec0))throw TypeError(".SessionData.sec0: object expected");i.sec0=f.Sec0Payload.fromObject(t.sec0,n+1)}if(t.sec1!=null){if(!l.isObject(t.sec1))throw TypeError(".SessionData.sec1: object expected");i.sec1=f.Sec1Payload.fromObject(t.sec1,n+1)}if(t.sec2!=null){if(!l.isObject(t.sec2))throw TypeError(".SessionData.sec2: object expected");i.sec2=f.Sec2Payload.fromObject(t.sec2,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.secVer=n.enums===String?"SecScheme0":0),t.secVer!=null&&Object.hasOwnProperty.call(t,"secVer")&&(o.secVer=n.enums===String?f.SecSchemeVersion[t.secVer]===void 0?t.secVer:f.SecSchemeVersion[t.secVer]:t.secVer),t.sec0!=null&&Object.hasOwnProperty.call(t,"sec0")&&(o.sec0=f.Sec0Payload.toObject(t.sec0,n,i+1),n.oneofs&&(o.proto="sec0")),t.sec1!=null&&Object.hasOwnProperty.call(t,"sec1")&&(o.sec1=f.Sec1Payload.toObject(t.sec1,n,i+1),n.oneofs&&(o.proto="sec1")),t.sec2!=null&&Object.hasOwnProperty.call(t,"sec2")&&(o.sec2=f.Sec2Payload.toObject(t.sec2,n,i+1),n.oneofs&&(o.proto="sec2")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/SessionData"},r})(),Tt=f.CmdGetStatus=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdGetStatus;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.CmdGetStatus?e:new f.CmdGetStatus},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdGetStatus"},r})();f.RespGetStatus=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.status=0,r.prototype.staState=0,r.prototype.failReason=null,r.prototype.connected=null;let c;return Object.defineProperty(r.prototype,"state",{get:l.oneOfGetter(c=["failReason","connected"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.status!=null&&Object.hasOwnProperty.call(t,"status")&&n.uint32(8).int32(t.status),t.staState!=null&&Object.hasOwnProperty.call(t,"staState")&&n.uint32(16).int32(t.staState),t.failReason!=null&&Object.hasOwnProperty.call(t,"failReason")&&n.uint32(80).int32(t.failReason),t.connected!=null&&Object.hasOwnProperty.call(t,"connected")&&f.WifiConnectedState.encode(t.connected,n.uint32(90).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.RespGetStatus;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.status=t.int32();break}case 2:{u.staState=t.int32();break}case 10:{u.failReason=t.int32();break}case 11:{u.connected=f.WifiConnectedState.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.status!=null&&Object.hasOwnProperty.call(t,"status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(t.staState!=null&&Object.hasOwnProperty.call(t,"staState"))switch(t.staState){default:return"staState: enum value expected";case 0:case 1:case 2:case 3:break}if(t.failReason!=null&&Object.hasOwnProperty.call(t,"failReason"))switch(i.state=1,t.failReason){default:return"failReason: enum value expected";case 0:case 1:break}if(t.connected!=null&&Object.hasOwnProperty.call(t,"connected")){if(i.state===1)return"state: multiple values";i.state=1;{let o=f.WifiConnectedState.verify(t.connected,n+1);if(o)return"connected."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.RespGetStatus)return t;if(!l.isObject(t))throw TypeError(".RespGetStatus: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.RespGetStatus;switch(t.status){default:if(typeof t.status=="number"){i.status=t.status;break}break;case"Success":case 0:i.status=0;break;case"InvalidSecScheme":case 1:i.status=1;break;case"InvalidProto":case 2:i.status=2;break;case"TooManySessions":case 3:i.status=3;break;case"InvalidArgument":case 4:i.status=4;break;case"InternalError":case 5:i.status=5;break;case"CryptoError":case 6:i.status=6;break;case"InvalidSession":case 7:i.status=7;break}switch(t.staState){default:if(typeof t.staState=="number"){i.staState=t.staState;break}break;case"Connected":case 0:i.staState=0;break;case"Connecting":case 1:i.staState=1;break;case"Disconnected":case 2:i.staState=2;break;case"ConnectionFailed":case 3:i.staState=3;break}switch(t.failReason){default:if(typeof t.failReason=="number"){i.failReason=t.failReason;break}break;case"AuthError":case 0:i.failReason=0;break;case"NetworkNotFound":case 1:i.failReason=1;break}if(t.connected!=null){if(!l.isObject(t.connected))throw TypeError(".RespGetStatus.connected: object expected");i.connected=f.WifiConnectedState.fromObject(t.connected,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.status=n.enums===String?"Success":0,o.staState=n.enums===String?"Connected":0),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&(o.status=n.enums===String?f.Status[t.status]===void 0?t.status:f.Status[t.status]:t.status),t.staState!=null&&Object.hasOwnProperty.call(t,"staState")&&(o.staState=n.enums===String?f.WifiStationState[t.staState]===void 0?t.staState:f.WifiStationState[t.staState]:t.staState),t.failReason!=null&&Object.hasOwnProperty.call(t,"failReason")&&(o.failReason=n.enums===String?f.WifiConnectFailedReason[t.failReason]===void 0?t.failReason:f.WifiConnectFailedReason[t.failReason]:t.failReason,n.oneofs&&(o.state="failReason")),t.connected!=null&&Object.hasOwnProperty.call(t,"connected")&&(o.connected=f.WifiConnectedState.toObject(t.connected,n,i+1),n.oneofs&&(o.state="connected")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/RespGetStatus"},r})();const gt=f.CmdSetConfig=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.ssid=l.newBuffer([]),r.prototype.passphrase=l.newBuffer([]),r.prototype.bssid=l.newBuffer([]),r.prototype.channel=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&t.uint32(10).bytes(e.ssid),e.passphrase!=null&&Object.hasOwnProperty.call(e,"passphrase")&&t.uint32(18).bytes(e.passphrase),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&t.uint32(26).bytes(e.bssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&t.uint32(32).int32(e.channel),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdSetConfig;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.ssid=e.bytes();break}case 2:{s.passphrase=e.bytes();break}case 3:{s.bssid=e.bytes();break}case 4:{s.channel=e.int32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&!(e.ssid&&typeof e.ssid.length=="number"||l.isString(e.ssid))?"ssid: buffer expected":e.passphrase!=null&&Object.hasOwnProperty.call(e,"passphrase")&&!(e.passphrase&&typeof e.passphrase.length=="number"||l.isString(e.passphrase))?"passphrase: buffer expected":e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&!(e.bssid&&typeof e.bssid.length=="number"||l.isString(e.bssid))?"bssid: buffer expected":e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&!l.isInteger(e.channel)?"channel: integer expected":null)},r.fromObject=function(e,t){if(e instanceof f.CmdSetConfig)return e;if(!l.isObject(e))throw TypeError(".CmdSetConfig: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.CmdSetConfig;return e.ssid!=null&&(typeof e.ssid=="string"?l.base64.decode(e.ssid,n.ssid=l.newBuffer(l.base64.length(e.ssid)),0):e.ssid.length>=0&&(n.ssid=e.ssid)),e.passphrase!=null&&(typeof e.passphrase=="string"?l.base64.decode(e.passphrase,n.passphrase=l.newBuffer(l.base64.length(e.passphrase)),0):e.passphrase.length>=0&&(n.passphrase=e.passphrase)),e.bssid!=null&&(typeof e.bssid=="string"?l.base64.decode(e.bssid,n.bssid=l.newBuffer(l.base64.length(e.bssid)),0):e.bssid.length>=0&&(n.bssid=e.bssid)),e.channel!=null&&(n.channel=e.channel|0),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.ssid="":(i.ssid=[],t.bytes!==Array&&(i.ssid=l.newBuffer(i.ssid))),t.bytes===String?i.passphrase="":(i.passphrase=[],t.bytes!==Array&&(i.passphrase=l.newBuffer(i.passphrase))),t.bytes===String?i.bssid="":(i.bssid=[],t.bytes!==Array&&(i.bssid=l.newBuffer(i.bssid))),i.channel=0),e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&(i.ssid=t.bytes===String?l.base64.encode(e.ssid,0,e.ssid.length):t.bytes===Array?Array.prototype.slice.call(e.ssid):e.ssid),e.passphrase!=null&&Object.hasOwnProperty.call(e,"passphrase")&&(i.passphrase=t.bytes===String?l.base64.encode(e.passphrase,0,e.passphrase.length):t.bytes===Array?Array.prototype.slice.call(e.passphrase):e.passphrase),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&(i.bssid=t.bytes===String?l.base64.encode(e.bssid,0,e.bssid.length):t.bytes===Array?Array.prototype.slice.call(e.bssid):e.bssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&(i.channel=e.channel),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdSetConfig"},r})();f.RespSetConfig=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespSetConfig;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?s.status=e.int32():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},r.fromObject=function(e,t){if(e instanceof f.RespSetConfig)return e;if(!l.isObject(e))throw TypeError(".RespSetConfig: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.RespSetConfig;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespSetConfig"},r})();const Dt=f.CmdApplyConfig=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdApplyConfig;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.CmdApplyConfig?e:new f.CmdApplyConfig},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdApplyConfig"},r})();f.RespApplyConfig=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.status=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.status!=null&&Object.hasOwnProperty.call(e,"status")&&t.uint32(8).int32(e.status),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespApplyConfig;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?s.status=e.int32():e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.status!=null&&Object.hasOwnProperty.call(e,"status"))switch(e.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},r.fromObject=function(e,t){if(e instanceof f.RespApplyConfig)return e;if(!l.isObject(e))throw TypeError(".RespApplyConfig: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.RespApplyConfig;switch(e.status){default:if(typeof e.status=="number"){n.status=e.status;break}break;case"Success":case 0:n.status=0;break;case"InvalidSecScheme":case 1:n.status=1;break;case"InvalidProto":case 2:n.status=2;break;case"TooManySessions":case 3:n.status=3;break;case"InvalidArgument":case 4:n.status=4;break;case"InternalError":case 5:n.status=5;break;case"CryptoError":case 6:n.status=6;break;case"InvalidSession":case 7:n.status=7;break}return n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.status=t.enums===String?"Success":0),e.status!=null&&Object.hasOwnProperty.call(e,"status")&&(i.status=t.enums===String?f.Status[e.status]===void 0?e.status:f.Status[e.status]:e.status),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespApplyConfig"},r})();const Te=f.WiFiConfigMsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="TypeCmdGetStatus"]=0,c[r[1]="TypeRespGetStatus"]=1,c[r[2]="TypeCmdSetConfig"]=2,c[r[3]="TypeRespSetConfig"]=3,c[r[4]="TypeCmdApplyConfig"]=4,c[r[5]="TypeRespApplyConfig"]=5,c})(),z=f.WiFiConfigPayload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.cmdGetStatus=null,r.prototype.respGetStatus=null,r.prototype.cmdSetConfig=null,r.prototype.respSetConfig=null,r.prototype.cmdApplyConfig=null,r.prototype.respApplyConfig=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["cmdGetStatus","respGetStatus","cmdSetConfig","respSetConfig","cmdApplyConfig","respApplyConfig"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.cmdGetStatus!=null&&Object.hasOwnProperty.call(t,"cmdGetStatus")&&f.CmdGetStatus.encode(t.cmdGetStatus,n.uint32(82).fork(),i+1).ldelim(),t.respGetStatus!=null&&Object.hasOwnProperty.call(t,"respGetStatus")&&f.RespGetStatus.encode(t.respGetStatus,n.uint32(90).fork(),i+1).ldelim(),t.cmdSetConfig!=null&&Object.hasOwnProperty.call(t,"cmdSetConfig")&&f.CmdSetConfig.encode(t.cmdSetConfig,n.uint32(98).fork(),i+1).ldelim(),t.respSetConfig!=null&&Object.hasOwnProperty.call(t,"respSetConfig")&&f.RespSetConfig.encode(t.respSetConfig,n.uint32(106).fork(),i+1).ldelim(),t.cmdApplyConfig!=null&&Object.hasOwnProperty.call(t,"cmdApplyConfig")&&f.CmdApplyConfig.encode(t.cmdApplyConfig,n.uint32(114).fork(),i+1).ldelim(),t.respApplyConfig!=null&&Object.hasOwnProperty.call(t,"respApplyConfig")&&f.RespApplyConfig.encode(t.respApplyConfig,n.uint32(122).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.WiFiConfigPayload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 10:{u.cmdGetStatus=f.CmdGetStatus.decode(t,t.uint32(),void 0,o+1);break}case 11:{u.respGetStatus=f.RespGetStatus.decode(t,t.uint32(),void 0,o+1);break}case 12:{u.cmdSetConfig=f.CmdSetConfig.decode(t,t.uint32(),void 0,o+1);break}case 13:{u.respSetConfig=f.RespSetConfig.decode(t,t.uint32(),void 0,o+1);break}case 14:{u.cmdApplyConfig=f.CmdApplyConfig.decode(t,t.uint32(),void 0,o+1);break}case 15:{u.respApplyConfig=f.RespApplyConfig.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:break}if(t.cmdGetStatus!=null&&Object.hasOwnProperty.call(t,"cmdGetStatus")){i.payload=1;{let o=f.CmdGetStatus.verify(t.cmdGetStatus,n+1);if(o)return"cmdGetStatus."+o}}if(t.respGetStatus!=null&&Object.hasOwnProperty.call(t,"respGetStatus")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespGetStatus.verify(t.respGetStatus,n+1);if(o)return"respGetStatus."+o}}if(t.cmdSetConfig!=null&&Object.hasOwnProperty.call(t,"cmdSetConfig")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.CmdSetConfig.verify(t.cmdSetConfig,n+1);if(o)return"cmdSetConfig."+o}}if(t.respSetConfig!=null&&Object.hasOwnProperty.call(t,"respSetConfig")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespSetConfig.verify(t.respSetConfig,n+1);if(o)return"respSetConfig."+o}}if(t.cmdApplyConfig!=null&&Object.hasOwnProperty.call(t,"cmdApplyConfig")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.CmdApplyConfig.verify(t.cmdApplyConfig,n+1);if(o)return"cmdApplyConfig."+o}}if(t.respApplyConfig!=null&&Object.hasOwnProperty.call(t,"respApplyConfig")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespApplyConfig.verify(t.respApplyConfig,n+1);if(o)return"respApplyConfig."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.WiFiConfigPayload)return t;if(!l.isObject(t))throw TypeError(".WiFiConfigPayload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.WiFiConfigPayload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"TypeCmdGetStatus":case 0:i.msg=0;break;case"TypeRespGetStatus":case 1:i.msg=1;break;case"TypeCmdSetConfig":case 2:i.msg=2;break;case"TypeRespSetConfig":case 3:i.msg=3;break;case"TypeCmdApplyConfig":case 4:i.msg=4;break;case"TypeRespApplyConfig":case 5:i.msg=5;break}if(t.cmdGetStatus!=null){if(!l.isObject(t.cmdGetStatus))throw TypeError(".WiFiConfigPayload.cmdGetStatus: object expected");i.cmdGetStatus=f.CmdGetStatus.fromObject(t.cmdGetStatus,n+1)}if(t.respGetStatus!=null){if(!l.isObject(t.respGetStatus))throw TypeError(".WiFiConfigPayload.respGetStatus: object expected");i.respGetStatus=f.RespGetStatus.fromObject(t.respGetStatus,n+1)}if(t.cmdSetConfig!=null){if(!l.isObject(t.cmdSetConfig))throw TypeError(".WiFiConfigPayload.cmdSetConfig: object expected");i.cmdSetConfig=f.CmdSetConfig.fromObject(t.cmdSetConfig,n+1)}if(t.respSetConfig!=null){if(!l.isObject(t.respSetConfig))throw TypeError(".WiFiConfigPayload.respSetConfig: object expected");i.respSetConfig=f.RespSetConfig.fromObject(t.respSetConfig,n+1)}if(t.cmdApplyConfig!=null){if(!l.isObject(t.cmdApplyConfig))throw TypeError(".WiFiConfigPayload.cmdApplyConfig: object expected");i.cmdApplyConfig=f.CmdApplyConfig.fromObject(t.cmdApplyConfig,n+1)}if(t.respApplyConfig!=null){if(!l.isObject(t.respApplyConfig))throw TypeError(".WiFiConfigPayload.respApplyConfig: object expected");i.respApplyConfig=f.RespApplyConfig.fromObject(t.respApplyConfig,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"TypeCmdGetStatus":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.WiFiConfigMsgType[t.msg]===void 0?t.msg:f.WiFiConfigMsgType[t.msg]:t.msg),t.cmdGetStatus!=null&&Object.hasOwnProperty.call(t,"cmdGetStatus")&&(o.cmdGetStatus=f.CmdGetStatus.toObject(t.cmdGetStatus,n,i+1),n.oneofs&&(o.payload="cmdGetStatus")),t.respGetStatus!=null&&Object.hasOwnProperty.call(t,"respGetStatus")&&(o.respGetStatus=f.RespGetStatus.toObject(t.respGetStatus,n,i+1),n.oneofs&&(o.payload="respGetStatus")),t.cmdSetConfig!=null&&Object.hasOwnProperty.call(t,"cmdSetConfig")&&(o.cmdSetConfig=f.CmdSetConfig.toObject(t.cmdSetConfig,n,i+1),n.oneofs&&(o.payload="cmdSetConfig")),t.respSetConfig!=null&&Object.hasOwnProperty.call(t,"respSetConfig")&&(o.respSetConfig=f.RespSetConfig.toObject(t.respSetConfig,n,i+1),n.oneofs&&(o.payload="respSetConfig")),t.cmdApplyConfig!=null&&Object.hasOwnProperty.call(t,"cmdApplyConfig")&&(o.cmdApplyConfig=f.CmdApplyConfig.toObject(t.cmdApplyConfig,n,i+1),n.oneofs&&(o.payload="cmdApplyConfig")),t.respApplyConfig!=null&&Object.hasOwnProperty.call(t,"respApplyConfig")&&(o.respApplyConfig=f.RespApplyConfig.toObject(t.respApplyConfig,n,i+1),n.oneofs&&(o.payload="respApplyConfig")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/WiFiConfigPayload"},r})(),oe=f.WifiStationState=(()=>{const r={},c=Object.create(r);return c[r[0]="Connected"]=0,c[r[1]="Connecting"]=1,c[r[2]="Disconnected"]=2,c[r[3]="ConnectionFailed"]=3,c})(),tt=f.WifiConnectFailedReason=(()=>{const r={},c=Object.create(r);return c[r[0]="AuthError"]=0,c[r[1]="NetworkNotFound"]=1,c})(),H=f.WifiAuthMode=(()=>{const r={},c=Object.create(r);return c[r[0]="Open"]=0,c[r[1]="WEP"]=1,c[r[2]="WPA_PSK"]=2,c[r[3]="WPA2_PSK"]=3,c[r[4]="WPA_WPA2_PSK"]=4,c[r[5]="WPA2_ENTERPRISE"]=5,c[r[6]="WPA3_PSK"]=6,c[r[7]="WPA2_WPA3_PSK"]=7,c})();f.WifiConnectedState=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.ip4Addr="",r.prototype.authMode=0,r.prototype.ssid=l.newBuffer([]),r.prototype.bssid=l.newBuffer([]),r.prototype.channel=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.ip4Addr!=null&&Object.hasOwnProperty.call(e,"ip4Addr")&&t.uint32(10).string(e.ip4Addr),e.authMode!=null&&Object.hasOwnProperty.call(e,"authMode")&&t.uint32(16).int32(e.authMode),e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&t.uint32(26).bytes(e.ssid),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&t.uint32(34).bytes(e.bssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&t.uint32(40).int32(e.channel),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.WifiConnectedState;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.ip4Addr=e.string();break}case 2:{s.authMode=e.int32();break}case 3:{s.ssid=e.bytes();break}case 4:{s.bssid=e.bytes();break}case 5:{s.channel=e.int32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.ip4Addr!=null&&Object.hasOwnProperty.call(e,"ip4Addr")&&!l.isString(e.ip4Addr))return"ip4Addr: string expected";if(e.authMode!=null&&Object.hasOwnProperty.call(e,"authMode"))switch(e.authMode){default:return"authMode: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&!(e.ssid&&typeof e.ssid.length=="number"||l.isString(e.ssid))?"ssid: buffer expected":e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&!(e.bssid&&typeof e.bssid.length=="number"||l.isString(e.bssid))?"bssid: buffer expected":e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&!l.isInteger(e.channel)?"channel: integer expected":null},r.fromObject=function(e,t){if(e instanceof f.WifiConnectedState)return e;if(!l.isObject(e))throw TypeError(".WifiConnectedState: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.WifiConnectedState;switch(e.ip4Addr!=null&&(n.ip4Addr=String(e.ip4Addr)),e.authMode){default:if(typeof e.authMode=="number"){n.authMode=e.authMode;break}break;case"Open":case 0:n.authMode=0;break;case"WEP":case 1:n.authMode=1;break;case"WPA_PSK":case 2:n.authMode=2;break;case"WPA2_PSK":case 3:n.authMode=3;break;case"WPA_WPA2_PSK":case 4:n.authMode=4;break;case"WPA2_ENTERPRISE":case 5:n.authMode=5;break;case"WPA3_PSK":case 6:n.authMode=6;break;case"WPA2_WPA3_PSK":case 7:n.authMode=7;break}return e.ssid!=null&&(typeof e.ssid=="string"?l.base64.decode(e.ssid,n.ssid=l.newBuffer(l.base64.length(e.ssid)),0):e.ssid.length>=0&&(n.ssid=e.ssid)),e.bssid!=null&&(typeof e.bssid=="string"?l.base64.decode(e.bssid,n.bssid=l.newBuffer(l.base64.length(e.bssid)),0):e.bssid.length>=0&&(n.bssid=e.bssid)),e.channel!=null&&(n.channel=e.channel|0),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.ip4Addr="",i.authMode=t.enums===String?"Open":0,t.bytes===String?i.ssid="":(i.ssid=[],t.bytes!==Array&&(i.ssid=l.newBuffer(i.ssid))),t.bytes===String?i.bssid="":(i.bssid=[],t.bytes!==Array&&(i.bssid=l.newBuffer(i.bssid))),i.channel=0),e.ip4Addr!=null&&Object.hasOwnProperty.call(e,"ip4Addr")&&(i.ip4Addr=e.ip4Addr),e.authMode!=null&&Object.hasOwnProperty.call(e,"authMode")&&(i.authMode=t.enums===String?f.WifiAuthMode[e.authMode]===void 0?e.authMode:f.WifiAuthMode[e.authMode]:e.authMode),e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&(i.ssid=t.bytes===String?l.base64.encode(e.ssid,0,e.ssid.length):t.bytes===Array?Array.prototype.slice.call(e.ssid):e.ssid),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&(i.bssid=t.bytes===String?l.base64.encode(e.bssid,0,e.bssid.length):t.bytes===Array?Array.prototype.slice.call(e.bssid):e.bssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&(i.channel=e.channel),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/WifiConnectedState"},r})();f.CmdCtrlReset=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdCtrlReset;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.CmdCtrlReset?e:new f.CmdCtrlReset},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdCtrlReset"},r})();f.RespCtrlReset=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespCtrlReset;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.RespCtrlReset?e:new f.RespCtrlReset},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespCtrlReset"},r})();f.CmdCtrlReprov=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdCtrlReprov;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.CmdCtrlReprov?e:new f.CmdCtrlReprov},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdCtrlReprov"},r})();f.RespCtrlReprov=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespCtrlReprov;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.RespCtrlReprov?e:new f.RespCtrlReprov},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespCtrlReprov"},r})();f.WiFiCtrlMsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="TypeCtrlReserved"]=0,c[r[1]="TypeCmdCtrlReset"]=1,c[r[2]="TypeRespCtrlReset"]=2,c[r[3]="TypeCmdCtrlReprov"]=3,c[r[4]="TypeRespCtrlReprov"]=4,c})();f.WiFiCtrlPayload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.status=0,r.prototype.cmdCtrlReset=null,r.prototype.respCtrlReset=null,r.prototype.cmdCtrlReprov=null,r.prototype.respCtrlReprov=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["cmdCtrlReset","respCtrlReset","cmdCtrlReprov","respCtrlReprov"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&n.uint32(16).int32(t.status),t.cmdCtrlReset!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReset")&&f.CmdCtrlReset.encode(t.cmdCtrlReset,n.uint32(90).fork(),i+1).ldelim(),t.respCtrlReset!=null&&Object.hasOwnProperty.call(t,"respCtrlReset")&&f.RespCtrlReset.encode(t.respCtrlReset,n.uint32(98).fork(),i+1).ldelim(),t.cmdCtrlReprov!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReprov")&&f.CmdCtrlReprov.encode(t.cmdCtrlReprov,n.uint32(106).fork(),i+1).ldelim(),t.respCtrlReprov!=null&&Object.hasOwnProperty.call(t,"respCtrlReprov")&&f.RespCtrlReprov.encode(t.respCtrlReprov,n.uint32(114).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.WiFiCtrlPayload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 2:{u.status=t.int32();break}case 11:{u.cmdCtrlReset=f.CmdCtrlReset.decode(t,t.uint32(),void 0,o+1);break}case 12:{u.respCtrlReset=f.RespCtrlReset.decode(t,t.uint32(),void 0,o+1);break}case 13:{u.cmdCtrlReprov=f.CmdCtrlReprov.decode(t,t.uint32(),void 0,o+1);break}case 14:{u.respCtrlReprov=f.RespCtrlReprov.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:break}if(t.status!=null&&Object.hasOwnProperty.call(t,"status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(t.cmdCtrlReset!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReset")){i.payload=1;{let o=f.CmdCtrlReset.verify(t.cmdCtrlReset,n+1);if(o)return"cmdCtrlReset."+o}}if(t.respCtrlReset!=null&&Object.hasOwnProperty.call(t,"respCtrlReset")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespCtrlReset.verify(t.respCtrlReset,n+1);if(o)return"respCtrlReset."+o}}if(t.cmdCtrlReprov!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReprov")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.CmdCtrlReprov.verify(t.cmdCtrlReprov,n+1);if(o)return"cmdCtrlReprov."+o}}if(t.respCtrlReprov!=null&&Object.hasOwnProperty.call(t,"respCtrlReprov")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespCtrlReprov.verify(t.respCtrlReprov,n+1);if(o)return"respCtrlReprov."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.WiFiCtrlPayload)return t;if(!l.isObject(t))throw TypeError(".WiFiCtrlPayload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.WiFiCtrlPayload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"TypeCtrlReserved":case 0:i.msg=0;break;case"TypeCmdCtrlReset":case 1:i.msg=1;break;case"TypeRespCtrlReset":case 2:i.msg=2;break;case"TypeCmdCtrlReprov":case 3:i.msg=3;break;case"TypeRespCtrlReprov":case 4:i.msg=4;break}switch(t.status){default:if(typeof t.status=="number"){i.status=t.status;break}break;case"Success":case 0:i.status=0;break;case"InvalidSecScheme":case 1:i.status=1;break;case"InvalidProto":case 2:i.status=2;break;case"TooManySessions":case 3:i.status=3;break;case"InvalidArgument":case 4:i.status=4;break;case"InternalError":case 5:i.status=5;break;case"CryptoError":case 6:i.status=6;break;case"InvalidSession":case 7:i.status=7;break}if(t.cmdCtrlReset!=null){if(!l.isObject(t.cmdCtrlReset))throw TypeError(".WiFiCtrlPayload.cmdCtrlReset: object expected");i.cmdCtrlReset=f.CmdCtrlReset.fromObject(t.cmdCtrlReset,n+1)}if(t.respCtrlReset!=null){if(!l.isObject(t.respCtrlReset))throw TypeError(".WiFiCtrlPayload.respCtrlReset: object expected");i.respCtrlReset=f.RespCtrlReset.fromObject(t.respCtrlReset,n+1)}if(t.cmdCtrlReprov!=null){if(!l.isObject(t.cmdCtrlReprov))throw TypeError(".WiFiCtrlPayload.cmdCtrlReprov: object expected");i.cmdCtrlReprov=f.CmdCtrlReprov.fromObject(t.cmdCtrlReprov,n+1)}if(t.respCtrlReprov!=null){if(!l.isObject(t.respCtrlReprov))throw TypeError(".WiFiCtrlPayload.respCtrlReprov: object expected");i.respCtrlReprov=f.RespCtrlReprov.fromObject(t.respCtrlReprov,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"TypeCtrlReserved":0,o.status=n.enums===String?"Success":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.WiFiCtrlMsgType[t.msg]===void 0?t.msg:f.WiFiCtrlMsgType[t.msg]:t.msg),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&(o.status=n.enums===String?f.Status[t.status]===void 0?t.status:f.Status[t.status]:t.status),t.cmdCtrlReset!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReset")&&(o.cmdCtrlReset=f.CmdCtrlReset.toObject(t.cmdCtrlReset,n,i+1),n.oneofs&&(o.payload="cmdCtrlReset")),t.respCtrlReset!=null&&Object.hasOwnProperty.call(t,"respCtrlReset")&&(o.respCtrlReset=f.RespCtrlReset.toObject(t.respCtrlReset,n,i+1),n.oneofs&&(o.payload="respCtrlReset")),t.cmdCtrlReprov!=null&&Object.hasOwnProperty.call(t,"cmdCtrlReprov")&&(o.cmdCtrlReprov=f.CmdCtrlReprov.toObject(t.cmdCtrlReprov,n,i+1),n.oneofs&&(o.payload="cmdCtrlReprov")),t.respCtrlReprov!=null&&Object.hasOwnProperty.call(t,"respCtrlReprov")&&(o.respCtrlReprov=f.RespCtrlReprov.toObject(t.respCtrlReprov,n,i+1),n.oneofs&&(o.payload="respCtrlReprov")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/WiFiCtrlPayload"},r})();const At=f.CmdScanStart=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.blocking=!1,r.prototype.passive=!1,r.prototype.groupChannels=0,r.prototype.periodMs=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.blocking!=null&&Object.hasOwnProperty.call(e,"blocking")&&t.uint32(8).bool(e.blocking),e.passive!=null&&Object.hasOwnProperty.call(e,"passive")&&t.uint32(16).bool(e.passive),e.groupChannels!=null&&Object.hasOwnProperty.call(e,"groupChannels")&&t.uint32(24).uint32(e.groupChannels),e.periodMs!=null&&Object.hasOwnProperty.call(e,"periodMs")&&t.uint32(32).uint32(e.periodMs),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdScanStart;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.blocking=e.bool();break}case 2:{s.passive=e.bool();break}case 3:{s.groupChannels=e.uint32();break}case 4:{s.periodMs=e.uint32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.blocking!=null&&Object.hasOwnProperty.call(e,"blocking")&&typeof e.blocking!="boolean"?"blocking: boolean expected":e.passive!=null&&Object.hasOwnProperty.call(e,"passive")&&typeof e.passive!="boolean"?"passive: boolean expected":e.groupChannels!=null&&Object.hasOwnProperty.call(e,"groupChannels")&&!l.isInteger(e.groupChannels)?"groupChannels: integer expected":e.periodMs!=null&&Object.hasOwnProperty.call(e,"periodMs")&&!l.isInteger(e.periodMs)?"periodMs: integer expected":null)},r.fromObject=function(e,t){if(e instanceof f.CmdScanStart)return e;if(!l.isObject(e))throw TypeError(".CmdScanStart: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.CmdScanStart;return e.blocking!=null&&(n.blocking=!!e.blocking),e.passive!=null&&(n.passive=!!e.passive),e.groupChannels!=null&&(n.groupChannels=e.groupChannels>>>0),e.periodMs!=null&&(n.periodMs=e.periodMs>>>0),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.blocking=!1,i.passive=!1,i.groupChannels=0,i.periodMs=0),e.blocking!=null&&Object.hasOwnProperty.call(e,"blocking")&&(i.blocking=e.blocking),e.passive!=null&&Object.hasOwnProperty.call(e,"passive")&&(i.passive=e.passive),e.groupChannels!=null&&Object.hasOwnProperty.call(e,"groupChannels")&&(i.groupChannels=e.groupChannels),e.periodMs!=null&&Object.hasOwnProperty.call(e,"periodMs")&&(i.periodMs=e.periodMs),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdScanStart"},r})();f.RespScanStart=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespScanStart;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.RespScanStart?e:new f.RespScanStart},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespScanStart"},r})();const Lt=f.CmdScanStatus=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdScanStatus;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":null)},r.fromObject=function(e,t){return e instanceof f.CmdScanStatus?e:new f.CmdScanStatus},r.toObject=function(){return{}},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdScanStatus"},r})();f.RespScanStatus=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.scanFinished=!1,r.prototype.resultCount=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.scanFinished!=null&&Object.hasOwnProperty.call(e,"scanFinished")&&t.uint32(8).bool(e.scanFinished),e.resultCount!=null&&Object.hasOwnProperty.call(e,"resultCount")&&t.uint32(16).uint32(e.resultCount),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespScanStatus;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.scanFinished=e.bool();break}case 2:{s.resultCount=e.uint32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.scanFinished!=null&&Object.hasOwnProperty.call(e,"scanFinished")&&typeof e.scanFinished!="boolean"?"scanFinished: boolean expected":e.resultCount!=null&&Object.hasOwnProperty.call(e,"resultCount")&&!l.isInteger(e.resultCount)?"resultCount: integer expected":null)},r.fromObject=function(e,t){if(e instanceof f.RespScanStatus)return e;if(!l.isObject(e))throw TypeError(".RespScanStatus: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.RespScanStatus;return e.scanFinished!=null&&(n.scanFinished=!!e.scanFinished),e.resultCount!=null&&(n.resultCount=e.resultCount>>>0),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.scanFinished=!1,i.resultCount=0),e.scanFinished!=null&&Object.hasOwnProperty.call(e,"scanFinished")&&(i.scanFinished=e.scanFinished),e.resultCount!=null&&Object.hasOwnProperty.call(e,"resultCount")&&(i.resultCount=e.resultCount),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespScanStatus"},r})();const Nt=f.CmdScanResult=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.startIndex=0,r.prototype.count=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.startIndex!=null&&Object.hasOwnProperty.call(e,"startIndex")&&t.uint32(8).uint32(e.startIndex),e.count!=null&&Object.hasOwnProperty.call(e,"count")&&t.uint32(16).uint32(e.count),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.CmdScanResult;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.startIndex=e.uint32();break}case 2:{s.count=e.uint32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){return typeof e!="object"||e===null?"object expected":(t===void 0&&(t=0),t>l.recursionLimit?"maximum nesting depth exceeded":e.startIndex!=null&&Object.hasOwnProperty.call(e,"startIndex")&&!l.isInteger(e.startIndex)?"startIndex: integer expected":e.count!=null&&Object.hasOwnProperty.call(e,"count")&&!l.isInteger(e.count)?"count: integer expected":null)},r.fromObject=function(e,t){if(e instanceof f.CmdScanResult)return e;if(!l.isObject(e))throw TypeError(".CmdScanResult: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.CmdScanResult;return e.startIndex!=null&&(n.startIndex=e.startIndex>>>0),e.count!=null&&(n.count=e.count>>>0),n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(i.startIndex=0,i.count=0),e.startIndex!=null&&Object.hasOwnProperty.call(e,"startIndex")&&(i.startIndex=e.startIndex),e.count!=null&&Object.hasOwnProperty.call(e,"count")&&(i.count=e.count),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/CmdScanResult"},r})();f.WiFiScanResult=(()=>{function r(c){if(c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.ssid=l.newBuffer([]),r.prototype.channel=0,r.prototype.rssi=0,r.prototype.bssid=l.newBuffer([]),r.prototype.auth=0,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");return e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&t.uint32(10).bytes(e.ssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&t.uint32(16).uint32(e.channel),e.rssi!=null&&Object.hasOwnProperty.call(e,"rssi")&&t.uint32(24).int32(e.rssi),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&t.uint32(34).bytes(e.bssid),e.auth!=null&&Object.hasOwnProperty.call(e,"auth")&&t.uint32(40).int32(e.auth),t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.WiFiScanResult;e.pos<o;){let u=e.uint32();if(u===n)break;switch(u>>>3){case 1:{s.ssid=e.bytes();break}case 2:{s.channel=e.uint32();break}case 3:{s.rssi=e.int32();break}case 4:{s.bssid=e.bytes();break}case 5:{s.auth=e.int32();break}default:e.skipType(u&7,i);break}}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&!(e.ssid&&typeof e.ssid.length=="number"||l.isString(e.ssid)))return"ssid: buffer expected";if(e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&!l.isInteger(e.channel))return"channel: integer expected";if(e.rssi!=null&&Object.hasOwnProperty.call(e,"rssi")&&!l.isInteger(e.rssi))return"rssi: integer expected";if(e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&!(e.bssid&&typeof e.bssid.length=="number"||l.isString(e.bssid)))return"bssid: buffer expected";if(e.auth!=null&&Object.hasOwnProperty.call(e,"auth"))switch(e.auth){default:return"auth: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}return null},r.fromObject=function(e,t){if(e instanceof f.WiFiScanResult)return e;if(!l.isObject(e))throw TypeError(".WiFiScanResult: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.WiFiScanResult;switch(e.ssid!=null&&(typeof e.ssid=="string"?l.base64.decode(e.ssid,n.ssid=l.newBuffer(l.base64.length(e.ssid)),0):e.ssid.length>=0&&(n.ssid=e.ssid)),e.channel!=null&&(n.channel=e.channel>>>0),e.rssi!=null&&(n.rssi=e.rssi|0),e.bssid!=null&&(typeof e.bssid=="string"?l.base64.decode(e.bssid,n.bssid=l.newBuffer(l.base64.length(e.bssid)),0):e.bssid.length>=0&&(n.bssid=e.bssid)),e.auth){default:if(typeof e.auth=="number"){n.auth=e.auth;break}break;case"Open":case 0:n.auth=0;break;case"WEP":case 1:n.auth=1;break;case"WPA_PSK":case 2:n.auth=2;break;case"WPA2_PSK":case 3:n.auth=3;break;case"WPA_WPA2_PSK":case 4:n.auth=4;break;case"WPA2_ENTERPRISE":case 5:n.auth=5;break;case"WPA3_PSK":case 6:n.auth=6;break;case"WPA2_WPA3_PSK":case 7:n.auth=7;break}return n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};return t.defaults&&(t.bytes===String?i.ssid="":(i.ssid=[],t.bytes!==Array&&(i.ssid=l.newBuffer(i.ssid))),i.channel=0,i.rssi=0,t.bytes===String?i.bssid="":(i.bssid=[],t.bytes!==Array&&(i.bssid=l.newBuffer(i.bssid))),i.auth=t.enums===String?"Open":0),e.ssid!=null&&Object.hasOwnProperty.call(e,"ssid")&&(i.ssid=t.bytes===String?l.base64.encode(e.ssid,0,e.ssid.length):t.bytes===Array?Array.prototype.slice.call(e.ssid):e.ssid),e.channel!=null&&Object.hasOwnProperty.call(e,"channel")&&(i.channel=e.channel),e.rssi!=null&&Object.hasOwnProperty.call(e,"rssi")&&(i.rssi=e.rssi),e.bssid!=null&&Object.hasOwnProperty.call(e,"bssid")&&(i.bssid=t.bytes===String?l.base64.encode(e.bssid,0,e.bssid.length):t.bytes===Array?Array.prototype.slice.call(e.bssid):e.bssid),e.auth!=null&&Object.hasOwnProperty.call(e,"auth")&&(i.auth=t.enums===String?f.WifiAuthMode[e.auth]===void 0?e.auth:f.WifiAuthMode[e.auth]:e.auth),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/WiFiScanResult"},r})();f.RespScanResult=(()=>{function r(c){if(this.entries=[],c)for(let e=Object.keys(c),t=0;t<e.length;++t)c[e[t]]!=null&&e[t]!=="__proto__"&&(this[e[t]]=c[e[t]])}return r.prototype.entries=l.emptyArray,r.create=function(e){return new r(e)},r.encode=function(e,t,n){if(t||(t=E.create()),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");if(e.entries!=null&&e.entries.length)for(let i=0;i<e.entries.length;++i)f.WiFiScanResult.encode(e.entries[i],t.uint32(10).fork(),n+1).ldelim();return t},r.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},r.decode=function(e,t,n,i){if(e instanceof d||(e=d.create(e)),i===void 0&&(i=0),i>d.recursionLimit)throw Error("maximum nesting depth exceeded");let o,s;if(t===void 0)o=e.len;else{if(o=e.pos+t,o>e.len)throw RangeError("index out of range");t=e.len,e.len=o}for(s=new f.RespScanResult;e.pos<o;){let u=e.uint32();if(u===n)break;u>>>3===1?(s.entries&&s.entries.length||(s.entries=[]),s.entries.push(f.WiFiScanResult.decode(e,e.uint32(),void 0,i+1))):e.skipType(u&7,i)}if(t!==void 0){if(e.pos!==o)throw RangeError("index out of range");e.len=t}return s},r.decodeDelimited=function(e){return e instanceof d||(e=new d(e)),this.decode(e,e.uint32())},r.verify=function(e,t){if(typeof e!="object"||e===null)return"object expected";if(t===void 0&&(t=0),t>l.recursionLimit)return"maximum nesting depth exceeded";if(e.entries!=null&&Object.hasOwnProperty.call(e,"entries")){if(!Array.isArray(e.entries))return"entries: array expected";for(let n=0;n<e.entries.length;++n){let i=f.WiFiScanResult.verify(e.entries[n],t+1);if(i)return"entries."+i}}return null},r.fromObject=function(e,t){if(e instanceof f.RespScanResult)return e;if(!l.isObject(e))throw TypeError(".RespScanResult: object expected");if(t===void 0&&(t=0),t>l.recursionLimit)throw Error("maximum nesting depth exceeded");let n=new f.RespScanResult;if(e.entries){if(!Array.isArray(e.entries))throw TypeError(".RespScanResult.entries: array expected");n.entries=[];for(let i=0;i<e.entries.length;++i){if(!l.isObject(e.entries[i]))throw TypeError(".RespScanResult.entries: object expected");n.entries[i]=f.WiFiScanResult.fromObject(e.entries[i],t+1)}}return n},r.toObject=function(e,t,n){if(t||(t={}),n===void 0&&(n=0),n>l.recursionLimit)throw Error("max depth exceeded");let i={};if((t.arrays||t.defaults)&&(i.entries=[]),e.entries&&e.entries.length){i.entries=[];for(let o=0;o<e.entries.length;++o)i.entries[o]=f.WiFiScanResult.toObject(e.entries[o],t,n+1)}return i},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/RespScanResult"},r})();const ge=f.WiFiScanMsgType=(()=>{const r={},c=Object.create(r);return c[r[0]="TypeCmdScanStart"]=0,c[r[1]="TypeRespScanStart"]=1,c[r[2]="TypeCmdScanStatus"]=2,c[r[3]="TypeRespScanStatus"]=3,c[r[4]="TypeCmdScanResult"]=4,c[r[5]="TypeRespScanResult"]=5,c})(),Z=f.WiFiScanPayload=(()=>{function r(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&t[n]!=="__proto__"&&(this[t[n]]=e[t[n]])}r.prototype.msg=0,r.prototype.status=0,r.prototype.cmdScanStart=null,r.prototype.respScanStart=null,r.prototype.cmdScanStatus=null,r.prototype.respScanStatus=null,r.prototype.cmdScanResult=null,r.prototype.respScanResult=null;let c;return Object.defineProperty(r.prototype,"payload",{get:l.oneOfGetter(c=["cmdScanStart","respScanStart","cmdScanStatus","respScanStatus","cmdScanResult","respScanResult"]),set:l.oneOfSetter(c)}),r.create=function(t){return new r(t)},r.encode=function(t,n,i){if(n||(n=E.create()),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");return t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&n.uint32(8).int32(t.msg),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&n.uint32(16).int32(t.status),t.cmdScanStart!=null&&Object.hasOwnProperty.call(t,"cmdScanStart")&&f.CmdScanStart.encode(t.cmdScanStart,n.uint32(82).fork(),i+1).ldelim(),t.respScanStart!=null&&Object.hasOwnProperty.call(t,"respScanStart")&&f.RespScanStart.encode(t.respScanStart,n.uint32(90).fork(),i+1).ldelim(),t.cmdScanStatus!=null&&Object.hasOwnProperty.call(t,"cmdScanStatus")&&f.CmdScanStatus.encode(t.cmdScanStatus,n.uint32(98).fork(),i+1).ldelim(),t.respScanStatus!=null&&Object.hasOwnProperty.call(t,"respScanStatus")&&f.RespScanStatus.encode(t.respScanStatus,n.uint32(106).fork(),i+1).ldelim(),t.cmdScanResult!=null&&Object.hasOwnProperty.call(t,"cmdScanResult")&&f.CmdScanResult.encode(t.cmdScanResult,n.uint32(114).fork(),i+1).ldelim(),t.respScanResult!=null&&Object.hasOwnProperty.call(t,"respScanResult")&&f.RespScanResult.encode(t.respScanResult,n.uint32(122).fork(),i+1).ldelim(),n},r.encodeDelimited=function(t,n){return this.encode(t,n&&n.len?n.fork():n).ldelim()},r.decode=function(t,n,i,o){if(t instanceof d||(t=d.create(t)),o===void 0&&(o=0),o>d.recursionLimit)throw Error("maximum nesting depth exceeded");let s,u;if(n===void 0)s=t.len;else{if(s=t.pos+n,s>t.len)throw RangeError("index out of range");n=t.len,t.len=s}for(u=new f.WiFiScanPayload;t.pos<s;){let p=t.uint32();if(p===i)break;switch(p>>>3){case 1:{u.msg=t.int32();break}case 2:{u.status=t.int32();break}case 10:{u.cmdScanStart=f.CmdScanStart.decode(t,t.uint32(),void 0,o+1);break}case 11:{u.respScanStart=f.RespScanStart.decode(t,t.uint32(),void 0,o+1);break}case 12:{u.cmdScanStatus=f.CmdScanStatus.decode(t,t.uint32(),void 0,o+1);break}case 13:{u.respScanStatus=f.RespScanStatus.decode(t,t.uint32(),void 0,o+1);break}case 14:{u.cmdScanResult=f.CmdScanResult.decode(t,t.uint32(),void 0,o+1);break}case 15:{u.respScanResult=f.RespScanResult.decode(t,t.uint32(),void 0,o+1);break}default:t.skipType(p&7,o);break}}if(n!==void 0){if(t.pos!==s)throw RangeError("index out of range");t.len=n}return u},r.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},r.verify=function(t,n){if(typeof t!="object"||t===null)return"object expected";if(n===void 0&&(n=0),n>l.recursionLimit)return"maximum nesting depth exceeded";let i={};if(t.msg!=null&&Object.hasOwnProperty.call(t,"msg"))switch(t.msg){default:return"msg: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:break}if(t.status!=null&&Object.hasOwnProperty.call(t,"status"))switch(t.status){default:return"status: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:break}if(t.cmdScanStart!=null&&Object.hasOwnProperty.call(t,"cmdScanStart")){i.payload=1;{let o=f.CmdScanStart.verify(t.cmdScanStart,n+1);if(o)return"cmdScanStart."+o}}if(t.respScanStart!=null&&Object.hasOwnProperty.call(t,"respScanStart")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespScanStart.verify(t.respScanStart,n+1);if(o)return"respScanStart."+o}}if(t.cmdScanStatus!=null&&Object.hasOwnProperty.call(t,"cmdScanStatus")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.CmdScanStatus.verify(t.cmdScanStatus,n+1);if(o)return"cmdScanStatus."+o}}if(t.respScanStatus!=null&&Object.hasOwnProperty.call(t,"respScanStatus")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespScanStatus.verify(t.respScanStatus,n+1);if(o)return"respScanStatus."+o}}if(t.cmdScanResult!=null&&Object.hasOwnProperty.call(t,"cmdScanResult")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.CmdScanResult.verify(t.cmdScanResult,n+1);if(o)return"cmdScanResult."+o}}if(t.respScanResult!=null&&Object.hasOwnProperty.call(t,"respScanResult")){if(i.payload===1)return"payload: multiple values";i.payload=1;{let o=f.RespScanResult.verify(t.respScanResult,n+1);if(o)return"respScanResult."+o}}return null},r.fromObject=function(t,n){if(t instanceof f.WiFiScanPayload)return t;if(!l.isObject(t))throw TypeError(".WiFiScanPayload: object expected");if(n===void 0&&(n=0),n>l.recursionLimit)throw Error("maximum nesting depth exceeded");let i=new f.WiFiScanPayload;switch(t.msg){default:if(typeof t.msg=="number"){i.msg=t.msg;break}break;case"TypeCmdScanStart":case 0:i.msg=0;break;case"TypeRespScanStart":case 1:i.msg=1;break;case"TypeCmdScanStatus":case 2:i.msg=2;break;case"TypeRespScanStatus":case 3:i.msg=3;break;case"TypeCmdScanResult":case 4:i.msg=4;break;case"TypeRespScanResult":case 5:i.msg=5;break}switch(t.status){default:if(typeof t.status=="number"){i.status=t.status;break}break;case"Success":case 0:i.status=0;break;case"InvalidSecScheme":case 1:i.status=1;break;case"InvalidProto":case 2:i.status=2;break;case"TooManySessions":case 3:i.status=3;break;case"InvalidArgument":case 4:i.status=4;break;case"InternalError":case 5:i.status=5;break;case"CryptoError":case 6:i.status=6;break;case"InvalidSession":case 7:i.status=7;break}if(t.cmdScanStart!=null){if(!l.isObject(t.cmdScanStart))throw TypeError(".WiFiScanPayload.cmdScanStart: object expected");i.cmdScanStart=f.CmdScanStart.fromObject(t.cmdScanStart,n+1)}if(t.respScanStart!=null){if(!l.isObject(t.respScanStart))throw TypeError(".WiFiScanPayload.respScanStart: object expected");i.respScanStart=f.RespScanStart.fromObject(t.respScanStart,n+1)}if(t.cmdScanStatus!=null){if(!l.isObject(t.cmdScanStatus))throw TypeError(".WiFiScanPayload.cmdScanStatus: object expected");i.cmdScanStatus=f.CmdScanStatus.fromObject(t.cmdScanStatus,n+1)}if(t.respScanStatus!=null){if(!l.isObject(t.respScanStatus))throw TypeError(".WiFiScanPayload.respScanStatus: object expected");i.respScanStatus=f.RespScanStatus.fromObject(t.respScanStatus,n+1)}if(t.cmdScanResult!=null){if(!l.isObject(t.cmdScanResult))throw TypeError(".WiFiScanPayload.cmdScanResult: object expected");i.cmdScanResult=f.CmdScanResult.fromObject(t.cmdScanResult,n+1)}if(t.respScanResult!=null){if(!l.isObject(t.respScanResult))throw TypeError(".WiFiScanPayload.respScanResult: object expected");i.respScanResult=f.RespScanResult.fromObject(t.respScanResult,n+1)}return i},r.toObject=function(t,n,i){if(n||(n={}),i===void 0&&(i=0),i>l.recursionLimit)throw Error("max depth exceeded");let o={};return n.defaults&&(o.msg=n.enums===String?"TypeCmdScanStart":0,o.status=n.enums===String?"Success":0),t.msg!=null&&Object.hasOwnProperty.call(t,"msg")&&(o.msg=n.enums===String?f.WiFiScanMsgType[t.msg]===void 0?t.msg:f.WiFiScanMsgType[t.msg]:t.msg),t.status!=null&&Object.hasOwnProperty.call(t,"status")&&(o.status=n.enums===String?f.Status[t.status]===void 0?t.status:f.Status[t.status]:t.status),t.cmdScanStart!=null&&Object.hasOwnProperty.call(t,"cmdScanStart")&&(o.cmdScanStart=f.CmdScanStart.toObject(t.cmdScanStart,n,i+1),n.oneofs&&(o.payload="cmdScanStart")),t.respScanStart!=null&&Object.hasOwnProperty.call(t,"respScanStart")&&(o.respScanStart=f.RespScanStart.toObject(t.respScanStart,n,i+1),n.oneofs&&(o.payload="respScanStart")),t.cmdScanStatus!=null&&Object.hasOwnProperty.call(t,"cmdScanStatus")&&(o.cmdScanStatus=f.CmdScanStatus.toObject(t.cmdScanStatus,n,i+1),n.oneofs&&(o.payload="cmdScanStatus")),t.respScanStatus!=null&&Object.hasOwnProperty.call(t,"respScanStatus")&&(o.respScanStatus=f.RespScanStatus.toObject(t.respScanStatus,n,i+1),n.oneofs&&(o.payload="respScanStatus")),t.cmdScanResult!=null&&Object.hasOwnProperty.call(t,"cmdScanResult")&&(o.cmdScanResult=f.CmdScanResult.toObject(t.cmdScanResult,n,i+1),n.oneofs&&(o.payload="cmdScanResult")),t.respScanResult!=null&&Object.hasOwnProperty.call(t,"respScanResult")&&(o.respScanResult=f.RespScanResult.toObject(t.respScanResult,n,i+1),n.oneofs&&(o.payload="respScanResult")),o},r.prototype.toJSON=function(){return this.constructor.toObject(this,x.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/WiFiScanPayload"},r})();class It extends rt{constructor(){super(...arguments),this.established=!1}async encrypt(c){return c}async decrypt(c){return c}async getSessionSetupRequest(){const c=ee.create({});return c.secVer=ne.SecScheme0,c.sec0=jt.create({msg:et.S0_Session_Command,sc:_t.create({})}),ee.encode(c).finish()}async processSessionSetupResponse(c){const e=ee.decode(c);if(e.secVer===ne.SecScheme0&&e.sec0?.msg===et.S0_Session_Response&&e.sec0.sr?.status===K.Success)this.established=!0;else throw new Error("Invalid session setup response for Security0")}isEstablished(){return this.established}}class Ft extends rt{constructor(c,e){if(super(),this.proofOfPossession=c,this.phase="command0",(e??0)!==0)throw new Error("Unsupported Security1 patch version");if(typeof c!="string")throw new Error("Unsupported security configuration")}async getSessionSetupRequest(){if(this.phase==="command0")return this.keyPair=await crypto.subtle.generateKey("X25519",!1,["deriveBits"]),this.publicKey=new Uint8Array(await crypto.subtle.exportKey("raw",this.keyPair.publicKey)),this.phase="response0",ee.encode({secVer:ne.SecScheme1,sec1:{msg:ce.Session_Command0,sc0:{clientPubkey:this.publicKey}}}).finish();if(this.phase==="command1"&&this.cipher&&this.devicePublicKey){const c=await this.cipher.update(this.devicePublicKey);return this.phase="response1",ee.encode({secVer:ne.SecScheme1,sec1:{msg:ce.Session_Command1,sc1:{clientVerifyData:c}}}).finish()}throw new Error("Invalid Security1 handshake state")}async processSessionSetupResponse(c){const e=ee.decode(c);if(e.secVer!==ne.SecScheme1||!e.sec1)throw new Error("Invalid Security1 session response");const t=e.sec1;if(this.phase==="response0"&&this.keyPair){const n=t.sr0;if(t.msg!==ce.Session_Response0||!n||n.status!==K.Success||n.devicePubkey?.length!==32||n.deviceRandom?.length!==16)throw new Error("Invalid Security1 key exchange response");this.devicePublicKey=new Uint8Array(n.devicePubkey);const i=await crypto.subtle.importKey("raw",new Uint8Array(this.devicePublicKey),"X25519",!1,[]),o=new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},this.keyPair.privateKey,256));this.keyPair=void 0;try{if(this.proofOfPossession.length>0){const s=await ft(se(this.proofOfPossession));for(let u=0;u<o.length;u++)o[u]^=s[u];s.fill(0)}this.proofOfPossession="",this.cipher=await je.create(o,n.deviceRandom)}finally{o.fill(0)}this.phase="command1";return}if(this.phase==="response1"&&this.cipher&&this.publicKey){const n=t.sr1;if(t.msg!==ce.Session_Response1||!n||n.status!==K.Success||n.deviceVerifyData?.length!==32)throw new Error("Security1 authentication failed");const i=await this.cipher.update(n.deviceVerifyData);let o=0;for(let s=0;s<this.publicKey.length;s++)o|=i[s]^this.publicKey[s];if(o!==0)throw new Error("Security1 device verification failed");this.phase="established";return}throw new Error("Unexpected Security1 handshake response")}async encrypt(c){if(!this.isEstablished()||!this.cipher)throw new Error("Security1 session not established");return this.cipher.update(c)}async decrypt(c){return this.encrypt(c)}isEstablished(){return this.phase==="established"}}const J={PROV_SESSION:"prov-session",PROV_SCAN:"prov-scan",PROV_CTRL:"prov-ctrl",PROV_CONFIG:"prov-config",PROTO_VER:"proto-ver"},st="PROV_",ue="1775244d-6b43-439b-877c-060f2d9bed07",Bt={"prov-session":"ff51","prov-config":"ff52","proto-ver":"ff53"},Wt={filters:[{namePrefix:st},{services:[ue]}],optionalServices:[ue]};var G=(r=>(r[r.open=0]="open",r[r.wep=1]="wep",r[r.wpa2Enterprise=2]="wpa2Enterprise",r[r.wpa2Psk=3]="wpa2Psk",r[r.wpaPsk=4]="wpaPsk",r[r.wpaWpa2Psk=5]="wpaWpa2Psk",r[r.wpa3Psk=6]="wpa3Psk",r[r.wpa2Wpa3Psk=7]="wpa2Wpa3Psk",r))(G||{}),q=(r=>(r[r.connected=0]="connected",r[r.connecting=1]="connecting",r[r.disconnected=2]="disconnected",r[r.failed=3]="failed",r))(q||{}),fe=(r=>(r[r.authError=1]="authError",r[r.networkNotFound=2]="networkNotFound",r))(fe||{});function ut(r){switch(r){case H.Open:return G.open;case H.WEP:return G.wep;case H.WPA_PSK:return G.wpaPsk;case H.WPA2_PSK:return G.wpa2Psk;case H.WPA_WPA2_PSK:return G.wpaWpa2Psk;case H.WPA2_ENTERPRISE:return G.wpa2Enterprise;case H.WPA3_PSK:return G.wpa3Psk;case H.WPA2_WPA3_PSK:return G.wpa2Wpa3Psk}}function Vt(r=!0,c=!1,e=5,t=120){const n=At.create({});n.blocking=r,n.passive=c,n.groupChannels=e,n.periodMs=t;const i=Z.create({msg:ge.TypeCmdScanStart,cmdScanStart:n});return Z.encode(i).finish()}function Mt(r){try{const c=Z.decode(r);if(c.status!==K.Success)throw new Error(`Scan start failed: ${c.status}`)}catch(c){console.error("Error processing scan start response:",c)}}function Ut(){const r=Z.create({msg:ge.TypeCmdScanStatus,cmdScanStatus:Lt.create({})});return Z.encode(r).finish()}function Jt(r){try{const c=Z.decode(r);if(c.status!==K.Success)throw new Error(`Scan status failed: ${c.status}`);const e=c.respScanStatus;return{scanFinished:e.scanFinished,count:e.resultCount}}catch{throw new Error("Failed to decode scan status response")}}function Gt(r,c){const e=Nt.create({});e.startIndex=r,e.count=c;const t=Z.create({msg:ge.TypeCmdScanResult,cmdScanResult:e});return Z.encode(t).finish()}function $t(r){try{const c=Z.decode(r);if(c.status!==K.Success)throw new Error(`Scan result failed: ${c.status}`);return c.respScanResult.entries.map(n=>{const i=n;return{ssid:le(i.ssid),rssi:i.rssi,auth:ut(i.auth),bssid:it(i.bssid),channel:i.channel}})}catch{throw new Error("Failed to decode scan result response")}}function Kt(){const r=z.create({});return r.msg=Te.TypeCmdGetStatus,r.cmdGetStatus=Tt.create({}),z.encode(r).finish()}function zt(r){try{const e=z.decode(r).respGetStatus;if(e.status!==K.Success)throw new Error(`Config status failed: ${e.status}`);let t;switch(e.staState){case oe.Disconnected:t=q.disconnected;break;case oe.Connecting:t=q.connecting;break;case oe.Connected:t=q.connected;break;case oe.ConnectionFailed:t=q.failed;break}let n;switch(e.failReason){case tt.AuthError:n=fe.authError;break;case tt.NetworkNotFound:n=fe.networkNotFound;break;default:break}let i;return e.connected&&(i={ssid:le(e.connected.ssid),rssi:e.connected.rssi,auth:ut(e.connected.auth),bssid:it(e.connected.bssid),channel:e.connected.channel}),{staState:t,failedReason:n,connected:i}}catch{throw new Error("Failed to decode config status response")}}function Zt(r,c){const e=z.create({});return e.msg=Te.TypeCmdSetConfig,e.cmdSetConfig=gt.create({ssid:se(r),passphrase:se(c)}),z.encode(e).finish()}function Ht(r){try{const e=z.decode(r).respSetConfig;if(e.status!==K.Success)throw new Error(`Config update failed: ${e.status}`)}catch{throw new Error("Failed to decode config update response")}}function Xt(){const r=z.create({});return r.msg=Te.TypeCmdApplyConfig,r.cmdApplyConfig=Dt.create({}),z.encode(r).finish()}function Qt(r){try{const e=z.decode(r).respApplyConfig;if(e.status!==K.Success)throw new Error(`Config apply failed: ${e.status}`)}catch{throw new Error("Failed to decode config apply response")}}class _e{constructor(c){this.requestQueue=Promise.resolve(),this.device=c}async connect(c){if(this.transportImpl)throw new Error("Device already connected or connecting");const e=this.device instanceof URL?new at(this.device.toString()):new lt(this.device,ue,new Map(Object.entries(Bt)));this.transportImpl=e;try{await e.connect();const t=await e.sendData(J.PROTO_VER,se("ESP")),n=JSON.parse(le(t));if(!n||!n.prov||typeof n.prov!="object"||Array.isArray(n.prov))throw new Error("Invalid proto-ver metadata");if(this.transportImpl!==e||!e.isConnected())throw new Error("Device disconnected during discovery");const i=typeof c=="function"?await c(n):c;if(this.transportImpl!==e||!e.isConnected())throw new Error("Device disconnected while resolving security");const o=i?.type==="Security1"?1:i?.type==="Security2"?2:0;if(n.prov.sec_ver!==void 0&&n.prov.sec_ver!==o)throw new Error(`Device requires Security${n.prov.sec_ver}; provide a matching security configuration`);let s;if(!i)s=new It;else if(i.type==="Security1")s=new Ft(i.proofOfPossession,n.prov.sec_patch_ver);else throw new Error("Unsupported security configuration");if(await this.establishSession(e,s),this.transportImpl!==e||!e.isConnected())throw new Error("Device disconnected during handshake");this.securityImpl=s}catch(t){throw this.transportImpl===e&&this.disconnect(),t}}async scanWifiList(){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const c=Vt(),e=await this.sendData(J.PROV_SCAN,c);Mt(e);const t=Ut(),n=await this.sendData(J.PROV_SCAN,t),{scanFinished:i,count:o}=Jt(n);if(!i)throw new Error("WiFi scan should have finished");let s=[];for(let u=0;u<o;u++){const p=Gt(u,1),w=await this.sendData(J.PROV_SCAN,p),S=$t(w);s=s.concat(S)}return s}catch(c){throw new Error(`WiFi scan failed: ${c}`)}}async provision(c,e){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const t=Zt(c,e),n=await this.sendData(J.PROV_CONFIG,t);Ht(n);const i=Xt(),o=await this.sendData(J.PROV_CONFIG,i);Qt(o)}catch(t){throw new Error(`Provisioning failed: ${t}`)}}async fetchWifiStatus(){if(!this.transportImpl||!this.securityImpl)throw new Error("Device not connected");try{const c=Kt(),e=await this.sendData(J.PROV_CONFIG,c);return zt(e)}catch(c){throw new Error(`Fetching WiFi status failed: ${c}`)}}async sendData(c,e){const t=this.transportImpl,n=this.securityImpl;if(!t||!n?.isEstablished())throw new Error("Device not connected");if(c===J.PROV_SESSION)throw new Error("Session endpoint is managed by connect()");const i=this.requestQueue.then(async()=>{if(this.transportImpl!==t||this.securityImpl!==n||!t.isConnected())throw new Error("Device disconnected");try{if(c===J.PROTO_VER)return await t.sendData(c,e);const o=await n.encrypt(e),s=await t.sendData(c,o);return await n.decrypt(s)}catch(o){throw this.transportImpl===t&&this.disconnect(),o}});return this.requestQueue=i.then(()=>{},()=>{}),i}disconnect(){this.transportImpl&&(this.transportImpl.disconnect(),this.transportImpl=void 0),this.securityImpl=void 0,this.requestQueue=Promise.resolve()}getDevice(){return this.device}async establishSession(c,e){for(;!e.isEstablished();){if(this.transportImpl!==c||!c.isConnected())throw new Error("Device disconnected during handshake");const t=await e.getSessionSetupRequest(),n=await c.sendData(J.PROV_SESSION,t);await e.processSessionSetupResponse(n)}}}class De{static async searchBLEDevice(c=Wt){if(!await De.getBluetoothAvailability())throw new Error("Web Bluetooth is not available.");try{const t=await navigator.bluetooth.requestDevice(c);if(!t.name)throw new Error("Device name not available");return new _e(t)}catch(t){if(t.name==="NotFoundError")return null;throw new Error(`Device search failed: ${t}`)}}static createSoftAPDevice(c){return new _e(c)}static isBluetoothSupported(){return typeof navigator<"u"&&"bluetooth"in navigator}static async getBluetoothAvailability(){if(!this.isBluetoothSupported())return!1;try{return await navigator.bluetooth.getAvailability()}catch(c){return console.error("Failed to get Bluetooth availability:",c),!1}}}exports.DEFAULT_DEVICE_PREFIX=st;exports.ESPConnectFailReason=fe;exports.ESPDevice=_e;exports.ESPProvisionManager=De;exports.ESPWifiAuthMode=G;exports.ESPWifiStaState=q;exports.FALLBACK_SERVICE_UUID=ue;
|