@wssto2/vue-core 0.5.0 → 0.5.2

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 (59) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/{AccessGate.vue_vue_type_script_setup_true_lang-Nw1IsB8N.js → AccessGate.vue_vue_type_script_setup_true_lang-DZ9GcLC1.js} +1 -1
  3. package/dist/{Activity-CoGI2_GL.js → Activity-dpY2kIs2.js} +2 -2
  4. package/dist/{Changes-Cwfe6wbX.js → Changes-CL8F1w8q.js} +2 -2
  5. package/dist/{CollectionPage.vue_vue_type_script_setup_true_lang-CtvHtFLy.js → CollectionPage.vue_vue_type_script_setup_true_lang-l-e-6WeS.js} +1 -1
  6. package/dist/{DeadLetters-DyA5Dqn0.js → DeadLetters-DopyRRx0.js} +4 -4
  7. package/dist/{General-DTEfxWls.js → General-mrVzi-5R.js} +2 -2
  8. package/dist/{NewRolePage-CRZoUajV.js → NewRolePage-sfr7tQs5.js} +2 -2
  9. package/dist/{ProfilePage-DLY81mvN.js → ProfilePage-EiTIYzZ5.js} +2 -2
  10. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-gXbxXG2R.js → RoleEditor.vue_vue_type_script_setup_true_lang-BGtyOyWL.js} +6 -5
  11. package/dist/{RolePage-B9t586Q8.js → RolePage-ByUr3v_H.js} +3 -3
  12. package/dist/{RolesPage-BRdG-OSL.js → RolesPage-CvHrY9ZC.js} +2 -2
  13. package/dist/{SectionNavigator.vue_vue_type_script_setup_true_lang-Cy9Oi0ts.js → SectionNavigator.vue_vue_type_script_setup_true_lang-Ci04hApd.js} +1 -1
  14. package/dist/{Sessions-vGyUOnPG.js → Sessions-CHLokZ9e.js} +2 -2
  15. package/dist/{SettingsPage-V8WeADZZ.js → SettingsPage-DvOGJz9L.js} +2 -2
  16. package/dist/{SignIn-C-3i8RG6.js → SignIn-ypRvdmjg.js} +2 -2
  17. package/dist/{SignInPage-D2NA3VKU.js → SignInPage-CbPeKlAo.js} +2 -2
  18. package/dist/{SignIns-eoYPB6kB.js → SignIns-BApzbGq-.js} +2 -2
  19. package/dist/{UserRecord-BaQl2zzQ.js → UserRecord-BCTaBajE.js} +5 -5
  20. package/dist/{UsersList-BfXWgH5K.js → UsersList-CqSK3cQL.js} +4 -4
  21. package/dist/access/api.d.ts +8 -7
  22. package/dist/access/context.d.ts +7 -0
  23. package/dist/access/feature.d.ts +8 -0
  24. package/dist/access/index.js +1 -1
  25. package/dist/access/labels.d.ts +5 -0
  26. package/dist/app/index.js +117 -115
  27. package/dist/app/keepAlive.d.ts +4 -8
  28. package/dist/collection/index.js +3 -3
  29. package/dist/{contributions-DVQPcjJz.js → contributions-fx5q5n1u.js} +1 -1
  30. package/dist/{guards-DRh4zmxO.js → guards-D4mXf_2X.js} +1 -1
  31. package/dist/{http-D_pBg22D.js → http-CdQowFlW.js} +1 -1
  32. package/dist/identity/index.d.ts +1 -1
  33. package/dist/identity/index.js +6 -7
  34. package/dist/identity/session.d.ts +10 -7
  35. package/dist/{index-g-qbUeTk.js → index-BPwfLD7i.js} +261 -239
  36. package/dist/index-BVlbcaKs.js +763 -0
  37. package/dist/{index-kqk7Mclb.js → index-auJqVMWC.js} +90 -92
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/keepAlive-z3IRFkQq.js +46 -0
  41. package/dist/{navigation-DuQwti76.js → navigation-Bc5EQ_Si.js} +1 -1
  42. package/dist/{neighbors-IMRQ4rkm.js → neighbors-Bv6vnWlW.js} +1 -1
  43. package/dist/notifications/index.d.ts +2 -0
  44. package/dist/notifications/index.js +5 -4
  45. package/dist/notifications/push/pushState.d.ts +27 -0
  46. package/dist/page/index.js +1 -1
  47. package/dist/platform/index.js +3 -3
  48. package/dist/platform/platform.d.ts +7 -2
  49. package/dist/platform/session.d.ts +17 -0
  50. package/dist/platform-Dx6STiwY.js +283 -0
  51. package/dist/router/index.js +3 -3
  52. package/dist/{sections-D5rgQ4YB.js → sections-B0HxIOC2.js} +1 -1
  53. package/dist/shell/index.js +3 -3
  54. package/dist/{status-C2gHqkj6.js → status-BUFELJz2.js} +2 -2
  55. package/dist/testing/index.js +1 -1
  56. package/package.json +1 -1
  57. package/dist/index-WkbzC_ee.js +0 -745
  58. package/dist/keepAlive-CDvMQlcJ.js +0 -49
  59. package/dist/platform-Dl1fbScN.js +0 -268
@@ -0,0 +1,763 @@
1
+ import { route as x } from "./client/index.js";
2
+ import { d as Re, p as Te } from "./feature-DdUAfyi4.js";
3
+ import { d as Ne } from "./context-Ch1r4fdN.js";
4
+ import { d as Se } from "./defineRoutes-BGAdiIrt.js";
5
+ import { useI18n as H } from "vue-i18n";
6
+ import { hasInjectionContext as Oe, inject as Ae, defineComponent as X, ref as O, computed as T, watch as re, openBlock as m, createBlock as N, unref as n, withCtx as h, createElementVNode as S, createElementBlock as g, toDisplayString as j, createCommentVNode as A, createVNode as E, Fragment as K, renderList as B, createSlots as ge, renderSlot as De, createTextVNode as V, useTemplateRef as ie } from "vue";
7
+ import { i as te } from "./error-Bb_dr_Ay.js";
8
+ import { u as Ke } from "./describeError-BqGAUZgX.js";
9
+ import { _ as J } from "./Button.vue_vue_type_script_setup_true_lang-CL9Qh5yq.js";
10
+ import { _ as z } from "./FormGroup.vue_vue_type_script_setup_true_lang-BPchlRCl.js";
11
+ import { g as U } from "./options-g8RwEhBk.js";
12
+ import { _ as Pe } from "./AlertDialog.vue_vue_type_script_setup_true_lang-whA4WLdl.js";
13
+ import { t as ae } from "./toast-CqSDTWRX.js";
14
+ import { _ as ue } from "./AccessGate.vue_vue_type_script_setup_true_lang-DZ9GcLC1.js";
15
+ import { _ as Be } from "./AsyncSection.vue_vue_type_script_setup_true_lang-B0NfvG3B.js";
16
+ import { _ as Ue } from "./EmptyState.vue_vue_type_script_setup_true_lang-50p-Mp8I.js";
17
+ import { u as Fe } from "./useLoad-W4tfxmm5.js";
18
+ import { _ as Ge, a as Me } from "./SelectField.vue_vue_type_script_setup_true_lang-BzQC1qDQ.js";
19
+ import { _ as Ve } from "./SegmentedField.vue_vue_type_script_setup_true_lang-BwyMvkis.js";
20
+ import { u as ze, _ as He } from "./useCommand-CtqheKUv.js";
21
+ import { u as We } from "./platform-Dx6STiwY.js";
22
+ import { _ as Ie } from "./IconTile.vue_vue_type_script_setup_true_lang-_FXvaj93.js";
23
+ import { u as Qe } from "./mediaQuery-CygcXmFW.js";
24
+ import { _ as Ye } from "./Badge.vue_vue_type_script_setup_true_lang-DJyZc0C7.js";
25
+ const D = {
26
+ rolesList: x("GET", "/v1/iam/roles", { permission: "iam.role:view" }),
27
+ rolesShow: x("GET", "/v1/iam/roles/:ref", { permission: "iam.role:view" }),
28
+ rolesHolders: x("GET", "/v1/iam/roles/:ref/holders", { permission: "iam.role:view" }),
29
+ rolesCompare: x("GET", "/v1/iam/roles/:ref/compare", { permission: "iam.role:view" }),
30
+ rolesCreate: x("POST", "/v1/iam/roles", { permission: "iam.role:manage" }),
31
+ rolesUpdate: x("PUT", "/v1/iam/roles/:ref", { permission: "iam.role:manage" }),
32
+ rolesDelete: x("DELETE", "/v1/iam/roles/:ref", { permission: "iam.role:delete" }),
33
+ rolesReplace: x("POST", "/v1/iam/roles/:ref/replace", { permission: "iam.role:manage" }),
34
+ bindable: x("GET", "/v1/iam/bindable-roles"),
35
+ subjectsAccess: x("GET", "/v1/iam/users/:id/access", { permission: "iam.user:view" }),
36
+ subjectsScopes: x("GET", "/v1/iam/users/:id/scopes", { permission: "iam.user:manage" }),
37
+ subjectsBind: x("POST", "/v1/iam/users/:id/bindings", { permission: "iam.user:manage" }),
38
+ subjectsUnbind: x("DELETE", "/v1/iam/users/:id/bindings/:binding_id", { permission: "iam.user:manage" }),
39
+ me: x.raw("GET", "/v1/me/access")
40
+ }, [ye, Z] = Ne("vue-core.access"), F = {
41
+ viewRoles: "iam.role:view",
42
+ manageRoles: "iam.role:manage",
43
+ deleteRoles: "iam.role:delete",
44
+ viewAccess: "iam.user:view",
45
+ manageBindings: "iam.user:manage"
46
+ }, de = Se({
47
+ roles: { name: "access.roles", path: "/iam/roles", component: () => import("./RolesPage-CvHrY9ZC.js"), meta: { access: F.viewRoles, titleKey: "core.access.title" } },
48
+ newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-sfr7tQs5.js"), meta: { access: F.manageRoles, titleKey: "core.access.new_title" } },
49
+ role: {
50
+ name: "access.role",
51
+ path: "/iam/roles/:ref",
52
+ component: () => import("./RolePage-ByUr3v_H.js"),
53
+ // A role's ref (its key, or the id of a custom one) swaps in place when a link leads to another role.
54
+ meta: { access: F.viewRoles, titleKey: "core.access.title", remountOnParam: "ref" }
55
+ }
56
+ }), na = {
57
+ access: F.viewAccess,
58
+ section: { labelKey: "core.access.person_roles", icon: "shieldStarFill" }
59
+ };
60
+ function la(s) {
61
+ return Re({
62
+ id: "access",
63
+ routes: de.records,
64
+ context: Te(ye, {
65
+ catalogue: s.catalogue,
66
+ subjectRoute: s.subjectRoute ?? (() => null),
67
+ constraints: s.roleConstraints ?? [],
68
+ problems: s.problems ?? {},
69
+ subjects: s.subjects ?? {},
70
+ scopes: s.scopes ?? null
71
+ }),
72
+ navigation: s.destination ? [{ destination: s.destination, to: de.roles, within: ["access.role", "access.roles.new"] }] : []
73
+ });
74
+ }
75
+ const G = "system", me = ["view", "create", "update", "manage", "delete"], fe = (s) => {
76
+ const l = me.indexOf(s);
77
+ return l === -1 ? me.length : l;
78
+ }, oe = (s) => s.system ? G : s.module, he = (s) => s.resource === "" ? s.module : `${s.module}_${s.resource.replace(/\./g, "_")}`;
79
+ function ca(s) {
80
+ const l = /* @__PURE__ */ new Map();
81
+ for (const [c, t] of Object.entries(s)) {
82
+ const o = l.get(oe(t)) ?? /* @__PURE__ */ new Map(), a = he(t);
83
+ o.set(a, [...o.get(a) ?? [], { ...t, id: c }]), l.set(oe(t), o);
84
+ }
85
+ return [...l.keys()].sort((c, t) => +(c === G) - +(t === G) || c.localeCompare(t)).map((c) => ({
86
+ key: c,
87
+ screens: [...l.get(c) ?? []].map(([t, o]) => ({ key: t, permissions: o.sort((a, u) => fe(a.verb) - fe(u.verb) || a.verb.localeCompare(u.verb)) })).sort((t, o) => t.key.localeCompare(o.key))
88
+ }));
89
+ }
90
+ function Je(s, l) {
91
+ const e = /* @__PURE__ */ new Set(), c = (t) => {
92
+ for (const o of s[t]?.requires ?? [])
93
+ e.has(o) || (e.add(o), c(o));
94
+ };
95
+ return c(l), [...e];
96
+ }
97
+ function Xe(s, l) {
98
+ const e = /* @__PURE__ */ new Set(), c = (t) => {
99
+ for (const [o, a] of Object.entries(s))
100
+ e.has(o) || !a.requires.includes(t) || (e.add(o), c(o));
101
+ };
102
+ return c(l), [...e];
103
+ }
104
+ function Ze(s, l, e) {
105
+ const c = Object.entries(s).filter(([o, a]) => a.ownable === e && o in l), t = c.find(([, o]) => o.verb === "view") ?? c[0];
106
+ return t ? l[t[0]] ?? null : null;
107
+ }
108
+ function es(s, l, e) {
109
+ for (const c of [e, ...Je(s, e)]) {
110
+ if (c in l || !(c in s)) continue;
111
+ const t = s[c]?.ownable;
112
+ l[c] = t ? Ze(s, l, t) ?? "own" : "all";
113
+ }
114
+ }
115
+ function ra(s, l, e) {
116
+ for (const c of [e, ...Xe(s, e)]) delete l[c];
117
+ }
118
+ function ia(s, l, e, c) {
119
+ for (const [t, o] of Object.entries(s)) o.ownable === e && t in l && (l[t] = c);
120
+ }
121
+ function ua(s, l) {
122
+ const e = new Set(Object.keys(l));
123
+ for (const c of e) es(s, l, c);
124
+ return Object.keys(l).filter((c) => !e.has(c));
125
+ }
126
+ function W() {
127
+ const { t: s, te: l } = H(), { catalogue: e, constraints: c } = Z(), t = (a, u) => {
128
+ const $ = a.find((p) => l(p));
129
+ return $ ? s($) : u;
130
+ }, o = (a) => t([`access.levels.${a}`, `core.access.levels.${a}`], a);
131
+ return {
132
+ roleName: (a) => a.key ? t([`access.roles.${a.key}`], a.name) : a.name,
133
+ permissionLabel: (a) => t(e[a]?.labelKey ? [e[a].labelKey] : [], a),
134
+ permissionDescription: (a) => t(e[a]?.descriptionKey ? [e[a].descriptionKey] : [], ""),
135
+ groupLabel: (a) => t([`access.modules.${a}`, ...a === G ? ["core.access.system_group"] : []], a),
136
+ screenLabel: (a) => t([`access.resources.${a}`], a),
137
+ ownableLabel: (a) => t([`access.ownable.${a.replace(/\./g, "_")}`], a),
138
+ qualifierLabel: (a) => s(`core.access.qualifier.${a}`),
139
+ qualifierHint: (a) => s(`core.access.qualifier_hint.${a}`),
140
+ qualifierNoun: (a) => s(`core.access.qualifier_noun.${a}`),
141
+ levelLabel: o,
142
+ /** A place: the level and its name (`Dealer · Auto Zagreb`); the root, which has no name, by its level. */
143
+ scopeLabel: (a) => a.name ? `${o(a.level)} · ${a.name}` : o(a.level),
144
+ /** A role's constraint as the application worded it (`Used only`); an attribute or value it gave no text for stays as `attribute: value`. */
145
+ constraintLabel: (a) => {
146
+ const u = c.find((p) => p.attribute === a.attribute)?.options ?? [], $ = a.values.map((p) => u.find((q) => q.value === p)?.labelKey);
147
+ return $.every((p) => p !== void 0 && l(p)) ? $.map((p) => s(p)).join(", ") : `${a.attribute}: ${a.values.join(", ")}`;
148
+ },
149
+ roleKind: (a) => s(`core.access.role_kind.${a.computed ? "computed" : a.predefined ? "predefined" : "custom"}`)
150
+ };
151
+ }
152
+ function ss(s) {
153
+ if (!te(s) || s.code !== "authz.invalid") return [];
154
+ const l = s.params?.problems;
155
+ return Array.isArray(l) ? l.flatMap((e) => {
156
+ if (typeof e != "object" || e === null || typeof e.code != "string") return [];
157
+ const { code: c, permission: t, detail: o } = e;
158
+ return [{ code: c, ...typeof t == "string" ? { permission: t } : {}, ...typeof o == "string" ? { detail: o } : {} }];
159
+ }) : [];
160
+ }
161
+ function we() {
162
+ const { t: s, te: l } = H(), e = Ke(), c = Oe() ? Ae(ye, null) : null, t = c ? W() : null;
163
+ return (o, a) => {
164
+ const u = ss(o);
165
+ if (u.length === 0) return e(o, a);
166
+ const $ = u.map((p) => {
167
+ const q = [c?.problems[p.code], `core.access.problems.${p.code}`].find((r) => r && l(r)), R = { code: p.code, permission: p.permission ? t?.permissionLabel(p.permission) ?? p.permission : "", detail: p.detail ?? "" };
168
+ return s(q ?? "core.access.problems.unknown", R);
169
+ });
170
+ return [...new Set($)].join(" ");
171
+ };
172
+ }
173
+ function as() {
174
+ const s = we();
175
+ return (l, e) => te(e) && e.code?.startsWith("authz.") ? s(e) : void 0;
176
+ }
177
+ function M(s, l) {
178
+ if (l === "user") return D;
179
+ const e = s[l];
180
+ if (!e) throw new Error(`vue-core access: no routes for ${l} subjects; pass accessFeature({ subjects: { ${l}: { base, bindable } } })`);
181
+ return {
182
+ bindable: x("GET", e.bindable),
183
+ subjectsAccess: x("GET", `${e.base}/:id/access`),
184
+ subjectsScopes: x("GET", `${e.base}/:id/scopes`),
185
+ subjectsBind: x("POST", `${e.base}/:id/bindings`),
186
+ subjectsUnbind: x("DELETE", `${e.base}/:id/bindings/:binding_id`)
187
+ };
188
+ }
189
+ function os(s, l = {}) {
190
+ return {
191
+ roles: async (e) => (await s.request(D.rolesList, void 0, e)).data.roles,
192
+ role: async (e, c) => (await s.request(D.rolesShow, { ref: e }, c)).data,
193
+ holders: async (e, c) => (await s.request(D.rolesHolders, { ref: e }, c)).data.holders,
194
+ compare: async (e, c, t) => (await s.request(D.rolesCompare, { ref: e, with: c }, t)).data,
195
+ create: async (e) => (await s.request(D.rolesCreate, e)).data,
196
+ update: async (e) => (await s.request(D.rolesUpdate, e)).data,
197
+ remove: async (e) => void await s.request(D.rolesDelete, { ref: e }),
198
+ replace: async (e, c) => (await s.request(D.rolesReplace, { ref: e, with: c })).data.rebound,
199
+ access: async (e, c) => (await s.request(M(l, e.kind).subjectsAccess, { id: e.id }, c)).data,
200
+ scopes: async (e, c) => (await s.request(M(l, e.kind).subjectsScopes, { id: e.id }, c)).data,
201
+ bindable: async (e, c, t, o) => (await s.request(M(l, e.kind).bindable, { level: c, scope_id: t ?? 0 }, o)).data.roles,
202
+ bind: async (e, c) => (await s.request(M(l, e.kind).subjectsBind, { id: e.id, ...c })).data,
203
+ unbind: async (e, c) => void await s.request(M(l, e.kind).subjectsUnbind, { id: e.id, binding_id: c })
204
+ };
205
+ }
206
+ const ke = () => os(We().http, Z().subjects);
207
+ function ts(s) {
208
+ const l = /* @__PURE__ */ new Map();
209
+ for (const t of s.places) l.set(t.level, t.parent_level);
210
+ const e = (t) => {
211
+ const o = [t], a = new Set(o);
212
+ for (let u = l.get(t); u !== void 0 && u !== s.root_level && l.has(u) && !a.has(u); u = l.get(u))
213
+ o.unshift(u), a.add(u);
214
+ return o;
215
+ }, c = [...l.keys()].map((t) => ({ level: t, chain: e(t) })).sort((t, o) => o.chain.length - t.chain.length || t.level.localeCompare(o.level));
216
+ return s.root ? [...c, { level: s.root_level, chain: [] }] : c;
217
+ }
218
+ const ns = (s) => s.filter((l) => l.chain.length > 0).sort((l, e) => l.chain.length - e.chain.length)[0] ?? s[0] ?? null;
219
+ function pe(s, l, e, c) {
220
+ const t = l.chain[e], o = l.chain[e + 1];
221
+ return s.places.filter(
222
+ (a) => a.level === t && (e === 0 || a.parent_level === l.chain[e - 1] && a.parent_id === c[e - 1]) && (o === void 0 || s.places.some((u) => u.level === o && u.parent_id === a.id))
223
+ );
224
+ }
225
+ const ls = {
226
+ class: "flex min-w-0 flex-col gap-group-gap",
227
+ "data-test": "add-role-sheet"
228
+ }, cs = {
229
+ key: 0,
230
+ class: "px-row-inset text-body text-content-destructive",
231
+ role: "alert",
232
+ "data-test": "scopes-failed"
233
+ }, rs = {
234
+ key: 1,
235
+ class: "px-row-inset text-body text-content-muted",
236
+ "data-test": "no-places"
237
+ }, is = {
238
+ key: 0,
239
+ class: "px-row-inset text-body text-content-muted",
240
+ "data-test": "roles-loading"
241
+ }, us = {
242
+ key: 1,
243
+ class: "px-row-inset text-body text-content-destructive",
244
+ role: "alert",
245
+ "data-test": "roles-failed"
246
+ }, ds = {
247
+ key: 2,
248
+ class: "px-row-inset text-body text-content-muted",
249
+ "data-test": "roles-none"
250
+ }, ms = {
251
+ key: 3,
252
+ "data-test": "bindable-roles"
253
+ }, fs = { class: "px-row-inset pb-1.5 text-footnote uppercase tracking-wide text-content-muted" }, ps = {
254
+ key: 4,
255
+ "data-test": "chosen-role"
256
+ }, vs = /* @__PURE__ */ X({
257
+ __name: "AddRoleDialog",
258
+ props: {
259
+ subject: {},
260
+ subjectLabel: {}
261
+ },
262
+ emits: ["added"],
263
+ setup(s, { expose: l, emit: e }) {
264
+ const c = s, t = e, { t: o } = H(), a = W(), u = ke(), { catalogue: $, scopes: p } = Z(), R = ze({
265
+ defaults: () => ({ level: null, place: null, role: null }),
266
+ validator: {
267
+ safeParse(i) {
268
+ const f = i, d = [
269
+ ...f.level === null || f.level !== v.value?.root_level && f.place === null ? [{ path: ["level"], message: o("core.access.add.choose_place") }] : [],
270
+ ...f.role === null ? [{ path: ["role"], message: o("core.access.add.choose_role") }] : []
271
+ ];
272
+ return d.length === 0 ? { success: !0, data: { level: f.level, place: f.place, role: f.role } } : { success: !1, error: { issues: d } };
273
+ }
274
+ },
275
+ failureMessage: as(),
276
+ run: (i) => u.bind(c.subject, { role_ref: i.role, level: i.level, scope_id: i.place }),
277
+ done: (i) => {
278
+ ae.success(o("core.access.added")), t("added", i);
279
+ }
280
+ }), r = R.form.values, v = O(null), y = O(!1), b = O([]), _ = O([]), L = O(!1), w = O(!1), k = T(() => v.value ? ts(v.value) : []), C = T(() => k.value.find((i) => i.level === r.level) ?? null), ne = T(() => k.value.length > 1), $e = T(() => {
281
+ const i = v.value, f = C.value;
282
+ return i && f ? f.chain.map((d, P) => ({ name: d, places: pe(i, f, P, b.value) })) : [];
283
+ }), xe = T(() => {
284
+ const i = C.value?.chain.length ?? 0, f = i ? b.value[i - 1] : null;
285
+ return v.value?.places.find((d) => d.level === C.value?.level && d.id === f)?.name ?? null;
286
+ }), ee = T(() => C.value !== null && C.value.chain.every((i, f) => b.value[f] != null));
287
+ function le(i) {
288
+ r.level = i, b.value = [], r.place = null;
289
+ }
290
+ function ce(i, f) {
291
+ const d = b.value.slice(0, i);
292
+ d[i] = f, b.value = d;
293
+ }
294
+ re([() => r.level, b, v], () => {
295
+ const i = v.value, f = C.value;
296
+ if (!(!i || !f)) {
297
+ for (let d = 0; d < f.chain.length; d++) {
298
+ if (b.value[d] != null) continue;
299
+ const P = pe(i, f, d, b.value);
300
+ P.length === 1 && P[0] && ce(d, P[0].id);
301
+ break;
302
+ }
303
+ r.place = f.chain.length === 0 ? null : b.value[f.chain.length - 1] ?? null;
304
+ }
305
+ }, { deep: !0 });
306
+ async function je() {
307
+ if (r.role = null, _.value = [], w.value = !1, !C.value || !ee.value) return;
308
+ L.value = !0;
309
+ const i = `${r.level}:${r.place}`;
310
+ try {
311
+ const f = await u.bindable(c.subject, C.value.level, r.place);
312
+ i === `${r.level}:${r.place}` && (_.value = f);
313
+ } catch {
314
+ i === `${r.level}:${r.place}` && (w.value = !0);
315
+ } finally {
316
+ L.value = !1;
317
+ }
318
+ }
319
+ re([() => r.level, () => r.place, ee], () => void je());
320
+ const qe = T(() => _.value.map((i) => ({ value: i.ref, label: a.roleName(i), description: a.roleKind(i) }))), I = T(() => _.value.find((i) => i.ref === r.role) ?? null), Le = T(() => {
321
+ const i = /* @__PURE__ */ new Map();
322
+ for (const f of I.value?.grants ?? []) {
323
+ const d = $[f.permission]?.ownable;
324
+ d && (!i.has(d) || f.permission.endsWith(":view")) && i.set(d, f.qualifier);
325
+ }
326
+ return [...i].map(([f, d]) => ({ ownable: f, qualifier: d }));
327
+ }), Ee = T(() => a.scopeLabel({ level: r.level ?? v.value?.root_level ?? "", name: xe.value }));
328
+ async function Ce() {
329
+ v.value = null, y.value = !1, b.value = [], _.value = [], R.present();
330
+ try {
331
+ v.value = p ? await p(c.subject, new AbortController().signal) : await u.scopes(c.subject);
332
+ } catch {
333
+ y.value = !0;
334
+ return;
335
+ }
336
+ const i = ns(k.value);
337
+ i && le(i.level);
338
+ }
339
+ return l({ present: Ce }), (i, f) => (m(), N(n(He), {
340
+ command: n(R),
341
+ title: n(o)("core.access.add_role"),
342
+ subtitle: c.subjectLabel,
343
+ size: "lg",
344
+ "confirm-label": n(o)("core.access.add.confirm")
345
+ }, {
346
+ default: h(() => [
347
+ S("div", ls, [
348
+ y.value ? (m(), g("p", cs, j(n(o)("core.access.add.scopes_failed")), 1)) : v.value && k.value.length === 0 ? (m(), g("p", rs, j(n(o)("core.access.add.no_places")), 1)) : A("", !0),
349
+ ne.value ? (m(), N(n(z), {
350
+ key: 2,
351
+ header: n(o)("core.access.add.scope_header")
352
+ }, {
353
+ default: h(() => [
354
+ E(n(Ve), {
355
+ "model-value": n(r).level,
356
+ label: n(o)("core.access.add.scope_level"),
357
+ options: k.value.map((d) => ({ value: d.level, label: n(a).levelLabel(d.level) })),
358
+ "onUpdate:modelValue": f[0] || (f[0] = (d) => le(d))
359
+ }, null, 8, ["model-value", "label", "options"]),
360
+ (m(!0), g(K, null, B($e.value, (d, P) => (m(), N(n(Ge), {
361
+ key: d.name,
362
+ "model-value": b.value[P] ?? null,
363
+ label: n(a).levelLabel(d.name),
364
+ options: d.places.map((Q) => ({ value: Q.id, label: Q.name })),
365
+ "onUpdate:modelValue": (Q) => ce(P, Q)
366
+ }, null, 8, ["model-value", "label", "options", "onUpdate:modelValue"]))), 128))
367
+ ]),
368
+ _: 1
369
+ }, 8, ["header"])) : A("", !0),
370
+ ee.value ? (m(), g(K, { key: 3 }, [
371
+ L.value ? (m(), g("p", is, j(n(o)("core.access.add.roles_loading")), 1)) : w.value ? (m(), g("p", us, j(n(o)("core.access.add.roles_failed")), 1)) : _.value.length === 0 ? (m(), g("p", ds, j(n(o)("core.access.add.no_roles")), 1)) : (m(), g("div", ms, [
372
+ S("p", fs, j(n(o)("core.access.add.role")), 1),
373
+ E(n(Me), {
374
+ options: qe.value,
375
+ "model-value": n(r).role,
376
+ onSelect: f[1] || (f[1] = (d) => n(r).role = d)
377
+ }, null, 8, ["options", "model-value"])
378
+ ]))
379
+ ], 64)) : A("", !0),
380
+ I.value ? (m(), g("div", ps, [
381
+ E(n(z), {
382
+ header: n(o)("core.access.add.role_gives"),
383
+ footer: n(o)("core.access.add.role_gives_footer")
384
+ }, {
385
+ default: h(() => [
386
+ E(n(U), {
387
+ layout: "setting",
388
+ label: n(a).roleName(I.value),
389
+ sub: I.value.description
390
+ }, null, 8, ["label", "sub"]),
391
+ (m(!0), g(K, null, B(Le.value, (d) => (m(), N(n(U), {
392
+ key: d.ownable,
393
+ layout: "setting",
394
+ label: n(a).ownableLabel(d.ownable),
395
+ value: `${n(a).qualifierNoun(d.qualifier)} · ${Ee.value}`
396
+ }, null, 8, ["label", "value"]))), 128))
397
+ ]),
398
+ _: 1
399
+ }, 8, ["header", "footer"])
400
+ ])) : A("", !0)
401
+ ])
402
+ ]),
403
+ _: 1
404
+ }, 8, ["command", "title", "subtitle", "confirm-label"]));
405
+ }
406
+ }), bs = {
407
+ class: "text-right text-footnote text-content-muted",
408
+ "data-test": "binding-scope"
409
+ }, _s = /* @__PURE__ */ X({
410
+ __name: "BindingRow",
411
+ props: {
412
+ binding: {}
413
+ },
414
+ setup(s) {
415
+ const l = s, e = W(), c = T(() => [e.roleKind(l.binding.role), ...l.binding.role.attrs.map(e.constraintLabel)].join(" · "));
416
+ return (t, o) => (m(), N(n(U), {
417
+ layout: "setting",
418
+ label: n(e).roleName(l.binding.role),
419
+ sub: c.value
420
+ }, ge({
421
+ leading: h(() => [
422
+ E(n(Ie), {
423
+ tone: l.binding.role.predefined ? "anchor" : "brand",
424
+ icon: "shieldStarFill"
425
+ }, null, 8, ["tone"])
426
+ ]),
427
+ default: h(() => [
428
+ S("span", bs, j(n(e).scopeLabel(l.binding.scope)), 1)
429
+ ]),
430
+ _: 2
431
+ }, [
432
+ t.$slots.trailing ? {
433
+ name: "trailing",
434
+ fn: h(() => [
435
+ De(t.$slots, "trailing")
436
+ ]),
437
+ key: "0"
438
+ } : void 0
439
+ ]), 1032, ["label", "sub"]));
440
+ }
441
+ }), ve = { own: 0, own_location: 1, all: 2 }, be = (s, l) => ve[l] > ve[s] ? l : s, Y = (s) => `${s.level}:${s.id ?? ""}`, se = ["view", "create", "update", "manage", "delete"], _e = (s) => se.includes(s) ? se.indexOf(s) : se.length;
442
+ function gs(s, l) {
443
+ const e = /* @__PURE__ */ new Map();
444
+ for (const t of l) {
445
+ if (t.grants.length === 0) continue;
446
+ const o = s[t.permission], [a = t.permission, u = ""] = t.permission.split(":"), $ = o ? oe(o) : a.split(".")[0] ?? a, p = o ? he(o) : a.replace(/\./g, "_"), q = o?.ownable != null, R = e.get($) ?? /* @__PURE__ */ new Map(), r = R.get(p) ?? { key: p, actions: [], sources: [], qualifier: null, scopes: [], ownable: !1, allUnavailable: !0 };
447
+ r.actions.push({ permission: t.permission, verb: o?.verb ?? u, unavailable: t.unavailable, grants: t.grants }), r.ownable || (r.ownable = q), r.allUnavailable && (r.allUnavailable = t.unavailable);
448
+ for (const v of t.grants) {
449
+ const y = q ? v.qualifier : "all";
450
+ r.scopes.some((_) => Y(_) === Y(v.scope)) || r.scopes.push(v.scope), q && (r.qualifier = r.qualifier ? be(r.qualifier, y) : y);
451
+ const b = r.sources.find((_) => _.roleName === v.role_name && Y(_.scope) === Y(v.scope));
452
+ b ? q && (r.sources[r.sources.indexOf(b)] = { ...b, qualifier: be(b.qualifier, y) }) : r.sources.push({ roleKey: v.role_key, roleName: v.role_name, qualifier: y, scope: v.scope });
453
+ }
454
+ R.set(p, r), e.set($, R);
455
+ }
456
+ return [...e.keys()].sort((t, o) => +(t === G) - +(o === G) || t.localeCompare(o)).map((t) => ({
457
+ key: t,
458
+ screens: [...e.get(t)?.values() ?? []].map((o) => ({
459
+ ...o,
460
+ actions: [...o.actions].sort((a, u) => _e(a.verb) - _e(u.verb) || a.verb.localeCompare(u.verb)),
461
+ // the root (the place without an id) first: what applies everywhere is what a reader looks for
462
+ scopes: [...o.scopes].sort((a, u) => +(u.id === null) - +(a.id === null))
463
+ })).sort((o, a) => o.key.localeCompare(a.key))
464
+ }));
465
+ }
466
+ const ys = {
467
+ class: "flex min-w-0 flex-col gap-group-gap",
468
+ "data-test": "effective-access"
469
+ }, hs = { class: "px-row-inset text-title3 font-semibold text-content-strong" }, ws = {
470
+ class: "block",
471
+ "data-test": "effective-actions"
472
+ }, ks = {
473
+ class: "block",
474
+ "data-test": "effective-sources"
475
+ }, $s = {
476
+ key: 0,
477
+ class: "mt-2 flex flex-col gap-1.5 border-l border-border-separator pl-3",
478
+ "data-test": "effective-why"
479
+ }, xs = ["data-permission"], js = { class: "text-content" }, qs = {
480
+ key: 0,
481
+ class: "ml-2 text-content-muted"
482
+ }, Ls = {
483
+ key: 0,
484
+ class: "contents",
485
+ "data-test": "effective-unavailable"
486
+ }, Es = {
487
+ class: "text-right text-footnote text-content-muted",
488
+ "data-test": "effective-reach"
489
+ }, Cs = ["data-test"], Rs = {
490
+ key: 0,
491
+ class: "contents",
492
+ "data-test": "effective-show-all"
493
+ }, Ts = /* @__PURE__ */ X({
494
+ __name: "EffectiveAccess",
495
+ props: {
496
+ effective: {},
497
+ name: {}
498
+ },
499
+ setup(s) {
500
+ const l = s, { t: e } = H(), { catalogue: c } = Z(), t = W(), o = Qe(), a = T(() => gs(c, l.effective)), u = O(!1), $ = T(() => o.value && !u.value ? a.value.slice(0, 3) : a.value), p = O({}), q = (v) => v.actions.map((y) => t.permissionLabel(y.permission)).join(" · "), R = (v) => v.sources.map((y) => {
501
+ const b = t.roleName({ key: y.roleKey, name: y.roleName });
502
+ return v.ownable ? `${b} (${t.qualifierNoun(y.qualifier).toLowerCase()})` : b;
503
+ }).join(", "), r = (v) => [v.qualifier ? t.qualifierNoun(v.qualifier) : "", v.scopes.map((y) => t.scopeLabel(y)).join(", ")].filter(Boolean).join(" · ");
504
+ return (v, y) => (m(), g("section", ys, [
505
+ S("h2", hs, j(n(e)("core.access.effective.title", { name: l.name })), 1),
506
+ a.value.length === 0 ? (m(), N(n(z), {
507
+ key: 0,
508
+ footer: n(e)("core.access.effective.footer")
509
+ }, {
510
+ default: h(() => [
511
+ E(n(U), {
512
+ layout: "setting",
513
+ label: n(e)("core.access.effective.empty")
514
+ }, null, 8, ["label"])
515
+ ]),
516
+ _: 1
517
+ }, 8, ["footer"])) : (m(), g(K, { key: 1 }, [
518
+ (m(!0), g(K, null, B($.value, (b) => (m(), N(n(z), {
519
+ key: b.key,
520
+ header: n(t).groupLabel(b.key),
521
+ footer: b === $.value[$.value.length - 1] ? n(e)("core.access.effective.footer") : void 0
522
+ }, {
523
+ default: h(() => [
524
+ (m(!0), g(K, null, B(b.screens, (_) => (m(), N(n(U), {
525
+ key: _.key,
526
+ layout: "setting",
527
+ label: n(t).screenLabel(_.key)
528
+ }, {
529
+ sub: h(() => [
530
+ S("span", ws, j(q(_)), 1),
531
+ S("span", ks, j(n(e)("core.access.effective.from_roles", { roles: R(_) })), 1),
532
+ p.value[_.key] ? (m(), g("ul", $s, [
533
+ (m(!0), g(K, null, B(_.actions, (L) => (m(), g("li", {
534
+ key: L.permission,
535
+ "data-permission": L.permission
536
+ }, [
537
+ S("span", js, j(n(t).permissionLabel(L.permission)), 1),
538
+ L.unavailable ? (m(), g("span", qs, j(n(e)("core.access.effective.unavailable")), 1)) : A("", !0),
539
+ (m(!0), g(K, null, B(L.grants, (w) => (m(), g("span", {
540
+ key: `${w.binding_id}-${w.scope.level}-${w.scope.id ?? 0}`,
541
+ class: "block text-content-muted"
542
+ }, j(n(e)("core.access.effective.why_row", {
543
+ role: n(t).roleName({ key: w.role_key, name: w.role_name }),
544
+ whose: n(t).qualifierNoun(_.ownable ? w.qualifier : "all"),
545
+ scope: n(t).scopeLabel(w.scope)
546
+ })), 1))), 128))
547
+ ], 8, xs))), 128))
548
+ ])) : A("", !0)
549
+ ]),
550
+ default: h(() => [
551
+ _.allUnavailable ? (m(), g("span", Ls, [
552
+ E(n(Ye), { tone: "warning" }, {
553
+ default: h(() => [
554
+ V(j(n(e)("core.access.effective.unavailable")), 1)
555
+ ]),
556
+ _: 1
557
+ })
558
+ ])) : A("", !0),
559
+ S("span", Es, j(r(_)), 1),
560
+ S("span", {
561
+ class: "contents",
562
+ "data-test": `why-${_.key}`
563
+ }, [
564
+ E(n(J), {
565
+ prominence: "secondary",
566
+ size: "sm",
567
+ onClick: (L) => p.value[_.key] = !p.value[_.key]
568
+ }, {
569
+ default: h(() => [
570
+ V(j(p.value[_.key] ? n(e)("core.access.effective.hide_why") : n(e)("core.access.effective.show_why")), 1)
571
+ ]),
572
+ _: 2
573
+ }, 1032, ["onClick"])
574
+ ], 8, Cs)
575
+ ]),
576
+ _: 2
577
+ }, 1032, ["label"]))), 128))
578
+ ]),
579
+ _: 2
580
+ }, 1032, ["header", "footer"]))), 128)),
581
+ n(o) && a.value.length > 3 ? (m(), g("span", Rs, [
582
+ E(n(J), {
583
+ prominence: "secondary",
584
+ class: "self-center",
585
+ onClick: y[0] || (y[0] = (b) => u.value = !u.value)
586
+ }, {
587
+ default: h(() => [
588
+ V(j(u.value ? n(e)("core.access.effective.fewer_modules") : n(e)("core.access.effective.all_modules", { count: a.value.length })), 1)
589
+ ]),
590
+ _: 1
591
+ })
592
+ ])) : A("", !0)
593
+ ], 64))
594
+ ]));
595
+ }
596
+ }), Ns = {
597
+ class: "flex min-w-0 flex-col gap-group-gap",
598
+ "data-test": "access-panel"
599
+ }, Ss = ["data-test"], Os = {
600
+ class: "contents",
601
+ "data-test": "add-role"
602
+ }, da = /* @__PURE__ */ X({
603
+ __name: "PersonAccess",
604
+ props: {
605
+ subject: {},
606
+ name: {},
607
+ subjectLabel: {}
608
+ },
609
+ emits: ["loaded"],
610
+ setup(s, { expose: l, emit: e }) {
611
+ const c = s, t = e, { t: o } = H(), a = W(), u = we(), $ = ke(), p = O(!1), q = Fe(async ({ signal: L, abandon: w }) => {
612
+ p.value = !1;
613
+ try {
614
+ const k = await $.access(c.subject, { signal: L });
615
+ return t("loaded", k.bindings.length), k;
616
+ } catch (k) {
617
+ if (!te(k) || k.kind !== "notFound") throw k;
618
+ return p.value = !0, w();
619
+ }
620
+ }, { watch: () => c.subject.id }), R = ie("addDialog"), r = ie("removeDialog");
621
+ async function v(L) {
622
+ await $.unbind(c.subject, L.id), ae.success(o("core.access.removed")), await q.reload();
623
+ }
624
+ const y = (L) => ae.error(u(L, { fallback: o("core.access.remove_failed") })), b = O(null), _ = T(() => b.value ? o("core.access.remove_body", { name: c.name, role: a.roleName(b.value.role), scope: a.scopeLabel(b.value.scope) }) : "");
625
+ return l({ reload: q.reload }), (L, w) => (m(), g("div", Ns, [
626
+ p.value ? (m(), N(n(Ue), {
627
+ key: 0,
628
+ title: n(o)("core.resource.not_found.title"),
629
+ description: n(o)("core.resource.not_found.body"),
630
+ icon: "errorWarningLine",
631
+ "data-test": "access-not-found"
632
+ }, null, 8, ["title", "description"])) : (m(), N(n(Be), {
633
+ key: 1,
634
+ state: n(q).state.value,
635
+ "skeleton-rows": 6,
636
+ "is-empty": () => !1,
637
+ onRetry: w[1] || (w[1] = (k) => n(q).reload())
638
+ }, {
639
+ default: h(({ value: k }) => [
640
+ E(n(z), {
641
+ header: n(o)("core.access.person_roles"),
642
+ footer: n(o)("core.access.roles_footer")
643
+ }, {
644
+ default: h(() => [
645
+ k.bindings.length === 0 ? (m(), N(n(U), {
646
+ key: 0,
647
+ layout: "setting",
648
+ label: n(o)("core.access.no_roles_title"),
649
+ sub: n(o)("core.access.no_roles_description")
650
+ }, null, 8, ["label", "sub"])) : A("", !0),
651
+ (m(!0), g(K, null, B(k.bindings, (C) => (m(), N(_s, {
652
+ key: C.id,
653
+ binding: C
654
+ }, ge({ _: 2 }, [
655
+ k.can_manage ? {
656
+ name: "trailing",
657
+ fn: h(() => [
658
+ E(n(ue), {
659
+ permission: n(F).manageBindings
660
+ }, {
661
+ default: h(() => [
662
+ S("span", {
663
+ class: "contents",
664
+ "data-test": `remove-binding-${C.id}`
665
+ }, [
666
+ E(n(J), {
667
+ tone: "critical",
668
+ prominence: "secondary",
669
+ size: "sm",
670
+ onClick: (ne) => (b.value = C, r.value?.present(C))
671
+ }, {
672
+ default: h(() => [
673
+ V(j(n(o)("core.access.remove")), 1)
674
+ ]),
675
+ _: 1
676
+ }, 8, ["onClick"])
677
+ ], 8, Ss)
678
+ ]),
679
+ _: 2
680
+ }, 1032, ["permission"])
681
+ ]),
682
+ key: "0"
683
+ } : void 0
684
+ ]), 1032, ["binding"]))), 128)),
685
+ k.can_manage ? (m(), N(n(ue), {
686
+ key: 1,
687
+ permission: n(F).manageBindings
688
+ }, {
689
+ default: h(() => [
690
+ E(n(U), { layout: "stacked" }, {
691
+ default: h(() => [
692
+ S("span", Os, [
693
+ E(n(J), {
694
+ prominence: "secondary",
695
+ icon: "addLine",
696
+ onClick: w[0] || (w[0] = (C) => R.value?.present())
697
+ }, {
698
+ default: h(() => [
699
+ V(j(n(o)("core.access.add_role")), 1)
700
+ ]),
701
+ _: 1
702
+ })
703
+ ])
704
+ ]),
705
+ _: 1
706
+ })
707
+ ]),
708
+ _: 1
709
+ }, 8, ["permission"])) : A("", !0)
710
+ ]),
711
+ _: 2
712
+ }, 1032, ["header", "footer"]),
713
+ E(Ts, {
714
+ effective: k.effective,
715
+ name: c.name
716
+ }, null, 8, ["effective", "name"])
717
+ ]),
718
+ _: 1
719
+ }, 8, ["state"])),
720
+ E(vs, {
721
+ ref_key: "addDialog",
722
+ ref: R,
723
+ subject: c.subject,
724
+ "subject-label": c.subjectLabel ?? c.name,
725
+ onAdded: w[2] || (w[2] = (k) => n(q).reload())
726
+ }, null, 8, ["subject", "subject-label"]),
727
+ E(n(Pe), {
728
+ ref_key: "removeDialog",
729
+ ref: r,
730
+ tone: "critical",
731
+ title: n(o)("core.access.remove_title"),
732
+ message: _.value,
733
+ "confirm-label": n(o)("core.access.remove"),
734
+ action: v,
735
+ onFailed: y
736
+ }, null, 8, ["title", "message", "confirm-label"])
737
+ ]));
738
+ }
739
+ });
740
+ export {
741
+ _s as _,
742
+ ke as a,
743
+ F as b,
744
+ de as c,
745
+ Z as d,
746
+ oe as e,
747
+ as as f,
748
+ es as g,
749
+ ua as h,
750
+ we as i,
751
+ da as j,
752
+ la as k,
753
+ D as l,
754
+ Xe as m,
755
+ na as n,
756
+ Ze as o,
757
+ ca as p,
758
+ Je as q,
759
+ ra as r,
760
+ ia as s,
761
+ ss as t,
762
+ W as u
763
+ };