@busy-app/busy-lib 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var P=Object.defineProperty;var j=(e,n,t)=>n in e?P(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var l=(e,n,t)=>j(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("openapi-fetch"),D=(e,n)=>{if(typeof FormData<"u"&&e instanceof FormData||typeof Buffer<"u"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(e)||typeof File<"u"&&e instanceof File||typeof Blob<"u"&&e instanceof Blob||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ArrayBuffer<"u"&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return e;let t;return n&&(n instanceof Headers?t=n.get("Content-Type")??n.get("content-type")??void 0:typeof n=="object"&&(t=n["Content-Type"]??n["content-type"]),t==="application/x-www-form-urlencoded")?e&&typeof e=="object"&&!(e instanceof URLSearchParams)?new URLSearchParams(e).toString():String(e):JSON.stringify(e)};async function w(e){const r=(e.headers.get("content-type")||"").includes("application/json")?await e.clone().json():await e.clone().text(),i=typeof r=="object"&&r!==null?r.error||r.message:typeof r=="string"?r:void 0;return Object.assign(new Error(i||`HTTP ${e.status} ${e.statusText}`),{status:e.status,statusText:e.statusText,body:r})}function L(e,n,t,r=3e3){let i,o=t??void 0,s,u=null;const a=async()=>{i||(u||(u=(async()=>{const f=await n();if(!f.api_semver)throw new Error("Empty API version");i=f.api_semver})().finally(()=>{u=null})),await u)},q={async onRequest({request:f,schemaPath:p}){return o&&f.headers.set("Authorization",`Bearer ${o}`),p!=="/version"&&(await a(),i&&f.headers.set("X-API-Sem-Ver",i),s&&f.headers.set("X-API-Token",s)),f},async onResponse({request:f,response:p,options:T,schemaPath:A}){if(p.ok)return p;if(A==="/version")throw await w(p);if(p.status!==405)throw await w(p);i=void 0,await a(),i&&f.headers.set("X-API-Sem-Ver",i),o&&f.headers.set("Authorization",`Bearer ${o}`);const y=await(T.fetch??fetch)(f);if(y.ok)return y;throw await w(y)}},R=I({baseUrl:e,bodySerializer:D});return R.withTimeout=async(f,p=r)=>{if(p<=0)return await f();const T=new AbortController,A=setTimeout(()=>T.abort(),p);try{return await f(T.signal)}catch(y){throw y instanceof DOMException&&y.name==="AbortError"?new Error(`Request timed out after ${p}ms`):y}finally{clearTimeout(A)}},R.use(q),{client:R,setApiKey:f=>{s=f},setToken:f=>{o=f}}}async function F(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/version",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function x(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function U(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/system",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function B(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/power",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function M(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/device",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function G(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/firmware",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function V(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/transport",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class W{async SystemVersionGet(n){const t=await F(this.apiClient,n);return this.apiSemver=t.api_semver,t}async SystemStatusGet(n){return await x(this.apiClient,n)}async SystemInfoGet(n){return await U(this.apiClient,n)}async SystemStatusPowerGet(n){return await B(this.apiClient,n)}async SystemStatusDeviceGet(n){return await M(this.apiClient,n)}async SystemStatusFirmwareGet(n){return await G(this.apiClient,n)}async SystemTransportGet(n){return await V(this.apiClient,n)}}async function $(e,n){const{file:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/update",{headers:{"Content-Type":"application/octet-stream"},body:t,signal:o}),n.timeout);if(i)throw i;return r}async function z(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/update/check",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function H(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/update/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function J(e,n){const{version:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.GET("/update/changelog",{params:{query:{version:t}},signal:o}),n.timeout);if(i)throw i;return r}async function K(e,n){const{version:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/update/install",{params:{query:{version:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Y(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/update/abort_download",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function X(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/update/autoupdate",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Z(e,n){const{is_enabled:t,interval_start:r,interval_end:i}=n,{data:o,error:s}=await e.withTimeout(u=>e.POST("/update/autoupdate",{body:{is_enabled:t,interval_start:r,interval_end:i},signal:u}),n.timeout);if(s)throw s;return o}class Q{async UpdateFromFile(n){return await $(this.apiClient,n)}async UpdateCheck(n){return await z(this.apiClient,n)}async UpdateStatusGet(n){return await H(this.apiClient,n)}async UpdateChangelogGet(n){return await J(this.apiClient,n)}async UpdateInstall(n){return await K(this.apiClient,n)}async UpdateAbort(n){return await Y(this.apiClient,n)}async UpdateAutoUpdateGet(n){return await X(this.apiClient,n)}async UpdateAutoUpdateSet(n){return await Z(this.apiClient,n)}}async function nn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function en(e,n){const{timestamp:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/time/timestamp",{params:{query:{timestamp:t}},signal:o}),n.timeout);if(i)throw i;return r}async function tn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time/timezone",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function rn(e,n){const{timezone:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/time/timezone",{params:{query:{timezone:t}},signal:o}),n.timeout);if(i)throw i;return r}async function on(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time/tzlist",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class sn{async TimeGet(n){return await nn(this.apiClient,n)}async TimeTimestampSet(n){return await en(this.apiClient,n)}async TimeTimezoneGet(n){return await tn(this.apiClient,n)}async TimeTimezoneSet(n){return await rn(this.apiClient,n)}async TimeTzListGet(n){return await on(this.apiClient,n)}}async function an(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function un(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/info",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function ln(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/profile",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function fn(e,n){const{profile:t,custom_url:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/account/profile",{params:{query:{profile:t,custom_url:r}},signal:s}),n.timeout);if(o)throw o;return i}async function cn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/account",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function dn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/account/link",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class pn{async AccountInfoGet(n){return await un(this.apiClient,n)}async AccountStateGet(n){return await an(this.apiClient,n)}async AccountProfileGet(n){return await ln(this.apiClient,n)}async AccountProfileSet(n){return await fn(this.apiClient,n)}async AccountUnlink(n){return await cn(this.apiClient,n)}async AccountLink(n){return await dn(this.apiClient,n)}}async function hn(e,n){const{application_name:t,elements:r,priority:i=50,timeout:o}=n,{data:s,error:u}=await e.withTimeout(a=>e.POST("/display/draw",{body:{application_name:t,priority:i,elements:r},signal:a}),o);if(u)throw u;return s}async function yn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/display/draw",{params:{query:{application_name:n==null?void 0:n.application_name}},signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function mn(e,n){const{display:t,timeout:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.GET("/screen",{params:{query:{display:t}},parseAs:"blob",signal:s}),r);if(o)throw o;return i}async function vn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/display/brightness",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function gn(e,n){const{value:t}=n,i=(u=>{if(typeof u=="number"){if(u<0||u>100)throw new Error("Brightness value must be between 0 and 100 or 'auto'");return String(u)}return"auto"})(t),{data:o,error:s}=await e.withTimeout(u=>e.POST("/display/brightness",{params:{query:{value:i}},signal:u}),n.timeout);if(s)throw s;return o}class bn{async DisplayDraw(n){return await hn(this.apiClient,n)}async DisplayClear(n){return await yn(this.apiClient,n)}async DisplayScreenFrameGet(n){return await mn(this.apiClient,n)}async DisplayBrightnessGet(n){return await vn(this.apiClient,n)}async DisplayBrightnessSet(n){return await gn(this.apiClient,n)}}async function En(e,n){const{application_name:t,path:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/audio/play",{params:{query:{application_name:t,path:r}},signal:s}),n.timeout);if(o)throw o;return i}async function _n(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/audio/play",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Tn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/audio/volume",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function On(e,n){const{volume:t,silent:r}=n;if(typeof t!="number"||t<0||t>100)throw new Error("Volume must be a number between 0 and 100");const{data:i,error:o}=await e.withTimeout(s=>e.POST("/audio/volume",{params:{query:{volume:t,silent:r}},signal:s}),n.timeout);if(o)throw o;return i}class Rn{async AudioPlay(n){return await En(this.apiClient,n)}async AudioStop(n){return await _n(this.apiClient,n)}async AudioVolumeGet(n){return await Tn(this.apiClient,n)}async AudioVolumeSet(n){return await On(this.apiClient,n)}}async function An(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/wifi/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function wn(e,n){const{ssid:t,password:r,security:i,ip_config:o}=n,{data:s,error:u}=await e.withTimeout(a=>e.POST("/wifi/connect",{body:{ssid:t,password:r,security:i,ip_config:o},signal:a}),n.timeout);if(u)throw u;return s}async function Sn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/wifi/disconnect",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Nn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/wifi/networks",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class In{async WifiStatusGet(n){return await An(this.apiClient,n)}async WifiConnect(n){return await wn(this.apiClient,n)}async WifiDisconnect(n){return await Sn(this.apiClient,n)}async WifiNetworksGet(n){return await Nn(this.apiClient,n)}}async function Cn(e,n){const{path:t,file:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/storage/write",{params:{query:{path:t}},headers:{"Content-Type":"application/octet-stream"},body:r,signal:s}),n.timeout);if(o)throw o;return i}async function kn(e,n){const{path:t,as_array_buffer:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.GET("/storage/read",{params:{query:{path:t}},parseAs:r?"arrayBuffer":"blob",signal:s}),n.timeout);if(o)throw o;return i}async function qn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.GET("/storage/list",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Pn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.DELETE("/storage/remove",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function jn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/storage/mkdir",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Dn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/storage/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Ln(e,n){const{path:t,new_path:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/storage/rename",{params:{query:{path:t,new_path:r}},signal:s}),n.timeout);if(o)throw o;return i}class Fn{async StorageWrite(n){return await Cn(this.apiClient,n)}async StorageRead(n){return await kn(this.apiClient,n)}async StorageListGet(n){return await qn(this.apiClient,n)}async StorageRemove(n){return await Pn(this.apiClient,n)}async StorageMkdir(n){return await jn(this.apiClient,n)}async StorageStatusGet(n){return await Dn(this.apiClient,n)}async StorageRename(n){return await Ln(this.apiClient,n)}}async function xn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/access",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Un(e,n){const{mode:t,key:r}=n,i=r??"";if(String(i).trim()&&!/^\d{4,10}$/.test(String(i)))throw new Error("Key must be a string of 4 to 10 digits");const{data:o,error:s}=await e.withTimeout(u=>e.POST("/access",{params:{query:{mode:t,key:i}},signal:u}),n.timeout);if(s)throw s;return o}async function Bn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/name",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Mn(e,n){const{name:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/name",{body:{name:t},signal:o}),n.timeout);if(i)throw i;return r}class Gn{async SettingsAccessGet(n){return await xn(this.apiClient,n)}async SettingsAccessSet(n){const t=await Un(this.apiClient,n);return n.mode==="key"&&n.key&&this.setApiKey(n.key),t}async SettingsNameGet(n){return await Bn(this.apiClient,n)}async SettingsNameSet(n){return await Mn(this.apiClient,n)}}async function Vn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/ble/enable",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Wn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/ble/disable",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function $n(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/ble/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function zn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/ble/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class Hn{async BleEnable(n){return await Vn(this.apiClient,n)}async BleDisable(n){return await Wn(this.apiClient,n)}async BleUnpair(n){return await $n(this.apiClient,n)}async BleStatusGet(n){return await zn(this.apiClient,n)}}async function Jn(e,n){const{key:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/input",{params:{query:{key:t}},signal:o}),n.timeout);if(i)throw i;return r}class Kn{async InputSend(n){return await Jn(this.apiClient,n)}}async function Yn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Xn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Zn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Qn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/smart_home/switch",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function ne(e,n){const{timeout:t,...r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/smart_home/switch",{body:r,signal:s}),t);if(o)throw o;return i}class ee{async SmartHomePairingGet(n){return await Yn(this.apiClient,n)}async SmartHomePair(n){return await Xn(this.apiClient,n)}async SmartHomeErase(n){return await Zn(this.apiClient,n)}async SmartHomeSwitchStateGet(n){return await Qn(this.apiClient,n)}async SmartHomeSwitchStateSet(n){return await ne(this.apiClient,n)}async MatterStatusGet(n){return await this.SmartHomePairingGet(n)}async MatterPair(n){return await this.SmartHomePair(n)}async MatterErase(n){return await this.SmartHomeErase(n)}}async function te(e,n){const{application_name:t,file:r,data:i}=n,{data:o,error:s}=await e.withTimeout(u=>e.POST("/assets/upload",{params:{query:{application_name:t,file:r}},headers:{"Content-Type":"application/octet-stream"},body:i,signal:u}),n.timeout);if(s)throw s;return o}async function re(e,n){const{application_name:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.DELETE("/assets/upload",{params:{query:{application_name:t}},signal:o}),n.timeout);if(i)throw i;return r}class ie{async AssetsUpload(n){return await te(this.apiClient,n)}async AssetsDelete(n){return await re(this.apiClient,n)}}const oe="http://10.0.4.20",se="https://proxy.busy.app",ae=/^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;function ue(e){const n=e.split(".");if(n.length!==4)return!1;for(const t of n){if(t.length===0||t.length>1&&t[0]==="0"||!/^\d+$/.test(t))return!1;const r=Number(t);if(r<0||r>255)return!1}return!0}function le(e){return/\.local$/i.test(e)}class C{constructor(n){l(this,"addr");l(this,"apiSemver");l(this,"apiClient");l(this,"setApiKeyFn");l(this,"setTokenFn");l(this,"connectionType","unknown");if(!n||!n.addr&&!n.token)this.addr=oe;else if(!n.addr)this.addr=se;else{let o=n.addr.trim();if(/^https?:\/\//i.test(o)||(o=`http://${o}`),ae.test(o)&&!n.token)throw new Error("Token is required. Please provide it.");this.addr=o}this.apiSemver="";const{client:t,setApiKey:r,setToken:i}=L(`${this.addr}/api/`,this.SystemVersionGet.bind(this),n==null?void 0:n.token,n==null?void 0:n.timeout);this.apiClient=t,this.setApiKeyFn=r,this.setTokenFn=i,this.detectConnectionType()}async detectConnectionType(){const n=new URL(this.addr).hostname;if(!ue(n)&&!le(n)){this.connectionType="wifi";return}const t=I({baseUrl:`${this.addr}/api/`});try{const{response:r}=await t.GET("/name");if(r.status===401||r.status===403)this.connectionType="wifi";else if(r.ok)this.connectionType="usb";else throw new Error(`Failed to detect connection type. Status: ${r.status}`)}catch(r){throw r}}setApiKey(n){this.setApiKeyFn(n)}setToken(n){this.setTokenFn(n)}}function fe(e,n){n.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{Object.defineProperty(e.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)||Object.create(null))})})}fe(C,[W,Q,sn,pn,bn,Rn,In,Fn,Gn,Hn,Kn,ee,ie]);var c=(e=>(e.CONNECTION_FAILED="CONNECTION_FAILED",e.RECONNECT_FAILED="RECONNECT_FAILED",e.CONNECTION_LOST="CONNECTION_LOST",e.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",e.AUTH_FAILED="AUTH_FAILED",e.AUTH_REFRESH_FAILED="AUTH_REFRESH_FAILED",e.DEVICE_ERROR="DEVICE_ERROR",e.DECODE_ERROR="DECODE_ERROR",e.FRAME_PROCESS_ERROR="FRAME_PROCESS_ERROR",e.STREAM_ALREADY_STARTED="STREAM_ALREADY_STARTED",e.WORKER_INIT_FAILED="WORKER_INIT_FAILED",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e))(c||{});class h extends Error{constructor(n,t,r){super(t),this.code=n,this.data=r,this.name="StateStreamError"}}var d=(e=>(e.IDLE="IDLE",e.STARTING="STARTING",e.RUNNING="RUNNING",e.STOPPED="STOPPED",e.FAILED="FAILED",e))(d||{}),m=(e=>(e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e))(m||{}),v=(e=>(e.UNAUTHENTICATED="UNAUTHENTICATED",e.AUTHENTICATING="AUTHENTICATING",e.AUTHENTICATED="AUTHENTICATED",e.FAILED="FAILED",e))(v||{}),g=(e=>(e.NONE="NONE",e.ACTIVE="ACTIVE",e.STALE="STALE",e))(g||{}),b=(e=>(e.OFF="OFF",e.INITIALIZING="INITIALIZING",e.READY="READY",e.ERROR="ERROR",e))(b||{});const k=`var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
1
+ "use strict";var D=Object.defineProperty;var j=(e,n,t)=>n in e?D(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var u=(e,n,t)=>j(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("openapi-fetch"),L=(e,n)=>{if(typeof FormData<"u"&&e instanceof FormData||typeof Buffer<"u"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(e)||typeof File<"u"&&e instanceof File||typeof Blob<"u"&&e instanceof Blob||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ArrayBuffer<"u"&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return e;let t;return n&&(n instanceof Headers?t=n.get("Content-Type")??n.get("content-type")??void 0:typeof n=="object"&&(t=n["Content-Type"]??n["content-type"]),t==="application/x-www-form-urlencoded")?e&&typeof e=="object"&&!(e instanceof URLSearchParams)?new URLSearchParams(e).toString():String(e):JSON.stringify(e)};async function w(e){const r=(e.headers.get("content-type")||"").includes("application/json")?await e.clone().json():await e.clone().text(),i=typeof r=="object"&&r!==null?r.error||r.message:typeof r=="string"?r:void 0;return Object.assign(new Error(i||`HTTP ${e.status} ${e.statusText}`),{status:e.status,statusText:e.statusText,body:r})}function x(e,n,t,r=3e3){let i,o=t??void 0,s,l=null;const a=async()=>{i||(l||(l=(async()=>{const f=await n();if(!f.api_semver)throw new Error("Empty API version");i=f.api_semver})().finally(()=>{l=null})),await l)},P={async onRequest({request:f,schemaPath:p}){return o&&f.headers.set("Authorization",`Bearer ${o}`),p!=="/version"&&(await a(),i&&f.headers.set("X-API-Sem-Ver",i),s&&f.headers.set("X-API-Token",s)),f},async onResponse({request:f,response:p,options:A,schemaPath:O}){if(p.ok)return p;if(O==="/version")throw await w(p);if(p.status!==405)throw await w(p);i=void 0,await a(),i&&f.headers.set("X-API-Sem-Ver",i),o&&f.headers.set("Authorization",`Bearer ${o}`);const m=await(A.fetch??fetch)(f);if(m.ok)return m;throw await w(m)}},R=I({baseUrl:e,bodySerializer:L});return R.withTimeout=async(f,p=r)=>{if(p<=0)return await f();const A=new AbortController,O=setTimeout(()=>A.abort(),p);try{return await f(A.signal)}catch(m){throw m instanceof DOMException&&m.name==="AbortError"?new Error(`Request timed out after ${p}ms`):m}finally{clearTimeout(O)}},R.use(P),{client:R,setApiKey:f=>{s=f},setToken:f=>{o=f}}}async function U(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/version",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function F(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function B(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/system",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function M(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/power",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function G(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/device",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function V(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/status/firmware",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function W(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/transport",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class ${async SystemVersionGet(n){const t=await U(this.apiClient,n);return this.apiSemver=t.api_semver,t}async SystemStatusGet(n){return await F(this.apiClient,n)}async SystemInfoGet(n){return await B(this.apiClient,n)}async SystemStatusPowerGet(n){return await M(this.apiClient,n)}async SystemStatusDeviceGet(n){return await G(this.apiClient,n)}async SystemStatusFirmwareGet(n){return await V(this.apiClient,n)}async SystemTransportGet(n){return await W(this.apiClient,n)}}async function H(e,n){const{file:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/update",{headers:{"Content-Type":"application/octet-stream"},body:t,signal:o}),n.timeout);if(i)throw i;return r}async function z(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/update/check",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function J(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/update/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function K(e,n){const{version:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.GET("/update/changelog",{params:{query:{version:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Y(e,n){const{version:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/update/install",{params:{query:{version:t}},signal:o}),n.timeout);if(i)throw i;return r}async function X(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/update/abort_download",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Z(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/update/autoupdate",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Q(e,n){const{is_enabled:t,interval_start:r,interval_end:i}=n,{data:o,error:s}=await e.withTimeout(l=>e.POST("/update/autoupdate",{body:{is_enabled:t,interval_start:r,interval_end:i},signal:l}),n.timeout);if(s)throw s;return o}class nn{async UpdateFromFile(n){return await H(this.apiClient,n)}async UpdateCheck(n){return await z(this.apiClient,n)}async UpdateStatusGet(n){return await J(this.apiClient,n)}async UpdateChangelogGet(n){return await K(this.apiClient,n)}async UpdateInstall(n){return await Y(this.apiClient,n)}async UpdateAbort(n){return await X(this.apiClient,n)}async UpdateAutoUpdateGet(n){return await Z(this.apiClient,n)}async UpdateAutoUpdateSet(n){return await Q(this.apiClient,n)}}async function en(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function tn(e,n){const{timestamp:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/time/timestamp",{params:{query:{timestamp:t}},signal:o}),n.timeout);if(i)throw i;return r}async function rn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time/timezone",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function on(e,n){const{timezone:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/time/timezone",{params:{query:{timezone:t}},signal:o}),n.timeout);if(i)throw i;return r}async function sn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/time/tzlist",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class an{async TimeGet(n){return await en(this.apiClient,n)}async TimeTimestampSet(n){return await tn(this.apiClient,n)}async TimeTimezoneGet(n){return await rn(this.apiClient,n)}async TimeTimezoneSet(n){return await on(this.apiClient,n)}async TimeTzListGet(n){return await sn(this.apiClient,n)}}async function un(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function ln(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/info",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function fn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/account/profile",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function cn(e,n){const{profile:t,custom_url:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/account/profile",{params:{query:{profile:t,custom_url:r}},signal:s}),n.timeout);if(o)throw o;return i}async function dn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/account",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function pn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/account/link",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class hn{async AccountInfoGet(n){return await ln(this.apiClient,n)}async AccountStateGet(n){return await un(this.apiClient,n)}async AccountProfileGet(n){return await fn(this.apiClient,n)}async AccountProfileSet(n){return await cn(this.apiClient,n)}async AccountUnlink(n){return await dn(this.apiClient,n)}async AccountLink(n){return await pn(this.apiClient,n)}}async function yn(e,n){const{application_name:t,elements:r,priority:i=50,timeout:o}=n,{data:s,error:l}=await e.withTimeout(a=>e.POST("/display/draw",{body:{application_name:t,priority:i,elements:r},signal:a}),o);if(l)throw l;return s}async function mn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/display/draw",{params:{query:{application_name:n==null?void 0:n.application_name}},signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function vn(e,n){const{display:t,timeout:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.GET("/screen",{params:{query:{display:t}},parseAs:"blob",signal:s}),r);if(o)throw o;return i}async function gn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/display/brightness",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function bn(e,n){const{value:t}=n,i=(l=>{if(typeof l=="number"){if(l<0||l>100)throw new Error("Brightness value must be between 0 and 100 or 'auto'");return String(l)}return"auto"})(t),{data:o,error:s}=await e.withTimeout(l=>e.POST("/display/brightness",{params:{query:{value:i}},signal:l}),n.timeout);if(s)throw s;return o}class En{async DisplayDraw(n){return await yn(this.apiClient,n)}async DisplayClear(n){return await mn(this.apiClient,n)}async DisplayScreenFrameGet(n){return await vn(this.apiClient,n)}async DisplayBrightnessGet(n){return await gn(this.apiClient,n)}async DisplayBrightnessSet(n){return await bn(this.apiClient,n)}}async function _n(e,n){const{application_name:t,path:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/audio/play",{params:{query:{application_name:t,path:r}},signal:s}),n.timeout);if(o)throw o;return i}async function An(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/audio/play",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Tn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/audio/volume",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Rn(e,n){const{volume:t,silent:r}=n;if(typeof t!="number"||t<0||t>100)throw new Error("Volume must be a number between 0 and 100");const{data:i,error:o}=await e.withTimeout(s=>e.POST("/audio/volume",{params:{query:{volume:t,silent:r}},signal:s}),n.timeout);if(o)throw o;return i}class On{async AudioPlay(n){return await _n(this.apiClient,n)}async AudioStop(n){return await An(this.apiClient,n)}async AudioVolumeGet(n){return await Tn(this.apiClient,n)}async AudioVolumeSet(n){return await Rn(this.apiClient,n)}}async function wn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/wifi/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Sn(e,n){const{ssid:t,password:r,security:i,ip_config:o}=n,{data:s,error:l}=await e.withTimeout(a=>e.POST("/wifi/connect",{body:{ssid:t,password:r,security:i,ip_config:o},signal:a}),n.timeout);if(l)throw l;return s}async function Nn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/wifi/disconnect",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function In(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/wifi/networks",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class Cn{async WifiStatusGet(n){return await wn(this.apiClient,n)}async WifiConnect(n){return await Sn(this.apiClient,n)}async WifiDisconnect(n){return await Nn(this.apiClient,n)}async WifiNetworksGet(n){return await In(this.apiClient,n)}}async function kn(e,n){const{path:t,file:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/storage/write",{params:{query:{path:t}},headers:{"Content-Type":"application/octet-stream"},body:r,signal:s}),n.timeout);if(o)throw o;return i}async function qn(e,n){const{path:t,as_array_buffer:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.GET("/storage/read",{params:{query:{path:t}},parseAs:r?"arrayBuffer":"blob",signal:s}),n.timeout);if(o)throw o;return i}async function Pn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.GET("/storage/list",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Dn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.DELETE("/storage/remove",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function jn(e,n){const{path:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/storage/mkdir",{params:{query:{path:t}},signal:o}),n.timeout);if(i)throw i;return r}async function Ln(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/storage/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function xn(e,n){const{path:t,new_path:r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/storage/rename",{params:{query:{path:t,new_path:r}},signal:s}),n.timeout);if(o)throw o;return i}class Un{async StorageWrite(n){return await kn(this.apiClient,n)}async StorageRead(n){return await qn(this.apiClient,n)}async StorageListGet(n){return await Pn(this.apiClient,n)}async StorageRemove(n){return await Dn(this.apiClient,n)}async StorageMkdir(n){return await jn(this.apiClient,n)}async StorageStatusGet(n){return await Ln(this.apiClient,n)}async StorageRename(n){return await xn(this.apiClient,n)}}async function Fn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/access",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Bn(e,n){const{mode:t,key:r}=n,i=r??"";if(String(i).trim()&&!/^\d{4,10}$/.test(String(i)))throw new Error("Key must be a string of 4 to 10 digits");const{data:o,error:s}=await e.withTimeout(l=>e.POST("/access",{params:{query:{mode:t,key:i}},signal:l}),n.timeout);if(s)throw s;return o}async function Mn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/name",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Gn(e,n){const{name:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/name",{body:{name:t},signal:o}),n.timeout);if(i)throw i;return r}class Vn{async SettingsAccessGet(n){return await Fn(this.apiClient,n)}async SettingsAccessSet(n){const t=await Bn(this.apiClient,n);return n.mode==="key"&&n.key&&this.setApiKey(n.key),t}async SettingsNameGet(n){return await Mn(this.apiClient,n)}async SettingsNameSet(n){return await Gn(this.apiClient,n)}}async function Wn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/ble/enable",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function $n(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/ble/disable",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Hn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/ble/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function zn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/ble/status",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}class Jn{async BleEnable(n){return await Wn(this.apiClient,n)}async BleDisable(n){return await $n(this.apiClient,n)}async BleUnpair(n){return await Hn(this.apiClient,n)}async BleStatusGet(n){return await zn(this.apiClient,n)}}async function Kn(e,n){const{key:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.POST("/input",{params:{query:{key:t}},signal:o}),n.timeout);if(i)throw i;return r}class Yn{async InputSend(n){return await Kn(this.apiClient,n)}}async function Xn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Zn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.POST("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function Qn(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.DELETE("/smart_home/pairing",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function ne(e,n){const{data:t,error:r}=await e.withTimeout(i=>e.GET("/smart_home/switch",{signal:i}),n==null?void 0:n.timeout);if(r)throw r;return t}async function ee(e,n){const{timeout:t,...r}=n,{data:i,error:o}=await e.withTimeout(s=>e.POST("/smart_home/switch",{body:r,signal:s}),t);if(o)throw o;return i}class te{async SmartHomePairingGet(n){return await Xn(this.apiClient,n)}async SmartHomePair(n){return await Zn(this.apiClient,n)}async SmartHomeErase(n){return await Qn(this.apiClient,n)}async SmartHomeSwitchStateGet(n){return await ne(this.apiClient,n)}async SmartHomeSwitchStateSet(n){return await ee(this.apiClient,n)}async MatterStatusGet(n){return await this.SmartHomePairingGet(n)}async MatterPair(n){return await this.SmartHomePair(n)}async MatterErase(n){return await this.SmartHomeErase(n)}}async function re(e,n){const{application_name:t,file:r,data:i}=n,{data:o,error:s}=await e.withTimeout(l=>e.POST("/assets/upload",{params:{query:{application_name:t,file:r}},headers:{"Content-Type":"application/octet-stream"},body:i,signal:l}),n.timeout);if(s)throw s;return o}async function ie(e,n){const{application_name:t}=n,{data:r,error:i}=await e.withTimeout(o=>e.DELETE("/assets/upload",{params:{query:{application_name:t}},signal:o}),n.timeout);if(i)throw i;return r}class oe{async AssetsUpload(n){return await re(this.apiClient,n)}async AssetsDelete(n){return await ie(this.apiClient,n)}}const se="http://10.0.4.20",ae="https://proxy.busy.app",ue=/^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;function le(e){const n=e.split(".");if(n.length!==4)return!1;for(const t of n){if(t.length===0||t.length>1&&t[0]==="0"||!/^\d+$/.test(t))return!1;const r=Number(t);if(r<0||r>255)return!1}return!0}function fe(e){return/\.local$/i.test(e)}class C{constructor(n){u(this,"addr");u(this,"apiSemver");u(this,"apiClient");u(this,"setApiKeyFn");u(this,"setTokenFn");u(this,"connectionType","unknown");if(!n||!n.addr&&!n.token)this.addr=se;else if(!n.addr)this.addr=ae;else{let o=n.addr.trim();if(/^https?:\/\//i.test(o)||(o=`http://${o}`),ue.test(o)&&!n.token)throw new Error("Token is required. Please provide it.");this.addr=o}this.apiSemver="";const{client:t,setApiKey:r,setToken:i}=x(`${this.addr}/api/`,this.SystemVersionGet.bind(this),n==null?void 0:n.token,n==null?void 0:n.timeout);this.apiClient=t,this.setApiKeyFn=r,this.setTokenFn=i,this.detectConnectionType()}async detectConnectionType(){const n=new URL(this.addr).hostname;if(!le(n)&&!fe(n)){this.connectionType="wifi";return}const t=I({baseUrl:`${this.addr}/api/`});try{const{response:r}=await t.GET("/name");if(r.status===401||r.status===403)this.connectionType="wifi";else if(r.ok)this.connectionType="usb";else throw new Error(`Failed to detect connection type. Status: ${r.status}`)}catch(r){throw r}}setApiKey(n){this.setApiKeyFn(n)}setToken(n){this.setTokenFn(n)}}function ce(e,n){n.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{Object.defineProperty(e.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)||Object.create(null))})})}ce(C,[$,nn,an,hn,En,On,Cn,Un,Vn,Jn,Yn,te,oe]);var c=(e=>(e.CONNECTION_FAILED="CONNECTION_FAILED",e.RECONNECT_FAILED="RECONNECT_FAILED",e.CONNECTION_LOST="CONNECTION_LOST",e.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",e.AUTH_FAILED="AUTH_FAILED",e.AUTH_REFRESH_FAILED="AUTH_REFRESH_FAILED",e.DEVICE_ERROR="DEVICE_ERROR",e.DECODE_ERROR="DECODE_ERROR",e.FRAME_PROCESS_ERROR="FRAME_PROCESS_ERROR",e.STREAM_ALREADY_STARTED="STREAM_ALREADY_STARTED",e.WORKER_INIT_FAILED="WORKER_INIT_FAILED",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e))(c||{});class h extends Error{constructor(n,t,r){super(t),this.code=n,this.data=r,this.name="StateStreamError"}}var d=(e=>(e.IDLE="IDLE",e.STARTING="STARTING",e.RUNNING="RUNNING",e.STOPPED="STOPPED",e.FAILED="FAILED",e))(d||{}),y=(e=>(e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e))(y||{}),v=(e=>(e.UNAUTHENTICATED="UNAUTHENTICATED",e.AUTHENTICATING="AUTHENTICATING",e.AUTHENTICATED="AUTHENTICATED",e.REAUTHENTICATING="REAUTHENTICATING",e.FAILED="FAILED",e))(v||{}),g=(e=>(e.NONE="NONE",e.ACTIVE="ACTIVE",e.STALE="STALE",e))(g||{}),b=(e=>(e.OFF="OFF",e.INITIALIZING="INITIALIZING",e.READY="READY",e.ERROR="ERROR",e))(b||{});const de=5,k=5,q=`var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
2
2
  function requireAspromise() {
3
3
  if (hasRequiredAspromise) return aspromise;
4
4
  hasRequiredAspromise = 1, aspromise = u;
@@ -564,8 +564,8 @@ function requireWriter() {
564
564
  var y = u.Array.prototype.set ? function(v, m, _) {
565
565
  m.set(v, _);
566
566
  } : function(v, m, _) {
567
- for (var b = 0; b < v.length; ++b)
568
- m[_ + b] = v[b];
567
+ for (var A = 0; A < v.length; ++A)
568
+ m[_ + A] = v[A];
569
569
  };
570
570
  return i.prototype.bytes = function(v) {
571
571
  var m = v.length >>> 0;
@@ -1706,10 +1706,10 @@ function requireType() {
1706
1706
  return this._fieldsById;
1707
1707
  this._fieldsById = {};
1708
1708
  for (var v = Object.keys(this.fields), m = 0; m < v.length; ++m) {
1709
- var _ = this.fields[v[m]], b = _.id;
1710
- if (this._fieldsById[b])
1711
- throw Error("duplicate id " + b + " in " + this);
1712
- this._fieldsById[b] = _;
1709
+ var _ = this.fields[v[m]], A = _.id;
1710
+ if (this._fieldsById[A])
1711
+ throw Error("duplicate id " + A + " in " + this);
1712
+ this._fieldsById[A] = _;
1713
1713
  }
1714
1714
  return this._fieldsById;
1715
1715
  }
@@ -1752,45 +1752,45 @@ function requireType() {
1752
1752
  for (var _ = 0; _ < /* initializes */
1753
1753
  this.fieldsArray.length; ++_)
1754
1754
  this._fieldsArray[_].resolve();
1755
- var b = {};
1755
+ var A = {};
1756
1756
  for (_ = 0; _ < /* initializes */
1757
1757
  this.oneofsArray.length; ++_)
1758
- b[this._oneofsArray[_].resolve().name] = {
1758
+ A[this._oneofsArray[_].resolve().name] = {
1759
1759
  get: t.oneOfGetter(this._oneofsArray[_].oneof),
1760
1760
  set: t.oneOfSetter(this._oneofsArray[_].oneof)
1761
1761
  };
1762
- _ && Object.defineProperties(v.prototype, b);
1762
+ _ && Object.defineProperties(v.prototype, A);
1763
1763
  }
1764
1764
  }
1765
1765
  }), y.generateConstructor = function(m) {
1766
- for (var _ = t.codegen(["p"], m.name), b = 0, I; b < m.fieldsArray.length; ++b)
1767
- (I = m._fieldsArray[b]).map ? _("this%s={}", t.safeProp(I.name)) : I.repeated && _("this%s=[]", t.safeProp(I.name));
1766
+ for (var _ = t.codegen(["p"], m.name), A = 0, I; A < m.fieldsArray.length; ++A)
1767
+ (I = m._fieldsArray[A]).map ? _("this%s={}", t.safeProp(I.name)) : I.repeated && _("this%s=[]", t.safeProp(I.name));
1768
1768
  return _("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]");
1769
1769
  };
1770
1770
  function E(v) {
1771
1771
  return v._fieldsById = v._fieldsArray = v._oneofsArray = null, delete v.encode, delete v.decode, delete v.verify, v;
1772
1772
  }
1773
1773
  return y.fromJSON = function(m, _) {
1774
- var b = new y(m, _.options);
1775
- b.extensions = _.extensions, b.reserved = _.reserved;
1774
+ var A = new y(m, _.options);
1775
+ A.extensions = _.extensions, A.reserved = _.reserved;
1776
1776
  for (var I = Object.keys(_.fields), C = 0; C < I.length; ++C)
1777
- b.add(
1777
+ A.add(
1778
1778
  (typeof _.fields[I[C]].keyType < "u" ? d.fromJSON : c.fromJSON)(I[C], _.fields[I[C]])
1779
1779
  );
1780
1780
  if (_.oneofs)
1781
1781
  for (I = Object.keys(_.oneofs), C = 0; C < I.length; ++C)
1782
- b.add(h.fromJSON(I[C], _.oneofs[I[C]]));
1782
+ A.add(h.fromJSON(I[C], _.oneofs[I[C]]));
1783
1783
  if (_.nested)
1784
1784
  for (I = Object.keys(_.nested), C = 0; C < I.length; ++C) {
1785
1785
  var j = _.nested[I[C]];
1786
- b.add(
1786
+ A.add(
1787
1787
  // most to least likely
1788
1788
  (j.id !== void 0 ? c.fromJSON : j.fields !== void 0 ? y.fromJSON : j.values !== void 0 ? f.fromJSON : j.methods !== void 0 ? n.fromJSON : u.fromJSON)(I[C], j)
1789
1789
  );
1790
1790
  }
1791
- return _.extensions && _.extensions.length && (b.extensions = _.extensions), _.reserved && _.reserved.length && (b.reserved = _.reserved), _.group && (b.group = !0), _.comment && (b.comment = _.comment), _.edition && (b._edition = _.edition), b._defaultEdition = "proto3", b;
1791
+ return _.extensions && _.extensions.length && (A.extensions = _.extensions), _.reserved && _.reserved.length && (A.reserved = _.reserved), _.group && (A.group = !0), _.comment && (A.comment = _.comment), _.edition && (A._edition = _.edition), A._defaultEdition = "proto3", A;
1792
1792
  }, y.prototype.toJSON = function(m) {
1793
- var _ = u.prototype.toJSON.call(this, m), b = m ? !!m.keepComments : !1;
1793
+ var _ = u.prototype.toJSON.call(this, m), A = m ? !!m.keepComments : !1;
1794
1794
  return t.toObject([
1795
1795
  "edition",
1796
1796
  this._editionToJSON(),
@@ -1811,16 +1811,16 @@ function requireType() {
1811
1811
  "nested",
1812
1812
  _ && _.nested || void 0,
1813
1813
  "comment",
1814
- b ? this.comment : void 0
1814
+ A ? this.comment : void 0
1815
1815
  ]);
1816
1816
  }, y.prototype.resolveAll = function() {
1817
1817
  if (!this._needsRecursiveResolve) return this;
1818
1818
  u.prototype.resolveAll.call(this);
1819
1819
  var m = this.oneofsArray;
1820
- for (b = 0; b < m.length; )
1821
- m[b++].resolve();
1822
- for (var _ = this.fieldsArray, b = 0; b < _.length; )
1823
- _[b++].resolve();
1820
+ for (A = 0; A < m.length; )
1821
+ m[A++].resolve();
1822
+ for (var _ = this.fieldsArray, A = 0; A < _.length; )
1823
+ _[A++].resolve();
1824
1824
  return this;
1825
1825
  }, y.prototype._resolveFeaturesRecursive = function(m) {
1826
1826
  return this._needsRecursiveFeatureResolution ? (m = this._edition || m, u.prototype._resolveFeaturesRecursive.call(this, m), this.oneofsArray.forEach((_) => {
@@ -1865,9 +1865,9 @@ function requireType() {
1865
1865
  }, y.prototype.create = function(m) {
1866
1866
  return new this.ctor(m);
1867
1867
  }, y.prototype.setup = function() {
1868
- for (var m = this.fullName, _ = [], b = 0; b < /* initializes */
1869
- this.fieldsArray.length; ++b)
1870
- _.push(this._fieldsArray[b].resolve().resolvedType);
1868
+ for (var m = this.fullName, _ = [], A = 0; A < /* initializes */
1869
+ this.fieldsArray.length; ++A)
1870
+ _.push(this._fieldsArray[A].resolve().resolvedType);
1871
1871
  this.encode = l(this)({
1872
1872
  Writer: i,
1873
1873
  types: _,
@@ -1907,8 +1907,8 @@ function requireType() {
1907
1907
  }, y.prototype.toObject = function(m, _) {
1908
1908
  return this.setup().toObject(m, _);
1909
1909
  }, y.d = function(m) {
1910
- return function(b) {
1911
- t.decorateType(b, m);
1910
+ return function(A) {
1911
+ t.decorateType(A, m);
1912
1912
  };
1913
1913
  }, type;
1914
1914
  }
@@ -1933,67 +1933,67 @@ function requireRoot() {
1933
1933
  if (!y)
1934
1934
  return d.asPromise(a, E, o, p);
1935
1935
  var v = y === t;
1936
- function m(D, P) {
1936
+ function m(B, L) {
1937
1937
  if (y) {
1938
1938
  if (v)
1939
- throw D;
1940
- P && P.resolveAll();
1939
+ throw B;
1940
+ L && L.resolveAll();
1941
1941
  var S = y;
1942
- y = null, S(D, P);
1942
+ y = null, S(B, L);
1943
1943
  }
1944
1944
  }
1945
- function _(D) {
1946
- var P = D.lastIndexOf("google/protobuf/");
1947
- if (P > -1) {
1948
- var S = D.substring(P);
1945
+ function _(B) {
1946
+ var L = B.lastIndexOf("google/protobuf/");
1947
+ if (L > -1) {
1948
+ var S = B.substring(L);
1949
1949
  if (S in r) return S;
1950
1950
  }
1951
1951
  return null;
1952
1952
  }
1953
- function b(D, P) {
1953
+ function A(B, L) {
1954
1954
  try {
1955
- if (d.isString(P) && P.charAt(0) === "{" && (P = JSON.parse(P)), !d.isString(P))
1956
- E.setOptions(P.options).addJSON(P.nested);
1955
+ if (d.isString(L) && L.charAt(0) === "{" && (L = JSON.parse(L)), !d.isString(L))
1956
+ E.setOptions(L.options).addJSON(L.nested);
1957
1957
  else {
1958
- e.filename = D;
1959
- var S = e(P, E, p), J, U = 0;
1958
+ e.filename = B;
1959
+ var S = e(L, E, p), J, M = 0;
1960
1960
  if (S.imports)
1961
- for (; U < S.imports.length; ++U)
1962
- (J = _(S.imports[U]) || E.resolvePath(D, S.imports[U])) && I(J);
1961
+ for (; M < S.imports.length; ++M)
1962
+ (J = _(S.imports[M]) || E.resolvePath(B, S.imports[M])) && I(J);
1963
1963
  if (S.weakImports)
1964
- for (U = 0; U < S.weakImports.length; ++U)
1965
- (J = _(S.weakImports[U]) || E.resolvePath(D, S.weakImports[U])) && I(J, !0);
1964
+ for (M = 0; M < S.weakImports.length; ++M)
1965
+ (J = _(S.weakImports[M]) || E.resolvePath(B, S.weakImports[M])) && I(J, !0);
1966
1966
  }
1967
1967
  } catch (T) {
1968
1968
  m(T);
1969
1969
  }
1970
1970
  !v && !C && m(null, E);
1971
1971
  }
1972
- function I(D, P) {
1973
- if (D = _(D) || D, !(E.files.indexOf(D) > -1)) {
1974
- if (E.files.push(D), D in r) {
1975
- v ? b(D, r[D]) : (++C, setTimeout(function() {
1976
- --C, b(D, r[D]);
1972
+ function I(B, L) {
1973
+ if (B = _(B) || B, !(E.files.indexOf(B) > -1)) {
1974
+ if (E.files.push(B), B in r) {
1975
+ v ? A(B, r[B]) : (++C, setTimeout(function() {
1976
+ --C, A(B, r[B]);
1977
1977
  }));
1978
1978
  return;
1979
1979
  }
1980
1980
  if (v) {
1981
1981
  var S;
1982
1982
  try {
1983
- S = d.fs.readFileSync(D).toString("utf8");
1983
+ S = d.fs.readFileSync(B).toString("utf8");
1984
1984
  } catch (J) {
1985
- P || m(J);
1985
+ L || m(J);
1986
1986
  return;
1987
1987
  }
1988
- b(D, S);
1988
+ A(B, S);
1989
1989
  } else
1990
- ++C, E.fetch(D, function(J, U) {
1990
+ ++C, E.fetch(B, function(J, M) {
1991
1991
  if (--C, !!y) {
1992
1992
  if (J) {
1993
- P ? C || m(null, E) : m(J);
1993
+ L ? C || m(null, E) : m(J);
1994
1994
  return;
1995
1995
  }
1996
- b(D, U);
1996
+ A(B, M);
1997
1997
  }
1998
1998
  });
1999
1999
  }
@@ -2737,93 +2737,93 @@ function requireTokenize() {
2737
2737
  function l(s, a) {
2738
2738
  s = s.toString();
2739
2739
  var o = 0, p = s.length, y = 1, E = 0, v = {}, m = [], _ = null;
2740
- function b(k) {
2740
+ function A(k) {
2741
2741
  return Error("illegal " + k + " (line " + y + ")");
2742
2742
  }
2743
2743
  function I() {
2744
2744
  var k = _ === "'" ? h : f;
2745
2745
  k.lastIndex = o - 1;
2746
- var L = k.exec(s);
2747
- if (!L)
2748
- throw b("string");
2749
- return o = k.lastIndex, S(_), _ = null, t(L[1]);
2746
+ var P = k.exec(s);
2747
+ if (!P)
2748
+ throw A("string");
2749
+ return o = k.lastIndex, S(_), _ = null, t(P[1]);
2750
2750
  }
2751
2751
  function C(k) {
2752
2752
  return s.charAt(k);
2753
2753
  }
2754
- function j(k, L, F) {
2754
+ function j(k, P, F) {
2755
2755
  var W = {
2756
2756
  type: s.charAt(k++),
2757
2757
  lineEmpty: !1,
2758
2758
  leading: F
2759
2759
  }, H;
2760
2760
  a ? H = 2 : H = 3;
2761
- var B = k - H, $;
2761
+ var D = k - H, $;
2762
2762
  do
2763
- if (--B < 0 || ($ = s.charAt(B)) === \`
2763
+ if (--D < 0 || ($ = s.charAt(D)) === \`
2764
2764
  \`) {
2765
2765
  W.lineEmpty = !0;
2766
2766
  break;
2767
2767
  }
2768
2768
  while ($ === " " || $ === " ");
2769
- for (var X = s.substring(k, L).split(n), z = 0; z < X.length; ++z)
2769
+ for (var X = s.substring(k, P).split(n), z = 0; z < X.length; ++z)
2770
2770
  X[z] = X[z].replace(a ? d : c, "").trim();
2771
2771
  W.text = X.join(\`
2772
2772
  \`).trim(), v[y] = W, E = y;
2773
2773
  }
2774
2774
  function K(k) {
2775
- var L = D(k), F = s.substring(k, L), W = /^\\s*\\/\\//.test(F);
2775
+ var P = B(k), F = s.substring(k, P), W = /^\\s*\\/\\//.test(F);
2776
2776
  return W;
2777
2777
  }
2778
- function D(k) {
2779
- for (var L = k; L < p && C(L) !== \`
2778
+ function B(k) {
2779
+ for (var P = k; P < p && C(P) !== \`
2780
2780
  \`; )
2781
- L++;
2782
- return L;
2781
+ P++;
2782
+ return P;
2783
2783
  }
2784
- function P() {
2784
+ function L() {
2785
2785
  if (m.length > 0)
2786
2786
  return m.shift();
2787
2787
  if (_)
2788
2788
  return I();
2789
- var k, L, F, W, H, B = o === 0;
2789
+ var k, P, F, W, H, D = o === 0;
2790
2790
  do {
2791
2791
  if (o === p)
2792
2792
  return null;
2793
2793
  for (k = !1; e.test(F = C(o)); )
2794
2794
  if (F === \`
2795
- \` && (B = !0, ++y), ++o === p)
2795
+ \` && (D = !0, ++y), ++o === p)
2796
2796
  return null;
2797
2797
  if (C(o) === "/") {
2798
2798
  if (++o === p)
2799
- throw b("comment");
2799
+ throw A("comment");
2800
2800
  if (C(o) === "/")
2801
2801
  if (a) {
2802
2802
  if (W = o, H = !1, K(o - 1)) {
2803
2803
  H = !0;
2804
2804
  do
2805
- if (o = D(o), o === p || (o++, !B))
2805
+ if (o = B(o), o === p || (o++, !D))
2806
2806
  break;
2807
2807
  while (K(o));
2808
2808
  } else
2809
- o = Math.min(p, D(o) + 1);
2810
- H && (j(W, o, B), B = !0), y++, k = !0;
2809
+ o = Math.min(p, B(o) + 1);
2810
+ H && (j(W, o, D), D = !0), y++, k = !0;
2811
2811
  } else {
2812
2812
  for (H = C(W = o + 1) === "/"; C(++o) !== \`
2813
2813
  \`; )
2814
2814
  if (o === p)
2815
2815
  return null;
2816
- ++o, H && (j(W, o - 1, B), B = !0), ++y, k = !0;
2816
+ ++o, H && (j(W, o - 1, D), D = !0), ++y, k = !0;
2817
2817
  }
2818
2818
  else if ((F = C(o)) === "*") {
2819
2819
  W = o + 1, H = a || C(W) === "*";
2820
2820
  do {
2821
2821
  if (F === \`
2822
2822
  \` && ++y, ++o === p)
2823
- throw b("comment");
2824
- L = F, F = C(o);
2825
- } while (L !== "*" || F !== "/");
2826
- ++o, H && (j(W, o - 2, B), B = !0), k = !0;
2823
+ throw A("comment");
2824
+ P = F, F = C(o);
2825
+ } while (P !== "*" || F !== "/");
2826
+ ++o, H && (j(W, o - 2, D), D = !0), k = !0;
2827
2827
  } else
2828
2828
  return "/";
2829
2829
  }
@@ -2842,30 +2842,30 @@ function requireTokenize() {
2842
2842
  }
2843
2843
  function J() {
2844
2844
  if (!m.length) {
2845
- var k = P();
2845
+ var k = L();
2846
2846
  if (k === null)
2847
2847
  return null;
2848
2848
  S(k);
2849
2849
  }
2850
2850
  return m[0];
2851
2851
  }
2852
- function U(k, L) {
2852
+ function M(k, P) {
2853
2853
  var F = J(), W = F === k;
2854
2854
  if (W)
2855
- return P(), !0;
2856
- if (!L)
2857
- throw b("token '" + F + "', '" + k + "' expected");
2855
+ return L(), !0;
2856
+ if (!P)
2857
+ throw A("token '" + F + "', '" + k + "' expected");
2858
2858
  return !1;
2859
2859
  }
2860
2860
  function T(k) {
2861
- var L = null, F;
2862
- return k === void 0 ? (F = v[y - 1], delete v[y - 1], F && (a || F.type === "*" || F.lineEmpty) && (L = F.leading ? F.text : null)) : (E < k && J(), F = v[k], delete v[k], F && !F.lineEmpty && (a || F.type === "/") && (L = F.leading ? null : F.text)), L;
2861
+ var P = null, F;
2862
+ return k === void 0 ? (F = v[y - 1], delete v[y - 1], F && (a || F.type === "*" || F.lineEmpty) && (P = F.leading ? F.text : null)) : (E < k && J(), F = v[k], delete v[k], F && !F.lineEmpty && (a || F.type === "/") && (P = F.leading ? null : F.text)), P;
2863
2863
  }
2864
2864
  return Object.defineProperty({
2865
- next: P,
2865
+ next: L,
2866
2866
  peek: J,
2867
2867
  push: S,
2868
- skip: U,
2868
+ skip: M,
2869
2869
  cmnt: T
2870
2870
  }, "line", {
2871
2871
  get: function() {
@@ -2879,33 +2879,33 @@ var parse_1, hasRequiredParse;
2879
2879
  function requireParse() {
2880
2880
  if (hasRequiredParse) return parse_1;
2881
2881
  hasRequiredParse = 1, parse_1 = I, I.filename = null, I.defaults = { keepCase: !1 };
2882
- var u = requireTokenize(), f = requireRoot(), h = requireType(), c = requireField(), d = requireMapfield(), n = requireOneof(), e = require_enum(), r = requireService(), i = requireMethod(), t = requireObject(), l = requireTypes(), s = requireUtil(), a = /^[1-9][0-9]*$/, o = /^-?[1-9][0-9]*$/, p = /^0[x][0-9a-fA-F]+$/, y = /^-?0[x][0-9a-fA-F]+$/, E = /^0[0-7]+$/, v = /^-?0[0-7]+$/, m = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, _ = /^[a-zA-Z_][a-zA-Z_0-9]*$/, b = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
2882
+ var u = requireTokenize(), f = requireRoot(), h = requireType(), c = requireField(), d = requireMapfield(), n = requireOneof(), e = require_enum(), r = requireService(), i = requireMethod(), t = requireObject(), l = requireTypes(), s = requireUtil(), a = /^[1-9][0-9]*$/, o = /^-?[1-9][0-9]*$/, p = /^0[x][0-9a-fA-F]+$/, y = /^-?0[x][0-9a-fA-F]+$/, E = /^0[0-7]+$/, v = /^-?0[0-7]+$/, m = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, _ = /^[a-zA-Z_][a-zA-Z_0-9]*$/, A = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
2883
2883
  function I(C, j, K) {
2884
2884
  j instanceof f || (K = j, j = new f()), K || (K = I.defaults);
2885
- var D = K.preferTrailingComment || !1, P = u(C, K.alternateCommentMode || !1), S = P.next, J = P.push, U = P.peek, T = P.skip, k = P.cmnt, L = !0, F, W, H, B = "proto2", $ = j, X = [], z = {}, ae = K.keepCase ? function(O) {
2886
- return O;
2885
+ var B = K.preferTrailingComment || !1, L = u(C, K.alternateCommentMode || !1), S = L.next, J = L.push, M = L.peek, T = L.skip, k = L.cmnt, P = !0, F, W, H, D = "proto2", $ = j, X = [], z = {}, ae = K.keepCase ? function(R) {
2886
+ return R;
2887
2887
  } : s.camelCase;
2888
2888
  function he() {
2889
- X.forEach((O) => {
2890
- O._edition = B, Object.keys(z).forEach((g) => {
2891
- O.getOption(g) === void 0 && O.setOption(g, z[g], !0);
2889
+ X.forEach((R) => {
2890
+ R._edition = D, Object.keys(z).forEach((g) => {
2891
+ R.getOption(g) === void 0 && R.setOption(g, z[g], !0);
2892
2892
  });
2893
2893
  });
2894
2894
  }
2895
- function N(O, g, R) {
2896
- var A = I.filename;
2897
- return R || (I.filename = null), Error("illegal " + (g || "token") + " '" + O + "' (" + (A ? A + ", " : "") + "line " + P.line + ")");
2895
+ function N(R, g, O) {
2896
+ var b = I.filename;
2897
+ return O || (I.filename = null), Error("illegal " + (g || "token") + " '" + R + "' (" + (b ? b + ", " : "") + "line " + L.line + ")");
2898
2898
  }
2899
2899
  function ee() {
2900
- var O = [], g;
2900
+ var R = [], g;
2901
2901
  do {
2902
2902
  if ((g = S()) !== '"' && g !== "'")
2903
2903
  throw N(g);
2904
- O.push(S()), T(g), g = U();
2904
+ R.push(S()), T(g), g = M();
2905
2905
  } while (g === '"' || g === "'");
2906
- return O.join("");
2906
+ return R.join("");
2907
2907
  }
2908
- function ue(O) {
2908
+ function ue(R) {
2909
2909
  var g = S();
2910
2910
  switch (g) {
2911
2911
  case "'":
@@ -2925,24 +2925,24 @@ function requireParse() {
2925
2925
  !0
2926
2926
  );
2927
2927
  } catch {
2928
- if (b.test(g))
2928
+ if (A.test(g))
2929
2929
  return g;
2930
2930
  throw N(g, "value");
2931
2931
  }
2932
2932
  }
2933
- function re(O, g) {
2934
- var R, A;
2933
+ function re(R, g) {
2934
+ var O, b;
2935
2935
  do
2936
- if (g && ((R = U()) === '"' || R === "'")) {
2936
+ if (g && ((O = M()) === '"' || O === "'")) {
2937
2937
  var w = ee();
2938
- if (O.push(w), B >= 2023)
2938
+ if (R.push(w), D >= 2023)
2939
2939
  throw N(w, "id");
2940
2940
  } else
2941
2941
  try {
2942
- O.push([A = te(S()), T("to", !0) ? te(S()) : A]);
2942
+ R.push([b = te(S()), T("to", !0) ? te(S()) : b]);
2943
2943
  } catch (x) {
2944
- if (g && b.test(R) && B >= 2023)
2945
- O.push(R);
2944
+ if (g && A.test(O) && D >= 2023)
2945
+ R.push(O);
2946
2946
  else
2947
2947
  throw x;
2948
2948
  }
@@ -2963,13 +2963,13 @@ function requireParse() {
2963
2963
  }
2964
2964
  );
2965
2965
  }
2966
- function pe(O, g) {
2967
- var R = 1;
2968
- switch (O.charAt(0) === "-" && (R = -1, O = O.substring(1)), O) {
2966
+ function pe(R, g) {
2967
+ var O = 1;
2968
+ switch (R.charAt(0) === "-" && (O = -1, R = R.substring(1)), R) {
2969
2969
  case "inf":
2970
2970
  case "INF":
2971
2971
  case "Inf":
2972
- return R * (1 / 0);
2972
+ return O * (1 / 0);
2973
2973
  case "nan":
2974
2974
  case "NAN":
2975
2975
  case "Nan":
@@ -2978,18 +2978,18 @@ function requireParse() {
2978
2978
  case "0":
2979
2979
  return 0;
2980
2980
  }
2981
- if (a.test(O))
2982
- return R * parseInt(O, 10);
2983
- if (p.test(O))
2984
- return R * parseInt(O, 16);
2985
- if (E.test(O))
2986
- return R * parseInt(O, 8);
2987
- if (m.test(O))
2988
- return R * parseFloat(O);
2989
- throw N(O, "number", g);
2990
- }
2991
- function te(O, g) {
2992
- switch (O) {
2981
+ if (a.test(R))
2982
+ return O * parseInt(R, 10);
2983
+ if (p.test(R))
2984
+ return O * parseInt(R, 16);
2985
+ if (E.test(R))
2986
+ return O * parseInt(R, 8);
2987
+ if (m.test(R))
2988
+ return O * parseFloat(R);
2989
+ throw N(R, "number", g);
2990
+ }
2991
+ function te(R, g) {
2992
+ switch (R) {
2993
2993
  case "max":
2994
2994
  case "MAX":
2995
2995
  case "Max":
@@ -2997,28 +2997,28 @@ function requireParse() {
2997
2997
  case "0":
2998
2998
  return 0;
2999
2999
  }
3000
- if (!g && O.charAt(0) === "-")
3001
- throw N(O, "id");
3002
- if (o.test(O))
3003
- return parseInt(O, 10);
3004
- if (y.test(O))
3005
- return parseInt(O, 16);
3006
- if (v.test(O))
3007
- return parseInt(O, 8);
3008
- throw N(O, "id");
3000
+ if (!g && R.charAt(0) === "-")
3001
+ throw N(R, "id");
3002
+ if (o.test(R))
3003
+ return parseInt(R, 10);
3004
+ if (y.test(R))
3005
+ return parseInt(R, 16);
3006
+ if (v.test(R))
3007
+ return parseInt(R, 8);
3008
+ throw N(R, "id");
3009
3009
  }
3010
3010
  function ye() {
3011
3011
  if (F !== void 0)
3012
3012
  throw N("package");
3013
- if (F = S(), !b.test(F))
3013
+ if (F = S(), !A.test(F))
3014
3014
  throw N(F, "name");
3015
3015
  $ = $.define(F), T(";");
3016
3016
  }
3017
3017
  function me() {
3018
- var O = U(), g;
3019
- switch (O) {
3018
+ var R = M(), g;
3019
+ switch (R) {
3020
3020
  case "option":
3021
- if (B < "2024")
3021
+ if (D < "2024")
3022
3022
  throw N("option");
3023
3023
  S(), ee(), T(";");
3024
3024
  return;
@@ -3032,185 +3032,185 @@ function requireParse() {
3032
3032
  g = W || (W = []);
3033
3033
  break;
3034
3034
  }
3035
- O = ee(), T(";"), g.push(O);
3035
+ R = ee(), T(";"), g.push(R);
3036
3036
  }
3037
3037
  function ve() {
3038
- if (T("="), B = ee(), B < 2023)
3039
- throw N(B, "syntax");
3038
+ if (T("="), D = ee(), D < 2023)
3039
+ throw N(D, "syntax");
3040
3040
  T(";");
3041
3041
  }
3042
3042
  function ge() {
3043
- if (T("="), B = ee(), !["2023", "2024"].includes(B))
3044
- throw N(B, "edition");
3043
+ if (T("="), D = ee(), !["2023", "2024"].includes(D))
3044
+ throw N(D, "edition");
3045
3045
  T(";");
3046
3046
  }
3047
- function ie(O, g) {
3047
+ function ie(R, g) {
3048
3048
  switch (g) {
3049
3049
  case "option":
3050
- return Q(O, g), T(";"), !0;
3050
+ return Q(R, g), T(";"), !0;
3051
3051
  case "message":
3052
- return ne(O, g), !0;
3052
+ return ne(R, g), !0;
3053
3053
  case "enum":
3054
- return de(O, g), !0;
3054
+ return de(R, g), !0;
3055
3055
  case "export":
3056
3056
  case "local":
3057
- return B < "2024" || (g = S(), g === "export" || g === "local") || g !== "message" && g !== "enum" ? !1 : ie(O, g);
3057
+ return D < "2024" || (g = S(), g === "export" || g === "local") || g !== "message" && g !== "enum" ? !1 : ie(R, g);
3058
3058
  case "service":
3059
- return Ae(O, g), !0;
3059
+ return be(R, g), !0;
3060
3060
  case "extend":
3061
- return Se(O, g), !0;
3061
+ return Se(R, g), !0;
3062
3062
  }
3063
3063
  return !1;
3064
3064
  }
3065
- function Z(O, g, R) {
3066
- var A = P.line;
3067
- if (O && (typeof O.comment != "string" && (O.comment = k()), O.filename = I.filename), T("{", !0)) {
3065
+ function Z(R, g, O) {
3066
+ var b = L.line;
3067
+ if (R && (typeof R.comment != "string" && (R.comment = k()), R.filename = I.filename), T("{", !0)) {
3068
3068
  for (var w; (w = S()) !== "}"; )
3069
3069
  g(w);
3070
3070
  T(";", !0);
3071
3071
  } else
3072
- R && R(), T(";"), O && (typeof O.comment != "string" || D) && (O.comment = k(A) || O.comment);
3072
+ O && O(), T(";"), R && (typeof R.comment != "string" || B) && (R.comment = k(b) || R.comment);
3073
3073
  }
3074
- function ne(O, g) {
3074
+ function ne(R, g) {
3075
3075
  if (!_.test(g = S()))
3076
3076
  throw N(g, "type name");
3077
- var R = new h(g);
3078
- Z(R, function(w) {
3079
- if (!ie(R, w))
3077
+ var O = new h(g);
3078
+ Z(O, function(w) {
3079
+ if (!ie(O, w))
3080
3080
  switch (w) {
3081
3081
  case "map":
3082
- Ee(R);
3082
+ Ee(O);
3083
3083
  break;
3084
3084
  case "required":
3085
- if (B !== "proto2")
3085
+ if (D !== "proto2")
3086
3086
  throw N(w);
3087
3087
  /* eslint-disable no-fallthrough */
3088
3088
  case "repeated":
3089
- Y(R, w);
3089
+ Y(O, w);
3090
3090
  break;
3091
3091
  case "optional":
3092
- if (B === "proto3")
3093
- Y(R, "proto3_optional");
3092
+ if (D === "proto3")
3093
+ Y(O, "proto3_optional");
3094
3094
  else {
3095
- if (B !== "proto2")
3095
+ if (D !== "proto2")
3096
3096
  throw N(w);
3097
- Y(R, "optional");
3097
+ Y(O, "optional");
3098
3098
  }
3099
3099
  break;
3100
3100
  case "oneof":
3101
- Oe(R, w);
3101
+ Re(O, w);
3102
3102
  break;
3103
3103
  case "extensions":
3104
- re(R.extensions || (R.extensions = []));
3104
+ re(O.extensions || (O.extensions = []));
3105
3105
  break;
3106
3106
  case "reserved":
3107
- re(R.reserved || (R.reserved = []), !0);
3107
+ re(O.reserved || (O.reserved = []), !0);
3108
3108
  break;
3109
3109
  default:
3110
- if (B === "proto2" || !b.test(w))
3110
+ if (D === "proto2" || !A.test(w))
3111
3111
  throw N(w);
3112
- J(w), Y(R, "optional");
3112
+ J(w), Y(O, "optional");
3113
3113
  break;
3114
3114
  }
3115
- }), O.add(R), O === $ && X.push(R);
3115
+ }), R.add(O), R === $ && X.push(O);
3116
3116
  }
3117
- function Y(O, g, R) {
3118
- var A = S();
3119
- if (A === "group") {
3120
- _e(O, g);
3117
+ function Y(R, g, O) {
3118
+ var b = S();
3119
+ if (b === "group") {
3120
+ _e(R, g);
3121
3121
  return;
3122
3122
  }
3123
- for (; A.endsWith(".") || U().startsWith("."); )
3124
- A += S();
3125
- if (!b.test(A))
3126
- throw N(A, "type");
3123
+ for (; b.endsWith(".") || M().startsWith("."); )
3124
+ b += S();
3125
+ if (!A.test(b))
3126
+ throw N(b, "type");
3127
3127
  var w = S();
3128
3128
  if (!_.test(w))
3129
3129
  throw N(w, "name");
3130
3130
  w = ae(w), T("=");
3131
- var q = new c(w, te(S()), A, g, R);
3132
- if (Z(q, function(M) {
3133
- if (M === "option")
3134
- Q(q, M), T(";");
3131
+ var q = new c(w, te(S()), b, g, O);
3132
+ if (Z(q, function(U) {
3133
+ if (U === "option")
3134
+ Q(q, U), T(";");
3135
3135
  else
3136
- throw N(M);
3136
+ throw N(U);
3137
3137
  }, function() {
3138
3138
  se(q);
3139
3139
  }), g === "proto3_optional") {
3140
3140
  var x = new n("_" + w);
3141
- q.setOption("proto3_optional", !0), x.add(q), O.add(x);
3141
+ q.setOption("proto3_optional", !0), x.add(q), R.add(x);
3142
3142
  } else
3143
- O.add(q);
3144
- O === $ && X.push(q);
3143
+ R.add(q);
3144
+ R === $ && X.push(q);
3145
3145
  }
3146
- function _e(O, g) {
3147
- if (B >= 2023)
3146
+ function _e(R, g) {
3147
+ if (D >= 2023)
3148
3148
  throw N("group");
3149
- var R = S();
3150
- if (!_.test(R))
3151
- throw N(R, "name");
3152
- var A = s.lcFirst(R);
3153
- R === A && (R = s.ucFirst(R)), T("=");
3154
- var w = te(S()), q = new h(R);
3149
+ var O = S();
3150
+ if (!_.test(O))
3151
+ throw N(O, "name");
3152
+ var b = s.lcFirst(O);
3153
+ O === b && (O = s.ucFirst(O)), T("=");
3154
+ var w = te(S()), q = new h(O);
3155
3155
  q.group = !0;
3156
- var x = new c(A, w, R, g);
3157
- x.filename = I.filename, Z(q, function(M) {
3158
- switch (M) {
3156
+ var x = new c(b, w, O, g);
3157
+ x.filename = I.filename, Z(q, function(U) {
3158
+ switch (U) {
3159
3159
  case "option":
3160
- Q(q, M), T(";");
3160
+ Q(q, U), T(";");
3161
3161
  break;
3162
3162
  case "required":
3163
3163
  case "repeated":
3164
- Y(q, M);
3164
+ Y(q, U);
3165
3165
  break;
3166
3166
  case "optional":
3167
- B === "proto3" ? Y(q, "proto3_optional") : Y(q, "optional");
3167
+ D === "proto3" ? Y(q, "proto3_optional") : Y(q, "optional");
3168
3168
  break;
3169
3169
  case "message":
3170
- ne(q, M);
3170
+ ne(q, U);
3171
3171
  break;
3172
3172
  case "enum":
3173
- de(q, M);
3173
+ de(q, U);
3174
3174
  break;
3175
3175
  case "reserved":
3176
3176
  re(q.reserved || (q.reserved = []), !0);
3177
3177
  break;
3178
3178
  case "export":
3179
3179
  case "local":
3180
- if (B < "2024")
3181
- throw N(M);
3182
- switch (M = S(), M) {
3180
+ if (D < "2024")
3181
+ throw N(U);
3182
+ switch (U = S(), U) {
3183
3183
  case "message":
3184
- ne(q, M);
3184
+ ne(q, U);
3185
3185
  break;
3186
3186
  case "enum":
3187
- ne(q, M);
3187
+ ne(q, U);
3188
3188
  break;
3189
3189
  default:
3190
- throw N(M);
3190
+ throw N(U);
3191
3191
  }
3192
3192
  break;
3193
3193
  /* istanbul ignore next */
3194
3194
  default:
3195
- throw N(M);
3195
+ throw N(U);
3196
3196
  }
3197
- }), O.add(q).add(x);
3197
+ }), R.add(q).add(x);
3198
3198
  }
3199
- function Ee(O) {
3199
+ function Ee(R) {
3200
3200
  T("<");
3201
3201
  var g = S();
3202
3202
  if (l.mapKey[g] === void 0)
3203
3203
  throw N(g, "type");
3204
3204
  T(",");
3205
- var R = S();
3206
- if (!b.test(R))
3207
- throw N(R, "type");
3205
+ var O = S();
3206
+ if (!A.test(O))
3207
+ throw N(O, "type");
3208
3208
  T(">");
3209
- var A = S();
3210
- if (!_.test(A))
3211
- throw N(A, "name");
3209
+ var b = S();
3210
+ if (!_.test(b))
3211
+ throw N(b, "name");
3212
3212
  T("=");
3213
- var w = new d(ae(A), te(S()), g, R);
3213
+ var w = new d(ae(b), te(S()), g, O);
3214
3214
  Z(w, function(x) {
3215
3215
  if (x === "option")
3216
3216
  Q(w, x), T(";");
@@ -3218,56 +3218,56 @@ function requireParse() {
3218
3218
  throw N(x);
3219
3219
  }, function() {
3220
3220
  se(w);
3221
- }), O.add(w);
3221
+ }), R.add(w);
3222
3222
  }
3223
- function Oe(O, g) {
3223
+ function Re(R, g) {
3224
3224
  if (!_.test(g = S()))
3225
3225
  throw N(g, "name");
3226
- var R = new n(ae(g));
3227
- Z(R, function(w) {
3228
- w === "option" ? (Q(R, w), T(";")) : (J(w), Y(R, "optional"));
3229
- }), O.add(R);
3226
+ var O = new n(ae(g));
3227
+ Z(O, function(w) {
3228
+ w === "option" ? (Q(O, w), T(";")) : (J(w), Y(O, "optional"));
3229
+ }), R.add(O);
3230
3230
  }
3231
- function de(O, g) {
3231
+ function de(R, g) {
3232
3232
  if (!_.test(g = S()))
3233
3233
  throw N(g, "name");
3234
- var R = new e(g);
3235
- Z(R, function(w) {
3234
+ var O = new e(g);
3235
+ Z(O, function(w) {
3236
3236
  switch (w) {
3237
3237
  case "option":
3238
- Q(R, w), T(";");
3238
+ Q(O, w), T(";");
3239
3239
  break;
3240
3240
  case "reserved":
3241
- re(R.reserved || (R.reserved = []), !0), R.reserved === void 0 && (R.reserved = []);
3241
+ re(O.reserved || (O.reserved = []), !0), O.reserved === void 0 && (O.reserved = []);
3242
3242
  break;
3243
3243
  default:
3244
- Re(R, w);
3244
+ Oe(O, w);
3245
3245
  }
3246
- }), O.add(R), O === $ && X.push(R);
3246
+ }), R.add(O), R === $ && X.push(O);
3247
3247
  }
3248
- function Re(O, g) {
3248
+ function Oe(R, g) {
3249
3249
  if (!_.test(g))
3250
3250
  throw N(g, "name");
3251
3251
  T("=");
3252
- var R = te(S(), !0), A = {
3252
+ var O = te(S(), !0), b = {
3253
3253
  options: void 0
3254
3254
  };
3255
- A.getOption = function(w) {
3255
+ b.getOption = function(w) {
3256
3256
  return this.options[w];
3257
- }, A.setOption = function(w, q) {
3258
- t.prototype.setOption.call(A, w, q);
3259
- }, A.setParsedOption = function() {
3260
- }, Z(A, function(q) {
3257
+ }, b.setOption = function(w, q) {
3258
+ t.prototype.setOption.call(b, w, q);
3259
+ }, b.setParsedOption = function() {
3260
+ }, Z(b, function(q) {
3261
3261
  if (q === "option")
3262
- Q(A, q), T(";");
3262
+ Q(b, q), T(";");
3263
3263
  else
3264
3264
  throw N(q);
3265
3265
  }, function() {
3266
- se(A);
3267
- }), O.add(g, R, A.comment, A.parsedOptions || A.options);
3266
+ se(b);
3267
+ }), R.add(g, O, b.comment, b.parsedOptions || b.options);
3268
3268
  }
3269
- function Q(O, g) {
3270
- var R, A, w = !0;
3269
+ function Q(R, g) {
3270
+ var O, b, w = !0;
3271
3271
  for (g === "option" && (g = S()); g !== "="; ) {
3272
3272
  if (g === "(") {
3273
3273
  var q = S();
@@ -3276,110 +3276,110 @@ function requireParse() {
3276
3276
  if (w) {
3277
3277
  if (w = !1, g.includes(".") && !g.includes("(")) {
3278
3278
  var x = g.split(".");
3279
- R = x[0] + ".", g = x[1];
3279
+ O = x[0] + ".", g = x[1];
3280
3280
  continue;
3281
3281
  }
3282
- R = g;
3282
+ O = g;
3283
3283
  } else
3284
- A = A ? A += g : g;
3284
+ b = b ? b += g : g;
3285
3285
  g = S();
3286
3286
  }
3287
- var G = A ? R.concat(A) : R, M = ce(O, G);
3288
- A = A && A[0] === "." ? A.slice(1) : A, R = R && R[R.length - 1] === "." ? R.slice(0, -1) : R, be(O, R, M, A);
3287
+ var G = b ? O.concat(b) : O, U = ce(R, G);
3288
+ b = b && b[0] === "." ? b.slice(1) : b, O = O && O[O.length - 1] === "." ? O.slice(0, -1) : O, Ae(R, O, U, b);
3289
3289
  }
3290
- function ce(O, g) {
3290
+ function ce(R, g) {
3291
3291
  if (T("{", !0)) {
3292
- for (var R = {}; !T("}", !0); ) {
3292
+ for (var O = {}; !T("}", !0); ) {
3293
3293
  if (!_.test(V = S()))
3294
3294
  throw N(V, "name");
3295
3295
  if (V === null)
3296
3296
  throw N(V, "end of input");
3297
- var A, w = V;
3298
- if (T(":", !0), U() === "{")
3299
- A = ce(O, g + "." + V);
3300
- else if (U() === "[") {
3301
- A = [];
3297
+ var b, w = V;
3298
+ if (T(":", !0), M() === "{")
3299
+ b = ce(R, g + "." + V);
3300
+ else if (M() === "[") {
3301
+ b = [];
3302
3302
  var q;
3303
3303
  if (T("[", !0)) {
3304
3304
  do
3305
- q = ue(), A.push(q);
3305
+ q = ue(), b.push(q);
3306
3306
  while (T(",", !0));
3307
- T("]"), typeof q < "u" && fe(O, g + "." + V, q);
3307
+ T("]"), typeof q < "u" && fe(R, g + "." + V, q);
3308
3308
  }
3309
3309
  } else
3310
- A = ue(), fe(O, g + "." + V, A);
3311
- var x = R[w];
3312
- x && (A = [].concat(x).concat(A)), R[w] = A, T(",", !0), T(";", !0);
3310
+ b = ue(), fe(R, g + "." + V, b);
3311
+ var x = O[w];
3312
+ x && (b = [].concat(x).concat(b)), O[w] = b, T(",", !0), T(";", !0);
3313
3313
  }
3314
- return R;
3314
+ return O;
3315
3315
  }
3316
3316
  var G = ue();
3317
- return fe(O, g, G), G;
3317
+ return fe(R, g, G), G;
3318
3318
  }
3319
- function fe(O, g, R) {
3320
- if ($ === O && /^features\\./.test(g)) {
3321
- z[g] = R;
3319
+ function fe(R, g, O) {
3320
+ if ($ === R && /^features\\./.test(g)) {
3321
+ z[g] = O;
3322
3322
  return;
3323
3323
  }
3324
- O.setOption && O.setOption(g, R);
3324
+ R.setOption && R.setOption(g, O);
3325
3325
  }
3326
- function be(O, g, R, A) {
3327
- O.setParsedOption && O.setParsedOption(g, R, A);
3326
+ function Ae(R, g, O, b) {
3327
+ R.setParsedOption && R.setParsedOption(g, O, b);
3328
3328
  }
3329
- function se(O) {
3329
+ function se(R) {
3330
3330
  if (T("[", !0)) {
3331
3331
  do
3332
- Q(O, "option");
3332
+ Q(R, "option");
3333
3333
  while (T(",", !0));
3334
3334
  T("]");
3335
3335
  }
3336
- return O;
3336
+ return R;
3337
3337
  }
3338
- function Ae(O, g) {
3338
+ function be(R, g) {
3339
3339
  if (!_.test(g = S()))
3340
3340
  throw N(g, "service name");
3341
- var R = new r(g);
3342
- Z(R, function(w) {
3343
- if (!ie(R, w))
3341
+ var O = new r(g);
3342
+ Z(O, function(w) {
3343
+ if (!ie(O, w))
3344
3344
  if (w === "rpc")
3345
- we(R, w);
3345
+ we(O, w);
3346
3346
  else
3347
3347
  throw N(w);
3348
- }), O.add(R), O === $ && X.push(R);
3348
+ }), R.add(O), R === $ && X.push(O);
3349
3349
  }
3350
- function we(O, g) {
3351
- var R = k(), A = g;
3350
+ function we(R, g) {
3351
+ var O = k(), b = g;
3352
3352
  if (!_.test(g = S()))
3353
3353
  throw N(g, "name");
3354
- var w = g, q, x, G, M;
3355
- if (T("("), T("stream", !0) && (x = !0), !b.test(g = S()) || (q = g, T(")"), T("returns"), T("("), T("stream", !0) && (M = !0), !b.test(g = S())))
3354
+ var w = g, q, x, G, U;
3355
+ if (T("("), T("stream", !0) && (x = !0), !A.test(g = S()) || (q = g, T(")"), T("returns"), T("("), T("stream", !0) && (U = !0), !A.test(g = S())))
3356
3356
  throw N(g);
3357
3357
  G = g, T(")");
3358
- var oe = new i(w, A, q, G, x, M);
3359
- oe.comment = R, Z(oe, function(le) {
3358
+ var oe = new i(w, b, q, G, x, U);
3359
+ oe.comment = O, Z(oe, function(le) {
3360
3360
  if (le === "option")
3361
3361
  Q(oe, le), T(";");
3362
3362
  else
3363
3363
  throw N(le);
3364
- }), O.add(oe);
3364
+ }), R.add(oe);
3365
3365
  }
3366
- function Se(O, g) {
3367
- if (!b.test(g = S()))
3366
+ function Se(R, g) {
3367
+ if (!A.test(g = S()))
3368
3368
  throw N(g, "reference");
3369
- var R = g;
3369
+ var O = g;
3370
3370
  Z(null, function(w) {
3371
3371
  switch (w) {
3372
3372
  case "required":
3373
3373
  case "repeated":
3374
- Y(O, w, R);
3374
+ Y(R, w, O);
3375
3375
  break;
3376
3376
  case "optional":
3377
- B === "proto3" ? Y(O, "proto3_optional", R) : Y(O, "optional", R);
3377
+ D === "proto3" ? Y(R, "proto3_optional", O) : Y(R, "optional", O);
3378
3378
  break;
3379
3379
  default:
3380
- if (B === "proto2" || !b.test(w))
3380
+ if (D === "proto2" || !A.test(w))
3381
3381
  throw N(w);
3382
- J(w), Y(O, "optional", R);
3382
+ J(w), Y(R, "optional", O);
3383
3383
  break;
3384
3384
  }
3385
3385
  });
@@ -3387,22 +3387,22 @@ function requireParse() {
3387
3387
  for (var V; (V = S()) !== null; )
3388
3388
  switch (V) {
3389
3389
  case "package":
3390
- if (!L)
3390
+ if (!P)
3391
3391
  throw N(V);
3392
3392
  ye();
3393
3393
  break;
3394
3394
  case "import":
3395
- if (!L)
3395
+ if (!P)
3396
3396
  throw N(V);
3397
3397
  me();
3398
3398
  break;
3399
3399
  case "syntax":
3400
- if (!L)
3400
+ if (!P)
3401
3401
  throw N(V);
3402
3402
  ve();
3403
3403
  break;
3404
3404
  case "edition":
3405
- if (!L)
3405
+ if (!P)
3406
3406
  throw N(V);
3407
3407
  ge();
3408
3408
  break;
@@ -3411,7 +3411,7 @@ function requireParse() {
3411
3411
  break;
3412
3412
  default:
3413
3413
  if (ie($, V)) {
3414
- L = !1;
3414
+ P = !1;
3415
3415
  continue;
3416
3416
  }
3417
3417
  throw N(V);
@@ -3755,8 +3755,8 @@ var protobufjs, hasRequiredProtobufjs;
3755
3755
  function requireProtobufjs() {
3756
3756
  return hasRequiredProtobufjs || (hasRequiredProtobufjs = 1, protobufjs = requireSrc()), protobufjs;
3757
3757
  }
3758
- var protobufjsExports = requireProtobufjs(), StateStreamErrorCode = /* @__PURE__ */ ((u) => (u.CONNECTION_FAILED = "CONNECTION_FAILED", u.RECONNECT_FAILED = "RECONNECT_FAILED", u.CONNECTION_LOST = "CONNECTION_LOST", u.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", u.AUTH_FAILED = "AUTH_FAILED", u.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", u.DEVICE_ERROR = "DEVICE_ERROR", u.DECODE_ERROR = "DECODE_ERROR", u.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", u.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", u.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", u.UNKNOWN_ERROR = "UNKNOWN_ERROR", u))(StateStreamErrorCode || {}), ConnectionStatus = /* @__PURE__ */ ((u) => (u.DISCONNECTED = "DISCONNECTED", u.CONNECTING = "CONNECTING", u.CONNECTED = "CONNECTED", u.RECONNECTING = "RECONNECTING", u))(ConnectionStatus || {}), AuthStatus = /* @__PURE__ */ ((u) => (u.UNAUTHENTICATED = "UNAUTHENTICATED", u.AUTHENTICATING = "AUTHENTICATING", u.AUTHENTICATED = "AUTHENTICATED", u.FAILED = "FAILED", u))(AuthStatus || {});
3759
- const nested = { BSB_State: { nested: { StateUpdate: { oneofs: { state: { oneof: ["deviceName", "power", "brightness", "audioVolume", "wifi", "updateState", "updateCheck", "timezone", "matter", "frame", "input", "timer", "ble", "autoUpdateState"] } }, fields: { deviceName: { type: "BSB_State.DeviceName", id: 1 }, power: { type: "BSB_State.Power", id: 2 }, brightness: { type: "BSB_State.Brightness", id: 3 }, audioVolume: { type: "BSB_State.AudioVolume", id: 4 }, wifi: { type: "BSB_State.Wifi", id: 5 }, updateState: { type: "BSB_Update.UpdateState", id: 6 }, updateCheck: { type: "BSB_Update.CheckState", id: 7 }, timezone: { type: "BSB_State.Timezone", id: 8 }, matter: { type: "BSB_State.Matter", id: 9 }, frame: { type: "BSB_Frame.Frame", id: 10 }, input: { type: "BSB_Input.InputEvent", id: 11 }, timer: { type: "BSB_Timer.Timer", id: 12 }, ble: { type: "BSB_State.Ble.Ble", id: 13 }, autoUpdateState: { type: "BSB_Update.AutoUpdateState", id: 14 } } }, State: { oneofs: { _error: { oneof: ["error"] } }, fields: { timestamp: { type: "fixed64", id: 1 }, updates: { rule: "repeated", type: "StateUpdate", id: 2 }, error: { type: "BSB_Error.Error", id: 3, options: { proto3_optional: !0 } } } }, DeviceName: { fields: { name: { type: "string", id: 1 } } }, BrightnessAutomatic: { fields: {} }, BrightnessManual: { fields: { brightness: { type: "uint32", id: 1 } } }, Brightness: { oneofs: { setting: { oneof: ["automatic", "manual"] } }, fields: { automatic: { type: "BrightnessAutomatic", id: 1 }, manual: { type: "BrightnessManual", id: 2 }, actualBrightness: { type: "uint32", id: 3 } } }, BatteryStatus: { values: { DISCHARGING: 0, CHARGING: 1, CHARGED: 2 } }, UnknownPowerState: { fields: {} }, PowerState: { fields: { batteryStatus: { type: "BatteryStatus", id: 1 }, batteryChargePercent: { type: "uint32", id: 2 }, batteryVoltageMv: { type: "uint32", id: 3 }, batteryCurrentMa: { type: "sint32", id: 4 }, usbVoltageMv: { type: "uint32", id: 5 } } }, Power: { oneofs: { state: { oneof: ["unknown", "known"] } }, fields: { unknown: { type: "UnknownPowerState", id: 1 }, known: { type: "PowerState", id: 2 } } }, AudioVolume: { fields: { volume: { type: "uint32", id: 1 } } }, WifiConnectionStatus: { values: { CONNECTED: 0, CONNECTING: 1, DISCONNECTING: 2, RECONNECTING: 3 } }, WifiSecurity: { values: { UNKNOWN: 0, OPEN: 1, WPA: 2, WPA2: 3, WEP: 4, WPA_WPA2: 5, WPA3: 6, WPA2_WPA3: 7 } }, IpConfigurationMethod: { values: { DHCP: 0, STATIC: 1 } }, IpProtocol: { values: { IPV4: 0, IPV6: 1 } }, WifiStateUnknown: { fields: {} }, WifiStateDisconnected: { fields: {} }, WifiStateConnected: { fields: { status: { type: "WifiConnectionStatus", id: 1 }, ssid: { type: "string", id: 2 }, bssid: { type: "string", id: 3 }, channel: { type: "uint32", id: 4 }, rssi: { type: "sint32", id: 5 }, security: { type: "WifiSecurity", id: 6 } } }, IpAddress: { fields: { protocol: { type: "IpProtocol", id: 1 }, method: { type: "IpConfigurationMethod", id: 2 }, address: { type: "string", id: 3 }, gateway: { type: "string", id: 4 }, netmask: { type: "string", id: 5 } } }, Wifi: { oneofs: { wifiState: { oneof: ["unknown", "disconnected", "connected"] } }, fields: { unknown: { type: "WifiStateUnknown", id: 1 }, disconnected: { type: "WifiStateDisconnected", id: 2 }, connected: { type: "WifiStateConnected", id: 3 }, ipAddresses: { rule: "repeated", type: "IpAddress", id: 4 } } }, Timezone: { fields: { name: { type: "string", id: 1 }, offset: { type: "sint32", id: 2 }, abbr: { type: "string", id: 3 } } }, MatterCommissioningStatus: { values: { NEVER_STARTED: 0, STARTED: 1, COMPLETED_SUCCESSFULLY: 2, FAILED: 3 } }, MatterCommissioningState: { fields: { status: { type: "MatterCommissioningStatus", id: 1 }, timestamp: { type: "fixed64", id: 2 } } }, Matter: { fields: { fabricCount: { type: "uint32", id: 1 }, state: { type: "MatterCommissioningState", id: 2 } } }, Ble: { nested: { ServiceStatus: { values: { RESET: 0, INITIALIZATION: 1, READY: 2, ADVERTISING: 3, CONNECTABLE: 4, CONNECTED: 5, ERROR: 6 } }, Ble: { oneofs: { _remoteAddress: { oneof: ["remoteAddress"] } }, fields: { status: { type: "ServiceStatus", id: 1 }, remoteAddress: { type: "string", id: 2, options: { proto3_optional: !0 } } } } } } } }, BSB_Update: { nested: { UpdateEvent: { values: { SESSION_START: 0, SESSION_STOP: 1, ACTION_BEGIN: 2, ACTION_DONE: 3, DETAIL_CHANGE: 4, ACTION_PROGRESS: 5, EVENT_NONE: 6 } }, UpdateAction: { values: { DOWNLOAD: 0, SHA_VERIFICATION: 1, UNPACK: 2, INSTALLATION_PREPARE: 3, INSTALLATION_APPLY: 4, ACTION_NONE: 5 } }, UpdateStatus: { values: { OK: 0, BATTERY_LOW: 1, BUSY: 2, DOWNLOAD_FAILURE: 3, DOWNLOAD_ABORT: 4, SHA_MISMATCH: 5, UNPACK_CREATE_STAGING_DIRECTORY_FAILURE: 6, UNPACK_ARCHIVE_OPEN_FAILURE: 7, UNPACK_ARCHIVE_UNPACK_FAILURE: 8, INSTALLATION_PREPARE_MANIFEST_NOT_FOUND: 9, INSTALLATION_PREPARE_MANIFEST_INVALID: 10, INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE: 11, INSTALLATION_PREPARE_POINTER_SETUP_FAILURE: 12, UNKNOWN_FAILURE: 13 } }, CheckError: { values: { NOT_AVAILABLE: 0, FAILURE: 1, IDLE: 2 } }, UpdateAvailable: { fields: { version: { type: "string", id: 1 } } }, UpdateUnavailable: { fields: { reason: { type: "CheckError", id: 1 } } }, UpdateState: { fields: { event: { type: "UpdateEvent", id: 1 }, action: { type: "UpdateAction", id: 2 }, status: { type: "UpdateStatus", id: 3 } } }, CheckState: { oneofs: { status: { oneof: ["available", "unavailable"] } }, fields: { available: { type: "UpdateAvailable", id: 1 }, unavailable: { type: "UpdateUnavailable", id: 2 } } }, AutoUpdateInterval: { fields: { start: { type: "uint32", id: 1 }, end: { type: "uint32", id: 2 } } }, AutoUpdateState: { fields: { enabled: { type: "bool", id: 1 }, interval: { type: "AutoUpdateInterval", id: 2 } } } } }, BSB_Frame: { nested: { Encoding: { values: { PLAIN: 0, RUN_LENGTH: 1, DEFLATE: 2, DEFLATE_RUN_LENGTH: 3 } }, PixelFormat: { values: { RGB888: 0, L8: 1, L4: 2 } }, Screen: { values: { FRONT: 0, BACK: 1 } }, Frame: { fields: { screen: { type: "Screen", id: 1 }, width: { type: "uint32", id: 2 }, height: { type: "uint32", id: 3 }, encoding: { type: "Encoding", id: 4 }, pixelFormat: { type: "PixelFormat", id: 5 }, data: { type: "bytes", id: 6 } } } } }, BSB_Timer: { nested: { Timer: { fields: { json: { type: "BSB_Util.Json", id: 1 } } } } }, BSB_Util: { nested: { Compression: { values: { PLAIN: 0, GZIP: 1 } }, Json: { fields: { compression: { type: "Compression", id: 1 }, data: { type: "bytes", id: 2 } } } } }, BSB_Input: { nested: { Button: { values: { OK: 0, BACK: 1, START: 2 } }, ButtonAction: { values: { PRESS: 0, RELEASE: 1 } }, SwitchPosition: { values: { BUSY: 0, CUSTOM: 1, OFF: 2, APPS: 3, SETTINGS: 4 } }, ButtonEvent: { fields: { button: { type: "Button", id: 1 }, action: { type: "ButtonAction", id: 2 } } }, SwitchEvent: { fields: { position: { type: "SwitchPosition", id: 1 } } }, EncoderEvent: { fields: { delta: { type: "sint32", id: 1 } } }, InputEvent: { oneofs: { event: { oneof: ["buttonEvent", "switchEvent", "encoderEvent"] } }, fields: { buttonEvent: { type: "ButtonEvent", id: 1 }, switchEvent: { type: "SwitchEvent", id: 2 }, encoderEvent: { type: "EncoderEvent", id: 3 } } } } }, BSB_Error: { nested: { Cause: { values: { RESOURCE_LIMIT: 0 } }, Severity: { values: { FATAL: 0, ERROR: 1, WARNING: 2 } }, Error: { fields: { cause: { type: "Cause", id: 1 }, severity: { type: "Severity", id: 2 } } } } } };
3758
+ var protobufjsExports = requireProtobufjs(), StateStreamErrorCode = /* @__PURE__ */ ((u) => (u.CONNECTION_FAILED = "CONNECTION_FAILED", u.RECONNECT_FAILED = "RECONNECT_FAILED", u.CONNECTION_LOST = "CONNECTION_LOST", u.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", u.AUTH_FAILED = "AUTH_FAILED", u.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", u.DEVICE_ERROR = "DEVICE_ERROR", u.DECODE_ERROR = "DECODE_ERROR", u.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", u.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", u.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", u.UNKNOWN_ERROR = "UNKNOWN_ERROR", u))(StateStreamErrorCode || {}), ConnectionStatus = /* @__PURE__ */ ((u) => (u.DISCONNECTED = "DISCONNECTED", u.CONNECTING = "CONNECTING", u.CONNECTED = "CONNECTED", u.RECONNECTING = "RECONNECTING", u))(ConnectionStatus || {}), AuthStatus = /* @__PURE__ */ ((u) => (u.UNAUTHENTICATED = "UNAUTHENTICATED", u.AUTHENTICATING = "AUTHENTICATING", u.AUTHENTICATED = "AUTHENTICATED", u.REAUTHENTICATING = "REAUTHENTICATING", u.FAILED = "FAILED", u))(AuthStatus || {});
3759
+ const DEFAULT_MAX_RECONNECT_ATTEMPTS = 5, DEFAULT_MAX_AUTH_ATTEMPTS = 5, nested = { BSB_State: { nested: { StateUpdate: { oneofs: { state: { oneof: ["deviceName", "power", "brightness", "audioVolume", "wifi", "updateState", "updateCheck", "timezone", "matter", "frame", "input", "timer", "ble", "autoUpdateState"] } }, fields: { deviceName: { type: "BSB_State.DeviceName", id: 1 }, power: { type: "BSB_State.Power", id: 2 }, brightness: { type: "BSB_State.Brightness", id: 3 }, audioVolume: { type: "BSB_State.AudioVolume", id: 4 }, wifi: { type: "BSB_State.Wifi", id: 5 }, updateState: { type: "BSB_Update.UpdateState", id: 6 }, updateCheck: { type: "BSB_Update.CheckState", id: 7 }, timezone: { type: "BSB_State.Timezone", id: 8 }, matter: { type: "BSB_State.Matter", id: 9 }, frame: { type: "BSB_Frame.Frame", id: 10 }, input: { type: "BSB_Input.InputEvent", id: 11 }, timer: { type: "BSB_Timer.Timer", id: 12 }, ble: { type: "BSB_State.Ble.Ble", id: 13 }, autoUpdateState: { type: "BSB_Update.AutoUpdateState", id: 14 } } }, State: { oneofs: { _error: { oneof: ["error"] } }, fields: { timestamp: { type: "fixed64", id: 1 }, updates: { rule: "repeated", type: "StateUpdate", id: 2 }, error: { type: "BSB_Error.Error", id: 3, options: { proto3_optional: !0 } } } }, DeviceName: { fields: { name: { type: "string", id: 1 } } }, BrightnessAutomatic: { fields: {} }, BrightnessManual: { fields: { brightness: { type: "uint32", id: 1 } } }, Brightness: { oneofs: { setting: { oneof: ["automatic", "manual"] } }, fields: { automatic: { type: "BrightnessAutomatic", id: 1 }, manual: { type: "BrightnessManual", id: 2 }, actualBrightness: { type: "uint32", id: 3 } } }, BatteryStatus: { values: { DISCHARGING: 0, CHARGING: 1, CHARGED: 2 } }, UnknownPowerState: { fields: {} }, PowerState: { fields: { batteryStatus: { type: "BatteryStatus", id: 1 }, batteryChargePercent: { type: "uint32", id: 2 }, batteryVoltageMv: { type: "uint32", id: 3 }, batteryCurrentMa: { type: "sint32", id: 4 }, usbVoltageMv: { type: "uint32", id: 5 } } }, Power: { oneofs: { state: { oneof: ["unknown", "known"] } }, fields: { unknown: { type: "UnknownPowerState", id: 1 }, known: { type: "PowerState", id: 2 } } }, AudioVolume: { fields: { volume: { type: "uint32", id: 1 } } }, WifiConnectionStatus: { values: { CONNECTED: 0, CONNECTING: 1, DISCONNECTING: 2, RECONNECTING: 3 } }, WifiSecurity: { values: { UNKNOWN: 0, OPEN: 1, WPA: 2, WPA2: 3, WEP: 4, WPA_WPA2: 5, WPA3: 6, WPA2_WPA3: 7 } }, IpConfigurationMethod: { values: { DHCP: 0, STATIC: 1 } }, IpProtocol: { values: { IPV4: 0, IPV6: 1 } }, WifiStateUnknown: { fields: {} }, WifiStateDisconnected: { fields: {} }, WifiStateConnected: { fields: { status: { type: "WifiConnectionStatus", id: 1 }, ssid: { type: "string", id: 2 }, bssid: { type: "string", id: 3 }, channel: { type: "uint32", id: 4 }, rssi: { type: "sint32", id: 5 }, security: { type: "WifiSecurity", id: 6 } } }, IpAddress: { fields: { protocol: { type: "IpProtocol", id: 1 }, method: { type: "IpConfigurationMethod", id: 2 }, address: { type: "string", id: 3 }, gateway: { type: "string", id: 4 }, netmask: { type: "string", id: 5 } } }, Wifi: { oneofs: { wifiState: { oneof: ["unknown", "disconnected", "connected"] } }, fields: { unknown: { type: "WifiStateUnknown", id: 1 }, disconnected: { type: "WifiStateDisconnected", id: 2 }, connected: { type: "WifiStateConnected", id: 3 }, ipAddresses: { rule: "repeated", type: "IpAddress", id: 4 } } }, Timezone: { fields: { name: { type: "string", id: 1 }, offset: { type: "sint32", id: 2 }, abbr: { type: "string", id: 3 } } }, MatterCommissioningStatus: { values: { NEVER_STARTED: 0, STARTED: 1, COMPLETED_SUCCESSFULLY: 2, FAILED: 3 } }, MatterCommissioningState: { fields: { status: { type: "MatterCommissioningStatus", id: 1 }, timestamp: { type: "fixed64", id: 2 } } }, Matter: { fields: { fabricCount: { type: "uint32", id: 1 }, state: { type: "MatterCommissioningState", id: 2 } } }, Ble: { nested: { ServiceStatus: { values: { RESET: 0, INITIALIZATION: 1, READY: 2, ADVERTISING: 3, CONNECTABLE: 4, CONNECTED: 5, ERROR: 6 } }, Ble: { oneofs: { _remoteAddress: { oneof: ["remoteAddress"] } }, fields: { status: { type: "ServiceStatus", id: 1 }, remoteAddress: { type: "string", id: 2, options: { proto3_optional: !0 } } } } } } } }, BSB_Update: { nested: { UpdateEvent: { values: { SESSION_START: 0, SESSION_STOP: 1, ACTION_BEGIN: 2, ACTION_DONE: 3, DETAIL_CHANGE: 4, ACTION_PROGRESS: 5, EVENT_NONE: 6 } }, UpdateAction: { values: { DOWNLOAD: 0, SHA_VERIFICATION: 1, UNPACK: 2, INSTALLATION_PREPARE: 3, INSTALLATION_APPLY: 4, ACTION_NONE: 5 } }, UpdateStatus: { values: { OK: 0, BATTERY_LOW: 1, BUSY: 2, DOWNLOAD_FAILURE: 3, DOWNLOAD_ABORT: 4, SHA_MISMATCH: 5, UNPACK_CREATE_STAGING_DIRECTORY_FAILURE: 6, UNPACK_ARCHIVE_OPEN_FAILURE: 7, UNPACK_ARCHIVE_UNPACK_FAILURE: 8, INSTALLATION_PREPARE_MANIFEST_NOT_FOUND: 9, INSTALLATION_PREPARE_MANIFEST_INVALID: 10, INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE: 11, INSTALLATION_PREPARE_POINTER_SETUP_FAILURE: 12, UNKNOWN_FAILURE: 13 } }, CheckError: { values: { NOT_AVAILABLE: 0, FAILURE: 1, IDLE: 2 } }, UpdateAvailable: { fields: { version: { type: "string", id: 1 } } }, UpdateUnavailable: { fields: { reason: { type: "CheckError", id: 1 } } }, UpdateState: { fields: { event: { type: "UpdateEvent", id: 1 }, action: { type: "UpdateAction", id: 2 }, status: { type: "UpdateStatus", id: 3 } } }, CheckState: { oneofs: { status: { oneof: ["available", "unavailable"] } }, fields: { available: { type: "UpdateAvailable", id: 1 }, unavailable: { type: "UpdateUnavailable", id: 2 } } }, AutoUpdateInterval: { fields: { start: { type: "uint32", id: 1 }, end: { type: "uint32", id: 2 } } }, AutoUpdateState: { fields: { enabled: { type: "bool", id: 1 }, interval: { type: "AutoUpdateInterval", id: 2 } } } } }, BSB_Frame: { nested: { Encoding: { values: { PLAIN: 0, RUN_LENGTH: 1, DEFLATE: 2, DEFLATE_RUN_LENGTH: 3 } }, PixelFormat: { values: { RGB888: 0, L8: 1, L4: 2 } }, Screen: { values: { FRONT: 0, BACK: 1 } }, Frame: { fields: { screen: { type: "Screen", id: 1 }, width: { type: "uint32", id: 2 }, height: { type: "uint32", id: 3 }, encoding: { type: "Encoding", id: 4 }, pixelFormat: { type: "PixelFormat", id: 5 }, data: { type: "bytes", id: 6 } } } } }, BSB_Timer: { nested: { Timer: { fields: { json: { type: "BSB_Util.Json", id: 1 } } } } }, BSB_Util: { nested: { Compression: { values: { PLAIN: 0, GZIP: 1 } }, Json: { fields: { compression: { type: "Compression", id: 1 }, data: { type: "bytes", id: 2 } } } } }, BSB_Input: { nested: { Button: { values: { OK: 0, BACK: 1, START: 2 } }, ButtonAction: { values: { PRESS: 0, RELEASE: 1 } }, SwitchPosition: { values: { BUSY: 0, CUSTOM: 1, OFF: 2, APPS: 3, SETTINGS: 4 } }, ButtonEvent: { fields: { button: { type: "Button", id: 1 }, action: { type: "ButtonAction", id: 2 } } }, SwitchEvent: { fields: { position: { type: "SwitchPosition", id: 1 } } }, EncoderEvent: { fields: { delta: { type: "sint32", id: 1 } } }, InputEvent: { oneofs: { event: { oneof: ["buttonEvent", "switchEvent", "encoderEvent"] } }, fields: { buttonEvent: { type: "ButtonEvent", id: 1 }, switchEvent: { type: "SwitchEvent", id: 2 }, encoderEvent: { type: "EncoderEvent", id: 3 } } } } }, BSB_Error: { nested: { Cause: { values: { RESOURCE_LIMIT: 0 } }, Severity: { values: { FATAL: 0, ERROR: 1, WARNING: 2 } }, Error: { fields: { cause: { type: "Cause", id: 1 }, severity: { type: "Severity", id: 2 } } } } } };
3760
3760
  var bundle = {
3761
3761
  nested
3762
3762
  };
@@ -3851,8 +3851,8 @@ async function processFrame(u) {
3851
3851
  return new Uint8ClampedArray(u.width * u.height * 4);
3852
3852
  }
3853
3853
  }
3854
- const root = protobufjsExports.Root.fromJSON(bundle), StateType = root.lookupType("BSB_State.State"), AUTH_CODE = 3e3, RECONNECT_CODES = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]), MAX_AUTH_ATTEMPTS = 5, MAX_RECONNECT_ATTEMPTS = 5;
3855
- let socket = null, isBinaryMode = !0, currentMode = "local", currentToken, currentAddr = "", retryCount = 0, authRetryCount = 0, isAuthReported = !1, stabilityTimeout;
3854
+ const root = protobufjsExports.Root.fromJSON(bundle), StateType = root.lookupType("BSB_State.State"), AUTH_CODE = 3e3, RECONNECT_CODES = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
3855
+ let maxAuthAttempts = DEFAULT_MAX_AUTH_ATTEMPTS, maxReconnectAttempts = DEFAULT_MAX_RECONNECT_ATTEMPTS, socket = null, isBinaryMode = !0, currentMode = "local", currentToken, currentAddr = "", retryCount = 0, authRetryCount = 0, isAuthReported = !1, stabilityTimeout;
3856
3856
  const activePorts = /* @__PURE__ */ new Set(), subscriptions = /* @__PURE__ */ new Map();
3857
3857
  let processingQueue = Promise.resolve();
3858
3858
  function broadcast(u) {
@@ -3957,25 +3957,25 @@ function connect(u, f, h = !0, c = "local") {
3957
3957
  return;
3958
3958
  }
3959
3959
  if (n.code === AUTH_CODE && currentMode === "remote") {
3960
- authRetryCount < MAX_AUTH_ATTEMPTS ? (authRetryCount++, console.warn(\`[Worker] Auth failed (3000). Requesting new token... (Attempt \${authRetryCount}/\${MAX_AUTH_ATTEMPTS})\`), broadcast({ type: "TOKEN_EXPIRED" })) : (broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.FAILED }), broadcast({
3960
+ authRetryCount < maxAuthAttempts ? (authRetryCount++, console.warn(\`[Worker] Auth failed (3000). Requesting new token... (Attempt \${authRetryCount}/\${maxAuthAttempts})\`), broadcast({ type: "TOKEN_EXPIRED" }), broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.REAUTHENTICATING, authAttempts: authRetryCount })) : (broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.FAILED }), broadcast({
3961
3961
  type: "ERROR",
3962
3962
  code: StateStreamErrorCode.AUTH_FAILED,
3963
- message: \`Maximum authentication attempts (\${MAX_AUTH_ATTEMPTS}) reached. Please log in again.\`
3963
+ message: \`Maximum authentication attempts (\${maxAuthAttempts}) reached. Please log in again.\`
3964
3964
  }));
3965
3965
  return;
3966
3966
  }
3967
- if (currentMode === "remote" && RECONNECT_CODES.has(n.code)) {
3968
- if (retryCount < MAX_RECONNECT_ATTEMPTS) {
3967
+ if (RECONNECT_CODES.has(n.code)) {
3968
+ if (retryCount < maxReconnectAttempts) {
3969
3969
  retryCount++;
3970
3970
  const e = Math.min(1e3 * retryCount, 5e3);
3971
- console.log(\`[Worker] Reconnecting (network code: \${n.code}) in \${e}ms... (Attempt \${retryCount}/\${MAX_RECONNECT_ATTEMPTS})\`), broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.RECONNECTING }), setTimeout(() => {
3971
+ console.log(\`[Worker] Reconnecting (network code: \${n.code}) in \${e}ms... (Attempt \${retryCount}/\${maxReconnectAttempts})\`), broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.RECONNECTING, connectionAttempts: retryCount }), setTimeout(() => {
3972
3972
  activePorts.size > 0 && socket && connect(currentAddr, currentToken, isBinaryMode, currentMode);
3973
3973
  }, e);
3974
3974
  } else
3975
3975
  broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.DISCONNECTED }), broadcast({
3976
3976
  type: "ERROR",
3977
3977
  code: StateStreamErrorCode.RECONNECT_FAILED,
3978
- message: \`Maximum reconnection attempts (\${MAX_RECONNECT_ATTEMPTS}) reached. Connection lost.\`
3978
+ message: \`Maximum reconnection attempts (\${maxReconnectAttempts}) reached. Connection lost.\`
3979
3979
  });
3980
3980
  return;
3981
3981
  }
@@ -3989,7 +3989,7 @@ function connect(u, f, h = !0, c = "local") {
3989
3989
  function handleCommand(u, f) {
3990
3990
  switch (u.type) {
3991
3991
  case "START":
3992
- activePorts.add(f), socket && socket.readyState === WebSocket.OPEN && currentAddr === u.addr ? (f.postMessage({ type: "CONNECTED" }), f.postMessage({ type: "STATUS_UPDATE", auth: AuthStatus.AUTHENTICATED })) : connect(u.addr, u.token, u.isBinary, u.mode);
3992
+ maxAuthAttempts = u.maxAuthAttempts ?? DEFAULT_MAX_AUTH_ATTEMPTS, maxReconnectAttempts = u.maxReconnectAttempts ?? DEFAULT_MAX_RECONNECT_ATTEMPTS, activePorts.add(f), socket && socket.readyState === WebSocket.OPEN && currentAddr === u.addr ? (f.postMessage({ type: "CONNECTED" }), f.postMessage({ type: "STATUS_UPDATE", auth: AuthStatus.AUTHENTICATED })) : connect(u.addr, u.token, u.isBinary, u.mode);
3993
3993
  break;
3994
3994
  case "STOP":
3995
3995
  activePorts.delete(f);
@@ -4030,7 +4030,7 @@ if ("SharedWorkerGlobalScope" in self) {
4030
4030
  handleCommand(f.data, u);
4031
4031
  };
4032
4032
  }
4033
- `,N=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",k],{type:"text/javascript;charset=utf-8"});function ce(e){let n;try{if(n=N&&(self.URL||self.webkitURL).createObjectURL(N),!n)throw"";const t=new Worker(n,{type:"module",name:e==null?void 0:e.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(k),{type:"module",name:e==null?void 0:e.name})}}const de=`var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
4033
+ `,N=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",q],{type:"text/javascript;charset=utf-8"});function pe(e){let n;try{if(n=N&&(self.URL||self.webkitURL).createObjectURL(N),!n)throw"";const t=new Worker(n,{type:"module",name:e==null?void 0:e.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(q),{type:"module",name:e==null?void 0:e.name})}}const he=`var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
4034
4034
  function requireAspromise() {
4035
4035
  if (hasRequiredAspromise) return aspromise;
4036
4036
  hasRequiredAspromise = 1, aspromise = u;
@@ -4596,8 +4596,8 @@ function requireWriter() {
4596
4596
  var y = u.Array.prototype.set ? function(v, m, _) {
4597
4597
  m.set(v, _);
4598
4598
  } : function(v, m, _) {
4599
- for (var b = 0; b < v.length; ++b)
4600
- m[_ + b] = v[b];
4599
+ for (var A = 0; A < v.length; ++A)
4600
+ m[_ + A] = v[A];
4601
4601
  };
4602
4602
  return i.prototype.bytes = function(v) {
4603
4603
  var m = v.length >>> 0;
@@ -5738,10 +5738,10 @@ function requireType() {
5738
5738
  return this._fieldsById;
5739
5739
  this._fieldsById = {};
5740
5740
  for (var v = Object.keys(this.fields), m = 0; m < v.length; ++m) {
5741
- var _ = this.fields[v[m]], b = _.id;
5742
- if (this._fieldsById[b])
5743
- throw Error("duplicate id " + b + " in " + this);
5744
- this._fieldsById[b] = _;
5741
+ var _ = this.fields[v[m]], A = _.id;
5742
+ if (this._fieldsById[A])
5743
+ throw Error("duplicate id " + A + " in " + this);
5744
+ this._fieldsById[A] = _;
5745
5745
  }
5746
5746
  return this._fieldsById;
5747
5747
  }
@@ -5784,45 +5784,45 @@ function requireType() {
5784
5784
  for (var _ = 0; _ < /* initializes */
5785
5785
  this.fieldsArray.length; ++_)
5786
5786
  this._fieldsArray[_].resolve();
5787
- var b = {};
5787
+ var A = {};
5788
5788
  for (_ = 0; _ < /* initializes */
5789
5789
  this.oneofsArray.length; ++_)
5790
- b[this._oneofsArray[_].resolve().name] = {
5790
+ A[this._oneofsArray[_].resolve().name] = {
5791
5791
  get: t.oneOfGetter(this._oneofsArray[_].oneof),
5792
5792
  set: t.oneOfSetter(this._oneofsArray[_].oneof)
5793
5793
  };
5794
- _ && Object.defineProperties(v.prototype, b);
5794
+ _ && Object.defineProperties(v.prototype, A);
5795
5795
  }
5796
5796
  }
5797
5797
  }), y.generateConstructor = function(m) {
5798
- for (var _ = t.codegen(["p"], m.name), b = 0, I; b < m.fieldsArray.length; ++b)
5799
- (I = m._fieldsArray[b]).map ? _("this%s={}", t.safeProp(I.name)) : I.repeated && _("this%s=[]", t.safeProp(I.name));
5798
+ for (var _ = t.codegen(["p"], m.name), A = 0, I; A < m.fieldsArray.length; ++A)
5799
+ (I = m._fieldsArray[A]).map ? _("this%s={}", t.safeProp(I.name)) : I.repeated && _("this%s=[]", t.safeProp(I.name));
5800
5800
  return _("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]");
5801
5801
  };
5802
5802
  function E(v) {
5803
5803
  return v._fieldsById = v._fieldsArray = v._oneofsArray = null, delete v.encode, delete v.decode, delete v.verify, v;
5804
5804
  }
5805
5805
  return y.fromJSON = function(m, _) {
5806
- var b = new y(m, _.options);
5807
- b.extensions = _.extensions, b.reserved = _.reserved;
5806
+ var A = new y(m, _.options);
5807
+ A.extensions = _.extensions, A.reserved = _.reserved;
5808
5808
  for (var I = Object.keys(_.fields), C = 0; C < I.length; ++C)
5809
- b.add(
5809
+ A.add(
5810
5810
  (typeof _.fields[I[C]].keyType < "u" ? d.fromJSON : c.fromJSON)(I[C], _.fields[I[C]])
5811
5811
  );
5812
5812
  if (_.oneofs)
5813
5813
  for (I = Object.keys(_.oneofs), C = 0; C < I.length; ++C)
5814
- b.add(h.fromJSON(I[C], _.oneofs[I[C]]));
5814
+ A.add(h.fromJSON(I[C], _.oneofs[I[C]]));
5815
5815
  if (_.nested)
5816
5816
  for (I = Object.keys(_.nested), C = 0; C < I.length; ++C) {
5817
5817
  var j = _.nested[I[C]];
5818
- b.add(
5818
+ A.add(
5819
5819
  // most to least likely
5820
5820
  (j.id !== void 0 ? c.fromJSON : j.fields !== void 0 ? y.fromJSON : j.values !== void 0 ? f.fromJSON : j.methods !== void 0 ? n.fromJSON : u.fromJSON)(I[C], j)
5821
5821
  );
5822
5822
  }
5823
- return _.extensions && _.extensions.length && (b.extensions = _.extensions), _.reserved && _.reserved.length && (b.reserved = _.reserved), _.group && (b.group = !0), _.comment && (b.comment = _.comment), _.edition && (b._edition = _.edition), b._defaultEdition = "proto3", b;
5823
+ return _.extensions && _.extensions.length && (A.extensions = _.extensions), _.reserved && _.reserved.length && (A.reserved = _.reserved), _.group && (A.group = !0), _.comment && (A.comment = _.comment), _.edition && (A._edition = _.edition), A._defaultEdition = "proto3", A;
5824
5824
  }, y.prototype.toJSON = function(m) {
5825
- var _ = u.prototype.toJSON.call(this, m), b = m ? !!m.keepComments : !1;
5825
+ var _ = u.prototype.toJSON.call(this, m), A = m ? !!m.keepComments : !1;
5826
5826
  return t.toObject([
5827
5827
  "edition",
5828
5828
  this._editionToJSON(),
@@ -5843,16 +5843,16 @@ function requireType() {
5843
5843
  "nested",
5844
5844
  _ && _.nested || void 0,
5845
5845
  "comment",
5846
- b ? this.comment : void 0
5846
+ A ? this.comment : void 0
5847
5847
  ]);
5848
5848
  }, y.prototype.resolveAll = function() {
5849
5849
  if (!this._needsRecursiveResolve) return this;
5850
5850
  u.prototype.resolveAll.call(this);
5851
5851
  var m = this.oneofsArray;
5852
- for (b = 0; b < m.length; )
5853
- m[b++].resolve();
5854
- for (var _ = this.fieldsArray, b = 0; b < _.length; )
5855
- _[b++].resolve();
5852
+ for (A = 0; A < m.length; )
5853
+ m[A++].resolve();
5854
+ for (var _ = this.fieldsArray, A = 0; A < _.length; )
5855
+ _[A++].resolve();
5856
5856
  return this;
5857
5857
  }, y.prototype._resolveFeaturesRecursive = function(m) {
5858
5858
  return this._needsRecursiveFeatureResolution ? (m = this._edition || m, u.prototype._resolveFeaturesRecursive.call(this, m), this.oneofsArray.forEach((_) => {
@@ -5897,9 +5897,9 @@ function requireType() {
5897
5897
  }, y.prototype.create = function(m) {
5898
5898
  return new this.ctor(m);
5899
5899
  }, y.prototype.setup = function() {
5900
- for (var m = this.fullName, _ = [], b = 0; b < /* initializes */
5901
- this.fieldsArray.length; ++b)
5902
- _.push(this._fieldsArray[b].resolve().resolvedType);
5900
+ for (var m = this.fullName, _ = [], A = 0; A < /* initializes */
5901
+ this.fieldsArray.length; ++A)
5902
+ _.push(this._fieldsArray[A].resolve().resolvedType);
5903
5903
  this.encode = l(this)({
5904
5904
  Writer: i,
5905
5905
  types: _,
@@ -5939,8 +5939,8 @@ function requireType() {
5939
5939
  }, y.prototype.toObject = function(m, _) {
5940
5940
  return this.setup().toObject(m, _);
5941
5941
  }, y.d = function(m) {
5942
- return function(b) {
5943
- t.decorateType(b, m);
5942
+ return function(A) {
5943
+ t.decorateType(A, m);
5944
5944
  };
5945
5945
  }, type;
5946
5946
  }
@@ -5965,67 +5965,67 @@ function requireRoot() {
5965
5965
  if (!y)
5966
5966
  return d.asPromise(a, E, o, p);
5967
5967
  var v = y === t;
5968
- function m(D, P) {
5968
+ function m(B, L) {
5969
5969
  if (y) {
5970
5970
  if (v)
5971
- throw D;
5972
- P && P.resolveAll();
5971
+ throw B;
5972
+ L && L.resolveAll();
5973
5973
  var S = y;
5974
- y = null, S(D, P);
5974
+ y = null, S(B, L);
5975
5975
  }
5976
5976
  }
5977
- function _(D) {
5978
- var P = D.lastIndexOf("google/protobuf/");
5979
- if (P > -1) {
5980
- var S = D.substring(P);
5977
+ function _(B) {
5978
+ var L = B.lastIndexOf("google/protobuf/");
5979
+ if (L > -1) {
5980
+ var S = B.substring(L);
5981
5981
  if (S in r) return S;
5982
5982
  }
5983
5983
  return null;
5984
5984
  }
5985
- function b(D, P) {
5985
+ function A(B, L) {
5986
5986
  try {
5987
- if (d.isString(P) && P.charAt(0) === "{" && (P = JSON.parse(P)), !d.isString(P))
5988
- E.setOptions(P.options).addJSON(P.nested);
5987
+ if (d.isString(L) && L.charAt(0) === "{" && (L = JSON.parse(L)), !d.isString(L))
5988
+ E.setOptions(L.options).addJSON(L.nested);
5989
5989
  else {
5990
- e.filename = D;
5991
- var S = e(P, E, p), J, U = 0;
5990
+ e.filename = B;
5991
+ var S = e(L, E, p), J, M = 0;
5992
5992
  if (S.imports)
5993
- for (; U < S.imports.length; ++U)
5994
- (J = _(S.imports[U]) || E.resolvePath(D, S.imports[U])) && I(J);
5993
+ for (; M < S.imports.length; ++M)
5994
+ (J = _(S.imports[M]) || E.resolvePath(B, S.imports[M])) && I(J);
5995
5995
  if (S.weakImports)
5996
- for (U = 0; U < S.weakImports.length; ++U)
5997
- (J = _(S.weakImports[U]) || E.resolvePath(D, S.weakImports[U])) && I(J, !0);
5996
+ for (M = 0; M < S.weakImports.length; ++M)
5997
+ (J = _(S.weakImports[M]) || E.resolvePath(B, S.weakImports[M])) && I(J, !0);
5998
5998
  }
5999
5999
  } catch (T) {
6000
6000
  m(T);
6001
6001
  }
6002
6002
  !v && !C && m(null, E);
6003
6003
  }
6004
- function I(D, P) {
6005
- if (D = _(D) || D, !(E.files.indexOf(D) > -1)) {
6006
- if (E.files.push(D), D in r) {
6007
- v ? b(D, r[D]) : (++C, setTimeout(function() {
6008
- --C, b(D, r[D]);
6004
+ function I(B, L) {
6005
+ if (B = _(B) || B, !(E.files.indexOf(B) > -1)) {
6006
+ if (E.files.push(B), B in r) {
6007
+ v ? A(B, r[B]) : (++C, setTimeout(function() {
6008
+ --C, A(B, r[B]);
6009
6009
  }));
6010
6010
  return;
6011
6011
  }
6012
6012
  if (v) {
6013
6013
  var S;
6014
6014
  try {
6015
- S = d.fs.readFileSync(D).toString("utf8");
6015
+ S = d.fs.readFileSync(B).toString("utf8");
6016
6016
  } catch (J) {
6017
- P || m(J);
6017
+ L || m(J);
6018
6018
  return;
6019
6019
  }
6020
- b(D, S);
6020
+ A(B, S);
6021
6021
  } else
6022
- ++C, E.fetch(D, function(J, U) {
6022
+ ++C, E.fetch(B, function(J, M) {
6023
6023
  if (--C, !!y) {
6024
6024
  if (J) {
6025
- P ? C || m(null, E) : m(J);
6025
+ L ? C || m(null, E) : m(J);
6026
6026
  return;
6027
6027
  }
6028
- b(D, U);
6028
+ A(B, M);
6029
6029
  }
6030
6030
  });
6031
6031
  }
@@ -6769,93 +6769,93 @@ function requireTokenize() {
6769
6769
  function l(s, a) {
6770
6770
  s = s.toString();
6771
6771
  var o = 0, p = s.length, y = 1, E = 0, v = {}, m = [], _ = null;
6772
- function b(k) {
6772
+ function A(k) {
6773
6773
  return Error("illegal " + k + " (line " + y + ")");
6774
6774
  }
6775
6775
  function I() {
6776
6776
  var k = _ === "'" ? h : f;
6777
6777
  k.lastIndex = o - 1;
6778
- var L = k.exec(s);
6779
- if (!L)
6780
- throw b("string");
6781
- return o = k.lastIndex, S(_), _ = null, t(L[1]);
6778
+ var P = k.exec(s);
6779
+ if (!P)
6780
+ throw A("string");
6781
+ return o = k.lastIndex, S(_), _ = null, t(P[1]);
6782
6782
  }
6783
6783
  function C(k) {
6784
6784
  return s.charAt(k);
6785
6785
  }
6786
- function j(k, L, F) {
6786
+ function j(k, P, F) {
6787
6787
  var W = {
6788
6788
  type: s.charAt(k++),
6789
6789
  lineEmpty: !1,
6790
6790
  leading: F
6791
6791
  }, H;
6792
6792
  a ? H = 2 : H = 3;
6793
- var B = k - H, $;
6793
+ var D = k - H, $;
6794
6794
  do
6795
- if (--B < 0 || ($ = s.charAt(B)) === \`
6795
+ if (--D < 0 || ($ = s.charAt(D)) === \`
6796
6796
  \`) {
6797
6797
  W.lineEmpty = !0;
6798
6798
  break;
6799
6799
  }
6800
6800
  while ($ === " " || $ === " ");
6801
- for (var X = s.substring(k, L).split(n), z = 0; z < X.length; ++z)
6801
+ for (var X = s.substring(k, P).split(n), z = 0; z < X.length; ++z)
6802
6802
  X[z] = X[z].replace(a ? d : c, "").trim();
6803
6803
  W.text = X.join(\`
6804
6804
  \`).trim(), v[y] = W, E = y;
6805
6805
  }
6806
6806
  function K(k) {
6807
- var L = D(k), F = s.substring(k, L), W = /^\\s*\\/\\//.test(F);
6807
+ var P = B(k), F = s.substring(k, P), W = /^\\s*\\/\\//.test(F);
6808
6808
  return W;
6809
6809
  }
6810
- function D(k) {
6811
- for (var L = k; L < p && C(L) !== \`
6810
+ function B(k) {
6811
+ for (var P = k; P < p && C(P) !== \`
6812
6812
  \`; )
6813
- L++;
6814
- return L;
6813
+ P++;
6814
+ return P;
6815
6815
  }
6816
- function P() {
6816
+ function L() {
6817
6817
  if (m.length > 0)
6818
6818
  return m.shift();
6819
6819
  if (_)
6820
6820
  return I();
6821
- var k, L, F, W, H, B = o === 0;
6821
+ var k, P, F, W, H, D = o === 0;
6822
6822
  do {
6823
6823
  if (o === p)
6824
6824
  return null;
6825
6825
  for (k = !1; e.test(F = C(o)); )
6826
6826
  if (F === \`
6827
- \` && (B = !0, ++y), ++o === p)
6827
+ \` && (D = !0, ++y), ++o === p)
6828
6828
  return null;
6829
6829
  if (C(o) === "/") {
6830
6830
  if (++o === p)
6831
- throw b("comment");
6831
+ throw A("comment");
6832
6832
  if (C(o) === "/")
6833
6833
  if (a) {
6834
6834
  if (W = o, H = !1, K(o - 1)) {
6835
6835
  H = !0;
6836
6836
  do
6837
- if (o = D(o), o === p || (o++, !B))
6837
+ if (o = B(o), o === p || (o++, !D))
6838
6838
  break;
6839
6839
  while (K(o));
6840
6840
  } else
6841
- o = Math.min(p, D(o) + 1);
6842
- H && (j(W, o, B), B = !0), y++, k = !0;
6841
+ o = Math.min(p, B(o) + 1);
6842
+ H && (j(W, o, D), D = !0), y++, k = !0;
6843
6843
  } else {
6844
6844
  for (H = C(W = o + 1) === "/"; C(++o) !== \`
6845
6845
  \`; )
6846
6846
  if (o === p)
6847
6847
  return null;
6848
- ++o, H && (j(W, o - 1, B), B = !0), ++y, k = !0;
6848
+ ++o, H && (j(W, o - 1, D), D = !0), ++y, k = !0;
6849
6849
  }
6850
6850
  else if ((F = C(o)) === "*") {
6851
6851
  W = o + 1, H = a || C(W) === "*";
6852
6852
  do {
6853
6853
  if (F === \`
6854
6854
  \` && ++y, ++o === p)
6855
- throw b("comment");
6856
- L = F, F = C(o);
6857
- } while (L !== "*" || F !== "/");
6858
- ++o, H && (j(W, o - 2, B), B = !0), k = !0;
6855
+ throw A("comment");
6856
+ P = F, F = C(o);
6857
+ } while (P !== "*" || F !== "/");
6858
+ ++o, H && (j(W, o - 2, D), D = !0), k = !0;
6859
6859
  } else
6860
6860
  return "/";
6861
6861
  }
@@ -6874,30 +6874,30 @@ function requireTokenize() {
6874
6874
  }
6875
6875
  function J() {
6876
6876
  if (!m.length) {
6877
- var k = P();
6877
+ var k = L();
6878
6878
  if (k === null)
6879
6879
  return null;
6880
6880
  S(k);
6881
6881
  }
6882
6882
  return m[0];
6883
6883
  }
6884
- function U(k, L) {
6884
+ function M(k, P) {
6885
6885
  var F = J(), W = F === k;
6886
6886
  if (W)
6887
- return P(), !0;
6888
- if (!L)
6889
- throw b("token '" + F + "', '" + k + "' expected");
6887
+ return L(), !0;
6888
+ if (!P)
6889
+ throw A("token '" + F + "', '" + k + "' expected");
6890
6890
  return !1;
6891
6891
  }
6892
6892
  function T(k) {
6893
- var L = null, F;
6894
- return k === void 0 ? (F = v[y - 1], delete v[y - 1], F && (a || F.type === "*" || F.lineEmpty) && (L = F.leading ? F.text : null)) : (E < k && J(), F = v[k], delete v[k], F && !F.lineEmpty && (a || F.type === "/") && (L = F.leading ? null : F.text)), L;
6893
+ var P = null, F;
6894
+ return k === void 0 ? (F = v[y - 1], delete v[y - 1], F && (a || F.type === "*" || F.lineEmpty) && (P = F.leading ? F.text : null)) : (E < k && J(), F = v[k], delete v[k], F && !F.lineEmpty && (a || F.type === "/") && (P = F.leading ? null : F.text)), P;
6895
6895
  }
6896
6896
  return Object.defineProperty({
6897
- next: P,
6897
+ next: L,
6898
6898
  peek: J,
6899
6899
  push: S,
6900
- skip: U,
6900
+ skip: M,
6901
6901
  cmnt: T
6902
6902
  }, "line", {
6903
6903
  get: function() {
@@ -6911,33 +6911,33 @@ var parse_1, hasRequiredParse;
6911
6911
  function requireParse() {
6912
6912
  if (hasRequiredParse) return parse_1;
6913
6913
  hasRequiredParse = 1, parse_1 = I, I.filename = null, I.defaults = { keepCase: !1 };
6914
- var u = requireTokenize(), f = requireRoot(), h = requireType(), c = requireField(), d = requireMapfield(), n = requireOneof(), e = require_enum(), r = requireService(), i = requireMethod(), t = requireObject(), l = requireTypes(), s = requireUtil(), a = /^[1-9][0-9]*$/, o = /^-?[1-9][0-9]*$/, p = /^0[x][0-9a-fA-F]+$/, y = /^-?0[x][0-9a-fA-F]+$/, E = /^0[0-7]+$/, v = /^-?0[0-7]+$/, m = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, _ = /^[a-zA-Z_][a-zA-Z_0-9]*$/, b = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
6914
+ var u = requireTokenize(), f = requireRoot(), h = requireType(), c = requireField(), d = requireMapfield(), n = requireOneof(), e = require_enum(), r = requireService(), i = requireMethod(), t = requireObject(), l = requireTypes(), s = requireUtil(), a = /^[1-9][0-9]*$/, o = /^-?[1-9][0-9]*$/, p = /^0[x][0-9a-fA-F]+$/, y = /^-?0[x][0-9a-fA-F]+$/, E = /^0[0-7]+$/, v = /^-?0[0-7]+$/, m = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, _ = /^[a-zA-Z_][a-zA-Z_0-9]*$/, A = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
6915
6915
  function I(C, j, K) {
6916
6916
  j instanceof f || (K = j, j = new f()), K || (K = I.defaults);
6917
- var D = K.preferTrailingComment || !1, P = u(C, K.alternateCommentMode || !1), S = P.next, J = P.push, U = P.peek, T = P.skip, k = P.cmnt, L = !0, F, W, H, B = "proto2", $ = j, X = [], z = {}, ae = K.keepCase ? function(O) {
6918
- return O;
6917
+ var B = K.preferTrailingComment || !1, L = u(C, K.alternateCommentMode || !1), S = L.next, J = L.push, M = L.peek, T = L.skip, k = L.cmnt, P = !0, F, W, H, D = "proto2", $ = j, X = [], z = {}, ae = K.keepCase ? function(R) {
6918
+ return R;
6919
6919
  } : s.camelCase;
6920
6920
  function he() {
6921
- X.forEach((O) => {
6922
- O._edition = B, Object.keys(z).forEach((g) => {
6923
- O.getOption(g) === void 0 && O.setOption(g, z[g], !0);
6921
+ X.forEach((R) => {
6922
+ R._edition = D, Object.keys(z).forEach((g) => {
6923
+ R.getOption(g) === void 0 && R.setOption(g, z[g], !0);
6924
6924
  });
6925
6925
  });
6926
6926
  }
6927
- function N(O, g, R) {
6928
- var A = I.filename;
6929
- return R || (I.filename = null), Error("illegal " + (g || "token") + " '" + O + "' (" + (A ? A + ", " : "") + "line " + P.line + ")");
6927
+ function N(R, g, O) {
6928
+ var b = I.filename;
6929
+ return O || (I.filename = null), Error("illegal " + (g || "token") + " '" + R + "' (" + (b ? b + ", " : "") + "line " + L.line + ")");
6930
6930
  }
6931
6931
  function ee() {
6932
- var O = [], g;
6932
+ var R = [], g;
6933
6933
  do {
6934
6934
  if ((g = S()) !== '"' && g !== "'")
6935
6935
  throw N(g);
6936
- O.push(S()), T(g), g = U();
6936
+ R.push(S()), T(g), g = M();
6937
6937
  } while (g === '"' || g === "'");
6938
- return O.join("");
6938
+ return R.join("");
6939
6939
  }
6940
- function ue(O) {
6940
+ function ue(R) {
6941
6941
  var g = S();
6942
6942
  switch (g) {
6943
6943
  case "'":
@@ -6957,24 +6957,24 @@ function requireParse() {
6957
6957
  !0
6958
6958
  );
6959
6959
  } catch {
6960
- if (b.test(g))
6960
+ if (A.test(g))
6961
6961
  return g;
6962
6962
  throw N(g, "value");
6963
6963
  }
6964
6964
  }
6965
- function re(O, g) {
6966
- var R, A;
6965
+ function re(R, g) {
6966
+ var O, b;
6967
6967
  do
6968
- if (g && ((R = U()) === '"' || R === "'")) {
6968
+ if (g && ((O = M()) === '"' || O === "'")) {
6969
6969
  var w = ee();
6970
- if (O.push(w), B >= 2023)
6970
+ if (R.push(w), D >= 2023)
6971
6971
  throw N(w, "id");
6972
6972
  } else
6973
6973
  try {
6974
- O.push([A = te(S()), T("to", !0) ? te(S()) : A]);
6974
+ R.push([b = te(S()), T("to", !0) ? te(S()) : b]);
6975
6975
  } catch (x) {
6976
- if (g && b.test(R) && B >= 2023)
6977
- O.push(R);
6976
+ if (g && A.test(O) && D >= 2023)
6977
+ R.push(O);
6978
6978
  else
6979
6979
  throw x;
6980
6980
  }
@@ -6995,13 +6995,13 @@ function requireParse() {
6995
6995
  }
6996
6996
  );
6997
6997
  }
6998
- function pe(O, g) {
6999
- var R = 1;
7000
- switch (O.charAt(0) === "-" && (R = -1, O = O.substring(1)), O) {
6998
+ function pe(R, g) {
6999
+ var O = 1;
7000
+ switch (R.charAt(0) === "-" && (O = -1, R = R.substring(1)), R) {
7001
7001
  case "inf":
7002
7002
  case "INF":
7003
7003
  case "Inf":
7004
- return R * (1 / 0);
7004
+ return O * (1 / 0);
7005
7005
  case "nan":
7006
7006
  case "NAN":
7007
7007
  case "Nan":
@@ -7010,18 +7010,18 @@ function requireParse() {
7010
7010
  case "0":
7011
7011
  return 0;
7012
7012
  }
7013
- if (a.test(O))
7014
- return R * parseInt(O, 10);
7015
- if (p.test(O))
7016
- return R * parseInt(O, 16);
7017
- if (E.test(O))
7018
- return R * parseInt(O, 8);
7019
- if (m.test(O))
7020
- return R * parseFloat(O);
7021
- throw N(O, "number", g);
7022
- }
7023
- function te(O, g) {
7024
- switch (O) {
7013
+ if (a.test(R))
7014
+ return O * parseInt(R, 10);
7015
+ if (p.test(R))
7016
+ return O * parseInt(R, 16);
7017
+ if (E.test(R))
7018
+ return O * parseInt(R, 8);
7019
+ if (m.test(R))
7020
+ return O * parseFloat(R);
7021
+ throw N(R, "number", g);
7022
+ }
7023
+ function te(R, g) {
7024
+ switch (R) {
7025
7025
  case "max":
7026
7026
  case "MAX":
7027
7027
  case "Max":
@@ -7029,28 +7029,28 @@ function requireParse() {
7029
7029
  case "0":
7030
7030
  return 0;
7031
7031
  }
7032
- if (!g && O.charAt(0) === "-")
7033
- throw N(O, "id");
7034
- if (o.test(O))
7035
- return parseInt(O, 10);
7036
- if (y.test(O))
7037
- return parseInt(O, 16);
7038
- if (v.test(O))
7039
- return parseInt(O, 8);
7040
- throw N(O, "id");
7032
+ if (!g && R.charAt(0) === "-")
7033
+ throw N(R, "id");
7034
+ if (o.test(R))
7035
+ return parseInt(R, 10);
7036
+ if (y.test(R))
7037
+ return parseInt(R, 16);
7038
+ if (v.test(R))
7039
+ return parseInt(R, 8);
7040
+ throw N(R, "id");
7041
7041
  }
7042
7042
  function ye() {
7043
7043
  if (F !== void 0)
7044
7044
  throw N("package");
7045
- if (F = S(), !b.test(F))
7045
+ if (F = S(), !A.test(F))
7046
7046
  throw N(F, "name");
7047
7047
  $ = $.define(F), T(";");
7048
7048
  }
7049
7049
  function me() {
7050
- var O = U(), g;
7051
- switch (O) {
7050
+ var R = M(), g;
7051
+ switch (R) {
7052
7052
  case "option":
7053
- if (B < "2024")
7053
+ if (D < "2024")
7054
7054
  throw N("option");
7055
7055
  S(), ee(), T(";");
7056
7056
  return;
@@ -7064,185 +7064,185 @@ function requireParse() {
7064
7064
  g = W || (W = []);
7065
7065
  break;
7066
7066
  }
7067
- O = ee(), T(";"), g.push(O);
7067
+ R = ee(), T(";"), g.push(R);
7068
7068
  }
7069
7069
  function ve() {
7070
- if (T("="), B = ee(), B < 2023)
7071
- throw N(B, "syntax");
7070
+ if (T("="), D = ee(), D < 2023)
7071
+ throw N(D, "syntax");
7072
7072
  T(";");
7073
7073
  }
7074
7074
  function ge() {
7075
- if (T("="), B = ee(), !["2023", "2024"].includes(B))
7076
- throw N(B, "edition");
7075
+ if (T("="), D = ee(), !["2023", "2024"].includes(D))
7076
+ throw N(D, "edition");
7077
7077
  T(";");
7078
7078
  }
7079
- function ie(O, g) {
7079
+ function ie(R, g) {
7080
7080
  switch (g) {
7081
7081
  case "option":
7082
- return Q(O, g), T(";"), !0;
7082
+ return Q(R, g), T(";"), !0;
7083
7083
  case "message":
7084
- return ne(O, g), !0;
7084
+ return ne(R, g), !0;
7085
7085
  case "enum":
7086
- return de(O, g), !0;
7086
+ return de(R, g), !0;
7087
7087
  case "export":
7088
7088
  case "local":
7089
- return B < "2024" || (g = S(), g === "export" || g === "local") || g !== "message" && g !== "enum" ? !1 : ie(O, g);
7089
+ return D < "2024" || (g = S(), g === "export" || g === "local") || g !== "message" && g !== "enum" ? !1 : ie(R, g);
7090
7090
  case "service":
7091
- return Ae(O, g), !0;
7091
+ return be(R, g), !0;
7092
7092
  case "extend":
7093
- return Se(O, g), !0;
7093
+ return Se(R, g), !0;
7094
7094
  }
7095
7095
  return !1;
7096
7096
  }
7097
- function Z(O, g, R) {
7098
- var A = P.line;
7099
- if (O && (typeof O.comment != "string" && (O.comment = k()), O.filename = I.filename), T("{", !0)) {
7097
+ function Z(R, g, O) {
7098
+ var b = L.line;
7099
+ if (R && (typeof R.comment != "string" && (R.comment = k()), R.filename = I.filename), T("{", !0)) {
7100
7100
  for (var w; (w = S()) !== "}"; )
7101
7101
  g(w);
7102
7102
  T(";", !0);
7103
7103
  } else
7104
- R && R(), T(";"), O && (typeof O.comment != "string" || D) && (O.comment = k(A) || O.comment);
7104
+ O && O(), T(";"), R && (typeof R.comment != "string" || B) && (R.comment = k(b) || R.comment);
7105
7105
  }
7106
- function ne(O, g) {
7106
+ function ne(R, g) {
7107
7107
  if (!_.test(g = S()))
7108
7108
  throw N(g, "type name");
7109
- var R = new h(g);
7110
- Z(R, function(w) {
7111
- if (!ie(R, w))
7109
+ var O = new h(g);
7110
+ Z(O, function(w) {
7111
+ if (!ie(O, w))
7112
7112
  switch (w) {
7113
7113
  case "map":
7114
- Ee(R);
7114
+ Ee(O);
7115
7115
  break;
7116
7116
  case "required":
7117
- if (B !== "proto2")
7117
+ if (D !== "proto2")
7118
7118
  throw N(w);
7119
7119
  /* eslint-disable no-fallthrough */
7120
7120
  case "repeated":
7121
- Y(R, w);
7121
+ Y(O, w);
7122
7122
  break;
7123
7123
  case "optional":
7124
- if (B === "proto3")
7125
- Y(R, "proto3_optional");
7124
+ if (D === "proto3")
7125
+ Y(O, "proto3_optional");
7126
7126
  else {
7127
- if (B !== "proto2")
7127
+ if (D !== "proto2")
7128
7128
  throw N(w);
7129
- Y(R, "optional");
7129
+ Y(O, "optional");
7130
7130
  }
7131
7131
  break;
7132
7132
  case "oneof":
7133
- Oe(R, w);
7133
+ Re(O, w);
7134
7134
  break;
7135
7135
  case "extensions":
7136
- re(R.extensions || (R.extensions = []));
7136
+ re(O.extensions || (O.extensions = []));
7137
7137
  break;
7138
7138
  case "reserved":
7139
- re(R.reserved || (R.reserved = []), !0);
7139
+ re(O.reserved || (O.reserved = []), !0);
7140
7140
  break;
7141
7141
  default:
7142
- if (B === "proto2" || !b.test(w))
7142
+ if (D === "proto2" || !A.test(w))
7143
7143
  throw N(w);
7144
- J(w), Y(R, "optional");
7144
+ J(w), Y(O, "optional");
7145
7145
  break;
7146
7146
  }
7147
- }), O.add(R), O === $ && X.push(R);
7147
+ }), R.add(O), R === $ && X.push(O);
7148
7148
  }
7149
- function Y(O, g, R) {
7150
- var A = S();
7151
- if (A === "group") {
7152
- _e(O, g);
7149
+ function Y(R, g, O) {
7150
+ var b = S();
7151
+ if (b === "group") {
7152
+ _e(R, g);
7153
7153
  return;
7154
7154
  }
7155
- for (; A.endsWith(".") || U().startsWith("."); )
7156
- A += S();
7157
- if (!b.test(A))
7158
- throw N(A, "type");
7155
+ for (; b.endsWith(".") || M().startsWith("."); )
7156
+ b += S();
7157
+ if (!A.test(b))
7158
+ throw N(b, "type");
7159
7159
  var w = S();
7160
7160
  if (!_.test(w))
7161
7161
  throw N(w, "name");
7162
7162
  w = ae(w), T("=");
7163
- var q = new c(w, te(S()), A, g, R);
7164
- if (Z(q, function(M) {
7165
- if (M === "option")
7166
- Q(q, M), T(";");
7163
+ var q = new c(w, te(S()), b, g, O);
7164
+ if (Z(q, function(U) {
7165
+ if (U === "option")
7166
+ Q(q, U), T(";");
7167
7167
  else
7168
- throw N(M);
7168
+ throw N(U);
7169
7169
  }, function() {
7170
7170
  se(q);
7171
7171
  }), g === "proto3_optional") {
7172
7172
  var x = new n("_" + w);
7173
- q.setOption("proto3_optional", !0), x.add(q), O.add(x);
7173
+ q.setOption("proto3_optional", !0), x.add(q), R.add(x);
7174
7174
  } else
7175
- O.add(q);
7176
- O === $ && X.push(q);
7175
+ R.add(q);
7176
+ R === $ && X.push(q);
7177
7177
  }
7178
- function _e(O, g) {
7179
- if (B >= 2023)
7178
+ function _e(R, g) {
7179
+ if (D >= 2023)
7180
7180
  throw N("group");
7181
- var R = S();
7182
- if (!_.test(R))
7183
- throw N(R, "name");
7184
- var A = s.lcFirst(R);
7185
- R === A && (R = s.ucFirst(R)), T("=");
7186
- var w = te(S()), q = new h(R);
7181
+ var O = S();
7182
+ if (!_.test(O))
7183
+ throw N(O, "name");
7184
+ var b = s.lcFirst(O);
7185
+ O === b && (O = s.ucFirst(O)), T("=");
7186
+ var w = te(S()), q = new h(O);
7187
7187
  q.group = !0;
7188
- var x = new c(A, w, R, g);
7189
- x.filename = I.filename, Z(q, function(M) {
7190
- switch (M) {
7188
+ var x = new c(b, w, O, g);
7189
+ x.filename = I.filename, Z(q, function(U) {
7190
+ switch (U) {
7191
7191
  case "option":
7192
- Q(q, M), T(";");
7192
+ Q(q, U), T(";");
7193
7193
  break;
7194
7194
  case "required":
7195
7195
  case "repeated":
7196
- Y(q, M);
7196
+ Y(q, U);
7197
7197
  break;
7198
7198
  case "optional":
7199
- B === "proto3" ? Y(q, "proto3_optional") : Y(q, "optional");
7199
+ D === "proto3" ? Y(q, "proto3_optional") : Y(q, "optional");
7200
7200
  break;
7201
7201
  case "message":
7202
- ne(q, M);
7202
+ ne(q, U);
7203
7203
  break;
7204
7204
  case "enum":
7205
- de(q, M);
7205
+ de(q, U);
7206
7206
  break;
7207
7207
  case "reserved":
7208
7208
  re(q.reserved || (q.reserved = []), !0);
7209
7209
  break;
7210
7210
  case "export":
7211
7211
  case "local":
7212
- if (B < "2024")
7213
- throw N(M);
7214
- switch (M = S(), M) {
7212
+ if (D < "2024")
7213
+ throw N(U);
7214
+ switch (U = S(), U) {
7215
7215
  case "message":
7216
- ne(q, M);
7216
+ ne(q, U);
7217
7217
  break;
7218
7218
  case "enum":
7219
- ne(q, M);
7219
+ ne(q, U);
7220
7220
  break;
7221
7221
  default:
7222
- throw N(M);
7222
+ throw N(U);
7223
7223
  }
7224
7224
  break;
7225
7225
  /* istanbul ignore next */
7226
7226
  default:
7227
- throw N(M);
7227
+ throw N(U);
7228
7228
  }
7229
- }), O.add(q).add(x);
7229
+ }), R.add(q).add(x);
7230
7230
  }
7231
- function Ee(O) {
7231
+ function Ee(R) {
7232
7232
  T("<");
7233
7233
  var g = S();
7234
7234
  if (l.mapKey[g] === void 0)
7235
7235
  throw N(g, "type");
7236
7236
  T(",");
7237
- var R = S();
7238
- if (!b.test(R))
7239
- throw N(R, "type");
7237
+ var O = S();
7238
+ if (!A.test(O))
7239
+ throw N(O, "type");
7240
7240
  T(">");
7241
- var A = S();
7242
- if (!_.test(A))
7243
- throw N(A, "name");
7241
+ var b = S();
7242
+ if (!_.test(b))
7243
+ throw N(b, "name");
7244
7244
  T("=");
7245
- var w = new d(ae(A), te(S()), g, R);
7245
+ var w = new d(ae(b), te(S()), g, O);
7246
7246
  Z(w, function(x) {
7247
7247
  if (x === "option")
7248
7248
  Q(w, x), T(";");
@@ -7250,56 +7250,56 @@ function requireParse() {
7250
7250
  throw N(x);
7251
7251
  }, function() {
7252
7252
  se(w);
7253
- }), O.add(w);
7253
+ }), R.add(w);
7254
7254
  }
7255
- function Oe(O, g) {
7255
+ function Re(R, g) {
7256
7256
  if (!_.test(g = S()))
7257
7257
  throw N(g, "name");
7258
- var R = new n(ae(g));
7259
- Z(R, function(w) {
7260
- w === "option" ? (Q(R, w), T(";")) : (J(w), Y(R, "optional"));
7261
- }), O.add(R);
7258
+ var O = new n(ae(g));
7259
+ Z(O, function(w) {
7260
+ w === "option" ? (Q(O, w), T(";")) : (J(w), Y(O, "optional"));
7261
+ }), R.add(O);
7262
7262
  }
7263
- function de(O, g) {
7263
+ function de(R, g) {
7264
7264
  if (!_.test(g = S()))
7265
7265
  throw N(g, "name");
7266
- var R = new e(g);
7267
- Z(R, function(w) {
7266
+ var O = new e(g);
7267
+ Z(O, function(w) {
7268
7268
  switch (w) {
7269
7269
  case "option":
7270
- Q(R, w), T(";");
7270
+ Q(O, w), T(";");
7271
7271
  break;
7272
7272
  case "reserved":
7273
- re(R.reserved || (R.reserved = []), !0), R.reserved === void 0 && (R.reserved = []);
7273
+ re(O.reserved || (O.reserved = []), !0), O.reserved === void 0 && (O.reserved = []);
7274
7274
  break;
7275
7275
  default:
7276
- Re(R, w);
7276
+ Oe(O, w);
7277
7277
  }
7278
- }), O.add(R), O === $ && X.push(R);
7278
+ }), R.add(O), R === $ && X.push(O);
7279
7279
  }
7280
- function Re(O, g) {
7280
+ function Oe(R, g) {
7281
7281
  if (!_.test(g))
7282
7282
  throw N(g, "name");
7283
7283
  T("=");
7284
- var R = te(S(), !0), A = {
7284
+ var O = te(S(), !0), b = {
7285
7285
  options: void 0
7286
7286
  };
7287
- A.getOption = function(w) {
7287
+ b.getOption = function(w) {
7288
7288
  return this.options[w];
7289
- }, A.setOption = function(w, q) {
7290
- t.prototype.setOption.call(A, w, q);
7291
- }, A.setParsedOption = function() {
7292
- }, Z(A, function(q) {
7289
+ }, b.setOption = function(w, q) {
7290
+ t.prototype.setOption.call(b, w, q);
7291
+ }, b.setParsedOption = function() {
7292
+ }, Z(b, function(q) {
7293
7293
  if (q === "option")
7294
- Q(A, q), T(";");
7294
+ Q(b, q), T(";");
7295
7295
  else
7296
7296
  throw N(q);
7297
7297
  }, function() {
7298
- se(A);
7299
- }), O.add(g, R, A.comment, A.parsedOptions || A.options);
7298
+ se(b);
7299
+ }), R.add(g, O, b.comment, b.parsedOptions || b.options);
7300
7300
  }
7301
- function Q(O, g) {
7302
- var R, A, w = !0;
7301
+ function Q(R, g) {
7302
+ var O, b, w = !0;
7303
7303
  for (g === "option" && (g = S()); g !== "="; ) {
7304
7304
  if (g === "(") {
7305
7305
  var q = S();
@@ -7308,110 +7308,110 @@ function requireParse() {
7308
7308
  if (w) {
7309
7309
  if (w = !1, g.includes(".") && !g.includes("(")) {
7310
7310
  var x = g.split(".");
7311
- R = x[0] + ".", g = x[1];
7311
+ O = x[0] + ".", g = x[1];
7312
7312
  continue;
7313
7313
  }
7314
- R = g;
7314
+ O = g;
7315
7315
  } else
7316
- A = A ? A += g : g;
7316
+ b = b ? b += g : g;
7317
7317
  g = S();
7318
7318
  }
7319
- var G = A ? R.concat(A) : R, M = ce(O, G);
7320
- A = A && A[0] === "." ? A.slice(1) : A, R = R && R[R.length - 1] === "." ? R.slice(0, -1) : R, be(O, R, M, A);
7319
+ var G = b ? O.concat(b) : O, U = ce(R, G);
7320
+ b = b && b[0] === "." ? b.slice(1) : b, O = O && O[O.length - 1] === "." ? O.slice(0, -1) : O, Ae(R, O, U, b);
7321
7321
  }
7322
- function ce(O, g) {
7322
+ function ce(R, g) {
7323
7323
  if (T("{", !0)) {
7324
- for (var R = {}; !T("}", !0); ) {
7324
+ for (var O = {}; !T("}", !0); ) {
7325
7325
  if (!_.test(V = S()))
7326
7326
  throw N(V, "name");
7327
7327
  if (V === null)
7328
7328
  throw N(V, "end of input");
7329
- var A, w = V;
7330
- if (T(":", !0), U() === "{")
7331
- A = ce(O, g + "." + V);
7332
- else if (U() === "[") {
7333
- A = [];
7329
+ var b, w = V;
7330
+ if (T(":", !0), M() === "{")
7331
+ b = ce(R, g + "." + V);
7332
+ else if (M() === "[") {
7333
+ b = [];
7334
7334
  var q;
7335
7335
  if (T("[", !0)) {
7336
7336
  do
7337
- q = ue(), A.push(q);
7337
+ q = ue(), b.push(q);
7338
7338
  while (T(",", !0));
7339
- T("]"), typeof q < "u" && fe(O, g + "." + V, q);
7339
+ T("]"), typeof q < "u" && fe(R, g + "." + V, q);
7340
7340
  }
7341
7341
  } else
7342
- A = ue(), fe(O, g + "." + V, A);
7343
- var x = R[w];
7344
- x && (A = [].concat(x).concat(A)), R[w] = A, T(",", !0), T(";", !0);
7342
+ b = ue(), fe(R, g + "." + V, b);
7343
+ var x = O[w];
7344
+ x && (b = [].concat(x).concat(b)), O[w] = b, T(",", !0), T(";", !0);
7345
7345
  }
7346
- return R;
7346
+ return O;
7347
7347
  }
7348
7348
  var G = ue();
7349
- return fe(O, g, G), G;
7349
+ return fe(R, g, G), G;
7350
7350
  }
7351
- function fe(O, g, R) {
7352
- if ($ === O && /^features\\./.test(g)) {
7353
- z[g] = R;
7351
+ function fe(R, g, O) {
7352
+ if ($ === R && /^features\\./.test(g)) {
7353
+ z[g] = O;
7354
7354
  return;
7355
7355
  }
7356
- O.setOption && O.setOption(g, R);
7356
+ R.setOption && R.setOption(g, O);
7357
7357
  }
7358
- function be(O, g, R, A) {
7359
- O.setParsedOption && O.setParsedOption(g, R, A);
7358
+ function Ae(R, g, O, b) {
7359
+ R.setParsedOption && R.setParsedOption(g, O, b);
7360
7360
  }
7361
- function se(O) {
7361
+ function se(R) {
7362
7362
  if (T("[", !0)) {
7363
7363
  do
7364
- Q(O, "option");
7364
+ Q(R, "option");
7365
7365
  while (T(",", !0));
7366
7366
  T("]");
7367
7367
  }
7368
- return O;
7368
+ return R;
7369
7369
  }
7370
- function Ae(O, g) {
7370
+ function be(R, g) {
7371
7371
  if (!_.test(g = S()))
7372
7372
  throw N(g, "service name");
7373
- var R = new r(g);
7374
- Z(R, function(w) {
7375
- if (!ie(R, w))
7373
+ var O = new r(g);
7374
+ Z(O, function(w) {
7375
+ if (!ie(O, w))
7376
7376
  if (w === "rpc")
7377
- we(R, w);
7377
+ we(O, w);
7378
7378
  else
7379
7379
  throw N(w);
7380
- }), O.add(R), O === $ && X.push(R);
7380
+ }), R.add(O), R === $ && X.push(O);
7381
7381
  }
7382
- function we(O, g) {
7383
- var R = k(), A = g;
7382
+ function we(R, g) {
7383
+ var O = k(), b = g;
7384
7384
  if (!_.test(g = S()))
7385
7385
  throw N(g, "name");
7386
- var w = g, q, x, G, M;
7387
- if (T("("), T("stream", !0) && (x = !0), !b.test(g = S()) || (q = g, T(")"), T("returns"), T("("), T("stream", !0) && (M = !0), !b.test(g = S())))
7386
+ var w = g, q, x, G, U;
7387
+ if (T("("), T("stream", !0) && (x = !0), !A.test(g = S()) || (q = g, T(")"), T("returns"), T("("), T("stream", !0) && (U = !0), !A.test(g = S())))
7388
7388
  throw N(g);
7389
7389
  G = g, T(")");
7390
- var oe = new i(w, A, q, G, x, M);
7391
- oe.comment = R, Z(oe, function(le) {
7390
+ var oe = new i(w, b, q, G, x, U);
7391
+ oe.comment = O, Z(oe, function(le) {
7392
7392
  if (le === "option")
7393
7393
  Q(oe, le), T(";");
7394
7394
  else
7395
7395
  throw N(le);
7396
- }), O.add(oe);
7396
+ }), R.add(oe);
7397
7397
  }
7398
- function Se(O, g) {
7399
- if (!b.test(g = S()))
7398
+ function Se(R, g) {
7399
+ if (!A.test(g = S()))
7400
7400
  throw N(g, "reference");
7401
- var R = g;
7401
+ var O = g;
7402
7402
  Z(null, function(w) {
7403
7403
  switch (w) {
7404
7404
  case "required":
7405
7405
  case "repeated":
7406
- Y(O, w, R);
7406
+ Y(R, w, O);
7407
7407
  break;
7408
7408
  case "optional":
7409
- B === "proto3" ? Y(O, "proto3_optional", R) : Y(O, "optional", R);
7409
+ D === "proto3" ? Y(R, "proto3_optional", O) : Y(R, "optional", O);
7410
7410
  break;
7411
7411
  default:
7412
- if (B === "proto2" || !b.test(w))
7412
+ if (D === "proto2" || !A.test(w))
7413
7413
  throw N(w);
7414
- J(w), Y(O, "optional", R);
7414
+ J(w), Y(R, "optional", O);
7415
7415
  break;
7416
7416
  }
7417
7417
  });
@@ -7419,22 +7419,22 @@ function requireParse() {
7419
7419
  for (var V; (V = S()) !== null; )
7420
7420
  switch (V) {
7421
7421
  case "package":
7422
- if (!L)
7422
+ if (!P)
7423
7423
  throw N(V);
7424
7424
  ye();
7425
7425
  break;
7426
7426
  case "import":
7427
- if (!L)
7427
+ if (!P)
7428
7428
  throw N(V);
7429
7429
  me();
7430
7430
  break;
7431
7431
  case "syntax":
7432
- if (!L)
7432
+ if (!P)
7433
7433
  throw N(V);
7434
7434
  ve();
7435
7435
  break;
7436
7436
  case "edition":
7437
- if (!L)
7437
+ if (!P)
7438
7438
  throw N(V);
7439
7439
  ge();
7440
7440
  break;
@@ -7443,7 +7443,7 @@ function requireParse() {
7443
7443
  break;
7444
7444
  default:
7445
7445
  if (ie($, V)) {
7446
- L = !1;
7446
+ P = !1;
7447
7447
  continue;
7448
7448
  }
7449
7449
  throw N(V);
@@ -7787,8 +7787,8 @@ var protobufjs, hasRequiredProtobufjs;
7787
7787
  function requireProtobufjs() {
7788
7788
  return hasRequiredProtobufjs || (hasRequiredProtobufjs = 1, protobufjs = requireSrc()), protobufjs;
7789
7789
  }
7790
- var protobufjsExports = requireProtobufjs(), StateStreamErrorCode = /* @__PURE__ */ ((u) => (u.CONNECTION_FAILED = "CONNECTION_FAILED", u.RECONNECT_FAILED = "RECONNECT_FAILED", u.CONNECTION_LOST = "CONNECTION_LOST", u.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", u.AUTH_FAILED = "AUTH_FAILED", u.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", u.DEVICE_ERROR = "DEVICE_ERROR", u.DECODE_ERROR = "DECODE_ERROR", u.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", u.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", u.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", u.UNKNOWN_ERROR = "UNKNOWN_ERROR", u))(StateStreamErrorCode || {}), ConnectionStatus = /* @__PURE__ */ ((u) => (u.DISCONNECTED = "DISCONNECTED", u.CONNECTING = "CONNECTING", u.CONNECTED = "CONNECTED", u.RECONNECTING = "RECONNECTING", u))(ConnectionStatus || {}), AuthStatus = /* @__PURE__ */ ((u) => (u.UNAUTHENTICATED = "UNAUTHENTICATED", u.AUTHENTICATING = "AUTHENTICATING", u.AUTHENTICATED = "AUTHENTICATED", u.FAILED = "FAILED", u))(AuthStatus || {});
7791
- const nested = { BSB_State: { nested: { StateUpdate: { oneofs: { state: { oneof: ["deviceName", "power", "brightness", "audioVolume", "wifi", "updateState", "updateCheck", "timezone", "matter", "frame", "input", "timer", "ble", "autoUpdateState"] } }, fields: { deviceName: { type: "BSB_State.DeviceName", id: 1 }, power: { type: "BSB_State.Power", id: 2 }, brightness: { type: "BSB_State.Brightness", id: 3 }, audioVolume: { type: "BSB_State.AudioVolume", id: 4 }, wifi: { type: "BSB_State.Wifi", id: 5 }, updateState: { type: "BSB_Update.UpdateState", id: 6 }, updateCheck: { type: "BSB_Update.CheckState", id: 7 }, timezone: { type: "BSB_State.Timezone", id: 8 }, matter: { type: "BSB_State.Matter", id: 9 }, frame: { type: "BSB_Frame.Frame", id: 10 }, input: { type: "BSB_Input.InputEvent", id: 11 }, timer: { type: "BSB_Timer.Timer", id: 12 }, ble: { type: "BSB_State.Ble.Ble", id: 13 }, autoUpdateState: { type: "BSB_Update.AutoUpdateState", id: 14 } } }, State: { oneofs: { _error: { oneof: ["error"] } }, fields: { timestamp: { type: "fixed64", id: 1 }, updates: { rule: "repeated", type: "StateUpdate", id: 2 }, error: { type: "BSB_Error.Error", id: 3, options: { proto3_optional: !0 } } } }, DeviceName: { fields: { name: { type: "string", id: 1 } } }, BrightnessAutomatic: { fields: {} }, BrightnessManual: { fields: { brightness: { type: "uint32", id: 1 } } }, Brightness: { oneofs: { setting: { oneof: ["automatic", "manual"] } }, fields: { automatic: { type: "BrightnessAutomatic", id: 1 }, manual: { type: "BrightnessManual", id: 2 }, actualBrightness: { type: "uint32", id: 3 } } }, BatteryStatus: { values: { DISCHARGING: 0, CHARGING: 1, CHARGED: 2 } }, UnknownPowerState: { fields: {} }, PowerState: { fields: { batteryStatus: { type: "BatteryStatus", id: 1 }, batteryChargePercent: { type: "uint32", id: 2 }, batteryVoltageMv: { type: "uint32", id: 3 }, batteryCurrentMa: { type: "sint32", id: 4 }, usbVoltageMv: { type: "uint32", id: 5 } } }, Power: { oneofs: { state: { oneof: ["unknown", "known"] } }, fields: { unknown: { type: "UnknownPowerState", id: 1 }, known: { type: "PowerState", id: 2 } } }, AudioVolume: { fields: { volume: { type: "uint32", id: 1 } } }, WifiConnectionStatus: { values: { CONNECTED: 0, CONNECTING: 1, DISCONNECTING: 2, RECONNECTING: 3 } }, WifiSecurity: { values: { UNKNOWN: 0, OPEN: 1, WPA: 2, WPA2: 3, WEP: 4, WPA_WPA2: 5, WPA3: 6, WPA2_WPA3: 7 } }, IpConfigurationMethod: { values: { DHCP: 0, STATIC: 1 } }, IpProtocol: { values: { IPV4: 0, IPV6: 1 } }, WifiStateUnknown: { fields: {} }, WifiStateDisconnected: { fields: {} }, WifiStateConnected: { fields: { status: { type: "WifiConnectionStatus", id: 1 }, ssid: { type: "string", id: 2 }, bssid: { type: "string", id: 3 }, channel: { type: "uint32", id: 4 }, rssi: { type: "sint32", id: 5 }, security: { type: "WifiSecurity", id: 6 } } }, IpAddress: { fields: { protocol: { type: "IpProtocol", id: 1 }, method: { type: "IpConfigurationMethod", id: 2 }, address: { type: "string", id: 3 }, gateway: { type: "string", id: 4 }, netmask: { type: "string", id: 5 } } }, Wifi: { oneofs: { wifiState: { oneof: ["unknown", "disconnected", "connected"] } }, fields: { unknown: { type: "WifiStateUnknown", id: 1 }, disconnected: { type: "WifiStateDisconnected", id: 2 }, connected: { type: "WifiStateConnected", id: 3 }, ipAddresses: { rule: "repeated", type: "IpAddress", id: 4 } } }, Timezone: { fields: { name: { type: "string", id: 1 }, offset: { type: "sint32", id: 2 }, abbr: { type: "string", id: 3 } } }, MatterCommissioningStatus: { values: { NEVER_STARTED: 0, STARTED: 1, COMPLETED_SUCCESSFULLY: 2, FAILED: 3 } }, MatterCommissioningState: { fields: { status: { type: "MatterCommissioningStatus", id: 1 }, timestamp: { type: "fixed64", id: 2 } } }, Matter: { fields: { fabricCount: { type: "uint32", id: 1 }, state: { type: "MatterCommissioningState", id: 2 } } }, Ble: { nested: { ServiceStatus: { values: { RESET: 0, INITIALIZATION: 1, READY: 2, ADVERTISING: 3, CONNECTABLE: 4, CONNECTED: 5, ERROR: 6 } }, Ble: { oneofs: { _remoteAddress: { oneof: ["remoteAddress"] } }, fields: { status: { type: "ServiceStatus", id: 1 }, remoteAddress: { type: "string", id: 2, options: { proto3_optional: !0 } } } } } } } }, BSB_Update: { nested: { UpdateEvent: { values: { SESSION_START: 0, SESSION_STOP: 1, ACTION_BEGIN: 2, ACTION_DONE: 3, DETAIL_CHANGE: 4, ACTION_PROGRESS: 5, EVENT_NONE: 6 } }, UpdateAction: { values: { DOWNLOAD: 0, SHA_VERIFICATION: 1, UNPACK: 2, INSTALLATION_PREPARE: 3, INSTALLATION_APPLY: 4, ACTION_NONE: 5 } }, UpdateStatus: { values: { OK: 0, BATTERY_LOW: 1, BUSY: 2, DOWNLOAD_FAILURE: 3, DOWNLOAD_ABORT: 4, SHA_MISMATCH: 5, UNPACK_CREATE_STAGING_DIRECTORY_FAILURE: 6, UNPACK_ARCHIVE_OPEN_FAILURE: 7, UNPACK_ARCHIVE_UNPACK_FAILURE: 8, INSTALLATION_PREPARE_MANIFEST_NOT_FOUND: 9, INSTALLATION_PREPARE_MANIFEST_INVALID: 10, INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE: 11, INSTALLATION_PREPARE_POINTER_SETUP_FAILURE: 12, UNKNOWN_FAILURE: 13 } }, CheckError: { values: { NOT_AVAILABLE: 0, FAILURE: 1, IDLE: 2 } }, UpdateAvailable: { fields: { version: { type: "string", id: 1 } } }, UpdateUnavailable: { fields: { reason: { type: "CheckError", id: 1 } } }, UpdateState: { fields: { event: { type: "UpdateEvent", id: 1 }, action: { type: "UpdateAction", id: 2 }, status: { type: "UpdateStatus", id: 3 } } }, CheckState: { oneofs: { status: { oneof: ["available", "unavailable"] } }, fields: { available: { type: "UpdateAvailable", id: 1 }, unavailable: { type: "UpdateUnavailable", id: 2 } } }, AutoUpdateInterval: { fields: { start: { type: "uint32", id: 1 }, end: { type: "uint32", id: 2 } } }, AutoUpdateState: { fields: { enabled: { type: "bool", id: 1 }, interval: { type: "AutoUpdateInterval", id: 2 } } } } }, BSB_Frame: { nested: { Encoding: { values: { PLAIN: 0, RUN_LENGTH: 1, DEFLATE: 2, DEFLATE_RUN_LENGTH: 3 } }, PixelFormat: { values: { RGB888: 0, L8: 1, L4: 2 } }, Screen: { values: { FRONT: 0, BACK: 1 } }, Frame: { fields: { screen: { type: "Screen", id: 1 }, width: { type: "uint32", id: 2 }, height: { type: "uint32", id: 3 }, encoding: { type: "Encoding", id: 4 }, pixelFormat: { type: "PixelFormat", id: 5 }, data: { type: "bytes", id: 6 } } } } }, BSB_Timer: { nested: { Timer: { fields: { json: { type: "BSB_Util.Json", id: 1 } } } } }, BSB_Util: { nested: { Compression: { values: { PLAIN: 0, GZIP: 1 } }, Json: { fields: { compression: { type: "Compression", id: 1 }, data: { type: "bytes", id: 2 } } } } }, BSB_Input: { nested: { Button: { values: { OK: 0, BACK: 1, START: 2 } }, ButtonAction: { values: { PRESS: 0, RELEASE: 1 } }, SwitchPosition: { values: { BUSY: 0, CUSTOM: 1, OFF: 2, APPS: 3, SETTINGS: 4 } }, ButtonEvent: { fields: { button: { type: "Button", id: 1 }, action: { type: "ButtonAction", id: 2 } } }, SwitchEvent: { fields: { position: { type: "SwitchPosition", id: 1 } } }, EncoderEvent: { fields: { delta: { type: "sint32", id: 1 } } }, InputEvent: { oneofs: { event: { oneof: ["buttonEvent", "switchEvent", "encoderEvent"] } }, fields: { buttonEvent: { type: "ButtonEvent", id: 1 }, switchEvent: { type: "SwitchEvent", id: 2 }, encoderEvent: { type: "EncoderEvent", id: 3 } } } } }, BSB_Error: { nested: { Cause: { values: { RESOURCE_LIMIT: 0 } }, Severity: { values: { FATAL: 0, ERROR: 1, WARNING: 2 } }, Error: { fields: { cause: { type: "Cause", id: 1 }, severity: { type: "Severity", id: 2 } } } } } };
7790
+ var protobufjsExports = requireProtobufjs(), StateStreamErrorCode = /* @__PURE__ */ ((u) => (u.CONNECTION_FAILED = "CONNECTION_FAILED", u.RECONNECT_FAILED = "RECONNECT_FAILED", u.CONNECTION_LOST = "CONNECTION_LOST", u.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", u.AUTH_FAILED = "AUTH_FAILED", u.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", u.DEVICE_ERROR = "DEVICE_ERROR", u.DECODE_ERROR = "DECODE_ERROR", u.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", u.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", u.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", u.UNKNOWN_ERROR = "UNKNOWN_ERROR", u))(StateStreamErrorCode || {}), ConnectionStatus = /* @__PURE__ */ ((u) => (u.DISCONNECTED = "DISCONNECTED", u.CONNECTING = "CONNECTING", u.CONNECTED = "CONNECTED", u.RECONNECTING = "RECONNECTING", u))(ConnectionStatus || {}), AuthStatus = /* @__PURE__ */ ((u) => (u.UNAUTHENTICATED = "UNAUTHENTICATED", u.AUTHENTICATING = "AUTHENTICATING", u.AUTHENTICATED = "AUTHENTICATED", u.REAUTHENTICATING = "REAUTHENTICATING", u.FAILED = "FAILED", u))(AuthStatus || {});
7791
+ const DEFAULT_MAX_RECONNECT_ATTEMPTS = 5, DEFAULT_MAX_AUTH_ATTEMPTS = 5, nested = { BSB_State: { nested: { StateUpdate: { oneofs: { state: { oneof: ["deviceName", "power", "brightness", "audioVolume", "wifi", "updateState", "updateCheck", "timezone", "matter", "frame", "input", "timer", "ble", "autoUpdateState"] } }, fields: { deviceName: { type: "BSB_State.DeviceName", id: 1 }, power: { type: "BSB_State.Power", id: 2 }, brightness: { type: "BSB_State.Brightness", id: 3 }, audioVolume: { type: "BSB_State.AudioVolume", id: 4 }, wifi: { type: "BSB_State.Wifi", id: 5 }, updateState: { type: "BSB_Update.UpdateState", id: 6 }, updateCheck: { type: "BSB_Update.CheckState", id: 7 }, timezone: { type: "BSB_State.Timezone", id: 8 }, matter: { type: "BSB_State.Matter", id: 9 }, frame: { type: "BSB_Frame.Frame", id: 10 }, input: { type: "BSB_Input.InputEvent", id: 11 }, timer: { type: "BSB_Timer.Timer", id: 12 }, ble: { type: "BSB_State.Ble.Ble", id: 13 }, autoUpdateState: { type: "BSB_Update.AutoUpdateState", id: 14 } } }, State: { oneofs: { _error: { oneof: ["error"] } }, fields: { timestamp: { type: "fixed64", id: 1 }, updates: { rule: "repeated", type: "StateUpdate", id: 2 }, error: { type: "BSB_Error.Error", id: 3, options: { proto3_optional: !0 } } } }, DeviceName: { fields: { name: { type: "string", id: 1 } } }, BrightnessAutomatic: { fields: {} }, BrightnessManual: { fields: { brightness: { type: "uint32", id: 1 } } }, Brightness: { oneofs: { setting: { oneof: ["automatic", "manual"] } }, fields: { automatic: { type: "BrightnessAutomatic", id: 1 }, manual: { type: "BrightnessManual", id: 2 }, actualBrightness: { type: "uint32", id: 3 } } }, BatteryStatus: { values: { DISCHARGING: 0, CHARGING: 1, CHARGED: 2 } }, UnknownPowerState: { fields: {} }, PowerState: { fields: { batteryStatus: { type: "BatteryStatus", id: 1 }, batteryChargePercent: { type: "uint32", id: 2 }, batteryVoltageMv: { type: "uint32", id: 3 }, batteryCurrentMa: { type: "sint32", id: 4 }, usbVoltageMv: { type: "uint32", id: 5 } } }, Power: { oneofs: { state: { oneof: ["unknown", "known"] } }, fields: { unknown: { type: "UnknownPowerState", id: 1 }, known: { type: "PowerState", id: 2 } } }, AudioVolume: { fields: { volume: { type: "uint32", id: 1 } } }, WifiConnectionStatus: { values: { CONNECTED: 0, CONNECTING: 1, DISCONNECTING: 2, RECONNECTING: 3 } }, WifiSecurity: { values: { UNKNOWN: 0, OPEN: 1, WPA: 2, WPA2: 3, WEP: 4, WPA_WPA2: 5, WPA3: 6, WPA2_WPA3: 7 } }, IpConfigurationMethod: { values: { DHCP: 0, STATIC: 1 } }, IpProtocol: { values: { IPV4: 0, IPV6: 1 } }, WifiStateUnknown: { fields: {} }, WifiStateDisconnected: { fields: {} }, WifiStateConnected: { fields: { status: { type: "WifiConnectionStatus", id: 1 }, ssid: { type: "string", id: 2 }, bssid: { type: "string", id: 3 }, channel: { type: "uint32", id: 4 }, rssi: { type: "sint32", id: 5 }, security: { type: "WifiSecurity", id: 6 } } }, IpAddress: { fields: { protocol: { type: "IpProtocol", id: 1 }, method: { type: "IpConfigurationMethod", id: 2 }, address: { type: "string", id: 3 }, gateway: { type: "string", id: 4 }, netmask: { type: "string", id: 5 } } }, Wifi: { oneofs: { wifiState: { oneof: ["unknown", "disconnected", "connected"] } }, fields: { unknown: { type: "WifiStateUnknown", id: 1 }, disconnected: { type: "WifiStateDisconnected", id: 2 }, connected: { type: "WifiStateConnected", id: 3 }, ipAddresses: { rule: "repeated", type: "IpAddress", id: 4 } } }, Timezone: { fields: { name: { type: "string", id: 1 }, offset: { type: "sint32", id: 2 }, abbr: { type: "string", id: 3 } } }, MatterCommissioningStatus: { values: { NEVER_STARTED: 0, STARTED: 1, COMPLETED_SUCCESSFULLY: 2, FAILED: 3 } }, MatterCommissioningState: { fields: { status: { type: "MatterCommissioningStatus", id: 1 }, timestamp: { type: "fixed64", id: 2 } } }, Matter: { fields: { fabricCount: { type: "uint32", id: 1 }, state: { type: "MatterCommissioningState", id: 2 } } }, Ble: { nested: { ServiceStatus: { values: { RESET: 0, INITIALIZATION: 1, READY: 2, ADVERTISING: 3, CONNECTABLE: 4, CONNECTED: 5, ERROR: 6 } }, Ble: { oneofs: { _remoteAddress: { oneof: ["remoteAddress"] } }, fields: { status: { type: "ServiceStatus", id: 1 }, remoteAddress: { type: "string", id: 2, options: { proto3_optional: !0 } } } } } } } }, BSB_Update: { nested: { UpdateEvent: { values: { SESSION_START: 0, SESSION_STOP: 1, ACTION_BEGIN: 2, ACTION_DONE: 3, DETAIL_CHANGE: 4, ACTION_PROGRESS: 5, EVENT_NONE: 6 } }, UpdateAction: { values: { DOWNLOAD: 0, SHA_VERIFICATION: 1, UNPACK: 2, INSTALLATION_PREPARE: 3, INSTALLATION_APPLY: 4, ACTION_NONE: 5 } }, UpdateStatus: { values: { OK: 0, BATTERY_LOW: 1, BUSY: 2, DOWNLOAD_FAILURE: 3, DOWNLOAD_ABORT: 4, SHA_MISMATCH: 5, UNPACK_CREATE_STAGING_DIRECTORY_FAILURE: 6, UNPACK_ARCHIVE_OPEN_FAILURE: 7, UNPACK_ARCHIVE_UNPACK_FAILURE: 8, INSTALLATION_PREPARE_MANIFEST_NOT_FOUND: 9, INSTALLATION_PREPARE_MANIFEST_INVALID: 10, INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE: 11, INSTALLATION_PREPARE_POINTER_SETUP_FAILURE: 12, UNKNOWN_FAILURE: 13 } }, CheckError: { values: { NOT_AVAILABLE: 0, FAILURE: 1, IDLE: 2 } }, UpdateAvailable: { fields: { version: { type: "string", id: 1 } } }, UpdateUnavailable: { fields: { reason: { type: "CheckError", id: 1 } } }, UpdateState: { fields: { event: { type: "UpdateEvent", id: 1 }, action: { type: "UpdateAction", id: 2 }, status: { type: "UpdateStatus", id: 3 } } }, CheckState: { oneofs: { status: { oneof: ["available", "unavailable"] } }, fields: { available: { type: "UpdateAvailable", id: 1 }, unavailable: { type: "UpdateUnavailable", id: 2 } } }, AutoUpdateInterval: { fields: { start: { type: "uint32", id: 1 }, end: { type: "uint32", id: 2 } } }, AutoUpdateState: { fields: { enabled: { type: "bool", id: 1 }, interval: { type: "AutoUpdateInterval", id: 2 } } } } }, BSB_Frame: { nested: { Encoding: { values: { PLAIN: 0, RUN_LENGTH: 1, DEFLATE: 2, DEFLATE_RUN_LENGTH: 3 } }, PixelFormat: { values: { RGB888: 0, L8: 1, L4: 2 } }, Screen: { values: { FRONT: 0, BACK: 1 } }, Frame: { fields: { screen: { type: "Screen", id: 1 }, width: { type: "uint32", id: 2 }, height: { type: "uint32", id: 3 }, encoding: { type: "Encoding", id: 4 }, pixelFormat: { type: "PixelFormat", id: 5 }, data: { type: "bytes", id: 6 } } } } }, BSB_Timer: { nested: { Timer: { fields: { json: { type: "BSB_Util.Json", id: 1 } } } } }, BSB_Util: { nested: { Compression: { values: { PLAIN: 0, GZIP: 1 } }, Json: { fields: { compression: { type: "Compression", id: 1 }, data: { type: "bytes", id: 2 } } } } }, BSB_Input: { nested: { Button: { values: { OK: 0, BACK: 1, START: 2 } }, ButtonAction: { values: { PRESS: 0, RELEASE: 1 } }, SwitchPosition: { values: { BUSY: 0, CUSTOM: 1, OFF: 2, APPS: 3, SETTINGS: 4 } }, ButtonEvent: { fields: { button: { type: "Button", id: 1 }, action: { type: "ButtonAction", id: 2 } } }, SwitchEvent: { fields: { position: { type: "SwitchPosition", id: 1 } } }, EncoderEvent: { fields: { delta: { type: "sint32", id: 1 } } }, InputEvent: { oneofs: { event: { oneof: ["buttonEvent", "switchEvent", "encoderEvent"] } }, fields: { buttonEvent: { type: "ButtonEvent", id: 1 }, switchEvent: { type: "SwitchEvent", id: 2 }, encoderEvent: { type: "EncoderEvent", id: 3 } } } } }, BSB_Error: { nested: { Cause: { values: { RESOURCE_LIMIT: 0 } }, Severity: { values: { FATAL: 0, ERROR: 1, WARNING: 2 } }, Error: { fields: { cause: { type: "Cause", id: 1 }, severity: { type: "Severity", id: 2 } } } } } };
7792
7792
  var bundle = {
7793
7793
  nested
7794
7794
  };
@@ -7883,8 +7883,8 @@ async function processFrame(u) {
7883
7883
  return new Uint8ClampedArray(u.width * u.height * 4);
7884
7884
  }
7885
7885
  }
7886
- const root = protobufjsExports.Root.fromJSON(bundle), StateType = root.lookupType("BSB_State.State"), AUTH_CODE = 3e3, RECONNECT_CODES = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]), MAX_AUTH_ATTEMPTS = 5, MAX_RECONNECT_ATTEMPTS = 5;
7887
- let socket = null, isBinaryMode = !0, currentMode = "local", currentToken, currentAddr = "", retryCount = 0, authRetryCount = 0, isAuthReported = !1, stabilityTimeout;
7886
+ const root = protobufjsExports.Root.fromJSON(bundle), StateType = root.lookupType("BSB_State.State"), AUTH_CODE = 3e3, RECONNECT_CODES = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
7887
+ let maxAuthAttempts = DEFAULT_MAX_AUTH_ATTEMPTS, maxReconnectAttempts = DEFAULT_MAX_RECONNECT_ATTEMPTS, socket = null, isBinaryMode = !0, currentMode = "local", currentToken, currentAddr = "", retryCount = 0, authRetryCount = 0, isAuthReported = !1, stabilityTimeout;
7888
7888
  const activePorts = /* @__PURE__ */ new Set(), subscriptions = /* @__PURE__ */ new Map();
7889
7889
  let processingQueue = Promise.resolve();
7890
7890
  function broadcast(u) {
@@ -7989,25 +7989,25 @@ function connect(u, f, h = !0, c = "local") {
7989
7989
  return;
7990
7990
  }
7991
7991
  if (n.code === AUTH_CODE && currentMode === "remote") {
7992
- authRetryCount < MAX_AUTH_ATTEMPTS ? (authRetryCount++, console.warn(\`[Worker] Auth failed (3000). Requesting new token... (Attempt \${authRetryCount}/\${MAX_AUTH_ATTEMPTS})\`), broadcast({ type: "TOKEN_EXPIRED" })) : (broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.FAILED }), broadcast({
7992
+ authRetryCount < maxAuthAttempts ? (authRetryCount++, console.warn(\`[Worker] Auth failed (3000). Requesting new token... (Attempt \${authRetryCount}/\${maxAuthAttempts})\`), broadcast({ type: "TOKEN_EXPIRED" }), broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.REAUTHENTICATING, authAttempts: authRetryCount })) : (broadcast({ type: "STATUS_UPDATE", auth: AuthStatus.FAILED }), broadcast({
7993
7993
  type: "ERROR",
7994
7994
  code: StateStreamErrorCode.AUTH_FAILED,
7995
- message: \`Maximum authentication attempts (\${MAX_AUTH_ATTEMPTS}) reached. Please log in again.\`
7995
+ message: \`Maximum authentication attempts (\${maxAuthAttempts}) reached. Please log in again.\`
7996
7996
  }));
7997
7997
  return;
7998
7998
  }
7999
- if (currentMode === "remote" && RECONNECT_CODES.has(n.code)) {
8000
- if (retryCount < MAX_RECONNECT_ATTEMPTS) {
7999
+ if (RECONNECT_CODES.has(n.code)) {
8000
+ if (retryCount < maxReconnectAttempts) {
8001
8001
  retryCount++;
8002
8002
  const e = Math.min(1e3 * retryCount, 5e3);
8003
- console.log(\`[Worker] Reconnecting (network code: \${n.code}) in \${e}ms... (Attempt \${retryCount}/\${MAX_RECONNECT_ATTEMPTS})\`), broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.RECONNECTING }), setTimeout(() => {
8003
+ console.log(\`[Worker] Reconnecting (network code: \${n.code}) in \${e}ms... (Attempt \${retryCount}/\${maxReconnectAttempts})\`), broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.RECONNECTING, connectionAttempts: retryCount }), setTimeout(() => {
8004
8004
  activePorts.size > 0 && socket && connect(currentAddr, currentToken, isBinaryMode, currentMode);
8005
8005
  }, e);
8006
8006
  } else
8007
8007
  broadcast({ type: "STATUS_UPDATE", connection: ConnectionStatus.DISCONNECTED }), broadcast({
8008
8008
  type: "ERROR",
8009
8009
  code: StateStreamErrorCode.RECONNECT_FAILED,
8010
- message: \`Maximum reconnection attempts (\${MAX_RECONNECT_ATTEMPTS}) reached. Connection lost.\`
8010
+ message: \`Maximum reconnection attempts (\${maxReconnectAttempts}) reached. Connection lost.\`
8011
8011
  });
8012
8012
  return;
8013
8013
  }
@@ -8021,7 +8021,7 @@ function connect(u, f, h = !0, c = "local") {
8021
8021
  function handleCommand(u, f) {
8022
8022
  switch (u.type) {
8023
8023
  case "START":
8024
- activePorts.add(f), socket && socket.readyState === WebSocket.OPEN && currentAddr === u.addr ? (f.postMessage({ type: "CONNECTED" }), f.postMessage({ type: "STATUS_UPDATE", auth: AuthStatus.AUTHENTICATED })) : connect(u.addr, u.token, u.isBinary, u.mode);
8024
+ maxAuthAttempts = u.maxAuthAttempts ?? DEFAULT_MAX_AUTH_ATTEMPTS, maxReconnectAttempts = u.maxReconnectAttempts ?? DEFAULT_MAX_RECONNECT_ATTEMPTS, activePorts.add(f), socket && socket.readyState === WebSocket.OPEN && currentAddr === u.addr ? (f.postMessage({ type: "CONNECTED" }), f.postMessage({ type: "STATUS_UPDATE", auth: AuthStatus.AUTHENTICATED })) : connect(u.addr, u.token, u.isBinary, u.mode);
8025
8025
  break;
8026
8026
  case "STOP":
8027
8027
  activePorts.delete(f);
@@ -8062,7 +8062,7 @@ if ("SharedWorkerGlobalScope" in self) {
8062
8062
  handleCommand(f.data, u);
8063
8063
  };
8064
8064
  }
8065
- `;function pe(e){return new SharedWorker("data:text/javascript;charset=utf-8,"+encodeURIComponent(de),{type:"module",name:e==null?void 0:e.name})}const E=class E{constructor(n,t){l(this,"addr");l(this,"token");l(this,"isBinary");l(this,"connectTimeout");l(this,"dataTimeout");l(this,"worker",null);l(this,"connectionTimer",null);l(this,"dataTimer",null);l(this,"_status");l(this,"dataCallback");l(this,"rawDataCallback");l(this,"errorCallback");l(this,"statusCallback");this.addr=n.addr||"",this.token=n.token,this.isBinary=n.isBinary??!0,this.connectTimeout=(t==null?void 0:t.timeout)??5e3,this.dataTimeout=(t==null?void 0:t.dataTimeout)??15e3,this._status={main:{status:d.IDLE},connection:{status:m.DISCONNECTED},auth:{status:v.UNAUTHENTICATED},data:{status:g.NONE},worker:{status:b.OFF}}}get status(){return this._status}resolveProtocol(n){let t=n.trim();if(t.startsWith("https://"))return t.replace("https://","wss://");if(t.startsWith("http://"))return t.replace("http://","ws://");if(t.startsWith("wss://")||t.startsWith("ws://"))return t;let r="ws:";return typeof window<"u"&&window.location.protocol==="https:"&&(r="wss:"),`${r}//${t}`}start({dataCallback:n,rawDataCallback:t,errorCallback:r,statusCallback:i}){if(this._status.main.status===d.STARTING||this._status.main.status===d.RUNNING){const o=new h(c.STREAM_ALREADY_STARTED,"StateStream is already running. Call stop() before starting again.");if(i&&i({...this._status,main:{...this._status.main,lastError:o}}),r)r(o);else throw o;return}this.dataCallback=n,this.rawDataCallback=t,this.errorCallback=r,this.statusCallback=i,this.updateStatusComponent("main",{status:d.STARTING,lastError:void 0});try{this.ensureWorker(),this.sendCommand({type:"START",addr:this.normalizeUrl(this.addr),token:this.token,isBinary:this.isBinary,mode:this.streamMode}),this.clearConnectionTimer(),this.connectionTimer=setTimeout(()=>{const o=new h(c.CONNECTION_TIMEOUT,`Connection timed out after ${this.connectTimeout}ms`);this.mapErrorToStatus(o),this.errorCallback&&this.errorCallback(o),this.stop()},this.connectTimeout)}catch(o){const s=o instanceof h?o:new h(c.UNKNOWN_ERROR,String(o));this.errorCallback&&this.errorCallback(s)}}stop(){this.clearConnectionTimer(),this.clearDataTimer(),!(this._status.main.status===d.IDLE||this._status.main.status===d.STOPPED)&&(this.updateStatusComponent("main",{status:d.STOPPED}),this.updateStatusComponent("connection",{status:m.DISCONNECTED}),this.sendCommand({type:"STOP"}),this.clearCallbacks())}destroy(){this.stop(),this.worker&&(this.worker.terminate?this.worker.terminate():"close"in this.worker.port&&this.worker.port.close(),this.worker=null)}clearCallbacks(){this.dataCallback=void 0,this.rawDataCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0}sendToken(n){this.token=n,this.sendCommand({type:"UPDATE_TOKEN",token:n})}sendCommand(n){this.worker&&this.worker.port.postMessage(n)}ensureWorker(){if(this.worker||typeof window>"u")return;const n=btoa(this.addr);try{if(this.updateStatusComponent("worker",{status:b.INITIALIZING,lastError:void 0}),window.SharedWorker){const t=new pe({name:n});this.worker={port:t.port},t.port.onmessage=r=>{this.handleWorkerMessage(r.data)},t.port.start()}else{const t=new ce;this.worker={port:t,terminate:()=>t.terminate()},t.onmessage=r=>{this.handleWorkerMessage(r.data)}}this.updateStatusComponent("worker",{status:b.READY})}catch(t){const r=new h(c.WORKER_INIT_FAILED,`Failed to initialize worker: ${String(t)}`);throw this.updateStatusComponent("worker",{status:b.ERROR,lastError:r}),this.updateStatusComponent("main",{status:d.FAILED,lastError:r}),r}}handleWorkerMessage(n){switch(n.type){case"DATA":this.resetDataTimer(),this.dataCallback&&this.dataCallback(this.normalizeState(n.data));break;case"RAW_DATA":this.resetDataTimer(),this.rawDataCallback&&this.rawDataCallback(n.data);break;case"CONNECTED":this.clearConnectionTimer(),this.updateStatusComponent("connection",{status:m.CONNECTED}),this.streamMode==="local"&&this.updateStatusComponent("main",{status:d.RUNNING});break;case"STATUS_UPDATE":n.connection&&this.updateStatusComponent("connection",{status:n.connection}),n.auth&&(this.updateStatusComponent("auth",{status:n.auth}),n.auth===v.AUTHENTICATED&&this.updateStatusComponent("main",{status:d.RUNNING}));break;case"ERROR":{this.clearConnectionTimer();const t=new h(n.code,n.message,n.data);this.mapErrorToStatus(t),this.errorCallback&&this.errorCallback(t);break}case"TOKEN_EXPIRED":this.updateStatusComponent("auth",{status:v.AUTHENTICATING}),this.handleTokenExpiredInternal();break;case"DISCONNECTED":this.updateStatusComponent("connection",{status:m.DISCONNECTED});break}}mapErrorToStatus(n){const t=n.code;(t===c.CONNECTION_FAILED||t===c.CONNECTION_LOST||t===c.RECONNECT_FAILED||t===c.CONNECTION_TIMEOUT)&&(this.updateStatusComponent("connection",{status:m.DISCONNECTED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.AUTH_FAILED||t===c.AUTH_REFRESH_FAILED)&&(this.updateStatusComponent("auth",{status:v.FAILED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.DEVICE_ERROR||t===c.DECODE_ERROR)&&this.updateStatusComponent("main",{lastError:n})}updateStatusComponent(n,t){const r=this._status[n];this._status[n]={...r,...t},this.statusCallback&&this.statusCallback({...this._status})}clearConnectionTimer(){this.connectionTimer&&(clearTimeout(this.connectionTimer),this.connectionTimer=null)}resetDataTimer(){this.clearDataTimer(),this._status.data.status!==g.ACTIVE?this.updateStatusComponent("data",{status:g.ACTIVE,lastActivity:Date.now()}):this._status.data.lastActivity=Date.now(),this.dataTimer=setTimeout(()=>{this.updateStatusComponent("data",{status:g.STALE})},this.dataTimeout)}clearDataTimer(){this.dataTimer&&(clearTimeout(this.dataTimer),this.dataTimer=null)}normalizeState(n){let t,r;"bar_id"in n&&"state"in n?(t=n.state,r=n.bar_id):t=n;let i=t.updates;return i&&(i=i.map(o=>{const s=Object.keys(o).find(u=>o[u]!=null);return{...o,state:s}})),{...t,updates:i,bar_id:r}}async handleTokenExpiredInternal(){const n=this.addr;let t=E.tokenRefreshPromises.get(n);if(!t&&this.onTokenExpired&&(t=(async()=>{try{const i=this.onTokenExpired();return i instanceof Promise?await i:""}finally{E.tokenRefreshPromises.delete(n)}})(),E.tokenRefreshPromises.set(n,t)),t){const r=await t;r&&this.sendToken(r)}}};l(E,"tokenRefreshPromises",new Map);let O=E;class he extends O{constructor(t={},r){let i=t.addr;i||(typeof window<"u"?i=window.location.origin:i="10.0.4.20");super({isBinary:!0,...t,addr:i},r);l(this,"streamMode","local")}normalizeUrl(t){const r=this.resolveProtocol(t),i=new URL(r);return(i.pathname==="/"||!i.pathname)&&(i.pathname="/api/status/ws"),this.token&&i.searchParams.set("x-api-token",this.token),i.toString()}}class ye extends O{constructor(t,r){super({isBinary:!1,...t},r);l(this,"streamMode","remote");l(this,"tokenProvider");this.tokenProvider=t.tokenProvider}subscribe(t){this.sendCommand({type:"SUBSCRIBE",guid:t})}unsubscribe(t){this.sendCommand({type:"UNSUBSCRIBE",guid:t})}normalizeUrl(t){return this.resolveProtocol(t)}onTokenExpired(){if(this.tokenProvider)return this.tokenProvider().then(t=>(this.sendToken(t),t)).catch(t=>{const r=`Failed to refresh token: ${t.message}`;throw this.errorCallback&&this.errorCallback(new h(c.AUTH_REFRESH_FAILED,r)),t})}}exports.BSB_State=void 0;(e=>{(n=>{n[n.DISCHARGING=0]="DISCHARGING",n[n.CHARGING=1]="CHARGING",n[n.CHARGED=2]="CHARGED"})(e.BatteryStatus||(e.BatteryStatus={})),(n=>{n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTING=2]="DISCONNECTING",n[n.RECONNECTING=3]="RECONNECTING"})(e.WifiConnectionStatus||(e.WifiConnectionStatus={})),(n=>{n[n.UNKNOWN=0]="UNKNOWN",n[n.OPEN=1]="OPEN",n[n.WPA=2]="WPA",n[n.WPA2=3]="WPA2",n[n.WEP=4]="WEP",n[n.WPA_WPA2=5]="WPA_WPA2",n[n.WPA3=6]="WPA3",n[n.WPA2_WPA3=7]="WPA2_WPA3"})(e.WifiSecurity||(e.WifiSecurity={})),(n=>{n[n.DHCP=0]="DHCP",n[n.STATIC=1]="STATIC"})(e.IpConfigurationMethod||(e.IpConfigurationMethod={})),(n=>{n[n.IPV4=0]="IPV4",n[n.IPV6=1]="IPV6"})(e.IpProtocol||(e.IpProtocol={})),(n=>{n[n.NEVER_STARTED=0]="NEVER_STARTED",n[n.STARTED=1]="STARTED",n[n.COMPLETED_SUCCESSFULLY=2]="COMPLETED_SUCCESSFULLY",n[n.FAILED=3]="FAILED"})(e.MatterCommissioningStatus||(e.MatterCommissioningStatus={})),(n=>{(t=>{t[t.RESET=0]="RESET",t[t.INITIALIZATION=1]="INITIALIZATION",t[t.READY=2]="READY",t[t.ADVERTISING=3]="ADVERTISING",t[t.CONNECTABLE=4]="CONNECTABLE",t[t.CONNECTED=5]="CONNECTED",t[t.ERROR=6]="ERROR"})(n.ServiceStatus||(n.ServiceStatus={}))})(e.Ble||(e.Ble={}))})(exports.BSB_State||(exports.BSB_State={}));exports.BSB_Update=void 0;(e=>{(n=>{n[n.SESSION_START=0]="SESSION_START",n[n.SESSION_STOP=1]="SESSION_STOP",n[n.ACTION_BEGIN=2]="ACTION_BEGIN",n[n.ACTION_DONE=3]="ACTION_DONE",n[n.DETAIL_CHANGE=4]="DETAIL_CHANGE",n[n.ACTION_PROGRESS=5]="ACTION_PROGRESS",n[n.EVENT_NONE=6]="EVENT_NONE"})(e.UpdateEvent||(e.UpdateEvent={})),(n=>{n[n.DOWNLOAD=0]="DOWNLOAD",n[n.SHA_VERIFICATION=1]="SHA_VERIFICATION",n[n.UNPACK=2]="UNPACK",n[n.INSTALLATION_PREPARE=3]="INSTALLATION_PREPARE",n[n.INSTALLATION_APPLY=4]="INSTALLATION_APPLY",n[n.ACTION_NONE=5]="ACTION_NONE"})(e.UpdateAction||(e.UpdateAction={})),(n=>{n[n.OK=0]="OK",n[n.BATTERY_LOW=1]="BATTERY_LOW",n[n.BUSY=2]="BUSY",n[n.DOWNLOAD_FAILURE=3]="DOWNLOAD_FAILURE",n[n.DOWNLOAD_ABORT=4]="DOWNLOAD_ABORT",n[n.SHA_MISMATCH=5]="SHA_MISMATCH",n[n.UNPACK_CREATE_STAGING_DIRECTORY_FAILURE=6]="UNPACK_CREATE_STAGING_DIRECTORY_FAILURE",n[n.UNPACK_ARCHIVE_OPEN_FAILURE=7]="UNPACK_ARCHIVE_OPEN_FAILURE",n[n.UNPACK_ARCHIVE_UNPACK_FAILURE=8]="UNPACK_ARCHIVE_UNPACK_FAILURE",n[n.INSTALLATION_PREPARE_MANIFEST_NOT_FOUND=9]="INSTALLATION_PREPARE_MANIFEST_NOT_FOUND",n[n.INSTALLATION_PREPARE_MANIFEST_INVALID=10]="INSTALLATION_PREPARE_MANIFEST_INVALID",n[n.INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE=11]="INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE",n[n.INSTALLATION_PREPARE_POINTER_SETUP_FAILURE=12]="INSTALLATION_PREPARE_POINTER_SETUP_FAILURE",n[n.UNKNOWN_FAILURE=13]="UNKNOWN_FAILURE"})(e.UpdateStatus||(e.UpdateStatus={})),(n=>{n[n.NOT_AVAILABLE=0]="NOT_AVAILABLE",n[n.FAILURE=1]="FAILURE",n[n.IDLE=2]="IDLE"})(e.CheckError||(e.CheckError={}))})(exports.BSB_Update||(exports.BSB_Update={}));exports.BSB_Frame=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.RUN_LENGTH=1]="RUN_LENGTH",n[n.DEFLATE=2]="DEFLATE",n[n.DEFLATE_RUN_LENGTH=3]="DEFLATE_RUN_LENGTH"})(e.Encoding||(e.Encoding={})),(n=>{n[n.RGB888=0]="RGB888",n[n.L8=1]="L8",n[n.L4=2]="L4"})(e.PixelFormat||(e.PixelFormat={})),(n=>{n[n.FRONT=0]="FRONT",n[n.BACK=1]="BACK"})(e.Screen||(e.Screen={}))})(exports.BSB_Frame||(exports.BSB_Frame={}));exports.BSB_Util=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.GZIP=1]="GZIP"})(e.Compression||(e.Compression={}))})(exports.BSB_Util||(exports.BSB_Util={}));exports.BSB_Input=void 0;(e=>{(n=>{n[n.OK=0]="OK",n[n.BACK=1]="BACK",n[n.START=2]="START"})(e.Button||(e.Button={})),(n=>{n[n.PRESS=0]="PRESS",n[n.RELEASE=1]="RELEASE"})(e.ButtonAction||(e.ButtonAction={})),(n=>{n[n.BUSY=0]="BUSY",n[n.CUSTOM=1]="CUSTOM",n[n.OFF=2]="OFF",n[n.APPS=3]="APPS",n[n.SETTINGS=4]="SETTINGS"})(e.SwitchPosition||(e.SwitchPosition={}))})(exports.BSB_Input||(exports.BSB_Input={}));exports.BSB_Error=void 0;(e=>{(n=>{n[n.RESOURCE_LIMIT=0]="RESOURCE_LIMIT"})(e.Cause||(e.Cause={})),(n=>{n[n.FATAL=0]="FATAL",n[n.ERROR=1]="ERROR",n[n.WARNING=2]="WARNING"})(e.Severity||(e.Severity={}))})(exports.BSB_Error||(exports.BSB_Error={}));const _=class _{constructor(){l(this,"gl",null);l(this,"program",null);l(this,"texture",null);l(this,"vs",`#version 300 es
8065
+ `;function ye(e){return new SharedWorker("data:text/javascript;charset=utf-8,"+encodeURIComponent(he),{type:"module",name:e==null?void 0:e.name})}const E=class E{constructor(n,t){u(this,"addr");u(this,"token");u(this,"isBinary");u(this,"connectTimeout");u(this,"dataTimeout");u(this,"maxReconnectAttempts");u(this,"maxAuthAttempts");u(this,"worker",null);u(this,"connectionTimer",null);u(this,"dataTimer",null);u(this,"_status");u(this,"dataCallback");u(this,"rawDataCallback");u(this,"errorCallback");u(this,"statusCallback");this.addr=n.addr||"",this.token=n.token,this.isBinary=n.isBinary??!0,this.connectTimeout=(t==null?void 0:t.timeout)??5e3,this.dataTimeout=(t==null?void 0:t.dataTimeout)??15e3,this.maxReconnectAttempts=(t==null?void 0:t.maxReconnectAttempts)??de,this.maxAuthAttempts=k,this._status={main:{status:d.IDLE},connection:{status:y.DISCONNECTED},auth:{status:v.UNAUTHENTICATED},data:{status:g.NONE},worker:{status:b.OFF}}}get status(){return this._status}resolveProtocol(n){let t=n.trim();if(t.startsWith("https://"))return t.replace("https://","wss://");if(t.startsWith("http://"))return t.replace("http://","ws://");if(t.startsWith("wss://")||t.startsWith("ws://"))return t;let r="ws:";return typeof window<"u"&&window.location.protocol==="https:"&&(r="wss:"),`${r}//${t}`}start({dataCallback:n,rawDataCallback:t,errorCallback:r,statusCallback:i}){if(this._status.main.status===d.STARTING||this._status.main.status===d.RUNNING){const o=new h(c.STREAM_ALREADY_STARTED,"StateStream is already running. Call stop() before starting again.");if(i&&i({...this._status,main:{...this._status.main,lastError:o}}),r)r(o);else throw o;return}this.dataCallback=n,this.rawDataCallback=t,this.errorCallback=r,this.statusCallback=i,this.updateStatusComponent("main",{status:d.STARTING,lastError:void 0});try{this.ensureWorker(),this.sendCommand({type:"START",addr:this.normalizeUrl(this.addr),token:this.token,isBinary:this.isBinary,mode:this.streamMode,maxReconnectAttempts:this.maxReconnectAttempts,maxAuthAttempts:this.maxAuthAttempts}),this.clearConnectionTimer(),this.connectionTimer=setTimeout(()=>{const o=new h(c.CONNECTION_TIMEOUT,`Connection timed out after ${this.connectTimeout}ms`);this.mapErrorToStatus(o),this.errorCallback&&this.errorCallback(o),this.stop()},this.connectTimeout)}catch(o){const s=o instanceof h?o:new h(c.UNKNOWN_ERROR,String(o));this.errorCallback&&this.errorCallback(s)}}stop(){this.clearConnectionTimer(),this.clearDataTimer(),!(this._status.main.status===d.IDLE||this._status.main.status===d.STOPPED)&&(this.updateStatusComponent("main",{status:d.STOPPED}),this.updateStatusComponent("connection",{status:y.DISCONNECTED}),this.sendCommand({type:"STOP"}),this.clearCallbacks())}destroy(){this.stop(),this.worker&&(this.worker.terminate?this.worker.terminate():"close"in this.worker.port&&this.worker.port.close(),this.worker=null)}clearCallbacks(){this.dataCallback=void 0,this.rawDataCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0}sendToken(n){this.token=n,this.sendCommand({type:"UPDATE_TOKEN",token:n})}sendCommand(n){this.worker&&this.worker.port.postMessage(n)}ensureWorker(){if(this.worker||typeof window>"u")return;const n=btoa(this.addr);try{if(this.updateStatusComponent("worker",{status:b.INITIALIZING,lastError:void 0}),window.SharedWorker){const t=new ye({name:n});this.worker={port:t.port},t.port.onmessage=r=>{this.handleWorkerMessage(r.data)},t.port.start()}else{const t=new pe;this.worker={port:t,terminate:()=>t.terminate()},t.onmessage=r=>{this.handleWorkerMessage(r.data)}}this.updateStatusComponent("worker",{status:b.READY})}catch(t){const r=new h(c.WORKER_INIT_FAILED,`Failed to initialize worker: ${String(t)}`);throw this.updateStatusComponent("worker",{status:b.ERROR,lastError:r}),this.updateStatusComponent("main",{status:d.FAILED,lastError:r}),r}}handleWorkerMessage(n){switch(n.type){case"DATA":this.resetDataTimer(),this.dataCallback&&this.dataCallback(this.normalizeState(n.data));break;case"RAW_DATA":this.resetDataTimer(),this.rawDataCallback&&this.rawDataCallback(n.data);break;case"CONNECTED":this.clearConnectionTimer(),this.updateStatusComponent("connection",{status:y.CONNECTED}),this.streamMode==="local"&&this.updateStatusComponent("main",{status:d.RUNNING});break;case"STATUS_UPDATE":if(n.connection){const t={status:n.connection,attempts:n.connection===y.RECONNECTING?n.connectionAttempts:void 0};this.updateStatusComponent("connection",t)}if(n.auth){const t={status:n.auth,attempts:n.auth===v.REAUTHENTICATING?n.authAttempts:void 0};this.updateStatusComponent("auth",t),n.auth===v.AUTHENTICATED&&this.updateStatusComponent("main",{status:d.RUNNING})}break;case"ERROR":{this.clearConnectionTimer();const t=new h(n.code,n.message,n.data);this.mapErrorToStatus(t),this.errorCallback&&this.errorCallback(t);break}case"TOKEN_EXPIRED":this.updateStatusComponent("auth",{status:v.AUTHENTICATING}),this.handleTokenExpiredInternal();break;case"DISCONNECTED":this.updateStatusComponent("connection",{status:y.DISCONNECTED});break}}mapErrorToStatus(n){const t=n.code;(t===c.CONNECTION_FAILED||t===c.CONNECTION_LOST||t===c.RECONNECT_FAILED||t===c.CONNECTION_TIMEOUT)&&(this.updateStatusComponent("connection",{status:y.DISCONNECTED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.AUTH_FAILED||t===c.AUTH_REFRESH_FAILED)&&(this.updateStatusComponent("auth",{status:v.FAILED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.DEVICE_ERROR||t===c.DECODE_ERROR)&&this.updateStatusComponent("main",{lastError:n})}updateStatusComponent(n,t){const i={...this._status[n],...t};Object.keys(i).forEach(o=>{i[o]===void 0&&delete i[o]}),this._status[n]=i,this.statusCallback&&this.statusCallback({...this._status})}clearConnectionTimer(){this.connectionTimer&&(clearTimeout(this.connectionTimer),this.connectionTimer=null)}resetDataTimer(){this.clearDataTimer(),this._status.data.status!==g.ACTIVE?this.updateStatusComponent("data",{status:g.ACTIVE,lastActivity:Date.now()}):this._status.data.lastActivity=Date.now(),this.dataTimer=setTimeout(()=>{this.updateStatusComponent("data",{status:g.STALE})},this.dataTimeout)}clearDataTimer(){this.dataTimer&&(clearTimeout(this.dataTimer),this.dataTimer=null)}normalizeState(n){let t,r;"bar_id"in n&&"state"in n?(t=n.state,r=n.bar_id):t=n;let i=t.updates;return i&&(i=i.map(o=>{const s=Object.keys(o).find(l=>o[l]!=null);return{...o,state:s}})),{...t,updates:i,bar_id:r}}async handleTokenExpiredInternal(){const n=this.addr;let t=E.tokenRefreshPromises.get(n);if(!t&&this.onTokenExpired&&(t=(async()=>{try{const i=this.onTokenExpired();return i instanceof Promise?await i:""}finally{E.tokenRefreshPromises.delete(n)}})(),E.tokenRefreshPromises.set(n,t)),t){const r=await t;r&&this.sendToken(r)}}};u(E,"tokenRefreshPromises",new Map);let T=E;class me extends T{constructor(t={},r){let i=t.addr;i||(typeof window<"u"?i=window.location.origin:i="10.0.4.20");super({isBinary:!0,...t,addr:i},r);u(this,"streamMode","local")}normalizeUrl(t){const r=this.resolveProtocol(t),i=new URL(r);return(i.pathname==="/"||!i.pathname)&&(i.pathname="/api/status/ws"),this.token&&i.searchParams.set("x-api-token",this.token),i.toString()}}class ve extends T{constructor(t,r){super({isBinary:!1,...t},r);u(this,"streamMode","remote");u(this,"tokenProvider");u(this,"maxAuthAttempts");this.tokenProvider=t.tokenProvider,this.maxAuthAttempts=(r==null?void 0:r.maxAuthAttempts)??k}subscribe(t){this.sendCommand({type:"SUBSCRIBE",guid:t})}unsubscribe(t){this.sendCommand({type:"UNSUBSCRIBE",guid:t})}normalizeUrl(t){return this.resolveProtocol(t)}onTokenExpired(){if(this.tokenProvider)return this.tokenProvider().then(t=>(this.sendToken(t),t)).catch(t=>{const r=`Failed to refresh token: ${t.message}`;throw this.errorCallback&&this.errorCallback(new h(c.AUTH_REFRESH_FAILED,r)),t})}}exports.BSB_State=void 0;(e=>{(n=>{n[n.DISCHARGING=0]="DISCHARGING",n[n.CHARGING=1]="CHARGING",n[n.CHARGED=2]="CHARGED"})(e.BatteryStatus||(e.BatteryStatus={})),(n=>{n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTING=2]="DISCONNECTING",n[n.RECONNECTING=3]="RECONNECTING"})(e.WifiConnectionStatus||(e.WifiConnectionStatus={})),(n=>{n[n.UNKNOWN=0]="UNKNOWN",n[n.OPEN=1]="OPEN",n[n.WPA=2]="WPA",n[n.WPA2=3]="WPA2",n[n.WEP=4]="WEP",n[n.WPA_WPA2=5]="WPA_WPA2",n[n.WPA3=6]="WPA3",n[n.WPA2_WPA3=7]="WPA2_WPA3"})(e.WifiSecurity||(e.WifiSecurity={})),(n=>{n[n.DHCP=0]="DHCP",n[n.STATIC=1]="STATIC"})(e.IpConfigurationMethod||(e.IpConfigurationMethod={})),(n=>{n[n.IPV4=0]="IPV4",n[n.IPV6=1]="IPV6"})(e.IpProtocol||(e.IpProtocol={})),(n=>{n[n.NEVER_STARTED=0]="NEVER_STARTED",n[n.STARTED=1]="STARTED",n[n.COMPLETED_SUCCESSFULLY=2]="COMPLETED_SUCCESSFULLY",n[n.FAILED=3]="FAILED"})(e.MatterCommissioningStatus||(e.MatterCommissioningStatus={})),(n=>{(t=>{t[t.RESET=0]="RESET",t[t.INITIALIZATION=1]="INITIALIZATION",t[t.READY=2]="READY",t[t.ADVERTISING=3]="ADVERTISING",t[t.CONNECTABLE=4]="CONNECTABLE",t[t.CONNECTED=5]="CONNECTED",t[t.ERROR=6]="ERROR"})(n.ServiceStatus||(n.ServiceStatus={}))})(e.Ble||(e.Ble={}))})(exports.BSB_State||(exports.BSB_State={}));exports.BSB_Update=void 0;(e=>{(n=>{n[n.SESSION_START=0]="SESSION_START",n[n.SESSION_STOP=1]="SESSION_STOP",n[n.ACTION_BEGIN=2]="ACTION_BEGIN",n[n.ACTION_DONE=3]="ACTION_DONE",n[n.DETAIL_CHANGE=4]="DETAIL_CHANGE",n[n.ACTION_PROGRESS=5]="ACTION_PROGRESS",n[n.EVENT_NONE=6]="EVENT_NONE"})(e.UpdateEvent||(e.UpdateEvent={})),(n=>{n[n.DOWNLOAD=0]="DOWNLOAD",n[n.SHA_VERIFICATION=1]="SHA_VERIFICATION",n[n.UNPACK=2]="UNPACK",n[n.INSTALLATION_PREPARE=3]="INSTALLATION_PREPARE",n[n.INSTALLATION_APPLY=4]="INSTALLATION_APPLY",n[n.ACTION_NONE=5]="ACTION_NONE"})(e.UpdateAction||(e.UpdateAction={})),(n=>{n[n.OK=0]="OK",n[n.BATTERY_LOW=1]="BATTERY_LOW",n[n.BUSY=2]="BUSY",n[n.DOWNLOAD_FAILURE=3]="DOWNLOAD_FAILURE",n[n.DOWNLOAD_ABORT=4]="DOWNLOAD_ABORT",n[n.SHA_MISMATCH=5]="SHA_MISMATCH",n[n.UNPACK_CREATE_STAGING_DIRECTORY_FAILURE=6]="UNPACK_CREATE_STAGING_DIRECTORY_FAILURE",n[n.UNPACK_ARCHIVE_OPEN_FAILURE=7]="UNPACK_ARCHIVE_OPEN_FAILURE",n[n.UNPACK_ARCHIVE_UNPACK_FAILURE=8]="UNPACK_ARCHIVE_UNPACK_FAILURE",n[n.INSTALLATION_PREPARE_MANIFEST_NOT_FOUND=9]="INSTALLATION_PREPARE_MANIFEST_NOT_FOUND",n[n.INSTALLATION_PREPARE_MANIFEST_INVALID=10]="INSTALLATION_PREPARE_MANIFEST_INVALID",n[n.INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE=11]="INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE",n[n.INSTALLATION_PREPARE_POINTER_SETUP_FAILURE=12]="INSTALLATION_PREPARE_POINTER_SETUP_FAILURE",n[n.UNKNOWN_FAILURE=13]="UNKNOWN_FAILURE"})(e.UpdateStatus||(e.UpdateStatus={})),(n=>{n[n.NOT_AVAILABLE=0]="NOT_AVAILABLE",n[n.FAILURE=1]="FAILURE",n[n.IDLE=2]="IDLE"})(e.CheckError||(e.CheckError={}))})(exports.BSB_Update||(exports.BSB_Update={}));exports.BSB_Frame=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.RUN_LENGTH=1]="RUN_LENGTH",n[n.DEFLATE=2]="DEFLATE",n[n.DEFLATE_RUN_LENGTH=3]="DEFLATE_RUN_LENGTH"})(e.Encoding||(e.Encoding={})),(n=>{n[n.RGB888=0]="RGB888",n[n.L8=1]="L8",n[n.L4=2]="L4"})(e.PixelFormat||(e.PixelFormat={})),(n=>{n[n.FRONT=0]="FRONT",n[n.BACK=1]="BACK"})(e.Screen||(e.Screen={}))})(exports.BSB_Frame||(exports.BSB_Frame={}));exports.BSB_Util=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.GZIP=1]="GZIP"})(e.Compression||(e.Compression={}))})(exports.BSB_Util||(exports.BSB_Util={}));exports.BSB_Input=void 0;(e=>{(n=>{n[n.OK=0]="OK",n[n.BACK=1]="BACK",n[n.START=2]="START"})(e.Button||(e.Button={})),(n=>{n[n.PRESS=0]="PRESS",n[n.RELEASE=1]="RELEASE"})(e.ButtonAction||(e.ButtonAction={})),(n=>{n[n.BUSY=0]="BUSY",n[n.CUSTOM=1]="CUSTOM",n[n.OFF=2]="OFF",n[n.APPS=3]="APPS",n[n.SETTINGS=4]="SETTINGS"})(e.SwitchPosition||(e.SwitchPosition={}))})(exports.BSB_Input||(exports.BSB_Input={}));exports.BSB_Error=void 0;(e=>{(n=>{n[n.RESOURCE_LIMIT=0]="RESOURCE_LIMIT"})(e.Cause||(e.Cause={})),(n=>{n[n.FATAL=0]="FATAL",n[n.ERROR=1]="ERROR",n[n.WARNING=2]="WARNING"})(e.Severity||(e.Severity={}))})(exports.BSB_Error||(exports.BSB_Error={}));const _=class _{constructor(){u(this,"gl",null);u(this,"program",null);u(this,"texture",null);u(this,"vs",`#version 300 es
8066
8066
  in vec2 position;
8067
8067
  out vec2 v_uv;
8068
8068
  void main() {
@@ -8070,7 +8070,7 @@ if ("SharedWorkerGlobalScope" in self) {
8070
8070
  v_uv.y = 1.0 - v_uv.y;
8071
8071
  gl_Position = vec4(position, 0, 1);
8072
8072
  }
8073
- `);l(this,"fs",`#version 300 es
8073
+ `);u(this,"fs",`#version 300 es
8074
8074
  precision highp float;
8075
8075
  in vec2 v_uv;
8076
8076
  out vec4 outColor;
@@ -8102,4 +8102,4 @@ if ("SharedWorkerGlobalScope" in self) {
8102
8102
  if (mask < 0.001) discard;
8103
8103
  outColor = vec4(finalColor, color.a * mask);
8104
8104
  }
8105
- `);if(_.instance)return _.instance;_.instance=this}init(){if(this.gl||typeof window>"u")return;const t=document.createElement("canvas").getContext("webgl2",{antialias:!0,alpha:!0,preserveDrawingBuffer:!0});if(!t)throw new Error("WebGL 2.0 not supported");this.gl=t,this.program=this.createProgram(this.vs,this.fs);const r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const i=t.getAttribLocation(this.program,"position");t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}render(n,t,r,i){const{pixelSize:o=.85,radius:s=.5,darkThreshold:u=.04}=i,a=this.gl;a.viewport(0,0,a.canvas.width,a.canvas.height),a.useProgram(this.program),a.bindTexture(a.TEXTURE_2D,this.texture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA8,t,r,0,a.RGBA,a.UNSIGNED_BYTE,n),a.uniform2f(a.getUniformLocation(this.program,"u_dataRes"),t,r),a.uniform2f(a.getUniformLocation(this.program,"u_canvasRes"),a.canvas.width,a.canvas.height),a.uniform1f(a.getUniformLocation(this.program,"u_pixelSize"),o),a.uniform1f(a.getUniformLocation(this.program,"u_radius"),s),a.uniform1f(a.getUniformLocation(this.program,"u_darkThreshold"),u),a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),a.drawArrays(a.TRIANGLES,0,6)}renderFrame(n,t,r,i,o={}){if(this.init(),typeof window>"u"||!this.gl)return;(this.gl.canvas.width!==n.width||this.gl.canvas.height!==n.height)&&(this.gl.canvas.width=n.width,this.gl.canvas.height=n.height),this.render(t,r,i,o);const s=n.getContext("2d");s&&(s.clearRect(0,0,n.width,n.height),s.drawImage(this.gl.canvas,0,0))}createProgram(n,t){const r=this.gl,i=(s,u)=>{const a=r.createShader(s);if(r.shaderSource(a,u),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(a)||"Shader Error");return a},o=r.createProgram();return r.attachShader(o,i(r.VERTEX_SHADER,n)),r.attachShader(o,i(r.FRAGMENT_SHADER,t)),r.linkProgram(o),o}};l(_,"instance",null);let S=_;const me=new S;exports.AuthStatus=v;exports.BusyBar=C;exports.ConnectionStatus=m;exports.DataStatus=g;exports.LEDRenderer=me;exports.LocalStateStream=he;exports.RemoteStateStream=ye;exports.StateStreamError=h;exports.StateStreamErrorCode=c;exports.StreamLifecycle=d;exports.WorkerStatus=b;
8105
+ `);if(_.instance)return _.instance;_.instance=this}init(){if(this.gl||typeof window>"u")return;const t=document.createElement("canvas").getContext("webgl2",{antialias:!0,alpha:!0,preserveDrawingBuffer:!0});if(!t)throw new Error("WebGL 2.0 not supported");this.gl=t,this.program=this.createProgram(this.vs,this.fs);const r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const i=t.getAttribLocation(this.program,"position");t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}render(n,t,r,i){const{pixelSize:o=.85,radius:s=.5,darkThreshold:l=.04}=i,a=this.gl;a.viewport(0,0,a.canvas.width,a.canvas.height),a.useProgram(this.program),a.bindTexture(a.TEXTURE_2D,this.texture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA8,t,r,0,a.RGBA,a.UNSIGNED_BYTE,n),a.uniform2f(a.getUniformLocation(this.program,"u_dataRes"),t,r),a.uniform2f(a.getUniformLocation(this.program,"u_canvasRes"),a.canvas.width,a.canvas.height),a.uniform1f(a.getUniformLocation(this.program,"u_pixelSize"),o),a.uniform1f(a.getUniformLocation(this.program,"u_radius"),s),a.uniform1f(a.getUniformLocation(this.program,"u_darkThreshold"),l),a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),a.drawArrays(a.TRIANGLES,0,6)}renderFrame(n,t,r,i,o={}){if(this.init(),typeof window>"u"||!this.gl)return;(this.gl.canvas.width!==n.width||this.gl.canvas.height!==n.height)&&(this.gl.canvas.width=n.width,this.gl.canvas.height=n.height),this.render(t,r,i,o);const s=n.getContext("2d");s&&(s.clearRect(0,0,n.width,n.height),s.drawImage(this.gl.canvas,0,0))}createProgram(n,t){const r=this.gl,i=(s,l)=>{const a=r.createShader(s);if(r.shaderSource(a,l),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(a)||"Shader Error");return a},o=r.createProgram();return r.attachShader(o,i(r.VERTEX_SHADER,n)),r.attachShader(o,i(r.FRAGMENT_SHADER,t)),r.linkProgram(o),o}};u(_,"instance",null);let S=_;const ge=new S;exports.AuthStatus=v;exports.BusyBar=C;exports.ConnectionStatus=y;exports.DataStatus=g;exports.LEDRenderer=ge;exports.LocalStateStream=me;exports.RemoteStateStream=ve;exports.StateStreamError=h;exports.StateStreamErrorCode=c;exports.StreamLifecycle=d;exports.WorkerStatus=b;