@multiplatform.one/components 10.1.2 → 10.1.4

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 (102) hide show
  1. package/dist/cjs/layouts/timeline.cjs +0 -1
  2. package/dist/cjs/layouts/timeline.native.cjs +0 -1
  3. package/dist/cjs/layouts/timeline.native.js +0 -1
  4. package/dist/cjs/layouts/timeline.native.js.map +1 -1
  5. package/dist/cjs/views/Calendar.cjs +54 -76
  6. package/dist/cjs/views/Calendar.native.cjs +54 -76
  7. package/dist/cjs/views/Calendar.native.js +54 -76
  8. package/dist/cjs/views/Calendar.native.js.map +1 -1
  9. package/dist/cjs/views/Gantt.cjs +185 -69
  10. package/dist/cjs/views/Gantt.native.cjs +190 -72
  11. package/dist/cjs/views/Gantt.native.js +190 -72
  12. package/dist/cjs/views/Gantt.native.js.map +1 -1
  13. package/dist/cjs/views/GanttDateGrip.cjs +20 -14
  14. package/dist/cjs/views/GanttDateGrip.native.cjs +24 -14
  15. package/dist/cjs/views/GanttDateGrip.native.js +24 -14
  16. package/dist/cjs/views/GanttDateGrip.native.js.map +1 -1
  17. package/dist/cjs/views/GanttGripDot.cjs +43 -0
  18. package/dist/cjs/views/GanttGripDot.native.cjs +46 -0
  19. package/dist/cjs/views/GanttGripDot.native.js +48 -0
  20. package/dist/cjs/views/GanttGripDot.native.js.map +1 -0
  21. package/dist/cjs/views/eventTint.cjs +242 -0
  22. package/dist/cjs/views/eventTint.native.cjs +346 -0
  23. package/dist/cjs/views/eventTint.native.js +348 -0
  24. package/dist/cjs/views/eventTint.native.js.map +1 -0
  25. package/dist/esm/layouts/timeline.mjs +0 -1
  26. package/dist/esm/layouts/timeline.mjs.map +1 -1
  27. package/dist/esm/layouts/timeline.native.js +0 -1
  28. package/dist/esm/layouts/timeline.native.js.map +1 -1
  29. package/dist/esm/views/Calendar.mjs +53 -75
  30. package/dist/esm/views/Calendar.mjs.map +1 -1
  31. package/dist/esm/views/Calendar.native.js +53 -75
  32. package/dist/esm/views/Calendar.native.js.map +1 -1
  33. package/dist/esm/views/Gantt.mjs +186 -70
  34. package/dist/esm/views/Gantt.mjs.map +1 -1
  35. package/dist/esm/views/Gantt.native.js +191 -73
  36. package/dist/esm/views/Gantt.native.js.map +1 -1
  37. package/dist/esm/views/GanttDateGrip.mjs +21 -15
  38. package/dist/esm/views/GanttDateGrip.mjs.map +1 -1
  39. package/dist/esm/views/GanttDateGrip.native.js +25 -15
  40. package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
  41. package/dist/esm/views/GanttGripDot.mjs +24 -0
  42. package/dist/esm/views/GanttGripDot.mjs.map +1 -0
  43. package/dist/esm/views/GanttGripDot.native.js +25 -0
  44. package/dist/esm/views/GanttGripDot.native.js.map +1 -0
  45. package/dist/esm/views/eventTint.mjs +196 -0
  46. package/dist/esm/views/eventTint.mjs.map +1 -0
  47. package/dist/esm/views/eventTint.native.js +298 -0
  48. package/dist/esm/views/eventTint.native.js.map +1 -0
  49. package/dist/jsx/layouts/timeline.mjs +0 -1
  50. package/dist/jsx/layouts/timeline.mjs.map +1 -1
  51. package/dist/jsx/layouts/timeline.native.cjs +0 -1
  52. package/dist/jsx/layouts/timeline.native.js +0 -1
  53. package/dist/jsx/layouts/timeline.native.js.map +1 -1
  54. package/dist/jsx/views/Calendar.mjs +53 -75
  55. package/dist/jsx/views/Calendar.mjs.map +1 -1
  56. package/dist/jsx/views/Calendar.native.cjs +54 -76
  57. package/dist/jsx/views/Calendar.native.js +54 -76
  58. package/dist/jsx/views/Calendar.native.js.map +1 -1
  59. package/dist/jsx/views/Gantt.mjs +186 -70
  60. package/dist/jsx/views/Gantt.mjs.map +1 -1
  61. package/dist/jsx/views/Gantt.native.cjs +190 -72
  62. package/dist/jsx/views/Gantt.native.js +190 -72
  63. package/dist/jsx/views/Gantt.native.js.map +1 -1
  64. package/dist/jsx/views/GanttDateGrip.mjs +21 -15
  65. package/dist/jsx/views/GanttDateGrip.mjs.map +1 -1
  66. package/dist/jsx/views/GanttDateGrip.native.cjs +24 -14
  67. package/dist/jsx/views/GanttDateGrip.native.js +24 -14
  68. package/dist/jsx/views/GanttDateGrip.native.js.map +1 -1
  69. package/dist/jsx/views/GanttGripDot.mjs +24 -0
  70. package/dist/jsx/views/GanttGripDot.mjs.map +1 -0
  71. package/dist/jsx/views/GanttGripDot.native.cjs +46 -0
  72. package/dist/jsx/views/GanttGripDot.native.js +48 -0
  73. package/dist/jsx/views/GanttGripDot.native.js.map +1 -0
  74. package/dist/jsx/views/eventTint.mjs +196 -0
  75. package/dist/jsx/views/eventTint.mjs.map +1 -0
  76. package/dist/jsx/views/eventTint.native.cjs +346 -0
  77. package/dist/jsx/views/eventTint.native.js +348 -0
  78. package/dist/jsx/views/eventTint.native.js.map +1 -0
  79. package/package.json +7 -7
  80. package/src/hoverTouchPath.coarse.spec.tsx +28 -4
  81. package/src/layouts/timeline.replyInset.spec.tsx +72 -22
  82. package/src/layouts/timeline.tsx +0 -1
  83. package/src/views/Calendar.eventFill.spec.tsx +44 -9
  84. package/src/views/Calendar.tsx +23 -31
  85. package/src/views/Gantt.barInk.spec.tsx +257 -0
  86. package/src/views/Gantt.grips.spec.tsx +226 -0
  87. package/src/views/Gantt.tint.palette.spec.ts +288 -0
  88. package/src/views/Gantt.tsx +224 -65
  89. package/src/views/GanttDateGrip.native.spec.tsx +8 -0
  90. package/src/views/GanttDateGrip.tsx +28 -17
  91. package/src/views/GanttGripDot.tsx +36 -0
  92. package/src/views/dataIdentity.spec.tsx +29 -13
  93. package/src/views/eventTint.ts +305 -0
  94. package/types/layouts/timeline.d.ts.map +1 -1
  95. package/types/views/Calendar.d.ts.map +1 -1
  96. package/types/views/Gantt.d.ts.map +1 -1
  97. package/types/views/GanttDateGrip.d.ts +7 -0
  98. package/types/views/GanttDateGrip.d.ts.map +1 -1
  99. package/types/views/GanttGripDot.d.ts +9 -0
  100. package/types/views/GanttGripDot.d.ts.map +1 -0
  101. package/types/views/eventTint.d.ts +72 -0
  102. package/types/views/eventTint.d.ts.map +1 -0
@@ -0,0 +1,242 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var eventTint_exports = {};
28
+ __export(eventTint_exports, {
29
+ EVENT_BAR_PX: () => EVENT_BAR_PX,
30
+ EVENT_GHOST_DARK: () => EVENT_GHOST_DARK,
31
+ EVENT_GRIP_DOT_PX: () => EVENT_GRIP_DOT_PX,
32
+ EVENT_REST_STANDOFF: () => EVENT_REST_STANDOFF,
33
+ EVENT_SOLID_SELECTED: () => EVENT_SOLID_SELECTED,
34
+ EVENT_STRIP_FLOOR: () => EVENT_STRIP_FLOOR,
35
+ EVENT_STRIP_STEP: () => EVENT_STRIP_STEP,
36
+ blendOver: () => blendOver,
37
+ eventInk: () => eventInk,
38
+ eventLabelInk: () => eventLabelInk,
39
+ eventPaint: () => eventPaint,
40
+ eventRamp: () => eventRamp,
41
+ eventRampSteps: () => eventRampSteps,
42
+ eventSolid: () => eventSolid,
43
+ eventStripPaint: () => eventStripPaint,
44
+ eventTintFor: () => eventTintFor,
45
+ eventTints: () => eventTints,
46
+ themeValue: () => themeValue,
47
+ useEventDark: () => useEventDark,
48
+ useEventTint: () => useEventTint
49
+ });
50
+ module.exports = __toCommonJS(eventTint_exports);
51
+ var Colors = __toESM(require("@tamagui/colors"));
52
+ var import_theme = require("@multiplatform.one/theme");
53
+ var import_tamagui = require("tamagui");
54
+ const EVENT_BAR_PX = 3;
55
+ const EVENT_GRIP_DOT_PX = 10;
56
+ const eventTints = {
57
+ light: {
58
+ rest: .22,
59
+ selected: .38,
60
+ ghost: .13
61
+ },
62
+ dark: {
63
+ rest: .4,
64
+ selected: .5,
65
+ ghost: .24
66
+ }
67
+ };
68
+ const eventRampSteps = {
69
+ rest: 6,
70
+ selected: 7
71
+ };
72
+ const EVENT_GHOST_DARK = .6;
73
+ const EVENT_STRIP_STEP = 11;
74
+ const EVENT_STRIP_FLOOR = 3;
75
+ const contrast = (a, b) => (0, import_theme.contrastRatio)((0, import_theme.relativeLuminance)(a), (0, import_theme.relativeLuminance)(b));
76
+ function eventTintFor(themeName) {
77
+ return eventTints[(0, import_theme.isDarkThemeName)(themeName) ? "dark" : "light"];
78
+ }
79
+ function useEventTint() {
80
+ return eventTintFor((0, import_tamagui.useThemeName)());
81
+ }
82
+ function useEventDark() {
83
+ return (0, import_theme.isDarkThemeName)((0, import_tamagui.useThemeName)());
84
+ }
85
+ function themeValue(theme, color) {
86
+ const token = color.startsWith("$");
87
+ const val = theme[token ? color.slice(1) : color]?.val;
88
+ if (typeof val === "string") return val;
89
+ return token ? void 0 : color;
90
+ }
91
+ function blendOver(fill, surface, alpha) {
92
+ const top = (0, import_theme.normalizeToHex)(fill);
93
+ const bottom = (0, import_theme.normalizeToHex)(surface);
94
+ if (!top || !bottom) return null;
95
+ return `#${[
96
+ 1,
97
+ 3,
98
+ 5
99
+ ].map((offset) => {
100
+ const a = Number.parseInt(top.slice(offset, offset + 2), 16);
101
+ const b = Number.parseInt(bottom.slice(offset, offset + 2), 16);
102
+ return Math.round(b + (a - b) * alpha).toString(16).padStart(2, "0");
103
+ }).join("")}`;
104
+ }
105
+ const rampFamilies = /* @__PURE__ */ new Map();
106
+ for (const [name, scale] of Object.entries(Colors)) {
107
+ if (/A$|P3/.test(name)) continue;
108
+ const family = name.replace(/Dark$/, "");
109
+ for (const value of Object.values(scale)) {
110
+ const hex = (0, import_theme.normalizeToHex)(String(value));
111
+ if (hex && !rampFamilies.has(hex)) rampFamilies.set(hex, family);
112
+ }
113
+ }
114
+ function eventRamp(theme, fill, dark) {
115
+ if (/^\$?color-\d+$/.test(fill)) return (step) => themeValue(theme, `color-${step}`);
116
+ const value = themeValue(theme, fill);
117
+ const hex = value ? (0, import_theme.normalizeToHex)(value) : null;
118
+ const family = hex ? rampFamilies.get(hex) : void 0;
119
+ const scale = family ? Colors[dark ? `${family}Dark` : family] : void 0;
120
+ return scale ? (step) => scale[`${family}${step}`] : null;
121
+ }
122
+ function eventPaint(theme, fill, state, { dark, surface = "background" }) {
123
+ const ground = themeValue(theme, surface);
124
+ if (dark) {
125
+ const step = eventRamp(theme, fill, true)?.(eventRampSteps[state === "ghost" ? "rest" : state]);
126
+ const hex = step ? (0, import_theme.normalizeToHex)(step) : null;
127
+ if (hex && state !== "ghost") return hex;
128
+ const ghost = hex && ground ? blendOver(hex, ground, EVENT_GHOST_DARK) : null;
129
+ if (ghost) return ghost;
130
+ }
131
+ const value = themeValue(theme, fill);
132
+ if (!value || !ground) return null;
133
+ if (dark || state === "ghost") return blendOver(value, ground, eventTints[dark ? "dark" : "light"][state]);
134
+ const strip = eventRamp(theme, fill, false)?.(EVENT_STRIP_STEP);
135
+ const stripHex = strip ? (0, import_theme.normalizeToHex)(strip) : null;
136
+ const clears = (paint) => paint !== null && (!stripHex || contrast(stripHex, paint) >= EVENT_STRIP_FLOOR);
137
+ const { rest, selected } = eventTints.light;
138
+ const restPaint = blendOver(value, ground, rest);
139
+ if (clears(restPaint)) {
140
+ if (state === "rest") return restPaint;
141
+ for (let percent = Math.round(selected * 100); percent > Math.round(rest * 100); percent--) {
142
+ const paint = blendOver(value, ground, percent / 100);
143
+ if (clears(paint)) return paint;
144
+ }
145
+ return restPaint;
146
+ }
147
+ const lightened = lightenedRest(value, ground, clears);
148
+ return lightened ? lightened[state] : restPaint;
149
+ }
150
+ const EVENT_REST_STANDOFF = 1.2;
151
+ function lightenedRest(value, ground, clears) {
152
+ const canvas = (0, import_theme.normalizeToHex)(ground);
153
+ if (!canvas) return null;
154
+ for (let percent = Math.round(eventTints.light.rest * 100) - 1; percent > 1; percent--) {
155
+ const selected = blendOver(value, ground, percent / 100);
156
+ if (!clears(selected)) continue;
157
+ const rest = blendOver(value, ground, (percent - 1) / 100);
158
+ if (!rest || contrast(rest, canvas) < EVENT_REST_STANDOFF) return null;
159
+ return {
160
+ rest,
161
+ selected
162
+ };
163
+ }
164
+ return null;
165
+ }
166
+ const labelHolds = (label, fill) => contrast(label, fill) >= import_theme.aaTextContrastRatio && Math.abs((0, import_theme.apcaContrast)(label, fill)) >= import_theme.fillLabelLc;
167
+ const EVENT_SOLID_SELECTED = .1;
168
+ function eventSolid(theme, fill, state) {
169
+ const [paper, anchor] = ["color-1", "color-12"].map((token) => {
170
+ const value2 = themeValue(theme, token);
171
+ return value2 ? (0, import_theme.normalizeToHex)(value2) : null;
172
+ });
173
+ const value = themeValue(theme, fill);
174
+ const solid = value ? (0, import_theme.normalizeToHex)(value) : null;
175
+ if (!paper || !anchor || !solid) return null;
176
+ const hueInk = eventRamp(theme, fill, false)?.(12);
177
+ const dark = hueInk && (0, import_theme.normalizeToHex)(hueInk) || anchor;
178
+ const ink = Math.abs((0, import_theme.apcaContrast)(paper, solid)) >= Math.abs((0, import_theme.apcaContrast)(dark, solid)) ? paper : dark;
179
+ const far = ink === paper ? anchor : paper;
180
+ const rest = Array.from({ length: 13 }, (_, step) => blendOver(far, solid, step / 20)).find((paint) => paint !== null && labelHolds(ink, paint));
181
+ if (!rest) return {
182
+ paint: solid,
183
+ ink: (0, import_theme.normalizeToHex)((0, import_theme.holdInkFloor)(solid, ink)) ?? ink
184
+ };
185
+ if (state === "rest") return {
186
+ paint: rest,
187
+ ink
188
+ };
189
+ const selected = [anchor, paper].map((toward) => blendOver(toward, rest, EVENT_SOLID_SELECTED)).find((paint) => paint !== null && labelHolds(ink, paint));
190
+ return {
191
+ paint: selected ?? rest,
192
+ ink
193
+ };
194
+ }
195
+ function eventStripPaint(theme, fill, { dark, surface }) {
196
+ const step = eventRamp(theme, fill, dark)?.(EVENT_STRIP_STEP);
197
+ const hex = step ? (0, import_theme.normalizeToHex)(step) : null;
198
+ if (hex) return hex;
199
+ const value = themeValue(theme, fill);
200
+ const solid = value ? (0, import_theme.normalizeToHex)(value) : null;
201
+ if (!solid) return null;
202
+ const ink = themeValue(theme, "color-12");
203
+ const paints = ["rest", "selected"].map((state) => eventPaint(theme, fill, state, {
204
+ dark,
205
+ surface
206
+ })).filter((paint) => paint !== null);
207
+ const candidates = [solid, ...ink ? [.35, .6].map((mix) => blendOver(solid, ink, mix)) : []].filter((candidate) => candidate !== null);
208
+ return candidates.find((candidate) => paints.every((paint) => contrast(candidate, paint) >= EVENT_STRIP_FLOOR)) ?? candidates.at(-1) ?? null;
209
+ }
210
+ function eventInk(theme, grounds, preferred = "color-12") {
211
+ const preferredValue = themeValue(theme, preferred);
212
+ if (!preferredValue) return preferred;
213
+ const paper = themeValue(theme, "color-1");
214
+ const ink = themeValue(theme, "color-12");
215
+ let replacement;
216
+ for (const ground of grounds) {
217
+ if (!ground) continue;
218
+ const resolved = (0, import_theme.resolveLegibleInkOn)({
219
+ fill: ground,
220
+ preferred: preferredValue,
221
+ paper,
222
+ ink
223
+ });
224
+ if (resolved && resolved !== preferredValue) replacement = resolved;
225
+ }
226
+ return replacement ?? preferred;
227
+ }
228
+ function eventLabelInk(theme, fill, grounds, dark, tone = "primary") {
229
+ const ramp = eventRamp(theme, fill, dark);
230
+ const [dim, full] = [11, 12].map((step) => {
231
+ const value = ramp?.(step);
232
+ return value ? (0, import_theme.normalizeToHex)(value) : null;
233
+ });
234
+ const grounded = grounds.map((ground) => ground ? (0, import_theme.normalizeToHex)(ground) : null).filter((hex) => hex !== null);
235
+ const reads = (ink) => grounded.every((ground) => contrast(ink, ground) >= import_theme.aaTextContrastRatio);
236
+ if (full && tone === "secondary" && dim) for (let percent = 0; percent < 100; percent++) {
237
+ const ink = blendOver(full, dim, percent / 100);
238
+ if (ink && reads(ink)) return ink;
239
+ }
240
+ if (full && reads(full)) return full;
241
+ return eventInk(theme, grounds, full ?? (tone === "secondary" ? "color-11" : "color-12"));
242
+ }
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name2 in all) __defProp(target, name2, {
11
+ get: all[name2],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var eventTint_exports = {};
30
+ __export(eventTint_exports, {
31
+ EVENT_BAR_PX: () => EVENT_BAR_PX,
32
+ EVENT_GHOST_DARK: () => EVENT_GHOST_DARK,
33
+ EVENT_GRIP_DOT_PX: () => EVENT_GRIP_DOT_PX,
34
+ EVENT_REST_STANDOFF: () => EVENT_REST_STANDOFF,
35
+ EVENT_SOLID_SELECTED: () => EVENT_SOLID_SELECTED,
36
+ EVENT_STRIP_FLOOR: () => EVENT_STRIP_FLOOR,
37
+ EVENT_STRIP_STEP: () => EVENT_STRIP_STEP,
38
+ blendOver: () => blendOver,
39
+ eventInk: () => eventInk,
40
+ eventLabelInk: () => eventLabelInk,
41
+ eventPaint: () => eventPaint,
42
+ eventRamp: () => eventRamp,
43
+ eventRampSteps: () => eventRampSteps,
44
+ eventSolid: () => eventSolid,
45
+ eventStripPaint: () => eventStripPaint,
46
+ eventTintFor: () => eventTintFor,
47
+ eventTints: () => eventTints,
48
+ themeValue: () => themeValue,
49
+ useEventDark: () => useEventDark,
50
+ useEventTint: () => useEventTint
51
+ });
52
+ module.exports = __toCommonJS(eventTint_exports);
53
+ var Colors = __toESM(require("@tamagui/colors"));
54
+ var import_theme = require("@multiplatform.one/theme");
55
+ var import_tamagui = require("tamagui");
56
+ var EVENT_BAR_PX = 3;
57
+ var EVENT_GRIP_DOT_PX = 10;
58
+ var eventTints = {
59
+ light: {
60
+ rest: .22,
61
+ selected: .38,
62
+ ghost: .13
63
+ },
64
+ dark: {
65
+ rest: .4,
66
+ selected: .5,
67
+ ghost: .24
68
+ }
69
+ };
70
+ var eventRampSteps = {
71
+ rest: 6,
72
+ selected: 7
73
+ };
74
+ var EVENT_GHOST_DARK = .6;
75
+ var EVENT_STRIP_STEP = 11;
76
+ var EVENT_STRIP_FLOOR = 3;
77
+ var contrast = function contrast2(a, b) {
78
+ return (0, import_theme.contrastRatio)((0, import_theme.relativeLuminance)(a), (0, import_theme.relativeLuminance)(b));
79
+ };
80
+ function eventTintFor(themeName) {
81
+ return eventTints[(0, import_theme.isDarkThemeName)(themeName) ? "dark" : "light"];
82
+ }
83
+ function useEventTint() {
84
+ return eventTintFor((0, import_tamagui.useThemeName)());
85
+ }
86
+ function useEventDark() {
87
+ return (0, import_theme.isDarkThemeName)((0, import_tamagui.useThemeName)());
88
+ }
89
+ function themeValue(theme, color) {
90
+ var _theme_;
91
+ var token = color.startsWith("$");
92
+ var val = (_theme_ = theme[token ? color.slice(1) : color]) === null || _theme_ === void 0 ? void 0 : _theme_.val;
93
+ if (typeof val === "string") return val;
94
+ return token ? void 0 : color;
95
+ }
96
+ function blendOver(fill, surface, alpha) {
97
+ var top = (0, import_theme.normalizeToHex)(fill);
98
+ var bottom = (0, import_theme.normalizeToHex)(surface);
99
+ if (!top || !bottom) return null;
100
+ return `#${[
101
+ 1,
102
+ 3,
103
+ 5
104
+ ].map(function(offset) {
105
+ var a = Number.parseInt(top.slice(offset, offset + 2), 16);
106
+ var b = Number.parseInt(bottom.slice(offset, offset + 2), 16);
107
+ return Math.round(b + (a - b) * alpha).toString(16).padStart(2, "0");
108
+ }).join("")}`;
109
+ }
110
+ var rampFamilies = /* @__PURE__ */ new Map();
111
+ var _iteratorNormalCompletion = true;
112
+ var _didIteratorError = false;
113
+ var _iteratorError = void 0;
114
+ try {
115
+ for (var _iterator = Object.entries(Colors)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
116
+ var [name, scale] = _step.value;
117
+ if (/A$|P3/.test(name)) continue;
118
+ var family = name.replace(/Dark$/, "");
119
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
120
+ try {
121
+ for (var _iterator1 = Object.values(scale)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
122
+ var value = _step1.value;
123
+ var hex = (0, import_theme.normalizeToHex)(String(value));
124
+ if (hex && !rampFamilies.has(hex)) rampFamilies.set(hex, family);
125
+ }
126
+ } catch (err) {
127
+ _didIteratorError1 = true;
128
+ _iteratorError1 = err;
129
+ } finally {
130
+ try {
131
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
132
+ _iterator1.return();
133
+ }
134
+ } finally {
135
+ if (_didIteratorError1) {
136
+ throw _iteratorError1;
137
+ }
138
+ }
139
+ }
140
+ }
141
+ } catch (err) {
142
+ _didIteratorError = true;
143
+ _iteratorError = err;
144
+ } finally {
145
+ try {
146
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
147
+ _iterator.return();
148
+ }
149
+ } finally {
150
+ if (_didIteratorError) {
151
+ throw _iteratorError;
152
+ }
153
+ }
154
+ }
155
+ function eventRamp(theme, fill, dark) {
156
+ if (/^\$?color-\d+$/.test(fill)) return function(step) {
157
+ return themeValue(theme, `color-${step}`);
158
+ };
159
+ var value2 = themeValue(theme, fill);
160
+ var hex2 = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
161
+ var family2 = hex2 ? rampFamilies.get(hex2) : void 0;
162
+ var scale2 = family2 ? Colors[dark ? `${family2}Dark` : family2] : void 0;
163
+ return scale2 ? function(step) {
164
+ return scale2[`${family2}${step}`];
165
+ } : null;
166
+ }
167
+ function eventPaint(theme, fill, state, param) {
168
+ var { dark, surface = "background" } = param;
169
+ var _eventRamp;
170
+ var ground = themeValue(theme, surface);
171
+ if (dark) {
172
+ var _eventRamp1;
173
+ var step = (_eventRamp1 = eventRamp(theme, fill, true)) === null || _eventRamp1 === void 0 ? void 0 : _eventRamp1(eventRampSteps[state === "ghost" ? "rest" : state]);
174
+ var hex2 = step ? (0, import_theme.normalizeToHex)(step) : null;
175
+ if (hex2 && state !== "ghost") return hex2;
176
+ var ghost = hex2 && ground ? blendOver(hex2, ground, EVENT_GHOST_DARK) : null;
177
+ if (ghost) return ghost;
178
+ }
179
+ var value2 = themeValue(theme, fill);
180
+ if (!value2 || !ground) return null;
181
+ if (dark || state === "ghost") return blendOver(value2, ground, eventTints[dark ? "dark" : "light"][state]);
182
+ var strip = (_eventRamp = eventRamp(theme, fill, false)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(EVENT_STRIP_STEP);
183
+ var stripHex = strip ? (0, import_theme.normalizeToHex)(strip) : null;
184
+ var clears = function clears2(paint2) {
185
+ return paint2 !== null && (!stripHex || contrast(stripHex, paint2) >= EVENT_STRIP_FLOOR);
186
+ };
187
+ var { rest, selected } = eventTints.light;
188
+ var restPaint = blendOver(value2, ground, rest);
189
+ if (clears(restPaint)) {
190
+ if (state === "rest") return restPaint;
191
+ for (var percent = Math.round(selected * 100); percent > Math.round(rest * 100); percent--) {
192
+ var paint = blendOver(value2, ground, percent / 100);
193
+ if (clears(paint)) return paint;
194
+ }
195
+ return restPaint;
196
+ }
197
+ var lightened = lightenedRest(value2, ground, clears);
198
+ return lightened ? lightened[state] : restPaint;
199
+ }
200
+ var EVENT_REST_STANDOFF = 1.2;
201
+ function lightenedRest(value2, ground, clears) {
202
+ var canvas = (0, import_theme.normalizeToHex)(ground);
203
+ if (!canvas) return null;
204
+ for (var percent = Math.round(eventTints.light.rest * 100) - 1; percent > 1; percent--) {
205
+ var selected = blendOver(value2, ground, percent / 100);
206
+ if (!clears(selected)) continue;
207
+ var rest = blendOver(value2, ground, (percent - 1) / 100);
208
+ if (!rest || contrast(rest, canvas) < EVENT_REST_STANDOFF) return null;
209
+ return {
210
+ rest,
211
+ selected
212
+ };
213
+ }
214
+ return null;
215
+ }
216
+ var labelHolds = function labelHolds2(label, fill) {
217
+ return contrast(label, fill) >= import_theme.aaTextContrastRatio && Math.abs((0, import_theme.apcaContrast)(label, fill)) >= import_theme.fillLabelLc;
218
+ };
219
+ var EVENT_SOLID_SELECTED = .1;
220
+ function eventSolid(theme, fill, state) {
221
+ var _normalizeToHex;
222
+ var _eventRamp;
223
+ var [paper, anchor] = ["color-1", "color-12"].map(function(token) {
224
+ var value3 = themeValue(theme, token);
225
+ return value3 ? (0, import_theme.normalizeToHex)(value3) : null;
226
+ });
227
+ var value2 = themeValue(theme, fill);
228
+ var solid = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
229
+ if (!paper || !anchor || !solid) return null;
230
+ var hueInk = (_eventRamp = eventRamp(theme, fill, false)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(12);
231
+ var dark = hueInk && (0, import_theme.normalizeToHex)(hueInk) || anchor;
232
+ var ink = Math.abs((0, import_theme.apcaContrast)(paper, solid)) >= Math.abs((0, import_theme.apcaContrast)(dark, solid)) ? paper : dark;
233
+ var far = ink === paper ? anchor : paper;
234
+ var rest = Array.from({ length: 13 }, function(_, step) {
235
+ return blendOver(far, solid, step / 20);
236
+ }).find(function(paint) {
237
+ return paint !== null && labelHolds(ink, paint);
238
+ });
239
+ if (!rest) return {
240
+ paint: solid,
241
+ ink: (_normalizeToHex = (0, import_theme.normalizeToHex)((0, import_theme.holdInkFloor)(solid, ink))) !== null && _normalizeToHex !== void 0 ? _normalizeToHex : ink
242
+ };
243
+ if (state === "rest") return {
244
+ paint: rest,
245
+ ink
246
+ };
247
+ var selected = [anchor, paper].map(function(toward) {
248
+ return blendOver(toward, rest, EVENT_SOLID_SELECTED);
249
+ }).find(function(paint) {
250
+ return paint !== null && labelHolds(ink, paint);
251
+ });
252
+ return {
253
+ paint: selected !== null && selected !== void 0 ? selected : rest,
254
+ ink
255
+ };
256
+ }
257
+ function eventStripPaint(theme, fill, param) {
258
+ var { dark, surface } = param;
259
+ var _ref, _candidates_find;
260
+ var _eventRamp;
261
+ var step = (_eventRamp = eventRamp(theme, fill, dark)) === null || _eventRamp === void 0 ? void 0 : _eventRamp(EVENT_STRIP_STEP);
262
+ var hex2 = step ? (0, import_theme.normalizeToHex)(step) : null;
263
+ if (hex2) return hex2;
264
+ var value2 = themeValue(theme, fill);
265
+ var solid = value2 ? (0, import_theme.normalizeToHex)(value2) : null;
266
+ if (!solid) return null;
267
+ var ink = themeValue(theme, "color-12");
268
+ var paints = ["rest", "selected"].map(function(state) {
269
+ return eventPaint(theme, fill, state, {
270
+ dark,
271
+ surface
272
+ });
273
+ }).filter(function(paint) {
274
+ return paint !== null;
275
+ });
276
+ var candidates = [solid, ...ink ? [.35, .6].map(function(mix) {
277
+ return blendOver(solid, ink, mix);
278
+ }) : []].filter(function(candidate) {
279
+ return candidate !== null;
280
+ });
281
+ return (_ref = (_candidates_find = candidates.find(function(candidate) {
282
+ return paints.every(function(paint) {
283
+ return contrast(candidate, paint) >= EVENT_STRIP_FLOOR;
284
+ });
285
+ })) !== null && _candidates_find !== void 0 ? _candidates_find : candidates.at(-1)) !== null && _ref !== void 0 ? _ref : null;
286
+ }
287
+ function eventInk(theme, grounds) {
288
+ var preferred = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "color-12";
289
+ var preferredValue = themeValue(theme, preferred);
290
+ if (!preferredValue) return preferred;
291
+ var paper = themeValue(theme, "color-1");
292
+ var ink = themeValue(theme, "color-12");
293
+ var replacement;
294
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
295
+ try {
296
+ for (var _iterator2 = grounds[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
297
+ var ground = _step2.value;
298
+ if (!ground) continue;
299
+ var resolved = (0, import_theme.resolveLegibleInkOn)({
300
+ fill: ground,
301
+ preferred: preferredValue,
302
+ paper,
303
+ ink
304
+ });
305
+ if (resolved && resolved !== preferredValue) replacement = resolved;
306
+ }
307
+ } catch (err) {
308
+ _didIteratorError2 = true;
309
+ _iteratorError2 = err;
310
+ } finally {
311
+ try {
312
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
313
+ _iterator2.return();
314
+ }
315
+ } finally {
316
+ if (_didIteratorError2) {
317
+ throw _iteratorError2;
318
+ }
319
+ }
320
+ }
321
+ return replacement !== null && replacement !== void 0 ? replacement : preferred;
322
+ }
323
+ function eventLabelInk(theme, fill, grounds, dark) {
324
+ var tone = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : "primary";
325
+ var ramp = eventRamp(theme, fill, dark);
326
+ var [dim, full] = [11, 12].map(function(step) {
327
+ var value2 = ramp === null || ramp === void 0 ? void 0 : ramp(step);
328
+ return value2 ? (0, import_theme.normalizeToHex)(value2) : null;
329
+ });
330
+ var grounded = grounds.map(function(ground) {
331
+ return ground ? (0, import_theme.normalizeToHex)(ground) : null;
332
+ }).filter(function(hex2) {
333
+ return hex2 !== null;
334
+ });
335
+ var reads = function reads2(ink2) {
336
+ return grounded.every(function(ground) {
337
+ return contrast(ink2, ground) >= import_theme.aaTextContrastRatio;
338
+ });
339
+ };
340
+ if (full && tone === "secondary" && dim) for (var percent = 0; percent < 100; percent++) {
341
+ var ink = blendOver(full, dim, percent / 100);
342
+ if (ink && reads(ink)) return ink;
343
+ }
344
+ if (full && reads(full)) return full;
345
+ return eventInk(theme, grounds, full !== null && full !== void 0 ? full : tone === "secondary" ? "color-11" : "color-12");
346
+ }