@stacksjs/mobile 0.75.383 → 0.75.388

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.
package/README.md CHANGED
@@ -345,6 +345,14 @@ anchor so GPS drift while standing still adds nothing, fixes less accurate than
345
345
  covered, moving time, and pace over the last 30 seconds and the whole route.
346
346
  `paceLabel` and `speedLabel` format min/km and km/h.
347
347
 
348
+ `createRouteStats()` keeps the same numbers up as fixes arrive: `add(fixes)`
349
+ counts only fixes newer than any it has seen and keeps just the anchors the pace
350
+ window needs, so a 20-hour route costs a read what its last few seconds do. The
351
+ recorder reads with `readRecording({ expectedId, since })`; a host that answers
352
+ with only the new fixes is read every `intervalMs`, and one that hands back the
353
+ whole recording is read less often past an hour of fixes (`routeReadInterval`,
354
+ at most every 30 s).
355
+
348
356
  ## Before the bridge arrives
349
357
 
350
358
  Craft installs `window.craft` once the page has finished loading, so
package/dist/index.d.ts CHANGED
@@ -515,6 +515,7 @@ declare function attachHeartRate<T extends RouteFix>(fixes: readonly T[], sample
515
515
  declare function fixDistance(a: { latitude: number, longitude: number }, b: { latitude: number, longitude: number }): number;
516
516
  /** The fixes worth counting, oldest first: a known position, accurate enough. */
517
517
  declare function usableFixes<T extends RouteFix>(fixes: readonly T[], maxAccuracyM?: number): T[];
518
+ declare function createRouteStats(options?: RouteStatsOptions): RouteStatsAccumulator;
518
519
  /**
519
520
  * The live numbers for a recording.
520
521
  *
@@ -530,6 +531,14 @@ declare function routeStats(fixes: readonly RouteFix[], options?: RouteStatsOpti
530
531
  declare function paceLabel(secondsPerKm: number | null | undefined): string;
531
532
  /** "24.3" kilometres per hour. */
532
533
  declare function speedLabel(metresPerSecond: number | null | undefined): string;
534
+ /**
535
+ * How long to wait before the next read, ms. A host that answers `since` with
536
+ * only the new fixes is read every `everyMs`, however long the route. One that
537
+ * hands back the whole recording costs more with every fix (a 20-hour route
538
+ * is ~72,000 of them through the bridge), so past ROUTE_FULL_READ_FIXES the
539
+ * wait grows with the recording, up to ROUTE_FULL_READ_MAX_MS.
540
+ */
541
+ declare function routeReadInterval(everyMs: number, fixes: number, wholeReads: boolean): number;
533
542
  /**
534
543
  * A recording to follow: start, pause, resume and stop the native recording,
535
544
  * and the live numbers read back from it every few seconds while the page is
@@ -540,6 +549,10 @@ declare function createRouteRecorder(options: RouteRecorderOptions): RouteRecord
540
549
  declare const HEART_RATE_MATCH_MS: 5000;
541
550
  /** Fixes further apart than this, seconds, are a break in the route (a pause). */
542
551
  declare const ROUTE_GAP_S: 30;
552
+ /** Past this many fixes (an hour at one a second), a whole-recording read is spaced out. */
553
+ declare const ROUTE_FULL_READ_FIXES: 3600;
554
+ /** The longest a whole-recording read is spaced to, ms. */
555
+ declare const ROUTE_FULL_READ_MAX_MS: unknown;
543
556
  /** A fix as Craft records it. */
544
557
  declare interface RouteFix extends Location {
545
558
  altitudeAccuracy?: number
@@ -558,6 +571,21 @@ declare interface RouteStatsOptions {
558
571
  maxAccuracyM?: number
559
572
  paceWindowS?: number
560
573
  }
574
+ /**
575
+ * The live numbers for a recording, kept up as fixes arrive: `add` takes the
576
+ * next fixes (a batch read back from the native recording) and counts only
577
+ * those newer than any it has seen, so a reader can hand it a whole recording
578
+ * or just its tail and get the same answer. Each fix is looked at once, and
579
+ * only the anchors inside the pace window are kept, so a 20-hour route costs
580
+ * what its last few seconds do rather than every fix again on every read.
581
+ *
582
+ * `routeStats` is this over one batch.
583
+ */
584
+ declare interface RouteStatsAccumulator {
585
+ add: (fixes: readonly RouteFix[]) => RouteStats
586
+ readonly stats: RouteStats
587
+ readonly latestTimestamp: number | null
588
+ }
561
589
  declare interface RouteRecorderOptions extends RouteStatsOptions {
562
590
  intervalMs?: number
563
591
  onUpdate?: (stats: RouteStats) => void
@@ -1607,6 +1635,14 @@ declare interface SecureStorageApi {
1607
1635
  declare interface RecordingOwnershipOptions {
1608
1636
  expectedId: string
1609
1637
  }
1638
+ /**
1639
+ * Reading a route recording back. `since` (epoch ms) asks only for the fixes
1640
+ * recorded after it: a host that knows it answers with the tail, one that
1641
+ * does not answers with every fix, and the caller skips what it has.
1642
+ */
1643
+ declare interface LocationRecordingReadOptions extends RecordingOwnershipOptions {
1644
+ since?: number
1645
+ }
1610
1646
  declare interface LocationApi {
1611
1647
  supportsRecordingOwnership: () => boolean
1612
1648
  supportsRecordingIntentIdentity: () => boolean
@@ -1619,7 +1655,7 @@ declare interface LocationApi {
1619
1655
  resumeRecording: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingState>
1620
1656
  stopRecording: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingResult>
1621
1657
  getRecordingState: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingState>
1622
- readRecording: (options?: RecordingOwnershipOptions) => Promise<Location[]>
1658
+ readRecording: (options?: LocationRecordingReadOptions) => Promise<Location[]>
1623
1659
  }
1624
1660
  declare interface ShareApi {
1625
1661
  share: (options: ShareOptions) => Promise<boolean>
@@ -2056,6 +2092,6 @@ declare interface VoiceRecorder {
2056
2092
  }
2057
2093
  type VoiceRecorderStatus = 'idle' | 'requesting' | 'recording' | 'ready' | 'error';
2058
2094
 
2059
- export { normalizeDeepLinkURL, getNativeMobileBridge, isNativeMobile, whenNativeMobile, onMobileReady, withNativeFeedback, biometrics, camera, device, lifecycle, location, notifications, permissions, secureStorage, share, appReview, haptics, deepLinks, snapshots, keepAwake, brightness, music, heartRate, speech, network, pushNotifications, health, liveActivities, watchConnectivity, splash, mobile, NativeVoiceFile, VoiceRecorder, VoiceRecorderOptions, VoiceRecorderSnapshot, VoiceRecorderStatus, createVoiceRecorder, voiceRecordingFormData, craftHost, craftRoot, hasNativeMobileHost, bridgePending, whenBridgeReady, nativeFunctionNow, nativeFunction, callNative, afterBridge, subscribeWhenReady, onCraftEvent, BRIDGE_WAIT_MS, CraftHost, CallNativeOptions, observeLongPress, segmentAt, observeSegmentScrub, segmentForKey, focusSegment, installPressables, LongPressOptions, SegmentScrubOptions, keepBreadcrumb, crashReporting, CrashReportingOptions, currentAppearance, normalizeAppearance, onAppearance, onResume, onMemoryWarning, onSilentPush, onBackgroundRefresh, NativeAppearance, pageScrollTop, observePageScroll, pullDistance, observePullToRefresh, largeTitleMetrics, observeLargeTitle, resolveScrollHost, ScrollHost, PullToRefreshOptions, LargeTitleMetrics, LargeTitleOptions, canGoBack, goBack, enterNavTrail, backLabelFor, navTrail, previousScreenPath, goBackToTabRoot, trailEntryFor, deepLinkPath, followDeepLinks, HistoryHost, NavTrailEntry, TabRootHost, attachHeartRate, fixDistance, usableFixes, routeStats, paceLabel, speedLabel, createRouteRecorder, HEART_RATE_MATCH_MS, ROUTE_GAP_S, RouteFix, RouteStats, RouteStatsOptions, RouteRecorderOptions, RouteRecorder, scheduledWorkoutsUnsupported, normalizeScheduledWorkout, scheduledWorkouts, AppleWorkoutStep, AppleIntervalBlock, AppleCustomWorkout, AppleWorkoutPlan, ScheduledWorkout, ScheduleWorkoutResult, ScheduledWorkoutsApi, ScheduledWorkoutsAuthorization, AppleWorkoutGoal, AppleWorkoutAlert, ScheduledWorkoutsMethod, startSessionClock, pauseSessionClock, resumeSessionClock, sessionClockElapsed, SessionClock, indoorVerdict, typedDistanceKm, INDOOR_CHECK_AFTER_S, IndoorFix, IndoorVerdict, toNativeRect, useActionSheet, confirmAction, showContextMenuFor, dialog, contextMenu, browser, symbols, statusBar, chrome, refresh, background, clipboard, db, files, shortcuts, widgets, orientation, auth, storeKit, DialogApi, ConfirmActionOptions, ContextMenuApi, BrowserOpenOptions, BrowserResult, BrowserApi, SymbolOptions, SymbolsApi, StatusBarApi, ChromeApi, RefreshApi, BackgroundApi, ClipboardApi, DatabaseExecuteResult, DatabaseApi, PickedFile, ScannedCode, FilesApi, HomeScreenShortcut, ShortcutsApi, WidgetsApi, OrientationApi, AppleSignInResult, AppleSignInOptions, AuthApi, StoreProduct, StoreTransaction, StoreKitApi, StatusBarStyle, OrientationLock, ActionSheetOptions, AlertOptions, ChoiceOptions, ConfirmOptions, ContextMenuItem, ContextMenuOptions, DialogAction, DialogActionStyle, NativeRect, isShown, observeNativeRefresh, NativeRefreshOptions, sheetStops, settleSheet, rubberBand, observeSheetDrag, liftToBody, presentPageAsCard, SHEET_FLICK_VELOCITY, SheetStop, SheetDragOptions, SheetDetent, SheetSettle, presentChoice, presentAlert, presentConfirm, presentActionSheet, placeMenu, presentContextMenu, applyAppearance, pageBackground, pageIsDark, installNativeChrome, NativeChromeOptions, readSpotlightKinds, spotlightKind, spotlightAction, spotlightSlot, spotlightActions, spotlightActivityTypes, spotlightTitle, placeSpotlightItem, removeSpotlightItem, spotlightRoute, readSpotlightEntries, spotlightBridge, createSpotlightIndex, onSpotlightTap, MAX_SPOTLIGHT_SLOTS_PER_KIND, SpotlightKind, SpotlightKindInput, SpotlightItem, SpotlightEntry, SpotlightKindsResult, SpotlightPlacement, SpotlightBridge, SpotlightIndexOptions, SpotlightIndex, readTabLinks, nativeTabs, routerHandlesTabs, handleTabReselect, coverTabBar, mirrorTabBar, tabBar, TAB_BAR_COVER_EVENT, TabBarApi, TabLink, TabReselectOptions, MirrorTabBarOptions, CraftMobileCapabilities, CraftMobileBridge, CraftReadyEvent, MobileApi, DeviceInfo, DeviceCapabilities, CameraOptions, PhotoResult, Location, LocationOptions, LocationRecordingState, RecordingStartOptions, LocationRecordingOptions, LocationRecordingResult, ShareOptions, NotificationOptions, DeviceApi, HapticsApi, PermissionsApi, CameraApi, BiometricsApi, StorageApi, CryptoApi, SecureStorageApi, RecordingOwnershipOptions, LocationApi, ShareApi, LifecycleApi, NotificationsApi, KeepAwakeApi, BrightnessApi, SpeechOptions, SpeechApi, NowPlaying, MusicSkipOptions, HeartRateDevice, HeartRateRecordingState, HeartRateState, HeartRateReading, HeartRateSample, HeartRateRecordingApi, HeartRateApi, MusicApi, DeepLinksApi, SnapshotsApi, NetworkStatus, NetworkApi, AppReviewApi, PushNotificationsApi, HealthQuantitySample, HealthDataOptions, HealthDataResult, HealthWorkoutLocation, HealthWorkout, HealthWorkoutResult, HealthWorkoutQuery, HealthWorkoutSample, HealthDailyValue, HealthSampleQuery, HealthHeartRateQuery, HealthHeartRateSample, HealthSleepInterval, HealthMindfulSession, HealthMindfulSessionResult, HealthMindfulSessionQuery, HealthMindfulSample, HealthHeartRateUpdatesOptions, HealthAuthorizationOptions, HealthApi, LiveActivityState, LiveActivityOptions, LiveActivitiesApi, WatchConnectivityApi, HapticStyle, HapticNotificationType, PermissionType, PermissionStatus, BiometricType, AppState, HapticKind, MusicAuthorization, MusicPlaybackState, MusicMethod, HeartRateAuthorization, BluetoothState, HeartRateConnection, HeartRateMethod, HealthDataType, HealthDailyType, HealthSampleType, HealthWorkoutType, HealthWorkoutActivity, HealthSleepStage, HealthReadMethod, storage, crypto };
2095
+ export { normalizeDeepLinkURL, getNativeMobileBridge, isNativeMobile, whenNativeMobile, onMobileReady, withNativeFeedback, biometrics, camera, device, lifecycle, location, notifications, permissions, secureStorage, share, appReview, haptics, deepLinks, snapshots, keepAwake, brightness, music, heartRate, speech, network, pushNotifications, health, liveActivities, watchConnectivity, splash, mobile, NativeVoiceFile, VoiceRecorder, VoiceRecorderOptions, VoiceRecorderSnapshot, VoiceRecorderStatus, createVoiceRecorder, voiceRecordingFormData, craftHost, craftRoot, hasNativeMobileHost, bridgePending, whenBridgeReady, nativeFunctionNow, nativeFunction, callNative, afterBridge, subscribeWhenReady, onCraftEvent, BRIDGE_WAIT_MS, CraftHost, CallNativeOptions, observeLongPress, segmentAt, observeSegmentScrub, segmentForKey, focusSegment, installPressables, LongPressOptions, SegmentScrubOptions, keepBreadcrumb, crashReporting, CrashReportingOptions, currentAppearance, normalizeAppearance, onAppearance, onResume, onMemoryWarning, onSilentPush, onBackgroundRefresh, NativeAppearance, pageScrollTop, observePageScroll, pullDistance, observePullToRefresh, largeTitleMetrics, observeLargeTitle, resolveScrollHost, ScrollHost, PullToRefreshOptions, LargeTitleMetrics, LargeTitleOptions, canGoBack, goBack, enterNavTrail, backLabelFor, navTrail, previousScreenPath, goBackToTabRoot, trailEntryFor, deepLinkPath, followDeepLinks, HistoryHost, NavTrailEntry, TabRootHost, attachHeartRate, fixDistance, usableFixes, createRouteStats, routeStats, paceLabel, speedLabel, routeReadInterval, createRouteRecorder, HEART_RATE_MATCH_MS, ROUTE_GAP_S, ROUTE_FULL_READ_FIXES, ROUTE_FULL_READ_MAX_MS, RouteFix, RouteStats, RouteStatsOptions, RouteStatsAccumulator, RouteRecorderOptions, RouteRecorder, scheduledWorkoutsUnsupported, normalizeScheduledWorkout, scheduledWorkouts, AppleWorkoutStep, AppleIntervalBlock, AppleCustomWorkout, AppleWorkoutPlan, ScheduledWorkout, ScheduleWorkoutResult, ScheduledWorkoutsApi, ScheduledWorkoutsAuthorization, AppleWorkoutGoal, AppleWorkoutAlert, ScheduledWorkoutsMethod, startSessionClock, pauseSessionClock, resumeSessionClock, sessionClockElapsed, SessionClock, indoorVerdict, typedDistanceKm, INDOOR_CHECK_AFTER_S, IndoorFix, IndoorVerdict, toNativeRect, useActionSheet, confirmAction, showContextMenuFor, dialog, contextMenu, browser, symbols, statusBar, chrome, refresh, background, clipboard, db, files, shortcuts, widgets, orientation, auth, storeKit, DialogApi, ConfirmActionOptions, ContextMenuApi, BrowserOpenOptions, BrowserResult, BrowserApi, SymbolOptions, SymbolsApi, StatusBarApi, ChromeApi, RefreshApi, BackgroundApi, ClipboardApi, DatabaseExecuteResult, DatabaseApi, PickedFile, ScannedCode, FilesApi, HomeScreenShortcut, ShortcutsApi, WidgetsApi, OrientationApi, AppleSignInResult, AppleSignInOptions, AuthApi, StoreProduct, StoreTransaction, StoreKitApi, StatusBarStyle, OrientationLock, ActionSheetOptions, AlertOptions, ChoiceOptions, ConfirmOptions, ContextMenuItem, ContextMenuOptions, DialogAction, DialogActionStyle, NativeRect, isShown, observeNativeRefresh, NativeRefreshOptions, sheetStops, settleSheet, rubberBand, observeSheetDrag, liftToBody, presentPageAsCard, SHEET_FLICK_VELOCITY, SheetStop, SheetDragOptions, SheetDetent, SheetSettle, presentChoice, presentAlert, presentConfirm, presentActionSheet, placeMenu, presentContextMenu, applyAppearance, pageBackground, pageIsDark, installNativeChrome, NativeChromeOptions, readSpotlightKinds, spotlightKind, spotlightAction, spotlightSlot, spotlightActions, spotlightActivityTypes, spotlightTitle, placeSpotlightItem, removeSpotlightItem, spotlightRoute, readSpotlightEntries, spotlightBridge, createSpotlightIndex, onSpotlightTap, MAX_SPOTLIGHT_SLOTS_PER_KIND, SpotlightKind, SpotlightKindInput, SpotlightItem, SpotlightEntry, SpotlightKindsResult, SpotlightPlacement, SpotlightBridge, SpotlightIndexOptions, SpotlightIndex, readTabLinks, nativeTabs, routerHandlesTabs, handleTabReselect, coverTabBar, mirrorTabBar, tabBar, TAB_BAR_COVER_EVENT, TabBarApi, TabLink, TabReselectOptions, MirrorTabBarOptions, CraftMobileCapabilities, CraftMobileBridge, CraftReadyEvent, MobileApi, DeviceInfo, DeviceCapabilities, CameraOptions, PhotoResult, Location, LocationOptions, LocationRecordingState, RecordingStartOptions, LocationRecordingOptions, LocationRecordingResult, ShareOptions, NotificationOptions, DeviceApi, HapticsApi, PermissionsApi, CameraApi, BiometricsApi, StorageApi, CryptoApi, SecureStorageApi, RecordingOwnershipOptions, LocationRecordingReadOptions, LocationApi, ShareApi, LifecycleApi, NotificationsApi, KeepAwakeApi, BrightnessApi, SpeechOptions, SpeechApi, NowPlaying, MusicSkipOptions, HeartRateDevice, HeartRateRecordingState, HeartRateState, HeartRateReading, HeartRateSample, HeartRateRecordingApi, HeartRateApi, MusicApi, DeepLinksApi, SnapshotsApi, NetworkStatus, NetworkApi, AppReviewApi, PushNotificationsApi, HealthQuantitySample, HealthDataOptions, HealthDataResult, HealthWorkoutLocation, HealthWorkout, HealthWorkoutResult, HealthWorkoutQuery, HealthWorkoutSample, HealthDailyValue, HealthSampleQuery, HealthHeartRateQuery, HealthHeartRateSample, HealthSleepInterval, HealthMindfulSession, HealthMindfulSessionResult, HealthMindfulSessionQuery, HealthMindfulSample, HealthHeartRateUpdatesOptions, HealthAuthorizationOptions, HealthApi, LiveActivityState, LiveActivityOptions, LiveActivitiesApi, WatchConnectivityApi, HapticStyle, HapticNotificationType, PermissionType, PermissionStatus, BiometricType, AppState, HapticKind, MusicAuthorization, MusicPlaybackState, MusicMethod, HeartRateAuthorization, BluetoothState, HeartRateConnection, HeartRateMethod, HealthDataType, HealthDailyType, HealthSampleType, HealthWorkoutType, HealthWorkoutActivity, HealthSleepStage, HealthReadMethod, storage, crypto };
2060
2096
  export { NativeTab } from 'craft-native/mobile';
2061
2097
  export { NativeTabBarOptions } from 'craft-native/mobile';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{appReview as Zn,biometrics as De,brightness as be,camera as ve,deepLinks as Mt,device as Q,haptics as ye,health as se,heartRate as T,keepAwake as Nt,lifecycle as er,liveActivities as _e,location as D,music as U,network as Ht,notifications as Se,permissions as le,pushNotifications as Be,secureStorage as we,share as Dt,speech as Fe,snapshots as xe,splash as tr,watchConnectivity as ce}from"craft-native/mobile";var Er=2500;function E(){if(typeof window>"u")return;return window}function G(){let e=E()?.craft;return e&&typeof e==="object"?e:void 0}function $t(){return typeof navigator>"u"?"":navigator.userAgent||""}function ee(){let e=E();if(!e)return!1;if(e.CraftAndroid)return!0;let t=G()?.platform;if(t==="ios"||t==="android")return!0;return Boolean(e.webkit?.messageHandlers?.craft)&&/iPhone|iPad|iPod/.test($t())}function ue(){let e=E();if(!e||e.craft)return!1;return ee()||Boolean(e.webkit?.messageHandlers?.craft)}function X(e=15000){let t=E();if(t?.craft)return Promise.resolve(!0);if(!t||!ue())return Promise.resolve(!1);return new Promise((n)=>{let r=()=>{clearTimeout(o),t.removeEventListener("craftReady",r),n(Boolean(t.craft))},o=setTimeout(r,e);t.addEventListener("craftReady",r)})}function Kt(e,t){if(!e)return null;let n=t.split("."),r=e;for(let i of n.slice(0,-1))if(r=r?.[i],!r||typeof r!=="object"&&typeof r!=="function")return null;let o=r?.[n[n.length-1]];return typeof o==="function"?o.bind(r):null}function I(e){return Kt(G(),e)}async function jt(e,t=2500){let n=I(e);if(n||!ue())return n;return await X(t),I(e)}async function v(e,t,n,r={}){let o=await jt(e,r.timeoutMs);if(!o)return n();try{return await o(...t)}catch(i){if(r.fallbackOnError)return n();throw i}}async function p(e,t=2500){if(ue())await X(t);return e()}function Y(e,t=2500){let n,r=!1;if(!ue())n=e();else X(t).then(()=>{if(!r)n=e()});return()=>{if(r=!0,typeof n==="function")n()}}function F(e,t){let n=E();if(!n)return()=>{};let r=(o)=>t(o.detail??{});return n.addEventListener(e,r),()=>n.removeEventListener(e,r)}var Ue="native-dialog-styles",zt=`
1
+ import{appReview as sr,biometrics as We,brightness as xe,camera as Re,deepLinks as Bt,device as Z,haptics as Ae,health as ue,heartRate as E,keepAwake as Ft,lifecycle as lr,liveActivities as $e,location as _,music as K,network as Ut,notifications as ke,permissions as de,pushNotifications as Ke,secureStorage as Te,share as Wt,speech as je,snapshots as Ee,splash as cr,watchConnectivity as pe}from"craft-native/mobile";var Nr=2500;function T(){if(typeof window>"u")return;return window}function Q(){let e=T()?.craft;return e&&typeof e==="object"?e:void 0}function Vt(){return typeof navigator>"u"?"":navigator.userAgent||""}function re(){let e=T();if(!e)return!1;if(e.CraftAndroid)return!0;let t=Q()?.platform;if(t==="ios"||t==="android")return!0;return Boolean(e.webkit?.messageHandlers?.craft)&&/iPhone|iPad|iPod/.test(Vt())}function me(){let e=T();if(!e||e.craft)return!1;return re()||Boolean(e.webkit?.messageHandlers?.craft)}function ee(e=15000){let t=T();if(t?.craft)return Promise.resolve(!0);if(!t||!me())return Promise.resolve(!1);return new Promise((n)=>{let r=()=>{clearTimeout(o),t.removeEventListener("craftReady",r),n(Boolean(t.craft))},o=setTimeout(r,e);t.addEventListener("craftReady",r)})}function Gt(e,t){if(!e)return null;let n=t.split("."),r=e;for(let i of n.slice(0,-1))if(r=r?.[i],!r||typeof r!=="object"&&typeof r!=="function")return null;let o=r?.[n[n.length-1]];return typeof o==="function"?o.bind(r):null}function L(e){return Gt(Q(),e)}async function Yt(e,t=2500){let n=L(e);if(n||!me())return n;return await ee(t),L(e)}async function y(e,t,n,r={}){let o=await Yt(e,r.timeoutMs);if(!o)return n();try{return await o(...t)}catch(i){if(r.fallbackOnError)return n();throw i}}async function d(e,t=2500){if(me())await ee(t);return e()}function J(e,t=2500){let n,r=!1;if(!me())n=e();else ee(t).then(()=>{if(!r)n=e()});return()=>{if(r=!0,typeof n==="function")n()}}function U(e,t){let n=T();if(!n)return()=>{};let r=(o)=>t(o.detail??{});return n.addEventListener(e,r),()=>n.removeEventListener(e,r)}var qe="native-dialog-styles",Xt=`
2
2
  .native-dialog { position: fixed; inset: 0; z-index: 2147483000; font-size: var(--native-font-size, 17px); font-family: var(--native-font-family, -apple-system, system-ui, sans-serif); -webkit-tap-highlight-color: transparent; }
3
3
  .native-dialog-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.3); opacity: 0; transition: opacity 220ms ease; }
4
4
  .native-dialog--menu .native-dialog-backdrop { background: rgb(0 0 0 / 0.12); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }
@@ -52,4 +52,4 @@ import{appReview as Zn,biometrics as De,brightness as be,camera as ve,deepLinks
52
52
  .native-dialog-group, .native-menu { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--native-dialog-solid, rgb(242 242 247)); }
53
53
  .dark .native-dialog-group, .dark .native-menu { background: var(--native-dialog-solid-dark, rgb(44 44 46)); }
54
54
  }
55
- `;function Ke(){return E()?.document}function qt(e){if(e.getElementById(Ue))return;let t=e.createElement("style");t.id=Ue,t.textContent=zt,(e.head??e.documentElement).appendChild(t)}var Vt=0;function L(e,t,n,r){let o=e.createElement(t);if(o.className=n,r!==void 0)o.textContent=r;return o}function $e(){return E()?.stx?.overlays}var Gt=0;function je(e,t,n,r){qt(e);let o=E(),i=`native-dialog-layer-${++Gt}`,a=L(e,"div",`native-dialog native-dialog--${t}`);return a.setAttribute("data-native-dialog",t),a.appendChild(L(e,"div","native-dialog-backdrop")),new Promise((s)=>{let l=!1,m=(c)=>{if(l)return;l=!0,a.classList.remove("is-open"),$e()?.close(i),setTimeout(()=>a.remove(),260),s(c)},d=n({root:a,settle:m});a.appendChild(d),e.body.appendChild(a),$e()?.open(i,{panel:d,root:a,onEscape:()=>m(r())});let u=o;(typeof u?.requestAnimationFrame==="function"?(c)=>u.requestAnimationFrame(()=>u.requestAnimationFrame(c)):(c)=>setTimeout(c,16))(()=>{if(!l)a.classList.add("is-open")})})}function ke(e){let t=Ke();if(!t?.body)return Promise.resolve(null);let n=`native-dialog-${++Vt}`,r=e.actions.find((a)=>a.style==="cancel"),o=e.variant==="sheet"?e.actions.filter((a)=>a.style!=="cancel"):e.actions,i=e.variant==="sheet"?r??{id:"__cancel",title:e.cancelLabel||"Cancel",style:"cancel"}:void 0;return je(t,e.variant,({root:a,settle:s})=>{let l=(c)=>c.style==="cancel"?null:c.id,m=L(t,"div","native-dialog-panel");m.setAttribute("role","alertdialog"),m.setAttribute("aria-modal","true"),m.tabIndex=-1;let d=L(t,"div","native-dialog-group");if(e.title||e.message){let c=L(t,"div","native-dialog-header");if(e.title){let f=L(t,"p","native-dialog-title",e.title);f.id=`${n}-title`,c.appendChild(f),m.setAttribute("aria-labelledby",f.id)}if(e.message){let f=L(t,"p","native-dialog-message",e.message);f.id=`${n}-message`,c.appendChild(f),m.setAttribute("aria-describedby",f.id)}d.appendChild(c)}let u=L(t,"div","native-dialog-actions");if(e.variant==="alert"&&o.length===2)u.classList.add("is-row");for(let c of o){let f=L(t,"button",`native-dialog-action${c.style==="destructive"?" is-destructive":""}${c.style==="cancel"?" is-cancel":""}`,c.title);f.type="button",f.setAttribute("data-action-id",c.id),f.addEventListener("click",()=>s(l(c))),u.appendChild(f)}if(d.appendChild(u),m.appendChild(d),i){let c=L(t,"div","native-dialog-group"),f=L(t,"button","native-dialog-action is-cancel",i.title);f.type="button",f.setAttribute("data-action-id",i.id),f.addEventListener("click",()=>s(null)),c.appendChild(f),m.appendChild(c)}let g=a.querySelector(".native-dialog-backdrop");if(e.variant==="sheet")g?.addEventListener("click",()=>s(null));return m},()=>{if(e.variant==="sheet")return null;if(r)return null;return o.length===1?o[0].id:null})}async function ze(e){await ke({variant:"alert",title:e.title,message:e.message,actions:[{id:"ok",title:e.okLabel||"OK"}]})}async function qe(e){return await ke({variant:"alert",title:e.title,message:e.message,actions:[{id:"cancel",title:e.cancelLabel||"Cancel",style:"cancel"},{id:"confirm",title:e.confirmLabel||"OK",style:e.destructive?"destructive":"default"}]})==="confirm"}function Ve(e){return ke({variant:"sheet",title:e.title,message:e.message,actions:e.actions,cancelLabel:e.cancelLabel})}function Yt(e,t,n){let i=Math.max(12,Math.min(e.x,n.width-t.width-12)),a=e.y+e.height+8,s=a+t.height<=n.height-12,l=e.y-8-t.height,m=s||l<12?Math.max(12,Math.min(a,n.height-t.height-12)):l,d=e.x+e.width/2>n.width/2?"right":"left";return{top:m,left:i,origin:`${s||l<12?"top":"bottom"} ${d}`}}function Ge(e){let t=Ke();if(!t?.body)return Promise.resolve(null);let n=E();return je(t,"menu",({root:r,settle:o})=>{let i=L(t,"div","native-menu native-dialog-panel");if(i.setAttribute("role","menu"),e.title)i.appendChild(L(t,"p","native-menu-title",e.title)),i.setAttribute("aria-label",e.title);for(let a of e.items){let s=L(t,"button",`native-menu-item${a.destructive?" is-destructive":""}`);if(s.type="button",s.setAttribute("role","menuitem"),s.setAttribute("data-action-id",a.id),a.disabled)s.disabled=!0;if(s.appendChild(L(t,"span","native-menu-label",a.title)),a.icon){let l=L(t,"i",`native-menu-icon ${a.icon}`);l.setAttribute("aria-hidden","true"),s.appendChild(l)}s.addEventListener("click",()=>o(a.id)),i.appendChild(s)}return r.querySelector(".native-dialog-backdrop")?.addEventListener("click",()=>o(null)),queueMicrotask(()=>{let a=i.getBoundingClientRect?.(),s=Yt(e.anchor,{width:a?.width||248,height:a?.height||e.items.length*44},{width:n?.innerWidth||390,height:n?.innerHeight||844});i.style.top=`${s.top}px`,i.style.left=`${s.left}px`,i.style.setProperty("--native-menu-origin",s.origin)}),i},()=>null)}var Je=()=>!0,M=()=>!1,W=()=>null;function Ye(){return E()?.navigator??(typeof navigator>"u"?void 0:navigator)}function Oe(e){return{x:Math.round(e.x??e.left??0),y:Math.round(e.y??e.top??0),width:Math.round(e.width),height:Math.round(e.height)}}var te={alert:(e)=>v("dialog.alert",[e],()=>ze(e),{fallbackOnError:!0}).then(()=>{}),confirm:(e)=>v("dialog.confirm",[e],()=>qe(e),{fallbackOnError:!0}).then(Boolean),actionSheet:async(e)=>{let t={...e,anchor:e.anchor?Oe(e.anchor):void 0},n=await v("dialog.actionSheet",[t],()=>Ve(e),{fallbackOnError:!0});if(typeof n!=="string")return null;return e.actions.find((r)=>r.id===n)?.style==="cancel"?null:n}};function Cr(){return(e)=>te.actionSheet(e)}async function Mr(e){if((e.style??(e.destructive?"sheet":"alert"))==="alert")return te.confirm(e);return await te.actionSheet({title:e.title,message:e.message,anchor:e.anchor,actions:[{id:"confirm",title:e.confirmLabel||"OK",style:e.destructive?"destructive":"default"},{id:"cancel",title:e.cancelLabel||"Cancel",style:"cancel"}]})==="confirm"}var Pe={show:async(e)=>{let t={title:e.title,anchor:Oe(e.anchor),items:e.items.map(({id:r,title:o,symbol:i,destructive:a,disabled:s})=>({id:r,title:o,symbol:i,destructive:a,disabled:s}))},n=await v("contextMenu.show",[t],()=>Ge(e),{fallbackOnError:!0});return typeof n==="string"?n:null}};function Nr(e,t){return Pe.show({...t,anchor:Oe(e.getBoundingClientRect())})}function Qt(e,t){let n=E();if(!n)return{cancelled:!0};if(typeof n.craft?.openURL==="function")return Promise.resolve(n.craft.openURL(e)).catch(()=>{}),{cancelled:!1};if(t.mode==="auth")return n.location?.assign(e),{cancelled:!1};if(!(typeof n.open==="function"?n.open(e,"_blank","noopener"):null))n.location?.assign(e);return{cancelled:!1}}var Ze={open:async(e,t={})=>{let n=await v("browser.open",[e,t],()=>Qt(e,t),{fallbackOnError:!0});if(!n||typeof n!=="object")return{cancelled:!1};let{url:r,cancelled:o}=n;return typeof r==="string"?{url:r,cancelled:Boolean(o)}:{cancelled:Boolean(o)}}},Ee=new Map,Te=new Map;function Qe(e,t){return`${e}|${t.pointSize??""}|${t.weight??""}|${t.color??""}|${t.scale??""}`}var et={isAvailable:()=>I("symbols.image")!==null,image:(e,t={})=>{let n=Qe(e,t),r=Ee.get(n);if(r)return r;let o=v("symbols.image",[e,t],W).then((i)=>typeof i==="string"&&i.startsWith("data:")?i:null,W).then((i)=>(Te.set(n,i),i));return Ee.set(n,o),o},cached:(e,t={})=>Te.get(Qe(e,t)),clearCache:()=>{Ee.clear(),Te.clear()}},de={setStyle:(e)=>v("statusBar.setStyle",[e],M,{fallbackOnError:!0}).then((t)=>t!==!1)},ne={setUnderPageColor:(e)=>v("chrome.setUnderPageColor",[e],M,{fallbackOnError:!0}).then((t)=>t!==!1),setKeyboardAccessory:(e)=>v("chrome.setKeyboardAccessory",[e],M,{fallbackOnError:!0}).then((t)=>t!==!1)},j={isAvailable:()=>I("refresh.enable")!==null,enable:(e)=>v("refresh.enable",[e??{}],M,{fallbackOnError:!0}).then((t)=>t!==!1),disable:()=>v("refresh.disable",[],M,{fallbackOnError:!0}).then((e)=>e!==!1),end:()=>v("refresh.end",[],M,{fallbackOnError:!0}).then((e)=>e!==!1),onRefresh:(e)=>F("craftRefresh",()=>e())},re={complete:(e)=>v("background.complete",[e],M,{fallbackOnError:!0}).then((t)=>t!==!1)},tt={write:(e)=>v("clipboard.write",[e],async()=>{let t=Ye()?.clipboard;if(!t?.writeText)return!1;return t.writeText(e).then(Je,M)},{fallbackOnError:!0}).then((t)=>t!==!1),read:()=>v("clipboard.read",[],async()=>{let e=Ye()?.clipboard;if(!e?.readText)return null;return e.readText().catch(W)},{fallbackOnError:!0}).then((e)=>typeof e==="string"?e:null)},nt={isAvailable:()=>I("db.query")!==null,query:(e,t=[])=>v("db.query",[e,t],W).then((n)=>Array.isArray(n)?n:null),execute:(e,t=[])=>v("db.execute",[e,t],W).then((n)=>{if(!n||typeof n!=="object")return null;let{rowsAffected:r,lastInsertId:o}=n;return{rowsAffected:Number(r)||0,lastInsertId:Number(o)||0}})};function Ie(e,t){let n=E()?.document;if(!n?.body)return null;let r=n.createElement("a");return r.href=e,r.download=t,r.rel="noopener",r.style.display="none",n.body.appendChild(r),r.click(),r.remove(),t}function Xt(e){let t=E()?.document;if(!t?.body)return Promise.resolve(null);return new Promise((n)=>{let r=t.createElement("input");if(r.type="file",r.style.display="none",e.length)r.accept=e.map((i)=>i.includes("/")||i.startsWith(".")?i:`.${i}`).join(",");let o=(i)=>{r.remove(),n(i)};r.addEventListener("cancel",()=>o(null)),r.addEventListener("change",()=>{let i=r.files?.[0];if(!i)return o(null);let a=new FileReader;a.onload=()=>o({name:i.name,mimeType:i.type||void 0,data:typeof a.result==="string"?a.result:void 0}),a.onerror=()=>o({name:i.name,mimeType:i.type||void 0}),a.readAsDataURL(i)}),t.body.appendChild(r),r.click()})}var rt={openPDF:(e,t=0)=>v("openPDF",[e,t],()=>{let n=E();return Boolean(n?.open?.(e,"_blank","noopener"))}).then((n)=>n!==!1),takeScreenshot:()=>v("takeScreenshot",[],W,{fallbackOnError:!0}).then((e)=>typeof e==="string"?e:null),scanQRCode:()=>v("scanQRCode",[],W).then((e)=>{if(!e||typeof e!=="object")return null;let{type:t,data:n}=e;return typeof n==="string"?{type:String(t??""),data:n}:null},W),pickFile:(e=[])=>v("pickFile",[e],()=>Xt(e)).then((t)=>{if(!t||typeof t!=="object")return null;let n=t;if(typeof n.name!=="string")return null;return{name:n.name,path:typeof n.path==="string"?n.path:void 0,data:typeof n.data==="string"?n.data:void 0,mimeType:typeof n.mimeType==="string"?n.mimeType:void 0}},W),saveFile:(e,t,n)=>v("saveFile",[e,t,n],()=>{if(e.startsWith("data:"))return Ie(e,t);let r=new Blob([e],{type:n||"text/plain"}),o=URL.createObjectURL(r),i=Ie(o,t);return setTimeout(()=>URL.revokeObjectURL(o),1000),i}).then((r)=>typeof r==="string"?r:null),downloadFile:(e,t)=>v("downloadFile",[e,t],()=>Ie(e,t)).then((n)=>typeof n==="string"?n:null)},ot={set:(e)=>v("shortcuts.set",[e.map(({symbol:t,...n})=>t?{...n,iconName:t}:n)],M).then((t)=>t!==!1),clear:()=>v("shortcuts.clear",[],M).then((e)=>e!==!1),onShortcut:(e)=>F("craftShortcut",(t)=>{if(typeof t.type==="string")e(t.type)})},it={update:(e)=>v("widget.update",[e],M).then((t)=>t!==!1),reload:()=>v("widget.reload",[],M).then((e)=>e!==!1)},Jt={portrait:"portrait-primary",portraitUpsideDown:"portrait-secondary",landscape:"landscape",landscapeLeft:"landscape-primary",landscapeRight:"landscape-secondary"};function Xe(){return E()?.screen?.orientation}var at={lock:(e)=>v("lockOrientation",[e],()=>{let t=Xe();return t?.lock?t.lock(Jt[e]).then(Je,M):!1}).then((t)=>t!==!1),unlock:()=>v("unlockOrientation",[],()=>(Xe()?.unlock?.(),!0)).then((e)=>e!==!1)},st={signInWithApple:(e={})=>v("signInWithApple",e.nonce?[{nonce:e.nonce}]:[],W).then((t)=>{if(!t||typeof t!=="object"||typeof t.userId!=="string")return null;return t})},lt={isAvailable:()=>I("iap.purchase")!==null,products:(e)=>v("iap.getProducts",[e],()=>[]).then((t)=>Array.isArray(t)?t:[]),purchase:(e)=>v("iap.purchase",[e],W).then((t)=>t&&typeof t==="object"?t:null,(t)=>{if(/cancel/i.test(String(t?.message??t)))return null;throw t}),restore:()=>v("iap.restore",[],()=>[]).then((e)=>Array.isArray(e)?e:[])};import{storage as K}from"craft-native/mobile";function ct(){return G()?.capabilities?.storageCompareAndSet===!0&&K.supportsCompareAndSet?.()===!0}function ut(){return G()?.capabilities?.storageSetIfAbsent===!0&&K.supportsSetIfAbsent?.()===!0}var dt={supportsCompareAndSet:ct,supportsSetIfAbsent:ut,get:(e)=>p(()=>K.get(e)),set:(e,t)=>p(()=>K.set(e,t)),remove:(e)=>p(()=>K.remove(e)),clear:()=>p(()=>K.clear()),keys:()=>p(()=>K.keys()),setIfAbsent:(e,t)=>p(()=>{if(!ut())throw Object.assign(Error("This host or adapter cannot create storage atomically"),{code:"STORAGE_SET_IF_ABSENT_UNSUPPORTED"});return K.setIfAbsent(e,t)}),compareAndSet:(e,t,n)=>p(()=>{if(!ct())throw Object.assign(Error("This host or adapter cannot compare storage atomically"),{code:"STORAGE_COMPARE_AND_SET_UNSUPPORTED"});return K.compareAndSet(e,t,n)})};import{crypto as Zt}from"craft-native/mobile";var pt={randomUUID:()=>p(()=>Zt.randomUUID())};var en=["authorized","denied","notDetermined","restricted","unsupported"];function pe(){let e=G(),t=e?.scheduledWorkouts;if(!t||typeof t!=="object"||e?.capabilities?.scheduledWorkouts!==!0)return;return t}function tn(){return Object.assign(Error("unsupported"),{code:"UNSUPPORTED"})}function ft(e){return en.includes(e)?e:"unsupported"}function nn(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.id!=="string"||!t.id||typeof t.date!=="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t.date))return null;let n={id:t.id.toLowerCase(),date:t.date,complete:t.complete===!0};if(typeof t.hour==="number"&&Number.isFinite(t.hour))n.hour=t.hour;if(typeof t.minute==="number"&&Number.isFinite(t.minute))n.minute=t.minute;return n}function J(e,t,...n){return p(async()=>{let r=pe();if(typeof r?.[e]!=="function")throw tn();return t(await r[e](...n))})}var mt={isAvailable:()=>typeof pe()?.isSupported==="function",supports:(e)=>typeof pe()?.[e]==="function",isSupported:()=>p(async()=>{let e=pe();if(typeof e?.isSupported!=="function")return!1;try{return await e.isSupported()===!0}catch{return!1}}),authorization:()=>J("authorization",ft),requestAuthorization:()=>J("requestAuthorization",ft),list:()=>J("list",(e)=>Array.isArray(e)?e.map(nn).filter((t)=>t!==null):[]),schedule:(e)=>{if(!e||typeof e!=="object"||typeof e.id!=="string")return Promise.reject(Object.assign(Error("schedule needs a plan with an id"),{code:"INVALID_ARGUMENT"}));return J("schedule",(t)=>{let n=t&&typeof t==="object"?t:{},r={id:(typeof n.id==="string"?n.id:e.id).toLowerCase()};if(Array.isArray(n.droppedAlerts)&&n.droppedAlerts.length)r.droppedAlerts=n.droppedAlerts.filter((o)=>typeof o==="string");return r},e)},remove:(e)=>J("remove",(t)=>t===!0,e),removeAll:()=>J("removeAll",(e)=>typeof e==="number"&&Number.isFinite(e)?e:0)};function zr(e,t){let n=t.delay??500,r=t.tolerance??10,o=null,i=null,a=!1,s=()=>{if(o)clearTimeout(o);if(o=null,i&&!a)t.onPressEnd?.();i=null},l=(g)=>{let c=g;if(c.button!==void 0&&c.button!==0)return;a=!1,i={x:c.clientX,y:c.clientY},t.onPressStart?.(),o=setTimeout(()=>{if(o=null,!i)return;a=!0,t.onLongPress({...i}),i=null},n)},m=(g)=>{if(!i)return;let c=g;if(Math.hypot(c.clientX-i.x,c.clientY-i.y)>r)s()},d=(g)=>{if(!a)return;a=!1,g.preventDefault(),g.stopPropagation()},u=(g)=>g.preventDefault();return e.addEventListener("pointerdown",l),e.addEventListener("pointermove",m),e.addEventListener("pointerup",s),e.addEventListener("pointercancel",s),e.addEventListener("pointerleave",s),e.addEventListener("click",d,!0),e.addEventListener("contextmenu",u),()=>{s(),e.removeEventListener("pointerdown",l),e.removeEventListener("pointermove",m),e.removeEventListener("pointerup",s),e.removeEventListener("pointercancel",s),e.removeEventListener("pointerleave",s),e.removeEventListener("click",d,!0),e.removeEventListener("contextmenu",u)}}function rn(e,t,n){if(n<=1||t.width<=0)return 0;let r=Math.floor((e-t.left)/t.width*n);return Math.max(0,Math.min(n-1,r))}function qr(e,t){let n=null,r=null,o=!1,i=0,a=(c)=>{let f=e.getBoundingClientRect();return rn(c,{left:f.left+2,width:f.width-4},t.count())},s=(c)=>{let f=c;if(f.button!==void 0&&f.button!==0)return;let h=a(f.clientX);if(h!==t.selected())return;n=h,i=h,o=!1,r=f.pointerId;try{e.setPointerCapture?.(f.pointerId)}catch{}t.onPress?.(!0)},l=(c)=>{if(n===null)return;let f=a(c.clientX);if(f===i)return;o=!0,i=f,t.onScrub(f)},m=(c)=>{if(n===null)return;if(r!==null)try{e.releasePointerCapture?.(r)}catch{}if(t.onPress?.(!1),c&&o)t.onCommit(i);else if(o)t.onScrub(n);n=null,r=null},d=(c)=>{if(!o)return;o=!1,c.preventDefault(),c.stopPropagation()},u=()=>m(!0),g=()=>m(!1);return e.addEventListener("pointerdown",s),e.addEventListener("pointermove",l),e.addEventListener("pointerup",u),e.addEventListener("pointercancel",g),e.addEventListener("click",d,!0),()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("pointermove",l),e.removeEventListener("pointerup",u),e.removeEventListener("pointercancel",g),e.removeEventListener("click",d,!0)}}function Vr(e,t,n){if(n<=0)return null;switch(e){case"ArrowRight":case"ArrowDown":return(t+1)%n;case"ArrowLeft":case"ArrowUp":return(t-1+n)%n;case"Home":return 0;case"End":return n-1;default:return null}}function Gr(e,t){e.querySelectorAll('[role="tab"]')[t]?.focus()}function Yr(e){let t=(n)=>{if(!n.target?.closest?.("[data-native-pressable]"))return;let o=I("haptics.prepare");if(o)Promise.resolve().then(()=>o("impact")).catch(()=>{})};return e.addEventListener("touchstart",t,{passive:!0,capture:!0}),()=>e.removeEventListener("touchstart",t,{capture:!0})}import{BugHQClient as on}from"@bughq/sdk";import{crashReporter as Z}from"craft-native/mobile";var H=null;function an(e){if(e.type!=="http")return!0;let t=e.data??{},n=typeof t.status==="number"?t.status:0;return t.error===!0||n>=400||n===0}function gt(){return Z.isAvailable()}function sn(e){return async(t)=>{if(!gt())return!e;return Z.capture(t)}}var eo={start(e={}){if(H)return H;let t=ee()||gt();if(!t&&!e.key&&!e.dsn)return null;let n=e.beforeBreadcrumb;return H=new on({framework:"stacks-mobile",sdkName:"bughq.stacks.mobile",autoInstrument:{navigation:!0,fetch:!0,xhr:!0},...e,heartbeat:t?!1:e.heartbeat,transport:t?sn(Boolean(e.key||e.dsn)):void 0,beforeBreadcrumb(r){if(!an(r))return null;let o=n?n(r):r;if(o===null)return null;let i=o||r;if(t)Z.addBreadcrumb(i);return i}}),H},async setUser(e){let t=e===null||e===void 0||e===""?null:String(e);H?.setUser(t===null?null:{id:t}),await Z.setUser(t)},capture(e,t){H?.captureException(e,t)},addBreadcrumb(e){if(H)H.addBreadcrumb(e);else Z.addBreadcrumb(e)},async flush(){await Promise.all([H?.flush(),Z.flush()])},client(){return H},stop(){H?.close(),H=null}};function Le(e){let t=E();try{return Boolean(t?.matchMedia?.(e).matches)}catch{return!1}}function ht(e){return e!==null&&e!==void 0&&e!=="false"&&e!=="0"}function bt(){let e=E()?.document?.documentElement,t=Number.parseFloat(e?.style?.getPropertyValue("--craft-font-scale")||"");return{fontScale:Number.isFinite(t)&&t>0?t:1,reduceMotion:ht(e?.getAttribute("data-craft-reduce-motion"))||Le("(prefers-reduced-motion: reduce)"),reduceTransparency:ht(e?.getAttribute("data-craft-reduce-transparency"))||Le("(prefers-reduced-transparency: reduce)"),colorScheme:e?.classList?.contains("dark")||Le("(prefers-color-scheme: dark)")?"dark":"light"}}function ln(e){let t=bt(),n=Number(e?.fontScale);return{contentSizeCategory:typeof e?.contentSizeCategory==="string"?e.contentSizeCategory:void 0,fontScale:Number.isFinite(n)&&n>0?n:t.fontScale,reduceMotion:typeof e?.reduceMotion==="boolean"?e.reduceMotion:t.reduceMotion,reduceTransparency:typeof e?.reduceTransparency==="boolean"?e.reduceTransparency:t.reduceTransparency,colorScheme:e?.colorScheme==="dark"||e?.colorScheme==="light"?e.colorScheme:t.colorScheme}}function vt(e,t={}){if(t.immediate!==!1)e(bt());return F("craftAppearance",(n)=>e(ln(n)))}function oo(e){return F("craftResume",(t)=>e({backgroundedMs:Number(t.backgroundedMs)||0}))}function io(e){return F("craftMemoryWarning",()=>e())}function yt(e){return(t)=>{Promise.resolve().then(()=>e(t)).then(()=>re.complete(!0),()=>re.complete(!1))}}function ao(e){let t=yt(e);return F("craftSilentPush",(n)=>t(n.payload??{}))}function so(e){let t=yt(()=>e());return F("craftBackgroundRefresh",()=>t(void 0))}import{haptics as cn}from"craft-native/mobile";function Ce(){if(typeof window>"u")return;return window}function oe(e=Ce()){if(!e)return 0;if(typeof e.scrollY==="number")return e.scrollY;if(typeof e.scrollTop==="number")return e.scrollTop;return e.document?.scrollingElement?.scrollTop??0}function un(e,t=Ce()){if(!t)return()=>{};let n=!1,r=typeof requestAnimationFrame==="function"?requestAnimationFrame:(i)=>setTimeout(i,16),o=()=>{if(n)return;n=!0,r(()=>{n=!1,e(oe(t))})};return e(oe(t)),t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)}function dn(e,t){let n=Math.max(0,-e),r=e<=0?Math.max(0,t)*0.5:0;return Math.round(Math.max(n,r))}function uo(e){let t=e.host??Ce();if(!t)return()=>{};let n=e.threshold??72,r=null,o=!1,i=!1,a=typeof requestAnimationFrame==="function"?requestAnimationFrame:(h)=>setTimeout(h,16),s=null,l=(h)=>{s=null,e.onPull?.(h,o,{bounce:Math.min(h,Math.max(0,-oe(t)))})},m=(h)=>{let w=s!==null;if(s=h,w)return;a(()=>{if(s!==null)l(s)})},d=(h)=>{let w=h.touches?.[0];return w?w.clientY:null},u=(h)=>{if(i||oe(t)>0)return;r=d(h),o=!1},g=(h)=>{if(r===null)return;let w=d(h);if(w===null)return;let k=dn(oe(t),w-r);if(!o&&k>=n)o=!0,Promise.resolve(cn.impact("medium")).catch(()=>{});else if(o&&k<n*0.8)o=!1;m(k)},c=async()=>{if(r===null)return;if(r=null,!o){l(0);return}o=!1,i=!0,l(n);try{await e.onRefresh()}finally{i=!1,l(0)}},f=()=>{if(r===null)return;r=null,o=!1,l(0)};return t.addEventListener("touchstart",u,{passive:!0}),t.addEventListener("touchmove",g,{passive:!0}),t.addEventListener("touchend",c),t.addEventListener("touchcancel",f),()=>{s=null,t.removeEventListener("touchstart",u),t.removeEventListener("touchmove",g),t.removeEventListener("touchend",c),t.removeEventListener("touchcancel",f)}}function pn(e,t=52){let n=Math.max(1,t),r=Math.min(1,Math.max(0,e/n)),o=e<0?1+Math.min(0.1,-e/600):1;return{progress:Math.round(r*1000)/1000,stretch:Math.round(o*1000)/1000}}function po(e,t={}){let n="",r=()=>t.title?.offsetHeight||t.height||52;return un((o)=>{let i=pn(o,r()),a=`${i.progress}|${i.stretch}`;if(a===n)return;n=a,e.style.setProperty("--native-nav-progress",String(i.progress)),e.style.setProperty("--native-nav-stretch",String(i.stretch)),t.onChange?.(i)},t.host)}function fo(e){if(!e||typeof window>"u")return;let t=window.document?.querySelector(e);return t?t:void 0}function xt(){if(typeof window>"u")return;return window}var St="__stxPushed",fn="__stxScroll";function mn(e=xt()){let t=e?.history?.state;if(t===null||t===void 0)return!1;if(typeof t!=="object")return!0;let n=t;if(St in n)return n[St]===!0;return!(fn in n)}function go(e=xt()){if(!mn(e))return!1;return e.history.back(),!0}function ho(e,t,n=50){let r=e[e.length-1];if(e.length>=2&&e[e.length-2].path===t)e.pop();else if(!r||r.path!==t)e.push({path:t,title:""});if(e.length>n)e.splice(0,e.length-n);return{current:e[e.length-1],previous:e[e.length-2]??null}}function bo(e,t,n=12){let r=e?.title.trim()??"";return r&&r.length<=n?r:t}function vo(){if(typeof window>"u")return[];let e=window;return e.__stacksNavTrail??=[]}function gn(e){try{let t=new URL(e,"http://local");return`${t.pathname}${t.search}`}catch{return e}}function yo(){if(typeof window>"u")return;let e=window.stxRouter;if(typeof e?.screens!=="function")return;let t=e.screens(),n=t.find((o)=>o.active);if(!n)return;let r=t.filter((o)=>o.tab===n.tab&&o.depth<n.depth);if(!r.length)return null;return gn(r.reduce((o,i)=>i.depth>o.depth?i:o).url)}function So(e=typeof window>"u"?void 0:window){let t=e?.stxRouter;if(typeof t?.screens!=="function"||typeof e?.history?.go!=="function")return!1;let n=t.screens(),r=n.find((a)=>a.active);if(!r)return!1;let o=n.filter((a)=>a.tab===r.tab&&a.depth<r.depth);if(!o.length)return!1;let i=o.reduce((a,s)=>s.depth<a.depth?s:a);return e.history.go(i.depth-r.depth),!0}function wo(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].path===t)return e[n];return null}function hn(e,t=bn()){let n;try{n=new URL(e)}catch{return null}let r=`${n.search}${n.hash}`;if(n.protocol==="http:"||n.protocol==="https:"){if(!t||n.origin!==t)return null;return`${n.pathname||"/"}${r}`}return`${`/${[n.host,n.pathname.replace(/^\/+/,"")].filter(Boolean).join("/")}`}${r}`}function bn(){if(typeof window>"u")return;return window.location?.origin}var wt="stacks-mobile-deep-link";function xo(e,t){let n=(r)=>{let o=hn(r);if(o)e(o)};return t.getInitialURL().then((r)=>{if(!r)return;try{if(sessionStorage.getItem(wt)===r)return;sessionStorage.setItem(wt,r)}catch{}n(r)}).catch(()=>{}),t.onLink((r,o)=>{if(o?.initial)return;n(r)})}var Ao=5000;function vn(e,t,n=5000){let r=t.filter((o)=>Number.isFinite(o.timestamp)&&Number.isFinite(o.bpm)&&o.bpm>0).slice().sort((o,i)=>o.timestamp-i.timestamp);if(!r.length)return e.slice();return e.map((o)=>{let i=0,a=r.length;while(i<a){let d=i+a>>1;if(r[d].timestamp<o.timestamp)i=d+1;else a=d}let s=r[i],l=r[i-1],m=!s?l:!l?s:o.timestamp-l.timestamp<=s.timestamp-o.timestamp?l:s;if(!m||Math.abs(m.timestamp-o.timestamp)>n)return o;return{...o,heartRate:Math.round(m.bpm)}})}var yn=6371008.8,Sn=30,wn=Sn;function xn(e,t){let n=Math.PI/180,r=(t.latitude-e.latitude)*n,o=(t.longitude-e.longitude)*n,i=Math.sin(r/2)**2+Math.cos(e.latitude*n)*Math.cos(t.latitude*n)*Math.sin(o/2)**2;return 2*yn*Math.asin(Math.min(1,Math.sqrt(i)))}function Rn(e,t=25){let n=new Set;return e.filter((r)=>Number.isFinite(r.latitude)&&Number.isFinite(r.longitude)&&Number.isFinite(r.timestamp)&&Math.abs(r.latitude)<=90&&Math.abs(r.longitude)<=180&&Number.isFinite(r.accuracy)&&r.accuracy>=0&&r.accuracy<=t).sort((r,o)=>r.timestamp-o.timestamp).filter((r)=>{if(n.has(r.timestamp))return!1;return n.add(r.timestamp),!0})}function Me(e,t={}){let n=Rn(e,t.maxAccuracyM??25),r=t.paceWindowS??30,o=[],i=0,a=0,s=null;for(let u of n){let g=o[o.length-1],c=s?(u.timestamp-s.timestamp)/1000:0;if(s=u,!g){o.push({fix:u,cumM:0});continue}if(c>wn){o.push({fix:u,cumM:i});continue}let f=(u.timestamp-g.fix.timestamp)/1000,h=xn(g.fix,u),w=Math.min(10,Math.max(3,g.fix.accuracy,u.accuracy));if(h<w)continue;if(i+=h,f>0&&h/f>=0.5)a+=f;o.push({fix:u,cumM:i})}let l=o[o.length-1],m=null,d=null;if(l&&n.at(-1).timestamp-l.fix.timestamp<=r*1000){let u=l.fix.timestamp-r*1000,g=o.find((h)=>h.fix.timestamp>=u)??l,c=l.cumM-g.cumM,f=(l.fix.timestamp-g.fix.timestamp)/1000;if(c>=20&&f>0)d=c/f,m=f/(c/1000)}return{distanceM:i,movingS:a,paceSPerKm:m,averagePaceSPerKm:i>=50&&a>0?a/(i/1000):null,speedMps:d,accuracyM:n.length?n[n.length-1].accuracy:e.length?e[e.length-1].accuracy??null:null,fixes:n.length}}function ko(e){if(e==null||e<=0||!Number.isFinite(e)||e>3600)return"–";let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Eo(e){return e!=null&&e>0&&Number.isFinite(e)?(e*3.6).toFixed(1):"–"}var Rt={distanceM:0,movingS:0,paceSPerKm:null,averagePaceSPerKm:null,speedMps:null,accuracyM:null,fixes:0};function To(e){let t=e.location,n=e.intervalMs??3000,r=Rt,o=null,i=e.heartRate,a=!1,s=null,l=[],m=()=>typeof document<"u"&&document.visibilityState==="hidden",d=0,u=null,g=Promise.resolve(),c=null,f=!1,h=null;function w(){if(f)throw Object.assign(Error("The recording screen is no longer active"),{code:"RECORDING_CONFLICT"});if(t.supportsRecordingOwnership?.()!==!0)throw Object.assign(Error("This host cannot protect native recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"})}function k(){if(w(),!h)throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});return h}function B(b){let S=g.then(b);return g=S.then(()=>{},()=>{}),S}function O(){if(u)return u;let b=d,S=h,P=(async()=>{if(w(),!S)throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});let C=await t.readRecording({expectedId:S}),N=Me(C,e);if(b===d&&!f)r=N,e.onUpdate?.(r);return N})().finally(()=>{if(u===P)u=null});return u=P,P}function y(){if(x(),f)return;o=setInterval(()=>{if(!m())O().catch(()=>{})},n)}function x(){if(o)clearInterval(o);o=null}function A(b,S,P){if(x(),d++,u=null,h=b,s=S,a=S!==null,l=[],r=P,!f)e.onUpdate?.(r)}async function R(b){if(!i||!a||!s||f||i.supportsRecordingOwnership?.()!==!0)return;await b(i,s).catch(()=>{})}return{get stats(){return r},get recordingId(){return h},get heartRateRecordingId(){return s},get heartRate(){return l},start(b){return c=null,B(async()=>{if(w(),b&&t.supportsRecordingIntentIdentity?.()!==!0)throw Object.assign(Error("This host cannot start a registered route identity"),{code:"RECORDING_INTENT_IDENTITY_UNSUPPORTED"});if(b&&(typeof b.recordingId!=="string"||!b.recordingId.trim()))throw Object.assign(Error("A registered recording ID is required"),{code:"INVALID_ARGUMENT"});let S=await t.startRecording({enableHighAccuracy:!0,...e.locationOptions,...b?{recordingId:b.recordingId}:{}});if(!S?.active||typeof S.id!=="string"||!S.id.trim())throw Object.assign(Error("The native recording did not provide an ID"),{code:"RECORDING_CONFLICT"});if(b&&S.id!==b.recordingId)throw Object.assign(Error("The native route did not start with its registered ID"),{code:"RECORDING_CONFLICT"});let P=null;if(!f&&i?.isAvailable()&&i.supportsRecordingOwnership?.()===!0&&(!b||b.heartRateRecordingId&&i.supportsRecordingIntentIdentity?.()===!0))try{let C=await i.startRecording(b?{recordingId:b.heartRateRecordingId}:void 0);if(b&&C.id!==b.heartRateRecordingId)throw Object.assign(Error("The native heart rate did not start with its registered ID"),{code:"RECORDING_CONFLICT"});if(C.active&&typeof C.id==="string"&&C.id.trim())P=C.id}catch{}return A(S.id,P,{...Rt}),y(),r})},attach(b){return c=null,B(async()=>{if(typeof b?.expectedId!=="string"||!b.expectedId.trim())throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});w();let S=await t.getRecordingState({expectedId:b.expectedId});if(w(),!S?.id)return null;if(S.id!==b.expectedId)throw Object.assign(Error("The recording belongs to another session"),{code:"RECORDING_CONFLICT"});let P=null;if(b.expectedHeartRateId!==void 0){let N=b.expectedHeartRateId;if(typeof N!=="string"||!N.trim())throw Object.assign(Error("A saved heart-rate recording ID is required"),{code:"RECORDING_CONFLICT"});if(!i?.isAvailable()||i.supportsRecordingOwnership?.()!==!0)throw Object.assign(Error("This host cannot protect heart-rate recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"});let Ut=await i.getRecordingState({expectedId:N});if(w(),Ut.id!==N)throw Object.assign(Error("The heart-rate recording belongs to another session"),{code:"RECORDING_CONFLICT"});await i.readRecording({expectedId:N,since:Date.now()}),w(),P=N}let C=await t.readRecording({expectedId:b.expectedId});if(w(),A(b.expectedId,P,Me(C,e)),S.active&&!S.paused)y();return S})},pause(){return B(async()=>{await t.pauseRecording({expectedId:k()}),await R((b,S)=>b.pauseRecording({expectedId:S})),x(),await O().catch(()=>{})})},resume(){return B(async()=>{await t.resumeRecording({expectedId:k()}),await R((b,S)=>b.resumeRecording({expectedId:S})),y()})},stop(){if(c)return c;let b=B(async()=>{x(),d++;let S=k(),P=await t.stopRecording({expectedId:S});if(P.id!==S)throw Object.assign(Error("The native recording identity changed"),{code:"RECORDING_CONFLICT"});let C=P?.locations??[];if(!f&&i&&a&&s&&i.supportsRecordingOwnership?.()===!0){let N=await i.stopRecording({expectedId:s}).catch(()=>null);a=!1,l=N?.id===s?N.samples:[],C=vn(C,l)}if(r=Me(C,e),!f)e.onUpdate?.(r);return C}).catch((S)=>{if(c===b)c=null;throw S});return c=b,b},dispose(){f=!0,d++,u=null,x()},refresh:O}}function Oo(e){return{startedAt:Number.isFinite(e)?e:null,pausedAt:null,pausedMs:0}}function Po(e,t){return e.startedAt===null||e.pausedAt!==null||!Number.isFinite(t)?e:{...e,pausedAt:Math.max(e.startedAt,t)}}function Lo(e,t){return e.pausedAt===null||!Number.isFinite(t)?e:{...e,pausedAt:null,pausedMs:e.pausedMs+Math.max(0,t-e.pausedAt)}}function Co(e,t){if(e.startedAt===null)return 0;let n=((e.pausedAt??t)-e.startedAt-e.pausedMs)/1000;return Number.isFinite(n)?Math.max(0,n):0}var No=150;function An(e,t){let n=Math.PI/180,r=(t.latitude-e.latitude)*n,o=(t.longitude-e.longitude)*n,i=Math.sin(r/2)**2+Math.cos(e.latitude*n)*Math.cos(t.latitude*n)*Math.sin(o/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(i)))}function fe(e,t){let n=[...e].sort((r,o)=>r-o);return n[Math.min(n.length-1,Math.floor(t*n.length))]}function Ho(e,t){let n=(e||[]).filter((a)=>Number.isFinite(a?.latitude)&&Number.isFinite(a?.longitude)&&Math.abs(a.latitude)<=90&&Math.abs(a.longitude)<=180),r=n.filter((a)=>a.accuracy!=null).map((a)=>Number(a.accuracy)).filter((a)=>Number.isFinite(a)&&a>=0),o=r.length?fe(r,0.5):Number.POSITIVE_INFINITY,i=0;if(n.length){let a={latitude:fe(n.map((s)=>s.latitude),0.5),longitude:fe(n.map((s)=>s.longitude),0.5)};i=fe(n.map((s)=>An(a,s)),0.8)}if(n.length>=10&&i>150&&o<=15)return"outside";if(t<150)return"unsure";if(n.length<3||o>30||i<25)return"indoors";if(i<50&&o>10)return"indoors";return"unsure"}function Do(e,t={}){let r=String(e||"").trim().toLowerCase().replace(",",".").match(/^(\d+(?:\.\d*)?|\.\d+)\s*(km|k|m|mi)?$/);if(!r)return null;let o=Number(r[1]),i=r[2]||t.defaultUnit||(o>100?"m":"km"),a=i==="m"?o/1000:i==="mi"?o*1.609344:o;return Number.isFinite(a)&&a>=0&&a<=2000?Math.round(a*1000)/1000:null}var he=new Set,At=!1,me=null;function kn(e){return e.isConnected&&e.getClientRects().length>0}function kt(){return[...he].find((e)=>kn(e.element))}function ge(){let e=kt(),t=Boolean(e);if(t===At)return;if(At=t,t)j.enable(e?.tintColor?{tintColor:e.tintColor}:{});else j.disable()}function En(){let e=kt();if(!e){j.end();return}Promise.resolve().then(()=>e.run()).catch(()=>{}).finally(()=>j.end())}function Fo(e,t){let n={element:e,tintColor:t.tintColor,run:t.onRefresh};he.add(n);let r=e.ownerDocument?.defaultView;if(!me){let o=j.onRefresh(En),i=()=>ge();r?.addEventListener("stx:load",i),me=()=>{o(),r?.removeEventListener("stx:load",i)}}return ge(),r?.requestAnimationFrame?.(()=>ge()),()=>{if(he.delete(n),he.size===0)me?.(),me=null;ge()}}var Uo=0.5;function Tn(e,t,n){let r=[];if(n.includes("large")||n.length===0)r.push({name:"large",y:0});if(n.includes("medium"))r.push({name:"medium",y:Math.max(0,Math.round(e-t*0.5))});return r.push({name:"dismiss",y:Math.max(1,e)}),r.sort((o,i)=>o.y-i.y)}function In(e){let{y:t,velocity:n,stops:r}=e,o=r.filter((s)=>s.name!=="dismiss"),i=r.find((s)=>s.name==="dismiss");if(o.length===0)return"dismiss";if(n>0.5)return(r.filter((l)=>l.y>t+1)[0]??i).name;if(n<-0.5){let s=o.filter((l)=>l.y<t-1);return(s[s.length-1]??o[0]).name}let a=o[o.length-1];if(t>a.y+(i.y-a.y)*0.5)return"dismiss";return o.reduce((s,l)=>Math.abs(l.y-t)<Math.abs(s.y-t)?l:s).name}function On(e,t=400){if(e<=0)return 0;return e*t*0.55/(t+e*0.55)}function $o(e){let{panel:t}=e,n=null,r=[],o=0,i=()=>e.viewport?.()??t.ownerDocument?.defaultView?.innerHeight??800,a=()=>Tn(t.offsetHeight||t.getBoundingClientRect().height,i(),e.detents()),s=(d)=>{let u=d;if(u.button!==void 0&&u.button!==0)return;if(u.target?.closest?.("button, a, input, select, textarea, [role=button]"))return;let g=a().find((c)=>c.name===e.detent())?.y??0;n={y:u.clientY,base:g,pointerId:u.pointerId},o=g,r=[{y:g,t:u.timeStamp}],t.classList.add("is-dragging");try{d.currentTarget?.setPointerCapture?.(u.pointerId)}catch{}},l=(d)=>{if(!n)return;let u=d,g=n.base+u.clientY-n.y;o=g<0?-On(-g):g,r.push({y:o,t:u.timeStamp});while(r.length>2&&u.timeStamp-r[0].t>100)r.shift();t.style.transform=`translateY(${o}px)`;let c=t.offsetHeight||1;t.parentElement?.style.setProperty("--native-sheet-presence",String(Math.max(0,Math.min(1,1-o/c))))},m=(d)=>{if(!n)return;let u=d;n=null;let g=r[0],c=Math.max(1,u.timeStamp-g.t),f=(o-g.y)/c;t.classList.remove("is-dragging"),t.style.transform="",t.parentElement?.style.removeProperty("--native-sheet-presence"),e.onSettle(In({y:o,velocity:f,stops:a()}))};for(let d of e.handles)d.addEventListener("pointerdown",s),d.addEventListener("pointermove",l),d.addEventListener("pointerup",m),d.addEventListener("pointercancel",m);return()=>{for(let d of e.handles)d.removeEventListener("pointerdown",s),d.removeEventListener("pointermove",l),d.removeEventListener("pointerup",m),d.removeEventListener("pointercancel",m)}}function Ko(e){let t=e.ownerDocument;if(e.parentElement===t.body)return()=>{};let n=t.createComment("native-sheet");return e.parentNode?.insertBefore(n,e),t.body.appendChild(e),()=>{if(n.parentNode)n.parentNode.insertBefore(e,n);else e.remove();n.remove()}}var Ne=new WeakMap;function jo(e,t){let n=e.documentElement,r=Ne.get(e)??0;if(!t){let a=Math.max(0,r-1);if(Ne.set(e,a),a===0)n.removeAttribute("data-native-sheet-card");return}if(Ne.set(e,r+1),r>0)return;let o=e.defaultView,i=(o?.scrollY??0)+(o?.innerHeight??800)/2;n.style.setProperty("--native-sheet-card-origin",`${Math.round(i)}px`),n.setAttribute("data-native-sheet-card","")}function Pn(e,t){e.style.setProperty("--native-font-scale",String(t.fontScale)),e.toggleAttribute("data-native-reduce-motion",t.reduceMotion),e.toggleAttribute("data-native-reduce-transparency",t.reduceTransparency)}function Ln(e){let t=e.replace(/\s+/g,"").toLowerCase();return!t||t==="transparent"||/^rgba\(\d+,\d+,\d+,0(\.0+)?\)$/.test(t)||/\/0(\.0+)?\)$/.test(t)}function Cn(e){let t=e.defaultView;if(!t?.getComputedStyle)return null;for(let n of[e.body,e.documentElement]){if(!n)continue;let r=t.getComputedStyle(n).backgroundColor;if(r&&!Ln(r))return r}return null}function Mn(e){if(e.documentElement.classList.contains("dark"))return!0;if(e.documentElement.classList.contains("light"))return!1;return Boolean(e.defaultView?.matchMedia?.("(prefers-color-scheme: dark)").matches)}function Go(e,t={}){let n=t.root??e.documentElement;ne.setKeyboardAccessory(t.keyboardAccessory===!0);let r="",o="",i=()=>{let d=Cn(e);if(d&&d!==r)r=d,ne.setUnderPageColor(d);let u=Mn(e)?"light":"dark";if(u!==o)o=u,de.setStyle(u)},a=vt((d)=>{Pn(n,d),i()}),s=e.defaultView,l=typeof s?.MutationObserver==="function"?new s.MutationObserver(i):null;l?.observe(e.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme"]});let m=s?.matchMedia?.("(prefers-color-scheme: dark)");return m?.addEventListener?.("change",i),s?.addEventListener("stx:load",i),i(),()=>{a(),l?.disconnect(),m?.removeEventListener?.("change",i),s?.removeEventListener("stx:load",i)}}var Qo=64;var Nn=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Hn=/^(?:0|[1-9]\d*)$/;function Tt(e){let t=[],n=[],r=e&&typeof e==="object"&&!Array.isArray(e)?e:{};for(let[o,i]of Object.entries(r)){let a=i&&typeof i==="object"?i:null;if(!a){n.push(`spotlight kind "${o}" is not an object`);continue}let{slots:s,route:l}=a,m=typeof a.noun==="string"&&a.noun.trim()?a.noun.trim():"Item";if(!Nn.test(o)||o.includes("-slot-")){n.push(`spotlight kind "${o}" is not a usable name: lowercase letters, digits and single dashes, and never "-slot-"`);continue}if(typeof s!=="number"||!Number.isInteger(s)||s<=0||s>64){n.push(`spotlight kind "${o}" needs slots between 1 and 64, not ${String(s)}`);continue}if(typeof l!=="string"||!l.startsWith("/")||!l.includes(":id")){n.push(`spotlight kind "${o}" needs a route starting with "/" and carrying ":id", not ${String(l)}`);continue}t.push({name:o,slots:s,route:l,noun:m})}return{kinds:t,problems:n}}function ae(e,t){return e.find((n)=>n.name===t)??null}function ie(e,t,n){let r=ae(e,t);if(!r||!Number.isInteger(n)||n<0||n>=r.slots)return null;return`${t}-slot-${n}`}function Dn(e,t){if(typeof t!=="string")return null;let n=t.lastIndexOf("-slot-");if(n<=0)return null;let r=t.slice(0,n),o=t.slice(n+6);if(!Hn.test(o))return null;let i=Number(o);return ie(e,r,i)===t?{kind:r,slot:i}:null}function It(e){return e.flatMap((t)=>Array.from({length:t.slots},(n,r)=>`${t.name}-slot-${r}`))}function Xo(e,t){let n=e&&typeof e==="object"?e:{};if(n.enabled===!1)return[];let o=[...(Array.isArray(n.activityTypes)?n.activityTypes.filter((i)=>typeof i==="string"&&i.trim().length>0):[]).map((i)=>i.trim()),...It(Tt(n.kinds).kinds)];return[...new Set(o)].map((i)=>`${t}.${i}`)}function Ot(e,t,n){let r=typeof n.name==="string"?n.name.replace(/\s+/g," ").trim():"";if(!r)return`${ae(e,t)?.noun??"Item"} #${n.id}`;return r.length>120?`${r.slice(0,119).trimEnd()}…`:r}function _n(e,t,n,r,o=Date.now()){let i=ae(e,n);if(!i||!Number.isInteger(r.id)||r.id<=0)return null;let a=t.filter((f)=>f.kind===n),s=Ot(e,n,r),l=a.find((f)=>f.itemId===r.id)??null,m=l?null:Un(a,i.slots),d=l||m!==null?null:$n(a),u=l?.slot??m??d?.slot;if(u===void 0||u===null)return null;let g={kind:n,slot:u,itemId:r.id,title:s,donatedAt:o},c=t.filter((f)=>f.kind!==n||f.slot!==u&&f.itemId!==r.id);return{entries:Pt(e,[...c,g]),entry:g,evicted:d,changed:!l||l.title!==s}}function Bn(e,t,n){let r=e.find((o)=>o.kind===t&&o.itemId===n)??null;return{entries:r?e.filter((o)=>o!==r):[...e],removed:r}}function Fn(e,t,n){let r=Dn(e,n);if(!r)return null;let o=t.find((a)=>a.kind===r.kind&&a.slot===r.slot),i=ae(e,r.kind)?.route;return o&&i?i.replace(":id",String(o.itemId)):null}function Wn(e,t){if(!Array.isArray(t))return[];let n=new Map,r=new Set;for(let o of t){if(!o||typeof o!=="object")continue;let i=o,{kind:a,slot:s,itemId:l,title:m,donatedAt:d}=i;if(typeof a!=="string"||typeof s!=="number"||ie(e,a,s)===null)continue;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)continue;let u=`${a}-slot-${s}`,g=`${a}#${l}`;if(n.has(u)||r.has(g))continue;n.set(u,{kind:a,slot:s,itemId:l,title:typeof m==="string"&&m.trim()?m:Ot(e,a,{id:l}),donatedAt:typeof d==="number"&&Number.isFinite(d)&&d>0?d:0}),r.add(g)}return Pt(e,[...n.values()])}function Pt(e,t){let n=new Map(e.map((r,o)=>[r.name,o]));return[...t].sort((r,o)=>(n.get(r.kind)??0)-(n.get(o.kind)??0)||r.slot-o.slot)}function Un(e,t){let n=new Set(e.map((r)=>r.slot));for(let r=0;r<t;r++)if(!n.has(r))return r;return null}function $n(e){return e.reduce((t,n)=>!t||n.donatedAt<t.donatedAt?n:t,null)}function Kn(){let e=globalThis.craft;return e&&typeof e==="object"?e.siri:void 0}var jn="stacks_spotlight_index",zn=3000;function Jo(e){let t=e.onProblem??((y)=>console.warn(`[spotlight] ${y}`)),n=Array.isArray(e.kinds)?{kinds:[...e.kinds],problems:[]}:Tt(e.kinds);for(let y of n.problems)t(y);let r=e.enabled===!1?[]:n.kinds,o=e.storageKey??jn,i=e.legacyStorageKeys??[],a=e.timeoutMs??zn,s=e.now??(()=>Date.now()),l=e.bridge??Kn,m=null;function d(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function u(){if(m)return m;m=[];let y=d();if(!y)return m;try{let x=[o,...i].map((A)=>y.getItem(A)).find((A)=>A);m=x?Wn(r,JSON.parse(x)):[]}catch{m=[]}return m}function g(y){m=y;let x=d();if(!x)return;try{x.setItem(o,JSON.stringify(y));for(let A of i)x.removeItem(A)}catch{}}async function c(y){if(!y)return null;let x;try{return await Promise.race([y,new Promise((A)=>{x=setTimeout(()=>A(null),a)})])}catch{return null}finally{if(x!==void 0)clearTimeout(x)}}let f=Promise.resolve();function h(y){let x=f.then(y,y);return f=x.catch(()=>{return}),x}async function w(y,x){let A=l()?.register;if(!A||r.length===0)return!1;return h(async()=>{let R=_n(r,u(),y,x,s()),b=R&&ie(r,y,R.entry.slot);if(!R||!b)return!1;if(!R.changed)return g(R.entries),!0;let S=await c(A(R.entry.title,b))!==null;if(S)g(R.entries);return S})}async function k(y,x){let A=l()?.remove;if(!A)return!1;return h(async()=>{let{entries:R,removed:b}=Bn(u(),y,x);if(!b)return!1;let S=ie(r,y,b.slot),P=S?await c(A(S))!==null:!1;return g(R),P})}async function B(y,x){let A=ae(r,y)?.slots;if(!A||!l()?.register)return 0;let R=0;for(let b of[...x].slice(0,A).reverse())if(await w(y,b))R++;return R}async function O(){let y=l()?.remove;if(!y)return g([]),0;return h(async()=>{let x=0;for(let A of u()){let R=ie(r,A.kind,A.slot);if(R&&await c(y(R))!==null)x++}return g([]),x})}return{kinds:r,index:w,sync:B,remove:k,clear:O,routeFor:(y)=>Fn(r,u(),y),entries:()=>u(),activityTypes:(y)=>It(r).map((x)=>`${y}.${x}`),reset:()=>{m=null}}}var Et=["craftShortcut","craftSiriShortcut"];function Zo(e,t){let n=(r)=>{let o=r.detail,i=typeof o==="string"?o:o&&typeof o==="object"?o.action??o.type:null,a=typeof i==="string"?e.routeFor(i):null;if(a)t(a)};if(typeof globalThis.addEventListener!=="function")return()=>{};for(let r of Et)globalThis.addEventListener(r,n);return()=>{for(let r of Et)globalThis.removeEventListener(r,n)}}import{tabBar as qn}from"craft-native/mobile";var Vn=qn;function Gn(e){return Array.from(e.querySelectorAll("a[data-native-tab]")).map((t)=>({id:t.getAttribute("href")||"",title:t.getAttribute("data-native-tab")||t.getAttribute("aria-label")||"",symbol:t.getAttribute("data-native-tab-symbol")||"circle",badge:(t.querySelector(".native-tab-badge")?.textContent||"").trim(),current:t.hasAttribute("data-stx-nav-current")||t.classList.contains("is-active")})).filter((t)=>t.id&&t.title)}function Yn(e){return{tabs:e.map(({id:n,title:r,symbol:o,badge:i})=>i?{id:n,title:r,symbol:o,badge:i}:{id:n,title:r,symbol:o}),selected:e.find((n)=>n.current)?.id}}function Ct(){if(typeof window>"u")return;let e=window.stxRouter;return e&&typeof e==="object"?e:void 0}function Qn(){return typeof Ct()?.selectTab==="function"}function ni(e,t={}){let n=(r)=>{if(Qn()||r.defaultPrevented)return;let o=r.target?.closest?.("a[data-native-tab]");if(!o||!e.contains(o))return;if(!o.hasAttribute("data-stx-nav-current")&&!o.classList.contains("is-active")&&o.getAttribute("aria-current")!=="page")return;r.preventDefault();let i=e.ownerDocument.defaultView;if(t.scrollToTop)t.scrollToTop();else i?.scrollTo?.({top:0,behavior:i.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"});i?.dispatchEvent(new CustomEvent("stx:tabreselect",{detail:{href:o.getAttribute("href")||""}}))};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)}function Lt(e){let t=e.trim();return/^#[0-9a-f]{6}$/i.test(t)?t:void 0}var He="stacks:tab-bar-cover";function ri(e,t){if(t)e.setAttribute("data-native-covers-tab-bar","");else e.removeAttribute("data-native-covers-tab-bar");e.ownerDocument?.defaultView?.dispatchEvent(new Event(He))}function oi(e,t={}){let n=t.api??Vn;if(!n.isAvailable())return null;let r=t.hidden??(()=>Boolean(e.ownerDocument?.querySelector("[data-native-hide-tab-bar], [data-native-covers-tab-bar]"))),o=typeof getComputedStyle==="function"?getComputedStyle(e):null,i=Lt(o?.getPropertyValue("--native-tab-active")||""),a=Lt(o?.getPropertyValue("--native-tab-active-dark")||""),s="",l=()=>{if(r()){if(s!=="hidden")n.hide();s="hidden";return}let{tabs:g,selected:c}=Yn(Gn(e)),f=JSON.stringify({tabs:g,selected:c});if(f===s)return;let h=s&&s!=="hidden"?JSON.parse(s):null;if(h&&c&&JSON.stringify(h.tabs)===JSON.stringify(g))n.select(c);else n.set(g,{selected:c,tint:i,tintDark:a});s=f},m=typeof MutationObserver==="function"?new MutationObserver(l):null;m?.observe(e,{attributes:!0,attributeFilter:["data-stx-nav-current","class"],childList:!0,subtree:!0,characterData:!0});let d=n.onSelect((g)=>{let c=Ct();if(c?.selectTab){c.selectTab(g);return}Array.from(e.querySelectorAll("a[data-native-tab]")).find((h)=>h.getAttribute("href")===g)?.click()}),u=()=>l();if(typeof window<"u")window.addEventListener("stx:load",u),window.addEventListener("stx:screen-shown",u),window.addEventListener(He,u);return l(),()=>{if(m?.disconnect(),d(),typeof window<"u")window.removeEventListener("stx:load",u),window.removeEventListener("stx:screen-shown",u),window.removeEventListener(He,u);n.hide()}}function Xn(e={}){let t=e.maxSeconds??300,n=e.maxBytes??12582912;if(![t,n].every((h)=>Number.isSafeInteger(h)&&h>0)||t>300)throw TypeError("Invalid voice recording limits");let r={status:"idle",audio:null,error:null},o=new Set,i={},a=null,s=null,l=null,m,d=(h)=>{r=h;for(let w of o)w({...h})},u=()=>{clearTimeout(m),l?.getTracks().forEach((h)=>h.stop()),l=null};function g(){if(i={},a){let w=a;a=null,Promise.resolve(I("audioRecording.cancel")?.(w)).catch(()=>{})}let h=s;if(s=null,h&&h.state!=="inactive")h.stop();u(),d({status:"idle",audio:null,error:null})}async function c(){g();let h=i;d({status:"requesting",audio:null,error:null});try{let w=I("audioRecording.start");if(w){let R=globalThis.crypto.randomUUID();if(a=R,await w(R,{maxSeconds:t}),i!==h)return;m=setTimeout(()=>{if(i===h)f()},t*1000-250),d({status:"recording",audio:null,error:null});return}if(typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>"u")throw Error("Microphone recording is unavailable. Upload an audio recording instead.");let k=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1},video:!1});if(i!==h){k.getTracks().forEach((R)=>R.stop());return}l=k;let B=["audio/webm;codecs=opus","audio/mp4","audio/webm"].find((R)=>MediaRecorder.isTypeSupported(R)),O=new MediaRecorder(k,{...B?{mimeType:B}:{},audioBitsPerSecond:32000});s=O;let y=[],x=0,A=!1;O.ondataavailable=(R)=>{if(i!==h||!R.data.size)return;if(x+=R.data.size,x>n){if(A=!0,y.length=0,O.state!=="inactive")O.stop();u();return}if(!A)y.push(R.data)},O.onerror=()=>{if(i!==h)return;g(),d({status:"error",audio:null,error:"Recording failed. Please try again."})},O.onstop=()=>{if(i!==h)return;s=null,u();let R=new Blob(y,{type:O.mimeType||B||"audio/webm"});d(A||!R.size?{status:"error",audio:null,error:A?"The recording exceeds the upload limit.":"The recording was empty."}:{status:"ready",audio:R,error:null})},O.start(1000),m=setTimeout(()=>{if(i===h&&O.state!=="inactive")O.stop()},t*1000-250),d({status:"recording",audio:null,error:null})}catch(w){if(i!==h)return;g(),d({status:"error",audio:null,error:w instanceof Error?w.message:"Microphone permission was refused."})}}async function f(){if(!a){if(s&&s.state!=="inactive")s.stop();return}let h=i,w=a;clearTimeout(m);try{let k=await I("audioRecording.stop")?.(w);if(i!==h)return;if(!k?.path||!k.size||k.size>n||!Number.isFinite(k.durationSeconds)||k.durationSeconds<=0||k.durationSeconds>t+1)throw Error("The recording is empty or exceeds its limits.");d({status:"ready",audio:k,error:null})}catch(k){if(i!==h)return;g(),d({status:"error",audio:null,error:k instanceof Error?k.message:"Recording failed."})}}return{start:c,cancel:g,dispose(){g(),o.clear()},stop:f,supported:()=>Boolean(I("audioRecording.start"))||typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getUserMedia)&&typeof MediaRecorder<"u",snapshot:()=>({...r}),subscribe(h){return o.add(h),h({...r}),()=>{o.delete(h)}}}}function Jn(e,t={},n="audio"){if(!n||Object.hasOwn(t,n))throw TypeError("Use a distinct recording field name");let r=new FormData;if(typeof Blob<"u"&&e instanceof Blob)r.append(n,e,"feedback");else{if(!e||!("path"in e)||typeof e.path!=="string"||!e.path||!I("audioRecording.stop"))throw TypeError("A native recording requires its native upload host");Reflect.apply(r.append,r,[n,e]);let o=r.get(n);if(!o||typeof o!=="object"||!("path"in o)||o.path!==e.path)throw TypeError("The upload host did not preserve the native recording file")}for(let[o,i]of Object.entries(t)){if(typeof i!=="string")throw TypeError("Upload fields must be strings");r.append(o,i)}return r}var nr={isAvailable:()=>p(()=>De.isAvailable()),getBiometricType:()=>p(()=>De.getBiometricType()),authenticate:(e)=>p(()=>De.authenticate(e))},rr={takePicture:(e)=>p(()=>ve.takePicture(e)),pickImage:()=>p(()=>ve.pickImage()),pickMultiple:(e)=>p(()=>ve.pickMultiple(e)),isAvailable:()=>p(()=>ve.isAvailable())},or={getInfo:()=>p(()=>Q.getInfo()),getCapabilities:()=>p(()=>Q.getCapabilities()),isMobile:()=>Q.isMobile(),isIOS:()=>Q.isIOS(),isAndroid:()=>Q.isAndroid(),getLocale:()=>Q.getLocale(),getTimezone:()=>Q.getTimezone()},ir=er;function z(){return V()?.capabilities.locationRecordingOwnership===!0&&D.supportsRecordingOwnership?.()===!0}function q(){return V()?.capabilities.heartRateRecordingOwnership===!0&&T.supportsRecordingOwnership?.()===!0}function _t(){return z()&&V()?.capabilities.locationRecordingIntentIdentity===!0&&D.supportsRecordingIntentIdentity?.()===!0}function Bt(){return q()&&V()?.capabilities.heartRateRecordingIntentIdentity===!0&&T.supportsRecordingIntentIdentity?.()===!0}function Wt(e,t,n){return p(async()=>{let r=e&&Object.hasOwn(e,"recordingId");if(r){if(!t())throw Object.assign(Error("This host or adapter cannot start a registered recording identity"),{code:"RECORDING_INTENT_IDENTITY_UNSUPPORTED"});if(typeof e.recordingId!=="string"||!e.recordingId.trim())throw Object.assign(Error("A registered recording ID is required"),{code:"INVALID_ARGUMENT"})}let o=await n();if(r&&o.id!==e.recordingId)throw Object.assign(Error("The native recording identity changed at start"),{code:"RECORDING_CONFLICT"});return o})}function _(e,t,n){return p(()=>{if(e&&Object.hasOwn(e,"expectedId")){if(!t())throw Object.assign(Error("This host or adapter cannot protect recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"});if(typeof e.expectedId!=="string"||!e.expectedId.trim())throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"})}return n()})}var ar={supportsRecordingOwnership:z,supportsRecordingIntentIdentity:_t,acknowledgeRecording:(e)=>_({expectedId:e?.expectedId},z,()=>D.acknowledgeRecording(e)),getCurrentPosition:(e)=>p(()=>D.getCurrentPosition(e)),watchPosition:(e,t)=>D.watchPosition(e,t),clearWatch:(e)=>D.clearWatch(e),startRecording:(e)=>Wt(e,_t,()=>D.startRecording(e)),pauseRecording:(e)=>_(e,z,()=>D.pauseRecording(e)),resumeRecording:(e)=>_(e,z,()=>D.resumeRecording(e)),stopRecording:(e)=>_(e,z,()=>D.stopRecording(e)),getRecordingState:(e)=>_(e,z,()=>D.getRecordingState(e)),readRecording:(e)=>_(e,z,()=>D.readRecording(e))},sr={show:(e)=>p(()=>Se.show(e)),schedule:(e)=>p(()=>Se.schedule(e)),cancelAll:()=>p(()=>Se.cancelAll()),setBadge:(e)=>p(()=>Se.setBadge(e))},lr={check:(e)=>p(()=>le.check(e)),request:(e)=>p(()=>le.request(e)),checkMultiple:(e)=>p(()=>le.checkMultiple(e)),requestMultiple:(e)=>p(()=>le.requestMultiple(e)),openSettings:()=>p(()=>le.openSettings())},cr={set:(e,t)=>p(()=>we.set(e,t)),get:(e)=>p(()=>we.get(e)),delete:(e)=>p(()=>we.delete(e)),clear:()=>p(()=>we.clear())},ur={share:(e)=>p(()=>Dt.share(e)),isAvailable:()=>Dt.isAvailable()},dr={request:()=>p(()=>Zn.request())},Re={impact:(e)=>Promise.resolve().then(()=>ye.impact(e)).catch(()=>{}),notification:(e)=>Promise.resolve().then(()=>ye.notification(e)).catch(()=>{}),selection:()=>Promise.resolve().then(()=>ye.selection()).catch(()=>{}),vibrate:(e)=>Promise.resolve().then(()=>ye.vibrate(e)).catch(()=>{}),prepare:(e)=>{let t=I("haptics.prepare");return t?Promise.resolve().then(()=>t(e)).then(()=>{},()=>{}):Promise.resolve()}};function Ft(e){if(typeof e==="string")return e.trim()||null;if(!e||typeof e!=="object")return null;let t=e.url;return typeof t==="string"&&t.trim()?t:null}var pr={async getInitialURL(){if(!await X())return null;return Ft(await Mt.getInitialURL?.())},onLink(e){let t=null,n=!1,r=()=>{if(n)return;t=Mt.onLink?.((o,i)=>{let a=Ft(o);if(a)e(a,{initial:i?.initial===!0})})??null};if(Ae()?.craft)r();else X().then(r);return()=>{n=!0,t?.()}}},mi={isAvailable:()=>xe.isAvailable(),set:(e,t)=>xe.set(e,t),remove:(e)=>xe.remove(e),clear:()=>xe.clear()},fr={enable:()=>p(()=>Nt.enable()),disable:()=>p(()=>Nt.disable())},mr={isAvailable:()=>be.isAvailable(),get:()=>p(()=>be.get()),set:(e)=>p(()=>be.set(e)),restore:()=>p(()=>be.restore())},gr={isAvailable:()=>U.isAvailable(),supports:(e)=>U.supports(e),getAuthorizationStatus:()=>p(()=>U.getAuthorizationStatus()),requestAuthorization:()=>p(()=>U.requestAuthorization()),getNowPlaying:()=>p(()=>U.getNowPlaying()),play:()=>p(()=>U.play()),pause:()=>p(()=>U.pause()),togglePlayPause:()=>p(()=>U.togglePlayPause()),skipToNext:()=>p(()=>U.skipToNext()),skipToPrevious:(e)=>p(()=>U.skipToPrevious(e)),onChange:(e)=>Y(()=>U.onChange(e))},hr={supportsRecordingOwnership:q,supportsRecordingIntentIdentity:Bt,acknowledgeRecording:(e)=>_({expectedId:e?.expectedId},q,()=>T.acknowledgeRecording(e)),isAvailable:()=>T.isAvailable(),supports:(e)=>T.supports(e),getState:()=>p(()=>T.getState()),requestAuthorization:()=>p(()=>T.requestAuthorization()),scan:(e)=>p(()=>T.scan(e)),stopScan:()=>p(()=>T.stopScan()),getDevices:()=>p(()=>T.getDevices()),connect:(e)=>p(()=>T.connect(e)),reconnect:()=>p(()=>T.reconnect()),disconnect:(e)=>p(()=>T.disconnect(e)),startRecording:(e)=>Wt(e,Bt,()=>T.startRecording(e)),pauseRecording:(e)=>_(e,q,()=>T.pauseRecording(e)),resumeRecording:(e)=>_(e,q,()=>T.resumeRecording(e)),stopRecording:(e)=>_(e,q,()=>T.stopRecording(e)),getRecordingState:(e)=>_(e,q,()=>T.getRecordingState(e)),readRecording:(e)=>_(e,q,()=>T.readRecording(e)),onReading:(e)=>Y(()=>T.onReading(e)),onDevice:(e)=>Y(()=>T.onDevice(e)),onState:(e)=>Y(()=>T.onState(e))},br={isAvailable:()=>Fe.isAvailable(),speak:(e,t)=>p(()=>Fe.speak(e,t)),stop:()=>p(()=>Fe.stop())},vr={getStatus:()=>p(()=>Ht.getStatus()),onChange:(e)=>Y(()=>Ht.onChange(e))},yr={register:()=>p(()=>Be.register()),onToken:(e)=>Be.onToken(e),onNotification:(e)=>Y(()=>Be.onNotification(e))},Sr={requestAuthorization:(e,t)=>p(()=>se.requestAuthorization(e,t)),getData:(e,t)=>p(()=>se.getData(e,t)),saveWorkout:(e)=>p(()=>se.saveWorkout(e)),getWorkouts:(e)=>p(()=>se.getWorkouts(e)),getDailyStatistics:(e,t)=>p(()=>se.getDailyStatistics(e,t)),getHeartRateSamples:(e)=>v("health.getHeartRateSamples",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),getSamples:(e,t)=>v("health.getSamples",[e,t??{}],()=>[]).then((n)=>Array.isArray(n)?n:[]),getSleepIntervals:(e)=>v("health.getSleepIntervals",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),saveMindfulSession:(e)=>v("health.saveMindfulSession",[e],()=>null).then((t)=>t??null),getMindfulSessions:(e)=>v("health.getMindfulSessions",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),startHeartRateUpdates:(e)=>v("health.startHeartRateUpdates",[e??{}],()=>!1).then((t)=>t!==!1),stopHeartRateUpdates:()=>v("health.stopHeartRateUpdates",[],()=>!0).then(()=>!0),onHeartRate:(e)=>F("craftHealthHeartRate",(t)=>{if(Array.isArray(t.samples)&&t.samples.length)e(t.samples)}),supports:(e)=>I(`health.${e}`)!==null},wr={start:(e)=>p(()=>_e.start(e)),update:(e)=>p(()=>_e.update(e)),end:()=>p(()=>_e.end())},xr={send:(e)=>p(()=>ce.send(e)),updateContext:(e)=>p(()=>ce.updateContext(e)),isReachable:()=>p(()=>ce.isReachable()),onMessage:(e)=>ce.onMessage(e),onReachabilityChange:(e)=>ce.onReachabilityChange(e)},gi=tr;function Ae(){return E()}function V(){let e=Ae()?.craft;if(!e||typeof e!=="object")return null;if(!("platform"in e)||e.platform!=="ios"&&e.platform!=="android")return null;let t="capabilities"in e?e.capabilities:void 0,n=t&&typeof t==="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,r])=>typeof r==="boolean")):{};return{platform:e.platform,capabilities:n}}function We(){return V()!==null}function Rr(e=2000){if(We()||ee())return Promise.resolve(!0);let t=Ae();if(!t||!(t.craft||t.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let r=()=>{clearTimeout(o),t.removeEventListener("craftReady",r),n(We())},o=setTimeout(r,e);t.addEventListener("craftReady",r,{once:!0})})}function Ar(e){let t=Ae();if(!t)return()=>{};if(V()){let r=!1;return queueMicrotask(()=>{if(!r)e(new Event("craftReady"))}),()=>{r=!0}}let n=(r)=>{if(!V())return;t.removeEventListener("craftReady",n),e(r)};return t.addEventListener("craftReady",n),()=>t.removeEventListener("craftReady",n)}async function kr(e){await Re.impact("light");try{let t=await e();return await Re.notification("success"),t}catch(t){throw await Re.notification("error"),t}}var hi={get nativeBridge(){return V()},biometrics:nr,camera:rr,device:or,haptics:Re,lifecycle:ir,location:ar,notifications:sr,permissions:lr,secureStorage:cr,storage:dt,crypto:pt,share:ur,appReview:dr,deepLinks:pr,keepAwake:fr,brightness:mr,music:gr,heartRate:hr,scheduledWorkouts:mt,speech:br,network:vr,pushNotifications:yr,health:Sr,liveActivities:wr,watchConnectivity:xr,dialog:te,contextMenu:Pe,browser:Ze,symbols:et,statusBar:de,chrome:ne,refresh:j,background:re,clipboard:tt,db:nt,files:rt,shortcuts:ot,widgets:it,orientation:at,auth:st,storeKit:lt,isNativeMobile:We,whenNative:Rr,onReady:Ar,withFeedback:kr};export{Er as BRIDGE_WAIT_MS,Ao as HEART_RATE_MATCH_MS,No as INDOOR_CHECK_AFTER_S,Qo as MAX_SPOTLIGHT_SLOTS_PER_KIND,Sn as ROUTE_GAP_S,Uo as SHEET_FLICK_VELOCITY,He as TAB_BAR_COVER_EVENT,p as afterBridge,dr as appReview,Pn as applyAppearance,vn as attachHeartRate,st as auth,bo as backLabelFor,re as background,nr as biometrics,ue as bridgePending,mr as brightness,Ze as browser,v as callNative,rr as camera,mn as canGoBack,ne as chrome,tt as clipboard,Mr as confirmAction,Pe as contextMenu,ri as coverTabBar,E as craftHost,G as craftRoot,eo as crashReporting,To as createRouteRecorder,Jo as createSpotlightIndex,Xn as createVoiceRecorder,pt as crypto,bt as currentAppearance,nt as db,hn as deepLinkPath,pr as deepLinks,or as device,te as dialog,ho as enterNavTrail,rt as files,xn as fixDistance,Gr as focusSegment,xo as followDeepLinks,V as getNativeMobileBridge,go as goBack,So as goBackToTabRoot,ni as handleTabReselect,Re as haptics,ee as hasNativeMobileHost,Sr as health,hr as heartRate,Ho as indoorVerdict,Go as installNativeChrome,Yr as installPressables,We as isNativeMobile,kn as isShown,fr as keepAwake,an as keepBreadcrumb,pn as largeTitleMetrics,ir as lifecycle,Ko as liftToBody,wr as liveActivities,ar as location,oi as mirrorTabBar,hi as mobile,gr as music,jt as nativeFunction,I as nativeFunctionNow,Yn as nativeTabs,vo as navTrail,vr as network,ln as normalizeAppearance,Ft as normalizeDeepLinkURL,nn as normalizeScheduledWorkout,sr as notifications,po as observeLargeTitle,zr as observeLongPress,Fo as observeNativeRefresh,un as observePageScroll,uo as observePullToRefresh,qr as observeSegmentScrub,$o as observeSheetDrag,vt as onAppearance,so as onBackgroundRefresh,F as onCraftEvent,io as onMemoryWarning,Ar as onMobileReady,oo as onResume,ao as onSilentPush,Zo as onSpotlightTap,at as orientation,ko as paceLabel,Cn as pageBackground,Mn as pageIsDark,oe as pageScrollTop,Po as pauseSessionClock,lr as permissions,Yt as placeMenu,_n as placeSpotlightItem,Ve as presentActionSheet,ze as presentAlert,ke as presentChoice,qe as presentConfirm,Ge as presentContextMenu,jo as presentPageAsCard,yo as previousScreenPath,dn as pullDistance,yr as pushNotifications,Wn as readSpotlightEntries,Tt as readSpotlightKinds,Gn as readTabLinks,j as refresh,Bn as removeSpotlightItem,fo as resolveScrollHost,Lo as resumeSessionClock,Me as routeStats,Qn as routerHandlesTabs,On as rubberBand,mt as scheduledWorkouts,tn as scheduledWorkoutsUnsupported,cr as secureStorage,rn as segmentAt,Vr as segmentForKey,Co as sessionClockElapsed,In as settleSheet,ur as share,Tn as sheetStops,ot as shortcuts,Nr as showContextMenuFor,mi as snapshots,br as speech,Eo as speedLabel,gi as splash,ie as spotlightAction,It as spotlightActions,Xo as spotlightActivityTypes,Kn as spotlightBridge,ae as spotlightKind,Fn as spotlightRoute,Dn as spotlightSlot,Ot as spotlightTitle,Oo as startSessionClock,de as statusBar,dt as storage,lt as storeKit,Y as subscribeWhenReady,et as symbols,Vn as tabBar,Oe as toNativeRect,wo as trailEntryFor,Do as typedDistanceKm,Rn as usableFixes,Cr as useActionSheet,Jn as voiceRecordingFormData,xr as watchConnectivity,X as whenBridgeReady,Rr as whenNativeMobile,it as widgets,kr as withNativeFeedback};
55
+ `;function Ge(){return T()?.document}function Qt(e){if(e.getElementById(qe))return;let t=e.createElement("style");t.id=qe,t.textContent=Xt,(e.head??e.documentElement).appendChild(t)}var Jt=0;function M(e,t,n,r){let o=e.createElement(t);if(o.className=n,r!==void 0)o.textContent=r;return o}function Ve(){return T()?.stx?.overlays}var Zt=0;function Ye(e,t,n,r){Qt(e);let o=T(),i=`native-dialog-layer-${++Zt}`,a=M(e,"div",`native-dialog native-dialog--${t}`);return a.setAttribute("data-native-dialog",t),a.appendChild(M(e,"div","native-dialog-backdrop")),new Promise((s)=>{let l=!1,f=(c)=>{if(l)return;l=!0,a.classList.remove("is-open"),Ve()?.close(i),setTimeout(()=>a.remove(),260),s(c)},u=n({root:a,settle:f});a.appendChild(u),e.body.appendChild(a),Ve()?.open(i,{panel:u,root:a,onEscape:()=>f(r())});let m=o;(typeof m?.requestAnimationFrame==="function"?(c)=>m.requestAnimationFrame(()=>m.requestAnimationFrame(c)):(c)=>setTimeout(c,16))(()=>{if(!l)a.classList.add("is-open")})})}function Pe(e){let t=Ge();if(!t?.body)return Promise.resolve(null);let n=`native-dialog-${++Jt}`,r=e.actions.find((a)=>a.style==="cancel"),o=e.variant==="sheet"?e.actions.filter((a)=>a.style!=="cancel"):e.actions,i=e.variant==="sheet"?r??{id:"__cancel",title:e.cancelLabel||"Cancel",style:"cancel"}:void 0;return Ye(t,e.variant,({root:a,settle:s})=>{let l=(c)=>c.style==="cancel"?null:c.id,f=M(t,"div","native-dialog-panel");f.setAttribute("role","alertdialog"),f.setAttribute("aria-modal","true"),f.tabIndex=-1;let u=M(t,"div","native-dialog-group");if(e.title||e.message){let c=M(t,"div","native-dialog-header");if(e.title){let p=M(t,"p","native-dialog-title",e.title);p.id=`${n}-title`,c.appendChild(p),f.setAttribute("aria-labelledby",p.id)}if(e.message){let p=M(t,"p","native-dialog-message",e.message);p.id=`${n}-message`,c.appendChild(p),f.setAttribute("aria-describedby",p.id)}u.appendChild(c)}let m=M(t,"div","native-dialog-actions");if(e.variant==="alert"&&o.length===2)m.classList.add("is-row");for(let c of o){let p=M(t,"button",`native-dialog-action${c.style==="destructive"?" is-destructive":""}${c.style==="cancel"?" is-cancel":""}`,c.title);p.type="button",p.setAttribute("data-action-id",c.id),p.addEventListener("click",()=>s(l(c))),m.appendChild(p)}if(u.appendChild(m),f.appendChild(u),i){let c=M(t,"div","native-dialog-group"),p=M(t,"button","native-dialog-action is-cancel",i.title);p.type="button",p.setAttribute("data-action-id",i.id),p.addEventListener("click",()=>s(null)),c.appendChild(p),f.appendChild(c)}let h=a.querySelector(".native-dialog-backdrop");if(e.variant==="sheet")h?.addEventListener("click",()=>s(null));return f},()=>{if(e.variant==="sheet")return null;if(r)return null;return o.length===1?o[0].id:null})}async function Xe(e){await Pe({variant:"alert",title:e.title,message:e.message,actions:[{id:"ok",title:e.okLabel||"OK"}]})}async function Qe(e){return await Pe({variant:"alert",title:e.title,message:e.message,actions:[{id:"cancel",title:e.cancelLabel||"Cancel",style:"cancel"},{id:"confirm",title:e.confirmLabel||"OK",style:e.destructive?"destructive":"default"}]})==="confirm"}function Je(e){return Pe({variant:"sheet",title:e.title,message:e.message,actions:e.actions,cancelLabel:e.cancelLabel})}function en(e,t,n){let i=Math.max(12,Math.min(e.x,n.width-t.width-12)),a=e.y+e.height+8,s=a+t.height<=n.height-12,l=e.y-8-t.height,f=s||l<12?Math.max(12,Math.min(a,n.height-t.height-12)):l,u=e.x+e.width/2>n.width/2?"right":"left";return{top:f,left:i,origin:`${s||l<12?"top":"bottom"} ${u}`}}function Ze(e){let t=Ge();if(!t?.body)return Promise.resolve(null);let n=T();return Ye(t,"menu",({root:r,settle:o})=>{let i=M(t,"div","native-menu native-dialog-panel");if(i.setAttribute("role","menu"),e.title)i.appendChild(M(t,"p","native-menu-title",e.title)),i.setAttribute("aria-label",e.title);for(let a of e.items){let s=M(t,"button",`native-menu-item${a.destructive?" is-destructive":""}`);if(s.type="button",s.setAttribute("role","menuitem"),s.setAttribute("data-action-id",a.id),a.disabled)s.disabled=!0;if(s.appendChild(M(t,"span","native-menu-label",a.title)),a.icon){let l=M(t,"i",`native-menu-icon ${a.icon}`);l.setAttribute("aria-hidden","true"),s.appendChild(l)}s.addEventListener("click",()=>o(a.id)),i.appendChild(s)}return r.querySelector(".native-dialog-backdrop")?.addEventListener("click",()=>o(null)),queueMicrotask(()=>{let a=i.getBoundingClientRect?.(),s=en(e.anchor,{width:a?.width||248,height:a?.height||e.items.length*44},{width:n?.innerWidth||390,height:n?.innerHeight||844});i.style.top=`${s.top}px`,i.style.left=`${s.left}px`,i.style.setProperty("--native-menu-origin",s.origin)}),i},()=>null)}var rt=()=>!0,H=()=>!1,W=()=>null;function et(){return T()?.navigator??(typeof navigator>"u"?void 0:navigator)}function Ne(e){return{x:Math.round(e.x??e.left??0),y:Math.round(e.y??e.top??0),width:Math.round(e.width),height:Math.round(e.height)}}var oe={alert:(e)=>y("dialog.alert",[e],()=>Xe(e),{fallbackOnError:!0}).then(()=>{}),confirm:(e)=>y("dialog.confirm",[e],()=>Qe(e),{fallbackOnError:!0}).then(Boolean),actionSheet:async(e)=>{let t={...e,anchor:e.anchor?Ne(e.anchor):void 0},n=await y("dialog.actionSheet",[t],()=>Je(e),{fallbackOnError:!0});if(typeof n!=="string")return null;return e.actions.find((r)=>r.id===n)?.style==="cancel"?null:n}};function Ur(){return(e)=>oe.actionSheet(e)}async function Wr(e){if((e.style??(e.destructive?"sheet":"alert"))==="alert")return oe.confirm(e);return await oe.actionSheet({title:e.title,message:e.message,anchor:e.anchor,actions:[{id:"confirm",title:e.confirmLabel||"OK",style:e.destructive?"destructive":"default"},{id:"cancel",title:e.cancelLabel||"Cancel",style:"cancel"}]})==="confirm"}var He={show:async(e)=>{let t={title:e.title,anchor:Ne(e.anchor),items:e.items.map(({id:r,title:o,symbol:i,destructive:a,disabled:s})=>({id:r,title:o,symbol:i,destructive:a,disabled:s}))},n=await y("contextMenu.show",[t],()=>Ze(e),{fallbackOnError:!0});return typeof n==="string"?n:null}};function $r(e,t){return He.show({...t,anchor:Ne(e.getBoundingClientRect())})}function tn(e,t){let n=T();if(!n)return{cancelled:!0};if(typeof n.craft?.openURL==="function")return Promise.resolve(n.craft.openURL(e)).catch(()=>{}),{cancelled:!1};if(t.mode==="auth")return n.location?.assign(e),{cancelled:!1};if(!(typeof n.open==="function"?n.open(e,"_blank","noopener"):null))n.location?.assign(e);return{cancelled:!1}}var ot={open:async(e,t={})=>{let n=await y("browser.open",[e,t],()=>tn(e,t),{fallbackOnError:!0});if(!n||typeof n!=="object")return{cancelled:!1};let{url:r,cancelled:o}=n;return typeof r==="string"?{url:r,cancelled:Boolean(o)}:{cancelled:Boolean(o)}}},Le=new Map,Me=new Map;function tt(e,t){return`${e}|${t.pointSize??""}|${t.weight??""}|${t.color??""}|${t.scale??""}`}var it={isAvailable:()=>L("symbols.image")!==null,image:(e,t={})=>{let n=tt(e,t),r=Le.get(n);if(r)return r;let o=y("symbols.image",[e,t],W).then((i)=>typeof i==="string"&&i.startsWith("data:")?i:null,W).then((i)=>(Me.set(n,i),i));return Le.set(n,o),o},cached:(e,t={})=>Me.get(tt(e,t)),clearCache:()=>{Le.clear(),Me.clear()}},ge={setStyle:(e)=>y("statusBar.setStyle",[e],H,{fallbackOnError:!0}).then((t)=>t!==!1)},ie={setUnderPageColor:(e)=>y("chrome.setUnderPageColor",[e],H,{fallbackOnError:!0}).then((t)=>t!==!1),setKeyboardAccessory:(e)=>y("chrome.setKeyboardAccessory",[e],H,{fallbackOnError:!0}).then((t)=>t!==!1)},V={isAvailable:()=>L("refresh.enable")!==null,enable:(e)=>y("refresh.enable",[e??{}],H,{fallbackOnError:!0}).then((t)=>t!==!1),disable:()=>y("refresh.disable",[],H,{fallbackOnError:!0}).then((e)=>e!==!1),end:()=>y("refresh.end",[],H,{fallbackOnError:!0}).then((e)=>e!==!1),onRefresh:(e)=>U("craftRefresh",()=>e())},ae={complete:(e)=>y("background.complete",[e],H,{fallbackOnError:!0}).then((t)=>t!==!1)},at={write:(e)=>y("clipboard.write",[e],async()=>{let t=et()?.clipboard;if(!t?.writeText)return!1;return t.writeText(e).then(rt,H)},{fallbackOnError:!0}).then((t)=>t!==!1),read:()=>y("clipboard.read",[],async()=>{let e=et()?.clipboard;if(!e?.readText)return null;return e.readText().catch(W)},{fallbackOnError:!0}).then((e)=>typeof e==="string"?e:null)},st={isAvailable:()=>L("db.query")!==null,query:(e,t=[])=>y("db.query",[e,t],W).then((n)=>Array.isArray(n)?n:null),execute:(e,t=[])=>y("db.execute",[e,t],W).then((n)=>{if(!n||typeof n!=="object")return null;let{rowsAffected:r,lastInsertId:o}=n;return{rowsAffected:Number(r)||0,lastInsertId:Number(o)||0}})};function Ce(e,t){let n=T()?.document;if(!n?.body)return null;let r=n.createElement("a");return r.href=e,r.download=t,r.rel="noopener",r.style.display="none",n.body.appendChild(r),r.click(),r.remove(),t}function nn(e){let t=T()?.document;if(!t?.body)return Promise.resolve(null);return new Promise((n)=>{let r=t.createElement("input");if(r.type="file",r.style.display="none",e.length)r.accept=e.map((i)=>i.includes("/")||i.startsWith(".")?i:`.${i}`).join(",");let o=(i)=>{r.remove(),n(i)};r.addEventListener("cancel",()=>o(null)),r.addEventListener("change",()=>{let i=r.files?.[0];if(!i)return o(null);let a=new FileReader;a.onload=()=>o({name:i.name,mimeType:i.type||void 0,data:typeof a.result==="string"?a.result:void 0}),a.onerror=()=>o({name:i.name,mimeType:i.type||void 0}),a.readAsDataURL(i)}),t.body.appendChild(r),r.click()})}var lt={openPDF:(e,t=0)=>y("openPDF",[e,t],()=>{let n=T();return Boolean(n?.open?.(e,"_blank","noopener"))}).then((n)=>n!==!1),takeScreenshot:()=>y("takeScreenshot",[],W,{fallbackOnError:!0}).then((e)=>typeof e==="string"?e:null),scanQRCode:()=>y("scanQRCode",[],W).then((e)=>{if(!e||typeof e!=="object")return null;let{type:t,data:n}=e;return typeof n==="string"?{type:String(t??""),data:n}:null},W),pickFile:(e=[])=>y("pickFile",[e],()=>nn(e)).then((t)=>{if(!t||typeof t!=="object")return null;let n=t;if(typeof n.name!=="string")return null;return{name:n.name,path:typeof n.path==="string"?n.path:void 0,data:typeof n.data==="string"?n.data:void 0,mimeType:typeof n.mimeType==="string"?n.mimeType:void 0}},W),saveFile:(e,t,n)=>y("saveFile",[e,t,n],()=>{if(e.startsWith("data:"))return Ce(e,t);let r=new Blob([e],{type:n||"text/plain"}),o=URL.createObjectURL(r),i=Ce(o,t);return setTimeout(()=>URL.revokeObjectURL(o),1000),i}).then((r)=>typeof r==="string"?r:null),downloadFile:(e,t)=>y("downloadFile",[e,t],()=>Ce(e,t)).then((n)=>typeof n==="string"?n:null)},ct={set:(e)=>y("shortcuts.set",[e.map(({symbol:t,...n})=>t?{...n,iconName:t}:n)],H).then((t)=>t!==!1),clear:()=>y("shortcuts.clear",[],H).then((e)=>e!==!1),onShortcut:(e)=>U("craftShortcut",(t)=>{if(typeof t.type==="string")e(t.type)})},ut={update:(e)=>y("widget.update",[e],H).then((t)=>t!==!1),reload:()=>y("widget.reload",[],H).then((e)=>e!==!1)},rn={portrait:"portrait-primary",portraitUpsideDown:"portrait-secondary",landscape:"landscape",landscapeLeft:"landscape-primary",landscapeRight:"landscape-secondary"};function nt(){return T()?.screen?.orientation}var dt={lock:(e)=>y("lockOrientation",[e],()=>{let t=nt();return t?.lock?t.lock(rn[e]).then(rt,H):!1}).then((t)=>t!==!1),unlock:()=>y("unlockOrientation",[],()=>(nt()?.unlock?.(),!0)).then((e)=>e!==!1)},pt={signInWithApple:(e={})=>y("signInWithApple",e.nonce?[{nonce:e.nonce}]:[],W).then((t)=>{if(!t||typeof t!=="object"||typeof t.userId!=="string")return null;return t})},ft={isAvailable:()=>L("iap.purchase")!==null,products:(e)=>y("iap.getProducts",[e],()=>[]).then((t)=>Array.isArray(t)?t:[]),purchase:(e)=>y("iap.purchase",[e],W).then((t)=>t&&typeof t==="object"?t:null,(t)=>{if(/cancel/i.test(String(t?.message??t)))return null;throw t}),restore:()=>y("iap.restore",[],()=>[]).then((e)=>Array.isArray(e)?e:[])};import{storage as z}from"craft-native/mobile";function mt(){return Q()?.capabilities?.storageCompareAndSet===!0&&z.supportsCompareAndSet?.()===!0}function gt(){return Q()?.capabilities?.storageSetIfAbsent===!0&&z.supportsSetIfAbsent?.()===!0}var ht={supportsCompareAndSet:mt,supportsSetIfAbsent:gt,get:(e)=>d(()=>z.get(e)),set:(e,t)=>d(()=>z.set(e,t)),remove:(e)=>d(()=>z.remove(e)),clear:()=>d(()=>z.clear()),keys:()=>d(()=>z.keys()),setIfAbsent:(e,t)=>d(()=>{if(!gt())throw Object.assign(Error("This host or adapter cannot create storage atomically"),{code:"STORAGE_SET_IF_ABSENT_UNSUPPORTED"});return z.setIfAbsent(e,t)}),compareAndSet:(e,t,n)=>d(()=>{if(!mt())throw Object.assign(Error("This host or adapter cannot compare storage atomically"),{code:"STORAGE_COMPARE_AND_SET_UNSUPPORTED"});return z.compareAndSet(e,t,n)})};import{crypto as on}from"craft-native/mobile";var bt={randomUUID:()=>d(()=>on.randomUUID())};var an=["authorized","denied","notDetermined","restricted","unsupported"];function he(){let e=Q(),t=e?.scheduledWorkouts;if(!t||typeof t!=="object"||e?.capabilities?.scheduledWorkouts!==!0)return;return t}function sn(){return Object.assign(Error("unsupported"),{code:"UNSUPPORTED"})}function vt(e){return an.includes(e)?e:"unsupported"}function ln(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.id!=="string"||!t.id||typeof t.date!=="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t.date))return null;let n={id:t.id.toLowerCase(),date:t.date,complete:t.complete===!0};if(typeof t.hour==="number"&&Number.isFinite(t.hour))n.hour=t.hour;if(typeof t.minute==="number"&&Number.isFinite(t.minute))n.minute=t.minute;return n}function te(e,t,...n){return d(async()=>{let r=he();if(typeof r?.[e]!=="function")throw sn();return t(await r[e](...n))})}var yt={isAvailable:()=>typeof he()?.isSupported==="function",supports:(e)=>typeof he()?.[e]==="function",isSupported:()=>d(async()=>{let e=he();if(typeof e?.isSupported!=="function")return!1;try{return await e.isSupported()===!0}catch{return!1}}),authorization:()=>te("authorization",vt),requestAuthorization:()=>te("requestAuthorization",vt),list:()=>te("list",(e)=>Array.isArray(e)?e.map(ln).filter((t)=>t!==null):[]),schedule:(e)=>{if(!e||typeof e!=="object"||typeof e.id!=="string")return Promise.reject(Object.assign(Error("schedule needs a plan with an id"),{code:"INVALID_ARGUMENT"}));return te("schedule",(t)=>{let n=t&&typeof t==="object"?t:{},r={id:(typeof n.id==="string"?n.id:e.id).toLowerCase()};if(Array.isArray(n.droppedAlerts)&&n.droppedAlerts.length)r.droppedAlerts=n.droppedAlerts.filter((o)=>typeof o==="string");return r},e)},remove:(e)=>te("remove",(t)=>t===!0,e),removeAll:()=>te("removeAll",(e)=>typeof e==="number"&&Number.isFinite(e)?e:0)};function Zr(e,t){let n=t.delay??500,r=t.tolerance??10,o=null,i=null,a=!1,s=()=>{if(o)clearTimeout(o);if(o=null,i&&!a)t.onPressEnd?.();i=null},l=(h)=>{let c=h;if(c.button!==void 0&&c.button!==0)return;a=!1,i={x:c.clientX,y:c.clientY},t.onPressStart?.(),o=setTimeout(()=>{if(o=null,!i)return;a=!0,t.onLongPress({...i}),i=null},n)},f=(h)=>{if(!i)return;let c=h;if(Math.hypot(c.clientX-i.x,c.clientY-i.y)>r)s()},u=(h)=>{if(!a)return;a=!1,h.preventDefault(),h.stopPropagation()},m=(h)=>h.preventDefault();return e.addEventListener("pointerdown",l),e.addEventListener("pointermove",f),e.addEventListener("pointerup",s),e.addEventListener("pointercancel",s),e.addEventListener("pointerleave",s),e.addEventListener("click",u,!0),e.addEventListener("contextmenu",m),()=>{s(),e.removeEventListener("pointerdown",l),e.removeEventListener("pointermove",f),e.removeEventListener("pointerup",s),e.removeEventListener("pointercancel",s),e.removeEventListener("pointerleave",s),e.removeEventListener("click",u,!0),e.removeEventListener("contextmenu",m)}}function cn(e,t,n){if(n<=1||t.width<=0)return 0;let r=Math.floor((e-t.left)/t.width*n);return Math.max(0,Math.min(n-1,r))}function eo(e,t){let n=null,r=null,o=!1,i=0,a=(c)=>{let p=e.getBoundingClientRect();return cn(c,{left:p.left+2,width:p.width-4},t.count())},s=(c)=>{let p=c;if(p.button!==void 0&&p.button!==0)return;let g=a(p.clientX);if(g!==t.selected())return;n=g,i=g,o=!1,r=p.pointerId;try{e.setPointerCapture?.(p.pointerId)}catch{}t.onPress?.(!0)},l=(c)=>{if(n===null)return;let p=a(c.clientX);if(p===i)return;o=!0,i=p,t.onScrub(p)},f=(c)=>{if(n===null)return;if(r!==null)try{e.releasePointerCapture?.(r)}catch{}if(t.onPress?.(!1),c&&o)t.onCommit(i);else if(o)t.onScrub(n);n=null,r=null},u=(c)=>{if(!o)return;o=!1,c.preventDefault(),c.stopPropagation()},m=()=>f(!0),h=()=>f(!1);return e.addEventListener("pointerdown",s),e.addEventListener("pointermove",l),e.addEventListener("pointerup",m),e.addEventListener("pointercancel",h),e.addEventListener("click",u,!0),()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("pointermove",l),e.removeEventListener("pointerup",m),e.removeEventListener("pointercancel",h),e.removeEventListener("click",u,!0)}}function to(e,t,n){if(n<=0)return null;switch(e){case"ArrowRight":case"ArrowDown":return(t+1)%n;case"ArrowLeft":case"ArrowUp":return(t-1+n)%n;case"Home":return 0;case"End":return n-1;default:return null}}function no(e,t){e.querySelectorAll('[role="tab"]')[t]?.focus()}function ro(e){let t=(n)=>{if(!n.target?.closest?.("[data-native-pressable]"))return;let o=L("haptics.prepare");if(o)Promise.resolve().then(()=>o("impact")).catch(()=>{})};return e.addEventListener("touchstart",t,{passive:!0,capture:!0}),()=>e.removeEventListener("touchstart",t,{capture:!0})}import{BugHQClient as un}from"@bughq/sdk";import{crashReporter as ne}from"craft-native/mobile";var D=null;function dn(e){if(e.type!=="http")return!0;let t=e.data??{},n=typeof t.status==="number"?t.status:0;return t.error===!0||n>=400||n===0}function St(){return ne.isAvailable()}function pn(e){return async(t)=>{if(!St())return!e;return ne.capture(t)}}var lo={start(e={}){if(D)return D;let t=re()||St();if(!t&&!e.key&&!e.dsn)return null;let n=e.beforeBreadcrumb;return D=new un({framework:"stacks-mobile",sdkName:"bughq.stacks.mobile",autoInstrument:{navigation:!0,fetch:!0,xhr:!0},...e,heartbeat:t?!1:e.heartbeat,transport:t?pn(Boolean(e.key||e.dsn)):void 0,beforeBreadcrumb(r){if(!dn(r))return null;let o=n?n(r):r;if(o===null)return null;let i=o||r;if(t)ne.addBreadcrumb(i);return i}}),D},async setUser(e){let t=e===null||e===void 0||e===""?null:String(e);D?.setUser(t===null?null:{id:t}),await ne.setUser(t)},capture(e,t){D?.captureException(e,t)},addBreadcrumb(e){if(D)D.addBreadcrumb(e);else ne.addBreadcrumb(e)},async flush(){await Promise.all([D?.flush(),ne.flush()])},client(){return D},stop(){D?.close(),D=null}};function De(e){let t=T();try{return Boolean(t?.matchMedia?.(e).matches)}catch{return!1}}function wt(e){return e!==null&&e!==void 0&&e!=="false"&&e!=="0"}function xt(){let e=T()?.document?.documentElement,t=Number.parseFloat(e?.style?.getPropertyValue("--craft-font-scale")||"");return{fontScale:Number.isFinite(t)&&t>0?t:1,reduceMotion:wt(e?.getAttribute("data-craft-reduce-motion"))||De("(prefers-reduced-motion: reduce)"),reduceTransparency:wt(e?.getAttribute("data-craft-reduce-transparency"))||De("(prefers-reduced-transparency: reduce)"),colorScheme:e?.classList?.contains("dark")||De("(prefers-color-scheme: dark)")?"dark":"light"}}function fn(e){let t=xt(),n=Number(e?.fontScale);return{contentSizeCategory:typeof e?.contentSizeCategory==="string"?e.contentSizeCategory:void 0,fontScale:Number.isFinite(n)&&n>0?n:t.fontScale,reduceMotion:typeof e?.reduceMotion==="boolean"?e.reduceMotion:t.reduceMotion,reduceTransparency:typeof e?.reduceTransparency==="boolean"?e.reduceTransparency:t.reduceTransparency,colorScheme:e?.colorScheme==="dark"||e?.colorScheme==="light"?e.colorScheme:t.colorScheme}}function Rt(e,t={}){if(t.immediate!==!1)e(xt());return U("craftAppearance",(n)=>e(fn(n)))}function fo(e){return U("craftResume",(t)=>e({backgroundedMs:Number(t.backgroundedMs)||0}))}function mo(e){return U("craftMemoryWarning",()=>e())}function At(e){return(t)=>{Promise.resolve().then(()=>e(t)).then(()=>ae.complete(!0),()=>ae.complete(!1))}}function go(e){let t=At(e);return U("craftSilentPush",(n)=>t(n.payload??{}))}function ho(e){let t=At(()=>e());return U("craftBackgroundRefresh",()=>t(void 0))}import{haptics as mn}from"craft-native/mobile";function _e(){if(typeof window>"u")return;return window}function se(e=_e()){if(!e)return 0;if(typeof e.scrollY==="number")return e.scrollY;if(typeof e.scrollTop==="number")return e.scrollTop;return e.document?.scrollingElement?.scrollTop??0}function gn(e,t=_e()){if(!t)return()=>{};let n=!1,r=typeof requestAnimationFrame==="function"?requestAnimationFrame:(i)=>setTimeout(i,16),o=()=>{if(n)return;n=!0,r(()=>{n=!1,e(se(t))})};return e(se(t)),t.addEventListener("scroll",o,{passive:!0}),()=>t.removeEventListener("scroll",o)}function hn(e,t){let n=Math.max(0,-e),r=e<=0?Math.max(0,t)*0.5:0;return Math.round(Math.max(n,r))}function yo(e){let t=e.host??_e();if(!t)return()=>{};let n=e.threshold??72,r=null,o=!1,i=!1,a=typeof requestAnimationFrame==="function"?requestAnimationFrame:(g)=>setTimeout(g,16),s=null,l=(g)=>{s=null,e.onPull?.(g,o,{bounce:Math.min(g,Math.max(0,-se(t)))})},f=(g)=>{let S=s!==null;if(s=g,S)return;a(()=>{if(s!==null)l(s)})},u=(g)=>{let S=g.touches?.[0];return S?S.clientY:null},m=(g)=>{if(i||se(t)>0)return;r=u(g),o=!1},h=(g)=>{if(r===null)return;let S=u(g);if(S===null)return;let b=hn(se(t),S-r);if(!o&&b>=n)o=!0,Promise.resolve(mn.impact("medium")).catch(()=>{});else if(o&&b<n*0.8)o=!1;f(b)},c=async()=>{if(r===null)return;if(r=null,!o){l(0);return}o=!1,i=!0,l(n);try{await e.onRefresh()}finally{i=!1,l(0)}},p=()=>{if(r===null)return;r=null,o=!1,l(0)};return t.addEventListener("touchstart",m,{passive:!0}),t.addEventListener("touchmove",h,{passive:!0}),t.addEventListener("touchend",c),t.addEventListener("touchcancel",p),()=>{s=null,t.removeEventListener("touchstart",m),t.removeEventListener("touchmove",h),t.removeEventListener("touchend",c),t.removeEventListener("touchcancel",p)}}function bn(e,t=52){let n=Math.max(1,t),r=Math.min(1,Math.max(0,e/n)),o=e<0?1+Math.min(0.1,-e/600):1;return{progress:Math.round(r*1000)/1000,stretch:Math.round(o*1000)/1000}}function So(e,t={}){let n="",r=()=>t.title?.offsetHeight||t.height||52;return gn((o)=>{let i=bn(o,r()),a=`${i.progress}|${i.stretch}`;if(a===n)return;n=a,e.style.setProperty("--native-nav-progress",String(i.progress)),e.style.setProperty("--native-nav-stretch",String(i.stretch)),t.onChange?.(i)},t.host)}function wo(e){if(!e||typeof window>"u")return;let t=window.document?.querySelector(e);return t?t:void 0}function Et(){if(typeof window>"u")return;return window}var kt="__stxPushed",vn="__stxScroll";function yn(e=Et()){let t=e?.history?.state;if(t===null||t===void 0)return!1;if(typeof t!=="object")return!0;let n=t;if(kt in n)return n[kt]===!0;return!(vn in n)}function Ro(e=Et()){if(!yn(e))return!1;return e.history.back(),!0}function Ao(e,t,n=50){let r=e[e.length-1];if(e.length>=2&&e[e.length-2].path===t)e.pop();else if(!r||r.path!==t)e.push({path:t,title:""});if(e.length>n)e.splice(0,e.length-n);return{current:e[e.length-1],previous:e[e.length-2]??null}}function ko(e,t,n=12){let r=e?.title.trim()??"";return r&&r.length<=n?r:t}function To(){if(typeof window>"u")return[];let e=window;return e.__stacksNavTrail??=[]}function Sn(e){try{let t=new URL(e,"http://local");return`${t.pathname}${t.search}`}catch{return e}}function Eo(){if(typeof window>"u")return;let e=window.stxRouter;if(typeof e?.screens!=="function")return;let t=e.screens(),n=t.find((o)=>o.active);if(!n)return;let r=t.filter((o)=>o.tab===n.tab&&o.depth<n.depth);if(!r.length)return null;return Sn(r.reduce((o,i)=>i.depth>o.depth?i:o).url)}function Oo(e=typeof window>"u"?void 0:window){let t=e?.stxRouter;if(typeof t?.screens!=="function"||typeof e?.history?.go!=="function")return!1;let n=t.screens(),r=n.find((a)=>a.active);if(!r)return!1;let o=n.filter((a)=>a.tab===r.tab&&a.depth<r.depth);if(!o.length)return!1;let i=o.reduce((a,s)=>s.depth<a.depth?s:a);return e.history.go(i.depth-r.depth),!0}function Io(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].path===t)return e[n];return null}function wn(e,t=xn()){let n;try{n=new URL(e)}catch{return null}let r=`${n.search}${n.hash}`;if(n.protocol==="http:"||n.protocol==="https:"){if(!t||n.origin!==t)return null;return`${n.pathname||"/"}${r}`}return`${`/${[n.host,n.pathname.replace(/^\/+/,"")].filter(Boolean).join("/")}`}${r}`}function xn(){if(typeof window>"u")return;return window.location?.origin}var Tt="stacks-mobile-deep-link";function Po(e,t){let n=(r)=>{let o=wn(r);if(o)e(o)};return t.getInitialURL().then((r)=>{if(!r)return;try{if(sessionStorage.getItem(Tt)===r)return;sessionStorage.setItem(Tt,r)}catch{}n(r)}).catch(()=>{}),t.onLink((r,o)=>{if(o?.initial)return;n(r)})}var Mo=5000;function Rn(e,t,n=5000){let r=t.filter((o)=>Number.isFinite(o.timestamp)&&Number.isFinite(o.bpm)&&o.bpm>0).slice().sort((o,i)=>o.timestamp-i.timestamp);if(!r.length)return e.slice();return e.map((o)=>{let i=0,a=r.length;while(i<a){let u=i+a>>1;if(r[u].timestamp<o.timestamp)i=u+1;else a=u}let s=r[i],l=r[i-1],f=!s?l:!l?s:o.timestamp-l.timestamp<=s.timestamp-o.timestamp?l:s;if(!f||Math.abs(f.timestamp-o.timestamp)>n)return o;return{...o,heartRate:Math.round(f.bpm)}})}var An=6371008.8,Be={distanceM:0,movingS:0,paceSPerKm:null,averagePaceSPerKm:null,speedMps:null,accuracyM:null,fixes:0},kn=30,Tn=kn;function En(e,t){let n=Math.PI/180,r=(t.latitude-e.latitude)*n,o=(t.longitude-e.longitude)*n,i=Math.sin(r/2)**2+Math.cos(e.latitude*n)*Math.cos(t.latitude*n)*Math.sin(o/2)**2;return 2*An*Math.asin(Math.min(1,Math.sqrt(i)))}function Co(e,t=25){let n=new Set;return e.filter((r)=>Number.isFinite(r.latitude)&&Number.isFinite(r.longitude)&&Number.isFinite(r.timestamp)&&Math.abs(r.latitude)<=90&&Math.abs(r.longitude)<=180&&Number.isFinite(r.accuracy)&&r.accuracy>=0&&r.accuracy<=t).sort((r,o)=>r.timestamp-o.timestamp).filter((r)=>{if(n.has(r.timestamp))return!1;return n.add(r.timestamp),!0})}function On(e,t){return Number.isFinite(e.latitude)&&Number.isFinite(e.longitude)&&Number.isFinite(e.timestamp)&&Math.abs(e.latitude)<=90&&Math.abs(e.longitude)<=180&&Number.isFinite(e.accuracy)&&e.accuracy>=0&&e.accuracy<=t}function be(e={}){let t=e.maxAccuracyM??25,n=(e.paceWindowS??30)*1000,r=[],o=0,i=0,a=null,s=0,l=null,f=null,u={...Be};function m(c){let p=r[r.length-1],g=a?(c.timestamp-a.timestamp)/1000:0;if(a=c,s++,!p){r.push({fix:c,cumM:0});return}if(g>Tn){r.push({fix:c,cumM:o});return}let S=(c.timestamp-p.fix.timestamp)/1000,b=En(p.fix,c),I=Math.min(10,Math.max(3,p.fix.accuracy,c.accuracy));if(b<I)return;if(o+=b,S>0&&b/S>=0.5)i+=S;r.push({fix:c,cumM:o})}function h(){let c=r[r.length-1];if(c){let S=c.fix.timestamp-n,b=0;while(b<r.length-1&&r[b].fix.timestamp<S)b++;if(b)r=r.slice(b)}let p=null,g=null;if(c&&a.timestamp-c.fix.timestamp<=n){let S=r[0],b=c.cumM-S.cumM,I=(c.fix.timestamp-S.fix.timestamp)/1000;if(b>=20&&I>0)g=b/I,p=I/(b/1000)}return{distanceM:o,movingS:i,paceSPerKm:p,averagePaceSPerKm:o>=50&&i>0?i/(o/1000):null,speedMps:g,accuracyM:a?a.accuracy:f,fixes:s}}return{get stats(){return u},get latestTimestamp(){return l},add(c){if(c.length){let p=c[c.length-1];if(!a)f=p.accuracy??null;let g=a?a.timestamp:-1/0,S=c.filter((b)=>On(b,t)&&b.timestamp>g).sort((b,I)=>b.timestamp-I.timestamp);for(let b of S){if(a&&b.timestamp<=a.timestamp)continue;m(b)}for(let b of c)if(Number.isFinite(b.timestamp)&&(l===null||b.timestamp>l))l=b.timestamp}return u=h(),u}}}function In(e,t={}){return be(t).add(e)}function No(e){if(e==null||e<=0||!Number.isFinite(e)||e>3600)return"–";let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Ho(e){return e!=null&&e>0&&Number.isFinite(e)?(e*3.6).toFixed(1):"–"}var Ot=3600,Pn=30000;function Ln(e,t,n){if(!n||t<=Ot)return e;return Math.max(e,Math.min(Pn,Math.round(e*t/Ot)))}function Do(e){let t=e.location,n=e.intervalMs??3000,r=Be,o=be(e),i=!1,a=null,s=0,l=e.heartRate,f=!1,u=null,m=[],h=()=>typeof document<"u"&&document.visibilityState==="hidden",c=0,p=null,g=Promise.resolve(),S=null,b=!1,I=null;function O(){if(b)throw Object.assign(Error("The recording screen is no longer active"),{code:"RECORDING_CONFLICT"});if(t.supportsRecordingOwnership?.()!==!0)throw Object.assign(Error("This host cannot protect native recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"})}function w(){if(O(),!I)throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});return I}function x(v){let A=g.then(v);return g=A.then(()=>{},()=>{}),A}function k(){if(p)return p;let v=c,A=I,C=(async()=>{if(O(),!A)throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});let P=o,j=P.latestTimestamp,F=await t.readRecording(j===null?{expectedId:A}:{expectedId:A,since:j});if(v!==c||b||P!==o)return P.add(F);if(j!==null&&F.length&&F[0].timestamp<=j)i=!0;return r=P.add(F),e.onUpdate?.(r),r})().finally(()=>{if(p===C)p=null});return p=C,C}function R(){if(N(),b)return;let v=s,A=()=>{a=setTimeout(()=>{if(a=null,b||v!==s)return;(h()?Promise.resolve():k().then(()=>{},()=>{})).then(()=>{if(!b&&v===s)A()})},Ln(n,r.fixes,i))};A()}function N(){if(s++,a)clearTimeout(a);a=null}function q(v,A,C,P=be(e)){if(N(),c++,p=null,o=P,i=!1,I=v,u=A,f=A!==null,m=[],r=C,!b)e.onUpdate?.(r)}async function fe(v){if(!l||!f||!u||b||l.supportsRecordingOwnership?.()!==!0)return;await v(l,u).catch(()=>{})}return{get stats(){return r},get recordingId(){return I},get heartRateRecordingId(){return u},get heartRate(){return m},start(v){return S=null,x(async()=>{if(O(),v&&t.supportsRecordingIntentIdentity?.()!==!0)throw Object.assign(Error("This host cannot start a registered route identity"),{code:"RECORDING_INTENT_IDENTITY_UNSUPPORTED"});if(v&&(typeof v.recordingId!=="string"||!v.recordingId.trim()))throw Object.assign(Error("A registered recording ID is required"),{code:"INVALID_ARGUMENT"});let A=await t.startRecording({enableHighAccuracy:!0,...e.locationOptions,...v?{recordingId:v.recordingId}:{}});if(!A?.active||typeof A.id!=="string"||!A.id.trim())throw Object.assign(Error("The native recording did not provide an ID"),{code:"RECORDING_CONFLICT"});if(v&&A.id!==v.recordingId)throw Object.assign(Error("The native route did not start with its registered ID"),{code:"RECORDING_CONFLICT"});let C=null;if(!b&&l?.isAvailable()&&l.supportsRecordingOwnership?.()===!0&&(!v||v.heartRateRecordingId&&l.supportsRecordingIntentIdentity?.()===!0))try{let P=await l.startRecording(v?{recordingId:v.heartRateRecordingId}:void 0);if(v&&P.id!==v.heartRateRecordingId)throw Object.assign(Error("The native heart rate did not start with its registered ID"),{code:"RECORDING_CONFLICT"});if(P.active&&typeof P.id==="string"&&P.id.trim())C=P.id}catch{}return q(A.id,C,{...Be}),R(),r})},attach(v){return S=null,x(async()=>{if(typeof v?.expectedId!=="string"||!v.expectedId.trim())throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"});O();let A=await t.getRecordingState({expectedId:v.expectedId});if(O(),!A?.id)return null;if(A.id!==v.expectedId)throw Object.assign(Error("The recording belongs to another session"),{code:"RECORDING_CONFLICT"});let C=null;if(v.expectedHeartRateId!==void 0){let F=v.expectedHeartRateId;if(typeof F!=="string"||!F.trim())throw Object.assign(Error("A saved heart-rate recording ID is required"),{code:"RECORDING_CONFLICT"});if(!l?.isAvailable()||l.supportsRecordingOwnership?.()!==!0)throw Object.assign(Error("This host cannot protect heart-rate recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"});let qt=await l.getRecordingState({expectedId:F});if(O(),qt.id!==F)throw Object.assign(Error("The heart-rate recording belongs to another session"),{code:"RECORDING_CONFLICT"});await l.readRecording({expectedId:F,since:Date.now()}),O(),C=F}let P=await t.readRecording({expectedId:v.expectedId});O();let j=be(e);if(q(v.expectedId,C,j.add(P),j),A.active&&!A.paused)R();return A})},pause(){return x(async()=>{await t.pauseRecording({expectedId:w()}),await fe((v,A)=>v.pauseRecording({expectedId:A})),N(),await k().catch(()=>{})})},resume(){return x(async()=>{await t.resumeRecording({expectedId:w()}),await fe((v,A)=>v.resumeRecording({expectedId:A})),R()})},stop(){if(S)return S;let v=x(async()=>{N(),c++;let A=w(),C=await t.stopRecording({expectedId:A});if(C.id!==A)throw Object.assign(Error("The native recording identity changed"),{code:"RECORDING_CONFLICT"});let P=C?.locations??[];if(!b&&l&&f&&u&&l.supportsRecordingOwnership?.()===!0){let j=await l.stopRecording({expectedId:u}).catch(()=>null);f=!1,m=j?.id===u?j.samples:[],P=Rn(P,m)}if(r=In(P,e),!b)e.onUpdate?.(r);return P}).catch((A)=>{if(S===v)S=null;throw A});return S=v,v},dispose(){b=!0,c++,p=null,N()},refresh:k}}function Bo(e){return{startedAt:Number.isFinite(e)?e:null,pausedAt:null,pausedMs:0}}function Fo(e,t){return e.startedAt===null||e.pausedAt!==null||!Number.isFinite(t)?e:{...e,pausedAt:Math.max(e.startedAt,t)}}function Uo(e,t){return e.pausedAt===null||!Number.isFinite(t)?e:{...e,pausedAt:null,pausedMs:e.pausedMs+Math.max(0,t-e.pausedAt)}}function Wo(e,t){if(e.startedAt===null)return 0;let n=((e.pausedAt??t)-e.startedAt-e.pausedMs)/1000;return Number.isFinite(n)?Math.max(0,n):0}var Ko=150;function Mn(e,t){let n=Math.PI/180,r=(t.latitude-e.latitude)*n,o=(t.longitude-e.longitude)*n,i=Math.sin(r/2)**2+Math.cos(e.latitude*n)*Math.cos(t.latitude*n)*Math.sin(o/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(i)))}function ve(e,t){let n=[...e].sort((r,o)=>r-o);return n[Math.min(n.length-1,Math.floor(t*n.length))]}function jo(e,t){let n=(e||[]).filter((a)=>Number.isFinite(a?.latitude)&&Number.isFinite(a?.longitude)&&Math.abs(a.latitude)<=90&&Math.abs(a.longitude)<=180),r=n.filter((a)=>a.accuracy!=null).map((a)=>Number(a.accuracy)).filter((a)=>Number.isFinite(a)&&a>=0),o=r.length?ve(r,0.5):Number.POSITIVE_INFINITY,i=0;if(n.length){let a={latitude:ve(n.map((s)=>s.latitude),0.5),longitude:ve(n.map((s)=>s.longitude),0.5)};i=ve(n.map((s)=>Mn(a,s)),0.8)}if(n.length>=10&&i>150&&o<=15)return"outside";if(t<150)return"unsure";if(n.length<3||o>30||i<25)return"indoors";if(i<50&&o>10)return"indoors";return"unsure"}function zo(e,t={}){let r=String(e||"").trim().toLowerCase().replace(",",".").match(/^(\d+(?:\.\d*)?|\.\d+)\s*(km|k|m|mi)?$/);if(!r)return null;let o=Number(r[1]),i=r[2]||t.defaultUnit||(o>100?"m":"km"),a=i==="m"?o/1000:i==="mi"?o*1.609344:o;return Number.isFinite(a)&&a>=0&&a<=2000?Math.round(a*1000)/1000:null}var we=new Set,It=!1,ye=null;function Cn(e){return e.isConnected&&e.getClientRects().length>0}function Pt(){return[...we].find((e)=>Cn(e.element))}function Se(){let e=Pt(),t=Boolean(e);if(t===It)return;if(It=t,t)V.enable(e?.tintColor?{tintColor:e.tintColor}:{});else V.disable()}function Nn(){let e=Pt();if(!e){V.end();return}Promise.resolve().then(()=>e.run()).catch(()=>{}).finally(()=>V.end())}function Go(e,t){let n={element:e,tintColor:t.tintColor,run:t.onRefresh};we.add(n);let r=e.ownerDocument?.defaultView;if(!ye){let o=V.onRefresh(Nn),i=()=>Se();r?.addEventListener("stx:load",i),ye=()=>{o(),r?.removeEventListener("stx:load",i)}}return Se(),r?.requestAnimationFrame?.(()=>Se()),()=>{if(we.delete(n),we.size===0)ye?.(),ye=null;Se()}}var Xo=0.5;function Hn(e,t,n){let r=[];if(n.includes("large")||n.length===0)r.push({name:"large",y:0});if(n.includes("medium"))r.push({name:"medium",y:Math.max(0,Math.round(e-t*0.5))});return r.push({name:"dismiss",y:Math.max(1,e)}),r.sort((o,i)=>o.y-i.y)}function Dn(e){let{y:t,velocity:n,stops:r}=e,o=r.filter((s)=>s.name!=="dismiss"),i=r.find((s)=>s.name==="dismiss");if(o.length===0)return"dismiss";if(n>0.5)return(r.filter((l)=>l.y>t+1)[0]??i).name;if(n<-0.5){let s=o.filter((l)=>l.y<t-1);return(s[s.length-1]??o[0]).name}let a=o[o.length-1];if(t>a.y+(i.y-a.y)*0.5)return"dismiss";return o.reduce((s,l)=>Math.abs(l.y-t)<Math.abs(s.y-t)?l:s).name}function _n(e,t=400){if(e<=0)return 0;return e*t*0.55/(t+e*0.55)}function Qo(e){let{panel:t}=e,n=null,r=[],o=0,i=()=>e.viewport?.()??t.ownerDocument?.defaultView?.innerHeight??800,a=()=>Hn(t.offsetHeight||t.getBoundingClientRect().height,i(),e.detents()),s=(u)=>{let m=u;if(m.button!==void 0&&m.button!==0)return;if(m.target?.closest?.("button, a, input, select, textarea, [role=button]"))return;let h=a().find((c)=>c.name===e.detent())?.y??0;n={y:m.clientY,base:h,pointerId:m.pointerId},o=h,r=[{y:h,t:m.timeStamp}],t.classList.add("is-dragging");try{u.currentTarget?.setPointerCapture?.(m.pointerId)}catch{}},l=(u)=>{if(!n)return;let m=u,h=n.base+m.clientY-n.y;o=h<0?-_n(-h):h,r.push({y:o,t:m.timeStamp});while(r.length>2&&m.timeStamp-r[0].t>100)r.shift();t.style.transform=`translateY(${o}px)`;let c=t.offsetHeight||1;t.parentElement?.style.setProperty("--native-sheet-presence",String(Math.max(0,Math.min(1,1-o/c))))},f=(u)=>{if(!n)return;let m=u;n=null;let h=r[0],c=Math.max(1,m.timeStamp-h.t),p=(o-h.y)/c;t.classList.remove("is-dragging"),t.style.transform="",t.parentElement?.style.removeProperty("--native-sheet-presence"),e.onSettle(Dn({y:o,velocity:p,stops:a()}))};for(let u of e.handles)u.addEventListener("pointerdown",s),u.addEventListener("pointermove",l),u.addEventListener("pointerup",f),u.addEventListener("pointercancel",f);return()=>{for(let u of e.handles)u.removeEventListener("pointerdown",s),u.removeEventListener("pointermove",l),u.removeEventListener("pointerup",f),u.removeEventListener("pointercancel",f)}}function Jo(e){let t=e.ownerDocument;if(e.parentElement===t.body)return()=>{};let n=t.createComment("native-sheet");return e.parentNode?.insertBefore(n,e),t.body.appendChild(e),()=>{if(n.parentNode)n.parentNode.insertBefore(e,n);else e.remove();n.remove()}}var Fe=new WeakMap;function Zo(e,t){let n=e.documentElement,r=Fe.get(e)??0;if(!t){let a=Math.max(0,r-1);if(Fe.set(e,a),a===0)n.removeAttribute("data-native-sheet-card");return}if(Fe.set(e,r+1),r>0)return;let o=e.defaultView,i=(o?.scrollY??0)+(o?.innerHeight??800)/2;n.style.setProperty("--native-sheet-card-origin",`${Math.round(i)}px`),n.setAttribute("data-native-sheet-card","")}function Bn(e,t){e.style.setProperty("--native-font-scale",String(t.fontScale)),e.toggleAttribute("data-native-reduce-motion",t.reduceMotion),e.toggleAttribute("data-native-reduce-transparency",t.reduceTransparency)}function Fn(e){let t=e.replace(/\s+/g,"").toLowerCase();return!t||t==="transparent"||/^rgba\(\d+,\d+,\d+,0(\.0+)?\)$/.test(t)||/\/0(\.0+)?\)$/.test(t)}function Un(e){let t=e.defaultView;if(!t?.getComputedStyle)return null;for(let n of[e.body,e.documentElement]){if(!n)continue;let r=t.getComputedStyle(n).backgroundColor;if(r&&!Fn(r))return r}return null}function Wn(e){if(e.documentElement.classList.contains("dark"))return!0;if(e.documentElement.classList.contains("light"))return!1;return Boolean(e.defaultView?.matchMedia?.("(prefers-color-scheme: dark)").matches)}function ri(e,t={}){let n=t.root??e.documentElement;ie.setKeyboardAccessory(t.keyboardAccessory===!0);let r="",o="",i=()=>{let u=Un(e);if(u&&u!==r)r=u,ie.setUnderPageColor(u);let m=Wn(e)?"light":"dark";if(m!==o)o=m,ge.setStyle(m)},a=Rt((u)=>{Bn(n,u),i()}),s=e.defaultView,l=typeof s?.MutationObserver==="function"?new s.MutationObserver(i):null;l?.observe(e.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme"]});let f=s?.matchMedia?.("(prefers-color-scheme: dark)");return f?.addEventListener?.("change",i),s?.addEventListener("stx:load",i),i(),()=>{a(),l?.disconnect(),f?.removeEventListener?.("change",i),s?.removeEventListener("stx:load",i)}}var ii=64;var $n=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Kn=/^(?:0|[1-9]\d*)$/;function Mt(e){let t=[],n=[],r=e&&typeof e==="object"&&!Array.isArray(e)?e:{};for(let[o,i]of Object.entries(r)){let a=i&&typeof i==="object"?i:null;if(!a){n.push(`spotlight kind "${o}" is not an object`);continue}let{slots:s,route:l}=a,f=typeof a.noun==="string"&&a.noun.trim()?a.noun.trim():"Item";if(!$n.test(o)||o.includes("-slot-")){n.push(`spotlight kind "${o}" is not a usable name: lowercase letters, digits and single dashes, and never "-slot-"`);continue}if(typeof s!=="number"||!Number.isInteger(s)||s<=0||s>64){n.push(`spotlight kind "${o}" needs slots between 1 and 64, not ${String(s)}`);continue}if(typeof l!=="string"||!l.startsWith("/")||!l.includes(":id")){n.push(`spotlight kind "${o}" needs a route starting with "/" and carrying ":id", not ${String(l)}`);continue}t.push({name:o,slots:s,route:l,noun:f})}return{kinds:t,problems:n}}function ce(e,t){return e.find((n)=>n.name===t)??null}function le(e,t,n){let r=ce(e,t);if(!r||!Number.isInteger(n)||n<0||n>=r.slots)return null;return`${t}-slot-${n}`}function jn(e,t){if(typeof t!=="string")return null;let n=t.lastIndexOf("-slot-");if(n<=0)return null;let r=t.slice(0,n),o=t.slice(n+6);if(!Kn.test(o))return null;let i=Number(o);return le(e,r,i)===t?{kind:r,slot:i}:null}function Ct(e){return e.flatMap((t)=>Array.from({length:t.slots},(n,r)=>`${t.name}-slot-${r}`))}function ai(e,t){let n=e&&typeof e==="object"?e:{};if(n.enabled===!1)return[];let o=[...(Array.isArray(n.activityTypes)?n.activityTypes.filter((i)=>typeof i==="string"&&i.trim().length>0):[]).map((i)=>i.trim()),...Ct(Mt(n.kinds).kinds)];return[...new Set(o)].map((i)=>`${t}.${i}`)}function Nt(e,t,n){let r=typeof n.name==="string"?n.name.replace(/\s+/g," ").trim():"";if(!r)return`${ce(e,t)?.noun??"Item"} #${n.id}`;return r.length>120?`${r.slice(0,119).trimEnd()}…`:r}function zn(e,t,n,r,o=Date.now()){let i=ce(e,n);if(!i||!Number.isInteger(r.id)||r.id<=0)return null;let a=t.filter((p)=>p.kind===n),s=Nt(e,n,r),l=a.find((p)=>p.itemId===r.id)??null,f=l?null:Yn(a,i.slots),u=l||f!==null?null:Xn(a),m=l?.slot??f??u?.slot;if(m===void 0||m===null)return null;let h={kind:n,slot:m,itemId:r.id,title:s,donatedAt:o},c=t.filter((p)=>p.kind!==n||p.slot!==m&&p.itemId!==r.id);return{entries:Ht(e,[...c,h]),entry:h,evicted:u,changed:!l||l.title!==s}}function qn(e,t,n){let r=e.find((o)=>o.kind===t&&o.itemId===n)??null;return{entries:r?e.filter((o)=>o!==r):[...e],removed:r}}function Vn(e,t,n){let r=jn(e,n);if(!r)return null;let o=t.find((a)=>a.kind===r.kind&&a.slot===r.slot),i=ce(e,r.kind)?.route;return o&&i?i.replace(":id",String(o.itemId)):null}function Gn(e,t){if(!Array.isArray(t))return[];let n=new Map,r=new Set;for(let o of t){if(!o||typeof o!=="object")continue;let i=o,{kind:a,slot:s,itemId:l,title:f,donatedAt:u}=i;if(typeof a!=="string"||typeof s!=="number"||le(e,a,s)===null)continue;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)continue;let m=`${a}-slot-${s}`,h=`${a}#${l}`;if(n.has(m)||r.has(h))continue;n.set(m,{kind:a,slot:s,itemId:l,title:typeof f==="string"&&f.trim()?f:Nt(e,a,{id:l}),donatedAt:typeof u==="number"&&Number.isFinite(u)&&u>0?u:0}),r.add(h)}return Ht(e,[...n.values()])}function Ht(e,t){let n=new Map(e.map((r,o)=>[r.name,o]));return[...t].sort((r,o)=>(n.get(r.kind)??0)-(n.get(o.kind)??0)||r.slot-o.slot)}function Yn(e,t){let n=new Set(e.map((r)=>r.slot));for(let r=0;r<t;r++)if(!n.has(r))return r;return null}function Xn(e){return e.reduce((t,n)=>!t||n.donatedAt<t.donatedAt?n:t,null)}function Qn(){let e=globalThis.craft;return e&&typeof e==="object"?e.siri:void 0}var Jn="stacks_spotlight_index",Zn=3000;function si(e){let t=e.onProblem??((w)=>console.warn(`[spotlight] ${w}`)),n=Array.isArray(e.kinds)?{kinds:[...e.kinds],problems:[]}:Mt(e.kinds);for(let w of n.problems)t(w);let r=e.enabled===!1?[]:n.kinds,o=e.storageKey??Jn,i=e.legacyStorageKeys??[],a=e.timeoutMs??Zn,s=e.now??(()=>Date.now()),l=e.bridge??Qn,f=null;function u(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function m(){if(f)return f;f=[];let w=u();if(!w)return f;try{let x=[o,...i].map((k)=>w.getItem(k)).find((k)=>k);f=x?Gn(r,JSON.parse(x)):[]}catch{f=[]}return f}function h(w){f=w;let x=u();if(!x)return;try{x.setItem(o,JSON.stringify(w));for(let k of i)x.removeItem(k)}catch{}}async function c(w){if(!w)return null;let x;try{return await Promise.race([w,new Promise((k)=>{x=setTimeout(()=>k(null),a)})])}catch{return null}finally{if(x!==void 0)clearTimeout(x)}}let p=Promise.resolve();function g(w){let x=p.then(w,w);return p=x.catch(()=>{return}),x}async function S(w,x){let k=l()?.register;if(!k||r.length===0)return!1;return g(async()=>{let R=zn(r,m(),w,x,s()),N=R&&le(r,w,R.entry.slot);if(!R||!N)return!1;if(!R.changed)return h(R.entries),!0;let q=await c(k(R.entry.title,N))!==null;if(q)h(R.entries);return q})}async function b(w,x){let k=l()?.remove;if(!k)return!1;return g(async()=>{let{entries:R,removed:N}=qn(m(),w,x);if(!N)return!1;let q=le(r,w,N.slot),fe=q?await c(k(q))!==null:!1;return h(R),fe})}async function I(w,x){let k=ce(r,w)?.slots;if(!k||!l()?.register)return 0;let R=0;for(let N of[...x].slice(0,k).reverse())if(await S(w,N))R++;return R}async function O(){let w=l()?.remove;if(!w)return h([]),0;return g(async()=>{let x=0;for(let k of m()){let R=le(r,k.kind,k.slot);if(R&&await c(w(R))!==null)x++}return h([]),x})}return{kinds:r,index:S,sync:I,remove:b,clear:O,routeFor:(w)=>Vn(r,m(),w),entries:()=>m(),activityTypes:(w)=>Ct(r).map((x)=>`${w}.${x}`),reset:()=>{f=null}}}var Lt=["craftShortcut","craftSiriShortcut"];function li(e,t){let n=(r)=>{let o=r.detail,i=typeof o==="string"?o:o&&typeof o==="object"?o.action??o.type:null,a=typeof i==="string"?e.routeFor(i):null;if(a)t(a)};if(typeof globalThis.addEventListener!=="function")return()=>{};for(let r of Lt)globalThis.addEventListener(r,n);return()=>{for(let r of Lt)globalThis.removeEventListener(r,n)}}import{tabBar as er}from"craft-native/mobile";var tr=er;function nr(e){return Array.from(e.querySelectorAll("a[data-native-tab]")).map((t)=>({id:t.getAttribute("href")||"",title:t.getAttribute("data-native-tab")||t.getAttribute("aria-label")||"",symbol:t.getAttribute("data-native-tab-symbol")||"circle",badge:(t.querySelector(".native-tab-badge")?.textContent||"").trim(),current:t.hasAttribute("data-stx-nav-current")||t.classList.contains("is-active")})).filter((t)=>t.id&&t.title)}function rr(e){return{tabs:e.map(({id:n,title:r,symbol:o,badge:i})=>i?{id:n,title:r,symbol:o,badge:i}:{id:n,title:r,symbol:o}),selected:e.find((n)=>n.current)?.id}}function _t(){if(typeof window>"u")return;let e=window.stxRouter;return e&&typeof e==="object"?e:void 0}function or(){return typeof _t()?.selectTab==="function"}function di(e,t={}){let n=(r)=>{if(or()||r.defaultPrevented)return;let o=r.target?.closest?.("a[data-native-tab]");if(!o||!e.contains(o))return;if(!o.hasAttribute("data-stx-nav-current")&&!o.classList.contains("is-active")&&o.getAttribute("aria-current")!=="page")return;r.preventDefault();let i=e.ownerDocument.defaultView;if(t.scrollToTop)t.scrollToTop();else i?.scrollTo?.({top:0,behavior:i.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"});i?.dispatchEvent(new CustomEvent("stx:tabreselect",{detail:{href:o.getAttribute("href")||""}}))};return e.addEventListener("click",n),()=>e.removeEventListener("click",n)}function Dt(e){let t=e.trim();return/^#[0-9a-f]{6}$/i.test(t)?t:void 0}var Ue="stacks:tab-bar-cover";function pi(e,t){if(t)e.setAttribute("data-native-covers-tab-bar","");else e.removeAttribute("data-native-covers-tab-bar");e.ownerDocument?.defaultView?.dispatchEvent(new Event(Ue))}function fi(e,t={}){let n=t.api??tr;if(!n.isAvailable())return null;let r=t.hidden??(()=>Boolean(e.ownerDocument?.querySelector("[data-native-hide-tab-bar], [data-native-covers-tab-bar]"))),o=typeof getComputedStyle==="function"?getComputedStyle(e):null,i=Dt(o?.getPropertyValue("--native-tab-active")||""),a=Dt(o?.getPropertyValue("--native-tab-active-dark")||""),s="",l=()=>{if(r()){if(s!=="hidden")n.hide();s="hidden";return}let{tabs:h,selected:c}=rr(nr(e)),p=JSON.stringify({tabs:h,selected:c});if(p===s)return;let g=s&&s!=="hidden"?JSON.parse(s):null;if(g&&c&&JSON.stringify(g.tabs)===JSON.stringify(h))n.select(c);else n.set(h,{selected:c,tint:i,tintDark:a});s=p},f=typeof MutationObserver==="function"?new MutationObserver(l):null;f?.observe(e,{attributes:!0,attributeFilter:["data-stx-nav-current","class"],childList:!0,subtree:!0,characterData:!0});let u=n.onSelect((h)=>{let c=_t();if(c?.selectTab){c.selectTab(h);return}Array.from(e.querySelectorAll("a[data-native-tab]")).find((g)=>g.getAttribute("href")===h)?.click()}),m=()=>l();if(typeof window<"u")window.addEventListener("stx:load",m),window.addEventListener("stx:screen-shown",m),window.addEventListener(Ue,m);return l(),()=>{if(f?.disconnect(),u(),typeof window<"u")window.removeEventListener("stx:load",m),window.removeEventListener("stx:screen-shown",m),window.removeEventListener(Ue,m);n.hide()}}function ir(e={}){let t=e.maxSeconds??300,n=e.maxBytes??12582912;if(![t,n].every((g)=>Number.isSafeInteger(g)&&g>0)||t>300)throw TypeError("Invalid voice recording limits");let r={status:"idle",audio:null,error:null},o=new Set,i={},a=null,s=null,l=null,f,u=(g)=>{r=g;for(let S of o)S({...g})},m=()=>{clearTimeout(f),l?.getTracks().forEach((g)=>g.stop()),l=null};function h(){if(i={},a){let S=a;a=null,Promise.resolve(L("audioRecording.cancel")?.(S)).catch(()=>{})}let g=s;if(s=null,g&&g.state!=="inactive")g.stop();m(),u({status:"idle",audio:null,error:null})}async function c(){h();let g=i;u({status:"requesting",audio:null,error:null});try{let S=L("audioRecording.start");if(S){let R=globalThis.crypto.randomUUID();if(a=R,await S(R,{maxSeconds:t}),i!==g)return;f=setTimeout(()=>{if(i===g)p()},t*1000-250),u({status:"recording",audio:null,error:null});return}if(typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>"u")throw Error("Microphone recording is unavailable. Upload an audio recording instead.");let b=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1},video:!1});if(i!==g){b.getTracks().forEach((R)=>R.stop());return}l=b;let I=["audio/webm;codecs=opus","audio/mp4","audio/webm"].find((R)=>MediaRecorder.isTypeSupported(R)),O=new MediaRecorder(b,{...I?{mimeType:I}:{},audioBitsPerSecond:32000});s=O;let w=[],x=0,k=!1;O.ondataavailable=(R)=>{if(i!==g||!R.data.size)return;if(x+=R.data.size,x>n){if(k=!0,w.length=0,O.state!=="inactive")O.stop();m();return}if(!k)w.push(R.data)},O.onerror=()=>{if(i!==g)return;h(),u({status:"error",audio:null,error:"Recording failed. Please try again."})},O.onstop=()=>{if(i!==g)return;s=null,m();let R=new Blob(w,{type:O.mimeType||I||"audio/webm"});u(k||!R.size?{status:"error",audio:null,error:k?"The recording exceeds the upload limit.":"The recording was empty."}:{status:"ready",audio:R,error:null})},O.start(1000),f=setTimeout(()=>{if(i===g&&O.state!=="inactive")O.stop()},t*1000-250),u({status:"recording",audio:null,error:null})}catch(S){if(i!==g)return;h(),u({status:"error",audio:null,error:S instanceof Error?S.message:"Microphone permission was refused."})}}async function p(){if(!a){if(s&&s.state!=="inactive")s.stop();return}let g=i,S=a;clearTimeout(f);try{let b=await L("audioRecording.stop")?.(S);if(i!==g)return;if(!b?.path||!b.size||b.size>n||!Number.isFinite(b.durationSeconds)||b.durationSeconds<=0||b.durationSeconds>t+1)throw Error("The recording is empty or exceeds its limits.");u({status:"ready",audio:b,error:null})}catch(b){if(i!==g)return;h(),u({status:"error",audio:null,error:b instanceof Error?b.message:"Recording failed."})}}return{start:c,cancel:h,dispose(){h(),o.clear()},stop:p,supported:()=>Boolean(L("audioRecording.start"))||typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getUserMedia)&&typeof MediaRecorder<"u",snapshot:()=>({...r}),subscribe(g){return o.add(g),g({...r}),()=>{o.delete(g)}}}}function ar(e,t={},n="audio"){if(!n||Object.hasOwn(t,n))throw TypeError("Use a distinct recording field name");let r=new FormData;if(typeof Blob<"u"&&e instanceof Blob)r.append(n,e,"feedback");else{if(!e||!("path"in e)||typeof e.path!=="string"||!e.path||!L("audioRecording.stop"))throw TypeError("A native recording requires its native upload host");Reflect.apply(r.append,r,[n,e]);let o=r.get(n);if(!o||typeof o!=="object"||!("path"in o)||o.path!==e.path)throw TypeError("The upload host did not preserve the native recording file")}for(let[o,i]of Object.entries(t)){if(typeof i!=="string")throw TypeError("Upload fields must be strings");r.append(o,i)}return r}var ur={isAvailable:()=>d(()=>We.isAvailable()),getBiometricType:()=>d(()=>We.getBiometricType()),authenticate:(e)=>d(()=>We.authenticate(e))},dr={takePicture:(e)=>d(()=>Re.takePicture(e)),pickImage:()=>d(()=>Re.pickImage()),pickMultiple:(e)=>d(()=>Re.pickMultiple(e)),isAvailable:()=>d(()=>Re.isAvailable())},pr={getInfo:()=>d(()=>Z.getInfo()),getCapabilities:()=>d(()=>Z.getCapabilities()),isMobile:()=>Z.isMobile(),isIOS:()=>Z.isIOS(),isAndroid:()=>Z.isAndroid(),getLocale:()=>Z.getLocale(),getTimezone:()=>Z.getTimezone()},fr=lr;function G(){return X()?.capabilities.locationRecordingOwnership===!0&&_.supportsRecordingOwnership?.()===!0}function Y(){return X()?.capabilities.heartRateRecordingOwnership===!0&&E.supportsRecordingOwnership?.()===!0}function $t(){return G()&&X()?.capabilities.locationRecordingIntentIdentity===!0&&_.supportsRecordingIntentIdentity?.()===!0}function Kt(){return Y()&&X()?.capabilities.heartRateRecordingIntentIdentity===!0&&E.supportsRecordingIntentIdentity?.()===!0}function zt(e,t,n){return d(async()=>{let r=e&&Object.hasOwn(e,"recordingId");if(r){if(!t())throw Object.assign(Error("This host or adapter cannot start a registered recording identity"),{code:"RECORDING_INTENT_IDENTITY_UNSUPPORTED"});if(typeof e.recordingId!=="string"||!e.recordingId.trim())throw Object.assign(Error("A registered recording ID is required"),{code:"INVALID_ARGUMENT"})}let o=await n();if(r&&o.id!==e.recordingId)throw Object.assign(Error("The native recording identity changed at start"),{code:"RECORDING_CONFLICT"});return o})}function B(e,t,n){return d(()=>{if(e&&Object.hasOwn(e,"expectedId")){if(!t())throw Object.assign(Error("This host or adapter cannot protect recording ownership"),{code:"RECORDING_OWNERSHIP_UNSUPPORTED"});if(typeof e.expectedId!=="string"||!e.expectedId.trim())throw Object.assign(Error("A saved recording ID is required"),{code:"RECORDING_CONFLICT"})}return n()})}var mr={supportsRecordingOwnership:G,supportsRecordingIntentIdentity:$t,acknowledgeRecording:(e)=>B({expectedId:e?.expectedId},G,()=>_.acknowledgeRecording(e)),getCurrentPosition:(e)=>d(()=>_.getCurrentPosition(e)),watchPosition:(e,t)=>_.watchPosition(e,t),clearWatch:(e)=>_.clearWatch(e),startRecording:(e)=>zt(e,$t,()=>_.startRecording(e)),pauseRecording:(e)=>B(e,G,()=>_.pauseRecording(e)),resumeRecording:(e)=>B(e,G,()=>_.resumeRecording(e)),stopRecording:(e)=>B(e,G,()=>_.stopRecording(e)),getRecordingState:(e)=>B(e,G,()=>_.getRecordingState(e)),readRecording:(e)=>B(e,G,()=>_.readRecording(e))},gr={show:(e)=>d(()=>ke.show(e)),schedule:(e)=>d(()=>ke.schedule(e)),cancelAll:()=>d(()=>ke.cancelAll()),setBadge:(e)=>d(()=>ke.setBadge(e))},hr={check:(e)=>d(()=>de.check(e)),request:(e)=>d(()=>de.request(e)),checkMultiple:(e)=>d(()=>de.checkMultiple(e)),requestMultiple:(e)=>d(()=>de.requestMultiple(e)),openSettings:()=>d(()=>de.openSettings())},br={set:(e,t)=>d(()=>Te.set(e,t)),get:(e)=>d(()=>Te.get(e)),delete:(e)=>d(()=>Te.delete(e)),clear:()=>d(()=>Te.clear())},vr={share:(e)=>d(()=>Wt.share(e)),isAvailable:()=>Wt.isAvailable()},yr={request:()=>d(()=>sr.request())},Oe={impact:(e)=>Promise.resolve().then(()=>Ae.impact(e)).catch(()=>{}),notification:(e)=>Promise.resolve().then(()=>Ae.notification(e)).catch(()=>{}),selection:()=>Promise.resolve().then(()=>Ae.selection()).catch(()=>{}),vibrate:(e)=>Promise.resolve().then(()=>Ae.vibrate(e)).catch(()=>{}),prepare:(e)=>{let t=L("haptics.prepare");return t?Promise.resolve().then(()=>t(e)).then(()=>{},()=>{}):Promise.resolve()}};function jt(e){if(typeof e==="string")return e.trim()||null;if(!e||typeof e!=="object")return null;let t=e.url;return typeof t==="string"&&t.trim()?t:null}var Sr={async getInitialURL(){if(!await ee())return null;return jt(await Bt.getInitialURL?.())},onLink(e){let t=null,n=!1,r=()=>{if(n)return;t=Bt.onLink?.((o,i)=>{let a=jt(o);if(a)e(a,{initial:i?.initial===!0})})??null};if(Ie()?.craft)r();else ee().then(r);return()=>{n=!0,t?.()}}},Ri={isAvailable:()=>Ee.isAvailable(),set:(e,t)=>Ee.set(e,t),remove:(e)=>Ee.remove(e),clear:()=>Ee.clear()},wr={enable:()=>d(()=>Ft.enable()),disable:()=>d(()=>Ft.disable())},xr={isAvailable:()=>xe.isAvailable(),get:()=>d(()=>xe.get()),set:(e)=>d(()=>xe.set(e)),restore:()=>d(()=>xe.restore())},Rr={isAvailable:()=>K.isAvailable(),supports:(e)=>K.supports(e),getAuthorizationStatus:()=>d(()=>K.getAuthorizationStatus()),requestAuthorization:()=>d(()=>K.requestAuthorization()),getNowPlaying:()=>d(()=>K.getNowPlaying()),play:()=>d(()=>K.play()),pause:()=>d(()=>K.pause()),togglePlayPause:()=>d(()=>K.togglePlayPause()),skipToNext:()=>d(()=>K.skipToNext()),skipToPrevious:(e)=>d(()=>K.skipToPrevious(e)),onChange:(e)=>J(()=>K.onChange(e))},Ar={supportsRecordingOwnership:Y,supportsRecordingIntentIdentity:Kt,acknowledgeRecording:(e)=>B({expectedId:e?.expectedId},Y,()=>E.acknowledgeRecording(e)),isAvailable:()=>E.isAvailable(),supports:(e)=>E.supports(e),getState:()=>d(()=>E.getState()),requestAuthorization:()=>d(()=>E.requestAuthorization()),scan:(e)=>d(()=>E.scan(e)),stopScan:()=>d(()=>E.stopScan()),getDevices:()=>d(()=>E.getDevices()),connect:(e)=>d(()=>E.connect(e)),reconnect:()=>d(()=>E.reconnect()),disconnect:(e)=>d(()=>E.disconnect(e)),startRecording:(e)=>zt(e,Kt,()=>E.startRecording(e)),pauseRecording:(e)=>B(e,Y,()=>E.pauseRecording(e)),resumeRecording:(e)=>B(e,Y,()=>E.resumeRecording(e)),stopRecording:(e)=>B(e,Y,()=>E.stopRecording(e)),getRecordingState:(e)=>B(e,Y,()=>E.getRecordingState(e)),readRecording:(e)=>B(e,Y,()=>E.readRecording(e)),onReading:(e)=>J(()=>E.onReading(e)),onDevice:(e)=>J(()=>E.onDevice(e)),onState:(e)=>J(()=>E.onState(e))},kr={isAvailable:()=>je.isAvailable(),speak:(e,t)=>d(()=>je.speak(e,t)),stop:()=>d(()=>je.stop())},Tr={getStatus:()=>d(()=>Ut.getStatus()),onChange:(e)=>J(()=>Ut.onChange(e))},Er={register:()=>d(()=>Ke.register()),onToken:(e)=>Ke.onToken(e),onNotification:(e)=>J(()=>Ke.onNotification(e))},Or={requestAuthorization:(e,t)=>d(()=>ue.requestAuthorization(e,t)),getData:(e,t)=>d(()=>ue.getData(e,t)),saveWorkout:(e)=>d(()=>ue.saveWorkout(e)),getWorkouts:(e)=>d(()=>ue.getWorkouts(e)),getDailyStatistics:(e,t)=>d(()=>ue.getDailyStatistics(e,t)),getHeartRateSamples:(e)=>y("health.getHeartRateSamples",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),getSamples:(e,t)=>y("health.getSamples",[e,t??{}],()=>[]).then((n)=>Array.isArray(n)?n:[]),getSleepIntervals:(e)=>y("health.getSleepIntervals",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),saveMindfulSession:(e)=>y("health.saveMindfulSession",[e],()=>null).then((t)=>t??null),getMindfulSessions:(e)=>y("health.getMindfulSessions",[e??{}],()=>[]).then((t)=>Array.isArray(t)?t:[]),startHeartRateUpdates:(e)=>y("health.startHeartRateUpdates",[e??{}],()=>!1).then((t)=>t!==!1),stopHeartRateUpdates:()=>y("health.stopHeartRateUpdates",[],()=>!0).then(()=>!0),onHeartRate:(e)=>U("craftHealthHeartRate",(t)=>{if(Array.isArray(t.samples)&&t.samples.length)e(t.samples)}),supports:(e)=>L(`health.${e}`)!==null},Ir={start:(e)=>d(()=>$e.start(e)),update:(e)=>d(()=>$e.update(e)),end:()=>d(()=>$e.end())},Pr={send:(e)=>d(()=>pe.send(e)),updateContext:(e)=>d(()=>pe.updateContext(e)),isReachable:()=>d(()=>pe.isReachable()),onMessage:(e)=>pe.onMessage(e),onReachabilityChange:(e)=>pe.onReachabilityChange(e)},Ai=cr;function Ie(){return T()}function X(){let e=Ie()?.craft;if(!e||typeof e!=="object")return null;if(!("platform"in e)||e.platform!=="ios"&&e.platform!=="android")return null;let t="capabilities"in e?e.capabilities:void 0,n=t&&typeof t==="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,r])=>typeof r==="boolean")):{};return{platform:e.platform,capabilities:n}}function ze(){return X()!==null}function Lr(e=2000){if(ze()||re())return Promise.resolve(!0);let t=Ie();if(!t||!(t.craft||t.webkit?.messageHandlers?.craft))return Promise.resolve(!1);return new Promise((n)=>{let r=()=>{clearTimeout(o),t.removeEventListener("craftReady",r),n(ze())},o=setTimeout(r,e);t.addEventListener("craftReady",r,{once:!0})})}function Mr(e){let t=Ie();if(!t)return()=>{};if(X()){let r=!1;return queueMicrotask(()=>{if(!r)e(new Event("craftReady"))}),()=>{r=!0}}let n=(r)=>{if(!X())return;t.removeEventListener("craftReady",n),e(r)};return t.addEventListener("craftReady",n),()=>t.removeEventListener("craftReady",n)}async function Cr(e){await Oe.impact("light");try{let t=await e();return await Oe.notification("success"),t}catch(t){throw await Oe.notification("error"),t}}var ki={get nativeBridge(){return X()},biometrics:ur,camera:dr,device:pr,haptics:Oe,lifecycle:fr,location:mr,notifications:gr,permissions:hr,secureStorage:br,storage:ht,crypto:bt,share:vr,appReview:yr,deepLinks:Sr,keepAwake:wr,brightness:xr,music:Rr,heartRate:Ar,scheduledWorkouts:yt,speech:kr,network:Tr,pushNotifications:Er,health:Or,liveActivities:Ir,watchConnectivity:Pr,dialog:oe,contextMenu:He,browser:ot,symbols:it,statusBar:ge,chrome:ie,refresh:V,background:ae,clipboard:at,db:st,files:lt,shortcuts:ct,widgets:ut,orientation:dt,auth:pt,storeKit:ft,isNativeMobile:ze,whenNative:Lr,onReady:Mr,withFeedback:Cr};export{Nr as BRIDGE_WAIT_MS,Mo as HEART_RATE_MATCH_MS,Ko as INDOOR_CHECK_AFTER_S,ii as MAX_SPOTLIGHT_SLOTS_PER_KIND,Ot as ROUTE_FULL_READ_FIXES,Pn as ROUTE_FULL_READ_MAX_MS,kn as ROUTE_GAP_S,Xo as SHEET_FLICK_VELOCITY,Ue as TAB_BAR_COVER_EVENT,d as afterBridge,yr as appReview,Bn as applyAppearance,Rn as attachHeartRate,pt as auth,ko as backLabelFor,ae as background,ur as biometrics,me as bridgePending,xr as brightness,ot as browser,y as callNative,dr as camera,yn as canGoBack,ie as chrome,at as clipboard,Wr as confirmAction,He as contextMenu,pi as coverTabBar,T as craftHost,Q as craftRoot,lo as crashReporting,Do as createRouteRecorder,be as createRouteStats,si as createSpotlightIndex,ir as createVoiceRecorder,bt as crypto,xt as currentAppearance,st as db,wn as deepLinkPath,Sr as deepLinks,pr as device,oe as dialog,Ao as enterNavTrail,lt as files,En as fixDistance,no as focusSegment,Po as followDeepLinks,X as getNativeMobileBridge,Ro as goBack,Oo as goBackToTabRoot,di as handleTabReselect,Oe as haptics,re as hasNativeMobileHost,Or as health,Ar as heartRate,jo as indoorVerdict,ri as installNativeChrome,ro as installPressables,ze as isNativeMobile,Cn as isShown,wr as keepAwake,dn as keepBreadcrumb,bn as largeTitleMetrics,fr as lifecycle,Jo as liftToBody,Ir as liveActivities,mr as location,fi as mirrorTabBar,ki as mobile,Rr as music,Yt as nativeFunction,L as nativeFunctionNow,rr as nativeTabs,To as navTrail,Tr as network,fn as normalizeAppearance,jt as normalizeDeepLinkURL,ln as normalizeScheduledWorkout,gr as notifications,So as observeLargeTitle,Zr as observeLongPress,Go as observeNativeRefresh,gn as observePageScroll,yo as observePullToRefresh,eo as observeSegmentScrub,Qo as observeSheetDrag,Rt as onAppearance,ho as onBackgroundRefresh,U as onCraftEvent,mo as onMemoryWarning,Mr as onMobileReady,fo as onResume,go as onSilentPush,li as onSpotlightTap,dt as orientation,No as paceLabel,Un as pageBackground,Wn as pageIsDark,se as pageScrollTop,Fo as pauseSessionClock,hr as permissions,en as placeMenu,zn as placeSpotlightItem,Je as presentActionSheet,Xe as presentAlert,Pe as presentChoice,Qe as presentConfirm,Ze as presentContextMenu,Zo as presentPageAsCard,Eo as previousScreenPath,hn as pullDistance,Er as pushNotifications,Gn as readSpotlightEntries,Mt as readSpotlightKinds,nr as readTabLinks,V as refresh,qn as removeSpotlightItem,wo as resolveScrollHost,Uo as resumeSessionClock,Ln as routeReadInterval,In as routeStats,or as routerHandlesTabs,_n as rubberBand,yt as scheduledWorkouts,sn as scheduledWorkoutsUnsupported,br as secureStorage,cn as segmentAt,to as segmentForKey,Wo as sessionClockElapsed,Dn as settleSheet,vr as share,Hn as sheetStops,ct as shortcuts,$r as showContextMenuFor,Ri as snapshots,kr as speech,Ho as speedLabel,Ai as splash,le as spotlightAction,Ct as spotlightActions,ai as spotlightActivityTypes,Qn as spotlightBridge,ce as spotlightKind,Vn as spotlightRoute,jn as spotlightSlot,Nt as spotlightTitle,Bo as startSessionClock,ge as statusBar,ht as storage,ft as storeKit,J as subscribeWhenReady,it as symbols,tr as tabBar,Ne as toNativeRect,Io as trailEntryFor,zo as typedDistanceKm,Co as usableFixes,Ur as useActionSheet,ar as voiceRecordingFormData,Pr as watchConnectivity,ee as whenBridgeReady,Lr as whenNativeMobile,ut as widgets,Cr as withNativeFeedback};
package/dist/route.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare function attachHeartRate<T extends RouteFix>(fixes: readonly T[],
10
10
  export declare function fixDistance(a: { latitude: number, longitude: number }, b: { latitude: number, longitude: number }): number;
11
11
  /** The fixes worth counting, oldest first: a known position, accurate enough. */
12
12
  export declare function usableFixes<T extends RouteFix>(fixes: readonly T[], maxAccuracyM?: number): T[];
13
+ export declare function createRouteStats(options?: RouteStatsOptions): RouteStatsAccumulator;
13
14
  /**
14
15
  * The live numbers for a recording.
15
16
  *
@@ -25,6 +26,14 @@ export declare function routeStats(fixes: readonly RouteFix[], options?: RouteSt
25
26
  export declare function paceLabel(secondsPerKm: number | null | undefined): string;
26
27
  /** "24.3" kilometres per hour. */
27
28
  export declare function speedLabel(metresPerSecond: number | null | undefined): string;
29
+ /**
30
+ * How long to wait before the next read, ms. A host that answers `since` with
31
+ * only the new fixes is read every `everyMs`, however long the route. One that
32
+ * hands back the whole recording costs more with every fix (a 20-hour route
33
+ * is ~72,000 of them through the bridge), so past ROUTE_FULL_READ_FIXES the
34
+ * wait grows with the recording, up to ROUTE_FULL_READ_MAX_MS.
35
+ */
36
+ export declare function routeReadInterval(everyMs: number, fixes: number, wholeReads: boolean): number;
28
37
  /**
29
38
  * A recording to follow: start, pause, resume and stop the native recording,
30
39
  * and the live numbers read back from it every few seconds while the page is
@@ -35,6 +44,10 @@ export declare function createRouteRecorder(options: RouteRecorderOptions): Rout
35
44
  export declare const HEART_RATE_MATCH_MS: 5000;
36
45
  /** Fixes further apart than this, seconds, are a break in the route (a pause). */
37
46
  export declare const ROUTE_GAP_S: 30;
47
+ /** Past this many fixes (an hour at one a second), a whole-recording read is spaced out. */
48
+ export declare const ROUTE_FULL_READ_FIXES: 3600;
49
+ /** The longest a whole-recording read is spaced to, ms. */
50
+ export declare const ROUTE_FULL_READ_MAX_MS: unknown;
38
51
  /** A fix as Craft records it. */
39
52
  export declare interface RouteFix extends Location {
40
53
  altitudeAccuracy?: number
@@ -53,6 +66,21 @@ export declare interface RouteStatsOptions {
53
66
  maxAccuracyM?: number
54
67
  paceWindowS?: number
55
68
  }
69
+ /**
70
+ * The live numbers for a recording, kept up as fixes arrive: `add` takes the
71
+ * next fixes (a batch read back from the native recording) and counts only
72
+ * those newer than any it has seen, so a reader can hand it a whole recording
73
+ * or just its tail and get the same answer. Each fix is looked at once, and
74
+ * only the anchors inside the pace window are kept, so a 20-hour route costs
75
+ * what its last few seconds do rather than every fix again on every read.
76
+ *
77
+ * `routeStats` is this over one batch.
78
+ */
79
+ export declare interface RouteStatsAccumulator {
80
+ add: (fixes: readonly RouteFix[]) => RouteStats
81
+ readonly stats: RouteStats
82
+ readonly latestTimestamp: number | null
83
+ }
56
84
  export declare interface RouteRecorderOptions extends RouteStatsOptions {
57
85
  intervalMs?: number
58
86
  onUpdate?: (stats: RouteStats) => void
package/dist/types.d.ts CHANGED
@@ -251,6 +251,14 @@ export declare interface SecureStorageApi {
251
251
  export declare interface RecordingOwnershipOptions {
252
252
  expectedId: string
253
253
  }
254
+ /**
255
+ * Reading a route recording back. `since` (epoch ms) asks only for the fixes
256
+ * recorded after it: a host that knows it answers with the tail, one that
257
+ * does not answers with every fix, and the caller skips what it has.
258
+ */
259
+ export declare interface LocationRecordingReadOptions extends RecordingOwnershipOptions {
260
+ since?: number
261
+ }
254
262
  export declare interface LocationApi {
255
263
  supportsRecordingOwnership: () => boolean
256
264
  supportsRecordingIntentIdentity: () => boolean
@@ -263,7 +271,7 @@ export declare interface LocationApi {
263
271
  resumeRecording: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingState>
264
272
  stopRecording: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingResult>
265
273
  getRecordingState: (options?: RecordingOwnershipOptions) => Promise<LocationRecordingState>
266
- readRecording: (options?: RecordingOwnershipOptions) => Promise<Location[]>
274
+ readRecording: (options?: LocationRecordingReadOptions) => Promise<Location[]>
267
275
  }
268
276
  export declare interface ShareApi {
269
277
  share: (options: ShareOptions) => Promise<boolean>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/mobile",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.383",
5
+ "version": "0.75.388",
6
6
  "description": "Craft-powered native mobile runtime for Stacks and STX applications",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@bughq/sdk": "^0.3.0",
42
- "@stacksjs/types": "0.75.383",
42
+ "@stacksjs/types": "0.75.388",
43
43
  "craft-native": ">=0.0.341"
44
44
  },
45
45
  "devDependencies": {
46
- "@stacksjs/build": "0.75.383",
46
+ "@stacksjs/build": "0.75.388",
47
47
  "better-dx": "^0.2.24"
48
48
  }
49
49
  }