@42-central/ui-react 0.20.2 → 0.22.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 (85) hide show
  1. package/dist/{chunk-45QRQKRC.js → chunk-3L5GLI67.js} +12 -8
  2. package/dist/chunk-3L5GLI67.js.map +1 -0
  3. package/dist/{chunk-C74TV64U.js → chunk-4FEOMQYR.js} +4 -4
  4. package/dist/{chunk-C74TV64U.js.map → chunk-4FEOMQYR.js.map} +1 -1
  5. package/dist/{chunk-LFQDB5OD.js → chunk-D3JYDAUZ.js} +3 -3
  6. package/dist/{chunk-LFQDB5OD.js.map → chunk-D3JYDAUZ.js.map} +1 -1
  7. package/dist/{chunk-UVQXRDRO.js → chunk-DHJB4UJD.js} +3 -3
  8. package/dist/{chunk-UVQXRDRO.js.map → chunk-DHJB4UJD.js.map} +1 -1
  9. package/dist/{chunk-UCCJUFOG.js → chunk-DJAXXLN6.js} +3 -3
  10. package/dist/{chunk-UCCJUFOG.js.map → chunk-DJAXXLN6.js.map} +1 -1
  11. package/dist/{chunk-Z4MBCKG5.js → chunk-FB2G4LNH.js} +4 -4
  12. package/dist/{chunk-Z4MBCKG5.js.map → chunk-FB2G4LNH.js.map} +1 -1
  13. package/dist/{chunk-FDCPMUJK.js → chunk-IRNF274I.js} +3 -3
  14. package/dist/chunk-IRNF274I.js.map +1 -0
  15. package/dist/{chunk-O5W3QWJ6.js → chunk-J44FJ7PH.js} +3 -3
  16. package/dist/{chunk-O5W3QWJ6.js.map → chunk-J44FJ7PH.js.map} +1 -1
  17. package/dist/{chunk-WXL5RP6P.js → chunk-MRAJ45IM.js} +3 -3
  18. package/dist/{chunk-WXL5RP6P.js.map → chunk-MRAJ45IM.js.map} +1 -1
  19. package/dist/{chunk-45TG7H5Q.js → chunk-OZMSXYBX.js} +3 -3
  20. package/dist/{chunk-45TG7H5Q.js.map → chunk-OZMSXYBX.js.map} +1 -1
  21. package/dist/{chunk-37VQGKD6.js → chunk-SZEOTXRZ.js} +4 -4
  22. package/dist/{chunk-37VQGKD6.js.map → chunk-SZEOTXRZ.js.map} +1 -1
  23. package/dist/{chunk-2BNIHOMT.js → chunk-YPFSRZ3T.js} +3 -3
  24. package/dist/{chunk-2BNIHOMT.js.map → chunk-YPFSRZ3T.js.map} +1 -1
  25. package/dist/{chunk-5CNVVA7I.js → chunk-YWTOW7PZ.js} +4 -4
  26. package/dist/{chunk-5CNVVA7I.js.map → chunk-YWTOW7PZ.js.map} +1 -1
  27. package/dist/components/autocomplete/index.js +2 -2
  28. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts +94 -0
  29. package/dist/components/calendar-heatmap/calendar-heatmap-grid.d.ts.map +1 -0
  30. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts +76 -0
  31. package/dist/components/calendar-heatmap/calendar-heatmap.d.ts.map +1 -0
  32. package/dist/components/calendar-heatmap/index.d.ts +2 -0
  33. package/dist/components/calendar-heatmap/index.d.ts.map +1 -0
  34. package/dist/components/calendar-heatmap/index.js +311 -0
  35. package/dist/components/calendar-heatmap/index.js.map +1 -0
  36. package/dist/components/camera/index.js +4 -4
  37. package/dist/components/clipboard/index.js +1 -1
  38. package/dist/components/combobox/index.js +2 -2
  39. package/dist/components/combobox-list/index.js +4 -4
  40. package/dist/components/data-table/index.js +13 -13
  41. package/dist/components/date-picker/index.js +5 -5
  42. package/dist/components/input/index.js +1 -1
  43. package/dist/components/input/input.d.ts.map +1 -1
  44. package/dist/components/menu/index.js +1 -1
  45. package/dist/components/menu/menu.d.ts +7 -5
  46. package/dist/components/menu/menu.d.ts.map +1 -1
  47. package/dist/components/multi-combobox-list/index.js +4 -4
  48. package/dist/components/multi-select/index.js +3 -3
  49. package/dist/components/navigation-progress/index.d.ts +2 -0
  50. package/dist/components/navigation-progress/index.d.ts.map +1 -0
  51. package/dist/components/navigation-progress/index.js +133 -0
  52. package/dist/components/navigation-progress/index.js.map +1 -0
  53. package/dist/components/navigation-progress/navigation-progress.d.ts +46 -0
  54. package/dist/components/navigation-progress/navigation-progress.d.ts.map +1 -0
  55. package/dist/components/number-input/index.js +2 -2
  56. package/dist/components/number-input/number-input.d.ts.map +1 -1
  57. package/dist/components/password-input/index.js +1 -1
  58. package/dist/components/photo-capture/index.js +4 -4
  59. package/dist/components/pills-input/index.js +2 -2
  60. package/dist/components/pin-input/index.js +1 -1
  61. package/dist/components/select/index.js +3 -3
  62. package/dist/components/spotlight/index.js +3 -3
  63. package/dist/components/tags-input/index.js +2 -2
  64. package/dist/components/text-input/index.js +1 -1
  65. package/dist/components/textarea/index.js +1 -1
  66. package/dist/components/time-input/index.js +3 -3
  67. package/dist/components/tree-multi-select/index.js +3 -3
  68. package/dist/components/tree-select/index.js +2 -2
  69. package/dist/index.js +2 -2
  70. package/package.json +1 -1
  71. package/src/as-child.contract.test.tsx +4 -0
  72. package/src/components/calendar-heatmap/calendar-heatmap-grid.test.ts +186 -0
  73. package/src/components/calendar-heatmap/calendar-heatmap-grid.ts +192 -0
  74. package/src/components/calendar-heatmap/calendar-heatmap.test.tsx +180 -0
  75. package/src/components/calendar-heatmap/calendar-heatmap.tsx +385 -0
  76. package/src/components/calendar-heatmap/index.ts +11 -0
  77. package/src/components/input/input.test.tsx +23 -0
  78. package/src/components/input/input.tsx +10 -6
  79. package/src/components/menu/menu.tsx +16 -9
  80. package/src/components/navigation-progress/index.ts +14 -0
  81. package/src/components/navigation-progress/navigation-progress.test.tsx +184 -0
  82. package/src/components/navigation-progress/navigation-progress.tsx +228 -0
  83. package/src/components/number-input/number-input.tsx +3 -4
  84. package/dist/chunk-45QRQKRC.js.map +0 -1
  85. package/dist/chunk-FDCPMUJK.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/image-file.ts","../src/components/camera/camera-machine.ts","../src/components/camera/use-camera.ts","../src/components/camera/platform.ts","../src/components/camera/camera.tsx"],"names":["match","mounted","P","CameraIcon","useRef","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;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,iBAAA,EAAA,EAAkB,SAAA,EAAW,UAAA,EAAY,QAAS,QAAA,EAAS;AAAA;AAAA;AAAA,KAC9D;AAAA,yBACC,KAAA,EAAA,EAAI,SAAA,EAAW,GAAG,kDAAA,EAAoD,UAAA,EAAY,QAAQ,CAAA,EACzF,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA;AAAA,sBACN,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAW,UAAA,EAAY,OAAA,EAAS,CAAA;AAAA,0BAC9C,UAAA,EAAA,EAAW,SAAA,EAAW,GAAG,oBAAA,EAAsB,UAAA,EAAY,IAAI,CAAA,EAAG;AAAA,KAAA,EACrE;AAAA,GAAA,EACF,CAAA;AAEJ,CAAA;AAEO,IAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB;AAAA,EACnD,IAAA,EAAM,UAAA;AAAA,EACN,UAAA,EAAY,gBAAA;AAAA,EACZ,KAAA,EAAO,WAAA;AAAA,EACP,OAAA,EAAS,aAAA;AAAA,EACT,IAAA,EAAM,UAAA;AAAA,EACN,OAAA,EAAS,aAAA;AAAA,EACT,MAAA,EAAQ,iBAAA;AAAA,EACR,IAAA,EAAM;AACR,CAAC","file":"chunk-UCCJUFOG.js","sourcesContent":["const EXTENSIONS: Record<string, string> = {\n \"image/jpeg\": \"jpg\",\n \"image/png\": \"png\",\n \"image/webp\": \"webp\",\n \"image/avif\": \"avif\",\n}\n\n/**\n * A canvas export as a `File`, named and typed for what the browser actually\n * encoded. `toBlob` falls back to PNG for a type it can't encode (Safari has\n * no WebP encoder), so the blob's own type wins over the one asked for.\n *\n * imageFile(blob, \"photo\") // photo.jpg, image/jpeg\n */\nexport const imageFile = (blob: Blob, name: string): File => {\n const type = blob.type || \"image/png\"\n return new File([blob], `${name}.${EXTENSIONS[type] ?? \"png\"}`, {\n type,\n lastModified: Date.now(),\n })\n}\n","import { match, P } from \"ts-pattern\"\nimport { type Ratio, ratioToNumber } from \"../../lib/ratio\"\n\n/**\n * The camera's state machine, kept pure so every transition is unit-tested\n * without a browser: `useCamera` feeds it what `getUserMedia`, the track and\n * the page report, and renders whatever it returns.\n */\n\n/** Which way a camera points: at the user (a selfie) or away (a document). */\nexport type CameraFacing = \"user\" | \"environment\"\n\n/**\n * - `idle`: off. The server render, and after `stop()` or a capture.\n * - `unsupported`: no camera API here (an insecure page, an old browser, an iframe without `allow=\"camera\"`).\n * - `prompt`: ready to ask. The browser's permission prompt comes on `start()`.\n * - `starting`: asked, waiting for the first frame.\n * - `live`: frames are showing.\n * - `paused`: the page was hidden or the track ended. `start()` resumes.\n * - `denied`: the user (or a site setting) refused the camera.\n * - `blocked`: the operating system refused it to the browser.\n * - `busy`: another app or tab holds the camera.\n * - `missing`: no camera matches.\n * - `error`: anything else, including a camera that never sent a frame.\n */\nexport type CameraStatus =\n | \"idle\"\n | \"unsupported\"\n | \"prompt\"\n | \"starting\"\n | \"live\"\n | \"paused\"\n | \"denied\"\n | \"blocked\"\n | \"busy\"\n | \"missing\"\n | \"error\"\n\n/** The statuses a failed `start()` can end in. */\nexport type CameraFailure = Extract<\n CameraStatus,\n \"unsupported\" | \"denied\" | \"blocked\" | \"busy\" | \"missing\" | \"error\"\n>\n\n/** What `navigator.permissions` says, when it says anything. A hint only: Safari keeps reporting `prompt` after a refusal. */\nexport type CameraPermission = \"granted\" | \"denied\" | \"prompt\" | \"unknown\"\n\n/** One video input. `label` is empty until the user grants the camera. */\nexport type CameraDevice = { id: string; label: string; facing: CameraFacing | null }\n\n/** A capture size to aim for, in px. Always `ideal`: the camera picks the closest it has. */\nexport type CameraResolution = { width: number; height: number }\n\nexport type CameraState = {\n status: CameraStatus\n /** Whether the client-side checks ran. `false` on the server and on the first client render. */\n ready: boolean\n permission: CameraPermission\n facing: CameraFacing\n /** The camera asked for, then the one actually opened. */\n device: string | null\n devices: readonly CameraDevice[]\n capabilities: MediaTrackCapabilities | null\n}\n\nexport type CameraEvent =\n | { type: \"mount\"; supported: boolean; permission: CameraPermission; lazy?: boolean }\n | { type: \"permission\"; permission: CameraPermission }\n | { type: \"request\" }\n | {\n type: \"stream\"\n device: string | null\n facing: CameraFacing | null\n capabilities: MediaTrackCapabilities | null\n }\n | { type: \"frame\" }\n | { type: \"timeout\" }\n | { type: \"fail\"; status: CameraFailure }\n | { type: \"pause\" }\n | { type: \"stop\" }\n | { type: \"devices\"; devices: readonly CameraDevice[] }\n | { type: \"target\"; device: string | null; facing: CameraFacing }\n\nexport const initialCameraState = (\n facing: CameraFacing,\n device: string | null = null,\n): CameraState => ({\n status: \"idle\",\n ready: false,\n permission: \"unknown\",\n facing,\n device,\n devices: [],\n capabilities: null,\n})\n\n/** Where the client lands once it knows what the browser supports and allows. */\nconst mounted = (supported: boolean, permission: CameraPermission, lazy: boolean): CameraStatus =>\n match({ supported, permission, lazy })\n .returnType<CameraStatus>()\n .with({ supported: false }, () => \"unsupported\")\n // Already granted but lazy: off, until `start()`.\n .with({ permission: \"granted\", lazy: true }, () => \"idle\")\n // Already granted: no priming screen, `useCamera` starts straight away.\n .with({ permission: \"granted\" }, () => \"starting\")\n // A known refusal: getUserMedia would fail at once, so go to the recovery steps.\n .with({ permission: \"denied\" }, () => \"denied\")\n .otherwise(() => \"prompt\")\n\nexport const reduceCamera = (state: CameraState, event: CameraEvent): CameraState =>\n match(event)\n .returnType<CameraState>()\n .with({ type: \"mount\" }, ({ supported, permission, lazy = false }) => ({\n ...state,\n ready: true,\n permission,\n status: mounted(supported, permission, lazy),\n }))\n .with({ type: \"permission\" }, ({ permission }) => ({\n ...state,\n permission,\n status: state.status === \"prompt\" && permission === \"denied\" ? \"denied\" : state.status,\n }))\n .with({ type: \"request\" }, () =>\n state.status === \"unsupported\" ? state : { ...state, status: \"starting\" },\n )\n .with({ type: \"stream\" }, ({ device, facing, capabilities }) => ({\n ...state,\n permission: \"granted\",\n device: device ?? state.device,\n facing: facing ?? state.facing,\n capabilities,\n }))\n .with({ type: \"frame\" }, () =>\n state.status === \"starting\" ? { ...state, status: \"live\" } : state,\n )\n .with({ type: \"timeout\" }, () =>\n state.status === \"starting\" ? { ...state, status: \"error\" } : state,\n )\n .with({ type: \"fail\" }, ({ status }) => ({\n ...state,\n status,\n permission: status === \"denied\" || status === \"blocked\" ? \"denied\" : state.permission,\n }))\n .with({ type: \"pause\" }, () =>\n state.status === \"live\" || state.status === \"starting\"\n ? { ...state, status: \"paused\" }\n : state,\n )\n .with({ type: \"stop\" }, () =>\n state.status === \"unsupported\" ? state : { ...state, status: \"idle\", capabilities: null },\n )\n .with({ type: \"devices\" }, ({ devices }) => ({ ...state, devices }))\n .with({ type: \"target\" }, ({ device, facing }) => ({ ...state, device, facing }))\n .exhaustive()\n\n/** The `name` of a thrown DOMException, or of anything shaped like one. */\nconst nameOf = (error: unknown): string =>\n match(error)\n .with({ name: P.string }, ({ name }) => name)\n .otherwise(() => \"\")\n\nconst messageOf = (error: unknown): string =>\n match(error)\n .with({ message: P.string }, ({ message }) => message)\n .otherwise(() => \"\")\n\n/**\n * The status a `getUserMedia` rejection means. Chrome tells an OS-level\n * refusal apart only by its message (\"Permission denied by system\"); the\n * legacy names are older Chrome and Firefox spellings of the same errors.\n */\nexport const failureOf = (error: unknown): CameraFailure =>\n match(nameOf(error))\n .returnType<CameraFailure>()\n .with(\"NotAllowedError\", \"PermissionDeniedError\", () =>\n /system/i.test(messageOf(error)) ? \"blocked\" : \"denied\",\n )\n .with(\"NotFoundError\", \"DevicesNotFoundError\", \"OverconstrainedError\", () => \"missing\")\n .with(\"NotReadableError\", \"TrackStartError\", () => \"busy\")\n // NotSupportedError: a browser that can't show a prompt here (a headless one, some webviews).\n .with(\"SecurityError\", \"NotSupportedError\", () => \"unsupported\")\n .otherwise(() => \"error\")\n\nexport const isOverconstrained = (error: unknown) => nameOf(error) === \"OverconstrainedError\"\n\n/** The resolution asked for when none is given: enough for a sharp photo, cheap for any webcam to approximate. */\nexport const DEFAULT_RESOLUTION: CameraResolution = { width: 1920, height: 1080 }\n\ntype ConstraintsInput = {\n device: string | null\n facing: CameraFacing\n ratio?: Ratio\n resolution?: CameraResolution\n}\n\n/**\n * What to ask `getUserMedia` for. Every constraint about the picture is\n * `ideal`: a camera that can't match gets the closest it has instead of an\n * `OverconstrainedError`.\n *\n * A chosen device is the one exception, `exact`, and wins over `facing`. As\n * an `ideal` it's only one term in Chrome's fitness distance, which an ideal\n * resolution the other camera matches better can outweigh: a flip or a pick\n * would quietly reopen the same camera. If that device is gone, the\n * `OverconstrainedError` is retried with `looseConstraintsOf`.\n */\nexport const constraintsOf = ({\n device,\n facing,\n ratio,\n resolution = DEFAULT_RESOLUTION,\n}: ConstraintsInput): MediaStreamConstraints => {\n const aspect = ratio === undefined ? Number.NaN : ratioToNumber(ratio)\n return {\n audio: false,\n video: {\n ...(device ? { deviceId: { exact: device } } : { facingMode: { ideal: facing } }),\n width: { ideal: resolution.width },\n height: { ideal: resolution.height },\n ...(Number.isFinite(aspect) && aspect > 0 ? { aspectRatio: { ideal: aspect } } : {}),\n },\n }\n}\n\n/** The one retry after an `OverconstrainedError`: the chosen camera if it's there, else any, at whatever size. */\nexport const looseConstraintsOf = ({\n device,\n}: {\n device: string | null\n}): MediaStreamConstraints => ({\n audio: false,\n video: device ? { deviceId: { ideal: device } } : true,\n})\n\n/** A device's facing, from its capabilities when the browser reports them, else from its label. */\nexport const facingOf = (label: string, reported?: readonly string[]): CameraFacing | null => {\n const named = reported?.find((mode) => mode === \"user\" || mode === \"environment\")\n if (named === \"user\" || named === \"environment\") return named\n if (/\\b(front|user|face|selfie|facetime)\\b/i.test(label)) return \"user\"\n if (/\\b(back|rear|environment|world)\\b/i.test(label)) return \"environment\"\n return null\n}\n\nconst opposite = (facing: CameraFacing): CameraFacing =>\n facing === \"user\" ? \"environment\" : \"user\"\n\n/**\n * Where `flip()` goes. On a phone the devices report a facing, so it's the\n * first camera facing the other way. Without facings (two webcams on a\n * desktop) it's the next camera in the list. With no list yet, it's the other\n * `facingMode`.\n */\nexport const flipTarget = ({\n facing,\n device,\n devices,\n}: Pick<CameraState, \"facing\" | \"device\" | \"devices\">): {\n device: string | null\n facing: CameraFacing\n} => {\n const other = devices.find((d) => d.facing !== null && d.facing !== facing && d.id)\n if (other?.facing) return { device: other.id, facing: other.facing }\n const usable = devices.filter((d) => d.id)\n if (usable.length > 1) {\n const index = usable.findIndex((d) => d.id === device)\n const next = usable[(index + 1) % usable.length]\n if (next) return { device: next.id, facing: next.facing ?? facing }\n }\n return { device: null, facing: opposite(facing) }\n}\n\n/** The statuses that hold, or are about to hold, a stream. */\nexport const isActive = (status: CameraStatus) => status === \"starting\" || status === \"live\"\n","\"use client\"\n\nimport {\n type RefCallback,\n type SyntheticEvent,\n useCallback,\n useEffect,\n useReducer,\n useRef,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { imageFile } from \"../../lib/image-file\"\nimport type { Ratio } from \"../../lib/ratio\"\nimport { useDocumentVisibility } from \"../../lib/use-document-visibility\"\nimport { useIsomorphicLayoutEffect } from \"../../lib/use-isomorphic-layout-effect\"\nimport {\n type CameraDevice,\n type CameraFacing,\n type CameraPermission,\n type CameraResolution,\n type CameraState,\n type CameraStatus,\n constraintsOf,\n facingOf,\n failureOf,\n flipTarget,\n initialCameraState,\n isActive,\n isOverconstrained,\n looseConstraintsOf,\n reduceCamera,\n} from \"./camera-machine\"\n\nexport type UseCameraOptions = {\n /** The camera to open first, when no `device` is given. Defaults to `user`, the selfie camera. */\n facing?: CameraFacing\n /** A `deviceId` to open first, from `devices` (or one you remembered). Wins over `facing`. */\n device?: string\n /** The frame shape to ask for, as width / height. The viewfinder uses it for its box too. */\n ratio?: Ratio\n /** The capture size to aim for. Defaults to 1920×1080; the camera picks the closest it has. */\n resolution?: CameraResolution\n /**\n * Waits for `start()` even when the camera is already allowed, instead of\n * turning it on as the hook mounts. For a camera that sits behind a choice\n * (a \"Take photo\" button, a tab) and must not light up before it.\n */\n lazy?: boolean\n}\n\nexport type CameraCaptureOptions = {\n /** The encoding. A browser that can't encode it falls back to PNG, and the File says so. Defaults to `image/jpeg`. */\n type?: string\n /** 0–1, for JPEG and WebP. Defaults to 0.9. */\n quality?: number\n /** Saves the photo mirrored, as the selfie preview shows it. Off by default: a saved selfie reads the right way round. */\n mirror?: boolean\n}\n\n/** Spread on the `<video>` that shows the camera. `Camera.Viewfinder` does it for you. */\nexport type CameraVideoProps = {\n ref: RefCallback<HTMLVideoElement>\n autoPlay: true\n muted: true\n playsInline: true\n onLoadedData: (event: SyntheticEvent<HTMLVideoElement>) => void\n onPlaying: (event: SyntheticEvent<HTMLVideoElement>) => void\n}\n\nexport type UseCameraResult = {\n status: CameraStatus\n /** Whether the client has checked support and permission yet. `false` on the server. */\n ready: boolean\n /** The permission hint. `granted` once a stream has opened, whatever the browser reported. */\n permission: CameraPermission\n /** The open camera's facing, or the one asked for. Desktop webcams count as `user`. */\n facing: CameraFacing\n /** The open camera's `deviceId`, or the one asked for. */\n device: string | null\n /** Every video input. Labels are empty until the camera is granted. Updated on `devicechange`. */\n devices: readonly CameraDevice[]\n /** Where `flip()` would go, for its label. */\n next: { device: string | null; facing: CameraFacing }\n /** The open track's capabilities (zoom, torch, resolution range), where the browser reports them. */\n capabilities: MediaTrackCapabilities | null\n ratio: Ratio | undefined\n /** Opens the camera, asking for permission if it must. Also resumes after `paused`, and retries after a failure. */\n start: () => Promise<void>\n /** Turns the camera off, light included. */\n stop: () => void\n /** Switches to the camera facing the other way, or the next one. */\n flip: () => void\n /** Switches to a camera from `devices`. */\n select: (device: string) => void\n /**\n * Takes a photo of the full frame, at the camera's own resolution, and\n * turns the camera off. The File carries no EXIF and nothing is uploaded.\n * Rejects when the camera isn't live.\n */\n capture: (options?: CameraCaptureOptions) => Promise<File>\n /** The `<video>`'s ref, also inside `props`. */\n videoRef: RefCallback<HTMLVideoElement>\n /** Spread on your own `<video>`. */\n props: CameraVideoProps\n}\n\n/** How long a camera has to send its first frame before it counts as an error. */\nexport const WARM_UP_TIMEOUT = 8000\n\nconst stopTracks = (stream: MediaStream | null) => {\n stream?.getTracks().forEach((track) => {\n track.stop()\n })\n}\n\nconst permissionOf = (state: string): CameraPermission =>\n match(state)\n .returnType<CameraPermission>()\n .with(\"granted\", \"denied\", \"prompt\", (known) => known)\n .otherwise(() => \"unknown\")\n\nconst deviceOf = (info: MediaDeviceInfo): CameraDevice => {\n const reported =\n typeof InputDeviceInfo !== \"undefined\" &&\n info instanceof InputDeviceInfo &&\n typeof info.getCapabilities === \"function\"\n ? info.getCapabilities().facingMode\n : undefined\n return { id: info.deviceId, label: info.label, facing: facingOf(info.label, reported) }\n}\n\nconst play = (video: HTMLVideoElement) => {\n try {\n // An explicit play(), on top of `autoplay`: iOS Safari won't start a\n // `srcObject` stream otherwise. Its rejection (a pause, a new source) is\n // harmless; the first frame is what counts.\n Promise.resolve(video.play()).catch(() => {})\n } catch {\n // jsdom and other DOMs without media playback.\n }\n}\n\n/**\n * The camera as plain state plus handlers, for `Camera.Root` or your own\n * viewfinder. It owns everything `getUserMedia` makes hard: permission,\n * error names, switching cameras, a stream that arrives after unmount, the\n * page being hidden, and turning the light off.\n *\n * SSR-safe: it reads `navigator` only in effects, so the server and the first\n * client render are `idle`. Once mounted it goes to `prompt`, or straight to\n * `starting` when the camera is already granted (unless `lazy`, which stays\n * `idle` until `start()`).\n *\n * const camera = useCamera({ facing: \"environment\" })\n * <video {...camera.props} />\n * <button onClick={() => camera.capture().then(upload)}>Take photo</button>\n *\n * The camera stops after `capture()`, on `stop()`, on unmount and on\n * `pagehide`. Hiding the page, or a track that ends (another app took the\n * camera), pauses it; `start()` resumes.\n */\nexport function useCamera({\n facing = \"user\",\n device,\n ratio,\n resolution,\n lazy = false,\n}: UseCameraOptions = {}): UseCameraResult {\n const [state, dispatch] = useReducer(reduceCamera, undefined, () =>\n initialCameraState(facing, device ?? null),\n )\n\n // Interop with the media APIs, not state: the open stream, the element\n // showing it, and what the async callbacks need to read at the time they run.\n const stream = useRef<MediaStream | null>(null)\n const video = useRef<HTMLVideoElement | null>(null)\n /** Bumped by every open and close, so a stream that resolves for an older one is stopped. */\n const generation = useRef(0)\n const mounted = useRef(false)\n const warmUp = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef<CameraState>(state)\n const config = useRef({ ratio, resolution, lazy })\n\n useIsomorphicLayoutEffect(() => {\n latest.current = state\n config.current = { ratio, resolution, lazy }\n })\n\n const release = useCallback(() => {\n generation.current += 1\n clearTimeout(warmUp.current)\n stopTracks(stream.current)\n stream.current = null\n if (video.current) video.current.srcObject = null\n }, [])\n\n const enumerate = useCallback(async () => {\n try {\n const all = await navigator.mediaDevices.enumerateDevices()\n if (!mounted.current) return\n dispatch({\n type: \"devices\",\n devices: all.filter((info) => info.kind === \"videoinput\").map(deviceOf),\n })\n } catch {\n // A list we can't read leaves the last one in place.\n }\n }, [])\n\n const pause = useCallback(() => {\n release()\n dispatch({ type: \"pause\" })\n }, [release])\n\n const open = useCallback(\n async (target: { device: string | null; facing: CameraFacing }) => {\n // Stop the current camera before asking for the next: a phone opens one at a time.\n release()\n const id = generation.current\n dispatch({ type: \"request\" })\n const media = typeof navigator === \"undefined\" ? undefined : navigator.mediaDevices\n if (typeof media?.getUserMedia !== \"function\") {\n dispatch({ type: \"fail\", status: \"unsupported\" })\n return\n }\n const request = { ...target, ...config.current }\n try {\n const next = await media.getUserMedia(constraintsOf(request)).catch((error: unknown) => {\n if (!isOverconstrained(error)) throw error\n return media.getUserMedia(looseConstraintsOf(request))\n })\n if (id !== generation.current || !mounted.current) {\n // Closed, unmounted or replaced while the prompt was up (Strict Mode's double effect, a fast flip).\n stopTracks(next)\n return\n }\n stream.current = next\n if (video.current) {\n video.current.srcObject = next\n play(video.current)\n }\n const [track] = next.getVideoTracks()\n const settings = track?.getSettings()\n const lost = () => {\n if (stream.current === next) pause()\n }\n track?.addEventListener(\"ended\", lost)\n track?.addEventListener(\"mute\", lost)\n dispatch({\n type: \"stream\",\n device: settings?.deviceId ?? null,\n // A track that doesn't say is a desktop webcam, which faces the user.\n facing:\n facingOf(track?.label ?? \"\", settings?.facingMode ? [settings.facingMode] : []) ??\n \"user\",\n capabilities:\n track && typeof track.getCapabilities === \"function\" ? track.getCapabilities() : null,\n })\n warmUp.current = setTimeout(() => dispatch({ type: \"timeout\" }), WARM_UP_TIMEOUT)\n // Labels and facings only appear once the camera is granted.\n void enumerate()\n } catch (error) {\n if (id !== generation.current || !mounted.current) return\n dispatch({ type: \"fail\", status: failureOf(error) })\n }\n },\n [release, pause, enumerate],\n )\n\n useEffect(() => {\n mounted.current = true\n let cancelled = false\n let permissionStatus: PermissionStatus | null = null\n const onPermission = () => {\n if (permissionStatus)\n dispatch({ type: \"permission\", permission: permissionOf(permissionStatus.state) })\n }\n const media = typeof navigator === \"undefined\" ? undefined : navigator.mediaDevices\n const supported = window.isSecureContext !== false && typeof media?.getUserMedia === \"function\"\n\n const check = async (): Promise<CameraPermission> => {\n try {\n permissionStatus = await navigator.permissions.query({ name: \"camera\" })\n permissionStatus.addEventListener(\"change\", onPermission)\n return permissionOf(permissionStatus.state)\n } catch {\n // No Permissions API, or no \"camera\" in it (older Firefox): no hint.\n return \"unknown\"\n }\n }\n\n void (async () => {\n const permission = supported ? await check() : \"unknown\"\n if (cancelled) return\n const { lazy: waiting } = config.current\n dispatch({ type: \"mount\", supported, permission, lazy: waiting })\n if (!supported) return\n void enumerate()\n if (permission === \"granted\" && !waiting) {\n const { device: current, facing: wanted } = latest.current\n void open({ device: current, facing: wanted })\n }\n })()\n\n const onDeviceChange = () => void enumerate()\n const onPageHide = () => {\n release()\n dispatch({ type: \"stop\" })\n }\n media?.addEventListener(\"devicechange\", onDeviceChange)\n window.addEventListener(\"pagehide\", onPageHide)\n\n return () => {\n cancelled = true\n mounted.current = false\n release()\n permissionStatus?.removeEventListener(\"change\", onPermission)\n media?.removeEventListener(\"devicechange\", onDeviceChange)\n window.removeEventListener(\"pagehide\", onPageHide)\n }\n }, [enumerate, open, release])\n\n // A hidden page keeps no camera live: pause, which also turns the light off.\n const visibility = useDocumentVisibility()\n useEffect(() => {\n if (visibility === \"hidden\" && stream.current) pause()\n }, [visibility, pause])\n\n const stop = useCallback(() => {\n release()\n dispatch({ type: \"stop\" })\n }, [release])\n\n const start = useCallback(() => {\n const { device: current, facing: wanted } = latest.current\n return open({ device: current, facing: wanted })\n }, [open])\n\n const retarget = useCallback(\n (target: { device: string | null; facing: CameraFacing }) => {\n dispatch({ type: \"target\", ...target })\n if (isActive(latest.current.status)) void open(target)\n },\n [open],\n )\n\n const flip = useCallback(() => retarget(flipTarget(latest.current)), [retarget])\n\n const select = useCallback(\n (id: string) => {\n const chosen = latest.current.devices.find((d) => d.id === id)\n retarget({ device: id, facing: chosen?.facing ?? latest.current.facing })\n },\n [retarget],\n )\n\n const capture = useCallback(\n async ({ type = \"image/jpeg\", quality = 0.9, mirror = false }: CameraCaptureOptions = {}) => {\n const el = video.current\n if (!el || latest.current.status !== \"live\" || el.videoWidth === 0) {\n throw new Error(\"[@42/ui-react] useCamera: capture() needs a live camera.\")\n }\n // The full native frame, not the cropped box the viewfinder shows.\n const canvas = document.createElement(\"canvas\")\n canvas.width = el.videoWidth\n canvas.height = el.videoHeight\n const context = canvas.getContext(\"2d\")\n if (!context) throw new Error(\"[@42/ui-react] useCamera: no 2D canvas to capture with.\")\n if (mirror) {\n context.translate(canvas.width, 0)\n context.scale(-1, 1)\n }\n context.drawImage(el, 0, 0, canvas.width, canvas.height)\n // The frame is drawn: the light goes off before encoding.\n stop()\n const blob = await new Promise<Blob | null>((resolve) =>\n canvas.toBlob(resolve, type, quality),\n )\n if (!blob) throw new Error(\"[@42/ui-react] useCamera: the photo couldn't be encoded.\")\n // Safari has no WebP encoder and hands back PNG: the file says so.\n return imageFile(blob, \"photo\")\n },\n [stop],\n )\n\n const videoRef = useCallback((node: HTMLVideoElement | null) => {\n video.current = node\n if (!node) return\n // React doesn't reflect `muted` to the attribute, which iOS autoplay checks.\n node.muted = true\n if (stream.current && node.srcObject !== stream.current) {\n node.srcObject = stream.current\n play(node)\n }\n }, [])\n\n const onFrame = useCallback((event: SyntheticEvent<HTMLVideoElement>) => {\n if (event.currentTarget.videoWidth === 0) return\n clearTimeout(warmUp.current)\n dispatch({ type: \"frame\" })\n }, [])\n\n return {\n status: state.status,\n ready: state.ready,\n permission: state.permission,\n facing: state.facing,\n device: state.device,\n devices: state.devices,\n next: flipTarget(state),\n capabilities: state.capabilities,\n ratio,\n start,\n stop,\n flip,\n select,\n capture,\n videoRef,\n props: {\n ref: videoRef,\n autoPlay: true,\n muted: true,\n playsInline: true,\n onLoadedData: onFrame,\n onPlaying: onFrame,\n },\n }\n}\n","import { match, P } from \"ts-pattern\"\n\n/**\n * Which recovery steps to show after a refusal. Detection is deliberately\n * conservative: anything not clearly one of these gets the generic steps,\n * which are right everywhere, rather than precise steps for the wrong browser.\n */\n\n/** The browser whose settings a `denied` camera is fixed in. */\nexport type CameraBrowser =\n | \"chrome-desktop\"\n | \"chrome-android\"\n | \"safari-macos\"\n | \"safari-ios\"\n | \"firefox\"\n | \"other\"\n\n/** The operating system whose settings a `blocked` camera is fixed in. */\nexport type CameraOs = \"macos\" | \"windows\" | \"android\" | \"ios\" | \"other\"\n\nexport type CameraPlatform = { browser: CameraBrowser; os: CameraOs }\n\nexport const UNKNOWN_PLATFORM: CameraPlatform = { browser: \"other\", os: \"other\" }\n\n/**\n * `navigator.userAgent` plus `maxTouchPoints`, which is how an iPad that\n * claims to be a Mac is told apart. Every iOS browser runs on WebKit with\n * Safari's permission model, so iOS is always `safari-ios`.\n */\nexport const detectPlatform = (userAgent: string, touchPoints = 0): CameraPlatform => {\n const ios = /iPhone|iPad|iPod/.test(userAgent) || (/Macintosh/.test(userAgent) && touchPoints > 1)\n const android = /Android/.test(userAgent)\n const os = match({ ios, android, userAgent })\n .returnType<CameraOs>()\n .with({ ios: true }, () => \"ios\")\n .with({ android: true }, () => \"android\")\n .with({ userAgent: P.string.regex(/Mac OS X|Macintosh/) }, () => \"macos\")\n .with({ userAgent: P.string.regex(/Windows/) }, () => \"windows\")\n .otherwise(() => \"other\")\n const firefox = /Firefox\\//.test(userAgent)\n // Edge, Opera, Brave and Samsung Internet all say \"Chrome/\" and share its settings.\n const chromium = /Chrome\\/|CriOS\\//.test(userAgent)\n const safari = /Safari\\//.test(userAgent) && !chromium\n const browser = match({ os, firefox, chromium, safari })\n .returnType<CameraBrowser>()\n .with({ os: \"ios\" }, () => \"safari-ios\")\n .with({ firefox: true }, () => \"firefox\")\n .with({ chromium: true, os: \"android\" }, () => \"chrome-android\")\n .with({ chromium: true, os: P.union(\"macos\", \"windows\", \"other\") }, () => \"chrome-desktop\")\n .with({ safari: true, os: \"macos\" }, () => \"safari-macos\")\n .otherwise(() => \"other\")\n return { browser, os }\n}\n","\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react/factory\"\nimport { Camera as CameraIcon, CameraOff, RotateCcw, SwitchCamera } from \"lucide-react\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type MouseEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { type CutoutRect, cutoutMask } from \"../../lib/cutout\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useDirectionCheck, useLocale } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { animate, durationOf } from \"../../lib/motion/animate\"\nimport { prefersReducedMotion } from \"../../lib/motion/reduced-motion\"\nimport { props } from \"../../lib/props\"\nimport { MEDIA_RADIUS, type MediaRadius } from \"../../lib/radius\"\nimport { type Ratio, ratioStyle, ratioToNumber } from \"../../lib/ratio\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { ActionIcon } from \"../action-icon/action-icon\"\nimport { Badge } from \"../badge/badge\"\nimport { Button } from \"../button/button\"\nimport { Select } from \"../select/select\"\nimport { Skeleton } from \"../skeleton/skeleton\"\nimport type { CameraFacing, CameraStatus } from \"./camera-machine\"\nimport {\n type CameraBrowser,\n type CameraOs,\n type CameraPlatform,\n detectPlatform,\n UNKNOWN_PLATFORM,\n} from \"./platform\"\nimport {\n type CameraCaptureOptions,\n type UseCameraOptions,\n type UseCameraResult,\n useCamera,\n} from \"./use-camera\"\n\n/**\n * Camera — take a photo in the page: a live viewfinder, a framing guide, a\n * shutter, a camera switch, and a panel for every state the camera can be in,\n * from the first permission prompt to the steps that undo a refusal.\n *\n * <Camera facing=\"user\" shape=\"circle\" onCapture={(file) => setPhoto(file)} />\n *\n * The parts read `useCamera`, the headless hook that owns `getUserMedia`, so\n * the same camera can drive your own layout:\n *\n * const camera = useCamera({ facing: \"environment\", ratio: \"4/3\" })\n * <Camera.Root camera={camera} onCapture={upload}>\n * <Camera.Viewfinder>\n * <Camera.Guide shape=\"rectangle\" ratio={1.586} />\n * <Camera.Status />\n * </Camera.Viewfinder>\n * <Camera.Shutter />\n * </Camera.Root>\n *\n * The photo comes back as a `File` through `onCapture`: the full frame at the\n * camera's own resolution, without EXIF, never uploaded. The camera turns off\n * once it's taken.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type CameraGuideShape = \"circle\" | \"rectangle\"\n\nexport type CameraTranslations = {\n /** The video's accessible name. */\n viewfinder?: string\n /** Before the first prompt: why the browser is about to ask. */\n primeTitle?: string\n primeBody?: string\n /** The button that asks for the camera. */\n enable?: string\n /** After `stop()` or a capture. */\n offTitle?: string\n /** The button that turns it back on. */\n start?: string\n starting?: string\n pausedTitle?: string\n /** The button that resumes a paused camera. */\n resume?: string\n busyTitle?: string\n busyBody?: string\n missingTitle?: string\n missingBody?: string\n unsupportedTitle?: string\n unsupportedBody?: string\n errorTitle?: string\n errorBody?: string\n retry?: string\n deniedTitle?: string\n deniedBody?: string\n /** How to allow the camera again, step by step, in the browser the visitor is using. */\n deniedSteps?: (browser: CameraBrowser) => readonly string[]\n blockedTitle?: string\n blockedBody?: string\n /** How to let the browser use the camera again, in the operating system's settings. */\n blockedSteps?: (os: CameraOs) => readonly string[]\n shutter?: string\n /** The switch's name, saying where it goes: the facing, or `null` for the next of several webcams. */\n flip?: (facing: CameraFacing | null) => string\n /** The camera picker's label. */\n devices?: string\n /** A camera with no label (before the grant), by its position. `index` is formatted. */\n device?: (index: string) => string\n /** The \"camera on\" badge. */\n live?: string\n /** Announced politely as the camera changes state. */\n announceStarting?: string\n announceReady?: string\n announcePaused?: string\n announceTaken?: string\n}\n\nconst DENIED_STEPS: Record<CameraBrowser, readonly string[]> = {\n \"chrome-desktop\": [\n \"Select the camera icon, or the site settings icon, next to the address.\",\n \"Set Camera to Allow.\",\n \"Select Try again.\",\n ],\n \"chrome-android\": [\n \"Tap the site settings icon next to the address.\",\n \"Tap Permissions, then Camera, and choose Allow.\",\n \"Come back and tap Try again.\",\n ],\n \"safari-macos\": [\n \"In the menu bar, choose Safari, then Settings for this website.\",\n \"Set Camera to Allow.\",\n \"Select Try again.\",\n ],\n \"safari-ios\": [\n \"Tap the page menu in the address bar, then Website Settings.\",\n \"Set Camera to Allow.\",\n \"Tap Try again.\",\n ],\n firefox: [\n \"Select the crossed-out camera icon in the address bar.\",\n \"Remove the Blocked setting for the camera.\",\n \"Select Try again.\",\n ],\n other: [\n \"Open this site's settings, usually from the icon next to the address.\",\n \"Allow the camera.\",\n \"Try again.\",\n ],\n}\n\nconst BLOCKED_STEPS: Record<CameraOs, readonly string[]> = {\n macos: [\n \"Open System Settings, then Privacy & Security, then Camera.\",\n \"Turn on your browser.\",\n \"Reopen the browser if it asks, then select Try again.\",\n ],\n windows: [\n \"Open Settings, then Privacy & security, then Camera.\",\n \"Turn on Camera access, and Let desktop apps access your camera.\",\n \"Select Try again.\",\n ],\n android: [\n \"Open Settings, then Apps, then your browser.\",\n \"Tap Permissions, then Camera, and choose Allow.\",\n \"Come back and tap Try again.\",\n ],\n ios: [\n \"Open Settings, then Apps, then your browser.\",\n \"Turn on Camera.\",\n \"Come back and tap Try again.\",\n ],\n other: [\"Open your system's privacy settings.\", \"Let your browser use the camera.\", \"Try again.\"],\n}\n\nexport const DEFAULT_TRANSLATIONS: Required<CameraTranslations> = {\n viewfinder: \"Camera preview\",\n primeTitle: \"Take a photo with your camera\",\n primeBody:\n \"Your browser will ask to use the camera. It's only on while you take the photo, and nothing is uploaded until you choose to.\",\n enable: \"Enable camera\",\n offTitle: \"The camera is off\",\n start: \"Turn on camera\",\n starting: \"Starting the camera…\",\n pausedTitle: \"The camera is paused\",\n resume: \"Tap to resume\",\n busyTitle: \"The camera is in use\",\n busyBody: \"Another app or tab is using it. Close it, then try again.\",\n missingTitle: \"No camera found\",\n missingBody: \"Connect a camera, or check that it's turned on, then try again.\",\n unsupportedTitle: \"The camera isn't available here\",\n unsupportedBody: \"This browser can't use the camera on this page.\",\n errorTitle: \"The camera couldn't start\",\n errorBody: \"Something went wrong while starting it.\",\n retry: \"Try again\",\n deniedTitle: \"Camera access is blocked\",\n deniedBody: \"To take a photo, allow the camera for this site:\",\n deniedSteps: (browser) => DENIED_STEPS[browser],\n blockedTitle: \"Your system is blocking the camera\",\n blockedBody: \"Your browser isn't allowed to use the camera. To allow it:\",\n blockedSteps: (os) => BLOCKED_STEPS[os],\n shutter: \"Take photo\",\n flip: (facing) =>\n match(facing)\n .with(\"user\", () => \"Switch to front camera\")\n .with(\"environment\", () => \"Switch to back camera\")\n .with(null, () => \"Switch camera\")\n .exhaustive(),\n devices: \"Camera\",\n device: (index) => `Camera ${index}`,\n live: \"Camera on\",\n announceStarting: \"Starting the camera\",\n announceReady: \"Camera ready\",\n announcePaused: \"Camera paused\",\n announceTaken: \"Photo taken\",\n}\n\n/** The replaceable icons, by slot: the buttons that turn the camera on share `start`, a failure panel shows `off`. */\nexport type CameraIconSlot = \"shutter\" | \"flip\" | \"start\" | \"retry\" | \"off\"\nexport type CameraIcons = IconMap<CameraIconSlot>\n\nexport const DEFAULT_ICONS: Record<CameraIconSlot, ReactNode> = {\n shutter: <CameraIcon aria-hidden className={iconStroke} />,\n flip: <SwitchCamera aria-hidden className={iconStroke} />,\n start: <CameraIcon aria-hidden className={iconStroke} />,\n retry: <RotateCcw aria-hidden className={iconStroke} />,\n off: <CameraOff aria-hidden className={iconStroke} />,\n}\n\ntype Shared = {\n camera: UseCameraResult\n t: Required<CameraTranslations>\n icons: Record<CameraIconSlot, ReactNode>\n output: Omit<CameraCaptureOptions, \"mirror\">\n mirror: boolean\n onCapture?: (file: File) => void\n /** The viewfinder's flash overlay, played by the shutter. */\n flash: RefObject<HTMLDivElement | null>\n announce: (message: string) => void\n number: (value: number) => string\n}\n\nconst CameraContext = createContext<Shared | null>(null)\n\n/** The nearest `Camera.Root`'s camera, translations and icons, for a part of your own. */\nexport const useCameraContext = (): Shared => {\n const shared = useContext(CameraContext)\n if (!shared) throw new Error(\"[@42/ui-react] Camera parts must be inside <Camera.Root>.\")\n return shared\n}\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\n/** A ≥ 44px control (WCAG 2.5.8). */\nconst control = \"size-11 [&_svg]:size-5\"\n\n/** The viewfinder's box when neither the part nor the hook names a ratio: a webcam's usual frame. */\nconst DEFAULT_RATIO: Ratio = \"4/3\"\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type CameraRootProps = Omit<HTMLArkProps<\"div\">, \"color\"> &\n WithTestId & {\n /** The camera, from `useCamera()`. */\n camera: UseCameraResult\n /** Receives the photo once the shutter is pressed. The camera is already off by then. */\n onCapture?: (file: File) => void\n /** The photo's encoding: `type` (default `image/jpeg`) and `quality` (default 0.9). */\n output?: Omit<CameraCaptureOptions, \"mirror\">\n /** Saves the photo mirrored, as the selfie preview shows it. Off by default. */\n mirror?: boolean\n translations?: CameraTranslations\n icons?: CameraIcons\n /** The palette of the shutter, the guide's edge and the panels' buttons. `brand` by default, like `ImageCropper`. */\n color?: Color\n ref?: Ref<HTMLDivElement>\n }\n\n/** Announces the camera's changes, politely, from a visually hidden region. */\nconst Announcer = ({ message }: { message: string }) => (\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {message}\n </div>\n)\n\nconst CameraRoot = ({\n camera,\n onCapture,\n output,\n mirror = false,\n translations,\n icons,\n color = \"brand\",\n className,\n testId,\n asChild,\n children,\n ref,\n ...rest\n}: CameraRootProps) => {\n const locale = useLocale()\n const direction = useDirectionCheck()\n const flash = useRef<HTMLDivElement | null>(null)\n const [message, setMessage] = useState(\"\")\n\n const t = useMemo(() => ({ ...DEFAULT_TRANSLATIONS, ...translations }), [translations])\n\n useEffect(() => {\n const next = match(camera.status)\n .with(\"starting\", () => t.announceStarting)\n .with(\"live\", () => t.announceReady)\n .with(\"paused\", () => t.announcePaused)\n .otherwise(() => null)\n if (next) setMessage(next)\n }, [camera.status, t])\n\n const shared = useMemo<Shared>(() => {\n const format = new Intl.NumberFormat(locale)\n return {\n camera,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n output: output ?? {},\n mirror,\n onCapture,\n flash,\n announce: setMessage,\n number: (value) => format.format(value),\n }\n }, [camera, t, icons, output, mirror, onCapture, locale])\n\n const rootRef = useMergedRefs(ref, direction)\n return (\n <CameraContext value={shared}>\n <ark.div\n ref={rootRef}\n asChild={asChild}\n data-color={color}\n data-status={camera.status}\n className={cn(\"relative flex w-full flex-col gap-3\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <Announcer message={message} />\n </>\n ))}\n </ark.div>\n </CameraContext>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Viewfinder\n// ---------------------------------------------------------------------------\n\nexport type CameraViewfinderProps = NoAsChild<\n ComponentPropsWithoutRef<\"div\"> &\n WithTestId & {\n /** The box's width / height. Defaults to the camera's `ratio`, else 4/3. The video covers it. */\n ratio?: Ratio\n /** Corner radius, from the media scale. */\n radius?: MediaRadius\n classNames?: { video?: string }\n }\n>\n\n/**\n * The live picture, in a box of a fixed ratio that the video covers. The\n * preview is mirrored for a camera facing the user, as a mirror would be,\n * and only for it. A skeleton holds the box while the camera warms up.\n *\n * Its children sit over the picture: a `Guide`, the `Status` panel, the\n * `Live` badge. It's a size container, so a guide can size its hole in\n * `cqw`/`cqh` without measuring.\n */\nconst CameraViewfinder = ({\n ratio,\n radius = \"xs\",\n classNames,\n className,\n style,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: CameraViewfinderProps) => {\n const { camera, t, flash } = useCameraContext()\n const warming = camera.status === \"starting\" || (camera.status === \"idle\" && !camera.ready)\n return (\n <div\n data-part=\"viewfinder\"\n data-status={camera.status}\n className={cn(\n \"relative w-full overflow-clip bg-black [container-type:size]\",\n MEDIA_RADIUS[radius],\n className,\n )}\n style={{ ...ratioStyle(ratio ?? camera.ratio ?? DEFAULT_RATIO), ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <video\n {...camera.props}\n aria-label={t.viewfinder}\n data-facing={camera.facing}\n className={cn(\n \"absolute inset-0 size-full object-cover\",\n camera.facing === \"user\" && \"-scale-x-100\",\n camera.status !== \"live\" && \"invisible\",\n classNames?.video,\n )}\n />\n {warming && (\n <Skeleton className=\"absolute inset-0 h-full rounded-none bg-white/8 dark:bg-white/8\" />\n )}\n <div\n ref={flash}\n aria-hidden\n data-part=\"flash\"\n className=\"pointer-events-none absolute inset-0 z-3 bg-white opacity-0\"\n />\n {children}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Guide\n// ---------------------------------------------------------------------------\n\nexport type CameraGuideProps = NoAsChild<\n ComponentPropsWithoutRef<\"div\"> &\n WithTestId & {\n /** A circle for a face, a rectangle for a card or a document. */\n shape?: CameraGuideShape\n /** The hole's share of the viewfinder, 0–1, along its tighter side. */\n size?: number\n /** A rectangle's width / height, for a card (`1.586`) or an A4 page (`\"210/297\"`). Defaults to the viewfinder's own. */\n ratio?: Ratio\n }\n>\n\n/** The shorter side of the viewfinder, which is a size container. */\nconst SHORT = \"min(100cqw, 100cqh)\"\n\n/** Where the hole goes, as lengths relative to the viewfinder, centered. */\nconst guideRect = (shape: CameraGuideShape, size: number, ratio: Ratio | undefined): CutoutRect => {\n const aspect = ratio === undefined ? Number.NaN : ratioToNumber(ratio)\n const [width, height] = match({ shape, sized: Number.isFinite(aspect) && aspect > 0 })\n .returnType<[string, string]>()\n .with({ shape: \"circle\" }, () => [`calc(${SHORT} * ${size})`, `calc(${SHORT} * ${size})`])\n .with({ sized: true }, () => {\n const w = `min(calc(100cqw * ${size}), calc(100cqh * ${size} * ${aspect}))`\n return [w, `calc(${w} / ${aspect})`]\n })\n .otherwise(() => [`calc(100cqw * ${size})`, `calc(100cqh * ${size})`])\n return {\n x: `calc((100cqw - ${width}) / 2)`,\n y: `calc((100cqh - ${height}) / 2)`,\n width,\n height,\n }\n}\n\n/**\n * A framing guide over the live picture: the view dimmed, with a circle or a\n * rectangle cut out of it. The dim is `ImageCropper`'s (`lib/cutout.ts`), so a\n * photo framed here crops the same way there. Decorative (`aria-hidden`); in\n * forced colors only its edge is drawn. Shows while the camera is live.\n */\nconst CameraGuide = ({\n shape = \"circle\",\n size = shape === \"circle\" ? 0.7 : 0.85,\n ratio,\n className,\n testId,\n asChild: _asChild,\n ...rest\n}: CameraGuideProps) => {\n const { camera } = useCameraContext()\n if (camera.status !== \"live\") return null\n const rect = guideRect(shape, size, ratio)\n return (\n <div\n aria-hidden\n data-part=\"guide\"\n data-shape={shape}\n className={cn(\"pointer-events-none absolute inset-0\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div\n // The cropper's dim, blur included, so the two read as one tool.\n className=\"absolute inset-0 bg-black/50 backdrop-blur-xs forced-colors:hidden\"\n style={cutoutMask(shape, rect)}\n />\n <div\n className={cn(\n \"absolute border border-(--c-solid) shadow-[0_0_0_1px_rgb(255_255_255/0.45)]\",\n \"forced-colors:border-[CanvasText]\",\n shape === \"circle\" ? \"rounded-full\" : \"rounded-xs\",\n )}\n style={{ insetInlineStart: rect.x, top: rect.y, width: rect.width, height: rect.height }}\n />\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Shutter\n// ---------------------------------------------------------------------------\n\nexport type CameraShutterProps = HTMLArkProps<\"button\"> &\n WithTestId & {\n /** The button, to move focus to it: back to the shutter on a retake. */\n ref?: Ref<HTMLButtonElement>\n }\n\n/**\n * A short white flash over the viewfinder, on the motion tokens. Under\n * reduced motion there's no fade: a frame held for a beat, then gone.\n */\nconst playFlash = (el: HTMLElement | null) => {\n if (!el || typeof el.animate !== \"function\") return\n if (prefersReducedMotion()) {\n el.animate(\n [\n { opacity: 1, backgroundColor: \"transparent\", boxShadow: \"inset 0 0 0 4px #fff\" },\n { opacity: 0 },\n ],\n { duration: durationOf(el, \"slow\"), easing: \"steps(1, end)\" },\n )\n return\n }\n animate(el, [{ opacity: 0.85 }, { opacity: 0 }], { duration: \"slow\", easing: \"standard\" })\n}\n\n/**\n * Takes the photo: a real button, so Space and Enter work. Enabled while the\n * camera is live. The File goes to `Camera.Root`'s `onCapture`, and the\n * camera turns off.\n *\n * Focus stays where it is: the shutter is disabled once the camera stops, so\n * move focus yourself to whatever comes next (the photo, a \"Use photo\"\n * button), or back to the shutter on a retake.\n */\nconst CameraShutter = ({\n className,\n testId,\n asChild,\n children,\n disabled,\n onClick,\n ...rest\n}: CameraShutterProps) => {\n const { camera, t, icons, output, mirror, onCapture, flash, announce } = useCameraContext()\n const [taking, setTaking] = useState(false)\n\n const take = async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n setTaking(true)\n playFlash(flash.current)\n try {\n const file = await camera.capture({ ...output, mirror })\n announce(t.announceTaken)\n onCapture?.(file)\n } catch {\n // Only reachable when the camera dropped between the press and the\n // draw; its own status panel already says so.\n } finally {\n setTaking(false)\n }\n }\n\n const off = disabled || camera.status !== \"live\" || taking\n return (\n <ark.button\n type=\"button\"\n asChild={asChild}\n aria-label={t.shutter}\n disabled={off}\n data-part=\"shutter\"\n onClick={take}\n className={cn(\n \"group/shutter inline-flex size-16 shrink-0 items-center justify-center rounded-full p-1\",\n \"border-[3px] border-(--c-solid) bg-transparent\",\n \"not-disabled:cursor-pointer disabled:opacity-50\",\n focusStyles(),\n className,\n )}\n {...props({ \"aria-busy\": taking, \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n <span\n aria-hidden\n className={cn(\n \"flex size-full items-center justify-center rounded-full bg-(--c-solid) text-(--c-on-solid)\",\n \"[&_svg]:size-6\",\n \"transition-[scale,background-color] duration-(--duration-fast) ease-standard motion-reduce:transition-none\",\n \"group-hover/shutter:group-enabled/shutter:bg-(--c-solid-hover) group-active/shutter:group-enabled/shutter:scale-90\",\n )}\n >\n {icons.shutter}\n </span>\n {own}\n </>\n ))}\n </ark.button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Flip\n// ---------------------------------------------------------------------------\n\nexport type CameraFlipProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"button\">, \"color\" | \"children\"> & WithTestId\n>\n\n/**\n * Switches cameras. Renders only when there are two or more. Its name says\n * where it goes: \"Switch to back camera\" from the front one, or \"Switch\n * camera\" between webcams that don't say which way they face.\n */\nconst CameraFlip = ({\n className,\n testId,\n onClick,\n asChild: _asChild,\n ...rest\n}: CameraFlipProps) => {\n const { camera, t, icons } = useCameraContext()\n if (camera.devices.length < 2) return null\n const target = camera.next.facing === camera.facing ? null : camera.next.facing\n return (\n <ActionIcon\n variant=\"subtle\"\n color=\"neutral\"\n aria-label={t.flip(target)}\n className={cn(control, className)}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) camera.flip()\n }}\n testId={testId}\n {...rest}\n >\n {icons.flip}\n </ActionIcon>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Devices\n// ---------------------------------------------------------------------------\n\nexport type CameraDevicesProps = WithTestId & { className?: string }\n\n/**\n * Picks a camera by name. Renders once the camera is granted (before that the\n * browser hides the names) and only when there's more than one.\n */\nconst CameraDevices = ({ className, testId }: CameraDevicesProps) => {\n const { camera, t, number } = useCameraContext()\n const devices = camera.devices.filter((device) => device.id)\n if (camera.permission !== \"granted\" || devices.length < 2) return null\n const data = devices.map((device, index) => ({\n value: device.id,\n label: device.label || t.device(number(index + 1)),\n }))\n return (\n <Select\n data={data}\n value={camera.device}\n onChange={(id) => id && camera.select(id)}\n label={t.devices}\n size=\"sm\"\n className={className}\n classNames={{ label: \"sr-only\" }}\n testId={testId}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// Status\n// ---------------------------------------------------------------------------\n\nexport type CameraStatusProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> &\n WithTestId & {\n /**\n * Rendered in every panel, under its own action: a \"choose a file\"\n * alternative, so a visitor whose camera won't work still has a way\n * through. Called with the status it's shown in.\n */\n children?: (status: CameraStatus) => ReactNode\n }\n>\n\ntype Panel = {\n title: string\n body?: string\n steps?: readonly string[]\n action?: { label: string; icon: ReactNode }\n /** A failure, announced assertively. */\n alert?: boolean\n}\n\n/**\n * The panel over the viewfinder for everything but a live picture: the\n * priming screen before the browser's prompt, starting, paused, and every\n * failure with what to do about it. Failures are `role=\"alert\"`; a refusal\n * lists the steps to undo it in this browser, or this OS.\n */\nconst CameraStatusPanel = ({\n className,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: CameraStatusProps) => {\n const { camera, t, icons } = useCameraContext()\n const [platform, setPlatform] = useState<CameraPlatform>(UNKNOWN_PLATFORM)\n\n // Read on the client only, so the server and hydration agree.\n useEffect(() => {\n setPlatform(detectPlatform(navigator.userAgent, navigator.maxTouchPoints))\n }, [])\n\n const retry = { label: t.retry, icon: icons.retry }\n const panel = match(camera.status)\n .returnType<Panel | null>()\n .with(\"live\", () => null)\n .with(\"idle\", () =>\n camera.ready ? { title: t.offTitle, action: { label: t.start, icon: icons.start } } : null,\n )\n .with(\"prompt\", () => ({\n title: t.primeTitle,\n body: t.primeBody,\n action: { label: t.enable, icon: icons.start },\n }))\n .with(\"starting\", () => ({ title: t.starting }))\n .with(\"paused\", () => ({\n title: t.pausedTitle,\n action: { label: t.resume, icon: icons.start },\n }))\n .with(\"denied\", () => ({\n title: t.deniedTitle,\n body: t.deniedBody,\n steps: t.deniedSteps(platform.browser),\n action: retry,\n alert: true,\n }))\n .with(\"blocked\", () => ({\n title: t.blockedTitle,\n body: t.blockedBody,\n steps: t.blockedSteps(platform.os),\n action: retry,\n alert: true,\n }))\n .with(\"busy\", () => ({ title: t.busyTitle, body: t.busyBody, action: retry, alert: true }))\n .with(\"missing\", () => ({\n title: t.missingTitle,\n body: t.missingBody,\n action: retry,\n alert: true,\n }))\n .with(\"unsupported\", () => ({\n title: t.unsupportedTitle,\n body: t.unsupportedBody,\n alert: true,\n }))\n .with(\"error\", () => ({ title: t.errorTitle, body: t.errorBody, action: retry, alert: true }))\n .exhaustive()\n\n if (!panel) return null\n return (\n <div\n data-part=\"status\"\n data-status={camera.status}\n className={cn(\n \"absolute inset-0 z-2 flex flex-col items-center justify-center gap-3 overflow-y-auto p-4 text-center\",\n \"bg-black/80 text-white\",\n camera.status === \"starting\" && \"bg-transparent\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div role={panel.alert ? \"alert\" : undefined} className=\"flex max-w-sm flex-col gap-2\">\n {panel.alert && <span className=\"mx-auto text-white/80 [&_svg]:size-6\">{icons.off}</span>}\n <p className=\"font-medium text-md\">{panel.title}</p>\n {panel.body && <p className=\"text-white/80 text-sm\">{panel.body}</p>}\n {panel.steps && (\n <ol className=\"list-decimal ps-5 text-start text-white/80 text-sm\">\n {panel.steps.map((step) => (\n <li key={step}>{step}</li>\n ))}\n </ol>\n )}\n </div>\n {(panel.action || children) && (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n {panel.action && (\n <Button size=\"sm\" startSlot={panel.action.icon} onClick={() => void camera.start()}>\n {panel.action.label}\n </Button>\n )}\n {children?.(camera.status)}\n </div>\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Live\n// ---------------------------------------------------------------------------\n\nexport type CameraLiveProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"span\">, \"color\" | \"children\"> & WithTestId\n>\n\n/** A \"Camera on\" badge, shown while the camera is live. */\nconst CameraLive = ({ className, testId, asChild: _asChild, ...rest }: CameraLiveProps) => {\n const { camera, t } = useCameraContext()\n if (camera.status !== \"live\") return null\n return (\n <Badge\n variant=\"filled\"\n color=\"red\"\n size=\"sm\"\n data-part=\"live\"\n className={cn(\"gap-1.5\", className)}\n testId={testId}\n {...rest}\n >\n <span aria-hidden className=\"size-1.5 rounded-full bg-current\" />\n {t.live}\n </Badge>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\nexport type CameraClassNames = {\n viewfinder?: string\n video?: string\n guide?: string\n status?: string\n controls?: string\n shutter?: string\n flip?: string\n}\n\nexport type CameraProps = NoAsChild<\n Omit<CameraRootProps, \"camera\" | \"children\"> &\n UseCameraOptions & {\n /** A framing guide over the picture. None by default. */\n shape?: CameraGuideShape\n /** The viewfinder's corner radius, from the media scale. */\n radius?: MediaRadius\n classNames?: CameraClassNames\n /** Rendered in every status panel: a file alternative. See `Camera.Status`. */\n children?: (status: CameraStatus) => ReactNode\n }\n>\n\nconst CameraComponent = ({\n facing,\n device,\n ratio,\n resolution,\n lazy,\n shape,\n radius,\n classNames,\n children,\n asChild: _asChild,\n ...rest\n}: CameraProps) => {\n const camera = useCamera({ facing, device, ratio, resolution, lazy })\n return (\n <CameraRoot camera={camera} {...rest}>\n <CameraViewfinder\n radius={radius}\n className={classNames?.viewfinder}\n classNames={{ video: classNames?.video }}\n >\n {shape && <CameraGuide shape={shape} className={classNames?.guide} />}\n <CameraLive className=\"absolute start-2 top-2 z-1\" />\n <CameraStatusPanel className={classNames?.status}>{children}</CameraStatusPanel>\n </CameraViewfinder>\n <div className={cn(\"grid grid-cols-[1fr_auto_1fr] items-center gap-3\", classNames?.controls)}>\n <span />\n <CameraShutter className={classNames?.shutter} />\n <CameraFlip className={cn(\"justify-self-start\", classNames?.flip)} />\n </div>\n </CameraRoot>\n )\n}\n\nexport const Camera = Object.assign(CameraComponent, {\n Root: CameraRoot,\n Viewfinder: CameraViewfinder,\n Guide: CameraGuide,\n Shutter: CameraShutter,\n Flip: CameraFlip,\n Devices: CameraDevices,\n Status: CameraStatusPanel,\n Live: CameraLive,\n})\n"]}
1
+ {"version":3,"sources":["../src/lib/image-file.ts","../src/components/camera/camera-machine.ts","../src/components/camera/use-camera.ts","../src/components/camera/platform.ts","../src/components/camera/camera.tsx"],"names":["match","mounted","P","CameraIcon","useRef","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,UAAA,GAAqC;AAAA,EACzC,YAAA,EAAc,KAAA;AAAA,EACd,WAAA,EAAa,KAAA;AAAA,EACb,YAAA,EAAc,MAAA;AAAA,EACd,YAAA,EAAc;AAChB,CAAA;AASO,IAAM,SAAA,GAAY,CAAC,IAAA,EAAY,IAAA,KAAuB;AAC3D,EAAA,MAAM,IAAA,GAAO,KAAK,IAAA,IAAQ,WAAA;AAC1B,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,IAAI,CAAA,EAAG,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,UAAA,CAAW,IAAI,CAAA,IAAK,KAAK,CAAA,CAAA,EAAI;AAAA,IAC9D,IAAA;AAAA,IACA,YAAA,EAAc,KAAK,GAAA;AAAI,GACxB,CAAA;AACH;AC+DO,IAAM,kBAAA,GAAqB,CAChC,MAAA,EACA,MAAA,GAAwB,IAAA,MACP;AAAA,EACjB,MAAA,EAAQ,MAAA;AAAA,EACR,KAAA,EAAO,KAAA;AAAA,EACP,UAAA,EAAY,SAAA;AAAA,EACZ,MAAA;AAAA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AAM,UAAA;AAAA,EACN,OAAA,EAAS,aAAA;AAAA,EACT,MAAA,EAAQ,iBAAA;AAAA,EACR,IAAA,EAAM;AACR,CAAC","file":"chunk-DJAXXLN6.js","sourcesContent":["const EXTENSIONS: Record<string, string> = {\n \"image/jpeg\": \"jpg\",\n \"image/png\": \"png\",\n \"image/webp\": \"webp\",\n \"image/avif\": \"avif\",\n}\n\n/**\n * A canvas export as a `File`, named and typed for what the browser actually\n * encoded. `toBlob` falls back to PNG for a type it can't encode (Safari has\n * no WebP encoder), so the blob's own type wins over the one asked for.\n *\n * imageFile(blob, \"photo\") // photo.jpg, image/jpeg\n */\nexport const imageFile = (blob: Blob, name: string): File => {\n const type = blob.type || \"image/png\"\n return new File([blob], `${name}.${EXTENSIONS[type] ?? \"png\"}`, {\n type,\n lastModified: Date.now(),\n })\n}\n","import { match, P } from \"ts-pattern\"\nimport { type Ratio, ratioToNumber } from \"../../lib/ratio\"\n\n/**\n * The camera's state machine, kept pure so every transition is unit-tested\n * without a browser: `useCamera` feeds it what `getUserMedia`, the track and\n * the page report, and renders whatever it returns.\n */\n\n/** Which way a camera points: at the user (a selfie) or away (a document). */\nexport type CameraFacing = \"user\" | \"environment\"\n\n/**\n * - `idle`: off. The server render, and after `stop()` or a capture.\n * - `unsupported`: no camera API here (an insecure page, an old browser, an iframe without `allow=\"camera\"`).\n * - `prompt`: ready to ask. The browser's permission prompt comes on `start()`.\n * - `starting`: asked, waiting for the first frame.\n * - `live`: frames are showing.\n * - `paused`: the page was hidden or the track ended. `start()` resumes.\n * - `denied`: the user (or a site setting) refused the camera.\n * - `blocked`: the operating system refused it to the browser.\n * - `busy`: another app or tab holds the camera.\n * - `missing`: no camera matches.\n * - `error`: anything else, including a camera that never sent a frame.\n */\nexport type CameraStatus =\n | \"idle\"\n | \"unsupported\"\n | \"prompt\"\n | \"starting\"\n | \"live\"\n | \"paused\"\n | \"denied\"\n | \"blocked\"\n | \"busy\"\n | \"missing\"\n | \"error\"\n\n/** The statuses a failed `start()` can end in. */\nexport type CameraFailure = Extract<\n CameraStatus,\n \"unsupported\" | \"denied\" | \"blocked\" | \"busy\" | \"missing\" | \"error\"\n>\n\n/** What `navigator.permissions` says, when it says anything. A hint only: Safari keeps reporting `prompt` after a refusal. */\nexport type CameraPermission = \"granted\" | \"denied\" | \"prompt\" | \"unknown\"\n\n/** One video input. `label` is empty until the user grants the camera. */\nexport type CameraDevice = { id: string; label: string; facing: CameraFacing | null }\n\n/** A capture size to aim for, in px. Always `ideal`: the camera picks the closest it has. */\nexport type CameraResolution = { width: number; height: number }\n\nexport type CameraState = {\n status: CameraStatus\n /** Whether the client-side checks ran. `false` on the server and on the first client render. */\n ready: boolean\n permission: CameraPermission\n facing: CameraFacing\n /** The camera asked for, then the one actually opened. */\n device: string | null\n devices: readonly CameraDevice[]\n capabilities: MediaTrackCapabilities | null\n}\n\nexport type CameraEvent =\n | { type: \"mount\"; supported: boolean; permission: CameraPermission; lazy?: boolean }\n | { type: \"permission\"; permission: CameraPermission }\n | { type: \"request\" }\n | {\n type: \"stream\"\n device: string | null\n facing: CameraFacing | null\n capabilities: MediaTrackCapabilities | null\n }\n | { type: \"frame\" }\n | { type: \"timeout\" }\n | { type: \"fail\"; status: CameraFailure }\n | { type: \"pause\" }\n | { type: \"stop\" }\n | { type: \"devices\"; devices: readonly CameraDevice[] }\n | { type: \"target\"; device: string | null; facing: CameraFacing }\n\nexport const initialCameraState = (\n facing: CameraFacing,\n device: string | null = null,\n): CameraState => ({\n status: \"idle\",\n ready: false,\n permission: \"unknown\",\n facing,\n device,\n devices: [],\n capabilities: null,\n})\n\n/** Where the client lands once it knows what the browser supports and allows. */\nconst mounted = (supported: boolean, permission: CameraPermission, lazy: boolean): CameraStatus =>\n match({ supported, permission, lazy })\n .returnType<CameraStatus>()\n .with({ supported: false }, () => \"unsupported\")\n // Already granted but lazy: off, until `start()`.\n .with({ permission: \"granted\", lazy: true }, () => \"idle\")\n // Already granted: no priming screen, `useCamera` starts straight away.\n .with({ permission: \"granted\" }, () => \"starting\")\n // A known refusal: getUserMedia would fail at once, so go to the recovery steps.\n .with({ permission: \"denied\" }, () => \"denied\")\n .otherwise(() => \"prompt\")\n\nexport const reduceCamera = (state: CameraState, event: CameraEvent): CameraState =>\n match(event)\n .returnType<CameraState>()\n .with({ type: \"mount\" }, ({ supported, permission, lazy = false }) => ({\n ...state,\n ready: true,\n permission,\n status: mounted(supported, permission, lazy),\n }))\n .with({ type: \"permission\" }, ({ permission }) => ({\n ...state,\n permission,\n status: state.status === \"prompt\" && permission === \"denied\" ? \"denied\" : state.status,\n }))\n .with({ type: \"request\" }, () =>\n state.status === \"unsupported\" ? state : { ...state, status: \"starting\" },\n )\n .with({ type: \"stream\" }, ({ device, facing, capabilities }) => ({\n ...state,\n permission: \"granted\",\n device: device ?? state.device,\n facing: facing ?? state.facing,\n capabilities,\n }))\n .with({ type: \"frame\" }, () =>\n state.status === \"starting\" ? { ...state, status: \"live\" } : state,\n )\n .with({ type: \"timeout\" }, () =>\n state.status === \"starting\" ? { ...state, status: \"error\" } : state,\n )\n .with({ type: \"fail\" }, ({ status }) => ({\n ...state,\n status,\n permission: status === \"denied\" || status === \"blocked\" ? \"denied\" : state.permission,\n }))\n .with({ type: \"pause\" }, () =>\n state.status === \"live\" || state.status === \"starting\"\n ? { ...state, status: \"paused\" }\n : state,\n )\n .with({ type: \"stop\" }, () =>\n state.status === \"unsupported\" ? state : { ...state, status: \"idle\", capabilities: null },\n )\n .with({ type: \"devices\" }, ({ devices }) => ({ ...state, devices }))\n .with({ type: \"target\" }, ({ device, facing }) => ({ ...state, device, facing }))\n .exhaustive()\n\n/** The `name` of a thrown DOMException, or of anything shaped like one. */\nconst nameOf = (error: unknown): string =>\n match(error)\n .with({ name: P.string }, ({ name }) => name)\n .otherwise(() => \"\")\n\nconst messageOf = (error: unknown): string =>\n match(error)\n .with({ message: P.string }, ({ message }) => message)\n .otherwise(() => \"\")\n\n/**\n * The status a `getUserMedia` rejection means. Chrome tells an OS-level\n * refusal apart only by its message (\"Permission denied by system\"); the\n * legacy names are older Chrome and Firefox spellings of the same errors.\n */\nexport const failureOf = (error: unknown): CameraFailure =>\n match(nameOf(error))\n .returnType<CameraFailure>()\n .with(\"NotAllowedError\", \"PermissionDeniedError\", () =>\n /system/i.test(messageOf(error)) ? \"blocked\" : \"denied\",\n )\n .with(\"NotFoundError\", \"DevicesNotFoundError\", \"OverconstrainedError\", () => \"missing\")\n .with(\"NotReadableError\", \"TrackStartError\", () => \"busy\")\n // NotSupportedError: a browser that can't show a prompt here (a headless one, some webviews).\n .with(\"SecurityError\", \"NotSupportedError\", () => \"unsupported\")\n .otherwise(() => \"error\")\n\nexport const isOverconstrained = (error: unknown) => nameOf(error) === \"OverconstrainedError\"\n\n/** The resolution asked for when none is given: enough for a sharp photo, cheap for any webcam to approximate. */\nexport const DEFAULT_RESOLUTION: CameraResolution = { width: 1920, height: 1080 }\n\ntype ConstraintsInput = {\n device: string | null\n facing: CameraFacing\n ratio?: Ratio\n resolution?: CameraResolution\n}\n\n/**\n * What to ask `getUserMedia` for. Every constraint about the picture is\n * `ideal`: a camera that can't match gets the closest it has instead of an\n * `OverconstrainedError`.\n *\n * A chosen device is the one exception, `exact`, and wins over `facing`. As\n * an `ideal` it's only one term in Chrome's fitness distance, which an ideal\n * resolution the other camera matches better can outweigh: a flip or a pick\n * would quietly reopen the same camera. If that device is gone, the\n * `OverconstrainedError` is retried with `looseConstraintsOf`.\n */\nexport const constraintsOf = ({\n device,\n facing,\n ratio,\n resolution = DEFAULT_RESOLUTION,\n}: ConstraintsInput): MediaStreamConstraints => {\n const aspect = ratio === undefined ? Number.NaN : ratioToNumber(ratio)\n return {\n audio: false,\n video: {\n ...(device ? { deviceId: { exact: device } } : { facingMode: { ideal: facing } }),\n width: { ideal: resolution.width },\n height: { ideal: resolution.height },\n ...(Number.isFinite(aspect) && aspect > 0 ? { aspectRatio: { ideal: aspect } } : {}),\n },\n }\n}\n\n/** The one retry after an `OverconstrainedError`: the chosen camera if it's there, else any, at whatever size. */\nexport const looseConstraintsOf = ({\n device,\n}: {\n device: string | null\n}): MediaStreamConstraints => ({\n audio: false,\n video: device ? { deviceId: { ideal: device } } : true,\n})\n\n/** A device's facing, from its capabilities when the browser reports them, else from its label. */\nexport const facingOf = (label: string, reported?: readonly string[]): CameraFacing | null => {\n const named = reported?.find((mode) => mode === \"user\" || mode === \"environment\")\n if (named === \"user\" || named === \"environment\") return named\n if (/\\b(front|user|face|selfie|facetime)\\b/i.test(label)) return \"user\"\n if (/\\b(back|rear|environment|world)\\b/i.test(label)) return \"environment\"\n return null\n}\n\nconst opposite = (facing: CameraFacing): CameraFacing =>\n facing === \"user\" ? \"environment\" : \"user\"\n\n/**\n * Where `flip()` goes. On a phone the devices report a facing, so it's the\n * first camera facing the other way. Without facings (two webcams on a\n * desktop) it's the next camera in the list. With no list yet, it's the other\n * `facingMode`.\n */\nexport const flipTarget = ({\n facing,\n device,\n devices,\n}: Pick<CameraState, \"facing\" | \"device\" | \"devices\">): {\n device: string | null\n facing: CameraFacing\n} => {\n const other = devices.find((d) => d.facing !== null && d.facing !== facing && d.id)\n if (other?.facing) return { device: other.id, facing: other.facing }\n const usable = devices.filter((d) => d.id)\n if (usable.length > 1) {\n const index = usable.findIndex((d) => d.id === device)\n const next = usable[(index + 1) % usable.length]\n if (next) return { device: next.id, facing: next.facing ?? facing }\n }\n return { device: null, facing: opposite(facing) }\n}\n\n/** The statuses that hold, or are about to hold, a stream. */\nexport const isActive = (status: CameraStatus) => status === \"starting\" || status === \"live\"\n","\"use client\"\n\nimport {\n type RefCallback,\n type SyntheticEvent,\n useCallback,\n useEffect,\n useReducer,\n useRef,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { imageFile } from \"../../lib/image-file\"\nimport type { Ratio } from \"../../lib/ratio\"\nimport { useDocumentVisibility } from \"../../lib/use-document-visibility\"\nimport { useIsomorphicLayoutEffect } from \"../../lib/use-isomorphic-layout-effect\"\nimport {\n type CameraDevice,\n type CameraFacing,\n type CameraPermission,\n type CameraResolution,\n type CameraState,\n type CameraStatus,\n constraintsOf,\n facingOf,\n failureOf,\n flipTarget,\n initialCameraState,\n isActive,\n isOverconstrained,\n looseConstraintsOf,\n reduceCamera,\n} from \"./camera-machine\"\n\nexport type UseCameraOptions = {\n /** The camera to open first, when no `device` is given. Defaults to `user`, the selfie camera. */\n facing?: CameraFacing\n /** A `deviceId` to open first, from `devices` (or one you remembered). Wins over `facing`. */\n device?: string\n /** The frame shape to ask for, as width / height. The viewfinder uses it for its box too. */\n ratio?: Ratio\n /** The capture size to aim for. Defaults to 1920×1080; the camera picks the closest it has. */\n resolution?: CameraResolution\n /**\n * Waits for `start()` even when the camera is already allowed, instead of\n * turning it on as the hook mounts. For a camera that sits behind a choice\n * (a \"Take photo\" button, a tab) and must not light up before it.\n */\n lazy?: boolean\n}\n\nexport type CameraCaptureOptions = {\n /** The encoding. A browser that can't encode it falls back to PNG, and the File says so. Defaults to `image/jpeg`. */\n type?: string\n /** 0–1, for JPEG and WebP. Defaults to 0.9. */\n quality?: number\n /** Saves the photo mirrored, as the selfie preview shows it. Off by default: a saved selfie reads the right way round. */\n mirror?: boolean\n}\n\n/** Spread on the `<video>` that shows the camera. `Camera.Viewfinder` does it for you. */\nexport type CameraVideoProps = {\n ref: RefCallback<HTMLVideoElement>\n autoPlay: true\n muted: true\n playsInline: true\n onLoadedData: (event: SyntheticEvent<HTMLVideoElement>) => void\n onPlaying: (event: SyntheticEvent<HTMLVideoElement>) => void\n}\n\nexport type UseCameraResult = {\n status: CameraStatus\n /** Whether the client has checked support and permission yet. `false` on the server. */\n ready: boolean\n /** The permission hint. `granted` once a stream has opened, whatever the browser reported. */\n permission: CameraPermission\n /** The open camera's facing, or the one asked for. Desktop webcams count as `user`. */\n facing: CameraFacing\n /** The open camera's `deviceId`, or the one asked for. */\n device: string | null\n /** Every video input. Labels are empty until the camera is granted. Updated on `devicechange`. */\n devices: readonly CameraDevice[]\n /** Where `flip()` would go, for its label. */\n next: { device: string | null; facing: CameraFacing }\n /** The open track's capabilities (zoom, torch, resolution range), where the browser reports them. */\n capabilities: MediaTrackCapabilities | null\n ratio: Ratio | undefined\n /** Opens the camera, asking for permission if it must. Also resumes after `paused`, and retries after a failure. */\n start: () => Promise<void>\n /** Turns the camera off, light included. */\n stop: () => void\n /** Switches to the camera facing the other way, or the next one. */\n flip: () => void\n /** Switches to a camera from `devices`. */\n select: (device: string) => void\n /**\n * Takes a photo of the full frame, at the camera's own resolution, and\n * turns the camera off. The File carries no EXIF and nothing is uploaded.\n * Rejects when the camera isn't live.\n */\n capture: (options?: CameraCaptureOptions) => Promise<File>\n /** The `<video>`'s ref, also inside `props`. */\n videoRef: RefCallback<HTMLVideoElement>\n /** Spread on your own `<video>`. */\n props: CameraVideoProps\n}\n\n/** How long a camera has to send its first frame before it counts as an error. */\nexport const WARM_UP_TIMEOUT = 8000\n\nconst stopTracks = (stream: MediaStream | null) => {\n stream?.getTracks().forEach((track) => {\n track.stop()\n })\n}\n\nconst permissionOf = (state: string): CameraPermission =>\n match(state)\n .returnType<CameraPermission>()\n .with(\"granted\", \"denied\", \"prompt\", (known) => known)\n .otherwise(() => \"unknown\")\n\nconst deviceOf = (info: MediaDeviceInfo): CameraDevice => {\n const reported =\n typeof InputDeviceInfo !== \"undefined\" &&\n info instanceof InputDeviceInfo &&\n typeof info.getCapabilities === \"function\"\n ? info.getCapabilities().facingMode\n : undefined\n return { id: info.deviceId, label: info.label, facing: facingOf(info.label, reported) }\n}\n\nconst play = (video: HTMLVideoElement) => {\n try {\n // An explicit play(), on top of `autoplay`: iOS Safari won't start a\n // `srcObject` stream otherwise. Its rejection (a pause, a new source) is\n // harmless; the first frame is what counts.\n Promise.resolve(video.play()).catch(() => {})\n } catch {\n // jsdom and other DOMs without media playback.\n }\n}\n\n/**\n * The camera as plain state plus handlers, for `Camera.Root` or your own\n * viewfinder. It owns everything `getUserMedia` makes hard: permission,\n * error names, switching cameras, a stream that arrives after unmount, the\n * page being hidden, and turning the light off.\n *\n * SSR-safe: it reads `navigator` only in effects, so the server and the first\n * client render are `idle`. Once mounted it goes to `prompt`, or straight to\n * `starting` when the camera is already granted (unless `lazy`, which stays\n * `idle` until `start()`).\n *\n * const camera = useCamera({ facing: \"environment\" })\n * <video {...camera.props} />\n * <button onClick={() => camera.capture().then(upload)}>Take photo</button>\n *\n * The camera stops after `capture()`, on `stop()`, on unmount and on\n * `pagehide`. Hiding the page, or a track that ends (another app took the\n * camera), pauses it; `start()` resumes.\n */\nexport function useCamera({\n facing = \"user\",\n device,\n ratio,\n resolution,\n lazy = false,\n}: UseCameraOptions = {}): UseCameraResult {\n const [state, dispatch] = useReducer(reduceCamera, undefined, () =>\n initialCameraState(facing, device ?? null),\n )\n\n // Interop with the media APIs, not state: the open stream, the element\n // showing it, and what the async callbacks need to read at the time they run.\n const stream = useRef<MediaStream | null>(null)\n const video = useRef<HTMLVideoElement | null>(null)\n /** Bumped by every open and close, so a stream that resolves for an older one is stopped. */\n const generation = useRef(0)\n const mounted = useRef(false)\n const warmUp = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef<CameraState>(state)\n const config = useRef({ ratio, resolution, lazy })\n\n useIsomorphicLayoutEffect(() => {\n latest.current = state\n config.current = { ratio, resolution, lazy }\n })\n\n const release = useCallback(() => {\n generation.current += 1\n clearTimeout(warmUp.current)\n stopTracks(stream.current)\n stream.current = null\n if (video.current) video.current.srcObject = null\n }, [])\n\n const enumerate = useCallback(async () => {\n try {\n const all = await navigator.mediaDevices.enumerateDevices()\n if (!mounted.current) return\n dispatch({\n type: \"devices\",\n devices: all.filter((info) => info.kind === \"videoinput\").map(deviceOf),\n })\n } catch {\n // A list we can't read leaves the last one in place.\n }\n }, [])\n\n const pause = useCallback(() => {\n release()\n dispatch({ type: \"pause\" })\n }, [release])\n\n const open = useCallback(\n async (target: { device: string | null; facing: CameraFacing }) => {\n // Stop the current camera before asking for the next: a phone opens one at a time.\n release()\n const id = generation.current\n dispatch({ type: \"request\" })\n const media = typeof navigator === \"undefined\" ? undefined : navigator.mediaDevices\n if (typeof media?.getUserMedia !== \"function\") {\n dispatch({ type: \"fail\", status: \"unsupported\" })\n return\n }\n const request = { ...target, ...config.current }\n try {\n const next = await media.getUserMedia(constraintsOf(request)).catch((error: unknown) => {\n if (!isOverconstrained(error)) throw error\n return media.getUserMedia(looseConstraintsOf(request))\n })\n if (id !== generation.current || !mounted.current) {\n // Closed, unmounted or replaced while the prompt was up (Strict Mode's double effect, a fast flip).\n stopTracks(next)\n return\n }\n stream.current = next\n if (video.current) {\n video.current.srcObject = next\n play(video.current)\n }\n const [track] = next.getVideoTracks()\n const settings = track?.getSettings()\n const lost = () => {\n if (stream.current === next) pause()\n }\n track?.addEventListener(\"ended\", lost)\n track?.addEventListener(\"mute\", lost)\n dispatch({\n type: \"stream\",\n device: settings?.deviceId ?? null,\n // A track that doesn't say is a desktop webcam, which faces the user.\n facing:\n facingOf(track?.label ?? \"\", settings?.facingMode ? [settings.facingMode] : []) ??\n \"user\",\n capabilities:\n track && typeof track.getCapabilities === \"function\" ? track.getCapabilities() : null,\n })\n warmUp.current = setTimeout(() => dispatch({ type: \"timeout\" }), WARM_UP_TIMEOUT)\n // Labels and facings only appear once the camera is granted.\n void enumerate()\n } catch (error) {\n if (id !== generation.current || !mounted.current) return\n dispatch({ type: \"fail\", status: failureOf(error) })\n }\n },\n [release, pause, enumerate],\n )\n\n useEffect(() => {\n mounted.current = true\n let cancelled = false\n let permissionStatus: PermissionStatus | null = null\n const onPermission = () => {\n if (permissionStatus)\n dispatch({ type: \"permission\", permission: permissionOf(permissionStatus.state) })\n }\n const media = typeof navigator === \"undefined\" ? undefined : navigator.mediaDevices\n const supported = window.isSecureContext !== false && typeof media?.getUserMedia === \"function\"\n\n const check = async (): Promise<CameraPermission> => {\n try {\n permissionStatus = await navigator.permissions.query({ name: \"camera\" })\n permissionStatus.addEventListener(\"change\", onPermission)\n return permissionOf(permissionStatus.state)\n } catch {\n // No Permissions API, or no \"camera\" in it (older Firefox): no hint.\n return \"unknown\"\n }\n }\n\n void (async () => {\n const permission = supported ? await check() : \"unknown\"\n if (cancelled) return\n const { lazy: waiting } = config.current\n dispatch({ type: \"mount\", supported, permission, lazy: waiting })\n if (!supported) return\n void enumerate()\n if (permission === \"granted\" && !waiting) {\n const { device: current, facing: wanted } = latest.current\n void open({ device: current, facing: wanted })\n }\n })()\n\n const onDeviceChange = () => void enumerate()\n const onPageHide = () => {\n release()\n dispatch({ type: \"stop\" })\n }\n media?.addEventListener(\"devicechange\", onDeviceChange)\n window.addEventListener(\"pagehide\", onPageHide)\n\n return () => {\n cancelled = true\n mounted.current = false\n release()\n permissionStatus?.removeEventListener(\"change\", onPermission)\n media?.removeEventListener(\"devicechange\", onDeviceChange)\n window.removeEventListener(\"pagehide\", onPageHide)\n }\n }, [enumerate, open, release])\n\n // A hidden page keeps no camera live: pause, which also turns the light off.\n const visibility = useDocumentVisibility()\n useEffect(() => {\n if (visibility === \"hidden\" && stream.current) pause()\n }, [visibility, pause])\n\n const stop = useCallback(() => {\n release()\n dispatch({ type: \"stop\" })\n }, [release])\n\n const start = useCallback(() => {\n const { device: current, facing: wanted } = latest.current\n return open({ device: current, facing: wanted })\n }, [open])\n\n const retarget = useCallback(\n (target: { device: string | null; facing: CameraFacing }) => {\n dispatch({ type: \"target\", ...target })\n if (isActive(latest.current.status)) void open(target)\n },\n [open],\n )\n\n const flip = useCallback(() => retarget(flipTarget(latest.current)), [retarget])\n\n const select = useCallback(\n (id: string) => {\n const chosen = latest.current.devices.find((d) => d.id === id)\n retarget({ device: id, facing: chosen?.facing ?? latest.current.facing })\n },\n [retarget],\n )\n\n const capture = useCallback(\n async ({ type = \"image/jpeg\", quality = 0.9, mirror = false }: CameraCaptureOptions = {}) => {\n const el = video.current\n if (!el || latest.current.status !== \"live\" || el.videoWidth === 0) {\n throw new Error(\"[@42/ui-react] useCamera: capture() needs a live camera.\")\n }\n // The full native frame, not the cropped box the viewfinder shows.\n const canvas = document.createElement(\"canvas\")\n canvas.width = el.videoWidth\n canvas.height = el.videoHeight\n const context = canvas.getContext(\"2d\")\n if (!context) throw new Error(\"[@42/ui-react] useCamera: no 2D canvas to capture with.\")\n if (mirror) {\n context.translate(canvas.width, 0)\n context.scale(-1, 1)\n }\n context.drawImage(el, 0, 0, canvas.width, canvas.height)\n // The frame is drawn: the light goes off before encoding.\n stop()\n const blob = await new Promise<Blob | null>((resolve) =>\n canvas.toBlob(resolve, type, quality),\n )\n if (!blob) throw new Error(\"[@42/ui-react] useCamera: the photo couldn't be encoded.\")\n // Safari has no WebP encoder and hands back PNG: the file says so.\n return imageFile(blob, \"photo\")\n },\n [stop],\n )\n\n const videoRef = useCallback((node: HTMLVideoElement | null) => {\n video.current = node\n if (!node) return\n // React doesn't reflect `muted` to the attribute, which iOS autoplay checks.\n node.muted = true\n if (stream.current && node.srcObject !== stream.current) {\n node.srcObject = stream.current\n play(node)\n }\n }, [])\n\n const onFrame = useCallback((event: SyntheticEvent<HTMLVideoElement>) => {\n if (event.currentTarget.videoWidth === 0) return\n clearTimeout(warmUp.current)\n dispatch({ type: \"frame\" })\n }, [])\n\n return {\n status: state.status,\n ready: state.ready,\n permission: state.permission,\n facing: state.facing,\n device: state.device,\n devices: state.devices,\n next: flipTarget(state),\n capabilities: state.capabilities,\n ratio,\n start,\n stop,\n flip,\n select,\n capture,\n videoRef,\n props: {\n ref: videoRef,\n autoPlay: true,\n muted: true,\n playsInline: true,\n onLoadedData: onFrame,\n onPlaying: onFrame,\n },\n }\n}\n","import { match, P } from \"ts-pattern\"\n\n/**\n * Which recovery steps to show after a refusal. Detection is deliberately\n * conservative: anything not clearly one of these gets the generic steps,\n * which are right everywhere, rather than precise steps for the wrong browser.\n */\n\n/** The browser whose settings a `denied` camera is fixed in. */\nexport type CameraBrowser =\n | \"chrome-desktop\"\n | \"chrome-android\"\n | \"safari-macos\"\n | \"safari-ios\"\n | \"firefox\"\n | \"other\"\n\n/** The operating system whose settings a `blocked` camera is fixed in. */\nexport type CameraOs = \"macos\" | \"windows\" | \"android\" | \"ios\" | \"other\"\n\nexport type CameraPlatform = { browser: CameraBrowser; os: CameraOs }\n\nexport const UNKNOWN_PLATFORM: CameraPlatform = { browser: \"other\", os: \"other\" }\n\n/**\n * `navigator.userAgent` plus `maxTouchPoints`, which is how an iPad that\n * claims to be a Mac is told apart. Every iOS browser runs on WebKit with\n * Safari's permission model, so iOS is always `safari-ios`.\n */\nexport const detectPlatform = (userAgent: string, touchPoints = 0): CameraPlatform => {\n const ios = /iPhone|iPad|iPod/.test(userAgent) || (/Macintosh/.test(userAgent) && touchPoints > 1)\n const android = /Android/.test(userAgent)\n const os = match({ ios, android, userAgent })\n .returnType<CameraOs>()\n .with({ ios: true }, () => \"ios\")\n .with({ android: true }, () => \"android\")\n .with({ userAgent: P.string.regex(/Mac OS X|Macintosh/) }, () => \"macos\")\n .with({ userAgent: P.string.regex(/Windows/) }, () => \"windows\")\n .otherwise(() => \"other\")\n const firefox = /Firefox\\//.test(userAgent)\n // Edge, Opera, Brave and Samsung Internet all say \"Chrome/\" and share its settings.\n const chromium = /Chrome\\/|CriOS\\//.test(userAgent)\n const safari = /Safari\\//.test(userAgent) && !chromium\n const browser = match({ os, firefox, chromium, safari })\n .returnType<CameraBrowser>()\n .with({ os: \"ios\" }, () => \"safari-ios\")\n .with({ firefox: true }, () => \"firefox\")\n .with({ chromium: true, os: \"android\" }, () => \"chrome-android\")\n .with({ chromium: true, os: P.union(\"macos\", \"windows\", \"other\") }, () => \"chrome-desktop\")\n .with({ safari: true, os: \"macos\" }, () => \"safari-macos\")\n .otherwise(() => \"other\")\n return { browser, os }\n}\n","\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react/factory\"\nimport { Camera as CameraIcon, CameraOff, RotateCcw, SwitchCamera } from \"lucide-react\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type MouseEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { type CutoutRect, cutoutMask } from \"../../lib/cutout\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useDirectionCheck, useLocale } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { animate, durationOf } from \"../../lib/motion/animate\"\nimport { prefersReducedMotion } from \"../../lib/motion/reduced-motion\"\nimport { props } from \"../../lib/props\"\nimport { MEDIA_RADIUS, type MediaRadius } from \"../../lib/radius\"\nimport { type Ratio, ratioStyle, ratioToNumber } from \"../../lib/ratio\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { ActionIcon } from \"../action-icon/action-icon\"\nimport { Badge } from \"../badge/badge\"\nimport { Button } from \"../button/button\"\nimport { Select } from \"../select/select\"\nimport { Skeleton } from \"../skeleton/skeleton\"\nimport type { CameraFacing, CameraStatus } from \"./camera-machine\"\nimport {\n type CameraBrowser,\n type CameraOs,\n type CameraPlatform,\n detectPlatform,\n UNKNOWN_PLATFORM,\n} from \"./platform\"\nimport {\n type CameraCaptureOptions,\n type UseCameraOptions,\n type UseCameraResult,\n useCamera,\n} from \"./use-camera\"\n\n/**\n * Camera — take a photo in the page: a live viewfinder, a framing guide, a\n * shutter, a camera switch, and a panel for every state the camera can be in,\n * from the first permission prompt to the steps that undo a refusal.\n *\n * <Camera facing=\"user\" shape=\"circle\" onCapture={(file) => setPhoto(file)} />\n *\n * The parts read `useCamera`, the headless hook that owns `getUserMedia`, so\n * the same camera can drive your own layout:\n *\n * const camera = useCamera({ facing: \"environment\", ratio: \"4/3\" })\n * <Camera.Root camera={camera} onCapture={upload}>\n * <Camera.Viewfinder>\n * <Camera.Guide shape=\"rectangle\" ratio={1.586} />\n * <Camera.Status />\n * </Camera.Viewfinder>\n * <Camera.Shutter />\n * </Camera.Root>\n *\n * The photo comes back as a `File` through `onCapture`: the full frame at the\n * camera's own resolution, without EXIF, never uploaded. The camera turns off\n * once it's taken.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type CameraGuideShape = \"circle\" | \"rectangle\"\n\nexport type CameraTranslations = {\n /** The video's accessible name. */\n viewfinder?: string\n /** Before the first prompt: why the browser is about to ask. */\n primeTitle?: string\n primeBody?: string\n /** The button that asks for the camera. */\n enable?: string\n /** After `stop()` or a capture. */\n offTitle?: string\n /** The button that turns it back on. */\n start?: string\n starting?: string\n pausedTitle?: string\n /** The button that resumes a paused camera. */\n resume?: string\n busyTitle?: string\n busyBody?: string\n missingTitle?: string\n missingBody?: string\n unsupportedTitle?: string\n unsupportedBody?: string\n errorTitle?: string\n errorBody?: string\n retry?: string\n deniedTitle?: string\n deniedBody?: string\n /** How to allow the camera again, step by step, in the browser the visitor is using. */\n deniedSteps?: (browser: CameraBrowser) => readonly string[]\n blockedTitle?: string\n blockedBody?: string\n /** How to let the browser use the camera again, in the operating system's settings. */\n blockedSteps?: (os: CameraOs) => readonly string[]\n shutter?: string\n /** The switch's name, saying where it goes: the facing, or `null` for the next of several webcams. */\n flip?: (facing: CameraFacing | null) => string\n /** The camera picker's label. */\n devices?: string\n /** A camera with no label (before the grant), by its position. `index` is formatted. */\n device?: (index: string) => string\n /** The \"camera on\" badge. */\n live?: string\n /** Announced politely as the camera changes state. */\n announceStarting?: string\n announceReady?: string\n announcePaused?: string\n announceTaken?: string\n}\n\nconst DENIED_STEPS: Record<CameraBrowser, readonly string[]> = {\n \"chrome-desktop\": [\n \"Select the camera icon, or the site settings icon, next to the address.\",\n \"Set Camera to Allow.\",\n \"Select Try again.\",\n ],\n \"chrome-android\": [\n \"Tap the site settings icon next to the address.\",\n \"Tap Permissions, then Camera, and choose Allow.\",\n \"Come back and tap Try again.\",\n ],\n \"safari-macos\": [\n \"In the menu bar, choose Safari, then Settings for this website.\",\n \"Set Camera to Allow.\",\n \"Select Try again.\",\n ],\n \"safari-ios\": [\n \"Tap the page menu in the address bar, then Website Settings.\",\n \"Set Camera to Allow.\",\n \"Tap Try again.\",\n ],\n firefox: [\n \"Select the crossed-out camera icon in the address bar.\",\n \"Remove the Blocked setting for the camera.\",\n \"Select Try again.\",\n ],\n other: [\n \"Open this site's settings, usually from the icon next to the address.\",\n \"Allow the camera.\",\n \"Try again.\",\n ],\n}\n\nconst BLOCKED_STEPS: Record<CameraOs, readonly string[]> = {\n macos: [\n \"Open System Settings, then Privacy & Security, then Camera.\",\n \"Turn on your browser.\",\n \"Reopen the browser if it asks, then select Try again.\",\n ],\n windows: [\n \"Open Settings, then Privacy & security, then Camera.\",\n \"Turn on Camera access, and Let desktop apps access your camera.\",\n \"Select Try again.\",\n ],\n android: [\n \"Open Settings, then Apps, then your browser.\",\n \"Tap Permissions, then Camera, and choose Allow.\",\n \"Come back and tap Try again.\",\n ],\n ios: [\n \"Open Settings, then Apps, then your browser.\",\n \"Turn on Camera.\",\n \"Come back and tap Try again.\",\n ],\n other: [\"Open your system's privacy settings.\", \"Let your browser use the camera.\", \"Try again.\"],\n}\n\nexport const DEFAULT_TRANSLATIONS: Required<CameraTranslations> = {\n viewfinder: \"Camera preview\",\n primeTitle: \"Take a photo with your camera\",\n primeBody:\n \"Your browser will ask to use the camera. It's only on while you take the photo, and nothing is uploaded until you choose to.\",\n enable: \"Enable camera\",\n offTitle: \"The camera is off\",\n start: \"Turn on camera\",\n starting: \"Starting the camera…\",\n pausedTitle: \"The camera is paused\",\n resume: \"Tap to resume\",\n busyTitle: \"The camera is in use\",\n busyBody: \"Another app or tab is using it. Close it, then try again.\",\n missingTitle: \"No camera found\",\n missingBody: \"Connect a camera, or check that it's turned on, then try again.\",\n unsupportedTitle: \"The camera isn't available here\",\n unsupportedBody: \"This browser can't use the camera on this page.\",\n errorTitle: \"The camera couldn't start\",\n errorBody: \"Something went wrong while starting it.\",\n retry: \"Try again\",\n deniedTitle: \"Camera access is blocked\",\n deniedBody: \"To take a photo, allow the camera for this site:\",\n deniedSteps: (browser) => DENIED_STEPS[browser],\n blockedTitle: \"Your system is blocking the camera\",\n blockedBody: \"Your browser isn't allowed to use the camera. To allow it:\",\n blockedSteps: (os) => BLOCKED_STEPS[os],\n shutter: \"Take photo\",\n flip: (facing) =>\n match(facing)\n .with(\"user\", () => \"Switch to front camera\")\n .with(\"environment\", () => \"Switch to back camera\")\n .with(null, () => \"Switch camera\")\n .exhaustive(),\n devices: \"Camera\",\n device: (index) => `Camera ${index}`,\n live: \"Camera on\",\n announceStarting: \"Starting the camera\",\n announceReady: \"Camera ready\",\n announcePaused: \"Camera paused\",\n announceTaken: \"Photo taken\",\n}\n\n/** The replaceable icons, by slot: the buttons that turn the camera on share `start`, a failure panel shows `off`. */\nexport type CameraIconSlot = \"shutter\" | \"flip\" | \"start\" | \"retry\" | \"off\"\nexport type CameraIcons = IconMap<CameraIconSlot>\n\nexport const DEFAULT_ICONS: Record<CameraIconSlot, ReactNode> = {\n shutter: <CameraIcon aria-hidden className={iconStroke} />,\n flip: <SwitchCamera aria-hidden className={iconStroke} />,\n start: <CameraIcon aria-hidden className={iconStroke} />,\n retry: <RotateCcw aria-hidden className={iconStroke} />,\n off: <CameraOff aria-hidden className={iconStroke} />,\n}\n\ntype Shared = {\n camera: UseCameraResult\n t: Required<CameraTranslations>\n icons: Record<CameraIconSlot, ReactNode>\n output: Omit<CameraCaptureOptions, \"mirror\">\n mirror: boolean\n onCapture?: (file: File) => void\n /** The viewfinder's flash overlay, played by the shutter. */\n flash: RefObject<HTMLDivElement | null>\n announce: (message: string) => void\n number: (value: number) => string\n}\n\nconst CameraContext = createContext<Shared | null>(null)\n\n/** The nearest `Camera.Root`'s camera, translations and icons, for a part of your own. */\nexport const useCameraContext = (): Shared => {\n const shared = useContext(CameraContext)\n if (!shared) throw new Error(\"[@42/ui-react] Camera parts must be inside <Camera.Root>.\")\n return shared\n}\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\n/** A ≥ 44px control (WCAG 2.5.8). */\nconst control = \"size-11 [&_svg]:size-5\"\n\n/** The viewfinder's box when neither the part nor the hook names a ratio: a webcam's usual frame. */\nconst DEFAULT_RATIO: Ratio = \"4/3\"\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type CameraRootProps = Omit<HTMLArkProps<\"div\">, \"color\"> &\n WithTestId & {\n /** The camera, from `useCamera()`. */\n camera: UseCameraResult\n /** Receives the photo once the shutter is pressed. The camera is already off by then. */\n onCapture?: (file: File) => void\n /** The photo's encoding: `type` (default `image/jpeg`) and `quality` (default 0.9). */\n output?: Omit<CameraCaptureOptions, \"mirror\">\n /** Saves the photo mirrored, as the selfie preview shows it. Off by default. */\n mirror?: boolean\n translations?: CameraTranslations\n icons?: CameraIcons\n /** The palette of the shutter, the guide's edge and the panels' buttons. `brand` by default, like `ImageCropper`. */\n color?: Color\n ref?: Ref<HTMLDivElement>\n }\n\n/** Announces the camera's changes, politely, from a visually hidden region. */\nconst Announcer = ({ message }: { message: string }) => (\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {message}\n </div>\n)\n\nconst CameraRoot = ({\n camera,\n onCapture,\n output,\n mirror = false,\n translations,\n icons,\n color = \"brand\",\n className,\n testId,\n asChild,\n children,\n ref,\n ...rest\n}: CameraRootProps) => {\n const locale = useLocale()\n const direction = useDirectionCheck()\n const flash = useRef<HTMLDivElement | null>(null)\n const [message, setMessage] = useState(\"\")\n\n const t = useMemo(() => ({ ...DEFAULT_TRANSLATIONS, ...translations }), [translations])\n\n useEffect(() => {\n const next = match(camera.status)\n .with(\"starting\", () => t.announceStarting)\n .with(\"live\", () => t.announceReady)\n .with(\"paused\", () => t.announcePaused)\n .otherwise(() => null)\n if (next) setMessage(next)\n }, [camera.status, t])\n\n const shared = useMemo<Shared>(() => {\n const format = new Intl.NumberFormat(locale)\n return {\n camera,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n output: output ?? {},\n mirror,\n onCapture,\n flash,\n announce: setMessage,\n number: (value) => format.format(value),\n }\n }, [camera, t, icons, output, mirror, onCapture, locale])\n\n const rootRef = useMergedRefs(ref, direction)\n return (\n <CameraContext value={shared}>\n <ark.div\n ref={rootRef}\n asChild={asChild}\n data-color={color}\n data-status={camera.status}\n className={cn(\"relative flex w-full flex-col gap-3\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n <Announcer message={message} />\n </>\n ))}\n </ark.div>\n </CameraContext>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Viewfinder\n// ---------------------------------------------------------------------------\n\nexport type CameraViewfinderProps = NoAsChild<\n ComponentPropsWithoutRef<\"div\"> &\n WithTestId & {\n /** The box's width / height. Defaults to the camera's `ratio`, else 4/3. The video covers it. */\n ratio?: Ratio\n /** Corner radius, from the media scale. */\n radius?: MediaRadius\n classNames?: { video?: string }\n }\n>\n\n/**\n * The live picture, in a box of a fixed ratio that the video covers. The\n * preview is mirrored for a camera facing the user, as a mirror would be,\n * and only for it. A skeleton holds the box while the camera warms up.\n *\n * Its children sit over the picture: a `Guide`, the `Status` panel, the\n * `Live` badge. It's a size container, so a guide can size its hole in\n * `cqw`/`cqh` without measuring.\n */\nconst CameraViewfinder = ({\n ratio,\n radius = \"xs\",\n classNames,\n className,\n style,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: CameraViewfinderProps) => {\n const { camera, t, flash } = useCameraContext()\n const warming = camera.status === \"starting\" || (camera.status === \"idle\" && !camera.ready)\n return (\n <div\n data-part=\"viewfinder\"\n data-status={camera.status}\n className={cn(\n \"relative w-full overflow-clip bg-black [container-type:size]\",\n MEDIA_RADIUS[radius],\n className,\n )}\n style={{ ...ratioStyle(ratio ?? camera.ratio ?? DEFAULT_RATIO), ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <video\n {...camera.props}\n aria-label={t.viewfinder}\n data-facing={camera.facing}\n className={cn(\n \"absolute inset-0 size-full object-cover\",\n camera.facing === \"user\" && \"-scale-x-100\",\n camera.status !== \"live\" && \"invisible\",\n classNames?.video,\n )}\n />\n {warming && (\n <Skeleton className=\"absolute inset-0 h-full rounded-none bg-white/8 dark:bg-white/8\" />\n )}\n <div\n ref={flash}\n aria-hidden\n data-part=\"flash\"\n className=\"pointer-events-none absolute inset-0 z-3 bg-white opacity-0\"\n />\n {children}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Guide\n// ---------------------------------------------------------------------------\n\nexport type CameraGuideProps = NoAsChild<\n ComponentPropsWithoutRef<\"div\"> &\n WithTestId & {\n /** A circle for a face, a rectangle for a card or a document. */\n shape?: CameraGuideShape\n /** The hole's share of the viewfinder, 0–1, along its tighter side. */\n size?: number\n /** A rectangle's width / height, for a card (`1.586`) or an A4 page (`\"210/297\"`). Defaults to the viewfinder's own. */\n ratio?: Ratio\n }\n>\n\n/** The shorter side of the viewfinder, which is a size container. */\nconst SHORT = \"min(100cqw, 100cqh)\"\n\n/** Where the hole goes, as lengths relative to the viewfinder, centered. */\nconst guideRect = (shape: CameraGuideShape, size: number, ratio: Ratio | undefined): CutoutRect => {\n const aspect = ratio === undefined ? Number.NaN : ratioToNumber(ratio)\n const [width, height] = match({ shape, sized: Number.isFinite(aspect) && aspect > 0 })\n .returnType<[string, string]>()\n .with({ shape: \"circle\" }, () => [`calc(${SHORT} * ${size})`, `calc(${SHORT} * ${size})`])\n .with({ sized: true }, () => {\n const w = `min(calc(100cqw * ${size}), calc(100cqh * ${size} * ${aspect}))`\n return [w, `calc(${w} / ${aspect})`]\n })\n .otherwise(() => [`calc(100cqw * ${size})`, `calc(100cqh * ${size})`])\n return {\n x: `calc((100cqw - ${width}) / 2)`,\n y: `calc((100cqh - ${height}) / 2)`,\n width,\n height,\n }\n}\n\n/**\n * A framing guide over the live picture: the view dimmed, with a circle or a\n * rectangle cut out of it. The dim is `ImageCropper`'s (`lib/cutout.ts`), so a\n * photo framed here crops the same way there. Decorative (`aria-hidden`); in\n * forced colors only its edge is drawn. Shows while the camera is live.\n */\nconst CameraGuide = ({\n shape = \"circle\",\n size = shape === \"circle\" ? 0.7 : 0.85,\n ratio,\n className,\n testId,\n asChild: _asChild,\n ...rest\n}: CameraGuideProps) => {\n const { camera } = useCameraContext()\n if (camera.status !== \"live\") return null\n const rect = guideRect(shape, size, ratio)\n return (\n <div\n aria-hidden\n data-part=\"guide\"\n data-shape={shape}\n className={cn(\"pointer-events-none absolute inset-0\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div\n // The cropper's dim, blur included, so the two read as one tool.\n className=\"absolute inset-0 bg-black/50 backdrop-blur-xs forced-colors:hidden\"\n style={cutoutMask(shape, rect)}\n />\n <div\n className={cn(\n \"absolute border border-(--c-solid) shadow-[0_0_0_1px_rgb(255_255_255/0.45)]\",\n \"forced-colors:border-[CanvasText]\",\n shape === \"circle\" ? \"rounded-full\" : \"rounded-xs\",\n )}\n style={{ insetInlineStart: rect.x, top: rect.y, width: rect.width, height: rect.height }}\n />\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Shutter\n// ---------------------------------------------------------------------------\n\nexport type CameraShutterProps = HTMLArkProps<\"button\"> &\n WithTestId & {\n /** The button, to move focus to it: back to the shutter on a retake. */\n ref?: Ref<HTMLButtonElement>\n }\n\n/**\n * A short white flash over the viewfinder, on the motion tokens. Under\n * reduced motion there's no fade: a frame held for a beat, then gone.\n */\nconst playFlash = (el: HTMLElement | null) => {\n if (!el || typeof el.animate !== \"function\") return\n if (prefersReducedMotion()) {\n el.animate(\n [\n { opacity: 1, backgroundColor: \"transparent\", boxShadow: \"inset 0 0 0 4px #fff\" },\n { opacity: 0 },\n ],\n { duration: durationOf(el, \"slow\"), easing: \"steps(1, end)\" },\n )\n return\n }\n animate(el, [{ opacity: 0.85 }, { opacity: 0 }], { duration: \"slow\", easing: \"standard\" })\n}\n\n/**\n * Takes the photo: a real button, so Space and Enter work. Enabled while the\n * camera is live. The File goes to `Camera.Root`'s `onCapture`, and the\n * camera turns off.\n *\n * Focus stays where it is: the shutter is disabled once the camera stops, so\n * move focus yourself to whatever comes next (the photo, a \"Use photo\"\n * button), or back to the shutter on a retake.\n */\nconst CameraShutter = ({\n className,\n testId,\n asChild,\n children,\n disabled,\n onClick,\n ...rest\n}: CameraShutterProps) => {\n const { camera, t, icons, output, mirror, onCapture, flash, announce } = useCameraContext()\n const [taking, setTaking] = useState(false)\n\n const take = async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n setTaking(true)\n playFlash(flash.current)\n try {\n const file = await camera.capture({ ...output, mirror })\n announce(t.announceTaken)\n onCapture?.(file)\n } catch {\n // Only reachable when the camera dropped between the press and the\n // draw; its own status panel already says so.\n } finally {\n setTaking(false)\n }\n }\n\n const off = disabled || camera.status !== \"live\" || taking\n return (\n <ark.button\n type=\"button\"\n asChild={asChild}\n aria-label={t.shutter}\n disabled={off}\n data-part=\"shutter\"\n onClick={take}\n className={cn(\n \"group/shutter inline-flex size-16 shrink-0 items-center justify-center rounded-full p-1\",\n \"border-[3px] border-(--c-solid) bg-transparent\",\n \"not-disabled:cursor-pointer disabled:opacity-50\",\n focusStyles(),\n className,\n )}\n {...props({ \"aria-busy\": taking, \"data-testid\": testId })}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n <span\n aria-hidden\n className={cn(\n \"flex size-full items-center justify-center rounded-full bg-(--c-solid) text-(--c-on-solid)\",\n \"[&_svg]:size-6\",\n \"transition-[scale,background-color] duration-(--duration-fast) ease-standard motion-reduce:transition-none\",\n \"group-hover/shutter:group-enabled/shutter:bg-(--c-solid-hover) group-active/shutter:group-enabled/shutter:scale-90\",\n )}\n >\n {icons.shutter}\n </span>\n {own}\n </>\n ))}\n </ark.button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Flip\n// ---------------------------------------------------------------------------\n\nexport type CameraFlipProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"button\">, \"color\" | \"children\"> & WithTestId\n>\n\n/**\n * Switches cameras. Renders only when there are two or more. Its name says\n * where it goes: \"Switch to back camera\" from the front one, or \"Switch\n * camera\" between webcams that don't say which way they face.\n */\nconst CameraFlip = ({\n className,\n testId,\n onClick,\n asChild: _asChild,\n ...rest\n}: CameraFlipProps) => {\n const { camera, t, icons } = useCameraContext()\n if (camera.devices.length < 2) return null\n const target = camera.next.facing === camera.facing ? null : camera.next.facing\n return (\n <ActionIcon\n variant=\"subtle\"\n color=\"neutral\"\n aria-label={t.flip(target)}\n className={cn(control, className)}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) camera.flip()\n }}\n testId={testId}\n {...rest}\n >\n {icons.flip}\n </ActionIcon>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Devices\n// ---------------------------------------------------------------------------\n\nexport type CameraDevicesProps = WithTestId & { className?: string }\n\n/**\n * Picks a camera by name. Renders once the camera is granted (before that the\n * browser hides the names) and only when there's more than one.\n */\nconst CameraDevices = ({ className, testId }: CameraDevicesProps) => {\n const { camera, t, number } = useCameraContext()\n const devices = camera.devices.filter((device) => device.id)\n if (camera.permission !== \"granted\" || devices.length < 2) return null\n const data = devices.map((device, index) => ({\n value: device.id,\n label: device.label || t.device(number(index + 1)),\n }))\n return (\n <Select\n data={data}\n value={camera.device}\n onChange={(id) => id && camera.select(id)}\n label={t.devices}\n size=\"sm\"\n className={className}\n classNames={{ label: \"sr-only\" }}\n testId={testId}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// Status\n// ---------------------------------------------------------------------------\n\nexport type CameraStatusProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> &\n WithTestId & {\n /**\n * Rendered in every panel, under its own action: a \"choose a file\"\n * alternative, so a visitor whose camera won't work still has a way\n * through. Called with the status it's shown in.\n */\n children?: (status: CameraStatus) => ReactNode\n }\n>\n\ntype Panel = {\n title: string\n body?: string\n steps?: readonly string[]\n action?: { label: string; icon: ReactNode }\n /** A failure, announced assertively. */\n alert?: boolean\n}\n\n/**\n * The panel over the viewfinder for everything but a live picture: the\n * priming screen before the browser's prompt, starting, paused, and every\n * failure with what to do about it. Failures are `role=\"alert\"`; a refusal\n * lists the steps to undo it in this browser, or this OS.\n */\nconst CameraStatusPanel = ({\n className,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: CameraStatusProps) => {\n const { camera, t, icons } = useCameraContext()\n const [platform, setPlatform] = useState<CameraPlatform>(UNKNOWN_PLATFORM)\n\n // Read on the client only, so the server and hydration agree.\n useEffect(() => {\n setPlatform(detectPlatform(navigator.userAgent, navigator.maxTouchPoints))\n }, [])\n\n const retry = { label: t.retry, icon: icons.retry }\n const panel = match(camera.status)\n .returnType<Panel | null>()\n .with(\"live\", () => null)\n .with(\"idle\", () =>\n camera.ready ? { title: t.offTitle, action: { label: t.start, icon: icons.start } } : null,\n )\n .with(\"prompt\", () => ({\n title: t.primeTitle,\n body: t.primeBody,\n action: { label: t.enable, icon: icons.start },\n }))\n .with(\"starting\", () => ({ title: t.starting }))\n .with(\"paused\", () => ({\n title: t.pausedTitle,\n action: { label: t.resume, icon: icons.start },\n }))\n .with(\"denied\", () => ({\n title: t.deniedTitle,\n body: t.deniedBody,\n steps: t.deniedSteps(platform.browser),\n action: retry,\n alert: true,\n }))\n .with(\"blocked\", () => ({\n title: t.blockedTitle,\n body: t.blockedBody,\n steps: t.blockedSteps(platform.os),\n action: retry,\n alert: true,\n }))\n .with(\"busy\", () => ({ title: t.busyTitle, body: t.busyBody, action: retry, alert: true }))\n .with(\"missing\", () => ({\n title: t.missingTitle,\n body: t.missingBody,\n action: retry,\n alert: true,\n }))\n .with(\"unsupported\", () => ({\n title: t.unsupportedTitle,\n body: t.unsupportedBody,\n alert: true,\n }))\n .with(\"error\", () => ({ title: t.errorTitle, body: t.errorBody, action: retry, alert: true }))\n .exhaustive()\n\n if (!panel) return null\n return (\n <div\n data-part=\"status\"\n data-status={camera.status}\n className={cn(\n \"absolute inset-0 z-2 flex flex-col items-center justify-center gap-3 overflow-y-auto p-4 text-center\",\n \"bg-black/80 text-white\",\n camera.status === \"starting\" && \"bg-transparent\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <div role={panel.alert ? \"alert\" : undefined} className=\"flex max-w-sm flex-col gap-2\">\n {panel.alert && <span className=\"mx-auto text-white/80 [&_svg]:size-6\">{icons.off}</span>}\n <p className=\"font-medium text-md\">{panel.title}</p>\n {panel.body && <p className=\"text-white/80 text-sm\">{panel.body}</p>}\n {panel.steps && (\n <ol className=\"list-decimal ps-5 text-start text-white/80 text-sm\">\n {panel.steps.map((step) => (\n <li key={step}>{step}</li>\n ))}\n </ol>\n )}\n </div>\n {(panel.action || children) && (\n <div className=\"flex flex-wrap items-center justify-center gap-2\">\n {panel.action && (\n <Button size=\"sm\" startSlot={panel.action.icon} onClick={() => void camera.start()}>\n {panel.action.label}\n </Button>\n )}\n {children?.(camera.status)}\n </div>\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Live\n// ---------------------------------------------------------------------------\n\nexport type CameraLiveProps = NoAsChild<\n Omit<ComponentPropsWithoutRef<\"span\">, \"color\" | \"children\"> & WithTestId\n>\n\n/** A \"Camera on\" badge, shown while the camera is live. */\nconst CameraLive = ({ className, testId, asChild: _asChild, ...rest }: CameraLiveProps) => {\n const { camera, t } = useCameraContext()\n if (camera.status !== \"live\") return null\n return (\n <Badge\n variant=\"filled\"\n color=\"red\"\n size=\"sm\"\n data-part=\"live\"\n className={cn(\"gap-1.5\", className)}\n testId={testId}\n {...rest}\n >\n <span aria-hidden className=\"size-1.5 rounded-full bg-current\" />\n {t.live}\n </Badge>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\nexport type CameraClassNames = {\n viewfinder?: string\n video?: string\n guide?: string\n status?: string\n controls?: string\n shutter?: string\n flip?: string\n}\n\nexport type CameraProps = NoAsChild<\n Omit<CameraRootProps, \"camera\" | \"children\"> &\n UseCameraOptions & {\n /** A framing guide over the picture. None by default. */\n shape?: CameraGuideShape\n /** The viewfinder's corner radius, from the media scale. */\n radius?: MediaRadius\n classNames?: CameraClassNames\n /** Rendered in every status panel: a file alternative. See `Camera.Status`. */\n children?: (status: CameraStatus) => ReactNode\n }\n>\n\nconst CameraComponent = ({\n facing,\n device,\n ratio,\n resolution,\n lazy,\n shape,\n radius,\n classNames,\n children,\n asChild: _asChild,\n ...rest\n}: CameraProps) => {\n const camera = useCamera({ facing, device, ratio, resolution, lazy })\n return (\n <CameraRoot camera={camera} {...rest}>\n <CameraViewfinder\n radius={radius}\n className={classNames?.viewfinder}\n classNames={{ video: classNames?.video }}\n >\n {shape && <CameraGuide shape={shape} className={classNames?.guide} />}\n <CameraLive className=\"absolute start-2 top-2 z-1\" />\n <CameraStatusPanel className={classNames?.status}>{children}</CameraStatusPanel>\n </CameraViewfinder>\n <div className={cn(\"grid grid-cols-[1fr_auto_1fr] items-center gap-3\", classNames?.controls)}>\n <span />\n <CameraShutter className={classNames?.shutter} />\n <CameraFlip className={cn(\"justify-self-start\", classNames?.flip)} />\n </div>\n </CameraRoot>\n )\n}\n\nexport const Camera = Object.assign(CameraComponent, {\n Root: CameraRoot,\n Viewfinder: CameraViewfinder,\n Guide: CameraGuide,\n Shutter: CameraShutter,\n Flip: CameraFlip,\n Devices: CameraDevices,\n Status: CameraStatusPanel,\n Live: CameraLive,\n})\n"]}
@@ -1,7 +1,7 @@
1
1
  import { normalizeSelectData } from './chunk-7TDHT3QD.js';
2
+ import { COMBOBOX_DEFAULT_TRANSLATIONS } from './chunk-YPFSRZ3T.js';
2
3
  import { controlOpenProps } from './chunk-5FDOOG4J.js';
3
- import { COMBOBOX_DEFAULT_TRANSLATIONS } from './chunk-2BNIHOMT.js';
4
- import { inputSlot, placeholderColor, shellGap, inputShell } from './chunk-45QRQKRC.js';
4
+ import { inputSlot, placeholderColor, shellGap, inputShell } from './chunk-3L5GLI67.js';
5
5
  import { FieldShell, fieldA11yProps } from './chunk-VD6PB3VA.js';
6
6
  import { useMergedRefs } from './chunk-HBWV5EPU.js';
7
7
  import { scrollHighlightedIntoView, popoverClearTrigger, popoverChevron, popoverGroupLabel, popoverList, popoverContent, popoverIndicator, popoverOption } from './chunk-N66NC6QK.js';
@@ -217,5 +217,5 @@ var Select = ({
217
217
  };
218
218
 
219
219
  export { Select };
220
- //# sourceMappingURL=chunk-Z4MBCKG5.js.map
221
- //# sourceMappingURL=chunk-Z4MBCKG5.js.map
220
+ //# sourceMappingURL=chunk-FB2G4LNH.js.map
221
+ //# sourceMappingURL=chunk-FB2G4LNH.js.map