een-api-toolkit 0.3.14 → 0.3.16

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +10 -40
  2. package/README.md +1 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +825 -0
  6. package/dist/index.js +489 -254
  7. package/dist/index.js.map +1 -1
  8. package/docs/AI-CONTEXT.md +314 -2
  9. package/examples/vue-alerts-metrics/README.md +136 -0
  10. package/examples/vue-alerts-metrics/e2e/app.spec.ts +74 -0
  11. package/examples/vue-alerts-metrics/e2e/auth.spec.ts +561 -0
  12. package/examples/vue-alerts-metrics/index.html +13 -0
  13. package/examples/vue-alerts-metrics/package-lock.json +1756 -0
  14. package/examples/vue-alerts-metrics/package.json +31 -0
  15. package/examples/vue-alerts-metrics/playwright.config.ts +46 -0
  16. package/examples/vue-alerts-metrics/src/App.vue +108 -0
  17. package/examples/vue-alerts-metrics/src/components/AlertsList.vue +881 -0
  18. package/examples/vue-alerts-metrics/src/components/CameraSelector.vue +106 -0
  19. package/examples/vue-alerts-metrics/src/components/MetricsChart.vue +336 -0
  20. package/examples/vue-alerts-metrics/src/components/NotificationsList.vue +825 -0
  21. package/examples/vue-alerts-metrics/src/components/TimeRangeSelector.vue +259 -0
  22. package/examples/vue-alerts-metrics/src/composables/useHlsPlayer.ts +285 -0
  23. package/examples/vue-alerts-metrics/src/main.ts +23 -0
  24. package/examples/vue-alerts-metrics/src/router/index.ts +61 -0
  25. package/examples/vue-alerts-metrics/src/views/Callback.vue +76 -0
  26. package/examples/vue-alerts-metrics/src/views/Dashboard.vue +174 -0
  27. package/examples/vue-alerts-metrics/src/views/Home.vue +216 -0
  28. package/examples/vue-alerts-metrics/src/views/Login.vue +33 -0
  29. package/examples/vue-alerts-metrics/src/views/Logout.vue +66 -0
  30. package/examples/vue-alerts-metrics/src/vite-env.d.ts +12 -0
  31. package/examples/vue-alerts-metrics/tsconfig.json +21 -0
  32. package/examples/vue-alerts-metrics/tsconfig.node.json +10 -0
  33. package/examples/vue-alerts-metrics/vite.config.ts +12 -0
  34. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { defineStore as ce } from "pinia";
2
- import { ref as h, computed as k } from "vue";
3
- const ue = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, le = () => {
1
+ import { defineStore as de } from "pinia";
2
+ import { ref as h, computed as O } from "vue";
3
+ const le = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, _e = () => {
4
4
  try {
5
- return ue?.VITE_DEBUG === "true";
5
+ return le?.VITE_DEBUG === "true";
6
6
  } catch {
7
7
  return !1;
8
8
  }
9
9
  };
10
10
  function c(...e) {
11
- le() && console.log("[een-api-toolkit]", ...e);
11
+ _e() && console.log("[een-api-toolkit]", ...e);
12
12
  }
13
- const ke = {
13
+ const me = {
14
14
  localStorage: "persists across sessions",
15
15
  sessionStorage: "per-tab, cleared on tab close",
16
16
  memory: "tokens lost on page refresh"
17
17
  };
18
- class de {
18
+ class fe {
19
19
  store = /* @__PURE__ */ new Map();
20
20
  getItem(n) {
21
21
  return this.store.get(n) ?? null;
@@ -27,7 +27,7 @@ class de {
27
27
  this.store.delete(n);
28
28
  }
29
29
  }
30
- class C {
30
+ class Q {
31
31
  constructor(n) {
32
32
  this.storage = n;
33
33
  }
@@ -41,142 +41,145 @@ class C {
41
41
  this.storage.removeItem(n);
42
42
  }
43
43
  }
44
- let q = "localStorage", L = null;
44
+ let q = "localStorage", b = null;
45
45
  function j() {
46
- return L || (L = new de()), L;
46
+ return b || (b = new fe()), b;
47
47
  }
48
- function fe(e) {
48
+ function ge(e) {
49
49
  q = e;
50
50
  }
51
- function $e() {
51
+ function we() {
52
52
  return q;
53
53
  }
54
- function N() {
54
+ function L() {
55
55
  switch (q) {
56
56
  case "memory":
57
57
  return j();
58
58
  case "sessionStorage":
59
- return typeof sessionStorage < "u" ? new C(sessionStorage) : (c("sessionStorage unavailable, falling back to memory storage"), j());
59
+ return typeof sessionStorage < "u" ? new Q(sessionStorage) : (c("sessionStorage unavailable, falling back to memory storage"), j());
60
60
  default:
61
- return typeof localStorage < "u" ? new C(localStorage) : (c("localStorage unavailable, falling back to memory storage"), j());
61
+ return typeof localStorage < "u" ? new Q(localStorage) : (c("localStorage unavailable, falling back to memory storage"), j());
62
62
  }
63
63
  }
64
- const I = {};
65
- let U = {};
66
- function Oe(e = {}) {
64
+ const T = {};
65
+ let y = {};
66
+ function Ne(e = {}) {
67
67
  const n = e.storageStrategy ?? "localStorage";
68
- fe(n), U = {
69
- proxyUrl: e.proxyUrl ?? I?.VITE_PROXY_URL,
70
- clientId: e.clientId ?? I?.VITE_EEN_CLIENT_ID,
71
- redirectUri: e.redirectUri ?? I?.VITE_REDIRECT_URI,
68
+ ge(n), y = {
69
+ proxyUrl: e.proxyUrl ?? T?.VITE_PROXY_URL,
70
+ clientId: e.clientId ?? T?.VITE_EEN_CLIENT_ID,
71
+ redirectUri: e.redirectUri ?? T?.VITE_REDIRECT_URI,
72
72
  storageStrategy: n,
73
- debug: e.debug ?? I?.VITE_DEBUG === "true"
73
+ debug: e.debug ?? T?.VITE_DEBUG === "true"
74
74
  };
75
75
  }
76
- function De() {
77
- return U;
76
+ function be() {
77
+ return y;
78
78
  }
79
79
  function P() {
80
- return U.proxyUrl ?? I?.VITE_PROXY_URL;
80
+ return y.proxyUrl ?? T?.VITE_PROXY_URL;
81
81
  }
82
- function _e() {
83
- return U.clientId ?? I?.VITE_EEN_CLIENT_ID;
82
+ function he() {
83
+ return y.clientId ?? T?.VITE_EEN_CLIENT_ID;
84
84
  }
85
- function z() {
86
- return U.redirectUri ?? I?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
85
+ function C() {
86
+ return y.redirectUri ?? T?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
87
87
  }
88
- function d(e) {
88
+ function l(e) {
89
89
  return { data: e, error: null };
90
90
  }
91
91
  function r(e, n, t, i) {
92
92
  return { data: null, error: { code: e, message: n, status: t, details: i } };
93
93
  }
94
+ function p(e) {
95
+ return e.endsWith("+00:00") ? e : e.endsWith("Z") ? e.replace("Z", "+00:00") : e;
96
+ }
94
97
  let F = null;
95
- function ge() {
96
- return F || (F = Promise.resolve().then(() => Ae).then((e) => e.refreshToken)), F;
98
+ function Re() {
99
+ return F || (F = Promise.resolve().then(() => ye).then((e) => e.refreshToken)), F;
97
100
  }
98
- const f = ce("een-auth", () => {
99
- const e = h(null), n = h(null), t = h(null), i = h(null), a = h(null), o = h(443), s = h(null), l = h(null), g = h(!1);
100
- let p = null;
101
- const R = h(!1), E = h(null), v = k(() => !!e.value), S = k(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), w = k(() => n.value ? Date.now() >= n.value : !0), K = k(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
102
- function G(u, _) {
103
- e.value = u, n.value = Date.now() + _ * 1e3, T(), b(), c("Token set, expires in", _, "seconds");
101
+ const _ = de("een-auth", () => {
102
+ const e = h(null), n = h(null), t = h(null), i = h(null), a = h(null), o = h(443), s = h(null), d = h(null), g = h(!1);
103
+ let E = null;
104
+ const R = h(!1), I = h(null), v = O(() => !!e.value), k = O(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), w = O(() => n.value ? Date.now() >= n.value : !0), J = O(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
105
+ function X(u, f) {
106
+ e.value = u, n.value = Date.now() + f * 1e3, A(), N(), c("Token set, expires in", f, "seconds");
104
107
  }
105
- function X(u) {
106
- t.value = u, T();
108
+ function Y(u) {
109
+ t.value = u, A();
107
110
  }
108
- function J(u) {
109
- i.value = u, T();
111
+ function Z(u) {
112
+ i.value = u, A();
110
113
  }
111
- function Y(u) {
114
+ function ee(u) {
112
115
  if (typeof u == "string")
113
116
  try {
114
- const _ = new URL(u.startsWith("http") ? u : `https://${u}`);
115
- a.value = _.hostname, o.value = _.port ? parseInt(_.port, 10) : 443;
116
- } catch (_) {
117
- c("Failed to parse URL, using as hostname:", _ instanceof Error ? _.message : String(_)), a.value = u, o.value = 443;
117
+ const f = new URL(u.startsWith("http") ? u : `https://${u}`);
118
+ a.value = f.hostname, o.value = f.port ? parseInt(f.port, 10) : 443;
119
+ } catch (f) {
120
+ c("Failed to parse URL, using as hostname:", f instanceof Error ? f.message : String(f)), a.value = u, o.value = 443;
118
121
  }
119
122
  else
120
123
  a.value = u.hostname, o.value = u.port ?? 443;
121
- T(), c("Base URL set:", S.value);
124
+ A(), c("Base URL set:", k.value);
122
125
  }
123
- function Z(u) {
124
- s.value = u, T();
126
+ function te(u) {
127
+ s.value = u, A();
125
128
  }
126
- function b() {
127
- if (l.value && (clearTimeout(l.value), l.value = null), !n.value || !e.value)
129
+ function N() {
130
+ if (d.value && (clearTimeout(d.value), d.value = null), !n.value || !e.value)
128
131
  return;
129
- const u = Date.now(), A = n.value - u, m = 300 * 1e3, oe = A / 2, ae = Math.min(m, oe), se = Math.max(A - ae, 60 * 1e3), H = Math.max(se, 5e3);
130
- c("Auto-refresh scheduled in", Math.round(H / 1e3), "seconds"), l.value = setTimeout(async () => {
131
- await ee();
132
- }, H);
132
+ const u = Date.now(), U = n.value - u, $ = 300 * 1e3, se = U / 2, ce = Math.min($, se), ue = Math.max(U - ce, 60 * 1e3), z = Math.max(ue, 5e3);
133
+ c("Auto-refresh scheduled in", Math.round(z / 1e3), "seconds"), d.value = setTimeout(async () => {
134
+ await ne();
135
+ }, z);
133
136
  }
134
- async function ee() {
135
- return p ? (c("Refresh already in progress, waiting for existing refresh"), p) : (g.value = !0, c("Performing auto-refresh"), p = (async () => {
137
+ async function ne() {
138
+ return E ? (c("Refresh already in progress, waiting for existing refresh"), E) : (g.value = !0, c("Performing auto-refresh"), E = (async () => {
136
139
  try {
137
- const _ = await (await ge())();
138
- _.error ? (R.value = !0, E.value = _.error.message, c("Auto-refresh failed:", _.error.message)) : (R.value = !1, E.value = null, c("Auto-refresh successful"));
140
+ const f = await (await Re())();
141
+ f.error ? (R.value = !0, I.value = f.error.message, c("Auto-refresh failed:", f.error.message)) : (R.value = !1, I.value = null, c("Auto-refresh successful"));
139
142
  } catch (u) {
140
- R.value = !0, E.value = u instanceof Error ? u.message : String(u), c("Auto-refresh error:", u);
143
+ R.value = !0, I.value = u instanceof Error ? u.message : String(u), c("Auto-refresh error:", u);
141
144
  } finally {
142
- g.value = !1, p = null;
145
+ g.value = !1, E = null;
143
146
  }
144
- })(), p);
147
+ })(), E);
145
148
  }
146
- function te() {
147
- R.value = !1, E.value = null;
149
+ function re() {
150
+ R.value = !1, I.value = null;
148
151
  }
149
152
  function x() {
150
- l.value && (clearTimeout(l.value), l.value = null), e.value = null, n.value = null, t.value = null, i.value = null, a.value = null, o.value = 443, s.value = null, R.value = !1, E.value = null, ie(), c("Logged out");
153
+ d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, i.value = null, a.value = null, o.value = 443, s.value = null, R.value = !1, I.value = null, ae(), c("Logged out");
151
154
  }
152
- function ne() {
153
- re(), e.value && !w.value ? (b(), c("Initialized from storage")) : e.value && w.value && (c("Stored token expired, clearing"), x());
155
+ function ie() {
156
+ oe(), e.value && !w.value ? (N(), c("Initialized from storage")) : e.value && w.value && (c("Stored token expired, clearing"), x());
154
157
  }
155
- function T() {
158
+ function A() {
156
159
  try {
157
- const u = N();
160
+ const u = L();
158
161
  e.value && u.setItem("een_token", e.value), n.value && u.setItem("een_tokenExpiration", String(n.value)), t.value && u.setItem("een_refreshTokenMarker", t.value), i.value && u.setItem("een_sessionId", i.value), a.value && u.setItem("een_hostname", a.value), o.value !== 443 && u.setItem("een_port", String(o.value)), s.value && u.setItem("een_userProfile", JSON.stringify(s.value));
159
162
  } catch (u) {
160
163
  c("Failed to save to storage:", u instanceof Error ? u.message : String(u));
161
164
  }
162
165
  }
163
- function re() {
166
+ function oe() {
164
167
  try {
165
- const u = N();
168
+ const u = L();
166
169
  e.value = u.getItem("een_token");
167
- const _ = u.getItem("een_tokenExpiration");
168
- n.value = _ ? parseInt(_, 10) : null, t.value = u.getItem("een_refreshTokenMarker"), i.value = u.getItem("een_sessionId"), a.value = u.getItem("een_hostname");
169
- const A = u.getItem("een_port");
170
- o.value = A ? parseInt(A, 10) : 443;
171
- const m = u.getItem("een_userProfile");
172
- s.value = m ? JSON.parse(m) : null;
170
+ const f = u.getItem("een_tokenExpiration");
171
+ n.value = f ? parseInt(f, 10) : null, t.value = u.getItem("een_refreshTokenMarker"), i.value = u.getItem("een_sessionId"), a.value = u.getItem("een_hostname");
172
+ const U = u.getItem("een_port");
173
+ o.value = U ? parseInt(U, 10) : 443;
174
+ const $ = u.getItem("een_userProfile");
175
+ s.value = $ ? JSON.parse($) : null;
173
176
  } catch (u) {
174
177
  c("Failed to load from storage:", u instanceof Error ? u.message : String(u));
175
178
  }
176
179
  }
177
- function ie() {
180
+ function ae() {
178
181
  try {
179
- const u = N();
182
+ const u = L();
180
183
  u.removeItem("een_token"), u.removeItem("een_tokenExpiration"), u.removeItem("een_refreshTokenMarker"), u.removeItem("een_sessionId"), u.removeItem("een_hostname"), u.removeItem("een_port"), u.removeItem("een_userProfile");
181
184
  } catch (u) {
182
185
  c("Failed to clear storage:", u instanceof Error ? u.message : String(u));
@@ -193,26 +196,26 @@ const f = ce("een-auth", () => {
193
196
  userProfile: s,
194
197
  isRefreshing: g,
195
198
  refreshFailed: R,
196
- refreshFailedMessage: E,
199
+ refreshFailedMessage: I,
197
200
  // Computed
198
201
  isAuthenticated: v,
199
- baseUrl: S,
202
+ baseUrl: k,
200
203
  isTokenExpired: w,
201
- tokenExpiresIn: K,
204
+ tokenExpiresIn: J,
202
205
  // Actions
203
- setToken: G,
204
- setRefreshTokenMarker: X,
205
- setSessionId: J,
206
- setBaseUrl: Y,
207
- setUserProfile: Z,
208
- setupAutoRefresh: b,
209
- clearRefreshFailed: te,
206
+ setToken: X,
207
+ setRefreshTokenMarker: Y,
208
+ setSessionId: Z,
209
+ setBaseUrl: ee,
210
+ setUserProfile: te,
211
+ setupAutoRefresh: N,
212
+ clearRefreshFailed: re,
210
213
  logout: x,
211
- initialize: ne
214
+ initialize: ie
212
215
  };
213
- }), he = "https://auth.eagleeyenetworks.com/oauth2/authorize";
214
- function Re() {
215
- const e = _e();
216
+ }), pe = "https://auth.eagleeyenetworks.com/oauth2/authorize";
217
+ function Ee() {
218
+ const e = he();
216
219
  if (!e)
217
220
  throw new Error("Client ID not configured. Call initEenToolkit() or set VITE_EEN_CLIENT_ID");
218
221
  const n = crypto.randomUUID();
@@ -224,18 +227,18 @@ function Re() {
224
227
  client_id: e,
225
228
  response_type: "code",
226
229
  scope: "vms.all",
227
- redirect_uri: z(),
230
+ redirect_uri: C(),
228
231
  state: n
229
232
  });
230
- return c("Generated auth URL with state:", n), `${he}?${t.toString()}`;
233
+ return c("Generated auth URL with state:", n), `${pe}?${t.toString()}`;
231
234
  }
232
- async function Q(e) {
235
+ async function M(e) {
233
236
  const n = P();
234
237
  if (!n)
235
238
  return r("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
236
239
  const t = new URLSearchParams({
237
240
  code: e,
238
- redirect_uri: z()
241
+ redirect_uri: C()
239
242
  });
240
243
  try {
241
244
  const i = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
@@ -250,16 +253,16 @@ async function Q(e) {
250
253
  return r("AUTH_FAILED", `Token exchange failed: ${o}`, i.status);
251
254
  }
252
255
  const a = await i.json();
253
- return c("Token received, expires in:", a.expiresIn), d(a);
256
+ return c("Token received, expires in:", a.expiresIn), l(a);
254
257
  } catch (i) {
255
258
  return r("NETWORK_ERROR", `Failed to exchange code: ${String(i)}`);
256
259
  }
257
260
  }
258
- async function pe() {
261
+ async function Ie() {
259
262
  const e = P();
260
263
  if (!e)
261
264
  return r("AUTH_FAILED", "Proxy URL not configured");
262
- const n = f();
265
+ const n = _();
263
266
  try {
264
267
  const t = {
265
268
  Accept: "application/json"
@@ -275,16 +278,16 @@ async function pe() {
275
278
  return r("AUTH_FAILED", `Token refresh failed: ${o}`, i.status);
276
279
  }
277
280
  const a = await i.json();
278
- return n.setToken(a.accessToken, a.expiresIn), c("Token refreshed, expires in:", a.expiresIn), d(a);
281
+ return n.setToken(a.accessToken, a.expiresIn), c("Token refreshed, expires in:", a.expiresIn), l(a);
279
282
  } catch (t) {
280
283
  return r("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
281
284
  }
282
285
  }
283
- async function Ee() {
286
+ async function Te() {
284
287
  const e = P();
285
288
  if (!e)
286
289
  return r("AUTH_FAILED", "Proxy URL not configured");
287
- const n = f();
290
+ const n = _();
288
291
  try {
289
292
  const t = {
290
293
  Accept: "application/json"
@@ -299,12 +302,12 @@ async function Ee() {
299
302
  const a = await i.text().catch(() => "Unknown error");
300
303
  return r("AUTH_FAILED", `Token revocation failed: ${a}`, i.status);
301
304
  }
302
- return c("Token revoked"), d(void 0);
305
+ return c("Token revoked"), l(void 0);
303
306
  } catch (t) {
304
307
  return n.logout(), r("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
305
308
  }
306
309
  }
307
- async function Ie(e, n) {
310
+ async function Ae(e, n) {
308
311
  let t = null;
309
312
  try {
310
313
  t = sessionStorage.getItem("een_oauth_state"), sessionStorage.removeItem("een_oauth_state");
@@ -312,16 +315,16 @@ async function Ie(e, n) {
312
315
  }
313
316
  if (!t)
314
317
  return r("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
315
- if (!Te(n, t))
318
+ if (!Ue(n, t))
316
319
  return r("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
317
320
  c("State validated, exchanging code for token");
318
- const i = await Q(e);
321
+ const i = await M(e);
319
322
  if (i.error)
320
323
  return i;
321
- const a = f(), o = i.data;
322
- return a.setToken(o.accessToken, o.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(o.sessionId), a.setBaseUrl(o.httpsBaseUrl), c("Auth callback complete, user:", o.userEmail), d(o);
324
+ const a = _(), o = i.data;
325
+ return a.setToken(o.accessToken, o.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(o.sessionId), a.setBaseUrl(o.httpsBaseUrl), c("Auth callback complete, user:", o.userEmail), l(o);
323
326
  }
324
- function Te(e, n) {
327
+ function Ue(e, n) {
325
328
  if (e.length !== n.length)
326
329
  return !1;
327
330
  let t = 0;
@@ -329,16 +332,16 @@ function Te(e, n) {
329
332
  t |= e.charCodeAt(i) ^ n.charCodeAt(i);
330
333
  return t === 0;
331
334
  }
332
- const Ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
335
+ const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
333
336
  __proto__: null,
334
- getAccessToken: Q,
335
- getAuthUrl: Re,
336
- handleAuthCallback: Ie,
337
- refreshToken: pe,
338
- revokeToken: Ee
337
+ getAccessToken: M,
338
+ getAuthUrl: Ee,
339
+ handleAuthCallback: Ae,
340
+ refreshToken: Ie,
341
+ revokeToken: Te
339
342
  }, Symbol.toStringTag, { value: "Module" }));
340
- async function we() {
341
- const e = f();
343
+ async function je() {
344
+ const e = _();
342
345
  if (!e.isAuthenticated)
343
346
  return r("AUTH_REQUIRED", "Authentication required");
344
347
  if (!e.baseUrl)
@@ -356,13 +359,13 @@ async function we() {
356
359
  if (!t.ok)
357
360
  return B(t);
358
361
  const i = await t.json();
359
- return c("Current user fetched:", i.email), e.setUserProfile(i), d(i);
362
+ return c("Current user fetched:", i.email), e.setUserProfile(i), l(i);
360
363
  } catch (t) {
361
364
  return r("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
362
365
  }
363
366
  }
364
- async function be(e) {
365
- const n = f();
367
+ async function Le(e) {
368
+ const n = _();
366
369
  if (!n.isAuthenticated)
367
370
  return r("AUTH_REQUIRED", "Authentication required");
368
371
  if (!n.baseUrl)
@@ -382,13 +385,13 @@ async function be(e) {
382
385
  if (!o.ok)
383
386
  return B(o);
384
387
  const s = await o.json();
385
- return c("Users fetched:", s.results?.length ?? 0, "users"), d(s);
388
+ return c("Users fetched:", s.results?.length ?? 0, "users"), l(s);
386
389
  } catch (o) {
387
390
  return r("NETWORK_ERROR", `Failed to fetch users: ${String(o)}`);
388
391
  }
389
392
  }
390
- async function Le(e, n) {
391
- const t = f();
393
+ async function Fe(e, n) {
394
+ const t = _();
392
395
  if (!t.isAuthenticated)
393
396
  return r("AUTH_REQUIRED", "Authentication required");
394
397
  if (!t.baseUrl)
@@ -409,8 +412,8 @@ async function Le(e, n) {
409
412
  });
410
413
  if (!s.ok)
411
414
  return B(s);
412
- const l = await s.json();
413
- return c("User fetched:", l.email), d(l);
415
+ const d = await s.json();
416
+ return c("User fetched:", d.email), l(d);
414
417
  } catch (s) {
415
418
  return r("NETWORK_ERROR", `Failed to fetch user: ${String(s)}`);
416
419
  }
@@ -437,8 +440,8 @@ async function B(e) {
437
440
  return r("API_ERROR", `API error: ${t}`, n);
438
441
  }
439
442
  }
440
- async function je(e) {
441
- const n = f();
443
+ async function qe(e) {
444
+ const n = _();
442
445
  if (!n.isAuthenticated)
443
446
  return r("AUTH_REQUIRED", "Authentication required");
444
447
  if (!n.baseUrl)
@@ -456,15 +459,15 @@ async function je(e) {
456
459
  }
457
460
  });
458
461
  if (!o.ok)
459
- return M(o);
462
+ return V(o);
460
463
  const s = await o.json();
461
- return c("Cameras fetched:", s.results?.length ?? 0, "cameras"), d(s);
464
+ return c("Cameras fetched:", s.results?.length ?? 0, "cameras"), l(s);
462
465
  } catch (o) {
463
466
  return r("NETWORK_ERROR", `Failed to fetch cameras: ${String(o)}`);
464
467
  }
465
468
  }
466
- async function Ne(e, n) {
467
- const t = f();
469
+ async function Pe(e, n) {
470
+ const t = _();
468
471
  if (!t.isAuthenticated)
469
472
  return r("AUTH_REQUIRED", "Authentication required");
470
473
  if (!t.baseUrl)
@@ -484,14 +487,14 @@ async function Ne(e, n) {
484
487
  }
485
488
  });
486
489
  if (!s.ok)
487
- return M(s);
488
- const l = await s.json();
489
- return c("Camera fetched:", l.name), d(l);
490
+ return V(s);
491
+ const d = await s.json();
492
+ return c("Camera fetched:", d.name), l(d);
490
493
  } catch (s) {
491
494
  return r("NETWORK_ERROR", `Failed to fetch camera: ${String(s)}`);
492
495
  }
493
496
  }
494
- async function M(e) {
497
+ async function V(e) {
495
498
  const n = e.status;
496
499
  let t;
497
500
  try {
@@ -513,8 +516,8 @@ async function M(e) {
513
516
  return r("API_ERROR", `API error: ${t}`, n);
514
517
  }
515
518
  }
516
- async function Fe(e) {
517
- const n = f();
519
+ async function Be(e) {
520
+ const n = _();
518
521
  if (!n.isAuthenticated)
519
522
  return r("AUTH_REQUIRED", "Authentication required");
520
523
  if (!n.baseUrl)
@@ -532,15 +535,15 @@ async function Fe(e) {
532
535
  }
533
536
  });
534
537
  if (!o.ok)
535
- return V(o);
538
+ return W(o);
536
539
  const s = await o.json();
537
- return c("Bridges fetched:", s.results?.length ?? 0, "bridges"), d(s);
540
+ return c("Bridges fetched:", s.results?.length ?? 0, "bridges"), l(s);
538
541
  } catch (o) {
539
542
  return r("NETWORK_ERROR", `Failed to fetch bridges: ${String(o)}`);
540
543
  }
541
544
  }
542
- async function qe(e, n) {
543
- const t = f();
545
+ async function He(e, n) {
546
+ const t = _();
544
547
  if (!t.isAuthenticated)
545
548
  return r("AUTH_REQUIRED", "Authentication required");
546
549
  if (!t.baseUrl)
@@ -560,14 +563,14 @@ async function qe(e, n) {
560
563
  }
561
564
  });
562
565
  if (!s.ok)
563
- return V(s);
564
- const l = await s.json();
565
- return c("Bridge fetched:", l.name), d(l);
566
+ return W(s);
567
+ const d = await s.json();
568
+ return c("Bridge fetched:", d.name), l(d);
566
569
  } catch (s) {
567
570
  return r("NETWORK_ERROR", `Failed to fetch bridge: ${String(s)}`);
568
571
  }
569
572
  }
570
- async function V(e) {
573
+ async function W(e) {
571
574
  const n = e.status;
572
575
  let t;
573
576
  try {
@@ -589,25 +592,25 @@ async function V(e) {
589
592
  return r("API_ERROR", `API error: ${t}`, n);
590
593
  }
591
594
  }
592
- const Ue = 3e4;
593
- function y(e = Ue) {
595
+ const Se = 3e4;
596
+ function S(e = Se) {
594
597
  const n = new AbortController(), t = setTimeout(() => n.abort(), e);
595
598
  return { controller: n, timeoutId: t };
596
599
  }
597
- function W(e) {
600
+ function K(e) {
598
601
  const n = new Uint8Array(e), t = 8192, i = [];
599
602
  for (let o = 0; o < n.byteLength; o += t) {
600
603
  const s = n.subarray(o, Math.min(o + t, n.byteLength));
601
- let l = "";
604
+ let d = "";
602
605
  for (let g = 0; g < s.length; g++)
603
- l += String.fromCharCode(s[g]);
604
- i.push(l);
606
+ d += String.fromCharCode(s[g]);
607
+ i.push(d);
605
608
  }
606
609
  const a = i.join("");
607
610
  return typeof btoa == "function" ? btoa(a) : Buffer.from(a, "binary").toString("base64");
608
611
  }
609
- async function Pe(e) {
610
- const n = f();
612
+ async function xe(e) {
613
+ const n = _();
611
614
  if (!n.isAuthenticated)
612
615
  return r("AUTH_REQUIRED", "Authentication required");
613
616
  if (!n.baseUrl)
@@ -624,7 +627,7 @@ async function Pe(e) {
624
627
  t.append("deviceId", e.deviceId), t.append("type", e.type), t.append("mediaType", e.mediaType), t.append("startTimestamp__gte", e.startTimestamp), e.endTimestamp && t.append("endTimestamp__lte", e.endTimestamp), typeof e.coalesce == "boolean" && t.append("coalesce", String(e.coalesce)), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), e.pageToken && t.append("pageToken", e.pageToken), typeof e.pageSize == "number" && t.append("pageSize", String(e.pageSize));
625
628
  const i = `${n.baseUrl}/api/v3.0/media?${t.toString()}`;
626
629
  c("Fetching media intervals:", i);
627
- const { controller: a, timeoutId: o } = y();
630
+ const { controller: a, timeoutId: o } = S();
628
631
  try {
629
632
  const s = await fetch(i, {
630
633
  method: "GET",
@@ -635,17 +638,17 @@ async function Pe(e) {
635
638
  signal: a.signal
636
639
  });
637
640
  if (!s.ok)
638
- return O(s);
639
- const l = await s.json();
640
- return c("Media intervals fetched:", l.results?.length ?? 0, "intervals"), d(l);
641
+ return D(s);
642
+ const d = await s.json();
643
+ return c("Media intervals fetched:", d.results?.length ?? 0, "intervals"), l(d);
641
644
  } catch (s) {
642
645
  return s instanceof Error && s.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch media intervals: ${String(s)}`);
643
646
  } finally {
644
647
  clearTimeout(o);
645
648
  }
646
649
  }
647
- async function Be(e) {
648
- const n = f();
650
+ async function ze(e) {
651
+ const n = _();
649
652
  if (!n.isAuthenticated)
650
653
  return r("AUTH_REQUIRED", "Authentication required");
651
654
  if (!n.baseUrl)
@@ -656,32 +659,32 @@ async function Be(e) {
656
659
  i.append("deviceId", e.deviceId), i.append("type", t);
657
660
  const a = `${n.baseUrl}/api/v3.0/media/liveImage.jpeg?${i.toString()}`;
658
661
  c("Fetching live image:", a);
659
- const { controller: o, timeoutId: s } = y();
662
+ const { controller: o, timeoutId: s } = S();
660
663
  try {
661
- const l = await fetch(a, {
664
+ const d = await fetch(a, {
662
665
  method: "GET",
663
666
  headers: {
664
667
  Accept: "image/jpeg",
665
668
  Authorization: `Bearer ${n.token}`
666
669
  },
667
670
  signal: o.signal
668
- }), g = l.headers.get("X-Een-Timestamp"), p = l.headers.get("X-Een-PrevToken");
669
- if (!l.ok)
670
- return O(l);
671
- const R = await l.arrayBuffer(), v = `data:image/jpeg;base64,${W(R)}`;
672
- return c("Live image fetched, timestamp:", g), d({
671
+ }), g = d.headers.get("X-Een-Timestamp"), E = d.headers.get("X-Een-PrevToken");
672
+ if (!d.ok)
673
+ return D(d);
674
+ const R = await d.arrayBuffer(), v = `data:image/jpeg;base64,${K(R)}`;
675
+ return c("Live image fetched, timestamp:", g), l({
673
676
  imageData: v,
674
677
  timestamp: g,
675
- prevToken: p
678
+ prevToken: E
676
679
  });
677
- } catch (l) {
678
- return l instanceof Error && l.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch live image: ${String(l)}`);
680
+ } catch (d) {
681
+ return d instanceof Error && d.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch live image: ${String(d)}`);
679
682
  } finally {
680
683
  clearTimeout(s);
681
684
  }
682
685
  }
683
- async function xe(e) {
684
- const n = f();
686
+ async function Qe(e) {
687
+ const n = _();
685
688
  if (!n.isAuthenticated)
686
689
  return r("AUTH_REQUIRED", "Authentication required");
687
690
  if (!n.baseUrl)
@@ -696,7 +699,7 @@ async function xe(e) {
696
699
  e.deviceId && t.append("deviceId", e.deviceId), e.pageToken && t.append("pageToken", e.pageToken), e.type && t.append("type", e.type), e.timestamp__lt && t.append("timestamp__lt", e.timestamp__lt), e.timestamp__lte && t.append("timestamp__lte", e.timestamp__lte), e.timestamp && t.append("timestamp", e.timestamp), e.timestamp__gte && t.append("timestamp__gte", e.timestamp__gte), e.timestamp__gt && t.append("timestamp__gt", e.timestamp__gt), e.overlayId__in && e.overlayId__in.length > 0 && t.append("overlayId__in", e.overlayId__in.join(",")), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), typeof e.targetWidth == "number" && t.append("targetWidth", String(e.targetWidth)), typeof e.targetHeight == "number" && t.append("targetHeight", String(e.targetHeight));
697
700
  const i = `${n.baseUrl}/api/v3.0/media/recordedImage.jpeg?${t.toString()}`;
698
701
  c("Fetching recorded image:", i);
699
- const { controller: a, timeoutId: o } = y();
702
+ const { controller: a, timeoutId: o } = S();
700
703
  try {
701
704
  const s = await fetch(i, {
702
705
  method: "GET",
@@ -705,15 +708,15 @@ async function xe(e) {
705
708
  Authorization: `Bearer ${n.token}`
706
709
  },
707
710
  signal: a.signal
708
- }), l = s.headers.get("X-Een-Timestamp"), g = s.headers.get("X-Een-NextToken"), p = s.headers.get("X-Een-PrevToken"), R = s.headers.get("X-Een-OverlaySvg");
711
+ }), d = s.headers.get("X-Een-Timestamp"), g = s.headers.get("X-Een-NextToken"), E = s.headers.get("X-Een-PrevToken"), R = s.headers.get("X-Een-OverlaySvg");
709
712
  if (!s.ok)
710
- return O(s);
711
- const E = await s.arrayBuffer(), S = `data:image/jpeg;base64,${W(E)}`;
712
- return c("Recorded image fetched, timestamp:", l), d({
713
- imageData: S,
714
- timestamp: l,
713
+ return D(s);
714
+ const I = await s.arrayBuffer(), k = `data:image/jpeg;base64,${K(I)}`;
715
+ return c("Recorded image fetched, timestamp:", d), l({
716
+ imageData: k,
717
+ timestamp: d,
715
718
  nextToken: g,
716
- prevToken: p,
719
+ prevToken: E,
717
720
  overlaySvg: R
718
721
  });
719
722
  } catch (s) {
@@ -722,7 +725,7 @@ async function xe(e) {
722
725
  clearTimeout(o);
723
726
  }
724
727
  }
725
- async function O(e) {
728
+ async function D(e) {
726
729
  const n = e.status;
727
730
  let t;
728
731
  try {
@@ -746,15 +749,15 @@ async function O(e) {
746
749
  return r("API_ERROR", `API error: ${t}`, n);
747
750
  }
748
751
  }
749
- async function ye() {
750
- const e = f();
752
+ async function ve() {
753
+ const e = _();
751
754
  if (!e.isAuthenticated)
752
755
  return r("AUTH_REQUIRED", "Authentication required");
753
756
  if (!e.baseUrl)
754
757
  return r("AUTH_REQUIRED", "Base URL not configured");
755
758
  const n = `${e.baseUrl}/api/v3.0/media/session`;
756
759
  c("Fetching media session:", n);
757
- const { controller: t, timeoutId: i } = y();
760
+ const { controller: t, timeoutId: i } = S();
758
761
  try {
759
762
  const a = await fetch(n, {
760
763
  method: "GET",
@@ -765,20 +768,20 @@ async function ye() {
765
768
  signal: t.signal
766
769
  });
767
770
  if (!a.ok)
768
- return O(a);
771
+ return D(a);
769
772
  const o = await a.json();
770
- return c("Media session URL received:", o.url), d(o);
773
+ return c("Media session URL received:", o.url), l(o);
771
774
  } catch (a) {
772
775
  return a instanceof Error && a.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch media session: ${String(a)}`);
773
776
  } finally {
774
777
  clearTimeout(i);
775
778
  }
776
779
  }
777
- async function He() {
778
- const e = f();
780
+ async function Ce() {
781
+ const e = _();
779
782
  if (!e.isAuthenticated)
780
783
  return r("AUTH_REQUIRED", "Authentication required");
781
- const n = await ye();
784
+ const n = await ve();
782
785
  if (n.error)
783
786
  return r(
784
787
  n.error.code,
@@ -789,7 +792,7 @@ async function He() {
789
792
  return r("API_ERROR", "No session URL returned from media session endpoint");
790
793
  const t = n.data.url;
791
794
  c("Calling session URL to set cookie:", t);
792
- const { controller: i, timeoutId: a } = y();
795
+ const { controller: i, timeoutId: a } = S();
793
796
  try {
794
797
  const o = await fetch(t, {
795
798
  method: "GET",
@@ -803,16 +806,16 @@ async function He() {
803
806
  });
804
807
  if (!o.ok && o.status !== 204) {
805
808
  const s = o.status;
806
- let l;
809
+ let d;
807
810
  try {
808
811
  const g = await o.json();
809
- l = g.message ?? g.error ?? o.statusText;
812
+ d = g.message ?? g.error ?? o.statusText;
810
813
  } catch {
811
- l = o.statusText || "Unknown error";
814
+ d = o.statusText || "Unknown error";
812
815
  }
813
- return r("API_ERROR", `Failed to set media session cookie: ${l}`, s);
816
+ return r("API_ERROR", `Failed to set media session cookie: ${d}`, s);
814
817
  }
815
- return c("Media session cookie set successfully"), d({
818
+ return c("Media session cookie set successfully"), l({
816
819
  success: !0,
817
820
  sessionUrl: t
818
821
  });
@@ -822,8 +825,8 @@ async function He() {
822
825
  clearTimeout(a);
823
826
  }
824
827
  }
825
- async function Ce(e) {
826
- const n = f();
828
+ async function Me(e) {
829
+ const n = _();
827
830
  if (!n.isAuthenticated)
828
831
  return r("AUTH_REQUIRED", "Authentication required");
829
832
  if (!n.baseUrl)
@@ -842,14 +845,14 @@ async function Ce(e) {
842
845
  signal: e?.signal
843
846
  });
844
847
  if (!o.ok)
845
- return ve(o);
848
+ return ke(o);
846
849
  const s = await o.json();
847
- return c("Feeds fetched:", s.results?.length ?? 0, "feeds"), d(s);
850
+ return c("Feeds fetched:", s.results?.length ?? 0, "feeds"), l(s);
848
851
  } catch (o) {
849
852
  return r("NETWORK_ERROR", `Failed to fetch feeds: ${String(o)}`);
850
853
  }
851
854
  }
852
- async function ve(e) {
855
+ async function ke(e) {
853
856
  const n = e.status;
854
857
  let t;
855
858
  try {
@@ -873,11 +876,8 @@ async function ve(e) {
873
876
  return r("API_ERROR", t || e.statusText || "API error", n);
874
877
  }
875
878
  }
876
- function $(e) {
877
- return e.endsWith("+00:00") ? e : e.endsWith("Z") ? e.replace("Z", "+00:00") : e;
878
- }
879
- async function ze(e) {
880
- const n = f();
879
+ async function Ve(e) {
880
+ const n = _();
881
881
  if (!n.isAuthenticated)
882
882
  return r("AUTH_REQUIRED", "Authentication required");
883
883
  if (!n.baseUrl)
@@ -889,7 +889,7 @@ async function ze(e) {
889
889
  if (!e.startTimestamp__gte)
890
890
  return r("VALIDATION_ERROR", "startTimestamp__gte parameter is required");
891
891
  const t = new URLSearchParams();
892
- t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte", $(e.startTimestamp__gte)), e.pageSize && t.append("pageSize", String(e.pageSize)), e.pageToken && t.append("pageToken", e.pageToken), e.startTimestamp__lte && t.append("startTimestamp__lte", $(e.startTimestamp__lte)), e.endTimestamp__gte && t.append("endTimestamp__gte", $(e.endTimestamp__gte)), e.endTimestamp__lte && t.append("endTimestamp__lte", $(e.endTimestamp__lte)), e.sort && t.append("sort", e.sort), e.include && e.include.length > 0 && t.append("include", e.include.join(","));
892
+ t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte", p(e.startTimestamp__gte)), e.pageSize && t.append("pageSize", String(e.pageSize)), e.pageToken && t.append("pageToken", e.pageToken), e.startTimestamp__lte && t.append("startTimestamp__lte", p(e.startTimestamp__lte)), e.endTimestamp__gte && t.append("endTimestamp__gte", p(e.endTimestamp__gte)), e.endTimestamp__lte && t.append("endTimestamp__lte", p(e.endTimestamp__lte)), e.sort && t.append("sort", e.sort), e.include && e.include.length > 0 && t.append("include", e.include.join(","));
893
893
  const i = t.toString(), a = `${n.baseUrl}/api/v3.0/events${i ? `?${i}` : ""}`;
894
894
  c("Fetching events:", a);
895
895
  try {
@@ -901,15 +901,15 @@ async function ze(e) {
901
901
  }
902
902
  });
903
903
  if (!o.ok)
904
- return D(o);
904
+ return m(o);
905
905
  const s = await o.json();
906
- return c("Events fetched:", s.results?.length ?? 0, "events"), d(s);
906
+ return c("Events fetched:", s.results?.length ?? 0, "events"), l(s);
907
907
  } catch (o) {
908
908
  return r("NETWORK_ERROR", `Failed to fetch events: ${String(o)}`);
909
909
  }
910
910
  }
911
- async function Qe(e, n) {
912
- const t = f();
911
+ async function We(e, n) {
912
+ const t = _();
913
913
  if (!t.isAuthenticated)
914
914
  return r("AUTH_REQUIRED", "Authentication required");
915
915
  if (!t.baseUrl)
@@ -929,15 +929,15 @@ async function Qe(e, n) {
929
929
  }
930
930
  });
931
931
  if (!s.ok)
932
- return D(s);
933
- const l = await s.json();
934
- return c("Event fetched:", l.id), d(l);
932
+ return m(s);
933
+ const d = await s.json();
934
+ return c("Event fetched:", d.id), l(d);
935
935
  } catch (s) {
936
936
  return r("NETWORK_ERROR", `Failed to fetch event: ${String(s)}`);
937
937
  }
938
938
  }
939
- async function Me(e) {
940
- const n = f();
939
+ async function Ke(e) {
940
+ const n = _();
941
941
  if (!n.isAuthenticated)
942
942
  return r("AUTH_REQUIRED", "Authentication required");
943
943
  if (!n.baseUrl)
@@ -955,15 +955,15 @@ async function Me(e) {
955
955
  }
956
956
  });
957
957
  if (!o.ok)
958
- return D(o);
958
+ return m(o);
959
959
  const s = await o.json();
960
- return c("Event types fetched:", s.results?.length ?? 0, "types"), d(s);
960
+ return c("Event types fetched:", s.results?.length ?? 0, "types"), l(s);
961
961
  } catch (o) {
962
962
  return r("NETWORK_ERROR", `Failed to fetch event types: ${String(o)}`);
963
963
  }
964
964
  }
965
- async function Ve(e) {
966
- const n = f();
965
+ async function Ge(e) {
966
+ const n = _();
967
967
  if (!n.isAuthenticated)
968
968
  return r("AUTH_REQUIRED", "Authentication required");
969
969
  if (!n.baseUrl)
@@ -983,14 +983,242 @@ async function Ve(e) {
983
983
  }
984
984
  });
985
985
  if (!o.ok)
986
- return D(o);
986
+ return m(o);
987
987
  const s = await o.json();
988
- return c("Event field values fetched:", s.type?.length ?? 0, "types"), d(s);
988
+ return c("Event field values fetched:", s.type?.length ?? 0, "types"), l(s);
989
989
  } catch (o) {
990
990
  return r("NETWORK_ERROR", `Failed to fetch event field values: ${String(o)}`);
991
991
  }
992
992
  }
993
- async function D(e) {
993
+ async function m(e) {
994
+ const n = e.status;
995
+ let t;
996
+ try {
997
+ const i = await e.json();
998
+ t = i.message ?? i.error ?? e.statusText;
999
+ } catch (i) {
1000
+ c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1001
+ }
1002
+ switch (n) {
1003
+ case 401:
1004
+ return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1005
+ case 403:
1006
+ return r("FORBIDDEN", `Access denied: ${t}`, n);
1007
+ case 404:
1008
+ return r("NOT_FOUND", `Not found: ${t}`, n);
1009
+ case 429:
1010
+ return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1011
+ default:
1012
+ return r("API_ERROR", `API error: ${t}`, n);
1013
+ }
1014
+ }
1015
+ async function Je(e) {
1016
+ const n = _();
1017
+ if (!n.isAuthenticated)
1018
+ return r("AUTH_REQUIRED", "Authentication required");
1019
+ if (!n.baseUrl)
1020
+ return r("AUTH_REQUIRED", "Base URL not configured");
1021
+ if (!e.actor)
1022
+ return r("VALIDATION_ERROR", "actor parameter is required");
1023
+ if (!e.eventType)
1024
+ return r("VALIDATION_ERROR", "eventType parameter is required");
1025
+ const t = new URLSearchParams();
1026
+ t.append("actor", e.actor), t.append("eventType", e.eventType), e.timestamp__gte && t.append("timestamp__gte", p(e.timestamp__gte)), e.timestamp__lte && t.append("timestamp__lte", p(e.timestamp__lte)), e.aggregateByMinutes !== void 0 && t.append("aggregateByMinutes", String(e.aggregateByMinutes));
1027
+ const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventMetrics${i ? `?${i}` : ""}`;
1028
+ c("Fetching event metrics:", a);
1029
+ try {
1030
+ const o = await fetch(a, {
1031
+ method: "GET",
1032
+ headers: {
1033
+ Accept: "application/json",
1034
+ Authorization: `Bearer ${n.token}`
1035
+ }
1036
+ });
1037
+ if (!o.ok)
1038
+ return $e(o);
1039
+ const s = await o.json();
1040
+ return c("Event metrics fetched:", s.length, "metrics"), l(s);
1041
+ } catch (o) {
1042
+ return r("NETWORK_ERROR", `Failed to fetch event metrics: ${String(o)}`);
1043
+ }
1044
+ }
1045
+ async function $e(e) {
1046
+ const n = e.status;
1047
+ let t;
1048
+ try {
1049
+ const i = await e.json();
1050
+ t = i.message ?? i.error ?? e.statusText;
1051
+ } catch (i) {
1052
+ c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1053
+ }
1054
+ switch (n) {
1055
+ case 401:
1056
+ return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1057
+ case 403:
1058
+ return r("FORBIDDEN", `Access denied: ${t}`, n);
1059
+ case 404:
1060
+ return r("NOT_FOUND", `Not found: ${t}`, n);
1061
+ case 429:
1062
+ return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1063
+ default:
1064
+ return r("API_ERROR", `API error: ${t}`, n);
1065
+ }
1066
+ }
1067
+ async function Xe(e) {
1068
+ const n = _();
1069
+ if (!n.isAuthenticated)
1070
+ return r("AUTH_REQUIRED", "Authentication required");
1071
+ if (!n.baseUrl)
1072
+ return r("AUTH_REQUIRED", "Base URL not configured");
1073
+ const t = new URLSearchParams();
1074
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", p(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", p(e.timestamp__gte)), e?.creatorId && t.append("creatorId", e.creatorId), e?.alertType__in && e.alertType__in.length > 0 && t.append("alertType__in", e.alertType__in.join(",")), e?.actorId__in && e.actorId__in.length > 0 && t.append("actorId__in", e.actorId__in.join(",")), e?.actorType__in && e.actorType__in.length > 0 && t.append("actorType__in", e.actorType__in.join(",")), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.ruleId && t.append("ruleId", e.ruleId), e?.ruleId__in && e.ruleId__in.length > 0 && t.append("ruleId__in", e.ruleId__in.join(",")), e?.eventId && t.append("eventId", e.eventId), e?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.priority__gte !== void 0 && t.append("priority__gte", String(e.priority__gte)), e?.priority__lte !== void 0 && t.append("priority__lte", String(e.priority__lte)), e?.showInvalidAlerts !== void 0 && t.append("showInvalidAlerts", String(e.showInvalidAlerts)), e?.alertActionId__in && e.alertActionId__in.length > 0 && t.append("alertActionId__in", e.alertActionId__in.join(",")), e?.alertActionStatus__in && e.alertActionStatus__in.length > 0 && t.append("alertActionStatus__in", e.alertActionStatus__in.join(",")), e?.include && e.include.length > 0 && t.append("include", e.include.join(",")), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1075
+ const i = t.toString(), a = `${n.baseUrl}/api/v3.0/alerts${i ? `?${i}` : ""}`;
1076
+ c("Fetching alerts:", a);
1077
+ try {
1078
+ const o = await fetch(a, {
1079
+ method: "GET",
1080
+ headers: {
1081
+ Accept: "application/json",
1082
+ Authorization: `Bearer ${n.token}`
1083
+ }
1084
+ });
1085
+ if (!o.ok)
1086
+ return H(o);
1087
+ const s = await o.json();
1088
+ return c("Alerts fetched:", s.results?.length ?? 0, "alerts"), l(s);
1089
+ } catch (o) {
1090
+ return r("NETWORK_ERROR", `Failed to fetch alerts: ${String(o)}`);
1091
+ }
1092
+ }
1093
+ async function Ye(e, n) {
1094
+ const t = _();
1095
+ if (!t.isAuthenticated)
1096
+ return r("AUTH_REQUIRED", "Authentication required");
1097
+ if (!t.baseUrl)
1098
+ return r("AUTH_REQUIRED", "Base URL not configured");
1099
+ if (!e)
1100
+ return r("VALIDATION_ERROR", "Alert ID is required");
1101
+ const i = new URLSearchParams();
1102
+ n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
1103
+ const a = i.toString(), o = `${t.baseUrl}/api/v3.0/alerts/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1104
+ c("Fetching alert:", o);
1105
+ try {
1106
+ const s = await fetch(o, {
1107
+ method: "GET",
1108
+ headers: {
1109
+ Accept: "application/json",
1110
+ Authorization: `Bearer ${t.token}`
1111
+ }
1112
+ });
1113
+ if (!s.ok)
1114
+ return H(s);
1115
+ const d = await s.json();
1116
+ return c("Alert fetched:", d.id), l(d);
1117
+ } catch (s) {
1118
+ return r("NETWORK_ERROR", `Failed to fetch alert: ${String(s)}`);
1119
+ }
1120
+ }
1121
+ async function Ze(e) {
1122
+ const n = _();
1123
+ if (!n.isAuthenticated)
1124
+ return r("AUTH_REQUIRED", "Authentication required");
1125
+ if (!n.baseUrl)
1126
+ return r("AUTH_REQUIRED", "Base URL not configured");
1127
+ const t = new URLSearchParams();
1128
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken);
1129
+ const i = t.toString(), a = `${n.baseUrl}/api/v3.0/alertTypes${i ? `?${i}` : ""}`;
1130
+ c("Fetching alert types:", a);
1131
+ try {
1132
+ const o = await fetch(a, {
1133
+ method: "GET",
1134
+ headers: {
1135
+ Accept: "application/json",
1136
+ Authorization: `Bearer ${n.token}`
1137
+ }
1138
+ });
1139
+ if (!o.ok)
1140
+ return H(o);
1141
+ const s = await o.json();
1142
+ return c("Alert types fetched:", s.results?.length ?? 0, "types"), l(s);
1143
+ } catch (o) {
1144
+ return r("NETWORK_ERROR", `Failed to fetch alert types: ${String(o)}`);
1145
+ }
1146
+ }
1147
+ async function H(e) {
1148
+ const n = e.status;
1149
+ let t;
1150
+ try {
1151
+ const i = await e.json();
1152
+ t = i.message ?? i.error ?? e.statusText;
1153
+ } catch (i) {
1154
+ c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1155
+ }
1156
+ switch (n) {
1157
+ case 401:
1158
+ return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1159
+ case 403:
1160
+ return r("FORBIDDEN", `Access denied: ${t}`, n);
1161
+ case 404:
1162
+ return r("NOT_FOUND", `Not found: ${t}`, n);
1163
+ case 429:
1164
+ return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1165
+ default:
1166
+ return r("API_ERROR", `API error: ${t}`, n);
1167
+ }
1168
+ }
1169
+ async function et(e) {
1170
+ const n = _();
1171
+ if (!n.isAuthenticated)
1172
+ return r("AUTH_REQUIRED", "Authentication required");
1173
+ if (!n.baseUrl)
1174
+ return r("AUTH_REQUIRED", "Base URL not configured");
1175
+ const t = new URLSearchParams();
1176
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", p(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", p(e.timestamp__gte)), e?.alertId && t.append("alertId", e.alertId), e?.alertType && t.append("alertType", e.alertType), e?.actorId && t.append("actorId", e.actorId), e?.actorType && t.append("actorType", e.actorType), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.category && t.append("category", e.category), e?.userId && t.append("userId", e.userId), e?.read !== void 0 && t.append("read", String(e.read)), e?.status && t.append("status", e.status), e?.includeV1Notifications !== void 0 && t.append("includeV1Notifications", String(e.includeV1Notifications)), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1177
+ const i = t.toString(), a = `${n.baseUrl}/api/v3.0/notifications${i ? `?${i}` : ""}`;
1178
+ c("Fetching notifications:", a);
1179
+ try {
1180
+ const o = await fetch(a, {
1181
+ method: "GET",
1182
+ headers: {
1183
+ Accept: "application/json",
1184
+ Authorization: `Bearer ${n.token}`
1185
+ }
1186
+ });
1187
+ if (!o.ok)
1188
+ return G(o);
1189
+ const s = await o.json();
1190
+ return c("Notifications fetched:", s.results?.length ?? 0, "notifications"), l(s);
1191
+ } catch (o) {
1192
+ return r("NETWORK_ERROR", `Failed to fetch notifications: ${String(o)}`);
1193
+ }
1194
+ }
1195
+ async function tt(e) {
1196
+ const n = _();
1197
+ if (!n.isAuthenticated)
1198
+ return r("AUTH_REQUIRED", "Authentication required");
1199
+ if (!n.baseUrl)
1200
+ return r("AUTH_REQUIRED", "Base URL not configured");
1201
+ if (!e)
1202
+ return r("VALIDATION_ERROR", "Notification ID is required");
1203
+ const t = `${n.baseUrl}/api/v3.0/notifications/${encodeURIComponent(e)}`;
1204
+ c("Fetching notification:", t);
1205
+ try {
1206
+ const i = await fetch(t, {
1207
+ method: "GET",
1208
+ headers: {
1209
+ Accept: "application/json",
1210
+ Authorization: `Bearer ${n.token}`
1211
+ }
1212
+ });
1213
+ if (!i.ok)
1214
+ return G(i);
1215
+ const a = await i.json();
1216
+ return c("Notification fetched:", a.id), l(a);
1217
+ } catch (i) {
1218
+ return r("NETWORK_ERROR", `Failed to fetch notification: ${String(i)}`);
1219
+ }
1220
+ }
1221
+ async function G(e) {
994
1222
  const n = e.status;
995
1223
  let t;
996
1224
  try {
@@ -1013,37 +1241,44 @@ async function D(e) {
1013
1241
  }
1014
1242
  }
1015
1243
  export {
1016
- ke as STORAGE_STRATEGY_DESCRIPTIONS,
1244
+ me as STORAGE_STRATEGY_DESCRIPTIONS,
1017
1245
  r as failure,
1018
- Q as getAccessToken,
1019
- Re as getAuthUrl,
1020
- qe as getBridge,
1021
- Fe as getBridges,
1022
- Ne as getCamera,
1023
- je as getCameras,
1024
- _e as getClientId,
1025
- De as getConfig,
1026
- we as getCurrentUser,
1027
- Qe as getEvent,
1028
- Be as getLiveImage,
1029
- ye as getMediaSession,
1246
+ p as formatTimestamp,
1247
+ M as getAccessToken,
1248
+ Ye as getAlert,
1249
+ Ee as getAuthUrl,
1250
+ He as getBridge,
1251
+ Be as getBridges,
1252
+ Pe as getCamera,
1253
+ qe as getCameras,
1254
+ he as getClientId,
1255
+ be as getConfig,
1256
+ je as getCurrentUser,
1257
+ We as getEvent,
1258
+ Je as getEventMetrics,
1259
+ ze as getLiveImage,
1260
+ ve as getMediaSession,
1261
+ tt as getNotification,
1030
1262
  P as getProxyUrl,
1031
- xe as getRecordedImage,
1032
- z as getRedirectUri,
1033
- $e as getStorageStrategy,
1034
- Le as getUser,
1035
- be as getUsers,
1036
- Ie as handleAuthCallback,
1037
- Oe as initEenToolkit,
1038
- He as initMediaSession,
1039
- Ve as listEventFieldValues,
1040
- Me as listEventTypes,
1041
- ze as listEvents,
1042
- Ce as listFeeds,
1043
- Pe as listMedia,
1044
- pe as refreshToken,
1045
- Ee as revokeToken,
1046
- d as success,
1047
- f as useAuthStore
1263
+ Qe as getRecordedImage,
1264
+ C as getRedirectUri,
1265
+ we as getStorageStrategy,
1266
+ Fe as getUser,
1267
+ Le as getUsers,
1268
+ Ae as handleAuthCallback,
1269
+ Ne as initEenToolkit,
1270
+ Ce as initMediaSession,
1271
+ Ze as listAlertTypes,
1272
+ Xe as listAlerts,
1273
+ Ge as listEventFieldValues,
1274
+ Ke as listEventTypes,
1275
+ Ve as listEvents,
1276
+ Me as listFeeds,
1277
+ xe as listMedia,
1278
+ et as listNotifications,
1279
+ Ie as refreshToken,
1280
+ Te as revokeToken,
1281
+ l as success,
1282
+ _ as useAuthStore
1048
1283
  };
1049
1284
  //# sourceMappingURL=index.js.map