@kya-os/consent 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +5 -1
  2. package/dist/bundle/inline.d.ts.map +1 -1
  3. package/dist/bundle/inline.js +4 -4
  4. package/dist/bundle/inline.js.map +1 -1
  5. package/dist/cjs/bundle/inline.js +4 -4
  6. package/dist/cjs/bundle/inline.js.map +1 -1
  7. package/dist/cjs/components/consent-action-bar.js +4 -0
  8. package/dist/cjs/components/consent-action-bar.js.map +1 -1
  9. package/dist/cjs/components/consent-capabilities-screen.js +1 -1
  10. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  11. package/dist/cjs/components/consent-connector-header.js +1 -0
  12. package/dist/cjs/components/consent-connector-header.js.map +1 -1
  13. package/dist/cjs/components/consent-flow.js +392 -10
  14. package/dist/cjs/components/consent-flow.js.map +1 -1
  15. package/dist/cjs/components/consent-wallet-orb.js +6 -1
  16. package/dist/cjs/components/consent-wallet-orb.js.map +1 -1
  17. package/dist/cjs/components/flow-blocks.js +162 -35
  18. package/dist/cjs/components/flow-blocks.js.map +1 -1
  19. package/dist/cjs/flow/copy.js +15 -0
  20. package/dist/cjs/flow/copy.js.map +1 -1
  21. package/dist/cjs/flow/index.js +5 -2
  22. package/dist/cjs/flow/index.js.map +1 -1
  23. package/dist/cjs/flow/model.js +46 -1
  24. package/dist/cjs/flow/model.js.map +1 -1
  25. package/dist/cjs/flow/page.js +282 -0
  26. package/dist/cjs/flow/page.js.map +1 -0
  27. package/dist/cjs/flow/presets.js +4 -0
  28. package/dist/cjs/flow/presets.js.map +1 -1
  29. package/dist/cjs/flow/schema.js +1 -0
  30. package/dist/cjs/flow/schema.js.map +1 -1
  31. package/dist/cjs/mcp-app/inline.js +2 -2
  32. package/dist/cjs/mcp-app/inline.js.map +1 -1
  33. package/dist/cjs/react/index.js +1 -0
  34. package/dist/cjs/react/index.js.map +1 -1
  35. package/dist/cjs/styles/brand.js +135 -38
  36. package/dist/cjs/styles/brand.js.map +1 -1
  37. package/dist/cjs/styles/theme.js +29 -3
  38. package/dist/cjs/styles/theme.js.map +1 -1
  39. package/dist/components/consent-action-bar.d.ts.map +1 -1
  40. package/dist/components/consent-action-bar.js +4 -0
  41. package/dist/components/consent-action-bar.js.map +1 -1
  42. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  43. package/dist/components/consent-capabilities-screen.js +1 -1
  44. package/dist/components/consent-capabilities-screen.js.map +1 -1
  45. package/dist/components/consent-connector-header.d.ts.map +1 -1
  46. package/dist/components/consent-connector-header.js +1 -0
  47. package/dist/components/consent-connector-header.js.map +1 -1
  48. package/dist/components/consent-flow.d.ts +56 -2
  49. package/dist/components/consent-flow.d.ts.map +1 -1
  50. package/dist/components/consent-flow.js +394 -12
  51. package/dist/components/consent-flow.js.map +1 -1
  52. package/dist/components/consent-wallet-orb.d.ts +4 -0
  53. package/dist/components/consent-wallet-orb.d.ts.map +1 -1
  54. package/dist/components/consent-wallet-orb.js +6 -1
  55. package/dist/components/consent-wallet-orb.js.map +1 -1
  56. package/dist/components/flow-blocks.d.ts +10 -1
  57. package/dist/components/flow-blocks.d.ts.map +1 -1
  58. package/dist/components/flow-blocks.js +162 -36
  59. package/dist/components/flow-blocks.js.map +1 -1
  60. package/dist/consent.js +853 -270
  61. package/dist/consent.min.js +634 -397
  62. package/dist/flow/copy.d.ts +2 -0
  63. package/dist/flow/copy.d.ts.map +1 -1
  64. package/dist/flow/copy.js +14 -0
  65. package/dist/flow/copy.js.map +1 -1
  66. package/dist/flow/index.d.ts +5 -2
  67. package/dist/flow/index.d.ts.map +1 -1
  68. package/dist/flow/index.js +5 -2
  69. package/dist/flow/index.js.map +1 -1
  70. package/dist/flow/model.d.ts +53 -2
  71. package/dist/flow/model.d.ts.map +1 -1
  72. package/dist/flow/model.js +45 -0
  73. package/dist/flow/model.js.map +1 -1
  74. package/dist/flow/page.d.ts +110 -0
  75. package/dist/flow/page.d.ts.map +1 -0
  76. package/dist/flow/page.js +276 -0
  77. package/dist/flow/page.js.map +1 -0
  78. package/dist/flow/presets.d.ts.map +1 -1
  79. package/dist/flow/presets.js +4 -0
  80. package/dist/flow/presets.js.map +1 -1
  81. package/dist/flow/schema.d.ts +19 -14
  82. package/dist/flow/schema.d.ts.map +1 -1
  83. package/dist/flow/schema.js +1 -0
  84. package/dist/flow/schema.js.map +1 -1
  85. package/dist/mcp-app/inline.d.ts.map +1 -1
  86. package/dist/mcp-app/inline.js +2 -2
  87. package/dist/mcp-app/inline.js.map +1 -1
  88. package/dist/react/index.d.ts +2 -1
  89. package/dist/react/index.d.ts.map +1 -1
  90. package/dist/react/index.js +1 -0
  91. package/dist/react/index.js.map +1 -1
  92. package/dist/styles/brand.d.ts +53 -18
  93. package/dist/styles/brand.d.ts.map +1 -1
  94. package/dist/styles/brand.js +136 -39
  95. package/dist/styles/brand.js.map +1 -1
  96. package/dist/styles/theme.d.ts +10 -1
  97. package/dist/styles/theme.d.ts.map +1 -1
  98. package/dist/styles/theme.js +28 -2
  99. package/dist/styles/theme.js.map +1 -1
  100. package/package.json +1 -1
package/dist/consent.js CHANGED
@@ -4920,6 +4920,7 @@ var ConsentActionBar = class extends i4 {
4920
4920
  <button
4921
4921
  class="action primary"
4922
4922
  part="submit"
4923
+ data-field="approve"
4923
4924
  type="button"
4924
4925
  ?disabled=${this.disabled || this.loading}
4925
4926
  @click=${this.emitAllow}
@@ -4929,6 +4930,7 @@ var ConsentActionBar = class extends i4 {
4929
4930
  <button
4930
4931
  class="action secondary"
4931
4932
  part="cancel"
4933
+ data-field="deny"
4932
4934
  type="button"
4933
4935
  ?disabled=${this.loading}
4934
4936
  @click=${this.emitDeny}
@@ -4947,6 +4949,7 @@ var ConsentActionBar = class extends i4 {
4947
4949
  <div
4948
4950
  class="action primary${this.disabled || this.loading ? " disabled" : ""}"
4949
4951
  part="submit"
4952
+ data-field="approve"
4950
4953
  >
4951
4954
  ${this.renderSubmitIcon()}${editRegion(
4952
4955
  CONSENT_EDIT_KEYS.submitLabel,
@@ -4958,6 +4961,7 @@ var ConsentActionBar = class extends i4 {
4958
4961
  <div
4959
4962
  class="action secondary${this.loading ? " disabled" : ""}"
4960
4963
  part="cancel"
4964
+ data-field="deny"
4961
4965
  >
4962
4966
  ${editRegion(
4963
4967
  CONSENT_EDIT_KEYS.cancelLabel,
@@ -5528,6 +5532,7 @@ var ConsentConnectorHeader = class extends i4 {
5528
5532
  ${this.renderBridge()}
5529
5533
  <div
5530
5534
  class="tile server ${serverLogo ? "has-logo" : ""}"
5535
+ data-field="merchant"
5531
5536
  aria-hidden="true"
5532
5537
  >
5533
5538
  ${serverLogo ? b2`<img
@@ -5788,6 +5793,11 @@ var FIXED_AGENT_TILE_BORDER = "rgba(15, 23, 42, 0.08)";
5788
5793
  var FIXED_AGENT_TILE_TEXT = "#0F172A";
5789
5794
  var TINT_PERCENT = 4;
5790
5795
  var TINT_LINE_PERCENT = 11;
5796
+ var WALLET_SUCCESS = "#10b981";
5797
+ var PAGE_TOKENS = [
5798
+ ["textTertiary", "--cs-page-text"],
5799
+ ["surfaceAccent", "--cs-page-accent"]
5800
+ ];
5791
5801
  var lightTheme = {
5792
5802
  surfaceBg: "#F4F1EA",
5793
5803
  surfaceCard: "#FFFFFF",
@@ -5838,7 +5848,7 @@ function resolveThemeTokens(tokens) {
5838
5848
  }
5839
5849
  return resolved;
5840
5850
  }
5841
- function themeScopeStyle(tokens, scope) {
5851
+ function themeScopeStyle(tokens, scope, page) {
5842
5852
  const resolved = resolveThemeTokens(tokens);
5843
5853
  const keys = Object.keys(resolved);
5844
5854
  const resolvedName = (key) => `--_${themeTokenProperty(key).slice(2)}`;
@@ -5850,11 +5860,28 @@ function themeScopeStyle(tokens, scope) {
5850
5860
  const publish = keys.map(
5851
5861
  (key) => ` ${themeTokenProperty(key)}: var(${resolvedName(key)});`
5852
5862
  );
5853
- return `:host {
5863
+ if (!page)
5864
+ return `:host {
5854
5865
  ${resolve.join("\n")}
5855
5866
  }
5856
5867
  ${scope} {
5857
5868
  ${publish.join("\n")}
5869
+ }`;
5870
+ const success = ` --_cs-wallet-success: var(--cs-wallet-success, var(--cs-page-success, ${WALLET_SUCCESS}));`;
5871
+ const onPage = [
5872
+ ...PAGE_TOKENS.map(
5873
+ ([key, pageToken]) => ` ${themeTokenProperty(key)}: var(${pageToken}, var(${resolvedName(key)}));`
5874
+ ),
5875
+ " --cs-wallet-success: var(--_cs-wallet-success);"
5876
+ ];
5877
+ return `:host {
5878
+ ${[...resolve, success].join("\n")}
5879
+ }
5880
+ ${scope}, ${page} {
5881
+ ${publish.join("\n")}
5882
+ }
5883
+ ${page} {
5884
+ ${onPage.join("\n")}
5858
5885
  }`;
5859
5886
  }
5860
5887
  var FIXED_TOKENS = {
@@ -6429,8 +6456,8 @@ function durationOptionsWithin(options, maxSeconds) {
6429
6456
  if (maxSeconds === void 0 || !Number.isFinite(maxSeconds)) {
6430
6457
  return valid;
6431
6458
  }
6432
- const within = valid.filter((o9) => o9.seconds <= maxSeconds);
6433
- if (within.length > 0) return within;
6459
+ const within2 = valid.filter((o9) => o9.seconds <= maxSeconds);
6460
+ if (within2.length > 0) return within2;
6434
6461
  const shortest = valid.reduce((a4, b4) => b4.seconds < a4.seconds ? b4 : a4);
6435
6462
  return [shortest];
6436
6463
  }
@@ -7216,7 +7243,8 @@ var ConsentCapabilitiesScreen = class extends i4 {
7216
7243
  hostStyle() {
7217
7244
  return themeScopeStyle(
7218
7245
  getConsentTheme(this.theme),
7219
- ".card, consent-connector-header, .below"
7246
+ ".card",
7247
+ "consent-connector-header, .below"
7220
7248
  );
7221
7249
  }
7222
7250
  /** Grant terms in the `details` slot. None when rendered without a DOM. */
@@ -8270,7 +8298,7 @@ ConsentWalletOrb.styles = i`
8270
8298
 
8271
8299
  .frame {
8272
8300
  --_ink: var(--cs-wallet-accent, var(--cs-surface-accent, #0f172a));
8273
- --_success: var(--cs-wallet-success, #10b981);
8301
+ --_success: var(--cs-wallet-success, ${r(WALLET_SUCCESS)});
8274
8302
  --_muted: var(--cs-wallet-muted, var(--cs-text-tertiary, #5d6c82));
8275
8303
  position: relative;
8276
8304
  width: 100%;
@@ -8983,6 +9011,8 @@ var FLOW_COPY = {
8983
9011
  receipt: { until: "Until {When}" },
8984
9012
  goBack: "Go back to {Agent} and tell it to continue. Revoke anytime under Connected agents at {Merchant}.",
8985
9013
  retry: "Try again",
9014
+ terms: { agree: "I agree to the {Terms}" },
9015
+ legal: { label: "Legal" },
8986
9016
  announce: {
8987
9017
  "sign-in": "Sign in to continue.",
8988
9018
  consent: "Review what {Agent} is asking for.",
@@ -9035,6 +9065,15 @@ function initialsOf(name = "", identifier = "") {
9035
9065
  if (words.length === 1) return first(words[0]).toUpperCase();
9036
9066
  return (first(identifier) || "?").toUpperCase();
9037
9067
  }
9068
+ function httpsUrl(value) {
9069
+ const raw = typeof value === "string" ? value.trim() : "";
9070
+ if (!raw) return void 0;
9071
+ try {
9072
+ return new URL(raw).protocol === "https:" ? raw : void 0;
9073
+ } catch {
9074
+ return void 0;
9075
+ }
9076
+ }
9038
9077
 
9039
9078
  // src/flow/model.ts
9040
9079
  var FLOW_SCHEMA_VERSION = 1;
@@ -9047,6 +9086,7 @@ var FLOW_BLOCKS = [
9047
9086
  "approver",
9048
9087
  "capability",
9049
9088
  "details",
9089
+ "infoNote",
9050
9090
  "countdown",
9051
9091
  "actions",
9052
9092
  "status",
@@ -9093,8 +9133,42 @@ var FLOW_EVENTS = [
9093
9133
  "retry",
9094
9134
  "expire",
9095
9135
  "motion",
9096
- "step"
9136
+ "step",
9137
+ "field"
9138
+ ];
9139
+ var FLOW_FIELDS = [
9140
+ ...FLOW_BLOCKS.filter((block) => block !== "actions"),
9141
+ "capabilitiesHeader",
9142
+ "approve",
9143
+ "deny",
9144
+ "terms",
9145
+ "legal",
9146
+ "merchant",
9147
+ "connector"
9097
9148
  ];
9149
+ var CONFIG_FIELD_REGIONS = Object.freeze({
9150
+ "branding.companyName": { field: "merchant", step: "consent" },
9151
+ "branding.logoUrl": { field: "merchant", step: "consent" },
9152
+ "branding.primaryColor": { field: "approve", step: "consent" },
9153
+ "ui.title": { field: "eyebrow", step: "consent" },
9154
+ "ui.headline": { field: "headline", step: "consent" },
9155
+ "ui.description": { field: "sub", step: "consent" },
9156
+ "ui.expirationText": { field: "infoNote", step: "consent" },
9157
+ "ui.permissionsHeader": { field: "capabilitiesHeader", step: "consent" },
9158
+ "ui.submitButtonText": { field: "approve", step: "consent" },
9159
+ "ui.cancelButtonText": { field: "deny", step: "consent" },
9160
+ headlineVerb: { field: "headline", step: "consent" },
9161
+ "terms.text": { field: "legal", step: "consent" },
9162
+ "terms.url": { field: "legal", step: "consent" },
9163
+ "terms.privacyUrl": { field: "legal", step: "consent" },
9164
+ "terms.required": { field: "terms", step: "consent" },
9165
+ "success.title": { field: "headline", step: "granted" },
9166
+ "success.description": { field: "sub", step: "granted" },
9167
+ // Both methods have a consent step, where Allow and "Approve with
9168
+ // passkey" differ; a consent flow has no passkey step to show.
9169
+ "flow.approvalMethod": { field: "approve", step: "consent" },
9170
+ "flow.connectorMark": { field: "connector", step: "consent" }
9171
+ });
9098
9172
  var FLOW_HOST_ATTRIBUTES = {
9099
9173
  version: "data-consent-version",
9100
9174
  approvalMethod: "data-approval-method"
@@ -9107,9 +9181,11 @@ function consentFlowRenders() {
9107
9181
  var CONSENT_BLOCKS = [
9108
9182
  "eyebrow",
9109
9183
  "headline",
9184
+ "sub",
9110
9185
  "approver",
9111
9186
  "capability",
9112
9187
  "details",
9188
+ "infoNote",
9113
9189
  "countdown",
9114
9190
  "actions"
9115
9191
  ];
@@ -9160,9 +9236,11 @@ var PASSKEY_STEPS = {
9160
9236
  blocks: [
9161
9237
  "eyebrow",
9162
9238
  "headline",
9239
+ "sub",
9163
9240
  "approver",
9164
9241
  "capability:locked",
9165
9242
  "details",
9243
+ "infoNote",
9166
9244
  "countdown",
9167
9245
  "actions:loading",
9168
9246
  "status"
@@ -9235,6 +9313,265 @@ function flowPreset(approvalMethod, { signIn: signIn2 = false } = {}) {
9235
9313
  return FLOW_PRESETS[approvalMethod][signIn2 ? "signIn" : "decision"];
9236
9314
  }
9237
9315
 
9316
+ // src/styles/brand.ts
9317
+ var AA_GRAPHIC_CONTRAST = 3;
9318
+ var TEXT_CONTRAST = 4.5;
9319
+ var ICON_TILE_PERCENT = 8;
9320
+ var HOVERED_ROW_PERCENT = 4;
9321
+ var MUTED_TEXT_PERCENT = 64;
9322
+ var PANEL_TINT_PERCENT = 4;
9323
+ var LIGHTNESS_STEP = 5e-3;
9324
+ var LIGHT_DRAWN_COLORS = Object.freeze({
9325
+ surface: lightTheme.surfaceCard,
9326
+ panel: lightTheme.surfaceInset,
9327
+ text: lightTheme.textPrimary,
9328
+ mutedText: lightTheme.textTertiary
9329
+ });
9330
+ var PALETTE_FIELDS = [
9331
+ "surfaceColor",
9332
+ "panelColor",
9333
+ "borderColor",
9334
+ "textColor",
9335
+ "mutedTextColor",
9336
+ "focusColor",
9337
+ "backgroundColor"
9338
+ ];
9339
+ function rgbOf(hex) {
9340
+ return [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
9341
+ }
9342
+ function hexOf(channels2) {
9343
+ return `#${channels2.map((value) => Math.round(value).toString(16).padStart(2, "0")).join("")}`;
9344
+ }
9345
+ function mixOver(top, percent, under) {
9346
+ const share = percent / 100;
9347
+ const below = rgbOf(under);
9348
+ return hexOf(
9349
+ rgbOf(top).map((above, i8) => above * share + below[i8] * (1 - share))
9350
+ );
9351
+ }
9352
+ function hslOf(hex) {
9353
+ const [red, green, blue] = rgbOf(hex).map((value) => value / 255);
9354
+ const high = Math.max(red, green, blue);
9355
+ const low = Math.min(red, green, blue);
9356
+ const spread = high - low;
9357
+ const lightness = (high + low) / 2;
9358
+ if (spread === 0) return { hue: 0, saturation: 0, lightness };
9359
+ const saturation = spread / (1 - Math.abs(2 * lightness - 1));
9360
+ const sector = high === red ? (green - blue) / spread : high === green ? (blue - red) / spread + 2 : (red - green) / spread + 4;
9361
+ return { hue: (sector * 60 + 360) % 360, saturation, lightness };
9362
+ }
9363
+ function hexFromHsl({ hue, saturation, lightness }) {
9364
+ const reach = saturation * Math.min(lightness, 1 - lightness);
9365
+ const channel = (offset) => {
9366
+ const turn = (offset + hue / 30) % 12;
9367
+ return (lightness - reach * Math.max(-1, Math.min(turn - 3, 9 - turn, 1))) * 255;
9368
+ };
9369
+ return hexOf([channel(0), channel(8), channel(4)]);
9370
+ }
9371
+ function iconColorFor(hex, primary, drawn = LIGHT_DRAWN_COLORS) {
9372
+ const hoveredRow = mixOver(primary, HOVERED_ROW_PERCENT, drawn.surface);
9373
+ return showingOn(hex, [
9374
+ drawn.surface,
9375
+ drawn.panel,
9376
+ mixOver(primary, ICON_TILE_PERCENT, drawn.surface),
9377
+ mixOver(primary, ICON_TILE_PERCENT, hoveredRow)
9378
+ ]);
9379
+ }
9380
+ function showingOn(hex, surfaces) {
9381
+ const worstRatio = (candidate) => Math.min(...surfaces.map((surface) => contrastRatio(candidate, surface)));
9382
+ if (worstRatio(hex) >= AA_GRAPHIC_CONTRAST) return hex;
9383
+ const start = hslOf(hex);
9384
+ for (let steps = 1; steps * LIGHTNESS_STEP <= 1; steps++) {
9385
+ for (const lightness of [
9386
+ start.lightness - steps * LIGHTNESS_STEP,
9387
+ start.lightness + steps * LIGHTNESS_STEP
9388
+ ]) {
9389
+ if (lightness < 0 || lightness > 1) continue;
9390
+ const candidate = hexFromHsl({ ...start, lightness });
9391
+ if (worstRatio(candidate) >= AA_GRAPHIC_CONTRAST) return candidate;
9392
+ }
9393
+ }
9394
+ return worstRatio("#000000") >= worstRatio("#ffffff") ? "#000000" : "#ffffff";
9395
+ }
9396
+ function focusRingFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
9397
+ return contrastRatio(hex, surface) >= AA_GRAPHIC_CONTRAST ? "brand" : "ink";
9398
+ }
9399
+ function readsOnCardAndTint(hex, ratio, surface) {
9400
+ const tint = mixOver(hex, TINT_PERCENT, surface);
9401
+ return contrastRatio(hex, surface) >= ratio && contrastRatio(hex, tint) >= ratio;
9402
+ }
9403
+ function actionColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
9404
+ return readsOnCardAndTint(hex, TEXT_CONTRAST, surface) ? "brand" : "ink";
9405
+ }
9406
+ function markColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
9407
+ return readsOnCardAndTint(hex, AA_GRAPHIC_CONTRAST, surface) ? "brand" : "ink";
9408
+ }
9409
+ function onPrimaryFor(hex) {
9410
+ const luminance = relativeLuminance(hex);
9411
+ const againstWhite = 1.05 / (luminance + 0.05);
9412
+ const againstBlack = (luminance + 0.05) / 0.05;
9413
+ return againstBlack >= againstWhite ? "black" : "white";
9414
+ }
9415
+ function panelOf(palette, text, drawn) {
9416
+ if (palette.panelColor) return palette.panelColor;
9417
+ if (palette.surfaceColor)
9418
+ return mixOver(text, PANEL_TINT_PERCENT, palette.surfaceColor);
9419
+ return drawn.panel;
9420
+ }
9421
+ function mutedOn(palette, background, drawn) {
9422
+ if (palette.mutedTextColor) return palette.mutedTextColor;
9423
+ if (palette.textColor)
9424
+ return mixOver(palette.textColor, MUTED_TEXT_PERCENT, background);
9425
+ return drawn.mutedText;
9426
+ }
9427
+ function pageTextOn(palette, page, drawn) {
9428
+ const muted = mutedOn(palette, page, drawn);
9429
+ if (contrastRatio(muted, page) >= TEXT_CONTRAST) return muted;
9430
+ const ink = onPrimaryFor(page) === "black" ? "#000000" : "#ffffff";
9431
+ for (let percent = MUTED_TEXT_PERCENT; percent < 100; percent++) {
9432
+ const quieter = mixOver(ink, percent, page);
9433
+ if (contrastRatio(quieter, page) >= TEXT_CONTRAST) return quieter;
9434
+ }
9435
+ return ink;
9436
+ }
9437
+ function floorToHundredths(ratio) {
9438
+ return Math.floor(ratio * 100) / 100;
9439
+ }
9440
+ function paletteFailures(palette, drawn = {}) {
9441
+ const colors = { ...LIGHT_DRAWN_COLORS, ...drawn };
9442
+ const text = palette.textColor ?? colors.text;
9443
+ const backgrounds = [
9444
+ {
9445
+ background: "surfaceColor",
9446
+ color: palette.surfaceColor ?? colors.surface
9447
+ },
9448
+ { background: "panelColor", color: panelOf(palette, text, colors) }
9449
+ ];
9450
+ return backgrounds.flatMap(({ background, color }) => {
9451
+ const pairs = [
9452
+ { foreground: "textColor", color: text, needs: TEXT_CONTRAST },
9453
+ {
9454
+ foreground: "mutedTextColor",
9455
+ color: mutedOn(palette, color, colors),
9456
+ needs: TEXT_CONTRAST
9457
+ },
9458
+ ...palette.focusColor ? [
9459
+ {
9460
+ foreground: "focusColor",
9461
+ color: palette.focusColor,
9462
+ needs: AA_GRAPHIC_CONTRAST
9463
+ }
9464
+ ] : []
9465
+ ];
9466
+ return pairs.flatMap(({ foreground, color: ink, needs }) => {
9467
+ const ratio = contrastRatio(ink, color);
9468
+ return ratio >= needs ? [] : [{ foreground, background, ratio: floorToHundredths(ratio), needs }];
9469
+ });
9470
+ });
9471
+ }
9472
+ function drawablePalette(chosen, drawn = {}) {
9473
+ const { focusColor, borderColor, backgroundColor, ...surfacesAndText } = chosen;
9474
+ const text = paletteFailures(surfacesAndText, drawn).length === 0 ? surfacesAndText : {};
9475
+ const focusShows = focusColor !== void 0 && paletteFailures({ ...text, focusColor }, drawn).length === 0;
9476
+ return {
9477
+ ...text,
9478
+ ...backgroundColor ? { backgroundColor } : {},
9479
+ ...borderColor ? { borderColor } : {},
9480
+ ...focusShows ? { focusColor } : {}
9481
+ };
9482
+ }
9483
+ function brandTokens(brand, theme = "light") {
9484
+ for (const [field, value] of Object.entries(brand)) {
9485
+ if (value !== void 0 && !isHexColor(value)) {
9486
+ throw new RangeError(
9487
+ `${field} must be a #rrggbb color, got ${JSON.stringify(value)}`
9488
+ );
9489
+ }
9490
+ }
9491
+ const { primaryColor: primary, secondaryColor, ...chosen } = brand;
9492
+ const palette = drawablePalette(chosen);
9493
+ const surface = palette.surfaceColor ?? LIGHT_DRAWN_COLORS.surface;
9494
+ const panel = panelOf(
9495
+ palette,
9496
+ palette.textColor ?? LIGHT_DRAWN_COLORS.text,
9497
+ LIGHT_DRAWN_COLORS
9498
+ );
9499
+ const tokens = primary ? primaryTokens(primary, palette, surface, panel, secondaryColor) : {};
9500
+ if (!primary) {
9501
+ if (palette.textColor) {
9502
+ tokens["--cs-surface-accent"] = palette.textColor;
9503
+ tokens["--cs-surface-accent-text"] = onPrimaryFor(palette.textColor);
9504
+ }
9505
+ const ring = palette.focusColor ?? palette.textColor;
9506
+ if (ring) tokens["--cs-focus-ring"] = ring;
9507
+ }
9508
+ if (palette.surfaceColor) tokens["--cs-surface-card"] = palette.surfaceColor;
9509
+ if (palette.surfaceColor || palette.panelColor)
9510
+ tokens["--cs-surface-inset"] = panel;
9511
+ if (palette.borderColor) tokens["--cs-surface-border"] = palette.borderColor;
9512
+ if (palette.textColor) {
9513
+ tokens["--cs-text-primary"] = palette.textColor;
9514
+ tokens["--cs-text-secondary"] = palette.textColor;
9515
+ }
9516
+ if (palette.mutedTextColor) {
9517
+ tokens["--cs-text-tertiary"] = palette.mutedTextColor;
9518
+ } else if (palette.textColor) {
9519
+ tokens["--cs-text-tertiary"] = `color-mix(in srgb, ${palette.textColor} ${MUTED_TEXT_PERCENT}%, transparent)`;
9520
+ }
9521
+ const page = palette.backgroundColor;
9522
+ if (page) {
9523
+ const text = pageTextOn(palette, page, LIGHT_DRAWN_COLORS);
9524
+ const shows = (hex) => contrastRatio(hex, page) >= AA_GRAPHIC_CONTRAST;
9525
+ const accent = primary ?? palette.textColor ?? lightTheme.surfaceAccent;
9526
+ const lockup = lightTheme.lockup;
9527
+ tokens["--cs-surface-bg"] = page;
9528
+ tokens["--cs-page-text"] = text;
9529
+ tokens["--cs-page-accent"] = shows(accent) ? accent : text;
9530
+ tokens["--cs-page-success"] = showingOn(WALLET_SUCCESS, [page]);
9531
+ tokens["--cs-lockup"] = lockup && shows(lockup) ? lockup : text;
9532
+ } else {
9533
+ const stage = getConsentTheme(theme);
9534
+ const accent = primary ?? palette.textColor;
9535
+ if (accent && contrastRatio(accent, stage.surfaceBg) < AA_GRAPHIC_CONTRAST)
9536
+ tokens["--cs-page-accent"] = stage.surfaceAccent;
9537
+ }
9538
+ return tokens;
9539
+ }
9540
+ function primaryTokens(primary, palette, surface, panel, secondaryColor) {
9541
+ const ink = palette.textColor ?? LIGHT_DRAWN_COLORS.text;
9542
+ const onPrimary = onPrimaryFor(primary);
9543
+ const inBrand = (pick) => pick === "brand" ? primary : ink;
9544
+ const tokens = {
9545
+ "--consent-primary": primary,
9546
+ "--consent-on-primary": onPrimary,
9547
+ "--consent-link": inBrand(actionColorFor(primary, surface)),
9548
+ "--cs-surface-accent": primary,
9549
+ "--cs-surface-accent-text": onPrimary,
9550
+ "--cs-tint": mixOver(primary, TINT_PERCENT, surface),
9551
+ "--cs-tint-line": mixOver(primary, TINT_LINE_PERCENT, surface),
9552
+ "--cs-mark": inBrand(markColorFor(primary, surface)),
9553
+ "--cs-action": inBrand(actionColorFor(primary, surface)),
9554
+ "--cs-focus-ring": palette.focusColor ?? inBrand(focusRingFor(primary, surface))
9555
+ };
9556
+ if (secondaryColor) {
9557
+ tokens["--cs-icon"] = iconColorFor(secondaryColor, primary, {
9558
+ surface,
9559
+ panel
9560
+ });
9561
+ }
9562
+ return tokens;
9563
+ }
9564
+ function brandStyle(brand, theme = "light") {
9565
+ const tokens = brandTokens(brand, theme);
9566
+ const page = tokens["--cs-surface-bg"];
9567
+ return [
9568
+ ...Object.entries(tokens).map(
9569
+ ([property, value]) => `${property}: ${value};`
9570
+ ),
9571
+ ...page ? [`background-color: ${page};`] : []
9572
+ ].join(" ");
9573
+ }
9574
+
9238
9575
  // src/components/flow-blocks.ts
9239
9576
  var BLOCK_MORPH_FROM = {
9240
9577
  approver: "signIn",
@@ -9251,6 +9588,14 @@ function flowValues(data) {
9251
9588
  Domain: data.agent.domain
9252
9589
  };
9253
9590
  }
9591
+ function filled(words, values) {
9592
+ return Object.fromEntries(
9593
+ Object.entries(words).map(([key, value]) => [
9594
+ key,
9595
+ fillTemplate(value, values)
9596
+ ])
9597
+ );
9598
+ }
9254
9599
  function whenLabel(at) {
9255
9600
  const date = new Date(at);
9256
9601
  if (Number.isNaN(date.getTime())) return "";
@@ -9271,6 +9616,9 @@ function richText(template, values) {
9271
9616
  return value;
9272
9617
  });
9273
9618
  }
9619
+ function breakable(value) {
9620
+ return value.split(/(?=[@.])/).map((piece, i8) => i8 ? b2`<wbr />${piece}` : piece);
9621
+ }
9274
9622
  var hide = (event) => {
9275
9623
  event.target.hidden = true;
9276
9624
  };
@@ -9292,16 +9640,16 @@ function agentTile(agent) {
9292
9640
  >`;
9293
9641
  }
9294
9642
  var approver = ({ data, copy, step, variant, values }) => {
9295
- const c6 = group(copy, "approver");
9643
+ const c6 = filled(group(copy, "approver"), values);
9296
9644
  const state = variant ?? step;
9297
9645
  const granted = state === "granted";
9298
9646
  const declined = state === "denied";
9299
9647
  const person = data.approver;
9300
9648
  const agent = data.agent;
9301
9649
  const unverified = agent.verification === "unverified";
9302
- const status = unverified ? c6.unverified : agent.domain ? fillTemplate(c6.identifiedBy ?? "", { Domain: agent.domain }) : "";
9650
+ const status = unverified ? c6.unverified : agent.domain ? c6.identifiedBy ?? "" : "";
9303
9651
  const detail = granted ? c6.confirmed : person.identifier;
9304
- const markLabel = declined ? c6.declined : fillTemplate(c6.signedInWith ?? "", values);
9652
+ const markLabel = declined ? c6.declined : c6.signedInWith ?? "";
9305
9653
  return b2`<div class="tinted lockup" part="approver">
9306
9654
  <div class="lockup-row">
9307
9655
  ${face(person.name, person.identifier, person.avatarUrl)}
@@ -9309,8 +9657,8 @@ var approver = ({ data, copy, step, variant, values }) => {
9309
9657
  <span class="lockup-label"
9310
9658
  >${granted ? c6.labelGranted : declined ? c6.labelDenied : c6.label}</span
9311
9659
  >
9312
- <span class="lockup-name">${person.name}</span>
9313
- ${detail ? b2`<span class="small">${detail}</span>` : A}
9660
+ <span class="lockup-name">${breakable(person.name)}</span>
9661
+ ${detail ? b2`<span class="small">${breakable(detail)}</span>` : A}
9314
9662
  </div>
9315
9663
  <span
9316
9664
  class="lockup-mark ${declined ? "declined" : ""}"
@@ -9326,12 +9674,12 @@ var approver = ({ data, copy, step, variant, values }) => {
9326
9674
  <span class="small"
9327
9675
  >${granted ? c6.partyGranted : declined ? c6.partyDenied : c6.party}</span
9328
9676
  >
9329
- <span class="value">${agent.name}</span>
9677
+ <span class="value">${breakable(agent.name)}</span>
9330
9678
  </div>
9331
9679
  ${status ? b2`<span
9332
9680
  class="party-status ${unverified ? "unverified" : ""}"
9333
9681
  part="agent-status"
9334
- >${status}${unverified && c6.unverifiedInfo ? b2`<button
9682
+ >${breakable(status)}${unverified && c6.unverifiedInfo ? b2`<button
9335
9683
  type="button"
9336
9684
  class="info"
9337
9685
  aria-label=${c6.unverified}
@@ -9354,10 +9702,14 @@ var capability = ({
9354
9702
  preview
9355
9703
  }) => {
9356
9704
  const locked = Boolean(variant);
9357
- return b2`<div class="section-header" part="section-header">
9705
+ return b2`<div
9706
+ class="section-header"
9707
+ part="section-header"
9708
+ data-field="capabilitiesHeader"
9709
+ >
9358
9710
  <span>${fillTemplate(token(copy, "capabilitiesHeader"), values)}</span>
9359
9711
  <span class="hint" part="section-hint" ?data-hidden=${locked}
9360
- >${token(copy, "tapToToggle")}</span
9712
+ >${fillTemplate(token(copy, "tapToToggle"), values)}</span
9361
9713
  >
9362
9714
  </div>
9363
9715
  <div class="rows ${variant === "dim" ? "dim" : ""}">
@@ -9428,6 +9780,23 @@ var receipt = ({ data, copy, selected }) => {
9428
9780
  )}
9429
9781
  </ul>`;
9430
9782
  };
9783
+ function termsBox({ copy, termsAccepted }, terms, loading) {
9784
+ const href = httpsUrl(terms.href);
9785
+ const words = splitTemplate(group(copy, "terms").agree ?? "{Terms}").map(
9786
+ (part) => part.name !== "Terms" ? part.text ?? "" : href ? b2`<a href=${href} target="_blank" rel="noopener noreferrer"
9787
+ >${terms.label}</a
9788
+ >` : terms.label
9789
+ );
9790
+ return b2`<label class="terms" part="terms" data-field="terms">
9791
+ <input
9792
+ type="checkbox"
9793
+ data-action="terms"
9794
+ .checked=${termsAccepted}
9795
+ ?disabled=${loading}
9796
+ />
9797
+ <span>${words}</span>
9798
+ </label>`;
9799
+ }
9431
9800
  var FINGERPRINT = b2`<svg
9432
9801
  viewBox="0 0 24 24"
9433
9802
  fill="none"
@@ -9440,8 +9809,8 @@ var FINGERPRINT = b2`<svg
9440
9809
  ${fingerprintIcon}
9441
9810
  </svg>`;
9442
9811
  var FLOW_BLOCK_RENDERERS = {
9443
- eyebrow: ({ copy, step }) => b2`<span class="eyebrow" part="eyebrow"
9444
- >${token(copy, "eyebrow", step)}</span
9812
+ eyebrow: ({ copy, step, values }) => b2`<span class="eyebrow" part="eyebrow"
9813
+ >${fillTemplate(token(copy, "eyebrow", step), values)}</span
9445
9814
  >`,
9446
9815
  headline: ({ copy, step, values }) => {
9447
9816
  const words = token(copy, "headline", step);
@@ -9451,7 +9820,7 @@ var FLOW_BLOCK_RENDERERS = {
9451
9820
  },
9452
9821
  sub: ({ copy, step, values }) => {
9453
9822
  const words = token(copy, "sub", step);
9454
- return words ? b2`<p class="sub">${fillTemplate(words, values)}</p>` : A;
9823
+ return words ? b2`<p class="sub" part="sub">${fillTemplate(words, values)}</p>` : A;
9455
9824
  },
9456
9825
  signIn,
9457
9826
  finePrint: ({ copy, values }) => {
@@ -9464,27 +9833,41 @@ var FLOW_BLOCK_RENDERERS = {
9464
9833
  details: ({ data }) => data.grantDetails ? grantDetailsSection(
9465
9834
  grantDetailRows(data.grantDetails, data.merchant.name)
9466
9835
  ) : A,
9836
+ /** The project's own note (Checkpoint's "Info note"); nothing without one. */
9837
+ infoNote: ({ copy, values }) => {
9838
+ const words = token(copy, "infoNote");
9839
+ return words ? b2`<p class="line tinted info-note" part="info-note">
9840
+ ${decisionIcon("info")}<span>${fillTemplate(words, values)}</span>
9841
+ </p>` : A;
9842
+ },
9467
9843
  /** The package's countdown; its expiry is the flow's `expire` event. */
9468
9844
  countdown: ({ data }) => data.requestExpiresAt !== void 0 ? b2`<consent-request-expiry
9469
9845
  .expiresAt=${data.requestExpiresAt}
9470
9846
  ></consent-request-expiry>` : A,
9471
- actions: ({ data, copy, variant, method, preview }) => {
9472
- const a4 = group(copy, "actions");
9473
- return b2`<consent-action-bar
9474
- .agentName=${data.agent.name}
9475
- .submitLabel=${a4.approve ?? ""}
9476
- .cancelLabel=${a4.deny ?? ""}
9477
- .submitIcon=${method === "passkey" ? "passkey" : ""}
9478
- .loadingLabel=${a4.confirming ?? ""}
9479
- .loading=${variant === "loading"}
9480
- .preview=${preview}
9481
- ></consent-action-bar>`;
9847
+ /** Allow and Deny; with terms, the box to tick over them, and Allow waits for it. */
9848
+ actions: (ctx) => {
9849
+ const { data, copy, variant, method, preview, terms, termsAccepted } = ctx;
9850
+ const a4 = filled(group(copy, "actions"), ctx.values);
9851
+ const loading = variant === "loading";
9852
+ return b2`${terms ? termsBox(ctx, terms, loading) : A}
9853
+ <consent-action-bar
9854
+ .agentName=${data.agent.name}
9855
+ .submitLabel=${a4.approve ?? ""}
9856
+ .cancelLabel=${a4.deny ?? ""}
9857
+ .submitIcon=${method === "passkey" ? "passkey" : ""}
9858
+ .loadingLabel=${a4.confirming ?? ""}
9859
+ .loading=${loading}
9860
+ .disabled=${Boolean(terms) && !termsAccepted}
9861
+ .preview=${preview}
9862
+ ></consent-action-bar>`;
9482
9863
  },
9483
- status: ({ copy }) => b2`<p class="line status" part="status" tabindex="-1">
9484
- ${FINGERPRINT}<span>${token(copy, "status")}</span>
9864
+ status: ({ copy, values }) => b2`<p class="line status" part="status" tabindex="-1">
9865
+ ${FINGERPRINT}<span>${fillTemplate(token(copy, "status"), values)}</span>
9485
9866
  </p>`,
9486
- notice: ({ copy }) => b2`<p class="line notice" part="notice" tabindex="-1">
9487
- ${decisionIcon("warning")}<span>${token(copy, "notice")}</span>
9867
+ notice: ({ copy, values }) => b2`<p class="line notice" part="notice" tabindex="-1">
9868
+ ${decisionIcon("warning")}<span
9869
+ >${fillTemplate(token(copy, "notice"), values)}</span
9870
+ >
9488
9871
  </p>`,
9489
9872
  expiredNote: ({ copy, values }) => b2`<p class="line tinted expired-note" part="expired-note">
9490
9873
  ${decisionIcon("duration")}<span
@@ -9496,8 +9879,8 @@ var FLOW_BLOCK_RENDERERS = {
9496
9879
  const words = token(copy, "goBack");
9497
9880
  return words ? b2`<p class="sub">${fillTemplate(words, values)}</p>` : A;
9498
9881
  },
9499
- retry: ({ copy }) => b2`<button type="button" class="primary" part="retry" data-action="retry">
9500
- ${token(copy, "retry")}
9882
+ retry: ({ copy, values }) => b2`<button type="button" class="primary" part="retry" data-action="retry">
9883
+ ${fillTemplate(token(copy, "retry"), values)}
9501
9884
  </button>`
9502
9885
  };
9503
9886
  var flowBlockStyles = i`
@@ -9592,12 +9975,14 @@ var flowBlockStyles = i`
9592
9975
  opacity: 0.55;
9593
9976
  }
9594
9977
 
9595
- /* The approver lockup. */
9978
+ /* The approver lockup. Names break only where a word can't fit, and
9979
+ an address at its "@" and dots first (breakable). */
9596
9980
  .lockup {
9597
9981
  display: flex;
9598
9982
  flex-direction: column;
9599
9983
  gap: 12px;
9600
9984
  padding: 16px 18px;
9985
+ container-type: inline-size;
9601
9986
  }
9602
9987
 
9603
9988
  .lockup-row {
@@ -9632,12 +10017,12 @@ var flowBlockStyles = i`
9632
10017
  font-size: 20px;
9633
10018
  font-weight: 600;
9634
10019
  line-height: 1.2;
9635
- overflow-wrap: anywhere;
10020
+ overflow-wrap: break-word;
9636
10021
  }
9637
10022
 
9638
10023
  .lockup-text .value {
9639
10024
  font-weight: 500;
9640
- overflow-wrap: anywhere;
10025
+ overflow-wrap: break-word;
9641
10026
  }
9642
10027
 
9643
10028
  .lockup-mark {
@@ -9727,18 +10112,44 @@ var flowBlockStyles = i`
9727
10112
  color: var(--cs-warning-text, var(--cs-text-primary));
9728
10113
  }
9729
10114
 
9730
- .info {
9731
- display: inline-grid;
9732
- place-items: center;
9733
- width: 22px;
9734
- height: 22px;
9735
- padding: 0;
9736
- border: 0;
9737
- border-radius: 50%;
9738
- background: none;
9739
- color: var(--cs-text-tertiary);
9740
- cursor: help;
9741
- }
10115
+ /* A phone-width card: smaller faces and padding, and the agent's status
10116
+ under its name, so the names keep their width. */
10117
+ @container (max-width: 300px) {
10118
+ .lockup-row {
10119
+ gap: 10px;
10120
+ }
10121
+
10122
+ .lockup-row.party {
10123
+ flex-wrap: wrap;
10124
+ }
10125
+
10126
+ .face,
10127
+ .tile {
10128
+ width: 36px;
10129
+ height: 36px;
10130
+ }
10131
+
10132
+ .party-status {
10133
+ flex-basis: 100%;
10134
+ flex-shrink: 1;
10135
+ min-width: 0;
10136
+ padding-left: 46px;
10137
+ overflow-wrap: break-word;
10138
+ }
10139
+ }
10140
+
10141
+ .info {
10142
+ display: inline-grid;
10143
+ place-items: center;
10144
+ width: 22px;
10145
+ height: 22px;
10146
+ padding: 0;
10147
+ border: 0;
10148
+ border-radius: 50%;
10149
+ background: none;
10150
+ color: var(--cs-text-tertiary);
10151
+ cursor: help;
10152
+ }
9742
10153
 
9743
10154
  .info svg {
9744
10155
  width: 16px;
@@ -9867,10 +10278,52 @@ var flowBlockStyles = i`
9867
10278
  color: var(--cs-text-secondary);
9868
10279
  }
9869
10280
 
9870
- .expired-note {
10281
+ .expired-note,
10282
+ .info-note {
9871
10283
  padding: 12px 14px;
9872
10284
  }
9873
10285
 
10286
+ .info-note {
10287
+ align-items: flex-start;
10288
+ font-size: 13px;
10289
+ color: var(--cs-text-secondary);
10290
+ }
10291
+
10292
+ .info-note svg {
10293
+ margin-top: 2px;
10294
+ }
10295
+
10296
+ /* The terms to accept, over Allow. */
10297
+ .terms {
10298
+ display: flex;
10299
+ align-items: flex-start;
10300
+ gap: 10px;
10301
+ margin-bottom: 14px;
10302
+ font-size: 13px;
10303
+ line-height: 1.45;
10304
+ color: var(--cs-text-secondary);
10305
+ cursor: pointer;
10306
+ }
10307
+
10308
+ .terms input {
10309
+ flex-shrink: 0;
10310
+ width: 16px;
10311
+ height: 16px;
10312
+ margin: 1px 0 0;
10313
+ accent-color: var(--cs-action, var(--cs-surface-accent));
10314
+ cursor: inherit;
10315
+ }
10316
+
10317
+ .terms input:disabled {
10318
+ cursor: default;
10319
+ }
10320
+
10321
+ .terms a {
10322
+ color: var(--consent-link, var(--cs-action, currentColor));
10323
+ text-decoration: underline;
10324
+ text-underline-offset: 2px;
10325
+ }
10326
+
9874
10327
  /* The receipt. */
9875
10328
  .receipt {
9876
10329
  display: flex;
@@ -10077,7 +10530,48 @@ function signatureOf(value) {
10077
10530
  return String(value);
10078
10531
  }
10079
10532
  var blockName = (key) => key.split("#")[0];
10080
- var DRAWN = ["flow", "data", "copy", "step", "preview"];
10533
+ var MOVES = ["flow", "step"];
10534
+ var SPOT_X = 8;
10535
+ var SPOT_Y = 6;
10536
+ var LABEL_ROOM = 10;
10537
+ function within(container, node) {
10538
+ while (node) {
10539
+ if (node === container) return true;
10540
+ node = node.parentNode ?? node.host ?? null;
10541
+ }
10542
+ return false;
10543
+ }
10544
+ function inset(rect, by) {
10545
+ return new DOMRect(
10546
+ rect.left + by,
10547
+ rect.top + by,
10548
+ rect.width - 2 * by,
10549
+ rect.height - 2 * by
10550
+ );
10551
+ }
10552
+ function ringRadius(region) {
10553
+ const box = region.getBoundingClientRect();
10554
+ for (const el of [region, region.firstElementChild]) {
10555
+ if (!el) continue;
10556
+ const r8 = el.getBoundingClientRect();
10557
+ if (Math.abs(r8.width - box.width) > 1 || Math.abs(r8.height - box.height) > 1)
10558
+ continue;
10559
+ const radius = parseFloat(getComputedStyle(el).borderTopLeftRadius) || 0;
10560
+ if (radius > 0) return radius + SPOT_Y;
10561
+ }
10562
+ return 8;
10563
+ }
10564
+ var isField = (name) => FLOW_FIELDS.includes(name ?? "");
10565
+ var termsKey = (terms) => terms ? JSON.stringify([terms.label, terms.href, terms.version]) : "";
10566
+ function brandRule(brand, theme) {
10567
+ if (!brand) return "";
10568
+ try {
10569
+ const declarations = Object.entries(brandTokens(brand, theme)).map(([property, value]) => `${property}: ${value};`).join(" ");
10570
+ return `:host { ${declarations} }`;
10571
+ } catch {
10572
+ return "";
10573
+ }
10574
+ }
10081
10575
  var ConsentFlow = class extends i4 {
10082
10576
  constructor() {
10083
10577
  super();
@@ -10085,6 +10579,10 @@ var ConsentFlow = class extends i4 {
10085
10579
  this.copy = {};
10086
10580
  this.step = "";
10087
10581
  this.theme = "light";
10582
+ this.legal = [];
10583
+ this.highlight = "";
10584
+ this.highlightMode = "select";
10585
+ this.highlightLabel = "";
10088
10586
  this.preview = false;
10089
10587
  this.selected = /* @__PURE__ */ new Set();
10090
10588
  this.resolved = null;
@@ -10093,12 +10591,18 @@ var ConsentFlow = class extends i4 {
10093
10591
  this.atRest = null;
10094
10592
  this.pointerInside = false;
10095
10593
  this.generation = 0;
10594
+ this.motionDone = Promise.resolve();
10595
+ this.termsAccepted = false;
10596
+ this.acceptedTerms = "";
10597
+ this.resizes = null;
10096
10598
  this.onDocumentPointer = (event) => {
10097
10599
  this.pointerInside = event.composedPath().includes(this);
10098
10600
  };
10099
10601
  this.onAllow = (event) => {
10100
10602
  event.stopPropagation();
10101
10603
  if (this.fromLeaving(event)) return;
10604
+ const terms = this.terms;
10605
+ if (terms && !this.termsAccepted) return;
10102
10606
  const ticked = (this.data?.capabilities ?? []).filter(
10103
10607
  (cap) => this.selected.has(cap.id)
10104
10608
  );
@@ -10108,11 +10612,76 @@ var ConsentFlow = class extends i4 {
10108
10612
  this.init({
10109
10613
  capabilities: ticked.map((cap) => cap.id),
10110
10614
  scopes: [...new Set(ticked.flatMap((cap) => cap.scopes))],
10111
- approvalMethod: this.flow.approvalMethod
10615
+ approvalMethod: this.flow.approvalMethod,
10616
+ // Without terms the fields stay out: a server reads an explicit
10617
+ // false as refused.
10618
+ ...terms ? { termsAccepted: true } : {},
10619
+ ...terms?.version !== void 0 ? { termsVersion: terms.version } : {}
10112
10620
  })
10113
10621
  )
10114
10622
  );
10115
10623
  };
10624
+ /** The terms box: its tick is the person's, in a preview too. */
10625
+ this.onChange = (event) => {
10626
+ const target = event.target;
10627
+ if (target?.dataset?.action !== "terms" || this.fromLeaving(event)) return;
10628
+ this.termsAccepted = target.checked;
10629
+ this.requestUpdate();
10630
+ };
10631
+ /** In a preview, a click names the region it landed in, for the editor's rail. */
10632
+ this.onFieldClick = (event) => {
10633
+ if (!this.preview || this.fromLeaving(event)) return;
10634
+ const field = this.fieldAt(event);
10635
+ if (!field) return;
10636
+ this.dispatchEvent(
10637
+ new CustomEvent(
10638
+ "consent-flow-field",
10639
+ this.init({ field })
10640
+ )
10641
+ );
10642
+ };
10643
+ /** Outlines the highlighted region, in a preview; fades the outline out otherwise. */
10644
+ this.placeSpotlight = () => {
10645
+ const spot = this.renderRoot.querySelector(".spotlight");
10646
+ const flow2 = this.renderRoot.querySelector(".flow");
10647
+ const card = this.card;
10648
+ if (!spot || !flow2 || !card) return;
10649
+ const region = this.preview && this.highlight ? this.regionOf(this.highlight) : null;
10650
+ if (!region) {
10651
+ delete spot.dataset.shown;
10652
+ return;
10653
+ }
10654
+ const outer = flow2.getBoundingClientRect();
10655
+ const scale = flow2.offsetWidth > 0 ? outer.width / flow2.offsetWidth : 1;
10656
+ const box = region.getBoundingClientRect();
10657
+ const clip = within(card, region) ? inset(card.getBoundingClientRect(), card.clientLeft * scale) : outer;
10658
+ const left = Math.max(box.left - SPOT_X * scale, clip.left);
10659
+ const top = Math.max(box.top - SPOT_Y * scale, clip.top);
10660
+ const right = Math.min(box.right + SPOT_X * scale, clip.right);
10661
+ const bottom = Math.min(box.bottom + SPOT_Y * scale, clip.bottom);
10662
+ const x3 = (left - outer.left) / scale;
10663
+ const y4 = (top - outer.top) / scale;
10664
+ const first = spot.dataset.shown === void 0;
10665
+ if (first) spot.classList.add("placing");
10666
+ spot.style.transform = `translate(${x3}px, ${y4}px)`;
10667
+ spot.style.width = `${(right - left) / scale}px`;
10668
+ spot.style.height = `${(bottom - top) / scale}px`;
10669
+ spot.style.borderRadius = `${ringRadius(region)}px`;
10670
+ spot.dataset.mode = this.highlightMode === "hover" ? "hover" : "select";
10671
+ const ghost = Boolean(region.querySelector(":scope > .ghost"));
10672
+ const label = [this.highlightLabel.trim(), ghost ? "Empty" : ""].filter(Boolean).join(" \xB7 ");
10673
+ const tag = spot.querySelector(".spot-label");
10674
+ if (tag) {
10675
+ tag.textContent = label;
10676
+ tag.hidden = !label;
10677
+ tag.dataset.below = String(y4 < LABEL_ROOM);
10678
+ }
10679
+ if (first) {
10680
+ void spot.offsetWidth;
10681
+ spot.classList.remove("placing");
10682
+ }
10683
+ spot.dataset.shown = "";
10684
+ };
10116
10685
  this.onDeny = (event) => {
10117
10686
  event.stopPropagation();
10118
10687
  if (!this.fromLeaving(event))
@@ -10169,6 +10738,26 @@ var ConsentFlow = class extends i4 {
10169
10738
  get currentStep() {
10170
10739
  return this.resolved;
10171
10740
  }
10741
+ /**
10742
+ * Where a region is drawn now, in viewport coordinates: the box `highlight`
10743
+ * outlines (Approve and Deny each their own button). Null when this step
10744
+ * draws no such region. A box that is moving between steps reads where it
10745
+ * is drawn this frame, so after a step change read it once `whenSettled()`
10746
+ * resolves.
10747
+ *
10748
+ * @example
10749
+ * flowEl.step = "granted";
10750
+ * await flowEl.whenSettled();
10751
+ * flowEl.fieldRect("headline"); // DOMRect
10752
+ */
10753
+ fieldRect(field) {
10754
+ return isField(field) ? this.regionOf(field)?.getBoundingClientRect() ?? null : null;
10755
+ }
10756
+ /** Resolves once the last change is drawn and its motion has finished (at once when nothing moves). */
10757
+ async whenSettled() {
10758
+ await this.updateComplete;
10759
+ await this.motionDone;
10760
+ }
10172
10761
  connectedCallback() {
10173
10762
  super.connectedCallback();
10174
10763
  document.addEventListener("pointerdown", this.onDocumentPointer, true);
@@ -10176,6 +10765,8 @@ var ConsentFlow = class extends i4 {
10176
10765
  disconnectedCallback() {
10177
10766
  super.disconnectedCallback();
10178
10767
  document.removeEventListener("pointerdown", this.onDocumentPointer, true);
10768
+ this.resizes?.disconnect();
10769
+ this.resizes = null;
10179
10770
  }
10180
10771
  get card() {
10181
10772
  return this.renderRoot.querySelector(".card");
@@ -10186,6 +10777,10 @@ var ConsentFlow = class extends i4 {
10186
10777
  willUpdate(changed) {
10187
10778
  if (changed.has("data"))
10188
10779
  this.reselect(changed.get("data"));
10780
+ if (changed.has("terms") && termsKey(this.terms) !== this.acceptedTerms) {
10781
+ this.termsAccepted = false;
10782
+ this.acceptedTerms = termsKey(this.terms);
10783
+ }
10189
10784
  const steps = this.flow.steps;
10190
10785
  const wanted = this.step;
10191
10786
  const swapped = this.hasUpdated && changed.has("flow");
@@ -10195,7 +10790,7 @@ var ConsentFlow = class extends i4 {
10195
10790
  this.atRest = null;
10196
10791
  const card = this.card;
10197
10792
  const fx = this.fx;
10198
- if (!this.hasUpdated || !card || !fx || !DRAWN.some((key) => changed.has(key)))
10793
+ if (!this.hasUpdated || !card || !fx || !MOVES.some((key) => changed.has(key)))
10199
10794
  return;
10200
10795
  settle(card);
10201
10796
  fx.replaceChildren();
@@ -10246,6 +10841,30 @@ var ConsentFlow = class extends i4 {
10246
10841
  const fx = this.fx;
10247
10842
  return Boolean(fx && event.composedPath().includes(fx));
10248
10843
  }
10844
+ /** The innermost region on an event's path, through the package's own shadow roots. */
10845
+ fieldAt(event) {
10846
+ for (const node of event.composedPath()) {
10847
+ if (node === this) return null;
10848
+ if (!(node instanceof HTMLElement)) continue;
10849
+ const name = node.dataset.field ?? node.dataset.block;
10850
+ if (isField(name)) return name;
10851
+ }
10852
+ return null;
10853
+ }
10854
+ /** The element a region is drawn by: the innermost one, inside the package's own parts too. */
10855
+ regionOf(field) {
10856
+ const selector = `[data-field="${field}"]`;
10857
+ const root = this.renderRoot;
10858
+ const own = root.querySelector(selector) ?? root.querySelector(`.card > [data-block="${field}"]`);
10859
+ if (own) return own;
10860
+ for (const host of root.querySelectorAll(
10861
+ "consent-action-bar, consent-connector-header"
10862
+ )) {
10863
+ const inner = host.shadowRoot?.querySelector(selector);
10864
+ if (inner) return inner;
10865
+ }
10866
+ return null;
10867
+ }
10249
10868
  specs(data, step, copy) {
10250
10869
  const ctx = {
10251
10870
  data,
@@ -10254,7 +10873,9 @@ var ConsentFlow = class extends i4 {
10254
10873
  selected: this.selected,
10255
10874
  method: this.flow.approvalMethod,
10256
10875
  preview: this.preview,
10257
- values: flowValues(data)
10876
+ values: flowValues(data),
10877
+ ...this.terms ? { terms: this.terms } : {},
10878
+ termsAccepted: this.termsAccepted
10258
10879
  };
10259
10880
  const seen = /* @__PURE__ */ new Map();
10260
10881
  const specs = [];
@@ -10262,7 +10883,9 @@ var ConsentFlow = class extends i4 {
10262
10883
  const [name, variant] = ref.split(":");
10263
10884
  const draw = FLOW_BLOCK_RENDERERS[name];
10264
10885
  if (!draw) continue;
10265
- const result = draw(variant ? { ...ctx, variant } : ctx);
10886
+ let result = draw(variant ? { ...ctx, variant } : ctx);
10887
+ if (result === A && this.preview && this.highlight === name)
10888
+ result = b2`<div class="ghost" part="ghost"></div>`;
10266
10889
  if (result === A) continue;
10267
10890
  const n6 = (seen.get(name) ?? 0) + 1;
10268
10891
  seen.set(name, n6);
@@ -10283,15 +10906,24 @@ var ConsentFlow = class extends i4 {
10283
10906
  );
10284
10907
  const seal = fillTemplate(group(copy, "seal")[def.connector] ?? "", values);
10285
10908
  const announce = fillTemplate(group(copy, "announce")[step] ?? "", values);
10909
+ const legal = this.legal.filter((link) => httpsUrl(link.href));
10286
10910
  return b2`<style>
10287
10911
  ${themeScopeStyle(
10288
10912
  getConsentTheme(this.theme),
10289
- ".card, consent-connector-header, .below"
10913
+ ".card",
10914
+ "consent-connector-header, .below"
10290
10915
  )}
10916
+ ${brandRule(this.brand, this.theme)}
10291
10917
  </style>
10292
- <div class="flow" data-step=${step}>
10918
+ <div
10919
+ class="flow"
10920
+ data-step=${step}
10921
+ data-motion=${this.flow.motion}
10922
+ @click=${this.onFieldClick}
10923
+ >
10293
10924
  <consent-connector-header
10294
10925
  part="connector"
10926
+ data-field="connector"
10295
10927
  variant="bridge"
10296
10928
  .clientName=${data.agent.name}
10297
10929
  .clientLogoUrl=${data.agent.logoUrl ?? ""}
@@ -10309,6 +10941,7 @@ var ConsentFlow = class extends i4 {
10309
10941
  class="card"
10310
10942
  part="card"
10311
10943
  @click=${this.onClick}
10944
+ @change=${this.onChange}
10312
10945
  @consent-allow=${this.onAllow}
10313
10946
  @consent-deny=${this.onDeny}
10314
10947
  @consent-request-expired=${this.onExpired}
@@ -10329,11 +10962,31 @@ var ConsentFlow = class extends i4 {
10329
10962
  </div>
10330
10963
  <div class="below" part="below">
10331
10964
  <consent-secured-by></consent-secured-by>
10965
+ ${legal.length > 0 ? b2`<nav
10966
+ class="legal"
10967
+ part="legal"
10968
+ data-field="legal"
10969
+ aria-label=${group(copy, "legal").label ?? "Legal"}
10970
+ >
10971
+ ${legal.map(
10972
+ (link) => b2`<a
10973
+ href=${link.href}
10974
+ target="_blank"
10975
+ rel="noopener noreferrer"
10976
+ >${link.label}</a
10977
+ >`
10978
+ )}
10979
+ </nav>` : A}
10332
10980
  </div>
10333
10981
  <p class="sr" role="status">${announce}</p>
10982
+ <div class="spotlight" aria-hidden="true">
10983
+ <span class="spot-label" hidden></span>
10984
+ </div>
10334
10985
  </div>`;
10335
10986
  }
10336
10987
  updated(changed) {
10988
+ this.watchLayout();
10989
+ this.placeSpotlight();
10337
10990
  this.setAttribute(FLOW_HOST_ATTRIBUTES.version, String(this.flow.version));
10338
10991
  this.setAttribute(
10339
10992
  FLOW_HOST_ATTRIBUTES.approvalMethod,
@@ -10356,6 +11009,15 @@ var ConsentFlow = class extends i4 {
10356
11009
  }
10357
11010
  if (before) this.animateStep(before);
10358
11011
  }
11012
+ /** Moves the outline with the card: a resize, a font loading, a step settling. */
11013
+ watchLayout() {
11014
+ if (this.resizes || typeof ResizeObserver === "undefined") return;
11015
+ const card = this.card;
11016
+ if (!card) return;
11017
+ this.resizes = new ResizeObserver(this.placeSpotlight);
11018
+ this.resizes.observe(card);
11019
+ this.resizes.observe(this);
11020
+ }
10359
11021
  /** The step's `focus` block takes focus: its own target (`tabindex="-1"`), else its first control. */
10360
11022
  focusStep(step) {
10361
11023
  const key = this.flow.steps[step]?.focus;
@@ -10416,10 +11078,12 @@ var ConsentFlow = class extends i4 {
10416
11078
  else play2("arrive", name, arrive(el, arrivals++, t8));
10417
11079
  }
10418
11080
  const generation = ++this.generation;
10419
- void Promise.allSettled(
11081
+ this.motionDone = Promise.allSettled(
10420
11082
  started.map((animation) => animation.finished)
10421
11083
  ).then(() => {
10422
- if (generation === this.generation) card.classList.remove("moving");
11084
+ if (generation !== this.generation) return;
11085
+ card.classList.remove("moving");
11086
+ this.placeSpotlight();
10423
11087
  });
10424
11088
  }
10425
11089
  };
@@ -10430,12 +11094,104 @@ ConsentFlow.styles = i`
10430
11094
  text-wrap: pretty;
10431
11095
  }
10432
11096
 
11097
+ /* A preview shows the brand's page behind the card, which a live page
11098
+ paints on its body; with none, the editor's own shows through. */
11099
+ :host([preview]) {
11100
+ background-color: var(--cs-surface-bg);
11101
+ }
11102
+
10433
11103
  .flow {
11104
+ position: relative;
10434
11105
  box-sizing: border-box;
10435
11106
  max-width: var(--cs-screen-max-width, 576px);
10436
11107
  margin: 0 auto;
10437
11108
  }
10438
11109
 
11110
+ /* The editor's focused field, outlined over the flow in a preview. */
11111
+ /* The editor's highlight: a selection over the flow, in an editor
11112
+ accent (not the brand, not ink). It never takes layout. */
11113
+ .spotlight {
11114
+ --_accent: var(--cs-edit-focus-ring, #6d5ae6);
11115
+ position: absolute;
11116
+ top: 0;
11117
+ left: 0;
11118
+ box-sizing: border-box;
11119
+ border: 1.5px solid var(--_accent);
11120
+ border-radius: 8px;
11121
+ background: var(
11122
+ --cs-edit-wash,
11123
+ color-mix(in srgb, var(--_accent) 6%, transparent)
11124
+ );
11125
+ opacity: 0;
11126
+ pointer-events: none;
11127
+ z-index: 6;
11128
+ transition:
11129
+ opacity 120ms ease-out,
11130
+ transform 180ms ease-out,
11131
+ width 180ms ease-out,
11132
+ height 180ms ease-out;
11133
+ }
11134
+
11135
+ .spotlight[data-shown] {
11136
+ opacity: 1;
11137
+ }
11138
+
11139
+ .spotlight[data-mode="hover"] {
11140
+ border: 1px dashed var(--cs-edit-hover-ring, var(--_accent));
11141
+ background: none;
11142
+ }
11143
+
11144
+ /* A first show lands in place; reduced motion and the none preset fade only. */
11145
+ .spotlight.placing,
11146
+ .flow[data-motion="none"] .spotlight {
11147
+ transition: opacity 120ms ease-out;
11148
+ }
11149
+
11150
+ @media (prefers-reduced-motion: reduce) {
11151
+ .spotlight {
11152
+ transition: opacity 120ms ease-out;
11153
+ }
11154
+ }
11155
+
11156
+ /* The field's name, on the ring's top edge like a legend, so it reaches
11157
+ into the gap above rather than over the block before. */
11158
+ .spot-label {
11159
+ position: absolute;
11160
+ top: 0;
11161
+ left: 10px;
11162
+ transform: translateY(-50%);
11163
+ padding: 2px 6px;
11164
+ border-radius: 4px;
11165
+ background: var(--_accent);
11166
+ /* Themable with the accent: text on it stays readable. */
11167
+ color: var(--cs-edit-on-accent, #ffffff);
11168
+ font:
11169
+ 600 10px/14px system-ui,
11170
+ -apple-system,
11171
+ "Segoe UI",
11172
+ sans-serif;
11173
+ letter-spacing: 0.06em;
11174
+ text-transform: uppercase;
11175
+ white-space: nowrap;
11176
+ }
11177
+
11178
+ .spot-label[data-below="true"] {
11179
+ top: 100%;
11180
+ }
11181
+
11182
+ .spot-label[hidden] {
11183
+ display: none;
11184
+ }
11185
+
11186
+ /* Where a highlighted field's words will go, before it has any. */
11187
+ .ghost {
11188
+ box-sizing: border-box;
11189
+ height: 28px;
11190
+ border: 1px dashed
11191
+ color-mix(in srgb, var(--cs-edit-focus-ring, #6d5ae6) 55%, transparent);
11192
+ border-radius: 6px;
11193
+ }
11194
+
10439
11195
  .card {
10440
11196
  position: relative;
10441
11197
  display: flex;
@@ -10476,10 +11232,25 @@ ConsentFlow.styles = i`
10476
11232
  display: flex;
10477
11233
  flex-direction: column;
10478
11234
  align-items: center;
11235
+ gap: 10px;
10479
11236
  margin-top: 16px;
10480
11237
  color: var(--cs-text-tertiary);
10481
11238
  }
10482
11239
 
11240
+ .legal {
11241
+ display: flex;
11242
+ flex-wrap: wrap;
11243
+ justify-content: center;
11244
+ gap: 4px 20px;
11245
+ font-size: 12px;
11246
+ }
11247
+
11248
+ .legal a {
11249
+ color: inherit;
11250
+ text-decoration: underline;
11251
+ text-underline-offset: 2px;
11252
+ }
11253
+
10483
11254
  .sr {
10484
11255
  position: absolute;
10485
11256
  width: 1px;
@@ -10507,6 +11278,24 @@ __decorateClass([
10507
11278
  __decorateClass([
10508
11279
  n4({ type: String })
10509
11280
  ], ConsentFlow.prototype, "theme", 2);
11281
+ __decorateClass([
11282
+ n4({ attribute: false })
11283
+ ], ConsentFlow.prototype, "brand", 2);
11284
+ __decorateClass([
11285
+ n4({ attribute: false })
11286
+ ], ConsentFlow.prototype, "legal", 2);
11287
+ __decorateClass([
11288
+ n4({ attribute: false })
11289
+ ], ConsentFlow.prototype, "terms", 2);
11290
+ __decorateClass([
11291
+ n4({ type: String })
11292
+ ], ConsentFlow.prototype, "highlight", 2);
11293
+ __decorateClass([
11294
+ n4({ type: String, attribute: "highlight-mode" })
11295
+ ], ConsentFlow.prototype, "highlightMode", 2);
11296
+ __decorateClass([
11297
+ n4({ type: String, attribute: "highlight-label" })
11298
+ ], ConsentFlow.prototype, "highlightLabel", 2);
10510
11299
  __decorateClass([
10511
11300
  n4({ type: Boolean, reflect: true })
10512
11301
  ], ConsentFlow.prototype, "preview", 2);
@@ -12974,215 +13763,6 @@ McpConsent = __decorateClass([
12974
13763
  t3("mcp-consent")
12975
13764
  ], McpConsent);
12976
13765
 
12977
- // src/styles/brand.ts
12978
- var AA_GRAPHIC_CONTRAST = 3;
12979
- var TEXT_CONTRAST = 4.5;
12980
- var ICON_TILE_PERCENT = 8;
12981
- var HOVERED_ROW_PERCENT = 4;
12982
- var MUTED_TEXT_PERCENT = 64;
12983
- var PANEL_TINT_PERCENT = 4;
12984
- var LIGHTNESS_STEP = 5e-3;
12985
- var LIGHT_DRAWN_COLORS = Object.freeze({
12986
- surface: lightTheme.surfaceCard,
12987
- panel: lightTheme.surfaceInset,
12988
- text: lightTheme.textPrimary,
12989
- mutedText: lightTheme.textTertiary
12990
- });
12991
- var PALETTE_FIELDS = [
12992
- "surfaceColor",
12993
- "panelColor",
12994
- "borderColor",
12995
- "textColor",
12996
- "mutedTextColor",
12997
- "focusColor"
12998
- ];
12999
- function rgbOf(hex) {
13000
- return [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
13001
- }
13002
- function hexOf(channels2) {
13003
- return `#${channels2.map((value) => Math.round(value).toString(16).padStart(2, "0")).join("")}`;
13004
- }
13005
- function mixOver(top, percent, under) {
13006
- const share = percent / 100;
13007
- const below = rgbOf(under);
13008
- return hexOf(
13009
- rgbOf(top).map((above, i8) => above * share + below[i8] * (1 - share))
13010
- );
13011
- }
13012
- function hslOf(hex) {
13013
- const [red, green, blue] = rgbOf(hex).map((value) => value / 255);
13014
- const high = Math.max(red, green, blue);
13015
- const low = Math.min(red, green, blue);
13016
- const spread = high - low;
13017
- const lightness = (high + low) / 2;
13018
- if (spread === 0) return { hue: 0, saturation: 0, lightness };
13019
- const saturation = spread / (1 - Math.abs(2 * lightness - 1));
13020
- const sector = high === red ? (green - blue) / spread : high === green ? (blue - red) / spread + 2 : (red - green) / spread + 4;
13021
- return { hue: (sector * 60 + 360) % 360, saturation, lightness };
13022
- }
13023
- function hexFromHsl({ hue, saturation, lightness }) {
13024
- const reach = saturation * Math.min(lightness, 1 - lightness);
13025
- const channel = (offset) => {
13026
- const turn = (offset + hue / 30) % 12;
13027
- return (lightness - reach * Math.max(-1, Math.min(turn - 3, 9 - turn, 1))) * 255;
13028
- };
13029
- return hexOf([channel(0), channel(8), channel(4)]);
13030
- }
13031
- function iconColorFor(hex, primary, drawn = LIGHT_DRAWN_COLORS) {
13032
- const hoveredRow = mixOver(primary, HOVERED_ROW_PERCENT, drawn.surface);
13033
- const surfaces = [
13034
- drawn.surface,
13035
- drawn.panel,
13036
- mixOver(primary, ICON_TILE_PERCENT, drawn.surface),
13037
- mixOver(primary, ICON_TILE_PERCENT, hoveredRow)
13038
- ];
13039
- const worstRatio = (candidate) => Math.min(...surfaces.map((surface) => contrastRatio(candidate, surface)));
13040
- if (worstRatio(hex) >= AA_GRAPHIC_CONTRAST) return hex;
13041
- const start = hslOf(hex);
13042
- for (let steps = 1; steps * LIGHTNESS_STEP <= 1; steps++) {
13043
- for (const lightness of [
13044
- start.lightness - steps * LIGHTNESS_STEP,
13045
- start.lightness + steps * LIGHTNESS_STEP
13046
- ]) {
13047
- if (lightness < 0 || lightness > 1) continue;
13048
- const candidate = hexFromHsl({ ...start, lightness });
13049
- if (worstRatio(candidate) >= AA_GRAPHIC_CONTRAST) return candidate;
13050
- }
13051
- }
13052
- return worstRatio("#000000") >= worstRatio("#ffffff") ? "#000000" : "#ffffff";
13053
- }
13054
- function focusRingFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
13055
- return contrastRatio(hex, surface) >= AA_GRAPHIC_CONTRAST ? "brand" : "ink";
13056
- }
13057
- function readsOnCardAndTint(hex, ratio, surface) {
13058
- const tint = mixOver(hex, TINT_PERCENT, surface);
13059
- return contrastRatio(hex, surface) >= ratio && contrastRatio(hex, tint) >= ratio;
13060
- }
13061
- function actionColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
13062
- return readsOnCardAndTint(hex, TEXT_CONTRAST, surface) ? "brand" : "ink";
13063
- }
13064
- function markColorFor(hex, surface = LIGHT_DRAWN_COLORS.surface) {
13065
- return readsOnCardAndTint(hex, AA_GRAPHIC_CONTRAST, surface) ? "brand" : "ink";
13066
- }
13067
- function onPrimaryFor(hex) {
13068
- const luminance = relativeLuminance(hex);
13069
- const againstWhite = 1.05 / (luminance + 0.05);
13070
- const againstBlack = (luminance + 0.05) / 0.05;
13071
- return againstBlack >= againstWhite ? "black" : "white";
13072
- }
13073
- function panelOf(palette, text, drawn) {
13074
- if (palette.panelColor) return palette.panelColor;
13075
- if (palette.surfaceColor)
13076
- return mixOver(text, PANEL_TINT_PERCENT, palette.surfaceColor);
13077
- return drawn.panel;
13078
- }
13079
- function mutedOn(palette, background, drawn) {
13080
- if (palette.mutedTextColor) return palette.mutedTextColor;
13081
- if (palette.textColor)
13082
- return mixOver(palette.textColor, MUTED_TEXT_PERCENT, background);
13083
- return drawn.mutedText;
13084
- }
13085
- function floorToHundredths(ratio) {
13086
- return Math.floor(ratio * 100) / 100;
13087
- }
13088
- function paletteFailures(palette, drawn = {}) {
13089
- const colors = { ...LIGHT_DRAWN_COLORS, ...drawn };
13090
- const text = palette.textColor ?? colors.text;
13091
- const backgrounds = [
13092
- {
13093
- background: "surfaceColor",
13094
- color: palette.surfaceColor ?? colors.surface
13095
- },
13096
- { background: "panelColor", color: panelOf(palette, text, colors) }
13097
- ];
13098
- return backgrounds.flatMap(({ background, color }) => {
13099
- const pairs = [
13100
- { foreground: "textColor", color: text, needs: TEXT_CONTRAST },
13101
- {
13102
- foreground: "mutedTextColor",
13103
- color: mutedOn(palette, color, colors),
13104
- needs: TEXT_CONTRAST
13105
- },
13106
- ...palette.focusColor ? [
13107
- {
13108
- foreground: "focusColor",
13109
- color: palette.focusColor,
13110
- needs: AA_GRAPHIC_CONTRAST
13111
- }
13112
- ] : []
13113
- ];
13114
- return pairs.flatMap(({ foreground, color: ink, needs }) => {
13115
- const ratio = contrastRatio(ink, color);
13116
- return ratio >= needs ? [] : [{ foreground, background, ratio: floorToHundredths(ratio), needs }];
13117
- });
13118
- });
13119
- }
13120
- function drawablePalette(chosen, drawn = {}) {
13121
- const { focusColor, borderColor, ...surfacesAndText } = chosen;
13122
- const kept = paletteFailures(surfacesAndText, drawn).length === 0 ? surfacesAndText : {};
13123
- const focusShows = focusColor !== void 0 && paletteFailures({ ...kept, focusColor }, drawn).length === 0;
13124
- return {
13125
- ...kept,
13126
- ...borderColor ? { borderColor } : {},
13127
- ...focusShows ? { focusColor } : {}
13128
- };
13129
- }
13130
- function brandTokens(brand) {
13131
- for (const [field, value] of Object.entries(brand)) {
13132
- if (value !== void 0 && !isHexColor(value)) {
13133
- throw new RangeError(
13134
- `${field} must be a #rrggbb color, got ${JSON.stringify(value)}`
13135
- );
13136
- }
13137
- }
13138
- const { primaryColor: primary, secondaryColor, ...chosen } = brand;
13139
- const palette = drawablePalette(chosen);
13140
- const surface = palette.surfaceColor ?? LIGHT_DRAWN_COLORS.surface;
13141
- const panel = panelOf(
13142
- palette,
13143
- palette.textColor ?? LIGHT_DRAWN_COLORS.text,
13144
- LIGHT_DRAWN_COLORS
13145
- );
13146
- const ink = palette.textColor ?? LIGHT_DRAWN_COLORS.text;
13147
- const onPrimary = onPrimaryFor(primary);
13148
- const inBrand = (pick) => pick === "brand" ? primary : ink;
13149
- const tokens = {
13150
- "--consent-primary": primary,
13151
- "--consent-on-primary": onPrimary,
13152
- "--consent-link": inBrand(actionColorFor(primary, surface)),
13153
- "--cs-surface-accent": primary,
13154
- "--cs-surface-accent-text": onPrimary,
13155
- "--cs-tint": mixOver(primary, TINT_PERCENT, surface),
13156
- "--cs-tint-line": mixOver(primary, TINT_LINE_PERCENT, surface),
13157
- "--cs-mark": inBrand(markColorFor(primary, surface)),
13158
- "--cs-action": inBrand(actionColorFor(primary, surface)),
13159
- "--cs-focus-ring": palette.focusColor ?? inBrand(focusRingFor(primary, surface))
13160
- };
13161
- if (secondaryColor) {
13162
- tokens["--cs-icon"] = iconColorFor(secondaryColor, primary, {
13163
- surface,
13164
- panel
13165
- });
13166
- }
13167
- if (palette.surfaceColor) tokens["--cs-surface-card"] = palette.surfaceColor;
13168
- if (palette.surfaceColor || palette.panelColor)
13169
- tokens["--cs-surface-inset"] = panel;
13170
- if (palette.borderColor) tokens["--cs-surface-border"] = palette.borderColor;
13171
- if (palette.textColor) {
13172
- tokens["--cs-text-primary"] = palette.textColor;
13173
- tokens["--cs-text-secondary"] = palette.textColor;
13174
- }
13175
- if (palette.mutedTextColor) {
13176
- tokens["--cs-text-tertiary"] = palette.mutedTextColor;
13177
- } else if (palette.textColor) {
13178
- tokens["--cs-text-tertiary"] = `color-mix(in srgb, ${palette.textColor} ${MUTED_TEXT_PERCENT}%, transparent)`;
13179
- }
13180
- return tokens;
13181
- }
13182
- function brandStyle(brand) {
13183
- return Object.entries(brandTokens(brand)).map(([property, value]) => `${property}: ${value};`).join(" ");
13184
- }
13185
-
13186
13766
  // ../../node_modules/.pnpm/@kya-os+id@0.11.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9._1fd211efd4c126c93f6c4adb9fbb1c99/node_modules/@kya-os/id/dist/base64url.js
13187
13767
  function bytesToBase64Url(bytes) {
13188
13768
  let b642;
@@ -13800,6 +14380,7 @@ function renderIcon() {
13800
14380
  }
13801
14381
  export {
13802
14382
  APPROVAL_METHODS,
14383
+ CONFIG_FIELD_REGIONS,
13803
14384
  CONNECTOR_MARKS,
13804
14385
  CONSENT_CAPABILITIES_FEATURES,
13805
14386
  CONSENT_EDIT_EVENTS,
@@ -13827,6 +14408,7 @@ export {
13827
14408
  FLOW_CONNECTOR_STATES,
13828
14409
  FLOW_COPY,
13829
14410
  FLOW_EVENTS,
14411
+ FLOW_FIELDS,
13830
14412
  FLOW_HOST_ATTRIBUTES,
13831
14413
  FLOW_PRESETS,
13832
14414
  FLOW_SCHEMA_VERSION,
@@ -13845,6 +14427,7 @@ export {
13845
14427
  flowCopy,
13846
14428
  flowPreset,
13847
14429
  group,
14430
+ httpsUrl,
13848
14431
  initialsOf,
13849
14432
  paletteFailures,
13850
14433
  parseConsentEditKey,