@brucesantos/design-space 0.1.1 → 0.2.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.
@@ -24,7 +24,7 @@ export type Registry = {
24
24
  /** Cenários que abrem a mesma rota. Serve para o seletor de situação. */
25
25
  scenariosForRoute: (route: string) => Scenario[];
26
26
  /**
27
- * Busca por vocabulário de negócio. Um PO precisa achar "convênio recusado"
27
+ * Busca por vocabulário de negócio. Um PO precisa achar "aprovação bloqueada"
28
28
  * sem saber o id nem o nome do arquivo (§15.1 "Compreensão de negócio").
29
29
  */
30
30
  search: (query: string) => Scenario[];
@@ -1,7 +1,7 @@
1
1
  import { ProductDefinition, Scenario } from '../types/index.js';
2
2
  export type ValidationIssue = {
3
3
  level: "error" | "warning";
4
- /** Onde o problema está: `scenario:finance.insurance-denied`. */
4
+ /** Onde o problema está: `scenario:requests.approve-blocked`. */
5
5
  where: string;
6
6
  message: string;
7
7
  };
@@ -9,7 +9,7 @@ export type RouteMatch = {
9
9
  */
10
10
  export declare function matchPath(pattern: string, path: string): Record<string, string> | null;
11
11
  /**
12
- * Resolve a rota ativa. Rotas mais específicas primeiro: entre `/patients/new`
13
- * e `/patients/:id`, a literal ganha, independente da ordem de declaração.
12
+ * Resolve a rota ativa. Rotas mais específicas primeiro: entre `/requests/new`
13
+ * e `/requests/:id`, a literal ganha, independente da ordem de declaração.
14
14
  */
15
15
  export declare function resolveRoute(routes: RouteDefinition[], path: string): RouteMatch | undefined;
@@ -1,5 +1,140 @@
1
1
  import { KeyboardCoverage, NetworkState, ScenarioStatus } from '../types/index.js';
2
+ export type Labels = {
3
+ status: Record<ScenarioStatus, string>;
4
+ statusMeaning: Record<ScenarioStatus, string>;
5
+ network: Record<NetworkState, string>;
6
+ keyboard: Record<KeyboardCoverage, string>;
7
+ /** Rótulo de viewport por id: `fit`, `mobile`, `tablet`, `desktop`, `custom`. */
8
+ viewport: Record<string, string>;
9
+ topbar: {
10
+ toggleNav: string;
11
+ copyLink: string;
12
+ copied: string;
13
+ copyPrompt: string;
14
+ cleanReview: string;
15
+ cleanReviewTitle: string;
16
+ panel: string;
17
+ branchTitle: (branch: string) => string;
18
+ commitTitle: (commit: string) => string;
19
+ envTitle: (env: string) => string;
20
+ };
21
+ sidebar: {
22
+ region: string;
23
+ searchPlaceholder: string;
24
+ searchLabel: string;
25
+ noMatch: (query: string) => string;
26
+ matchCount: (total: number) => string;
27
+ emptyModule: string;
28
+ withoutModule: string;
29
+ };
30
+ controls: {
31
+ region: string;
32
+ persona: string;
33
+ fixture: string;
34
+ network: string;
35
+ viewport: string;
36
+ customWidth: string;
37
+ theme: string;
38
+ locale: string;
39
+ dataSource: string;
40
+ fixturesOption: string;
41
+ a11y: string;
42
+ keyboardMode: string;
43
+ keyboardModeTitle: string;
44
+ reducedMotion: string;
45
+ reducedMotionTitle: string;
46
+ textScale: string;
47
+ none: string;
48
+ };
49
+ inspector: {
50
+ region: string;
51
+ tabScenario: string;
52
+ tabA11y: string;
53
+ tabDiagnostics: string;
54
+ diagnosticsWithErrors: (count: number) => string;
55
+ noScenario: string;
56
+ situation: string;
57
+ reproduction: string;
58
+ id: string;
59
+ route: string;
60
+ persona: string;
61
+ personaSwapped: string;
62
+ data: string;
63
+ network: string;
64
+ goal: (goal: string) => string;
65
+ permissions: string;
66
+ preconditions: string;
67
+ rules: string;
68
+ actions: string;
69
+ expected: string;
70
+ approval: string;
71
+ openApproved: string;
72
+ engineering: string;
73
+ a11yContract: string;
74
+ keyboard: string;
75
+ contrast: string;
76
+ contrastTarget: (target: string) => string;
77
+ announces: string;
78
+ focusedElement: string;
79
+ keyboardModeOff: string;
80
+ pressTab: (tabStops: number) => string;
81
+ role: string;
82
+ name: string;
83
+ noAccessibleName: string;
84
+ nameFrom: string;
85
+ description: string;
86
+ selector: string;
87
+ focusableButHidden: string;
88
+ tabStopsInStage: (tabStops: number) => string;
89
+ tokenContrast: string;
90
+ noContrastPairs: string;
91
+ pair: string;
92
+ ratio: string;
93
+ pairsFailing: (count: number) => string;
94
+ automatedIsFloor: string;
95
+ coverage: string;
96
+ scenariosRegistered: (count: number) => string;
97
+ scenarioContract: string;
98
+ noIssues: string;
99
+ };
100
+ home: {
101
+ lead: (total: number) => string;
102
+ withoutModule: string;
103
+ withoutModuleHint: string;
104
+ emptyModule: string;
105
+ keyboardBadge: string;
106
+ };
107
+ shell: {
108
+ restoreChrome: string;
109
+ noRoute: string;
110
+ noRouteHint: string;
111
+ };
112
+ };
113
+ /** Português. É o padrão, não uma obrigação. */
114
+ export declare const DEFAULT_LABELS: Labels;
115
+ /** Override por grupo. O que não vier declarado fica no padrão. */
116
+ export type LabelsOverride = {
117
+ [Group in keyof Labels]?: Partial<Labels[Group]>;
118
+ };
119
+ /**
120
+ * Mescla um grupo por vez. Dois níveis bastam porque a estrutura tem dois, e
121
+ * mesclagem profunda genérica engoliria erro de digitação em vez de deixar o
122
+ * TypeScript reclamar.
123
+ */
124
+ export declare function resolveLabels(override?: LabelsOverride): Labels;
125
+ /**
126
+ * Rótulos resolvidos, para o chrome inteiro.
127
+ *
128
+ * O padrão do contexto é o português, então `Home` e `Stage` — exportados e
129
+ * montáveis fora do `DesignSpace` — continuam funcionando sem provider.
130
+ */
131
+ export declare const LabelsContext: import('react').Context<Labels>;
132
+ export declare function useLabels(): Labels;
133
+ /** @deprecated Use `useLabels().status`, ou `DEFAULT_LABELS.status` fora de React. */
2
134
  export declare const STATUS_LABELS: Record<ScenarioStatus, string>;
135
+ /** @deprecated Use `useLabels().statusMeaning`. */
3
136
  export declare const STATUS_MEANING: Record<ScenarioStatus, string>;
137
+ /** @deprecated Use `useLabels().network`. */
4
138
  export declare const NETWORK_LABELS: Record<NetworkState, string>;
139
+ /** @deprecated Use `useLabels().keyboard`. */
5
140
  export declare const KEYBOARD_LABELS: Record<KeyboardCoverage, string>;
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
- import { v as n, j as o, i, s as t } from "./contrast-DsgJg12D.js";
2
- import { b as v, d as P, c as g, f as E } from "./contrast-DsgJg12D.js";
1
+ import { v as n, j as o, i, s as t } from "./contrast-BXd_acxo.js";
2
+ import { b as v, d as P, c as g, f as E } from "./contrast-BXd_acxo.js";
3
3
  function a(e = "http://localhost:5173") {
4
4
  const r = typeof process < "u" ? process.env : {};
5
5
  return (r.PREVIEW_URL || r.BASE_URL || e).replace(/\/$/, "");
@@ -1,4 +1,5 @@
1
1
  import { ComponentType, ReactNode } from 'react';
2
+ import { LabelsOverride } from '../shell/labels.js';
2
3
  /**
3
4
  * Estado de ciclo de vida do cenário (§18.1). Existe para evitar que a
4
5
  * referência envelheça em silêncio quando o produto real muda.
@@ -19,9 +20,9 @@ export type A11yContract = {
19
20
  contrast: ContrastTarget;
20
21
  /**
21
22
  * Eventos que precisam ser anunciados para leitor de tela. São chaves de
22
- * domínio, não seletores: `claim.status`, `retry.result`.
23
+ * domínio, não seletores: `request.status`, `retry.result`.
23
24
  *
24
- * Um cenário de convênio recusado em que a recusa não é anunciada está
25
+ * Um cenário de aprovação bloqueada em que a recusa não é anunciada está
25
26
  * incompleto, não está pronto para aprovação.
26
27
  */
27
28
  announces?: string[];
@@ -31,7 +32,7 @@ export type A11yContract = {
31
32
  export type Persona = {
32
33
  /** Identificador estável usado em URL e em cenário. */
33
34
  id: string;
34
- /** Nome no vocabulário do cliente: "Recepcionista". */
35
+ /** Nome no vocabulário do cliente: "Aprovador". */
35
36
  name: string;
36
37
  /** O que essa pessoa está tentando fazer. */
37
38
  goal?: string;
@@ -46,7 +47,7 @@ export type Rule = {
46
47
  statement: string;
47
48
  /** Por que a regra existe. Contexto, não implementação. */
48
49
  rationale?: string;
49
- /** Onde a regra vive no código, quando existir: `src/rules/claims.ts`. */
50
+ /** Onde a regra vive no código, quando existir: `src/rules/requests.ts`. */
50
51
  source?: string;
51
52
  };
52
53
  /**
@@ -72,9 +73,9 @@ export declare const NETWORK_STATES: readonly NetworkState[];
72
73
  * disponíveis, regras e resultado esperado.
73
74
  */
74
75
  export type Scenario = {
75
- /** `modulo.situacao` em kebab-case: `finance.insurance-denied`. */
76
+ /** `modulo.situacao` em kebab-case: `requests.approve-blocked`. */
76
77
  id: string;
77
- /** Título no vocabulário do negócio: "Convênio recusado". */
78
+ /** Título no vocabulário do negócio: "Aprovação bloqueada por falta de documento". */
78
79
  title: string;
79
80
  /** Rota que o cenário abre. Precisa casar com uma rota do produto. */
80
81
  route: string;
@@ -82,8 +83,8 @@ export type Scenario = {
82
83
  persona: string;
83
84
  /**
84
85
  * Permissões efetivas do cenário. Quando ausente, herda as da persona.
85
- * Declarar aqui permite representar "recepcionista sem permissão de
86
- * cancelamento" sem inventar uma segunda persona.
86
+ * Declarar aqui permite representar "solicitante sem permissão de aprovar"
87
+ * sem inventar uma segunda persona.
87
88
  */
88
89
  permissions?: string[];
89
90
  /** Id de uma fixture registrada no produto. */
@@ -125,7 +126,7 @@ export type Scenario = {
125
126
  */
126
127
  export type Flow = {
127
128
  id: string;
128
- /** Título de negócio: "Agendar uma consulta". */
129
+ /** Título de negócio: "Decidir uma solicitação". */
129
130
  title: string;
130
131
  description?: string;
131
132
  steps: FlowStep[];
@@ -141,9 +142,9 @@ export type FlowStep = {
141
142
  branches?: Record<string, string>;
142
143
  };
143
144
  export type Module = {
144
- /** `agenda`, `patients`, `finance`. */
145
+ /** `requests`, `catalog`, `billing`. */
145
146
  id: string;
146
- /** Nome no vocabulário do cliente: "Agenda". */
147
+ /** Nome no vocabulário do cliente: "Solicitações". */
147
148
  name: string;
148
149
  description?: string;
149
150
  /** Jornadas guiadas do módulo. Opcional: navegação livre é o padrão. */
@@ -200,6 +201,18 @@ export type ProductTheme = {
200
201
  modes?: string[];
201
202
  /** Idiomas disponíveis, quando o produto tiver essa variação. */
202
203
  locales?: string[];
204
+ /**
205
+ * Rótulos do chrome do motor. Sobrescreve por grupo o que estiver em
206
+ * `DEFAULT_LABELS`; o que não for declarado fica no padrão em português.
207
+ *
208
+ * Serve para o Design Space de um cliente que revisa em outro idioma: o chrome
209
+ * divide a tela com a UI do produto, e chrome em português ao lado de interface
210
+ * em inglês é ruído no meio da revisão.
211
+ *
212
+ * Isto é rótulo de **mecanismo**. Nome de módulo, título de cenário e nome de
213
+ * persona continuam vindo do catálogo do produto.
214
+ */
215
+ labels?: LabelsOverride;
203
216
  };
204
217
  export type ContrastPair = {
205
218
  /** Nome do par: `fg-1 sobre bg-app`. */
@@ -214,9 +227,9 @@ export type ContrastPair = {
214
227
  largeText?: boolean;
215
228
  };
216
229
  export type ProductDefinition = {
217
- /** `bloomy`. */
230
+ /** `acme`. */
218
231
  id: string;
219
- /** "Bloomy". */
232
+ /** "Acme". */
220
233
  name: string;
221
234
  /** Uma linha sobre o produto, exibida na entrada do Design Space. */
222
235
  tagline?: string;
@@ -236,24 +249,25 @@ export type ProductDefinition = {
236
249
  adapters?: DataSourceAdapter[];
237
250
  };
238
251
  /**
239
- * Contexto do deployment, informado pelo produto.
252
+ * Contexto do deployment, informado pelo produto. **Opcional**: um Design
253
+ * Space que roda só local não precisa dele.
240
254
  *
241
255
  * O motor **não consegue** descobrir isso sozinho. Ele é uma biblioteca já
242
256
  * compilada: o `import.meta.env` do código dele foi resolvido no build do
243
257
  * pacote, não no build do produto, então não sobra nada para o bundler do
244
258
  * produto substituir. Quem tem acesso ao próprio ambiente de build é o produto.
245
259
  *
246
- * Passe os valores do bundler:
260
+ * Passe os valores do bundler, com o nome que o seu build usar:
247
261
  *
248
262
  * ```ts
249
263
  * deploy: {
250
- * env: import.meta.env.VITE_VERCEL_ENV,
251
- * branch: import.meta.env.VITE_VERCEL_GIT_COMMIT_REF,
252
- * commit: import.meta.env.VITE_VERCEL_GIT_COMMIT_SHA,
264
+ * env: import.meta.env.VITE_DEPLOY_ENV,
265
+ * branch: import.meta.env.VITE_DEPLOY_BRANCH,
266
+ * commit: import.meta.env.VITE_DEPLOY_COMMIT,
253
267
  * }
254
268
  * ```
255
269
  *
256
- * Sem isso o cabeçalho da revisão mostra "development" e fica sem branch nem
270
+ * Sem isso o cabeçalho da revisão mostra "development" e omite branch e
257
271
  * commit — e é o commit que torna uma aprovação rastreável.
258
272
  */
259
273
  deploy?: DeployOverrides;
@@ -268,8 +282,9 @@ export type ProductDefinition = {
268
282
  }>;
269
283
  };
270
284
  /**
271
- * Contexto do deployment informado pelo produto. Todos os campos são opcionais:
272
- * o que vier preenchido substitui a detecção do motor.
285
+ * Contexto do deployment informado pelo produto. Todos os campos são opcionais,
286
+ * e é essa a fonte única: o motor não lê ambiente nem conhece provedor de
287
+ * hospedagem. Campo ausente cai no padrão local.
273
288
  */
274
289
  export type DeployOverrides = {
275
290
  /** `development`, `preview` ou `production`. */
@@ -8,10 +8,9 @@
8
8
  *
9
9
  * O bug que a originou: `new Date("2011-09-08")` é parseado como meia-noite
10
10
  * **UTC**. Formatado em qualquer fuso a oeste de Greenwich — o Brasil inteiro —
11
- * exibe o dia anterior. No Bloomy isso apareceu como data de nascimento com um dia
12
- * de atraso, o que também deslocava o cálculo de idade e portanto a regra do
13
- * paciente menor de idade. Na Finaya, como vencimento de cobrança errado por um
14
- * dia.
11
+ * exibe o dia anterior. Em um produto isso apareceu como data de nascimento
12
+ * atrasada em um dia, o que deslocava a idade calculada e portanto uma regra que
13
+ * dependia dela; em outro, como vencimento errado por um dia.
15
14
  *
16
15
  * Os dois produtos escreveram a mesma correção separadamente. Quando isso
17
16
  * acontece, o lugar da correção é o motor — senão o terceiro produto reescreve o
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brucesantos/design-space",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Motor neutro do Bananas Design Space: registry de cenários, shell, deep links, controles de persona/viewport/rede, inspetor de regras e ferramentas de acessibilidade. Não contém UI de cliente.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,4 +64,4 @@
64
64
  "typecheck": "tsc --noEmit",
65
65
  "test": "vitest run"
66
66
  }
67
- }
67
+ }
@@ -1,265 +0,0 @@
1
- const b = [
2
- "proposed",
3
- "in-review",
4
- "approved",
5
- "in-implementation",
6
- "implemented",
7
- "superseded"
8
- ], w = [
9
- "success",
10
- "loading",
11
- "empty",
12
- "error",
13
- "slow"
14
- ], x = /^[a-z0-9]+([.\-][a-z0-9]+)*$/;
15
- function p(e) {
16
- return typeof e == "string" && e.trim().length > 0;
17
- }
18
- function S(e, t) {
19
- const r = [], o = p(e?.id) ? `scenario:${e.id}` : `scenario[${t ?? "?"}]`, n = (d) => r.push({ level: "error", where: o, message: d }), i = (d) => r.push({ level: "warning", where: o, message: d });
20
- p(e?.id) ? x.test(e.id) ? e.id.includes(".") || i("`id` sem prefixo de módulo dificulta a navegação e a busca do agente.") : n(
21
- "`id` deve ser minúsculo em kebab-case, com o módulo como prefixo: `finance.insurance-denied`."
22
- ) : n("`id` é obrigatório."), p(e?.title) || n("`title` é obrigatório e deve usar o vocabulário do negócio."), p(e?.route) ? e.route.startsWith("/") || n("`route` deve começar com `/`.") : n("`route` é obrigatório."), p(e?.persona) || n("`persona` é obrigatório."), p(e?.fixture) || n("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), b.includes(e?.status) || n(`\`status\` deve ser um de: ${b.join(", ")}.`), e?.network && !w.includes(e.network) && n(`\`network\` deve ser um de: ${w.join(", ")}.`);
23
- const a = e?.a11y;
24
- return !a || typeof a != "object" ? n(
25
- "`a11y` é obrigatório. Acessibilidade é campo do contrato, não auditoria de fim de projeto (D-15)."
26
- ) : (["full", "partial", "not-applicable"].includes(a.keyboard) || n("`a11y.keyboard` deve ser `full`, `partial` ou `not-applicable`."), ["AA", "AAA"].includes(a.contrast) || n("`a11y.contrast` deve ser `AA` ou `AAA`. O padrão interno é WCAG 2.2 AA."), a.announces !== void 0 && !Array.isArray(a.announces) && n("`a11y.announces` deve ser uma lista de chaves de evento de domínio.")), e?.status === "approved" && a?.keyboard === "partial" && i(
27
- 'Cenário aprovado com `a11y.keyboard: "partial"`. Confirme que esta jornada não é crítica.'
28
- ), e?.status === "approved" && !e.approvedAt && i(
29
- "Cenário aprovado sem `approvedAt`. A aprovação deve ser registrada por URL de commit (§10.2), senão muda de conteúdo debaixo de quem aprovou."
30
- ), e?.expected?.length || i(
31
- "Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
32
- ), r;
33
- }
34
- function M(e) {
35
- const t = [], r = (c, s, l) => t.push({ level: c, where: s, message: l }), o = new Set(e.personas?.map((c) => c.id) ?? []), n = new Set(e.fixtures?.map((c) => c.id) ?? []), i = new Set(e.rules?.map((c) => c.id) ?? []), a = new Set(e.modules?.map((c) => c.id) ?? []), d = /* @__PURE__ */ new Set();
36
- p(e.id) || r("error", "product", "`id` é obrigatório."), p(e.name) || r("error", "product", "`name` é obrigatório."), e.routes?.length || r("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar.");
37
- for (const [c, s] of (e.scenarios ?? []).entries()) {
38
- t.push(...S(s, c));
39
- const l = `scenario:${s?.id ?? c}`;
40
- if (s?.id) {
41
- d.has(s.id) && r("error", l, `\`id\` duplicado: ${s.id}.`), d.add(s.id);
42
- const f = s.id.split(".")[0];
43
- f && a.size > 0 && !a.has(f) && r(
44
- "warning",
45
- l,
46
- `Prefixo \`${f}\` não corresponde a nenhum módulo registrado. O cenário não vai aparecer na navegação.`
47
- );
48
- }
49
- s?.persona && !o.has(s.persona) && r("error", l, `Persona não registrada: \`${s.persona}\`.`), s?.fixture && !n.has(s.fixture) && r("error", l, `Fixture não registrada: \`${s.fixture}\`.`);
50
- for (const f of s?.rules ?? [])
51
- i.has(f) || r("error", l, `Regra não registrada: \`${f}\`.`);
52
- s?.route && !R(s.route, e) && r(
53
- "error",
54
- l,
55
- `Rota \`${s.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
56
- );
57
- }
58
- for (const c of e.modules ?? [])
59
- for (const s of c.flows ?? []) {
60
- const l = `flow:${c.id}/${s.id}`;
61
- s.steps?.length || r("warning", l, "Jornada sem passos.");
62
- for (const f of s.steps ?? []) {
63
- d.has(f.scenario) || r("error", l, `Passo aponta para cenário inexistente: \`${f.scenario}\`.`);
64
- for (const [_, g] of Object.entries(f.branches ?? {}))
65
- d.has(g) || r(
66
- "error",
67
- l,
68
- `Ramificação "${_}" aponta para cenário inexistente: \`${g}\`.`
69
- );
70
- }
71
- }
72
- const u = e.dataSources?.default;
73
- return u && u !== "fixtures" && (new Set(e.dataSources?.adapters?.map((s) => s.id) ?? []).has(u) || r("error", "product", `\`dataSources.default\` aponta para adapter inexistente: \`${u}\`.`), r(
74
- "warning",
75
- "product",
76
- "A fonte padrão não é `fixtures`. O padrão do ambiente é dado sintético e determinístico (D-05); API real entra como adapter opcional, com justificativa."
77
- )), t;
78
- }
79
- function R(e, t) {
80
- const r = e.split("?")[0] ?? e;
81
- return (t.routes ?? []).some((o) => $(o.path, r));
82
- }
83
- function $(e, t) {
84
- const r = e.split("/").filter(Boolean), o = t.split("/").filter(Boolean);
85
- for (const [n, i] of r.entries()) {
86
- if (i === "*") return !0;
87
- const a = o[n];
88
- if (a === void 0) return !1;
89
- if (!i.startsWith(":") && i !== a)
90
- return !1;
91
- }
92
- return r.length === o.length;
93
- }
94
- function U(e) {
95
- return e.some((t) => t.level === "error");
96
- }
97
- function j(e) {
98
- return e.length === 0 ? "Nenhum problema encontrado." : e.map((t) => `${t.level === "error" ? "✖" : "▲"} ${t.where}
99
- ${t.message}`).join(`
100
- `);
101
- }
102
- const m = {
103
- scenario: "scenario",
104
- persona: "persona",
105
- fixture: "fixture",
106
- network: "network",
107
- viewport: "viewport",
108
- customWidth: "w",
109
- themeMode: "theme",
110
- locale: "locale",
111
- dataSource: "source",
112
- chrome: "chrome",
113
- keyboardMode: "kb",
114
- reducedMotion: "motion",
115
- textScale: "scale",
116
- inspector: "panel"
117
- };
118
- function C(e) {
119
- return typeof e == "boolean" ? e ? "1" : "0" : String(e);
120
- }
121
- function y(e, t = {}) {
122
- for (const [r, o] of Object.entries(t)) {
123
- if (o == null) continue;
124
- const n = m[r];
125
- n && e.set(n, C(o));
126
- }
127
- }
128
- const I = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
129
- function T() {
130
- const e = I;
131
- return e || (typeof process < "u" && process.env ? process.env : {});
132
- }
133
- function A(e = {}) {
134
- const t = T(), r = e.branchUrl || t.VITE_VERCEL_BRANCH_URL || t.VERCEL_BRANCH_URL, o = e.deploymentUrl || t.VITE_VERCEL_URL || t.VERCEL_URL, n = e.env || t.VITE_VERCEL_ENV || t.VERCEL_ENV, i = e.commit || t.VITE_VERCEL_GIT_COMMIT_SHA || t.VERCEL_GIT_COMMIT_SHA, a = r && `https://${r}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
135
- return {
136
- env: n ?? "development",
137
- origin: a.replace(/\/$/, ""),
138
- branchUrl: r,
139
- deploymentUrl: o,
140
- branch: e.branch || t.VITE_VERCEL_GIT_COMMIT_REF || t.VERCEL_GIT_COMMIT_REF,
141
- commit: i,
142
- shortCommit: i?.slice(0, 7),
143
- isDeployed: n === "preview" || n === "production"
144
- };
145
- }
146
- function N(e, t = {}) {
147
- const r = t.origin ?? A().origin, o = new URL(e.route, r);
148
- return o.searchParams.set(m.scenario, e.id), o.searchParams.set(m.persona, e.persona), o.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && o.searchParams.set(m.network, e.network), y(o.searchParams, t.overrides), o.toString();
149
- }
150
- function D(e, t) {
151
- const r = t.commit ?? A().shortCommit;
152
- if (!r) return;
153
- const o = `https://${t.project}-${r}-${t.scope}.vercel.app`;
154
- return N(e, { origin: o });
155
- }
156
- const E = {
157
- AA: { normal: 4.5, large: 3 },
158
- AAA: { normal: 7, large: 4.5 }
159
- }, k = {
160
- white: "#ffffff",
161
- black: "#000000",
162
- transparent: "#00000000"
163
- };
164
- function v(e) {
165
- const t = e.trim().toLowerCase(), r = k[t];
166
- if (r) return v(r);
167
- if (t.startsWith("#")) {
168
- const n = t.slice(1), i = (a) => Number.parseInt(a.repeat(2), 16);
169
- if (n.length === 3 || n.length === 4) {
170
- const [a, d, u, c] = [...n];
171
- return !a || !d || !u ? void 0 : { r: i(a), g: i(d), b: i(u), a: c ? i(c) / 255 : 1 };
172
- }
173
- if (n.length === 6 || n.length === 8) {
174
- const a = (u) => Number.parseInt(n.slice(u, u + 2), 16), d = [a(0), a(2), a(4)];
175
- return d.some(Number.isNaN) ? void 0 : {
176
- r: d[0],
177
- g: d[1],
178
- b: d[2],
179
- a: n.length === 8 ? a(6) / 255 : 1
180
- };
181
- }
182
- return;
183
- }
184
- const o = t.match(/^rgba?\(([^)]+)\)$/);
185
- if (o?.[1]) {
186
- const n = o[1].split(/[\s,/]+/).filter(Boolean), [i, a, d, u] = n.map(Number);
187
- return [i, a, d].some((c) => c === void 0 || Number.isNaN(c)) ? void 0 : { r: i, g: a, b: d, a: u === void 0 || Number.isNaN(u) ? 1 : u };
188
- }
189
- }
190
- function L(e, t) {
191
- if (e.a >= 1) return e;
192
- const r = (o, n) => o * e.a + n * (1 - e.a);
193
- return {
194
- r: r(e.r, t.r),
195
- g: r(e.g, t.g),
196
- b: r(e.b, t.b),
197
- a: 1
198
- };
199
- }
200
- function h({ r: e, g: t, b: r }) {
201
- const o = (n) => {
202
- const i = n / 255;
203
- return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
204
- };
205
- return 0.2126 * o(e) + 0.7152 * o(t) + 0.0722 * o(r);
206
- }
207
- function P(e, t) {
208
- const r = v(t), o = v(e);
209
- if (!r || !o) return;
210
- const n = L(o, r), i = Math.max(h(n), h(r)), a = Math.min(h(n), h(r));
211
- return (i + 0.05) / (a + 0.05);
212
- }
213
- function V(e) {
214
- const t = e.target ?? "AA", r = e.largeText ? E[t].large : E[t].normal, o = P(e.foreground, e.background);
215
- return {
216
- pair: e,
217
- target: t,
218
- ratio: o,
219
- required: r,
220
- passes: o === void 0 ? void 0 : o >= r,
221
- label: o === void 0 ? "não medido" : `${o.toFixed(2)}:1`
222
- };
223
- }
224
- function O(e = []) {
225
- return e.map(V);
226
- }
227
- function z(e) {
228
- const t = O(e).filter((o) => o.passes !== !0);
229
- if (t.length === 0) return;
230
- const r = t.map(
231
- (o) => ` ✖ ${o.pair.name}: ${o.label} (mínimo ${o.required}:1 para ${o.target}${o.pair.largeText ? ", texto grande" : ""})`
232
- ).join(`
233
- `);
234
- throw new Error(`Pares de contraste fora do alvo:
235
- ${r}`);
236
- }
237
- function B(e, t) {
238
- if (typeof window > "u") return;
239
- const r = t ?? document.documentElement;
240
- return window.getComputedStyle(r).getPropertyValue(e).trim() || void 0;
241
- }
242
- export {
243
- E as C,
244
- w as N,
245
- m as P,
246
- b as S,
247
- y as a,
248
- z as b,
249
- O as c,
250
- V as d,
251
- D as e,
252
- P as f,
253
- A as g,
254
- L as h,
255
- j as i,
256
- U as j,
257
- h as k,
258
- C as l,
259
- S as m,
260
- v as p,
261
- B as r,
262
- N as s,
263
- M as v
264
- };
265
- //# sourceMappingURL=contrast-DsgJg12D.js.map