@brucesantos/design-space 0.12.0 → 0.13.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.
@@ -1,16 +1,16 @@
1
- const C = [
1
+ const j = [
2
2
  "success",
3
3
  "loading",
4
4
  "empty",
5
5
  "error",
6
6
  "slow"
7
7
  ];
8
- function j(e, r) {
9
- const o = e.split("/").filter(Boolean), t = M(r).split("/").filter(Boolean), a = {};
8
+ function I(e, t) {
9
+ const o = e.split("/").filter(Boolean), r = M(t).split("/").filter(Boolean), a = {};
10
10
  for (const [s, c] of o.entries()) {
11
11
  if (c === "*")
12
- return a["*"] = t.slice(s).join("/"), a;
13
- const h = t[s];
12
+ return a["*"] = r.slice(s).join("/"), a;
13
+ const h = r[s];
14
14
  if (h === void 0) return null;
15
15
  if (c.startsWith(":")) {
16
16
  a[c.slice(1)] = h;
@@ -18,61 +18,61 @@ function j(e, r) {
18
18
  }
19
19
  if (c !== h) return null;
20
20
  }
21
- return o.length !== t.length ? null : a;
21
+ return o.length !== r.length ? null : a;
22
22
  }
23
- function P(e, r) {
24
- const o = [...e].sort((t, a) => I(a.path) - I(t.path));
25
- for (const t of o) {
26
- const a = j(t.path, r);
27
- if (a) return { definition: t, params: a };
23
+ function P(e, t) {
24
+ const o = [...e].sort((r, a) => C(a.path) - C(r.path));
25
+ for (const r of o) {
26
+ const a = I(r.path, t);
27
+ if (a) return { definition: r, params: a };
28
28
  }
29
29
  }
30
- function E(e, r = {}) {
30
+ function E(e, t = {}) {
31
31
  const o = (a) => {
32
- const s = r[a];
32
+ const s = t[a];
33
33
  return typeof s == "string" && s.length > 0 ? s : void 0;
34
- }, t = [];
34
+ }, r = [];
35
35
  for (const a of e.split("/").filter(Boolean)) {
36
36
  if (a === "*") {
37
37
  const c = o("*");
38
- c && t.push(...c.split("/").filter(Boolean).map(encodeURIComponent));
38
+ c && r.push(...c.split("/").filter(Boolean).map(encodeURIComponent));
39
39
  continue;
40
40
  }
41
41
  const s = a.startsWith(":") ? o(a.slice(1)) : void 0;
42
- t.push(s === void 0 ? a : encodeURIComponent(s));
42
+ r.push(s === void 0 ? a : encodeURIComponent(s));
43
43
  }
44
- return `/${t.join("/")}`;
44
+ return `/${r.join("/")}`;
45
45
  }
46
- function I(e) {
47
- const r = e.split("/").filter(Boolean);
48
- let o = r.length;
49
- for (const t of r)
50
- t === "*" ? o -= 2 : t.startsWith(":") ? o += 1 : o += 4;
46
+ function C(e) {
47
+ const t = e.split("/").filter(Boolean);
48
+ let o = t.length;
49
+ for (const r of t)
50
+ r === "*" ? o -= 2 : r.startsWith(":") ? o += 1 : o += 4;
51
51
  return o;
52
52
  }
53
53
  function M(e) {
54
- const r = e.split("?")[0] ?? e;
54
+ const t = e.split("?")[0] ?? e;
55
55
  try {
56
- return decodeURI(r);
56
+ return decodeURI(t);
57
57
  } catch {
58
- return r;
58
+ return t;
59
59
  }
60
60
  }
61
61
  const R = /^[a-z0-9]+([.\-][a-z0-9]+)*$/, z = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
62
62
  function u(e) {
63
63
  return typeof e == "string" && e.trim().length > 0;
64
64
  }
65
- function L(e, r) {
66
- const o = [], t = u(e?.id) ? `scenario:${e.id}` : `scenario[${r ?? "?"}]`, a = (c) => o.push({ level: "error", where: t, message: c }), s = (c) => o.push({ level: "warning", where: t, message: c });
65
+ function q(e, t) {
66
+ const o = [], r = u(e?.id) ? `scenario:${e.id}` : `scenario[${t ?? "?"}]`, a = (c) => o.push({ level: "error", where: r, message: c }), s = (c) => o.push({ level: "warning", where: r, message: c });
67
67
  return u(e?.id) ? R.test(e.id) || a(
68
68
  "`id` deve ser minúsculo, em kebab-case, com pontos opcionais: `requests.approve-blocked` ou `approve-blocked`."
69
- ) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !C.includes(e.network) && a(`\`network\` deve ser um de: ${C.join(", ")}.`), e?.expected?.length || s(
69
+ ) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !j.includes(e.network) && a(`\`network\` deve ser um de: ${j.join(", ")}.`), e?.expected?.length || s(
70
70
  "Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
71
71
  ), o;
72
72
  }
73
73
  function Q(e) {
74
- const r = [], o = (l, n, i) => r.push({ level: l, where: n, message: i }), t = new Set(e.personas?.map((l) => l.id) ?? []), a = new Set(e.fixtures?.map((l) => l.id) ?? []), s = new Set(e.rules?.map((l) => l.id) ?? []), c = /* @__PURE__ */ new Set();
75
- u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !t.has(e.defaultPersona) && o(
74
+ const t = [], o = (l, n, i) => t.push({ level: l, where: n, message: i }), r = new Set(e.personas?.map((l) => l.id) ?? []), a = new Set(e.fixtures?.map((l) => l.id) ?? []), s = new Set(e.rules?.map((l) => l.id) ?? []), c = /* @__PURE__ */ new Set();
75
+ u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !r.has(e.defaultPersona) && o(
76
76
  "error",
77
77
  "product",
78
78
  `\`defaultPersona\` aponta para persona não registrada: \`${e.defaultPersona}\`.`
@@ -88,20 +88,24 @@ function Q(e) {
88
88
  o("error", i, "`path` é obrigatório.");
89
89
  continue;
90
90
  }
91
- n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), h.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), h.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ? q(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
91
+ n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), h.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), h.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ? L(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
92
92
  }
93
93
  const f = /* @__PURE__ */ new Set();
94
94
  for (const [l, n] of (e.components ?? []).entries()) {
95
95
  const i = `component:${n?.id ?? l}`;
96
- u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre.");
96
+ u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre."), n?.implementation !== void 0 && (Array.isArray(n.implementation) ? n.implementation : [n.implementation]).some((g) => typeof g != "function" && (typeof g != "object" || g === null)) && o(
97
+ "error",
98
+ i,
99
+ "`implementation`, quando informado, é o componente React real (ou uma lista deles), não o nome."
100
+ );
97
101
  const p = /* @__PURE__ */ new Set();
98
- for (const [b, v] of (n?.fixtures ?? []).entries()) {
99
- const g = `${i}/fixture:${v?.id ?? b}`;
100
- u(v?.id) ? R.test(v.id) ? p.has(v.id) ? o("error", g, `Id de fixture do componente duplicado: \`${v.id}\`.`) : p.add(v.id) : o(
102
+ for (const [b, g] of (n?.fixtures ?? []).entries()) {
103
+ const v = `${i}/fixture:${g?.id ?? b}`;
104
+ u(g?.id) ? R.test(g.id) ? p.has(g.id) ? o("error", v, `Id de fixture do componente duplicado: \`${g.id}\`.`) : p.add(g.id) : o(
101
105
  "error",
102
- g,
103
- `Id de fixture do componente inválido: \`${v.id}\`. Use minúsculas em kebab-case.`
104
- ) : o("error", g, "`id` da fixture do componente é obrigatório."), u(v?.label) || o("error", g, "`label` da fixture do componente é obrigatório."), (!v || !("data" in v)) && o("error", g, "`data` da fixture do componente é obrigatório.");
106
+ v,
107
+ `Id de fixture do componente inválido: \`${g.id}\`. Use minúsculas em kebab-case.`
108
+ ) : o("error", v, "`id` da fixture do componente é obrigatório."), u(g?.label) || o("error", v, "`label` da fixture do componente é obrigatório."), (!g || !("data" in g)) && o("error", v, "`data` da fixture do componente é obrigatório.");
105
109
  }
106
110
  n?.defaultFixture && !p.has(n.defaultFixture) && o(
107
111
  "error",
@@ -127,9 +131,9 @@ function Q(e) {
127
131
  );
128
132
  }
129
133
  for (const [l, n] of (e.scenarios ?? []).entries()) {
130
- r.push(...L(n, l));
134
+ t.push(...q(n, l));
131
135
  const i = `scenario:${n?.id ?? l}`;
132
- n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !t.has(n.persona) && o("error", i, `Persona não registrada: \`${n.persona}\`.`), n?.fixture && !a.has(n.fixture) && o("error", i, `Fixture não registrada: \`${n.fixture}\`.`);
136
+ n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !r.has(n.persona) && o("error", i, `Persona não registrada: \`${n.persona}\`.`), n?.fixture && !a.has(n.fixture) && o("error", i, `Fixture não registrada: \`${n.fixture}\`.`);
133
137
  for (const p of n?.rules ?? [])
134
138
  s.has(p) || o("error", i, `Regra não registrada: \`${p}\`.`);
135
139
  for (const p of Array.isArray(n?.components) ? n.components : [])
@@ -142,22 +146,22 @@ function Q(e) {
142
146
  if (!n.controls || typeof n.controls != "object" || Array.isArray(n.controls))
143
147
  o("error", i, "`controls`, quando informado, é um objeto de id do controle → valor.");
144
148
  else if (n.route) {
145
- const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], v = new Map(
146
- b.flatMap((g) => Array.isArray(g?.controls) ? g.controls : []).map((g) => [
147
- g?.id,
148
- g
149
+ const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], g = new Map(
150
+ b.flatMap((v) => Array.isArray(v?.controls) ? v.controls : []).map((v) => [
151
+ v?.id,
152
+ v
149
153
  ])
150
154
  );
151
- for (const [g, O] of Object.entries(n.controls)) {
152
- const x = v.get(g);
153
- x ? (x.options ?? []).some((A) => A?.value === O) || o(
155
+ for (const [v, O] of Object.entries(n.controls)) {
156
+ const A = g.get(v);
157
+ A ? (A.options ?? []).some((x) => x?.value === O) || o(
154
158
  "error",
155
159
  i,
156
- `Valor \`${O}\` não é opção do controle \`${g}\`. Opções: ${(x.options ?? []).map((A) => `\`${A?.value}\``).join(", ")}.`
160
+ `Valor \`${O}\` não é opção do controle \`${v}\`. Opções: ${(A.options ?? []).map((x) => `\`${x?.value}\``).join(", ")}.`
157
161
  ) : o(
158
162
  "error",
159
163
  i,
160
- `Controle \`${g}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
164
+ `Controle \`${v}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
161
165
  );
162
166
  }
163
167
  }
@@ -173,13 +177,13 @@ function Q(e) {
173
177
  "warning",
174
178
  "product",
175
179
  "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."
176
- )), r;
180
+ )), t;
177
181
  }
178
- function q(e, r, o) {
179
- const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
182
+ function L(e, t, o) {
183
+ const r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
180
184
  for (const [s, c] of e.entries()) {
181
- const h = `${r}/group:${c?.id ?? s}`;
182
- if (u(c?.id) ? t.has(c.id) ? o("error", h, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : t.add(c.id) : o("error", h, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", h, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
185
+ const h = `${t}/group:${c?.id ?? s}`;
186
+ if (u(c?.id) ? r.has(c.id) ? o("error", h, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : r.add(c.id) : o("error", h, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", h, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
183
187
  o("error", h, "`controls` do grupo deve ser uma lista.");
184
188
  continue;
185
189
  }
@@ -206,56 +210,56 @@ function q(e, r, o) {
206
210
  }
207
211
  }
208
212
  }
209
- function W(e, r, o, t) {
210
- const a = r.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = r.params;
213
+ function W(e, t, o, r) {
214
+ const a = t.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = t.params;
211
215
  if (s !== void 0 && (!s || typeof s != "object" || Array.isArray(s))) {
212
- t("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
216
+ r("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
213
217
  return;
214
218
  }
215
219
  const c = s ?? {};
216
220
  for (const [f, d] of Object.entries(c))
217
- a.includes(f) ? u(d) || t("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : t("warning", o, `\`params.${f}\` não é parâmetro de \`${r.path}\` e é ignorado.`);
221
+ a.includes(f) ? u(d) || r("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : r("warning", o, `\`params.${f}\` não é parâmetro de \`${t.path}\` e é ignorado.`);
218
222
  const h = a.filter((f) => f !== "*" && !u(c[f]));
219
223
  if (h.length > 0) {
220
224
  (e.scenarios ?? []).some(
221
- (d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === r.path
222
- ) || t(
225
+ (d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === t.path
226
+ ) || r(
223
227
  "warning",
224
228
  o,
225
- `Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${r.path}\`. Declare \`params: { ${h.map((d) => `${d}: "…"`).join(", ")} }\`.`
229
+ `Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${t.path}\`. Declare \`params: { ${h.map((d) => `${d}: "…"`).join(", ")} }\`.`
226
230
  );
227
231
  return;
228
232
  }
229
233
  if (a.length > 0) {
230
- const f = E(r.path, c), d = P(e.routes ?? [], f);
231
- d && d.definition.path !== r.path && t(
234
+ const f = E(t.path, c), d = P(e.routes ?? [], f);
235
+ d && d.definition.path !== t.path && r(
232
236
  "warning",
233
237
  o,
234
238
  `Os exemplos de \`params\` montam \`${f}\`, que abre a rota \`${d.definition.path}\`, não esta.`
235
239
  );
236
240
  }
237
241
  }
238
- function _(e, r) {
242
+ function _(e, t) {
239
243
  const o = e.split("?")[0] ?? e;
240
- return (r.routes ?? []).some((t) => B(t.path, o));
244
+ return (t.routes ?? []).some((r) => B(r.path, o));
241
245
  }
242
- function B(e, r) {
243
- const o = e.split("/").filter(Boolean), t = r.split("/").filter(Boolean);
246
+ function B(e, t) {
247
+ const o = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean);
244
248
  for (const [a, s] of o.entries()) {
245
249
  if (s === "*") return !0;
246
- const c = t[a];
250
+ const c = r[a];
247
251
  if (c === void 0) return !1;
248
252
  if (!s.startsWith(":") && s !== c)
249
253
  return !1;
250
254
  }
251
- return o.length === t.length;
255
+ return o.length === r.length;
252
256
  }
253
257
  function X(e) {
254
- return e.some((r) => r.level === "error");
258
+ return e.some((t) => t.level === "error");
255
259
  }
256
260
  function Y(e) {
257
- return e.length === 0 ? "Nenhum problema encontrado." : e.map((r) => `${r.level === "error" ? "✖" : "▲"} ${r.where}
258
- ${r.message}`).join(`
261
+ return e.length === 0 ? "Nenhum problema encontrado." : e.map((t) => `${t.level === "error" ? "✖" : "▲"} ${t.where}
262
+ ${t.message}`).join(`
259
263
  `);
260
264
  }
261
265
  const w = {
@@ -272,37 +276,37 @@ function ee(e) {
272
276
  components: e.getAll(w.component)
273
277
  });
274
278
  }
275
- function N(e, r) {
276
- for (const t of Object.values(w)) e.delete(t);
277
- if (!r) return;
279
+ function N(e, t) {
280
+ for (const r of Object.values(w)) e.delete(r);
281
+ if (!t) return;
278
282
  e.set(w.enabled, "1");
279
- const o = k(r);
280
- for (const t of o.scenarios ?? []) e.append(w.scenario, t);
281
- for (const t of o.routes ?? []) e.append(w.route, t);
282
- for (const t of o.components ?? []) e.append(w.component, t);
283
+ const o = k(t);
284
+ for (const r of o.scenarios ?? []) e.append(w.scenario, r);
285
+ for (const r of o.routes ?? []) e.append(w.route, r);
286
+ for (const r of o.components ?? []) e.append(w.component, r);
283
287
  }
284
288
  function k(e) {
285
- const r = S(e.scenarios), o = S(e.routes), t = S(e.components);
289
+ const t = S(e.scenarios), o = S(e.routes), r = S(e.components);
286
290
  return {
287
- ...r.length ? { scenarios: r } : {},
291
+ ...t.length ? { scenarios: t } : {},
288
292
  ...o.length ? { routes: o } : {},
289
- ...t.length ? { components: t } : {}
293
+ ...r.length ? { components: r } : {}
290
294
  };
291
295
  }
292
- function D(e, r) {
293
- return !e || !!(r && e.scenarios?.includes(r));
296
+ function D(e, t) {
297
+ return !e || !!(t && e.scenarios?.includes(t));
294
298
  }
295
- function oe(e, r) {
296
- return !e || !!(r && e.components?.includes(r));
299
+ function oe(e, t) {
300
+ return !e || !!(t && e.components?.includes(t));
297
301
  }
298
- function re(e, r, o = []) {
299
- return !e || r === "/" ? !0 : [
302
+ function te(e, t, o = []) {
303
+ return !e || t === "/" ? !0 : [
300
304
  ...e.routes ?? [],
301
305
  ...o.filter((a) => D(e, a.id)).map((a) => a.route)
302
- ].some((a) => j(a, r) !== null);
306
+ ].some((a) => I(a, t) !== null);
303
307
  }
304
308
  function S(e) {
305
- return [...new Set((e ?? []).map((r) => r.trim()).filter(Boolean))].sort();
309
+ return [...new Set((e ?? []).map((t) => t.trim()).filter(Boolean))].sort();
306
310
  }
307
311
  const m = {
308
312
  scenario: "scenario",
@@ -322,46 +326,46 @@ const m = {
322
326
  zoom: "zoom",
323
327
  rotated: "rotate",
324
328
  highlight: "highlight"
325
- }, $ = "c.", H = /* @__PURE__ */ new Set([
329
+ }, y = "c.", H = /* @__PURE__ */ new Set([
326
330
  ...Object.values(m),
327
331
  ...Object.values(w)
328
332
  ]);
329
- function te(e) {
330
- return e.startsWith($) || H.has(e);
333
+ function re(e) {
334
+ return e.startsWith(y) || H.has(e);
331
335
  }
332
336
  function ne(e) {
333
- const r = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
334
- for (const [t, a] of r) {
335
- if (!t.startsWith($)) continue;
336
- const s = t.slice($.length);
337
+ const t = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
338
+ for (const [r, a] of t) {
339
+ if (!r.startsWith(y)) continue;
340
+ const s = r.slice(y.length);
337
341
  s && (o[s] = a);
338
342
  }
339
343
  return o;
340
344
  }
341
345
  function ae(e) {
342
- for (const r of [...e.keys()])
343
- r.startsWith($) && e.delete(r);
346
+ for (const t of [...e.keys()])
347
+ t.startsWith(y) && e.delete(t);
344
348
  }
345
349
  function G(e) {
346
350
  return typeof e == "boolean" ? e ? "1" : "0" : String(e);
347
351
  }
348
- function F(e, r = {}) {
349
- for (const [o, t] of Object.entries(r)) {
350
- if (t == null) continue;
352
+ function F(e, t = {}) {
353
+ for (const [o, r] of Object.entries(t)) {
354
+ if (r == null) continue;
351
355
  if (o === "handoff") {
352
- N(e, t);
356
+ N(e, r);
353
357
  continue;
354
358
  }
355
359
  if (o === "screenControls") {
356
- for (const [s, c] of Object.entries(t))
357
- e.set(`${$}${s}`, c);
360
+ for (const [s, c] of Object.entries(r))
361
+ e.set(`${y}${s}`, c);
358
362
  continue;
359
363
  }
360
364
  const a = m[o];
361
- a && e.set(a, G(t));
365
+ a && e.set(a, G(r));
362
366
  }
363
367
  }
364
- const y = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
368
+ const $ = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
365
369
  m.chromeTheme,
366
370
  m.chrome,
367
371
  m.inspector,
@@ -369,38 +373,38 @@ const y = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
369
373
  m.zoom,
370
374
  m.rotated
371
375
  ];
372
- function V(e, r) {
373
- const o = new URLSearchParams(r);
374
- for (const t of T) o.delete(t);
375
- return o.delete(y), o.set(y, "1"), `${e || "/"}?${o.toString()}`;
376
+ function V(e, t) {
377
+ const o = new URLSearchParams(t);
378
+ for (const r of T) o.delete(r);
379
+ return o.delete($), o.set($, "1"), `${e || "/"}?${o.toString()}`;
376
380
  }
377
- function se(e, r, o) {
378
- let { path: t, search: a } = o;
381
+ function se(e, t, o) {
382
+ let { path: r, search: a } = o;
379
383
  if (e)
380
384
  try {
381
385
  const c = new URL(e);
382
- c.origin === r && ({ pathname: t, search: a } = c);
386
+ c.origin === t && ({ pathname: r, search: a } = c);
383
387
  } catch {
384
388
  }
385
389
  const s = new URLSearchParams(a);
386
- return s.delete(m.viewport), s.delete(m.customWidth), V(t, `?${s.toString()}`);
390
+ return s.delete(m.viewport), s.delete(m.customWidth), V(r, `?${s.toString()}`);
387
391
  }
388
392
  function ce(e) {
389
- const r = new URL(e, "http://design-space.invalid");
390
- r.searchParams.delete(y);
391
- const o = r.searchParams.toString();
392
- return { path: r.pathname || "/", search: o ? `?${o}` : "" };
393
+ const t = new URL(e, "http://design-space.invalid");
394
+ t.searchParams.delete($);
395
+ const o = t.searchParams.toString();
396
+ return { path: t.pathname || "/", search: o ? `?${o}` : "" };
393
397
  }
394
398
  function le(e) {
395
- const r = new URL(e, "http://design-space.invalid");
396
- return `${r.pathname}|${r.searchParams.get(m.component) ?? ""}`;
399
+ const t = new URL(e, "http://design-space.invalid");
400
+ return `${t.pathname}|${t.searchParams.get(m.component) ?? ""}`;
397
401
  }
398
- function de(e, r) {
399
- const o = new URLSearchParams(e), t = new URLSearchParams(r);
400
- o.delete(y);
402
+ function de(e, t) {
403
+ const o = new URLSearchParams(e), r = new URLSearchParams(t);
404
+ o.delete($);
401
405
  for (const s of T) {
402
406
  o.delete(s);
403
- const c = t.get(s);
407
+ const c = r.get(s);
404
408
  c !== null && o.set(s, c);
405
409
  }
406
410
  const a = o.toString();
@@ -408,33 +412,33 @@ function de(e, r) {
408
412
  }
409
413
  function Z(e) {
410
414
  if (!e || typeof e != "object") return !1;
411
- const r = e;
412
- if (r.ds !== 1 || typeof r.type != "string") return !1;
413
- switch (r.type) {
415
+ const t = e;
416
+ if (t.ds !== 1 || typeof t.type != "string") return !1;
417
+ switch (t.type) {
414
418
  case "ready":
415
419
  case "location":
416
- return typeof r.url == "string";
420
+ return typeof t.url == "string";
417
421
  case "navigate":
418
- return typeof r.url == "string";
422
+ return typeof t.url == "string";
419
423
  case "shortcut":
420
- return ["C", "K", "F"].includes(r.key);
424
+ return ["C", "K", "F"].includes(t.key);
421
425
  default:
422
426
  return !1;
423
427
  }
424
428
  }
425
- function fe(e, r) {
426
- if (e.origin === r.origin && !(!r.source || e.source !== r.source))
429
+ function fe(e, t) {
430
+ if (e.origin === t.origin && !(!t.source || e.source !== t.source))
427
431
  return Z(e.data) ? e.data : void 0;
428
432
  }
429
- function ue(e, r, o) {
433
+ function ue(e, t, o) {
430
434
  try {
431
- e?.postMessage(r, o);
435
+ e?.postMessage(t, o);
432
436
  } catch {
433
437
  }
434
438
  }
435
439
  function pe(e = typeof window > "u" ? void 0 : window) {
436
440
  if (!e) return !1;
437
- if (new URLSearchParams(e.location.search).get(y) === "1") return !0;
441
+ if (new URLSearchParams(e.location.search).get($) === "1") return !0;
438
442
  try {
439
443
  return !!e.frameElement?.hasAttribute(K);
440
444
  } catch {
@@ -442,54 +446,54 @@ function pe(e = typeof window > "u" ? void 0 : window) {
442
446
  }
443
447
  }
444
448
  function U(e = {}) {
445
- const r = e.branchUrl || void 0, o = e.deploymentUrl || void 0, t = e.commit || void 0, a = e.env || "development", s = r && `https://${r}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
449
+ const t = e.branchUrl || void 0, o = e.deploymentUrl || void 0, r = e.commit || void 0, a = e.env || "development", s = t && `https://${t}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
446
450
  return {
447
451
  env: a,
448
452
  origin: s.replace(/\/$/, ""),
449
- branchUrl: r,
453
+ branchUrl: t,
450
454
  deploymentUrl: o,
451
455
  branch: e.branch || void 0,
452
- commit: t,
453
- shortCommit: t?.slice(0, 7),
456
+ commit: r,
457
+ shortCommit: r?.slice(0, 7),
454
458
  isDeployed: a === "preview" || a === "production"
455
459
  };
456
460
  }
457
- function J(e, r = {}) {
458
- const o = r.origin ?? U().origin, t = new URL(e.route, o);
459
- return t.searchParams.set(m.scenario, e.id), e.persona && t.searchParams.set(m.persona, e.persona), t.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && t.searchParams.set(m.network, e.network), F(t.searchParams, r.overrides), t.toString();
461
+ function J(e, t = {}) {
462
+ const o = t.origin ?? U().origin, r = new URL(e.route, o);
463
+ return r.searchParams.set(m.scenario, e.id), e.persona && r.searchParams.set(m.persona, e.persona), r.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && r.searchParams.set(m.network, e.network), F(r.searchParams, t.overrides), r.toString();
460
464
  }
461
- function me(e, r = {}) {
462
- const o = r.origin ?? U().origin, t = new URL("/", o), a = r.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
463
- return t.searchParams.set(m.component, e.id), a && t.searchParams.set(m.fixture, a), F(t.searchParams, r.overrides), t.toString();
465
+ function me(e, t = {}) {
466
+ const o = t.origin ?? U().origin, r = new URL("/", o), a = t.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
467
+ return r.searchParams.set(m.component, e.id), a && r.searchParams.set(m.fixture, a), F(r.searchParams, t.overrides), r.toString();
464
468
  }
465
- function he(e, r) {
466
- const o = r.commit ?? U().commit;
469
+ function he(e, t) {
470
+ const o = t.commit ?? U().commit;
467
471
  if (!o) return;
468
- const t = r.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
469
- return J(e, { origin: t });
472
+ const r = t.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
473
+ return J(e, { origin: r });
470
474
  }
471
475
  export {
472
476
  me as A,
473
477
  Y as B,
474
- $ as C,
478
+ y as C,
475
479
  X as D,
476
- j as E,
477
- y as F,
480
+ I as E,
481
+ $ as F,
478
482
  k as G,
479
483
  w as H,
480
484
  G as I,
481
- L as J,
482
- C as N,
485
+ q as J,
486
+ j as N,
483
487
  m as P,
484
488
  oe as a,
485
- re as b,
489
+ te as b,
486
490
  ne as c,
487
491
  N as d,
488
492
  ue as e,
489
493
  ce as f,
490
494
  fe as g,
491
495
  D as h,
492
- te as i,
496
+ re as i,
493
497
  ae as j,
494
498
  J as k,
495
499
  F as l,
@@ -508,4 +512,4 @@ export {
508
512
  se as y,
509
513
  he as z
510
514
  };
511
- //# sourceMappingURL=index-rWBjjVMg.js.map
515
+ //# sourceMappingURL=index-CLox5DuH.js.map