@nivaro/react 0.3.111 → 0.3.112

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 (75) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +170 -2
  4. package/dist/index.js +745 -728
  5. package/dist/shared/components/CollectionBrowserView.js +3097 -2972
  6. package/dist/shared/components/CollectionImportBanner.js +135 -0
  7. package/dist/shared/components/ItemEditForm.js +2235 -2218
  8. package/dist/shared/components/JobsTray.js +54 -47
  9. package/dist/shared/components/ViewAsPersonButton.js +109 -0
  10. package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
  11. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
  12. package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
  13. package/dist/shared/components/bulk/bulk-field-options.js +20 -19
  14. package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
  15. package/dist/shared/components/cbv/ColumnHeaderMenu.js +113 -0
  16. package/dist/shared/components/cbv/column-totals.js +66 -0
  17. package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
  18. package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
  19. package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
  20. package/dist/shared/components/collections-directory/directory-data.js +70 -58
  21. package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
  22. package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
  23. package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
  24. package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
  25. package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
  26. package/dist/shared/components/item-edit/FieldRow.js +248 -246
  27. package/dist/shared/components/item-edit/InlineGridField.js +34 -33
  28. package/dist/shared/components/item-edit/InlineTableField.js +3064 -2882
  29. package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
  31. package/dist/shared/components/item-edit/PlanGrid.js +2 -1
  32. package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
  34. package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
  35. package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
  36. package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
  37. package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
  38. package/dist/shared/components/item-edit/grid-search.js +345 -0
  39. package/dist/shared/components/item-edit/render-stability.js +61 -54
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
  41. package/dist/shared/components/ops-report/DigestSections.js +163 -144
  42. package/dist/shared/components/ops-report/drill.js +97 -97
  43. package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
  44. package/dist/shared/components/panels/AddendumPanel.js +92 -91
  45. package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
  46. package/dist/shared/components/panels/CommentPanel.js +265 -252
  47. package/dist/shared/components/panels/OwnersSlot.js +47 -35
  48. package/dist/shared/components/panels/PipelineInsight.js +186 -0
  49. package/dist/shared/components/panels/PipelinePanel.js +1529 -1492
  50. package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
  51. package/dist/shared/components/panels/RevisionsPanel.js +261 -260
  52. package/dist/shared/components/pipeline/FieldPicker.js +41 -40
  53. package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
  54. package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
  55. package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
  56. package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
  57. package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
  58. package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
  59. package/dist/shared/components/profile/PersonHeader.js +29 -29
  60. package/dist/shared/components/profile/PersonProfile.js +30 -28
  61. package/dist/shared/components/profile/SlowScreensCard.js +286 -0
  62. package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
  63. package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
  64. package/dist/shared/components/support/TicketDetailSheet.js +25 -16
  65. package/dist/shared/components/support/TicketSlowScreens.js +32 -0
  66. package/dist/shared/lib/activity-sentence.js +224 -178
  67. package/dist/shared/lib/collection-import-banner.js +27 -0
  68. package/dist/shared/lib/crash-report.js +112 -0
  69. package/dist/shared/lib/export-runs.js +99 -0
  70. package/dist/shared/lib/jobs-tray.js +89 -67
  71. package/dist/shared/lib/list-link.js +76 -69
  72. package/dist/shared/lib/nav-trail.js +180 -76
  73. package/dist/shared/lib/query-keys.js +26 -0
  74. package/dist/shared/lib/view-as.js +16 -11
  75. package/package.json +1 -1
@@ -1,74 +1,78 @@
1
- import { jsxs as l, jsx as t, Fragment as we } from "react/jsx-runtime";
2
- import { useQuery as D, useQueries as xe, useQueryClient as Me, useMutation as V } from "@tanstack/react-query";
3
- import { Loader2 as te, Users2 as ue, Plus as me, X as pe, ChevronDown as ke, Search as _e, Check as Ue } from "lucide-react";
4
- import { useState as K, useEffect as fe, useMemo as ve, Fragment as De, useRef as se } from "react";
5
- import { createPortal as st } from "react-dom";
6
- import { toast as P } from "sonner";
7
- import { useNivaroClient as Z } from "../../context.js";
8
- import { get as E, post as M, del as Ne, patch as Ae } from "../../lib/commands.js";
9
- import { UserAvatar as qe } from "../UserAvatar.js";
10
- import { Button as it } from "../ui/button.js";
11
- import { Popover as Fe, PopoverTrigger as Ce, PopoverContent as Se } from "../ui/popover.js";
12
- import { findM2ORelation as ge, findO2MRelation as Qe, renderDisplayTemplate as ye } from "./relations.js";
13
- import { TeamScopeEditor as ot } from "./TeamScopeEditor.js";
14
- import { useScopeDimensions as dt, rankTeamForFilters as Ve, tierOrder as Le } from "./teamScopes.js";
15
- function ct(m) {
16
- return [...m].sort((f, N) => {
17
- const c = Number(f.label), y = Number(N.label);
18
- return !Number.isNaN(c) && !Number.isNaN(y) ? c - y : f.label.localeCompare(N.label, void 0, { sensitivity: "base" });
1
+ import { jsxs as l, jsx as t, Fragment as je } from "react/jsx-runtime";
2
+ import { useQuery as V, useQueries as qe, useQueryClient as tt, useMutation as G } from "@tanstack/react-query";
3
+ import { Loader2 as te, FilePen as Xe, Users2 as xe, Plus as ge, X as ye, ChevronDown as Ie, Search as Te, Check as Je } from "lucide-react";
4
+ import { useState as T, useMemo as de, useEffect as ve, Fragment as rt, useRef as ue } from "react";
5
+ import { createPortal as gt } from "react-dom";
6
+ import { toast as O } from "sonner";
7
+ import { useNivaroClient as re } from "../../context.js";
8
+ import { get as K, post as A, del as ce, patch as Fe } from "../../lib/commands.js";
9
+ import { queryKeys as be } from "../../lib/query-keys.js";
10
+ import { toastError as yt } from "../../lib/error-toast.js";
11
+ import { UserAvatar as Oe } from "../UserAvatar.js";
12
+ import { Button as Se } from "../ui/button.js";
13
+ import { Popover as Pe, PopoverTrigger as Ee, PopoverContent as Ke } from "../ui/popover.js";
14
+ import { OwnerRecordTrial as vt } from "./OwnerRecordTrial.js";
15
+ import { draftDelta as Nt, draftAddUser as wt, draftAddTeam as kt, draftRemoveTeam as _t, draftCreateGroup as qt, draftPatchGroup as Ye, draftRemoveUser as Ft, draftSaveOps as Ct, cloneGroupsMap as $t } from "./owner-matrix-draft.js";
16
+ import { findM2ORelation as Ce, findO2MRelation as Ze, renderDisplayTemplate as $e } from "./relations.js";
17
+ import { TeamScopeEditor as St } from "./TeamScopeEditor.js";
18
+ import { useScopeDimensions as jt, rankTeamForFilters as at, tierOrder as et } from "./teamScopes.js";
19
+ function It(f) {
20
+ return [...f].sort((b, v) => {
21
+ const o = Number(b.label), N = Number(v.label);
22
+ return !Number.isNaN(o) && !Number.isNaN(N) ? o - N : b.label.localeCompare(v.label, void 0, { sensitivity: "base" });
19
23
  });
20
24
  }
21
- function ut({
22
- label: m,
23
- value: f,
24
- options: N,
25
- onChange: c,
26
- onSearch: y,
27
- loading: d
25
+ function Tt({
26
+ label: f,
27
+ value: b,
28
+ options: v,
29
+ onChange: o,
30
+ onSearch: N,
31
+ loading: c
28
32
  }) {
29
- var b;
30
- const [h, _] = K(!1), [F, q] = K(""), $ = se(null), I = se(null), k = ve(() => ct(N), [N]), x = se(y);
31
- x.current = y, fe(() => {
32
- h ? setTimeout(() => {
33
+ var m;
34
+ const [y, _] = T(!1), [$, F] = T(""), j = ue(null), w = ue(null), C = de(() => It(v), [v]), x = ue(N);
35
+ x.current = N, ve(() => {
36
+ y ? setTimeout(() => {
33
37
  var u;
34
- return (u = $.current) == null ? void 0 : u.focus();
35
- }, 50) : (q(""), x.current(""));
36
- }, [h]);
37
- const j = (u) => {
38
- q(u), I.current && clearTimeout(I.current), I.current = setTimeout(() => y(u.trim()), 300);
39
- }, L = f ? ((b = N.find((u) => u.value === f)) == null ? void 0 : b.label) ?? f : null;
40
- return /* @__PURE__ */ l(Fe, { open: h, onOpenChange: _, children: [
41
- /* @__PURE__ */ t(Ce, { asChild: !0, children: /* @__PURE__ */ l(
38
+ return (u = j.current) == null ? void 0 : u.focus();
39
+ }, 50) : (F(""), x.current(""));
40
+ }, [y]);
41
+ const E = (u) => {
42
+ F(u), w.current && clearTimeout(w.current), w.current = setTimeout(() => N(u.trim()), 300);
43
+ }, W = b ? ((m = v.find((u) => u.value === b)) == null ? void 0 : m.label) ?? b : null;
44
+ return /* @__PURE__ */ l(Pe, { open: y, onOpenChange: _, children: [
45
+ /* @__PURE__ */ t(Ee, { asChild: !0, children: /* @__PURE__ */ l(
42
46
  "button",
43
47
  {
44
48
  type: "button",
45
- className: `flex h-7 items-center gap-1 rounded-md border pl-2.5 text-[12px] transition-colors ${f ? "border-nvr-cyan/50 bg-nvr-cyan/5 font-medium text-nvr-cyan pr-1" : "border-slate-200 bg-white text-slate-600 hover:border-slate-300 pr-2.5"}`,
49
+ className: `flex h-7 items-center gap-1 rounded-md border pl-2.5 text-[12px] transition-colors ${b ? "border-nvr-cyan/50 bg-nvr-cyan/5 font-medium text-nvr-cyan pr-1" : "border-slate-200 bg-white text-slate-600 hover:border-slate-300 pr-2.5"}`,
46
50
  children: [
47
- /* @__PURE__ */ t("span", { children: L ?? `All ${m}` }),
48
- f ? /* @__PURE__ */ t(
51
+ /* @__PURE__ */ t("span", { children: W ?? `All ${f}` }),
52
+ b ? /* @__PURE__ */ t(
49
53
  "button",
50
54
  {
51
55
  type: "button",
52
56
  onClick: (u) => {
53
- u.stopPropagation(), c(""), y("");
57
+ u.stopPropagation(), o(""), N("");
54
58
  },
55
59
  className: "flex h-5 w-5 items-center justify-center rounded hover:bg-nvr-cyan/20",
56
- children: /* @__PURE__ */ t(pe, { className: "h-3 w-3" })
60
+ children: /* @__PURE__ */ t(ye, { className: "h-3 w-3" })
57
61
  }
58
- ) : d ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin opacity-50" }) : /* @__PURE__ */ t(ke, { className: "h-3 w-3 opacity-50" })
62
+ ) : c ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin opacity-50" }) : /* @__PURE__ */ t(Ie, { className: "h-3 w-3 opacity-50" })
59
63
  ]
60
64
  }
61
65
  ) }),
62
- /* @__PURE__ */ l(Se, { align: "start", className: "w-56 p-0", sideOffset: 4, children: [
66
+ /* @__PURE__ */ l(Ke, { align: "start", className: "w-56 p-0", sideOffset: 4, children: [
63
67
  /* @__PURE__ */ t("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ l("div", { className: "relative", children: [
64
- /* @__PURE__ */ t(_e, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
68
+ /* @__PURE__ */ t(Te, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
65
69
  /* @__PURE__ */ t(
66
70
  "input",
67
71
  {
68
- ref: $,
69
- value: F,
70
- onChange: (u) => j(u.target.value),
71
- placeholder: `Search ${m.toLowerCase()}…`,
72
+ ref: j,
73
+ value: $,
74
+ onChange: (u) => E(u.target.value),
75
+ placeholder: `Search ${f.toLowerCase()}…`,
72
76
  className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40"
73
77
  }
74
78
  )
@@ -79,28 +83,28 @@ function ut({
79
83
  {
80
84
  type: "button",
81
85
  onClick: () => {
82
- c(""), _(!1);
86
+ o(""), _(!1);
83
87
  },
84
- className: `flex w-full items-center gap-2 px-3 py-1.5 text-[12px] hover:bg-slate-50 ${f ? "text-slate-500" : "font-medium text-slate-800"}`,
88
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-[12px] hover:bg-slate-50 ${b ? "text-slate-500" : "font-medium text-slate-800"}`,
85
89
  children: [
86
- /* @__PURE__ */ t(Ue, { className: `h-3.5 w-3.5 shrink-0 ${f ? "opacity-0" : "text-nvr-cyan"}` }),
90
+ /* @__PURE__ */ t(Je, { className: `h-3.5 w-3.5 shrink-0 ${b ? "opacity-0" : "text-nvr-cyan"}` }),
87
91
  "All"
88
92
  ]
89
93
  }
90
94
  ),
91
- k.map((u) => /* @__PURE__ */ l(
95
+ C.map((u) => /* @__PURE__ */ l(
92
96
  "button",
93
97
  {
94
98
  type: "button",
95
99
  onClick: () => {
96
- c(u.value), _(!1);
100
+ o(u.value), _(!1);
97
101
  },
98
- className: `flex w-full items-center gap-2 px-3 py-1.5 text-[12px] hover:bg-slate-50 ${f === u.value ? "font-medium text-slate-800" : "text-slate-600"}`,
102
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-[12px] hover:bg-slate-50 ${b === u.value ? "font-medium text-slate-800" : "text-slate-600"}`,
99
103
  children: [
100
104
  /* @__PURE__ */ t(
101
- Ue,
105
+ Je,
102
106
  {
103
- className: `h-3.5 w-3.5 shrink-0 ${f === u.value ? "text-nvr-cyan" : "opacity-0"}`
107
+ className: `h-3.5 w-3.5 shrink-0 ${b === u.value ? "text-nvr-cyan" : "opacity-0"}`
104
108
  }
105
109
  ),
106
110
  u.label
@@ -108,512 +112,633 @@ function ut({
108
112
  },
109
113
  u.value
110
114
  )),
111
- k.length === 0 && /* @__PURE__ */ t("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" })
115
+ C.length === 0 && /* @__PURE__ */ t("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" })
112
116
  ] })
113
117
  ] })
114
118
  ] });
115
119
  }
116
- function ee(m, f, N, c) {
117
- const y = m.field.split("."), d = y.length > 1 ? y[y.length - 1] : m.field, _ = [...N ?? [], ...c ?? []].find((q) => String(q[d] ?? "") === f);
120
+ function le(f, b, v, o) {
121
+ const N = f.field.split("."), c = N.length > 1 ? N[N.length - 1] : f.field, _ = [...v ?? [], ...o ?? []].find((F) => String(F[c] ?? "") === b);
118
122
  if (!_) return null;
119
- const F = _.id;
120
- return typeof F == "number" ? F : typeof F == "string" && Number(F) || null;
123
+ const $ = _.id;
124
+ return typeof $ == "number" ? $ : typeof $ == "string" && Number($) || null;
121
125
  }
122
- function mt(m, f, N) {
123
- const c = m.split(".");
124
- let y = { _eq: N };
125
- for (let d = c.length - 1; d >= 1; d--) y = { [c[d]]: y };
126
- return f ? { [c[0]]: { _some: y } } : c.length > 1 ? { [c[0]]: y } : { [c[0]]: { _eq: N } };
126
+ function Ot(f, b, v) {
127
+ const o = f.split(".");
128
+ let N = { _eq: v };
129
+ for (let c = o.length - 1; c >= 1; c--) N = { [o[c]]: N };
130
+ return b ? { [o[0]]: { _some: N } } : o.length > 1 ? { [o[0]]: N } : { [o[0]]: { _eq: v } };
127
131
  }
128
- function Re(m, f) {
129
- const N = m.role ? (f == null ? void 0 : f.get(String(m.role).toUpperCase())) ?? null : null;
130
- return [m.title || N, m.department].filter(Boolean).join(" · ") || m.email;
132
+ function nt(f, b) {
133
+ const v = f.role ? (b == null ? void 0 : b.get(String(f.role).toUpperCase())) ?? null : null;
134
+ return [f.title || v, f.department].filter(Boolean).join(" · ") || f.email;
131
135
  }
132
- function ze() {
133
- const m = Z(), { data: f } = D({
136
+ function st() {
137
+ const f = re(), { data: b } = V({
134
138
  queryKey: ["roles-name-map"],
135
- queryFn: () => m.request(E("/roles")).then((N) => new Map(N.data.map((c) => [String(c.id).toUpperCase(), c.name]))).catch(() => null),
139
+ queryFn: () => f.request(K("/roles")).then((v) => new Map(v.data.map((o) => [String(o.id).toUpperCase(), o.name]))).catch(() => null),
136
140
  staleTime: 5 * 6e4
137
141
  });
138
- return f ?? null;
142
+ return b ?? null;
139
143
  }
140
- function pt(m) {
141
- const f = Z(), N = m.trim(), { data: c, isFetching: y } = D({
142
- queryKey: ["people-search", N],
143
- queryFn: () => f.request(
144
- E("/users", { limit: 50, sort: "first_name", search: N || void 0 })
145
- ).then((d) => d.data),
144
+ function Pt(f) {
145
+ const b = re(), v = f.trim(), { data: o, isFetching: N } = V({
146
+ queryKey: ["people-search", v],
147
+ queryFn: () => b.request(
148
+ K("/users", { limit: 50, sort: "first_name", search: v || void 0 })
149
+ ).then((c) => c.data),
146
150
  staleTime: 6e4
147
151
  });
148
- return { people: c ?? [], isFetching: y };
152
+ return { people: o ?? [], isFetching: N };
149
153
  }
150
- function $e(m) {
151
- const f = [m.first_name, m.last_name].filter(Boolean);
152
- return f.length ? f.map((N) => N[0]).join("").toUpperCase() : m.email[0].toUpperCase();
154
+ function Be(f) {
155
+ const b = [f.first_name, f.last_name].filter(Boolean);
156
+ return b.length ? b.map((v) => v[0]).join("").toUpperCase() : f.email[0].toUpperCase();
153
157
  }
154
- function Tt({ templateId: m, states: f, bindings: N }) {
155
- var Ee;
156
- const c = Z(), y = N.flatMap((e) => e.dimensions ?? []), d = y.find((e) => e.is_row_axis) ?? null, h = y.filter((e) => !e.is_row_axis), { data: _, isLoading: F } = D({
157
- queryKey: ["pipeline-all-owner-groups", m],
158
- queryFn: () => c.request(E(`/pipelines/${m}/owner-groups`)).then((e) => e.data)
159
- }), [q, $] = K(!1), I = dt(), k = ((Ee = N[0]) == null ? void 0 : Ee.collection) ?? "", { data: x } = D({
160
- queryKey: ["collection-meta", k],
161
- queryFn: () => c.request(E(`/collections/${k}`)).then((e) => e.data),
162
- enabled: !!k && (!!d || h.length > 0)
163
- }), j = (x == null ? void 0 : x.relations) ?? [], L = d ? d.field.split(".") : [], b = L[0] ?? "", u = L[1] ?? null, S = d ? ge(j, k, b) ?? null : null, A = !S && d ? j.find(
164
- (e) => e.many_collection === k && e.many_field === b && e.junction_field !== null && e.one_collection
165
- ) ?? null : null, B = !S && !A && d ? j.find(
166
- (e) => e.one_collection === k && e.one_field === b && e.junction_field !== null
167
- ) ?? null : null, H = B ? j.find(
168
- (e) => e.many_collection === B.many_collection && e.many_field === B.junction_field && e.one_collection
169
- ) ?? null : null, W = !S && !A && !B && d ? Qe(j, k, b) ?? null : null, U = (S == null ? void 0 : S.one_collection) ?? (A == null ? void 0 : A.one_collection) ?? (H == null ? void 0 : H.one_collection) ?? (B == null ? void 0 : B.many_collection) ?? (W == null ? void 0 : W.many_collection) ?? null, ie = !!d && L.length === 1 && !U, X = U ?? (ie ? k : null), J = u ?? (ie ? b : null), p = h.map((e) => {
170
- const r = e.field.split(".");
158
+ function sr({ templateId: f, states: b, bindings: v }) {
159
+ var He;
160
+ const o = re(), N = v.flatMap((e) => e.dimensions ?? []), c = N.find((e) => e.is_row_axis) ?? null, y = N.filter((e) => !e.is_row_axis), { data: _, isLoading: $ } = V({
161
+ queryKey: ["pipeline-all-owner-groups", f],
162
+ queryFn: () => o.request(K(`/pipelines/${f}/owner-groups`)).then((e) => e.data)
163
+ }), [F, j] = T(!1), [w, C] = T(null), x = w ?? _, E = de(() => Nt(_, w), [_, w]), W = jt(), m = ((He = v[0]) == null ? void 0 : He.collection) ?? "", { data: u } = V({
164
+ queryKey: be.collectionMeta(m),
165
+ queryFn: () => o.request(K(`/collections/${m}`)).then((e) => e.data),
166
+ enabled: !!m && (!!c || y.length > 0)
167
+ }), q = (u == null ? void 0 : u.relations) ?? [], Q = c ? c.field.split(".") : [], B = Q[0] ?? "", ae = Q[1] ?? null, R = c ? Ce(q, m, B) ?? null : null, M = !R && c ? q.find(
168
+ (e) => e.many_collection === m && e.many_field === B && e.junction_field !== null && e.one_collection
169
+ ) ?? null : null, H = !R && !M && c ? q.find(
170
+ (e) => e.one_collection === m && e.one_field === B && e.junction_field !== null
171
+ ) ?? null : null, Z = H ? q.find(
172
+ (e) => e.many_collection === H.many_collection && e.many_field === H.junction_field && e.one_collection
173
+ ) ?? null : null, ne = !R && !M && !H && c ? Ze(q, m, B) ?? null : null, p = (R == null ? void 0 : R.one_collection) ?? (M == null ? void 0 : M.one_collection) ?? (Z == null ? void 0 : Z.one_collection) ?? (H == null ? void 0 : H.many_collection) ?? (ne == null ? void 0 : ne.many_collection) ?? null, ie = !!c && Q.length === 1 && !p, Ne = p ?? (ie ? m : null), me = ae ?? (ie ? B : null), we = y.map((e) => {
174
+ const a = e.field.split(".");
171
175
  return {
172
- baseField: r[0],
176
+ baseField: a[0],
173
177
  // segments between base and leaf for 3+ part paths
174
- midFields: r.length > 2 ? r.slice(1, -1) : [],
178
+ midFields: a.length > 2 ? a.slice(1, -1) : [],
175
179
  // leaf = sub-field to display/filter by; null when path is a direct relation field
176
- leafField: r.length > 1 ? r[r.length - 1] : null
180
+ leafField: a.length > 1 ? a[a.length - 1] : null
177
181
  };
178
- }), re = p.map(({ baseField: e }) => {
179
- const r = ge(j, k, e);
180
- if (r != null && r.one_collection) return r.one_collection;
181
- const a = j.find(
182
- (o) => o.many_collection === k && o.many_field === e && o.junction_field !== null && o.one_collection
183
- );
182
+ }), Ue = we.map(({ baseField: e }) => {
183
+ const a = Ce(q, m, e);
184
184
  if (a != null && a.one_collection) return a.one_collection;
185
- const i = j.find(
186
- (o) => o.one_collection === k && o.one_field === e && o.junction_field !== null
185
+ const r = q.find(
186
+ (d) => d.many_collection === m && d.many_field === e && d.junction_field !== null && d.one_collection
187
187
  );
188
- if (i) {
189
- const o = j.find(
190
- (v) => v.many_collection === i.many_collection && v.many_field === i.junction_field && v.one_collection
188
+ if (r != null && r.one_collection) return r.one_collection;
189
+ const n = q.find(
190
+ (d) => d.one_collection === m && d.one_field === e && d.junction_field !== null
191
+ );
192
+ if (n) {
193
+ const d = q.find(
194
+ (g) => g.many_collection === n.many_collection && g.many_field === n.junction_field && g.one_collection
191
195
  );
192
- if (o != null && o.one_collection) return o.one_collection;
196
+ if (d != null && d.one_collection) return d.one_collection;
193
197
  }
194
- const s = Qe(j, k, e);
195
- return s != null && s.many_collection ? s.many_collection : null;
196
- }), We = xe({
197
- queries: p.map((e, r) => {
198
- const a = re[r];
199
- return !a || e.midFields.length === 0 ? {
200
- queryKey: ["noop-inter", r],
198
+ const i = Ze(q, m, e);
199
+ return i != null && i.many_collection ? i.many_collection : null;
200
+ }), lt = qe({
201
+ queries: we.map((e, a) => {
202
+ const r = Ue[a];
203
+ return !r || e.midFields.length === 0 ? {
204
+ queryKey: ["noop-inter", a],
201
205
  queryFn: async () => null,
202
206
  enabled: !1
203
207
  } : {
204
- queryKey: ["collection-meta", a],
205
- queryFn: () => c.request(E(`/collections/${a}`)).then((i) => i.data)
208
+ queryKey: be.collectionMeta(r),
209
+ queryFn: () => o.request(K(`/collections/${r}`)).then((n) => n.data)
206
210
  };
207
211
  })
208
- }), oe = p.map((e, r) => {
209
- var v;
210
- const a = re[r];
211
- if (!a) return null;
212
+ }), pe = we.map((e, a) => {
213
+ var g;
214
+ const r = Ue[a];
215
+ if (!r) return null;
212
216
  if (e.midFields.length === 0)
213
- return { relatedCollection: a, subField: e.leafField };
214
- const i = (v = We[r]) == null ? void 0 : v.data;
215
- if (!i) return null;
216
- let s = a;
217
- const o = i.relations ?? [];
218
- for (const n of e.midFields) {
219
- const C = ge(o, s, n) ?? o.find(
220
- (g) => g.many_collection === s && g.many_field === n && g.one_collection
217
+ return { relatedCollection: r, subField: e.leafField };
218
+ const n = (g = lt[a]) == null ? void 0 : g.data;
219
+ if (!n) return null;
220
+ let i = r;
221
+ const d = n.relations ?? [];
222
+ for (const s of e.midFields) {
223
+ const k = Ce(d, i, s) ?? d.find(
224
+ (h) => h.many_collection === i && h.many_field === s && h.one_collection
221
225
  ) ?? null;
222
- if (!C) return null;
223
- s = C.one_collection ?? s;
226
+ if (!k) return null;
227
+ i = k.one_collection ?? i;
224
228
  }
225
- return { relatedCollection: s, subField: e.leafField };
226
- }), [T, Ge] = K({}), [He, Xe] = K({}), Je = (e) => (e.cascade ?? []).map((r) => {
227
- const a = h.find((i) => i.field === r.parent_field);
228
- return a ? `${r.parent_field}=${T[a.id] ?? ""}` : "";
229
- }).join("&"), ae = xe({
230
- queries: h.map((e, r) => {
231
- const a = oe[r], i = He[e.id] ?? "";
232
- if (a != null && a.relatedCollection) {
233
- const s = Je(e);
229
+ return { relatedCollection: i, subField: e.leafField };
230
+ }), [P, it] = T({}), [ot, dt] = T({}), ct = (e) => (e.cascade ?? []).map((a) => {
231
+ const r = y.find((n) => n.field === a.parent_field);
232
+ return r ? `${a.parent_field}=${P[r.id] ?? ""}` : "";
233
+ }).join("&"), oe = qe({
234
+ queries: y.map((e, a) => {
235
+ const r = pe[a], n = ot[e.id] ?? "";
236
+ if (r != null && r.relatedCollection) {
237
+ const i = ct(e);
234
238
  return {
235
- queryKey: ["items-picker", a.relatedCollection, i, s],
239
+ queryKey: ["items-picker", r.relatedCollection, n, i],
236
240
  queryFn: async () => {
237
- const o = [];
238
- for (const v of e.cascade ?? []) {
239
- const n = h.findIndex((w) => w.field === v.parent_field);
240
- if (n < 0) continue;
241
- const C = T[h[n].id];
242
- if (!C) continue;
243
- const g = oe[n];
244
- let O = C;
245
- if (g != null && g.relatedCollection && g.subField) {
246
- const w = await c.request(
247
- E(`/items/${g.relatedCollection}`, {
241
+ const d = [];
242
+ for (const g of e.cascade ?? []) {
243
+ const s = y.findIndex((I) => I.field === g.parent_field);
244
+ if (s < 0) continue;
245
+ const k = P[y[s].id];
246
+ if (!k) continue;
247
+ const h = pe[s];
248
+ let S = k;
249
+ if (h != null && h.relatedCollection && h.subField) {
250
+ const I = await o.request(
251
+ K(`/items/${h.relatedCollection}`, {
248
252
  limit: 1,
249
253
  fields: "id",
250
- filter: JSON.stringify({ [g.subField]: { _eq: C } })
254
+ filter: JSON.stringify({ [h.subField]: { _eq: k } })
251
255
  })
252
- ).then((ce) => ce.data).catch(() => []);
253
- if (w.length === 0) continue;
254
- O = w[0].id;
256
+ ).then((D) => D.data).catch(() => []);
257
+ if (I.length === 0) continue;
258
+ S = I[0].id;
255
259
  }
256
- o.push(mt(v.filter, v.via_many, O));
260
+ d.push(Ot(g.filter, g.via_many, S));
257
261
  }
258
- return c.request(
259
- E(`/items/${a.relatedCollection}`, {
262
+ return o.request(
263
+ K(`/items/${r.relatedCollection}`, {
260
264
  limit: 100,
261
- ...i ? { search: i } : {},
262
- ...o.length > 0 ? { filter: JSON.stringify({ _and: o }) } : {}
265
+ ...n ? { search: n } : {},
266
+ ...d.length > 0 ? { filter: JSON.stringify({ _and: d }) } : {}
263
267
  })
264
- ).then((v) => v.data);
268
+ ).then((g) => g.data);
265
269
  }
266
270
  };
267
271
  }
268
272
  return {
269
- queryKey: ["noop-items", r],
273
+ queryKey: ["noop-items", a],
270
274
  queryFn: async () => [],
271
275
  enabled: !1
272
276
  };
273
277
  })
274
- }), Ye = xe({
275
- queries: h.map((e, r) => {
276
- const a = oe[r];
277
- return !(a != null && a.relatedCollection) || a.subField ? {
278
+ }), ut = qe({
279
+ queries: y.map((e, a) => {
280
+ const r = pe[a];
281
+ return !(r != null && r.relatedCollection) || r.subField ? {
278
282
  queryKey: ["noop-meta", e.id],
279
283
  queryFn: async () => null,
280
284
  enabled: !1
281
285
  } : {
282
- queryKey: ["collection-meta", a.relatedCollection],
283
- queryFn: () => c.request(E(`/collections/${a.relatedCollection}`)).then((i) => i.data)
286
+ queryKey: be.collectionMeta(r.relatedCollection),
287
+ queryFn: () => o.request(K(`/collections/${r.relatedCollection}`)).then((n) => n.data)
284
288
  };
285
289
  })
286
- }), { data: R } = D({
287
- queryKey: ["items-picker", X],
288
- queryFn: () => c.request(
289
- E(`/items/${X}`, { limit: 500 })
290
+ }), { data: X } = V({
291
+ queryKey: ["items-picker", Ne],
292
+ queryFn: () => o.request(
293
+ K(`/items/${Ne}`, { limit: 500 })
290
294
  ).then((e) => e.data),
291
- enabled: !!X
292
- }), { data: Y } = D({
293
- queryKey: ["collection-meta", U],
294
- queryFn: () => c.request(E(`/collections/${U}`)).then((e) => e.data),
295
- enabled: !!U && !u
296
- }), [Q, be] = K(
295
+ enabled: !!Ne
296
+ }), { data: ee } = V({
297
+ queryKey: be.collectionMeta(p),
298
+ queryFn: () => o.request(K(`/collections/${p}`)).then((e) => e.data),
299
+ enabled: !!p && !ae
300
+ }), [L, ke] = T(
297
301
  null
298
302
  );
299
- fe(() => {
300
- if (!Q) return;
301
- const e = (r) => {
302
- const a = r.target;
303
- a && (a.closest("[data-omx-editor]") || a.closest("[data-omx-overlay]") || a.closest("[data-radix-popper-content-wrapper]") || a.closest("[data-nvr-combobox-panel]") || a.closest('[role="dialog"]') || be(null));
303
+ ve(() => {
304
+ if (!L) return;
305
+ const e = (a) => {
306
+ const r = a.target;
307
+ r && (r.closest("[data-omx-editor]") || r.closest("[data-omx-overlay]") || r.closest("[data-radix-popper-content-wrapper]") || r.closest("[data-nvr-combobox-panel]") || r.closest('[role="dialog"]') || ke(null));
304
308
  };
305
309
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
306
- }, [Q]);
307
- const Ie = ve(() => {
308
- if (!d || !_) return [];
310
+ }, [L]);
311
+ const Ae = de(() => {
312
+ if (!c || !x) return [];
309
313
  const e = /* @__PURE__ */ new Map();
310
- for (const r of Object.values(_))
311
- for (const a of r)
312
- for (const i of a.filters ?? [])
313
- i.field === d.field && i.op === "eq" && !e.has(String(i.value)) && e.set(String(i.value), String(i.value));
314
- return [...e.entries()].map(([r, a]) => ({ value: r, label: a }));
315
- }, [d, _]), je = ve(() => {
316
- const e = [], r = (i) => {
317
- i.value !== "" && !e.some((s) => s.value === i.value) && e.push(i);
314
+ for (const a of Object.values(x))
315
+ for (const r of a)
316
+ for (const n of r.filters ?? [])
317
+ n.field === c.field && n.op === "eq" && !e.has(String(n.value)) && e.set(String(n.value), String(n.value));
318
+ return [...e.entries()].map(([a, r]) => ({ value: a, label: r }));
319
+ }, [c, x]), De = de(() => {
320
+ const e = [], a = (n) => {
321
+ n.value !== "" && !e.some((i) => i.value === n.value) && e.push(n);
318
322
  };
319
- if (R)
320
- if (J) {
321
- const i = [
322
- ...new Set(R.map((s) => String(s[J] ?? "")).filter(Boolean))
323
+ if (X)
324
+ if (me) {
325
+ const n = [
326
+ ...new Set(X.map((i) => String(i[me] ?? "")).filter(Boolean))
323
327
  ];
324
- i.sort((s, o) => s.localeCompare(o));
325
- for (const s of i) r({ value: s, label: s });
328
+ n.sort((i, d) => i.localeCompare(d));
329
+ for (const i of n) a({ value: i, label: i });
326
330
  } else {
327
- const i = (Y == null ? void 0 : Y.display_template) ?? null;
328
- for (const s of R)
329
- r({ value: String(s.id), label: ye(i, s) });
331
+ const n = (ee == null ? void 0 : ee.display_template) ?? null;
332
+ for (const i of X)
333
+ a({ value: String(i.id), label: $e(n, i) });
330
334
  }
331
- for (const i of Ie) r(i);
332
- if (J || !U || !R) return e;
333
- const a = (Y == null ? void 0 : Y.display_template) ?? null;
334
- return e.map((i) => {
335
- const s = R.find((o) => String(o.id) === i.value);
336
- return s ? { value: i.value, label: ye(a, s) } : i;
335
+ for (const n of Ae) a(n);
336
+ if (me || !p || !X) return e;
337
+ const r = (ee == null ? void 0 : ee.display_template) ?? null;
338
+ return e.map((n) => {
339
+ const i = X.find((d) => String(d.id) === n.value);
340
+ return i ? { value: n.value, label: $e(r, i) } : n;
337
341
  });
338
- }, [Ie, J, U, R, Y]);
339
- function ne(e, r) {
340
- if (!d || !_) return { group: null, isInherited: !1 };
341
- const a = _[e] ?? [], i = { [d.field]: r };
342
- for (const g of h)
343
- T[g.id] && (i[g.field] = T[g.id]);
344
- const s = a.filter((g) => {
345
- const O = g.filters ?? [];
346
- return O.some(
347
- (w) => w.field === d.field && w.op === "eq" && String(w.value) === r
348
- ) ? O.every(
349
- (w) => w.op === "eq" && i[w.field] !== void 0 && String(i[w.field]) === String(w.value)
342
+ }, [Ae, me, p, X, ee]);
343
+ function se(e, a) {
344
+ if (!c || !x) return { group: null, isInherited: !1 };
345
+ const r = x[e] ?? [], n = { [c.field]: a };
346
+ for (const h of y)
347
+ P[h.id] && (n[h.field] = P[h.id]);
348
+ const i = r.filter((h) => {
349
+ const S = h.filters ?? [];
350
+ return S.some(
351
+ (I) => I.field === c.field && I.op === "eq" && String(I.value) === a
352
+ ) ? S.every(
353
+ (I) => I.op === "eq" && n[I.field] !== void 0 && String(n[I.field]) === String(I.value)
350
354
  ) : !1;
351
355
  });
352
- if (s.length === 0) return { group: null, isInherited: !1 };
353
- const v = [...s].sort((g, O) => {
354
- const w = (O.filters ?? []).length - (g.filters ?? []).length;
355
- return w !== 0 ? w : (g.priority ?? 0) - (O.priority ?? 0);
356
- })[0], n = h.filter((g) => !g.required && T[g.id]), C = n.length > 0 && !n.every(
357
- (g) => {
358
- var O;
359
- return (O = v.filters) == null ? void 0 : O.some((w) => w.field === g.field && String(w.value) === T[g.id]);
356
+ if (i.length === 0) return { group: null, isInherited: !1 };
357
+ const g = [...i].sort((h, S) => {
358
+ const I = (S.filters ?? []).length - (h.filters ?? []).length;
359
+ return I !== 0 ? I : (h.priority ?? 0) - (S.priority ?? 0);
360
+ })[0], s = y.filter((h) => !h.required && P[h.id]), k = s.length > 0 && !s.every(
361
+ (h) => {
362
+ var S;
363
+ return (S = g.filters) == null ? void 0 : S.some((I) => I.field === h.field && String(I.value) === P[h.id]);
360
364
  }
361
365
  );
362
- return { group: v, isInherited: C };
366
+ return { group: g, isInherited: k };
363
367
  }
364
- function Ze(e, r) {
365
- if (!d || !_) return !1;
366
- const a = _[e] ?? [], i = new Set(h.filter((s) => !s.required).map((s) => s.field));
367
- return i.size === 0 ? !1 : a.some(
368
- (s) => (s.filters ?? []).some((o) => o.field === d.field && String(o.value) === r) && (s.filters ?? []).some((o) => i.has(o.field))
368
+ function mt(e, a) {
369
+ if (!c || !x) return !1;
370
+ const r = x[e] ?? [], n = new Set(y.filter((i) => !i.required).map((i) => i.field));
371
+ return n.size === 0 ? !1 : r.some(
372
+ (i) => (i.filters ?? []).some((d) => d.field === c.field && String(d.value) === a) && (i.filters ?? []).some((d) => n.has(d.field))
369
373
  );
370
374
  }
371
- const de = Me(), z = () => de.invalidateQueries({ queryKey: ["pipeline-all-owner-groups", m] }), Oe = V({
375
+ const fe = tt(), z = () => fe.invalidateQueries({ queryKey: ["pipeline-all-owner-groups", f] }), U = "drafted", Me = (e, a) => {
376
+ const { group: r, isInherited: n } = se(e, a);
377
+ return !n && r ? r.id : null;
378
+ }, Le = G({
372
379
  mutationFn: async ({
373
380
  stateId: e,
374
- rowValue: r,
375
- userId: a
381
+ rowValue: a,
382
+ userId: r,
383
+ user: n
376
384
  }) => {
377
- const { group: i, isInherited: s } = ne(e, r);
378
- let o = s ? null : i;
379
- if (!o) {
380
- const v = ae.flatMap(
381
- (w) => w.data ?? []
382
- ), n = {
383
- field: (d == null ? void 0 : d.field) ?? "",
385
+ if (w) {
386
+ const s = Me(e, a), k = J(e, a), h = n ? {
387
+ id: String(n.id),
388
+ first_name: n.first_name ?? null,
389
+ last_name: n.last_name ?? null,
390
+ email: n.email
391
+ } : { id: r, first_name: null, last_name: null, email: r };
392
+ return C((S) => S && wt(S, { stateId: e, groupId: s, filters: k, user: h })), U;
393
+ }
394
+ const { group: i, isInherited: d } = se(e, a);
395
+ let g = d ? null : i;
396
+ if (!g) {
397
+ const s = oe.flatMap(
398
+ (D) => D.data ?? []
399
+ ), k = {
400
+ field: (c == null ? void 0 : c.field) ?? "",
384
401
  op: "eq",
385
- value: r,
386
- id_value: d ? ee(d, r, R, void 0) : void 0
387
- }, C = h.filter((w) => T[w.id]).map((w) => ({
388
- field: w.field,
402
+ value: a,
403
+ id_value: c ? le(c, a, X, void 0) : void 0
404
+ }, h = y.filter((D) => P[D.id]).map((D) => ({
405
+ field: D.field,
389
406
  op: "eq",
390
- value: T[w.id],
391
- id_value: ee(w, T[w.id], void 0, v)
392
- })), g = [n, ...C];
393
- o = (await c.request(
394
- M(`/pipelines/states/${e}/owner-groups`, {
395
- filters: g,
407
+ value: P[D.id],
408
+ id_value: le(D, P[D.id], void 0, s)
409
+ })), S = [k, ...h];
410
+ g = (await o.request(
411
+ A(`/pipelines/states/${e}/owner-groups`, {
412
+ filters: S,
396
413
  is_default: !1,
397
414
  sort: 0,
398
415
  priority: 0
399
416
  })
400
417
  )).data;
401
418
  }
402
- return c.request(M(`/pipelines/owner-groups/${o.id}/users`, { user: a }));
419
+ return o.request(A(`/pipelines/owner-groups/${g.id}/users`, { user: r }));
403
420
  },
404
- onSuccess: () => {
405
- z(), P.success("Owner added");
421
+ onSuccess: (e) => {
422
+ e !== U && (z(), O.success("Owner added"));
406
423
  },
407
- onError: () => P.error("Failed to add owner")
408
- }), le = (e, r) => {
409
- const a = ae.flatMap(
410
- (o) => o.data ?? []
411
- ), i = {
412
- field: (d == null ? void 0 : d.field) ?? "",
424
+ onError: () => O.error("Failed to add owner")
425
+ }), J = (e, a) => {
426
+ const r = oe.flatMap(
427
+ (d) => d.data ?? []
428
+ ), n = {
429
+ field: (c == null ? void 0 : c.field) ?? "",
413
430
  op: "eq",
414
- value: r,
415
- id_value: d ? ee(d, r, R, void 0) : void 0
416
- }, s = h.filter((o) => T[o.id]).map((o) => ({
417
- field: o.field,
431
+ value: a,
432
+ id_value: c ? le(c, a, X, void 0) : void 0
433
+ }, i = y.filter((d) => P[d.id]).map((d) => ({
434
+ field: d.field,
418
435
  op: "eq",
419
- value: T[o.id],
420
- id_value: ee(o, T[o.id], void 0, a)
436
+ value: P[d.id],
437
+ id_value: le(d, P[d.id], void 0, r)
421
438
  }));
422
- return [i, ...s];
423
- }, { data: et } = D({
439
+ return [n, ...i];
440
+ }, { data: Qe } = V({
424
441
  queryKey: ["user-groups-teams"],
425
- queryFn: () => c.request(E("/user-groups")).then((e) => e.data),
442
+ queryFn: () => o.request(K("/user-groups")).then((e) => e.data),
426
443
  staleTime: 6e4
427
- }), Ke = V({
444
+ }), Re = G({
428
445
  mutationFn: async ({
429
446
  stateId: e,
430
- rowValue: r,
431
- teamId: a
447
+ rowValue: a,
448
+ teamId: r
432
449
  }) => {
433
- const { group: i, isInherited: s } = ne(e, r);
434
- let o = s ? null : i;
435
- return o || (o = (await c.request(
436
- M(`/pipelines/states/${e}/owner-groups`, {
437
- filters: le(e, r),
450
+ if (w) {
451
+ const g = (Qe ?? []).find((h) => h.id === r) ?? {
452
+ id: r,
453
+ name: `Team ${r}`,
454
+ slug: "",
455
+ member_count: 0
456
+ }, s = Me(e, a), k = J(e, a);
457
+ return C((h) => h && kt(h, { stateId: e, groupId: s, filters: k, team: g })), U;
458
+ }
459
+ const { group: n, isInherited: i } = se(e, a);
460
+ let d = i ? null : n;
461
+ return d || (d = (await o.request(
462
+ A(`/pipelines/states/${e}/owner-groups`, {
463
+ filters: J(e, a),
438
464
  is_default: !1,
439
465
  sort: 0,
440
466
  priority: 0
441
467
  })
442
- )).data), c.request(M(`/pipelines/owner-groups/${o.id}/teams`, { team_id: a }));
468
+ )).data), o.request(A(`/pipelines/owner-groups/${d.id}/teams`, { team_id: r }));
443
469
  },
444
- onSuccess: () => {
445
- z(), P.success("Team assigned");
470
+ onSuccess: (e) => {
471
+ e !== U && (z(), O.success("Team assigned"));
446
472
  },
447
- onError: () => P.error("Failed to assign team")
448
- }), tt = V({
449
- mutationFn: ({ groupId: e, teamId: r }) => c.request(Ne(`/pipelines/owner-groups/${e}/teams/${r}`)),
450
- onSuccess: () => {
451
- z(), P.success("Team unassigned");
473
+ onError: () => O.error("Failed to assign team")
474
+ }), pt = G({
475
+ mutationFn: async ({ groupId: e, teamId: a }) => w ? (C((r) => r && _t(r, e, a)), U) : o.request(ce(`/pipelines/owner-groups/${e}/teams/${a}`)),
476
+ onSuccess: (e) => {
477
+ e !== U && (z(), O.success("Team unassigned"));
452
478
  },
453
- onError: () => P.error("Failed to unassign team")
454
- }), [Te, he] = K(null), Pe = V({
479
+ onError: () => O.error("Failed to unassign team")
480
+ }), [ze, _e] = T(null), Ge = G({
455
481
  mutationFn: async ({
456
482
  stateId: e,
457
- rowValue: r,
458
- name: a
483
+ rowValue: a,
484
+ name: r
459
485
  }) => {
460
- const i = await c.request(
461
- M("/user-groups", { name: a })
462
- ), { group: s, isInherited: o } = ne(e, r);
463
- let v = o ? null : s;
464
- return v || (v = (await c.request(
465
- M(`/pipelines/states/${e}/owner-groups`, {
466
- filters: le(e, r),
486
+ const n = await o.request(
487
+ A("/user-groups", { name: r })
488
+ ), { group: i, isInherited: d } = se(e, a);
489
+ let g = d ? null : i;
490
+ return g || (g = (await o.request(
491
+ A(`/pipelines/states/${e}/owner-groups`, {
492
+ filters: J(e, a),
467
493
  is_default: !1,
468
494
  sort: 0,
469
495
  priority: 0
470
496
  })
471
- )).data), await c.request(
472
- M(`/pipelines/owner-groups/${v.id}/teams`, { team_id: i.data.id })
473
- ), i.data;
497
+ )).data), await o.request(
498
+ A(`/pipelines/owner-groups/${g.id}/teams`, { team_id: n.data.id })
499
+ ), n.data;
474
500
  },
475
501
  onSuccess: (e) => {
476
- z(), de.invalidateQueries({ queryKey: ["user-groups-teams"] }), P.success(`Team "${e.name}" created and assigned — add its members`), he({ id: e.id, name: e.name });
502
+ z(), fe.invalidateQueries({ queryKey: ["user-groups-teams"] }), O.success(`Team "${e.name}" created and assigned — add its members`), _e({ id: e.id, name: e.name });
477
503
  },
478
504
  onError: (e) => {
479
- var r;
480
- return P.error(
481
- ((r = e == null ? void 0 : e.response) == null ? void 0 : r.error) ?? "Failed to create team"
505
+ var a;
506
+ return O.error(
507
+ ((a = e == null ? void 0 : e.response) == null ? void 0 : a.error) ?? "Failed to create team"
482
508
  );
483
509
  }
484
- }), Be = V({
485
- mutationFn: async ({ stateId: e, rowValue: r }) => {
486
- const a = ae.flatMap(
487
- (v) => v.data ?? []
488
- ), i = {
489
- field: (d == null ? void 0 : d.field) ?? "",
510
+ }), Ve = G({
511
+ mutationFn: async ({ stateId: e, rowValue: a }) => {
512
+ if (w) {
513
+ const g = J(e, a);
514
+ return C((s) => s && qt(s, e, g)), U;
515
+ }
516
+ const r = oe.flatMap(
517
+ (g) => g.data ?? []
518
+ ), n = {
519
+ field: (c == null ? void 0 : c.field) ?? "",
490
520
  op: "eq",
491
- value: r,
492
- id_value: ee(d, r, R, void 0)
493
- }, s = h.filter((v) => T[v.id]).map((v) => ({
494
- field: v.field,
521
+ value: a,
522
+ id_value: le(c, a, X, void 0)
523
+ }, i = y.filter((g) => P[g.id]).map((g) => ({
524
+ field: g.field,
495
525
  op: "eq",
496
- value: T[v.id],
497
- id_value: ee(v, T[v.id], void 0, a)
498
- })), o = [i, ...s];
499
- return c.request(
500
- M(`/pipelines/states/${e}/owner-groups`, {
501
- filters: o,
526
+ value: P[g.id],
527
+ id_value: le(g, P[g.id], void 0, r)
528
+ })), d = [n, ...i];
529
+ return o.request(
530
+ A(`/pipelines/states/${e}/owner-groups`, {
531
+ filters: d,
502
532
  is_default: !1,
503
533
  sort: 0,
504
534
  priority: 0
505
535
  })
506
536
  );
507
537
  },
508
- onSuccess: () => {
509
- z(), P.success("Override created");
538
+ onSuccess: (e) => {
539
+ e !== U && (z(), O.success("Override created"));
540
+ },
541
+ onError: () => O.error("Failed to create override")
542
+ }), ft = G({
543
+ mutationFn: async ({ groupId: e, priority: a }) => w ? (C((r) => r && Ye(r, e, { priority: a })), U) : o.request(Fe(`/pipelines/owner-groups/${e}`, { priority: a })),
544
+ onSuccess: (e) => {
545
+ e !== U && z();
546
+ },
547
+ onError: () => O.error("Failed to update priority")
548
+ }), ht = G({
549
+ mutationFn: async ({ groupId: e, maxWip: a }) => w ? (C((r) => r && Ye(r, e, { max_wip: a })), U) : o.request(Fe(`/pipelines/owner-groups/${e}`, { max_wip: a })),
550
+ onSuccess: (e) => {
551
+ e !== U && z();
552
+ },
553
+ onError: () => O.error("Failed to update WIP limit")
554
+ }), bt = G({
555
+ mutationFn: async (e) => w ? (C((a) => a && Ft(a, e)), U) : o.request(ce(`/pipelines/owner-group-users/${e}`)),
556
+ onSuccess: (e) => {
557
+ e !== U && (z(), O.success("Owner removed"));
558
+ },
559
+ onError: () => O.error("Failed to remove owner")
560
+ }), he = G({
561
+ mutationFn: async (e) => {
562
+ const a = /* @__PURE__ */ new Map(), r = (n) => a.get(n) ?? n;
563
+ for (const n of e)
564
+ if (n.kind === "create") {
565
+ const i = await o.request(
566
+ A(`/pipelines/states/${n.stateId}/owner-groups`, {
567
+ filters: n.filters ?? [],
568
+ is_default: !1,
569
+ sort: 0,
570
+ priority: n.priority
571
+ })
572
+ );
573
+ a.set(n.draftId, i.data.id);
574
+ } else n.kind === "patch" ? await o.request(Fe(`/pipelines/owner-groups/${r(n.group)}`, n.body)) : n.kind === "add-user" ? await o.request(
575
+ A(`/pipelines/owner-groups/${r(n.group)}/users`, { user: n.user })
576
+ ) : n.kind === "remove-user" ? await o.request(ce(`/pipelines/owner-group-users/${n.linkId}`)) : n.kind === "add-team" ? await o.request(
577
+ A(`/pipelines/owner-groups/${r(n.group)}/teams`, { team_id: n.team })
578
+ ) : await o.request(ce(`/pipelines/owner-groups/${r(n.group)}/teams/${n.team}`));
579
+ return e.length;
510
580
  },
511
- onError: () => P.error("Failed to create override")
512
- }), rt = V({
513
- mutationFn: ({ groupId: e, priority: r }) => c.request(Ae(`/pipelines/owner-groups/${e}`, { priority: r })),
514
- onSuccess: () => z(),
515
- onError: () => P.error("Failed to update priority")
516
- }), at = V({
517
- mutationFn: ({ groupId: e, maxWip: r }) => c.request(Ae(`/pipelines/owner-groups/${e}`, { max_wip: r })),
518
- onSuccess: () => z(),
519
- onError: () => P.error("Failed to update WIP limit")
520
- }), nt = V({
521
- mutationFn: (e) => c.request(Ne(`/pipelines/owner-group-users/${e}`)),
522
- onSuccess: () => {
523
- z(), P.success("Owner removed");
581
+ onSuccess: (e) => {
582
+ C(null), z(), O.success(`Draft saved — ${e} change${e === 1 ? "" : "s"} written`);
524
583
  },
525
- onError: () => P.error("Failed to remove owner")
526
- }), G = h.filter((e) => e.required && !T[e.id]);
527
- return d ? F ? /* @__PURE__ */ l("div", { className: "flex items-center gap-2 py-4 text-[13px] text-slate-400", children: [
584
+ onError: (e) => {
585
+ z(), yt(e, "Could not save the draft");
586
+ }
587
+ }), We = de(() => Ct(_, w), [_, w]), Y = y.filter((e) => e.required && !P[e.id]);
588
+ return c ? $ ? /* @__PURE__ */ l("div", { className: "flex items-center gap-2 py-4 text-[13px] text-slate-400", children: [
528
589
  /* @__PURE__ */ t(te, { className: "h-4 w-4 animate-spin" }),
529
590
  "Loading matrix…"
530
591
  ] }) : /* @__PURE__ */ l("div", { className: "space-y-4", children: [
531
- Te && /* @__PURE__ */ t(
532
- xt,
592
+ ze && /* @__PURE__ */ t(
593
+ Ut,
533
594
  {
534
- team: Te,
595
+ team: ze,
535
596
  onClose: () => {
536
- he(null), z(), de.invalidateQueries({ queryKey: ["user-groups-teams"] });
597
+ _e(null), z(), fe.invalidateQueries({ queryKey: ["user-groups-teams"] });
537
598
  }
538
599
  }
539
600
  ),
540
- q && /* @__PURE__ */ t(
541
- ht,
601
+ F && /* @__PURE__ */ t(
602
+ Bt,
542
603
  {
543
- templateId: m,
604
+ templateId: f,
544
605
  groupsMap: _ ?? {},
545
- states: f,
546
- onClose: () => $(!1),
606
+ states: b,
607
+ onClose: () => j(!1),
547
608
  onDone: () => {
548
- $(!1), de.invalidateQueries({ queryKey: ["pipeline-all-owner-groups", m] });
609
+ j(!1), fe.invalidateQueries({ queryKey: ["pipeline-all-owner-groups", f] });
549
610
  }
550
611
  }
551
612
  ),
552
- /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-4 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 dark:border-border dark:bg-muted/40", children: [
553
- h.length > 0 && /* @__PURE__ */ l(we, { children: [
613
+ (y.length > 0 || !w) && /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-4 rounded-lg border border-slate-200 bg-slate-50 px-4 py-2.5 dark:border-border dark:bg-muted/40", children: [
614
+ y.length > 0 && /* @__PURE__ */ l(je, { children: [
554
615
  /* @__PURE__ */ t("span", { className: "text-[11px] font-medium text-slate-400 uppercase tracking-wide shrink-0 dark:text-muted-foreground", children: "Filter" }),
555
- h.map((e, r) => {
556
- var v, n, C;
557
- const a = oe[r], i = ((v = ae[r]) == null ? void 0 : v.data) ?? [], s = (n = Ye[r]) == null ? void 0 : n.data, o = a != null && a.relatedCollection ? i.map((g) => {
558
- if (a.subField) {
559
- const O = String(g[a.subField] ?? "");
560
- return { value: O, label: O };
616
+ y.map((e, a) => {
617
+ var g, s, k;
618
+ const r = pe[a], n = ((g = oe[a]) == null ? void 0 : g.data) ?? [], i = (s = ut[a]) == null ? void 0 : s.data, d = r != null && r.relatedCollection ? n.map((h) => {
619
+ if (r.subField) {
620
+ const S = String(h[r.subField] ?? "");
621
+ return { value: S, label: S };
561
622
  }
562
623
  return {
563
- value: String(g.id),
564
- label: ye((s == null ? void 0 : s.display_template) ?? null, g)
624
+ value: String(h.id),
625
+ label: $e((i == null ? void 0 : i.display_template) ?? null, h)
565
626
  };
566
627
  }) : [];
567
628
  return /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
568
629
  /* @__PURE__ */ t("span", { className: "text-[12px] font-medium text-slate-600", children: e.label }),
569
630
  /* @__PURE__ */ t(
570
- ut,
631
+ Tt,
571
632
  {
572
633
  label: e.label,
573
- value: T[e.id] ?? "",
574
- options: o,
575
- onChange: (g) => Ge((O) => {
576
- const w = { ...O, [e.id]: g };
577
- for (const ce of h)
578
- (ce.cascade ?? []).some((lt) => lt.parent_field === e.field) && (w[ce.id] = "");
579
- return w;
634
+ value: P[e.id] ?? "",
635
+ options: d,
636
+ onChange: (h) => it((S) => {
637
+ const I = { ...S, [e.id]: h };
638
+ for (const D of y)
639
+ (D.cascade ?? []).some((xt) => xt.parent_field === e.field) && (I[D.id] = "");
640
+ return I;
580
641
  }),
581
- onSearch: (g) => Xe((O) => ({ ...O, [e.id]: g })),
582
- loading: (C = ae[r]) == null ? void 0 : C.isLoading
642
+ onSearch: (h) => dt((S) => ({ ...S, [e.id]: h })),
643
+ loading: (k = oe[a]) == null ? void 0 : k.isLoading
583
644
  }
584
645
  )
585
646
  ] }, e.id);
586
647
  })
587
648
  ] }),
588
- /* @__PURE__ */ t(
589
- "button",
590
- {
591
- type: "button",
592
- onClick: () => $((e) => !e),
593
- className: "ml-auto shrink-0 rounded-md border border-slate-300 bg-white px-2.5 py-1 text-[12px] font-medium text-slate-600 transition-colors hover:border-nvr-cyan/50 hover:text-nvr-cyan-dark dark:border-border dark:bg-card dark:text-slate-300 dark:hover:text-nvr-cyan",
594
- children: "+ Add a user to many cells…"
595
- }
596
- )
649
+ /* @__PURE__ */ l("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: [
650
+ !w && /* @__PURE__ */ t(
651
+ "button",
652
+ {
653
+ type: "button",
654
+ onClick: () => j((e) => !e),
655
+ className: "shrink-0 rounded-md border border-slate-300 bg-white px-2.5 py-1 text-[12px] font-medium text-slate-600 transition-colors hover:border-nvr-cyan/50 hover:text-nvr-cyan-dark dark:border-border dark:bg-card dark:text-slate-300 dark:hover:text-nvr-cyan",
656
+ children: "+ Add a user to many cells…"
657
+ }
658
+ ),
659
+ !w && /* @__PURE__ */ l(
660
+ "button",
661
+ {
662
+ type: "button",
663
+ "data-tip": "Edit the matrix without saving, and try the changes on a record first",
664
+ onClick: () => {
665
+ j(!1), C($t(_));
666
+ },
667
+ className: "inline-flex shrink-0 items-center gap-1.5 rounded-md border border-violet-300 bg-white px-2.5 py-1 text-[12px] font-medium text-violet-700 transition-colors hover:bg-violet-50 dark:border-violet-500/40 dark:bg-card dark:text-violet-300 dark:hover:bg-violet-500/10",
668
+ children: [
669
+ /* @__PURE__ */ t(Xe, { className: "h-3.5 w-3.5" }),
670
+ "Draft changes"
671
+ ]
672
+ }
673
+ )
674
+ ] })
597
675
  ] }),
598
- G.length > 0 && /* @__PURE__ */ l("div", { className: "rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400", children: [
676
+ w && /* @__PURE__ */ l(
677
+ "div",
678
+ {
679
+ "data-owner-draft-bar": !0,
680
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-violet-300 bg-violet-50 px-4 py-2 text-[12px] text-violet-900 dark:border-violet-500/40 dark:bg-violet-500/10 dark:text-violet-200",
681
+ children: [
682
+ /* @__PURE__ */ t(Xe, { className: "h-3.5 w-3.5 shrink-0" }),
683
+ /* @__PURE__ */ t("span", { className: "font-semibold", children: "Draft mode" }),
684
+ /* @__PURE__ */ t("span", { className: "text-violet-800/80 dark:text-violet-200/80", children: E.length === 0 ? "Edit cells as usual — nothing is saved until you say so." : `${E.length} owner group${E.length === 1 ? "" : "s"} changed, not saved yet.` }),
685
+ /* @__PURE__ */ l("div", { className: "ml-auto flex items-center gap-2", children: [
686
+ /* @__PURE__ */ t(
687
+ Se,
688
+ {
689
+ size: "sm",
690
+ variant: "outline",
691
+ className: "h-7 text-[12px]",
692
+ disabled: he.isPending,
693
+ onClick: () => C(null),
694
+ children: E.length === 0 ? "Leave draft mode" : "Discard draft"
695
+ }
696
+ ),
697
+ /* @__PURE__ */ l(
698
+ Se,
699
+ {
700
+ size: "sm",
701
+ className: "h-7 bg-nvr-cyan text-[12px] text-white",
702
+ disabled: We.length === 0 || he.isPending,
703
+ onClick: () => he.mutate(We),
704
+ children: [
705
+ he.isPending && /* @__PURE__ */ t(te, { className: "mr-1 h-3 w-3 animate-spin" }),
706
+ "Save draft"
707
+ ]
708
+ }
709
+ )
710
+ ] })
711
+ ]
712
+ }
713
+ ),
714
+ /* @__PURE__ */ t(
715
+ vt,
716
+ {
717
+ templateId: f,
718
+ collections: [...new Set(v.map((e) => e.collection))],
719
+ draft: w ? E : null,
720
+ displayTemplates: { [m]: (u == null ? void 0 : u.display_template) ?? null }
721
+ }
722
+ ),
723
+ Y.length > 0 && /* @__PURE__ */ l("div", { className: "rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400", children: [
599
724
  /* @__PURE__ */ t("span", { className: "font-medium", children: "Select a value for " }),
600
- G.map((e, r) => /* @__PURE__ */ l("span", { children: [
725
+ Y.map((e, a) => /* @__PURE__ */ l("span", { children: [
601
726
  /* @__PURE__ */ t("span", { className: "font-semibold", children: e.label }),
602
- r < G.length - 2 ? ", " : r === G.length - 2 ? " and " : ""
727
+ a < Y.length - 2 ? ", " : a === Y.length - 2 ? " and " : ""
603
728
  ] }, e.id)),
604
729
  /* @__PURE__ */ t("span", { children: " before managing owners." })
605
730
  ] }),
606
731
  /* @__PURE__ */ t("div", { className: "overflow-x-auto rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ l("table", { className: "min-w-full border-collapse text-[12px]", children: [
607
732
  /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ l("tr", { className: "bg-slate-50", children: [
608
- /* @__PURE__ */ t("th", { className: "sticky left-0 z-10 bg-slate-50 dark:bg-muted border-b border-r border-slate-200 dark:border-border px-3 py-2 text-left text-[12px] font-semibold text-slate-700 dark:text-slate-200 min-w-[100px]", children: d.label }),
609
- f.map((e) => {
610
- const r = /^waiting on\s+/i.test(e.label), a = r ? e.label.replace(/^waiting on\s+/i, "") : e.label;
733
+ /* @__PURE__ */ t("th", { className: "sticky left-0 z-10 bg-slate-50 dark:bg-muted border-b border-r border-slate-200 dark:border-border px-3 py-2 text-left text-[12px] font-semibold text-slate-700 dark:text-slate-200 min-w-[100px]", children: c.label }),
734
+ b.map((e) => {
735
+ const a = /^waiting on\s+/i.test(e.label), r = a ? e.label.replace(/^waiting on\s+/i, "") : e.label;
611
736
  return /* @__PURE__ */ l(
612
737
  "th",
613
738
  {
614
739
  className: "min-w-[110px] border-b border-r border-slate-200 bg-slate-50 px-3 py-2 text-left align-bottom last:border-r-0 dark:border-border dark:bg-muted",
615
740
  children: [
616
- r && /* @__PURE__ */ t("span", { className: "block text-[9px] font-medium uppercase tracking-[0.06em] leading-tight text-slate-400", children: "Waiting on" }),
741
+ a && /* @__PURE__ */ t("span", { className: "block text-[9px] font-medium uppercase tracking-[0.06em] leading-tight text-slate-400", children: "Waiting on" }),
617
742
  /* @__PURE__ */ l("span", { className: "flex items-center gap-1.5", children: [
618
743
  /* @__PURE__ */ t(
619
744
  "span",
@@ -622,7 +747,7 @@ function Tt({ templateId: m, states: f, bindings: N }) {
622
747
  style: { backgroundColor: e.color ?? "#94a3b8" }
623
748
  }
624
749
  ),
625
- /* @__PURE__ */ t("span", { className: "whitespace-nowrap text-[11.5px] font-semibold leading-tight text-slate-700 dark:text-slate-200", children: a })
750
+ /* @__PURE__ */ t("span", { className: "whitespace-nowrap text-[11.5px] font-semibold leading-tight text-slate-700 dark:text-slate-200", children: r })
626
751
  ] })
627
752
  ]
628
753
  },
@@ -631,68 +756,68 @@ function Tt({ templateId: m, states: f, bindings: N }) {
631
756
  })
632
757
  ] }) }),
633
758
  /* @__PURE__ */ l("tbody", { children: [
634
- je.map((e) => /* @__PURE__ */ l(De, { children: [
759
+ De.map((e) => /* @__PURE__ */ l(rt, { children: [
635
760
  /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/50", children: [
636
761
  /* @__PURE__ */ t("td", { className: "sticky left-0 z-10 bg-white dark:bg-card border-b border-r border-slate-200 dark:border-border px-3 py-2 font-medium text-slate-700 dark:text-slate-200 text-[13px]", children: e.label }),
637
- f.map((r) => {
638
- const { group: a, isInherited: i } = ne(r.id, e.value), s = (a == null ? void 0 : a.users) ?? [], o = (Q == null ? void 0 : Q.stateId) === r.id && (Q == null ? void 0 : Q.rowValue) === e.value, v = !i && h.some((n) => !n.required) && h.every((n) => n.required || !T[n.id]) && Ze(r.id, e.value);
762
+ b.map((a) => {
763
+ const { group: r, isInherited: n } = se(a.id, e.value), i = (r == null ? void 0 : r.users) ?? [], d = (L == null ? void 0 : L.stateId) === a.id && (L == null ? void 0 : L.rowValue) === e.value, g = !n && y.some((s) => !s.required) && y.every((s) => s.required || !P[s.id]) && mt(a.id, e.value);
639
764
  return /* @__PURE__ */ t(
640
765
  "td",
641
766
  {
642
767
  className: `border-b border-r border-slate-200 bg-white px-2 py-1.5 last:border-r-0 transition-colors dark:border-border dark:bg-card ${// Locked (required filters unset): gate the INTERACTION,
643
768
  // not the contrast — the banner above explains why, and
644
769
  // an opacity fade made the whole grid illegible.
645
- G.length > 0 ? "cursor-not-allowed select-none" : "cursor-pointer hover:bg-nvr-cyan/5"} ${o ? "bg-nvr-cyan/5" : ""}`,
770
+ Y.length > 0 ? "cursor-not-allowed select-none" : "cursor-pointer hover:bg-nvr-cyan/5"} ${d ? "bg-nvr-cyan/5" : ""}`,
646
771
  onClick: () => {
647
- G.length > 0 || be(
648
- o ? null : { stateId: r.id, rowValue: e.value }
772
+ Y.length > 0 || ke(
773
+ d ? null : { stateId: a.id, rowValue: e.value }
649
774
  );
650
775
  },
651
- onKeyDown: (n) => {
652
- if (n.key === "Enter" || n.key === " ") {
653
- if (G.length > 0) return;
654
- be(
655
- o ? null : { stateId: r.id, rowValue: e.value }
776
+ onKeyDown: (s) => {
777
+ if (s.key === "Enter" || s.key === " ") {
778
+ if (Y.length > 0) return;
779
+ ke(
780
+ d ? null : { stateId: a.id, rowValue: e.value }
656
781
  );
657
782
  }
658
783
  },
659
- tabIndex: G.length > 0 ? -1 : 0,
784
+ tabIndex: Y.length > 0 ? -1 : 0,
660
785
  children: /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-1", children: [
661
- ((a == null ? void 0 : a.teams) ?? []).map((n) => /* @__PURE__ */ l(
786
+ ((r == null ? void 0 : r.teams) ?? []).map((s) => /* @__PURE__ */ l(
662
787
  "span",
663
788
  {
664
- "data-tip": `Team · ${n.member_count} member${n.member_count === 1 ? "" : "s"}`,
665
- className: `inline-flex h-6 items-center gap-1 rounded-full px-2 text-[10.5px] font-semibold ${i ? "bg-slate-100 text-slate-400" : "bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300"}`,
789
+ "data-tip": `Team · ${s.member_count} member${s.member_count === 1 ? "" : "s"}`,
790
+ className: `inline-flex h-6 items-center gap-1 rounded-full px-2 text-[10.5px] font-semibold ${n ? "bg-slate-100 text-slate-400" : "bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300"}`,
666
791
  children: [
667
- /* @__PURE__ */ t(ue, { className: "h-3 w-3" }),
668
- n.name
792
+ /* @__PURE__ */ t(xe, { className: "h-3 w-3" }),
793
+ s.name
669
794
  ]
670
795
  },
671
- `t${n.link_id}`
796
+ `t${s.link_id}`
672
797
  )),
673
- s.length === 0 && ((a == null ? void 0 : a.teams) ?? []).length === 0 ? /* @__PURE__ */ t("span", { className: "text-slate-400 text-[11px] dark:text-slate-500", children: "—" }) : s.slice(0, 4).map((n) => /* @__PURE__ */ t(
674
- qe,
798
+ i.length === 0 && ((r == null ? void 0 : r.teams) ?? []).length === 0 ? /* @__PURE__ */ t("span", { className: "text-slate-400 text-[11px] dark:text-slate-500", children: "—" }) : i.slice(0, 4).map((s) => /* @__PURE__ */ t(
799
+ Oe,
675
800
  {
676
- userId: n.user,
677
- className: `h-6 w-6 ${i ? "opacity-50" : ""}`,
678
- alt: [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email,
801
+ userId: s.user,
802
+ className: `h-6 w-6 ${n ? "opacity-50" : ""}`,
803
+ alt: [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email,
679
804
  fallback: /* @__PURE__ */ t(
680
805
  "span",
681
806
  {
682
- title: [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email,
683
- className: `inline-flex h-6 w-6 items-center justify-center rounded-full text-[10px] font-semibold ${i ? "bg-slate-100 text-slate-400" : "bg-nvr-cyan/10 text-nvr-cyan"}`,
684
- children: $e(n)
807
+ title: [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email,
808
+ className: `inline-flex h-6 w-6 items-center justify-center rounded-full text-[10px] font-semibold ${n ? "bg-slate-100 text-slate-400" : "bg-nvr-cyan/10 text-nvr-cyan"}`,
809
+ children: Be(s)
685
810
  }
686
811
  )
687
812
  },
688
- n.link_id
813
+ s.link_id
689
814
  )),
690
- s.length > 4 && /* @__PURE__ */ l("span", { className: "inline-flex h-6 items-center px-1 text-[10px] text-slate-400", children: [
815
+ i.length > 4 && /* @__PURE__ */ l("span", { className: "inline-flex h-6 items-center px-1 text-[10px] text-slate-400", children: [
691
816
  "+",
692
- s.length - 4
817
+ i.length - 4
693
818
  ] }),
694
- i && s.length > 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400 italic", children: "inherited" }),
695
- v && /* @__PURE__ */ t(
819
+ n && i.length > 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400 italic", children: "inherited" }),
820
+ g && /* @__PURE__ */ t(
696
821
  "span",
697
822
  {
698
823
  title: "Has context-specific overrides",
@@ -701,63 +826,63 @@ function Tt({ templateId: m, states: f, bindings: N }) {
701
826
  )
702
827
  ] })
703
828
  },
704
- r.id
829
+ a.id
705
830
  );
706
831
  })
707
832
  ] }),
708
- (Q == null ? void 0 : Q.rowValue) === e.value && /* @__PURE__ */ l("tr", { children: [
833
+ (L == null ? void 0 : L.rowValue) === e.value && /* @__PURE__ */ l("tr", { children: [
709
834
  /* @__PURE__ */ t("td", { className: "sticky left-0 z-10 bg-slate-50 dark:bg-muted border-b border-r border-slate-200 dark:border-border" }),
710
- f.map((r) => {
711
- if (Q.stateId !== r.id)
835
+ b.map((a) => {
836
+ if (L.stateId !== a.id)
712
837
  return /* @__PURE__ */ t(
713
838
  "td",
714
839
  {
715
840
  className: "border-b border-r border-slate-200 last:border-r-0 bg-slate-50/50"
716
841
  },
717
- r.id
842
+ a.id
718
843
  );
719
- const { group: a, isInherited: i } = ne(r.id, e.value), s = (a == null ? void 0 : a.users) ?? [], o = s.filter(
720
- (n) => n.is_out_of_office
721
- ).length, v = s.length > 0 && o === s.length ? "bg-amber-100/80 dark:bg-amber-500/15" : o > 0 ? "bg-amber-50/70 dark:bg-amber-500/8" : "bg-nvr-cyan/5";
844
+ const { group: r, isInherited: n } = se(a.id, e.value), i = (r == null ? void 0 : r.users) ?? [], d = i.filter(
845
+ (s) => s.is_out_of_office
846
+ ).length, g = i.length > 0 && d === i.length ? "bg-amber-100/80 dark:bg-amber-500/15" : d > 0 ? "bg-amber-50/70 dark:bg-amber-500/8" : "bg-nvr-cyan/5";
722
847
  return /* @__PURE__ */ t(
723
848
  "td",
724
849
  {
725
850
  "data-omx-editor": !0,
726
- "data-tip": o > 0 ? `${o}/${s.length} member(s) out of office` : void 0,
727
- className: `border-b border-r border-slate-200 px-3 py-2 last:border-r-0 ${v}`,
728
- onClick: (n) => n.stopPropagation(),
729
- onKeyDown: (n) => n.stopPropagation(),
730
- children: i ? /* @__PURE__ */ l("div", { className: "space-y-2 min-w-[200px]", children: [
851
+ "data-tip": d > 0 ? `${d}/${i.length} member(s) out of office` : void 0,
852
+ className: `border-b border-r border-slate-200 px-3 py-2 last:border-r-0 ${g}`,
853
+ onClick: (s) => s.stopPropagation(),
854
+ onKeyDown: (s) => s.stopPropagation(),
855
+ children: n ? /* @__PURE__ */ l("div", { className: "space-y-2 min-w-[200px]", children: [
731
856
  /* @__PURE__ */ t("div", { className: "rounded bg-amber-50 px-2 py-1 text-[11px] text-amber-700 border border-amber-200", children: "Inherited from base level" }),
732
- s.map((n) => /* @__PURE__ */ t(
857
+ i.map((s) => /* @__PURE__ */ t(
733
858
  "div",
734
859
  {
735
860
  className: "flex items-center gap-1.5 opacity-60",
736
- children: /* @__PURE__ */ t("span", { className: "flex-1 text-[12px] text-slate-600", children: [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email })
861
+ children: /* @__PURE__ */ t("span", { className: "flex-1 text-[12px] text-slate-600", children: [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email })
737
862
  },
738
- n.link_id
863
+ s.link_id
739
864
  )),
740
- s.length === 0 && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-400", children: "No owners at base level" }),
865
+ i.length === 0 && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-400", children: "No owners at base level" }),
741
866
  /* @__PURE__ */ l(
742
867
  "button",
743
868
  {
744
869
  type: "button",
745
- disabled: Be.isPending,
746
- onClick: () => Be.mutate({ stateId: r.id, rowValue: e.value }),
870
+ disabled: Ve.isPending,
871
+ onClick: () => Ve.mutate({ stateId: a.id, rowValue: e.value }),
747
872
  className: "flex w-full items-center justify-center gap-1 rounded border border-dashed border-slate-300 px-2 py-1.5 text-[12px] text-slate-500 hover:border-nvr-cyan/50 hover:text-nvr-cyan disabled:opacity-40",
748
873
  children: [
749
- /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
874
+ /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5" }),
750
875
  "Create override for this context"
751
876
  ]
752
877
  }
753
878
  )
754
879
  ] }) : /* @__PURE__ */ l("div", { className: "space-y-2 min-w-[200px]", children: [
755
- ((a == null ? void 0 : a.teams) ?? []).map((n) => {
756
- const C = Ve(
757
- n.scopes,
758
- le(r.id, e.value),
759
- I,
760
- k || null
880
+ ((r == null ? void 0 : r.teams) ?? []).map((s) => {
881
+ const k = at(
882
+ s.scopes,
883
+ J(a.id, e.value),
884
+ W,
885
+ m || null
761
886
  );
762
887
  return /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
763
888
  /* @__PURE__ */ l(
@@ -765,20 +890,20 @@ function Tt({ templateId: m, states: f, bindings: N }) {
765
890
  {
766
891
  type: "button",
767
892
  "data-tip": "Manage this team’s members and scope",
768
- onClick: () => he({ id: n.id, name: n.name }),
893
+ onClick: () => _e({ id: s.id, name: s.name }),
769
894
  className: "flex flex-1 items-center gap-1.5 text-left text-[12px] font-medium text-violet-700 hover:underline dark:text-violet-300",
770
895
  children: [
771
- /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" }),
772
- n.name,
896
+ /* @__PURE__ */ t(xe, { className: "h-3.5 w-3.5" }),
897
+ s.name,
773
898
  /* @__PURE__ */ l("span", { className: "font-normal tabular-nums text-slate-400", children: [
774
- n.member_count,
899
+ s.member_count,
775
900
  " member",
776
- n.member_count === 1 ? "" : "s"
901
+ s.member_count === 1 ? "" : "s"
777
902
  ] }),
778
- C.tier === "out" && /* @__PURE__ */ t(
903
+ k.tier === "out" && /* @__PURE__ */ t(
779
904
  "span",
780
905
  {
781
- "data-tip": `Assigned outside its scope — ${C.mismatches.join("; ")}`,
906
+ "data-tip": `Assigned outside its scope — ${k.mismatches.join("; ")}`,
782
907
  className: "rounded bg-amber-100 px-1 py-px text-[9px] font-semibold uppercase text-amber-700 dark:bg-amber-500/15 dark:text-amber-400",
783
908
  children: "out of scope"
784
909
  }
@@ -791,114 +916,118 @@ function Tt({ templateId: m, states: f, bindings: N }) {
791
916
  {
792
917
  type: "button",
793
918
  "data-tip": "Unassign this team from the cell (the team itself is untouched)",
794
- onClick: () => a && tt.mutate({ groupId: a.id, teamId: n.id }),
919
+ onClick: () => r && pt.mutate({ groupId: r.id, teamId: s.id }),
795
920
  className: "text-slate-400 hover:text-red-500",
796
- children: /* @__PURE__ */ t(pe, { className: "h-3 w-3" })
921
+ children: /* @__PURE__ */ t(ye, { className: "h-3 w-3" })
797
922
  }
798
923
  )
799
- ] }, `t${n.link_id}`);
924
+ ] }, `t${s.link_id}`);
800
925
  }),
801
- s.map((n) => /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
926
+ i.map((s) => /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
802
927
  /* @__PURE__ */ l("span", { className: "flex-1 text-[12px] text-slate-700", children: [
803
- [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email,
804
- n.is_out_of_office && /* @__PURE__ */ t("span", { className: "ml-1 rounded bg-amber-100 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:bg-amber-500/15 dark:text-amber-300", children: "OOO" })
928
+ [s.first_name, s.last_name].filter(Boolean).join(" ") || s.email,
929
+ s.is_out_of_office && /* @__PURE__ */ t("span", { className: "ml-1 rounded bg-amber-100 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:bg-amber-500/15 dark:text-amber-300", children: "OOO" })
805
930
  ] }),
806
931
  /* @__PURE__ */ t(
807
932
  "button",
808
933
  {
809
934
  type: "button",
810
- onClick: () => nt.mutate(n.link_id),
935
+ onClick: () => bt.mutate(s.link_id),
811
936
  className: "text-slate-400 hover:text-red-500",
812
- children: /* @__PURE__ */ t(pe, { className: "h-3 w-3" })
937
+ children: /* @__PURE__ */ t(ye, { className: "h-3 w-3" })
813
938
  }
814
939
  )
815
- ] }, n.link_id)),
940
+ ] }, s.link_id)),
816
941
  /* @__PURE__ */ t(
817
- ft,
942
+ Et,
818
943
  {
819
- templateId: m,
820
- stateId: r.id,
821
- buildFilters: () => le(r.id, e.value)
944
+ templateId: f,
945
+ stateId: a.id,
946
+ buildFilters: () => J(a.id, e.value)
822
947
  }
823
948
  ),
824
949
  /* @__PURE__ */ t(
825
- bt,
950
+ Kt,
826
951
  {
827
- stateId: r.id,
952
+ stateId: a.id,
828
953
  rowValue: e.value,
829
- existingUserIds: s.map((n) => String(n.user ?? n.id)),
830
- teams: (et ?? []).filter(
831
- (n) => !((a == null ? void 0 : a.teams) ?? []).some((C) => C.id === n.id)
954
+ existingUserIds: i.map((s) => String(s.user ?? s.id)),
955
+ teams: (Qe ?? []).filter(
956
+ (s) => !((r == null ? void 0 : r.teams) ?? []).some((k) => k.id === s.id)
832
957
  ),
833
- cellFilters: le(r.id, e.value),
834
- scopeDims: I,
835
- boundCollection: k || null,
836
- onAdd: (n) => Oe.mutate({
837
- stateId: r.id,
958
+ cellFilters: J(a.id, e.value),
959
+ scopeDims: W,
960
+ boundCollection: m || null,
961
+ onAdd: (s, k) => Le.mutate({
962
+ stateId: a.id,
838
963
  rowValue: e.value,
839
- userId: n
964
+ userId: s,
965
+ user: k
840
966
  }),
841
- onAddTeam: (n) => Ke.mutate({
842
- stateId: r.id,
967
+ onAddTeam: (s) => Re.mutate({
968
+ stateId: a.id,
843
969
  rowValue: e.value,
844
- teamId: n
970
+ teamId: s
845
971
  }),
846
- onCreateTeam: (n) => Pe.mutate({
847
- stateId: r.id,
848
- rowValue: e.value,
849
- name: n
850
- }),
851
- isPending: Oe.isPending || Ke.isPending || Pe.isPending
972
+ onCreateTeam: (
973
+ // A new team is a real write — not offered in Draft mode.
974
+ w ? void 0 : (s) => Ge.mutate({
975
+ stateId: a.id,
976
+ rowValue: e.value,
977
+ name: s
978
+ })
979
+ ),
980
+ isPending: Le.isPending || Re.isPending || Ge.isPending
852
981
  }
853
982
  ),
854
- a && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 border-t border-slate-100 pt-2", children: [
983
+ r && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 border-t border-slate-100 pt-2", children: [
855
984
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-400 shrink-0", children: "Priority" }),
856
985
  /* @__PURE__ */ t(
857
986
  "input",
858
987
  {
859
988
  type: "number",
860
- defaultValue: a.priority ?? 0,
989
+ defaultValue: r.priority ?? 0,
861
990
  min: 0,
862
991
  className: "h-6 w-14 rounded border border-slate-200 px-1 text-[12px] text-center focus:border-nvr-cyan/50 focus:outline-none",
863
- onBlur: (n) => {
864
- const C = Number.parseInt(n.target.value, 10);
865
- !Number.isNaN(C) && C !== (a.priority ?? 0) && rt.mutate({ groupId: a.id, priority: C });
992
+ onBlur: (s) => {
993
+ const k = Number.parseInt(s.target.value, 10);
994
+ !Number.isNaN(k) && k !== (r.priority ?? 0) && ft.mutate({ groupId: r.id, priority: k });
866
995
  }
867
996
  },
868
- a.id
997
+ r.id
869
998
  ),
870
999
  /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: "lower = higher" })
871
1000
  ] }),
872
- a && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 border-t border-slate-100 pt-2", children: [
1001
+ r && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 border-t border-slate-100 pt-2", children: [
873
1002
  /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-400 shrink-0", children: "Max WIP" }),
874
1003
  /* @__PURE__ */ t(
875
1004
  "input",
876
1005
  {
877
1006
  type: "number",
878
- defaultValue: a.max_wip ?? "",
1007
+ defaultValue: r.max_wip ?? "",
879
1008
  min: 0,
880
1009
  placeholder: "—",
881
1010
  className: "h-6 w-14 rounded border border-slate-200 px-1 text-[12px] text-center focus:border-nvr-cyan/50 focus:outline-none",
882
- onBlur: (n) => {
883
- const C = n.target.value.trim(), g = C === "" ? null : Number.parseInt(C, 10), O = a.max_wip ?? null;
884
- (g === null || !Number.isNaN(g)) && g !== O && at.mutate({ groupId: a.id, maxWip: g });
1011
+ onBlur: (s) => {
1012
+ const k = s.target.value.trim(), h = k === "" ? null : Number.parseInt(k, 10), S = r.max_wip ?? null;
1013
+ (h === null || !Number.isNaN(h)) && h !== S && ht.mutate({ groupId: r.id, maxWip: h });
885
1014
  }
886
1015
  },
887
- `${a.id}-wip`
1016
+ `${r.id}-wip`
888
1017
  ),
889
1018
  /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: "blank = unlimited" })
890
1019
  ] })
891
1020
  ] })
892
1021
  },
893
- r.id
1022
+ a.id
894
1023
  );
895
1024
  })
896
1025
  ] })
897
1026
  ] }, e.value)),
898
- je.length === 0 && /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
1027
+ De.length === 0 && /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
899
1028
  "td",
900
1029
  {
901
- colSpan: f.length + 1,
1030
+ colSpan: b.length + 1,
902
1031
  className: "px-4 py-6 text-center text-[13px] text-slate-400",
903
1032
  children: "No rows yet — the axis fills in automatically once the row dimension's collection has records."
904
1033
  }
@@ -907,37 +1036,37 @@ function Tt({ templateId: m, states: f, bindings: N }) {
907
1036
  ] }) })
908
1037
  ] }) : null;
909
1038
  }
910
- function ft({
911
- templateId: m,
912
- stateId: f,
913
- buildFilters: N
1039
+ function Et({
1040
+ templateId: f,
1041
+ stateId: b,
1042
+ buildFilters: v
914
1043
  }) {
915
- const c = Z(), [y, d] = K(null), [h, _] = K(!1), F = async () => {
1044
+ const o = re(), [N, c] = T(null), [y, _] = T(!1), $ = async () => {
916
1045
  _(!0);
917
1046
  try {
918
- const q = await c.request(
919
- M(`/pipelines/${m}/owner-impact`, {
920
- state_id: f,
921
- filters: N()
1047
+ const F = await o.request(
1048
+ A(`/pipelines/${f}/owner-impact`, {
1049
+ state_id: b,
1050
+ filters: v()
922
1051
  })
923
1052
  );
924
- d(q.data);
1053
+ c(F.data);
925
1054
  } catch {
926
- d(null);
1055
+ c(null);
927
1056
  } finally {
928
1057
  _(!1);
929
1058
  }
930
1059
  };
931
- return /* @__PURE__ */ t("div", { className: "mt-1 text-[10.5px]", children: y ? /* @__PURE__ */ l(
1060
+ return /* @__PURE__ */ t("div", { className: "mt-1 text-[10.5px]", children: N ? /* @__PURE__ */ l(
932
1061
  "span",
933
1062
  {
934
1063
  className: "text-slate-500 dark:text-muted-foreground",
935
- title: y.sample.map((q) => q.label).join(", "),
1064
+ title: N.sample.map((F) => F.label).join(", "),
936
1065
  children: [
937
1066
  "Governs ",
938
- y.matched.toLocaleString(),
1067
+ N.matched.toLocaleString(),
939
1068
  " of ",
940
- y.total_in_state.toLocaleString(),
1069
+ N.total_in_state.toLocaleString(),
941
1070
  " live record(s) in this state"
942
1071
  ]
943
1072
  }
@@ -945,50 +1074,50 @@ function ft({
945
1074
  "button",
946
1075
  {
947
1076
  type: "button",
948
- disabled: h,
949
- onClick: () => void F(),
1077
+ disabled: y,
1078
+ onClick: () => void $(),
950
1079
  className: "text-slate-400 underline decoration-dotted hover:text-slate-600 disabled:opacity-50",
951
- children: h ? "Checking…" : "Preview impact"
1080
+ children: y ? "Checking…" : "Preview impact"
952
1081
  }
953
1082
  ) });
954
1083
  }
955
- function bt({
956
- stateId: m,
957
- rowValue: f,
958
- existingUserIds: N,
959
- teams: c = [],
960
- cellFilters: y = [],
961
- scopeDims: d = [],
962
- boundCollection: h = null,
1084
+ function Kt({
1085
+ stateId: f,
1086
+ rowValue: b,
1087
+ existingUserIds: v,
1088
+ teams: o = [],
1089
+ cellFilters: N = [],
1090
+ scopeDims: c = [],
1091
+ boundCollection: y = null,
963
1092
  onAdd: _,
964
- onAddTeam: F,
965
- onCreateTeam: q,
966
- isPending: $
1093
+ onAddTeam: $,
1094
+ onCreateTeam: F,
1095
+ isPending: j
967
1096
  }) {
968
- const [I, k] = K(!1), [x, j] = K(""), [L, b] = K(!1), [u, S] = K(""), A = se(null);
969
- fe(() => {
970
- I ? setTimeout(() => {
1097
+ const [w, C] = T(!1), [x, E] = T(""), [W, m] = T(!1), [u, q] = T(""), Q = ue(null);
1098
+ ve(() => {
1099
+ w ? setTimeout(() => {
971
1100
  var p;
972
- return (p = A.current) == null ? void 0 : p.focus();
973
- }, 50) : (j(""), b(!1), S(""));
974
- }, [I]);
975
- const B = ze(), { people: H } = pt(I ? x : ""), W = x.trim().toLowerCase(), U = (p) => [p.first_name, p.last_name].filter(Boolean).join(" ") || p.email, ie = new Set(N.filter(Boolean).map((p) => String(p).toUpperCase())), X = (W ? c.filter((p) => p.name.toLowerCase().includes(W)) : c).map((p) => ({
1101
+ return (p = Q.current) == null ? void 0 : p.focus();
1102
+ }, 50) : (E(""), m(!1), q(""));
1103
+ }, [w]);
1104
+ const B = st(), { people: ae } = Pt(w ? x : ""), R = x.trim().toLowerCase(), M = (p) => [p.first_name, p.last_name].filter(Boolean).join(" ") || p.email, H = new Set(v.filter(Boolean).map((p) => String(p).toUpperCase())), Z = (R ? o.filter((p) => p.name.toLowerCase().includes(R)) : o).map((p) => ({
976
1105
  ...p,
977
- rank: Ve(p.scopes, y, d, h)
1106
+ rank: at(p.scopes, N, c, y)
978
1107
  })).sort(
979
- (p, re) => Le(p.rank.tier) - Le(re.rank.tier) || p.name.localeCompare(re.name, void 0, { sensitivity: "base" })
980
- ), J = H.filter((p) => !ie.has(String(p.id).toUpperCase()));
981
- return L ? /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
1108
+ (p, ie) => et(p.rank.tier) - et(ie.rank.tier) || p.name.localeCompare(ie.name, void 0, { sensitivity: "base" })
1109
+ ), ne = ae.filter((p) => !H.has(String(p.id).toUpperCase()));
1110
+ return W ? /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
982
1111
  /* @__PURE__ */ t(
983
1112
  "input",
984
1113
  {
985
1114
  autoFocus: !0,
986
1115
  value: u,
987
- onChange: (p) => S(p.target.value),
1116
+ onChange: (p) => q(p.target.value),
988
1117
  placeholder: "New team name…",
989
1118
  className: "h-7 flex-1 rounded border border-slate-200 bg-white px-1.5 text-[12px] focus:outline-none focus:ring-1 focus:ring-violet-400/50 dark:border-border dark:bg-card",
990
1119
  onKeyDown: (p) => {
991
- p.key === "Enter" && u.trim() && (q == null || q(u.trim()), b(!1), S("")), p.key === "Escape" && b(!1);
1120
+ p.key === "Enter" && u.trim() && (F == null || F(u.trim()), m(!1), q("")), p.key === "Escape" && m(!1);
992
1121
  }
993
1122
  }
994
1123
  ),
@@ -996,68 +1125,68 @@ function bt({
996
1125
  "button",
997
1126
  {
998
1127
  type: "button",
999
- disabled: !u.trim() || $,
1128
+ disabled: !u.trim() || j,
1000
1129
  onClick: () => {
1001
- q == null || q(u.trim()), b(!1), S("");
1130
+ F == null || F(u.trim()), m(!1), q("");
1002
1131
  },
1003
1132
  className: "h-7 rounded bg-violet-600 px-2 text-[11px] font-medium text-white disabled:opacity-40",
1004
- children: $ ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : "Create"
1133
+ children: j ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : "Create"
1005
1134
  }
1006
1135
  ),
1007
1136
  /* @__PURE__ */ t(
1008
1137
  "button",
1009
1138
  {
1010
1139
  type: "button",
1011
- onClick: () => b(!1),
1140
+ onClick: () => m(!1),
1012
1141
  className: "h-7 rounded px-1.5 text-[11px] text-slate-400 hover:text-slate-600",
1013
1142
  children: "✕"
1014
1143
  }
1015
1144
  )
1016
- ] }) : /* @__PURE__ */ l(Fe, { open: I, onOpenChange: k, children: [
1017
- /* @__PURE__ */ t(Ce, { asChild: !0, children: /* @__PURE__ */ l(
1145
+ ] }) : /* @__PURE__ */ l(Pe, { open: w, onOpenChange: C, children: [
1146
+ /* @__PURE__ */ t(Ee, { asChild: !0, children: /* @__PURE__ */ l(
1018
1147
  "button",
1019
1148
  {
1020
1149
  type: "button",
1021
- disabled: $,
1150
+ disabled: j,
1022
1151
  className: "flex h-7 w-full items-center justify-between rounded border border-slate-200 bg-white px-2 text-[12px] text-slate-500 transition-colors hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-300",
1023
1152
  children: [
1024
1153
  /* @__PURE__ */ l("span", { className: "flex items-center gap-1.5", children: [
1025
- $ ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(me, { className: "h-3 w-3" }),
1154
+ j ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ge, { className: "h-3 w-3" }),
1026
1155
  "Add owner…"
1027
1156
  ] }),
1028
- /* @__PURE__ */ t(ke, { className: "h-3 w-3 opacity-50" })
1157
+ /* @__PURE__ */ t(Ie, { className: "h-3 w-3 opacity-50" })
1029
1158
  ]
1030
1159
  }
1031
1160
  ) }),
1032
- /* @__PURE__ */ l(Se, { align: "start", className: "w-96 p-0", sideOffset: 4, children: [
1161
+ /* @__PURE__ */ l(Ke, { align: "start", className: "w-96 p-0", sideOffset: 4, children: [
1033
1162
  /* @__PURE__ */ t("div", { className: "border-b border-slate-100 px-2 py-1.5 dark:border-border", children: /* @__PURE__ */ l("div", { className: "relative", children: [
1034
- /* @__PURE__ */ t(_e, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1163
+ /* @__PURE__ */ t(Te, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1035
1164
  /* @__PURE__ */ t(
1036
1165
  "input",
1037
1166
  {
1038
- ref: A,
1167
+ ref: Q,
1039
1168
  value: x,
1040
- onChange: (p) => j(p.target.value),
1169
+ onChange: (p) => E(p.target.value),
1041
1170
  placeholder: "Search teams and people…",
1042
1171
  className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40 dark:bg-muted"
1043
1172
  }
1044
1173
  )
1045
1174
  ] }) }),
1046
1175
  /* @__PURE__ */ l("div", { className: "max-h-64 overflow-y-auto py-1", children: [
1047
- F && (X.length > 0 || q) && /* @__PURE__ */ l(we, { children: [
1176
+ $ && (Z.length > 0 || F) && /* @__PURE__ */ l(je, { children: [
1048
1177
  /* @__PURE__ */ t("p", { className: "px-3 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Teams" }),
1049
- X.map((p) => /* @__PURE__ */ l(
1178
+ Z.map((p) => /* @__PURE__ */ l(
1050
1179
  "button",
1051
1180
  {
1052
1181
  type: "button",
1053
1182
  "data-tip": p.rank.tier === "out" ? `Outside this cell's scope — ${p.rank.mismatches.join("; ")}. Adding it is an override.` : p.rank.tier === "suggested" ? "Scoped to this combination" : void 0,
1054
1183
  onClick: () => {
1055
- F(p.id), k(!1);
1184
+ $(p.id), C(!1);
1056
1185
  },
1057
1186
  className: "flex w-full items-center gap-2 whitespace-nowrap px-3 py-1.5 text-left text-[12px] text-slate-700 hover:bg-muted dark:text-slate-200",
1058
1187
  children: [
1059
1188
  /* @__PURE__ */ t(
1060
- ue,
1189
+ xe,
1061
1190
  {
1062
1191
  className: `h-3.5 w-3.5 shrink-0 ${p.rank.tier === "out" ? "text-amber-500" : "text-violet-500"}`
1063
1192
  }
@@ -1073,99 +1202,99 @@ function bt({
1073
1202
  },
1074
1203
  p.id
1075
1204
  )),
1076
- q && /* @__PURE__ */ l(
1205
+ F && /* @__PURE__ */ l(
1077
1206
  "button",
1078
1207
  {
1079
1208
  type: "button",
1080
1209
  onClick: () => {
1081
- k(!1), b(!0), S(x.trim());
1210
+ C(!1), m(!0), q(x.trim());
1082
1211
  },
1083
1212
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] text-violet-700 hover:bg-muted dark:text-violet-300",
1084
1213
  children: [
1085
- /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5 shrink-0" }),
1214
+ /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5 shrink-0" }),
1086
1215
  "New team…"
1087
1216
  ]
1088
1217
  }
1089
1218
  )
1090
1219
  ] }),
1091
1220
  /* @__PURE__ */ t("p", { className: "px-3 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "People" }),
1092
- J.map((p) => /* @__PURE__ */ l(
1221
+ ne.map((p) => /* @__PURE__ */ l(
1093
1222
  "button",
1094
1223
  {
1095
1224
  type: "button",
1096
1225
  onClick: () => {
1097
- _(p.id), k(!1);
1226
+ _(p.id, p), C(!1);
1098
1227
  },
1099
1228
  className: "flex w-full items-center gap-2 whitespace-nowrap px-3 py-1.5 text-left text-[12px] text-slate-700 hover:bg-muted dark:text-slate-200",
1100
1229
  children: [
1101
1230
  /* @__PURE__ */ t(
1102
- qe,
1231
+ Oe,
1103
1232
  {
1104
1233
  userId: p.id,
1105
1234
  className: "h-6 w-6",
1106
- fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[9.5px] font-semibold text-slate-600 dark:text-slate-300", children: $e(p) })
1235
+ fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[9.5px] font-semibold text-slate-600 dark:text-slate-300", children: Be(p) })
1107
1236
  }
1108
1237
  ),
1109
- /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate font-medium", children: U(p) }),
1110
- /* @__PURE__ */ t("span", { className: "max-w-[55%] shrink-0 truncate text-[11px] text-slate-400", children: Re(p, B) })
1238
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate font-medium", children: M(p) }),
1239
+ /* @__PURE__ */ t("span", { className: "max-w-[55%] shrink-0 truncate text-[11px] text-slate-400", children: nt(p, B) })
1111
1240
  ]
1112
1241
  },
1113
1242
  p.id
1114
1243
  )),
1115
- J.length === 0 && X.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No matches — people already in this cell are hidden" })
1244
+ ne.length === 0 && Z.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No matches — people already in this cell are hidden" })
1116
1245
  ] })
1117
1246
  ] })
1118
1247
  ] });
1119
1248
  }
1120
- function ht({
1121
- templateId: m,
1122
- groupsMap: f,
1123
- states: N,
1124
- onClose: c,
1125
- onDone: y
1249
+ function Bt({
1250
+ templateId: f,
1251
+ groupsMap: b,
1252
+ states: v,
1253
+ onClose: o,
1254
+ onDone: N
1126
1255
  }) {
1127
- const d = Z(), [h, _] = K(""), [F, q] = K(""), [$, I] = K(/* @__PURE__ */ new Set()), [k, x] = K(!1), { data: j = [] } = D({
1128
- queryKey: ["bulk-matrix-users", h.trim()],
1129
- queryFn: () => d.request(E("/users", { limit: 50, sort: "first_name", search: h.trim() || void 0 })).then((u) => u.data)
1130
- }), L = j.slice(0, 8), b = () => {
1131
- x(!0), d.request(
1132
- M(`/pipelines/${m}/owner-groups/bulk-add`, {
1133
- user_id: F,
1134
- group_ids: [...$]
1256
+ const c = re(), [y, _] = T(""), [$, F] = T(""), [j, w] = T(/* @__PURE__ */ new Set()), [C, x] = T(!1), { data: E = [] } = V({
1257
+ queryKey: ["bulk-matrix-users", y.trim()],
1258
+ queryFn: () => c.request(K("/users", { limit: 50, sort: "first_name", search: y.trim() || void 0 })).then((u) => u.data)
1259
+ }), W = E.slice(0, 8), m = () => {
1260
+ x(!0), c.request(
1261
+ A(`/pipelines/${f}/owner-groups/bulk-add`, {
1262
+ user_id: $,
1263
+ group_ids: [...j]
1135
1264
  })
1136
1265
  ).then((u) => {
1137
- P.success(`Added to ${u.data.added} group(s)`), y();
1138
- }).catch(() => P.error("Bulk add failed")).finally(() => x(!1));
1266
+ O.success(`Added to ${u.data.added} group(s)`), N();
1267
+ }).catch(() => O.error("Bulk add failed")).finally(() => x(!1));
1139
1268
  };
1140
1269
  return /* @__PURE__ */ l("div", { className: "space-y-2 rounded-lg border border-slate-200 bg-slate-50/70 p-3 dark:border-border dark:bg-muted/30", children: [
1141
1270
  /* @__PURE__ */ t("p", { className: "text-[12.5px] font-medium", children: "Add one user to many owner-matrix cells" }),
1142
- F ? /* @__PURE__ */ l(we, { children: [
1271
+ $ ? /* @__PURE__ */ l(je, { children: [
1143
1272
  /* @__PURE__ */ l("p", { className: "text-[12px] text-slate-500", children: [
1144
1273
  "Adding",
1145
1274
  " ",
1146
1275
  /* @__PURE__ */ t("b", { children: (() => {
1147
- const u = j.find((S) => S.id === F);
1148
- return u ? [u.first_name, u.last_name].filter(Boolean).join(" ") || u.email : F;
1276
+ const u = E.find((q) => q.id === $);
1277
+ return u ? [u.first_name, u.last_name].filter(Boolean).join(" ") || u.email : $;
1149
1278
  })() }),
1150
1279
  " ",
1151
1280
  "— pick the groups:"
1152
1281
  ] }),
1153
- /* @__PURE__ */ t("div", { className: "max-h-64 space-y-2 overflow-y-auto", children: N.map((u) => {
1154
- const S = f[u.id] ?? [];
1155
- return S.length === 0 ? null : /* @__PURE__ */ l("div", { children: [
1282
+ /* @__PURE__ */ t("div", { className: "max-h-64 space-y-2 overflow-y-auto", children: v.map((u) => {
1283
+ const q = b[u.id] ?? [];
1284
+ return q.length === 0 ? null : /* @__PURE__ */ l("div", { children: [
1156
1285
  /* @__PURE__ */ t("p", { className: "text-[10.5px] font-semibold uppercase tracking-wide text-slate-400", children: u.label }),
1157
- /* @__PURE__ */ t("div", { className: "mt-0.5 flex flex-wrap gap-1", children: S.slice(0, 60).map((A) => {
1158
- const B = Number(A.id), H = $.has(B);
1286
+ /* @__PURE__ */ t("div", { className: "mt-0.5 flex flex-wrap gap-1", children: q.slice(0, 60).map((Q) => {
1287
+ const B = Number(Q.id), ae = j.has(B);
1159
1288
  return /* @__PURE__ */ t(
1160
1289
  "button",
1161
1290
  {
1162
1291
  type: "button",
1163
- onClick: () => I((W) => {
1164
- const U = new Set(W);
1165
- return U.has(B) ? U.delete(B) : U.add(B), U;
1292
+ onClick: () => w((R) => {
1293
+ const M = new Set(R);
1294
+ return M.has(B) ? M.delete(B) : M.add(B), M;
1166
1295
  }),
1167
- className: H ? "rounded-full bg-nvr-cyan/15 px-2 py-0.5 text-[11px] font-medium text-nvr-navy dark:text-nvr-cyan" : "rounded-full border border-slate-200 px-2 py-0.5 text-[11px] text-slate-500 hover:border-nvr-cyan/50 dark:border-border",
1168
- children: A.name ?? `group ${B}`
1296
+ className: ae ? "rounded-full bg-nvr-cyan/15 px-2 py-0.5 text-[11px] font-medium text-nvr-navy dark:text-nvr-cyan" : "rounded-full border border-slate-200 px-2 py-0.5 text-[11px] text-slate-500 hover:border-nvr-cyan/50 dark:border-border",
1297
+ children: Q.name ?? `group ${B}`
1169
1298
  },
1170
1299
  B
1171
1300
  );
@@ -1176,17 +1305,17 @@ function ht({
1176
1305
  /* @__PURE__ */ t(
1177
1306
  "input",
1178
1307
  {
1179
- value: h,
1308
+ value: y,
1180
1309
  onChange: (u) => _(u.target.value),
1181
1310
  placeholder: "Search people…",
1182
1311
  className: "h-8 w-[280px] rounded-md border border-slate-200 bg-background px-2.5 text-[12.5px] dark:border-border"
1183
1312
  }
1184
1313
  ),
1185
- /* @__PURE__ */ t("div", { className: "mt-1 flex flex-wrap gap-1.5", children: h && L.map((u) => /* @__PURE__ */ t(
1314
+ /* @__PURE__ */ t("div", { className: "mt-1 flex flex-wrap gap-1.5", children: y && W.map((u) => /* @__PURE__ */ t(
1186
1315
  "button",
1187
1316
  {
1188
1317
  type: "button",
1189
- onClick: () => q(u.id),
1318
+ onClick: () => F(u.id),
1190
1319
  className: "rounded-full border border-slate-200 px-2.5 py-0.5 text-[12px] hover:border-nvr-cyan/60 dark:border-border",
1191
1320
  children: [u.first_name, u.last_name].filter(Boolean).join(" ") || u.email
1192
1321
  },
@@ -1198,7 +1327,7 @@ function ht({
1198
1327
  "button",
1199
1328
  {
1200
1329
  type: "button",
1201
- onClick: c,
1330
+ onClick: o,
1202
1331
  className: "rounded-md px-2.5 py-1 text-[12px] text-slate-500 hover:bg-white dark:hover:bg-muted",
1203
1332
  children: "Cancel"
1204
1333
  }
@@ -1207,49 +1336,49 @@ function ht({
1207
1336
  "button",
1208
1337
  {
1209
1338
  type: "button",
1210
- onClick: b,
1211
- disabled: k || !F || $.size === 0,
1339
+ onClick: m,
1340
+ disabled: C || !$ || j.size === 0,
1212
1341
  className: "rounded-md bg-nvr-cyan px-3 py-1 text-[12px] font-semibold text-white disabled:opacity-50",
1213
- children: k ? "Adding…" : `Add to ${$.size} group(s)`
1342
+ children: C ? "Adding…" : `Add to ${j.size} group(s)`
1214
1343
  }
1215
1344
  )
1216
1345
  ] })
1217
1346
  ] });
1218
1347
  }
1219
- function xt({
1220
- team: m,
1221
- onClose: f
1348
+ function Ut({
1349
+ team: f,
1350
+ onClose: b
1222
1351
  }) {
1223
- var k;
1224
- const N = Z(), c = Me(), { data: y, isLoading: d } = D({
1225
- queryKey: ["team-members", m.id],
1226
- queryFn: () => N.request(E(`/user-groups/${m.id}/members`)).then((x) => x.data)
1227
- }), h = () => {
1228
- c.invalidateQueries({ queryKey: ["team-members", m.id] }), c.invalidateQueries({ queryKey: ["user-groups-teams"] });
1229
- }, _ = V({
1230
- mutationFn: (x) => N.request(M(`/user-groups/${m.id}/members`, { user_ids: [x] })),
1231
- onSuccess: h,
1232
- onError: () => P.error("Failed to add member")
1233
- }), F = V({
1234
- mutationFn: (x) => N.request(Ne(`/user-groups/${m.id}/members/${x}`)),
1235
- onSuccess: h,
1236
- onError: () => P.error("Failed to remove member")
1237
- }), q = new Set((y ?? []).map((x) => String(x.id).toUpperCase())), { data: $ } = D({
1352
+ var C;
1353
+ const v = re(), o = tt(), { data: N, isLoading: c } = V({
1354
+ queryKey: ["team-members", f.id],
1355
+ queryFn: () => v.request(K(`/user-groups/${f.id}/members`)).then((x) => x.data)
1356
+ }), y = () => {
1357
+ o.invalidateQueries({ queryKey: ["team-members", f.id] }), o.invalidateQueries({ queryKey: ["user-groups-teams"] });
1358
+ }, _ = G({
1359
+ mutationFn: (x) => v.request(A(`/user-groups/${f.id}/members`, { user_ids: [x] })),
1360
+ onSuccess: y,
1361
+ onError: () => O.error("Failed to add member")
1362
+ }), $ = G({
1363
+ mutationFn: (x) => v.request(ce(`/user-groups/${f.id}/members/${x}`)),
1364
+ onSuccess: y,
1365
+ onError: () => O.error("Failed to remove member")
1366
+ }), F = new Set((N ?? []).map((x) => String(x.id).toUpperCase())), { data: j } = V({
1238
1367
  queryKey: ["user-groups-teams"],
1239
- queryFn: () => N.request(
1240
- E("/user-groups")
1368
+ queryFn: () => v.request(
1369
+ K("/user-groups")
1241
1370
  ).then((x) => x.data),
1242
1371
  staleTime: 6e4
1243
- }), I = ((k = $ == null ? void 0 : $.find((x) => x.id === m.id)) == null ? void 0 : k.scopes) ?? {};
1244
- return st(
1372
+ }), w = ((C = j == null ? void 0 : j.find((x) => x.id === f.id)) == null ? void 0 : C.scopes) ?? {};
1373
+ return gt(
1245
1374
  /* @__PURE__ */ t(
1246
1375
  "div",
1247
1376
  {
1248
1377
  "data-omx-overlay": !0,
1249
1378
  className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4",
1250
- onClick: f,
1379
+ onClick: b,
1251
1380
  onKeyDown: (x) => {
1252
- x.key === "Escape" && f();
1381
+ x.key === "Escape" && b();
1253
1382
  },
1254
1383
  children: /* @__PURE__ */ l(
1255
1384
  "div",
@@ -1258,43 +1387,43 @@ function xt({
1258
1387
  onClick: (x) => x.stopPropagation(),
1259
1388
  children: [
1260
1389
  /* @__PURE__ */ l("div", { className: "mb-1 flex items-center gap-2", children: [
1261
- /* @__PURE__ */ t(ue, { className: "h-4 w-4 text-violet-500" }),
1262
- /* @__PURE__ */ t("h2", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: m.name }),
1390
+ /* @__PURE__ */ t(xe, { className: "h-4 w-4 text-violet-500" }),
1391
+ /* @__PURE__ */ t("h2", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: f.name }),
1263
1392
  /* @__PURE__ */ l("span", { className: "ml-auto text-[11px] tabular-nums text-slate-400", children: [
1264
- (y ?? []).length,
1393
+ (N ?? []).length,
1265
1394
  " member",
1266
- (y ?? []).length === 1 ? "" : "s"
1395
+ (N ?? []).length === 1 ? "" : "s"
1267
1396
  ] })
1268
1397
  ] }),
1269
1398
  /* @__PURE__ */ t("p", { className: "mb-3 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Roster edits apply everywhere this team is assigned." }),
1270
- d ? /* @__PURE__ */ t("div", { className: "flex justify-center py-4", children: /* @__PURE__ */ t(te, { className: "h-4 w-4 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "mb-2 max-h-56 divide-y divide-slate-100 overflow-y-auto dark:divide-border/60", children: [
1271
- (y ?? []).map((x) => /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5 py-1.5", children: [
1399
+ c ? /* @__PURE__ */ t("div", { className: "flex justify-center py-4", children: /* @__PURE__ */ t(te, { className: "h-4 w-4 animate-spin text-slate-400" }) }) : /* @__PURE__ */ l("div", { className: "mb-2 max-h-56 divide-y divide-slate-100 overflow-y-auto dark:divide-border/60", children: [
1400
+ (N ?? []).map((x) => /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5 py-1.5", children: [
1272
1401
  /* @__PURE__ */ t("span", { className: "flex-1 truncate text-[12.5px] text-slate-700 dark:text-slate-200", children: [x.first_name, x.last_name].filter(Boolean).join(" ") || x.email }),
1273
1402
  /* @__PURE__ */ t(
1274
1403
  "button",
1275
1404
  {
1276
1405
  type: "button",
1277
1406
  "aria-label": "Remove from team",
1278
- disabled: F.isPending,
1279
- onClick: () => F.mutate(x.id),
1407
+ disabled: $.isPending,
1408
+ onClick: () => $.mutate(x.id),
1280
1409
  className: "text-slate-400 hover:text-red-500",
1281
- children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
1410
+ children: /* @__PURE__ */ t(ye, { className: "h-3.5 w-3.5" })
1282
1411
  }
1283
1412
  )
1284
1413
  ] }, x.id)),
1285
- (y ?? []).length === 0 && /* @__PURE__ */ t("p", { className: "py-2 text-[12px] text-slate-400", children: "No members yet — add people below." })
1414
+ (N ?? []).length === 0 && /* @__PURE__ */ t("p", { className: "py-2 text-[12px] text-slate-400", children: "No members yet — add people below." })
1286
1415
  ] }),
1287
1416
  /* @__PURE__ */ t(
1288
- yt,
1417
+ Dt,
1289
1418
  {
1290
- teamId: m.id,
1291
- excludeIds: [...q],
1419
+ teamId: f.id,
1420
+ excludeIds: [...F],
1292
1421
  isPending: _.isPending,
1293
1422
  onPick: (x) => _.mutate(x)
1294
1423
  }
1295
1424
  ),
1296
- /* @__PURE__ */ t("div", { className: "mt-3 border-t border-slate-100 pt-3 dark:border-border/60", children: /* @__PURE__ */ t(ot, { teamId: m.id, scopes: I }) }),
1297
- /* @__PURE__ */ t("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ t(it, { size: "sm", variant: "outline", className: "h-7 text-[12px]", onClick: f, children: "Done" }) })
1425
+ /* @__PURE__ */ t("div", { className: "mt-3 border-t border-slate-100 pt-3 dark:border-border/60", children: /* @__PURE__ */ t(St, { teamId: f.id, scopes: w }) }),
1426
+ /* @__PURE__ */ t("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ t(Se, { size: "sm", variant: "outline", className: "h-7 text-[12px]", onClick: b, children: "Done" }) })
1298
1427
  ]
1299
1428
  }
1300
1429
  )
@@ -1303,110 +1432,110 @@ function xt({
1303
1432
  document.body
1304
1433
  );
1305
1434
  }
1306
- const gt = {
1435
+ const At = {
1307
1436
  match: "Matches team scope",
1308
1437
  unrestricted: "No restrictions",
1309
1438
  mismatch: "Outside team scope"
1310
1439
  };
1311
- function yt({
1312
- teamId: m,
1313
- excludeIds: f,
1314
- isPending: N,
1315
- onPick: c
1440
+ function Dt({
1441
+ teamId: f,
1442
+ excludeIds: b,
1443
+ isPending: v,
1444
+ onPick: o
1316
1445
  }) {
1317
- const y = Z(), [d, h] = K(!1), [_, F] = K(""), q = se(null);
1318
- fe(() => {
1319
- d ? setTimeout(() => {
1320
- var b;
1321
- return (b = q.current) == null ? void 0 : b.focus();
1322
- }, 50) : F("");
1323
- }, [d]);
1324
- const $ = ze(), { data: I } = D({
1325
- queryKey: ["team-candidates", m, _.trim()],
1326
- queryFn: () => y.request(
1327
- E(`/user-groups/${m}/candidates`, { search: _.trim() || void 0 })
1328
- ).then((b) => b.data),
1329
- enabled: d,
1446
+ const N = re(), [c, y] = T(!1), [_, $] = T(""), F = ue(null);
1447
+ ve(() => {
1448
+ c ? setTimeout(() => {
1449
+ var m;
1450
+ return (m = F.current) == null ? void 0 : m.focus();
1451
+ }, 50) : $("");
1452
+ }, [c]);
1453
+ const j = st(), { data: w } = V({
1454
+ queryKey: ["team-candidates", f, _.trim()],
1455
+ queryFn: () => N.request(
1456
+ K(`/user-groups/${f}/candidates`, { search: _.trim() || void 0 })
1457
+ ).then((m) => m.data),
1458
+ enabled: c,
1330
1459
  staleTime: 6e4
1331
- }), k = (b) => [b.first_name, b.last_name].filter(Boolean).join(" ") || b.email, x = new Set(f.map((b) => b.toUpperCase())), j = ((I == null ? void 0 : I.users) ?? []).filter((b) => !x.has(String(b.id).toUpperCase())), L = !!(I != null && I.ranked);
1332
- return /* @__PURE__ */ l(Fe, { open: d, onOpenChange: h, children: [
1333
- /* @__PURE__ */ t(Ce, { asChild: !0, children: /* @__PURE__ */ l(
1460
+ }), C = (m) => [m.first_name, m.last_name].filter(Boolean).join(" ") || m.email, x = new Set(b.map((m) => m.toUpperCase())), E = ((w == null ? void 0 : w.users) ?? []).filter((m) => !x.has(String(m.id).toUpperCase())), W = !!(w != null && w.ranked);
1461
+ return /* @__PURE__ */ l(Pe, { open: c, onOpenChange: y, children: [
1462
+ /* @__PURE__ */ t(Ee, { asChild: !0, children: /* @__PURE__ */ l(
1334
1463
  "button",
1335
1464
  {
1336
1465
  type: "button",
1337
- disabled: N,
1466
+ disabled: v,
1338
1467
  className: "flex h-7 w-full items-center justify-between rounded border border-slate-200 bg-white px-2 text-[12px] text-slate-500 transition-colors hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-card dark:text-slate-300",
1339
1468
  children: [
1340
1469
  /* @__PURE__ */ l("span", { className: "flex items-center gap-1.5", children: [
1341
- N ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(me, { className: "h-3 w-3" }),
1470
+ v ? /* @__PURE__ */ t(te, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ge, { className: "h-3 w-3" }),
1342
1471
  "Add member…"
1343
1472
  ] }),
1344
- /* @__PURE__ */ t(ke, { className: "h-3 w-3 opacity-50" })
1473
+ /* @__PURE__ */ t(Ie, { className: "h-3 w-3 opacity-50" })
1345
1474
  ]
1346
1475
  }
1347
1476
  ) }),
1348
- /* @__PURE__ */ l(Se, { align: "start", className: "z-[140] w-96 p-0", sideOffset: 4, children: [
1477
+ /* @__PURE__ */ l(Ke, { align: "start", className: "z-[140] w-96 p-0", sideOffset: 4, children: [
1349
1478
  /* @__PURE__ */ t("div", { className: "border-b border-slate-100 px-2 py-1.5 dark:border-border", children: /* @__PURE__ */ l("div", { className: "relative", children: [
1350
- /* @__PURE__ */ t(_e, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1479
+ /* @__PURE__ */ t(Te, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
1351
1480
  /* @__PURE__ */ t(
1352
1481
  "input",
1353
1482
  {
1354
- ref: q,
1483
+ ref: F,
1355
1484
  value: _,
1356
- onChange: (b) => F(b.target.value),
1485
+ onChange: (m) => $(m.target.value),
1357
1486
  placeholder: "Search people…",
1358
1487
  className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-violet-400/40 dark:bg-muted"
1359
1488
  }
1360
1489
  )
1361
1490
  ] }) }),
1362
1491
  /* @__PURE__ */ l("div", { className: "max-h-56 overflow-y-auto py-1", children: [
1363
- j.map((b, u) => {
1364
- const S = b.scope_tier ?? "unrestricted", A = L && (u === 0 || (j[u - 1].scope_tier ?? "unrestricted") !== S);
1365
- return /* @__PURE__ */ l(De, { children: [
1366
- A && /* @__PURE__ */ t(
1492
+ E.map((m, u) => {
1493
+ const q = m.scope_tier ?? "unrestricted", Q = W && (u === 0 || (E[u - 1].scope_tier ?? "unrestricted") !== q);
1494
+ return /* @__PURE__ */ l(rt, { children: [
1495
+ Q && /* @__PURE__ */ t(
1367
1496
  "p",
1368
1497
  {
1369
- className: `px-3 pb-0.5 pt-1.5 text-[10px] font-semibold uppercase tracking-wide ${S === "mismatch" ? "text-amber-500" : S === "match" ? "text-emerald-600 dark:text-emerald-400" : "text-slate-400"}`,
1370
- children: gt[S]
1498
+ className: `px-3 pb-0.5 pt-1.5 text-[10px] font-semibold uppercase tracking-wide ${q === "mismatch" ? "text-amber-500" : q === "match" ? "text-emerald-600 dark:text-emerald-400" : "text-slate-400"}`,
1499
+ children: At[q]
1371
1500
  }
1372
1501
  ),
1373
1502
  /* @__PURE__ */ l(
1374
1503
  "button",
1375
1504
  {
1376
1505
  type: "button",
1377
- "data-tip": S === "mismatch" && (b.scope_mismatch ?? []).length > 0 ? `Restricted elsewhere on ${(b.scope_mismatch ?? []).join(", ")} — adding is an override` : void 0,
1506
+ "data-tip": q === "mismatch" && (m.scope_mismatch ?? []).length > 0 ? `Restricted elsewhere on ${(m.scope_mismatch ?? []).join(", ")} — adding is an override` : void 0,
1378
1507
  onClick: () => {
1379
- c(b.id), h(!1);
1508
+ o(m.id), y(!1);
1380
1509
  },
1381
1510
  className: "flex w-full items-center gap-2 whitespace-nowrap px-3 py-1.5 text-left text-[12px] text-slate-700 hover:bg-muted dark:text-slate-200",
1382
1511
  children: [
1383
1512
  /* @__PURE__ */ t(
1384
- qe,
1513
+ Oe,
1385
1514
  {
1386
- userId: b.id,
1515
+ userId: m.id,
1387
1516
  className: "h-6 w-6",
1388
1517
  fallback: /* @__PURE__ */ t(
1389
1518
  "span",
1390
1519
  {
1391
- className: `flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[9.5px] font-semibold ${S === "mismatch" ? "bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-400" : "bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300"}`,
1392
- children: $e(b)
1520
+ className: `flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[9.5px] font-semibold ${q === "mismatch" ? "bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-400" : "bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300"}`,
1521
+ children: Be(m)
1393
1522
  }
1394
1523
  )
1395
1524
  }
1396
1525
  ),
1397
- /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate font-medium", children: k(b) }),
1398
- /* @__PURE__ */ t("span", { className: "max-w-[55%] shrink-0 truncate text-[11px] text-slate-400", children: Re(b, $) })
1526
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate font-medium", children: C(m) }),
1527
+ /* @__PURE__ */ t("span", { className: "max-w-[55%] shrink-0 truncate text-[11px] text-slate-400", children: nt(m, j) })
1399
1528
  ]
1400
1529
  }
1401
1530
  )
1402
- ] }, b.id);
1531
+ ] }, m.id);
1403
1532
  }),
1404
- j.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No matches — people already on the team are hidden" })
1533
+ E.length === 0 && /* @__PURE__ */ t("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No matches — people already on the team are hidden" })
1405
1534
  ] })
1406
1535
  ] })
1407
1536
  ] });
1408
1537
  }
1409
1538
  export {
1410
- yt as MemberPickerCombobox,
1411
- Tt as OwnerMatrix
1539
+ Dt as MemberPickerCombobox,
1540
+ sr as OwnerMatrix
1412
1541
  };