@burdenoff/microfe-movethewheels 2026.1108.2 → 2026.1108.4

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 (26) hide show
  1. package/dist/components/DocumentsCard.js +183 -55
  2. package/dist/generated/tracking-quality-operations.d.ts +328 -1
  3. package/dist/generated/wspace-types.d.ts +1479 -10
  4. package/dist/hooks/useCarrierIntegrations.js +30 -29
  5. package/dist/hooks/useDocumentExtractions.js +100 -0
  6. package/dist/movethewheels/hooks/useCarrierIntegrations.d.ts +9 -3
  7. package/dist/movethewheels/hooks/useDocumentExtractions.d.ts +49 -0
  8. package/dist/movethewheels/hooks/useEntityDocuments.d.ts +5 -5
  9. package/dist/movethewheels/utils/carrierIntegrations.d.ts +90 -9
  10. package/dist/node_modules/lucide-react/dist/esm/icons/cloud-download.js +18 -0
  11. package/dist/node_modules/lucide-react/dist/esm/icons/file-search.js +24 -0
  12. package/dist/pages/IntegrationsPage.js +551 -329
  13. package/dist/pages/MultiModalShipmentPage.js +125 -121
  14. package/dist/pages/RouteDetailsPage.js +212 -207
  15. package/dist/utils/carrierIntegrations.js +127 -30
  16. package/package.json +1 -1
  17. package/src/generated/tracking-quality-operations.ts +373 -0
  18. package/src/generated/wspace-types.ts +1672 -10
  19. package/src/movethewheels/components/DocumentsCard.tsx +174 -29
  20. package/src/movethewheels/hooks/useCarrierIntegrations.ts +19 -2
  21. package/src/movethewheels/hooks/useDocumentExtractions.ts +246 -0
  22. package/src/movethewheels/hooks/useEntityDocuments.ts +5 -5
  23. package/src/movethewheels/pages/IntegrationsPage.tsx +292 -36
  24. package/src/movethewheels/pages/MultiModalShipmentPage.tsx +2 -0
  25. package/src/movethewheels/pages/RouteDetailsPage.tsx +2 -0
  26. package/src/movethewheels/utils/carrierIntegrations.ts +252 -10
@@ -2,282 +2,420 @@ import { Activity as e } from "../node_modules/lucide-react/dist/esm/icons/activ
2
2
  import { Check as t } from "../node_modules/lucide-react/dist/esm/icons/check.js";
3
3
  import { ChevronDown as n } from "../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
4
4
  import { ChevronUp as r } from "../node_modules/lucide-react/dist/esm/icons/chevron-up.js";
5
- import { Copy as i } from "../node_modules/lucide-react/dist/esm/icons/copy.js";
6
- import { KeyRound as a } from "../node_modules/lucide-react/dist/esm/icons/key-round.js";
7
- import { Pause as o } from "../node_modules/lucide-react/dist/esm/icons/pause.js";
8
- import { Play as s } from "../node_modules/lucide-react/dist/esm/icons/play.js";
9
- import { Plug as c } from "../node_modules/lucide-react/dist/esm/icons/plug.js";
10
- import { Plus as l } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
11
- import { RefreshCw as u } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
12
- import { ShieldCheck as d } from "../node_modules/lucide-react/dist/esm/icons/shield-check.js";
13
- import { Trash2 as f } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
14
- import { useMoveTheWheels as p } from "../providers/MoveTheWheelsProvider.js";
15
- import { formatDateTime as m } from "../utils/formatters.js";
16
- import { Badge as h, Button as g, Card as _, CardContent as v, Input as y, Label as b, Select as ee, SelectContent as te, SelectItem as x, SelectTrigger as ne, SelectValue as re, Skeleton as S } from "../components/ui.js";
17
- import { PageLayout as C } from "../components/PageLayout.js";
18
- import { MetricCard as w, MetricGrid as ie } from "../components/MetricCard.js";
19
- import { FormError as T } from "../components/FormError.js";
20
- import { Notice as ae, useNotice as oe } from "../components/Notice.js";
21
- import { DEFAULT_SAMSARA_SHIPMENT_KEY as E, INTEGRATION_STATUSES as se, PLANNED_ELD_PROVIDERS as ce, ROADMAP_PROVIDERS as le, SAMSARA_EVENT_TYPES as ue, SAMSARA_SIGNATURE_HEADERS as de, SIGNATURE_HEADER as D, TRACKING_EVENT_TYPES as fe, curlExample as O, eventStatusTone as pe, examplePayload as k, externalIdKeyError as me, generateSigningSecret as A, humanize as j, integrationNameError as M, integrationStatusTone as he, providerLabel as ge, samsaraSecretError as N, signingSecretError as _e, statusExplanation as P, webhookUrl as ve } from "../utils/carrierIntegrations.js";
22
- import { useCarrierIntegrationActions as ye, useCarrierIntegrationCounts as be, useCarrierIntegrationEvents as F, useCarrierIntegrations as xe } from "../hooks/useCarrierIntegrations.js";
23
- import { useEffect as Se, useRef as Ce, useState as I } from "react";
24
- import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
25
- import { CTAOverflowMenu as we, PagePurpose as Te, ResponsiveDialog as B, ResponsiveDialogContent as V, ResponsiveDialogDescription as H, ResponsiveDialogFooter as U, ResponsiveDialogHeader as W, ResponsiveDialogTitle as G } from "@burdenoff/fe-libs/ui";
5
+ import { CloudDownload as i } from "../node_modules/lucide-react/dist/esm/icons/cloud-download.js";
6
+ import { Copy as a } from "../node_modules/lucide-react/dist/esm/icons/copy.js";
7
+ import { KeyRound as o } from "../node_modules/lucide-react/dist/esm/icons/key-round.js";
8
+ import { Pause as s } from "../node_modules/lucide-react/dist/esm/icons/pause.js";
9
+ import { Play as c } from "../node_modules/lucide-react/dist/esm/icons/play.js";
10
+ import { Plug as l } from "../node_modules/lucide-react/dist/esm/icons/plug.js";
11
+ import { Plus as u } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
12
+ import { RefreshCw as d } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
13
+ import { ShieldCheck as f } from "../node_modules/lucide-react/dist/esm/icons/shield-check.js";
14
+ import { Trash2 as p } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
15
+ import { useMoveTheWheels as m } from "../providers/MoveTheWheelsProvider.js";
16
+ import { formatDateTime as h } from "../utils/formatters.js";
17
+ import { Badge as g, Button as _, Card as v, CardContent as y, Checkbox as b, Input as x, Label as S, Select as C, SelectContent as ee, SelectItem as w, SelectTrigger as te, SelectValue as ne, Skeleton as T, Textarea as re } from "../components/ui.js";
18
+ import { PageLayout as ie } from "../components/PageLayout.js";
19
+ import { MetricCard as E, MetricGrid as ae } from "../components/MetricCard.js";
20
+ import { FormError as D } from "../components/FormError.js";
21
+ import { Notice as oe, useNotice as se } from "../components/Notice.js";
22
+ import { DEFAULT_GEOTAB_SERVER as O, DEFAULT_SAMSARA_SHIPMENT_KEY as ce, GEOTAB_RULE_EVENT_TYPES as le, INTEGRATION_STATUSES as ue, PLANNED_ELD_PROVIDERS as k, ROADMAP_PROVIDERS as de, SAMSARA_EVENT_TYPES as A, SAMSARA_SIGNATURE_HEADERS as j, SIGNATURE_HEADER as M, TRACKING_EVENT_TYPES as N, buildGeotabConfig as fe, curlExample as P, eventStatusTone as F, examplePayload as pe, externalIdKeyError as me, generateSigningSecret as I, geotabPasswordError as L, humanize as R, integrationNameError as z, integrationStatusTone as B, isPolledProvider as he, pollResultMessage as ge, pollStatusSummary as V, pollStatusTone as _e, providerLabel as ve, samsaraSecretError as ye, signingSecretError as be, statusExplanation as xe, webhookUrl as Se } from "../utils/carrierIntegrations.js";
23
+ import { useCarrierIntegrationActions as Ce, useCarrierIntegrationCounts as we, useCarrierIntegrationEvents as H, useCarrierIntegrations as Te } from "../hooks/useCarrierIntegrations.js";
24
+ import { useEffect as Ee, useRef as De, useState as U } from "react";
25
+ import { Fragment as W, jsx as G, jsxs as K } from "react/jsx-runtime";
26
+ import { CTAOverflowMenu as Oe, PagePurpose as ke, ResponsiveDialog as q, ResponsiveDialogContent as J, ResponsiveDialogDescription as Y, ResponsiveDialogFooter as X, ResponsiveDialogHeader as Ae, ResponsiveDialogTitle as je } from "@burdenoff/fe-libs/ui";
26
27
  //#region src/movethewheels/pages/IntegrationsPage.tsx
27
- var K = 20, q = "ALL";
28
- function J(e, t) {
28
+ var Me = 20, Z = "ALL";
29
+ function Q(e, t) {
29
30
  return e instanceof Error && e.message ? e.message : t;
30
31
  }
31
- function Y({ label: e, value: n, multiline: r }) {
32
- let [a, o] = I(!1), s = async () => {
32
+ function $({ label: e, value: n, multiline: r }) {
33
+ let [i, o] = U(!1), s = async () => {
33
34
  try {
34
35
  await navigator.clipboard.writeText(n), o(!0), window.setTimeout(() => o(!1), 2e3);
35
36
  } catch {
36
37
  o(!1);
37
38
  }
38
39
  };
39
- return /* @__PURE__ */ z("div", {
40
+ return /* @__PURE__ */ K("div", {
40
41
  className: "space-y-1",
41
- children: [/* @__PURE__ */ z("div", {
42
+ children: [/* @__PURE__ */ K("div", {
42
43
  className: "flex items-center justify-between gap-2",
43
- children: [/* @__PURE__ */ R("span", {
44
+ children: [/* @__PURE__ */ G("span", {
44
45
  className: "text-xs font-medium text-text-secondary",
45
46
  children: e
46
- }), /* @__PURE__ */ z(g, {
47
+ }), /* @__PURE__ */ K(_, {
47
48
  type: "button",
48
49
  size: "sm",
49
50
  variant: "ghost",
50
51
  onClick: () => void s(),
51
52
  "aria-label": `Copy ${e.toLowerCase()}`,
52
- children: [R(a ? t : i, {
53
+ children: [G(i ? t : a, {
53
54
  size: 14,
54
55
  className: "mr-1"
55
- }), a ? "Copied" : "Copy"]
56
+ }), i ? "Copied" : "Copy"]
56
57
  })]
57
- }), r ? /* @__PURE__ */ R("pre", {
58
+ }), r ? /* @__PURE__ */ G("pre", {
58
59
  className: "max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs text-text-primary",
59
60
  children: n
60
- }) : /* @__PURE__ */ R("code", {
61
+ }) : /* @__PURE__ */ G("code", {
61
62
  className: "block break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs text-text-primary",
62
63
  children: n
63
64
  })]
64
65
  });
65
66
  }
66
- function Ee({ secret: e, integrationName: t, onClose: n }) {
67
- return /* @__PURE__ */ R(B, {
67
+ function Ne({ secret: e, integrationName: t, onClose: n }) {
68
+ return /* @__PURE__ */ G(q, {
68
69
  open: e !== null,
69
70
  onOpenChange: (e) => !e && n(),
70
- children: /* @__PURE__ */ z(V, { children: [
71
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ z(G, { children: ["Signing secret for ", t] }), /* @__PURE__ */ R(H, { children: "Copy it into the sending system now. MoveTheWheels stores it to verify deliveries but will not show it again; rotate it if it is lost." })] }),
72
- e ? /* @__PURE__ */ R(Y, {
71
+ children: /* @__PURE__ */ K(J, { children: [
72
+ /* @__PURE__ */ K(Ae, { children: [/* @__PURE__ */ K(je, { children: ["Signing secret for ", t] }), /* @__PURE__ */ G(Y, { children: "Copy it into the sending system now. MoveTheWheels stores it to verify deliveries but will not show it again; rotate it if it is lost." })] }),
73
+ e ? /* @__PURE__ */ G($, {
73
74
  label: "Signing secret",
74
75
  value: e
75
76
  }, e) : null,
76
- /* @__PURE__ */ R(U, { children: /* @__PURE__ */ R(g, {
77
+ /* @__PURE__ */ G(X, { children: /* @__PURE__ */ G(_, {
77
78
  onClick: n,
78
79
  children: "I have saved it"
79
80
  }) })
80
81
  ] })
81
82
  });
82
83
  }
83
- function De({ open: e, onOpenChange: t, onCreated: n }) {
84
- let r = ye(), [i, a] = I("GENERIC_WEBHOOK"), [o, s] = I(""), [c, l] = I(() => A()), [d, f] = I(""), [p, m] = I(""), [h, _] = I(null), [v, S] = I(!1), C = i === "SAMSARA", w = () => {
85
- a("GENERIC_WEBHOOK"), s(""), l(A()), f(""), m(""), _(null);
86
- }, ie = async (e) => {
84
+ function Pe({ open: e, onOpenChange: t, onCreated: n }) {
85
+ let r = Ce(), [i, a] = U("GENERIC_WEBHOOK"), [o, s] = U(""), [c, l] = U(() => I()), [u, f] = U(""), [p, m] = U(""), [h, g] = U(""), [v, y] = U(""), [T, ie] = U(""), [E, ae] = U(""), [oe, se] = U(""), [ue, k] = U(!0), [de, A] = U(null), [j, M] = U(!1), N = i === "SAMSARA", P = i === "GEOTAB", F = () => {
86
+ a("GENERIC_WEBHOOK"), s(""), l(I()), f(""), m(""), g(""), y(""), ie(""), ae(""), se(""), k(!0), A(null);
87
+ }, pe = () => {
88
+ let e = fe({
89
+ server: h,
90
+ database: v,
91
+ userName: T,
92
+ ruleMappings: oe,
93
+ locationUpdates: ue
94
+ });
95
+ if (!e.ok) return {
96
+ error: e.error,
97
+ input: null
98
+ };
99
+ let t = L(E);
100
+ return t ? {
101
+ error: t,
102
+ input: null
103
+ } : {
104
+ error: null,
105
+ input: {
106
+ provider: "GEOTAB",
107
+ name: o,
108
+ apiSecret: E,
109
+ config: e.config
110
+ }
111
+ };
112
+ }, R = async (e) => {
87
113
  e.preventDefault();
88
- let i = M(o) ?? (C ? N(d) ?? me(p) : _e(c));
89
- if (i) {
90
- _(i);
114
+ let i = P ? pe() : null, a = z(o) ?? (P ? i?.error ?? null : N ? ye(u) ?? me(p) : be(c));
115
+ if (a) {
116
+ A(a);
91
117
  return;
92
118
  }
93
- S(!0), _(null);
119
+ M(!0), A(null);
94
120
  try {
95
121
  let e = p.trim();
96
- n(await r.create(C ? {
122
+ n(await r.create(i?.input ? i.input : N ? {
97
123
  provider: "SAMSARA",
98
124
  name: o,
99
- apiSecret: d.trim(),
125
+ apiSecret: u.trim(),
100
126
  ...e ? { config: { shipmentExternalIdKey: e } } : {}
101
127
  } : {
102
128
  provider: "GENERIC_WEBHOOK",
103
129
  name: o,
104
130
  apiSecret: c
105
- }), C ? null : c), w(), t(!1);
131
+ }), N || P ? null : c), F(), t(!1);
106
132
  } catch (e) {
107
- _(J(e, "Could not create the integration."));
133
+ A(Q(e, "Could not create the integration."));
108
134
  } finally {
109
- S(!1);
135
+ M(!1);
110
136
  }
111
137
  };
112
- return /* @__PURE__ */ R(B, {
138
+ return /* @__PURE__ */ G(q, {
113
139
  open: e,
114
140
  onOpenChange: (e) => {
115
- e || w(), t(e);
141
+ e || F(), t(e);
116
142
  },
117
- children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
118
- onSubmit: (e) => void ie(e),
143
+ children: /* @__PURE__ */ G(J, { children: /* @__PURE__ */ K("form", {
144
+ onSubmit: (e) => void R(e),
119
145
  className: "space-y-4",
120
146
  children: [
121
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ R(G, { children: "Connect a tracking feed" }), /* @__PURE__ */ R(H, { children: "A signed webhook from a carrier, ELD or GPS provider. Updates it sends become tracking events on the matching shipments." })] }),
122
- /* @__PURE__ */ z("div", {
147
+ /* @__PURE__ */ K(Ae, { children: [/* @__PURE__ */ G(je, { children: "Connect a tracking feed" }), /* @__PURE__ */ G(Y, { children: P ? "MoveTheWheels signs in to MyGeotab and reads new GPS positions and exception events every 5 minutes. They become tracking events on the matching shipments." : "A signed webhook from a carrier, ELD or GPS provider. Updates it sends become tracking events on the matching shipments." })] }),
148
+ /* @__PURE__ */ K("div", {
123
149
  className: "space-y-1.5",
124
- children: [/* @__PURE__ */ R(b, {
150
+ children: [/* @__PURE__ */ G(S, {
125
151
  htmlFor: "integration-name",
126
152
  children: "Name"
127
- }), /* @__PURE__ */ R(y, {
153
+ }), /* @__PURE__ */ G(x, {
128
154
  id: "integration-name",
129
155
  value: o,
130
156
  maxLength: 120,
131
- placeholder: C ? "e.g. Samsara fleet" : "e.g. Fleet GPS feed",
157
+ placeholder: N ? "e.g. Samsara fleet" : P ? "e.g. Geotab fleet" : "e.g. Fleet GPS feed",
132
158
  onChange: (e) => s(e.target.value),
133
159
  autoFocus: !0
134
160
  })]
135
161
  }),
136
- /* @__PURE__ */ z("div", {
162
+ /* @__PURE__ */ K("div", {
137
163
  className: "space-y-1.5",
138
- children: [/* @__PURE__ */ R(b, {
164
+ children: [/* @__PURE__ */ G(S, {
139
165
  htmlFor: "integration-type",
140
166
  children: "Type"
141
- }), /* @__PURE__ */ z(ee, {
167
+ }), /* @__PURE__ */ K(C, {
142
168
  value: i,
143
169
  onValueChange: (e) => {
144
- a(e), _(null);
170
+ a(e), A(null);
145
171
  },
146
- children: [/* @__PURE__ */ R(ne, {
172
+ children: [/* @__PURE__ */ G(te, {
147
173
  id: "integration-type",
148
174
  "aria-label": "Type",
149
- children: /* @__PURE__ */ R(re, {})
150
- }), /* @__PURE__ */ z(te, { children: [/* @__PURE__ */ R(x, {
151
- value: "GENERIC_WEBHOOK",
152
- children: "Signed webhook (any system that can send HTTPS POSTs)"
153
- }), /* @__PURE__ */ R(x, {
154
- value: "SAMSARA",
155
- children: "Samsara (ELD and telematics)"
156
- })] })]
175
+ children: /* @__PURE__ */ G(ne, {})
176
+ }), /* @__PURE__ */ K(ee, { children: [
177
+ /* @__PURE__ */ G(w, {
178
+ value: "GENERIC_WEBHOOK",
179
+ children: "Signed webhook (any system that can send HTTPS POSTs)"
180
+ }),
181
+ /* @__PURE__ */ G(w, {
182
+ value: "SAMSARA",
183
+ children: "Samsara (ELD and telematics)"
184
+ }),
185
+ /* @__PURE__ */ G(w, {
186
+ value: "GEOTAB",
187
+ children: "Geotab / MyGeotab (telematics, polled)"
188
+ })
189
+ ] })]
157
190
  })]
158
191
  }),
159
- C ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
192
+ P ? /* @__PURE__ */ K(W, { children: [
193
+ /* @__PURE__ */ K("div", {
194
+ className: "grid gap-4 sm:grid-cols-2",
195
+ children: [
196
+ /* @__PURE__ */ K("div", {
197
+ className: "space-y-1.5",
198
+ children: [/* @__PURE__ */ G(S, {
199
+ htmlFor: "geotab-database",
200
+ children: "MyGeotab database"
201
+ }), /* @__PURE__ */ G(x, {
202
+ id: "geotab-database",
203
+ value: v,
204
+ maxLength: 255,
205
+ autoComplete: "off",
206
+ spellCheck: !1,
207
+ placeholder: "e.g. acme_logistics",
208
+ onChange: (e) => y(e.target.value)
209
+ })]
210
+ }),
211
+ /* @__PURE__ */ K("div", {
212
+ className: "space-y-1.5",
213
+ children: [/* @__PURE__ */ G(S, {
214
+ htmlFor: "geotab-server",
215
+ children: "Server (optional)"
216
+ }), /* @__PURE__ */ G(x, {
217
+ id: "geotab-server",
218
+ value: h,
219
+ maxLength: 255,
220
+ autoComplete: "off",
221
+ spellCheck: !1,
222
+ placeholder: O,
223
+ onChange: (e) => g(e.target.value)
224
+ })]
225
+ }),
226
+ /* @__PURE__ */ K("div", {
227
+ className: "space-y-1.5",
228
+ children: [/* @__PURE__ */ G(S, {
229
+ htmlFor: "geotab-user",
230
+ children: "User name"
231
+ }), /* @__PURE__ */ G(x, {
232
+ id: "geotab-user",
233
+ value: T,
234
+ maxLength: 255,
235
+ autoComplete: "off",
236
+ spellCheck: !1,
237
+ placeholder: "e.g. mtw-api@acme.com",
238
+ onChange: (e) => ie(e.target.value)
239
+ })]
240
+ }),
241
+ /* @__PURE__ */ K("div", {
242
+ className: "space-y-1.5",
243
+ children: [/* @__PURE__ */ G(S, {
244
+ htmlFor: "geotab-password",
245
+ children: "Password"
246
+ }), /* @__PURE__ */ G(x, {
247
+ id: "geotab-password",
248
+ type: "password",
249
+ autoComplete: "new-password",
250
+ spellCheck: !1,
251
+ value: E,
252
+ onChange: (e) => ae(e.target.value)
253
+ })]
254
+ })
255
+ ]
256
+ }),
257
+ /* @__PURE__ */ G("p", {
258
+ className: "text-xs text-text-secondary",
259
+ children: "Use a dedicated MyGeotab user with read access to devices, GPS logs and exceptions. MoveTheWheels stores the password encrypted and never shows it again."
260
+ }),
261
+ /* @__PURE__ */ K("div", {
262
+ className: "flex items-center gap-3",
263
+ children: [/* @__PURE__ */ G(b, {
264
+ id: "geotab-locations",
265
+ checked: ue,
266
+ onCheckedChange: (e) => k(e === !0)
267
+ }), /* @__PURE__ */ G(S, {
268
+ htmlFor: "geotab-locations",
269
+ children: "Add each vehicle's latest GPS position as an In transit event"
270
+ })]
271
+ }),
272
+ /* @__PURE__ */ K("div", {
273
+ className: "space-y-1.5",
274
+ children: [
275
+ /* @__PURE__ */ G(S, {
276
+ htmlFor: "geotab-rules",
277
+ children: "Exception rules to track (optional)"
278
+ }),
279
+ /* @__PURE__ */ G(re, {
280
+ id: "geotab-rules",
281
+ value: oe,
282
+ rows: 3,
283
+ spellCheck: !1,
284
+ placeholder: "RuleArriveCustomerId = ARRIVED\nRuleLeaveDepotId = DEPARTED",
285
+ onChange: (e) => se(e.target.value)
286
+ }),
287
+ /* @__PURE__ */ K("p", {
288
+ className: "text-xs text-text-secondary",
289
+ children: [
290
+ "One per line: a MyGeotab rule id (for example a zone arrival rule) and the event it becomes: ",
291
+ le.join(", "),
292
+ ". Other rules are ignored."
293
+ ]
294
+ })
295
+ ]
296
+ })
297
+ ] }) : N ? /* @__PURE__ */ K(W, { children: [/* @__PURE__ */ K("div", {
160
298
  className: "space-y-1.5",
161
299
  children: [
162
- /* @__PURE__ */ R(b, {
300
+ /* @__PURE__ */ G(S, {
163
301
  htmlFor: "samsara-secret",
164
302
  children: "Samsara webhook secret key"
165
303
  }),
166
- /* @__PURE__ */ R(y, {
304
+ /* @__PURE__ */ G(x, {
167
305
  id: "samsara-secret",
168
306
  type: "password",
169
307
  autoComplete: "off",
170
308
  spellCheck: !1,
171
- value: d,
309
+ value: u,
172
310
  placeholder: "Paste from Samsara → Settings → Webhooks",
173
311
  onChange: (e) => f(e.target.value)
174
312
  }),
175
- /* @__PURE__ */ R("p", {
313
+ /* @__PURE__ */ G("p", {
176
314
  className: "text-xs text-text-secondary",
177
315
  children: "Create the webhook in Samsara first; its page shows this key. MoveTheWheels stores it encrypted and never shows it again."
178
316
  })
179
317
  ]
180
- }), /* @__PURE__ */ z("div", {
318
+ }), /* @__PURE__ */ K("div", {
181
319
  className: "space-y-1.5",
182
320
  children: [
183
- /* @__PURE__ */ R(b, {
321
+ /* @__PURE__ */ G(S, {
184
322
  htmlFor: "samsara-shipment-key",
185
323
  children: "Shipment external ID key (optional)"
186
324
  }),
187
- /* @__PURE__ */ R(y, {
325
+ /* @__PURE__ */ G(x, {
188
326
  id: "samsara-shipment-key",
189
327
  value: p,
190
328
  maxLength: 64,
191
- placeholder: E,
329
+ placeholder: ce,
192
330
  onChange: (e) => m(e.target.value)
193
331
  }),
194
- /* @__PURE__ */ z("p", {
332
+ /* @__PURE__ */ K("p", {
195
333
  className: "text-xs text-text-secondary",
196
334
  children: [
197
335
  "The external ID on a Samsara route or stop that holds the MoveTheWheels tracking number. Leave blank to use",
198
336
  " ",
199
- /* @__PURE__ */ R("code", {
337
+ /* @__PURE__ */ G("code", {
200
338
  className: "font-mono",
201
- children: E
339
+ children: ce
202
340
  }),
203
341
  "."
204
342
  ]
205
343
  })
206
344
  ]
207
- })] }) : /* @__PURE__ */ z("div", {
345
+ })] }) : /* @__PURE__ */ K("div", {
208
346
  className: "space-y-1.5",
209
347
  children: [
210
- /* @__PURE__ */ z("div", {
348
+ /* @__PURE__ */ K("div", {
211
349
  className: "flex items-center justify-between",
212
- children: [/* @__PURE__ */ R(b, { children: "Signing secret" }), /* @__PURE__ */ z(g, {
350
+ children: [/* @__PURE__ */ G(S, { children: "Signing secret" }), /* @__PURE__ */ K(_, {
213
351
  type: "button",
214
352
  size: "sm",
215
353
  variant: "ghost",
216
- onClick: () => l(A()),
217
- children: [/* @__PURE__ */ R(u, {
354
+ onClick: () => l(I()),
355
+ children: [/* @__PURE__ */ G(d, {
218
356
  size: 14,
219
357
  className: "mr-1"
220
358
  }), "Generate another"]
221
359
  })]
222
360
  }),
223
- /* @__PURE__ */ R("code", {
361
+ /* @__PURE__ */ G("code", {
224
362
  className: "block break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs",
225
363
  children: c
226
364
  }),
227
- /* @__PURE__ */ R("p", {
365
+ /* @__PURE__ */ G("p", {
228
366
  className: "text-xs text-text-secondary",
229
367
  children: "Generated in your browser. You can copy it on the next step."
230
368
  })
231
369
  ]
232
370
  }),
233
- /* @__PURE__ */ R(T, { message: h }),
234
- /* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
371
+ /* @__PURE__ */ G(D, { message: de }),
372
+ /* @__PURE__ */ K(X, { children: [/* @__PURE__ */ G(_, {
235
373
  type: "button",
236
374
  variant: "outline",
237
375
  onClick: () => t(!1),
238
376
  children: "Cancel"
239
- }), /* @__PURE__ */ R(g, {
377
+ }), /* @__PURE__ */ G(_, {
240
378
  type: "submit",
241
- disabled: v,
242
- children: v ? "Connecting…" : "Connect"
379
+ disabled: j,
380
+ children: j ? "Connecting…" : "Connect"
243
381
  })] })
244
382
  ]
245
383
  }) })
246
384
  });
247
385
  }
248
- function Oe({ integration: e, onClose: t, onReplace: n }) {
249
- let [r, i] = I(""), [a, o] = I(null), [s, c] = I(!1), l = () => {
386
+ function Fe({ integration: e, onClose: t, onReplace: n }) {
387
+ let [r, i] = U(""), [a, o] = U(null), [s, c] = U(!1), l = e?.provider === "GEOTAB", u = () => {
250
388
  i(""), o(null), t();
251
- }, u = async (t) => {
389
+ }, d = async (t) => {
252
390
  if (t.preventDefault(), !e) return;
253
- let i = N(r);
391
+ let i = l ? L(r) : ye(r);
254
392
  if (i) {
255
393
  o(i);
256
394
  return;
257
395
  }
258
396
  c(!0), o(null);
259
397
  try {
260
- await n(e, r.trim()), l();
398
+ await n(e, l ? r : r.trim()), u();
261
399
  } catch (e) {
262
- o(J(e, "Could not replace the secret."));
400
+ o(Q(e, "Could not replace the secret."));
263
401
  } finally {
264
402
  c(!1);
265
403
  }
266
404
  };
267
- return /* @__PURE__ */ R(B, {
405
+ return /* @__PURE__ */ G(q, {
268
406
  open: e !== null,
269
- onOpenChange: (e) => !e && l(),
270
- children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
271
- onSubmit: (e) => void u(e),
407
+ onOpenChange: (e) => !e && u(),
408
+ children: /* @__PURE__ */ G(J, { children: /* @__PURE__ */ K("form", {
409
+ onSubmit: (e) => void d(e),
272
410
  className: "space-y-4",
273
411
  children: [
274
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ z(G, { children: ["Replace the Samsara secret for ", e?.name] }), /* @__PURE__ */ R(H, { children: "Regenerate the secret on the webhook page in Samsara, then paste the new key here. Deliveries signed with the old key are refused once you save." })] }),
275
- /* @__PURE__ */ z("div", {
412
+ /* @__PURE__ */ K(Ae, { children: [/* @__PURE__ */ G(je, { children: l ? `Update the MyGeotab password for ${e?.name ?? ""}` : `Replace the Samsara secret for ${e?.name ?? ""}` }), /* @__PURE__ */ G(Y, { children: l ? "Enter the current password of the MyGeotab user this feed signs in as. The next poll signs in with it." : "Regenerate the secret on the webhook page in Samsara, then paste the new key here. Deliveries signed with the old key are refused once you save." })] }),
413
+ /* @__PURE__ */ K("div", {
276
414
  className: "space-y-1.5",
277
- children: [/* @__PURE__ */ R(b, {
415
+ children: [/* @__PURE__ */ G(S, {
278
416
  htmlFor: "samsara-new-secret",
279
- children: "New Samsara webhook secret key"
280
- }), /* @__PURE__ */ R(y, {
417
+ children: l ? "New MyGeotab password" : "New Samsara webhook secret key"
418
+ }), /* @__PURE__ */ G(x, {
281
419
  id: "samsara-new-secret",
282
420
  type: "password",
283
421
  autoComplete: "off",
@@ -287,58 +425,58 @@ function Oe({ integration: e, onClose: t, onReplace: n }) {
287
425
  autoFocus: !0
288
426
  })]
289
427
  }),
290
- /* @__PURE__ */ R(T, { message: a }),
291
- /* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
428
+ /* @__PURE__ */ G(D, { message: a }),
429
+ /* @__PURE__ */ K(X, { children: [/* @__PURE__ */ G(_, {
292
430
  type: "button",
293
431
  variant: "outline",
294
- onClick: l,
432
+ onClick: u,
295
433
  children: "Cancel"
296
- }), /* @__PURE__ */ R(g, {
434
+ }), /* @__PURE__ */ G(_, {
297
435
  type: "submit",
298
436
  disabled: s,
299
- children: s ? "Saving…" : "Replace secret"
437
+ children: s ? "Saving…" : l ? "Update password" : "Replace secret"
300
438
  })] })
301
439
  ]
302
440
  }) })
303
441
  });
304
442
  }
305
- function X({ url: e }) {
306
- return /* @__PURE__ */ z("div", {
443
+ function Ie({ url: e }) {
444
+ return /* @__PURE__ */ K("div", {
307
445
  className: "space-y-3",
308
446
  children: [
309
- /* @__PURE__ */ R("p", {
447
+ /* @__PURE__ */ G("p", {
310
448
  className: "text-sm font-medium",
311
449
  children: "How to connect Samsara"
312
450
  }),
313
- /* @__PURE__ */ R(Y, {
451
+ /* @__PURE__ */ G($, {
314
452
  label: "Webhook URL",
315
453
  value: e
316
454
  }),
317
- /* @__PURE__ */ z("ol", {
455
+ /* @__PURE__ */ K("ol", {
318
456
  className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
319
457
  children: [
320
- /* @__PURE__ */ z("li", { children: [
458
+ /* @__PURE__ */ K("li", { children: [
321
459
  "In Samsara, open Settings → Developer → Webhooks, add a webhook with the URL above and subscribe it to",
322
460
  " ",
323
- ue.map((e, t) => /* @__PURE__ */ z("span", { children: [t > 0 ? ", " : "", /* @__PURE__ */ R("code", {
461
+ A.map((e, t) => /* @__PURE__ */ K("span", { children: [t > 0 ? ", " : "", /* @__PURE__ */ G("code", {
324
462
  className: "font-mono",
325
463
  children: e.type
326
464
  })] }, e.type)),
327
465
  "."
328
466
  ] }),
329
- /* @__PURE__ */ R("li", { children: "Route stop and geofence arrivals become Arrived events; departures become Departed events." }),
330
- /* @__PURE__ */ z("li", { children: [
467
+ /* @__PURE__ */ G("li", { children: "Route stop and geofence arrivals become Arrived events; departures become Departed events." }),
468
+ /* @__PURE__ */ K("li", { children: [
331
469
  "To match a shipment, put its MoveTheWheels tracking number in the route or stop external ID under the key chosen when this feed was connected (default",
332
470
  " ",
333
- /* @__PURE__ */ R("code", {
471
+ /* @__PURE__ */ G("code", {
334
472
  className: "font-mono",
335
- children: E
473
+ children: ce
336
474
  }),
337
475
  "). Without one, the Samsara vehicle name or licence plate is matched to a MoveTheWheels vehicle, and the event goes to that vehicle's single in-progress route."
338
476
  ] }),
339
- /* @__PURE__ */ z("li", { children: [
477
+ /* @__PURE__ */ K("li", { children: [
340
478
  "Samsara signs every delivery (",
341
- de.join(" and "),
479
+ j.join(" and "),
342
480
  "); deliveries with a wrong signature or more than five minutes old are refused."
343
481
  ] })
344
482
  ]
@@ -346,105 +484,157 @@ function X({ url: e }) {
346
484
  ]
347
485
  });
348
486
  }
349
- function Z({ integrationId: e, refreshKey: t }) {
350
- let { events: n, isLoading: r, error: i } = F(e, t);
351
- return /* @__PURE__ */ z("div", {
487
+ function Le({ integration: e }) {
488
+ return /* @__PURE__ */ K("div", {
489
+ className: "space-y-3",
490
+ children: [
491
+ /* @__PURE__ */ G("p", {
492
+ className: "text-sm font-medium",
493
+ children: "How the Geotab feed works"
494
+ }),
495
+ /* @__PURE__ */ K("ol", {
496
+ className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
497
+ children: [
498
+ /* @__PURE__ */ K("li", { children: [
499
+ "Every ",
500
+ 5,
501
+ " minutes MoveTheWheels signs in to MyGeotab and reads the GPS log and exception events added since the last poll. Nothing is set up in Geotab."
502
+ ] }),
503
+ /* @__PURE__ */ G("li", { children: "Each Geotab vehicle is matched to a MoveTheWheels vehicle by its name, licence plate or VIN; the event goes to that vehicle's single in-progress route. Records for vehicles that are not on a route are skipped." }),
504
+ /* @__PURE__ */ G("li", { children: "The newest GPS position of each vehicle becomes an In transit event with its location, when position updates are on. Mapped exception rules (typically zone arrivals and departures) become the events they are mapped to." }),
505
+ /* @__PURE__ */ G("li", { children: "Repeated sign-in failures slow the polling down so the MyGeotab user is not locked out; update the password, then use Poll now." })
506
+ ]
507
+ }),
508
+ /* @__PURE__ */ G(Re, { integration: e })
509
+ ]
510
+ });
511
+ }
512
+ function Re({ integration: e }) {
513
+ let t = e.pollStatus;
514
+ return /* @__PURE__ */ K("div", {
515
+ className: "space-y-1 rounded-lg bg-bg-sunken px-3 py-2",
516
+ "data-testid": "poll-status",
517
+ children: [
518
+ /* @__PURE__ */ K("div", {
519
+ className: "flex items-center gap-2",
520
+ children: [/* @__PURE__ */ G("span", {
521
+ className: "text-xs font-medium",
522
+ children: "Latest poll"
523
+ }), t?.lastPollStatus ? /* @__PURE__ */ G(g, {
524
+ variant: _e(t.lastPollStatus),
525
+ children: R(t.lastPollStatus)
526
+ }) : null]
527
+ }),
528
+ /* @__PURE__ */ G("p", {
529
+ className: "text-xs text-text-secondary",
530
+ children: V(t, h)
531
+ }),
532
+ t?.lastPollError ? /* @__PURE__ */ G("p", {
533
+ className: "break-words text-xs text-status-error-text",
534
+ children: t.lastPollError
535
+ }) : null
536
+ ]
537
+ });
538
+ }
539
+ function ze({ integrationId: e, refreshKey: t, polled: n = !1 }) {
540
+ let { events: r, isLoading: i, error: a } = H(e, t);
541
+ return /* @__PURE__ */ K("div", {
352
542
  className: "space-y-2",
353
543
  children: [
354
- /* @__PURE__ */ R("p", {
544
+ /* @__PURE__ */ G("p", {
355
545
  className: "text-sm font-medium",
356
- children: "Recent deliveries"
546
+ children: n ? "Recent polls" : "Recent deliveries"
357
547
  }),
358
- /* @__PURE__ */ R(T, { message: i?.message }),
359
- r && n.length === 0 ? /* @__PURE__ */ R(S, { className: "h-12 w-full" }) : n.length === 0 ? /* @__PURE__ */ R("p", {
548
+ /* @__PURE__ */ G(D, { message: a?.message }),
549
+ i && r.length === 0 ? /* @__PURE__ */ G(T, { className: "h-12 w-full" }) : r.length === 0 ? /* @__PURE__ */ G("p", {
360
550
  className: "text-sm text-text-secondary",
361
- children: "No deliveries yet. Send a signed test update with the example below."
362
- }) : /* @__PURE__ */ R("ul", {
551
+ children: n ? "No polls with updates yet. Polls that find nothing to add are not listed." : "No deliveries yet. Send a signed test update with the example below."
552
+ }) : /* @__PURE__ */ G("ul", {
363
553
  className: "space-y-2",
364
- children: n.map((e) => /* @__PURE__ */ z("li", {
554
+ children: r.map((e) => /* @__PURE__ */ K("li", {
365
555
  className: "flex flex-wrap items-start justify-between gap-3 rounded-lg bg-bg-sunken px-3 py-2",
366
- children: [/* @__PURE__ */ z("div", {
556
+ children: [/* @__PURE__ */ K("div", {
367
557
  className: "min-w-0",
368
558
  children: [
369
- /* @__PURE__ */ z("p", {
559
+ /* @__PURE__ */ K("p", {
370
560
  className: "text-sm font-medium",
371
- children: [e.eventType ? j(e.eventType) : "Delivery", e.externalEventId ? /* @__PURE__ */ R("span", {
561
+ children: [e.eventType ? R(e.eventType) : n ? "Poll" : "Delivery", e.externalEventId ? /* @__PURE__ */ G("span", {
372
562
  className: "ml-2 font-mono text-xs text-text-tertiary",
373
563
  children: e.externalEventId
374
564
  }) : null]
375
565
  }),
376
- /* @__PURE__ */ R("p", {
566
+ /* @__PURE__ */ G("p", {
377
567
  className: "text-xs text-text-secondary",
378
- children: m(e.receivedAt)
568
+ children: h(e.receivedAt)
379
569
  }),
380
- e.errorMessage ? /* @__PURE__ */ R("p", {
570
+ e.errorMessage ? /* @__PURE__ */ G("p", {
381
571
  className: "mt-1 break-words text-xs text-status-error-text",
382
572
  children: e.errorMessage
383
573
  }) : null
384
574
  ]
385
- }), /* @__PURE__ */ R(h, {
386
- variant: pe(e.status),
387
- children: j(e.status)
575
+ }), /* @__PURE__ */ G(g, {
576
+ variant: F(e.status),
577
+ children: R(e.status)
388
578
  })]
389
579
  }, e.id))
390
580
  })
391
581
  ]
392
582
  });
393
583
  }
394
- function Q({ url: e }) {
395
- return /* @__PURE__ */ z("div", {
584
+ function Be({ url: e }) {
585
+ return /* @__PURE__ */ K("div", {
396
586
  className: "space-y-3",
397
587
  children: [
398
- /* @__PURE__ */ R("p", {
588
+ /* @__PURE__ */ G("p", {
399
589
  className: "text-sm font-medium",
400
590
  children: "How to send updates"
401
591
  }),
402
- /* @__PURE__ */ R(Y, {
592
+ /* @__PURE__ */ G($, {
403
593
  label: "Webhook URL",
404
594
  value: e
405
595
  }),
406
- /* @__PURE__ */ z("ul", {
596
+ /* @__PURE__ */ K("ul", {
407
597
  className: "list-disc space-y-1 pl-5 text-xs text-text-secondary",
408
598
  children: [
409
- /* @__PURE__ */ z("li", { children: [
599
+ /* @__PURE__ */ K("li", { children: [
410
600
  "POST JSON: one update object, or an array of up to ",
411
601
  5,
412
602
  "."
413
603
  ] }),
414
- /* @__PURE__ */ z("li", { children: [
604
+ /* @__PURE__ */ K("li", { children: [
415
605
  "Sign the exact raw body with HMAC-SHA256 using the signing secret and send the hex digest in the ",
416
- /* @__PURE__ */ R("code", {
606
+ /* @__PURE__ */ G("code", {
417
607
  className: "font-mono",
418
- children: D
608
+ children: M
419
609
  }),
420
610
  " header (a",
421
611
  " ",
422
- /* @__PURE__ */ R("code", {
612
+ /* @__PURE__ */ G("code", {
423
613
  className: "font-mono",
424
614
  children: "sha256="
425
615
  }),
426
616
  " prefix is accepted)."
427
617
  ] }),
428
- /* @__PURE__ */ z("li", { children: [
618
+ /* @__PURE__ */ K("li", { children: [
429
619
  "Identify the shipment with ",
430
- /* @__PURE__ */ R("code", {
620
+ /* @__PURE__ */ G("code", {
431
621
  className: "font-mono",
432
622
  children: "trackingNumber"
433
623
  }),
434
624
  " or its",
435
625
  " ",
436
- /* @__PURE__ */ R("code", {
626
+ /* @__PURE__ */ G("code", {
437
627
  className: "font-mono",
438
628
  children: "shipmentId"
439
629
  }),
440
630
  ". Event types:",
441
631
  " ",
442
- fe.join(", "),
632
+ N.join(", "),
443
633
  "."
444
634
  ] }),
445
- /* @__PURE__ */ z("li", { children: [
635
+ /* @__PURE__ */ K("li", { children: [
446
636
  "Send a stable ",
447
- /* @__PURE__ */ R("code", {
637
+ /* @__PURE__ */ G("code", {
448
638
  className: "font-mono",
449
639
  children: "externalEventId"
450
640
  }),
@@ -452,334 +642,366 @@ function Q({ url: e }) {
452
642
  ] })
453
643
  ]
454
644
  }),
455
- /* @__PURE__ */ R(Y, {
645
+ /* @__PURE__ */ G($, {
456
646
  label: "Example body",
457
- value: k(),
647
+ value: pe(),
458
648
  multiline: !0
459
649
  }),
460
- /* @__PURE__ */ R(Y, {
650
+ /* @__PURE__ */ G($, {
461
651
  label: "Example request",
462
- value: O(e),
652
+ value: P(e),
463
653
  multiline: !0
464
654
  })
465
655
  ]
466
656
  });
467
657
  }
468
- function ke({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onToggle: u, onSetStatus: d, onRotate: p, onDelete: y }) {
469
- let b = e.status === "ACTIVE";
470
- return /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
658
+ function Ve({ integration: e, url: t, expanded: a, refreshKey: l, busy: u, onToggle: d, onSetStatus: f, onRotate: m, onPoll: b, onDelete: x }) {
659
+ let S = e.status === "ACTIVE", C = he(e.provider);
660
+ return /* @__PURE__ */ G(v, { children: /* @__PURE__ */ K(y, {
471
661
  className: "p-5",
472
- children: [/* @__PURE__ */ z("div", {
662
+ children: [/* @__PURE__ */ K("div", {
473
663
  className: "flex flex-wrap items-start justify-between gap-3",
474
- children: [/* @__PURE__ */ z("div", {
664
+ children: [/* @__PURE__ */ K("div", {
475
665
  className: "min-w-0 space-y-1",
476
666
  children: [
477
- /* @__PURE__ */ z("div", {
667
+ /* @__PURE__ */ K("div", {
478
668
  className: "flex flex-wrap items-center gap-2",
479
- children: [/* @__PURE__ */ R("p", {
669
+ children: [/* @__PURE__ */ G("p", {
480
670
  className: "text-base font-semibold",
481
671
  children: e.name
482
- }), /* @__PURE__ */ R(h, {
483
- variant: he(e.status),
484
- children: j(e.status)
672
+ }), /* @__PURE__ */ G(g, {
673
+ variant: B(e.status),
674
+ children: R(e.status)
485
675
  })]
486
676
  }),
487
- /* @__PURE__ */ z("p", {
677
+ /* @__PURE__ */ K("p", {
488
678
  className: "text-xs text-text-secondary",
489
679
  children: [
490
- ge(e.provider),
491
- " · ",
492
- P(e.status)
680
+ ve(e.provider),
681
+ " ·",
682
+ " ",
683
+ xe(e.status, e.provider)
493
684
  ]
494
685
  }),
495
- /* @__PURE__ */ z("p", {
686
+ C ? /* @__PURE__ */ G("p", {
687
+ className: "text-xs text-text-secondary",
688
+ children: V(e.pollStatus, h)
689
+ }) : null,
690
+ /* @__PURE__ */ K("p", {
496
691
  className: "text-xs text-text-secondary",
497
692
  children: [
498
693
  "Last accepted update:",
499
694
  " ",
500
- e.lastSyncAt ? m(e.lastSyncAt) : "none yet",
501
- e.lastErrorAt ? ` · Last error ${m(e.lastErrorAt)}` : ""
695
+ e.lastSyncAt ? h(e.lastSyncAt) : "none yet",
696
+ e.lastErrorAt ? ` · Last error ${h(e.lastErrorAt)}` : ""
502
697
  ]
503
698
  }),
504
- e.lastErrorMessage ? /* @__PURE__ */ R("p", {
699
+ e.lastErrorMessage ? /* @__PURE__ */ G("p", {
505
700
  className: "break-words text-xs text-status-error-text",
506
701
  children: e.lastErrorMessage
507
702
  }) : null
508
703
  ]
509
- }), /* @__PURE__ */ z("div", {
704
+ }), /* @__PURE__ */ K("div", {
510
705
  className: "flex flex-wrap items-center gap-2",
511
706
  children: [
512
- /* @__PURE__ */ z(g, {
707
+ /* @__PURE__ */ K(_, {
513
708
  size: "sm",
514
709
  variant: "outline",
515
- disabled: l,
516
- onClick: () => d(b ? "PAUSED" : "ACTIVE"),
517
- children: [R(b ? o : s, {
710
+ disabled: u,
711
+ onClick: () => f(S ? "PAUSED" : "ACTIVE"),
712
+ children: [G(S ? s : c, {
518
713
  size: 14,
519
714
  className: "mr-1"
520
- }), b ? "Pause" : "Resume"]
715
+ }), S ? "Pause" : "Resume"]
521
716
  }),
522
- /* @__PURE__ */ z(g, {
717
+ C ? /* @__PURE__ */ K(_, {
523
718
  size: "sm",
524
719
  variant: "outline",
525
- disabled: l,
526
- onClick: p,
527
- children: [/* @__PURE__ */ R(a, {
720
+ disabled: u || !S,
721
+ onClick: b,
722
+ children: [/* @__PURE__ */ G(i, {
528
723
  size: 14,
529
724
  className: "mr-1"
530
- }), e.provider === "SAMSARA" ? "Replace secret" : "Rotate secret"]
725
+ }), "Poll now"]
726
+ }) : null,
727
+ /* @__PURE__ */ K(_, {
728
+ size: "sm",
729
+ variant: "outline",
730
+ disabled: u,
731
+ onClick: m,
732
+ children: [/* @__PURE__ */ G(o, {
733
+ size: 14,
734
+ className: "mr-1"
735
+ }), e.provider === "SAMSARA" ? "Replace secret" : C ? "Update password" : "Rotate secret"]
531
736
  }),
532
- /* @__PURE__ */ R(g, {
737
+ /* @__PURE__ */ G(_, {
533
738
  size: "sm",
534
739
  variant: "ghost",
535
- disabled: l,
536
- onClick: y,
740
+ disabled: u,
741
+ onClick: x,
537
742
  "aria-label": `Delete ${e.name}`,
538
- children: /* @__PURE__ */ R(f, { size: 14 })
743
+ children: /* @__PURE__ */ G(p, { size: 14 })
539
744
  }),
540
- /* @__PURE__ */ R(g, {
745
+ /* @__PURE__ */ G(_, {
541
746
  size: "sm",
542
747
  variant: "ghost",
543
- onClick: u,
544
- "aria-expanded": i,
545
- "aria-label": i ? "Hide details" : "Show details",
546
- children: R(i ? r : n, { size: 16 })
748
+ onClick: d,
749
+ "aria-expanded": a,
750
+ "aria-label": a ? "Hide details" : "Show details",
751
+ children: G(a ? r : n, { size: 16 })
547
752
  })
548
753
  ]
549
754
  })]
550
- }), i ? /* @__PURE__ */ z("div", {
755
+ }), a ? /* @__PURE__ */ K("div", {
551
756
  className: "mt-4 grid gap-6 border-t border-border-subtle pt-4 lg:grid-cols-2",
552
- children: [e.provider === "SAMSARA" ? /* @__PURE__ */ R(X, { url: t }) : /* @__PURE__ */ R(Q, { url: t }), /* @__PURE__ */ R(Z, {
757
+ children: [C ? /* @__PURE__ */ G(Le, { integration: e }) : e.provider === "SAMSARA" ? /* @__PURE__ */ G(Ie, { url: t }) : /* @__PURE__ */ G(Be, { url: t }), /* @__PURE__ */ G(ze, {
553
758
  integrationId: e.id,
554
- refreshKey: c
759
+ refreshKey: l,
760
+ polled: C
555
761
  })]
556
762
  }) : null]
557
763
  }) });
558
764
  }
559
- function Ae() {
560
- let { tenantId: e, workspaceId: t } = p();
561
- return /* @__PURE__ */ R(je, {}, `${e ?? ""}:${t ?? ""}`);
765
+ function He() {
766
+ let { tenantId: e, workspaceId: t } = m();
767
+ return /* @__PURE__ */ G(Ue, {}, `${e ?? ""}:${t ?? ""}`);
562
768
  }
563
- function je() {
564
- let { apiGatewayUrl: t } = p(), n = ye(), { message: r, notify: i } = oe(), [a, o] = I(null), [s, f] = I(q), [y, b] = I(0), [E, ue] = I(0), [de, D] = I(null), [fe, O] = I(!1), [pe, k] = I(null), [me, M] = I([]), he = me[0] ?? null, ge = (e, t) => M((n) => [...n, {
769
+ function Ue() {
770
+ let { apiGatewayUrl: t } = m(), n = Ce(), { message: r, notify: i } = se(), [a, o] = U(null), [s, c] = U(Z), [p, b] = U(0), [x, S] = U(0), [re, O] = U(null), [ce, le] = U(!1), [A, j] = U(null), [M, N] = U([]), fe = M[0] ?? null, P = (e, t) => N((n) => [...n, {
565
771
  name: e,
566
772
  secret: t
567
- }]), N = Ce(/* @__PURE__ */ new Set()), [_e, P] = I(() => /* @__PURE__ */ new Set()), F = async (e, t) => {
568
- if (!N.current.has(e)) {
569
- N.current.add(e), P(new Set(N.current));
773
+ }]), F = De(/* @__PURE__ */ new Set()), [pe, me] = U(() => /* @__PURE__ */ new Set()), L = async (e, t) => {
774
+ if (!F.current.has(e)) {
775
+ F.current.add(e), me(new Set(F.current));
570
776
  try {
571
777
  await t();
572
778
  } finally {
573
- N.current.delete(e), P(new Set(N.current));
779
+ F.current.delete(e), me(new Set(F.current));
574
780
  }
575
781
  }
576
- }, { integrations: L, total: B, isLoading: V, error: H, refetch: U } = xe({
577
- status: s === q ? void 0 : s,
578
- limit: K,
579
- offset: y * K
580
- }), { all: W, active: G, refetch: Y } = be(), X = Math.max(1, Math.ceil(B / K));
581
- Se(() => {
582
- !V && y > 0 && y >= X && b(X - 1);
782
+ }, { integrations: z, total: B, isLoading: V, error: _e, refetch: ve } = Te({
783
+ status: s === Z ? void 0 : s,
784
+ limit: Me,
785
+ offset: p * Me
786
+ }), { all: ye, active: be, refetch: xe } = we(), H = Math.max(1, Math.ceil(B / Me));
787
+ Ee(() => {
788
+ !V && p > 0 && p >= H && b(H - 1);
583
789
  }, [
584
790
  V,
585
- y,
586
- X
791
+ p,
792
+ H
587
793
  ]);
588
- let Z = L.map((e) => e.lastSyncAt).filter((e) => !!e).sort(), Q = Z.length > 0 ? Z[Z.length - 1] : void 0, Ae = (e) => ve(t, e.workspaceId, e.id, window.location.origin), je = () => {
589
- ue((e) => e + 1), U(), Y();
590
- }, $ = (e) => {
591
- o(null), i(e), je();
592
- }, Me = async (e, t) => {
794
+ let W = z.map((e) => e.lastSyncAt).filter((e) => !!e).sort(), q = W.length > 0 ? W[W.length - 1] : void 0, J = (e) => Se(t, e.workspaceId, e.id, window.location.origin), Y = () => {
795
+ S((e) => e + 1), ve(), xe();
796
+ }, X = (e) => {
797
+ o(null), i(e), Y();
798
+ }, Ae = async (e, t) => {
593
799
  try {
594
- await n.update(e.id, { status: t }), $(t === "ACTIVE" ? `Resumed ${e.name}.` : `Paused ${e.name}.`);
800
+ await n.update(e.id, { status: t }), X(t === "ACTIVE" ? `Resumed ${e.name}.` : `Paused ${e.name}.`);
595
801
  } catch (e) {
596
- o(J(e, "Could not change the integration status."));
802
+ o(Q(e, "Could not change the integration status."));
597
803
  }
598
- }, Ne = async (e) => {
804
+ }, je = async (e) => {
599
805
  if (!window.confirm(`Rotate the signing secret for ${e.name}? Deliveries signed with the old secret are refused as soon as it changes.`)) return;
600
- let t = A();
806
+ let t = I();
601
807
  try {
602
- await n.update(e.id, { apiSecret: t }), ge(e.name, t), $(`Rotated the signing secret for ${e.name}.`);
808
+ await n.update(e.id, { apiSecret: t }), P(e.name, t), X(`Rotated the signing secret for ${e.name}.`);
603
809
  } catch (e) {
604
- o(J(e, "Could not rotate the signing secret."));
810
+ o(Q(e, "Could not rotate the signing secret."));
605
811
  }
606
- }, Pe = async (e, t) => {
607
- await F(e.id, async () => {
608
- await n.update(e.id, { apiSecret: t }), $(`Replaced the Samsara secret for ${e.name}.`);
812
+ }, $ = async (e, t) => {
813
+ await L(e.id, async () => {
814
+ await n.update(e.id, { apiSecret: t }), X(e.provider === "GEOTAB" ? `Updated the MyGeotab password for ${e.name}.` : `Replaced the Samsara secret for ${e.name}.`);
609
815
  });
610
- }, Fe = async (e) => {
816
+ }, Ie = async (e) => {
817
+ try {
818
+ let t = await n.pollNow(e.id);
819
+ if (t.status === "FAILED") {
820
+ o(ge(e.name, t)), Y();
821
+ return;
822
+ }
823
+ X(ge(e.name, t));
824
+ } catch (t) {
825
+ o(Q(t, `Could not poll ${e.name}.`));
826
+ }
827
+ }, Le = async (e) => {
611
828
  if (window.confirm(`Delete ${e.name}? Its webhook URL stops working; tracking events it already created stay on their shipments.`)) try {
612
- await n.remove(e.id), de === e.id && D(null), $(`Deleted ${e.name}.`);
829
+ await n.remove(e.id), re === e.id && O(null), X(`Deleted ${e.name}.`);
613
830
  } catch (e) {
614
- o(J(e, "Could not delete the integration."));
831
+ o(Q(e, "Could not delete the integration."));
615
832
  }
616
833
  };
617
- return /* @__PURE__ */ z(C, {
834
+ return /* @__PURE__ */ K(ie, {
618
835
  title: "Integrations",
619
836
  subtitle: "Carrier, ELD and GPS tracking feeds",
620
- icon: /* @__PURE__ */ R(c, { size: 24 }),
621
- headerActions: /* @__PURE__ */ R(we, {
837
+ icon: /* @__PURE__ */ G(l, { size: 24 }),
838
+ headerActions: /* @__PURE__ */ G(Oe, {
622
839
  primary: {
623
840
  label: "Connect feed",
624
- icon: /* @__PURE__ */ R(l, { size: 16 }),
625
- onSelect: () => O(!0)
841
+ icon: /* @__PURE__ */ G(u, { size: 16 }),
842
+ onSelect: () => le(!0)
626
843
  },
627
844
  actions: [{
628
845
  label: "Refresh",
629
- icon: /* @__PURE__ */ R(u, { size: 16 }),
630
- onSelect: je
846
+ icon: /* @__PURE__ */ G(d, { size: 16 }),
847
+ onSelect: Y
631
848
  }]
632
849
  }),
633
850
  children: [
634
- /* @__PURE__ */ R(Te, {
635
- icon: /* @__PURE__ */ R(c, { size: 18 }),
851
+ /* @__PURE__ */ G(ke, {
852
+ icon: /* @__PURE__ */ G(l, { size: 18 }),
636
853
  children: "Connect the systems that already know where your freight is. Each feed gets its own signed webhook; every update it sends becomes a tracking event on the matching shipment, so status and ETA stay current without manual entry."
637
854
  }),
638
- /* @__PURE__ */ R(ae, { message: r }),
639
- /* @__PURE__ */ R(T, { message: a }),
640
- /* @__PURE__ */ z(ie, {
855
+ /* @__PURE__ */ G(oe, { message: r }),
856
+ /* @__PURE__ */ G(D, { message: a }),
857
+ /* @__PURE__ */ K(ae, {
641
858
  columns: 3,
642
859
  children: [
643
- /* @__PURE__ */ R(w, {
860
+ /* @__PURE__ */ G(E, {
644
861
  label: "Feeds",
645
- value: W,
646
- icon: /* @__PURE__ */ R(c, { size: 20 }),
862
+ value: ye,
863
+ icon: /* @__PURE__ */ G(l, { size: 20 }),
647
864
  accent: "brand"
648
865
  }),
649
- /* @__PURE__ */ R(w, {
866
+ /* @__PURE__ */ G(E, {
650
867
  label: "Active",
651
- value: G,
652
- icon: /* @__PURE__ */ R(d, { size: 20 }),
868
+ value: be,
869
+ icon: /* @__PURE__ */ G(f, { size: 20 }),
653
870
  accent: "success"
654
871
  }),
655
- /* @__PURE__ */ R(w, {
872
+ /* @__PURE__ */ G(E, {
656
873
  label: "Last accepted update (shown)",
657
- value: Q ? m(Q) : "—",
658
- icon: /* @__PURE__ */ R(e, { size: 20 }),
874
+ value: q ? h(q) : "—",
875
+ icon: /* @__PURE__ */ G(e, { size: 20 }),
659
876
  accent: "blue"
660
877
  })
661
878
  ]
662
879
  }),
663
- /* @__PURE__ */ R("div", {
880
+ /* @__PURE__ */ G("div", {
664
881
  className: "flex flex-col gap-3 sm:flex-row sm:items-center",
665
- children: /* @__PURE__ */ z(ee, {
882
+ children: /* @__PURE__ */ K(C, {
666
883
  value: s,
667
884
  onValueChange: (e) => {
668
- f(e), b(0);
885
+ c(e), b(0);
669
886
  },
670
- children: [/* @__PURE__ */ R(ne, {
887
+ children: [/* @__PURE__ */ G(te, {
671
888
  "aria-label": "Status",
672
889
  className: "sm:w-56",
673
- children: /* @__PURE__ */ R(re, {})
674
- }), /* @__PURE__ */ z(te, { children: [/* @__PURE__ */ R(x, {
675
- value: q,
890
+ children: /* @__PURE__ */ G(ne, {})
891
+ }), /* @__PURE__ */ K(ee, { children: [/* @__PURE__ */ G(w, {
892
+ value: Z,
676
893
  children: "All statuses"
677
- }), se.map((e) => /* @__PURE__ */ R(x, {
894
+ }), ue.map((e) => /* @__PURE__ */ G(w, {
678
895
  value: e,
679
- children: j(e)
896
+ children: R(e)
680
897
  }, e))] })]
681
898
  })
682
899
  }),
683
- /* @__PURE__ */ R(T, { message: H?.message }),
684
- V && L.length === 0 ? /* @__PURE__ */ z("div", {
900
+ /* @__PURE__ */ G(D, { message: _e?.message }),
901
+ V && z.length === 0 ? /* @__PURE__ */ K("div", {
685
902
  className: "grid gap-4",
686
- children: [/* @__PURE__ */ R(S, { className: "h-28 w-full" }), /* @__PURE__ */ R(S, { className: "h-28 w-full" })]
687
- }) : L.length === 0 && !H ? /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
903
+ children: [/* @__PURE__ */ G(T, { className: "h-28 w-full" }), /* @__PURE__ */ G(T, { className: "h-28 w-full" })]
904
+ }) : z.length === 0 && !_e ? /* @__PURE__ */ G(v, { children: /* @__PURE__ */ K(y, {
688
905
  className: "flex flex-col items-center gap-3 p-10 text-center",
689
906
  children: [
690
- /* @__PURE__ */ R(c, {
907
+ /* @__PURE__ */ G(l, {
691
908
  size: 32,
692
909
  className: "text-text-tertiary"
693
910
  }),
694
- /* @__PURE__ */ R("p", {
911
+ /* @__PURE__ */ G("p", {
695
912
  className: "font-medium",
696
- children: s === q ? "No tracking feeds connected" : "No feeds with this status"
913
+ children: s === Z ? "No tracking feeds connected" : "No feeds with this status"
697
914
  }),
698
- /* @__PURE__ */ R("p", {
915
+ /* @__PURE__ */ G("p", {
699
916
  className: "max-w-md text-sm text-text-secondary",
700
- children: s === q ? "Connect a carrier portal, ELD or GPS tracker so shipment updates arrive on their own." : "Choose another status to see the rest of your feeds."
917
+ children: s === Z ? "Connect a carrier portal, ELD or GPS tracker so shipment updates arrive on their own." : "Choose another status to see the rest of your feeds."
701
918
  }),
702
- s === q ? /* @__PURE__ */ z(g, {
703
- onClick: () => O(!0),
704
- children: [/* @__PURE__ */ R(l, {
919
+ s === Z ? /* @__PURE__ */ K(_, {
920
+ onClick: () => le(!0),
921
+ children: [/* @__PURE__ */ G(u, {
705
922
  size: 16,
706
923
  className: "mr-1.5"
707
924
  }), "Connect feed"]
708
925
  }) : null
709
926
  ]
710
- }) }) : /* @__PURE__ */ R("div", {
927
+ }) }) : /* @__PURE__ */ G("div", {
711
928
  className: "grid gap-4",
712
- children: L.map((e) => /* @__PURE__ */ R(ke, {
929
+ children: z.map((e) => /* @__PURE__ */ G(Ve, {
713
930
  integration: e,
714
- url: Ae(e),
715
- expanded: de === e.id,
716
- refreshKey: E,
717
- busy: _e.has(e.id),
718
- onToggle: () => D((t) => t === e.id ? null : e.id),
719
- onSetStatus: (t) => void F(e.id, () => Me(e, t)),
720
- onRotate: () => e.provider === "SAMSARA" ? k(e) : void F(e.id, () => Ne(e)),
721
- onDelete: () => void F(e.id, () => Fe(e))
931
+ url: J(e),
932
+ expanded: re === e.id,
933
+ refreshKey: x,
934
+ busy: pe.has(e.id),
935
+ onToggle: () => O((t) => t === e.id ? null : e.id),
936
+ onSetStatus: (t) => void L(e.id, () => Ae(e, t)),
937
+ onRotate: () => e.provider === "SAMSARA" || he(e.provider) ? j(e) : void L(e.id, () => je(e)),
938
+ onPoll: () => void L(e.id, () => Ie(e)),
939
+ onDelete: () => void L(e.id, () => Le(e))
722
940
  }, e.id))
723
941
  }),
724
- B > K ? /* @__PURE__ */ z("div", {
942
+ B > Me ? /* @__PURE__ */ K("div", {
725
943
  className: "flex items-center justify-between text-sm",
726
- children: [/* @__PURE__ */ z("span", {
944
+ children: [/* @__PURE__ */ K("span", {
727
945
  className: "text-text-secondary",
728
946
  children: [
729
947
  "Page ",
730
- y + 1,
948
+ p + 1,
731
949
  " of ",
732
- X,
950
+ H,
733
951
  " · ",
734
952
  B,
735
953
  " feeds"
736
954
  ]
737
- }), /* @__PURE__ */ z("div", {
955
+ }), /* @__PURE__ */ K("div", {
738
956
  className: "flex gap-2",
739
- children: [/* @__PURE__ */ R(g, {
957
+ children: [/* @__PURE__ */ G(_, {
740
958
  variant: "outline",
741
959
  size: "sm",
742
- disabled: y === 0,
960
+ disabled: p === 0,
743
961
  onClick: () => b((e) => e - 1),
744
962
  children: "Previous"
745
- }), /* @__PURE__ */ R(g, {
963
+ }), /* @__PURE__ */ G(_, {
746
964
  variant: "outline",
747
965
  size: "sm",
748
- disabled: y + 1 >= X,
966
+ disabled: p + 1 >= H,
749
967
  onClick: () => b((e) => e + 1),
750
968
  children: "Next"
751
969
  })]
752
970
  })]
753
971
  }) : null,
754
- /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
972
+ /* @__PURE__ */ G(v, { children: /* @__PURE__ */ K(y, {
755
973
  className: "space-y-2 p-5",
756
974
  children: [
757
- /* @__PURE__ */ R("p", {
975
+ /* @__PURE__ */ G("p", {
758
976
  className: "text-sm font-medium",
759
977
  children: "Carrier and ELD networks"
760
978
  }),
761
- /* @__PURE__ */ z("p", {
979
+ /* @__PURE__ */ K("p", {
762
980
  className: "text-sm text-text-secondary",
763
981
  children: [
764
- "Samsara connects directly: choose it when you connect a feed. Direct connections to",
982
+ "Samsara and Geotab connect directly: choose them when you connect a feed. Direct connections to",
765
983
  " ",
766
- [...le.map((e) => e.label), ...ce].join(", "),
984
+ [...de.map((e) => e.label), ...k].join(", "),
767
985
  " ",
768
986
  "are not available yet. Until they are, any carrier or telematics system that can send HTTPS webhooks connects through a signed feed above."
769
987
  ]
770
988
  }),
771
- /* @__PURE__ */ z("div", {
989
+ /* @__PURE__ */ K("div", {
772
990
  className: "flex flex-wrap gap-2",
773
991
  children: [
774
- /* @__PURE__ */ R(h, {
992
+ /* @__PURE__ */ G(g, {
775
993
  variant: "default",
776
994
  children: "Samsara · available"
777
995
  }),
778
- ce.map((e) => /* @__PURE__ */ z(h, {
996
+ /* @__PURE__ */ G(g, {
997
+ variant: "default",
998
+ children: "Geotab · available"
999
+ }),
1000
+ k.map((e) => /* @__PURE__ */ K(g, {
779
1001
  variant: "outline",
780
1002
  children: [e, " · not available yet"]
781
1003
  }, e)),
782
- le.map((e) => /* @__PURE__ */ z(h, {
1004
+ de.map((e) => /* @__PURE__ */ K(g, {
783
1005
  variant: "outline",
784
1006
  children: [e.label, " · not available yet"]
785
1007
  }, e.id))
@@ -787,25 +1009,25 @@ function je() {
787
1009
  })
788
1010
  ]
789
1011
  }) }),
790
- /* @__PURE__ */ R(De, {
791
- open: fe,
792
- onOpenChange: O,
1012
+ /* @__PURE__ */ G(Pe, {
1013
+ open: ce,
1014
+ onOpenChange: le,
793
1015
  onCreated: (e, t) => {
794
- D(e.id), t && ge(e.name, t), $(`Connected ${e.name}.`);
1016
+ O(e.id), t && P(e.name, t), X(`Connected ${e.name}.`);
795
1017
  }
796
1018
  }),
797
- /* @__PURE__ */ R(Oe, {
798
- integration: pe,
799
- onClose: () => k(null),
800
- onReplace: Pe
1019
+ /* @__PURE__ */ G(Fe, {
1020
+ integration: A,
1021
+ onClose: () => j(null),
1022
+ onReplace: $
801
1023
  }),
802
- /* @__PURE__ */ R(Ee, {
803
- secret: he?.secret ?? null,
804
- integrationName: he?.name ?? "",
805
- onClose: () => M((e) => e.slice(1))
1024
+ /* @__PURE__ */ G(Ne, {
1025
+ secret: fe?.secret ?? null,
1026
+ integrationName: fe?.name ?? "",
1027
+ onClose: () => N((e) => e.slice(1))
806
1028
  })
807
1029
  ]
808
1030
  });
809
1031
  }
810
1032
  //#endregion
811
- export { Ae as default };
1033
+ export { He as default };