@nivaro/react 0.3.51 → 0.3.53

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/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +3885 -3847
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +600 -549
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  14. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  15. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  16. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  17. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  18. package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
  19. package/dist/shared/components/item-edit/line-qty.js +115 -53
  20. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  21. package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
  22. package/dist/shared/components/panels/CommentPanel.js +204 -197
  23. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  24. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  26. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  27. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  28. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  29. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  30. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  31. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  32. package/dist/shared/lib/activity-sentence.js +236 -227
  33. package/dist/shared/lib/record-ref.js +43 -34
  34. package/package.json +1 -1
@@ -1,291 +1,317 @@
1
- import { jsxs as y, jsx as k } from "react/jsx-runtime";
2
- import { QueryClientContext as Oe } from "@tanstack/react-query";
3
- import { Lock as ne, LockOpen as de } from "lucide-react";
4
- import { useState as E, useEffect as $, useRef as q, useCallback as L, useContext as Me } from "react";
1
+ import { jsxs as x, jsx as v } from "react/jsx-runtime";
2
+ import { QueryClientContext as Pe } from "@tanstack/react-query";
3
+ import { Lock as ue, LockOpen as ve } from "lucide-react";
4
+ import { useState as S, useEffect as w, useRef as T, useCallback as E, useContext as je } from "react";
5
5
  import { toast as d } from "sonner";
6
- import { useNivaroClient as De, useItemEditAuth as Ye } from "../../context.js";
7
- import { post as A, get as Fe, del as B } from "../../lib/commands.js";
8
- import { idleState as ze } from "../../lib/idle.js";
9
- import { useOptionalRealtime as fe, updateTouches as Pe } from "../../lib/realtime.js";
10
- import { announceRecordTabs as J, useRecordTabsSignal as je } from "../../lib/record-tabs.js";
6
+ import { useNivaroClient as Be, useItemEditAuth as Qe } from "../../context.js";
7
+ import { post as I, get as Ue, del as W } from "../../lib/commands.js";
8
+ import { idleState as Ve } from "../../lib/idle.js";
9
+ import { useOptionalRealtime as ye, updateTouches as We } from "../../lib/realtime.js";
10
+ import { announceRecordTabs as Z, useRecordTabsSignal as He } from "../../lib/record-tabs.js";
11
+ import { noteTakeOverHold as ie } from "../item-edit/FieldAffordances.js";
11
12
  import { Button as O } from "../ui/button.js";
12
- import { Popover as me, PopoverTrigger as he, PopoverContent as ke } from "../ui/popover.js";
13
- const G = 1e4, be = 1500, Be = 2e3, Ke = 5 * 6e4, Qe = 3e4, Ue = 6e4, Ve = 15e3, We = 1500;
14
- function ve(e, t) {
13
+ import { Popover as ge, PopoverTrigger as we, PopoverContent as xe } from "../ui/popover.js";
14
+ const ee = 1e4, _e = 1500, Je = 2e3, Ge = 5 * 6e4, Xe = 3e4, Ze = 6e4, et = 15e3, pe = 1500, tt = 6e4;
15
+ function Le(e, t) {
15
16
  return e ? `${t ?? "Someone else"} took over editing — your changes are still here, but can’t be saved until they release it` : "Someone else started editing while you were away — your changes are still here, but can’t be saved until they release it";
16
17
  }
17
- function Je() {
18
- const [e, t] = E(!0);
19
- return $(() => {
18
+ function rt() {
19
+ const [e, t] = S(!0);
20
+ return w(() => {
20
21
  if (typeof window > "u" || typeof document > "u") return;
21
- let s = null, C = null, f = 0;
22
- const T = () => typeof document.hasFocus == "function" ? document.hasFocus() : !0, g = () => {
23
- C && clearInterval(C), C = null;
24
- }, _ = (b) => b instanceof HTMLInputElement && b.type === "file", x = (b) => {
25
- _(b.target) && (f = Date.now() + Ke);
26
- }, o = (b) => {
27
- !_(b.target) || !f || (f = 0, T() || R());
28
- }, R = () => {
22
+ let s = null, N = null, k = 0;
23
+ const q = () => typeof document.hasFocus == "function" ? document.hasFocus() : !0, g = () => {
24
+ N && clearInterval(N), N = null;
25
+ }, $ = (y) => y instanceof HTMLInputElement && y.type === "file", _ = (y) => {
26
+ $(y.target) && (k = Date.now() + Ge);
27
+ }, o = (y) => {
28
+ !$(y.target) || !k || (k = 0, q() || C());
29
+ }, C = () => {
29
30
  s && clearTimeout(s);
30
- const b = f - Date.now();
31
+ const y = k - Date.now();
31
32
  s = setTimeout(
32
33
  () => {
33
- if (s = null, !T()) {
34
+ if (s = null, !q()) {
34
35
  g(), t(!1);
35
36
  return;
36
37
  }
37
- g(), C = setInterval(() => {
38
- T() || (g(), t(!1));
39
- }, Be);
38
+ g(), N = setInterval(() => {
39
+ q() || (g(), t(!1));
40
+ }, Je);
40
41
  },
41
- b > 0 ? Math.max(b, be) : be
42
+ y > 0 ? Math.max(y, _e) : _e
42
43
  );
43
44
  }, c = () => {
44
- s && clearTimeout(s), s = null, f = 0, g(), t(!0);
45
+ s && clearTimeout(s), s = null, k = 0, g(), t(!0);
45
46
  };
46
- return window.addEventListener("blur", R), window.addEventListener("focus", c), document.addEventListener("click", x, !0), document.addEventListener("change", o, !0), document.addEventListener("cancel", o, !0), () => {
47
- window.removeEventListener("blur", R), window.removeEventListener("focus", c), document.removeEventListener("click", x, !0), document.removeEventListener("change", o, !0), document.removeEventListener("cancel", o, !0), s && clearTimeout(s), g();
47
+ return window.addEventListener("blur", C), window.addEventListener("focus", c), document.addEventListener("click", _, !0), document.addEventListener("change", o, !0), document.addEventListener("cancel", o, !0), () => {
48
+ window.removeEventListener("blur", C), window.removeEventListener("focus", c), document.removeEventListener("click", _, !0), document.removeEventListener("change", o, !0), document.removeEventListener("cancel", o, !0), s && clearTimeout(s), g();
48
49
  };
49
50
  }, []), e;
50
51
  }
51
- function Ge() {
52
- const [e, t] = E(
52
+ function nt() {
53
+ const [e, t] = S(
53
54
  () => typeof document > "u" || document.visibilityState !== "hidden"
54
55
  );
55
- return $(() => {
56
+ return w(() => {
56
57
  const s = () => t(document.visibilityState !== "hidden");
57
58
  return document.addEventListener("visibilitychange", s), () => document.removeEventListener("visibilitychange", s);
58
59
  }, []), e;
59
60
  }
60
- function lt(e, t, s, C = {}) {
61
- const { lazy: f = !1, active: T = !0, dirty: g } = C, _ = q(g);
62
- _.current = g;
63
- const x = L(() => f && _.current === !1, [f]), o = De(), { isAdmin: R, userId: c } = Ye(), b = Me(Oe), [M, S] = E(null), [K, p] = E(!1), [z, ae] = E(!1), [ye, ge] = E([]), [xe, P] = E(null), [we, se] = E(!1), [_e, oe] = E(""), [pe, X] = E(!1), [Le, ie] = E(!1), Q = q(null), i = q(!1), I = q(!1), Z = q(!1), H = q(0), D = q(!1), j = q(null), U = q(null), m = L(() => {
64
- Q.current && (clearInterval(Q.current), Q.current = null);
65
- }, []), ee = L(
61
+ function vt(e, t, s, N = {}) {
62
+ const { lazy: k = !1, active: q = !0, dirty: g } = N, $ = T(g);
63
+ $.current = g;
64
+ const _ = E(() => k && $.current === !1, [k]), o = Be(), { isAdmin: C, userId: c } = Qe(), y = je(Pe), [D, R] = S(null), [Y, L] = S(!1), [j, le] = S(!1), [Ee, $e] = S([]), [Se, B] = S(null), [Ne, ce] = S(!1), [Re, de] = S(""), [Ce, te] = S(!1), [Te, fe] = S(!1), H = T(null), i = T(!1), A = T(!1), re = T(!1), ne = T(0), M = T(!1), Q = T(null), U = T(null), V = T(null), J = T(!1), F = `${e ?? ""}:${t ?? ""}`, z = E(() => {
65
+ V.current = null, J.current = !1, ie(F, !1);
66
+ }, [F]), f = E(() => {
67
+ H.current && (clearInterval(H.current), H.current = null);
68
+ }, []), ae = E(
66
69
  (a) => {
67
- var r, l;
68
- const n = a, v = n.status ?? ((r = n.response) == null ? void 0 : r.status), u = ((l = n.response) == null ? void 0 : l.data) ?? n.response;
69
- return v !== 403 || (u == null ? void 0 : u.code) !== "EDIT_LOCKED" ? !1 : (m(), i.current = !1, p(!1), d.warning(u.error || "You can no longer edit this record — your edit lock was let go"), b == null || b.invalidateQueries({ queryKey: ["pipeline-instance-lock", e, t] }), b == null || b.invalidateQueries({ queryKey: ["pipeline-instance", e, t] }), !0);
70
+ var r, u;
71
+ const n = a, m = n.status ?? ((r = n.response) == null ? void 0 : r.status), l = ((u = n.response) == null ? void 0 : u.data) ?? n.response;
72
+ return m !== 403 || (l == null ? void 0 : l.code) !== "EDIT_LOCKED" ? !1 : (f(), i.current = !1, L(!1), d.warning(l.error || "You can no longer edit this record — your edit lock was let go"), y == null || y.invalidateQueries({ queryKey: ["pipeline-instance-lock", e, t] }), y == null || y.invalidateQueries({ queryKey: ["pipeline-instance", e, t] }), !0);
70
73
  },
71
- [b, e, t, m]
72
- ), h = L(async () => {
74
+ [y, e, t, f]
75
+ ), h = E(async () => {
73
76
  var a, n;
74
- if (!e || !t || D.current) return !1;
75
- j.current = null, U.current = null;
77
+ if (!e || !t || M.current) return !1;
78
+ Q.current = null, U.current = null;
76
79
  try {
77
80
  return await o.request(
78
- A(`/item-locks/${e}/${t}/lock`, { beat_ms: G })
79
- ), i.current = !0, p(!0), X(!1), S(null), m(), Q.current = setInterval(() => {
80
- const v = Math.max(
81
+ I(`/item-locks/${e}/${t}/lock`, { beat_ms: ee })
82
+ ), i.current = !0, L(!0), te(!1), R(null), f(), H.current = setInterval(() => {
83
+ const m = Math.max(
81
84
  0,
82
- Math.floor((Date.now() - new Date(ze().last_active).getTime()) / 1e3)
85
+ Math.floor((Date.now() - new Date(Ve().last_active).getTime()) / 1e3)
83
86
  );
84
87
  o.request(
85
- A(`/item-locks/${e}/${t}/heartbeat`, {
86
- idle_seconds: v,
87
- beat_ms: G
88
+ I(`/item-locks/${e}/${t}/heartbeat`, {
89
+ idle_seconds: m,
90
+ beat_ms: ee
88
91
  })
89
- ).then((u) => {
90
- if (!(u != null && u.idle_released)) return;
91
- m(), i.current = !1, p(!1), d.info(
92
+ ).then((l) => {
93
+ if (!(l != null && l.idle_released)) return;
94
+ f(), i.current = !1, L(!1), d.info(
92
95
  "Your edit lock was released after inactivity — it re-locks when you resume."
93
96
  );
94
97
  const r = () => {
95
- window.removeEventListener("pointerdown", r, !0), window.removeEventListener("keydown", r, !0), !x() && h();
98
+ window.removeEventListener("pointerdown", r, !0), window.removeEventListener("keydown", r, !0), !_() && h();
96
99
  };
97
100
  window.addEventListener("pointerdown", r, !0), window.addEventListener("keydown", r, !0);
98
- }).catch((u) => {
99
- var le, ce;
100
- const r = u, l = r.status ?? ((le = r.response) == null ? void 0 : le.status);
101
- if (ee(u) || l !== 404 && l !== 409) return;
102
- const N = ((ce = r.response) == null ? void 0 : ce.data) ?? r.response;
103
- if (l === 404 && !(N != null && N.locked_by)) {
104
- if (x()) {
105
- m(), i.current = !1, p(!1);
101
+ }).catch((l) => {
102
+ var ke, he;
103
+ const r = l, u = r.status ?? ((ke = r.response) == null ? void 0 : ke.status);
104
+ if (ae(l) || u !== 404 && u !== 409) return;
105
+ const b = ((he = r.response) == null ? void 0 : he.data) ?? r.response;
106
+ if (u === 404 && !(b != null && b.locked_by) && (b == null ? void 0 : b.taken_over) === !0) {
107
+ f(), i.current = !1, L(!1);
108
+ const be = b.taken_over_by_name ?? null;
109
+ U.current = be ?? "Someone else", d.warning(
110
+ `${be ?? "Someone else"} took over editing — your changes are still here; they save once you edit again`
111
+ );
112
+ return;
113
+ }
114
+ if (u === 404 && !(b != null && b.locked_by)) {
115
+ if (_()) {
116
+ f(), i.current = !1, L(!1);
106
117
  return;
107
118
  }
108
119
  h();
109
120
  return;
110
121
  }
111
- m(), i.current = !1, p(!1), N != null && N.locked_by && (S({
112
- locked_by: N.locked_by,
113
- locked_by_name: N.locked_by_name ?? null
122
+ f(), i.current = !1, L(!1), b != null && b.locked_by && (R({
123
+ locked_by: b.locked_by,
124
+ locked_by_name: b.locked_by_name ?? null
114
125
  }), d.warning(
115
- N.taken_over === !1 ? ve(!1) : `${N.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
126
+ b.taken_over === !1 ? Le(!1) : `${b.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
116
127
  ));
117
128
  });
118
- }, G), !0;
119
- } catch (v) {
120
- const u = v, r = u.status ?? ((a = u.response) == null ? void 0 : a.status), l = ((n = u.response) == null ? void 0 : n.data) ?? u.response;
121
- return j.current = r ?? null, U.current = (l == null ? void 0 : l.taken_over) === !0 ? l.locked_by_name ?? "Someone else" : null, ee(v) ? !1 : r === 404 ? (D.current = !0, m(), i.current = !1, p(!1), !1) : (r === 409 && (l != null && l.locked_by) && (i.current = !1, p(!1), S({
122
- locked_by: l.locked_by,
123
- locked_by_name: l.locked_by_name ?? null,
124
- ...typeof l.may_take_over == "boolean" ? { may_take_over: l.may_take_over } : {}
129
+ }, ee), !0;
130
+ } catch (m) {
131
+ const l = m, r = l.status ?? ((a = l.response) == null ? void 0 : a.status), u = ((n = l.response) == null ? void 0 : n.data) ?? l.response;
132
+ return Q.current = r ?? null, U.current = (u == null ? void 0 : u.taken_over) === !0 ? u.locked_by_name ?? "Someone else" : null, ae(m) ? !1 : r === 404 ? (M.current = !0, f(), i.current = !1, L(!1), !1) : (r === 409 && (u != null && u.locked_by) && (i.current = !1, L(!1), R({
133
+ locked_by: u.locked_by,
134
+ locked_by_name: u.locked_by_name ?? null,
135
+ ...typeof u.may_take_over == "boolean" ? { may_take_over: u.may_take_over } : {}
125
136
  })), !1);
126
137
  }
127
- }, [o, e, t, m, ee, x]), w = L(async () => {
138
+ }, [o, e, t, f, ae, _]), p = E(async () => {
128
139
  if (!(!e || !t))
129
140
  try {
130
- const a = await o.request(Fe(`/item-locks/${e}/${t}/lock`)), n = a == null ? void 0 : a.data;
131
- ge(Array.isArray(n == null ? void 0 : n.queue) ? n.queue : []), P(typeof (n == null ? void 0 : n.my_position) == "number" ? n.my_position : null);
132
- const v = (n == null ? void 0 : n.is_mine) === !0 || !!c && String((n == null ? void 0 : n.locked_by) ?? "").toLowerCase() === c.toLowerCase(), u = typeof (n == null ? void 0 : n.may_take_over) == "boolean" ? { may_take_over: n.may_take_over } : {};
141
+ const a = await o.request(Ue(`/item-locks/${e}/${t}/lock`)), n = a == null ? void 0 : a.data;
142
+ $e(Array.isArray(n == null ? void 0 : n.queue) ? n.queue : []), B(typeof (n == null ? void 0 : n.my_position) == "number" ? n.my_position : null);
143
+ const m = (n == null ? void 0 : n.is_mine) === !0 || !!c && String((n == null ? void 0 : n.locked_by) ?? "").toLowerCase() === c.toLowerCase(), l = typeof (n == null ? void 0 : n.may_take_over) == "boolean" ? { may_take_over: n.may_take_over } : {};
133
144
  if (i.current) return;
134
- if (!(n != null && n.locked_by) || v) {
135
- S(null);
145
+ if (!(n != null && n.locked_by) || m) {
146
+ R(null);
136
147
  return;
137
148
  }
138
- S(
149
+ R(
139
150
  (r) => r && r.locked_by === String(n.locked_by) ? {
140
151
  ...r,
141
152
  note: n.note ?? r.note ?? null,
142
153
  idle_minutes: n.locked_by_idle_minutes ?? r.idle_minutes ?? null,
143
- ...u
154
+ ...l
144
155
  } : {
145
156
  locked_by: String(n.locked_by),
146
157
  locked_by_name: n.locked_by_name ?? null,
147
158
  note: n.note ?? null,
148
159
  idle_minutes: n.locked_by_idle_minutes ?? null,
149
- ...u
160
+ ...l
150
161
  }
151
- ), X(!1);
162
+ ), te(!1);
152
163
  } catch (a) {
153
- (a == null ? void 0 : a.status) === 404 && (D.current = !0);
164
+ (a == null ? void 0 : a.status) === 404 && (M.current = !0);
154
165
  }
155
- }, [o, e, t, c]), Y = (M == null ? void 0 : M.locked_by) ?? null;
156
- $(() => {
157
- Y && w();
158
- }, [Y, w]), $(() => {
159
- if (!Y) return;
160
- const a = setInterval(() => void w(), Qe);
166
+ }, [o, e, t, c]), K = (D == null ? void 0 : D.locked_by) ?? null;
167
+ w(() => {
168
+ K && p();
169
+ }, [K, p]), w(() => {
170
+ if (!K) return;
171
+ const a = setInterval(() => void p(), Xe);
161
172
  return () => clearInterval(a);
162
- }, [Y, w]), $(() => {
173
+ }, [K, p]), w(() => {
163
174
  if (!(!s || !e || !t))
164
- return I.current = !1, D.current = !1, f ? w() : h(), () => {
165
- m(), I.current = !1, i.current && (i.current = !1, o.request(B(`/item-locks/${e}/${t}/lock`)).then(() => J(c, "lock-released", e, t)).catch(() => {
175
+ return A.current = !1, M.current = !1, k ? p() : h(), () => {
176
+ f(), A.current = !1, i.current && (i.current = !1, o.request(W(`/item-locks/${e}/${t}/lock`)).then(() => Z(c, "lock-released", e, t)).catch(() => {
166
177
  }));
167
178
  };
168
- }, [s, e, t, h, o, m, c, f, w]);
169
- const Ee = L(async () => {
170
- if (!(!s || i.current || Z.current) && !(Date.now() < H.current)) {
171
- Z.current = !0;
179
+ }, [s, e, t, h, o, f, c, k, p]);
180
+ const qe = E(async () => {
181
+ if (!(!s || i.current || re.current) && !(Date.now() < ne.current)) {
182
+ re.current = !0;
172
183
  try {
173
184
  const a = await h();
174
- !a && j.current === 409 && d.warning("Someone else is editing this record — your change can’t be saved yet"), !a && j.current !== 409 && !D.current && (H.current = Date.now() + Ve);
185
+ !a && Q.current === 409 && d.warning("Someone else is editing this record — your change can’t be saved yet"), !a && Q.current !== 409 && !M.current && (ne.current = Date.now() + et);
175
186
  } finally {
176
- Z.current = !1;
187
+ re.current = !1;
177
188
  }
178
189
  }
179
190
  }, [s, h]);
180
- $(() => {
191
+ w(() => {
181
192
  const a = () => {
182
- H.current = 0;
193
+ ne.current = 0;
183
194
  };
184
195
  return window.addEventListener("online", a), () => window.removeEventListener("online", a);
185
196
  }, []);
186
- const V = L(() => {
197
+ const G = E(() => {
187
198
  var a;
188
199
  if (!(!e || !t))
189
200
  try {
190
- const n = (a = o.getToken) == null ? void 0 : a.call(o), v = o.url ?? "";
201
+ const n = (a = o.getToken) == null ? void 0 : a.call(o), m = o.url ?? "";
191
202
  fetch(
192
- `${v}/api/item-locks/${encodeURIComponent(e)}/${encodeURIComponent(t)}/lock/release`,
203
+ `${m}/api/item-locks/${encodeURIComponent(e)}/${encodeURIComponent(t)}/lock/release`,
193
204
  {
194
205
  method: "POST",
195
206
  keepalive: !0,
196
207
  credentials: n ? "omit" : "include",
197
208
  headers: n ? { Authorization: `Bearer ${n}` } : {}
198
209
  }
199
- ).then(() => J(c, "lock-released", e, t)).catch(() => {
210
+ ).then(() => Z(c, "lock-released", e, t)).catch(() => {
200
211
  });
201
212
  } catch {
202
213
  }
203
- }, [o, e, t, c]), te = Ge(), $e = Je(), W = T && te && $e;
204
- $(() => {
214
+ }, [o, e, t, c]), se = nt(), Ae = rt(), X = q && se && Ae;
215
+ w(() => {
205
216
  if (!(!s || !e || !t)) {
206
- if (W) {
207
- if (I.current) {
208
- if (I.current = !1, x()) return;
217
+ if (X) {
218
+ if (A.current) {
219
+ if (A.current = !1, _()) return;
209
220
  h().then((a) => {
210
- !a && j.current === 409 && d.warning(ve(U.current != null, U.current));
221
+ !a && Q.current === 409 && d.warning(Le(U.current != null, U.current));
211
222
  });
212
223
  }
213
224
  return;
214
225
  }
215
- i.current && (m(), i.current = !1, p(!1), I.current = !0, te ? o.request(B(`/item-locks/${e}/${t}/lock`)).then(() => J(c, "lock-released", e, t)).catch(() => {
216
- }) : V());
226
+ i.current && (f(), i.current = !1, L(!1), A.current = !0, se ? o.request(W(`/item-locks/${e}/${t}/lock`)).then(() => Z(c, "lock-released", e, t)).catch(() => {
227
+ }) : G());
217
228
  }
218
229
  }, [
219
230
  s,
220
- W,
221
- te,
231
+ X,
232
+ se,
222
233
  e,
223
234
  t,
224
235
  h,
225
236
  o,
226
- m,
237
+ f,
227
238
  c,
228
- V,
229
- x
230
- ]), $(() => {
231
- if (!s || !f || !e || !t || Y || !W) return;
239
+ G,
240
+ _
241
+ ]), w(() => {
242
+ if (!s || !k || !e || !t || K || !X) return;
232
243
  const a = setInterval(() => {
233
- !i.current && !D.current && w();
234
- }, Ue);
244
+ !i.current && !M.current && p();
245
+ }, Ze);
235
246
  return () => clearInterval(a);
236
- }, [s, f, e, t, Y, W, w]), $(() => {
247
+ }, [s, k, e, t, K, X, p]), w(() => {
237
248
  if (!s || !e || !t) return;
238
249
  const a = () => {
239
- i.current && (m(), i.current = !1, I.current = !0, V());
240
- }, n = (v) => {
241
- v.persisted && I.current && (I.current = !1, x() || h());
250
+ i.current && (f(), i.current = !1, A.current = !0, G());
251
+ }, n = (m) => {
252
+ m.persisted && A.current && (A.current = !1, _() || h());
242
253
  };
243
254
  return window.addEventListener("pagehide", a), window.addEventListener("pageshow", n), () => {
244
255
  window.removeEventListener("pagehide", a), window.removeEventListener("pageshow", n);
245
256
  };
246
- }, [s, e, t, m, h, V, x]), $(() => {
247
- if (!s || !f || !e || !t || g !== !1 || !i.current) return;
248
- const a = setTimeout(() => {
249
- _.current !== !1 || !i.current || (m(), i.current = !1, p(!1), o.request(B(`/item-locks/${e}/${t}/lock`)).then(() => J(c, "lock-released", e, t)).catch(() => {
257
+ }, [s, e, t, f, h, G, _]), w(() => {
258
+ if (!s || !k || !e || !t || g !== !1 || !i.current) return;
259
+ const a = V.current, n = a != null && !J.current ? Math.max(pe, a + tt - Date.now()) : pe, m = setTimeout(() => {
260
+ $.current !== !1 || !i.current || (f(), i.current = !1, L(!1), z(), o.request(W(`/item-locks/${e}/${t}/lock`)).then(() => Z(c, "lock-released", e, t)).catch(() => {
250
261
  }));
251
- }, We);
252
- return () => clearTimeout(a);
253
- }, [s, f, e, t, g, K, o, m, c]), je(c, "lock-released", e, t, () => {
262
+ }, n);
263
+ return () => clearTimeout(m);
264
+ }, [
265
+ s,
266
+ k,
267
+ e,
268
+ t,
269
+ g,
270
+ Y,
271
+ o,
272
+ f,
273
+ c,
274
+ z
275
+ ]), w(() => {
276
+ g === !0 && V.current != null && (J.current = !0);
277
+ }, [g]), w(() => {
278
+ !Y && V.current != null && z();
279
+ }, [Y, z]), w(() => () => ie(F, !1), [F]), He(c, "lock-released", e, t, () => {
254
280
  s && i.current && h();
255
281
  });
256
- const re = fe();
257
- $(() => {
258
- if (!(!s || !re || !e || !t))
259
- return re.subscribeCollections([e], (a) => {
282
+ const oe = ye();
283
+ w(() => {
284
+ if (!(!s || !oe || !e || !t))
285
+ return oe.subscribeCollections([e], (a) => {
260
286
  var n;
261
- i.current || D.current || !((n = a.changed_fields) != null && n.includes("$lock")) || !Pe(a, t) || w();
287
+ i.current || M.current || !((n = a.changed_fields) != null && n.includes("$lock")) || !We(a, t) || p();
262
288
  });
263
- }, [s, re, e, t, w]);
264
- const F = fe(), [Ne, ue] = E(!1), Ce = L(async () => {
289
+ }, [s, oe, e, t, p]);
290
+ const P = ye(), [Ie, me] = S(!1), Oe = E(async () => {
265
291
  if (!(!e || !t)) {
266
- ue(!0);
292
+ me(!0);
267
293
  try {
268
- await o.request(A(`/item-locks/${e}/${t}/lock/request`, {})), d.success("Asked the current editor to release the lock");
294
+ await o.request(I(`/item-locks/${e}/${t}/lock/request`, {})), d.success("Asked the current editor to release the lock");
269
295
  } catch {
270
296
  d.error("Could not send the lock request");
271
297
  } finally {
272
- ue(!1);
298
+ me(!1);
273
299
  }
274
300
  }
275
301
  }, [o, e, t]);
276
- $(() => {
277
- if (!F || !e || !t) return;
278
- const a = F.on("lock:requested", (r) => {
302
+ w(() => {
303
+ if (!P || !e || !t) return;
304
+ const a = P.on("lock:requested", (r) => {
279
305
  if ((r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || !i.current) return;
280
- const l = (r == null ? void 0 : r.from) ?? {};
281
- d(`${l.name ?? "Someone"} is asking you to release this record`, {
306
+ const u = (r == null ? void 0 : r.from) ?? {};
307
+ d(`${u.name ?? "Someone"} is asking you to release this record`, {
282
308
  duration: 3e4,
283
309
  action: {
284
310
  label: "Release",
285
311
  onClick: () => {
286
- m(), i.current = !1, p(!1), o.request(
287
- A(`/item-locks/${e}/${t}/lock/respond`, {
288
- to: l.id,
312
+ f(), i.current = !1, L(!1), o.request(
313
+ I(`/item-locks/${e}/${t}/lock/respond`, {
314
+ to: u.id,
289
315
  action: "release"
290
316
  })
291
317
  ).then(() => d.success("Lock released")).catch(() => d.error("Failed to release the lock"));
@@ -295,8 +321,8 @@ function lt(e, t, s, C = {}) {
295
321
  label: "Keep editing",
296
322
  onClick: () => {
297
323
  o.request(
298
- A(`/item-locks/${e}/${t}/lock/respond`, {
299
- to: l.id,
324
+ I(`/item-locks/${e}/${t}/lock/respond`, {
325
+ to: u.id,
300
326
  action: "decline"
301
327
  })
302
328
  ).catch(() => {
@@ -304,127 +330,127 @@ function lt(e, t, s, C = {}) {
304
330
  }
305
331
  }
306
332
  });
307
- }), n = F.on("lock:response", (r) => {
308
- var l, N;
309
- (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || i.current || ((r == null ? void 0 : r.action) === "release" ? (d.success(`${((l = r == null ? void 0 : r.from) == null ? void 0 : l.name) ?? "The editor"} released the lock — it's yours`), h()) : d.warning(
310
- `${((N = r == null ? void 0 : r.from) == null ? void 0 : N.name) ?? "The editor"} is keeping the lock${r != null && r.note ? `: "${r.note}"` : ""}`
333
+ }), n = P.on("lock:response", (r) => {
334
+ var u, b;
335
+ (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || i.current || ((r == null ? void 0 : r.action) === "release" ? (d.success(`${((u = r == null ? void 0 : r.from) == null ? void 0 : u.name) ?? "The editor"} released the lock — it's yours`), h()) : d.warning(
336
+ `${((b = r == null ? void 0 : r.from) == null ? void 0 : b.name) ?? "The editor"} is keeping the lock${r != null && r.note ? `: "${r.note}"` : ""}`
311
337
  ));
312
- }), v = F.on("lock:available", (r) => {
313
- (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || i.current || (d.success("Your turn — the edit lock is yours"), P(null), h());
314
- }), u = F.on("lock:queued", (r) => {
315
- (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || (i.current && d(`${(r == null ? void 0 : r.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }), w());
338
+ }), m = P.on("lock:available", (r) => {
339
+ (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || i.current || (d.success("Your turn — the edit lock is yours"), B(null), h());
340
+ }), l = P.on("lock:queued", (r) => {
341
+ (r == null ? void 0 : r.collection) !== e || String(r == null ? void 0 : r.item) !== String(t) || (i.current && d(`${(r == null ? void 0 : r.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }), p());
316
342
  });
317
343
  return () => {
318
- a(), n(), v(), u();
344
+ a(), n(), m(), l();
319
345
  };
320
- }, [F, e, t, o, h, m, w]);
321
- const Se = L(async () => {
346
+ }, [P, e, t, o, h, f, p]);
347
+ const De = E(async () => {
322
348
  if (!(!e || !t)) {
323
- se(!0);
349
+ ce(!0);
324
350
  try {
325
351
  const a = await o.request(
326
- A(`/item-locks/${e}/${t}/lock/queue`, {})
352
+ I(`/item-locks/${e}/${t}/lock/queue`, {})
327
353
  ), n = a == null ? void 0 : a.data;
328
354
  if (n != null && n.free) {
329
- P(null), S(null), d.success("Nobody is editing this record now — go ahead");
355
+ B(null), R(null), d.success("Nobody is editing this record now — go ahead");
330
356
  return;
331
357
  }
332
- const v = n == null ? void 0 : n.position;
333
- P(typeof v == "number" ? v : 1), d.success("You are in line — the lock comes to you automatically when it frees up"), w();
358
+ const m = n == null ? void 0 : n.position;
359
+ B(typeof m == "number" ? m : 1), d.success("You are in line — the lock comes to you automatically when it frees up"), p();
334
360
  } catch {
335
361
  d.error("Could not join the queue");
336
362
  } finally {
337
- se(!1);
363
+ ce(!1);
338
364
  }
339
365
  }
340
- }, [o, e, t, w]), Re = L(async () => {
366
+ }, [o, e, t, p]), Me = E(async () => {
341
367
  if (!(!e || !t))
342
368
  try {
343
- await o.request(B(`/item-locks/${e}/${t}/lock/queue`)), P(null), w();
369
+ await o.request(W(`/item-locks/${e}/${t}/lock/queue`)), B(null), p();
344
370
  } catch {
345
371
  }
346
- }, [o, e, t, w]), Te = L(
372
+ }, [o, e, t, p]), Ye = E(
347
373
  async (a) => {
348
374
  if (!(!e || !t || !i.current)) {
349
- oe(a);
375
+ de(a);
350
376
  try {
351
- await o.request(A(`/item-locks/${e}/${t}/lock/note`, { note: a }));
377
+ await o.request(I(`/item-locks/${e}/${t}/lock/note`, { note: a }));
352
378
  } catch {
353
379
  }
354
380
  }
355
381
  },
356
382
  [o, e, t]
357
- ), qe = L(async () => {
383
+ ), Fe = E(async () => {
358
384
  if (!(!e || !t || !i.current)) {
359
- ie(!0), m(), i.current = !1, p(!1);
385
+ fe(!0), f(), i.current = !1, L(!1);
360
386
  try {
361
- await o.request(B(`/item-locks/${e}/${t}/lock`)), X(!0), oe(""), d.success("Lock released — anyone can edit this record now");
387
+ await o.request(W(`/item-locks/${e}/${t}/lock`)), te(!0), de(""), d.success("Lock released — anyone can edit this record now");
362
388
  } catch {
363
389
  d.error("Failed to release the lock"), h();
364
390
  } finally {
365
- ie(!1);
391
+ fe(!1);
366
392
  }
367
393
  }
368
- }, [o, e, t, m, h]), Ie = L(async () => {
394
+ }, [o, e, t, f, h]), ze = E(async () => {
369
395
  if (i.current) return !0;
370
396
  const a = await h();
371
397
  return a && d.success("You hold the edit lock again"), a;
372
- }, [h]), Ae = L(async () => {
398
+ }, [h]), Ke = E(async () => {
373
399
  var a;
374
400
  if (!(!e || !t)) {
375
- ae(!0);
401
+ le(!0);
376
402
  try {
377
403
  await o.request(
378
- A(`/item-locks/${e}/${t}/lock/force`, { beat_ms: G })
379
- ), d.success("You now hold the edit lock"), await h();
404
+ I(`/item-locks/${e}/${t}/lock/force`, { beat_ms: ee })
405
+ ), d.success("You now hold the edit lock"), V.current = Date.now(), J.current = !1, ie(F, !0), await h() || z();
380
406
  } catch (n) {
381
- const v = ((a = n == null ? void 0 : n.response) == null ? void 0 : a.error) ?? "Failed to take over the lock";
382
- d.error(v), (n == null ? void 0 : n.status) === 403 && S((u) => u && { ...u, may_take_over: !1 });
407
+ const m = ((a = n == null ? void 0 : n.response) == null ? void 0 : a.error) ?? "Failed to take over the lock";
408
+ d.error(m), (n == null ? void 0 : n.status) === 403 && R((l) => l && { ...l, may_take_over: !1 });
383
409
  } finally {
384
- ae(!1);
410
+ le(!1);
385
411
  }
386
412
  }
387
- }, [o, e, t, h]);
413
+ }, [o, e, t, h, F, z]);
388
414
  return {
389
- lockHolder: M,
390
- acquired: K,
391
- isReadOnly: !!M,
392
- takeOver: Ae,
393
- takingOver: z,
394
- isAdmin: R,
395
- requestLock: Ce,
396
- requesting: Ne,
397
- queue: ye,
398
- myPosition: xe,
399
- joinQueue: Se,
400
- leaveQueue: Re,
401
- joining: we,
402
- myNote: _e,
403
- saveNote: Te,
404
- release: qe,
405
- releasing: Le,
406
- released: pe,
407
- relock: Ie,
408
- claim: Ee
415
+ lockHolder: D,
416
+ acquired: Y,
417
+ isReadOnly: !!D,
418
+ takeOver: Ke,
419
+ takingOver: j,
420
+ isAdmin: C,
421
+ requestLock: Oe,
422
+ requesting: Ie,
423
+ queue: Ee,
424
+ myPosition: Se,
425
+ joinQueue: De,
426
+ leaveQueue: Me,
427
+ joining: Ne,
428
+ myNote: Re,
429
+ saveNote: Ye,
430
+ release: Fe,
431
+ releasing: Te,
432
+ released: Ce,
433
+ relock: ze,
434
+ claim: qe
409
435
  };
410
436
  }
411
- function ct({
437
+ function yt({
412
438
  note: e,
413
439
  onSave: t,
414
440
  waiting: s,
415
- onRelease: C,
416
- releasing: f,
417
- released: T,
441
+ onRelease: N,
442
+ releasing: k,
443
+ released: q,
418
444
  onRelock: g
419
445
  }) {
420
- var R;
421
- const [_, x] = E(e);
422
- $(() => x(e), [e]);
446
+ var C;
447
+ const [$, _] = S(e);
448
+ w(() => _(e), [e]);
423
449
  const o = () => {
424
- _.trim() !== e && t(_.trim());
450
+ $.trim() !== e && t($.trim());
425
451
  };
426
- return T ? /* @__PURE__ */ y(me, { children: [
427
- /* @__PURE__ */ k(he, { asChild: !0, children: /* @__PURE__ */ k(
452
+ return q ? /* @__PURE__ */ x(ge, { children: [
453
+ /* @__PURE__ */ v(we, { asChild: !0, children: /* @__PURE__ */ v(
428
454
  "button",
429
455
  {
430
456
  type: "button",
@@ -432,13 +458,13 @@ function ct({
432
458
  title: "Lock released — anyone can edit this record",
433
459
  "data-lock-released": !0,
434
460
  className: "relative inline-flex h-8 w-8 items-center justify-center text-slate-400 transition-colors hover:bg-accent hover:text-accent-foreground dark:text-slate-500",
435
- children: /* @__PURE__ */ k(de, { className: "h-4 w-4", strokeWidth: 2 })
461
+ children: /* @__PURE__ */ v(ve, { className: "h-4 w-4", strokeWidth: 2 })
436
462
  }
437
463
  ) }),
438
- /* @__PURE__ */ y(ke, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
439
- /* @__PURE__ */ k("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You released the edit lock" }),
440
- /* @__PURE__ */ k("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Anyone can edit this record now. Your next edit locks it again — or lock it now." }),
441
- /* @__PURE__ */ y(
464
+ /* @__PURE__ */ x(xe, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
465
+ /* @__PURE__ */ v("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You released the edit lock" }),
466
+ /* @__PURE__ */ v("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Anyone can edit this record now. Your next edit locks it again — or lock it now." }),
467
+ /* @__PURE__ */ x(
442
468
  O,
443
469
  {
444
470
  type: "button",
@@ -447,14 +473,14 @@ function ct({
447
473
  onClick: g,
448
474
  "data-lock-relock": !0,
449
475
  children: [
450
- /* @__PURE__ */ k(ne, { className: "mr-1.5 h-3.5 w-3.5" }),
476
+ /* @__PURE__ */ v(ue, { className: "mr-1.5 h-3.5 w-3.5" }),
451
477
  " Lock again"
452
478
  ]
453
479
  }
454
480
  )
455
481
  ] })
456
- ] }) : /* @__PURE__ */ y(me, { children: [
457
- /* @__PURE__ */ k(he, { asChild: !0, children: /* @__PURE__ */ y(
482
+ ] }) : /* @__PURE__ */ x(ge, { children: [
483
+ /* @__PURE__ */ v(we, { asChild: !0, children: /* @__PURE__ */ x(
458
484
  "button",
459
485
  {
460
486
  type: "button",
@@ -463,19 +489,19 @@ function ct({
463
489
  "data-lock-holder": !0,
464
490
  className: "relative inline-flex h-8 w-8 items-center justify-center text-[#0e7490] transition-colors hover:bg-accent hover:text-accent-foreground dark:text-nvr-cyan",
465
491
  children: [
466
- /* @__PURE__ */ k(ne, { className: "h-4 w-4", strokeWidth: 2 }),
467
- s.length > 0 && /* @__PURE__ */ k("span", { className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500 ring-2 ring-background" })
492
+ /* @__PURE__ */ v(ue, { className: "h-4 w-4", strokeWidth: 2 }),
493
+ s.length > 0 && /* @__PURE__ */ v("span", { className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500 ring-2 ring-background" })
468
494
  ]
469
495
  }
470
496
  ) }),
471
- /* @__PURE__ */ y(ke, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
472
- /* @__PURE__ */ k("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You hold the edit lock" }),
473
- /* @__PURE__ */ k("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Others see this record read-only. A note tells them what you’re doing." }),
474
- /* @__PURE__ */ k(
497
+ /* @__PURE__ */ x(xe, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
498
+ /* @__PURE__ */ v("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You hold the edit lock" }),
499
+ /* @__PURE__ */ v("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Others see this record read-only. A note tells them what you’re doing." }),
500
+ /* @__PURE__ */ v(
475
501
  "input",
476
502
  {
477
- value: _,
478
- onChange: (c) => x(c.target.value.slice(0, 300)),
503
+ value: $,
504
+ onChange: (c) => _(c.target.value.slice(0, 300)),
479
505
  onBlur: o,
480
506
  onKeyDown: (c) => {
481
507
  c.key === "Enter" && (c.preventDefault(), o());
@@ -485,65 +511,65 @@ function ct({
485
511
  className: "mt-2 h-7 w-full rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card"
486
512
  }
487
513
  ),
488
- s.length > 0 && /* @__PURE__ */ y("div", { className: "mt-2 rounded-md bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-500/10 dark:text-amber-200", children: [
489
- /* @__PURE__ */ y("span", { className: "font-semibold", children: [
514
+ s.length > 0 && /* @__PURE__ */ x("div", { className: "mt-2 rounded-md bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-500/10 dark:text-amber-200", children: [
515
+ /* @__PURE__ */ x("span", { className: "font-semibold", children: [
490
516
  s.length,
491
517
  " waiting for the lock:"
492
518
  ] }),
493
519
  " ",
494
520
  s.map((c) => c.name ?? "someone").join(", ")
495
521
  ] }),
496
- C && /* @__PURE__ */ y(
522
+ N && /* @__PURE__ */ x(
497
523
  O,
498
524
  {
499
525
  type: "button",
500
526
  variant: "outline",
501
527
  size: "sm",
502
528
  className: "mt-2 h-7 w-full text-[12px]",
503
- onClick: C,
504
- disabled: f,
529
+ onClick: N,
530
+ disabled: k,
505
531
  "data-lock-release": !0,
506
532
  children: [
507
- /* @__PURE__ */ k(de, { className: "mr-1.5 h-3.5 w-3.5" }),
508
- f ? "Releasing…" : s.length > 0 ? `Release lock to ${((R = s[0]) == null ? void 0 : R.name) ?? "the next person"}` : "Release lock"
533
+ /* @__PURE__ */ v(ve, { className: "mr-1.5 h-3.5 w-3.5" }),
534
+ k ? "Releasing…" : s.length > 0 ? `Release lock to ${((C = s[0]) == null ? void 0 : C.name) ?? "the next person"}` : "Release lock"
509
535
  ]
510
536
  }
511
537
  )
512
538
  ] })
513
539
  ] });
514
540
  }
515
- function dt({
541
+ function gt({
516
542
  lockHolder: e,
517
543
  onTakeOver: t,
518
544
  takingOver: s,
519
- isAdmin: C,
520
- onRequestLock: f,
521
- requesting: T,
545
+ isAdmin: N,
546
+ onRequestLock: k,
547
+ requesting: q,
522
548
  queue: g,
523
- myPosition: _,
524
- onJoinQueue: x,
549
+ myPosition: $,
550
+ onJoinQueue: _,
525
551
  onLeaveQueue: o,
526
- joining: R,
552
+ joining: C,
527
553
  noun: c = "this item",
528
- readOnlyText: b = "fields are read-only"
554
+ readOnlyText: y = "fields are read-only"
529
555
  }) {
530
- const [M, S] = E(!1), K = (e == null ? void 0 : e.locked_by) ?? null;
531
- if ($(() => S(!1), [K]), !e) return null;
532
- const p = e.locked_by_name || "Another user", z = (g == null ? void 0 : g.length) ?? 0;
533
- return /* @__PURE__ */ y(
556
+ const [D, R] = S(!1), Y = (e == null ? void 0 : e.locked_by) ?? null;
557
+ if (w(() => R(!1), [Y]), !e) return null;
558
+ const L = e.locked_by_name || "Another user", j = (g == null ? void 0 : g.length) ?? 0;
559
+ return /* @__PURE__ */ x(
534
560
  "div",
535
561
  {
536
562
  className: "mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",
537
563
  "data-lock-banner": !0,
538
564
  children: [
539
- /* @__PURE__ */ k(ne, { className: "h-4 w-4 shrink-0 text-amber-500" }),
540
- /* @__PURE__ */ y("span", { className: "min-w-0 flex-1", children: [
541
- /* @__PURE__ */ k("span", { className: "font-medium", children: p }),
565
+ /* @__PURE__ */ v(ue, { className: "h-4 w-4 shrink-0 text-amber-500" }),
566
+ /* @__PURE__ */ x("span", { className: "min-w-0 flex-1", children: [
567
+ /* @__PURE__ */ v("span", { className: "font-medium", children: L }),
542
568
  " is editing ",
543
569
  c,
544
570
  " — ",
545
- b,
546
- e.idle_minutes != null && e.idle_minutes >= 2 && /* @__PURE__ */ y(
571
+ y,
572
+ e.idle_minutes != null && e.idle_minutes >= 2 && /* @__PURE__ */ x(
547
573
  "span",
548
574
  {
549
575
  className: "ml-1.5 rounded bg-amber-100 px-1 py-px text-[10px] font-semibold text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",
@@ -558,19 +584,19 @@ function dt({
558
584
  ),
559
585
  " ",
560
586
  "until the lock is released.",
561
- e.note && /* @__PURE__ */ y("span", { className: "mt-0.5 block text-[12.5px] text-amber-800/90 dark:text-amber-200/90", children: [
587
+ e.note && /* @__PURE__ */ x("span", { className: "mt-0.5 block text-[12.5px] text-amber-800/90 dark:text-amber-200/90", children: [
562
588
  "“",
563
589
  e.note,
564
590
  "”"
565
591
  ] }),
566
- z > 0 && _ == null && /* @__PURE__ */ y("span", { className: "mt-0.5 block text-[11.5px] text-amber-700/80 dark:text-amber-300/80", children: [
567
- z,
592
+ j > 0 && $ == null && /* @__PURE__ */ x("span", { className: "mt-0.5 block text-[11.5px] text-amber-700/80 dark:text-amber-300/80", children: [
593
+ j,
568
594
  " ",
569
- z === 1 ? "person is" : "people are",
595
+ j === 1 ? "person is" : "people are",
570
596
  " already waiting."
571
597
  ] })
572
598
  ] }),
573
- x && (_ != null ? /* @__PURE__ */ y(
599
+ _ && ($ != null ? /* @__PURE__ */ x(
574
600
  O,
575
601
  {
576
602
  size: "sm",
@@ -580,64 +606,64 @@ function dt({
580
606
  "data-lock-queue-leave": !0,
581
607
  children: [
582
608
  "You’re #",
583
- _,
609
+ $,
584
610
  " in line · Leave"
585
611
  ]
586
612
  }
587
- ) : /* @__PURE__ */ k(
613
+ ) : /* @__PURE__ */ v(
588
614
  O,
589
615
  {
590
616
  size: "sm",
591
617
  variant: "outline",
592
618
  className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
593
- onClick: x,
594
- disabled: R,
619
+ onClick: _,
620
+ disabled: C,
595
621
  "data-lock-queue-join": !0,
596
- children: R ? "Joining…" : "Ask to be next"
622
+ children: C ? "Joining…" : "Ask to be next"
597
623
  }
598
624
  )),
599
- f && /* @__PURE__ */ k(
625
+ k && /* @__PURE__ */ v(
600
626
  O,
601
627
  {
602
628
  size: "sm",
603
629
  variant: "outline",
604
630
  className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
605
- onClick: f,
606
- disabled: T,
607
- children: T ? "Asking…" : "Ask them to wrap up"
631
+ onClick: k,
632
+ disabled: q,
633
+ children: q ? "Asking…" : "Ask them to wrap up"
608
634
  }
609
635
  ),
610
636
  // Admins always; other roles only when the server says they may (the
611
637
  // takeover-role allowlist, #256) — unknown = offered, and a 403 then
612
638
  // hides it. A Take over that can only fail was a dead end.
613
- (C || e.may_take_over !== !1) && (M ? /* @__PURE__ */ y(
639
+ (N || e.may_take_over !== !1) && (D ? /* @__PURE__ */ x(
614
640
  "span",
615
641
  {
616
642
  className: "flex basis-full flex-wrap items-center justify-end gap-2 text-[12px] text-amber-800 dark:text-amber-200",
617
643
  "data-lock-takeover-confirm": !0,
618
644
  children: [
619
- /* @__PURE__ */ y("span", { className: "min-w-0 flex-1 text-right", children: [
620
- p,
645
+ /* @__PURE__ */ x("span", { className: "min-w-0 flex-1 text-right", children: [
646
+ L,
621
647
  " may have unsaved changes — they can’t save them once you take over."
622
648
  ] }),
623
- /* @__PURE__ */ k(
649
+ /* @__PURE__ */ v(
624
650
  O,
625
651
  {
626
652
  size: "sm",
627
653
  variant: "outline",
628
654
  className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
629
- onClick: () => S(!1),
655
+ onClick: () => R(!1),
630
656
  disabled: s,
631
657
  children: "Cancel"
632
658
  }
633
659
  ),
634
- /* @__PURE__ */ k(
660
+ /* @__PURE__ */ v(
635
661
  O,
636
662
  {
637
663
  size: "sm",
638
664
  className: "h-7 shrink-0 bg-amber-600 text-[12px] text-white hover:bg-amber-700",
639
665
  onClick: () => {
640
- S(!1), t();
666
+ R(!1), t();
641
667
  },
642
668
  disabled: s,
643
669
  "data-lock-takeover-go": !0,
@@ -646,13 +672,13 @@ function dt({
646
672
  )
647
673
  ]
648
674
  }
649
- ) : /* @__PURE__ */ k(
675
+ ) : /* @__PURE__ */ v(
650
676
  O,
651
677
  {
652
678
  size: "sm",
653
679
  variant: "outline",
654
- className: C ? "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15" : "h-7 shrink-0 border-amber-200 bg-white/60 text-[12px] text-amber-700/80 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-transparent dark:text-amber-200/80 dark:hover:bg-amber-500/15",
655
- onClick: () => S(!0),
680
+ className: N ? "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15" : "h-7 shrink-0 border-amber-200 bg-white/60 text-[12px] text-amber-700/80 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-transparent dark:text-amber-200/80 dark:hover:bg-amber-500/15",
681
+ onClick: () => R(!0),
656
682
  disabled: s,
657
683
  children: s ? "Taking over…" : "Take over"
658
684
  }
@@ -662,8 +688,9 @@ function dt({
662
688
  );
663
689
  }
664
690
  export {
665
- dt as ItemLockBanner,
666
- ct as LockHolderButton,
667
- ve as takenAwayText,
668
- lt as useItemLock
691
+ gt as ItemLockBanner,
692
+ yt as LockHolderButton,
693
+ tt as TAKEOVER_HOLD_MS,
694
+ Le as takenAwayText,
695
+ vt as useItemLock
669
696
  };