{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "flight-track",
  "type": "registry:item",
  "title": "Flight Track",
  "description": "A flight card whose route fills with a glowing line behind a small plane with blinking wing lights.",
  "categories": [
    "data"
  ],
  "dependencies": [
    "@shopify/react-native-skia",
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/flight-track.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/flight-track.tsx",
      "content": "import { Canvas, Group, Path, Skia } from '@shopify/react-native-skia';\nimport { useEffect, useState } from 'react';\nimport { StyleSheet, Text, View, type StyleProp, type ViewStyle } from 'react-native';\nimport Animated, {\n  Easing,\n  useAnimatedStyle,\n  useSharedValue,\n  withDelay,\n  withRepeat,\n  withSequence,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\n\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { spring } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\nimport { glow } from '../../lib/kinetik/tokens/tokens';\n\nexport type FlightStop = {\n  /** Airport code, e.g. \"LHR\". */\n  code: string;\n  /** Place under the code, e.g. \"London, UK\". */\n  city: string;\n  /** Local time, e.g. \"20:50\". */\n  time: string;\n  /** Time zone tag, e.g. \"GMT+1\". */\n  zone?: string;\n};\n\nexport type FlightTrackProps = {\n  from: FlightStop;\n  to: FlightStop;\n  /** How far along the flight is, 0–1. Changes glide the plane along the route. */\n  progress: number;\n  /** Label before the departure time. Defaults to \"DEP\". */\n  departLabel?: string;\n  /** Label before the arrival time. Defaults to \"ETA\". */\n  arriveLabel?: string;\n  style?: StyleProp<ViewStyle>;\n};\n\n/** Plane from Tabler Icons (MIT, https://tabler.io/icons), nose right on a 24 pt grid. */\nconst PLANE = Skia.Path.MakeFromSVGString(\n  'M16 10h4a2 2 0 0 1 0 4h-4l-4 7h-3l2 -7h-4l-2 2h-3l2 -4l-2 -4h3l2 2h4l-2 -7h3z',\n)!;\n\nconst ICON = 30;\n/** Fit the plane, wing tips included, in the box. */\nconst SCALE = (ICON / 24) * 0.84;\nconst BAR = 6;\n\n/**\n * A boarding-pass style flight card: departure and arrival codes with their\n * times, and a route between them that fills with a glowing line behind a\n * small plane. The plane glides to each new position, its wing-tip lights\n * blink red and green, and the distance still to fly is hatched.\n */\nexport function FlightTrack({\n  from,\n  to,\n  progress,\n  departLabel = 'DEP',\n  arriveLabel = 'ETA',\n  style,\n}: FlightTrackProps) {\n  const { colors, radius, space } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const [width, setWidth] = useState(0);\n  const [track, setTrack] = useState(0);\n  const p = Math.max(0, Math.min(1, progress));\n  const compact = width > 0 && width < 460;\n\n  const at = useSharedValue(reduced ? p : 0);\n  useEffect(() => {\n    at.set(reduced ? p : withSpring(p, spring('smooth')));\n  }, [p, reduced, at]);\n\n  const fill = useAnimatedStyle(() => ({ width: Math.max(BAR, at.get() * track) }));\n  const plane = useAnimatedStyle(() => ({\n    transform: [{ translateX: at.get() * track - ICON / 2 }],\n  }));\n  const rest = useAnimatedStyle(() => ({ left: at.get() * track }));\n\n  const pct = Math.round(p * 100);\n  const summary =\n    `${from.code}, ${from.city}, to ${to.code}, ${to.city}. ` +\n    `${departLabel === 'DEP' ? 'Departs' : departLabel} ${from.time}${from.zone ? ` ${from.zone}` : ''}, ` +\n    `${arriveLabel === 'ETA' ? 'arrives' : arriveLabel} ${to.time}${to.zone ? ` ${to.zone}` : ''}.`;\n\n  const route = (\n    <View\n      style={styles.route}\n      onLayout={(e) => setTrack(e.nativeEvent.layout.width)}\n      pointerEvents=\"none\"\n    >\n      <Animated.View style={[styles.rest, rest]}>\n        <Hatch />\n      </Animated.View>\n      <Animated.View\n        style={[\n          styles.fill,\n          { backgroundColor: colors.highlight, boxShadow: glow(colors.highlight) },\n          fill,\n        ]}\n      />\n      <Animated.View style={[styles.plane, plane]}>\n        <Plane landed={p >= 1} />\n      </Animated.View>\n    </View>\n  );\n\n  return (\n    <View\n      accessible\n      accessibilityRole=\"progressbar\"\n      accessibilityLabel={summary}\n      accessibilityValue={{ min: 0, max: 100, now: pct, text: `${pct}% of the way` }}\n      onLayout={(e) => setWidth(e.nativeEvent.layout.width)}\n      style={[\n        styles.shell,\n        {\n          borderColor: colors.borderStrong,\n          borderRadius: radius.xl + 6,\n          backgroundColor: colors.background,\n        },\n        style,\n      ]}\n    >\n      <View\n        style={[\n          styles.card,\n          {\n            backgroundColor: colors.surface,\n            borderColor: colors.border,\n            borderRadius: radius.xl,\n            padding: compact ? space[4] : space[6],\n            gap: compact ? space[4] : 0,\n          },\n        ]}\n      >\n        {compact ? (\n          <>\n            <View style={[styles.row, { gap: space[3] }]}>\n              <Airport stop={from} />\n              <View style={styles.grow}>{route}</View>\n              <Airport stop={to} />\n            </View>\n            <View style={[styles.row, styles.between, { gap: space[2] }]}>\n              <TimeChip label={departLabel} stop={from} />\n              <TimeChip label={arriveLabel} stop={to} />\n            </View>\n          </>\n        ) : (\n          <View style={[styles.row, { gap: space[5] }]}>\n            <View style={[styles.end, { gap: space[3] }]}>\n              <Airport stop={from} />\n              <TimeChip label={departLabel} stop={from} />\n            </View>\n            <View style={styles.grow}>{route}</View>\n            <View style={[styles.end, { gap: space[3] }]}>\n              <Airport stop={to} />\n              <TimeChip label={arriveLabel} stop={to} />\n            </View>\n          </View>\n        )}\n      </View>\n    </View>\n  );\n}\n\nfunction Airport({ stop }: { stop: FlightStop }) {\n  const { colors, font } = useKinetikTheme();\n  return (\n    <View style={styles.airport}>\n      <Text\n        style={{\n          color: colors.text,\n          fontSize: font.size['2xl'],\n          fontWeight: font.weight.medium,\n          letterSpacing: font.tracking.tight,\n        }}\n      >\n        {stop.code}\n      </Text>\n      <Text numberOfLines={1} style={{ color: colors.textSubtle, fontSize: 11 }}>\n        {stop.city}\n      </Text>\n    </View>\n  );\n}\n\nfunction TimeChip({ label, stop }: { label: string; stop: FlightStop }) {\n  const { colors, font, radius, space } = useKinetikTheme();\n  return (\n    <View\n      style={[\n        styles.chip,\n        {\n          backgroundColor: colors.surfaceRaised,\n          borderColor: colors.border,\n          borderRadius: radius.sm,\n          gap: space[1.5],\n          paddingLeft: space[2],\n          paddingRight: stop.zone ? 4 : space[2],\n        },\n      ]}\n    >\n      <Text style={{ color: colors.textMuted, fontSize: font.size.sm }}>{label}</Text>\n      <Text\n        style={{\n          color: colors.text,\n          fontSize: font.size.md,\n          fontWeight: font.weight.medium,\n          fontVariant: ['tabular-nums'],\n        }}\n      >\n        {stop.time}\n      </Text>\n      {stop.zone ? (\n        <View style={[styles.zone, { backgroundColor: colors.surface, borderRadius: radius.xs }]}>\n          <Text style={{ color: colors.textMuted, fontSize: 10 }}>{stop.zone}</Text>\n        </View>\n      ) : null}\n    </View>\n  );\n}\n\n/** Diagonal stripes for the distance still to fly. */\nfunction Hatch() {\n  const { colors } = useKinetikTheme();\n  return (\n    <View style={styles.hatch}>\n      {Array.from({ length: 48 }, (_, i) => (\n        <View key={i} style={[styles.stripe, { backgroundColor: colors.textSubtle }]} />\n      ))}\n    </View>\n  );\n}\n\n/** The plane, rocking a little in the air, with blinking wing-tip lights. */\nfunction Plane({ landed }: { landed: boolean }) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const red = useSharedValue(1);\n  const green = useSharedValue(1);\n  const bob = useSharedValue(0);\n\n  useEffect(() => {\n    if (reduced || landed) {\n      red.set(1);\n      green.set(1);\n      bob.set(0);\n      return;\n    }\n    // Navigation lights: mostly on, with a quick dip, out of step with each other.\n    const blink = withRepeat(\n      withSequence(\n        withTiming(1, { duration: 900 }),\n        withTiming(0.15, { duration: 120 }),\n        withTiming(1, { duration: 180 }),\n      ),\n      -1,\n    );\n    red.set(blink);\n    green.set(withDelay(600, blink));\n    bob.set(\n      withRepeat(withTiming(1, { duration: 1800, easing: Easing.inOut(Easing.sin) }), -1, true),\n    );\n  }, [reduced, landed, red, green, bob]);\n\n  const body = useAnimatedStyle(() => ({\n    transform: [{ translateY: (bob.get() - 0.5) * 2 }, { rotate: `${(bob.get() - 0.5) * 3}deg` }],\n  }));\n  const redStyle = useAnimatedStyle(() => ({ opacity: red.get() }));\n  const greenStyle = useAnimatedStyle(() => ({ opacity: green.get() }));\n\n  return (\n    <Animated.View style={[styles.planeBox, body]}>\n      <Canvas style={styles.planeBox}>\n        <Group\n          transform={[\n            { translateX: ICON / 2 },\n            { translateY: ICON / 2 },\n            { scale: SCALE },\n            { translateX: -12 },\n            { translateY: -12 },\n          ]}\n        >\n          <Path path={PLANE} color={colors.textSubtle} />\n          <Path path={PLANE} color={colors.border} style=\"stroke\" strokeWidth={0.8} />\n        </Group>\n      </Canvas>\n      <Animated.View\n        style={[\n          styles.light,\n          styles.lightTop,\n          { backgroundColor: colors.danger, boxShadow: glow(colors.danger, 'strong') },\n          redStyle,\n        ]}\n      />\n      <Animated.View\n        style={[\n          styles.light,\n          styles.lightBottom,\n          { backgroundColor: colors.success, boxShadow: glow(colors.success, 'strong') },\n          greenStyle,\n        ]}\n      />\n    </Animated.View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  shell: { borderWidth: 1, padding: 5 },\n  card: { borderWidth: StyleSheet.hairlineWidth },\n  row: { flexDirection: 'row', alignItems: 'center' },\n  between: { justifyContent: 'space-between' },\n  end: { alignItems: 'center' },\n  grow: { flex: 1 },\n  airport: { alignItems: 'center' },\n  chip: {\n    flexDirection: 'row',\n    alignItems: 'center',\n    height: 32,\n    borderWidth: StyleSheet.hairlineWidth,\n  },\n  zone: { paddingHorizontal: 6, paddingVertical: 3 },\n  route: { height: ICON, justifyContent: 'center' },\n  fill: { position: 'absolute', left: 0, height: BAR, borderRadius: BAR / 2 },\n  rest: {\n    position: 'absolute',\n    right: 0,\n    height: BAR + 2,\n    borderRadius: (BAR + 2) / 2,\n    overflow: 'hidden',\n    opacity: 0.55,\n  },\n  hatch: { flexDirection: 'row', gap: 4, marginLeft: -6, marginTop: -6 },\n  stripe: { width: 3, height: 20, transform: [{ rotate: '35deg' }] },\n  plane: { position: 'absolute', left: 0, width: ICON, height: ICON },\n  planeBox: { width: ICON, height: ICON },\n  light: { position: 'absolute', width: 4, height: 4, borderRadius: 2 },\n  // Wing tips of the turned plane.\n  lightTop: { left: ICON * 0.43 - 2, top: ICON * 0.16 - 2 },\n  lightBottom: { left: ICON * 0.46 - 2, top: ICON * 0.83 - 2 },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "data",
    "web": "live",
    "perf": {
      "budget": "The plane rocks and its lights blink on the UI thread; the route only animates when progress changes. One small Skia canvas for the plane.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 21,
          "p90Ms": 24,
          "baselineMs": 17,
          "jankyPercent": 0.1,
          "atRest": "animating",
          "memoryMb": 162,
          "notes": "Animating at rest: the plane rocks and its wing lights blink while it is in the air; both stop once landed."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The plane jumps to its place, does not rock and its lights stay on.",
      "screenReader": "One progress bar reading the route and times (\"LHR, London, UK, to OPO, Porto, PT. Departs 20:50 GMT+1, arrives 22:40 GMT+1.\") with \"55% of the way\".",
      "touchTarget": "Not interactive."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { FlightTrack } from '@/components/kinetik/flight-track';\n\n<FlightTrack\n  from={{ code: 'LHR', city: 'London, UK', time: '20:50', zone: 'GMT+1' }}\n  to={{ code: 'OPO', city: 'Porto, PT', time: '22:40', zone: 'GMT+1' }}\n  progress={elapsed / duration}\n/>;\n```\n\n## When to use\n\n- Live flight or trip status in a travel app, a booking or a widget.\n- Any journey between two points with a known start and end time: deliveries, train legs, transfers.\n\n## When not to use\n\n- Journeys with stops: one route line cannot show them. Show a timeline instead.\n- When progress is unknown: an estimate that jumps backwards confuses people.\n\n## Notes\n\n- `progress` is yours to compute (for example elapsed time over scheduled time). Each change glides the plane along the route.\n- Below 460 pt wide the times move under the route so the codes keep their size.\n- The plane is the Tabler Icons plane (MIT licence, via iconstack.io).\n"
  },
  "docs": "Prefer `npx kinetik-ui add flight-track`: it installs dependencies with expo install, so versions match your Expo SDK."
}
