@coffre/ui 0.14.4 → 0.15.0

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 (115) hide show
  1. package/dist/chunks/{audit-sentence-JgJEwQEC.js → actions-log-DupYCEyV.js} +186 -21
  2. package/dist/chunks/actions-log-DupYCEyV.js.map +1 -0
  3. package/dist/chunks/{connected-apps-IJdunsu8.js → connected-apps-CGUQlFMx.js} +5 -5
  4. package/dist/chunks/{connected-apps-IJdunsu8.js.map → connected-apps-CGUQlFMx.js.map} +1 -1
  5. package/dist/chunks/{delete-place-dIVoK87I.js → delete-place-CswZ-meh.js} +5 -5
  6. package/dist/chunks/{delete-place-dIVoK87I.js.map → delete-place-CswZ-meh.js.map} +1 -1
  7. package/dist/chunks/{directory-BM8yoiJN.js → directory-DrswWQLT.js} +15 -15
  8. package/dist/chunks/directory-DrswWQLT.js.map +1 -0
  9. package/dist/chunks/environment-actions-8rL9Cw6X.js +576 -0
  10. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +1 -0
  11. package/dist/chunks/{folders-D3A1NGpt.js → folders-A6sbR_PG.js} +3 -3
  12. package/dist/chunks/{folders-D3A1NGpt.js.map → folders-A6sbR_PG.js.map} +1 -1
  13. package/dist/chunks/{grants-CjVmOgb2.js → grants-C0cb2oii.js} +8 -8
  14. package/dist/chunks/grants-C0cb2oii.js.map +1 -0
  15. package/dist/chunks/{multi-combobox-B0JzP1QN.js → multi-combobox-B3SEv1gq.js} +3 -3
  16. package/dist/chunks/{multi-combobox-B0JzP1QN.js.map → multi-combobox-B3SEv1gq.js.map} +1 -1
  17. package/dist/chunks/{offboarding-DbozhPym.js → offboarding-C1jbG_dk.js} +72 -67
  18. package/dist/chunks/offboarding-C1jbG_dk.js.map +1 -0
  19. package/dist/chunks/{page-JTORvh-N.js → page-CfhC9Hp1.js} +11 -6
  20. package/dist/chunks/page-CfhC9Hp1.js.map +1 -0
  21. package/dist/chunks/{personal-tokens-zWZOzLIC.js → personal-tokens-xC9wulhg.js} +5 -5
  22. package/dist/chunks/{personal-tokens-zWZOzLIC.js.map → personal-tokens-xC9wulhg.js.map} +1 -1
  23. package/dist/chunks/{principal-DFBswTBr.js → principal-CI17XK13.js} +2 -2
  24. package/dist/chunks/{principal-DFBswTBr.js.map → principal-CI17XK13.js.map} +1 -1
  25. package/dist/chunks/{principal-page-jJ0RVFg8.js → principal-page-CdSeftGD.js} +17 -127
  26. package/dist/chunks/principal-page-CdSeftGD.js.map +1 -0
  27. package/dist/chunks/{project-page-BjwEoXfU.js → project-page-CHxjBE97.js} +3 -3
  28. package/dist/chunks/{project-page-BjwEoXfU.js.map → project-page-CHxjBE97.js.map} +1 -1
  29. package/dist/chunks/{queries-2jdgTwfZ.js → queries-D1JuimTu.js} +82 -26
  30. package/dist/chunks/queries-D1JuimTu.js.map +1 -0
  31. package/dist/chunks/{references-CRT2BsOS.js → references-D5llUGQL.js} +5 -5
  32. package/dist/chunks/{references-CRT2BsOS.js.map → references-D5llUGQL.js.map} +1 -1
  33. package/dist/chunks/{role-field-DswIpPqY.js → role-field-CoCv8wse.js} +5 -5
  34. package/dist/chunks/role-field-CoCv8wse.js.map +1 -0
  35. package/dist/chunks/{row-state-xtRGFnDc.js → row-state-CYH7kZHl.js} +3 -3
  36. package/dist/chunks/{row-state-xtRGFnDc.js.map → row-state-CYH7kZHl.js.map} +1 -1
  37. package/dist/chunks/{theme-Ck45wzWB.js → theme-rF44Wbmm.js} +3 -3
  38. package/dist/chunks/{theme-Ck45wzWB.js.map → theme-rF44Wbmm.js.map} +1 -1
  39. package/dist/chunks/{ui-D-blFWfx.js → ui-CGdORVzW.js} +2 -2
  40. package/dist/chunks/{ui-D-blFWfx.js.map → ui-CGdORVzW.js.map} +1 -1
  41. package/dist/chunks/{use-action-CXEFFjx5.js → use-action-BxrHTBZw.js} +3 -3
  42. package/dist/chunks/{use-action-CXEFFjx5.js.map → use-action-BxrHTBZw.js.map} +1 -1
  43. package/dist/chunks/{use-change-BC4xo02c.js → use-change-BorW2R6C.js} +4 -4
  44. package/dist/chunks/{use-change-BC4xo02c.js.map → use-change-BorW2R6C.js.map} +1 -1
  45. package/dist/chunks/{use-roles-DswiNxBk.js → use-roles-BZnJ9Cq0.js} +56 -13
  46. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +1 -0
  47. package/dist/chunks/{use-shell-zpjE_MKh.js → use-shell-CPskgi1k.js} +3 -3
  48. package/dist/chunks/{use-shell-zpjE_MKh.js.map → use-shell-CPskgi1k.js.map} +1 -1
  49. package/dist/index.d.ts +46 -2
  50. package/dist/index.js +30 -11
  51. package/dist/index.js.map +1 -1
  52. package/dist/pages/account.js +11 -11
  53. package/dist/pages/account.js.map +1 -1
  54. package/dist/pages/approval.js +2 -2
  55. package/dist/pages/audit.js +55 -21
  56. package/dist/pages/audit.js.map +1 -1
  57. package/dist/pages/device-login.js +2 -2
  58. package/dist/pages/environment.js +228 -389
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +3 -3
  61. package/dist/pages/oauth-authorize.js +2 -2
  62. package/dist/pages/project-access.js +11 -11
  63. package/dist/pages/project-environments.js +28 -359
  64. package/dist/pages/project-environments.js.map +1 -1
  65. package/dist/pages/project-settings.js +8 -8
  66. package/dist/pages/project.js +3 -3
  67. package/dist/pages/projects.js +8 -8
  68. package/dist/pages/service-account.js +11 -10
  69. package/dist/pages/service-account.js.map +1 -1
  70. package/dist/pages/service-accounts.js +7 -6
  71. package/dist/pages/service-accounts.js.map +1 -1
  72. package/dist/pages/settings.d.ts +6 -1
  73. package/dist/pages/settings.js +284 -164
  74. package/dist/pages/settings.js.map +1 -1
  75. package/dist/pages/unregistered.js +2 -2
  76. package/dist/pages/user.js +7 -6
  77. package/dist/pages/user.js.map +1 -1
  78. package/dist/pages/users.js +7 -6
  79. package/dist/pages/users.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/components/actions-log.tsx +61 -8
  82. package/src/components/directory.tsx +5 -5
  83. package/src/components/environment-actions.tsx +508 -0
  84. package/src/components/grants.tsx +2 -2
  85. package/src/components/icons.tsx +2 -0
  86. package/src/components/offboarding.tsx +7 -0
  87. package/src/components/page.tsx +3 -2
  88. package/src/components/principal-page.tsx +1 -1
  89. package/src/components/protected.tsx +52 -39
  90. package/src/components/role-editor.tsx +99 -68
  91. package/src/components/role-field.tsx +1 -1
  92. package/src/lib/audit-sentences.ts +24 -19
  93. package/src/lib/queries.ts +85 -21
  94. package/src/lib/roles.ts +36 -10
  95. package/src/options.ts +19 -3
  96. package/src/pages/account.tsx +1 -1
  97. package/src/pages/audit.tsx +56 -16
  98. package/src/pages/environment.tsx +227 -352
  99. package/src/pages/project-environments.tsx +20 -322
  100. package/src/pages/service-accounts.tsx +1 -1
  101. package/src/pages/settings.tsx +129 -48
  102. package/src/pages/users.tsx +1 -1
  103. package/src/parity.ts +18 -11
  104. package/src/styles/globals.css +271 -89
  105. package/dist/chunks/audit-sentence-JgJEwQEC.js.map +0 -1
  106. package/dist/chunks/directory-BM8yoiJN.js.map +0 -1
  107. package/dist/chunks/grants-CjVmOgb2.js.map +0 -1
  108. package/dist/chunks/offboarding-DbozhPym.js.map +0 -1
  109. package/dist/chunks/page-JTORvh-N.js.map +0 -1
  110. package/dist/chunks/principal-page-jJ0RVFg8.js.map +0 -1
  111. package/dist/chunks/protected-y7KVhtHd.js +0 -77
  112. package/dist/chunks/protected-y7KVhtHd.js.map +0 -1
  113. package/dist/chunks/queries-2jdgTwfZ.js.map +0 -1
  114. package/dist/chunks/role-field-DswIpPqY.js.map +0 -1
  115. package/dist/chunks/use-roles-DswiNxBk.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries-D1JuimTu.js","names":[],"sources":["../../src/lib/project-environments.ts","../../src/lib/capabilities.ts","../../src/lib/queries.ts"],"sourcesContent":["import type { ProjectSummary } from '../shared/models';\n\nexport type ProjectEnvironment = ProjectSummary['environments'][number];\nexport type DetailedProjectEnvironment = ProjectEnvironment & {\n details: NonNullable<ProjectEnvironment['details']>;\n};\n\nexport function hasEnvironmentDetails(\n environment: ProjectEnvironment,\n): environment is DetailedProjectEnvironment {\n return environment.details !== null;\n}\n\nexport function isActiveAccessibleEnvironment(\n environment: ProjectEnvironment,\n): environment is ProjectEnvironment & {\n accessible: true;\n details: { archivedAt: null; secretCount: number };\n} {\n return environment.accessible\n && environment.details !== null\n && environment.details.archivedAt === null;\n}\n","import { administers, makesProjects, ownsInstance } from '@coffre/core/access';\n\nimport type { Me, Permission, ProjectSummary } from '../shared/models';\n\n/**\n * The small set of instance-wide decisions the shell has to make.\n *\n * Resource-specific controls still use the permissions returned for that\n * project or environment. These are only the capabilities whose affordances\n * live outside one resource page.\n */\nexport type UiCapabilities = {\n /** Admins and owners, scoped or not: the Users and Service accounts pages. */\n canManageGrants: boolean;\n /**\n * Admins and owners whose scope narrows nothing: adding and removing\n * people and service accounts, instance roles, tokens and trust bindings,\n * offboarding reports, the instance's keys.\n */\n runsInstance: boolean;\n /**\n * Owners whose scope narrows nothing: they alone make someone an Owner,\n * and change or remove one, their own role included.\n */\n ownsInstance: boolean;\n /**\n * Who sets up service accounts: those who run the instance, and a person\n * who holds access somewhere the instance's setting takes in. The Service\n * accounts page lists them the ones they manage.\n */\n setsUpServices: boolean;\n canReadAudit: boolean;\n canCreateProject: boolean;\n};\n\nconst NONE: UiCapabilities = {\n canManageGrants: false,\n runsInstance: false,\n ownsInstance: false,\n setsUpServices: false,\n canReadAudit: false,\n canCreateProject: false,\n};\n\nexport function deriveUiCapabilities(\n me: Me | null,\n projects: readonly ProjectSummary[],\n): UiCapabilities {\n if (me === null) return NONE;\n\n const role = me.instanceRole;\n\n return {\n // Users and Service accounts list the instance's directory, for those\n // who manage access across projects. Project access managers keep their\n // grant controls on each project page.\n canManageGrants: administers(role),\n runsInstance: me.runsInstance,\n ownsInstance: ownsInstance({ role, scope: me.scope }),\n setsUpServices: me.setsUpServices,\n canReadAudit: me.canReadAudit,\n // A new project is one no `only` list names: as the server decides,\n // from the role and the scope, projects by slug.\n canCreateProject: makesProjects({ role, scope: me.scope, grants: [] }),\n };\n}\n\n/** Secret values are available only where the API reports secret.read. */\nexport function canRevealSecrets(permissions: readonly Permission[]): boolean {\n return permissions.includes('secret.read');\n}\n","import type { AuthInfo, CoffreClient, Member } from '@coffre/client';\nimport { EVERYWHERE, INSTANCE_ROLES } from '@coffre/core/access';\nimport { QueryClient, queryOptions, type FetchQueryOptions, type QueryKey } from '@tanstack/react-query';\n\nimport { deriveUiCapabilities } from './capabilities.ts';\nimport { memberRef, statusOf, uiResult } from './coffre.ts';\nimport { isActiveAccessibleEnvironment } from './project-environments.ts';\nimport type { DirectoryPrincipal, GrantRow, Me, ProjectSummary } from '../shared/models';\n\n/**\n * Every read the pages make, cached by TanStack Query: one cache per request\n * on the server, whose reads the page carries to the browser's, and one in the\n * browser for the whole visit.\n *\n * How fresh a page is. A read is reused for `FRESH_MS`, refetched when the\n * window regains focus, and refetched at once by any change made here, which\n * names what it touches (`affects`), so your own changes always show.\n * Someone else's change shows within that window. Nothing is decided on a\n * cached read: the server authorizes every call, so a stale screen can offer\n * an action the server then refuses, never grant one. The audit log is the\n * exception, read fresh on every visit: its whole point is to be current.\n * The chain's verification is read once a visit like the rest, and again\n * after any change made here.\n */\nexport const FRESH_MS = 10_000;\n\nexport function createQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: FRESH_MS,\n refetchOnWindowFocus: true,\n // A read either answers or says why it cannot (`uiResult`), so a\n // throw is a fault, and asking again would only repeat it.\n retry: false,\n },\n },\n });\n}\n\ntype Place = { project: string; environment: string };\n\n/**\n * The keys, which `affects` names too. A project's keys start with it, so\n * one invalidation covers everything read under it.\n */\nexport const keys = {\n me: ['me'],\n auth: ['auth'],\n projects: ['projects'],\n grants: (project: string) => ['grants', project],\n secrets: ({ project, environment }: Place) => ['secrets', project, environment],\n references: (path: string) => ['references', path],\n missing: ({ project, environment }: Place) => ['missing', project, environment],\n personal: (project: string) => ['personal', project],\n directory: ['directory'],\n report: (member: string) => ['report', member],\n memberAccess: (member: string) => ['member-access', member],\n credentials: (member: string) => ['credentials', member],\n bindings: (member: string) => ['bindings', member],\n githubRepositories: ['github-repositories'],\n tokenPlan: (member: string, scope: Record<string, string>) => ['token-plan', member, scope],\n identities: ['identities'],\n sessions: ['sessions'],\n apps: ['apps'],\n audit: ['audit'],\n auditKeys: ['audit', 'keys'],\n settings: ['settings'],\n roles: ['roles'],\n} satisfies Record<string, QueryKey | ((...args: never[]) => QueryKey)>;\n\n/** Members' grants, as rows, and a row for each one whose instance role reaches the place listed. */\nfunction grantRows(members: Member[]): GrantRow[] {\n return members.flatMap((member): GrantRow[] => [\n ...(member.reachesByRole\n ? [{\n id: `${member.member}/instance-role`,\n principalType: member.principalType,\n principalId: member.principalId,\n role: member.instanceRole,\n roleName: INSTANCE_ROLES[member.instanceRole].name,\n permissions: [...INSTANCE_ROLES[member.instanceRole].permissions],\n scope: 'instance-role' as const,\n environmentSlug: null,\n expiresAt: null,\n }]\n : []),\n ...member.grants.map((grant) => ({\n id: grant.id,\n principalType: member.principalType,\n principalId: member.principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? ('project' as const) : ('environment' as const),\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n ]);\n}\n\nfunction listDirectory(client: CoffreClient) {\n return uiResult(async () => {\n const { members, removed, reads } = await client.members.list();\n const principals: DirectoryPrincipal[] = members.map(\n ({ principalType, principalId, instanceRole, scope, tampered, managed, declared, grants }) => ({\n principalType,\n principalId,\n instanceRole,\n scope,\n tampered,\n managed,\n declared,\n grants: grants.map(({ project, environment }) => ({ project, environment })),\n }),\n );\n // How far reads are listed, under 0.15's log, which the counts of what the removed saw are as of (T166).\n return { principals, removed, ...(reads === undefined ? {} : { reads }) };\n });\n}\n\nconst readProjects = (client: CoffreClient) => uiResult(() => client.projects.list());\n\n/** The projects you can see, or why they could not be listed. */\nexport type ProjectsResult = Awaited<ReturnType<typeof readProjects>>;\n\nexport type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };\n\n/** Settings' tabs past the first, General, by their `?tab=`. */\nexport const SETTINGS_TABS = ['roles', 'keys'] as const;\nexport type SettingsTab = (typeof SETTINGS_TABS)[number];\n/** Settings' search: its tab, and on Roles, `roles=global` for the global roles rather than the project roles. */\nexport type SettingsSearch = { tab?: SettingsTab; roles?: 'global' };\n\nexport const AUDIT_PAGE_SIZE = 200;\n\nexport const queries = {\n /** Who is looking; null when nobody is signed in. */\n me: (client: CoffreClient) =>\n queryOptions({\n queryKey: keys.me,\n queryFn: async (): Promise<Me | null> => {\n try {\n return await client.me();\n } catch (error) {\n if (statusOf(error) === 401) return null;\n throw error;\n }\n },\n }),\n\n /** How this instance signs people in. */\n auth: (client: CoffreClient) => queryOptions({ queryKey: keys.auth, queryFn: (): Promise<AuthInfo> => client.auth() }),\n\n /** The projects you can see, each with its distinct secret count. */\n projects: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.projects, queryFn: () => readProjects(client) }),\n\n /**\n * The repositories the deployment's GitHub App is installed on, for the\n * Trust dialog's picker; `{ app: null }` without one. Each listing asks\n * GitHub, so it is kept a minute, and not asked again on focus.\n */\n githubRepositories: (client: CoffreClient) =>\n queryOptions({\n queryKey: keys.githubRepositories,\n queryFn: () => client.bindings.repositories(),\n staleTime: 60_000,\n refetchOnWindowFocus: false,\n }),\n\n /**\n * What a service's token would reach, as the server would issue it now,\n * and the sensitive values it would not read (`withheld`); issues\n * nothing. A scope the server refuses plans nothing: issuing says why.\n * Any other failure is one, asked once.\n */\n tokenPlan: (client: CoffreClient, member: string, scope: Record<string, string>) =>\n queryOptions({\n queryKey: keys.tokenPlan(member, scope),\n queryFn: () => client.tokens.preview(member, { label: null, expiresInDays: 1, scope }).catch((failure: unknown) => {\n const status = statusOf(failure);\n if (status !== undefined && status >= 400 && status < 500) return null;\n throw failure;\n }),\n staleTime: 60_000,\n refetchOnWindowFocus: false,\n retry: false,\n }),\n\n /** Who holds what in a project, for those who manage its access. */\n grants: (client: CoffreClient, project: string) =>\n queryOptions({\n queryKey: keys.grants(project),\n queryFn: () => uiResult(async () => ({ grants: grantRows((await client.members.list(project)).members) })),\n }),\n\n secrets: (client: CoffreClient, place: Place) =>\n queryOptions({\n queryKey: keys.secrets(place),\n queryFn: () => uiResult(() => client.secrets.list(`${place.project}/${place.environment}`)),\n }),\n\n /** What an environment lacks of its siblings' keys, read or not, and what its team dismissed. */\n missing: (client: CoffreClient, place: Place) =>\n queryOptions({\n queryKey: keys.missing(place),\n queryFn: () => uiResult(() => client.environments.missing(`${place.project}/${place.environment}`)),\n }),\n\n /** A project's personal configs, for whoever manages its environments: whose, of what, and their key names. */\n personal: (client: CoffreClient, project: string) =>\n queryOptions({\n queryKey: keys.personal(project),\n queryFn: () => uiResult(() => client.environments.personal(project)),\n }),\n\n /** The live references into and out of a place, and who reads through them, for whoever manages its access. */\n references: (client: CoffreClient, path: string) =>\n queryOptions({\n queryKey: keys.references(path),\n queryFn: () => uiResult(() => client.references.list(path)),\n }),\n\n /**\n * Everyone in the directory, and who was removed. The API shows grant\n * managers the members of their projects; the directory pages are admins'\n * and owners', and asking for anyone else would only log a refusal, so\n * nobody else is asked.\n */\n directory: (client: CoffreClient, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.directory, { owner }],\n queryFn: () =>\n owner\n ? listDirectory(client)\n : Promise.resolve({\n ok: false as const,\n error: 'Only admins and owners manage users, and service accounts are set up by those who hold access where the instance lets them.',\n signedOut: false,\n }),\n }),\n\n /**\n * One member's instance role and scope, and the grants you manage, in one\n * read: their page's Access tab. Null for whoever may list nobody, which\n * asking would only log as a refusal.\n */\n memberAccess: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.memberAccess(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.members.access(member)) : Promise.resolve(null)),\n }),\n\n /** What one member can reach and has seen; null for anyone but owners, who alone may ask. */\n report: (client: CoffreClient, member: string, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.report(member), { owner }],\n queryFn: () =>\n owner\n ? uiResult(async () => {\n try {\n return { report: await client.members.get(member) };\n } catch (error) {\n // No such member is an answer, not a failure.\n if (statusOf(error) === 404) return { report: null };\n throw error;\n }\n })\n : Promise.resolve(null),\n }),\n\n /**\n * A token's credentials; null where they cannot be listed. Only owners\n * issue and see them, and only coffre's own sign-in issues any.\n */\n credentials: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.credentials(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.tokens.list(member)) : Promise.resolve(null)),\n }),\n\n /**\n * A token's trust bindings: the CI runs that may sign in as it. Null for\n * anyone but an owner, and where the deployment trusts no workloads\n * (`features.workloads`), so there is nothing to ask.\n */\n bindings: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.bindings(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.bindings.list(member)) : Promise.resolve(null)),\n }),\n\n /** The accounts you sign in with, under coffre's own sign-in. */\n identities: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.identities, queryFn: () => uiResult(() => client.identities.list()) }),\n\n /** Where you are signed in, under coffre's own sign-in. */\n sessions: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.sessions, queryFn: () => uiResult(() => client.sessions.list()) }),\n /** The MCP clients I connected, where the deployment serves MCP (`features.mcp`). */\n apps: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.apps, queryFn: () => uiResult(() => client.apps.list()) }),\n\n /**\n * What the keys an operator keeps are checked against: the vault's ID and\n * the app key's fingerprint, no secret. Null for anyone but owners and root\n * admins, who alone may ask.\n */\n auditKeys: (client: CoffreClient, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.auditKeys, { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.audit.keys()) : Promise.resolve(null)),\n }),\n\n /** The instance's settings: null for anyone but those who run it, who alone may ask. */\n settings: (client: CoffreClient, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.settings, { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.settings.get()) : Promise.resolve(null)),\n }),\n\n /**\n * The instance's roles and instance roles, as an Owner edited and made\n * them (docs/design/roles.md), and whether the caller edits them. Any\n * member reads them: they are what every grant picker offers.\n */\n roles: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.roles, queryFn: () => uiResult(() => client.roles.list()) }),\n\n /** A page of the log, as filtered: always read fresh. */\n auditEntries: (client: CoffreClient, search: AuditSearch) =>\n queryOptions({\n queryKey: [...keys.audit, 'entries', search],\n staleTime: 0,\n // Detail is left out by the server unless asked for, and counted.\n queryFn: () =>\n uiResult(() =>\n client.audit.list({\n limit: AUDIT_PAGE_SIZE,\n decision: search.decision,\n actor: search.actorId,\n detail: search.detail,\n // What 0.15's sealed log alone records too: sign-ins through trust bindings, tokens' issues, revokes and sign-outs.\n sealed: '1',\n }),\n ),\n }),\n\n /**\n * Whether the log holds: verified with each visit, and rendered with the\n * page, the loader's read to carry to the browser: it is not asked again on\n * mount, and not for a filter change or a hover, which `FRESH_MS` covers.\n * It reads what was written since the newest checkpoint, so it takes as\n * long as five minutes of the log, however long the log. It never rejects:\n * a check that could not run is its verdict (`unknown`).\n */\n auditChain: (client: CoffreClient) =>\n queryOptions({ queryKey: [...keys.audit, 'chain'], refetchOnMount: false, queryFn: () => verifyChain(client) }),\n /** What deleting `market` or `market/prod` would take, asked afresh each time it is shown. */\n deletion: (client: CoffreClient, path: string) =>\n queryOptions({\n queryKey: ['deletion', path],\n staleTime: 0,\n gcTime: 0,\n queryFn: () =>\n uiResult(async () => {\n const { deletion } = path.includes('/')\n ? await client.environments.previewDelete(path)\n : await client.projects.previewDelete(path);\n return { deletion };\n }),\n }),\n};\n\n/**\n * Whether the log holds, or why that is not known. Verifying is for those\n * who read the whole log (an Auditor, Admin or Owner whose scope narrows\n * nothing): anyone else reads their projects' part of it, and a part cannot be\n * checked as a chain, so for them it is a fact about the page, not a fault.\n */\nasync function verifyChain(client: CoffreClient) {\n const [chain, trees] = await Promise.allSettled([client.audit.verify(), client.audit.verifyTrees()]);\n if (chain.status === 'rejected') return chainUnknown(chain.reason);\n return withTrees(chain.value, false, trees);\n}\n\n/**\n * 0.14's verdict with 0.15's check beside it, each settled apart: a check\n * of 0.15's log that could not run says so beside 0.14's verdict, never in\n * its place, on a visit and after a walk alike.\n */\nexport function withTrees(chain: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: PromiseSettledResult<TreesResult>) {\n if (trees.status === 'fulfilled') return chainResult(chain, whole, trees.value);\n // Whatever turned it away, a refusal included (access narrowed between the two, review r11): not checked, never \"Verified\".\n const failed = chainUnknown(trees.reason);\n const problem = failed.integrity === 'unknown' ? failed.problem : 'the request was refused (HTTP 403)';\n return { ...chainResult(chain, whole), ...(chain.ok ? { treesFailed: `coffre could not check the sealed log: ${problem}` } : {}) };\n}\n\n/** 0.15's log as its check found it (`audit.verifyTrees`): `kept` false where the instance keeps 0.14's alone. */\nexport type TreesResult = Awaited<ReturnType<CoffreClient['audit']['verifyTrees']>>;\n\n/**\n * 0.15's log checked whole, as a walk from the first entry has it: its trees\n * from the newest checkpoint, and the reads the pages list held to the uses\n * it sealed (`audit.verifyReads`, T166), whose problems are the log's.\n */\nexport async function wholeTrees(client: CoffreClient): Promise<TreesResult> {\n const [trees, reads] = await Promise.all([client.audit.verifyTrees(), client.audit.verifyReads()]);\n if (!trees.kept || !reads.kept || reads.ok) return trees;\n return { ...trees, ok: false, problems: [...trees.problems, ...reads.problems.map((problem) => `the reads' listing: ${problem}`)] };\n}\n\n/**\n * A verdict as the page shows it: `whole` when it comes from the walk\n * from the first entry, which someone asked for, not from the newest\n * checkpoint's. Where the instance keeps 0.15's log too, its check\n * (`trees`) is part of it: what it finds breaks the log as 0.14's would.\n */\nexport function chainResult(result: Awaited<ReturnType<CoffreClient['audit']['verify']>>, whole: boolean, trees: TreesResult = { kept: false }) {\n // More entries above the newest checkpoint than a check reads: a checkpointer behind, not a break (review r4 of W240).\n const behind = trees.kept && trees.capped;\n if (result.ok && trees.kept && trees.problems.length > 0) {\n const more = trees.problems.length - 1;\n return {\n integrity: 'broken' as const,\n through: result.through,\n failedAtSeq: null,\n author: 'vault' as const,\n reason: `the sealed log: ${trees.problems[0]}${more > 0 ? ` (and ${more} more)` : ''}`,\n };\n }\n return result.ok\n ? {\n integrity: 'intact' as const,\n whole,\n through: result.through,\n entries: result.entries,\n // A server older than 0.10.1 checked from the first entry, and reached the head.\n from: result.from ?? 0,\n remaining: result.remaining ?? 0,\n checkpoint: result.checkpoint,\n pending: result.pending ?? 0,\n /**\n * Why the check of 0.15's log could not run, or stopped short of its head (`treesBehind`): the chain's verdict\n * stands, the sealed log's is not known.\n */\n treesFailed: behind\n ? `coffre checked the sealed log's first ${trees.unsealed.toLocaleString('en')} entries above its newest checkpoint, not the rest: the checkpointer is behind`\n : (null as string | null),\n /** The sealed log checked, but not to its head: more entries wait above its newest checkpoint than a check reads. */\n treesBehind: behind,\n /** 0.15's log, where it is kept: the newest pair its check reached. */\n trees: trees.kept ? { checkpoint: trees.checkpoint, pending: trees.capped ? trees.unsealed : 0 } : null,\n }\n : {\n integrity: 'broken' as const,\n through: result.through,\n failedAtSeq: result.failedAtSeq,\n author: result.author,\n reason: result.reason,\n };\n}\n\n/**\n * What the page shows, of the check from the newest checkpoint (`quick`)\n * and the walk from the first entry, once someone ran it (`whole`). A break\n * the walk found stands; otherwise the newer check says how the log is now,\n * broken, partly checked or not checked at all; and only while it found the\n * log whole too does the walk's verdict, which read further back, stand\n * over it.\n *\n * whole broken → whole\n * whole intact, quick intact, 0 remaining, sealed log checked → whole\n * whole intact, quick anything else → quick\n *\n * A newer check that could not check the sealed log (review r10) is\n * \"anything else\": the walk's seal would stand over a log nobody can now\n * say holds.\n */\nexport function shownChain(quick: ChainResult, whole: ChainResult | null): ChainResult {\n if (whole === null || whole.integrity === 'broken') return whole ?? quick;\n return quick.integrity === 'intact' && quick.remaining === 0 && quick.treesFailed === null && whole.integrity === 'intact' ? whole : quick;\n}\n\n/** Why the log's verdict is not known: closed to the caller, or no answer. */\nexport function chainUnknown(error: unknown) {\n const status = statusOf(error);\n if (status === 403) return { integrity: 'owners-only' as const };\n return {\n integrity: 'unknown' as const,\n problem: status === undefined ? 'the request never got an answer' : `the request failed with HTTP ${status}`,\n };\n}\n\nexport type ChainResult = Awaited<ReturnType<typeof verifyChain>>;\n\n/**\n * Who is looking, how this instance signs people in, and the projects they\n * can see: what the shell needs on every screen. For someone signed out or\n * not yet a member the project list is refused, and they get the sign-in or\n * closed-door page.\n */\nexport function shellOf(\n auth: AuthInfo,\n me: Me | null,\n projects: ProjectsResult,\n) {\n const listed = projects.ok ? projects.projects : [];\n const member: Me | null = me?.registered === true ? me : null;\n return {\n auth,\n principal: me === null ? null : me.principal,\n instanceRole: member?.instanceRole ?? null,\n /** Where their instance role applies, projects by slug. */\n scope: member?.scope ?? EVERYWHERE,\n projects: listed,\n capabilities: deriveUiCapabilities(member, listed),\n registrationRequired: me !== null && !me.registered,\n /** A member the vault refuses: their record failed its integrity check. */\n accessTampered: me?.tampered === true,\n /** What the deployment's configuration turns on: MCP clients, as their endpoint's URL, and CI runs signing in by their ID tokens. */\n features: member?.features ?? { mcp: null, workloads: false },\n /** Every environment you hold something in, and what: what you may give a service account there (`givable`). */\n environments: member?.environments ?? [],\n /** Where you set up service accounts yourself, the instance's setting, projects by slug. */\n serviceSetup: member?.serviceSetup ?? null,\n };\n}\n\nexport type Shell = ReturnType<typeof shellOf>;\n\n/**\n * How a loader reads. `fresh`, a page's own reads: the cached answer within\n * `FRESH_MS`, else the network's, waited for. `cached`, a tab's: its page's\n * layout has read the same, so it takes the cached answer at once, however\n * old, and refetches behind it, and switching tabs never waits on the\n * network. A read the cache lacks is waited for either way.\n */\nexport type Freshness = 'fresh' | 'cached';\n\nfunction read<T, TKey extends QueryKey>(queryClient: QueryClient, options: FetchQueryOptions<T, Error, T, TKey>, freshness: Freshness): Promise<T> {\n return freshness === 'fresh' ? queryClient.fetchQuery(options) : queryClient.ensureQueryData({ ...options, revalidateIfStale: true });\n}\n\n/**\n * Whether a tab may open: from the cache, and where the cache says no, from\n * the network, which a no needs before the tab sends anyone away. A stale\n * no could be an account since added back, or a role since given.\n */\nexport async function tabOpens(opens: (freshness: Freshness) => Promise<boolean>): Promise<boolean> {\n return (await opens('cached')) || opens('fresh');\n}\n\n/**\n * The shell, as every loader reads it: from the cache while fresh, so a\n * child route never asks again for what the root has.\n */\nexport async function loadShell(queryClient: QueryClient, client: CoffreClient, freshness: Freshness = 'fresh'): Promise<Shell> {\n const [auth, me, projects] = await Promise.all([\n read(queryClient, queries.auth(client), freshness),\n read(queryClient, queries.me(client), freshness),\n read(queryClient, queries.projects(client), freshness),\n ]);\n return shellOf(auth, me, projects);\n}\n\n/**\n * One project and, when you manage its access, its grants. A project that is\n * not there for you fails with no message: the page words that itself.\n */\nexport function projectOf(projects: ProjectsResult, slug: string) {\n if (!projects.ok) return projects;\n const project = projects.projects.find((entry) => entry.slug === slug);\n if (project === undefined) return { ok: false as const, error: null };\n return { ok: true as const, project, managesAccess: project.permissions.includes('grant.manage') };\n}\n\n/** What a project page reads: the project list, and its grants when you manage them. */\nexport async function loadProject(queryClient: QueryClient, client: CoffreClient, slug: string) {\n const found = projectOf(await queryClient.fetchQuery(queries.projects(client)), slug);\n if (found.ok && found.managesAccess) await queryClient.fetchQuery(queries.grants(client, slug));\n}\n\n/**\n * What an environment's page reads: its secrets and, for whoever reads them,\n * the references that read them from elsewhere and the keys it lacks,\n * rendered with them. Where the project tree the shell holds says you read\n * it, all three are asked at once, one round trip; elsewhere the others wait\n * for the secrets, so a refused visit is one refusal in the log, not three.\n */\nexport async function loadEnvironment(queryClient: QueryClient, client: CoffreClient, place: Place) {\n const others = () =>\n Promise.all([\n queryClient.fetchQuery(queries.references(client, `${place.project}/${place.environment}`)),\n queryClient.fetchQuery(queries.missing(client, place)),\n ]);\n const found = projectOf(await queryClient.ensureQueryData(queries.projects(client)), place.project);\n // Neither in an archived project nor archived itself: the API serves neither.\n const here = found.ok && found.project.archivedAt === null\n ? found.project.environments.find((environment) => environment.slug === place.environment)\n : undefined;\n if (here !== undefined && isActiveAccessibleEnvironment(here)) {\n const [secrets] = await Promise.all([queryClient.fetchQuery(queries.secrets(client, place)), others()]);\n return secrets;\n }\n const secrets = await queryClient.fetchQuery(queries.secrets(client, place));\n if (secrets.ok) await others();\n return secrets;\n}\n\n/**\n * What the audit page reads: a page of the log and the verification from\n * the newest checkpoint, asked together and rendered together, so the badge\n * arrives with the page. The verification never fails the load: a check that\n * could not run is its verdict.\n */\nexport async function loadAudit(queryClient: QueryClient, client: CoffreClient, search: AuditSearch) {\n const [entries] = await Promise.all([\n queryClient.fetchQuery(queries.auditEntries(client, search)),\n queryClient.fetchQuery(queries.auditChain(client)),\n ]);\n return entries;\n}\n\n/** The directory pages' read: the directory, for owners. */\nexport async function loadDirectory(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n return queryClient.fetchQuery(queries.directory(client, shell.capabilities.canManageGrants));\n}\n\n/** The instance's settings: the directory's counts, where people set up service accounts, and what its keys are checked against. */\n/** What a tab of Settings reads, its own alone: General the directory and the instance's settings, Roles the roles, project and global alike, Keys the key checks. */\nexport async function loadSettings(queryClient: QueryClient, client: CoffreClient, tab: SettingsTab | undefined) {\n const { capabilities } = await loadShell(queryClient, client);\n if (tab === undefined) {\n await Promise.all([loadDirectory(queryClient, client), queryClient.fetchQuery(queries.settings(client, capabilities.runsInstance))]);\n } else if (tab === 'keys') {\n await queryClient.fetchQuery(queries.auditKeys(client, capabilities.runsInstance));\n } else {\n await queryClient.fetchQuery(queries.roles(client));\n }\n}\n\n/** Whether the Service accounts page lists anyone: to admins and owners, and to whoever sets one up, those they manage. */\nexport function listsServices(shell: Shell): boolean {\n return shell.capabilities.canManageGrants || shell.capabilities.setsUpServices;\n}\n\n/**\n * How the caller may have a service account sign in, from its list entry\n * or its access: bearer tokens under coffre's own sign-in, trusted\n * workloads where the deployment trusts them, each only for an account they\n * manage.\n */\nexport function waysFor(shell: Shell, managed: boolean): { tokens: boolean; workloads: boolean } {\n return { tokens: managed && shell.auth.signin !== null, workloads: managed && shell.features.workloads };\n}\n\n/**\n * The service accounts page: the directory, and each account's bindings and\n * tokens, read here as its own page reads them, so the list shows how each\n * signs in from the first paint and the browser asks for nothing that may be\n * refused (a deployment that trusts no workloads answers bindings with one).\n */\nexport async function loadServiceDirectory(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n const directory = await queryClient.fetchQuery(queries.directory(client, listsServices(shell)));\n if (!directory.ok) return directory;\n await Promise.all(\n directory.principals\n .filter((principal) => principal.principalType === 'service')\n .flatMap((principal) => {\n const member = memberRef('service', principal.principalId);\n const ways = waysFor(shell, principal.managed === true);\n return [\n queryClient.fetchQuery(queries.credentials(client, member, ways.tokens)),\n queryClient.fetchQuery(queries.bindings(client, member, ways.workloads)),\n ];\n }),\n );\n return directory;\n}\n\n/** Who a user or service account is to the instance, its pages' header: null to anyone who does not run it. */\nexport async function loadMember(queryClient: QueryClient, client: CoffreClient, member: string, freshness: Freshness = 'fresh') {\n const shell = await loadShell(queryClient, client, freshness);\n return read(queryClient, queries.report(client, member, shell.capabilities.runsInstance), freshness);\n}\n\nexport type MemberReport = Awaited<ReturnType<typeof loadMember>>;\n\n/**\n * What a user's or service account's Access tab reads: their role, scope\n * and the grants you manage, in one request, which the server answers in\n * one query, however many projects they hold grants in.\n */\nexport async function loadAccess(queryClient: QueryClient, client: CoffreClient, member: string, freshness: Freshness = 'fresh') {\n const shell = await loadShell(queryClient, client, freshness);\n return read(queryClient, queries.memberAccess(client, member, listsAccess(shell)), freshness);\n}\n\n/**\n * A user's or service account's page: what every tab but Activity shows,\n * read once by its layout, so its tabs open at once. Who they are, what they\n * hold and, for a service account, how it signs in.\n */\nexport async function loadPrincipal(queryClient: QueryClient, client: CoffreClient, principalType: 'user' | 'service', principalId: string) {\n const member = memberRef(principalType, principalId);\n await Promise.all([\n loadMember(queryClient, client, member),\n principalType === 'service' ? loadSignIn(queryClient, client, member) : loadAccess(queryClient, client, member),\n ]);\n}\n\n/**\n * A service account's Sign-in tab: its bearer tokens and trust bindings, as\n * far as its page shows them (`signInWays`), which it returns: null where it\n * shows neither.\n */\nexport async function loadSignIn(queryClient: QueryClient, client: CoffreClient, member: string, freshness: Freshness = 'fresh') {\n const [shell, access] = await Promise.all([\n loadShell(queryClient, client, freshness),\n loadAccess(queryClient, client, member, freshness),\n ]);\n const ways = signInWays(shell, access);\n if (ways !== null) {\n await Promise.all([\n read(queryClient, queries.credentials(client, member, ways.tokens), freshness),\n read(queryClient, queries.bindings(client, member, ways.workloads), freshness),\n ]);\n }\n return ways;\n}\n\n/**\n * Whether the caller may ask what someone holds: admins and owners,\n * whoever manages a project's access, and whoever sets up service accounts,\n * of those they manage.\n */\nexport function listsAccess(shell: Shell): boolean {\n return shell.capabilities.canManageGrants || shell.capabilities.setsUpServices || managedProjects(shell.projects).length > 0;\n}\n\nexport type MemberAccessResult = Awaited<ReturnType<typeof loadAccess>>;\n\n/**\n * How a service account's page lets it sign in: bearer tokens under\n * coffre's own sign-in, trusted workloads where the deployment trusts them.\n * Null where it shows neither: to anyone who does not manage it (its access\n * says, `managed`), and for an account that is not active, which can be\n * issued nothing.\n */\nexport function signInWays(shell: Shell, access: MemberAccessResult): { tokens: boolean; workloads: boolean } | null {\n const managed = access?.ok === true && access.managed && access.status === 'active';\n const ways = waysFor(shell, managed);\n return ways.tokens || ways.workloads ? ways : null;\n}\n\n/**\n * Whether a user has a Connected apps tab: for an owner, where the\n * deployment serves MCP, and while the user is registered and not removed,\n * since removal disconnects every app. The tab, and the route under it,\n * both ask.\n */\nexport function hasAppsTab(shell: Shell, report: MemberReport): boolean {\n const found = report?.ok === true ? report.report : null;\n return Boolean(shell.features.mcp) && shell.capabilities.runsInstance && found !== null && found.status !== 'removed';\n}\n\nexport function managedProjects(projects: ProjectSummary[]): ProjectSummary[] {\n return projects.filter((project) => project.permissions.includes('grant.manage'));\n}\n\n/**\n * What each change touches, which `useAction` refetches when it lands. Every\n * change also lands in the audit log, which is always read fresh.\n */\nexport const affects = {\n /**\n * A project or environment made, renamed or archived: the tree, where you\n * hold access, and the personal configs listed of it, which go with it.\n */\n places: (): QueryKey[] => [keys.projects, keys.me, ['personal']],\n /** Secrets written, renamed, restored or archived: the environment, the counts, and the personal configs' key names. */\n secrets: (place: Place): QueryKey[] => [keys.secrets(place), keys.projects, ['references'], ['missing'], ['personal']],\n /**\n * Someone's access in a project changed: its grants, their report, and, as\n * it may be your own, what you can see.\n */\n access: (project: string, member: string): QueryKey[] => [\n keys.grants(project),\n keys.memberAccess(member),\n keys.report(member),\n keys.projects,\n keys.me,\n ],\n /**\n * Someone let in: the directory, and whatever was read of them before\n * they were there, which said there was no such member: a new service\n * account's row asks how it signs in as soon as it shows.\n */\n admission: (member: string): QueryKey[] => [\n keys.directory,\n keys.report(member),\n keys.memberAccess(member),\n keys.credentials(member),\n keys.bindings(member),\n ],\n /**\n * An instance role changed: the directory, their report, and, as it may be\n * your own, what you can see and do.\n */\n role: (member: string): QueryKey[] => [keys.directory, keys.report(member), keys.memberAccess(member), keys.me, keys.projects],\n /** Someone removed: the directory, their report, and every grant, which removal ends, those on every project too. */\n removal: (member: string): QueryKey[] => [keys.directory, keys.report(member), keys.memberAccess(member), ['grants'], keys.projects],\n /**\n * Where people set up service accounts changed: the setting, and what you\n * may do, which the directory and `/me` say.\n */\n settings: (): QueryKey[] => [keys.settings, keys.me, keys.directory],\n /**\n * A role edited, made, reset or deleted, or an environment protected:\n * what everyone holds may change, so the roles, what you hold, and every\n * grant and environment read with what it holds.\n */\n roles: (): QueryKey[] => [keys.roles, keys.me, keys.projects, ['grants'], ['member-access'], ['secrets']],\n credentials: (member: string): QueryKey[] => [keys.credentials(member)],\n bindings: (member: string): QueryKey[] => [keys.bindings(member)],\n /** Unlinking an account also ends the sessions it signed in. */\n identities: (): QueryKey[] => [keys.identities, keys.sessions],\n sessions: (): QueryKey[] => [keys.sessions],\n apps: (): QueryKey[] => [keys.apps],\n};\n\n/**\n * Refetch what a change touched: at once where it is on screen, on next use\n * elsewhere. Every change lands in the audit log, so the log and its\n * verification are always among them.\n */\nexport async function refresh(queryClient: QueryClient, touched: QueryKey[]): Promise<void> {\n await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));\n}\n"],"mappings":";;;;AAOA,SAAgB,sBACd,aAC2C;CAC3C,OAAO,YAAY,YAAY;AACjC;AAEA,SAAgB,8BACd,aAIA;CACA,OAAO,YAAY,cACd,YAAY,YAAY,QACxB,YAAY,QAAQ,eAAe;AAC1C;;;ACaA,IAAM,OAAuB;CAC3B,iBAAiB;CACjB,cAAc;CACd,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,kBAAkB;AACpB;AAEA,SAAgB,qBACd,IACA,UACgB;CAChB,IAAI,OAAO,MAAM,OAAO;CAExB,MAAM,OAAO,GAAG;CAEhB,OAAO;EAIL,iBAAiB,YAAY,IAAI;EACjC,cAAc,GAAG;EACjB,cAAc,aAAa;GAAE;GAAM,OAAO,GAAG;EAAM,CAAC;EACpD,gBAAgB,GAAG;EACnB,cAAc,GAAG;EAGjB,kBAAkB,cAAc;GAAE;GAAM,OAAO,GAAG;GAAO,QAAQ,CAAC;EAAE,CAAC;CACvE;AACF;;AAGA,SAAgB,iBAAiB,aAA6C;CAC5E,OAAO,YAAY,SAAS,aAAa;AAC3C;;;;;;;;;;;;;;;;;;AC9CA,IAAa,WAAW;AAExB,SAAgB,oBAAiC;CAC/C,OAAO,IAAI,YAAY,EACrB,gBAAgB,EACd,SAAS;EACP,WAAW;EACX,sBAAsB;EAGtB,OAAO;CACT,EACF,EACF,CAAC;AACH;;;;;AAQA,IAAa,OAAO;CAClB,IAAI,CAAC,IAAI;CACT,MAAM,CAAC,MAAM;CACb,UAA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@ -1,8 +1,8 @@
1
- import { x as queries } from "./queries-2jdgTwfZ.js";
2
- import { a as ErrorLine, c as Notice, n as ConfirmDialog, s as Modal, u as Timestamp } from "./ui-D-blFWfx.js";
3
- import { g as ArrowRight, t as Card, u as useCoffre } from "./page-JTORvh-N.js";
1
+ import { x as queries } from "./queries-D1JuimTu.js";
2
+ import { a as ErrorLine, c as Notice, n as ConfirmDialog, s as Modal, u as Timestamp } from "./ui-CGdORVzW.js";
3
+ import { g as ArrowRight, t as Card, u as useCoffre } from "./page-CfhC9Hp1.js";
4
4
  import { i as secretKeyProblem } from "./validation-DiHIwZRA.js";
5
- import { t as useAction } from "./use-action-CXEFFjx5.js";
5
+ import { t as useAction } from "./use-action-BxrHTBZw.js";
6
6
  import { useEffect, useId, useState } from "react";
7
7
  import { Link } from "@tanstack/react-router";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -341,4 +341,4 @@ function ArchiveBlocked({ references }) {
341
341
  //#endregion
342
342
  export { ReferencesInto as a, ReferenceValue as i, LentReferences as n, archiveBlockers as o, MakeReference as r, referenceProblem as s, ArchiveBlocked as t };
343
343
 
344
- //# sourceMappingURL=references-CRT2BsOS.js.map
344
+ //# sourceMappingURL=references-D5llUGQL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"references-CRT2BsOS.js","names":[],"sources":["../../src/components/references.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { Link } from '@tanstack/react-router';\nimport type { ListedReference, ReferenceView, SecretKey } from '@coffre/client';\n\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { secretKeyProblem } from '../lib/validation';\nimport { ArrowRight } from './icons';\nimport { Card } from './page';\nimport { ConfirmDialog, ErrorLine, Modal, Notice, Timestamp } from './ui';\n\n/**\n * References: a secret read live through another (docs/design/environments.md).\n * The vault makes and checks each one; these only show them.\n */\n\n/** Why a reference does not read, in a few words; null while it does. */\nexport function referenceProblem(state: ReferenceView['state']): string | null {\n switch (state) {\n case 'live':\n return null;\n case 'broken':\n return 'Broken';\n case 'replaced':\n return 'No value';\n case 'source_archived':\n return 'Source archived';\n case 'source_deleted':\n return 'Source deleted';\n case 'source_is_reference':\n return 'Source is a reference';\n case 'source_empty':\n return 'Source has no value';\n }\n}\n\n/** A secret's path as a link to it, when you can open it there. */\nfunction SecretPath({ path, open }: { path: string; open: boolean }) {\n const [project, environment, key] = path.split('/') as [string, string, string];\n if (!open) {\n return (\n <span className=\"mono\" title=\"You can't open the source\">\n {path}\n </span>\n );\n }\n return (\n <Link className=\"mono\" to=\"/projects/$project/$environment\" params={{ project, environment }} search={{ filter: key }}>\n {path}\n </Link>\n );\n}\n\n/**\n * What a key that is a reference shows where its value would be: what it\n * reads, and, when it does not read, why. Reading it is a reveal like any\n * other, logged as a read of the source.\n */\nexport function ReferenceValue({ reference }: { reference: NonNullable<SecretKey['reference']> }) {\n const problem = referenceProblem(reference.state);\n return (\n <span className=\"reference-value\">\n <ArrowRight size={13} aria-label=\"A reference to\" />\n <SecretPath path={reference.source} open={reference.canOpenSource} />\n {problem !== null && (\n <span className=\"tag tag-red\" title={reference.endedBy === null ? undefined : `By ${reference.endedBy}`}>\n {problem}\n </span>\n )}\n </span>\n );\n}\n\n/**\n * The references that read a secret from elsewhere, under its row: where\n * each is held, who made it, who reads through it, and Break for those who\n * may.\n */\nexport function LentReferences({ references, onBreak }: { references: ListedReference[]; onBreak: (reference: ListedReference) => void }) {\n return (\n <ul className=\"lent-references\" aria-label=\"Read through references\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span>\n Read through <SecretPath path={reference.holder} open={false} />, made by {reference.createdBy.replace(/^user:/, '')}{' '}\n <Timestamp iso={reference.createdAt} display=\"relative\" />\n {reference.readers !== null && (\n <span className=\"cell-muted\">\n {' '}\n · {reference.readers.length === 0 ? 'no one reads it by a grant' : `${reference.readers.length} ${reference.readers.length === 1 ? 'person reads' : 'people read'} it: ${reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}`}\n </span>\n )}\n </span>\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => onBreak(reference)}>\n Break\n </button>\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Make a key a reference to a secret you read, by path: whoever reads its\n * environment reads that secret through it, as it changes. Paths you can\n * read are offered as you type.\n */\nexport function MakeReference({\n open,\n onOpenChange,\n holder,\n environments,\n onMake,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** `billing/prod/DATABASE_URL`. */\n holder: string;\n /** `market/prod`, each environment you read. */\n environments: readonly string[];\n onMake: (source: string) => void;\n}) {\n const [source, setSource] = useState('');\n const listId = useId();\n useEffect(() => {\n if (open) setSource('');\n }, [open]);\n const [project, environment, key] = source.split('/');\n const problem =\n source === '' ? null\n : source.split('/').length !== 3 || project === '' || environment === '' ? 'A secret, as project/environment/KEY.'\n : secretKeyProblem(key!);\n const holderEnvironment = holder.split('/').slice(0, 2).join('/');\n\n return (\n <Modal\n open={open}\n onOpenChange={onOpenChange}\n title={`Make ${holder.split('/')[2]} a reference`}\n description={`Whoever can read ${holderEnvironment} will read the secret you name, as it changes, even without access to its project. You need read access to that secret.`}\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n if (problem !== null || source === '') return;\n onMake(source);\n onOpenChange(false);\n }}\n >\n <label className=\"field\">\n <span className=\"label\">Secret to read</span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n list={listId}\n placeholder=\"market/prod/DATABASE_URL\"\n value={source}\n aria-invalid={problem !== null}\n onChange={(event) => setSource(event.target.value)}\n />\n <datalist id={listId}>\n {environments.map((each) => (\n <option key={each} value={`${each}/`} />\n ))}\n </datalist>\n <span className={`hint${problem !== null ? ' edit-note-error' : ''}`}>\n {problem ?? 'A reference cannot point at a reference: name the secret it reads.'}\n </span>\n </label>\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => onOpenChange(false)}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={source === '' || problem !== null}>\n Make reference\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n/**\n * A project's secrets that others read through references held elsewhere,\n * and who: on its access tab, beside the grants, since \"who can read this\"\n * includes them. Those who may break one, its source's access managers or\n * whoever writes where it is held, do it here.\n */\nexport function ReferencesInto({ project }: { project: string }) {\n const coffre = useCoffre();\n const { data } = useQuery(queries.references(coffre, project));\n const { run, error } = useAction();\n const [breaking, setBreaking] = useState<ListedReference | null>(null);\n const into = data?.ok === true ? data.references.filter((reference) => reference.source.startsWith(`${project}/`)) : [];\n if (into.length === 0) return null;\n return (\n <Card\n labelledBy=\"references-into\"\n title=\"Also readable through references\"\n description={`Secrets of ${project} that references elsewhere read. Whoever reads a reference's environment reads its source, with no grant here.`}\n >\n <div className=\"dt-wrap\">\n <table className=\"dt stacks\">\n <thead>\n <tr>\n <th>Secret</th>\n <th>Read through</th>\n <th>Readers</th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {into.map((reference) => (\n <tr key={reference.id}>\n <td className=\"mono\" data-label=\"Secret\">{reference.source}</td>\n <td data-label=\"Read through\">\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small className=\"cell-muted\">\n Made by {reference.createdBy.replace(/^user:/, '')} <Timestamp iso={reference.createdAt} display=\"relative\" />\n </small>\n </span>\n </td>\n <td data-label=\"Readers\">\n {reference.readers === null\n ? '—'\n : reference.readers.length === 0\n ? <span className=\"cell-muted\">No one, by a grant</span>\n : reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}\n </td>\n <td className=\"col-actions\">\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => setBreaking(reference)}>\n Break\n </button>\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {error !== null && <ErrorLine error={error} />}\n <ConfirmDialog\n open={breaking !== null}\n onOpenChange={(open) => !open && setBreaking(null)}\n title=\"Break this reference?\"\n body={breaking === null ? '' : `Whoever reads ${breaking.holder.split('/').slice(0, 2).join('/')} stops reading ${breaking.source} through it, and a run there refuses until ${breaking.holder.split('/')[2]} gets a value.`}\n confirmLabel=\"Break\"\n onConfirm={() => {\n const path = breaking!.holder;\n void run(() => coffre.references.break(path), { affects: [['references']] });\n }}\n />\n </Card>\n );\n}\n\n/**\n * The references that archiving `path` would stop, a project, an\n * environment or a key: those reading a secret in it, held outside it in a\n * place not archived itself (D58). Archiving is refused while any read\n * (D41); the server decides, and this shows the dialog what it will say.\n */\nexport function archiveBlockers(path: string, references: readonly ListedReference[]): ListedReference[] {\n const within = (secret: string) => secret === path || secret.startsWith(`${path}/`);\n return references.filter((reference) => reference.state === 'live' && !reference.holderArchived && within(reference.source) && !within(reference.holder));\n}\n\n/**\n * What an archive dialog shows while references read what it would\n * archive: each, and Break for those who may break it. Archive waits until\n * none is left.\n */\nexport function ArchiveBlocked({ references }: { references: readonly ListedReference[] }) {\n const coffre = useCoffre();\n const { run, error, pending } = useAction();\n if (references.length === 0) return null;\n const many = references.length > 1;\n return (\n <div className=\"archive-blocked\">\n <Notice tone=\"bad\">\n {many ? `${references.length} references read it` : 'A reference reads it'} from elsewhere. Break{' '}\n {many ? 'them' : 'it'} first: archiving would stop {many ? 'those reads' : 'that read'}.\n </Notice>\n <ul className=\"archive-blockers\" aria-label=\"References that read it\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small>\n reads <span className=\"mono\">{reference.source}</span>\n </small>\n </span>\n {reference.canBreak ? (\n <button\n type=\"button\"\n className=\"btn btn-sm btn-danger-outline\"\n disabled={pending}\n onClick={() => void run(() => coffre.references.break(reference.holder), { affects: [['references'], ['secrets']] })}\n >\n Break\n </button>\n ) : (\n <small className=\"cell-muted\">{`${reference.source.split('/')[0]}'s access managers, or whoever writes ${reference.holder.split('/').slice(0, 2).join('/')}, can break it`}</small>\n )}\n </li>\n ))}\n </ul>\n <p className=\"hint\">Once broken, a run where it is held refuses until that key gets a value of its own.</p>\n {error !== null && <ErrorLine error={error} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAA8C;CAC7E,QAAQ,OAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,gBACH,OAAO;CACX;AACF;;AAGA,SAAS,WAAW,EAAE,MAAM,QAAyC;CACnE,MAAM,CAAC,SAAS,aAAa,OAAO,KAAK,MAAM,GAAG;CAClD,IAAI,CAAC,MACH,OACE,oBAAC,QAAD;EAAM,WAAU;EAAO,OAAM;YAC1B;CACG,CAAA;CAGV,OACE,oBAAC,MAAD;EAAM,WAAU;EAAO,IAAG;EAAkC,QAAQ;GAAE;GAAS;EAAY;EAAG,QAAQ,EAAE,QAAQ,IAAI;YACjH;CACG,CAAA;AAEV;;;;;;AAOA,SAAgB,eAAe,EAAE,aAAiE;CAChG,MAAM,UAAU,iBAAiB,UAAU,KAAK;CAChD,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,oBAAC,YAAD;IAAY,MAAM;IAAI,cAAW;GAAkB,CAAA;GACnD,oBAAC,YAAD;IAAY,MAAM,UAAU;IAAQ,MAAM,UAAU;GAAgB,CAAA;GACnE,YAAY,QACX,oBAAC,QAAD;IAAM,WAAU;IAAc,OAAO,UAAU,YAAY,OAAO,KAAA,IAAY,MAAM,UAAU;cAC3F;GACG,CAAA;EAEJ;;AAEV;;;;;;AAOA,SAAgB,eAAe,EAAE,YAAY,WAA6F;CACxI,OACE,oBAAC,MAA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QAAD;IAAQ,MAAK;cAAb;KACG,OAAO,GAAG,WAAW,OAAO,uBAAuB;KAAuB;KAAuB;KACjG,OAAO,SAAS;KAAK;KAA8B,OAAO,gBAAgB;KAAY;IACjF;;GACR,oBAAC,MAAD;IAAI,WAAU;IAAmB,cAAW;cACzC,WAAW,KAAK,cACf,qBAAC,MAAD,EAAA,UAAA,CACE,qBAAC,QAAD;KAAM,WAAU;eAAhB,CACE,oBAAC,QAAD;MAAM,WAAU;gBAAQ,UAAU;KAAa,CAAA,GAC/C,qBAAC,SAAD,EAAA,UAAA,CAAO,UACC,oBAAC,QAAD;MAAM,WAAU;gBAAQ,UAAU;KAAa,CAAA,CAChD,EAAA,CAAA,CACH;QACL,UAAU,WACT,oBAAC,UAAD;KACE,MAAK;KACL,WAAU;KACV,UAAU;KACV,eAAe,KAAK,UAAU,OAAO,WAAW,MAAM,UAAU,MAAM,GAAG,EAAE,SAAS,CAAC,CAAC,YAAY,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;eACpH;IAEO,CAAA,IAER,oBAAC,SAAD;KAAO,WAAU;eAAc,GAAG,UAAU,OAAO,MAAM,GAAG,CAAC,CAAC,GAAG,wCAAwC,UAAU,OAAO,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAAuB,CAAA,CAElL,EAAA,GAnBK,UAAU,EAmBf,CACL;GACC,CAAA;GACJ,oBAAC,KAAD;IAAG,WAAU;cAAO;GAAsF,CAAA;GACzG,UAAU,QAAQ,oBAAC,WAAD,EAAkB,MAAQ,CAAA;EAC1C;;AAET"}
1
+ {"version":3,"file":"references-D5llUGQL.js","names":[],"sources":["../../src/components/references.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { Link } from '@tanstack/react-router';\nimport type { ListedReference, ReferenceView, SecretKey } from '@coffre/client';\n\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { secretKeyProblem } from '../lib/validation';\nimport { ArrowRight } from './icons';\nimport { Card } from './page';\nimport { ConfirmDialog, ErrorLine, Modal, Notice, Timestamp } from './ui';\n\n/**\n * References: a secret read live through another (docs/design/environments.md).\n * The vault makes and checks each one; these only show them.\n */\n\n/** Why a reference does not read, in a few words; null while it does. */\nexport function referenceProblem(state: ReferenceView['state']): string | null {\n switch (state) {\n case 'live':\n return null;\n case 'broken':\n return 'Broken';\n case 'replaced':\n return 'No value';\n case 'source_archived':\n return 'Source archived';\n case 'source_deleted':\n return 'Source deleted';\n case 'source_is_reference':\n return 'Source is a reference';\n case 'source_empty':\n return 'Source has no value';\n }\n}\n\n/** A secret's path as a link to it, when you can open it there. */\nfunction SecretPath({ path, open }: { path: string; open: boolean }) {\n const [project, environment, key] = path.split('/') as [string, string, string];\n if (!open) {\n return (\n <span className=\"mono\" title=\"You can't open the source\">\n {path}\n </span>\n );\n }\n return (\n <Link className=\"mono\" to=\"/projects/$project/$environment\" params={{ project, environment }} search={{ filter: key }}>\n {path}\n </Link>\n );\n}\n\n/**\n * What a key that is a reference shows where its value would be: what it\n * reads, and, when it does not read, why. Reading it is a reveal like any\n * other, logged as a read of the source.\n */\nexport function ReferenceValue({ reference }: { reference: NonNullable<SecretKey['reference']> }) {\n const problem = referenceProblem(reference.state);\n return (\n <span className=\"reference-value\">\n <ArrowRight size={13} aria-label=\"A reference to\" />\n <SecretPath path={reference.source} open={reference.canOpenSource} />\n {problem !== null && (\n <span className=\"tag tag-red\" title={reference.endedBy === null ? undefined : `By ${reference.endedBy}`}>\n {problem}\n </span>\n )}\n </span>\n );\n}\n\n/**\n * The references that read a secret from elsewhere, under its row: where\n * each is held, who made it, who reads through it, and Break for those who\n * may.\n */\nexport function LentReferences({ references, onBreak }: { references: ListedReference[]; onBreak: (reference: ListedReference) => void }) {\n return (\n <ul className=\"lent-references\" aria-label=\"Read through references\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span>\n Read through <SecretPath path={reference.holder} open={false} />, made by {reference.createdBy.replace(/^user:/, '')}{' '}\n <Timestamp iso={reference.createdAt} display=\"relative\" />\n {reference.readers !== null && (\n <span className=\"cell-muted\">\n {' '}\n · {reference.readers.length === 0 ? 'no one reads it by a grant' : `${reference.readers.length} ${reference.readers.length === 1 ? 'person reads' : 'people read'} it: ${reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}`}\n </span>\n )}\n </span>\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => onBreak(reference)}>\n Break\n </button>\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Make a key a reference to a secret you read, by path: whoever reads its\n * environment reads that secret through it, as it changes. Paths you can\n * read are offered as you type.\n */\nexport function MakeReference({\n open,\n onOpenChange,\n holder,\n environments,\n onMake,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** `billing/prod/DATABASE_URL`. */\n holder: string;\n /** `market/prod`, each environment you read. */\n environments: readonly string[];\n onMake: (source: string) => void;\n}) {\n const [source, setSource] = useState('');\n const listId = useId();\n useEffect(() => {\n if (open) setSource('');\n }, [open]);\n const [project, environment, key] = source.split('/');\n const problem =\n source === '' ? null\n : source.split('/').length !== 3 || project === '' || environment === '' ? 'A secret, as project/environment/KEY.'\n : secretKeyProblem(key!);\n const holderEnvironment = holder.split('/').slice(0, 2).join('/');\n\n return (\n <Modal\n open={open}\n onOpenChange={onOpenChange}\n title={`Make ${holder.split('/')[2]} a reference`}\n description={`Whoever can read ${holderEnvironment} will read the secret you name, as it changes, even without access to its project. You need read access to that secret.`}\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n if (problem !== null || source === '') return;\n onMake(source);\n onOpenChange(false);\n }}\n >\n <label className=\"field\">\n <span className=\"label\">Secret to read</span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n list={listId}\n placeholder=\"market/prod/DATABASE_URL\"\n value={source}\n aria-invalid={problem !== null}\n onChange={(event) => setSource(event.target.value)}\n />\n <datalist id={listId}>\n {environments.map((each) => (\n <option key={each} value={`${each}/`} />\n ))}\n </datalist>\n <span className={`hint${problem !== null ? ' edit-note-error' : ''}`}>\n {problem ?? 'A reference cannot point at a reference: name the secret it reads.'}\n </span>\n </label>\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => onOpenChange(false)}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={source === '' || problem !== null}>\n Make reference\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n/**\n * A project's secrets that others read through references held elsewhere,\n * and who: on its access tab, beside the grants, since \"who can read this\"\n * includes them. Those who may break one, its source's access managers or\n * whoever writes where it is held, do it here.\n */\nexport function ReferencesInto({ project }: { project: string }) {\n const coffre = useCoffre();\n const { data } = useQuery(queries.references(coffre, project));\n const { run, error } = useAction();\n const [breaking, setBreaking] = useState<ListedReference | null>(null);\n const into = data?.ok === true ? data.references.filter((reference) => reference.source.startsWith(`${project}/`)) : [];\n if (into.length === 0) return null;\n return (\n <Card\n labelledBy=\"references-into\"\n title=\"Also readable through references\"\n description={`Secrets of ${project} that references elsewhere read. Whoever reads a reference's environment reads its source, with no grant here.`}\n >\n <div className=\"dt-wrap\">\n <table className=\"dt stacks\">\n <thead>\n <tr>\n <th>Secret</th>\n <th>Read through</th>\n <th>Readers</th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {into.map((reference) => (\n <tr key={reference.id}>\n <td className=\"mono\" data-label=\"Secret\">{reference.source}</td>\n <td data-label=\"Read through\">\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small className=\"cell-muted\">\n Made by {reference.createdBy.replace(/^user:/, '')} <Timestamp iso={reference.createdAt} display=\"relative\" />\n </small>\n </span>\n </td>\n <td data-label=\"Readers\">\n {reference.readers === null\n ? '—'\n : reference.readers.length === 0\n ? <span className=\"cell-muted\">No one, by a grant</span>\n : reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}\n </td>\n <td className=\"col-actions\">\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => setBreaking(reference)}>\n Break\n </button>\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {error !== null && <ErrorLine error={error} />}\n <ConfirmDialog\n open={breaking !== null}\n onOpenChange={(open) => !open && setBreaking(null)}\n title=\"Break this reference?\"\n body={breaking === null ? '' : `Whoever reads ${breaking.holder.split('/').slice(0, 2).join('/')} stops reading ${breaking.source} through it, and a run there refuses until ${breaking.holder.split('/')[2]} gets a value.`}\n confirmLabel=\"Break\"\n onConfirm={() => {\n const path = breaking!.holder;\n void run(() => coffre.references.break(path), { affects: [['references']] });\n }}\n />\n </Card>\n );\n}\n\n/**\n * The references that archiving `path` would stop, a project, an\n * environment or a key: those reading a secret in it, held outside it in a\n * place not archived itself (D58). Archiving is refused while any read\n * (D41); the server decides, and this shows the dialog what it will say.\n */\nexport function archiveBlockers(path: string, references: readonly ListedReference[]): ListedReference[] {\n const within = (secret: string) => secret === path || secret.startsWith(`${path}/`);\n return references.filter((reference) => reference.state === 'live' && !reference.holderArchived && within(reference.source) && !within(reference.holder));\n}\n\n/**\n * What an archive dialog shows while references read what it would\n * archive: each, and Break for those who may break it. Archive waits until\n * none is left.\n */\nexport function ArchiveBlocked({ references }: { references: readonly ListedReference[] }) {\n const coffre = useCoffre();\n const { run, error, pending } = useAction();\n if (references.length === 0) return null;\n const many = references.length > 1;\n return (\n <div className=\"archive-blocked\">\n <Notice tone=\"bad\">\n {many ? `${references.length} references read it` : 'A reference reads it'} from elsewhere. Break{' '}\n {many ? 'them' : 'it'} first: archiving would stop {many ? 'those reads' : 'that read'}.\n </Notice>\n <ul className=\"archive-blockers\" aria-label=\"References that read it\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small>\n reads <span className=\"mono\">{reference.source}</span>\n </small>\n </span>\n {reference.canBreak ? (\n <button\n type=\"button\"\n className=\"btn btn-sm btn-danger-outline\"\n disabled={pending}\n onClick={() => void run(() => coffre.references.break(reference.holder), { affects: [['references'], ['secrets']] })}\n >\n Break\n </button>\n ) : (\n <small className=\"cell-muted\">{`${reference.source.split('/')[0]}'s access managers, or whoever writes ${reference.holder.split('/').slice(0, 2).join('/')}, can break it`}</small>\n )}\n </li>\n ))}\n </ul>\n <p className=\"hint\">Once broken, a run where it is held refuses until that key gets a value of its own.</p>\n {error !== null && <ErrorLine error={error} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAA8C;CAC7E,QAAQ,OAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,gBACH,OAAO;CACX;AACF;;AAGA,SAAS,WAAW,EAAE,MAAM,QAAyC;CACnE,MAAM,CAAC,SAAS,aAAa,OAAO,KAAK,MAAM,GAAG;CAClD,IAAI,CAAC,MACH,OACE,oBAAC,QAAD;EAAM,WAAU;EAAO,OAAM;YAC1B;CACG,CAAA;CAGV,OACE,oBAAC,MAAD;EAAM,WAAU;EAAO,IAAG;EAAkC,QAAQ;GAAE;GAAS;EAAY;EAAG,QAAQ,EAAE,QAAQ,IAAI;YACjH;CACG,CAAA;AAEV;;;;;;AAOA,SAAgB,eAAe,EAAE,aAAiE;CAChG,MAAM,UAAU,iBAAiB,UAAU,KAAK;CAChD,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,oBAAC,YAAD;IAAY,MAAM;IAAI,cAAW;GAAkB,CAAA;GACnD,oBAAC,YAAD;IAAY,MAAM,UAAU;IAAQ,MAAM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@@
1
- import { st as X } from "./page-JTORvh-N.js";
2
- import { t as useShell } from "./use-shell-zpjE_MKh.js";
1
+ import { ct as X } from "./page-CfhC9Hp1.js";
2
+ import { t as useShell } from "./use-shell-CPskgi1k.js";
3
3
  import { a as slugProblem } from "./validation-DiHIwZRA.js";
4
- import { t as useRoles } from "./use-roles-DswiNxBk.js";
4
+ import { t as useRoles } from "./use-roles-BZnJ9Cq0.js";
5
5
  import { useId, useState } from "react";
6
6
  import { INSTANCE_ROLE_NAMES } from "@coffre/core/access";
7
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -23,7 +23,7 @@ function RoleField({ value, onChange }) {
23
23
  children: [
24
24
  /* @__PURE__ */ jsx("span", {
25
25
  className: "label",
26
- children: "Role"
26
+ children: "Global role"
27
27
  }),
28
28
  /* @__PURE__ */ jsx("select", {
29
29
  className: "select",
@@ -199,4 +199,4 @@ function NamePicker({ label, names, options, free, onChange }) {
199
199
  //#endregion
200
200
  export { ScopeField as n, RoleField as t };
201
201
 
202
- //# sourceMappingURL=role-field-DswIpPqY.js.map
202
+ //# sourceMappingURL=role-field-CoCv8wse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-field-CoCv8wse.js","names":[],"sources":["../../src/components/role-field.tsx"],"sourcesContent":["import { useId, useState } from 'react';\nimport { INSTANCE_ROLE_NAMES, type Filter, type InstanceRole, type Scope } from '@coffre/core/access';\nimport type { RoleVars } from '../lib/changes';\nimport { useShell } from '../lib/use-shell';\nimport { useRoles } from '../lib/use-roles';\nimport { slugProblem } from '../lib/validation';\nimport { X } from './icons';\n\n/**\n * A person's instance role, one dropdown, and under it, for every role but\n * Member, where it applies: projects and environments, each All, Only or\n * All except. Projects are picked from those there are; environments are\n * names, so any slug goes, the ones made later too. Owner is offered only\n * to an Owner of the whole instance, who alone makes one.\n */\nexport function RoleField({ value, onChange }: { value: RoleVars; onChange: (value: RoleVars) => void }) {\n const { role, scope } = value;\n const owners = useShell().capabilities.ownsInstance;\n // As the instance defines them: an Owner may have renamed or redescribed one.\n const { instanceRoles } = useRoles();\n const shown = (name: InstanceRole) => instanceRoles.find((each) => each.id === name);\n return (\n <>\n <label className=\"field\">\n <span className=\"label\">Global role</span>\n <select\n className=\"select\"\n value={role}\n onChange={(event) => onChange({ role: event.target.value as InstanceRole, scope })}\n >\n {INSTANCE_ROLE_NAMES.filter((name) => owners || name !== 'owner').map((name) => (\n <option key={name} value={name}>\n {shown(name)?.name ?? name}\n </option>\n ))}\n </select>\n <span className=\"hint\">\n Default permissions: {shown(role)?.description} Project grants add more.\n {!owners && ' Only an Owner makes someone an Owner.'}\n </span>\n </label>\n {role !== 'member' && <ScopeField scope={scope} onChange={(next) => onChange({ role, scope: next })} />}\n </>\n );\n}\n\n/**\n * Where something applies: projects and environments, each All, Only or All\n * except. A role's scope, and the instance's setting of where people set\n * up service accounts, which has the same shape.\n */\nexport function ScopeField({ scope, onChange, legend = 'Where' }: { scope: Scope; onChange: (scope: Scope) => void; legend?: string }) {\n const { projects } = useShell();\n const slugs = [...new Set(projects.flatMap((project) => project.environments.map((environment) => environment.slug)))].sort();\n return (\n <fieldset className=\"field scope-field\">\n <legend className=\"label\">{legend}</legend>\n <FilterRow\n label=\"Projects\"\n filter={scope.projects}\n options={projects.map((project) => project.slug)}\n onChange={(filter) => onChange({ ...scope, projects: filter })}\n />\n <FilterRow\n label=\"Environments\"\n filter={scope.environments}\n options={slugs}\n free\n onChange={(filter) => onChange({ ...scope, environments: filter })}\n />\n {scope.environments !== 'all' && <span className=\"hint\">Environments match by name in every project, new ones included.</span>}\n </fieldset>\n );\n}\n\ntype Mode = 'all' | 'only' | 'except';\n\nconst namesOf = (filter: Filter): string[] => (filter === 'all' ? [] : 'only' in filter ? filter.only : filter.except);\n\nfunction filterOf(mode: Mode, names: string[]): Filter {\n return mode === 'all' ? 'all' : mode === 'only' ? { only: names } : { except: names };\n}\n\n/** One filter: All, Only or All except, and the names it lists. */\nfunction FilterRow({\n label,\n filter,\n options,\n free = false,\n onChange,\n}: {\n label: string;\n filter: Filter;\n options: string[];\n /** Whether a name need not be among `options`: an environment's slug, which may come later. */\n free?: boolean;\n onChange: (filter: Filter) => void;\n}) {\n const mode: Mode = filter === 'all' ? 'all' : 'only' in filter ? 'only' : 'except';\n const names = namesOf(filter);\n return (\n <div className=\"scope-row\">\n <span className=\"scope-label\">{label}</span>\n <select\n className=\"select select-sm\"\n aria-label={`${label}: which`}\n value={mode}\n onChange={(event) => onChange(filterOf(event.target.value as Mode, names))}\n >\n <option value=\"all\">All</option>\n <option value=\"only\">Only</option>\n <option value=\"except\">All except</option>\n </select>\n {mode !== 'all' && (\n <NamePicker label={label} names={names} options={options} free={free} onChange={(next) => onChange(filterOf(mode, next))} />\n )}\n </div>\n );\n}\n\n/** Names as chips, and a field to add one: picked from the list, or, where any name goes, typed and entered. */\nfunction NamePicker({\n label,\n names,\n options,\n free,\n onChange,\n}: {\n label: string;\n names: string[];\n options: string[];\n free: boolean;\n onChange: (names: string[]) => void;\n}) {\n const [draft, setDraft] = useState('');\n const list = useId();\n const add = (raw: string) => {\n const name = raw.trim();\n setDraft('');\n if (name === '' || names.includes(name)) return;\n if (free ? slugProblem(name) !== null : !options.includes(name)) return;\n onChange([...names, name]);\n };\n const offered = options.filter((option) => !names.includes(option));\n return (\n <span className=\"scope-names\">\n {names.map((name) => (\n <span key={name} className=\"tag scope-chip\">\n <span className=\"mono\">{name}</span>\n <button type=\"button\" aria-label={`Remove ${name}`} onClick={() => onChange(names.filter((other) => other !== name))}>\n <X size={11} />\n </button>\n </span>\n ))}\n <input\n className=\"input input-mono scope-input\"\n list={list}\n value={draft}\n spellCheck={false}\n autoComplete=\"off\"\n placeholder={names.length === 0 ? (free ? 'dev' : 'Pick a project') : 'Add'}\n aria-label={`Add to ${label}`}\n aria-invalid={draft !== '' && free && slugProblem(draft.trim()) !== null}\n onChange={(event) => {\n // A name picked from the list goes in at once; one typed, on Enter.\n if ((event.nativeEvent as InputEvent).inputType === 'insertReplacementText' || (!free && options.includes(event.target.value))) {\n add(event.target.value);\n } else {\n setDraft(event.target.value);\n }\n }}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ',') {\n event.preventDefault();\n add(draft);\n } else if (event.key === 'Backspace' && draft === '' && names.length > 0) {\n onChange(names.slice(0, -1));\n }\n }}\n onBlur={() => add(draft)}\n />\n <datalist id={list}>\n {offered.map((option) => (\n <option key={option} value={option} />\n ))}\n </datalist>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,UAAU,EAAE,OAAO,YAAsE;CACvG,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,SAAS,SAAS,CAAC,CAAC,aAAa;CAEvC,MAAM,EAAE,kBAAkB,SAAS;CACnC,MAAM,SAAS,SAAuB,cAAc,MAAM,SAAS,KAAK,OAAO,IAAI;CACnF,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,qBAAC,SAAD;EAAO,WAAU;YAAjB;GACE,oBAAC,QAAD;IAAM,WAAU;cAAQ;GAAiB,CAAA;GACzC,oBAAC,UAAD;IACE,WAAU;IACV,OAAO;IACP,WAAW,UAAU,SAAS;KAAE,MAAM,MAAM,OAAO;KAAuB;IAAM,CAAC;cAEhF,oBAAoB,QAAQ,SAAS,UAAU,SAAS,OAAO,CAAC,CAAC,KAAK,SACrE,oBAAC,UAAD;KAAmB,OAAO;eACvB,MAAM,IAAI,CAAC,EAAE,QAAQ;IAChB,GAFK,IAEL,CACT;GACK,CAAA;GACR,qBAAC,QAAD;IAAM,WAAU;cAAhB;KAAuB;KACC,MAAM,IAAI,CAAC,EAAE;KAAY;KAC9C,CAAC,UAAU;IACR;;EACD;KACN,SAAS,YAAY,oBAAC,YAAD;EAAmB;EAAO,WAAW,SAAS,SAAS;GAAE;GAAM,OAAO;EAAK,CAAC;CAAI,CAAA,CACtG,EAAA,CAAA;AAEN;;;;;;AAOA,SAAgB,WAAW,EAAE,OAAO,UAAU,SAAS,WAAgF;CACrI,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,MAAM;IACpE,WAAW,UAAU;KAEnB,IAAK,MAAM,YAA2B,cAAc,2BAA4B,CAAC,QAAQ,QAAQ,SAAS,MAAM,OAAO,KAAK,GAC1H,IAAI,MAAM,OAAO,KAAK;UAEtB,SAAS,MAAM,OAAO,KAAK;IAE/B;IACA,YAAY,UAAU;KACpB,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;MAC9C,MAAM,eAAe;MACrB,IAAI,KAAK;KACX,OAAO,IAAI,MAAM,QAAQ,eAAe,UAAU,MAAM,MAAM,SAAS,GACrE,SAAS,MAAM,MAAM,GAAG,EAAE,CAAC;IAE/B;IACA,cAAc,IAAI,KAAK;GACxB,CAAA;GACD,oBAAC,YAAD;IAAU,IAAI;cACX,QAAQ,KAAK,WACZ,oBAAC,UAAD,EAAqB,OAAO,OAAS,GAAxB,MAAwB,CACtC;GACO,CAAA;EACN;;AAEV"}
@@ -1,5 +1,5 @@
1
- import { l as Spinner } from "./ui-D-blFWfx.js";
2
- import { p as AlertCircle, st as X } from "./page-JTORvh-N.js";
1
+ import { l as Spinner } from "./ui-CGdORVzW.js";
2
+ import { ct as X, p as AlertCircle } from "./page-CfhC9Hp1.js";
3
3
  import { useSyncExternalStore } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/lib/announce.ts
@@ -123,4 +123,4 @@ function LiveRegion() {
123
123
  //#endregion
124
124
  export { rowClass as a, RowPending as i, LiveRegion as n, announce as o, RowFailure as r, ItemFailure as t };
125
125
 
126
- //# sourceMappingURL=row-state-xtRGFnDc.js.map
126
+ //# sourceMappingURL=row-state-CYH7kZHl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"row-state-xtRGFnDc.js","names":[],"sources":["../../src/lib/announce.ts","../../src/components/row-state.tsx"],"sourcesContent":["/**\n * What a screen reader hears of a change: that it is on its way, that it\n * landed, or why it did not. Changes show on screen as dimmed or struck-out\n * rows; this says the same in words, through two live regions in the shell\n * (`LiveRegion`), one polite and one for failures, which interrupts.\n */\nexport type Announcement = { text: string; id: number };\n\ntype Heard = { polite: Announcement | null; urgent: Announcement | null };\n\nlet heard: Heard = { polite: null, urgent: null };\nlet next = 0;\nconst listeners = new Set<() => void>();\n\nexport function announce(text: string, { urgent = false }: { urgent?: boolean } = {}): void {\n // A fresh id, so the same words said twice are heard twice.\n const said = { text, id: next++ };\n heard = urgent ? { ...heard, urgent: said } : { ...heard, polite: said };\n for (const listener of listeners) listener();\n}\n\nexport function subscribeAnnouncements(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nexport function announcements(): Heard {\n return heard;\n}\n\nconst nobody: Heard = { polite: null, urgent: null };\n\n/** On the server nothing has been said yet. */\nexport function serverAnnouncements(): Heard {\n return nobody;\n}\n","import { useSyncExternalStore, type ReactNode } from 'react';\n\nimport { announcements, serverAnnouncements, subscribeAnnouncements } from '../lib/announce';\nimport type { ItemStatus } from '../lib/optimistic';\nimport { Spinner } from './ui';\nimport { AlertCircle, X } from './icons';\n\n/**\n * How a row looks while a change to it is on its way, or after the server\n * refused it. Never colour alone: a waiting row is quieter and says what it\n * waits for, a row being removed is struck through as well, and a refused\n * change says so in words beneath its row.\n */\nexport function rowClass(status: ItemStatus): string {\n if (status.state === 'pending') return status.kind === 'removing' ? 'is-removing' : 'is-saving';\n if (status.state === 'failed') return 'is-failed';\n return '';\n}\n\n/**\n * In place of a row's actions while its change is on its way. Where the\n * actions column fits only a button, the words go from sight, not from the\n * page: they stay for a screen reader and the spinner's tooltip.\n */\nexport function RowPending({ status }: { status: ItemStatus }) {\n if (status.state !== 'pending') return null;\n return (\n <span className=\"row-pending\" title={status.words.pending}>\n <Spinner size={13} />\n <span className=\"row-pending-words\">{status.words.pending}</span>\n </span>\n );\n}\n\n/** Beneath a row whose change the server refused: why, until dismissed. */\nexport function RowFailure({\n status,\n columns,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n columns: number;\n onDismiss: () => void;\n /** Said before the reason; by default, what did not happen. */\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <tr className=\"row-error row-failure\">\n <td colSpan={columns}>\n <ItemFailure status={status} onDismiss={onDismiss}>\n {children}\n </ItemFailure>\n </td>\n </tr>\n );\n}\n\n/** Why the server refused a change, where it shows: under a row, or in a card. */\nexport function ItemFailure({\n status,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n onDismiss: () => void;\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <div className=\"row-failure-line\">\n <p className=\"error-line\">\n <AlertCircle size={14} />\n <span>\n <strong>{children ?? status.words.failed}</strong> {status.error}\n </span>\n </p>\n <button type=\"button\" className=\"act act-quiet\" onClick={onDismiss} aria-label=\"Dismiss\">\n <X size={13} />\n </button>\n </div>\n );\n}\n\n/** Where changes are announced to screen readers (`lib/announce.ts`). */\nexport function LiveRegion() {\n const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);\n return (\n <>\n <div className=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite !== null && <span key={polite.id}>{polite.text}</span>}\n </div>\n <div className=\"visually-hidden\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {urgent !== null && <span key={urgent.id}>{urgent.text}</span>}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;AAUA,IAAI,QAAe;CAAE,QAAQ;CAAM,QAAQ;AAAK;AAChD,IAAI,OAAO;AACX,IAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,SAAS,MAAc,EAAE,SAAS,UAAgC,CAAC,GAAS;CAE1F,MAAM,OAAO;EAAE;EAAM,IAAI;CAAO;CAChC,QAAQ,SAAS;EAAE,GAAG;EAAO,QAAQ;CAAK,IAAI;EAAE,GAAG;EAAO,QAAQ;CAAK;CACvE,KAAK,MAAM,YAAY,WAAW,SAAS;AAC7C;AAEA,SAAgB,uBAAuB,UAAkC;CACvE,UAAU,IAAI,QAA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,EAAG,MAAM,GAAK,CAAA;EACR,CAAA,CACL;;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,QAAQ,WAAW,qBAAqB,wBAAwB,eAAe,mBAAmB;CAC1G,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAS,aAAU;EAAS,eAAY;YAC3E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,GACL,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAQ,aAAU;EAAY,eAAY;YAC7E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,CACL,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"row-state-CYH7kZHl.js","names":[],"sources":["../../src/lib/announce.ts","../../src/components/row-state.tsx"],"sourcesContent":["/**\n * What a screen reader hears of a change: that it is on its way, that it\n * landed, or why it did not. Changes show on screen as dimmed or struck-out\n * rows; this says the same in words, through two live regions in the shell\n * (`LiveRegion`), one polite and one for failures, which interrupts.\n */\nexport type Announcement = { text: string; id: number };\n\ntype Heard = { polite: Announcement | null; urgent: Announcement | null };\n\nlet heard: Heard = { polite: null, urgent: null };\nlet next = 0;\nconst listeners = new Set<() => void>();\n\nexport function announce(text: string, { urgent = false }: { urgent?: boolean } = {}): void {\n // A fresh id, so the same words said twice are heard twice.\n const said = { text, id: next++ };\n heard = urgent ? { ...heard, urgent: said } : { ...heard, polite: said };\n for (const listener of listeners) listener();\n}\n\nexport function subscribeAnnouncements(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nexport function announcements(): Heard {\n return heard;\n}\n\nconst nobody: Heard = { polite: null, urgent: null };\n\n/** On the server nothing has been said yet. */\nexport function serverAnnouncements(): Heard {\n return nobody;\n}\n","import { useSyncExternalStore, type ReactNode } from 'react';\n\nimport { announcements, serverAnnouncements, subscribeAnnouncements } from '../lib/announce';\nimport type { ItemStatus } from '../lib/optimistic';\nimport { Spinner } from './ui';\nimport { AlertCircle, X } from './icons';\n\n/**\n * How a row looks while a change to it is on its way, or after the server\n * refused it. Never colour alone: a waiting row is quieter and says what it\n * waits for, a row being removed is struck through as well, and a refused\n * change says so in words beneath its row.\n */\nexport function rowClass(status: ItemStatus): string {\n if (status.state === 'pending') return status.kind === 'removing' ? 'is-removing' : 'is-saving';\n if (status.state === 'failed') return 'is-failed';\n return '';\n}\n\n/**\n * In place of a row's actions while its change is on its way. Where the\n * actions column fits only a button, the words go from sight, not from the\n * page: they stay for a screen reader and the spinner's tooltip.\n */\nexport function RowPending({ status }: { status: ItemStatus }) {\n if (status.state !== 'pending') return null;\n return (\n <span className=\"row-pending\" title={status.words.pending}>\n <Spinner size={13} />\n <span className=\"row-pending-words\">{status.words.pending}</span>\n </span>\n );\n}\n\n/** Beneath a row whose change the server refused: why, until dismissed. */\nexport function RowFailure({\n status,\n columns,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n columns: number;\n onDismiss: () => void;\n /** Said before the reason; by default, what did not happen. */\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <tr className=\"row-error row-failure\">\n <td colSpan={columns}>\n <ItemFailure status={status} onDismiss={onDismiss}>\n {children}\n </ItemFailure>\n </td>\n </tr>\n );\n}\n\n/** Why the server refused a change, where it shows: under a row, or in a card. */\nexport function ItemFailure({\n status,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n onDismiss: () => void;\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <div className=\"row-failure-line\">\n <p className=\"error-line\">\n <AlertCircle size={14} />\n <span>\n <strong>{children ?? status.words.failed}</strong> {status.error}\n </span>\n </p>\n <button type=\"button\" className=\"act act-quiet\" onClick={onDismiss} aria-label=\"Dismiss\">\n <X size={13} />\n </button>\n </div>\n );\n}\n\n/** Where changes are announced to screen readers (`lib/announce.ts`). */\nexport function LiveRegion() {\n const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);\n return (\n <>\n <div className=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite !== null && <span key={polite.id}>{polite.text}</span>}\n </div>\n <div className=\"visually-hidden\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {urgent !== null && <span key={urgent.id}>{urgent.text}</span>}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;AAUA,IAAI,QAAe;CAAE,QAAQ;CAAM,QAAQ;AAAK;AAChD,IAAI,OAAO;AACX,IAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,SAAS,MAAc,EAAE,SAAS,UAAgC,CAAC,GAAS;CAE1F,MAAM,OAAO;EAAE;EAAM,IAAI;CAAO;CAChC,QAAQ,SAAS;EAAE,GAAG;EAAO,QAAQ;CAAK,IAAI;EAAE,GAAG;EAAO,QAAQ;CAAK;CACvE,KAAK,MAAM,YAAY,WAAW,SAAS;AAC7C;AAEA,SAAgB,uBAAuB,UAAkC;CACvE,UAAU,IAAI,QAAQ;CACtB,aAAa,UAAU,OAAO,QAAQ;AACxC;AAEA,SAAgB,gBAAuB;CACrC,OAAO;AACT;AAEA,IAAM,SAAgB;CAAE,QAAQ;CAAM,QAAQ;AAAK;;AAGnD,SAAgB,sBAA6B;CAC3C,OAAO;AACT;;;;;;;;;ACtBA,SAAgB,SAAS,QAA4B;CACnD,IAAI,OAAO,UAAU,WAAW,OAAO,OAAO,SAAS,aAAa,gBAAgB;CACpF,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO;AACT;;;;;;AAOA,SAAgB,WAAW,EAAE,UAAkC;CAC7D,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,OACE,qBAAC,QAAD;EAAM,WAAU;EAAc,OAAO,OAAO,MAAM;YAAlD,CACE,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA,GACpB,oBAAC,QA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,5 @@
1
- import { x as usePreferences } from "./ui-D-blFWfx.js";
2
- import { B as Monitor, V as Moon, _ as Check, et as Sun } from "./page-JTORvh-N.js";
1
+ import { x as usePreferences } from "./ui-CGdORVzW.js";
2
+ import { H as Moon, V as Monitor, _ as Check, tt as Sun } from "./page-CfhC9Hp1.js";
3
3
  import { Menu } from "@base-ui/react/menu";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/components/theme.tsx
@@ -83,4 +83,4 @@ function ThemeCards() {
83
83
  //#endregion
84
84
  export { ThemeMenuItems as n, ThemeToggle as r, ThemeCards as t };
85
85
 
86
- //# sourceMappingURL=theme-Ck45wzWB.js.map
86
+ //# sourceMappingURL=theme-rF44Wbmm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-Ck45wzWB.js","names":[],"sources":["../../src/components/theme.tsx"],"sourcesContent":["import { Menu } from '@base-ui/react/menu';\nimport { usePreferences, type Theme } from '../lib/preferences';\nimport { Check, Monitor, Moon, Sun } from './icons';\n\nconst OPTIONS: { value: Theme; label: string; Icon: typeof Sun }[] = [\n { value: 'system', label: 'Match system', Icon: Monitor },\n { value: 'light', label: 'Light', Icon: Sun },\n { value: 'dark', label: 'Dark', Icon: Moon },\n];\n\n/** The theme as a radio group inside a dropdown menu (the account menu). */\nexport function ThemeMenuItems() {\n const { theme, setTheme } = usePreferences();\n return (\n <Menu.RadioGroup value={theme} onValueChange={(value: Theme) => setTheme(value)}>\n <Menu.GroupLabel className=\"menu-label\">Theme</Menu.GroupLabel>\n {OPTIONS.map(({ value, label, Icon }) => (\n <Menu.RadioItem key={value} value={value} className=\"menu-item\" closeOnClick>\n <Icon size={15} />\n {label}\n <Menu.RadioItemIndicator className=\"menu-check\">\n <Check size={14} />\n </Menu.RadioItemIndicator>\n </Menu.RadioItem>\n ))}\n </Menu.RadioGroup>\n );\n}\n\n/**\n * Three glyphs, one of them pressed, for pages without the account menu.\n * A menu for a three-way choice costs a click to find out the current value.\n */\nexport function ThemeToggle() {\n const { theme, setTheme } = usePreferences();\n\n return (\n <div className=\"theme-choice\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n aria-pressed={theme === value}\n aria-label={label}\n title={label}\n onClick={() => setTheme(value)}\n >\n <Icon size={14} />\n </button>\n ))}\n </div>\n );\n}\n\n/** The theme as three large choices, for the Settings page. */\nexport function ThemeCards() {\n const { theme, setTheme } = usePreferences();\n return (\n <div className=\"choice-grid\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n className=\"choice\"\n aria-pressed={theme === value}\n onClick={() => setTheme(value)}\n >\n <Icon size={16} />\n {label}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAIA,IAAM,UAA+D;CACnE;EAAE,OAAO;EAAU,OAAO;EAAgB,MAAM;CAAQ;CACxD;EAAE,OAAO;EAAS,OAAO;EAAS,MAAM;CAAI;CAC5C;EAAE,OAAO;EAAQ,OAAO;EAAQ,MAAM;CAAK;AAC7C;;AAGA,SAAgB,iBAAiB;CAC/B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,qBAAC,KAAK,YAAN;EAAiB,OAAO;EAAO,gBAAgB,UAAiB,SAAS,KAAK;YAA9E,CACE,oBAAC,KAAK,YAAN;GAAiB,WAAU;aAAa;EAAsB,CAAA,GAC7D,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,KAAK,WAAN;GAAmC;GAAO,WAAU;GAAY,cAAA;aAAhE;IACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;IAChB;IACD,oBAAC,KAAK,oBAAN;KAAyB,WAAU;eACjC,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IACK,CAAA;GACX;KANK,KAML,CACjB,CACc;;AAErB;;;;;AAMA,SAAgB,cAAc;CAC5B,MAAM,EAAE,OAAO,aAAa,eAAe;CAE3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAe,MAAK;EAAQ,cAAW;YACnD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,oBAAC,UAAD;GAEE,MAAK;GACL,gBAAc,UAAU;GACxB,cAAY;GACZ,OAAO;GACP,eAAe,SAAS,KAAK;aAE7B,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACX,GARD,KAQC,CACT;CACE,CAAA;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAc,MAAK;EAAQ,cAAW;YAClD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,UAAD;GAEE,MAAK;GACL,WAAU;GACV,gBAAc,UAAU;GACxB,eAAe,SAAS,KAAK;aAL/B,CAOE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAChB,KACK;KARD,KAQC,CACT;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"theme-rF44Wbmm.js","names":[],"sources":["../../src/components/theme.tsx"],"sourcesContent":["import { Menu } from '@base-ui/react/menu';\nimport { usePreferences, type Theme } from '../lib/preferences';\nimport { Check, Monitor, Moon, Sun } from './icons';\n\nconst OPTIONS: { value: Theme; label: string; Icon: typeof Sun }[] = [\n { value: 'system', label: 'Match system', Icon: Monitor },\n { value: 'light', label: 'Light', Icon: Sun },\n { value: 'dark', label: 'Dark', Icon: Moon },\n];\n\n/** The theme as a radio group inside a dropdown menu (the account menu). */\nexport function ThemeMenuItems() {\n const { theme, setTheme } = usePreferences();\n return (\n <Menu.RadioGroup value={theme} onValueChange={(value: Theme) => setTheme(value)}>\n <Menu.GroupLabel className=\"menu-label\">Theme</Menu.GroupLabel>\n {OPTIONS.map(({ value, label, Icon }) => (\n <Menu.RadioItem key={value} value={value} className=\"menu-item\" closeOnClick>\n <Icon size={15} />\n {label}\n <Menu.RadioItemIndicator className=\"menu-check\">\n <Check size={14} />\n </Menu.RadioItemIndicator>\n </Menu.RadioItem>\n ))}\n </Menu.RadioGroup>\n );\n}\n\n/**\n * Three glyphs, one of them pressed, for pages without the account menu.\n * A menu for a three-way choice costs a click to find out the current value.\n */\nexport function ThemeToggle() {\n const { theme, setTheme } = usePreferences();\n\n return (\n <div className=\"theme-choice\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n aria-pressed={theme === value}\n aria-label={label}\n title={label}\n onClick={() => setTheme(value)}\n >\n <Icon size={14} />\n </button>\n ))}\n </div>\n );\n}\n\n/** The theme as three large choices, for the Settings page. */\nexport function ThemeCards() {\n const { theme, setTheme } = usePreferences();\n return (\n <div className=\"choice-grid\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n className=\"choice\"\n aria-pressed={theme === value}\n onClick={() => setTheme(value)}\n >\n <Icon size={16} />\n {label}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAIA,IAAM,UAA+D;CACnE;EAAE,OAAO;EAAU,OAAO;EAAgB,MAAM;CAAQ;CACxD;EAAE,OAAO;EAAS,OAAO;EAAS,MAAM;CAAI;CAC5C;EAAE,OAAO;EAAQ,OAAO;EAAQ,MAAM;CAAK;AAC7C;;AAGA,SAAgB,iBAAiB;CAC/B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,qBAAC,KAAK,YAAN;EAAiB,OAAO;EAAO,gBAAgB,UAAiB,SAAS,KAAK;YAA9E,CACE,oBAAC,KAAK,YAAN;GAAiB,WAAU;aAAa;EAAsB,CAAA,GAC7D,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,KAAK,WAAN;GAAmC;GAAO,WAAU;GAAY,cAAA;aAAhE;IACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;IAChB;IACD,oBAAC,KAAK,oBAAN;KAAyB,WAAU;eACjC,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IACK,CAAA;GACX;KANK,KAML,CACjB,CACc;;AAErB;;;;;AAMA,SAAgB,cAAc;CAC5B,MAAM,EAAE,OAAO,aAAa,eAAe;CAE3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAe,MAAK;EAAQ,cAAW;YACnD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,oBAAC,UAAD;GAEE,MAAK;GACL,gBAAc,UAAU;GACxB,cAAY;GACZ,OAAO;GACP,eAAe,SAAS,KAAK;aAE7B,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACX,GARD,KAQC,CACT;CACE,CAAA;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAc,MAAK;EAAQ,cAAW;YAClD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,UAAD;GAEE,MAAK;GACL,WAAU;GACV,gBAAc,UAAU;GACxB,eAAe,SAAS,KAAK;aAL/B,CAOE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAChB,KACK;KARD,KAQC,CACT;CACE,CAAA;AAET"}
@@ -1,4 +1,4 @@
1
- import { C as Copy, I as Loader, _ as Check, j as Info, m as AlertTriangle, p as AlertCircle, st as X } from "./page-JTORvh-N.js";
1
+ import { C as Copy, L as Loader, M as Info, _ as Check, ct as X, m as AlertTriangle, p as AlertCircle } from "./page-CfhC9Hp1.js";
2
2
  import { createContext, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { Dialog } from "@base-ui/react/dialog";
4
4
  import { Menu } from "@base-ui/react/menu";
@@ -502,4 +502,4 @@ function Timestamp({ iso, precise = false, display = "absolute" }) {
502
502
  //#endregion
503
503
  export { PreferencesContext as _, ErrorLine as a, rememberTheme as b, Notice as c, Tip as d, Toggletip as f, createCopier as g, breakAfterUnderscores as h, EmptyState as i, Spinner as l, absolute as m, ConfirmDialog as n, MenuPopup as o, TooltipProvider as p, CopyButton as r, Modal as s, ConfirmButton as t, Timestamp as u, browserPreferences as v, usePreferences as x, rememberSidebar as y };
504
504
 
505
- //# sourceMappingURL=ui-D-blFWfx.js.map
505
+ //# sourceMappingURL=ui-CGdORVzW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui-D-blFWfx.js","names":[],"sources":["../../src/lib/preferences.tsx","../../src/lib/clipboard.ts","../../src/lib/copy-attempts.ts","../../src/components/ui.tsx"],"sourcesContent":["import { createContext, useContext, type RefObject } from 'react';\n\nimport { PREFERENCE_COOKIES, preferencesIn, type Preferences } from '@coffre/core/pages';\n\nexport type { Preferences };\n\nexport type Theme = Preferences['theme'];\n\n/**\n * The preferences in the browser's cookies, as the server read them in the\n * request's: each is a cookie, so the server renders the page as the\n * visitor left it, from the first byte, and the browser hydrates the same.\n */\nexport function browserPreferences(): Preferences {\n return preferencesIn(document.cookie);\n}\n\n/** Keep a choice for a year; the default, by removing it. */\nfunction remember(name: string, value: string | null) {\n document.cookie =\n value === null ? `${name}=; Path=/; SameSite=Lax; Max-Age=0` : `${name}=${value}; Path=/; SameSite=Lax; Max-Age=31536000`;\n}\n\nexport function rememberTheme(theme: Theme) {\n remember(PREFERENCE_COOKIES.theme, theme === 'system' ? null : theme);\n}\n\nexport function rememberSidebar(sidebar: Preferences['sidebar']) {\n remember(PREFERENCE_COOKIES.sidebar, sidebar === 'collapsed' ? 'collapsed' : null);\n}\n\ntype PreferencesValue = Preferences & {\n setTheme(theme: Theme): void;\n setSidebar(sidebar: Preferences['sidebar']): void;\n /** coffre's element, which menus, dialogs and tooltips render into, so they are drawn in its theme. */\n portal: RefObject<HTMLDivElement | null>;\n};\n\nexport const PreferencesContext = createContext<PreferencesValue | null>(null);\n\n/** The visitor's preferences, and the switches, from `<CoffreProvider>`. */\nexport function usePreferences(): PreferencesValue {\n const value = useContext(PreferencesContext);\n if (value === null) throw new Error(\"coffre's pages render inside <CoffreProvider>, in the app's root document\");\n return value;\n}\n","/**\n * Writing to the clipboard, from text that may still be on its way.\n *\n * A browser lets a page write to the clipboard only inside a click's user\n * gesture, and Safari drops the gesture across an `await`. So a value that has\n * to be fetched first (Copy on a hidden secret) is handed over as a promise:\n * `clipboard.write` is called at once, with the promise inside a\n * `ClipboardItem`, and the browser waits for it. Where that is not supported,\n * the text is awaited, then written with `writeText`, which is what every\n * browser but Safari allows.\n *\n * The text goes through byte for byte: no trimming, no newline changes.\n */\n\n/** What of the clipboard `copyText` uses; the browser's `navigator.clipboard` fits. */\nexport type ClipboardLike = {\n writeText(text: string): Promise<void>;\n write?(items: unknown[]): Promise<void>;\n};\n\ntype ClipboardItemConstructor = new (items: Record<string, Promise<string>>) => unknown;\n\nexport async function copyText(\n text: string | Promise<string>,\n {\n clipboard = globalThis.navigator?.clipboard as ClipboardLike | undefined,\n item = (globalThis as { ClipboardItem?: ClipboardItemConstructor }).ClipboardItem,\n }: { clipboard?: ClipboardLike; item?: ClipboardItemConstructor } = {},\n): Promise<void> {\n // A read that fails after the copy has ended is nobody's to hear: not an unhandled rejection.\n if (typeof text !== 'string') text.catch(() => {});\n if (clipboard === undefined) throw new Error('The clipboard is not available here.');\n if (typeof text !== 'string' && item !== undefined && clipboard.write !== undefined) {\n // Called before anything is awaited: this is what keeps the user gesture.\n // The text goes in as a string, not a Blob: decoding a Blob drops a leading U+FEFF.\n await clipboard.write([new item({ 'text/plain': text })]);\n return;\n }\n await clipboard.writeText(await text);\n}\n","import { copyText } from './clipboard.ts';\n\n/**\n * How a copy ended, as far as anyone still cares.\n *\n * `superseded`: a newer copy began before this one ended, so this one reports\n * nothing and writes nothing. Its result, good or bad, is not what the person\n * asked for last.\n */\nexport type CopyResult = { outcome: 'copied' } | { outcome: 'failed'; failure: unknown } | { outcome: 'superseded' };\n\n/** What a copy button shows: a copy under way, or how the last one ended, for a moment. */\nexport type CopyFeedback = 'idle' | 'pending' | 'copied' | 'failed';\n\n/**\n * Copies where the latest one wins, and what they look like while they run.\n *\n * The clipboard is one resource per page, so \"latest\" is decided per page: every\n * copy, from any row, takes a number from one counter before it awaits anything,\n * and only the newest reports, shows feedback, or writes. A copy may start while\n * an earlier one is still reading or waiting on the clipboard: a retry after a\n * refusal, a click on another row, a row filtered out and back, a button replaced\n * by a remount. When a copy from another copier takes over, the older one drops\n * its pending or \"Copied\" feedback and goes back to idle. A copier belongs to\n * whoever outlives the button (a row); the button only subscribes to it, so a\n * remount picks up where it was.\n */\nexport type Copier = {\n run(text: string | Promise<string>): Promise<CopyResult>;\n feedback(): CopyFeedback;\n subscribe(listener: () => void): () => void;\n};\n\nconst SUPERSEDED = new Error('A newer copy began.');\n\n/** The page's newest copy, and the copier that made it. */\nlet latest = 0;\nlet owner: { drop(): void } | null = null;\n\nexport function createCopier({\n copy = copyText,\n copiedMs = 1400,\n failedMs = 3000,\n}: { copy?: typeof copyText; copiedMs?: number; failedMs?: number } = {}): Copier {\n let feedback: CopyFeedback = 'idle';\n let timer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n function show(next: CopyFeedback) {\n if (feedback === next) return;\n feedback = next;\n for (const listener of listeners) listener();\n }\n\n function stopTimer() {\n if (timer !== null) clearTimeout(timer);\n timer = null;\n }\n\n const self = {\n /** Another copier's copy took over: nothing of this one's is left showing. */\n drop() {\n stopTimer();\n show('idle');\n },\n };\n\n return {\n feedback: () => feedback,\n subscribe(listener) {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n async run(text) {\n const attempt = ++latest;\n if (owner !== null && owner !== self) owner.drop();\n owner = self;\n stopTimer();\n show('pending');\n // A read that finishes after a newer copy began, anywhere on the page, is\n // refused here, so it never reaches the clipboard: the fallback does not\n // write it, and a ClipboardItem whose payload rejects writes nothing.\n const gated =\n typeof text === 'string'\n ? text\n : text.then((value) => {\n if (attempt !== latest) throw SUPERSEDED;\n return value;\n });\n let result: CopyResult = { outcome: 'copied' };\n try {\n // Called before anything is awaited: the click's gesture is still live.\n await copy(gated);\n } catch (failure) {\n result = { outcome: 'failed', failure };\n }\n if (attempt !== latest) return { outcome: 'superseded' };\n show(result.outcome === 'copied' ? 'copied' : 'failed');\n timer = setTimeout(() => show('idle'), result.outcome === 'copied' ? copiedMs : failedMs);\n return result;\n },\n };\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactElement, type ReactNode } from 'react';\nimport { AlertDialog } from '@base-ui/react/alert-dialog';\nimport { Dialog } from '@base-ui/react/dialog';\nimport { Menu } from '@base-ui/react/menu';\nimport { Popover } from '@base-ui/react/popover';\nimport { Tooltip } from '@base-ui/react/tooltip';\nimport { AlertCircle, AlertTriangle, Check, Copy, Info, Loader, X } from './icons';\nimport { createCopier, type Copier } from '../lib/copy-attempts';\nimport { usePreferences } from '../lib/preferences';\n\n/* -------------------------------------------------------------------------- */\n/* Tooltip */\n/* -------------------------------------------------------------------------- */\n\nexport function TooltipProvider({ children }: { children: ReactNode }) {\n // 400ms before the first tip; afterwards adjacent tips open instantly, which\n // makes a row of controls feel immediate without the delay losing its\n // purpose (preventing accidental activation on a passing cursor).\n return (\n <Tooltip.Provider delay={400} timeout={300}>\n {children}\n </Tooltip.Provider>\n );\n}\n\nexport function Tip({\n label,\n side,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n return (\n <Tooltip.Root>\n <Tooltip.Trigger render={children} />\n <Tooltip.Portal container={portal}>\n <Tooltip.Positioner\n className=\"tooltip-positioner\"\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n <Tooltip.Popup className=\"tooltip\">{label}</Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n\n/**\n * The same bubble as Tip, for a note a touch screen must reach too.\n *\n * A tooltip opens on hover and focus only, so on a phone it never opens. This\n * one also opens on a tap, which means its trigger has to be a real button.\n * With a mouse, hover alone drives it: a click would otherwise close the note\n * the hover just opened.\n */\nexport function Toggletip({\n label,\n side,\n align,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n /** `end` for a trigger at the right edge, so the tip opens leftwards. */\n align?: 'start' | 'center' | 'end';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n const [open, setOpen] = useState(false);\n const mouse = useRef(false);\n const hover = (next: boolean) => (event: { pointerType: string }) => {\n if (event.pointerType === 'mouse') setOpen(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(next, { reason }) => {\n const clicked = reason === 'trigger-press' && mouse.current;\n mouse.current = false;\n if (!clicked) setOpen(next);\n }}\n >\n <Popover.Trigger\n render={children}\n onPointerEnter={hover(true)}\n onPointerLeave={hover(false)}\n onPointerDown={(event) => {\n mouse.current = event.pointerType === 'mouse';\n }}\n />\n <Popover.Portal container={portal}>\n <Popover.Positioner\n className=\"tooltip-positioner\"\n side={side}\n align={align}\n sideOffset={6}\n collisionPadding={16}\n >\n {/* Focus stays on the trigger, so there is nothing to return it to. */}\n <Popover.Popup className=\"tooltip\" initialFocus={false} finalFocus={false}>\n {label}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Menu */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A menu's floating panel, placed against its `Menu.Trigger`.\n *\n * The callers keep the rest of Base UI's menu parts: the trigger, the items\n * and their separators read better at the call site than behind props.\n */\nexport function MenuPopup({\n side,\n align,\n className,\n children,\n}: {\n side?: 'top' | 'bottom';\n align: 'start' | 'end';\n className?: string;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n return (\n <Menu.Portal container={portal}>\n <Menu.Positioner className=\"menu-positioner\" side={side} align={align} sideOffset={6}>\n <Menu.Popup className={className === undefined ? 'menu' : `menu ${className}`}>\n {children}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Feedback primitives */\n/* -------------------------------------------------------------------------- */\n\nexport function Spinner({ size = 14 }: { size?: number }) {\n return <Loader size={size} className=\"spinner\" />;\n}\n\nexport function ErrorLine({ error }: { error: string | null }) {\n if (error === null) return null;\n return (\n <p className=\"error-line\" role=\"alert\">\n <AlertCircle size={14} />\n <span>{error}</span>\n </p>\n );\n}\n\nconst NOTICE_ICON = {\n info: Info,\n good: Check,\n bad: AlertTriangle,\n warn: AlertTriangle,\n neutral: Info,\n} as const;\n\nexport function Notice({\n tone = 'neutral',\n children,\n}: {\n tone?: keyof typeof NOTICE_ICON;\n children: ReactNode;\n}) {\n const Icon = NOTICE_ICON[tone];\n return (\n <div\n className={`notice${tone === 'neutral' ? '' : ` notice-${tone}`}`}\n role={tone === 'bad' ? 'alert' : undefined}\n >\n <Icon size={16} />\n <div>{children}</div>\n </div>\n );\n}\n\n/**\n * Nothing here yet, said in a sentence.\n *\n * It sits where the table would have been, left-aligned like the rows it\n * stands in for, rather than as a centred illustration.\n */\nexport function EmptyState({\n title,\n children,\n actions,\n}: {\n title: string;\n children?: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <div className=\"empty\">\n <p className=\"empty-title\">{title}</p>\n {children !== undefined && <p className=\"empty-body\">{children}</p>}\n {actions !== undefined && <div className=\"empty-actions\">{actions}</div>}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Text */\n/* -------------------------------------------------------------------------- */\n\n/**\n * An identifier that wraps after its underscores rather than mid-word.\n *\n * To the line breaker `DOCUSIGN_INTEGRATION_KEY` is one word, so a narrow\n * column cuts it wherever room runs out (`…_KE` / `Y`). A <wbr> after each\n * underscore offers the natural places instead. Copied text is unchanged, and\n * `overflow-wrap: anywhere` still catches a segment too long for any line.\n */\nexport function breakAfterUnderscores(text: string): ReactNode {\n return text\n .split('_')\n .flatMap((part, index) => (index === 0 ? [part] : ['_', <wbr key={index} />, part]));\n}\n\n/* -------------------------------------------------------------------------- */\n/* Copy */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy to clipboard with a settled confirmation.\n *\n * The glyph turns into a check, and screen readers hear \"Copied\", for 1.4s --\n * long enough to be noticed after the eye has moved on, short enough not to\n * look stuck. A copy that fails says so the same way, in red, rather than\n * leaving the click looking ignored.\n *\n * `value` is the text. A caller that must read it first (Copy on a hidden\n * secret) passes the `copier` it owns instead, and `onCopy`, called inside the\n * click so the clipboard write keeps its user gesture, which starts a copy on\n * that copier. Copies do not lock the button: a click while one is out starts\n * the next, and the latest one's ending is the one that shows. The copier's\n * owner outlives the button, so a remount keeps the feedback of a copy in flight.\n */\nexport function CopyButton({\n label = 'Copy',\n variant = 'icon',\n ...source\n}: {\n label?: string;\n /** `act` sits among a table row's actions; `icon` anywhere else. */\n variant?: 'icon' | 'act';\n} & ({ value: string; copier?: undefined; onCopy?: undefined } | { value?: undefined; copier: Copier; onCopy: () => void })) {\n const [own] = useState(() => createCopier());\n const copier = source.copier ?? own;\n const state = useSyncExternalStore(copier.subscribe, copier.feedback, copier.feedback);\n\n function copy() {\n if (source.copier !== undefined) source.onCopy();\n else void own.run(source.value);\n }\n\n const text = state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : label;\n return (\n <Tip label={text}>\n <button\n type=\"button\"\n className={variant === 'act' ? 'act act-icon' : 'btn btn-quiet btn-sm btn-icon'}\n aria-label={label}\n aria-busy={state === 'pending'}\n onClick={copy}\n >\n {state === 'pending' ? (\n <Spinner size={13} />\n ) : state === 'copied' ? (\n <Check size={14} className=\"copied\" />\n ) : state === 'failed' ? (\n <AlertCircle size={14} className=\"copy-failed\" />\n ) : (\n <Copy size={14} />\n )}\n <span className=\"visually-hidden\" aria-live=\"polite\">\n {state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : ''}\n </span>\n </button>\n </Tip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Confirmation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Confirmation for actions with reach.\n *\n * Reserved for changes that affect other people or other screens (archiving a\n * project, revoking a grant). Restoring one secret is reversible and gets an\n * undo toast instead -- a dialog on every action trains people to dismiss them.\n */\ntype ConfirmProps = {\n title: ReactNode;\n body: ReactNode;\n /** What the body's sentence cannot hold, such as a list: after it, outside its paragraph. */\n detail?: ReactNode;\n confirmLabel: string;\n destructive?: boolean;\n /** While something must happen first, which `detail` says. */\n confirmDisabled?: boolean;\n onConfirm: () => void;\n};\n\nfunction ConfirmContent({ title, body, detail, confirmLabel, destructive, confirmDisabled, onConfirm }: ConfirmProps) {\n const { portal } = usePreferences();\n return (\n <AlertDialog.Portal container={portal}>\n <AlertDialog.Backdrop className=\"overlay\" />\n <AlertDialog.Popup className=\"dialog dialog-confirm\">\n <AlertDialog.Title className=\"dialog-title\">{title}</AlertDialog.Title>\n <AlertDialog.Description className=\"dialog-body\">{body}</AlertDialog.Description>\n {detail}\n <div className=\"dialog-actions\">\n <AlertDialog.Close className=\"btn\">Cancel</AlertDialog.Close>\n <AlertDialog.Close\n className={`btn ${destructive === false ? 'btn-primary' : 'btn-danger'}`}\n onClick={onConfirm}\n disabled={confirmDisabled}\n >\n {confirmLabel}\n </AlertDialog.Close>\n </div>\n </AlertDialog.Popup>\n </AlertDialog.Portal>\n );\n}\n\nexport function ConfirmButton({\n trigger,\n disabled,\n ...confirm\n}: ConfirmProps & { trigger: ReactElement; disabled?: boolean }) {\n return (\n <AlertDialog.Root>\n <AlertDialog.Trigger render={trigger} disabled={disabled} />\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\nconst hydrated = () => true;\nconst serverRender = () => false;\nconst unchanging = () => () => {};\n\n/**\n * Whether a dialog's root is drawn: always once the page is the browser's,\n * which closes it with its animation; on the server and while hydrating,\n * only when it is open. Closed, a dialog draws nothing, so the page's HTML\n * is the same either way, and the server skips a root per dialog: four in\n * each row of an environment's table. Its trigger is elsewhere, so mounting\n * it after hydration remounts nothing else.\n */\nfunction useHydrated(open: boolean): boolean {\n return useSyncExternalStore(unchanging, hydrated, serverRender) || open;\n}\n\n/**\n * The same confirmation, opened from something that is not a trigger.\n *\n * A menu item cannot be one: it unmounts as the menu closes, taking the dialog\n * with it. So the caller keeps the open state and the dialog lives outside the\n * menu entirely.\n */\nexport function ConfirmDialog({\n open,\n onOpenChange,\n ...confirm\n}: ConfirmProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n if (!useHydrated(open)) return null;\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\n/**\n * A plain modal, for a task you chose to begin.\n *\n * Distinct from ConfirmButton: that one interrupts to ask about something you\n * already started, this one holds a form.\n */\nexport function Modal({\n open,\n onOpenChange,\n title,\n description,\n wide = false,\n children,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n wide?: boolean;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n if (!useHydrated(open)) return null;\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Portal container={portal}>\n <Dialog.Backdrop className=\"overlay\" />\n <Dialog.Popup className={`dialog${wide ? ' dialog-wide' : ''}`}>\n <div className=\"dialog-head\">\n <Dialog.Title className=\"dialog-title\">{title}</Dialog.Title>\n <Dialog.Close className=\"btn btn-quiet btn-sm btn-icon\" aria-label=\"Close\">\n <X size={15} />\n </Dialog.Close>\n </div>\n {description !== undefined && (\n <Dialog.Description className=\"dialog-body\">{description}</Dialog.Description>\n )}\n {children}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Time */\n/* -------------------------------------------------------------------------- */\n\nconst RELATIVE_STEPS: [limit: number, divisor: number, unit: Intl.RelativeTimeFormatUnit][] = [\n [60, 1, 'second'],\n [3600, 60, 'minute'],\n [86400, 3600, 'hour'],\n [2592000, 86400, 'day'],\n [31536000, 2592000, 'month'],\n [Infinity, 31536000, 'year'],\n];\n\n/** One formatter per style, made once: making one costs more than a row of a page renders around it. */\nconst RELATIVE = {\n long: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'long' }),\n narrow: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'narrow' }),\n};\n\nfunction relative(iso: string, now: number, style: 'long' | 'narrow' = 'long'): string {\n const delta = (new Date(iso).getTime() - now) / 1000;\n const magnitude = Math.abs(delta);\n const [, divisor, unit] = RELATIVE_STEPS.find(([limit]) => magnitude < limit)!;\n return RELATIVE[style].format(Math.round(delta / divisor), unit);\n}\n\n/** A UTC time as the log writes it: `2026-10-17 08:45:13`, to the millisecond when `precise`. */\nexport function absolute(iso: string, precise: boolean): string {\n return iso.replace('T', ' ').replace('Z', '').slice(0, precise ? 23 : 19);\n}\n\n/**\n * A timestamp. Absolute UTC by default, \"3 hours ago\" on hover.\n *\n * Absolute is the default on purpose: in the audit log this is evidence, and\n * someone reading it is often transcribing it into a finding. `relative` flips\n * the two, in the short form (\"5h ago\"), for glanceable metadata like \"last\n * written\". The relative form can\n * differ between server and client by a rounding step, so that one text node\n * opts out of the hydration check rather than render a placeholder first.\n */\nexport function Timestamp({\n iso,\n precise = false,\n display = 'absolute',\n}: {\n iso: string;\n precise?: boolean;\n display?: 'absolute' | 'relative';\n}) {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => setNow(Date.now()), [iso]);\n\n if (display === 'relative') {\n return (\n <Tip label={`${absolute(iso, precise)} UTC`}>\n <time dateTime={iso} suppressHydrationWarning>\n {relative(iso, now ?? Date.now(), 'narrow')}\n </time>\n </Tip>\n );\n }\n\n const body = (\n <time className=\"mono\" dateTime={iso}>\n {absolute(iso, precise)}\n </time>\n );\n if (now === null) return body;\n return <Tip label={relative(iso, now)}>{body}</Tip>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,qBAAkC;CAChD,OAAO,cAAc,SAAS,MAAM;AACtC;;AAGA,SAAS,SAAS,MAAc,OAAsB;CACpD,SAAS,SACP,UAAU,OAAO,GAAG,KAAK,s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ACJ,oBAAC,QAAD;EAAM,WAAU;EAAO,UAAU;YAC9B,SAAS,KAAK,OAAO;CAClB,CAAA;CAER,IAAI,QAAQ,MAAM,OAAO;CACzB,OAAO,oBAAC,KAAD;EAAK,OAAO,SAAS,KAAK,GAAG;YAAI;CAAU,CAAA;AACpD"}
1
+ {"version":3,"file":"ui-CGdORVzW.js","names":[],"sources":["../../src/lib/preferences.tsx","../../src/lib/clipboard.ts","../../src/lib/copy-attempts.ts","../../src/components/ui.tsx"],"sourcesContent":["import { createContext, useContext, type RefObject } from 'react';\n\nimport { PREFERENCE_COOKIES, preferencesIn, type Preferences } from '@coffre/core/pages';\n\nexport type { Preferences };\n\nexport type Theme = Preferences['theme'];\n\n/**\n * The preferences in the browser's cookies, as the server read them in the\n * request's: each is a cookie, so the server renders the page as the\n * visitor left it, from the first byte, and the browser hydrates the same.\n */\nexport function browserPreferences(): Preferences {\n return preferencesIn(document.cookie);\n}\n\n/** Keep a choice for a year; the default, by removing it. */\nfunction remember(name: string, value: string | null) {\n document.cookie =\n value === null ? `${name}=; Path=/; SameSite=Lax; Max-Age=0` : `${name}=${value}; Path=/; SameSite=Lax; Max-Age=31536000`;\n}\n\nexport function rememberTheme(theme: Theme) {\n remember(PREFERENCE_COOKIES.theme, theme === 'system' ? null : theme);\n}\n\nexport function rememberSidebar(sidebar: Preferences['sidebar']) {\n remember(PREFERENCE_COOKIES.sidebar, sidebar === 'collapsed' ? 'collapsed' : null);\n}\n\ntype PreferencesValue = Preferences & {\n setTheme(theme: Theme): void;\n setSidebar(sidebar: Preferences['sidebar']): void;\n /** coffre's element, which menus, dialogs and tooltips render into, so they are drawn in its theme. */\n portal: RefObject<HTMLDivElement | null>;\n};\n\nexport const PreferencesContext = createContext<PreferencesValue | null>(null);\n\n/** The visitor's preferences, and the switches, from `<CoffreProvider>`. */\nexport function usePreferences(): PreferencesValue {\n const value = useContext(PreferencesContext);\n if (value === null) throw new Error(\"coffre's pages render inside <CoffreProvider>, in the app's root document\");\n return value;\n}\n","/**\n * Writing to the clipboard, from text that may still be on its way.\n *\n * A browser lets a page write to the clipboard only inside a click's user\n * gesture, and Safari drops the gesture across an `await`. So a value that has\n * to be fetched first (Copy on a hidden secret) is handed over as a promise:\n * `clipboard.write` is called at once, with the promise inside a\n * `ClipboardItem`, and the browser waits for it. Where that is not supported,\n * the text is awaited, then written with `writeText`, which is what every\n * browser but Safari allows.\n *\n * The text goes through byte for byte: no trimming, no newline changes.\n */\n\n/** What of the clipboard `copyText` uses; the browser's `navigator.clipboard` fits. */\nexport type ClipboardLike = {\n writeText(text: string): Promise<void>;\n write?(items: unknown[]): Promise<void>;\n};\n\ntype ClipboardItemConstructor = new (items: Record<string, Promise<string>>) => unknown;\n\nexport async function copyText(\n text: string | Promise<string>,\n {\n clipboard = globalThis.navigator?.clipboard as ClipboardLike | undefined,\n item = (globalThis as { ClipboardItem?: ClipboardItemConstructor }).ClipboardItem,\n }: { clipboard?: ClipboardLike; item?: ClipboardItemConstructor } = {},\n): Promise<void> {\n // A read that fails after the copy has ended is nobody's to hear: not an unhandled rejection.\n if (typeof text !== 'string') text.catch(() => {});\n if (clipboard === undefined) throw new Error('The clipboard is not available here.');\n if (typeof text !== 'string' && item !== undefined && clipboard.write !== undefined) {\n // Called before anything is awaited: this is what keeps the user gesture.\n // The text goes in as a string, not a Blob: decoding a Blob drops a leading U+FEFF.\n await clipboard.write([new item({ 'text/plain': text })]);\n return;\n }\n await clipboard.writeText(await text);\n}\n","import { copyText } from './clipboard.ts';\n\n/**\n * How a copy ended, as far as anyone still cares.\n *\n * `superseded`: a newer copy began before this one ended, so this one reports\n * nothing and writes nothing. Its result, good or bad, is not what the person\n * asked for last.\n */\nexport type CopyResult = { outcome: 'copied' } | { outcome: 'failed'; failure: unknown } | { outcome: 'superseded' };\n\n/** What a copy button shows: a copy under way, or how the last one ended, for a moment. */\nexport type CopyFeedback = 'idle' | 'pending' | 'copied' | 'failed';\n\n/**\n * Copies where the latest one wins, and what they look like while they run.\n *\n * The clipboard is one resource per page, so \"latest\" is decided per page: every\n * copy, from any row, takes a number from one counter before it awaits anything,\n * and only the newest reports, shows feedback, or writes. A copy may start while\n * an earlier one is still reading or waiting on the clipboard: a retry after a\n * refusal, a click on another row, a row filtered out and back, a button replaced\n * by a remount. When a copy from another copier takes over, the older one drops\n * its pending or \"Copied\" feedback and goes back to idle. A copier belongs to\n * whoever outlives the button (a row); the button only subscribes to it, so a\n * remount picks up where it was.\n */\nexport type Copier = {\n run(text: string | Promise<string>): Promise<CopyResult>;\n feedback(): CopyFeedback;\n subscribe(listener: () => void): () => void;\n};\n\nconst SUPERSEDED = new Error('A newer copy began.');\n\n/** The page's newest copy, and the copier that made it. */\nlet latest = 0;\nlet owner: { drop(): void } | null = null;\n\nexport function createCopier({\n copy = copyText,\n copiedMs = 1400,\n failedMs = 3000,\n}: { copy?: typeof copyText; copiedMs?: number; failedMs?: number } = {}): Copier {\n let feedback: CopyFeedback = 'idle';\n let timer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n function show(next: CopyFeedback) {\n if (feedback === next) return;\n feedback = next;\n for (const listener of listeners) listener();\n }\n\n function stopTimer() {\n if (timer !== null) clearTimeout(timer);\n timer = null;\n }\n\n const self = {\n /** Another copier's copy took over: nothing of this one's is left showing. */\n drop() {\n stopTimer();\n show('idle');\n },\n };\n\n return {\n feedback: () => feedback,\n subscribe(listener) {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n async run(text) {\n const attempt = ++latest;\n if (owner !== null && owner !== self) owner.drop();\n owner = self;\n stopTimer();\n show('pending');\n // A read that finishes after a newer copy began, anywhere on the page, is\n // refused here, so it never reaches the clipboard: the fallback does not\n // write it, and a ClipboardItem whose payload rejects writes nothing.\n const gated =\n typeof text === 'string'\n ? text\n : text.then((value) => {\n if (attempt !== latest) throw SUPERSEDED;\n return value;\n });\n let result: CopyResult = { outcome: 'copied' };\n try {\n // Called before anything is awaited: the click's gesture is still live.\n await copy(gated);\n } catch (failure) {\n result = { outcome: 'failed', failure };\n }\n if (attempt !== latest) return { outcome: 'superseded' };\n show(result.outcome === 'copied' ? 'copied' : 'failed');\n timer = setTimeout(() => show('idle'), result.outcome === 'copied' ? copiedMs : failedMs);\n return result;\n },\n };\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactElement, type ReactNode } from 'react';\nimport { AlertDialog } from '@base-ui/react/alert-dialog';\nimport { Dialog } from '@base-ui/react/dialog';\nimport { Menu } from '@base-ui/react/menu';\nimport { Popover } from '@base-ui/react/popover';\nimport { Tooltip } from '@base-ui/react/tooltip';\nimport { AlertCircle, AlertTriangle, Check, Copy, Info, Loader, X } from './icons';\nimport { createCopier, type Copier } from '../lib/copy-attempts';\nimport { usePreferences } from '../lib/preferences';\n\n/* -------------------------------------------------------------------------- */\n/* Tooltip */\n/* -------------------------------------------------------------------------- */\n\nexport function TooltipProvider({ children }: { children: ReactNode }) {\n // 400ms before the first tip; afterwards adjacent tips open instantly, which\n // makes a row of controls feel immediate without the delay losing its\n // purpose (preventing accidental activation on a passing cursor).\n return (\n <Tooltip.Provider delay={400} timeout={300}>\n {children}\n </Tooltip.Provider>\n );\n}\n\nexport function Tip({\n label,\n side,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n return (\n <Tooltip.Root>\n <Tooltip.Trigger render={children} />\n <Tooltip.Portal container={portal}>\n <Tooltip.Positioner\n className=\"tooltip-positioner\"\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n <Tooltip.Popup className=\"tooltip\">{label}</Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n\n/**\n * The same bubble as Tip, for a note a touch screen must reach too.\n *\n * A tooltip opens on hover and focus only, so on a phone it never opens. This\n * one also opens on a tap, which means its trigger has to be a real button.\n * With a mouse, hover alone drives it: a click would otherwise close the note\n * the hover just opened.\n */\nexport function Toggletip({\n label,\n side,\n align,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n /** `end` for a trigger at the right edge, so the tip opens leftwards. */\n align?: 'start' | 'center' | 'end';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n const [open, setOpen] = useState(false);\n const mouse = useRef(false);\n const hover = (next: boolean) => (event: { pointerType: string }) => {\n if (event.pointerType === 'mouse') setOpen(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(next, { reason }) => {\n const clicked = reason === 'trigger-press' && mouse.current;\n mouse.current = false;\n if (!clicked) setOpen(next);\n }}\n >\n <Popover.Trigger\n render={children}\n onPointerEnter={hover(true)}\n onPointerLeave={hover(false)}\n onPointerDown={(event) => {\n mouse.current = event.pointerType === 'mouse';\n }}\n />\n <Popover.Portal container={portal}>\n <Popover.Positioner\n className=\"tooltip-positioner\"\n side={side}\n align={align}\n sideOffset={6}\n collisionPadding={16}\n >\n {/* Focus stays on the trigger, so there is nothing to return it to. */}\n <Popover.Popup className=\"tooltip\" initialFocus={false} finalFocus={false}>\n {label}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Menu */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A menu's floating panel, placed against its `Menu.Trigger`.\n *\n * The callers keep the rest of Base UI's menu parts: the trigger, the items\n * and their separators read better at the call site than behind props.\n */\nexport function MenuPopup({\n side,\n align,\n className,\n children,\n}: {\n side?: 'top' | 'bottom';\n align: 'start' | 'end';\n className?: string;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n return (\n <Menu.Portal container={portal}>\n <Menu.Positioner className=\"menu-positioner\" side={side} align={align} sideOffset={6}>\n <Menu.Popup className={className === undefined ? 'menu' : `menu ${className}`}>\n {children}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Feedback primitives */\n/* -------------------------------------------------------------------------- */\n\nexport function Spinner({ size = 14 }: { size?: number }) {\n return <Loader size={size} className=\"spinner\" />;\n}\n\nexport function ErrorLine({ error }: { error: string | null }) {\n if (error === null) return null;\n return (\n <p className=\"error-line\" role=\"alert\">\n <AlertCircle size={14} />\n <span>{error}</span>\n </p>\n );\n}\n\nconst NOTICE_ICON = {\n info: Info,\n good: Check,\n bad: AlertTriangle,\n warn: AlertTriangle,\n neutral: Info,\n} as const;\n\nexport function Notice({\n tone = 'neutral',\n children,\n}: {\n tone?: keyof typeof NOTICE_ICON;\n children: ReactNode;\n}) {\n const Icon = NOTICE_ICON[tone];\n return (\n <div\n className={`notice${tone === 'neutral' ? '' : ` notice-${tone}`}`}\n role={tone === 'bad' ? 'alert' : undefined}\n >\n <Icon size={16} />\n <div>{children}</div>\n </div>\n );\n}\n\n/**\n * Nothing here yet, said in a sentence.\n *\n * It sits where the table would have been, left-aligned like the rows it\n * stands in for, rather than as a centred illustration.\n */\nexport function EmptyState({\n title,\n children,\n actions,\n}: {\n title: string;\n children?: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <div className=\"empty\">\n <p className=\"empty-title\">{title}</p>\n {children !== undefined && <p className=\"empty-body\">{children}</p>}\n {actions !== undefined && <div className=\"empty-actions\">{actions}</div>}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Text */\n/* -------------------------------------------------------------------------- */\n\n/**\n * An identifier that wraps after its underscores rather than mid-word.\n *\n * To the line breaker `DOCUSIGN_INTEGRATION_KEY` is one word, so a narrow\n * column cuts it wherever room runs out (`…_KE` / `Y`). A <wbr> after each\n * underscore offers the natural places instead. Copied text is unchanged, and\n * `overflow-wrap: anywhere` still catches a segment too long for any line.\n */\nexport function breakAfterUnderscores(text: string): ReactNode {\n return text\n .split('_')\n .flatMap((part, index) => (index === 0 ? [part] : ['_', <wbr key={index} />, part]));\n}\n\n/* -------------------------------------------------------------------------- */\n/* Copy */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy to clipboard with a settled confirmation.\n *\n * The glyph turns into a check, and screen readers hear \"Copied\", for 1.4s --\n * long enough to be noticed after the eye has moved on, short enough not to\n * look stuck. A copy that fails says so the same way, in red, rather than\n * leaving the click looking ignored.\n *\n * `value` is the text. A caller that must read it first (Copy on a hidden\n * secret) passes the `copier` it owns instead, and `onCopy`, called inside the\n * click so the clipboard write keeps its user gesture, which starts a copy on\n * that copier. Copies do not lock the button: a click while one is out starts\n * the next, and the latest one's ending is the one that shows. The copier's\n * owner outlives the button, so a remount keeps the feedback of a copy in flight.\n */\nexport function CopyButton({\n label = 'Copy',\n variant = 'icon',\n ...source\n}: {\n label?: string;\n /** `act` sits among a table row's actions; `icon` anywhere else. */\n variant?: 'icon' | 'act';\n} & ({ value: string; copier?: undefined; onCopy?: undefined } | { value?: undefined; copier: Copier; onCopy: () => void })) {\n const [own] = useState(() => createCopier());\n const copier = source.copier ?? own;\n const state = useSyncExternalStore(copier.subscribe, copier.feedback, copier.feedback);\n\n function copy() {\n if (source.copier !== undefined) source.onCopy();\n else void own.run(source.value);\n }\n\n const text = state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : label;\n return (\n <Tip label={text}>\n <button\n type=\"button\"\n className={variant === 'act' ? 'act act-icon' : 'btn btn-quiet btn-sm btn-icon'}\n aria-label={label}\n aria-busy={state === 'pending'}\n onClick={copy}\n >\n {state === 'pending' ? (\n <Spinner size={13} />\n ) : state === 'copied' ? (\n <Check size={14} className=\"copied\" />\n ) : state === 'failed' ? (\n <AlertCircle size={14} className=\"copy-failed\" />\n ) : (\n <Copy size={14} />\n )}\n <span className=\"visually-hidden\" aria-live=\"polite\">\n {state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : ''}\n </span>\n </button>\n </Tip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Confirmation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Confirmation for actions with reach.\n *\n * Reserved for changes that affect other people or other screens (archiving a\n * project, revoking a grant). Restoring one secret is reversible and gets an\n * undo toast instead -- a dialog on every action trains people to dismiss them.\n */\ntype ConfirmProps = {\n title: ReactNode;\n body: ReactNode;\n /** What the body's sentence cannot hold, such as a list: after it, outside its paragraph. */\n detail?: ReactNode;\n confirmLabel: string;\n destructive?: boolean;\n /** While something must happen first, which `detail` says. */\n confirmDisabled?: boolean;\n onConfirm: () => void;\n};\n\nfunction ConfirmContent({ title, body, detail, confirmLabel, destructive, confirmDisabled, onConfirm }: ConfirmProps) {\n const { portal } = usePreferences();\n return (\n <AlertDialog.Portal container={portal}>\n <AlertDialog.Backdrop className=\"overlay\" />\n <AlertDialog.Popup className=\"dialog dialog-confirm\">\n <AlertDialog.Title className=\"dialog-title\">{title}</AlertDialog.Title>\n <AlertDialog.Description className=\"dialog-body\">{body}</AlertDialog.Description>\n {detail}\n <div className=\"dialog-actions\">\n <AlertDialog.Close className=\"btn\">Cancel</AlertDialog.Close>\n <AlertDialog.Close\n className={`btn ${destructive === false ? 'btn-primary' : 'btn-danger'}`}\n onClick={onConfirm}\n disabled={confirmDisabled}\n >\n {confirmLabel}\n </AlertDialog.Close>\n </div>\n </AlertDialog.Popup>\n </AlertDialog.Portal>\n );\n}\n\nexport function ConfirmButton({\n trigger,\n disabled,\n ...confirm\n}: ConfirmProps & { trigger: ReactElement; disabled?: boolean }) {\n return (\n <AlertDialog.Root>\n <AlertDialog.Trigger render={trigger} disabled={disabled} />\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\nconst hydrated = () => true;\nconst serverRender = () => false;\nconst unchanging = () => () => {};\n\n/**\n * Whether a dialog's root is drawn: always once the page is the browser's,\n * which closes it with its animation; on the server and while hydrating,\n * only when it is open. Closed, a dialog draws nothing, so the page's HTML\n * is the same either way, and the server skips a root per dialog: four in\n * each row of an environment's table. Its trigger is elsewhere, so mounting\n * it after hydration remounts nothing else.\n */\nfunction useHydrated(open: boolean): boolean {\n return useSyncExternalStore(unchanging, hydrated, serverRender) || open;\n}\n\n/**\n * The same confirmation, opened from something that is not a trigger.\n *\n * A menu item cannot be one: it unmounts as the menu closes, taking the dialog\n * with it. So the caller keeps the open state and the dialog lives outside the\n * menu entirely.\n */\nexport function ConfirmDialog({\n open,\n onOpenChange,\n ...confirm\n}: ConfirmProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n if (!useHydrated(open)) return null;\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\n/**\n * A plain modal, for a task you chose to begin.\n *\n * Distinct from ConfirmButton: that one interrupts to ask about something you\n * already started, this one holds a form.\n */\nexport function Modal({\n open,\n onOpenChange,\n title,\n description,\n wide = false,\n children,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n wide?: boolean;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n if (!useHydrated(open)) return null;\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Portal container={portal}>\n <Dialog.Backdrop className=\"overlay\" />\n <Dialog.Popup className={`dialog${wide ? ' dialog-wide' : ''}`}>\n <div className=\"dialog-head\">\n <Dialog.Title className=\"dialog-title\">{title}</Dialog.Title>\n <Dialog.Close className=\"btn btn-quiet btn-sm btn-icon\" aria-label=\"Close\">\n <X size={15} />\n </Dialog.Close>\n </div>\n {description !== undefined && (\n <Dialog.Description className=\"dialog-body\">{description}</Dialog.Description>\n )}\n {children}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Time */\n/* -------------------------------------------------------------------------- */\n\nconst RELATIVE_STEPS: [limit: number, divisor: number, unit: Intl.RelativeTimeFormatUnit][] = [\n [60, 1, 'second'],\n [3600, 60, 'minute'],\n [86400, 3600, 'hour'],\n [2592000, 86400, 'day'],\n [31536000, 2592000, 'month'],\n [Infinity, 31536000, 'year'],\n];\n\n/** One formatter per style, made once: making one costs more than a row of a page renders around it. */\nconst RELATIVE = {\n long: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'long' }),\n narrow: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'narrow' }),\n};\n\nfunction relative(iso: string, now: number, style: 'long' | 'narrow' = 'long'): string {\n const delta = (new Date(iso).getTime() - now) / 1000;\n const magnitude = Math.abs(delta);\n const [, divisor, unit] = RELATIVE_STEPS.find(([limit]) => magnitude < limit)!;\n return RELATIVE[style].format(Math.round(delta / divisor), unit);\n}\n\n/** A UTC time as the log writes it: `2026-10-17 08:45:13`, to the millisecond when `precise`. */\nexport function absolute(iso: string, precise: boolean): string {\n return iso.replace('T', ' ').replace('Z', '').slice(0, precise ? 23 : 19);\n}\n\n/**\n * A timestamp. Absolute UTC by default, \"3 hours ago\" on hover.\n *\n * Absolute is the default on purpose: in the audit log this is evidence, and\n * someone reading it is often transcribing it into a finding. `relative` flips\n * the two, in the short form (\"5h ago\"), for glanceable metadata like \"last\n * written\". The relative form can\n * differ between server and client by a rounding step, so that one text node\n * opts out of the hydration check rather than render a placeholder first.\n */\nexport function Timestamp({\n iso,\n precise = false,\n display = 'absolute',\n}: {\n iso: string;\n precise?: boolean;\n display?: 'absolute' | 'relative';\n}) {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => setNow(Date.now()), [iso]);\n\n if (display === 'relative') {\n return (\n <Tip label={`${absolute(iso, precise)} UTC`}>\n <time dateTime={iso} suppressHydrationWarning>\n {relative(iso, now ?? Date.now(), 'narrow')}\n </time>\n </Tip>\n );\n }\n\n const body = (\n <time className=\"mono\" dateTime={iso}>\n {absolute(iso, precise)}\n </time>\n );\n if (now === null) return body;\n return <Tip label={relative(iso, now)}>{body}</Tip>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,qBAAkC;CAChD,OAAO,cAAc,SAAS,MAAM;AACtC;;AAGA,SAAS,SAAS,MAAc,OAAsB;CACpD,SAAS,SACP,UAAU,OAAO,GAAG,KAAK,sCAAsC,GAA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