tempest-react-sdk 0.48.0 → 0.49.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 (194) hide show
  1. package/dist/audio/sfx-pool.cjs +1 -1
  2. package/dist/audio/sfx-pool.cjs.map +1 -1
  3. package/dist/audio/sfx-pool.js +16 -7
  4. package/dist/audio/sfx-pool.js.map +1 -1
  5. package/dist/audio/use-sfx-pool.cjs +1 -1
  6. package/dist/audio/use-sfx-pool.cjs.map +1 -1
  7. package/dist/audio/use-sfx-pool.js +3 -8
  8. package/dist/audio/use-sfx-pool.js.map +1 -1
  9. package/dist/auth/passkey.cjs +1 -1
  10. package/dist/auth/passkey.cjs.map +1 -1
  11. package/dist/auth/passkey.js +79 -81
  12. package/dist/auth/passkey.js.map +1 -1
  13. package/dist/charts.cjs +1 -1
  14. package/dist/charts.js +4 -4
  15. package/dist/components/BarList/BarList.cjs +1 -1
  16. package/dist/components/BarList/BarList.cjs.map +1 -1
  17. package/dist/components/BarList/BarList.js +31 -24
  18. package/dist/components/BarList/BarList.js.map +1 -1
  19. package/dist/components/BarList/bar-list-model.cjs +1 -1
  20. package/dist/components/BarList/bar-list-model.cjs.map +1 -1
  21. package/dist/components/BarList/bar-list-model.js +5 -5
  22. package/dist/components/BarList/bar-list-model.js.map +1 -1
  23. package/dist/components/ClickOutside/ClickOutside.cjs +1 -1
  24. package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
  25. package/dist/components/ClickOutside/ClickOutside.js +13 -14
  26. package/dist/components/ClickOutside/ClickOutside.js.map +1 -1
  27. package/dist/components/DataTable/DataTable.cjs +1 -1
  28. package/dist/components/DataTable/DataTable.cjs.map +1 -1
  29. package/dist/components/DataTable/DataTable.js +124 -122
  30. package/dist/components/DataTable/DataTable.js.map +1 -1
  31. package/dist/components/FilterBar/filter-apply.cjs +1 -1
  32. package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
  33. package/dist/components/FilterBar/filter-apply.js +35 -38
  34. package/dist/components/FilterBar/filter-apply.js.map +1 -1
  35. package/dist/components/FilterBar/filter-query.cjs +1 -1
  36. package/dist/components/FilterBar/filter-query.cjs.map +1 -1
  37. package/dist/components/FilterBar/filter-query.js +16 -13
  38. package/dist/components/FilterBar/filter-query.js.map +1 -1
  39. package/dist/geo/use-position-tracker.cjs +1 -1
  40. package/dist/geo/use-position-tracker.cjs.map +1 -1
  41. package/dist/geo/use-position-tracker.js +25 -26
  42. package/dist/geo/use-position-tracker.js.map +1 -1
  43. package/dist/hooks/use-async.cjs +1 -1
  44. package/dist/hooks/use-async.cjs.map +1 -1
  45. package/dist/hooks/use-async.js +27 -30
  46. package/dist/hooks/use-async.js.map +1 -1
  47. package/dist/hooks/use-click-outside.cjs +1 -1
  48. package/dist/hooks/use-click-outside.cjs.map +1 -1
  49. package/dist/hooks/use-click-outside.js +8 -9
  50. package/dist/hooks/use-click-outside.js.map +1 -1
  51. package/dist/hooks/use-countdown.cjs +1 -1
  52. package/dist/hooks/use-countdown.cjs.map +1 -1
  53. package/dist/hooks/use-countdown.js +8 -13
  54. package/dist/hooks/use-countdown.js.map +1 -1
  55. package/dist/hooks/use-event-listener.cjs +1 -1
  56. package/dist/hooks/use-event-listener.cjs.map +1 -1
  57. package/dist/hooks/use-event-listener.js +6 -6
  58. package/dist/hooks/use-event-listener.js.map +1 -1
  59. package/dist/hooks/use-interval.cjs +1 -1
  60. package/dist/hooks/use-interval.cjs.map +1 -1
  61. package/dist/hooks/use-interval.js +5 -6
  62. package/dist/hooks/use-interval.js.map +1 -1
  63. package/dist/hooks/use-latest-ref.cjs.map +1 -1
  64. package/dist/hooks/use-latest-ref.js.map +1 -1
  65. package/dist/hooks/use-long-press-handlers.cjs +1 -1
  66. package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
  67. package/dist/hooks/use-long-press-handlers.js +8 -10
  68. package/dist/hooks/use-long-press-handlers.js.map +1 -1
  69. package/dist/hooks/use-long-press.cjs +1 -1
  70. package/dist/hooks/use-long-press.cjs.map +1 -1
  71. package/dist/hooks/use-long-press.js +6 -6
  72. package/dist/hooks/use-long-press.js.map +1 -1
  73. package/dist/hooks/use-online.cjs +1 -1
  74. package/dist/hooks/use-online.cjs.map +1 -1
  75. package/dist/hooks/use-online.js +10 -10
  76. package/dist/hooks/use-online.js.map +1 -1
  77. package/dist/hooks/use-service-worker-update.cjs +1 -1
  78. package/dist/hooks/use-service-worker-update.cjs.map +1 -1
  79. package/dist/hooks/use-service-worker-update.js +24 -25
  80. package/dist/hooks/use-service-worker-update.js.map +1 -1
  81. package/dist/hooks/use-stable-callback.cjs +1 -1
  82. package/dist/hooks/use-stable-callback.cjs.map +1 -1
  83. package/dist/hooks/use-stable-callback.js +4 -3
  84. package/dist/hooks/use-stable-callback.js.map +1 -1
  85. package/dist/hooks/use-timeout.cjs +1 -1
  86. package/dist/hooks/use-timeout.cjs.map +1 -1
  87. package/dist/hooks/use-timeout.js +5 -6
  88. package/dist/hooks/use-timeout.js.map +1 -1
  89. package/dist/hooks/use-typewriter.cjs +1 -1
  90. package/dist/hooks/use-typewriter.cjs.map +1 -1
  91. package/dist/hooks/use-typewriter.js +9 -18
  92. package/dist/hooks/use-typewriter.js.map +1 -1
  93. package/dist/http/api-client.cjs +1 -1
  94. package/dist/http/api-client.cjs.map +1 -1
  95. package/dist/http/api-client.js +11 -16
  96. package/dist/http/api-client.js.map +1 -1
  97. package/dist/http/describe-api-error.cjs +1 -1
  98. package/dist/http/describe-api-error.cjs.map +1 -1
  99. package/dist/http/describe-api-error.js +12 -15
  100. package/dist/http/describe-api-error.js.map +1 -1
  101. package/dist/http/errors.cjs +1 -1
  102. package/dist/http/errors.cjs.map +1 -1
  103. package/dist/http/errors.js +18 -6
  104. package/dist/http/errors.js.map +1 -1
  105. package/dist/http/resumable-upload.cjs +1 -1
  106. package/dist/http/resumable-upload.cjs.map +1 -1
  107. package/dist/http/resumable-upload.js +60 -61
  108. package/dist/http/resumable-upload.js.map +1 -1
  109. package/dist/http/retry.cjs +1 -1
  110. package/dist/http/retry.cjs.map +1 -1
  111. package/dist/http/retry.js +20 -16
  112. package/dist/http/retry.js.map +1 -1
  113. package/dist/http/use-describe-api-error.cjs +1 -1
  114. package/dist/http/use-describe-api-error.cjs.map +1 -1
  115. package/dist/http/use-describe-api-error.js +2 -2
  116. package/dist/http/use-describe-api-error.js.map +1 -1
  117. package/dist/i18n/create-i18n.cjs +1 -1
  118. package/dist/i18n/create-i18n.cjs.map +1 -1
  119. package/dist/i18n/create-i18n.js +6 -6
  120. package/dist/i18n/create-i18n.js.map +1 -1
  121. package/dist/icons/material-symbols.cjs +1 -1
  122. package/dist/icons/material-symbols.cjs.map +1 -1
  123. package/dist/icons/material-symbols.js +136 -5
  124. package/dist/icons/material-symbols.js.map +1 -1
  125. package/dist/icons.d.ts +17 -5
  126. package/dist/offline/create-offline-sync.cjs +1 -1
  127. package/dist/offline/create-offline-sync.cjs.map +1 -1
  128. package/dist/offline/create-offline-sync.js +17 -9
  129. package/dist/offline/create-offline-sync.js.map +1 -1
  130. package/dist/offline/use-offline-sync.cjs +1 -1
  131. package/dist/offline/use-offline-sync.cjs.map +1 -1
  132. package/dist/offline/use-offline-sync.js +7 -8
  133. package/dist/offline/use-offline-sync.js.map +1 -1
  134. package/dist/push/use-push-subscription.cjs +1 -1
  135. package/dist/push/use-push-subscription.cjs.map +1 -1
  136. package/dist/push/use-push-subscription.js +13 -12
  137. package/dist/push/use-push-subscription.js.map +1 -1
  138. package/dist/query/retry-policy.cjs +1 -1
  139. package/dist/query/retry-policy.cjs.map +1 -1
  140. package/dist/query/retry-policy.js +3 -3
  141. package/dist/query/retry-policy.js.map +1 -1
  142. package/dist/sse/use-event-stream.cjs +1 -1
  143. package/dist/sse/use-event-stream.cjs.map +1 -1
  144. package/dist/sse/use-event-stream.js +19 -20
  145. package/dist/sse/use-event-stream.js.map +1 -1
  146. package/dist/tabular/use-tabular-predictor.cjs +1 -1
  147. package/dist/tabular/use-tabular-predictor.cjs.map +1 -1
  148. package/dist/tabular/use-tabular-predictor.js +20 -17
  149. package/dist/tabular/use-tabular-predictor.js.map +1 -1
  150. package/dist/tempest-react-sdk.cjs +1 -1
  151. package/dist/tempest-react-sdk.d.ts +363 -149
  152. package/dist/tempest-react-sdk.js +143 -143
  153. package/dist/theme/ThemeProvider.cjs +1 -1
  154. package/dist/theme/ThemeProvider.cjs.map +1 -1
  155. package/dist/theme/ThemeProvider.js +12 -17
  156. package/dist/theme/ThemeProvider.js.map +1 -1
  157. package/dist/utils/base64.cjs +2 -0
  158. package/dist/utils/base64.cjs.map +1 -0
  159. package/dist/utils/base64.js +16 -0
  160. package/dist/utils/base64.js.map +1 -0
  161. package/dist/utils/compare-values.cjs +1 -1
  162. package/dist/utils/compare-values.cjs.map +1 -1
  163. package/dist/utils/compare-values.js +4 -3
  164. package/dist/utils/compare-values.js.map +1 -1
  165. package/dist/utils/compressed-storage.cjs +1 -1
  166. package/dist/utils/compressed-storage.cjs.map +1 -1
  167. package/dist/utils/compressed-storage.js +16 -46
  168. package/dist/utils/compressed-storage.js.map +1 -1
  169. package/dist/utils/storage.cjs +1 -1
  170. package/dist/utils/storage.cjs.map +1 -1
  171. package/dist/utils/storage.js +37 -17
  172. package/dist/utils/storage.js.map +1 -1
  173. package/dist/vision/use-camera-stream.cjs +1 -1
  174. package/dist/vision/use-camera-stream.cjs.map +1 -1
  175. package/dist/vision/use-camera-stream.js +34 -33
  176. package/dist/vision/use-camera-stream.js.map +1 -1
  177. package/dist/vite/base-url.cjs +2 -0
  178. package/dist/vite/base-url.cjs.map +1 -0
  179. package/dist/vite/base-url.js +8 -0
  180. package/dist/vite/base-url.js.map +1 -0
  181. package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
  182. package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
  183. package/dist/vite/tempest-pwa-dev-sw.js +54 -29
  184. package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
  185. package/dist/vite/tempest-pwa-manifest.cjs +2 -2
  186. package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
  187. package/dist/vite/tempest-pwa-manifest.js +15 -14
  188. package/dist/vite/tempest-pwa-manifest.js.map +1 -1
  189. package/dist/vite.d.ts +2 -2
  190. package/dist/ws/use-web-socket.cjs +1 -1
  191. package/dist/ws/use-web-socket.cjs.map +1 -1
  192. package/dist/ws/use-web-socket.js +40 -42
  193. package/dist/ws/use-web-socket.js.map +1 -1
  194. package/package.json +1 -1
@@ -39,23 +39,23 @@ import { useDebounce as H } from "./hooks/use-debounce.js";
39
39
  import { usePagination as U } from "./hooks/use-pagination.js";
40
40
  import { useClientFilter as W } from "./hooks/use-client-filter.js";
41
41
  import { useMediaQuery as G } from "./hooks/use-media-query.js";
42
- import { useEventListener as K } from "./hooks/use-event-listener.js";
43
- import { useLocalStorage as q } from "./hooks/use-local-storage.js";
44
- import { useToggle as J } from "./hooks/use-toggle.js";
45
- import { useAsync as Y } from "./hooks/use-async.js";
46
- import { useOnline as X } from "./hooks/use-online.js";
47
- import { useDocumentVisibility as Z } from "./hooks/use-document-visibility.js";
48
- import { useIntersectionObserver as Q } from "./hooks/use-intersection-observer.js";
49
- import { useResizeObserver as $ } from "./hooks/use-resize-observer.js";
50
- import { useClipboard as ee } from "./hooks/use-clipboard.js";
51
- import { useKeyboardShortcut as te } from "./hooks/use-keyboard-shortcut.js";
52
- import { useIdle as ne } from "./hooks/use-idle.js";
53
- import { useGeolocation as re } from "./hooks/use-geolocation.js";
54
- import { useScrollLock as ie } from "./hooks/use-scroll-lock.js";
55
- import { useFocusTrap as ae } from "./hooks/use-focus-trap.js";
56
- import { announce as oe, clearAnnouncer as se, useAnnounce as ce } from "./hooks/use-announce.js";
57
- import { useStableCallback as le } from "./hooks/use-stable-callback.js";
58
- import { useLatestRef as ue } from "./hooks/use-latest-ref.js";
42
+ import { useLatestRef as K } from "./hooks/use-latest-ref.js";
43
+ import { useEventListener as q } from "./hooks/use-event-listener.js";
44
+ import { useLocalStorage as J } from "./hooks/use-local-storage.js";
45
+ import { useToggle as Y } from "./hooks/use-toggle.js";
46
+ import { useAsync as X } from "./hooks/use-async.js";
47
+ import { useOnline as Z } from "./hooks/use-online.js";
48
+ import { useDocumentVisibility as Q } from "./hooks/use-document-visibility.js";
49
+ import { useIntersectionObserver as $ } from "./hooks/use-intersection-observer.js";
50
+ import { useResizeObserver as ee } from "./hooks/use-resize-observer.js";
51
+ import { useClipboard as te } from "./hooks/use-clipboard.js";
52
+ import { useKeyboardShortcut as ne } from "./hooks/use-keyboard-shortcut.js";
53
+ import { useIdle as re } from "./hooks/use-idle.js";
54
+ import { useGeolocation as ie } from "./hooks/use-geolocation.js";
55
+ import { useScrollLock as ae } from "./hooks/use-scroll-lock.js";
56
+ import { useFocusTrap as oe } from "./hooks/use-focus-trap.js";
57
+ import { announce as se, clearAnnouncer as ce, useAnnounce as le } from "./hooks/use-announce.js";
58
+ import { useStableCallback as ue } from "./hooks/use-stable-callback.js";
59
59
  import { useDeepMemo as de } from "./hooks/use-deep-memo.js";
60
60
  import { usePrevious as fe } from "./hooks/use-previous.js";
61
61
  import { useInterval as pe } from "./hooks/use-interval.js";
@@ -205,129 +205,129 @@ import { buildBarListRows as Pr } from "./components/BarList/bar-list-model.js";
205
205
  import { BarList as Fr } from "./components/BarList/BarList.js";
206
206
  import { describeFilter as Ir, filtersFromSearchParams as Lr, filtersToSearchParams as Rr, operatorsFor as zr } from "./components/FilterBar/filter-model.js";
207
207
  import { FilterBar as Br } from "./components/FilterBar/FilterBar.js";
208
- import { applyFilters as Vr } from "./components/FilterBar/filter-apply.js";
209
- import { filtersToQueryParams as Hr } from "./components/FilterBar/filter-query.js";
210
- import { formatCPF as Ur, formatCurrency as Wr, formatDate as Gr, formatDateForInput as Kr, formatDateTime as qr, formatPercent as Jr, formatPhone as Yr } from "./utils/format.js";
211
- import { storage as Xr } from "./utils/storage.js";
212
- import { compressToString as Zr, compressedStorage as Qr, compressedStorageCodec as $r, decompressFromString as ei } from "./utils/compressed-storage.js";
213
- import { camelCase as ti, capitalize as ni, kebabCase as ri, pluralize as ii, slugify as ai, truncate as oi } from "./utils/strings.js";
214
- import { chunk as si, groupBy as ci, range as li, uniqueBy as ui } from "./utils/arrays.js";
215
- import { deepMerge as di, isEmpty as fi, omit as pi, pick as mi } from "./utils/objects.js";
216
- import { assertNever as hi, isDefined as gi, isNumber as _i, isPlainObject as vi, isString as yi } from "./utils/guards.js";
217
- import { debounce as bi, memoizeOne as xi, once as Si, throttle as Ci } from "./utils/functions.js";
218
- import { sleep as wi, withTimeout as Ti } from "./utils/promises.js";
219
- import { randomId as Ei } from "./utils/ids.js";
220
- import { writeXlsx as Di } from "./utils/xlsx.js";
221
- import { isShareSupported as Oi, share as ki } from "./share/share.js";
222
- import { shareOrDownloadBlob as Ai } from "./share/share-or-download.js";
223
- import { downloadCsv as ji, toCsv as Mi } from "./utils/csv.js";
224
- import { buildApiUrl as Ni } from "./http/build-url.js";
225
- import { TempestApiError as Pi, isApiError as Fi } from "./http/errors.js";
226
- import { retry as Ii } from "./http/retry.js";
227
- import { createApiClient as Li } from "./http/api-client.js";
228
- import { API_ERROR_OFFLINE_KEY as Ri, API_ERROR_VALIDATION_KEY as zi, DEFAULT_API_ERROR_STRINGS as Bi, describeApiError as Vi } from "./http/describe-api-error.js";
229
- import { createI18n as Hi } from "./i18n/create-i18n.js";
230
- import { I18nProvider as Ui, useI18n as Wi, useOptionalI18n as Gi, useTranslate as Ki } from "./i18n/I18nProvider.js";
231
- import { useDescribeApiError as qi } from "./http/use-describe-api-error.js";
232
- import { parseResponse as Ji } from "./http/parse-response.js";
233
- import { uploadWithProgress as Yi } from "./http/upload-with-progress.js";
234
- import { generateIdempotencyKey as Xi } from "./http/idempotency.js";
235
- import { DEFAULT_CHUNK_SIZE as Zi, createLocalUploadStorage as Qi, createResumableUpload as $i, uploadFingerprint as ea } from "./http/resumable-upload.js";
236
- import { usePoll as ta } from "./http/use-poll.js";
237
- import { createAuthStore as na } from "./auth/create-auth-store.js";
238
- import { AuthGuard as ra } from "./auth/AuthGuard.js";
239
- import { decodeJWT as ia, isJWTExpired as aa } from "./auth/jwt.js";
240
- import { lazyWithRetry as oa } from "./auth/lazy-with-retry.js";
241
- import { createRefreshQueue as sa } from "./auth/refresh-queue.js";
242
- import { DEFAULT_PUB_KEY_CRED_PARAMS as ca, PasskeyError as la, base64UrlToBytes as ua, bytesToBase64Url as da, classifyPasskeyError as fa, createPasskeyClient as pa, isConditionalMediationAvailable as ma, isPasskeySupported as ha, isPlatformAuthenticatorAvailable as ga } from "./auth/passkey.js";
243
- import { usePasskeyCapabilities as _a, usePasskeyRegistration as va, usePasskeySignIn as ya } from "./auth/use-passkey.js";
244
- import { createTempestAuth as ba } from "./auth/create-tempest-auth.js";
245
- import { AccessControlProvider as xa, useAccessControl as Sa } from "./access/access-control-context.js";
246
- import { useCan as Ca } from "./access/use-can.js";
247
- import { Can as wa } from "./access/Can.js";
248
- import { createRoleAccessControl as Ta } from "./access/create-role-access-control.js";
249
- import { permissionsFromToken as Ea } from "./access/permissions-from-token.js";
250
- import { GoogleSignIn as Da } from "./oauth/GoogleSignIn.js";
251
- import { useOAuthCallback as Oa } from "./oauth/use-oauth-callback.js";
252
- import { CACHE_TIME as ka, REFETCH_TIME as Aa, STALE_TIME as ja } from "./query/constants.js";
253
- import { createQueryKeys as Ma } from "./query/create-query-keys.js";
254
- import { shouldRetryQuery as Na } from "./query/retry-policy.js";
255
- import { QueryProvider as Pa } from "./query/QueryProvider.js";
256
- import { emptyOffsetPage as Fa, isCursorPage as Ia, isOffsetPage as La } from "./query/pagination.js";
257
- import { usePaginatedQuery as Ra } from "./query/use-paginated-query.js";
258
- import { useCursorQuery as za } from "./query/use-cursor-query.js";
259
- import { useOfflineMutation as Ba } from "./query/use-offline-mutation.js";
260
- import { removeById as Va, upsertById as Ha } from "./query/optimistic.js";
261
- import { createOfflineStore as Ua } from "./offline/create-offline-store.js";
262
- import { persistQueryClientOffline as Wa } from "./query/offline-persistence.js";
263
- import { createDataProvider as Ga } from "./data/create-data-provider.js";
264
- import { TempestDataProvider as Ka, useDataProvider as qa } from "./data/data-provider-context.js";
265
- import { listQueryKey as Ja, oneQueryKey as Ya, useCreate as Xa, useDelete as Za, useList as Qa, useOne as $a, useUpdate as eo } from "./data/use-resource.js";
266
- import { RouteGuard as to } from "./router/RouteGuard.js";
267
- import { AppRouter as no, defineRoutes as ro } from "./router/AppRouter.js";
268
- import { BrowserRouter as io, HashRouter as ao, Link as oo, MemoryRouter as so, NavLink as co, Navigate as lo, Outlet as uo, Route as fo, Routes as po, redirect as mo, useLocation as ho, useMatch as go, useNavigate as _o, useParams as vo, useRouteError as yo, useSearchParams as bo } from "./router/index.js";
269
- import { createStore as xo } from "./store/create-store.js";
270
- import { createSelectors as So } from "./store/create-selectors.js";
271
- import { ThemeProvider as Co, useTheme as wo } from "./theme/ThemeProvider.js";
272
- import { ErrorBoundary as To } from "./error-boundary/ErrorBoundary.js";
273
- import { AppProviders as Eo } from "./app/AppProviders.js";
274
- import { createEventStream as Do } from "./sse/create-event-stream.js";
275
- import { useEventStream as Oo } from "./sse/use-event-stream.js";
276
- import { isPushSupported as ko, urlBase64ToUint8Array as Ao } from "./push/utils.js";
277
- import { WebPushClient as jo, WebPushPermissionDeniedError as Mo, WebPushUnsupportedError as No } from "./push/web-push-client.js";
278
- import { usePushSubscription as Po } from "./push/use-push-subscription.js";
279
- import { installNotificationClickHandler as Fo, installPushHandler as Io, installSkipWaitingListener as Lo } from "./sw/create-push-handler.js";
280
- import { createPartialResponse as Ro, installPrecache as zo, installRuntimeCache as Bo } from "./sw/cache.js";
281
- import { installBackgroundSync as Vo } from "./sw/background-sync.js";
282
- import { registerPeriodicSync as Ho } from "./sw/periodic-sync.js";
283
- import { clearCaches as Uo, inspectCaches as Wo } from "./sw/cache-inspect.js";
284
- import { createAudioPlayer as Go, playAudio as Ko, stopAudio as qo } from "./audio/audio-player.js";
285
- import { useAudio as Jo } from "./audio/use-audio.js";
286
- import { createSfxPool as Yo } from "./audio/sfx-pool.js";
287
- import { useSfxPool as Xo } from "./audio/use-sfx-pool.js";
288
- import { createVideoRecorder as Zo, isVideoRecordingSupported as Qo, pickVideoMimeType as $o } from "./capture/video-recorder.js";
289
- import { useVideoRecorder as es } from "./capture/use-video-recorder.js";
290
- import { isScreenCaptureSupported as ts, useScreenCapture as ns } from "./capture/use-screen-capture.js";
291
- import { isSpeechRecognitionSupported as rs, useSpeechRecognition as is } from "./capture/use-speech-recognition.js";
292
- import { createOfflineSync as as } from "./offline/create-offline-sync.js";
293
- import { higherVersionWins as os, lastWriteWins as ss } from "./offline/conflict.js";
294
- import { useErrorHandler as cs } from "./error-boundary/use-error-handler.js";
295
- import { FormField as ls } from "./forms/FormField.js";
296
- import { validateForm as us } from "./forms/validate-form.js";
297
- import { zodResolver as ds } from "./forms/zod-resolver.js";
298
- import { useZodForm as fs } from "./forms/use-zod-form.js";
299
- import { formatCEP as ps, formatCNPJ as ms, unmask as hs, validateCNPJ as gs, validateCPF as _s } from "./forms/br-validators.js";
300
- import { CEPInput as vs, CNPJInput as ys, CPFInput as bs, MoneyInput as xs, PhoneInput as Ss } from "./forms/masked-inputs.js";
301
- import { useViaCEP as Cs } from "./forms/use-viacep.js";
302
- import { Controller as ws, FormProvider as Ts, useFieldArray as Es, useForm as Ds, useFormContext as Os, useFormState as ks, useWatch as As } from "./forms/index.js";
303
- import { createWebSocket as js } from "./ws/create-web-socket.js";
304
- import { useWebSocket as Ms } from "./ws/use-web-socket.js";
305
- import { clampLatitude as Ns, isCoordinate as Ps, isValidLatitude as Fs, isValidLongitude as Is, normalizeLongitude as Ls } from "./geo/types.js";
306
- import { EARTH_RADIUS_KM as Rs, bearingDeg as zs, haversineKm as Bs, pathLengthKm as Vs, toRadians as Hs } from "./geo/distance.js";
307
- import { DEFAULT_CAR_SPEED_KMH as Us, DEFAULT_CIRCUITY_FACTOR as Ws, DEFAULT_MODE_DURATION_FACTORS as Gs, estimateTravel as Ks } from "./geo/estimate.js";
308
- import { boundingBox as qs, boundsCenter as Js, expandBounds as Ys } from "./geo/bounds.js";
309
- import { fitProjection as Xs, projectMercator as Zs, unprojectMercator as Qs } from "./geo/projection.js";
310
- import { createOSRMBackend as $s } from "./geo/routing.js";
311
- import { createPositionTracker as ec } from "./geo/create-position-tracker.js";
312
- import { usePositionTracker as tc } from "./geo/use-position-tracker.js";
313
- import { TrajectoryMap as nc } from "./geo/TrajectoryMap.js";
314
- import { applyTheme as rc, readThemeToken as ic } from "./theme/apply-theme.js";
315
- import { contrastRatio as ac, createColorScale as oc, hexToOklch as sc, hexToRgb as cc, hexToRgbaString as lc, oklchToHex as uc, readableForeground as dc, relativeLuminance as fc, rgbToHex as pc } from "./theme/color.js";
316
- import { createTheme as mc, themeContrast as hc } from "./theme/create-theme.js";
317
- import { getThemePreset as gc, themePresets as _c } from "./theme/theme-presets.js";
318
- import { getInitialTheme as vc, themeInitScript as yc } from "./theme/initial-theme.js";
319
- import { consoleSink as bc, createLogger as xc } from "./logger/logger.js";
320
- import { TelemetryProvider as Sc, useTelemetry as Cc } from "./telemetry/TelemetryProvider.js";
321
- import { consoleTelemetryAdapter as wc } from "./telemetry/console-adapter.js";
322
- import { createSentryTelemetryAdapter as Tc } from "./telemetry/sentry-adapter.js";
323
- import { createPostHogTelemetryAdapter as Ec } from "./telemetry/posthog-adapter.js";
324
- import { FeatureFlagsProvider as Dc, useFeatureFlag as Oc, useFlagValue as kc } from "./feature-flags/FeatureFlagsProvider.js";
325
- import { createInMemoryFlags as Ac } from "./feature-flags/in-memory-adapter.js";
326
- import { createGrowthBookFeatureFlagsAdapter as jc } from "./feature-flags/growthbook-adapter.js";
327
- import { createLaunchDarklyFeatureFlagsAdapter as Mc } from "./feature-flags/launchdarkly-adapter.js";
328
- import { DIVERGING_STEP_COUNT as Nc, ORDINAL_START_STEP as Pc, SEQUENTIAL_STEP_COUNT as Fc, divergingScale as Ic, scaleSteps as Lc, sequentialScale as Rc } from "./charts/scales.js";
329
- import { cachedResponseBytes as zc } from "./perf/cache-size.js";
330
- import { readDeviceProfile as Bc } from "./perf/device.js";
331
- import { formatDurationMs as Vc } from "./perf/format.js";
332
- import { createInferenceProfiler as Hc } from "./perf/profiler.js";
333
- export { Ar as AIChat, Dr as AIChatComposer, kr as AIChatTurn, dr as ALL_BARCODE_FORMATS, Ri as API_ERROR_OFFLINE_KEY, zi as API_ERROR_VALIDATION_KEY, er as AUDIO_MIME_CANDIDATES, xa as AccessControlProvider, t as Accordion, n as Alert, r as AppBar, Eo as AppProviders, no as AppRouter, o as AppShell, s as AspectRatio, Qn as AudioPlayer, ur as AudioRecorder, ra as AuthGuard, c as Avatar, l as AvatarGroup, i as BREAKPOINTS, u as Badge, d as Banner, Fr as BarList, yr as BarcodeScanner, f as BottomNavigation, p as BottomSheet, m as Breadcrumbs, io as BrowserRouter, h as Button, ka as CACHE_TIME, vs as CEPInput, ys as CNPJInput, bs as CPFInput, Mn as Calendar, wa as Can, g as Card, Rn as Carousel, _ as Center, Yn as Chat, Jn as ChatComposer, v as Checkbox, y as ChipInput, hn as ClickOutside, ln as CodeBlock, En as Collapsible, b as Combobox, kn as Command, gn as ConditionalWrapper, S as ConfirmDialog, I as Container, Dn as ContextMenu, ws as Controller, cn as CopyButton, Bi as DEFAULT_API_ERROR_STRINGS, fr as DEFAULT_BARCODE_FORMATS, Us as DEFAULT_CAR_SPEED_KMH, Zi as DEFAULT_CHUNK_SIZE, Ws as DEFAULT_CIRCUITY_FACTOR, Gs as DEFAULT_MODE_DURATION_FACTORS, ca as DEFAULT_PUB_KEY_CRED_PARAMS, Nc as DIVERGING_STEP_COUNT, bn as DataList, zn as DataTable, w as DatePicker, Fn as DateRangePicker, xn as DescriptionList, T as Divider, E as Drawer, D as DropdownMenu, O as Dropzone, Rs as EARTH_RADIUS_KM, k as EmptyState, To as ErrorBoundary, A as ErrorState, vn as ErrorText, Dc as FeatureFlagsProvider, j as FileUpload, Br as FilterBar, Vn as FloatingActionButton, _n as For, M as Form, N as FormActions, ls as FormField, Ts as FormProvider, P as FormRow, F as FormSection, Da as GoogleSignIn, L as Grid, ao as HashRouter, St as Hide, On as HoverCard, Ui as I18nProvider, yn as Image, Jt as ImageCropper, C as Input, B as InstallBanner, V as InstallButton, rt as Kanban, at as Kbd, Tn as Label, Kn as Lightbox, oo as Link, Bn as ListTile, Or as Markdown, Mr as Masonry, so as MemoryRouter, Ln as Menubar, x as Modal, ot as ModalsProvider, dn as Money, xs as MoneyInput, Pn as MultiSelect, lt as NProgressBar, co as NavLink, ct as Navbar, lo as Navigate, In as NavigationMenu, Hn as NavigationRail, Qt as NotificationCenter, Pc as ORDINAL_START_STEP, Ze as OfflineIndicator, uo as Outlet, dt as Page, ft as Pagination, la as PasskeyError, pt as PasswordInput, Ss as PhoneInput, ht as PinInput, gt as Popover, mn as Portal, _t as Progress, rn as QRCapacityError, sn as QRCode, Pa as QueryProvider, Aa as REFETCH_TIME, vt as Radio, yt as RadioGroup, bt as RangeSlider, xt as RatingStars, Wn as RefreshIndicator, un as RelativeTime, jn as Resizable, fo as Route, to as RouteGuard, po as Routes, Fc as SEQUENTIAL_STEP_COUNT, ja as STALE_TIME, wt as SafeArea, Xt as Scheduler, An as ScrollArea, Tt as SearchBar, Et as SegmentedControl, Dt as Select, Ct as Show, Ot as Sidebar, qn as SignaturePad, kt as Skeleton, Nn as Slider, At as Spacer, Yt as Sparkline, jt as Spinner, R as Stack, Mt as Stat, Nt as Stepper, Rt as StepperInput, zt as Switch, tt as SyncStatusBadge, Vt as Table, Ht as Tabs, Bt as Tag, Sc as TelemetryProvider, Pi as TempestApiError, Ka as TempestDataProvider, Ut as Textarea, Co as ThemeProvider, Un as TimePicker, Wt as Timeline, Kt as ToastProvider, Sn as Toggle, Cn as ToggleGroup, wn as ToggleGroupItem, Gt as Tooltip, Nr as Tour, nc as TrajectoryMap, jr as Transfer, fn as TreeView, pn as TruncateText, nt as UpdatePrompt, en as VirtualList, nn as VirtualTable, et as VisuallyHidden, jo as WebPushClient, Mo as WebPushPermissionDeniedError, No as WebPushUnsupportedError, Gn as Wizard, br as aiChatStrings, oe as announce, Vr as applyFilters, it as applyKanbanMove, rc as applyTheme, hi as assertNever, ua as base64UrlToBytes, zs as bearingDeg, cr as blobToWav, qs as boundingBox, Js as boundsCenter, Ni as buildApiUrl, Pr as buildBarListRows, Ne as buildOpenInChromeIntent, da as bytesToBase64Url, zc as cachedResponseBytes, ti as camelCase, ni as capitalize, si as chunk, Pt as clamp, Ns as clampLatitude, fa as classifyPasskeyError, se as clearAnnouncer, Uo as clearCaches, e as cn, tn as compareValues, Zr as compressToString, Qr as compressedStorage, $r as compressedStorageCodec, bc as consoleSink, wc as consoleTelemetryAdapter, ac as contrastRatio, Li as createApiClient, Go as createAudioPlayer, tr as createAudioRecorder, na as createAuthStore, pr as createBarcodeDetector, oc as createColorScale, Ga as createDataProvider, Do as createEventStream, jc as createGrowthBookFeatureFlagsAdapter, Hi as createI18n, Ac as createInMemoryFlags, Hc as createInferenceProfiler, Mc as createLaunchDarklyFeatureFlagsAdapter, ir as createLevelMeter, Qi as createLocalUploadStorage, xc as createLogger, $n as createMediaRecorder, $s as createOSRMBackend, Ua as createOfflineStore, as as createOfflineSync, Ro as createPartialResponse, pa as createPasskeyClient, ec as createPositionTracker, Ec as createPostHogTelemetryAdapter, Ma as createQueryKeys, sa as createRefreshQueue, $i as createResumableUpload, Ta as createRoleAccessControl, So as createSelectors, Tc as createSentryTelemetryAdapter, Yo as createSfxPool, xo as createStore, ba as createTempestAuth, mc as createTheme, Zo as createVideoRecorder, js as createWebSocket, bi as debounce, ia as decodeJWT, ei as decompressFromString, di as deepMerge, ro as defineRoutes, Vi as describeApiError, Ir as describeFilter, Ic as divergingScale, ji as downloadCsv, Fa as emptyOffsetPage, an as encodeQR, lr as encodeWav, mt as estimatePasswordStrength, Ue as estimateStorage, Ks as estimateTravel, Ys as expandBounds, Lr as filtersFromSearchParams, Hr as filtersToQueryParams, Rr as filtersToSearchParams, Xs as fitProjection, Ft as formatBytes, ps as formatCEP, ms as formatCNPJ, Ur as formatCPF, It as formatCompactNumber, Wr as formatCurrency, Gr as formatDate, Kr as formatDateForInput, qr as formatDateTime, Vc as formatDurationMs, Jr as formatPercent, Yr as formatPhone, Xi as generateIdempotencyKey, vc as getInitialTheme, mr as getSupportedBarcodeFormats, gc as getThemePreset, ci as groupBy, Bs as haversineKm, sc as hexToOklch, cc as hexToRgb, lc as hexToRgbaString, os as higherVersionWins, Wo as inspectCaches, Vo as installBackgroundSync, Fo as installNotificationClickHandler, zo as installPrecache, Io as installPushHandler, Bo as installRuntimeCache, Lo as installSkipWaitingListener, Pe as isAndroid, Fe as isAndroidWithoutPromptApi, Fi as isApiError, Xn as isAudioOutputSelectionSupported, nr as isAudioRecordingSupported, hr as isBarcodeDetectionSupported, ma as isConditionalMediationAvailable, Ps as isCoordinate, Ia as isCursorPage, gi as isDefined, fi as isEmpty, xr as isGenerating, Ie as isIOS, aa as isJWTExpired, or as isMediaCaptureSupported, _i as isNumber, La as isOffsetPage, ha as isPasskeySupported, vi as isPlainObject, ga as isPlatformAuthenticatorAvailable, ko as isPushSupported, ts as isScreenCaptureSupported, Oi as isShareSupported, rs as isSpeechRecognitionSupported, Le as isStandalone, yi as isString, Fs as isValidLatitude, Is as isValidLongitude, Qo as isVideoRecordingSupported, ri as kebabCase, Sr as lastAssistantId, ss as lastWriteWins, oa as lazyWithRetry, Ja as listQueryKey, on as matrixToPath, xi as memoizeOne, Ke as moveItem, gr as normalizeBarcode, Ls as normalizeLongitude, ut as nprogress, uc as oklchToHex, pi as omit, Si as once, Ya as oneQueryKey, zr as operatorsFor, Ji as parseResponse, Vs as pathLengthKm, Lt as percentOf, Ea as permissionsFromToken, Wa as persistQueryClientOffline, mi as pick, rr as pickAudioMimeType, $o as pickVideoMimeType, Ko as playAudio, ii as pluralize, Zs as projectMercator, Ei as randomId, li as range, Bc as readDeviceProfile, ic as readThemeToken, dc as readableForeground, mo as redirect, Ho as registerPeriodicSync, ze as registerServiceWorker, fc as relativeLuminance, Zt as relativeTime, Va as removeById, We as requestPersistentStorage, Ii as retry, pc as rgbToHex, Cr as roleLabel, Lc as scaleSteps, Rc as sequentialScale, Zn as setAudioOutput, ki as share, Ai as shareOrDownloadBlob, Na as shouldRetryQuery, Be as skipWaiting, wi as sleep, ai as slugify, qo as stopAudio, Xr as storage, wr as tailSignature, hc as themeContrast, yc as themeInitScript, _c as themePresets, Ci as throttle, Mi as toCsv, Hs as toRadians, oi as truncate, Tr as turnTime, ui as uniqueBy, hs as unmask, Qs as unprojectMercator, Ve as unregisterAllServiceWorkers, ea as uploadFingerprint, Yi as uploadWithProgress, Ha as upsertById, Ao as urlBase64ToUint8Array, Sa as useAccessControl, ce as useAnnounce, Y as useAsync, Jo as useAudio, ar as useAudioRecorder, vr as useBarcodeScanner, z as useBeforeInstallPrompt, a as useBreakpoint, Ca as useCan, ke as useClickOutside, W as useClientFilter, ee as useClipboard, Se as useCountdown, xe as useCounter, Xa as useCreate, za as useCursorQuery, qa as useDataProvider, H as useDebounce, de as useDeepMemo, Za as useDelete, qi as useDescribeApiError, ye as useDisclosure, we as useDocumentTitle, Z as useDocumentVisibility, cs as useErrorHandler, K as useEventListener, Oo as useEventStream, Te as useFavicon, Oc as useFeatureFlag, Es as useFieldArray, kc as useFlagValue, ae as useFocusTrap, Ds as useForm, Os as useFormContext, ks as useFormState, re as useGeolocation, _e as useHover, Wi as useI18n, ne as useIdle, Re as useInstallPrompt, Q as useIntersectionObserver, pe as useInterval, Ae as useIsFirstRender, te as useKeyboardShortcut, ue as useLatestRef, Qa as useList, be as useListState, q as useLocalStorage, ho as useLocation, ve as useLongPress, Me as useLongPressHandlers, Ee as useMap, go as useMatch, Xe as useMediaDevices, Ye as useMediaPermission, G as useMediaQuery, sr as useMicrophone, st as useModals, _o as useNavigate, $t as useNotificationInbox, Oa as useOAuthCallback, je as useObjectUrl, Ba as useOfflineMutation, Qe as useOfflineSync, $a as useOne, X as useOnline, Gi as useOptionalI18n, Ra as usePaginatedQuery, U as usePagination, vo as useParams, _a as usePasskeyCapabilities, va as usePasskeyRegistration, ya as usePasskeySignIn, ta as usePoll, tc as usePositionTracker, fe as usePrevious, Po as usePushSubscription, Oe as useQueue, $ as useResizeObserver, yo as useRouteError, ns as useScreenCapture, ie as useScrollLock, Je as useScrollOverflow, bo as useSearchParams, He as useServiceWorkerUpdate, De as useSet, Xo as useSfxPool, qe as useSortable, is as useSpeechRecognition, le as useStableCallback, Ge as useStorageEstimate, $e as useSyncStatus, Cc as useTelemetry, wo as useTheme, he as useThrottle, me as useTimeout, qt as useToast, J as useToggle, _r as useTorch, Ki as useTranslate, Ce as useTypewriter, eo as useUpdate, Cs as useViaCEP, es as useVideoRecorder, As as useWatch, Ms as useWebSocket, ge as useWindowSize, fs as useZodForm, gs as validateCNPJ, _s as validateCPF, us as validateForm, Er as visibleTurns, Ti as withTimeout, Di as writeXlsx, ds as zodResolver };
208
+ import { formatCPF as Vr, formatCurrency as Hr, formatDate as Ur, formatDateForInput as Wr, formatDateTime as Gr, formatPercent as Kr, formatPhone as qr } from "./utils/format.js";
209
+ import { applyFilters as Jr } from "./components/FilterBar/filter-apply.js";
210
+ import { filtersToQueryParams as Yr } from "./components/FilterBar/filter-query.js";
211
+ import { createJsonStorage as Xr, storage as Zr } from "./utils/storage.js";
212
+ import { compressToString as Qr, compressedStorage as $r, compressedStorageCodec as ei, decompressFromString as ti } from "./utils/compressed-storage.js";
213
+ import { camelCase as ni, capitalize as ri, kebabCase as ii, pluralize as ai, slugify as oi, truncate as si } from "./utils/strings.js";
214
+ import { chunk as ci, groupBy as li, range as ui, uniqueBy as di } from "./utils/arrays.js";
215
+ import { deepMerge as fi, isEmpty as pi, omit as mi, pick as hi } from "./utils/objects.js";
216
+ import { assertNever as gi, isDefined as _i, isNumber as vi, isPlainObject as yi, isString as bi } from "./utils/guards.js";
217
+ import { debounce as xi, memoizeOne as Si, once as Ci, throttle as wi } from "./utils/functions.js";
218
+ import { sleep as Ti, withTimeout as Ei } from "./utils/promises.js";
219
+ import { randomId as Di } from "./utils/ids.js";
220
+ import { writeXlsx as Oi } from "./utils/xlsx.js";
221
+ import { isShareSupported as ki, share as Ai } from "./share/share.js";
222
+ import { shareOrDownloadBlob as ji } from "./share/share-or-download.js";
223
+ import { downloadCsv as Mi, toCsv as Ni } from "./utils/csv.js";
224
+ import { buildApiUrl as Pi } from "./http/build-url.js";
225
+ import { TempestApiError as Fi, isApiError as Ii, isRetriableStatus as Li } from "./http/errors.js";
226
+ import { retry as Ri } from "./http/retry.js";
227
+ import { createApiClient as zi } from "./http/api-client.js";
228
+ import { API_ERROR_OFFLINE_KEY as Bi, API_ERROR_VALIDATION_KEY as Vi, DEFAULT_API_ERROR_STRINGS as Hi, describeApiError as Ui } from "./http/describe-api-error.js";
229
+ import { createI18n as Wi } from "./i18n/create-i18n.js";
230
+ import { I18nProvider as Gi, useI18n as Ki, useOptionalI18n as qi, useTranslate as Ji } from "./i18n/I18nProvider.js";
231
+ import { useDescribeApiError as Yi } from "./http/use-describe-api-error.js";
232
+ import { parseResponse as Xi } from "./http/parse-response.js";
233
+ import { uploadWithProgress as Zi } from "./http/upload-with-progress.js";
234
+ import { generateIdempotencyKey as Qi } from "./http/idempotency.js";
235
+ import { DEFAULT_CHUNK_SIZE as $i, createLocalUploadStorage as ea, createResumableUpload as ta, uploadFingerprint as na } from "./http/resumable-upload.js";
236
+ import { usePoll as ra } from "./http/use-poll.js";
237
+ import { createAuthStore as ia } from "./auth/create-auth-store.js";
238
+ import { AuthGuard as aa } from "./auth/AuthGuard.js";
239
+ import { decodeJWT as oa, isJWTExpired as sa } from "./auth/jwt.js";
240
+ import { lazyWithRetry as ca } from "./auth/lazy-with-retry.js";
241
+ import { createRefreshQueue as la } from "./auth/refresh-queue.js";
242
+ import { DEFAULT_PUB_KEY_CRED_PARAMS as ua, PasskeyError as da, base64UrlToBytes as fa, bytesToBase64Url as pa, classifyPasskeyError as ma, createPasskeyClient as ha, isConditionalMediationAvailable as ga, isPasskeySupported as _a, isPlatformAuthenticatorAvailable as va } from "./auth/passkey.js";
243
+ import { usePasskeyCapabilities as ya, usePasskeyRegistration as ba, usePasskeySignIn as xa } from "./auth/use-passkey.js";
244
+ import { createTempestAuth as Sa } from "./auth/create-tempest-auth.js";
245
+ import { AccessControlProvider as Ca, useAccessControl as wa } from "./access/access-control-context.js";
246
+ import { useCan as Ta } from "./access/use-can.js";
247
+ import { Can as Ea } from "./access/Can.js";
248
+ import { createRoleAccessControl as Da } from "./access/create-role-access-control.js";
249
+ import { permissionsFromToken as Oa } from "./access/permissions-from-token.js";
250
+ import { GoogleSignIn as ka } from "./oauth/GoogleSignIn.js";
251
+ import { useOAuthCallback as Aa } from "./oauth/use-oauth-callback.js";
252
+ import { CACHE_TIME as ja, REFETCH_TIME as Ma, STALE_TIME as Na } from "./query/constants.js";
253
+ import { createQueryKeys as Pa } from "./query/create-query-keys.js";
254
+ import { shouldRetryQuery as Fa } from "./query/retry-policy.js";
255
+ import { QueryProvider as Ia } from "./query/QueryProvider.js";
256
+ import { emptyOffsetPage as La, isCursorPage as Ra, isOffsetPage as za } from "./query/pagination.js";
257
+ import { usePaginatedQuery as Ba } from "./query/use-paginated-query.js";
258
+ import { useCursorQuery as Va } from "./query/use-cursor-query.js";
259
+ import { useOfflineMutation as Ha } from "./query/use-offline-mutation.js";
260
+ import { removeById as Ua, upsertById as Wa } from "./query/optimistic.js";
261
+ import { createOfflineStore as Ga } from "./offline/create-offline-store.js";
262
+ import { persistQueryClientOffline as Ka } from "./query/offline-persistence.js";
263
+ import { createDataProvider as qa } from "./data/create-data-provider.js";
264
+ import { TempestDataProvider as Ja, useDataProvider as Ya } from "./data/data-provider-context.js";
265
+ import { listQueryKey as Xa, oneQueryKey as Za, useCreate as Qa, useDelete as $a, useList as eo, useOne as to, useUpdate as no } from "./data/use-resource.js";
266
+ import { RouteGuard as ro } from "./router/RouteGuard.js";
267
+ import { AppRouter as io, defineRoutes as ao } from "./router/AppRouter.js";
268
+ import { BrowserRouter as oo, HashRouter as so, Link as co, MemoryRouter as lo, NavLink as uo, Navigate as fo, Outlet as po, Route as mo, Routes as ho, redirect as go, useLocation as _o, useMatch as vo, useNavigate as yo, useParams as bo, useRouteError as xo, useSearchParams as So } from "./router/index.js";
269
+ import { createStore as Co } from "./store/create-store.js";
270
+ import { createSelectors as wo } from "./store/create-selectors.js";
271
+ import { ThemeProvider as To, useTheme as Eo } from "./theme/ThemeProvider.js";
272
+ import { ErrorBoundary as Do } from "./error-boundary/ErrorBoundary.js";
273
+ import { AppProviders as Oo } from "./app/AppProviders.js";
274
+ import { createEventStream as ko } from "./sse/create-event-stream.js";
275
+ import { useEventStream as Ao } from "./sse/use-event-stream.js";
276
+ import { isPushSupported as jo, urlBase64ToUint8Array as Mo } from "./push/utils.js";
277
+ import { WebPushClient as No, WebPushPermissionDeniedError as Po, WebPushUnsupportedError as Fo } from "./push/web-push-client.js";
278
+ import { usePushSubscription as Io } from "./push/use-push-subscription.js";
279
+ import { installNotificationClickHandler as Lo, installPushHandler as Ro, installSkipWaitingListener as zo } from "./sw/create-push-handler.js";
280
+ import { createPartialResponse as Bo, installPrecache as Vo, installRuntimeCache as Ho } from "./sw/cache.js";
281
+ import { installBackgroundSync as Uo } from "./sw/background-sync.js";
282
+ import { registerPeriodicSync as Wo } from "./sw/periodic-sync.js";
283
+ import { clearCaches as Go, inspectCaches as Ko } from "./sw/cache-inspect.js";
284
+ import { createAudioPlayer as qo, playAudio as Jo, stopAudio as Yo } from "./audio/audio-player.js";
285
+ import { useAudio as Xo } from "./audio/use-audio.js";
286
+ import { createSfxPool as Zo } from "./audio/sfx-pool.js";
287
+ import { useSfxPool as Qo } from "./audio/use-sfx-pool.js";
288
+ import { createVideoRecorder as $o, isVideoRecordingSupported as es, pickVideoMimeType as ts } from "./capture/video-recorder.js";
289
+ import { useVideoRecorder as ns } from "./capture/use-video-recorder.js";
290
+ import { isScreenCaptureSupported as rs, useScreenCapture as is } from "./capture/use-screen-capture.js";
291
+ import { isSpeechRecognitionSupported as as, useSpeechRecognition as os } from "./capture/use-speech-recognition.js";
292
+ import { createOfflineSync as ss } from "./offline/create-offline-sync.js";
293
+ import { higherVersionWins as cs, lastWriteWins as ls } from "./offline/conflict.js";
294
+ import { useErrorHandler as us } from "./error-boundary/use-error-handler.js";
295
+ import { FormField as ds } from "./forms/FormField.js";
296
+ import { validateForm as fs } from "./forms/validate-form.js";
297
+ import { zodResolver as ps } from "./forms/zod-resolver.js";
298
+ import { useZodForm as ms } from "./forms/use-zod-form.js";
299
+ import { formatCEP as hs, formatCNPJ as gs, unmask as _s, validateCNPJ as vs, validateCPF as ys } from "./forms/br-validators.js";
300
+ import { CEPInput as bs, CNPJInput as xs, CPFInput as Ss, MoneyInput as Cs, PhoneInput as ws } from "./forms/masked-inputs.js";
301
+ import { useViaCEP as Ts } from "./forms/use-viacep.js";
302
+ import { Controller as Es, FormProvider as Ds, useFieldArray as Os, useForm as ks, useFormContext as As, useFormState as js, useWatch as Ms } from "./forms/index.js";
303
+ import { createWebSocket as Ns } from "./ws/create-web-socket.js";
304
+ import { useWebSocket as Ps } from "./ws/use-web-socket.js";
305
+ import { clampLatitude as Fs, isCoordinate as Is, isValidLatitude as Ls, isValidLongitude as Rs, normalizeLongitude as zs } from "./geo/types.js";
306
+ import { EARTH_RADIUS_KM as Bs, bearingDeg as Vs, haversineKm as Hs, pathLengthKm as Us, toRadians as Ws } from "./geo/distance.js";
307
+ import { DEFAULT_CAR_SPEED_KMH as Gs, DEFAULT_CIRCUITY_FACTOR as Ks, DEFAULT_MODE_DURATION_FACTORS as qs, estimateTravel as Js } from "./geo/estimate.js";
308
+ import { boundingBox as Ys, boundsCenter as Xs, expandBounds as Zs } from "./geo/bounds.js";
309
+ import { fitProjection as Qs, projectMercator as $s, unprojectMercator as ec } from "./geo/projection.js";
310
+ import { createOSRMBackend as tc } from "./geo/routing.js";
311
+ import { createPositionTracker as nc } from "./geo/create-position-tracker.js";
312
+ import { usePositionTracker as rc } from "./geo/use-position-tracker.js";
313
+ import { TrajectoryMap as ic } from "./geo/TrajectoryMap.js";
314
+ import { applyTheme as ac, readThemeToken as oc } from "./theme/apply-theme.js";
315
+ import { contrastRatio as sc, createColorScale as cc, hexToOklch as lc, hexToRgb as uc, hexToRgbaString as dc, oklchToHex as fc, readableForeground as pc, relativeLuminance as mc, rgbToHex as hc } from "./theme/color.js";
316
+ import { createTheme as gc, themeContrast as _c } from "./theme/create-theme.js";
317
+ import { getThemePreset as vc, themePresets as yc } from "./theme/theme-presets.js";
318
+ import { getInitialTheme as bc, themeInitScript as xc } from "./theme/initial-theme.js";
319
+ import { consoleSink as Sc, createLogger as Cc } from "./logger/logger.js";
320
+ import { TelemetryProvider as wc, useTelemetry as Tc } from "./telemetry/TelemetryProvider.js";
321
+ import { consoleTelemetryAdapter as Ec } from "./telemetry/console-adapter.js";
322
+ import { createSentryTelemetryAdapter as Dc } from "./telemetry/sentry-adapter.js";
323
+ import { createPostHogTelemetryAdapter as Oc } from "./telemetry/posthog-adapter.js";
324
+ import { FeatureFlagsProvider as kc, useFeatureFlag as Ac, useFlagValue as jc } from "./feature-flags/FeatureFlagsProvider.js";
325
+ import { createInMemoryFlags as Mc } from "./feature-flags/in-memory-adapter.js";
326
+ import { createGrowthBookFeatureFlagsAdapter as Nc } from "./feature-flags/growthbook-adapter.js";
327
+ import { createLaunchDarklyFeatureFlagsAdapter as Pc } from "./feature-flags/launchdarkly-adapter.js";
328
+ import { DIVERGING_STEP_COUNT as Fc, ORDINAL_START_STEP as Ic, SEQUENTIAL_STEP_COUNT as Lc, divergingScale as Rc, scaleSteps as zc, sequentialScale as Bc } from "./charts/scales.js";
329
+ import { cachedResponseBytes as Vc } from "./perf/cache-size.js";
330
+ import { readDeviceProfile as Hc } from "./perf/device.js";
331
+ import { formatDurationMs as Uc } from "./perf/format.js";
332
+ import { createInferenceProfiler as Wc } from "./perf/profiler.js";
333
+ export { Ar as AIChat, Dr as AIChatComposer, kr as AIChatTurn, dr as ALL_BARCODE_FORMATS, Bi as API_ERROR_OFFLINE_KEY, Vi as API_ERROR_VALIDATION_KEY, er as AUDIO_MIME_CANDIDATES, Ca as AccessControlProvider, t as Accordion, n as Alert, r as AppBar, Oo as AppProviders, io as AppRouter, o as AppShell, s as AspectRatio, Qn as AudioPlayer, ur as AudioRecorder, aa as AuthGuard, c as Avatar, l as AvatarGroup, i as BREAKPOINTS, u as Badge, d as Banner, Fr as BarList, yr as BarcodeScanner, f as BottomNavigation, p as BottomSheet, m as Breadcrumbs, oo as BrowserRouter, h as Button, ja as CACHE_TIME, bs as CEPInput, xs as CNPJInput, Ss as CPFInput, Mn as Calendar, Ea as Can, g as Card, Rn as Carousel, _ as Center, Yn as Chat, Jn as ChatComposer, v as Checkbox, y as ChipInput, hn as ClickOutside, ln as CodeBlock, En as Collapsible, b as Combobox, kn as Command, gn as ConditionalWrapper, S as ConfirmDialog, I as Container, Dn as ContextMenu, Es as Controller, cn as CopyButton, Hi as DEFAULT_API_ERROR_STRINGS, fr as DEFAULT_BARCODE_FORMATS, Gs as DEFAULT_CAR_SPEED_KMH, $i as DEFAULT_CHUNK_SIZE, Ks as DEFAULT_CIRCUITY_FACTOR, qs as DEFAULT_MODE_DURATION_FACTORS, ua as DEFAULT_PUB_KEY_CRED_PARAMS, Fc as DIVERGING_STEP_COUNT, bn as DataList, zn as DataTable, w as DatePicker, Fn as DateRangePicker, xn as DescriptionList, T as Divider, E as Drawer, D as DropdownMenu, O as Dropzone, Bs as EARTH_RADIUS_KM, k as EmptyState, Do as ErrorBoundary, A as ErrorState, vn as ErrorText, kc as FeatureFlagsProvider, j as FileUpload, Br as FilterBar, Vn as FloatingActionButton, _n as For, M as Form, N as FormActions, ds as FormField, Ds as FormProvider, P as FormRow, F as FormSection, ka as GoogleSignIn, L as Grid, so as HashRouter, St as Hide, On as HoverCard, Gi as I18nProvider, yn as Image, Jt as ImageCropper, C as Input, B as InstallBanner, V as InstallButton, rt as Kanban, at as Kbd, Tn as Label, Kn as Lightbox, co as Link, Bn as ListTile, Or as Markdown, Mr as Masonry, lo as MemoryRouter, Ln as Menubar, x as Modal, ot as ModalsProvider, dn as Money, Cs as MoneyInput, Pn as MultiSelect, lt as NProgressBar, uo as NavLink, ct as Navbar, fo as Navigate, In as NavigationMenu, Hn as NavigationRail, Qt as NotificationCenter, Ic as ORDINAL_START_STEP, Ze as OfflineIndicator, po as Outlet, dt as Page, ft as Pagination, da as PasskeyError, pt as PasswordInput, ws as PhoneInput, ht as PinInput, gt as Popover, mn as Portal, _t as Progress, rn as QRCapacityError, sn as QRCode, Ia as QueryProvider, Ma as REFETCH_TIME, vt as Radio, yt as RadioGroup, bt as RangeSlider, xt as RatingStars, Wn as RefreshIndicator, un as RelativeTime, jn as Resizable, mo as Route, ro as RouteGuard, ho as Routes, Lc as SEQUENTIAL_STEP_COUNT, Na as STALE_TIME, wt as SafeArea, Xt as Scheduler, An as ScrollArea, Tt as SearchBar, Et as SegmentedControl, Dt as Select, Ct as Show, Ot as Sidebar, qn as SignaturePad, kt as Skeleton, Nn as Slider, At as Spacer, Yt as Sparkline, jt as Spinner, R as Stack, Mt as Stat, Nt as Stepper, Rt as StepperInput, zt as Switch, tt as SyncStatusBadge, Vt as Table, Ht as Tabs, Bt as Tag, wc as TelemetryProvider, Fi as TempestApiError, Ja as TempestDataProvider, Ut as Textarea, To as ThemeProvider, Un as TimePicker, Wt as Timeline, Kt as ToastProvider, Sn as Toggle, Cn as ToggleGroup, wn as ToggleGroupItem, Gt as Tooltip, Nr as Tour, ic as TrajectoryMap, jr as Transfer, fn as TreeView, pn as TruncateText, nt as UpdatePrompt, en as VirtualList, nn as VirtualTable, et as VisuallyHidden, No as WebPushClient, Po as WebPushPermissionDeniedError, Fo as WebPushUnsupportedError, Gn as Wizard, br as aiChatStrings, se as announce, Jr as applyFilters, it as applyKanbanMove, ac as applyTheme, gi as assertNever, fa as base64UrlToBytes, Vs as bearingDeg, cr as blobToWav, Ys as boundingBox, Xs as boundsCenter, Pi as buildApiUrl, Pr as buildBarListRows, Ne as buildOpenInChromeIntent, pa as bytesToBase64Url, Vc as cachedResponseBytes, ni as camelCase, ri as capitalize, ci as chunk, Pt as clamp, Fs as clampLatitude, ma as classifyPasskeyError, ce as clearAnnouncer, Go as clearCaches, e as cn, tn as compareValues, Qr as compressToString, $r as compressedStorage, ei as compressedStorageCodec, Sc as consoleSink, Ec as consoleTelemetryAdapter, sc as contrastRatio, zi as createApiClient, qo as createAudioPlayer, tr as createAudioRecorder, ia as createAuthStore, pr as createBarcodeDetector, cc as createColorScale, qa as createDataProvider, ko as createEventStream, Nc as createGrowthBookFeatureFlagsAdapter, Wi as createI18n, Mc as createInMemoryFlags, Wc as createInferenceProfiler, Xr as createJsonStorage, Pc as createLaunchDarklyFeatureFlagsAdapter, ir as createLevelMeter, ea as createLocalUploadStorage, Cc as createLogger, $n as createMediaRecorder, tc as createOSRMBackend, Ga as createOfflineStore, ss as createOfflineSync, Bo as createPartialResponse, ha as createPasskeyClient, nc as createPositionTracker, Oc as createPostHogTelemetryAdapter, Pa as createQueryKeys, la as createRefreshQueue, ta as createResumableUpload, Da as createRoleAccessControl, wo as createSelectors, Dc as createSentryTelemetryAdapter, Zo as createSfxPool, Co as createStore, Sa as createTempestAuth, gc as createTheme, $o as createVideoRecorder, Ns as createWebSocket, xi as debounce, oa as decodeJWT, ti as decompressFromString, fi as deepMerge, ao as defineRoutes, Ui as describeApiError, Ir as describeFilter, Rc as divergingScale, Mi as downloadCsv, La as emptyOffsetPage, an as encodeQR, lr as encodeWav, mt as estimatePasswordStrength, Ue as estimateStorage, Js as estimateTravel, Zs as expandBounds, Lr as filtersFromSearchParams, Yr as filtersToQueryParams, Rr as filtersToSearchParams, Qs as fitProjection, Ft as formatBytes, hs as formatCEP, gs as formatCNPJ, Vr as formatCPF, It as formatCompactNumber, Hr as formatCurrency, Ur as formatDate, Wr as formatDateForInput, Gr as formatDateTime, Uc as formatDurationMs, Kr as formatPercent, qr as formatPhone, Qi as generateIdempotencyKey, bc as getInitialTheme, mr as getSupportedBarcodeFormats, vc as getThemePreset, li as groupBy, Hs as haversineKm, lc as hexToOklch, uc as hexToRgb, dc as hexToRgbaString, cs as higherVersionWins, Ko as inspectCaches, Uo as installBackgroundSync, Lo as installNotificationClickHandler, Vo as installPrecache, Ro as installPushHandler, Ho as installRuntimeCache, zo as installSkipWaitingListener, Pe as isAndroid, Fe as isAndroidWithoutPromptApi, Ii as isApiError, Xn as isAudioOutputSelectionSupported, nr as isAudioRecordingSupported, hr as isBarcodeDetectionSupported, ga as isConditionalMediationAvailable, Is as isCoordinate, Ra as isCursorPage, _i as isDefined, pi as isEmpty, xr as isGenerating, Ie as isIOS, sa as isJWTExpired, or as isMediaCaptureSupported, vi as isNumber, za as isOffsetPage, _a as isPasskeySupported, yi as isPlainObject, va as isPlatformAuthenticatorAvailable, jo as isPushSupported, Li as isRetriableStatus, rs as isScreenCaptureSupported, ki as isShareSupported, as as isSpeechRecognitionSupported, Le as isStandalone, bi as isString, Ls as isValidLatitude, Rs as isValidLongitude, es as isVideoRecordingSupported, ii as kebabCase, Sr as lastAssistantId, ls as lastWriteWins, ca as lazyWithRetry, Xa as listQueryKey, on as matrixToPath, Si as memoizeOne, Ke as moveItem, gr as normalizeBarcode, zs as normalizeLongitude, ut as nprogress, fc as oklchToHex, mi as omit, Ci as once, Za as oneQueryKey, zr as operatorsFor, Xi as parseResponse, Us as pathLengthKm, Lt as percentOf, Oa as permissionsFromToken, Ka as persistQueryClientOffline, hi as pick, rr as pickAudioMimeType, ts as pickVideoMimeType, Jo as playAudio, ai as pluralize, $s as projectMercator, Di as randomId, ui as range, Hc as readDeviceProfile, oc as readThemeToken, pc as readableForeground, go as redirect, Wo as registerPeriodicSync, ze as registerServiceWorker, mc as relativeLuminance, Zt as relativeTime, Ua as removeById, We as requestPersistentStorage, Ri as retry, hc as rgbToHex, Cr as roleLabel, zc as scaleSteps, Bc as sequentialScale, Zn as setAudioOutput, Ai as share, ji as shareOrDownloadBlob, Fa as shouldRetryQuery, Be as skipWaiting, Ti as sleep, oi as slugify, Yo as stopAudio, Zr as storage, wr as tailSignature, _c as themeContrast, xc as themeInitScript, yc as themePresets, wi as throttle, Ni as toCsv, Ws as toRadians, si as truncate, Tr as turnTime, di as uniqueBy, _s as unmask, ec as unprojectMercator, Ve as unregisterAllServiceWorkers, na as uploadFingerprint, Zi as uploadWithProgress, Wa as upsertById, Mo as urlBase64ToUint8Array, wa as useAccessControl, le as useAnnounce, X as useAsync, Xo as useAudio, ar as useAudioRecorder, vr as useBarcodeScanner, z as useBeforeInstallPrompt, a as useBreakpoint, Ta as useCan, ke as useClickOutside, W as useClientFilter, te as useClipboard, Se as useCountdown, xe as useCounter, Qa as useCreate, Va as useCursorQuery, Ya as useDataProvider, H as useDebounce, de as useDeepMemo, $a as useDelete, Yi as useDescribeApiError, ye as useDisclosure, we as useDocumentTitle, Q as useDocumentVisibility, us as useErrorHandler, q as useEventListener, Ao as useEventStream, Te as useFavicon, Ac as useFeatureFlag, Os as useFieldArray, jc as useFlagValue, oe as useFocusTrap, ks as useForm, As as useFormContext, js as useFormState, ie as useGeolocation, _e as useHover, Ki as useI18n, re as useIdle, Re as useInstallPrompt, $ as useIntersectionObserver, pe as useInterval, Ae as useIsFirstRender, ne as useKeyboardShortcut, K as useLatestRef, eo as useList, be as useListState, J as useLocalStorage, _o as useLocation, ve as useLongPress, Me as useLongPressHandlers, Ee as useMap, vo as useMatch, Xe as useMediaDevices, Ye as useMediaPermission, G as useMediaQuery, sr as useMicrophone, st as useModals, yo as useNavigate, $t as useNotificationInbox, Aa as useOAuthCallback, je as useObjectUrl, Ha as useOfflineMutation, Qe as useOfflineSync, to as useOne, Z as useOnline, qi as useOptionalI18n, Ba as usePaginatedQuery, U as usePagination, bo as useParams, ya as usePasskeyCapabilities, ba as usePasskeyRegistration, xa as usePasskeySignIn, ra as usePoll, rc as usePositionTracker, fe as usePrevious, Io as usePushSubscription, Oe as useQueue, ee as useResizeObserver, xo as useRouteError, is as useScreenCapture, ae as useScrollLock, Je as useScrollOverflow, So as useSearchParams, He as useServiceWorkerUpdate, De as useSet, Qo as useSfxPool, qe as useSortable, os as useSpeechRecognition, ue as useStableCallback, Ge as useStorageEstimate, $e as useSyncStatus, Tc as useTelemetry, Eo as useTheme, he as useThrottle, me as useTimeout, qt as useToast, Y as useToggle, _r as useTorch, Ji as useTranslate, Ce as useTypewriter, no as useUpdate, Ts as useViaCEP, ns as useVideoRecorder, Ms as useWatch, Ps as useWebSocket, ge as useWindowSize, ms as useZodForm, vs as validateCNPJ, ys as validateCPF, fs as validateForm, Er as visibleTurns, Ei as withTimeout, Oi as writeXlsx, ps as zodResolver };
@@ -1,2 +1,2 @@
1
- let e=require("react"),t=require("react/jsx-runtime");var n=(0,e.createContext)(null);function r(e){return e===`dark`||e===`light`?e:typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function i(e,t,n,r){let i=Array.isArray(n)?n:[n];for(let n of i)e.setAttribute(n,t);if(r&&typeof document<`u`){let e=document.querySelector(`meta[name="theme-color"]`);e&&(e.content=r[t])}}function a(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(e);return t===`light`||t===`dark`||t===`system`?t:null}catch{return null}}function o({children:o,defaultTheme:s=`system`,storageKey:c=`tempest-theme`,target:l,attribute:u=`data-tempest-theme`,themeColor:d}){let[f,p]=(0,e.useState)(()=>a(c)??s),[m,h]=(0,e.useState)(()=>r(f)),g=(0,e.useRef)(l);(0,e.useEffect)(()=>{g.current=l},[l]);let _=Array.isArray(u)?u.join(`,`):u,v=(0,e.useRef)(d);(0,e.useEffect)(()=>{v.current=d},[d]),(0,e.useEffect)(()=>{let e=g.current?.()??document.documentElement;if(!e)return;let t=r(f);i(e,t,u,v.current),h(t)},[f,_]),(0,e.useEffect)(()=>{if(f!==`system`||typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{let t=g.current?.()??document.documentElement;if(!t)return;let n=e.matches?`dark`:`light`;i(t,n,u,v.current),h(n)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[f,_]);let y=(0,e.useCallback)(e=>{if(p(e),c&&typeof window<`u`)try{window.localStorage.setItem(c,e)}catch{}},[c]),b=(0,e.useCallback)(()=>{y(m===`dark`?`light`:`dark`)},[m,y]),x=(0,e.useMemo)(()=>({theme:f,resolvedTheme:m,setTheme:y,toggle:b}),[f,m,y,b]);return(0,t.jsx)(n.Provider,{value:x,children:o})}function s(){let t=(0,e.useContext)(n);if(!t)throw Error(`useTheme must be used inside a <ThemeProvider>`);return t}exports.ThemeProvider=o,exports.useTheme=s;
1
+ const e=require("../hooks/use-latest-ref.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=(0,t.createContext)(null);function i(e){return e===`dark`||e===`light`?e:typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function a(e,t,n,r){let i=Array.isArray(n)?n:[n];for(let n of i)e.setAttribute(n,t);if(r&&typeof document<`u`){let e=document.querySelector(`meta[name="theme-color"]`);e&&(e.content=r[t])}}function o(e){if(!e||typeof window>`u`)return null;try{let t=window.localStorage.getItem(e);return t===`light`||t===`dark`||t===`system`?t:null}catch{return null}}function s({children:s,defaultTheme:c=`system`,storageKey:l=`tempest-theme`,target:u,attribute:d=`data-tempest-theme`,themeColor:f}){let[p,m]=(0,t.useState)(()=>o(l)??c),[h,g]=(0,t.useState)(()=>i(p)),_=e.useLatestRef(u),v=Array.isArray(d)?d.join(`,`):d,y=e.useLatestRef(f);(0,t.useEffect)(()=>{let e=_.current?.()??document.documentElement;if(!e)return;let t=i(p);a(e,t,d,y.current),g(t)},[p,v]),(0,t.useEffect)(()=>{if(p!==`system`||typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{let t=_.current?.()??document.documentElement;if(!t)return;let n=e.matches?`dark`:`light`;a(t,n,d,y.current),g(n)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p,v]);let b=(0,t.useCallback)(e=>{if(m(e),l&&typeof window<`u`)try{window.localStorage.setItem(l,e)}catch{}},[l]),x=(0,t.useCallback)(()=>{b(h===`dark`?`light`:`dark`)},[h,b]),S=(0,t.useMemo)(()=>({theme:p,resolvedTheme:h,setTheme:b,toggle:x}),[p,h,b,x]);return(0,n.jsx)(r.Provider,{value:S,children:s})}function c(){let e=(0,t.useContext)(r);if(!e)throw Error(`useTheme must be used inside a <ThemeProvider>`);return e}exports.ThemeProvider=s,exports.useTheme=c;
2
2
  //# sourceMappingURL=ThemeProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.cjs","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useRef<typeof target>(target);\n useEffect(() => {\n targetRef.current = target;\n }, [target]);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useRef(themeColor);\n useEffect(() => {\n themeColorRef.current = themeColor;\n }, [themeColor]);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":"sDAuBA,IAAM,GAAA,EAAe,EAAA,cAAA,CAAwC,IAAI,EAgCjE,SAAS,EAAQ,EAAgC,CAG7C,OAFI,IAAS,QAAU,IAAS,QAAgB,EAC5C,OAAO,OAAW,IAAoB,QACnC,OAAO,WAAW,8BAA8B,CAAC,CAAC,QAAU,OAAS,OAChF,CAMA,SAAS,EACL,EACA,EACA,EACA,EACI,CACJ,IAAM,EAAQ,MAAM,QAAQ,CAAS,EAAI,EAAY,CAAC,CAAS,EAC/D,IAAK,IAAM,KAAQ,EAAO,EAAQ,aAAa,EAAM,CAAQ,EAC7D,GAAI,GAAc,OAAO,SAAa,IAAa,CAC/C,IAAM,EAAO,SAAS,cAA+B,0BAA0B,EAC3E,IAAM,EAAK,QAAU,EAAW,GACxC,CACJ,CAEA,SAAS,EAAW,EAA6C,CAC7D,GAAI,CAAC,GAAc,OAAO,OAAW,IAAa,OAAO,KACzD,GAAI,CACA,IAAM,EAAQ,OAAO,aAAa,QAAQ,CAAU,EAEpD,OADI,IAAU,SAAW,IAAU,QAAU,IAAU,SAAiB,EACjE,IACX,MAAQ,CACJ,OAAO,IACX,CACJ,CAeA,SAAgB,EAAc,CAC1B,WACA,eAAe,SACf,aAAa,gBACb,SACA,YAAY,qBACZ,cACmB,CACnB,GAAM,CAAC,EAAO,IAAA,EAAiB,EAAA,SAAA,KACrB,EAAW,CAAU,GAAK,CACpC,EACM,CAAC,EAAe,IAAA,EAAoB,EAAA,SAAA,KAA8B,EAAQ,CAAK,CAAC,EAEhF,GAAA,EAAY,EAAA,OAAA,CAAsB,CAAM,GAC9C,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAU,QAAU,CACxB,EAAG,CAAC,CAAM,CAAC,EAEX,IAAM,EAAe,MAAM,QAAQ,CAAS,EAAI,EAAU,KAAK,GAAG,EAAI,EAChE,GAAA,EAAgB,EAAA,OAAA,CAAO,CAAU,GACvC,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAc,QAAU,CAC5B,EAAG,CAAC,CAAU,CAAC,GAEf,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAO,EAAQ,CAAK,EAC1B,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CAGzB,EAAG,CAAC,EAAO,CAAY,CAAC,GAExB,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAU,UAAY,OAAO,OAAW,IAAa,OACzD,IAAM,EAAO,OAAO,WAAW,8BAA8B,EACvD,MAAsB,CACxB,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAsB,EAAK,QAAU,OAAS,QACpD,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CACzB,EAEA,OADA,EAAK,iBAAiB,SAAU,CAAO,MAC1B,EAAK,oBAAoB,SAAU,CAAO,CAE3D,EAAG,CAAC,EAAO,CAAY,CAAC,EAExB,IAAM,GAAA,EAAW,EAAA,YAAA,CACZ,GAAoB,CAEjB,GADA,EAAc,CAAI,EACd,GAAc,OAAO,OAAW,IAChC,GAAI,CACA,OAAO,aAAa,QAAQ,EAAY,CAAI,CAChD,MAAQ,CAER,CAER,EACA,CAAC,CAAU,CACf,EAEM,GAAA,EAAS,EAAA,YAAA,KAAkB,CAC7B,EAAS,IAAkB,OAAS,QAAU,MAAM,CACxD,EAAG,CAAC,EAAe,CAAQ,CAAC,EAEtB,GAAA,EAAQ,EAAA,QAAA,MACH,CAAE,QAAO,gBAAe,WAAU,QAAO,GAChD,CAAC,EAAO,EAAe,EAAU,CAAM,CAC3C,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAa,SAAd,CAA8B,QAAQ,UAAgC,CAAA,CACjF,CAKA,SAAgB,GAA8B,CAC1C,IAAM,GAAA,EAAM,EAAA,WAAA,CAAW,CAAY,EACnC,GAAI,CAAC,EAAK,MAAU,MAAM,gDAAgD,EAC1E,OAAO,CACX"}
1
+ {"version":3,"file":"ThemeProvider.cjs","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useLatestRef } from \"@/hooks/use-latest-ref\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useLatestRef(target);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useLatestRef(themeColor);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":"qGAgBA,IAAM,GAAA,EAAe,EAAA,cAAA,CAAwC,IAAI,EAgCjE,SAAS,EAAQ,EAAgC,CAG7C,OAFI,IAAS,QAAU,IAAS,QAAgB,EAC5C,OAAO,OAAW,IAAoB,QACnC,OAAO,WAAW,8BAA8B,CAAC,CAAC,QAAU,OAAS,OAChF,CAMA,SAAS,EACL,EACA,EACA,EACA,EACI,CACJ,IAAM,EAAQ,MAAM,QAAQ,CAAS,EAAI,EAAY,CAAC,CAAS,EAC/D,IAAK,IAAM,KAAQ,EAAO,EAAQ,aAAa,EAAM,CAAQ,EAC7D,GAAI,GAAc,OAAO,SAAa,IAAa,CAC/C,IAAM,EAAO,SAAS,cAA+B,0BAA0B,EAC3E,IAAM,EAAK,QAAU,EAAW,GACxC,CACJ,CAEA,SAAS,EAAW,EAA6C,CAC7D,GAAI,CAAC,GAAc,OAAO,OAAW,IAAa,OAAO,KACzD,GAAI,CACA,IAAM,EAAQ,OAAO,aAAa,QAAQ,CAAU,EAEpD,OADI,IAAU,SAAW,IAAU,QAAU,IAAU,SAAiB,EACjE,IACX,MAAQ,CACJ,OAAO,IACX,CACJ,CAeA,SAAgB,EAAc,CAC1B,WACA,eAAe,SACf,aAAa,gBACb,SACA,YAAY,qBACZ,cACmB,CACnB,GAAM,CAAC,EAAO,IAAA,EAAiB,EAAA,SAAA,KACrB,EAAW,CAAU,GAAK,CACpC,EACM,CAAC,EAAe,IAAA,EAAoB,EAAA,SAAA,KAA8B,EAAQ,CAAK,CAAC,EAEhF,EAAY,EAAA,aAAa,CAAM,EAE/B,EAAe,MAAM,QAAQ,CAAS,EAAI,EAAU,KAAK,GAAG,EAAI,EAChE,EAAgB,EAAA,aAAa,CAAU,GAE7C,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAO,EAAQ,CAAK,EAC1B,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CAGzB,EAAG,CAAC,EAAO,CAAY,CAAC,GAExB,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAU,UAAY,OAAO,OAAW,IAAa,OACzD,IAAM,EAAO,OAAO,WAAW,8BAA8B,EACvD,MAAsB,CACxB,IAAM,EAAU,EAAU,UAAU,GAAK,SAAS,gBAClD,GAAI,CAAC,EAAS,OACd,IAAM,EAAsB,EAAK,QAAU,OAAS,QACpD,EAAc,EAAS,EAAM,EAAW,EAAc,OAAO,EAC7D,EAAiB,CAAI,CACzB,EAEA,OADA,EAAK,iBAAiB,SAAU,CAAO,MAC1B,EAAK,oBAAoB,SAAU,CAAO,CAE3D,EAAG,CAAC,EAAO,CAAY,CAAC,EAExB,IAAM,GAAA,EAAW,EAAA,YAAA,CACZ,GAAoB,CAEjB,GADA,EAAc,CAAI,EACd,GAAc,OAAO,OAAW,IAChC,GAAI,CACA,OAAO,aAAa,QAAQ,EAAY,CAAI,CAChD,MAAQ,CAER,CAER,EACA,CAAC,CAAU,CACf,EAEM,GAAA,EAAS,EAAA,YAAA,KAAkB,CAC7B,EAAS,IAAkB,OAAS,QAAU,MAAM,CACxD,EAAG,CAAC,EAAe,CAAQ,CAAC,EAEtB,GAAA,EAAQ,EAAA,QAAA,MACH,CAAE,QAAO,gBAAe,WAAU,QAAO,GAChD,CAAC,EAAO,EAAe,EAAU,CAAM,CAC3C,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAa,SAAd,CAA8B,QAAQ,UAAgC,CAAA,CACjF,CAKA,SAAgB,GAA8B,CAC1C,IAAM,GAAA,EAAM,EAAA,WAAA,CAAW,CAAY,EACnC,GAAI,CAAC,EAAK,MAAU,MAAM,gDAAgD,EAC1E,OAAO,CACX"}
@@ -1,7 +1,8 @@
1
- import { createContext as e, useCallback as t, useContext as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
1
+ import { useLatestRef as e } from "../hooks/use-latest-ref.js";
2
+ import { createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useState as o } from "react";
2
3
  import { jsx as s } from "react/jsx-runtime";
3
4
  //#region src/theme/ThemeProvider.tsx
4
- var c = e(null);
5
+ var c = t(null);
5
6
  function l(e) {
6
7
  return e === "dark" || e === "light" ? e : typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
7
8
  }
@@ -22,20 +23,14 @@ function d(e) {
22
23
  return null;
23
24
  }
24
25
  }
25
- function f({ children: e, defaultTheme: n = "system", storageKey: f = "tempest-theme", target: p, attribute: m = "data-tempest-theme", themeColor: h }) {
26
- let [g, _] = o(() => d(f) ?? n), [v, y] = o(() => l(g)), b = a(p);
27
- r(() => {
28
- b.current = p;
29
- }, [p]);
30
- let x = Array.isArray(m) ? m.join(",") : m, S = a(h);
31
- r(() => {
32
- S.current = h;
33
- }, [h]), r(() => {
26
+ function f({ children: t, defaultTheme: r = "system", storageKey: f = "tempest-theme", target: p, attribute: m = "data-tempest-theme", themeColor: h }) {
27
+ let [g, _] = o(() => d(f) ?? r), [v, y] = o(() => l(g)), b = e(p), x = Array.isArray(m) ? m.join(",") : m, S = e(h);
28
+ i(() => {
34
29
  let e = b.current?.() ?? document.documentElement;
35
30
  if (!e) return;
36
31
  let t = l(g);
37
32
  u(e, t, m, S.current), y(t);
38
- }, [g, x]), r(() => {
33
+ }, [g, x]), i(() => {
39
34
  if (g !== "system" || typeof window > "u") return;
40
35
  let e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => {
41
36
  let t = b.current?.() ?? document.documentElement;
@@ -45,13 +40,13 @@ function f({ children: e, defaultTheme: n = "system", storageKey: f = "tempest-t
45
40
  };
46
41
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
47
42
  }, [g, x]);
48
- let C = t((e) => {
43
+ let C = n((e) => {
49
44
  if (_(e), f && typeof window < "u") try {
50
45
  window.localStorage.setItem(f, e);
51
46
  } catch {}
52
- }, [f]), w = t(() => {
47
+ }, [f]), w = n(() => {
53
48
  C(v === "dark" ? "light" : "dark");
54
- }, [v, C]), T = i(() => ({
49
+ }, [v, C]), T = a(() => ({
55
50
  theme: g,
56
51
  resolvedTheme: v,
57
52
  setTheme: C,
@@ -64,11 +59,11 @@ function f({ children: e, defaultTheme: n = "system", storageKey: f = "tempest-t
64
59
  ]);
65
60
  return /* @__PURE__ */ s(c.Provider, {
66
61
  value: T,
67
- children: e
62
+ children: t
68
63
  });
69
64
  }
70
65
  function p() {
71
- let e = n(c);
66
+ let e = r(c);
72
67
  if (!e) throw Error("useTheme must be used inside a <ThemeProvider>");
73
68
  return e;
74
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useRef<typeof target>(target);\n useEffect(() => {\n targetRef.current = target;\n }, [target]);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useRef(themeColor);\n useEffect(() => {\n themeColorRef.current = themeColor;\n }, [themeColor]);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":";;;AAuBA,IAAM,IAAe,EAAwC,IAAI;AAgCjE,SAAS,EAAQ,GAAgC;CAG7C,OAFI,MAAS,UAAU,MAAS,UAAgB,IAC5C,OAAO,SAAW,MAAoB,UACnC,OAAO,WAAW,8BAA8B,CAAC,CAAC,UAAU,SAAS;AAChF;AAMA,SAAS,EACL,GACA,GACA,GACA,GACI;CACJ,IAAM,IAAQ,MAAM,QAAQ,CAAS,IAAI,IAAY,CAAC,CAAS;CAC/D,KAAK,IAAM,KAAQ,GAAO,EAAQ,aAAa,GAAM,CAAQ;CAC7D,IAAI,KAAc,OAAO,WAAa,KAAa;EAC/C,IAAM,IAAO,SAAS,cAA+B,4BAA0B;EAC/E,AAAI,MAAM,EAAK,UAAU,EAAW;CACxC;AACJ;AAEA,SAAS,EAAW,GAA6C;CAC7D,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,IAAM,IAAQ,OAAO,aAAa,QAAQ,CAAU;EAEpD,OADI,MAAU,WAAW,MAAU,UAAU,MAAU,WAAiB,IACjE;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAeA,SAAgB,EAAc,EAC1B,aACA,kBAAe,UACf,gBAAa,iBACb,WACA,eAAY,sBACZ,iBACmB;CACnB,IAAM,CAAC,GAAO,KAAiB,QACrB,EAAW,CAAU,KAAK,CACpC,GACM,CAAC,GAAe,KAAoB,QAA8B,EAAQ,CAAK,CAAC,GAEhF,IAAY,EAAsB,CAAM;CAC9C,QAAgB;EACZ,EAAU,UAAU;CACxB,GAAG,CAAC,CAAM,CAAC;CAEX,IAAM,IAAe,MAAM,QAAQ,CAAS,IAAI,EAAU,KAAK,GAAG,IAAI,GAChE,IAAgB,EAAO,CAAU;CAevC,AAdA,QAAgB;EACZ,EAAc,UAAU;CAC5B,GAAG,CAAC,CAAU,CAAC,GAEf,QAAgB;EACZ,IAAM,IAAU,EAAU,UAAU,KAAK,SAAS;EAClD,IAAI,CAAC,GAAS;EACd,IAAM,IAAO,EAAQ,CAAK;EAE1B,AADA,EAAc,GAAS,GAAM,GAAW,EAAc,OAAO,GAC7D,EAAiB,CAAI;CAGzB,GAAG,CAAC,GAAO,CAAY,CAAC,GAExB,QAAgB;EACZ,IAAI,MAAU,YAAY,OAAO,SAAW,KAAa;EACzD,IAAM,IAAO,OAAO,WAAW,8BAA8B,GACvD,UAAsB;GACxB,IAAM,IAAU,EAAU,UAAU,KAAK,SAAS;GAClD,IAAI,CAAC,GAAS;GACd,IAAM,IAAsB,EAAK,UAAU,SAAS;GAEpD,AADA,EAAc,GAAS,GAAM,GAAW,EAAc,OAAO,GAC7D,EAAiB,CAAI;EACzB;EAEA,OADA,EAAK,iBAAiB,UAAU,CAAO,SAC1B,EAAK,oBAAoB,UAAU,CAAO;CAE3D,GAAG,CAAC,GAAO,CAAY,CAAC;CAExB,IAAM,IAAW,GACZ,MAAoB;EAEjB,IADA,EAAc,CAAI,GACd,KAAc,OAAO,SAAW,KAChC,IAAI;GACA,OAAO,aAAa,QAAQ,GAAY,CAAI;EAChD,QAAQ,CAER;CAER,GACA,CAAC,CAAU,CACf,GAEM,IAAS,QAAkB;EAC7B,EAAS,MAAkB,SAAS,UAAU,MAAM;CACxD,GAAG,CAAC,GAAe,CAAQ,CAAC,GAEtB,IAAQ,SACH;EAAE;EAAO;EAAe;EAAU;CAAO,IAChD;EAAC;EAAO;EAAe;EAAU;CAAM,CAC3C;CAEA,OAAO,kBAAC,EAAa,UAAd;EAA8B;EAAQ;CAAgC,CAAA;AACjF;AAKA,SAAgB,IAA8B;CAC1C,IAAM,IAAM,EAAW,CAAY;CACnC,IAAI,CAAC,GAAK,MAAU,MAAM,gDAAgD;CAC1E,OAAO;AACX"}
1
+ {"version":3,"file":"ThemeProvider.js","names":[],"sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useLatestRef } from \"@/hooks/use-latest-ref\";\nimport type { ResolvedTheme, ThemeMode } from \"./types\";\n\nexport interface ThemeContextValue {\n /** Raw user preference (light / dark / system). */\n theme: ThemeMode;\n /** Effective theme actually applied to the DOM (light or dark). */\n resolvedTheme: ResolvedTheme;\n /** Update the preference. Persisted to localStorage when `storageKey` is set. */\n setTheme: (next: ThemeMode) => void;\n /** Convenience: flip light ↔ dark. When in `system` mode, switches to the opposite of the current resolved theme. */\n toggle: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n /** Initial preference when nothing is stored. Default: `\"system\"`. */\n defaultTheme?: ThemeMode;\n /** localStorage key used to persist the preference. Pass `null` to disable persistence. Default: `\"tempest-theme\"`. */\n storageKey?: string | null;\n /**\n * Element that receives the theme attribute(s). Defaults to\n * `document.documentElement`. Override when scoping the theme to a subtree.\n */\n target?: () => HTMLElement | null;\n /**\n * Attribute name(s) written on the target with the resolved theme\n * (`\"light\"` / `\"dark\"`). Default: `\"data-tempest-theme\"`.\n *\n * Pass an array to mirror the theme onto more than one attribute — handy\n * when the SDK components read `data-tempest-theme` but the host app's own\n * CSS keys off a different attribute (e.g. `[\"data-tempest-theme\",\n * \"data-theme\"]`). Avoids a separate sync effect in the consumer.\n */\n attribute?: string | string[];\n /**\n * When set, keeps `<meta name=\"theme-color\">` in sync with the resolved\n * theme — `content` becomes `themeColor.dark` in dark mode and\n * `themeColor.light` in light mode. The meta tag must already exist in the\n * document `<head>`. No-op when omitted.\n */\n themeColor?: { light: string; dark: string };\n}\n\nfunction resolve(mode: ThemeMode): ResolvedTheme {\n if (mode === \"dark\" || mode === \"light\") return mode;\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\n/**\n * Write the resolved theme onto every configured attribute and, when a\n * `themeColor` map is provided, sync the `<meta name=\"theme-color\">` tag.\n */\nfunction applyResolved(\n element: HTMLElement,\n resolved: ResolvedTheme,\n attribute: string | string[],\n themeColor?: { light: string; dark: string },\n): void {\n const attrs = Array.isArray(attribute) ? attribute : [attribute];\n for (const attr of attrs) element.setAttribute(attr, resolved);\n if (themeColor && typeof document !== \"undefined\") {\n const meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (meta) meta.content = themeColor[resolved];\n }\n}\n\nfunction readStored(storageKey: string | null): ThemeMode | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value === \"light\" || value === \"dark\" || value === \"system\") return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Wire dark/light theming. Writes a data attribute on a target element (the\n * `<html>` element by default) and exposes the current preference via\n * {@link useTheme}.\n *\n * Pair with `themeInitScript()` in the HTML head to prevent the flash of\n * incorrect theme on first paint.\n *\n * @tempest-limits empty-catch — the theme is applied to the DOM before it is\n * persisted, so a `localStorage` write refused by quota or private mode leaves the\n * user with the theme they just picked and only forfeits it on the next load.\n * Throwing from the setter would break the switch that already worked.\n */\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"tempest-theme\",\n target,\n attribute = \"data-tempest-theme\",\n themeColor,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(\n () => readStored(storageKey) ?? defaultTheme,\n );\n const [resolvedTheme, setResolvedTheme] = useState<ResolvedTheme>(() => resolve(theme));\n\n const targetRef = useLatestRef(target);\n\n const attributeKey = Array.isArray(attribute) ? attribute.join(\",\") : attribute;\n const themeColorRef = useLatestRef(themeColor);\n\n useEffect(() => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next = resolve(theme);\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n // attributeKey is the stable string form of `attribute`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n useEffect(() => {\n if (theme !== \"system\" || typeof window === \"undefined\") return;\n const list = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (): void => {\n const element = targetRef.current?.() ?? document.documentElement;\n if (!element) return;\n const next: ResolvedTheme = list.matches ? \"dark\" : \"light\";\n applyResolved(element, next, attribute, themeColorRef.current);\n setResolvedTheme(next);\n };\n list.addEventListener(\"change\", handler);\n return () => list.removeEventListener(\"change\", handler);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [theme, attributeKey]);\n\n const setTheme = useCallback(\n (next: ThemeMode) => {\n setThemeState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const toggle = useCallback(() => {\n setTheme(resolvedTheme === \"dark\" ? \"light\" : \"dark\");\n }, [resolvedTheme, setTheme]);\n\n const value = useMemo<ThemeContextValue>(\n () => ({ theme, resolvedTheme, setTheme, toggle }),\n [theme, resolvedTheme, setTheme, toggle],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read and mutate the current theme. Must be used inside a {@link ThemeProvider}.\n */\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error(\"useTheme must be used inside a <ThemeProvider>\");\n return ctx;\n}\n"],"mappings":";;;;AAgBA,IAAM,IAAe,EAAwC,IAAI;AAgCjE,SAAS,EAAQ,GAAgC;CAG7C,OAFI,MAAS,UAAU,MAAS,UAAgB,IAC5C,OAAO,SAAW,MAAoB,UACnC,OAAO,WAAW,8BAA8B,CAAC,CAAC,UAAU,SAAS;AAChF;AAMA,SAAS,EACL,GACA,GACA,GACA,GACI;CACJ,IAAM,IAAQ,MAAM,QAAQ,CAAS,IAAI,IAAY,CAAC,CAAS;CAC/D,KAAK,IAAM,KAAQ,GAAO,EAAQ,aAAa,GAAM,CAAQ;CAC7D,IAAI,KAAc,OAAO,WAAa,KAAa;EAC/C,IAAM,IAAO,SAAS,cAA+B,4BAA0B;EAC/E,AAAI,MAAM,EAAK,UAAU,EAAW;CACxC;AACJ;AAEA,SAAS,EAAW,GAA6C;CAC7D,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,IAAM,IAAQ,OAAO,aAAa,QAAQ,CAAU;EAEpD,OADI,MAAU,WAAW,MAAU,UAAU,MAAU,WAAiB,IACjE;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAeA,SAAgB,EAAc,EAC1B,aACA,kBAAe,UACf,gBAAa,iBACb,WACA,eAAY,sBACZ,iBACmB;CACnB,IAAM,CAAC,GAAO,KAAiB,QACrB,EAAW,CAAU,KAAK,CACpC,GACM,CAAC,GAAe,KAAoB,QAA8B,EAAQ,CAAK,CAAC,GAEhF,IAAY,EAAa,CAAM,GAE/B,IAAe,MAAM,QAAQ,CAAS,IAAI,EAAU,KAAK,GAAG,IAAI,GAChE,IAAgB,EAAa,CAAU;CAY7C,AAVA,QAAgB;EACZ,IAAM,IAAU,EAAU,UAAU,KAAK,SAAS;EAClD,IAAI,CAAC,GAAS;EACd,IAAM,IAAO,EAAQ,CAAK;EAE1B,AADA,EAAc,GAAS,GAAM,GAAW,EAAc,OAAO,GAC7D,EAAiB,CAAI;CAGzB,GAAG,CAAC,GAAO,CAAY,CAAC,GAExB,QAAgB;EACZ,IAAI,MAAU,YAAY,OAAO,SAAW,KAAa;EACzD,IAAM,IAAO,OAAO,WAAW,8BAA8B,GACvD,UAAsB;GACxB,IAAM,IAAU,EAAU,UAAU,KAAK,SAAS;GAClD,IAAI,CAAC,GAAS;GACd,IAAM,IAAsB,EAAK,UAAU,SAAS;GAEpD,AADA,EAAc,GAAS,GAAM,GAAW,EAAc,OAAO,GAC7D,EAAiB,CAAI;EACzB;EAEA,OADA,EAAK,iBAAiB,UAAU,CAAO,SAC1B,EAAK,oBAAoB,UAAU,CAAO;CAE3D,GAAG,CAAC,GAAO,CAAY,CAAC;CAExB,IAAM,IAAW,GACZ,MAAoB;EAEjB,IADA,EAAc,CAAI,GACd,KAAc,OAAO,SAAW,KAChC,IAAI;GACA,OAAO,aAAa,QAAQ,GAAY,CAAI;EAChD,QAAQ,CAER;CAER,GACA,CAAC,CAAU,CACf,GAEM,IAAS,QAAkB;EAC7B,EAAS,MAAkB,SAAS,UAAU,MAAM;CACxD,GAAG,CAAC,GAAe,CAAQ,CAAC,GAEtB,IAAQ,SACH;EAAE;EAAO;EAAe;EAAU;CAAO,IAChD;EAAC;EAAO;EAAe;EAAU;CAAM,CAC3C;CAEA,OAAO,kBAAC,EAAa,UAAd;EAA8B;EAAQ;CAAgC,CAAA;AACjF;AAKA,SAAgB,IAA8B;CAC1C,IAAM,IAAM,EAAW,CAAY;CACnC,IAAI,CAAC,GAAK,MAAU,MAAM,gDAAgD;CAC1E,OAAO;AACX"}
@@ -0,0 +1,2 @@
1
+ function e(e,t={}){let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));let i=btoa(n);return t.urlSafe?i.replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``):i}function t(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.padEnd(t.length+(4-t.length%4)%4,`=`),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);return i}exports.base64ToBytes=t,exports.bytesToBase64=e;
2
+ //# sourceMappingURL=base64.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.cjs","names":[],"sources":["../../src/utils/base64.ts"],"sourcesContent":["/**\n * Base64-encode bytes, without splatting the whole array into `fromCharCode`.\n *\n * `String.fromCharCode(...bytes)` overflows the argument limit somewhere around\n * a hundred thousand entries — which a compressed save reaches easily — so the\n * conversion walks the buffer in 32 KiB windows. That is also why this is the\n * version worth sharing: the byte-at-a-time loop the other two call sites used\n * has no argument limit either, but it is markedly slower on the payload sizes\n * `compressedStorage` exists for.\n *\n * @param bytes - The bytes to encode.\n * @param options - Pass `urlSafe` for the base64url alphabet (`-`/`_`, unpadded),\n * which is what WebAuthn and anything travelling in a URL needs.\n * @returns Base64 text.\n */\nexport function bytesToBase64(bytes: Uint8Array, options: { urlSafe?: boolean } = {}): string {\n let binary = \"\";\n const chunkSize = 0x8000;\n for (let index = 0; index < bytes.length; index += chunkSize) {\n binary += String.fromCharCode(...bytes.subarray(index, index + chunkSize));\n }\n const encoded = btoa(binary);\n if (!options.urlSafe) return encoded;\n return encoded.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/**\n * Decode base64 into bytes, accepting either alphabet.\n *\n * Takes no `urlSafe` option on purpose: translating `-`/`_` and restoring the\n * padding are no-ops on standard padded base64, so one permissive decoder is\n * correct for both inputs. Getting this half wrong — usually by feeding\n * unpadded base64url straight to `atob` and losing the last byte — is the\n * classic broken-WebAuthn bug.\n *\n * @param value - Base64 or base64url text, with or without `=` padding.\n * @returns The decoded bytes.\n */\nexport function base64ToBytes(value: string): Uint8Array<ArrayBuffer> {\n const standard = value.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = standard.padEnd(standard.length + ((4 - (standard.length % 4)) % 4), \"=\");\n const binary = atob(padded);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return bytes;\n}\n"],"mappings":"AAeA,SAAgB,EAAc,EAAmB,EAAiC,CAAC,EAAW,CAC1F,IAAI,EAAS,GACP,EAAY,MAClB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,GAAS,EAC/C,GAAU,OAAO,aAAa,GAAG,EAAM,SAAS,EAAO,EAAQ,CAAS,CAAC,EAE7E,IAAM,EAAU,KAAK,CAAM,EAE3B,OADK,EAAQ,QACN,EAAQ,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAAO,EAAE,EAD3C,CAEjC,CAcA,SAAgB,EAAc,EAAwC,CAClE,IAAM,EAAW,EAAM,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EACrD,EAAS,EAAS,OAAO,EAAS,QAAW,EAAK,EAAS,OAAS,GAAM,EAAI,GAAG,EACjF,EAAS,KAAK,CAAM,EACpB,EAAQ,IAAI,WAAW,EAAO,MAAM,EAC1C,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAO,OAAQ,GAAS,EAChD,EAAM,GAAS,EAAO,WAAW,CAAK,EAE1C,OAAO,CACX"}
@@ -0,0 +1,16 @@
1
+ //#region src/utils/base64.ts
2
+ function e(e, t = {}) {
3
+ let n = "", r = 32768;
4
+ for (let t = 0; t < e.length; t += r) n += String.fromCharCode(...e.subarray(t, t + r));
5
+ let i = btoa(n);
6
+ return t.urlSafe ? i.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "") : i;
7
+ }
8
+ function t(e) {
9
+ let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t.padEnd(t.length + (4 - t.length % 4) % 4, "="), r = atob(n), i = new Uint8Array(r.length);
10
+ for (let e = 0; e < r.length; e += 1) i[e] = r.charCodeAt(e);
11
+ return i;
12
+ }
13
+ //#endregion
14
+ export { t as base64ToBytes, e as bytesToBase64 };
15
+
16
+ //# sourceMappingURL=base64.js.map