@marktiderman/genesis-ui-native 3.10.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +69 -0
  2. package/dist/{chunk-ZUR4PK77.js → chunk-47CDRP43.js} +45 -166
  3. package/dist/chunk-47CDRP43.js.map +1 -0
  4. package/dist/{chunk-SG7LYX7Z.js → chunk-BQYT6TH2.js} +14 -6
  5. package/dist/chunk-BQYT6TH2.js.map +1 -0
  6. package/dist/{chunk-EAHK7D7N.js → chunk-C2ARUGT7.js} +146 -42
  7. package/dist/chunk-C2ARUGT7.js.map +1 -0
  8. package/dist/{chunk-VEWSY4TZ.js → chunk-D4UU6KIF.js} +236 -21
  9. package/dist/chunk-D4UU6KIF.js.map +1 -0
  10. package/dist/{chunk-GGH3ZQNO.js → chunk-TUDJDIGC.js} +4 -4
  11. package/dist/{chunk-GGH3ZQNO.js.map → chunk-TUDJDIGC.js.map} +1 -1
  12. package/dist/{chunk-PMS2V46D.js → chunk-VHUUOH46.js} +2 -2
  13. package/dist/{chunk-PMS2V46D.js.map → chunk-VHUUOH46.js.map} +1 -1
  14. package/dist/{chunk-IWWXERKQ.js → chunk-X5CPLUPZ.js} +1236 -136
  15. package/dist/chunk-X5CPLUPZ.js.map +1 -0
  16. package/dist/components/index.d.ts +510 -25
  17. package/dist/components/index.js +5 -5
  18. package/dist/data/index.d.ts +176 -34
  19. package/dist/data/index.js +1312 -985
  20. package/dist/data/index.js.map +1 -1
  21. package/dist/hooks/index.d.ts +2 -2
  22. package/dist/hooks/index.js +1 -1
  23. package/dist/icons/lucide.d.ts +1 -1
  24. package/dist/index.d.ts +6 -3
  25. package/dist/index.js +7 -7
  26. package/dist/layouts/index.d.ts +79 -6
  27. package/dist/layouts/index.js +5 -5
  28. package/dist/{native-modules-Bkm1jHO-.d.ts → native-modules-6JnyeGR-.d.ts} +55 -1
  29. package/package.json +70 -4
  30. package/src/components/__tests__/combobox.test.tsx +20 -0
  31. package/src/components/__tests__/number-input.test.tsx +112 -1
  32. package/src/components/__tests__/parity-controls.test.tsx +366 -0
  33. package/src/components/__tests__/parity-display.test.tsx +295 -0
  34. package/src/components/__tests__/twin-props.test.tsx +114 -0
  35. package/src/components/badge.tsx +3 -0
  36. package/src/components/button-group.tsx +50 -0
  37. package/src/components/calendar.tsx +183 -0
  38. package/src/components/carousel.tsx +175 -0
  39. package/src/components/chart.tsx +268 -0
  40. package/src/components/chip-group.tsx +34 -14
  41. package/src/components/choice-card.tsx +56 -19
  42. package/src/components/combobox.tsx +6 -5
  43. package/src/components/empty-state.tsx +40 -0
  44. package/src/components/flatten-children.ts +13 -0
  45. package/src/components/index.ts +49 -1
  46. package/src/components/inline-alert.tsx +3 -1
  47. package/src/components/input-group.tsx +99 -0
  48. package/src/components/input-otp.tsx +124 -0
  49. package/src/components/input.tsx +40 -12
  50. package/src/components/list-item.tsx +20 -4
  51. package/src/components/number-input.tsx +45 -15
  52. package/src/components/radio-group.tsx +5 -0
  53. package/src/components/resource.tsx +227 -0
  54. package/src/components/settings-row.tsx +194 -0
  55. package/src/components/slider.tsx +3 -9
  56. package/src/components/sortable-list.tsx +287 -0
  57. package/src/components/stat-card.tsx +106 -0
  58. package/src/components/stepper.tsx +4 -2
  59. package/src/components/widget-tile.tsx +66 -0
  60. package/src/components/workspace-switcher.tsx +217 -0
  61. package/src/data/NativeCustomView.tsx +117 -0
  62. package/src/data/NativeFormFields.tsx +312 -0
  63. package/src/data/NativeRecordPeek.tsx +130 -0
  64. package/src/data/NativeResourceFormField.tsx +32 -0
  65. package/src/data/__tests__/parity-data.test.tsx +350 -0
  66. package/src/data/index.ts +13 -0
  67. package/src/data/resource-view/NativeResourceView.tsx +17 -2
  68. package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +8 -0
  69. package/src/data/resource-view/index.ts +1 -0
  70. package/src/data/resource-view/mapping.ts +4 -4
  71. package/src/layouts/__tests__/keyboard-scroll.test.tsx +58 -2
  72. package/src/layouts/__tests__/notifications-page.test.tsx +12 -0
  73. package/src/layouts/index.ts +13 -0
  74. package/src/layouts/keyboard.tsx +22 -2
  75. package/src/layouts/notifications-page.tsx +13 -35
  76. package/src/layouts/pages.tsx +262 -0
  77. package/src/native-modules.tsx +37 -0
  78. package/dist/chunk-EAHK7D7N.js.map +0 -1
  79. package/dist/chunk-IWWXERKQ.js.map +0 -1
  80. package/dist/chunk-SG7LYX7Z.js.map +0 -1
  81. package/dist/chunk-VEWSY4TZ.js.map +0 -1
  82. package/dist/chunk-ZUR4PK77.js.map +0 -1
@@ -1,15 +1,23 @@
1
- import { NativeImage, NativeCheckbox } from './chunk-ZUR4PK77.js';
2
- import { NativeIcon, NativeSheet, NativeText, NativeBadge, NativeButton, buttonTextVariants, NativeSheetScrollView, NativeSkeleton } from './chunk-VEWSY4TZ.js';
3
- import { useGenesisModules, useThemeMode, useMotion, useReducedMotion, useThemeRoles } from './chunk-PMS2V46D.js';
1
+ import { NativeCheckbox, NativeAvatar, NativeCard, NativeSegmentedControl, NativeSwitch, NativeSearchBar } from './chunk-47CDRP43.js';
2
+ import { flattenChildren } from './chunk-BQYT6TH2.js';
3
+ import { NativeIcon, NativeImage, NativeSheet, NativeText, NativeBadge, NativeButton, buttonTextVariants, NativeSheetScrollView, NativeInput, NativeContextMenu, NativeSkeleton, NativeListItem, NativeListItemDivider, NativeSectionListHeader } from './chunk-D4UU6KIF.js';
4
+ import { useGenesisModules, useThemeMode, useMotion, useReducedMotion, useThemeRoles } from './chunk-VHUUOH46.js';
4
5
  import { cn } from './chunk-OHZD7KRO.js';
5
6
  import { View, Text, Platform, AccessibilityInfo, Animated, Pressable, Modal, StatusBar, Dimensions, TextInput, ScrollView, PanResponder, FlatList, Easing, Share } from 'react-native';
6
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
8
  import { MOTION_DURATIONS, MOTION_EASINGS } from '@marktiderman/genesis-design-system/tokens/motion';
8
9
  import { createContext, useState, useEffect, useCallback, useMemo, useRef, useContext, Children, cloneElement, isValidElement } from 'react';
9
10
  import { SafeAreaProvider, SafeAreaInsetsContext, useSafeAreaInsets } from 'react-native-safe-area-context';
11
+ import { clampNumber, canStepNumber, stepNumber, readNumberDraft, stepState, otpSlots, OTP_PATTERN_DIGITS, dayOfDate, monthWeeks, dateOfDay, weekdayDays, carouselOffset, carouselIndex, chartSeriesColor, chartTokenOf, defaultChartToken, chartDomain, chartSummary, dropIndex, moveItem, formatTrend, STATUS_BADGE_TONES, statusBadgeLabel, dayInRange, pickRangeDay, chartPosition, sanitizeOtp, otpComplete, commitNumberDraft, movedAnnouncement, matchesQuery, snapToStep } from '@marktiderman/genesis-core/headless';
10
12
  import { useOptionalTheme } from '@marktiderman/genesis-design-system';
11
13
  import { cva } from 'class-variance-authority';
12
14
  import { splitTabBarItems, TAB_BAR_MAX } from '@marktiderman/genesis-core/navigation';
15
+ import { startOfMonth, addMonths } from '@marktiderman/genesis-core/dates';
16
+ import { nativeThemeDark, nativeThemeLight } from '@marktiderman/genesis-design-system/tokens';
17
+ import { initialsOf } from '@marktiderman/genesis-core/resource-view';
18
+ import { readinessChip } from '@marktiderman/genesis-core/resource';
19
+ import { useWorkspace } from '@marktiderman/genesis-core/hooks';
20
+ import { workspaceHref, DEFAULT_WORKSPACE_KIND_LABELS, WORKSPACE_SWITCHER_SEARCH_THRESHOLD, groupWorkspaces, filterWorkspaces, WORKSPACE_KIND_ORDER, hasWorkspaceBadge, workspaceBadgeLabel, workspaceInitials } from '@marktiderman/genesis-core/workspaces';
13
21
 
14
22
  function NativeHeaderCard({
15
23
  title,
@@ -750,7 +758,7 @@ function NativeAccordionContent({
750
758
  }
751
759
  );
752
760
  }
753
- var defaultFilter = (o, q) => o.label.toLowerCase().includes(q.toLowerCase()) || (o.description?.toLowerCase().includes(q.toLowerCase()) ?? false);
761
+ var defaultFilter = (o, q) => matchesQuery([o.label, o.description], q);
754
762
  function NativeCombobox({
755
763
  options,
756
764
  value,
@@ -825,11 +833,6 @@ function NativeCombobox({
825
833
  ) : null
826
834
  ] });
827
835
  }
828
- function clamp(v, min, max) {
829
- if (min !== void 0 && v < min) return min;
830
- if (max !== void 0 && v > max) return max;
831
- return v;
832
- }
833
836
  function NativeNumberInput({
834
837
  value,
835
838
  onChange,
@@ -837,6 +840,7 @@ function NativeNumberInput({
837
840
  max,
838
841
  step = 1,
839
842
  precision = 0,
843
+ locale,
840
844
  disabled,
841
845
  readOnlyInput,
842
846
  className,
@@ -846,12 +850,25 @@ function NativeNumberInput({
846
850
  const setValue = useCallback(
847
851
  (next) => {
848
852
  if (Number.isNaN(next)) return;
849
- onChange(clamp(next, min, max));
853
+ onChange(clampNumber(next, min, max));
850
854
  },
851
855
  [max, min, onChange]
852
856
  );
853
- const decBlocked = disabled || min !== void 0 && value <= min;
854
- const incBlocked = disabled || max !== void 0 && value >= max;
857
+ const [draft, setDraftState] = useState(null);
858
+ const draftRef = useRef(null);
859
+ const setDraft = (next) => {
860
+ draftRef.current = next;
861
+ setDraftState(next);
862
+ };
863
+ const commit = () => {
864
+ const text = draftRef.current;
865
+ if (text === null) return;
866
+ setDraft(null);
867
+ const typed = commitNumberDraft(text, { min, max, precision, locale });
868
+ if (typed !== null && typed !== value) onChange(typed);
869
+ };
870
+ const decBlocked = disabled || !canStepNumber(value, -1, { min, max });
871
+ const incBlocked = disabled || !canStepNumber(value, 1, { min, max });
855
872
  return /* @__PURE__ */ jsxs(
856
873
  View,
857
874
  {
@@ -870,7 +887,10 @@ function NativeNumberInput({
870
887
  accessibilityRole: "button",
871
888
  accessibilityLabel: "Decrement",
872
889
  disabled: decBlocked,
873
- onPress: () => setValue(value - step),
890
+ onPress: () => {
891
+ setDraft(null);
892
+ setValue(stepNumber(value, -1, { step, min, max }));
893
+ },
874
894
  className: cn(
875
895
  "min-h-[44px] min-w-[44px] items-center justify-center px-3",
876
896
  decBlocked && "opacity-40"
@@ -882,14 +902,18 @@ function NativeNumberInput({
882
902
  TextInput,
883
903
  {
884
904
  testID: testID ? `${testID}-field` : "number-input-field",
885
- value: value.toFixed(precision),
905
+ value: draft ?? value.toFixed(precision),
886
906
  editable: !disabled && !readOnlyInput,
887
907
  keyboardType: "numeric",
888
908
  accessibilityLabel: "Numeric value",
889
909
  onChangeText: (t) => {
890
- const parsed = Number(t.replace(/[^0-9.\-]/g, ""));
891
- setValue(parsed);
910
+ setDraft(t);
911
+ const typed = readNumberDraft(t, { min, max, precision, locale });
912
+ if (typed.ready && typed.value !== null && typed.value !== value) onChange(typed.value);
892
913
  },
914
+ onBlur: commit,
915
+ onEndEditing: commit,
916
+ onSubmitEditing: commit,
893
917
  className: cn(
894
918
  "min-w-[64px] flex-1 border-x border-input bg-background text-center text-base text-foreground",
895
919
  inputClassName
@@ -903,7 +927,10 @@ function NativeNumberInput({
903
927
  accessibilityRole: "button",
904
928
  accessibilityLabel: "Increment",
905
929
  disabled: incBlocked,
906
- onPress: () => setValue(value + step),
930
+ onPress: () => {
931
+ setDraft(null);
932
+ setValue(stepNumber(value, 1, { step, min, max }));
933
+ },
907
934
  className: cn(
908
935
  "min-h-[44px] min-w-[44px] items-center justify-center px-3",
909
936
  incBlocked && "opacity-40"
@@ -930,8 +957,9 @@ function NativeStepper({
930
957
  className: cn("w-full", className),
931
958
  children: [
932
959
  /* @__PURE__ */ jsx(View, { className: "flex-row items-center", children: steps.map((s, i) => {
933
- const isCompleted = i < current;
934
- const isCurrent = i === current;
960
+ const state = stepState(i, current);
961
+ const isCompleted = state === "complete";
962
+ const isCurrent = state === "current";
935
963
  return /* @__PURE__ */ jsxs(View, { className: "flex-1 flex-row items-center", children: [
936
964
  /* @__PURE__ */ jsx(
937
965
  View,
@@ -985,12 +1013,7 @@ function NativeStepper({
985
1013
  }
986
1014
  );
987
1015
  }
988
- function snap(v, step, min, max) {
989
- const clamped = Math.min(max, Math.max(min, v));
990
- if (step <= 0) return clamped;
991
- const stepped = Math.round((clamped - min) / step) * step + min;
992
- return Math.min(max, Math.max(min, stepped));
993
- }
1016
+ var snap = snapToStep;
994
1017
  function useTrackWidth() {
995
1018
  const [width, setWidth] = useState(0);
996
1019
  const onLayout = (e) => {
@@ -1174,29 +1197,32 @@ function NativeChipGroup({
1174
1197
  mode = "multiple",
1175
1198
  value,
1176
1199
  onChange,
1200
+ allowEmpty = false,
1177
1201
  disabled,
1178
1202
  className,
1179
1203
  children,
1180
1204
  testID
1181
1205
  }) {
1206
+ const single = mode === "single";
1182
1207
  const selected = new Set(
1183
- mode === "single" ? typeof value === "string" ? [value] : [] : Array.isArray(value) ? value : []
1208
+ single ? typeof value === "string" && value ? [value] : [] : Array.isArray(value) ? value : []
1184
1209
  );
1210
+ const emit = onChange;
1185
1211
  const toggle = (v) => {
1186
- if (mode === "single") {
1187
- onChange(v);
1212
+ if (single) {
1213
+ emit(selected.has(v) && allowEmpty ? "" : v);
1188
1214
  return;
1189
1215
  }
1190
1216
  const next = new Set(selected);
1191
1217
  if (next.has(v)) next.delete(v);
1192
1218
  else next.add(v);
1193
- onChange(Array.from(next));
1219
+ emit(Array.from(next));
1194
1220
  };
1195
1221
  return /* @__PURE__ */ jsx(ChipContext.Provider, { value: { mode, selected, toggle, disabled }, children: /* @__PURE__ */ jsx(
1196
1222
  View,
1197
1223
  {
1198
1224
  testID: testID ?? "native-chip-group",
1199
- accessibilityRole: mode === "single" ? "radiogroup" : void 0,
1225
+ accessibilityRole: single ? "radiogroup" : void 0,
1200
1226
  className: cn("flex-row flex-wrap gap-2", className),
1201
1227
  children
1202
1228
  }
@@ -1380,46 +1406,6 @@ function NativeTierBadge({ label, tone, icon, size = "md", className, textClassN
1380
1406
  }
1381
1407
  );
1382
1408
  }
1383
- function NativeProgress({
1384
- className,
1385
- value = 0,
1386
- trackClassName,
1387
- indicatorClassName,
1388
- indicatorColor,
1389
- trackColor,
1390
- style,
1391
- indicatorStyle,
1392
- ...props
1393
- }) {
1394
- const safeValue = Number.isFinite(value) ? value : 0;
1395
- const clampedValue = Math.min(100, Math.max(0, safeValue));
1396
- return /* @__PURE__ */ jsx(
1397
- View,
1398
- {
1399
- className: cn(
1400
- "h-2 w-full overflow-hidden rounded-full bg-muted",
1401
- trackClassName,
1402
- className
1403
- ),
1404
- accessibilityRole: "progressbar",
1405
- accessibilityLabel: `${clampedValue}% complete`,
1406
- accessibilityValue: { min: 0, max: 100, now: clampedValue },
1407
- ...props,
1408
- style: trackColor === void 0 ? style : { ...style, backgroundColor: trackColor },
1409
- children: /* @__PURE__ */ jsx(
1410
- View,
1411
- {
1412
- className: cn("h-full rounded-full bg-primary", indicatorClassName),
1413
- style: {
1414
- ...indicatorStyle,
1415
- width: `${clampedValue}%`,
1416
- ...indicatorColor === void 0 ? {} : { backgroundColor: indicatorColor }
1417
- }
1418
- }
1419
- )
1420
- }
1421
- );
1422
- }
1423
1409
  function NativeDialog({ open, onOpenChange, children }) {
1424
1410
  return /* @__PURE__ */ jsx(
1425
1411
  Modal,
@@ -1540,63 +1526,6 @@ function NativeDropdownMenuItem({
1540
1526
  }
1541
1527
  );
1542
1528
  }
1543
- function Indicator({ on, multiple, testID }) {
1544
- return /* @__PURE__ */ jsx(
1545
- View,
1546
- {
1547
- testID,
1548
- className: cn(
1549
- "h-5 w-5 items-center justify-center border",
1550
- multiple ? "rounded" : "rounded-full",
1551
- on ? "border-primary" : "border-input",
1552
- on && multiple && "bg-primary"
1553
- ),
1554
- children: on ? multiple ? /* @__PURE__ */ jsx(Text, { className: "text-xs font-bold text-primary-foreground", children: "\u2713" }) : /* @__PURE__ */ jsx(View, { className: "h-2.5 w-2.5 rounded-full bg-primary" }) : null
1555
- }
1556
- );
1557
- }
1558
- function NativeChoiceCard({
1559
- title,
1560
- description,
1561
- media,
1562
- selected,
1563
- onPress,
1564
- multiple = false,
1565
- disabled = false,
1566
- invalid = false,
1567
- hint,
1568
- className,
1569
- testID = "native-choice-card"
1570
- }) {
1571
- const name = description ? `${title}, ${description}` : title;
1572
- const accessibilityHint = [hint, invalid ? "Needs an answer" : ""].filter(Boolean).join(". ") || void 0;
1573
- return /* @__PURE__ */ jsxs(
1574
- Pressable,
1575
- {
1576
- testID,
1577
- onPress,
1578
- disabled,
1579
- accessibilityRole: multiple ? "checkbox" : "radio",
1580
- accessibilityLabel: name,
1581
- accessibilityHint,
1582
- accessibilityState: { checked: selected, selected, disabled },
1583
- className: cn(
1584
- "min-h-[44px] flex-row items-center gap-3 rounded-lg border bg-card p-3",
1585
- selected ? "border-primary bg-primary/5" : invalid ? "border-destructive" : "border-border",
1586
- disabled && "opacity-50",
1587
- className
1588
- ),
1589
- children: [
1590
- /* @__PURE__ */ jsx(Indicator, { on: selected, multiple, testID: `${testID}-indicator` }),
1591
- media ? /* @__PURE__ */ jsx(View, { testID: `${testID}-media`, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: media }) : null,
1592
- /* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
1593
- /* @__PURE__ */ jsx(Text, { className: "text-base text-foreground", children: title }),
1594
- description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-muted-foreground", children: description }) : null
1595
- ] })
1596
- ]
1597
- }
1598
- );
1599
- }
1600
1529
  var RadioGroupContext = createContext(null);
1601
1530
  function useRadioGroup() {
1602
1531
  const context = useContext(RadioGroupContext);
@@ -1604,6 +1533,9 @@ function useRadioGroup() {
1604
1533
  throw new Error("RadioGroup components must be used within <NativeRadioGroup>");
1605
1534
  return context;
1606
1535
  }
1536
+ function useNativeRadioGroupContext() {
1537
+ return useContext(RadioGroupContext);
1538
+ }
1607
1539
  function NativeRadioGroup({
1608
1540
  className,
1609
1541
  value: controlledValue,
@@ -1646,6 +1578,61 @@ function NativeRadioGroupItem({
1646
1578
  }
1647
1579
  );
1648
1580
  }
1581
+ function Indicator({ on, multiple, testID }) {
1582
+ return /* @__PURE__ */ jsx(
1583
+ View,
1584
+ {
1585
+ testID,
1586
+ className: cn(
1587
+ "h-5 w-5 items-center justify-center border",
1588
+ multiple ? "rounded" : "rounded-full",
1589
+ on ? "border-primary" : "border-input",
1590
+ on && multiple && "bg-primary"
1591
+ ),
1592
+ children: on ? multiple ? /* @__PURE__ */ jsx(Text, { className: "text-xs font-bold text-primary-foreground", children: "\u2713" }) : /* @__PURE__ */ jsx(View, { className: "h-2.5 w-2.5 rounded-full bg-primary" }) : null
1593
+ }
1594
+ );
1595
+ }
1596
+ function NativeChoiceCard(props) {
1597
+ const { title, description, media, disabled = false, invalid = false, hint, className, testID = "native-choice-card" } = props;
1598
+ const group = useNativeRadioGroupContext();
1599
+ if (props.value !== void 0 && !group) throw new Error("A NativeChoiceCard with a `value` must be inside <NativeRadioGroup>.");
1600
+ const multiple = props.multiple === true;
1601
+ const selected = props.value !== void 0 ? group.value === props.value : props.selected;
1602
+ const onPress = () => {
1603
+ if (props.value !== void 0) group.onValueChange(props.value);
1604
+ else if (props.onSelectedChange) props.onSelectedChange(!props.selected);
1605
+ else props.onPress?.();
1606
+ };
1607
+ const name = description ? `${title}, ${description}` : title;
1608
+ const accessibilityHint = [hint, invalid ? "Needs an answer" : ""].filter(Boolean).join(". ") || void 0;
1609
+ return /* @__PURE__ */ jsxs(
1610
+ Pressable,
1611
+ {
1612
+ testID,
1613
+ onPress,
1614
+ disabled,
1615
+ accessibilityRole: multiple ? "checkbox" : "radio",
1616
+ accessibilityLabel: name,
1617
+ accessibilityHint,
1618
+ accessibilityState: { checked: selected, selected, disabled },
1619
+ className: cn(
1620
+ "min-h-[44px] flex-row items-center gap-3 rounded-lg border bg-card p-3",
1621
+ selected ? "border-primary bg-primary/5" : invalid ? "border-destructive" : "border-border",
1622
+ disabled && "opacity-50",
1623
+ className
1624
+ ),
1625
+ children: [
1626
+ /* @__PURE__ */ jsx(Indicator, { on: selected, multiple, testID: `${testID}-indicator` }),
1627
+ media ? /* @__PURE__ */ jsx(View, { testID: `${testID}-media`, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: media }) : null,
1628
+ /* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
1629
+ /* @__PURE__ */ jsx(Text, { className: "text-base text-foreground", children: title }),
1630
+ description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-muted-foreground", children: description }) : null
1631
+ ] })
1632
+ ]
1633
+ }
1634
+ );
1635
+ }
1649
1636
  var TabsContext = createContext(null);
1650
1637
  function useTabs() {
1651
1638
  const context = useContext(TabsContext);
@@ -2119,7 +2106,7 @@ function lightboxTouchDistance(touches) {
2119
2106
  function lightboxPanLimit(scale, size) {
2120
2107
  return Math.max(0, (scale - 1) * size / 2);
2121
2108
  }
2122
- var clamp2 = (v, limit) => Math.max(-limit, Math.min(limit, v));
2109
+ var clamp = (v, limit) => Math.max(-limit, Math.min(limit, v));
2123
2110
  function NativeZoomablePhoto(props) {
2124
2111
  return Platform.OS === "ios" ? /* @__PURE__ */ jsx(ZoomableIos, { ...props }) : /* @__PURE__ */ jsx(ZoomablePan, { ...props });
2125
2112
  }
@@ -2233,8 +2220,8 @@ function ZoomablePan({ src, cacheKey, alt, width, height, active, onZoomChange,
2233
2220
  const z = 2.5;
2234
2221
  settle({
2235
2222
  scale: z,
2236
- x: clamp2((width / 2 - at.locationX) * (z - 1), lightboxPanLimit(z, width)),
2237
- y: clamp2((height / 2 - at.locationY) * (z - 1), lightboxPanLimit(z, height))
2223
+ x: clamp((width / 2 - at.locationX) * (z - 1), lightboxPanLimit(z, width)),
2224
+ y: clamp((height / 2 - at.locationY) * (z - 1), lightboxPanLimit(z, height))
2238
2225
  });
2239
2226
  });
2240
2227
  const responder = useMemo(
@@ -2272,8 +2259,8 @@ function ZoomablePan({ src, cacheKey, alt, width, height, active, onZoomChange,
2272
2259
  return;
2273
2260
  }
2274
2261
  if (st.scale > 1.01) {
2275
- st.x = clamp2(st.startX + g.dx, lightboxPanLimit(st.scale, width));
2276
- st.y = clamp2(st.startY + g.dy, lightboxPanLimit(st.scale, height));
2262
+ st.x = clamp(st.startX + g.dx, lightboxPanLimit(st.scale, width));
2263
+ st.y = clamp(st.startY + g.dy, lightboxPanLimit(st.scale, height));
2277
2264
  tx.setValue(st.x);
2278
2265
  ty.setValue(st.y);
2279
2266
  }
@@ -2288,7 +2275,7 @@ function ZoomablePan({ src, cacheKey, alt, width, height, active, onZoomChange,
2288
2275
  }
2289
2276
  st.pinching = false;
2290
2277
  const z = Math.max(1, st.scale);
2291
- settle({ scale: z, x: clamp2(st.x, lightboxPanLimit(z, width)), y: clamp2(st.y, lightboxPanLimit(z, height)) });
2278
+ settle({ scale: z, x: clamp(st.x, lightboxPanLimit(z, width)), y: clamp(st.y, lightboxPanLimit(z, height)) });
2292
2279
  },
2293
2280
  onPanResponderTerminate: () => {
2294
2281
  onPull?.(0);
@@ -2847,7 +2834,1120 @@ function NativeWhatsNewSheet({
2847
2834
  /* @__PURE__ */ jsx(NativeButton, { onPress: dismiss, testID: `${testID}-done`, children: doneLabel })
2848
2835
  ] }) });
2849
2836
  }
2837
+ var CORNERS = {
2838
+ horizontal: { first: "rounded-r-none", last: "rounded-l-none", middle: "rounded-none", join: "-ml-px" },
2839
+ vertical: { first: "rounded-b-none", last: "rounded-t-none", middle: "rounded-none", join: "-mt-px" }
2840
+ };
2841
+ function NativeButtonGroup({ orientation = "horizontal", children, accessibilityLabel, className, testID }) {
2842
+ const items = Children.toArray(children).filter(isValidElement);
2843
+ const c = CORNERS[orientation];
2844
+ return /* @__PURE__ */ jsx(
2845
+ View,
2846
+ {
2847
+ testID: testID ?? "native-button-group",
2848
+ accessibilityRole: "toolbar",
2849
+ accessibilityLabel,
2850
+ className: cn(orientation === "horizontal" ? "flex-row self-start" : "flex-col self-start", className),
2851
+ children: items.map((child, i) => {
2852
+ if (items.length === 1) return child;
2853
+ const first = i === 0;
2854
+ const last = i === items.length - 1;
2855
+ return cloneElement(child, {
2856
+ className: cn(child.props.className, first ? c.first : last ? c.last : c.middle, !first && c.join)
2857
+ });
2858
+ })
2859
+ }
2860
+ );
2861
+ }
2862
+ function NativeInputGroup({ prefix, suffix, ...props }) {
2863
+ const text = (node) => typeof node === "string" || typeof node === "number" ? /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: node }) : node;
2864
+ return /* @__PURE__ */ jsx(NativeInput, { ...props, leading: prefix != null ? text(prefix) : void 0, trailing: suffix != null ? text(suffix) : void 0 });
2865
+ }
2866
+ function NativePasswordToggleField({
2867
+ defaultVisible = false,
2868
+ visible: visibleProp,
2869
+ onVisibleChange,
2870
+ labels = {},
2871
+ testID,
2872
+ onSelectionChange,
2873
+ onChangeText,
2874
+ ...props
2875
+ }) {
2876
+ const [visibleState, setVisibleState] = useState(defaultVisible);
2877
+ const visible = visibleProp ?? visibleState;
2878
+ const selection = useRef(null);
2879
+ const [restore, setRestore] = useState(null);
2880
+ const toggle = () => {
2881
+ if (selection.current) setRestore(selection.current);
2882
+ if (visibleProp === void 0) setVisibleState(!visible);
2883
+ onVisibleChange?.(!visible);
2884
+ };
2885
+ const id = testID ?? "native-password-field";
2886
+ return /* @__PURE__ */ jsx(
2887
+ NativeInput,
2888
+ {
2889
+ autoCapitalize: "none",
2890
+ autoCorrect: false,
2891
+ textContentType: "password",
2892
+ autoComplete: "password",
2893
+ ...props,
2894
+ testID: id,
2895
+ secureTextEntry: !visible,
2896
+ ...restore ? { selection: restore } : {},
2897
+ onSelectionChange: (e) => {
2898
+ selection.current = e.nativeEvent.selection;
2899
+ if (restore && (e.nativeEvent.selection.start !== restore.start || e.nativeEvent.selection.end !== restore.end)) setRestore(null);
2900
+ onSelectionChange?.(e);
2901
+ },
2902
+ onChangeText: (text) => {
2903
+ if (restore) setRestore(null);
2904
+ onChangeText?.(text);
2905
+ },
2906
+ trailing: /* @__PURE__ */ jsx(
2907
+ Pressable,
2908
+ {
2909
+ testID: `${id}-toggle`,
2910
+ accessibilityRole: "button",
2911
+ accessibilityLabel: visible ? labels.hideAccessible ?? "Hide password" : labels.showAccessible ?? "Show password",
2912
+ onPress: toggle,
2913
+ hitSlop: 8,
2914
+ className: "min-h-[36px] min-w-[44px] items-center justify-center px-2",
2915
+ children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-primary-text", children: visible ? labels.hide ?? "Hide" : labels.show ?? "Show" })
2916
+ }
2917
+ )
2918
+ }
2919
+ );
2920
+ }
2921
+ var HIDDEN_BUT_READABLE = 0.011;
2922
+ function NativeInputOTP({
2923
+ maxLength = 6,
2924
+ value,
2925
+ onChange,
2926
+ onComplete,
2927
+ pattern = OTP_PATTERN_DIGITS,
2928
+ separatorAfter = [],
2929
+ disabled,
2930
+ autoFocus,
2931
+ accessibilityLabel = "One-time code",
2932
+ accessibilityHint,
2933
+ className,
2934
+ testID = "native-input-otp"
2935
+ }) {
2936
+ const input = useRef(null);
2937
+ const [focused, setFocused] = useState(false);
2938
+ const digits = pattern === OTP_PATTERN_DIGITS;
2939
+ const slots = otpSlots(value, maxLength, focused);
2940
+ const change = (text) => {
2941
+ const next = sanitizeOtp(text, maxLength, pattern);
2942
+ if (next === null) return;
2943
+ onChange(next);
2944
+ if (otpComplete(next, maxLength) && !otpComplete(value, maxLength)) onComplete?.(next);
2945
+ };
2946
+ return /* @__PURE__ */ jsxs(
2947
+ Pressable,
2948
+ {
2949
+ testID,
2950
+ accessible: false,
2951
+ disabled,
2952
+ onPress: () => input.current?.focus?.(),
2953
+ className: cn("relative flex-row items-center self-start", disabled && "opacity-50", className),
2954
+ children: [
2955
+ slots.map((slot, i) => /* @__PURE__ */ jsxs(View, { className: "flex-row items-center", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: [
2956
+ /* @__PURE__ */ jsx(
2957
+ View,
2958
+ {
2959
+ testID: `${testID}-slot-${i}`,
2960
+ className: cn(
2961
+ "h-12 w-10 items-center justify-center border-y border-r border-input bg-background",
2962
+ (i === 0 || separatorAfter.includes(i - 1)) && "rounded-l-md border-l",
2963
+ (i === maxLength - 1 || separatorAfter.includes(i)) && "rounded-r-md",
2964
+ slot.isActive && "border-2 border-ring"
2965
+ ),
2966
+ children: /* @__PURE__ */ jsx(Text, { className: "text-lg font-medium text-foreground", children: slot.char ?? "" })
2967
+ }
2968
+ ),
2969
+ separatorAfter.includes(i) && i < maxLength - 1 ? /* @__PURE__ */ jsx(Text, { className: "mx-1 text-lg text-muted-foreground", children: "\xB7" }) : null
2970
+ ] }, i)),
2971
+ /* @__PURE__ */ jsx(
2972
+ TextInput,
2973
+ {
2974
+ ref: input,
2975
+ testID: `${testID}-input`,
2976
+ value,
2977
+ onChangeText: change,
2978
+ onFocus: () => setFocused(true),
2979
+ onBlur: () => setFocused(false),
2980
+ editable: !disabled,
2981
+ autoFocus,
2982
+ keyboardType: digits ? "number-pad" : "default",
2983
+ autoCapitalize: "characters",
2984
+ textContentType: "oneTimeCode",
2985
+ autoComplete: digits ? "sms-otp" : "one-time-code",
2986
+ accessibilityLabel,
2987
+ accessibilityHint: accessibilityHint ?? `${maxLength} characters`,
2988
+ caretHidden: true,
2989
+ className: "absolute inset-0 text-transparent",
2990
+ style: { opacity: HIDDEN_BUT_READABLE }
2991
+ }
2992
+ )
2993
+ ]
2994
+ }
2995
+ );
2996
+ }
2997
+ function firstSelected(props) {
2998
+ if (props.mode === "multiple") return props.selected?.[0];
2999
+ if (props.mode === "range") return props.selected?.from;
3000
+ return props.selected;
3001
+ }
3002
+ function NativeCalendar(props) {
3003
+ const { month: monthProp, defaultMonth, onMonthChange, disabled, weekStartsOn = 0, showOutsideDays = true, locale, labels = {}, today = /* @__PURE__ */ new Date(), className, testID = "native-calendar" } = props;
3004
+ const [monthState, setMonthState] = useState(() => startOfMonth(dayOfDate(defaultMonth ?? firstSelected(props) ?? today)));
3005
+ const month = monthProp ? startOfMonth(dayOfDate(monthProp)) : monthState;
3006
+ const weeks = useMemo(() => monthWeeks(month, weekStartsOn), [month, weekStartsOn]);
3007
+ const todayDay = dayOfDate(today);
3008
+ const monthKey = month.slice(0, 7);
3009
+ const fmt = (options) => new Intl.DateTimeFormat(locale, options);
3010
+ const title = fmt({ month: "long", year: "numeric" }).format(dateOfDay(month));
3011
+ const weekdayShort = fmt({ weekday: "short" });
3012
+ const weekdayLong = fmt({ weekday: "long" });
3013
+ const fullDate = fmt({ weekday: "long", day: "numeric", month: "long", year: "numeric" });
3014
+ const go = (delta) => {
3015
+ const next = addMonths(month, delta);
3016
+ if (!monthProp) setMonthState(next);
3017
+ onMonthChange?.(dateOfDay(next));
3018
+ };
3019
+ const isSelected = (day) => {
3020
+ if (props.mode === "multiple") return (props.selected ?? []).some((d) => dayOfDate(d) === day);
3021
+ if (props.mode === "range") {
3022
+ const r = props.selected;
3023
+ return dayInRange(day, { from: r?.from ? dayOfDate(r.from) : void 0, to: r?.to ? dayOfDate(r.to) : void 0 });
3024
+ }
3025
+ return props.selected ? dayOfDate(props.selected) === day : false;
3026
+ };
3027
+ const pick = (day) => {
3028
+ const date = dateOfDay(day);
3029
+ if (props.mode === "multiple") {
3030
+ const current = props.selected ?? [];
3031
+ const has = current.some((d) => dayOfDate(d) === day);
3032
+ props.onSelect?.(has ? current.filter((d) => dayOfDate(d) !== day) : [...current, date]);
3033
+ } else if (props.mode === "range") {
3034
+ const r = props.selected;
3035
+ const next = pickRangeDay(r?.from ? { from: dayOfDate(r.from), to: r.to ? dayOfDate(r.to) : void 0 } : void 0, day);
3036
+ props.onSelect?.({ from: dateOfDay(next.from), to: next.to ? dateOfDay(next.to) : void 0 });
3037
+ } else {
3038
+ const same = props.selected && dayOfDate(props.selected) === day;
3039
+ props.onSelect?.(same ? void 0 : date);
3040
+ }
3041
+ if (day.slice(0, 7) !== monthKey) go(day < month ? -1 : 1);
3042
+ };
3043
+ return /* @__PURE__ */ jsxs(View, { testID, className: cn("w-full gap-2 bg-background p-3", className), children: [
3044
+ /* @__PURE__ */ jsxs(View, { className: "flex-row items-center justify-between", children: [
3045
+ /* @__PURE__ */ jsx(MonthButton, { testID: `${testID}-previous`, label: labels.previousMonth ?? "Previous month", glyph: "\u2039", onPress: () => go(-1) }),
3046
+ /* @__PURE__ */ jsx(Text, { testID: `${testID}-title`, accessibilityRole: "header", accessibilityLiveRegion: "polite", className: "text-sm font-medium text-foreground", children: title }),
3047
+ /* @__PURE__ */ jsx(MonthButton, { testID: `${testID}-next`, label: labels.nextMonth ?? "Next month", glyph: "\u203A", onPress: () => go(1) })
3048
+ ] }),
3049
+ /* @__PURE__ */ jsx(View, { className: "flex-row", children: weekdayDays(weekStartsOn).map((d) => /* @__PURE__ */ jsx(
3050
+ Text,
3051
+ {
3052
+ accessibilityLabel: weekdayLong.format(dateOfDay(d)),
3053
+ className: "flex-1 text-center text-xs text-muted-foreground",
3054
+ children: weekdayShort.format(dateOfDay(d))
3055
+ },
3056
+ d
3057
+ )) }),
3058
+ weeks.map((week) => /* @__PURE__ */ jsx(View, { className: "flex-row", children: week.map((day) => {
3059
+ const outside = day.slice(0, 7) !== monthKey;
3060
+ if (outside && !showOutsideDays) return /* @__PURE__ */ jsx(View, { className: "h-10 flex-1" }, day);
3061
+ const off = disabled?.(dateOfDay(day)) ?? false;
3062
+ const selected = isSelected(day);
3063
+ const isToday = day === todayDay;
3064
+ return /* @__PURE__ */ jsx(
3065
+ Pressable,
3066
+ {
3067
+ testID: `${testID}-day-${day}`,
3068
+ accessibilityRole: "button",
3069
+ accessibilityLabel: fullDate.format(dateOfDay(day)),
3070
+ accessibilityState: { selected, disabled: off },
3071
+ disabled: off,
3072
+ onPress: () => pick(day),
3073
+ className: cn(
3074
+ "m-0.5 h-10 flex-1 items-center justify-center rounded-md",
3075
+ selected && "bg-primary",
3076
+ !selected && isToday && "bg-accent",
3077
+ off && "opacity-40"
3078
+ ),
3079
+ children: /* @__PURE__ */ jsx(
3080
+ Text,
3081
+ {
3082
+ className: cn(
3083
+ "text-sm",
3084
+ selected ? "text-primary-foreground" : outside ? "text-muted-foreground" : "text-foreground",
3085
+ isToday && "font-semibold"
3086
+ ),
3087
+ children: Number(day.slice(8))
3088
+ }
3089
+ )
3090
+ },
3091
+ day
3092
+ );
3093
+ }) }, week[0]))
3094
+ ] });
3095
+ }
3096
+ function MonthButton({ label, glyph, onPress, testID }) {
3097
+ return /* @__PURE__ */ jsx(
3098
+ Pressable,
3099
+ {
3100
+ testID,
3101
+ accessibilityRole: "button",
3102
+ accessibilityLabel: label,
3103
+ onPress,
3104
+ hitSlop: 6,
3105
+ className: "h-11 w-11 items-center justify-center rounded-md",
3106
+ children: /* @__PURE__ */ jsx(Text, { className: "text-xl text-foreground", children: glyph })
3107
+ }
3108
+ );
3109
+ }
3110
+ function NativeCarousel({
3111
+ children,
3112
+ index: indexProp,
3113
+ defaultIndex = 0,
3114
+ onIndexChange,
3115
+ showDots = true,
3116
+ showControls = false,
3117
+ accessibilityLabel,
3118
+ labels = {},
3119
+ className,
3120
+ slideClassName,
3121
+ testID = "native-carousel"
3122
+ }) {
3123
+ const slides = Children.toArray(children);
3124
+ const count = slides.length;
3125
+ const scroll = useRef(null);
3126
+ const [width, setWidth] = useState(0);
3127
+ const [indexState, setIndexState] = useState(defaultIndex);
3128
+ const index = Math.max(0, Math.min(count - 1, indexProp ?? indexState));
3129
+ const slideWords = (i) => (labels.slide ?? "Slide {index} of {count}").replace("{index}", String(i + 1)).replace("{count}", String(count));
3130
+ const settle = (next) => {
3131
+ if (next === index) return;
3132
+ if (indexProp === void 0) setIndexState(next);
3133
+ onIndexChange?.(next);
3134
+ };
3135
+ const scrolledTo = useRef(null);
3136
+ const scrollTo = (x, animated) => {
3137
+ scrolledTo.current = x;
3138
+ scroll.current?.scrollTo?.({ x, animated });
3139
+ };
3140
+ const goTo = (next) => {
3141
+ const target = Math.max(0, Math.min(count - 1, next));
3142
+ scrollTo(carouselOffset(target, width), true);
3143
+ settle(target);
3144
+ };
3145
+ useEffect(() => {
3146
+ if (width <= 0) return;
3147
+ const x = carouselOffset(index, width);
3148
+ if (scrolledTo.current !== x) scrollTo(x, false);
3149
+ }, [index, width]);
3150
+ const navigable = showDots || showControls;
3151
+ return /* @__PURE__ */ jsxs(
3152
+ View,
3153
+ {
3154
+ testID,
3155
+ className: cn("w-full", className),
3156
+ onLayout: (e) => setWidth(e.nativeEvent?.layout?.width ?? 0),
3157
+ children: [
3158
+ /* @__PURE__ */ jsx(
3159
+ ScrollView,
3160
+ {
3161
+ ref: scroll,
3162
+ testID: `${testID}-pages`,
3163
+ horizontal: true,
3164
+ pagingEnabled: true,
3165
+ showsHorizontalScrollIndicator: false,
3166
+ onMomentumScrollEnd: (e) => {
3167
+ scrolledTo.current = e.nativeEvent.contentOffset.x;
3168
+ settle(carouselIndex(e.nativeEvent.contentOffset.x, width, count));
3169
+ },
3170
+ children: slides.map((slide, i) => /* @__PURE__ */ jsx(
3171
+ View,
3172
+ {
3173
+ testID: `${testID}-slide-${i}`,
3174
+ style: width ? { width } : void 0,
3175
+ className: cn("w-full", slideClassName),
3176
+ importantForAccessibility: !navigable || i === index ? "auto" : "no-hide-descendants",
3177
+ accessibilityElementsHidden: navigable && i !== index,
3178
+ children: slide
3179
+ },
3180
+ i
3181
+ ))
3182
+ }
3183
+ ),
3184
+ showDots || showControls ? /* @__PURE__ */ jsxs(View, { className: "mt-3 flex-row items-center justify-center gap-3", children: [
3185
+ showControls ? /* @__PURE__ */ jsx(ArrowButton, { testID: `${testID}-previous`, label: labels.previous ?? "Previous slide", glyph: "\u2039", disabled: index === 0, onPress: () => goTo(index - 1) }) : null,
3186
+ showDots ? (
3187
+ // The page control: one adjustable element, as UIPageControl is; the dots are for touch.
3188
+ /* @__PURE__ */ jsx(
3189
+ View,
3190
+ {
3191
+ testID: `${testID}-dots`,
3192
+ className: "flex-row items-center gap-1.5",
3193
+ accessible: true,
3194
+ accessibilityRole: "adjustable",
3195
+ accessibilityLabel,
3196
+ accessibilityValue: { text: slideWords(index) },
3197
+ accessibilityActions: [{ name: "increment" }, { name: "decrement" }],
3198
+ onAccessibilityAction: (e) => goTo(index + (e.nativeEvent.actionName === "increment" ? 1 : -1)),
3199
+ children: slides.map((_, i) => /* @__PURE__ */ jsx(
3200
+ Pressable,
3201
+ {
3202
+ testID: `${testID}-dot-${i}`,
3203
+ accessible: false,
3204
+ accessibilityLabel: slideWords(i),
3205
+ hitSlop: 8,
3206
+ onPress: () => goTo(i),
3207
+ className: cn("h-2 rounded-full", i === index ? "w-5 bg-primary" : "w-2 bg-muted-foreground/40")
3208
+ },
3209
+ i
3210
+ ))
3211
+ }
3212
+ )
3213
+ ) : null,
3214
+ showControls ? /* @__PURE__ */ jsx(ArrowButton, { testID: `${testID}-next`, label: labels.next ?? "Next slide", glyph: "\u203A", disabled: index >= count - 1, onPress: () => goTo(index + 1) }) : null
3215
+ ] }) : null
3216
+ ]
3217
+ }
3218
+ );
3219
+ }
3220
+ function ArrowButton({ label, glyph, disabled, onPress, testID }) {
3221
+ return /* @__PURE__ */ jsx(
3222
+ Pressable,
3223
+ {
3224
+ testID,
3225
+ accessibilityRole: "button",
3226
+ accessibilityLabel: label,
3227
+ accessibilityState: { disabled },
3228
+ disabled,
3229
+ onPress,
3230
+ className: cn("h-9 w-9 items-center justify-center rounded-full border border-border bg-background", disabled && "opacity-40"),
3231
+ children: /* @__PURE__ */ jsx(Text, { className: "text-lg text-foreground", children: glyph })
3232
+ }
3233
+ );
3234
+ }
3235
+ var AXIS_WIDTH = 36;
3236
+ function nativeColor(color, tokens) {
3237
+ if (!color.includes("var(")) return color;
3238
+ const name = /var\(\s*--([a-z0-9-]{1,40})\s*\)/i.exec(color.slice(0, 120))?.[1];
3239
+ if (!name) return void 0;
3240
+ const key = name.toLowerCase().replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
3241
+ return tokens[key] ?? (key === "primary" ? tokens.primaryText : void 0);
3242
+ }
3243
+ function NativeChartContainer({
3244
+ config,
3245
+ data,
3246
+ xKey,
3247
+ type = "bar",
3248
+ stacked = false,
3249
+ height = 200,
3250
+ showLegend,
3251
+ showGrid = true,
3252
+ valueFormat = (v) => String(v),
3253
+ accessibilityLabel,
3254
+ className,
3255
+ testID = "native-chart"
3256
+ }) {
3257
+ const scheme = useThemeMode();
3258
+ const { svg } = useGenesisModules();
3259
+ const [width, setWidth] = useState(0);
3260
+ const keys = Object.keys(config);
3261
+ const tokens = scheme === "dark" ? nativeThemeDark : nativeThemeLight;
3262
+ const series = useMemo(
3263
+ () => keys.map((key, i) => {
3264
+ const color = chartSeriesColor(config[key], scheme);
3265
+ const token = chartTokenOf(color) ?? (color ? void 0 : defaultChartToken(i));
3266
+ const hex = token ? tokens[token.replace("-", "")] : nativeColor(color, tokens);
3267
+ return { key, label: config[key]?.label ?? key, color: hex ?? tokens.foreground };
3268
+ }),
3269
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keys are config's
3270
+ [config, scheme, tokens]
3271
+ );
3272
+ const domain = useMemo(() => chartDomain(data, keys, { stacked: stacked && type === "bar" }), [data, keys, stacked, type]);
3273
+ const plotWidth = Math.max(0, width - AXIS_WIDTH);
3274
+ const y = (v) => height - chartPosition(v, domain, height);
3275
+ const zero = y(0);
3276
+ const summary = chartSummary(data, xKey, series, valueFormat);
3277
+ const legend = showLegend ?? series.length > 1;
3278
+ const slot = data.length > 0 ? plotWidth / data.length : 0;
3279
+ return /* @__PURE__ */ jsxs(
3280
+ View,
3281
+ {
3282
+ testID,
3283
+ className: cn("w-full", className),
3284
+ accessible: true,
3285
+ accessibilityRole: "image",
3286
+ accessibilityLabel: accessibilityLabel ? `${accessibilityLabel}. ${summary}` : summary,
3287
+ children: [
3288
+ /* @__PURE__ */ jsxs(View, { className: "flex-row", style: { height }, children: [
3289
+ /* @__PURE__ */ jsx(View, { style: { width: AXIS_WIDTH, height }, importantForAccessibility: "no-hide-descendants", children: domain.ticks.map((t) => /* @__PURE__ */ jsx(Text, { className: "absolute right-1 text-[10px] text-muted-foreground", style: { top: y(t) - 7 }, children: valueFormat(t) }, t)) }),
3290
+ /* @__PURE__ */ jsxs(
3291
+ View,
3292
+ {
3293
+ className: "flex-1",
3294
+ style: { height },
3295
+ onLayout: (e) => setWidth((e.nativeEvent?.layout?.width ?? 0) + AXIS_WIDTH),
3296
+ children: [
3297
+ showGrid ? domain.ticks.map((t) => /* @__PURE__ */ jsx(View, { className: "absolute left-0 right-0 h-px bg-border/60", style: { top: y(t) } }, t)) : null,
3298
+ type === "bar" ? data.map((row, i) => /* @__PURE__ */ jsx(BarGroup, { testID: `${testID}-bar-${i}`, row, series, stacked, left: i * slot, width: slot, y, zero }, i)) : /* @__PURE__ */ jsx(Lines, { svg, data, series, area: type === "area", slot, width: plotWidth, height, y, zero, testID })
3299
+ ]
3300
+ }
3301
+ )
3302
+ ] }),
3303
+ /* @__PURE__ */ jsx(View, { className: "flex-row", style: { marginLeft: AXIS_WIDTH }, importantForAccessibility: "no-hide-descendants", children: data.map((row, i) => /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: "flex-1 text-center text-[10px] text-muted-foreground", children: String(row[xKey] ?? "") }, i)) }),
3304
+ legend ? /* @__PURE__ */ jsx(View, { className: "mt-2 flex-row flex-wrap justify-center gap-3", importantForAccessibility: "no-hide-descendants", children: series.map((s) => /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-1.5", children: [
3305
+ /* @__PURE__ */ jsx(View, { className: "h-2.5 w-2.5 rounded-sm", style: { backgroundColor: s.color } }),
3306
+ /* @__PURE__ */ jsx(Text, { className: "text-xs text-muted-foreground", children: s.label })
3307
+ ] }, s.key)) }) : null
3308
+ ]
3309
+ }
3310
+ );
3311
+ }
3312
+ function num(v) {
3313
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
3314
+ }
3315
+ function BarGroup({ row, series, stacked, left, width, y, zero, testID }) {
3316
+ const inner = width * 0.7;
3317
+ const pad = (width - inner) / 2;
3318
+ if (stacked) {
3319
+ let base = 0;
3320
+ return /* @__PURE__ */ jsx(View, { testID, className: "absolute", style: { left: left + pad, width: inner, top: 0, bottom: 0 }, children: series.map((s) => {
3321
+ const v = num(row[s.key]);
3322
+ const top = y(base + v);
3323
+ const bottom = y(base);
3324
+ base += v;
3325
+ return /* @__PURE__ */ jsx(View, { className: "absolute left-0 right-0 rounded-sm", style: { top: Math.min(top, bottom), height: Math.abs(bottom - top), backgroundColor: s.color } }, s.key);
3326
+ }) });
3327
+ }
3328
+ const bar = inner / Math.max(1, series.length);
3329
+ return /* @__PURE__ */ jsx(View, { testID, className: "absolute", style: { left: left + pad, width: inner, top: 0, bottom: 0 }, children: series.map((s, j) => {
3330
+ const top = y(num(row[s.key]));
3331
+ return /* @__PURE__ */ jsx(
3332
+ View,
3333
+ {
3334
+ className: "absolute rounded-sm",
3335
+ style: { left: j * bar + 1, width: Math.max(1, bar - 2), top: Math.min(top, zero), height: Math.abs(zero - top), backgroundColor: s.color }
3336
+ },
3337
+ s.key
3338
+ );
3339
+ }) });
3340
+ }
3341
+ function Lines({
3342
+ svg,
3343
+ data,
3344
+ series,
3345
+ area,
3346
+ slot,
3347
+ width,
3348
+ height,
3349
+ y,
3350
+ zero,
3351
+ testID
3352
+ }) {
3353
+ const x = (i) => i * slot + slot / 2;
3354
+ const Root = svg?.Svg ?? svg?.default;
3355
+ if (svg && Root && width > 0) {
3356
+ const { Path } = svg;
3357
+ return /* @__PURE__ */ jsx(View, { className: "absolute inset-0", pointerEvents: "none", children: /* @__PURE__ */ jsx(Root, { width, height, testID: `${testID}-svg`, children: series.map((s) => {
3358
+ const points = data.map((row, i) => `${x(i).toFixed(1)},${y(num(row[s.key])).toFixed(1)}`);
3359
+ const line = `M${points.join(" L")}`;
3360
+ return [
3361
+ area ? /* @__PURE__ */ jsx(Path, { d: `${line} L${x(data.length - 1).toFixed(1)},${zero.toFixed(1)} L${x(0).toFixed(1)},${zero.toFixed(1)} Z`, fill: s.color, fillOpacity: 0.2 }, `${s.key}-area`) : null,
3362
+ /* @__PURE__ */ jsx(Path, { d: line, stroke: s.color, strokeWidth: 2, fill: "none", testID: `${testID}-line-${s.key}` }, s.key)
3363
+ ];
3364
+ }) }) });
3365
+ }
3366
+ return /* @__PURE__ */ jsx(Fragment, { children: series.map(
3367
+ (s) => data.map((row, i) => /* @__PURE__ */ jsx(
3368
+ View,
3369
+ {
3370
+ testID: `${testID}-point-${s.key}-${i}`,
3371
+ className: "absolute h-2 w-2 rounded-full",
3372
+ style: { left: x(i) - 4, top: y(num(row[s.key])) - 4, backgroundColor: s.color }
3373
+ },
3374
+ `${s.key}-${i}`
3375
+ ))
3376
+ ) });
3377
+ }
3378
+ var DEFAULT_LABELS = {
3379
+ reorder: "Reorder {name}",
3380
+ moveUp: "Move up",
3381
+ moveDown: "Move down",
3382
+ moveToTop: "Move to top",
3383
+ moveToBottom: "Move to bottom",
3384
+ moved: "{name} moved to position {n} of {total}.",
3385
+ moveFailed: "Couldn\u2019t move {name}.",
3386
+ cancel: "Cancel"
3387
+ };
3388
+ var announce = (text) => AccessibilityInfo.announceForAccessibility?.(text);
3389
+ function NativeSortableList({
3390
+ items,
3391
+ getKey,
3392
+ getItemLabel,
3393
+ renderItem,
3394
+ onReorder,
3395
+ label,
3396
+ disabled = false,
3397
+ moveMenu = true,
3398
+ onDragChange,
3399
+ labels: labelsProp,
3400
+ className,
3401
+ itemClassName,
3402
+ testID = "native-sortable-list"
3403
+ }) {
3404
+ const t = { ...DEFAULT_LABELS, ...labelsProp };
3405
+ const itemKeys = items.map(getKey);
3406
+ const byKey = new Map(items.map((item) => [getKey(item), item]));
3407
+ const [preview, setPreview] = useState(null);
3408
+ const pending = useRef(false);
3409
+ const [drag, setDrag] = useState(null);
3410
+ const [menuFor, setMenuFor] = useState(null);
3411
+ const rowHeight = useRef(56);
3412
+ const baseKeys = preview && preview.length === itemKeys.length && preview.every((k) => byKey.has(k)) ? preview : itemKeys;
3413
+ const total = baseKeys.length;
3414
+ const nameOf = (key) => {
3415
+ const item = byKey.get(key);
3416
+ return item === void 0 ? key : getItemLabel(item);
3417
+ };
3418
+ const target = drag ? dropIndex(drag.from, drag.dy, rowHeight.current, total) : null;
3419
+ const keys = drag && target !== null ? moveItem(baseKeys, drag.from, target) : baseKeys;
3420
+ const move = (key, to) => {
3421
+ if (disabled || pending.current) return;
3422
+ const from = itemKeys.indexOf(key);
3423
+ const dest = Math.max(0, Math.min(total - 1, Math.round(to)));
3424
+ if (from < 0 || dest === from) return;
3425
+ pending.current = true;
3426
+ setPreview(moveItem(itemKeys, from, dest));
3427
+ let result;
3428
+ try {
3429
+ result = onReorder(from, dest, { key });
3430
+ } catch (error) {
3431
+ result = Promise.reject(error);
3432
+ }
3433
+ Promise.resolve(result).then(
3434
+ () => announce(movedAnnouncement(nameOf(key), dest, total, t.moved)),
3435
+ () => announce(t.moveFailed.replace("{name}", nameOf(key)))
3436
+ ).finally(() => {
3437
+ pending.current = false;
3438
+ setPreview(null);
3439
+ });
3440
+ };
3441
+ const latest = useRef({ move, onDragChange });
3442
+ latest.current = { move, onDragChange };
3443
+ const responders = useMemo(() => {
3444
+ const map = /* @__PURE__ */ new Map();
3445
+ for (const [i, key] of baseKeys.entries()) {
3446
+ map.set(
3447
+ key,
3448
+ PanResponder.create({
3449
+ onStartShouldSetPanResponder: () => !disabled && !pending.current,
3450
+ onMoveShouldSetPanResponder: () => !disabled && !pending.current,
3451
+ // A drag in progress keeps the gesture: a parent ScrollView asking for it is refused, and
3452
+ // on Android the native scroll is blocked while the handle holds it.
3453
+ onPanResponderTerminationRequest: () => false,
3454
+ onShouldBlockNativeResponder: () => true,
3455
+ onPanResponderGrant: () => {
3456
+ setDrag({ key, from: i, dy: 0 });
3457
+ latest.current.onDragChange?.(true);
3458
+ },
3459
+ onPanResponderMove: (_e, g) => setDrag({ key, from: i, dy: g.dy }),
3460
+ onPanResponderRelease: (_e, g) => {
3461
+ setDrag(null);
3462
+ latest.current.onDragChange?.(false);
3463
+ latest.current.move(key, dropIndex(i, g.dy, rowHeight.current, baseKeys.length));
3464
+ },
3465
+ onPanResponderTerminate: () => {
3466
+ setDrag(null);
3467
+ latest.current.onDragChange?.(false);
3468
+ }
3469
+ })
3470
+ );
3471
+ }
3472
+ return map;
3473
+ }, [baseKeys.join("\0"), disabled]);
3474
+ const menuIndex = menuFor ? baseKeys.indexOf(menuFor) : -1;
3475
+ return /* @__PURE__ */ jsxs(View, { testID, accessibilityRole: "list", accessibilityLabel: label, className: cn("gap-2", className), children: [
3476
+ keys.map((key, index) => {
3477
+ const item = byKey.get(key);
3478
+ if (item === void 0) return null;
3479
+ const from = baseKeys.indexOf(key);
3480
+ const isDragging = drag?.key === key;
3481
+ const name = nameOf(key);
3482
+ const handle = /* @__PURE__ */ jsx(
3483
+ View,
3484
+ {
3485
+ testID: `${testID}-handle-${key}`,
3486
+ accessible: false,
3487
+ importantForAccessibility: "no-hide-descendants",
3488
+ className: cn("h-11 w-8 items-center justify-center", disabled && "opacity-40"),
3489
+ ...responders.get(key)?.panHandlers ?? {},
3490
+ children: /* @__PURE__ */ jsx(Text, { className: "text-lg text-muted-foreground", children: "\u22EE\u22EE" })
3491
+ }
3492
+ );
3493
+ const actions = [
3494
+ ...from > 0 ? [{ name: "moveToTop", label: t.moveToTop }, { name: "moveUp", label: t.moveUp }] : [],
3495
+ ...from < total - 1 ? [{ name: "moveDown", label: t.moveDown }, { name: "moveToBottom", label: t.moveToBottom }] : []
3496
+ ];
3497
+ return /* @__PURE__ */ jsx(
3498
+ View,
3499
+ {
3500
+ testID: `${testID}-item-${key}`,
3501
+ accessible: true,
3502
+ accessibilityLabel: `${name}, ${index + 1} of ${total}`,
3503
+ accessibilityHint: disabled ? void 0 : t.reorder.replace("{name}", name),
3504
+ accessibilityActions: disabled ? [] : [...actions, ...moveMenu ? [{ name: "longpress", label: t.reorder.replace("{name}", name) }] : []],
3505
+ onAccessibilityAction: (e) => {
3506
+ const a = e.nativeEvent.actionName;
3507
+ if (a === "moveUp") move(key, from - 1);
3508
+ else if (a === "moveDown") move(key, from + 1);
3509
+ else if (a === "moveToTop") move(key, 0);
3510
+ else if (a === "moveToBottom") move(key, total - 1);
3511
+ else if (a === "longpress" && moveMenu) setMenuFor(key);
3512
+ },
3513
+ onLayout: index === 0 ? (e) => {
3514
+ const h = e.nativeEvent?.layout?.height;
3515
+ if (h) rowHeight.current = h + 8;
3516
+ } : void 0,
3517
+ className: cn(isDragging && "z-10 opacity-90 shadow-lg", itemClassName),
3518
+ style: isDragging && target !== null ? { transform: [{ translateY: drag.dy - (target - drag.from) * rowHeight.current }] } : void 0,
3519
+ children: /* @__PURE__ */ jsx(LongPress, { enabled: moveMenu && !disabled, onLongPress: () => setMenuFor(key), testID: `${testID}-row-${key}`, children: renderItem(item, {
3520
+ index,
3521
+ handle,
3522
+ isDragging,
3523
+ moveUp: () => move(key, from - 1),
3524
+ moveDown: () => move(key, from + 1),
3525
+ moveTo: (to) => move(key, to)
3526
+ }) })
3527
+ },
3528
+ key
3529
+ );
3530
+ }),
3531
+ moveMenu ? /* @__PURE__ */ jsx(
3532
+ NativeContextMenu,
3533
+ {
3534
+ testID: `${testID}-menu`,
3535
+ open: menuFor !== null,
3536
+ onOpenChange: (open) => open ? void 0 : setMenuFor(null),
3537
+ title: menuFor ? nameOf(menuFor) : void 0,
3538
+ cancelLabel: t.cancel,
3539
+ actions: menuFor === null ? [] : [
3540
+ ...menuIndex > 0 ? [
3541
+ { id: "top", label: t.moveToTop, onPress: () => move(menuFor, 0) },
3542
+ { id: "up", label: t.moveUp, onPress: () => move(menuFor, menuIndex - 1) }
3543
+ ] : [],
3544
+ ...menuIndex < total - 1 ? [
3545
+ { id: "down", label: t.moveDown, onPress: () => move(menuFor, menuIndex + 1) },
3546
+ { id: "bottom", label: t.moveToBottom, onPress: () => move(menuFor, total - 1) }
3547
+ ] : []
3548
+ ]
3549
+ }
3550
+ ) : null
3551
+ ] });
3552
+ }
3553
+ function LongPress({ enabled, onLongPress, children, testID }) {
3554
+ if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children });
3555
+ return /* @__PURE__ */ jsx(Pressable, { testID, accessible: false, onLongPress, delayLongPress: 350, children });
3556
+ }
3557
+ var asText = (node, className) => typeof node === "string" || typeof node === "number" ? /* @__PURE__ */ jsx(Text, { className, children: node }) : node;
3558
+ function WidgetTile({ variant, label, value, detail, detailClassName, icon, meta, children, onPress, className, testID }) {
3559
+ const spoken = [label, typeof value === "string" || typeof value === "number" ? String(value) : null, typeof detail === "string" ? detail : null].filter(Boolean).join(", ");
3560
+ const body = /* @__PURE__ */ jsxs(NativeCard, { className: cn("gap-1 p-4", className), testID, children: [
3561
+ /* @__PURE__ */ jsxs(View, { className: "flex-row items-center justify-between gap-2", children: [
3562
+ /* @__PURE__ */ jsxs(View, { className: "min-w-0 flex-1 flex-row items-center gap-2", children: [
3563
+ variant === "summary" && icon ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: icon }) : null,
3564
+ /* @__PURE__ */ jsx(
3565
+ Text,
3566
+ {
3567
+ numberOfLines: variant === "summary" ? 2 : 1,
3568
+ className: variant === "summary" ? "flex-1 text-base font-semibold text-foreground" : "flex-1 text-sm font-medium text-muted-foreground",
3569
+ children: label
3570
+ }
3571
+ )
3572
+ ] }),
3573
+ variant !== "summary" && icon ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: icon }) : null,
3574
+ meta ? asText(meta, "text-xs text-muted-foreground") : null
3575
+ ] }),
3576
+ value !== void 0 ? asText(value, variant === "headline" ? "text-3xl font-bold text-foreground" : "text-2xl font-bold text-foreground") : null,
3577
+ detail ? asText(detail, cn("text-xs text-muted-foreground", detailClassName)) : null,
3578
+ children ? /* @__PURE__ */ jsx(View, { className: "mt-2", children }) : null
3579
+ ] });
3580
+ if (onPress) {
3581
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: spoken, onPress, children: body });
3582
+ }
3583
+ if (variant === "summary") return body;
3584
+ return /* @__PURE__ */ jsx(View, { accessible: true, accessibilityLabel: spoken, children: body });
3585
+ }
3586
+ var ICON_TONE = {
3587
+ primary: "text-primary-text",
3588
+ success: "text-success",
3589
+ warning: "text-warning",
3590
+ info: "text-info",
3591
+ destructive: "text-destructive",
3592
+ muted: "text-muted-foreground"
3593
+ };
3594
+ function NativeStatCard({ label, value, icon, color = "primary", trend, onPress, className, testID = "native-stat-card" }) {
3595
+ const t = trend ? formatTrend(trend) : null;
3596
+ return /* @__PURE__ */ jsx(
3597
+ WidgetTile,
3598
+ {
3599
+ variant: "stat",
3600
+ label,
3601
+ value,
3602
+ icon: icon ? /* @__PURE__ */ jsx(View, { className: ICON_TONE[color], children: icon }) : void 0,
3603
+ detail: t?.text,
3604
+ detailClassName: t ? t.positive ? "text-primary-text" : "text-destructive" : void 0,
3605
+ onPress,
3606
+ className,
3607
+ testID
3608
+ }
3609
+ );
3610
+ }
3611
+ function NativeStatusBadge({ status, children, className, testID }) {
3612
+ return /* @__PURE__ */ jsx(NativeBadge, { variant: STATUS_BADGE_TONES[status], className, testID: testID ?? `status-badge-${status}`, children: children ?? statusBadgeLabel(status) });
3613
+ }
3614
+ var AVATAR_SIZE = { sm: 32, default: 40, lg: 48 };
3615
+ function NativeUserAvatar({ name, src, size = "default", distinct, className, testID }) {
3616
+ return /* @__PURE__ */ jsx(
3617
+ NativeAvatar,
3618
+ {
3619
+ src,
3620
+ alt: name,
3621
+ fallback: initialsOf(name, { distinct }) || "?",
3622
+ size: AVATAR_SIZE[size],
3623
+ className: cn(className),
3624
+ testID: testID ?? "native-user-avatar"
3625
+ }
3626
+ );
3627
+ }
3628
+ function ToneChip({ tone, children, testID }) {
3629
+ return /* @__PURE__ */ jsx(NativeBadge, { variant: tone, testID, children });
3630
+ }
3631
+ function NativeReadinessChip({ readiness, labels, onPress, className }) {
3632
+ const { label, tone } = readinessChip(readiness, labels);
3633
+ const mark = readiness.state === "ready" ? "\u2713 " : readiness.state === "problems" ? "! " : readiness.state === "warnings" ? "\u26A0 " : "";
3634
+ const chip = /* @__PURE__ */ jsx(View, { className, children: /* @__PURE__ */ jsx(ToneChip, { tone, testID: "readiness", children: `${mark}${label}` }) });
3635
+ if (!onPress) return chip;
3636
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, hitSlop: 8, className: "self-start", children: chip });
3637
+ }
3638
+ var HEADLINE_TONE = {
3639
+ positive: "text-emerald-700 dark:text-emerald-300",
3640
+ negative: "text-red-700 dark:text-red-300",
3641
+ warning: "text-amber-800 dark:text-amber-200",
3642
+ muted: "text-muted-foreground"
3643
+ };
3644
+ function NativeHeadlineNumbers({ numbers, isLoading = false, className }) {
3645
+ if (isLoading) {
3646
+ return /* @__PURE__ */ jsx(View, { className: cn("flex-row flex-wrap gap-3", className), testID: "headline-numbers-loading", children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx(View, { className: "min-w-[45%] flex-1", children: /* @__PURE__ */ jsx(NativeSkeleton, { height: 112, className: "w-full rounded-lg" }) }, i)) });
3647
+ }
3648
+ if (!numbers.length) return null;
3649
+ return /* @__PURE__ */ jsx(View, { className: cn("flex-row flex-wrap gap-3", className), testID: "headline-numbers", children: numbers.map((n) => /* @__PURE__ */ jsx(View, { className: "min-w-[45%] flex-1", children: /* @__PURE__ */ jsx(
3650
+ WidgetTile,
3651
+ {
3652
+ variant: "headline",
3653
+ label: n.label,
3654
+ value: n.value,
3655
+ detail: n.detail,
3656
+ detailClassName: HEADLINE_TONE[n.tone ?? "muted"],
3657
+ testID: `headline-${n.key}`
3658
+ }
3659
+ ) }, n.key)) });
3660
+ }
3661
+ function NativeSummaryCard({ icon, title, meta, children, className, testID }) {
3662
+ return /* @__PURE__ */ jsx(WidgetTile, { variant: "summary", label: title, icon, meta, className, testID, children });
3663
+ }
3664
+ function NativeFollowUpList({
3665
+ entries,
3666
+ actions,
3667
+ title = "Needs a follow-up",
3668
+ isLoading = false,
3669
+ empty = "Nothing to follow up right now.",
3670
+ noComment = "No comment",
3671
+ className
3672
+ }) {
3673
+ return /* @__PURE__ */ jsxs(NativeCard, { className: cn("gap-3 p-4", className), testID: "follow-up-list", children: [
3674
+ /* @__PURE__ */ jsxs(View, { className: "flex-row items-center justify-between gap-2", children: [
3675
+ /* @__PURE__ */ jsxs(Text, { accessibilityRole: "header", className: "text-base font-semibold text-foreground", children: [
3676
+ "\u26A0 ",
3677
+ title
3678
+ ] }),
3679
+ !isLoading ? /* @__PURE__ */ jsx(NativeBadge, { variant: "muted", accessibilityLabel: `${entries.length}`, children: String(entries.length) }) : null
3680
+ ] }),
3681
+ isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
3682
+ /* @__PURE__ */ jsx(NativeSkeleton, { height: 96, className: "w-full rounded-md" }),
3683
+ /* @__PURE__ */ jsx(NativeSkeleton, { height: 96, className: "w-full rounded-md" })
3684
+ ] }) : entries.length === 0 ? /* @__PURE__ */ jsxs(Text, { className: "text-sm text-muted-foreground", children: [
3685
+ "\u2713 ",
3686
+ empty
3687
+ ] }) : entries.map((entry) => {
3688
+ const buttons = actions?.(entry);
3689
+ return /* @__PURE__ */ jsxs(View, { testID: `follow-up-${entry.id}`, className: "gap-1.5 rounded-md border border-border p-3", children: [
3690
+ /* @__PURE__ */ jsxs(View, { className: "flex-row items-start justify-between gap-2", children: [
3691
+ /* @__PURE__ */ jsxs(View, { className: "min-w-0 flex-1 flex-row flex-wrap items-center gap-2", children: [
3692
+ /* @__PURE__ */ jsx(Text, { className: "font-medium text-foreground", children: entry.name }),
3693
+ entry.tag ? /* @__PURE__ */ jsx(ToneChip, { tone: entry.tag.tone ?? "muted", children: entry.tag.label }) : null
3694
+ ] }),
3695
+ entry.rating ? /* @__PURE__ */ jsxs(
3696
+ Text,
3697
+ {
3698
+ accessibilityLabel: `Rated ${entry.rating.value} out of ${entry.rating.max}`,
3699
+ className: "text-sm font-medium text-amber-800 dark:text-amber-200",
3700
+ children: [
3701
+ entry.rating.value,
3702
+ " \u2605"
3703
+ ]
3704
+ }
3705
+ ) : null
3706
+ ] }),
3707
+ entry.meta ? /* @__PURE__ */ jsx(Text, { className: "text-xs text-muted-foreground", children: entry.meta }) : null,
3708
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 3, className: cn("text-sm", entry.comment ? "text-foreground" : "text-muted-foreground"), children: entry.comment || noComment }),
3709
+ buttons ? /* @__PURE__ */ jsx(View, { className: "mt-1 flex-row flex-wrap gap-2", children: buttons }) : null
3710
+ ] }, entry.id);
3711
+ })
3712
+ ] });
3713
+ }
3714
+ function NativeResponsesToolbar({ view, onViewChange, filters, actions, labels = {}, className }) {
3715
+ return /* @__PURE__ */ jsxs(View, { className: cn("gap-2", className), testID: "responses-toolbar", children: [
3716
+ /* @__PURE__ */ jsx(
3717
+ NativeSegmentedControl,
3718
+ {
3719
+ testID: "responses-view",
3720
+ options: [
3721
+ { value: "summary", label: labels.summary ?? "Summary" },
3722
+ { value: "each", label: labels.each ?? "Each response" }
3723
+ ],
3724
+ value: view,
3725
+ onChange: onViewChange
3726
+ }
3727
+ ),
3728
+ filters ? /* @__PURE__ */ jsx(View, { className: "flex-row flex-wrap items-center gap-2", children: filters }) : null,
3729
+ actions ? /* @__PURE__ */ jsx(View, { className: "flex-row flex-wrap items-center gap-2", children: actions }) : null
3730
+ ] });
3731
+ }
3732
+ function NativeSettingsRow({ label, description, children, onPress, showChevron, disabled, className, testID = "settings-row" }) {
3733
+ return /* @__PURE__ */ jsx(
3734
+ NativeListItem,
3735
+ {
3736
+ title: label,
3737
+ subtitle: description,
3738
+ trailing: children,
3739
+ onPress,
3740
+ showChevron,
3741
+ disabled,
3742
+ className: cn(disabled && !onPress && "opacity-50", className),
3743
+ testID
3744
+ }
3745
+ );
3746
+ }
3747
+ function NativeToggleRow({ label, description, checked: checkedProp, defaultChecked = false, onCheckedChange, disabled, className, testID = "toggle-row-switch", rowTestID = "toggle-row" }) {
3748
+ const [checkedState, setCheckedState] = useState(defaultChecked);
3749
+ const checked = checkedProp ?? checkedState;
3750
+ const set = (next) => {
3751
+ if (disabled) return;
3752
+ if (checkedProp === void 0) setCheckedState(next);
3753
+ onCheckedChange?.(next);
3754
+ };
3755
+ return /* @__PURE__ */ jsx(
3756
+ NativeListItem,
3757
+ {
3758
+ title: label,
3759
+ subtitle: description,
3760
+ onPress: () => set(!checked),
3761
+ disabled,
3762
+ accessibilityRole: "switch",
3763
+ accessibilityState: { checked },
3764
+ className,
3765
+ testID: rowTestID,
3766
+ trailing: (
3767
+ // The row is the switch for a screen reader; the control itself is hidden from it.
3768
+ /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: /* @__PURE__ */ jsx(NativeSwitch, { testID, checked, onCheckedChange: set, disabled }) })
3769
+ )
3770
+ }
3771
+ );
3772
+ }
3773
+ function NativeResourceSettingsPage({ sections, navLabel = "On this page", className, testID = "resource-settings-page" }) {
3774
+ const scroll = useRef(null);
3775
+ const offsets = useRef(/* @__PURE__ */ new Map());
3776
+ const [active, setActive] = useState(sections[0]?.id);
3777
+ const jump = (s) => {
3778
+ setActive(s.id);
3779
+ if (s.content === void 0) {
3780
+ s.onSelect?.();
3781
+ return;
3782
+ }
3783
+ scroll.current?.scrollTo?.({ y: offsets.current.get(s.id) ?? 0, animated: true });
3784
+ };
3785
+ return /* @__PURE__ */ jsxs(
3786
+ ScrollView,
3787
+ {
3788
+ ref: scroll,
3789
+ testID,
3790
+ className: cn("flex-1", className),
3791
+ contentContainerClassName: "gap-4 p-4",
3792
+ contentInsetAdjustmentBehavior: "automatic",
3793
+ onScroll: (e) => {
3794
+ const y = e.nativeEvent.contentOffset.y + 24;
3795
+ let current = sections[0]?.id;
3796
+ for (const s of sections) if ((offsets.current.get(s.id) ?? Infinity) <= y) current = s.id;
3797
+ if (current !== active) setActive(current);
3798
+ },
3799
+ scrollEventThrottle: 64,
3800
+ children: [
3801
+ /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, accessibilityLabel: navLabel, contentContainerClassName: "gap-2", children: sections.map((s) => /* @__PURE__ */ jsxs(
3802
+ Pressable,
3803
+ {
3804
+ testID: `${testID}-link-${s.id}`,
3805
+ accessibilityRole: "link",
3806
+ accessibilityState: { selected: active === s.id },
3807
+ onPress: () => jump(s),
3808
+ className: cn("min-h-[36px] flex-row items-center gap-2 rounded-md px-3", active === s.id ? "bg-muted" : "bg-transparent"),
3809
+ children: [
3810
+ s.icon ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: s.icon }) : null,
3811
+ /* @__PURE__ */ jsx(Text, { className: cn("text-sm", active === s.id ? "font-medium text-foreground" : "text-muted-foreground"), children: s.title })
3812
+ ]
3813
+ },
3814
+ s.id
3815
+ )) }),
3816
+ sections.filter((s) => s.content !== void 0).map((s) => /* @__PURE__ */ jsx(
3817
+ View,
3818
+ {
3819
+ onLayout: (e) => offsets.current.set(s.id, e.nativeEvent?.layout?.y ?? 0),
3820
+ children: /* @__PURE__ */ jsxs(NativeCard, { testID: `${testID}-section-${s.id}`, className: "overflow-hidden", children: [
3821
+ /* @__PURE__ */ jsxs(View, { className: "flex-row gap-3 border-b border-border px-4 py-3", children: [
3822
+ s.icon ? /* @__PURE__ */ jsx(View, { className: "mt-0.5", accessibilityElementsHidden: true, children: s.icon }) : null,
3823
+ /* @__PURE__ */ jsxs(View, { className: "min-w-0 flex-1", children: [
3824
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", className: "text-base font-semibold text-foreground", children: s.title }),
3825
+ s.description ? /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: s.description }) : null
3826
+ ] })
3827
+ ] }),
3828
+ /* @__PURE__ */ jsx(SectionRows, { children: s.content })
3829
+ ] })
3830
+ },
3831
+ s.id
3832
+ ))
3833
+ ]
3834
+ }
3835
+ );
3836
+ }
3837
+ function SectionRows({ children }) {
3838
+ const rows = flattenChildren(children);
3839
+ return /* @__PURE__ */ jsx(View, { children: rows.map((row, i) => /* @__PURE__ */ jsxs(View, { children: [
3840
+ i > 0 ? /* @__PURE__ */ jsx(NativeListItemDivider, {}) : null,
3841
+ row
3842
+ ] }, i)) });
3843
+ }
3844
+ var NO_WORKSPACES = [];
3845
+ function NativeWorkspaceSwitcher({
3846
+ workspaces: workspacesProp,
3847
+ current: currentProp,
3848
+ onSelect,
3849
+ hrefFor: hrefForProp,
3850
+ order = WORKSPACE_KIND_ORDER,
3851
+ kindLabels,
3852
+ renderImage,
3853
+ badgeLabel = workspaceBadgeLabel,
3854
+ search = "auto",
3855
+ searchPlaceholder = "Find a workspace",
3856
+ emptyText = "No workspaces found",
3857
+ placeholder = "Choose a workspace",
3858
+ label = "Switch workspace",
3859
+ actions,
3860
+ open: openProp,
3861
+ onOpenChange,
3862
+ variant = "row",
3863
+ className,
3864
+ testID = "workspace-switcher"
3865
+ }) {
3866
+ const scope = useWorkspace();
3867
+ const workspaces = workspacesProp ?? scope?.workspaces ?? NO_WORKSPACES;
3868
+ const current = currentProp ?? scope?.current;
3869
+ const hrefFor = hrefForProp ?? scope?.hrefFor ?? ((to) => workspaceHref(workspaces, to, current?.path));
3870
+ const labels = { ...DEFAULT_WORKSPACE_KIND_LABELS, ...kindLabels };
3871
+ const [openState, setOpenState] = useState(false);
3872
+ const open = openProp ?? openState;
3873
+ const [query, setQuery] = useState("");
3874
+ const setOpen = (next) => {
3875
+ if (openProp === void 0) setOpenState(next);
3876
+ onOpenChange?.(next);
3877
+ if (!next) setQuery("");
3878
+ };
3879
+ const showSearch = search === true || search === "auto" && workspaces.length > WORKSPACE_SWITCHER_SEARCH_THRESHOLD;
3880
+ const groups = groupWorkspaces(showSearch ? filterWorkspaces(workspaces, query) : workspaces, order);
3881
+ const picture = (w, size) => w && renderImage ? renderImage(w, size) : /* @__PURE__ */ jsx(NativeAvatar, { size, src: w?.image ?? null, fallback: w ? workspaceInitials(w.label) : "?", alt: "" });
3882
+ const pick = (w) => {
3883
+ setOpen(false);
3884
+ if (w.id !== current?.id) onSelect(w, hrefFor(w));
3885
+ };
3886
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3887
+ /* @__PURE__ */ jsxs(
3888
+ Pressable,
3889
+ {
3890
+ testID: `${testID}-trigger`,
3891
+ accessibilityRole: "button",
3892
+ accessibilityLabel: current ? `${current.label}${current.description ? `, ${current.description}` : ""}` : placeholder,
3893
+ accessibilityHint: label,
3894
+ accessibilityState: { expanded: open },
3895
+ onPress: () => setOpen(true),
3896
+ className: cn("min-h-[44px] flex-row items-center gap-3", variant === "row" ? "rounded-lg px-3 py-2" : "px-1", className),
3897
+ children: [
3898
+ variant === "row" ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, children: picture(current, 32) }) : null,
3899
+ /* @__PURE__ */ jsxs(View, { className: "min-w-0 flex-1", children: [
3900
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cn("text-foreground", variant === "row" ? "text-base font-semibold" : "text-base font-semibold"), children: current?.label ?? placeholder }),
3901
+ variant === "row" && current?.description ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: "text-xs text-muted-foreground", children: current.description }) : null
3902
+ ] }),
3903
+ /* @__PURE__ */ jsx(Text, { className: "text-muted-foreground", accessibilityElementsHidden: true, children: "\u2304" })
3904
+ ]
3905
+ }
3906
+ ),
3907
+ /* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, testID: `${testID}-sheet`, snapPoints: ["60%", "90%"], children: /* @__PURE__ */ jsxs(NativeSheetScrollView, { contentContainerStyle: { paddingBottom: 24 }, children: [
3908
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", className: "px-4 pb-2 pt-1 text-lg font-semibold text-foreground", children: label }),
3909
+ showSearch ? /* @__PURE__ */ jsx(View, { className: "px-4 pb-2", children: /* @__PURE__ */ jsx(NativeSearchBar, { testID: `${testID}-search`, value: query, onChange: setQuery, placeholder: searchPlaceholder, showCancel: false }) }) : null,
3910
+ groups.length === 0 ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-empty`, className: "px-4 py-6 text-center text-sm text-muted-foreground", children: emptyText }) : groups.map((group) => /* @__PURE__ */ jsxs(View, { accessibilityRole: "radiogroup", children: [
3911
+ labels[group.kind] ? /* @__PURE__ */ jsx(NativeSectionListHeader, { title: labels[group.kind] }) : null,
3912
+ group.workspaces.map((w) => {
3913
+ const selected = w.id === current?.id;
3914
+ const badge = hasWorkspaceBadge(w.badge) ? w.badge : null;
3915
+ return /* @__PURE__ */ jsx(
3916
+ NativeListItem,
3917
+ {
3918
+ testID: `${testID}-option-${w.id}`,
3919
+ title: w.label,
3920
+ subtitle: w.description,
3921
+ leading: picture(w, 32),
3922
+ accessibilityRole: "radio",
3923
+ accessibilityState: { checked: selected },
3924
+ accessibilityLabel: [w.label, w.description, badge !== null ? badgeLabel(w, badge) : null].filter(Boolean).join(", "),
3925
+ trailing: /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-2", children: [
3926
+ badge !== null ? /* @__PURE__ */ jsx(NativeBadge, { variant: "secondary", accessibilityLabel: badgeLabel(w, badge), children: String(badge) }) : null,
3927
+ selected ? /* @__PURE__ */ jsx(Text, { className: "text-base text-primary-text", children: "\u2713" }) : null
3928
+ ] }),
3929
+ onPress: () => pick(w)
3930
+ },
3931
+ w.id
3932
+ );
3933
+ })
3934
+ ] }, group.kind)),
3935
+ actions?.length ? /* @__PURE__ */ jsx(View, { className: "mt-2 border-t border-border", children: actions.map((a) => /* @__PURE__ */ jsx(
3936
+ NativeListItem,
3937
+ {
3938
+ testID: `${testID}-action-${a.id}`,
3939
+ title: a.label,
3940
+ onPress: () => {
3941
+ setOpen(false);
3942
+ a.onPress();
3943
+ }
3944
+ },
3945
+ a.id
3946
+ )) }) : null
3947
+ ] }) })
3948
+ ] });
3949
+ }
2850
3950
 
2851
- export { Box, FULL_SCREEN_DARK, Grid, Inline, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_DOUBLE_TAP_MS, LIGHTBOX_MAX_ZOOM, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeBulkBar, NativeChip, NativeChipGroup, NativeChoiceCard, NativeCombobox, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeFullScreenModal, NativeGalleryCard, NativeGlassSurface, NativeHeaderCard, NativeLightbox, NativeLiveIndicator, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRating, NativeShareSheet, NativeSlider, NativeStepper, NativeTabBar, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeTierBadge, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, NativeWhatsNewSheet, NativeZoomablePhoto, Stack, defaultNativeLightboxLabels, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss, lightboxTouchDistance, nextRating, spaceScale, spacingClass, toggleVariants, useLiquidGlass, useReduceTransparency, useToast };
2852
- //# sourceMappingURL=chunk-IWWXERKQ.js.map
2853
- //# sourceMappingURL=chunk-IWWXERKQ.js.map
3951
+ export { Box, FULL_SCREEN_DARK, Grid, Inline, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_DOUBLE_TAP_MS, LIGHTBOX_MAX_ZOOM, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeBulkBar, NativeButtonGroup, NativeCalendar, NativeCarousel, NativeChartContainer, NativeChip, NativeChipGroup, NativeChoiceCard, NativeCombobox, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeFollowUpList, NativeFullScreenModal, NativeGalleryCard, NativeGlassSurface, NativeHeaderCard, NativeHeadlineNumbers, NativeInputGroup, NativeInputOTP, NativeLightbox, NativeLiveIndicator, NativeNumberInput, NativePagination, NativePasswordToggleField, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRating, NativeReadinessChip, NativeResourceSettingsPage, NativeResponsesToolbar, NativeSettingsRow, NativeShareSheet, NativeSlider, NativeSortableList, NativeStatCard, NativeStatusBadge, NativeStepper, NativeSummaryCard, NativeTabBar, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeTierBadge, NativeToastProvider, NativeToggle, NativeToggleRow, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, NativeUserAvatar, NativeWhatsNewSheet, NativeWorkspaceSwitcher, NativeZoomablePhoto, Stack, defaultNativeLightboxLabels, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss, lightboxTouchDistance, nextRating, spaceScale, spacingClass, toggleVariants, useLiquidGlass, useReduceTransparency, useToast };
3952
+ //# sourceMappingURL=chunk-X5CPLUPZ.js.map
3953
+ //# sourceMappingURL=chunk-X5CPLUPZ.js.map