@busy-app/busy-lib 0.11.0 → 0.13.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.js CHANGED
@@ -1,112 +1,113 @@
1
- var G = Object.defineProperty;
2
- var P = (n, t, i) => t in n ? G(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
- var c = (n, t, i) => P(n, typeof t != "symbol" ? t + "" : t, i);
4
- import m from "openapi-fetch";
5
- const L = (n, t) => {
6
- if (typeof FormData < "u" && n instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(n) || typeof File < "u" && n instanceof File || typeof Blob < "u" && n instanceof Blob || typeof ArrayBuffer < "u" && n instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(n))
7
- return n;
8
- let i;
9
- return t && (t instanceof Headers ? i = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (i = t["Content-Type"] ?? t["content-type"]), i === "application/x-www-form-urlencoded") ? n && typeof n == "object" && !(n instanceof URLSearchParams) ? new URLSearchParams(n).toString() : String(n) : JSON.stringify(n);
1
+ var B = Object.defineProperty;
2
+ var F = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var u = (r, t, e) => F(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import O from "openapi-fetch";
5
+ import { W as S, D as C, A as k, C as E, S as f, a as y, b as d } from "./types.status-gCPe7MrJ.js";
6
+ const W = (r, t) => {
7
+ if (typeof FormData < "u" && r instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(r) || typeof File < "u" && r instanceof File || typeof Blob < "u" && r instanceof Blob || typeof ArrayBuffer < "u" && r instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(r))
8
+ return r;
9
+ let e;
10
+ return t && (t instanceof Headers ? e = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (e = t["Content-Type"] ?? t["content-type"]), e === "application/x-www-form-urlencoded") ? r && typeof r == "object" && !(r instanceof URLSearchParams) ? new URLSearchParams(r).toString() : String(r) : JSON.stringify(r);
10
11
  };
11
- async function y(n) {
12
- const e = (n.headers.get("content-type") || "").includes("application/json") ? await n.clone().json() : await n.clone().text(), r = typeof e == "object" && e !== null ? e.error || e.message : typeof e == "string" ? e : void 0;
13
- return Object.assign(new Error(r || `HTTP ${n.status} ${n.statusText}`), {
14
- status: n.status,
15
- statusText: n.statusText,
16
- body: e
12
+ async function b(r) {
13
+ const i = (r.headers.get("content-type") || "").includes("application/json") ? await r.clone().json() : await r.clone().text(), n = typeof i == "object" && i !== null ? i.error || i.message : typeof i == "string" ? i : void 0;
14
+ return Object.assign(new Error(n || `HTTP ${r.status} ${r.statusText}`), {
15
+ status: r.status,
16
+ statusText: r.statusText,
17
+ body: i
17
18
  });
18
19
  }
19
- async function s(n, t = 3e3) {
20
+ async function a(r, t = 3e3) {
20
21
  if (t <= 0)
21
- return await n();
22
- const i = new AbortController(), e = setTimeout(() => i.abort(), t);
22
+ return await r();
23
+ const e = new AbortController(), i = setTimeout(() => e.abort(), t);
23
24
  try {
24
- return await n(i.signal);
25
- } catch (r) {
26
- throw r instanceof DOMException && r.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : r;
25
+ return await r(e.signal);
26
+ } catch (n) {
27
+ throw n instanceof DOMException && n.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : n;
27
28
  } finally {
28
- clearTimeout(e);
29
+ clearTimeout(i);
29
30
  }
30
31
  }
31
- function O(n, t, i) {
32
- let e, r = i ?? void 0, o, a = null;
33
- const u = async () => {
34
- e || (a || (a = (async () => {
35
- const h = await t();
36
- if (!h.api_semver)
32
+ function M(r, t, e) {
33
+ let i, n = e ?? void 0, s, o = null;
34
+ const h = async () => {
35
+ i || (o || (o = (async () => {
36
+ const l = await t();
37
+ if (!l.api_semver)
37
38
  throw new Error("Empty API version");
38
- e = h.api_semver;
39
+ i = l.api_semver;
39
40
  })().finally(() => {
40
- a = null;
41
- })), await a);
42
- }, w = {
43
- async onRequest({ request: h, schemaPath: d }) {
44
- return r && h.headers.set("Authorization", `Bearer ${r}`), d !== "/version" && (await u(), e && h.headers.set("X-API-Sem-Ver", e), o && h.headers.set("X-API-Token", o)), h;
41
+ o = null;
42
+ })), await o);
43
+ }, c = {
44
+ async onRequest({ request: l, schemaPath: w }) {
45
+ return n && l.headers.set("Authorization", `Bearer ${n}`), w !== "/version" && (await h(), i && l.headers.set("X-API-Sem-Ver", i), s && l.headers.set("X-API-Token", s)), l;
45
46
  },
46
- async onResponse({ request: h, response: d, options: b, schemaPath: v }) {
47
- if (d.ok)
48
- return d;
49
- if (v === "/version")
50
- throw await y(d);
51
- if (d.status !== 405)
52
- throw await y(d);
53
- e = void 0, await u(), e && h.headers.set("X-API-Sem-Ver", e), r && h.headers.set("Authorization", `Bearer ${r}`);
54
- const l = await (b.fetch ?? fetch)(h);
55
- if (l.ok)
56
- return l;
57
- throw await y(l);
47
+ async onResponse({ request: l, response: w, options: G, schemaPath: x }) {
48
+ if (w.ok)
49
+ return w;
50
+ if (x === "/version")
51
+ throw await b(w);
52
+ if (w.status !== 405)
53
+ throw await b(w);
54
+ i = void 0, await h(), i && l.headers.set("X-API-Sem-Ver", i), n && l.headers.set("Authorization", `Bearer ${n}`);
55
+ const A = await (G.fetch ?? fetch)(l);
56
+ if (A.ok)
57
+ return A;
58
+ throw await b(A);
58
59
  }
59
- }, f = m({
60
- baseUrl: n,
61
- bodySerializer: L
60
+ }, p = O({
61
+ baseUrl: r,
62
+ bodySerializer: W
62
63
  });
63
- return f.use(w), {
64
- client: f,
65
- setApiKey: (h) => {
66
- o = h;
64
+ return p.use(c), {
65
+ client: p,
66
+ setApiKey: (l) => {
67
+ s = l;
67
68
  },
68
- setToken: (h) => {
69
- r = h;
69
+ setToken: (l) => {
70
+ n = l;
70
71
  }
71
72
  };
72
73
  }
73
- async function D(n, t) {
74
- const { data: i, error: e } = await s((r) => n.GET("/version", { signal: r }), t == null ? void 0 : t.timeout);
75
- if (e)
76
- throw e;
77
- return i;
74
+ async function $(r, t) {
75
+ const { data: e, error: i } = await a((n) => r.GET("/version", { signal: n }), t == null ? void 0 : t.timeout);
76
+ if (i)
77
+ throw i;
78
+ return e;
78
79
  }
79
- async function U(n, t) {
80
- const { data: i, error: e } = await s((r) => n.GET("/status", { signal: r }), t == null ? void 0 : t.timeout);
81
- if (e)
82
- throw e;
83
- return i;
80
+ async function K(r, t) {
81
+ const { data: e, error: i } = await a((n) => r.GET("/status", { signal: n }), t == null ? void 0 : t.timeout);
82
+ if (i)
83
+ throw i;
84
+ return e;
84
85
  }
85
- async function B(n, t) {
86
- const { data: i, error: e } = await s((r) => n.GET("/status/system", { signal: r }), t == null ? void 0 : t.timeout);
87
- if (e)
88
- throw e;
89
- return i;
86
+ async function z(r, t) {
87
+ const { data: e, error: i } = await a((n) => r.GET("/status/system", { signal: n }), t == null ? void 0 : t.timeout);
88
+ if (i)
89
+ throw i;
90
+ return e;
90
91
  }
91
- async function I(n, t) {
92
- const { data: i, error: e } = await s((r) => n.GET("/status/power", { signal: r }), t == null ? void 0 : t.timeout);
93
- if (e)
94
- throw e;
95
- return i;
92
+ async function H(r, t) {
93
+ const { data: e, error: i } = await a((n) => r.GET("/status/power", { signal: n }), t == null ? void 0 : t.timeout);
94
+ if (i)
95
+ throw i;
96
+ return e;
96
97
  }
97
- async function $(n, t) {
98
- const { data: i, error: e } = await s((r) => n.GET("/status/device", { signal: r }), t == null ? void 0 : t.timeout);
99
- if (e)
100
- throw e;
101
- return i;
98
+ async function q(r, t) {
99
+ const { data: e, error: i } = await a((n) => r.GET("/status/device", { signal: n }), t == null ? void 0 : t.timeout);
100
+ if (i)
101
+ throw i;
102
+ return e;
102
103
  }
103
- async function R(n, t) {
104
- const { data: i, error: e } = await s((r) => n.GET("/status/firmware", { signal: r }), t == null ? void 0 : t.timeout);
105
- if (e)
106
- throw e;
107
- return i;
104
+ async function V(r, t) {
105
+ const { data: e, error: i } = await a((n) => r.GET("/status/firmware", { signal: n }), t == null ? void 0 : t.timeout);
106
+ if (i)
107
+ throw i;
108
+ return e;
108
109
  }
109
- class K {
110
+ class X {
110
111
  /**
111
112
  * Get API version information.
112
113
  *
@@ -115,8 +116,8 @@ class K {
115
116
  * @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
116
117
  */
117
118
  async SystemVersionGet(t) {
118
- const i = await D(this.apiClient, t);
119
- return this.apiSemver = i.api_semver, i;
119
+ const e = await $(this.apiClient, t);
120
+ return this.apiSemver = e.api_semver, e;
120
121
  }
121
122
  /**
122
123
  * Get full status.
@@ -126,7 +127,7 @@ class K {
126
127
  * @returns {Promise<Status>} Current status of the device.
127
128
  */
128
129
  async SystemStatusGet(t) {
129
- return await U(this.apiClient, t);
130
+ return await K(this.apiClient, t);
130
131
  }
131
132
  /**
132
133
  * Get system status.
@@ -136,7 +137,7 @@ class K {
136
137
  * @returns {Promise<StatusSystem>} Current system status.
137
138
  */
138
139
  async SystemInfoGet(t) {
139
- return await B(this.apiClient, t);
140
+ return await z(this.apiClient, t);
140
141
  }
141
142
  /**
142
143
  * Get power status.
@@ -146,7 +147,7 @@ class K {
146
147
  * @returns {Promise<StatusPower>} Current power status.
147
148
  */
148
149
  async SystemStatusPowerGet(t) {
149
- return await I(this.apiClient, t);
150
+ return await H(this.apiClient, t);
150
151
  }
151
152
  /**
152
153
  * Get device status.
@@ -156,7 +157,7 @@ class K {
156
157
  * @returns {Promise<StatusDevice>} Current device status.
157
158
  */
158
159
  async SystemStatusDeviceGet(t) {
159
- return await $(this.apiClient, t);
160
+ return await q(this.apiClient, t);
160
161
  }
161
162
  /**
162
163
  * Get firmware status.
@@ -166,93 +167,93 @@ class K {
166
167
  * @returns {Promise<StatusFirmware>} Current firmware status.
167
168
  */
168
169
  async SystemStatusFirmwareGet(t) {
169
- return await R(this.apiClient, t);
170
+ return await V(this.apiClient, t);
170
171
  }
171
172
  }
172
- async function F(n, t) {
173
- const { file: i } = t, { data: e, error: r } = await s(
174
- (o) => n.POST("/update", {
173
+ async function j(r, t) {
174
+ const { file: e } = t, { data: i, error: n } = await a(
175
+ (s) => r.POST("/update", {
175
176
  headers: {
176
177
  "Content-Type": "application/octet-stream"
177
178
  },
178
- body: i,
179
- signal: o
179
+ body: e,
180
+ signal: s
180
181
  }),
181
182
  t.timeout
182
183
  );
183
- if (r)
184
- throw r;
185
- return e;
186
- }
187
- async function _(n, t) {
188
- const { data: i, error: e } = await s((r) => n.POST("/update/check", { signal: r }), t == null ? void 0 : t.timeout);
189
- if (e)
190
- throw e;
184
+ if (n)
185
+ throw n;
191
186
  return i;
192
187
  }
193
- async function W(n, t) {
194
- const { data: i, error: e } = await s((r) => n.GET("/update/status", { signal: r }), t == null ? void 0 : t.timeout);
195
- if (e)
196
- throw e;
197
- return i;
188
+ async function Y(r, t) {
189
+ const { data: e, error: i } = await a((n) => r.POST("/update/check", { signal: n }), t == null ? void 0 : t.timeout);
190
+ if (i)
191
+ throw i;
192
+ return e;
198
193
  }
199
- async function M(n, t) {
200
- const { version: i } = t, { data: e, error: r } = await s(
201
- (o) => n.GET("/update/changelog", {
194
+ async function J(r, t) {
195
+ const { data: e, error: i } = await a((n) => r.GET("/update/status", { signal: n }), t == null ? void 0 : t.timeout);
196
+ if (i)
197
+ throw i;
198
+ return e;
199
+ }
200
+ async function Q(r, t) {
201
+ const { version: e } = t, { data: i, error: n } = await a(
202
+ (s) => r.GET("/update/changelog", {
202
203
  params: {
203
204
  query: {
204
- version: i
205
+ version: e
205
206
  }
206
207
  },
207
- signal: o
208
+ signal: s
208
209
  }),
209
210
  t.timeout
210
211
  );
211
- if (r)
212
- throw r;
213
- return e;
212
+ if (n)
213
+ throw n;
214
+ return i;
214
215
  }
215
- async function N(n, t) {
216
- const { version: i } = t, { data: e, error: r } = await s(
217
- (o) => n.POST("/update/install", {
216
+ async function Z(r, t) {
217
+ const { version: e } = t, { data: i, error: n } = await a(
218
+ (s) => r.POST("/update/install", {
218
219
  params: {
219
220
  query: {
220
- version: i
221
+ version: e
221
222
  }
222
223
  },
223
- signal: o
224
+ signal: s
224
225
  }),
225
226
  t.timeout
226
227
  );
227
- if (r)
228
- throw r;
229
- return e;
230
- }
231
- async function q(n, t) {
232
- const { data: i, error: e } = await s((r) => n.POST("/update/abort_download", { signal: r }), t == null ? void 0 : t.timeout);
233
- if (e)
234
- throw e;
228
+ if (n)
229
+ throw n;
235
230
  return i;
236
231
  }
237
- async function x(n, t) {
238
- const { data: i, error: e } = await s((r) => n.GET("/update/autoupdate", { signal: r }), t == null ? void 0 : t.timeout);
239
- if (e)
240
- throw e;
241
- return i;
232
+ async function tt(r, t) {
233
+ const { data: e, error: i } = await a((n) => r.POST("/update/abort_download", { signal: n }), t == null ? void 0 : t.timeout);
234
+ if (i)
235
+ throw i;
236
+ return e;
237
+ }
238
+ async function et(r, t) {
239
+ const { data: e, error: i } = await a((n) => r.GET("/update/autoupdate", { signal: n }), t == null ? void 0 : t.timeout);
240
+ if (i)
241
+ throw i;
242
+ return e;
242
243
  }
243
- async function V(n, t) {
244
- const { is_enabled: i, interval_start: e, interval_end: r } = t, { data: o, error: a } = await s(
245
- (u) => n.POST("/update/autoupdate", {
246
- body: { is_enabled: i, interval_start: e, interval_end: r },
247
- signal: u
244
+ async function it(r, t) {
245
+ const { is_enabled: e, interval_start: i, interval_end: n } = t, { data: s, error: o } = await a(
246
+ (h) => r.POST("/update/autoupdate", {
247
+ body: { is_enabled: e, interval_start: i, interval_end: n },
248
+ signal: h
248
249
  }),
249
250
  t.timeout
250
251
  );
251
- if (a)
252
- throw a;
253
- return o;
252
+ if (o)
253
+ throw o;
254
+ return s;
254
255
  }
255
- class j {
256
+ class rt {
256
257
  /**
257
258
  * Upload firmware update package.
258
259
  *
@@ -262,7 +263,7 @@ class j {
262
263
  * @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
263
264
  */
264
265
  async UpdateFromFile(t) {
265
- return await F(this.apiClient, t);
266
+ return await j(this.apiClient, t);
266
267
  }
267
268
  /**
268
269
  * Start firmware update check.
@@ -272,7 +273,7 @@ class j {
272
273
  * @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
273
274
  */
274
275
  async UpdateCheck(t) {
275
- return await _(this.apiClient, t);
276
+ return await Y(this.apiClient, t);
276
277
  }
277
278
  /**
278
279
  * Get firmware update status.
@@ -282,7 +283,7 @@ class j {
282
283
  * @returns {Promise<UpdateStatus>} A promise that resolves to the update status.
283
284
  */
284
285
  async UpdateStatusGet(t) {
285
- return await W(this.apiClient, t);
286
+ return await J(this.apiClient, t);
286
287
  }
287
288
  /**
288
289
  * Get firmware update changelog.
@@ -293,7 +294,7 @@ class j {
293
294
  * @returns {Promise<UpdateChangelog>} A promise that resolves to the changelog content.
294
295
  */
295
296
  async UpdateChangelogGet(t) {
296
- return await M(this.apiClient, t);
297
+ return await Q(this.apiClient, t);
297
298
  }
298
299
  /**
299
300
  * Start firmware update installation.
@@ -304,7 +305,7 @@ class j {
304
305
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
305
306
  */
306
307
  async UpdateInstall(t) {
307
- return await N(this.apiClient, t);
308
+ return await Z(this.apiClient, t);
308
309
  }
309
310
  /**
310
311
  * Abort firmware update download.
@@ -314,7 +315,7 @@ class j {
314
315
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
315
316
  */
316
317
  async UpdateAbort(t) {
317
- return await q(this.apiClient, t);
318
+ return await tt(this.apiClient, t);
318
319
  }
319
320
  /**
320
321
  * Get current auto-update settings.
@@ -324,7 +325,7 @@ class j {
324
325
  * @returns {Promise<AutoUpdateSettings>} A promise that resolves to the current auto-update settings.
325
326
  */
326
327
  async UpdateAutoUpdateGet(t) {
327
- return await x(this.apiClient, t);
328
+ return await et(this.apiClient, t);
328
329
  }
329
330
  /**
330
331
  * Set auto-update settings.
@@ -337,56 +338,56 @@ class j {
337
338
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
338
339
  */
339
340
  async UpdateAutoUpdateSet(t) {
340
- return await V(this.apiClient, t);
341
+ return await it(this.apiClient, t);
341
342
  }
342
343
  }
343
- async function z(n, t) {
344
- const { data: i, error: e } = await s((r) => n.GET("/time", { signal: r }), t == null ? void 0 : t.timeout);
345
- if (e)
346
- throw e;
347
- return i;
344
+ async function nt(r, t) {
345
+ const { data: e, error: i } = await a((n) => r.GET("/time", { signal: n }), t == null ? void 0 : t.timeout);
346
+ if (i)
347
+ throw i;
348
+ return e;
348
349
  }
349
- async function H(n, t) {
350
- const { data: i, error: e } = await s(
351
- (r) => n.POST("/time/timestamp", {
350
+ async function st(r, t) {
351
+ const { timestamp: e } = t, { data: i, error: n } = await a(
352
+ (s) => r.POST("/time/timestamp", {
352
353
  params: {
353
- query: { ...t, timeout: void 0 }
354
+ query: { timestamp: e }
354
355
  },
355
- signal: r
356
+ signal: s
356
357
  }),
357
358
  t.timeout
358
359
  );
359
- if (e)
360
- throw e;
360
+ if (n)
361
+ throw n;
361
362
  return i;
362
363
  }
363
- async function J(n, t) {
364
- const { data: i, error: e } = await s((r) => n.GET("/time/timezone", { signal: r }), t == null ? void 0 : t.timeout);
365
- if (e)
366
- throw e;
367
- return i;
364
+ async function at(r, t) {
365
+ const { data: e, error: i } = await a((n) => r.GET("/time/timezone", { signal: n }), t == null ? void 0 : t.timeout);
366
+ if (i)
367
+ throw i;
368
+ return e;
368
369
  }
369
- async function X(n, t) {
370
- const { data: i, error: e } = await s(
371
- (r) => n.POST("/time/timezone", {
370
+ async function ot(r, t) {
371
+ const { timezone: e } = t, { data: i, error: n } = await a(
372
+ (s) => r.POST("/time/timezone", {
372
373
  params: {
373
- query: { ...t, timeout: void 0 }
374
+ query: { timezone: e }
374
375
  },
375
- signal: r
376
+ signal: s
376
377
  }),
377
378
  t.timeout
378
379
  );
379
- if (e)
380
- throw e;
380
+ if (n)
381
+ throw n;
381
382
  return i;
382
383
  }
383
- async function Y(n, t) {
384
- const { data: i, error: e } = await s((r) => n.GET("/time/tzlist", { signal: r }), t == null ? void 0 : t.timeout);
385
- if (e)
386
- throw e;
387
- return i;
384
+ async function ct(r, t) {
385
+ const { data: e, error: i } = await a((n) => r.GET("/time/tzlist", { signal: n }), t == null ? void 0 : t.timeout);
386
+ if (i)
387
+ throw i;
388
+ return e;
388
389
  }
389
- class Q {
390
+ class ut {
390
391
  /**
391
392
  * Get current timestamp info.
392
393
  *
@@ -395,7 +396,7 @@ class Q {
395
396
  * @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
396
397
  */
397
398
  async TimeGet(t) {
398
- return await z(this.apiClient, t);
399
+ return await nt(this.apiClient, t);
399
400
  }
400
401
  /**
401
402
  * Set system timestamp.
@@ -406,7 +407,7 @@ class Q {
406
407
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
407
408
  */
408
409
  async TimeTimestampSet(t) {
409
- return await H(this.apiClient, t);
410
+ return await st(this.apiClient, t);
410
411
  }
411
412
  /**
412
413
  * Get current timezone.
@@ -416,7 +417,7 @@ class Q {
416
417
  * @returns {Promise<TimezoneInfo>} A promise that resolves to the timezone information.
417
418
  */
418
419
  async TimeTimezoneGet(t) {
419
- return await J(this.apiClient, t);
420
+ return await at(this.apiClient, t);
420
421
  }
421
422
  /**
422
423
  * Set system timezone.
@@ -427,7 +428,7 @@ class Q {
427
428
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
428
429
  */
429
430
  async TimeTimezoneSet(t) {
430
- return await X(this.apiClient, t);
431
+ return await ot(this.apiClient, t);
431
432
  }
432
433
  /**
433
434
  * Get list of supported timezones.
@@ -437,56 +438,57 @@ class Q {
437
438
  * @returns {Promise<TimezoneList>} A promise that resolves to a list of timezone items.
438
439
  */
439
440
  async TimeTzListGet(t) {
440
- return await Y(this.apiClient, t);
441
+ return await ct(this.apiClient, t);
441
442
  }
442
443
  }
443
- async function Z(n, t) {
444
- const { data: i, error: e } = await s((r) => n.GET("/account/status", { signal: r }), t == null ? void 0 : t.timeout);
445
- if (e)
446
- throw e;
447
- return i;
444
+ async function ht(r, t) {
445
+ const { data: e, error: i } = await a((n) => r.GET("/account/status", { signal: n }), t == null ? void 0 : t.timeout);
446
+ if (i)
447
+ throw i;
448
+ return e;
448
449
  }
449
- async function tt(n, t) {
450
- const { data: i, error: e } = await s((r) => n.GET("/account/info", { signal: r }), t == null ? void 0 : t.timeout);
451
- if (e)
452
- throw e;
453
- return i;
450
+ async function lt(r, t) {
451
+ const { data: e, error: i } = await a((n) => r.GET("/account/info", { signal: n }), t == null ? void 0 : t.timeout);
452
+ if (i)
453
+ throw i;
454
+ return e;
454
455
  }
455
- async function et(n, t) {
456
- const { data: i, error: e } = await s((r) => n.GET("/account/profile", { signal: r }), t == null ? void 0 : t.timeout);
457
- if (e)
458
- throw e;
459
- return i;
456
+ async function dt(r, t) {
457
+ const { data: e, error: i } = await a((n) => r.GET("/account/profile", { signal: n }), t == null ? void 0 : t.timeout);
458
+ if (i)
459
+ throw i;
460
+ return e;
460
461
  }
461
- async function it(n, t) {
462
- const { profile: i } = t, { data: e, error: r } = await s(
463
- (o) => n.POST("/account/profile", {
462
+ async function ft(r, t) {
463
+ const { profile: e, custom_url: i } = t, { data: n, error: s } = await a(
464
+ (o) => r.POST("/account/profile", {
464
465
  params: {
465
466
  query: {
466
- profile: i
467
+ profile: e,
468
+ custom_url: i
467
469
  }
468
470
  },
469
471
  signal: o
470
472
  }),
471
473
  t.timeout
472
474
  );
473
- if (r)
474
- throw r;
475
+ if (s)
476
+ throw s;
477
+ return n;
478
+ }
479
+ async function wt(r, t) {
480
+ const { data: e, error: i } = await a((n) => r.DELETE("/account", { signal: n }), t == null ? void 0 : t.timeout);
481
+ if (i)
482
+ throw i;
475
483
  return e;
476
484
  }
477
- async function nt(n, t) {
478
- const { data: i, error: e } = await s((r) => n.DELETE("/account", { signal: r }), t == null ? void 0 : t.timeout);
479
- if (e)
480
- throw e;
481
- return i;
482
- }
483
- async function rt(n, t) {
484
- const { data: i, error: e } = await s((r) => n.POST("/account/link", { signal: r }), t == null ? void 0 : t.timeout);
485
- if (e)
486
- throw e;
487
- return i;
485
+ async function yt(r, t) {
486
+ const { data: e, error: i } = await a((n) => r.POST("/account/link", { signal: n }), t == null ? void 0 : t.timeout);
487
+ if (i)
488
+ throw i;
489
+ return e;
488
490
  }
489
- class ot {
491
+ class pt {
490
492
  /**
491
493
  * Get account info.
492
494
  *
@@ -495,17 +497,17 @@ class ot {
495
497
  * @returns {Promise<AccountInfo>} A promise that resolves to the account information.
496
498
  */
497
499
  async AccountInfoGet(t) {
498
- return await tt(this.apiClient, t);
500
+ return await lt(this.apiClient, t);
499
501
  }
500
502
  /**
501
503
  * Get account state.
502
504
  *
503
505
  * @param {TimeoutOptions} [params] - Optional parameters.
504
506
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
505
- * @returns {Promise<AccountState>} A promise that resolves to the account state.
507
+ * @returns {Promise<AccountStatus>} A promise that resolves to the account state.
506
508
  */
507
509
  async AccountStateGet(t) {
508
- return await Z(this.apiClient, t);
510
+ return await ht(this.apiClient, t);
509
511
  }
510
512
  /**
511
513
  * Get account profile.
@@ -515,18 +517,19 @@ class ot {
515
517
  * @returns {Promise<AccountProfile>} A promise that resolves to the account profile.
516
518
  */
517
519
  async AccountProfileGet(t) {
518
- return await et(this.apiClient, t);
520
+ return await dt(this.apiClient, t);
519
521
  }
520
522
  /**
521
523
  * Set account profile.
522
524
  *
523
525
  * @param {SetAccountProfileParams} params - Parameters for setting the account profile.
524
- * @param {string} params.profile - Profile data string.
526
+ * @param {string} params.profile - Profile name.
527
+ * @param {string} [params.custom_url] - Custom profile URL.
525
528
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
526
529
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
527
530
  */
528
531
  async AccountProfileSet(t) {
529
- return await it(this.apiClient, t);
532
+ return await ft(this.apiClient, t);
530
533
  }
531
534
  /**
532
535
  * Unlink device from account. Removes association with the current account.
@@ -536,7 +539,7 @@ class ot {
536
539
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful unlinking.
537
540
  */
538
541
  async AccountUnlink(t) {
539
- return await nt(this.apiClient, t);
542
+ return await wt(this.apiClient, t);
540
543
  }
541
544
  /**
542
545
  * Link device to account. Requests account link PIN. Works only if device is connected to MQTT and is not linked to account.
@@ -546,112 +549,123 @@ class ot {
546
549
  * @returns {Promise<AccountLink>} A promise that resolves to the link information (e.g., PIN).
547
550
  */
548
551
  async AccountLink(t) {
549
- return await rt(this.apiClient, t);
552
+ return await yt(this.apiClient, t);
550
553
  }
551
554
  }
552
- async function st(n, t) {
553
- const { appId: i, elements: e, priority: r = 6 } = t, { data: o, error: a } = await s(
554
- (u) => n.POST("/display/draw", {
555
+ async function mt(r, t) {
556
+ const { application_name: e, elements: i, priority: n = 50, timeout: s } = t, { data: o, error: h } = await a(
557
+ (c) => r.POST("/display/draw", {
555
558
  body: {
556
- app_id: i,
557
- priority: r,
558
- elements: e
559
+ application_name: e,
560
+ priority: n,
561
+ elements: i
559
562
  },
560
- signal: u
563
+ signal: c
561
564
  }),
562
- t.timeout
565
+ s
563
566
  );
564
- if (a)
565
- throw a;
567
+ if (h)
568
+ throw h;
566
569
  return o;
567
570
  }
568
- async function at(n, t) {
569
- const { data: i, error: e } = await s((r) => n.DELETE("/display/draw", { signal: r }), t == null ? void 0 : t.timeout);
570
- if (e)
571
- throw e;
572
- return i;
571
+ async function Tt(r, t) {
572
+ const { data: e, error: i } = await a(
573
+ (n) => r.DELETE("/display/draw", {
574
+ params: {
575
+ query: {
576
+ application_name: t == null ? void 0 : t.application_name
577
+ }
578
+ },
579
+ signal: n
580
+ }),
581
+ t == null ? void 0 : t.timeout
582
+ );
583
+ if (i)
584
+ throw i;
585
+ return e;
573
586
  }
574
- async function ct(n, t) {
575
- const { display: i } = t, { data: e, error: r } = await s(
576
- (o) => n.GET("/screen", {
587
+ async function Et(r, t) {
588
+ const { display: e, timeout: i } = t, { data: n, error: s } = await a(
589
+ (o) => r.GET("/screen", {
577
590
  params: {
578
591
  query: {
579
- display: i
592
+ display: e
580
593
  }
581
594
  },
582
595
  parseAs: "blob",
583
596
  signal: o
584
597
  }),
585
- t.timeout
598
+ i
586
599
  );
587
- if (r)
588
- throw r;
600
+ if (s)
601
+ throw s;
602
+ return n;
603
+ }
604
+ async function St(r, t) {
605
+ const { data: e, error: i } = await a((n) => r.GET("/display/brightness", { signal: n }), t == null ? void 0 : t.timeout);
606
+ if (i)
607
+ throw i;
589
608
  return e;
590
609
  }
591
- async function ut(n, t) {
592
- const { data: i, error: e } = await s((r) => n.GET("/display/brightness", { signal: r }), t == null ? void 0 : t.timeout);
593
- if (e)
594
- throw e;
595
- return i;
596
- }
597
- async function ht(n, t) {
598
- const { value: i } = t, r = ((u) => {
599
- if (typeof u == "number") {
600
- if (u < 0 || u > 100)
610
+ async function Ct(r, t) {
611
+ const { value: e } = t, n = ((h) => {
612
+ if (typeof h == "number") {
613
+ if (h < 0 || h > 100)
601
614
  throw new Error("Brightness value must be between 0 and 100 or 'auto'");
602
- return String(u);
615
+ return String(h);
603
616
  }
604
- if (u === "auto")
605
- return "auto";
606
- })(i), { data: o, error: a } = await s(
607
- (u) => n.POST("/display/brightness", {
617
+ return "auto";
618
+ })(e), { data: s, error: o } = await a(
619
+ (h) => r.POST("/display/brightness", {
608
620
  params: {
609
621
  query: {
610
- value: r
622
+ value: n
611
623
  }
612
624
  },
613
- signal: u
625
+ signal: h
614
626
  }),
615
627
  t.timeout
616
628
  );
617
- if (a)
618
- throw a;
619
- return o;
629
+ if (o)
630
+ throw o;
631
+ return s;
620
632
  }
621
- class dt {
633
+ class kt {
622
634
  /**
623
- * Draw on display. Starts the Canvas application if not running.
635
+ * Draw on display. Sends drawing data to the display. Supports JSON-defined display elements.
624
636
  *
625
637
  * @param {DrawParams} params - Parameters for the draw operation.
626
- * @param {DrawParams['appId']} params.appId - Application ID.
627
- * @param {DrawParams['elements']} params.elements - Display elements to draw.
628
- * @param {DrawParams['priority']} [params.priority=6] - Priority for the draw request (1-10).
638
+ * @param {string} params.application_name - Application ID for organizing assets.
639
+ * @param {Array} params.elements - Display elements to draw.
640
+ * @param {number} [params.priority=50] - Draw priority in the range [1, 100].
629
641
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
630
642
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
631
643
  */
632
644
  async DisplayDraw(t) {
633
- return await st(this.apiClient, t);
645
+ return await mt(this.apiClient, t);
634
646
  }
635
647
  /**
636
- * Clear display. Clears the display and stops the Canvas application if running.
648
+ * Clear display. Deletes display elements drawn by the Canvas application.
649
+ * If application_name is specified, only elements for that app are removed.
637
650
  *
638
- * @param {TimeoutOptions} [params] - Optional parameters.
651
+ * @param {ClearParams} [params] - Optional parameters.
652
+ * @param {string} [params.application_name] - Application identifier.
639
653
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
640
654
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
641
655
  */
642
656
  async DisplayClear(t) {
643
- return await at(this.apiClient, t);
657
+ return await Tt(this.apiClient, t);
644
658
  }
645
659
  /**
646
660
  * Get single frame for requested screen.
647
661
  *
648
662
  * @param {GetScreenFrameParams} params - Parameters for the frame request.
649
- * @param {string} params.display - Display identifier.
663
+ * @param {number} params.display - Type of the display (Front = 0, Back = 1).
650
664
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
651
665
  * @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
652
666
  */
653
667
  async DisplayScreenFrameGet(t) {
654
- return await ct(this.apiClient, t);
668
+ return await Et(this.apiClient, t);
655
669
  }
656
670
  /**
657
671
  * Get display brightness.
@@ -661,80 +675,80 @@ class dt {
661
675
  * @returns {Promise<DisplayBrightnessInfo>} A promise that resolves to the brightness information.
662
676
  */
663
677
  async DisplayBrightnessGet(t) {
664
- return await ut(this.apiClient, t);
678
+ return await St(this.apiClient, t);
665
679
  }
666
680
  /**
667
681
  * Set display brightness.
668
682
  *
669
- * @param {BrightnessParams} params - Brightness parameters:
670
- * @param {BrightnessParams['value']} [params.value] - Brightness (0-100 or "auto").
683
+ * @param {BrightnessParams} params - Brightness parameters.
684
+ * @param {number | 'auto'} params.value - Brightness (0-100 or "auto").
671
685
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
672
686
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
673
687
  */
674
688
  async DisplayBrightnessSet(t) {
675
- return await ht(this.apiClient, t);
689
+ return await Ct(this.apiClient, t);
676
690
  }
677
691
  }
678
- async function ft(n, t) {
679
- const { appId: i, path: e } = t, { data: r, error: o } = await s(
680
- (a) => n.POST("/audio/play", {
692
+ async function gt(r, t) {
693
+ const { application_name: e, path: i } = t, { data: n, error: s } = await a(
694
+ (o) => r.POST("/audio/play", {
681
695
  params: {
682
696
  query: {
683
- app_id: i,
684
- path: e
697
+ application_name: e,
698
+ path: i
685
699
  }
686
700
  },
687
- signal: a
701
+ signal: o
688
702
  }),
689
703
  t.timeout
690
704
  );
691
- if (o)
692
- throw o;
693
- return r;
694
- }
695
- async function wt(n, t) {
696
- const { data: i, error: e } = await s((r) => n.DELETE("/audio/play", { signal: r }), t == null ? void 0 : t.timeout);
697
- if (e)
698
- throw e;
699
- return i;
705
+ if (s)
706
+ throw s;
707
+ return n;
708
+ }
709
+ async function At(r, t) {
710
+ const { data: e, error: i } = await a((n) => r.DELETE("/audio/play", { signal: n }), t == null ? void 0 : t.timeout);
711
+ if (i)
712
+ throw i;
713
+ return e;
700
714
  }
701
- async function lt(n, t) {
702
- const { data: i, error: e } = await s((r) => n.GET("/audio/volume", { signal: r }), t == null ? void 0 : t.timeout);
703
- if (e)
704
- throw e;
705
- return i;
715
+ async function bt(r, t) {
716
+ const { data: e, error: i } = await a((n) => r.GET("/audio/volume", { signal: n }), t == null ? void 0 : t.timeout);
717
+ if (i)
718
+ throw i;
719
+ return e;
706
720
  }
707
- async function yt(n, t) {
708
- const { volume: i } = t;
709
- if (typeof i != "number" || i < 0 || i > 100)
721
+ async function _t(r, t) {
722
+ const { volume: e } = t;
723
+ if (typeof e != "number" || e < 0 || e > 100)
710
724
  throw new Error("Volume must be a number between 0 and 100");
711
- const { data: e, error: r } = await s(
712
- (o) => n.POST("/audio/volume", {
725
+ const { data: i, error: n } = await a(
726
+ (s) => r.POST("/audio/volume", {
713
727
  params: {
714
728
  query: {
715
- volume: i
729
+ volume: e
716
730
  }
717
731
  },
718
- signal: o
732
+ signal: s
719
733
  }),
720
734
  t.timeout
721
735
  );
722
- if (r)
723
- throw r;
724
- return e;
736
+ if (n)
737
+ throw n;
738
+ return i;
725
739
  }
726
- class pt {
740
+ class Rt {
727
741
  /**
728
742
  * Play audio file. Plays a file from internal storage.
729
743
  *
730
744
  * @param {AudioPlayParams} params - Parameters for audio playback.
731
- * @param {string} params.appId - Application ID.
745
+ * @param {string} params.application_name - Application name.
732
746
  * @param {string} params.path - Path to the audio file.
733
747
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
734
748
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
735
749
  */
736
750
  async AudioPlay(t) {
737
- return await ft(this.apiClient, t);
751
+ return await gt(this.apiClient, t);
738
752
  }
739
753
  /**
740
754
  * Stop audio playback. Stops any currently playing audio.
@@ -744,7 +758,7 @@ class pt {
744
758
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
745
759
  */
746
760
  async AudioStop(t) {
747
- return await wt(this.apiClient, t);
761
+ return await At(this.apiClient, t);
748
762
  }
749
763
  /**
750
764
  * Get audio volume.
@@ -754,7 +768,7 @@ class pt {
754
768
  * @returns {Promise<AudioVolumeInfo>} A promise that resolves to the audio volume information.
755
769
  */
756
770
  async AudioVolumeGet(t) {
757
- return await lt(this.apiClient, t);
771
+ return await bt(this.apiClient, t);
758
772
  }
759
773
  /**
760
774
  * Set audio volume.
@@ -765,50 +779,45 @@ class pt {
765
779
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
766
780
  */
767
781
  async AudioVolumeSet(t) {
768
- return await yt(this.apiClient, t);
782
+ return await _t(this.apiClient, t);
769
783
  }
770
784
  }
771
- async function St(n, t) {
772
- const { data: i, error: e } = await s((r) => n.GET("/wifi/status", { signal: r }), t == null ? void 0 : t.timeout);
773
- if (e)
774
- throw e;
775
- return i;
785
+ async function Dt(r, t) {
786
+ const { data: e, error: i } = await a((n) => r.GET("/wifi/status", { signal: n }), t == null ? void 0 : t.timeout);
787
+ if (i)
788
+ throw i;
789
+ return e;
776
790
  }
777
- async function Tt(n, t) {
778
- const { data: i, error: e } = await s(
779
- (r) => n.POST("/wifi/connect", {
791
+ async function vt(r, t) {
792
+ const { ssid: e, password: i, security: n, ip_config: s } = t, { data: o, error: h } = await a(
793
+ (c) => r.POST("/wifi/connect", {
780
794
  body: {
781
- ssid: t.ssid,
782
- password: t.password,
783
- security: t.security,
784
- ip_config: {
785
- ip_method: t.ipConfig.ipMethod,
786
- address: t.ipConfig.address,
787
- mask: t.ipConfig.mask,
788
- gateway: t.ipConfig.gateway
789
- }
795
+ ssid: e,
796
+ password: i,
797
+ security: n,
798
+ ip_config: s
790
799
  },
791
- signal: r
800
+ signal: c
792
801
  }),
793
802
  t.timeout
794
803
  );
795
- if (e)
796
- throw e;
797
- return i;
804
+ if (h)
805
+ throw h;
806
+ return o;
798
807
  }
799
- async function Et(n, t) {
800
- const { data: i, error: e } = await s((r) => n.POST("/wifi/disconnect", { signal: r }), t == null ? void 0 : t.timeout);
801
- if (e)
802
- throw e;
803
- return i;
808
+ async function Pt(r, t) {
809
+ const { data: e, error: i } = await a((n) => r.POST("/wifi/disconnect", { signal: n }), t == null ? void 0 : t.timeout);
810
+ if (i)
811
+ throw i;
812
+ return e;
804
813
  }
805
- async function mt(n, t) {
806
- const { data: i, error: e } = await s((r) => n.GET("/wifi/networks", { signal: r }), t == null ? void 0 : t.timeout);
807
- if (e)
808
- throw e;
809
- return i;
814
+ async function Ot(r, t) {
815
+ const { data: e, error: i } = await a((n) => r.GET("/wifi/networks", { signal: n }), t == null ? void 0 : t.timeout);
816
+ if (i)
817
+ throw i;
818
+ return e;
810
819
  }
811
- class Ct {
820
+ class Ut {
812
821
  /**
813
822
  * Returns current Wi-Fi status.
814
823
  *
@@ -817,7 +826,7 @@ class Ct {
817
826
  * @returns {Promise<WifiStatusResponse>} A promise that resolves to the Wi-Fi status.
818
827
  */
819
828
  async WifiStatusGet(t) {
820
- return await St(this.apiClient, t);
829
+ return await Dt(this.apiClient, t);
821
830
  }
822
831
  /**
823
832
  * Connects to Wi-Fi network.
@@ -826,12 +835,12 @@ class Ct {
826
835
  * @param {string} params.ssid - Network SSID.
827
836
  * @param {string} params.password - Network password.
828
837
  * @param {WifiSecurityMethod} params.security - Security method.
829
- * @param {object} params.ipConfig - IP configuration.
838
+ * @param {object} [params.ip_config] - IP configuration.
830
839
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
831
840
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
832
841
  */
833
842
  async WifiConnect(t) {
834
- return await Tt(this.apiClient, t);
843
+ return await vt(this.apiClient, t);
835
844
  }
836
845
  /**
837
846
  * Disconnects from Wi-Fi.
@@ -841,7 +850,7 @@ class Ct {
841
850
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
842
851
  */
843
852
  async WifiDisconnect(t) {
844
- return await Et(this.apiClient, t);
853
+ return await Pt(this.apiClient, t);
845
854
  }
846
855
  /**
847
856
  * Scans environment for available Wi-Fi networks.
@@ -851,118 +860,118 @@ class Ct {
851
860
  * @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
852
861
  */
853
862
  async WifiNetworksGet(t) {
854
- return await mt(this.apiClient, t);
863
+ return await Ot(this.apiClient, t);
855
864
  }
856
865
  }
857
- async function kt(n, t) {
858
- const { path: i, file: e } = t, { data: r, error: o } = await s(
859
- (a) => n.POST("/storage/write", {
866
+ async function It(r, t) {
867
+ const { path: e, file: i } = t, { data: n, error: s } = await a(
868
+ (o) => r.POST("/storage/write", {
860
869
  params: {
861
870
  query: {
862
- path: i
871
+ path: e
863
872
  }
864
873
  },
865
874
  headers: {
866
875
  "Content-Type": "application/octet-stream"
867
876
  },
868
- body: e,
869
- signal: a
877
+ body: i,
878
+ signal: o
870
879
  }),
871
880
  t.timeout
872
881
  );
873
- if (o)
874
- throw o;
875
- return r;
882
+ if (s)
883
+ throw s;
884
+ return n;
876
885
  }
877
- async function gt(n, t) {
878
- const { path: i, asArrayBuffer: e } = t, { data: r, error: o } = await s(
879
- (a) => n.GET("/storage/read", {
886
+ async function Lt(r, t) {
887
+ const { path: e, as_array_buffer: i } = t, { data: n, error: s } = await a(
888
+ (o) => r.GET("/storage/read", {
880
889
  params: {
881
890
  query: {
882
- path: i
891
+ path: e
883
892
  }
884
893
  },
885
- parseAs: e ? "arrayBuffer" : "blob",
886
- signal: a
894
+ parseAs: i ? "arrayBuffer" : "blob",
895
+ signal: o
887
896
  }),
888
897
  t.timeout
889
898
  );
890
- if (o)
891
- throw o;
892
- return r;
899
+ if (s)
900
+ throw s;
901
+ return n;
893
902
  }
894
- async function At(n, t) {
895
- const { path: i } = t, { data: e, error: r } = await s(
896
- (o) => n.GET("/storage/list", {
903
+ async function Nt(r, t) {
904
+ const { path: e } = t, { data: i, error: n } = await a(
905
+ (s) => r.GET("/storage/list", {
897
906
  params: {
898
907
  query: {
899
- path: i
908
+ path: e
900
909
  }
901
910
  },
902
- signal: o
911
+ signal: s
903
912
  }),
904
913
  t.timeout
905
914
  );
906
- if (r)
907
- throw r;
908
- return e;
915
+ if (n)
916
+ throw n;
917
+ return i;
909
918
  }
910
- async function bt(n, t) {
911
- const { path: i } = t, { data: e, error: r } = await s(
912
- (o) => n.DELETE("/storage/remove", {
919
+ async function Gt(r, t) {
920
+ const { path: e } = t, { data: i, error: n } = await a(
921
+ (s) => r.DELETE("/storage/remove", {
913
922
  params: {
914
923
  query: {
915
- path: i
924
+ path: e
916
925
  }
917
926
  },
918
- signal: o
927
+ signal: s
919
928
  }),
920
929
  t.timeout
921
930
  );
922
- if (r)
923
- throw r;
924
- return e;
931
+ if (n)
932
+ throw n;
933
+ return i;
925
934
  }
926
- async function vt(n, t) {
927
- const { path: i } = t, { data: e, error: r } = await s(
928
- (o) => n.POST("/storage/mkdir", {
935
+ async function xt(r, t) {
936
+ const { path: e } = t, { data: i, error: n } = await a(
937
+ (s) => r.POST("/storage/mkdir", {
929
938
  params: {
930
939
  query: {
931
- path: i
940
+ path: e
932
941
  }
933
942
  },
934
- signal: o
943
+ signal: s
935
944
  }),
936
945
  t.timeout
937
946
  );
938
- if (r)
939
- throw r;
940
- return e;
941
- }
942
- async function Gt(n, t) {
943
- const { data: i, error: e } = await s((r) => n.GET("/storage/status", { signal: r }), t == null ? void 0 : t.timeout);
944
- if (e)
945
- throw e;
947
+ if (n)
948
+ throw n;
946
949
  return i;
947
950
  }
948
- async function Pt(n, t) {
949
- const { path: i, new_path: e } = t, { data: r, error: o } = await s(
950
- (a) => n.POST("/storage/rename", {
951
+ async function Bt(r, t) {
952
+ const { data: e, error: i } = await a((n) => r.GET("/storage/status", { signal: n }), t == null ? void 0 : t.timeout);
953
+ if (i)
954
+ throw i;
955
+ return e;
956
+ }
957
+ async function Ft(r, t) {
958
+ const { path: e, new_path: i } = t, { data: n, error: s } = await a(
959
+ (o) => r.POST("/storage/rename", {
951
960
  params: {
952
961
  query: {
953
- path: i,
954
- new_path: e
962
+ path: e,
963
+ new_path: i
955
964
  }
956
965
  },
957
- signal: a
966
+ signal: o
958
967
  }),
959
968
  t.timeout
960
969
  );
961
- if (o)
962
- throw o;
963
- return r;
970
+ if (s)
971
+ throw s;
972
+ return n;
964
973
  }
965
- class Lt {
974
+ class Wt {
966
975
  /**
967
976
  * Upload file to internal storage. Uploads a file to a specified path.
968
977
  *
@@ -973,19 +982,19 @@ class Lt {
973
982
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful upload.
974
983
  */
975
984
  async StorageWrite(t) {
976
- return await kt(this.apiClient, t);
985
+ return await It(this.apiClient, t);
977
986
  }
978
987
  /**
979
988
  * Download file from internal storage. Downloads a file from a specified path.
980
989
  *
981
990
  * @param {DownloadFileParams} params - Download parameters:
982
991
  * @param {string} params.path - Path to the file.
983
- * @param {boolean} [params.asArrayBuffer] - Whether to return ArrayBuffer instead of Blob.
992
+ * @param {boolean} [params.as_array_buffer] - Whether to return ArrayBuffer instead of Blob.
984
993
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
985
994
  * @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
986
995
  */
987
996
  async StorageRead(t) {
988
- return await gt(this.apiClient, t);
997
+ return await Lt(this.apiClient, t);
989
998
  }
990
999
  /**
991
1000
  * List files on internal storage.
@@ -996,7 +1005,7 @@ class Lt {
996
1005
  * @returns {Promise<StorageList>} A promise that resolves to a list of files and directories.
997
1006
  */
998
1007
  async StorageListGet(t) {
999
- return await At(this.apiClient, t);
1008
+ return await Nt(this.apiClient, t);
1000
1009
  }
1001
1010
  /**
1002
1011
  * Remove a file on internal storage. Removes a file with a specified path.
@@ -1007,7 +1016,7 @@ class Lt {
1007
1016
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful removal.
1008
1017
  */
1009
1018
  async StorageRemove(t) {
1010
- return await bt(this.apiClient, t);
1019
+ return await Gt(this.apiClient, t);
1011
1020
  }
1012
1021
  /**
1013
1022
  * Create a directory on internal storage. Creates a new directory with a specified path.
@@ -1018,7 +1027,7 @@ class Lt {
1018
1027
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
1019
1028
  */
1020
1029
  async StorageMkdir(t) {
1021
- return await vt(this.apiClient, t);
1030
+ return await xt(this.apiClient, t);
1022
1031
  }
1023
1032
  /**
1024
1033
  * Show storage usage.
@@ -1028,7 +1037,7 @@ class Lt {
1028
1037
  * @returns {Promise<StorageStatus>} A promise that resolves to the storage status.
1029
1038
  */
1030
1039
  async StorageStatusGet(t) {
1031
- return await Gt(this.apiClient, t);
1040
+ return await Bt(this.apiClient, t);
1032
1041
  }
1033
1042
  /**
1034
1043
  * Rename/move a file. Moves a file to a new location.
@@ -1040,54 +1049,54 @@ class Lt {
1040
1049
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
1041
1050
  */
1042
1051
  async StorageRename(t) {
1043
- return await Pt(this.apiClient, t);
1052
+ return await Ft(this.apiClient, t);
1044
1053
  }
1045
1054
  }
1046
- async function Ot(n, t) {
1047
- const { data: i, error: e } = await s((r) => n.GET("/access", { signal: r }), t == null ? void 0 : t.timeout);
1048
- if (e)
1049
- throw e;
1050
- return i;
1055
+ async function Mt(r, t) {
1056
+ const { data: e, error: i } = await a((n) => r.GET("/access", { signal: n }), t == null ? void 0 : t.timeout);
1057
+ if (i)
1058
+ throw i;
1059
+ return e;
1051
1060
  }
1052
- async function Dt(n, t) {
1053
- let { mode: i, key: e } = t;
1054
- if (e = e ?? "", String(e).trim() && !/^\d{4,10}$/.test(String(e)))
1061
+ async function $t(r, t) {
1062
+ const { mode: e, key: i } = t, n = i ?? "";
1063
+ if (String(n).trim() && !/^\d{4,10}$/.test(String(n)))
1055
1064
  throw new Error("Key must be a string of 4 to 10 digits");
1056
- const { data: r, error: o } = await s(
1057
- (a) => n.POST("/access", {
1065
+ const { data: s, error: o } = await a(
1066
+ (h) => r.POST("/access", {
1058
1067
  params: {
1059
1068
  query: {
1060
- mode: i,
1061
- key: e
1069
+ mode: e,
1070
+ key: n
1062
1071
  }
1063
1072
  },
1064
- signal: a
1073
+ signal: h
1065
1074
  }),
1066
1075
  t.timeout
1067
1076
  );
1068
1077
  if (o)
1069
1078
  throw o;
1070
- return r;
1079
+ return s;
1071
1080
  }
1072
- async function Ut(n, t) {
1073
- const { data: i, error: e } = await s((r) => n.GET("/name", { signal: r }), t == null ? void 0 : t.timeout);
1074
- if (e)
1075
- throw e;
1076
- return i;
1081
+ async function Kt(r, t) {
1082
+ const { data: e, error: i } = await a((n) => r.GET("/name", { signal: n }), t == null ? void 0 : t.timeout);
1083
+ if (i)
1084
+ throw i;
1085
+ return e;
1077
1086
  }
1078
- async function Bt(n, t) {
1079
- const { data: i, error: e } = await s(
1080
- (r) => n.POST("/name", {
1081
- body: t,
1082
- signal: r
1087
+ async function zt(r, t) {
1088
+ const { name: e } = t, { data: i, error: n } = await a(
1089
+ (s) => r.POST("/name", {
1090
+ body: { name: e },
1091
+ signal: s
1083
1092
  }),
1084
1093
  t.timeout
1085
1094
  );
1086
- if (e)
1087
- throw e;
1095
+ if (n)
1096
+ throw n;
1088
1097
  return i;
1089
1098
  }
1090
- class It {
1099
+ class Ht {
1091
1100
  /**
1092
1101
  * Get HTTP API access over Wi-Fi configuration.
1093
1102
  *
@@ -1096,20 +1105,20 @@ class It {
1096
1105
  * @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
1097
1106
  */
1098
1107
  async SettingsAccessGet(t) {
1099
- return await Ot(this.apiClient, t);
1108
+ return await Mt(this.apiClient, t);
1100
1109
  }
1101
1110
  /**
1102
1111
  * Set HTTP API access over Wi-Fi configuration.
1103
1112
  *
1104
1113
  * @param {HttpAccessParams} params - Access parameters:
1105
1114
  * @param {boolean} params.mode - Enable/disable access.
1106
- * @param {string} params.key - Access key (4-10 digits).
1115
+ * @param {string} [params.key] - Access key (4-10 digits).
1107
1116
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1108
1117
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1109
1118
  */
1110
1119
  async SettingsAccessSet(t) {
1111
- const i = await Dt(this.apiClient, t);
1112
- return t.mode === "key" && t.key && this.setApiKey(t.key), i;
1120
+ const e = await $t(this.apiClient, t);
1121
+ return t.mode === "key" && t.key && this.setApiKey(t.key), e;
1113
1122
  }
1114
1123
  /**
1115
1124
  * Get current device name.
@@ -1119,7 +1128,7 @@ class It {
1119
1128
  * @returns {Promise<NameInfo>} A promise that resolves to the device name.
1120
1129
  */
1121
1130
  async SettingsNameGet(t) {
1122
- return await Ut(this.apiClient, t);
1131
+ return await Kt(this.apiClient, t);
1123
1132
  }
1124
1133
  /**
1125
1134
  * Set device name.
@@ -1130,34 +1139,34 @@ class It {
1130
1139
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1131
1140
  */
1132
1141
  async SettingsNameSet(t) {
1133
- return await Bt(this.apiClient, t);
1142
+ return await zt(this.apiClient, t);
1134
1143
  }
1135
1144
  }
1136
- async function $t(n, t) {
1137
- const { data: i, error: e } = await s((r) => n.POST("/ble/enable", { signal: r }), t == null ? void 0 : t.timeout);
1138
- if (e)
1139
- throw e;
1140
- return i;
1145
+ async function qt(r, t) {
1146
+ const { data: e, error: i } = await a((n) => r.POST("/ble/enable", { signal: n }), t == null ? void 0 : t.timeout);
1147
+ if (i)
1148
+ throw i;
1149
+ return e;
1141
1150
  }
1142
- async function Rt(n, t) {
1143
- const { data: i, error: e } = await s((r) => n.POST("/ble/disable", { signal: r }), t == null ? void 0 : t.timeout);
1144
- if (e)
1145
- throw e;
1146
- return i;
1151
+ async function Vt(r, t) {
1152
+ const { data: e, error: i } = await a((n) => r.POST("/ble/disable", { signal: n }), t == null ? void 0 : t.timeout);
1153
+ if (i)
1154
+ throw i;
1155
+ return e;
1147
1156
  }
1148
- async function Kt(n, t) {
1149
- const { data: i, error: e } = await s((r) => n.DELETE("/ble/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1150
- if (e)
1151
- throw e;
1152
- return i;
1157
+ async function Xt(r, t) {
1158
+ const { data: e, error: i } = await a((n) => r.DELETE("/ble/pairing", { signal: n }), t == null ? void 0 : t.timeout);
1159
+ if (i)
1160
+ throw i;
1161
+ return e;
1153
1162
  }
1154
- async function Ft(n, t) {
1155
- const { data: i, error: e } = await s((r) => n.GET("/ble/status", { signal: r }), t == null ? void 0 : t.timeout);
1156
- if (e)
1157
- throw e;
1158
- return i;
1163
+ async function jt(r, t) {
1164
+ const { data: e, error: i } = await a((n) => r.GET("/ble/status", { signal: n }), t == null ? void 0 : t.timeout);
1165
+ if (i)
1166
+ throw i;
1167
+ return e;
1159
1168
  }
1160
- class _t {
1169
+ class Yt {
1161
1170
  /**
1162
1171
  * Enable BLE. Starts advertising.
1163
1172
  *
@@ -1166,7 +1175,7 @@ class _t {
1166
1175
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1167
1176
  */
1168
1177
  async BleEnable(t) {
1169
- return await $t(this.apiClient, t);
1178
+ return await qt(this.apiClient, t);
1170
1179
  }
1171
1180
  /**
1172
1181
  * Disable BLE. Stops advertising.
@@ -1176,7 +1185,7 @@ class _t {
1176
1185
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1177
1186
  */
1178
1187
  async BleDisable(t) {
1179
- return await Rt(this.apiClient, t);
1188
+ return await Vt(this.apiClient, t);
1180
1189
  }
1181
1190
  /**
1182
1191
  * Remove pairing. Remove pairing with previous device.
@@ -1186,7 +1195,7 @@ class _t {
1186
1195
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1187
1196
  */
1188
1197
  async BleUnpair(t) {
1189
- return await Kt(this.apiClient, t);
1198
+ return await Xt(this.apiClient, t);
1190
1199
  }
1191
1200
  /**
1192
1201
  * Returns current BLE status.
@@ -1196,169 +1205,218 @@ class _t {
1196
1205
  * @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
1197
1206
  */
1198
1207
  async BleStatusGet(t) {
1199
- return await Ft(this.apiClient, t);
1208
+ return await jt(this.apiClient, t);
1200
1209
  }
1201
1210
  }
1202
- async function Wt(n, t) {
1203
- const { keyName: i } = t, { data: e, error: r } = await s(
1204
- (o) => n.POST("/input", {
1211
+ async function Jt(r, t) {
1212
+ const { key: e } = t, { data: i, error: n } = await a(
1213
+ (s) => r.POST("/input", {
1205
1214
  params: {
1206
1215
  query: {
1207
- key: i
1216
+ key: e
1208
1217
  }
1209
1218
  },
1210
- signal: o
1219
+ signal: s
1211
1220
  }),
1212
1221
  t.timeout
1213
1222
  );
1214
- if (r)
1215
- throw r;
1216
- return e;
1223
+ if (n)
1224
+ throw n;
1225
+ return i;
1217
1226
  }
1218
- class Mt {
1227
+ class Qt {
1219
1228
  /**
1220
1229
  * Send input event. Send single key press event.
1221
1230
  *
1222
1231
  * @param {InputKeyParams} params - Button press parameters:
1223
- * @param {KeyName} params.keyName - Name of the key to press.
1232
+ * @param {KeyName} params.key - Key name.
1224
1233
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1225
1234
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1226
1235
  */
1227
1236
  async InputSend(t) {
1228
- return await Wt(this.apiClient, t);
1237
+ return await Jt(this.apiClient, t);
1229
1238
  }
1230
1239
  }
1231
- async function Nt(n, t) {
1232
- const { data: i, error: e } = await s((r) => n.GET("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1233
- if (e)
1234
- throw e;
1235
- return i;
1240
+ async function Zt(r, t) {
1241
+ const { data: e, error: i } = await a((n) => r.GET("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
1242
+ if (i)
1243
+ throw i;
1244
+ return e;
1236
1245
  }
1237
- async function qt(n, t) {
1238
- const { data: i, error: e } = await s((r) => n.POST("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1239
- if (e)
1240
- throw e;
1241
- return i;
1246
+ async function te(r, t) {
1247
+ const { data: e, error: i } = await a((n) => r.POST("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
1248
+ if (i)
1249
+ throw i;
1250
+ return e;
1242
1251
  }
1243
- async function xt(n, t) {
1244
- const { data: i, error: e } = await s((r) => n.DELETE("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1245
- if (e)
1246
- throw e;
1247
- return i;
1252
+ async function ee(r, t) {
1253
+ const { data: e, error: i } = await a((n) => r.DELETE("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
1254
+ if (i)
1255
+ throw i;
1256
+ return e;
1257
+ }
1258
+ async function ie(r, t) {
1259
+ const { data: e, error: i } = await a((n) => r.GET("/smart_home/switch", { signal: n }), t == null ? void 0 : t.timeout);
1260
+ if (i)
1261
+ throw i;
1262
+ return e;
1248
1263
  }
1249
- class Vt {
1264
+ async function re(r, t) {
1265
+ const { timeout: e, ...i } = t, { data: n, error: s } = await a((o) => r.POST("/smart_home/switch", { body: i, signal: o }), e);
1266
+ if (s)
1267
+ throw s;
1268
+ return n;
1269
+ }
1270
+ class ne {
1250
1271
  /**
1251
- * Get Matter status.
1272
+ * Smart home commissioning status.
1252
1273
  *
1253
1274
  * @param {TimeoutOptions} [params] - Optional parameters.
1254
1275
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1255
- * @returns {Promise<MatterStatus>} A promise that resolves to the Matter status.
1276
+ * @returns {Promise<SmartHomePairingInfo>} A promise that resolves to the pairing info.
1256
1277
  */
1257
- async MatterStatusGet(t) {
1258
- return await Nt(this.apiClient, t);
1278
+ async SmartHomePairingGet(t) {
1279
+ return await Zt(this.apiClient, t);
1280
+ }
1281
+ /**
1282
+ * Link device to a smart home.
1283
+ *
1284
+ * @param {TimeoutOptions} [params] - Optional timeout.
1285
+ * @returns {Promise<SmartHomePairingPayload>} A promise that resolves to the pairing payload.
1286
+ */
1287
+ async SmartHomePair(t) {
1288
+ return await te(this.apiClient, t);
1259
1289
  }
1260
1290
  /**
1261
- * Pair Matter device.
1291
+ * Erase all smart home links.
1262
1292
  *
1263
1293
  * @param {TimeoutOptions} [params] - Optional parameters.
1264
1294
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1265
- * @returns {Promise<MatterPairingInfo>} A promise that resolves on success.
1295
+ * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1266
1296
  */
1267
- async MatterPair(t) {
1268
- return await qt(this.apiClient, t);
1297
+ async SmartHomeErase(t) {
1298
+ return await ee(this.apiClient, t);
1269
1299
  }
1270
1300
  /**
1271
- * Erase Matter devices.
1301
+ * Get state of emulated smart home switch.
1272
1302
  *
1273
1303
  * @param {TimeoutOptions} [params] - Optional parameters.
1274
1304
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1305
+ * @returns {Promise<SmartHomeSwitchState>} A promise that resolves to the switch state.
1306
+ */
1307
+ async SmartHomeSwitchStateGet(t) {
1308
+ return await ie(this.apiClient, t);
1309
+ }
1310
+ /**
1311
+ * Set state of emulated smart home switch.
1312
+ *
1313
+ * @param {SmartHomeSwitchState & TimeoutOptions} params - Switch state and optional timeout.
1275
1314
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1276
1315
  */
1316
+ async SmartHomeSwitchStateSet(t) {
1317
+ return await re(this.apiClient, t);
1318
+ }
1319
+ // ALIASES for backward compatibility (Matter -> SmartHome)
1320
+ /**
1321
+ * @deprecated Use SmartHomePairingGet instead.
1322
+ */
1323
+ async MatterStatusGet(t) {
1324
+ return await this.SmartHomePairingGet(t);
1325
+ }
1326
+ /**
1327
+ * @deprecated Use SmartHomePair instead.
1328
+ */
1329
+ async MatterPair(t) {
1330
+ return await this.SmartHomePair(t);
1331
+ }
1332
+ /**
1333
+ * @deprecated Use SmartHomeErase instead.
1334
+ */
1277
1335
  async MatterErase(t) {
1278
- return await xt(this.apiClient, t);
1336
+ return await this.SmartHomeErase(t);
1279
1337
  }
1280
1338
  }
1281
- async function jt(n, t) {
1282
- const { appId: i, fileName: e, file: r } = t, { data: o, error: a } = await s(
1283
- (u) => n.POST("/assets/upload", {
1339
+ async function se(r, t) {
1340
+ const { application_name: e, file: i, data: n } = t, { data: s, error: o } = await a(
1341
+ (h) => r.POST("/assets/upload", {
1284
1342
  params: {
1285
1343
  query: {
1286
- app_id: i,
1287
- file: e
1344
+ application_name: e,
1345
+ file: i
1288
1346
  }
1289
1347
  },
1290
1348
  headers: {
1291
1349
  "Content-Type": "application/octet-stream"
1292
1350
  },
1293
- body: r,
1294
- signal: u
1351
+ body: n,
1352
+ signal: h
1295
1353
  }),
1296
1354
  t.timeout
1297
1355
  );
1298
- if (a)
1299
- throw a;
1300
- return o;
1356
+ if (o)
1357
+ throw o;
1358
+ return s;
1301
1359
  }
1302
- async function zt(n, t) {
1303
- const { appId: i } = t, { data: e, error: r } = await s(
1304
- (o) => n.DELETE("/assets/upload", {
1360
+ async function ae(r, t) {
1361
+ const { application_name: e } = t, { data: i, error: n } = await a(
1362
+ (s) => r.DELETE("/assets/upload", {
1305
1363
  params: {
1306
1364
  query: {
1307
- app_id: i
1365
+ application_name: e
1308
1366
  }
1309
1367
  },
1310
- signal: o
1368
+ signal: s
1311
1369
  }),
1312
1370
  t.timeout
1313
1371
  );
1314
- if (r)
1315
- throw r;
1316
- return e;
1372
+ if (n)
1373
+ throw n;
1374
+ return i;
1317
1375
  }
1318
- class Ht {
1376
+ class oe {
1319
1377
  /**
1320
1378
  * Upload asset file with app ID. Uploads a file to a specific app's assets directory.
1321
1379
  *
1322
1380
  * @param {UploadParams} params - Parameters for the upload.
1323
- * @param {UploadParams['appId']} params.appId - Application ID for organizing assets.
1324
- * @param {UploadParams['fileName']} params.fileName - Filename for the uploaded asset.
1325
- * @param {UploadParams['file']} params.file - File data to upload.
1326
- * @param {UploadParams['timeout']} [params.timeout] - Request timeout in milliseconds.
1381
+ * @param {string} params.application_name - Application name for organizing assets.
1382
+ * @param {string} params.file - Filename for the uploaded asset.
1383
+ * @param {BusyFile} params.data - File data to upload.
1384
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1327
1385
  * @returns {Promise<SuccessResponse>} Result of the upload operation.
1328
1386
  */
1329
1387
  async AssetsUpload(t) {
1330
- return await jt(this.apiClient, t);
1388
+ return await se(this.apiClient, t);
1331
1389
  }
1332
1390
  /**
1333
1391
  * Delete app assets. Deletes all assets for a specific app ID.
1334
1392
  *
1335
1393
  * @param {DeleteParams} params - Parameters for the delete.
1336
- * @param {DeleteParams['appId']} params.appId - Application ID whose assets should be deleted.
1337
- * @param {DeleteParams['timeout']} [params.timeout] - Request timeout in milliseconds.
1394
+ * @param {string} params.application_name - Application name whose assets should be deleted.
1395
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1338
1396
  * @returns {Promise<SuccessResponse>} Result of the delete operation.
1339
1397
  */
1340
1398
  async AssetsDelete(t) {
1341
- return await zt(this.apiClient, t);
1399
+ return await ae(this.apiClient, t);
1342
1400
  }
1343
1401
  }
1344
- const S = "http://10.0.4.20", Jt = "https://proxy.busy.app", Xt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
1345
- function T(n) {
1346
- const t = n.split(".");
1402
+ const D = "http://10.0.4.20", ce = "https://proxy.busy.app", ue = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
1403
+ function v(r) {
1404
+ const t = r.split(".");
1347
1405
  if (t.length !== 4)
1348
1406
  return !1;
1349
- for (const i of t) {
1350
- if (i.length === 0 || i.length > 1 && i[0] === "0" || !/^\d+$/.test(i))
1407
+ for (const e of t) {
1408
+ if (e.length === 0 || e.length > 1 && e[0] === "0" || !/^\d+$/.test(e))
1351
1409
  return !1;
1352
- const e = Number(i);
1353
- if (e < 0 || e > 255)
1410
+ const i = Number(e);
1411
+ if (i < 0 || i > 255)
1354
1412
  return !1;
1355
1413
  }
1356
1414
  return !0;
1357
1415
  }
1358
- function E(n) {
1359
- return /\.local$/i.test(n);
1416
+ function P(r) {
1417
+ return /\.local$/i.test(r);
1360
1418
  }
1361
- class Yt {
1419
+ class he {
1362
1420
  /**
1363
1421
  * Creates an instance of BUSY Bar.
1364
1422
  * Initializes the API client with the provided host address.
@@ -1387,38 +1445,38 @@ class Yt {
1387
1445
  * @type {BusyBarConfig['host']}
1388
1446
  * @readonly
1389
1447
  */
1390
- c(this, "addr");
1448
+ u(this, "addr");
1391
1449
  /**
1392
1450
  * Current API semantic version.
1393
1451
  * @type {ApiSemver}
1394
1452
  */
1395
- c(this, "apiSemver");
1453
+ u(this, "apiSemver");
1396
1454
  /**
1397
1455
  * API Client instance.
1398
1456
  */
1399
- c(this, "apiClient");
1400
- c(this, "setApiKeyFn");
1401
- c(this, "setTokenFn");
1457
+ u(this, "apiClient");
1458
+ u(this, "setApiKeyFn");
1459
+ u(this, "setTokenFn");
1402
1460
  /**
1403
1461
  * Detected connection type based on auth requirements.
1404
1462
  * - "wifi": Device requires authentication (returned 401/403).
1405
1463
  * - "usb": Device allows access without token (returned 200).
1406
1464
  * - "unknown": Detection failed or not yet completed.
1407
1465
  */
1408
- c(this, "connectionType", "unknown");
1466
+ u(this, "connectionType", "unknown");
1409
1467
  if (!t || !t.addr && !t.token)
1410
- this.addr = S;
1468
+ this.addr = D;
1411
1469
  else if (!t.addr)
1412
- this.addr = Jt;
1470
+ this.addr = ce;
1413
1471
  else {
1414
- let o = t.addr.trim();
1415
- if (/^https?:\/\//i.test(o) || (o = `http://${o}`), Xt.test(o) && !t.token)
1472
+ let s = t.addr.trim();
1473
+ if (/^https?:\/\//i.test(s) || (s = `http://${s}`), ue.test(s) && !t.token)
1416
1474
  throw new Error("Token is required. Please provide it.");
1417
- this.addr = o;
1475
+ this.addr = s;
1418
1476
  }
1419
1477
  this.apiSemver = "";
1420
- const { client: i, setApiKey: e, setToken: r } = O(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
1421
- this.apiClient = i, this.setApiKeyFn = e, this.setTokenFn = r, this.detectConnectionType();
1478
+ const { client: e, setApiKey: i, setToken: n } = M(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
1479
+ this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn = n, this.detectConnectionType();
1422
1480
  }
1423
1481
  /**
1424
1482
  * Probes the device to determine connection type.
@@ -1426,23 +1484,23 @@ class Yt {
1426
1484
  */
1427
1485
  async detectConnectionType() {
1428
1486
  const t = new URL(this.addr).hostname;
1429
- if (!T(t) && !E(t)) {
1487
+ if (!v(t) && !P(t)) {
1430
1488
  this.connectionType = "wifi";
1431
1489
  return;
1432
1490
  }
1433
- const i = m({
1491
+ const e = O({
1434
1492
  baseUrl: `${this.addr}/api/`
1435
1493
  });
1436
1494
  try {
1437
- const { response: e } = await i.GET("/name");
1438
- if (e.status === 401 || e.status === 403)
1495
+ const { response: i } = await e.GET("/name");
1496
+ if (i.status === 401 || i.status === 403)
1439
1497
  this.connectionType = "wifi";
1440
- else if (e.ok)
1498
+ else if (i.ok)
1441
1499
  this.connectionType = "usb";
1442
1500
  else
1443
- throw new Error(`Failed to detect connection type. Status: ${e.status}`);
1444
- } catch (e) {
1445
- throw e;
1501
+ throw new Error(`Failed to detect connection type. Status: ${i.status}`);
1502
+ } catch (i) {
1503
+ throw i;
1446
1504
  }
1447
1505
  }
1448
1506
  /**
@@ -1460,95 +1518,95 @@ class Yt {
1460
1518
  this.setTokenFn(t);
1461
1519
  }
1462
1520
  }
1463
- function Qt(n, t) {
1464
- t.forEach((i) => {
1465
- Object.getOwnPropertyNames(i.prototype).forEach((e) => {
1466
- Object.defineProperty(n.prototype, e, Object.getOwnPropertyDescriptor(i.prototype, e) || /* @__PURE__ */ Object.create(null));
1521
+ function le(r, t) {
1522
+ t.forEach((e) => {
1523
+ Object.getOwnPropertyNames(e.prototype).forEach((i) => {
1524
+ Object.defineProperty(r.prototype, i, Object.getOwnPropertyDescriptor(e.prototype, i) || /* @__PURE__ */ Object.create(null));
1467
1525
  });
1468
1526
  });
1469
1527
  }
1470
- Qt(Yt, [
1471
- K,
1472
- j,
1473
- Q,
1474
- ot,
1475
- dt,
1528
+ le(he, [
1529
+ X,
1530
+ rt,
1531
+ ut,
1476
1532
  pt,
1477
- Ct,
1478
- Lt,
1479
- It,
1480
- _t,
1481
- Mt,
1482
- Vt,
1483
- Ht
1533
+ kt,
1534
+ Rt,
1535
+ Ut,
1536
+ Wt,
1537
+ Ht,
1538
+ Yt,
1539
+ Qt,
1540
+ ne,
1541
+ oe
1484
1542
  ]);
1485
- var p = /* @__PURE__ */ ((n) => (n[n.FRONT = 0] = "FRONT", n[n.BACK = 1] = "BACK", n))(p || {});
1486
- const C = 3e3, k = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1487
- function g(n, t) {
1488
- if (t < 0 || t >= n.length)
1489
- throw new Error(`Index ${t} is out of bounds (0…${n.length - 1})`);
1490
- const i = n[t];
1491
- if (i === void 0)
1543
+ var _ = /* @__PURE__ */ ((r) => (r[r.FRONT = 0] = "FRONT", r[r.BACK = 1] = "BACK", r))(_ || {});
1544
+ const U = 3e3, I = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1545
+ function L(r, t) {
1546
+ if (t < 0 || t >= r.length)
1547
+ throw new Error(`Index ${t} is out of bounds (0…${r.length - 1})`);
1548
+ const e = r[t];
1549
+ if (e === void 0)
1492
1550
  throw new Error(`Unexpected undefined at index ${t}`);
1493
- return i;
1551
+ return e;
1494
1552
  }
1495
- function Zt(n, t) {
1496
- let i = 0;
1497
- const e = n.length, r = [];
1498
- for (; i < e; ) {
1499
- const o = g(n, i);
1500
- if (i += 1, (o & 128) !== 0) {
1501
- const a = o & 127;
1502
- for (let u = 0; u < a * t; u++)
1503
- r.push(n[i + u]);
1504
- i += a * t;
1553
+ function de(r, t) {
1554
+ let e = 0;
1555
+ const i = r.length, n = [];
1556
+ for (; e < i; ) {
1557
+ const s = L(r, e);
1558
+ if (e += 1, (s & 128) !== 0) {
1559
+ const o = s & 127;
1560
+ for (let h = 0; h < o * t; h++)
1561
+ n.push(r[e + h]);
1562
+ e += o * t;
1505
1563
  } else {
1506
- const a = o, u = n.slice(i, i + t);
1507
- for (let w = 0; w < a; w++)
1508
- for (let f = 0; f < t; f++)
1509
- r.push(u[f]);
1510
- i += t;
1564
+ const o = s, h = r.slice(e, e + t);
1565
+ for (let c = 0; c < o; c++)
1566
+ for (let p = 0; p < t; p++)
1567
+ n.push(h[p]);
1568
+ e += t;
1511
1569
  }
1512
1570
  }
1513
- return new Uint8Array(r);
1571
+ return new Uint8Array(n);
1514
1572
  }
1515
- function te(n) {
1516
- const t = new Uint8Array(n.length * 2);
1517
- let i = 0, e = 0;
1518
- for (; i < n.length; ) {
1519
- const r = g(n, i), o = r & 15, a = r >> 4 & 15;
1520
- t[e] = o, t[e + 1] = a, i += 1, e += 2;
1573
+ function fe(r) {
1574
+ const t = new Uint8Array(r.length * 2);
1575
+ let e = 0, i = 0;
1576
+ for (; e < r.length; ) {
1577
+ const n = L(r, e), s = n & 15, o = n >> 4 & 15;
1578
+ t[i] = s, t[i + 1] = o, e += 1, i += 2;
1521
1579
  }
1522
1580
  return t;
1523
1581
  }
1524
- const A = () => typeof window < "u" && typeof window.document < "u";
1525
- class ne {
1582
+ const N = () => typeof window < "u" && typeof window.document < "u";
1583
+ class me {
1526
1584
  constructor(t) {
1527
- c(this, "addr");
1528
- c(this, "connected", !1);
1585
+ u(this, "addr");
1586
+ u(this, "connected", !1);
1529
1587
  // @ts-ignore
1530
- c(this, "apiKey");
1588
+ u(this, "apiKey");
1531
1589
  // @ts-ignore
1532
- c(this, "apiSemver");
1533
- c(this, "dataListeners", []);
1534
- c(this, "stopListeners", []);
1535
- c(this, "errorListeners", []);
1536
- c(this, "socket", null);
1537
- if (this.config = t, !A())
1590
+ u(this, "apiSemver");
1591
+ u(this, "dataListeners", []);
1592
+ u(this, "stopListeners", []);
1593
+ u(this, "errorListeners", []);
1594
+ u(this, "socket", null);
1595
+ if (this.config = t, !N())
1538
1596
  throw new Error("not browser");
1539
1597
  if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1540
- this.addr = S;
1598
+ this.addr = D;
1541
1599
  else {
1542
- let i = t.addr.trim();
1543
- /^https?:\/\//i.test(i) || (i = `http://${i}`);
1600
+ let e = t.addr.trim();
1601
+ /^https?:\/\//i.test(e) || (e = `http://${e}`);
1544
1602
  try {
1545
- const r = new URL(i).hostname;
1546
- if (!T(r) && !E(r))
1603
+ const n = new URL(e).hostname;
1604
+ if (!v(n) && !P(n))
1547
1605
  throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
1548
- } catch (e) {
1549
- throw e instanceof Error && e.message.startsWith("Invalid address") ? e : new Error(`Invalid URL format: "${t.addr}"`);
1606
+ } catch (i) {
1607
+ throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1550
1608
  }
1551
- this.addr = i;
1609
+ this.addr = e;
1552
1610
  }
1553
1611
  }
1554
1612
  onData(t) {
@@ -1561,16 +1619,16 @@ class ne {
1561
1619
  this.errorListeners.push(t);
1562
1620
  }
1563
1621
  emitData(t) {
1564
- for (const i of this.dataListeners)
1565
- i(t);
1622
+ for (const e of this.dataListeners)
1623
+ e(t);
1566
1624
  }
1567
1625
  emitStop() {
1568
1626
  for (const t of this.stopListeners)
1569
1627
  t();
1570
1628
  }
1571
1629
  emitError(t) {
1572
- for (const i of this.errorListeners)
1573
- i(t);
1630
+ for (const e of this.errorListeners)
1631
+ e(t);
1574
1632
  }
1575
1633
  async openWebsocket() {
1576
1634
  this.socket && await this.closeWebsocket();
@@ -1579,35 +1637,35 @@ class ne {
1579
1637
  throw new Error("The WebSocket URL is not specified");
1580
1638
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1581
1639
  this.socket && (this.socket.send(JSON.stringify({ display: this.config.deviceScreen })), this.connected = !0);
1582
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1640
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1583
1641
  try {
1584
- if (typeof i.data == "string")
1642
+ if (typeof e.data == "string")
1585
1643
  return;
1586
- const e = new Uint8Array(i.data);
1587
- let r;
1588
- const o = this.config.deviceScreen === p.FRONT ? 3 : 2;
1644
+ const i = new Uint8Array(e.data);
1645
+ let n;
1646
+ const s = this.config.deviceScreen === _.FRONT ? 3 : 2;
1589
1647
  try {
1590
- const a = Zt(e, o);
1591
- this.config.deviceScreen === p.BACK ? r = te(a) : r = a, this.emitData(r);
1648
+ const o = de(i, s);
1649
+ this.config.deviceScreen === _.BACK ? n = fe(o) : n = o, this.emitData(n);
1592
1650
  } catch {
1593
- this.emitData(e);
1651
+ this.emitData(i);
1594
1652
  }
1595
1653
  } catch {
1596
1654
  this.connected = !1, this.emitStop();
1597
1655
  }
1598
- }, this.socket.onerror = (i) => {
1656
+ }, this.socket.onerror = (e) => {
1599
1657
  this.connected = !1, this.emitError({
1600
1658
  code: 1006,
1601
1659
  // Standard «abnormal closure» code per RFC-6455
1602
1660
  message: "WebSocket error occurred",
1603
- raw: i
1661
+ raw: e
1604
1662
  }), this.emitStop();
1605
- }, this.socket.onclose = async (i) => {
1606
- if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1663
+ }, this.socket.onclose = async (e) => {
1664
+ if (this.socket = null, this.connected = !1, e.code === U || I.has(e.code)) {
1607
1665
  this.emitError({
1608
- code: i.code,
1609
- message: i.reason,
1610
- raw: i
1666
+ code: e.code,
1667
+ message: e.reason,
1668
+ raw: e
1611
1669
  });
1612
1670
  return;
1613
1671
  }
@@ -1622,34 +1680,34 @@ class ne {
1622
1680
  });
1623
1681
  }
1624
1682
  }
1625
- class re {
1683
+ class Te {
1626
1684
  constructor(t) {
1627
- c(this, "addr");
1628
- c(this, "connected", !1);
1685
+ u(this, "addr");
1686
+ u(this, "connected", !1);
1629
1687
  // @ts-ignore
1630
- c(this, "apiKey");
1688
+ u(this, "apiKey");
1631
1689
  // @ts-ignore
1632
- c(this, "apiSemver");
1633
- c(this, "inputEvent");
1634
- c(this, "dataListeners", []);
1635
- c(this, "stopListeners", []);
1636
- c(this, "errorListeners", []);
1637
- c(this, "socket", null);
1638
- if (!A())
1690
+ u(this, "apiSemver");
1691
+ u(this, "inputEvent");
1692
+ u(this, "dataListeners", []);
1693
+ u(this, "stopListeners", []);
1694
+ u(this, "errorListeners", []);
1695
+ u(this, "socket", null);
1696
+ if (!N())
1639
1697
  throw new Error("not browser");
1640
1698
  if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1641
- this.addr = S;
1699
+ this.addr = D;
1642
1700
  else {
1643
- let i = t.addr.trim();
1644
- /^https?:\/\//i.test(i) || (i = `http://${i}`);
1701
+ let e = t.addr.trim();
1702
+ /^https?:\/\//i.test(e) || (e = `http://${e}`);
1645
1703
  try {
1646
- const r = new URL(i).hostname;
1647
- if (!T(r) && !E(r))
1704
+ const n = new URL(e).hostname;
1705
+ if (!v(n) && !P(n))
1648
1706
  throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
1649
- } catch (e) {
1650
- throw e instanceof Error && e.message.startsWith("Invalid address") ? e : new Error(`Invalid URL format: "${t.addr}"`);
1707
+ } catch (i) {
1708
+ throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1651
1709
  }
1652
- this.addr = i;
1710
+ this.addr = e;
1653
1711
  }
1654
1712
  this.inputEvent = {};
1655
1713
  }
@@ -1663,16 +1721,16 @@ class re {
1663
1721
  this.errorListeners.push(t);
1664
1722
  }
1665
1723
  emitData(t) {
1666
- for (const i of this.dataListeners)
1667
- i(t);
1724
+ for (const e of this.dataListeners)
1725
+ e(t);
1668
1726
  }
1669
1727
  emitStop() {
1670
1728
  for (const t of this.stopListeners)
1671
1729
  t();
1672
1730
  }
1673
1731
  emitError(t) {
1674
- for (const i of this.errorListeners)
1675
- i(t);
1732
+ for (const e of this.errorListeners)
1733
+ e(t);
1676
1734
  }
1677
1735
  async openWebsocket() {
1678
1736
  this.socket && await this.closeWebsocket();
@@ -1681,38 +1739,38 @@ class re {
1681
1739
  throw new Error("The WebSocket URL is not specified");
1682
1740
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1683
1741
  this.socket && (this.connected = !0);
1684
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1742
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1685
1743
  try {
1686
- if (typeof i.data == "string")
1744
+ if (typeof e.data == "string")
1687
1745
  return;
1688
- const e = new Uint8Array(i.data);
1689
- this.emitData(e);
1746
+ const i = new Uint8Array(e.data);
1747
+ this.emitData(i);
1690
1748
  } catch {
1691
1749
  this.connected = !1, this.emitStop();
1692
1750
  }
1693
- }, this.socket.onerror = (i) => {
1751
+ }, this.socket.onerror = (e) => {
1694
1752
  this.connected = !1, this.emitError({
1695
1753
  code: 1006,
1696
1754
  // Standard «abnormal closure» code per RFC-6455
1697
1755
  message: "WebSocket error occurred",
1698
- raw: i
1756
+ raw: e
1699
1757
  }), this.emitStop();
1700
- }, this.socket.onclose = async (i) => {
1701
- if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1758
+ }, this.socket.onclose = async (e) => {
1759
+ if (this.socket = null, this.connected = !1, e.code === U || I.has(e.code)) {
1702
1760
  this.emitError({
1703
- code: i.code,
1704
- message: i.reason,
1705
- raw: i
1761
+ code: e.code,
1762
+ message: e.reason,
1763
+ raw: e
1706
1764
  });
1707
1765
  return;
1708
1766
  }
1709
1767
  this.emitStop();
1710
1768
  };
1711
1769
  }
1712
- sendInput({ keyName: t, value: i }) {
1770
+ sendInput({ keyName: t, value: e }) {
1713
1771
  if (!this.socket || !this.connected)
1714
1772
  throw new Error("WebSocket: Not connected");
1715
- this.inputEvent[t] = i, this.socket.send(JSON.stringify(this.inputEvent)), i === 0 && delete this.inputEvent[t];
1773
+ this.inputEvent[t] = e, this.socket.send(JSON.stringify(this.inputEvent)), e === 0 && delete this.inputEvent[t];
1716
1774
  }
1717
1775
  closeWebsocket() {
1718
1776
  return this.connected = !1, new Promise((t) => {
@@ -1722,9 +1780,437 @@ class re {
1722
1780
  });
1723
1781
  }
1724
1782
  }
1783
+ const m = class m {
1784
+ constructor(t, e) {
1785
+ u(this, "addr");
1786
+ u(this, "token");
1787
+ u(this, "isBinary");
1788
+ u(this, "connectTimeout");
1789
+ u(this, "dataTimeout");
1790
+ u(this, "worker", null);
1791
+ u(this, "connectionTimer", null);
1792
+ u(this, "dataTimer", null);
1793
+ u(this, "_status");
1794
+ // Callbacks
1795
+ u(this, "dataCallback");
1796
+ u(this, "rawDataCallback");
1797
+ u(this, "errorCallback");
1798
+ u(this, "statusCallback");
1799
+ this.addr = t.addr || "", this.token = t.token, this.isBinary = t.isBinary ?? !0, this.connectTimeout = (e == null ? void 0 : e.timeout) ?? 5e3, this.dataTimeout = (e == null ? void 0 : e.dataTimeout) ?? 15e3, this._status = {
1800
+ main: { status: f.IDLE },
1801
+ connection: { status: E.DISCONNECTED },
1802
+ auth: { status: k.UNAUTHENTICATED },
1803
+ data: { status: C.NONE },
1804
+ worker: { status: S.OFF }
1805
+ };
1806
+ }
1807
+ get status() {
1808
+ return this._status;
1809
+ }
1810
+ /**
1811
+ * Transforms http/https to ws/wss and prefixes with auto-inferred protocol if no protocol present.
1812
+ */
1813
+ resolveProtocol(t) {
1814
+ let e = t.trim();
1815
+ if (e.startsWith("https://"))
1816
+ return e.replace("https://", "wss://");
1817
+ if (e.startsWith("http://"))
1818
+ return e.replace("http://", "ws://");
1819
+ if (e.startsWith("wss://") || e.startsWith("ws://"))
1820
+ return e;
1821
+ let i = "ws:";
1822
+ return typeof window < "u" && window.location.protocol === "https:" && (i = "wss:"), `${i}//${e}`;
1823
+ }
1824
+ /**
1825
+ * Starts the stream connection.
1826
+ * Throws an error if already running.
1827
+ */
1828
+ start({
1829
+ dataCallback: t,
1830
+ rawDataCallback: e,
1831
+ errorCallback: i,
1832
+ statusCallback: n
1833
+ }) {
1834
+ if (this._status.main.status === f.STARTING || this._status.main.status === f.RUNNING) {
1835
+ const s = new y(d.STREAM_ALREADY_STARTED, "StateStream is already running. Call stop() before starting again.");
1836
+ if (n && n({
1837
+ ...this._status,
1838
+ main: { ...this._status.main, lastError: s }
1839
+ }), i)
1840
+ i(s);
1841
+ else
1842
+ throw s;
1843
+ return;
1844
+ }
1845
+ this.dataCallback = t, this.rawDataCallback = e, this.errorCallback = i, this.statusCallback = n, this.updateStatusComponent("main", { status: f.STARTING, lastError: void 0 });
1846
+ try {
1847
+ this.ensureWorker(), this.sendCommand({
1848
+ type: "START",
1849
+ addr: this.normalizeUrl(this.addr),
1850
+ token: this.token,
1851
+ isBinary: this.isBinary,
1852
+ mode: this.streamMode
1853
+ }), this.clearConnectionTimer(), this.connectionTimer = setTimeout(() => {
1854
+ const s = new y(d.CONNECTION_TIMEOUT, `Connection timed out after ${this.connectTimeout}ms`);
1855
+ this.mapErrorToStatus(s), this.errorCallback && this.errorCallback(s), this.stop();
1856
+ }, this.connectTimeout);
1857
+ } catch (s) {
1858
+ const o = s instanceof y ? s : new y(d.UNKNOWN_ERROR, String(s));
1859
+ this.errorCallback && this.errorCallback(o);
1860
+ }
1861
+ }
1862
+ /**
1863
+ * Stops the stream connection.
1864
+ */
1865
+ stop() {
1866
+ this.clearConnectionTimer(), this.clearDataTimer(), !(this._status.main.status === f.IDLE || this._status.main.status === f.STOPPED) && (this.updateStatusComponent("main", { status: f.STOPPED }), this.updateStatusComponent("connection", { status: E.DISCONNECTED }), this.sendCommand({ type: "STOP" }), this.clearCallbacks());
1867
+ }
1868
+ /**
1869
+ * Cleans up all resources.
1870
+ */
1871
+ destroy() {
1872
+ this.stop(), this.worker && (this.worker.terminate ? this.worker.terminate() : "close" in this.worker.port && this.worker.port.close(), this.worker = null);
1873
+ }
1874
+ /**
1875
+ * Clears all registered callbacks.
1876
+ */
1877
+ clearCallbacks() {
1878
+ this.dataCallback = void 0, this.rawDataCallback = void 0, this.errorCallback = void 0, this.statusCallback = void 0;
1879
+ }
1880
+ /**
1881
+ * Sends a new token to the worker (for auth or token refresh).
1882
+ */
1883
+ sendToken(t) {
1884
+ this.token = t, this.sendCommand({ type: "UPDATE_TOKEN", token: t });
1885
+ }
1886
+ /**
1887
+ * Sends a command to the worker port.
1888
+ */
1889
+ sendCommand(t) {
1890
+ this.worker && this.worker.port.postMessage(t);
1891
+ }
1892
+ ensureWorker() {
1893
+ if (this.worker || typeof window > "u") return;
1894
+ const t = btoa(this.addr);
1895
+ try {
1896
+ this.updateStatusComponent("worker", { status: S.INITIALIZING, lastError: void 0 });
1897
+ const e = new URL(
1898
+ /* @vite-ignore */
1899
+ "./index.worker.js",
1900
+ import.meta.url
1901
+ );
1902
+ if (window.SharedWorker) {
1903
+ const i = new SharedWorker(e, {
1904
+ name: t,
1905
+ type: "module"
1906
+ });
1907
+ this.worker = {
1908
+ port: i.port
1909
+ }, i.port.onmessage = (n) => {
1910
+ this.handleWorkerMessage(n.data);
1911
+ }, i.port.start();
1912
+ } else {
1913
+ const i = new Worker(e, { type: "module" });
1914
+ this.worker = {
1915
+ port: i,
1916
+ terminate: () => i.terminate()
1917
+ }, i.onmessage = (n) => {
1918
+ this.handleWorkerMessage(n.data);
1919
+ };
1920
+ }
1921
+ this.updateStatusComponent("worker", { status: S.READY });
1922
+ } catch (e) {
1923
+ const i = new y(d.WORKER_INIT_FAILED, `Failed to initialize worker: ${String(e)}`);
1924
+ throw this.updateStatusComponent("worker", { status: S.ERROR, lastError: i }), this.updateStatusComponent("main", { status: f.FAILED, lastError: i }), i;
1925
+ }
1926
+ }
1927
+ /**
1928
+ * Processes messages from the worker.
1929
+ */
1930
+ handleWorkerMessage(t) {
1931
+ switch (t.type) {
1932
+ case "DATA":
1933
+ this.resetDataTimer(), this.dataCallback && this.dataCallback(this.normalizeState(t.data));
1934
+ break;
1935
+ case "RAW_DATA":
1936
+ this.resetDataTimer(), this.rawDataCallback && this.rawDataCallback(t.data);
1937
+ break;
1938
+ case "CONNECTED":
1939
+ this.clearConnectionTimer(), this.updateStatusComponent("connection", { status: E.CONNECTED }), this.streamMode === "local" && this.updateStatusComponent("main", { status: f.RUNNING });
1940
+ break;
1941
+ case "STATUS_UPDATE":
1942
+ t.connection && this.updateStatusComponent("connection", { status: t.connection }), t.auth && (this.updateStatusComponent("auth", { status: t.auth }), t.auth === k.AUTHENTICATED && this.updateStatusComponent("main", { status: f.RUNNING }));
1943
+ break;
1944
+ case "ERROR": {
1945
+ this.clearConnectionTimer();
1946
+ const e = new y(t.code, t.message, t.data);
1947
+ this.mapErrorToStatus(e), this.errorCallback && this.errorCallback(e);
1948
+ break;
1949
+ }
1950
+ case "TOKEN_EXPIRED":
1951
+ this.updateStatusComponent("auth", { status: k.AUTHENTICATING }), this.handleTokenExpiredInternal();
1952
+ break;
1953
+ case "DISCONNECTED":
1954
+ this.updateStatusComponent("connection", { status: E.DISCONNECTED });
1955
+ break;
1956
+ }
1957
+ }
1958
+ /**
1959
+ * Maps an error code to the corresponding status component
1960
+ */
1961
+ mapErrorToStatus(t) {
1962
+ const e = t.code;
1963
+ (e === d.CONNECTION_FAILED || e === d.CONNECTION_LOST || e === d.RECONNECT_FAILED || e === d.CONNECTION_TIMEOUT) && (this.updateStatusComponent("connection", { status: E.DISCONNECTED, lastError: t }), this.updateStatusComponent("main", { status: f.FAILED, lastError: t })), (e === d.AUTH_FAILED || e === d.AUTH_REFRESH_FAILED) && (this.updateStatusComponent("auth", { status: k.FAILED, lastError: t }), this.updateStatusComponent("main", { status: f.FAILED, lastError: t })), (e === d.DEVICE_ERROR || e === d.DECODE_ERROR) && this.updateStatusComponent("main", { lastError: t });
1964
+ }
1965
+ /**
1966
+ * Updates a single component of the status and notifies listeners
1967
+ */
1968
+ updateStatusComponent(t, e) {
1969
+ const i = this._status[t];
1970
+ this._status[t] = { ...i, ...e }, this.statusCallback && this.statusCallback({ ...this._status });
1971
+ }
1972
+ /**
1973
+ * Safe timer cleanup
1974
+ */
1975
+ clearConnectionTimer() {
1976
+ this.connectionTimer && (clearTimeout(this.connectionTimer), this.connectionTimer = null);
1977
+ }
1978
+ /**
1979
+ * Reset the data inactivity timer
1980
+ */
1981
+ resetDataTimer() {
1982
+ this.clearDataTimer(), this._status.data.status !== C.ACTIVE ? this.updateStatusComponent("data", {
1983
+ status: C.ACTIVE,
1984
+ lastActivity: Date.now()
1985
+ }) : this._status.data.lastActivity = Date.now(), this.dataTimer = setTimeout(() => {
1986
+ this.updateStatusComponent("data", { status: C.STALE });
1987
+ }, this.dataTimeout);
1988
+ }
1989
+ clearDataTimer() {
1990
+ this.dataTimer && (clearTimeout(this.dataTimer), this.dataTimer = null);
1991
+ }
1992
+ /**
1993
+ * Normalizes the raw state from the worker into a ProcessedState for the UI.
1994
+ * Extracts the 'state' key for each update and merges bar_id for remote mode.
1995
+ */
1996
+ normalizeState(t) {
1997
+ let e, i;
1998
+ "bar_id" in t && "state" in t ? (e = t.state, i = t.bar_id) : e = t;
1999
+ let n = e.updates;
2000
+ return n && (n = n.map((s) => {
2001
+ const o = Object.keys(s).find((h) => s[h] != null);
2002
+ return {
2003
+ ...s,
2004
+ state: o
2005
+ };
2006
+ })), {
2007
+ ...e,
2008
+ updates: n,
2009
+ bar_id: i
2010
+ };
2011
+ }
2012
+ /**
2013
+ * Internally deduplicates token refresh requests for the same address.
2014
+ */
2015
+ async handleTokenExpiredInternal() {
2016
+ const t = this.addr;
2017
+ let e = m.tokenRefreshPromises.get(t);
2018
+ if (!e && this.onTokenExpired && (e = (async () => {
2019
+ try {
2020
+ const n = this.onTokenExpired();
2021
+ return n instanceof Promise ? await n : "";
2022
+ } finally {
2023
+ m.tokenRefreshPromises.delete(t);
2024
+ }
2025
+ })(), m.tokenRefreshPromises.set(t, e)), e) {
2026
+ const i = await e;
2027
+ i && this.sendToken(i);
2028
+ }
2029
+ }
2030
+ };
2031
+ /** Static map to deduplicate token refresh requests across all instances in this JS context */
2032
+ u(m, "tokenRefreshPromises", /* @__PURE__ */ new Map());
2033
+ let g = m;
2034
+ class Ee extends g {
2035
+ constructor(e = {}, i) {
2036
+ let n = e.addr;
2037
+ n || (typeof window < "u" ? n = window.location.origin : n = "10.0.4.20");
2038
+ super(
2039
+ {
2040
+ isBinary: !0,
2041
+ // Default for local is binary
2042
+ ...e,
2043
+ addr: n
2044
+ },
2045
+ i
2046
+ );
2047
+ u(this, "streamMode", "local");
2048
+ }
2049
+ /**
2050
+ * Normalizes the address to use ws:// protocol and adds default path if missing.
2051
+ */
2052
+ normalizeUrl(e) {
2053
+ const i = this.resolveProtocol(e), n = new URL(i);
2054
+ return (n.pathname === "/" || !n.pathname) && (n.pathname = "/api/status/ws"), n.toString();
2055
+ }
2056
+ }
2057
+ class Se extends g {
2058
+ constructor(e, i) {
2059
+ super(
2060
+ {
2061
+ isBinary: !1,
2062
+ // Default for remote is JSON
2063
+ ...e
2064
+ },
2065
+ i
2066
+ );
2067
+ u(this, "streamMode", "remote");
2068
+ u(this, "tokenProvider");
2069
+ this.tokenProvider = e.tokenProvider;
2070
+ }
2071
+ /**
2072
+ * Subscribes to updates for a specific device GUID.
2073
+ */
2074
+ subscribe(e) {
2075
+ this.sendCommand({ type: "SUBSCRIBE", guid: e });
2076
+ }
2077
+ /**
2078
+ * Unsubscribes from updates for a specific device GUID.
2079
+ */
2080
+ unsubscribe(e) {
2081
+ this.sendCommand({ type: "UNSUBSCRIBE", guid: e });
2082
+ }
2083
+ /**
2084
+ * Standardizes the address to use wss:// or ws:// protocol.
2085
+ */
2086
+ normalizeUrl(e) {
2087
+ return this.resolveProtocol(e);
2088
+ }
2089
+ /**
2090
+ * Handles token expiration by invoking the tokenProvider.
2091
+ * Returns the promise for deduplication.
2092
+ */
2093
+ onTokenExpired() {
2094
+ if (this.tokenProvider)
2095
+ return this.tokenProvider().then((e) => (this.sendToken(e), e)).catch((e) => {
2096
+ const i = `Failed to refresh token: ${e.message}`;
2097
+ throw this.errorCallback && this.errorCallback(new y(d.AUTH_REFRESH_FAILED, i)), e;
2098
+ });
2099
+ }
2100
+ }
2101
+ const T = class T {
2102
+ constructor() {
2103
+ u(this, "gl", null);
2104
+ u(this, "program", null);
2105
+ u(this, "texture", null);
2106
+ u(this, "vs", `#version 300 es
2107
+ in vec2 position;
2108
+ out vec2 v_uv;
2109
+ void main() {
2110
+ v_uv = position * 0.5 + 0.5;
2111
+ v_uv.y = 1.0 - v_uv.y;
2112
+ gl_Position = vec4(position, 0, 1);
2113
+ }
2114
+ `);
2115
+ u(this, "fs", `#version 300 es
2116
+ precision highp float;
2117
+ in vec2 v_uv;
2118
+ out vec4 outColor;
2119
+ uniform sampler2D u_texture;
2120
+ uniform vec2 u_dataRes;
2121
+ uniform vec2 u_canvasRes;
2122
+ uniform float u_pixelSize;
2123
+ uniform float u_radius;
2124
+ uniform float u_darkThreshold;
2125
+ void main() {
2126
+ vec2 gridPos = v_uv * u_dataRes;
2127
+ vec2 localUv = fract(gridPos);
2128
+ vec2 cellCoords = (floor(gridPos) + 0.5) / u_dataRes;
2129
+ vec4 color = texture(u_texture, cellCoords);
2130
+ if (dot(color.rgb, vec3(1.0)) < u_darkThreshold) discard;
2131
+ float halfSize = u_pixelSize * 0.5;
2132
+ float visualRadius = sqrt(clamp(u_radius, 0.0, 1.0));
2133
+ float r = visualRadius * halfSize;
2134
+ vec2 q = abs(localUv - 0.5) - (halfSize - r);
2135
+ float dist = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
2136
+ float unitsPerPixel = (u_dataRes.y / u_canvasRes.y);
2137
+ float delta = unitsPerPixel * 1.5;
2138
+ float effectRes = (1.0 - u_pixelSize) + u_radius;
2139
+ float effectStrength = smoothstep(0.0, 0.02, effectRes);
2140
+ float edgeOffset = mix(0.0, -delta, effectStrength);
2141
+ float mask = 1.0 - smoothstep(edgeOffset, edgeOffset + delta * 2.0, dist);
2142
+ float vignette = smoothstep(0.7, 0.3, length(localUv - 0.5));
2143
+ vec3 finalColor = color.rgb * (1.0 - (0.15 * effectStrength * (1.0 - vignette)));
2144
+ if (mask < 0.001) discard;
2145
+ outColor = vec4(finalColor, color.a * mask);
2146
+ }
2147
+ `);
2148
+ if (T.instance)
2149
+ return T.instance;
2150
+ T.instance = this;
2151
+ }
2152
+ /**
2153
+ * Lazily initializes the WebGL context and resources.
2154
+ * Only executes in a browser environment.
2155
+ */
2156
+ init() {
2157
+ if (this.gl || typeof window > "u")
2158
+ return;
2159
+ const e = document.createElement("canvas").getContext("webgl2", {
2160
+ antialias: !0,
2161
+ alpha: !0,
2162
+ preserveDrawingBuffer: !0
2163
+ });
2164
+ if (!e)
2165
+ throw new Error("WebGL 2.0 not supported");
2166
+ this.gl = e, this.program = this.createProgram(this.vs, this.fs);
2167
+ const i = e.createBuffer();
2168
+ e.bindBuffer(e.ARRAY_BUFFER, i), e.bufferData(e.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), e.STATIC_DRAW);
2169
+ const n = e.getAttribLocation(this.program, "position");
2170
+ e.enableVertexAttribArray(n), e.vertexAttribPointer(n, 2, e.FLOAT, !1, 0, 0), this.texture = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.texture), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE);
2171
+ }
2172
+ /**
2173
+ * Internal WebGL rendering pass.
2174
+ */
2175
+ render(t, e, i, n) {
2176
+ const { pixelSize: s = 0.85, radius: o = 0.5, darkThreshold: h = 0.04 } = n, c = this.gl;
2177
+ c.viewport(0, 0, c.canvas.width, c.canvas.height), c.useProgram(this.program), c.bindTexture(c.TEXTURE_2D, this.texture), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA8, e, i, 0, c.RGBA, c.UNSIGNED_BYTE, t), c.uniform2f(c.getUniformLocation(this.program, "u_dataRes"), e, i), c.uniform2f(c.getUniformLocation(this.program, "u_canvasRes"), c.canvas.width, c.canvas.height), c.uniform1f(c.getUniformLocation(this.program, "u_pixelSize"), s), c.uniform1f(c.getUniformLocation(this.program, "u_radius"), o), c.uniform1f(c.getUniformLocation(this.program, "u_darkThreshold"), h), c.clearColor(0, 0, 0, 0), c.clear(c.COLOR_BUFFER_BIT), c.enable(c.BLEND), c.blendFunc(c.SRC_ALPHA, c.ONE_MINUS_SRC_ALPHA), c.drawArrays(c.TRIANGLES, 0, 6);
2178
+ }
2179
+ /**
2180
+ * Public API: Renders the LED frame to a target 2D canvas.
2181
+ */
2182
+ renderFrame(t, e, i, n, s = {}) {
2183
+ if (this.init(), typeof window > "u" || !this.gl)
2184
+ return;
2185
+ (this.gl.canvas.width !== t.width || this.gl.canvas.height !== t.height) && (this.gl.canvas.width = t.width, this.gl.canvas.height = t.height), this.render(e, i, n, s);
2186
+ const o = t.getContext("2d");
2187
+ o && (o.clearRect(0, 0, t.width, t.height), o.drawImage(this.gl.canvas, 0, 0));
2188
+ }
2189
+ createProgram(t, e) {
2190
+ const i = this.gl, n = (o, h) => {
2191
+ const c = i.createShader(o);
2192
+ if (i.shaderSource(c, h), i.compileShader(c), !i.getShaderParameter(c, i.COMPILE_STATUS)) throw new Error(i.getShaderInfoLog(c) || "Shader Error");
2193
+ return c;
2194
+ }, s = i.createProgram();
2195
+ return i.attachShader(s, n(i.VERTEX_SHADER, t)), i.attachShader(s, n(i.FRAGMENT_SHADER, e)), i.linkProgram(s), s;
2196
+ }
2197
+ };
2198
+ u(T, "instance", null);
2199
+ let R = T;
2200
+ const Ce = new R();
1725
2201
  export {
1726
- Yt as BusyBar,
1727
- p as DeviceScreen,
1728
- re as Input,
1729
- ne as ScreenStream
2202
+ k as AuthStatus,
2203
+ he as BusyBar,
2204
+ E as ConnectionStatus,
2205
+ C as DataStatus,
2206
+ _ as DeviceScreen,
2207
+ Te as Input,
2208
+ Ce as LEDRenderer,
2209
+ Ee as LocalStateStream,
2210
+ Se as RemoteStateStream,
2211
+ me as ScreenStream,
2212
+ y as StateStreamError,
2213
+ d as StateStreamErrorCode,
2214
+ f as StreamLifecycle,
2215
+ S as WorkerStatus
1730
2216
  };