@busy-app/busy-lib 0.9.0 → 0.11.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,115 +1,112 @@
1
- var P = Object.defineProperty;
2
- var G = (n, t, e) => t in n ? P(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var c = (n, t, e) => G(n, typeof t != "symbol" ? t + "" : t, e);
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
4
  import m from "openapi-fetch";
5
5
  const L = (n, t) => {
6
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
7
  return n;
8
- let e;
9
- 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") ? n && typeof n == "object" && !(n instanceof URLSearchParams) ? new URLSearchParams(n).toString() : String(n) : JSON.stringify(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);
10
10
  };
11
11
  async function y(n) {
12
- const i = (n.headers.get("content-type") || "").includes("application/json") ? await n.clone().json() : await n.clone().text(), r = typeof i == "object" && i !== null ? i.error || i.message : typeof i == "string" ? i : void 0;
13
- return Object.assign(
14
- new Error(r || `HTTP ${n.status} ${n.statusText}`),
15
- {
16
- status: n.status,
17
- statusText: n.statusText,
18
- body: i
19
- }
20
- );
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
17
+ });
21
18
  }
22
19
  async function s(n, t = 3e3) {
23
20
  if (t <= 0)
24
21
  return await n();
25
- const e = new AbortController(), i = setTimeout(() => e.abort(), t);
22
+ const i = new AbortController(), e = setTimeout(() => i.abort(), t);
26
23
  try {
27
- return await n(e.signal);
24
+ return await n(i.signal);
28
25
  } catch (r) {
29
26
  throw r instanceof DOMException && r.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : r;
30
27
  } finally {
31
- clearTimeout(i);
28
+ clearTimeout(e);
32
29
  }
33
30
  }
34
- function O(n, t, e) {
35
- let i, r = e ?? void 0, o, a = null;
36
- const d = async () => {
37
- i || (a || (a = (async () => {
38
- const u = await t();
39
- if (!u.api_semver)
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)
40
37
  throw new Error("Empty API version");
41
- i = u.api_semver;
38
+ e = h.api_semver;
42
39
  })().finally(() => {
43
40
  a = null;
44
41
  })), await a);
45
- }, f = {
46
- async onRequest({ request: u, schemaPath: w }) {
47
- return r && u.headers.set("Authorization", `Bearer ${r}`), w !== "/version" && (await d(), i && u.headers.set("X-API-Sem-Ver", i), o && u.headers.set("X-API-Token", o)), u;
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;
48
45
  },
49
- async onResponse({ request: u, response: w, options: A, schemaPath: v }) {
50
- if (w.ok)
51
- return w;
46
+ async onResponse({ request: h, response: d, options: b, schemaPath: v }) {
47
+ if (d.ok)
48
+ return d;
52
49
  if (v === "/version")
53
- throw await y(w);
54
- if (w.status !== 405)
55
- throw await y(w);
56
- i = void 0, await d(), i && u.headers.set("X-API-Sem-Ver", i), r && u.headers.set("Authorization", `Bearer ${r}`);
57
- const l = await (A.fetch ?? fetch)(u);
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);
58
55
  if (l.ok)
59
56
  return l;
60
57
  throw await y(l);
61
58
  }
62
- }, h = m({
59
+ }, f = m({
63
60
  baseUrl: n,
64
61
  bodySerializer: L
65
62
  });
66
- return h.use(f), {
67
- client: h,
68
- setApiKey: (u) => {
69
- o = u;
63
+ return f.use(w), {
64
+ client: f,
65
+ setApiKey: (h) => {
66
+ o = h;
70
67
  },
71
- setToken: (u) => {
72
- r = u;
68
+ setToken: (h) => {
69
+ r = h;
73
70
  }
74
71
  };
75
72
  }
76
73
  async function D(n, t) {
77
- const { data: e, error: i } = await s(
78
- (r) => n.GET("/version", { signal: r }),
79
- t == null ? void 0 : t.timeout
80
- );
81
- if (i)
82
- throw i;
83
- return e;
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;
78
+ }
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;
84
84
  }
85
85
  async function B(n, t) {
86
- const { data: e, error: i } = await s(
87
- (r) => n.GET("/status", { signal: r }),
88
- t == null ? void 0 : t.timeout
89
- );
90
- if (i)
91
- throw i;
92
- return e;
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;
93
90
  }
94
- async function U(n, t) {
95
- const { data: e, error: i } = await s(
96
- (r) => n.GET("/status/system", { signal: r }),
97
- t == null ? void 0 : t.timeout
98
- );
99
- if (i)
100
- throw i;
101
- return e;
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;
102
96
  }
103
97
  async function $(n, t) {
104
- const { data: e, error: i } = await s(
105
- (r) => n.GET("/status/power", { signal: r }),
106
- t == null ? void 0 : t.timeout
107
- );
108
- if (i)
109
- throw i;
110
- return e;
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;
111
102
  }
112
- class I {
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;
108
+ }
109
+ class K {
113
110
  /**
114
111
  * Get API version information.
115
112
  *
@@ -118,18 +115,18 @@ class I {
118
115
  * @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
119
116
  */
120
117
  async SystemVersionGet(t) {
121
- const e = await D(this.apiClient, t);
122
- return this.apiSemver = e.api_semver, e;
118
+ const i = await D(this.apiClient, t);
119
+ return this.apiSemver = i.api_semver, i;
123
120
  }
124
121
  /**
125
- * Get device status.
122
+ * Get full status.
126
123
  *
127
124
  * @param {TimeoutOptions} [params] - Optional parameters.
128
125
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
129
126
  * @returns {Promise<Status>} Current status of the device.
130
127
  */
131
128
  async SystemStatusGet(t) {
132
- return await B(this.apiClient, t);
129
+ return await U(this.apiClient, t);
133
130
  }
134
131
  /**
135
132
  * Get system status.
@@ -139,7 +136,7 @@ class I {
139
136
  * @returns {Promise<StatusSystem>} Current system status.
140
137
  */
141
138
  async SystemInfoGet(t) {
142
- return await U(this.apiClient, t);
139
+ return await B(this.apiClient, t);
143
140
  }
144
141
  /**
145
142
  * Get power status.
@@ -149,48 +146,62 @@ class I {
149
146
  * @returns {Promise<StatusPower>} Current power status.
150
147
  */
151
148
  async SystemStatusPowerGet(t) {
149
+ return await I(this.apiClient, t);
150
+ }
151
+ /**
152
+ * Get device status.
153
+ *
154
+ * @param {TimeoutOptions} [params] - Optional parameters.
155
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
156
+ * @returns {Promise<StatusDevice>} Current device status.
157
+ */
158
+ async SystemStatusDeviceGet(t) {
152
159
  return await $(this.apiClient, t);
153
160
  }
161
+ /**
162
+ * Get firmware status.
163
+ *
164
+ * @param {TimeoutOptions} [params] - Optional parameters.
165
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
166
+ * @returns {Promise<StatusFirmware>} Current firmware status.
167
+ */
168
+ async SystemStatusFirmwareGet(t) {
169
+ return await R(this.apiClient, t);
170
+ }
154
171
  }
155
- async function K(n, t) {
156
- const { file: e } = t, { data: i, error: r } = await s(
172
+ async function F(n, t) {
173
+ const { file: i } = t, { data: e, error: r } = await s(
157
174
  (o) => n.POST("/update", {
158
175
  headers: {
159
176
  "Content-Type": "application/octet-stream"
160
177
  },
161
- body: e,
178
+ body: i,
162
179
  signal: o
163
180
  }),
164
181
  t.timeout
165
182
  );
166
183
  if (r)
167
184
  throw r;
168
- return i;
169
- }
170
- async function R(n, t) {
171
- const { data: e, error: i } = await s(
172
- (r) => n.POST("/update/check", { signal: r }),
173
- t == null ? void 0 : t.timeout
174
- );
175
- if (i)
176
- throw i;
177
185
  return e;
178
186
  }
179
- async function F(n, t) {
180
- const { data: e, error: i } = await s(
181
- (r) => n.GET("/update/status", { signal: r }),
182
- t == null ? void 0 : t.timeout
183
- );
184
- if (i)
185
- throw i;
186
- return e;
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;
191
+ return i;
187
192
  }
188
193
  async function W(n, t) {
189
- const { version: e } = t, { data: i, error: r } = await s(
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;
198
+ }
199
+ async function M(n, t) {
200
+ const { version: i } = t, { data: e, error: r } = await s(
190
201
  (o) => n.GET("/update/changelog", {
191
202
  params: {
192
203
  query: {
193
- version: e
204
+ version: i
194
205
  }
195
206
  },
196
207
  signal: o
@@ -199,14 +210,14 @@ async function W(n, t) {
199
210
  );
200
211
  if (r)
201
212
  throw r;
202
- return i;
213
+ return e;
203
214
  }
204
- async function M(n, t) {
205
- const { version: e } = t, { data: i, error: r } = await s(
215
+ async function N(n, t) {
216
+ const { version: i } = t, { data: e, error: r } = await s(
206
217
  (o) => n.POST("/update/install", {
207
218
  params: {
208
219
  query: {
209
- version: e
220
+ version: i
210
221
  }
211
222
  },
212
223
  signal: o
@@ -215,18 +226,33 @@ async function M(n, t) {
215
226
  );
216
227
  if (r)
217
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;
218
235
  return i;
219
236
  }
220
- async function N(n, t) {
221
- const { data: e, error: i } = await s(
222
- (r) => n.POST("/update/abort_download", { signal: r }),
223
- t == null ? void 0 : t.timeout
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;
242
+ }
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
248
+ }),
249
+ t.timeout
224
250
  );
225
- if (i)
226
- throw i;
227
- return e;
251
+ if (a)
252
+ throw a;
253
+ return o;
228
254
  }
229
- class x {
255
+ class j {
230
256
  /**
231
257
  * Upload firmware update package.
232
258
  *
@@ -236,7 +262,7 @@ class x {
236
262
  * @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
237
263
  */
238
264
  async UpdateFromFile(t) {
239
- return await K(this.apiClient, t);
265
+ return await F(this.apiClient, t);
240
266
  }
241
267
  /**
242
268
  * Start firmware update check.
@@ -246,7 +272,7 @@ class x {
246
272
  * @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
247
273
  */
248
274
  async UpdateCheck(t) {
249
- return await R(this.apiClient, t);
275
+ return await _(this.apiClient, t);
250
276
  }
251
277
  /**
252
278
  * Get firmware update status.
@@ -256,7 +282,7 @@ class x {
256
282
  * @returns {Promise<UpdateStatus>} A promise that resolves to the update status.
257
283
  */
258
284
  async UpdateStatusGet(t) {
259
- return await F(this.apiClient, t);
285
+ return await W(this.apiClient, t);
260
286
  }
261
287
  /**
262
288
  * Get firmware update changelog.
@@ -267,7 +293,7 @@ class x {
267
293
  * @returns {Promise<UpdateChangelog>} A promise that resolves to the changelog content.
268
294
  */
269
295
  async UpdateChangelogGet(t) {
270
- return await W(this.apiClient, t);
296
+ return await M(this.apiClient, t);
271
297
  }
272
298
  /**
273
299
  * Start firmware update installation.
@@ -278,7 +304,7 @@ class x {
278
304
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
279
305
  */
280
306
  async UpdateInstall(t) {
281
- return await M(this.apiClient, t);
307
+ return await N(this.apiClient, t);
282
308
  }
283
309
  /**
284
310
  * Abort firmware update download.
@@ -288,20 +314,40 @@ class x {
288
314
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
289
315
  */
290
316
  async UpdateAbort(t) {
291
- return await N(this.apiClient, t);
317
+ return await q(this.apiClient, t);
318
+ }
319
+ /**
320
+ * Get current auto-update settings.
321
+ *
322
+ * @param {TimeoutOptions} [params] - Optional parameters.
323
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
324
+ * @returns {Promise<AutoUpdateSettings>} A promise that resolves to the current auto-update settings.
325
+ */
326
+ async UpdateAutoUpdateGet(t) {
327
+ return await x(this.apiClient, t);
328
+ }
329
+ /**
330
+ * Set auto-update settings.
331
+ *
332
+ * @param {AutoUpdateParams} params - Parameters for auto-update settings.
333
+ * @param {AutoUpdateParams['is_enabled']} params.is_enabled - Whether auto-update is enabled.
334
+ * @param {AutoUpdateParams['interval_start']} params.interval_start - Auto-update interval start time (HH:mm).
335
+ * @param {AutoUpdateParams['interval_end']} params.interval_end - Auto-update interval end time (HH:mm).
336
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
337
+ * @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
338
+ */
339
+ async UpdateAutoUpdateSet(t) {
340
+ return await V(this.apiClient, t);
292
341
  }
293
342
  }
294
- async function _(n, t) {
295
- const { data: e, error: i } = await s(
296
- (r) => n.GET("/time", { signal: r }),
297
- t == null ? void 0 : t.timeout
298
- );
299
- if (i)
300
- throw i;
301
- return e;
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;
302
348
  }
303
- async function q(n, t) {
304
- const { data: e, error: i } = await s(
349
+ async function H(n, t) {
350
+ const { data: i, error: e } = await s(
305
351
  (r) => n.POST("/time/timestamp", {
306
352
  params: {
307
353
  query: { ...t, timeout: void 0 }
@@ -310,21 +356,18 @@ async function q(n, t) {
310
356
  }),
311
357
  t.timeout
312
358
  );
313
- if (i)
314
- throw i;
315
- return e;
359
+ if (e)
360
+ throw e;
361
+ return i;
316
362
  }
317
- async function V(n, t) {
318
- const { data: e, error: i } = await s(
319
- (r) => n.GET("/time/timezone", { signal: r }),
320
- t == null ? void 0 : t.timeout
321
- );
322
- if (i)
323
- throw i;
324
- return e;
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;
325
368
  }
326
- async function j(n, t) {
327
- const { data: e, error: i } = await s(
369
+ async function X(n, t) {
370
+ const { data: i, error: e } = await s(
328
371
  (r) => n.POST("/time/timezone", {
329
372
  params: {
330
373
  query: { ...t, timeout: void 0 }
@@ -333,20 +376,17 @@ async function j(n, t) {
333
376
  }),
334
377
  t.timeout
335
378
  );
336
- if (i)
337
- throw i;
338
- return e;
379
+ if (e)
380
+ throw e;
381
+ return i;
339
382
  }
340
- async function z(n, t) {
341
- const { data: e, error: i } = await s(
342
- (r) => n.GET("/time/tzlist", { signal: r }),
343
- t == null ? void 0 : t.timeout
344
- );
345
- if (i)
346
- throw i;
347
- return e;
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;
348
388
  }
349
- class H {
389
+ class Q {
350
390
  /**
351
391
  * Get current timestamp info.
352
392
  *
@@ -355,7 +395,7 @@ class H {
355
395
  * @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
356
396
  */
357
397
  async TimeGet(t) {
358
- return await _(this.apiClient, t);
398
+ return await z(this.apiClient, t);
359
399
  }
360
400
  /**
361
401
  * Set system timestamp.
@@ -366,7 +406,7 @@ class H {
366
406
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
367
407
  */
368
408
  async TimeTimestampSet(t) {
369
- return await q(this.apiClient, t);
409
+ return await H(this.apiClient, t);
370
410
  }
371
411
  /**
372
412
  * Get current timezone.
@@ -376,7 +416,7 @@ class H {
376
416
  * @returns {Promise<TimezoneInfo>} A promise that resolves to the timezone information.
377
417
  */
378
418
  async TimeTimezoneGet(t) {
379
- return await V(this.apiClient, t);
419
+ return await J(this.apiClient, t);
380
420
  }
381
421
  /**
382
422
  * Set system timezone.
@@ -387,7 +427,7 @@ class H {
387
427
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
388
428
  */
389
429
  async TimeTimezoneSet(t) {
390
- return await j(this.apiClient, t);
430
+ return await X(this.apiClient, t);
391
431
  }
392
432
  /**
393
433
  * Get list of supported timezones.
@@ -397,42 +437,33 @@ class H {
397
437
  * @returns {Promise<TimezoneList>} A promise that resolves to a list of timezone items.
398
438
  */
399
439
  async TimeTzListGet(t) {
400
- return await z(this.apiClient, t);
440
+ return await Y(this.apiClient, t);
401
441
  }
402
442
  }
403
- async function J(n, t) {
404
- const { data: e, error: i } = await s(
405
- (r) => n.GET("/account/status", { signal: r }),
406
- t == null ? void 0 : t.timeout
407
- );
408
- if (i)
409
- throw i;
410
- return e;
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;
411
448
  }
412
- async function X(n, t) {
413
- const { data: e, error: i } = await s(
414
- (r) => n.GET("/account/info", { signal: r }),
415
- t == null ? void 0 : t.timeout
416
- );
417
- if (i)
418
- throw i;
419
- return e;
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;
420
454
  }
421
- async function Q(n, t) {
422
- const { data: e, error: i } = await s(
423
- (r) => n.GET("/account/profile", { signal: r }),
424
- t == null ? void 0 : t.timeout
425
- );
426
- if (i)
427
- throw i;
428
- return e;
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;
429
460
  }
430
- async function Y(n, t) {
431
- const { profile: e } = t, { data: i, error: r } = await s(
461
+ async function it(n, t) {
462
+ const { profile: i } = t, { data: e, error: r } = await s(
432
463
  (o) => n.POST("/account/profile", {
433
464
  params: {
434
465
  query: {
435
- profile: e
466
+ profile: i
436
467
  }
437
468
  },
438
469
  signal: o
@@ -441,27 +472,21 @@ async function Y(n, t) {
441
472
  );
442
473
  if (r)
443
474
  throw r;
444
- return i;
445
- }
446
- async function Z(n, t) {
447
- const { data: e, error: i } = await s(
448
- (r) => n.DELETE("/account", { signal: r }),
449
- t == null ? void 0 : t.timeout
450
- );
451
- if (i)
452
- throw i;
453
475
  return e;
454
476
  }
455
- async function tt(n, t) {
456
- const { data: e, error: i } = await s(
457
- (r) => n.POST("/account/link", { signal: r }),
458
- t == null ? void 0 : t.timeout
459
- );
460
- if (i)
461
- throw i;
462
- return e;
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;
463
488
  }
464
- class et {
489
+ class ot {
465
490
  /**
466
491
  * Get account info.
467
492
  *
@@ -470,7 +495,7 @@ class et {
470
495
  * @returns {Promise<AccountInfo>} A promise that resolves to the account information.
471
496
  */
472
497
  async AccountInfoGet(t) {
473
- return await X(this.apiClient, t);
498
+ return await tt(this.apiClient, t);
474
499
  }
475
500
  /**
476
501
  * Get account state.
@@ -480,7 +505,7 @@ class et {
480
505
  * @returns {Promise<AccountState>} A promise that resolves to the account state.
481
506
  */
482
507
  async AccountStateGet(t) {
483
- return await J(this.apiClient, t);
508
+ return await Z(this.apiClient, t);
484
509
  }
485
510
  /**
486
511
  * Get account profile.
@@ -490,7 +515,7 @@ class et {
490
515
  * @returns {Promise<AccountProfile>} A promise that resolves to the account profile.
491
516
  */
492
517
  async AccountProfileGet(t) {
493
- return await Q(this.apiClient, t);
518
+ return await et(this.apiClient, t);
494
519
  }
495
520
  /**
496
521
  * Set account profile.
@@ -501,7 +526,7 @@ class et {
501
526
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
502
527
  */
503
528
  async AccountProfileSet(t) {
504
- return await Y(this.apiClient, t);
529
+ return await it(this.apiClient, t);
505
530
  }
506
531
  /**
507
532
  * Unlink device from account. Removes association with the current account.
@@ -511,7 +536,7 @@ class et {
511
536
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful unlinking.
512
537
  */
513
538
  async AccountUnlink(t) {
514
- return await Z(this.apiClient, t);
539
+ return await nt(this.apiClient, t);
515
540
  }
516
541
  /**
517
542
  * Link device to account. Requests account link PIN. Works only if device is connected to MQTT and is not linked to account.
@@ -521,39 +546,37 @@ class et {
521
546
  * @returns {Promise<AccountLink>} A promise that resolves to the link information (e.g., PIN).
522
547
  */
523
548
  async AccountLink(t) {
524
- return await tt(this.apiClient, t);
549
+ return await rt(this.apiClient, t);
525
550
  }
526
551
  }
527
- async function it(n, t) {
528
- const { appId: e, elements: i } = t, { data: r, error: o } = await s(
529
- (a) => n.POST("/display/draw", {
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", {
530
555
  body: {
531
- app_id: e,
532
- elements: i
556
+ app_id: i,
557
+ priority: r,
558
+ elements: e
533
559
  },
534
- signal: a
560
+ signal: u
535
561
  }),
536
562
  t.timeout
537
563
  );
538
- if (o)
539
- throw o;
540
- return r;
541
- }
542
- async function nt(n, t) {
543
- const { data: e, error: i } = await s(
544
- (r) => n.DELETE("/display/draw", { signal: r }),
545
- t == null ? void 0 : t.timeout
546
- );
547
- if (i)
548
- throw i;
549
- return e;
564
+ if (a)
565
+ throw a;
566
+ return o;
567
+ }
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;
550
573
  }
551
- async function rt(n, t) {
552
- const { display: e } = t, { data: i, error: r } = await s(
574
+ async function ct(n, t) {
575
+ const { display: i } = t, { data: e, error: r } = await s(
553
576
  (o) => n.GET("/screen", {
554
577
  params: {
555
578
  query: {
556
- display: e
579
+ display: i
557
580
  }
558
581
  },
559
582
  parseAs: "blob",
@@ -563,54 +586,51 @@ async function rt(n, t) {
563
586
  );
564
587
  if (r)
565
588
  throw r;
566
- return i;
567
- }
568
- async function ot(n, t) {
569
- const { data: e, error: i } = await s(
570
- (r) => n.GET("/display/brightness", { signal: r }),
571
- t == null ? void 0 : t.timeout
572
- );
573
- if (i)
574
- throw i;
575
589
  return e;
576
590
  }
577
- async function st(n, t) {
578
- const { front: e, back: i } = t, r = (h) => {
579
- if (typeof h == "number") {
580
- if (h < 0 || h > 100)
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)
581
601
  throw new Error("Brightness value must be between 0 and 100 or 'auto'");
582
- return String(h);
602
+ return String(u);
583
603
  }
584
- if (h === "auto")
604
+ if (u === "auto")
585
605
  return "auto";
586
- }, o = r(e), a = r(i), { data: d, error: f } = await s(
587
- (h) => n.POST("/display/brightness", {
606
+ })(i), { data: o, error: a } = await s(
607
+ (u) => n.POST("/display/brightness", {
588
608
  params: {
589
609
  query: {
590
- front: o,
591
- back: a
610
+ value: r
592
611
  }
593
612
  },
594
- signal: h
613
+ signal: u
595
614
  }),
596
615
  t.timeout
597
616
  );
598
- if (f)
599
- throw f;
600
- return d;
617
+ if (a)
618
+ throw a;
619
+ return o;
601
620
  }
602
- class at {
621
+ class dt {
603
622
  /**
604
623
  * Draw on display. Starts the Canvas application if not running.
605
624
  *
606
625
  * @param {DrawParams} params - Parameters for the draw operation.
607
- * @param {string} params.appId - Application ID.
608
- * @param {any} params.elements - Display elements to draw.
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).
609
629
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
610
630
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
611
631
  */
612
632
  async DisplayDraw(t) {
613
- return await it(this.apiClient, t);
633
+ return await st(this.apiClient, t);
614
634
  }
615
635
  /**
616
636
  * Clear display. Clears the display and stops the Canvas application if running.
@@ -620,7 +640,7 @@ class at {
620
640
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
621
641
  */
622
642
  async DisplayClear(t) {
623
- return await nt(this.apiClient, t);
643
+ return await at(this.apiClient, t);
624
644
  }
625
645
  /**
626
646
  * Get single frame for requested screen.
@@ -631,7 +651,7 @@ class at {
631
651
  * @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
632
652
  */
633
653
  async DisplayScreenFrameGet(t) {
634
- return await rt(this.apiClient, t);
654
+ return await ct(this.apiClient, t);
635
655
  }
636
656
  /**
637
657
  * Get display brightness.
@@ -641,28 +661,27 @@ class at {
641
661
  * @returns {Promise<DisplayBrightnessInfo>} A promise that resolves to the brightness information.
642
662
  */
643
663
  async DisplayBrightnessGet(t) {
644
- return await ot(this.apiClient, t);
664
+ return await ut(this.apiClient, t);
645
665
  }
646
666
  /**
647
667
  * Set display brightness.
648
668
  *
649
669
  * @param {BrightnessParams} params - Brightness parameters:
650
- * @param {number|"auto"} [params.front] - Front brightness (0-100 or "auto").
651
- * @param {number|"auto"} [params.back] - Back brightness (0-100 or "auto").
670
+ * @param {BrightnessParams['value']} [params.value] - Brightness (0-100 or "auto").
652
671
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
653
672
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
654
673
  */
655
674
  async DisplayBrightnessSet(t) {
656
- return await st(this.apiClient, t);
675
+ return await ht(this.apiClient, t);
657
676
  }
658
677
  }
659
- async function ct(n, t) {
660
- const { appId: e, path: i } = t, { data: r, error: o } = await s(
678
+ async function ft(n, t) {
679
+ const { appId: i, path: e } = t, { data: r, error: o } = await s(
661
680
  (a) => n.POST("/audio/play", {
662
681
  params: {
663
682
  query: {
664
- app_id: e,
665
- path: i
683
+ app_id: i,
684
+ path: e
666
685
  }
667
686
  },
668
687
  signal: a
@@ -673,33 +692,27 @@ async function ct(n, t) {
673
692
  throw o;
674
693
  return r;
675
694
  }
676
- async function ut(n, t) {
677
- const { data: e, error: i } = await s(
678
- (r) => n.DELETE("/audio/play", { signal: r }),
679
- t == null ? void 0 : t.timeout
680
- );
681
- if (i)
682
- throw i;
683
- return e;
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;
684
700
  }
685
- async function ht(n, t) {
686
- const { data: e, error: i } = await s(
687
- (r) => n.GET("/audio/volume", { signal: r }),
688
- t == null ? void 0 : t.timeout
689
- );
690
- if (i)
691
- throw i;
692
- return e;
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;
693
706
  }
694
- async function dt(n, t) {
695
- const { volume: e } = t;
696
- if (typeof e != "number" || e < 0 || e > 100)
707
+ async function yt(n, t) {
708
+ const { volume: i } = t;
709
+ if (typeof i != "number" || i < 0 || i > 100)
697
710
  throw new Error("Volume must be a number between 0 and 100");
698
- const { data: i, error: r } = await s(
711
+ const { data: e, error: r } = await s(
699
712
  (o) => n.POST("/audio/volume", {
700
713
  params: {
701
714
  query: {
702
- volume: e
715
+ volume: i
703
716
  }
704
717
  },
705
718
  signal: o
@@ -708,9 +721,9 @@ async function dt(n, t) {
708
721
  );
709
722
  if (r)
710
723
  throw r;
711
- return i;
724
+ return e;
712
725
  }
713
- class ft {
726
+ class pt {
714
727
  /**
715
728
  * Play audio file. Plays a file from internal storage.
716
729
  *
@@ -721,7 +734,7 @@ class ft {
721
734
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
722
735
  */
723
736
  async AudioPlay(t) {
724
- return await ct(this.apiClient, t);
737
+ return await ft(this.apiClient, t);
725
738
  }
726
739
  /**
727
740
  * Stop audio playback. Stops any currently playing audio.
@@ -731,7 +744,7 @@ class ft {
731
744
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
732
745
  */
733
746
  async AudioStop(t) {
734
- return await ut(this.apiClient, t);
747
+ return await wt(this.apiClient, t);
735
748
  }
736
749
  /**
737
750
  * Get audio volume.
@@ -741,7 +754,7 @@ class ft {
741
754
  * @returns {Promise<AudioVolumeInfo>} A promise that resolves to the audio volume information.
742
755
  */
743
756
  async AudioVolumeGet(t) {
744
- return await ht(this.apiClient, t);
757
+ return await lt(this.apiClient, t);
745
758
  }
746
759
  /**
747
760
  * Set audio volume.
@@ -752,20 +765,17 @@ class ft {
752
765
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
753
766
  */
754
767
  async AudioVolumeSet(t) {
755
- return await dt(this.apiClient, t);
768
+ return await yt(this.apiClient, t);
756
769
  }
757
770
  }
758
- async function wt(n, t) {
759
- const { data: e, error: i } = await s(
760
- (r) => n.GET("/wifi/status", { signal: r }),
761
- t == null ? void 0 : t.timeout
762
- );
763
- if (i)
764
- throw i;
765
- return e;
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;
766
776
  }
767
- async function lt(n, t) {
768
- const { data: e, error: i } = await s(
777
+ async function Tt(n, t) {
778
+ const { data: i, error: e } = await s(
769
779
  (r) => n.POST("/wifi/connect", {
770
780
  body: {
771
781
  ssid: t.ssid,
@@ -782,29 +792,23 @@ async function lt(n, t) {
782
792
  }),
783
793
  t.timeout
784
794
  );
785
- if (i)
786
- throw i;
787
- return e;
795
+ if (e)
796
+ throw e;
797
+ return i;
788
798
  }
789
- async function yt(n, t) {
790
- const { data: e, error: i } = await s(
791
- (r) => n.POST("/wifi/disconnect", { signal: r }),
792
- t == null ? void 0 : t.timeout
793
- );
794
- if (i)
795
- throw i;
796
- return e;
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;
797
804
  }
798
- async function pt(n, t) {
799
- const { data: e, error: i } = await s(
800
- (r) => n.GET("/wifi/networks", { signal: r }),
801
- t == null ? void 0 : t.timeout
802
- );
803
- if (i)
804
- throw i;
805
- return e;
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;
806
810
  }
807
- class St {
811
+ class Ct {
808
812
  /**
809
813
  * Returns current Wi-Fi status.
810
814
  *
@@ -813,7 +817,7 @@ class St {
813
817
  * @returns {Promise<WifiStatusResponse>} A promise that resolves to the Wi-Fi status.
814
818
  */
815
819
  async WifiStatusGet(t) {
816
- return await wt(this.apiClient, t);
820
+ return await St(this.apiClient, t);
817
821
  }
818
822
  /**
819
823
  * Connects to Wi-Fi network.
@@ -827,7 +831,7 @@ class St {
827
831
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
828
832
  */
829
833
  async WifiConnect(t) {
830
- return await lt(this.apiClient, t);
834
+ return await Tt(this.apiClient, t);
831
835
  }
832
836
  /**
833
837
  * Disconnects from Wi-Fi.
@@ -837,7 +841,7 @@ class St {
837
841
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
838
842
  */
839
843
  async WifiDisconnect(t) {
840
- return await yt(this.apiClient, t);
844
+ return await Et(this.apiClient, t);
841
845
  }
842
846
  /**
843
847
  * Scans environment for available Wi-Fi networks.
@@ -847,21 +851,21 @@ class St {
847
851
  * @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
848
852
  */
849
853
  async WifiNetworksGet(t) {
850
- return await pt(this.apiClient, t);
854
+ return await mt(this.apiClient, t);
851
855
  }
852
856
  }
853
- async function Tt(n, t) {
854
- const { path: e, file: i } = t, { data: r, error: o } = await s(
857
+ async function kt(n, t) {
858
+ const { path: i, file: e } = t, { data: r, error: o } = await s(
855
859
  (a) => n.POST("/storage/write", {
856
860
  params: {
857
861
  query: {
858
- path: e
862
+ path: i
859
863
  }
860
864
  },
861
865
  headers: {
862
866
  "Content-Type": "application/octet-stream"
863
867
  },
864
- body: i,
868
+ body: e,
865
869
  signal: a
866
870
  }),
867
871
  t.timeout
@@ -870,15 +874,15 @@ async function Tt(n, t) {
870
874
  throw o;
871
875
  return r;
872
876
  }
873
- async function Et(n, t) {
874
- const { path: e, asArrayBuffer: i } = t, { data: r, error: o } = await s(
877
+ async function gt(n, t) {
878
+ const { path: i, asArrayBuffer: e } = t, { data: r, error: o } = await s(
875
879
  (a) => n.GET("/storage/read", {
876
880
  params: {
877
881
  query: {
878
- path: e
882
+ path: i
879
883
  }
880
884
  },
881
- parseAs: i ? "arrayBuffer" : "blob",
885
+ parseAs: e ? "arrayBuffer" : "blob",
882
886
  signal: a
883
887
  }),
884
888
  t.timeout
@@ -887,12 +891,12 @@ async function Et(n, t) {
887
891
  throw o;
888
892
  return r;
889
893
  }
890
- async function mt(n, t) {
891
- const { path: e } = t, { data: i, error: r } = await s(
894
+ async function At(n, t) {
895
+ const { path: i } = t, { data: e, error: r } = await s(
892
896
  (o) => n.GET("/storage/list", {
893
897
  params: {
894
898
  query: {
895
- path: e
899
+ path: i
896
900
  }
897
901
  },
898
902
  signal: o
@@ -901,14 +905,14 @@ async function mt(n, t) {
901
905
  );
902
906
  if (r)
903
907
  throw r;
904
- return i;
908
+ return e;
905
909
  }
906
- async function kt(n, t) {
907
- const { path: e } = t, { data: i, error: r } = await s(
910
+ async function bt(n, t) {
911
+ const { path: i } = t, { data: e, error: r } = await s(
908
912
  (o) => n.DELETE("/storage/remove", {
909
913
  params: {
910
914
  query: {
911
- path: e
915
+ path: i
912
916
  }
913
917
  },
914
918
  signal: o
@@ -917,14 +921,14 @@ async function kt(n, t) {
917
921
  );
918
922
  if (r)
919
923
  throw r;
920
- return i;
924
+ return e;
921
925
  }
922
- async function Ct(n, t) {
923
- const { path: e } = t, { data: i, error: r } = await s(
926
+ async function vt(n, t) {
927
+ const { path: i } = t, { data: e, error: r } = await s(
924
928
  (o) => n.POST("/storage/mkdir", {
925
929
  params: {
926
930
  query: {
927
- path: e
931
+ path: i
928
932
  }
929
933
  },
930
934
  signal: o
@@ -933,18 +937,32 @@ async function Ct(n, t) {
933
937
  );
934
938
  if (r)
935
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;
936
946
  return i;
937
947
  }
938
- async function gt(n, t) {
939
- const { data: e, error: i } = await s(
940
- (r) => n.GET("/storage/status", { signal: r }),
941
- t == null ? void 0 : t.timeout
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
+ params: {
952
+ query: {
953
+ path: i,
954
+ new_path: e
955
+ }
956
+ },
957
+ signal: a
958
+ }),
959
+ t.timeout
942
960
  );
943
- if (i)
944
- throw i;
945
- return e;
961
+ if (o)
962
+ throw o;
963
+ return r;
946
964
  }
947
- class bt {
965
+ class Lt {
948
966
  /**
949
967
  * Upload file to internal storage. Uploads a file to a specified path.
950
968
  *
@@ -955,7 +973,7 @@ class bt {
955
973
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful upload.
956
974
  */
957
975
  async StorageWrite(t) {
958
- return await Tt(this.apiClient, t);
976
+ return await kt(this.apiClient, t);
959
977
  }
960
978
  /**
961
979
  * Download file from internal storage. Downloads a file from a specified path.
@@ -967,7 +985,7 @@ class bt {
967
985
  * @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
968
986
  */
969
987
  async StorageRead(t) {
970
- return await Et(this.apiClient, t);
988
+ return await gt(this.apiClient, t);
971
989
  }
972
990
  /**
973
991
  * List files on internal storage.
@@ -978,7 +996,7 @@ class bt {
978
996
  * @returns {Promise<StorageList>} A promise that resolves to a list of files and directories.
979
997
  */
980
998
  async StorageListGet(t) {
981
- return await mt(this.apiClient, t);
999
+ return await At(this.apiClient, t);
982
1000
  }
983
1001
  /**
984
1002
  * Remove a file on internal storage. Removes a file with a specified path.
@@ -989,7 +1007,7 @@ class bt {
989
1007
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful removal.
990
1008
  */
991
1009
  async StorageRemove(t) {
992
- return await kt(this.apiClient, t);
1010
+ return await bt(this.apiClient, t);
993
1011
  }
994
1012
  /**
995
1013
  * Create a directory on internal storage. Creates a new directory with a specified path.
@@ -1000,7 +1018,7 @@ class bt {
1000
1018
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
1001
1019
  */
1002
1020
  async StorageMkdir(t) {
1003
- return await Ct(this.apiClient, t);
1021
+ return await vt(this.apiClient, t);
1004
1022
  }
1005
1023
  /**
1006
1024
  * Show storage usage.
@@ -1010,28 +1028,37 @@ class bt {
1010
1028
  * @returns {Promise<StorageStatus>} A promise that resolves to the storage status.
1011
1029
  */
1012
1030
  async StorageStatusGet(t) {
1013
- return await gt(this.apiClient, t);
1031
+ return await Gt(this.apiClient, t);
1032
+ }
1033
+ /**
1034
+ * Rename/move a file. Moves a file to a new location.
1035
+ *
1036
+ * @param {RenameParams} params - Rename parameters:
1037
+ * @param {RenameParams['path']} params.path - Current path of the file or directory.
1038
+ * @param {RenameParams['new_path']} params.new_path - New path for the file or directory.
1039
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1040
+ * @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
1041
+ */
1042
+ async StorageRename(t) {
1043
+ return await Pt(this.apiClient, t);
1014
1044
  }
1015
1045
  }
1016
- async function At(n, t) {
1017
- const { data: e, error: i } = await s(
1018
- (r) => n.GET("/access", { signal: r }),
1019
- t == null ? void 0 : t.timeout
1020
- );
1021
- if (i)
1022
- throw i;
1023
- return e;
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;
1024
1051
  }
1025
- async function vt(n, t) {
1026
- let { mode: e, key: i } = t;
1027
- if (i = i ?? "", String(i).trim() && !/^\d{4,10}$/.test(String(i)))
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)))
1028
1055
  throw new Error("Key must be a string of 4 to 10 digits");
1029
1056
  const { data: r, error: o } = await s(
1030
1057
  (a) => n.POST("/access", {
1031
1058
  params: {
1032
1059
  query: {
1033
- mode: e,
1034
- key: i
1060
+ mode: i,
1061
+ key: e
1035
1062
  }
1036
1063
  },
1037
1064
  signal: a
@@ -1042,28 +1069,25 @@ async function vt(n, t) {
1042
1069
  throw o;
1043
1070
  return r;
1044
1071
  }
1045
- async function Pt(n, t) {
1046
- const { data: e, error: i } = await s(
1047
- (r) => n.GET("/name", { signal: r }),
1048
- t == null ? void 0 : t.timeout
1049
- );
1050
- if (i)
1051
- throw i;
1052
- return e;
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;
1053
1077
  }
1054
- async function Gt(n, t) {
1055
- const { data: e, error: i } = await s(
1078
+ async function Bt(n, t) {
1079
+ const { data: i, error: e } = await s(
1056
1080
  (r) => n.POST("/name", {
1057
1081
  body: t,
1058
1082
  signal: r
1059
1083
  }),
1060
1084
  t.timeout
1061
1085
  );
1062
- if (i)
1063
- throw i;
1064
- return e;
1086
+ if (e)
1087
+ throw e;
1088
+ return i;
1065
1089
  }
1066
- class Lt {
1090
+ class It {
1067
1091
  /**
1068
1092
  * Get HTTP API access over Wi-Fi configuration.
1069
1093
  *
@@ -1072,7 +1096,7 @@ class Lt {
1072
1096
  * @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
1073
1097
  */
1074
1098
  async SettingsAccessGet(t) {
1075
- return await At(this.apiClient, t);
1099
+ return await Ot(this.apiClient, t);
1076
1100
  }
1077
1101
  /**
1078
1102
  * Set HTTP API access over Wi-Fi configuration.
@@ -1084,8 +1108,8 @@ class Lt {
1084
1108
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1085
1109
  */
1086
1110
  async SettingsAccessSet(t) {
1087
- const e = await vt(this.apiClient, t);
1088
- return t.mode === "key" && t.key && this.setApiKey(t.key), e;
1111
+ const i = await Dt(this.apiClient, t);
1112
+ return t.mode === "key" && t.key && this.setApiKey(t.key), i;
1089
1113
  }
1090
1114
  /**
1091
1115
  * Get current device name.
@@ -1095,7 +1119,7 @@ class Lt {
1095
1119
  * @returns {Promise<NameInfo>} A promise that resolves to the device name.
1096
1120
  */
1097
1121
  async SettingsNameGet(t) {
1098
- return await Pt(this.apiClient, t);
1122
+ return await Ut(this.apiClient, t);
1099
1123
  }
1100
1124
  /**
1101
1125
  * Set device name.
@@ -1106,46 +1130,34 @@ class Lt {
1106
1130
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1107
1131
  */
1108
1132
  async SettingsNameSet(t) {
1109
- return await Gt(this.apiClient, t);
1133
+ return await Bt(this.apiClient, t);
1110
1134
  }
1111
1135
  }
1112
- async function Ot(n, t) {
1113
- const { data: e, error: i } = await s(
1114
- (r) => n.POST("/ble/enable", { signal: r }),
1115
- t == null ? void 0 : t.timeout
1116
- );
1117
- if (i)
1118
- throw i;
1119
- return e;
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;
1120
1141
  }
1121
- async function Dt(n, t) {
1122
- const { data: e, error: i } = await s(
1123
- (r) => n.POST("/ble/disable", { signal: r }),
1124
- t == null ? void 0 : t.timeout
1125
- );
1126
- if (i)
1127
- throw i;
1128
- return e;
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;
1129
1147
  }
1130
- async function Bt(n, t) {
1131
- const { data: e, error: i } = await s(
1132
- (r) => n.DELETE("/ble/pairing", { signal: r }),
1133
- t == null ? void 0 : t.timeout
1134
- );
1135
- if (i)
1136
- throw i;
1137
- return e;
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;
1138
1153
  }
1139
- async function Ut(n, t) {
1140
- const { data: e, error: i } = await s(
1141
- (r) => n.GET("/ble/status", { signal: r }),
1142
- t == null ? void 0 : t.timeout
1143
- );
1144
- if (i)
1145
- throw i;
1146
- return e;
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;
1147
1159
  }
1148
- class $t {
1160
+ class _t {
1149
1161
  /**
1150
1162
  * Enable BLE. Starts advertising.
1151
1163
  *
@@ -1154,7 +1166,7 @@ class $t {
1154
1166
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1155
1167
  */
1156
1168
  async BleEnable(t) {
1157
- return await Ot(this.apiClient, t);
1169
+ return await $t(this.apiClient, t);
1158
1170
  }
1159
1171
  /**
1160
1172
  * Disable BLE. Stops advertising.
@@ -1164,7 +1176,7 @@ class $t {
1164
1176
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1165
1177
  */
1166
1178
  async BleDisable(t) {
1167
- return await Dt(this.apiClient, t);
1179
+ return await Rt(this.apiClient, t);
1168
1180
  }
1169
1181
  /**
1170
1182
  * Remove pairing. Remove pairing with previous device.
@@ -1174,7 +1186,7 @@ class $t {
1174
1186
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1175
1187
  */
1176
1188
  async BleUnpair(t) {
1177
- return await Bt(this.apiClient, t);
1189
+ return await Kt(this.apiClient, t);
1178
1190
  }
1179
1191
  /**
1180
1192
  * Returns current BLE status.
@@ -1184,15 +1196,15 @@ class $t {
1184
1196
  * @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
1185
1197
  */
1186
1198
  async BleStatusGet(t) {
1187
- return await Ut(this.apiClient, t);
1199
+ return await Ft(this.apiClient, t);
1188
1200
  }
1189
1201
  }
1190
- async function It(n, t) {
1191
- const { keyName: e } = t, { data: i, error: r } = await s(
1202
+ async function Wt(n, t) {
1203
+ const { keyName: i } = t, { data: e, error: r } = await s(
1192
1204
  (o) => n.POST("/input", {
1193
1205
  params: {
1194
1206
  query: {
1195
- key: e
1207
+ key: i
1196
1208
  }
1197
1209
  },
1198
1210
  signal: o
@@ -1201,9 +1213,9 @@ async function It(n, t) {
1201
1213
  );
1202
1214
  if (r)
1203
1215
  throw r;
1204
- return i;
1216
+ return e;
1205
1217
  }
1206
- class Kt {
1218
+ class Mt {
1207
1219
  /**
1208
1220
  * Send input event. Send single key press event.
1209
1221
  *
@@ -1213,37 +1225,28 @@ class Kt {
1213
1225
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1214
1226
  */
1215
1227
  async InputSend(t) {
1216
- return await It(this.apiClient, t);
1228
+ return await Wt(this.apiClient, t);
1217
1229
  }
1218
1230
  }
1219
- async function Rt(n, t) {
1220
- const { data: e, error: i } = await s(
1221
- (r) => n.GET("/matter/commissioning", { signal: r }),
1222
- t == null ? void 0 : t.timeout
1223
- );
1224
- if (i)
1225
- throw i;
1226
- return e;
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;
1227
1236
  }
1228
- async function Ft(n, t) {
1229
- const { data: e, error: i } = await s(
1230
- (r) => n.POST("/matter/commissioning", { signal: r }),
1231
- t == null ? void 0 : t.timeout
1232
- );
1233
- if (i)
1234
- throw i;
1235
- return e;
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;
1236
1242
  }
1237
- async function Wt(n, t) {
1238
- const { data: e, error: i } = await s(
1239
- (r) => n.DELETE("/matter/commissioning", { signal: r }),
1240
- t == null ? void 0 : t.timeout
1241
- );
1242
- if (i)
1243
- throw i;
1244
- return e;
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;
1245
1248
  }
1246
- class Mt {
1249
+ class Vt {
1247
1250
  /**
1248
1251
  * Get Matter status.
1249
1252
  *
@@ -1252,7 +1255,7 @@ class Mt {
1252
1255
  * @returns {Promise<MatterStatus>} A promise that resolves to the Matter status.
1253
1256
  */
1254
1257
  async MatterStatusGet(t) {
1255
- return await Rt(this.apiClient, t);
1258
+ return await Nt(this.apiClient, t);
1256
1259
  }
1257
1260
  /**
1258
1261
  * Pair Matter device.
@@ -1262,7 +1265,7 @@ class Mt {
1262
1265
  * @returns {Promise<MatterPairingInfo>} A promise that resolves on success.
1263
1266
  */
1264
1267
  async MatterPair(t) {
1265
- return await Ft(this.apiClient, t);
1268
+ return await qt(this.apiClient, t);
1266
1269
  }
1267
1270
  /**
1268
1271
  * Erase Matter devices.
@@ -1272,19 +1275,82 @@ class Mt {
1272
1275
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1273
1276
  */
1274
1277
  async MatterErase(t) {
1275
- return await Wt(this.apiClient, t);
1278
+ return await xt(this.apiClient, t);
1276
1279
  }
1277
1280
  }
1278
- const S = "http://10.0.4.20", Nt = "https://proxy.busy.app", xt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
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", {
1284
+ params: {
1285
+ query: {
1286
+ app_id: i,
1287
+ file: e
1288
+ }
1289
+ },
1290
+ headers: {
1291
+ "Content-Type": "application/octet-stream"
1292
+ },
1293
+ body: r,
1294
+ signal: u
1295
+ }),
1296
+ t.timeout
1297
+ );
1298
+ if (a)
1299
+ throw a;
1300
+ return o;
1301
+ }
1302
+ async function zt(n, t) {
1303
+ const { appId: i } = t, { data: e, error: r } = await s(
1304
+ (o) => n.DELETE("/assets/upload", {
1305
+ params: {
1306
+ query: {
1307
+ app_id: i
1308
+ }
1309
+ },
1310
+ signal: o
1311
+ }),
1312
+ t.timeout
1313
+ );
1314
+ if (r)
1315
+ throw r;
1316
+ return e;
1317
+ }
1318
+ class Ht {
1319
+ /**
1320
+ * Upload asset file with app ID. Uploads a file to a specific app's assets directory.
1321
+ *
1322
+ * @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.
1327
+ * @returns {Promise<SuccessResponse>} Result of the upload operation.
1328
+ */
1329
+ async AssetsUpload(t) {
1330
+ return await jt(this.apiClient, t);
1331
+ }
1332
+ /**
1333
+ * Delete app assets. Deletes all assets for a specific app ID.
1334
+ *
1335
+ * @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.
1338
+ * @returns {Promise<SuccessResponse>} Result of the delete operation.
1339
+ */
1340
+ async AssetsDelete(t) {
1341
+ return await zt(this.apiClient, t);
1342
+ }
1343
+ }
1344
+ const S = "http://10.0.4.20", Jt = "https://proxy.busy.app", Xt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
1279
1345
  function T(n) {
1280
1346
  const t = n.split(".");
1281
1347
  if (t.length !== 4)
1282
1348
  return !1;
1283
- for (const e of t) {
1284
- if (e.length === 0 || e.length > 1 && e[0] === "0" || !/^\d+$/.test(e))
1349
+ for (const i of t) {
1350
+ if (i.length === 0 || i.length > 1 && i[0] === "0" || !/^\d+$/.test(i))
1285
1351
  return !1;
1286
- const i = Number(e);
1287
- if (i < 0 || i > 255)
1352
+ const e = Number(i);
1353
+ if (e < 0 || e > 255)
1288
1354
  return !1;
1289
1355
  }
1290
1356
  return !0;
@@ -1292,7 +1358,7 @@ function T(n) {
1292
1358
  function E(n) {
1293
1359
  return /\.local$/i.test(n);
1294
1360
  }
1295
- class _t {
1361
+ class Yt {
1296
1362
  /**
1297
1363
  * Creates an instance of BUSY Bar.
1298
1364
  * Initializes the API client with the provided host address.
@@ -1343,20 +1409,16 @@ class _t {
1343
1409
  if (!t || !t.addr && !t.token)
1344
1410
  this.addr = S;
1345
1411
  else if (!t.addr)
1346
- this.addr = Nt;
1412
+ this.addr = Jt;
1347
1413
  else {
1348
1414
  let o = t.addr.trim();
1349
- if (/^https?:\/\//i.test(o) || (o = `http://${o}`), xt.test(o) && !t.token)
1415
+ if (/^https?:\/\//i.test(o) || (o = `http://${o}`), Xt.test(o) && !t.token)
1350
1416
  throw new Error("Token is required. Please provide it.");
1351
1417
  this.addr = o;
1352
1418
  }
1353
1419
  this.apiSemver = "";
1354
- const { client: e, setApiKey: i, setToken: r } = O(
1355
- `${this.addr}/api/`,
1356
- this.SystemVersionGet.bind(this),
1357
- t == null ? void 0 : t.token
1358
- );
1359
- this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn = r, this.detectConnectionType();
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();
1360
1422
  }
1361
1423
  /**
1362
1424
  * Probes the device to determine connection type.
@@ -1368,21 +1430,19 @@ class _t {
1368
1430
  this.connectionType = "wifi";
1369
1431
  return;
1370
1432
  }
1371
- const e = m({
1433
+ const i = m({
1372
1434
  baseUrl: `${this.addr}/api/`
1373
1435
  });
1374
1436
  try {
1375
- const { response: i } = await e.GET("/name");
1376
- if (i.status === 401 || i.status === 403)
1437
+ const { response: e } = await i.GET("/name");
1438
+ if (e.status === 401 || e.status === 403)
1377
1439
  this.connectionType = "wifi";
1378
- else if (i.ok)
1440
+ else if (e.ok)
1379
1441
  this.connectionType = "usb";
1380
1442
  else
1381
- throw new Error(
1382
- `Failed to detect connection type. Status: ${i.status}`
1383
- );
1384
- } catch (i) {
1385
- throw i;
1443
+ throw new Error(`Failed to detect connection type. Status: ${e.status}`);
1444
+ } catch (e) {
1445
+ throw e;
1386
1446
  }
1387
1447
  }
1388
1448
  /**
@@ -1400,72 +1460,69 @@ class _t {
1400
1460
  this.setTokenFn(t);
1401
1461
  }
1402
1462
  }
1403
- function qt(n, t) {
1404
- t.forEach((e) => {
1405
- Object.getOwnPropertyNames(e.prototype).forEach((i) => {
1406
- Object.defineProperty(
1407
- n.prototype,
1408
- i,
1409
- Object.getOwnPropertyDescriptor(e.prototype, i) || /* @__PURE__ */ Object.create(null)
1410
- );
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));
1411
1467
  });
1412
1468
  });
1413
1469
  }
1414
- qt(_t, [
1415
- I,
1416
- x,
1417
- H,
1418
- et,
1419
- at,
1420
- ft,
1421
- St,
1422
- bt,
1470
+ Qt(Yt, [
1471
+ K,
1472
+ j,
1473
+ Q,
1474
+ ot,
1475
+ dt,
1476
+ pt,
1477
+ Ct,
1423
1478
  Lt,
1424
- $t,
1425
- Kt,
1426
- Mt
1479
+ It,
1480
+ _t,
1481
+ Mt,
1482
+ Vt,
1483
+ Ht
1427
1484
  ]);
1428
1485
  var p = /* @__PURE__ */ ((n) => (n[n.FRONT = 0] = "FRONT", n[n.BACK = 1] = "BACK", n))(p || {});
1429
- const k = 3e3, C = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1486
+ const C = 3e3, k = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1430
1487
  function g(n, t) {
1431
1488
  if (t < 0 || t >= n.length)
1432
1489
  throw new Error(`Index ${t} is out of bounds (0…${n.length - 1})`);
1433
- const e = n[t];
1434
- if (e === void 0)
1490
+ const i = n[t];
1491
+ if (i === void 0)
1435
1492
  throw new Error(`Unexpected undefined at index ${t}`);
1436
- return e;
1493
+ return i;
1437
1494
  }
1438
- function Vt(n, t) {
1439
- let e = 0;
1440
- const i = n.length, r = [];
1441
- for (; e < i; ) {
1442
- const o = g(n, e);
1443
- if (e += 1, (o & 128) !== 0) {
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) {
1444
1501
  const a = o & 127;
1445
- for (let d = 0; d < a * t; d++)
1446
- r.push(n[e + d]);
1447
- e += a * t;
1502
+ for (let u = 0; u < a * t; u++)
1503
+ r.push(n[i + u]);
1504
+ i += a * t;
1448
1505
  } else {
1449
- const a = o, d = n.slice(e, e + t);
1450
- for (let f = 0; f < a; f++)
1451
- for (let h = 0; h < t; h++)
1452
- r.push(d[h]);
1453
- e += t;
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;
1454
1511
  }
1455
1512
  }
1456
1513
  return new Uint8Array(r);
1457
1514
  }
1458
- function jt(n) {
1515
+ function te(n) {
1459
1516
  const t = new Uint8Array(n.length * 2);
1460
- let e = 0, i = 0;
1461
- for (; e < n.length; ) {
1462
- const r = g(n, e), o = r & 15, a = r >> 4 & 15;
1463
- t[i] = o, t[i + 1] = a, e += 1, i += 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;
1464
1521
  }
1465
1522
  return t;
1466
1523
  }
1467
- const b = () => typeof window < "u" && typeof window.document < "u";
1468
- class Jt {
1524
+ const A = () => typeof window < "u" && typeof window.document < "u";
1525
+ class ne {
1469
1526
  constructor(t) {
1470
1527
  c(this, "addr");
1471
1528
  c(this, "connected", !1);
@@ -1477,23 +1534,21 @@ class Jt {
1477
1534
  c(this, "stopListeners", []);
1478
1535
  c(this, "errorListeners", []);
1479
1536
  c(this, "socket", null);
1480
- if (this.config = t, !b())
1537
+ if (this.config = t, !A())
1481
1538
  throw new Error("not browser");
1482
1539
  if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1483
1540
  this.addr = S;
1484
1541
  else {
1485
- let e = t.addr.trim();
1486
- /^https?:\/\//i.test(e) || (e = `http://${e}`);
1542
+ let i = t.addr.trim();
1543
+ /^https?:\/\//i.test(i) || (i = `http://${i}`);
1487
1544
  try {
1488
- const r = new URL(e).hostname;
1545
+ const r = new URL(i).hostname;
1489
1546
  if (!T(r) && !E(r))
1490
- throw new Error(
1491
- `Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`
1492
- );
1493
- } catch (i) {
1494
- throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1547
+ 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}"`);
1495
1550
  }
1496
- this.addr = e;
1551
+ this.addr = i;
1497
1552
  }
1498
1553
  }
1499
1554
  onData(t) {
@@ -1506,16 +1561,16 @@ class Jt {
1506
1561
  this.errorListeners.push(t);
1507
1562
  }
1508
1563
  emitData(t) {
1509
- for (const e of this.dataListeners)
1510
- e(t);
1564
+ for (const i of this.dataListeners)
1565
+ i(t);
1511
1566
  }
1512
1567
  emitStop() {
1513
1568
  for (const t of this.stopListeners)
1514
1569
  t();
1515
1570
  }
1516
1571
  emitError(t) {
1517
- for (const e of this.errorListeners)
1518
- e(t);
1572
+ for (const i of this.errorListeners)
1573
+ i(t);
1519
1574
  }
1520
1575
  async openWebsocket() {
1521
1576
  this.socket && await this.closeWebsocket();
@@ -1524,35 +1579,35 @@ class Jt {
1524
1579
  throw new Error("The WebSocket URL is not specified");
1525
1580
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1526
1581
  this.socket && (this.socket.send(JSON.stringify({ display: this.config.deviceScreen })), this.connected = !0);
1527
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1582
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1528
1583
  try {
1529
- if (typeof e.data == "string")
1584
+ if (typeof i.data == "string")
1530
1585
  return;
1531
- const i = new Uint8Array(e.data);
1586
+ const e = new Uint8Array(i.data);
1532
1587
  let r;
1533
1588
  const o = this.config.deviceScreen === p.FRONT ? 3 : 2;
1534
1589
  try {
1535
- const a = Vt(i, o);
1536
- this.config.deviceScreen === p.BACK ? r = jt(a) : r = a, this.emitData(r);
1590
+ const a = Zt(e, o);
1591
+ this.config.deviceScreen === p.BACK ? r = te(a) : r = a, this.emitData(r);
1537
1592
  } catch {
1538
- this.emitData(i);
1593
+ this.emitData(e);
1539
1594
  }
1540
1595
  } catch {
1541
1596
  this.connected = !1, this.emitStop();
1542
1597
  }
1543
- }, this.socket.onerror = (e) => {
1598
+ }, this.socket.onerror = (i) => {
1544
1599
  this.connected = !1, this.emitError({
1545
1600
  code: 1006,
1546
1601
  // Standard «abnormal closure» code per RFC-6455
1547
1602
  message: "WebSocket error occurred",
1548
- raw: e
1603
+ raw: i
1549
1604
  }), this.emitStop();
1550
- }, this.socket.onclose = async (e) => {
1551
- if (this.socket = null, this.connected = !1, e.code === k || C.has(e.code)) {
1605
+ }, this.socket.onclose = async (i) => {
1606
+ if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1552
1607
  this.emitError({
1553
- code: e.code,
1554
- message: e.reason,
1555
- raw: e
1608
+ code: i.code,
1609
+ message: i.reason,
1610
+ raw: i
1556
1611
  });
1557
1612
  return;
1558
1613
  }
@@ -1567,7 +1622,7 @@ class Jt {
1567
1622
  });
1568
1623
  }
1569
1624
  }
1570
- class Xt {
1625
+ class re {
1571
1626
  constructor(t) {
1572
1627
  c(this, "addr");
1573
1628
  c(this, "connected", !1);
@@ -1580,23 +1635,21 @@ class Xt {
1580
1635
  c(this, "stopListeners", []);
1581
1636
  c(this, "errorListeners", []);
1582
1637
  c(this, "socket", null);
1583
- if (!b())
1638
+ if (!A())
1584
1639
  throw new Error("not browser");
1585
1640
  if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1586
1641
  this.addr = S;
1587
1642
  else {
1588
- let e = t.addr.trim();
1589
- /^https?:\/\//i.test(e) || (e = `http://${e}`);
1643
+ let i = t.addr.trim();
1644
+ /^https?:\/\//i.test(i) || (i = `http://${i}`);
1590
1645
  try {
1591
- const r = new URL(e).hostname;
1646
+ const r = new URL(i).hostname;
1592
1647
  if (!T(r) && !E(r))
1593
- throw new Error(
1594
- `Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`
1595
- );
1596
- } catch (i) {
1597
- throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1648
+ 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}"`);
1598
1651
  }
1599
- this.addr = e;
1652
+ this.addr = i;
1600
1653
  }
1601
1654
  this.inputEvent = {};
1602
1655
  }
@@ -1610,16 +1663,16 @@ class Xt {
1610
1663
  this.errorListeners.push(t);
1611
1664
  }
1612
1665
  emitData(t) {
1613
- for (const e of this.dataListeners)
1614
- e(t);
1666
+ for (const i of this.dataListeners)
1667
+ i(t);
1615
1668
  }
1616
1669
  emitStop() {
1617
1670
  for (const t of this.stopListeners)
1618
1671
  t();
1619
1672
  }
1620
1673
  emitError(t) {
1621
- for (const e of this.errorListeners)
1622
- e(t);
1674
+ for (const i of this.errorListeners)
1675
+ i(t);
1623
1676
  }
1624
1677
  async openWebsocket() {
1625
1678
  this.socket && await this.closeWebsocket();
@@ -1628,38 +1681,38 @@ class Xt {
1628
1681
  throw new Error("The WebSocket URL is not specified");
1629
1682
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1630
1683
  this.socket && (this.connected = !0);
1631
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1684
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1632
1685
  try {
1633
- if (typeof e.data == "string")
1686
+ if (typeof i.data == "string")
1634
1687
  return;
1635
- const i = new Uint8Array(e.data);
1636
- this.emitData(i);
1688
+ const e = new Uint8Array(i.data);
1689
+ this.emitData(e);
1637
1690
  } catch {
1638
1691
  this.connected = !1, this.emitStop();
1639
1692
  }
1640
- }, this.socket.onerror = (e) => {
1693
+ }, this.socket.onerror = (i) => {
1641
1694
  this.connected = !1, this.emitError({
1642
1695
  code: 1006,
1643
1696
  // Standard «abnormal closure» code per RFC-6455
1644
1697
  message: "WebSocket error occurred",
1645
- raw: e
1698
+ raw: i
1646
1699
  }), this.emitStop();
1647
- }, this.socket.onclose = async (e) => {
1648
- if (this.socket = null, this.connected = !1, e.code === k || C.has(e.code)) {
1700
+ }, this.socket.onclose = async (i) => {
1701
+ if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1649
1702
  this.emitError({
1650
- code: e.code,
1651
- message: e.reason,
1652
- raw: e
1703
+ code: i.code,
1704
+ message: i.reason,
1705
+ raw: i
1653
1706
  });
1654
1707
  return;
1655
1708
  }
1656
1709
  this.emitStop();
1657
1710
  };
1658
1711
  }
1659
- sendInput({ keyName: t, value: e }) {
1712
+ sendInput({ keyName: t, value: i }) {
1660
1713
  if (!this.socket || !this.connected)
1661
1714
  throw new Error("WebSocket: Not connected");
1662
- this.inputEvent[t] = e, this.socket.send(JSON.stringify(this.inputEvent)), e === 0 && delete this.inputEvent[t];
1715
+ this.inputEvent[t] = i, this.socket.send(JSON.stringify(this.inputEvent)), i === 0 && delete this.inputEvent[t];
1663
1716
  }
1664
1717
  closeWebsocket() {
1665
1718
  return this.connected = !1, new Promise((t) => {
@@ -1670,8 +1723,8 @@ class Xt {
1670
1723
  }
1671
1724
  }
1672
1725
  export {
1673
- _t as BusyBar,
1726
+ Yt as BusyBar,
1674
1727
  p as DeviceScreen,
1675
- Xt as Input,
1676
- Jt as ScreenStream
1728
+ re as Input,
1729
+ ne as ScreenStream
1677
1730
  };