@buoy-gg/location 7.0.56 → 7.0.58
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/lib/commonjs/engine/adapters/browser.js +1 -0
- package/lib/commonjs/engine/adapters/browser.web.js +1 -0
- package/lib/commonjs/engine/adapters/capacitor.js +1 -0
- package/lib/commonjs/engine/adapters/capacitor.web.js +1 -0
- package/lib/commonjs/engine/adapters/index.js +1 -1
- package/lib/commonjs/engine/readSavedSync.web.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/module/engine/adapters/browser.js +1 -0
- package/lib/module/engine/adapters/browser.web.js +1 -0
- package/lib/module/engine/adapters/capacitor.js +1 -0
- package/lib/module/engine/adapters/capacitor.web.js +1 -0
- package/lib/module/engine/adapters/index.js +1 -1
- package/lib/module/engine/readSavedSync.web.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/typescript/engine/adapters/browser.d.ts +4 -0
- package/lib/typescript/engine/adapters/browser.web.d.ts +38 -0
- package/lib/typescript/engine/adapters/capacitor.d.ts +4 -0
- package/lib/typescript/engine/adapters/capacitor.web.d.ts +16 -0
- package/lib/typescript/engine/readSavedSync.web.d.ts +7 -2
- package/lib/web/index.mjs +2 -2
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.BROWSER_LIBRARY=void 0;exports.installBrowserGeolocationAdapter=installBrowserGeolocationAdapter;const BROWSER_LIBRARY=exports.BROWSER_LIBRARY="navigator.geolocation";function installBrowserGeolocationAdapter(){return false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.BROWSER_LIBRARY=void 0;exports.__resetBrowserGeolocationForTests=__resetBrowserGeolocationForTests;exports.browserPosition=browserPosition;exports.installBrowserGeolocationAdapter=installBrowserGeolocationAdapter;var _store=require("../store");var _wrap=require("./wrap");const BROWSER_LIBRARY=exports.BROWSER_LIBRARY="navigator.geolocation";const CODES={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function positionError(t,i){return{code:t,message:i,...CODES}}function browserPosition(t,i){const s={latitude:t.latitude,longitude:t.longitude,altitude:t.altitude,accuracy:t.accuracy,altitudeAccuracy:t.altitudeAccuracy,heading:t.heading,speed:t.speed};return{coords:{...s,toJSON:()=>s},timestamp:i,toJSON:()=>({coords:s,timestamp:i})}}function fromBrowser(t,i){const s=()=>t.gen===i&&t.nativeId!==null;return[(...u)=>s()?t.success(...u):void 0,(...u)=>s()?t.error?.(...u):void 0]}const watches=new Map;let nextId=1e6;let installed=false;function installBrowserGeolocationAdapter(){if(installed)return true;const t=globalThis.navigator?.geolocation;if(!t||typeof t.getCurrentPosition!=="function")return false;installed=true;let i=null;let s=null;const u=o=>(0,_store.trackWatch)({library:BROWSER_LIBRARY,id:o.id,kind:"position",options:o.options,deliver:e=>o.success(browserPosition(e,Date.now())),fail:e=>o.error?.(positionError(2,e))});(0,_wrap.wrapMethod)(t,"getCurrentPosition",o=>(...e)=>{if(!(0,_store.isLocationActive)())return o(...e);const r=e[0];const n=e[1];if(!(0,_store.servicesEnabled)()){(0,_store.addLog)("request",BROWSER_LIBRARY,"getCurrentPosition \u2192 services off");(0,_store.realSetTimeout)(()=>n?.(positionError(2,"Location services are disabled")),0);return void 0}const{fix:a}=(0,_store.currentFix)();if(!a){(0,_store.addLog)("request",BROWSER_LIBRARY,"getCurrentPosition \u2192 no signal");(0,_store.realSetTimeout)(()=>n?.(positionError(3,"Timeout expired")),1e3);return void 0}(0,_store.addLog)("request",BROWSER_LIBRARY,`getCurrentPosition \u2192 ${a.latitude.toFixed(5)}, ${a.longitude.toFixed(5)}`);(0,_store.realSetTimeout)(()=>r?.(browserPosition(a,Date.now())),0);return void 0});i=(0,_wrap.wrapMethod)(t,"watchPosition",o=>(...e)=>{const r=e[0];const n=e[1];const a=e[2]&&typeof e[2]==="object"?e[2]:{};if(!(0,_store.isLocationActive)()){const d={id:0,success:r,error:n,options:a,nativeId:null,gen:1};const[f,p]=fromBrowser(d,1);const l=o(f,p,e[2]);d.id=l;d.nativeId=l;watches.set(l,d);return l}const c={id:nextId++,success:r,error:n,options:a,nativeId:null,gen:1};watches.set(c.id,c);u(c);return c.id});s=(0,_wrap.wrapMethod)(t,"clearWatch",o=>(...e)=>{const r=e[0];const n=watches.get(r);if(!n)return o(...e);watches.delete(r);n.gen++;(0,_store.untrackWatch)(BROWSER_LIBRARY,"position",r);if(n.nativeId!==null)return o(n.nativeId);return void 0});(0,_store.registerAdapter)({library:BROWSER_LIBRARY,onActiveChange(o){for(const e of watches.values()){if(o&&e.nativeId!==null){e.gen++;s?.(e.nativeId);e.nativeId=null;u(e)}else if(!o&&e.nativeId===null){(0,_store.untrackWatch)(BROWSER_LIBRARY,"position",e.id);const r=++e.gen;const[n,a]=fromBrowser(e,r);e.nativeId=i?.(n,a,e.options)??null}}}});return true}function __resetBrowserGeolocationForTests(){watches.clear();installed=false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CAPACITOR_LIBRARY=void 0;exports.installCapacitorGeolocationAdapter=installCapacitorGeolocationAdapter;const CAPACITOR_LIBRARY=exports.CAPACITOR_LIBRARY="@capacitor/geolocation";function installCapacitorGeolocationAdapter(){return false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CAPACITOR_LIBRARY=void 0;exports.__resetCapacitorGeolocationForTests=__resetCapacitorGeolocationForTests;exports.capacitorPosition=capacitorPosition;exports.fromCapacitorPermission=fromCapacitorPermission;exports.installCapacitorGeolocationAdapter=installCapacitorGeolocationAdapter;var _license=require("@buoy-gg/license");var _store=require("../store");const CAPACITOR_LIBRARY=exports.CAPACITOR_LIBRARY="@capacitor/geolocation";const PLUGIN="Geolocation";function capacitorPosition(t,e){return{timestamp:e,coords:{latitude:t.latitude,longitude:t.longitude,accuracy:t.accuracy,altitude:t.altitude,altitudeAccuracy:t.altitudeAccuracy,speed:t.speed,heading:t.heading}}}function positionError(t){return new Error(t)}function fromCapacitorPermission(t){if(!t||typeof t!=="object")return null;const e=t.location;const i=t.coarseLocation??e;const n=e==="granted"||i==="granted";const o=e==="denied"&&(i==="denied"||i===void 0);return{status:n?"granted":o?"denied":"undetermined",background:null,precision:e!=="granted"&&i==="granted"?"reduced":"full"}}function fromNative(t,e){return(i,n)=>{if(t.gen===e&&t.nativeId!==null)t.callback(i,n)}}const watches=new Map;let installed=false;function simulate(t){(0,_store.trackWatch)({library:CAPACITOR_LIBRARY,id:t.id,kind:"position",options:t.options,deliver:e=>t.callback(capacitorPosition(e,Date.now())),fail:e=>t.callback(null,positionError(e))})}function startNative(t){const e=++t.gen;t.nativeId=(0,_license.callCapacitorNativeCallback)(PLUGIN,"watchPosition",t.options,fromNative(t,e))}function stopNative(t){t.gen++;if(t.nativeId===null)return;const e=t.nativeId;t.nativeId=null;void(0,_license.callCapacitorNative)(PLUGIN,"clearWatch",{id:e}).catch(()=>{})}function installCapacitorGeolocationAdapter(){if(installed)return true;if(!(0,_license.capacitorPlatform)()||!(0,_license.hasCapacitorPlugin)(PLUGIN)||!(0,_license.installCapacitorBridge)())return false;installed=true;(0,_license.interceptCapacitor)({plugin:PLUGIN,methods:["getCurrentPosition"],promise:(t,e)=>{if(!(0,_store.isLocationActive)())return e();if(!(0,_store.servicesEnabled)()){(0,_store.addLog)("request",CAPACITOR_LIBRARY,"getCurrentPosition \u2192 services off");return Promise.reject(positionError("Location services are not enabled"))}const{fix:i}=(0,_store.currentFix)();if(!i){(0,_store.addLog)("request",CAPACITOR_LIBRARY,"getCurrentPosition \u2192 no signal");return new Promise((n,o)=>(0,_store.realSetTimeout)(()=>o(positionError("Timeout")),1e3))}(0,_store.addLog)("request",CAPACITOR_LIBRARY,`getCurrentPosition \u2192 ${i.latitude.toFixed(5)}, ${i.longitude.toFixed(5)}`);return capacitorPosition(i,Date.now())}});(0,_license.interceptCapacitor)({plugin:PLUGIN,methods:["watchPosition"],callback:(t,e,i)=>{if(!(0,_store.isLocationActive)()){const o={id:"",options:t.options,callback:e,nativeId:null,gen:1};const r=i(fromNative(o,1));if(r===null)return null;o.id=r;o.nativeId=r;watches.set(r,o);return r}const n={id:(0,_license.makeCapacitorCallbackId)(),options:t.options,callback:e,nativeId:null,gen:1};watches.set(n.id,n);simulate(n);return n.id}});(0,_license.interceptCapacitor)({plugin:PLUGIN,methods:["clearWatch"],promise:(t,e)=>{const i=String(t.options.id??"");const n=watches.get(i);if(!n)return e();watches.delete(i);n.gen++;(0,_store.untrackWatch)(CAPACITOR_LIBRARY,"position",i);if(n.nativeId===null)return void 0;const o=n.nativeId;n.nativeId=null;return o===i?e():(0,_license.callCapacitorNative)(PLUGIN,"clearWatch",{id:o})}});(0,_store.registerAdapter)({library:CAPACITOR_LIBRARY,onActiveChange(t){for(const e of watches.values()){if(t&&e.nativeId!==null){stopNative(e);simulate(e)}else if(!t&&e.nativeId===null){(0,_store.untrackWatch)(CAPACITOR_LIBRARY,"position",e.id);startNative(e)}}},async readPermission(){try{return fromCapacitorPermission(await(0,_license.callCapacitorAsApp)(PLUGIN,"checkPermissions"))}catch{return null}}});return true}function __resetCapacitorGeolocationForTests(){watches.clear();installed=false}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installLocationAdapters=installLocationAdapters;var _community=require("./community");var _expo=require("./expo");let found=null;function installLocationAdapters(){if(found)return found;found=[];if((0,_expo.installExpoLocationAdapter)())found.push("expo-location");found.push(...(0,_community.installCommunityAdapters)());return found}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.installLocationAdapters=installLocationAdapters;var _community=require("./community");var _expo=require("./expo");var _capacitor=require("./capacitor");var _browser=require("./browser");let found=null;function installLocationAdapters(){if(found)return found;found=[];if((0,_expo.installExpoLocationAdapter)())found.push("expo-location");found.push(...(0,_community.installCommunityAdapters)());if((0,_capacitor.installCapacitorGeolocationAdapter)())found.push("@capacitor/geolocation");if((0,_browser.installBrowserGeolocationAdapter)())found.push("navigator.geolocation");return found}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readSavedSync=readSavedSync;function readSavedSync(){return void 0}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.readSavedSync=readSavedSync;var _persistence=require("./persistence");function readSavedSync(){try{const e=globalThis.localStorage;if(!e)return void 0;return(0,_persistence.parseSaved)(e.getItem(_persistence.LOCATION_STORAGE_KEY))}catch{return void 0}}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"BUILT_IN_PLACES",{enumerable:true,get:function(){return _fixtures.BUILT_IN_PLACES}});Object.defineProperty(exports,"LOCATION_CHIP_ID",{enumerable:true,get:function(){return _LocationChip.LOCATION_CHIP_ID}});Object.defineProperty(exports,"LOCATION_TOOL_ICON_COLOR",{enumerable:true,get:function(){return _sharedUi.LOCATION_TOOL_ICON_COLOR}});Object.defineProperty(exports,"LocationBody",{enumerable:true,get:function(){return _LocationBody.LocationBody}});Object.defineProperty(exports,"LocationChip",{enumerable:true,get:function(){return _LocationChip.LocationChip}});Object.defineProperty(exports,"LocationToolIcon",{enumerable:true,get:function(){return _sharedUi.LocationToolIcon}});Object.defineProperty(exports,"LocationToolView",{enumerable:true,get:function(){return _LocationToolView.LocationToolView}});Object.defineProperty(exports,"ROUTE_PRESETS",{enumerable:true,get:function(){return _fixtures.ROUTE_PRESETS}});Object.defineProperty(exports,"bearingDegrees",{enumerable:true,get:function(){return _geo.bearingDegrees}});Object.defineProperty(exports,"bootLocation",{enumerable:true,get:function(){return _store.bootLocation}});Object.defineProperty(exports,"buildPresetRoute",{enumerable:true,get:function(){return _fixtures.buildPresetRoute}});Object.defineProperty(exports,"createLocationTool",{enumerable:true,get:function(){return _preset.createLocationTool}});Object.defineProperty(exports,"destination",{enumerable:true,get:function(){return _geo.destination}});Object.defineProperty(exports,"distanceMeters",{enumerable:true,get:function(){return _geo.distanceMeters}});Object.defineProperty(exports,"getLocationSnapshot",{enumerable:true,get:function(){return _store.getLocationSnapshot}});Object.defineProperty(exports,"installLocationAdapters",{enumerable:true,get:function(){return _adapters.installLocationAdapters}});Object.defineProperty(exports,"isLocationActive",{enumerable:true,get:function(){return _store.isLocationActive}});Object.defineProperty(exports,"locationSyncAdapter",{enumerable:true,get:function(){return _locationSyncAdapter.locationSyncAdapter}});Object.defineProperty(exports,"locationToolPreset",{enumerable:true,get:function(){return _preset.locationToolPreset}});Object.defineProperty(exports,"moveToRegion",{enumerable:true,get:function(){return _store.moveToRegion}});Object.defineProperty(exports,"parseCoordinate",{enumerable:true,get:function(){return _geo.parseCoordinate}});Object.defineProperty(exports,"pauseRoute",{enumerable:true,get:function(){return _store.pauseRoute}});Object.defineProperty(exports,"refreshLocationPermission",{enumerable:true,get:function(){return _store.refreshLocationPermission}});Object.defineProperty(exports,"registerLocationPlaces",{enumerable:true,get:function(){return _store.registerLocationPlaces}});Object.defineProperty(exports,"registerLocationRoutes",{enumerable:true,get:function(){return _store.registerLocationRoutes}});Object.defineProperty(exports,"resetLocation",{enumerable:true,get:function(){return _store.resetLocation}});Object.defineProperty(exports,"resumeRoute",{enumerable:true,get:function(){return _store.resumeRoute}});Object.defineProperty(exports,"seekRoute",{enumerable:true,get:function(){return _store.seekRoute}});Object.defineProperty(exports,"setConditions",{enumerable:true,get:function(){return _store.setConditions}});Object.defineProperty(exports,"setPlace",{enumerable:true,get:function(){return _store.setPlace}});Object.defineProperty(exports,"setRouteSpeed",{enumerable:true,get:function(){return _store.setRouteSpeed}});Object.defineProperty(exports,"setServices",{enumerable:true,get:function(){return _store.setServices}});Object.defineProperty(exports,"setSignal",{enumerable:true,get:function(){return _store.setSignal}});Object.defineProperty(exports,"startRoute",{enumerable:true,get:function(){return _store.startRoute}});Object.defineProperty(exports,"stopRoute",{enumerable:true,get:function(){return _store.stopRoute}});Object.defineProperty(exports,"subscribeLocation",{enumerable:true,get:function(){return _store.subscribeLocation}});Object.defineProperty(exports,"tuneOverride",{enumerable:true,get:function(){return _store.tuneOverride}});Object.defineProperty(exports,"useRealLocation",{enumerable:true,get:function(){return _store.useRealLocation}});var _store=require("./engine/store");var _adapters=require("./engine/adapters");var _LocationChip=require("./components/LocationChip");var _preset=require("./preset");var _LocationBody=require("./components/LocationBody");var _LocationToolView=require("./components/LocationToolView");var _sharedUi=require("@buoy-gg/shared-ui");var _locationSyncAdapter=require("./sync/locationSyncAdapter");var _fixtures=require("./engine/fixtures");var _geo=require("./engine/geo");const isReactNativeRuntime=typeof navigator!=="undefined"&&navigator.product==="ReactNative";if(isReactNativeRuntime){(0,_LocationChip.watchLocationChip)();if(typeof __DEV__!=="undefined"&&__DEV__){(0,_adapters.installLocationAdapters)();(0,_store.bootLocation)()}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"BUILT_IN_PLACES",{enumerable:true,get:function(){return _fixtures.BUILT_IN_PLACES}});Object.defineProperty(exports,"LOCATION_CHIP_ID",{enumerable:true,get:function(){return _LocationChip.LOCATION_CHIP_ID}});Object.defineProperty(exports,"LOCATION_TOOL_ICON_COLOR",{enumerable:true,get:function(){return _sharedUi.LOCATION_TOOL_ICON_COLOR}});Object.defineProperty(exports,"LocationBody",{enumerable:true,get:function(){return _LocationBody.LocationBody}});Object.defineProperty(exports,"LocationChip",{enumerable:true,get:function(){return _LocationChip.LocationChip}});Object.defineProperty(exports,"LocationToolIcon",{enumerable:true,get:function(){return _sharedUi.LocationToolIcon}});Object.defineProperty(exports,"LocationToolView",{enumerable:true,get:function(){return _LocationToolView.LocationToolView}});Object.defineProperty(exports,"ROUTE_PRESETS",{enumerable:true,get:function(){return _fixtures.ROUTE_PRESETS}});Object.defineProperty(exports,"bearingDegrees",{enumerable:true,get:function(){return _geo.bearingDegrees}});Object.defineProperty(exports,"bootLocation",{enumerable:true,get:function(){return _store.bootLocation}});Object.defineProperty(exports,"buildPresetRoute",{enumerable:true,get:function(){return _fixtures.buildPresetRoute}});Object.defineProperty(exports,"createLocationTool",{enumerable:true,get:function(){return _preset.createLocationTool}});Object.defineProperty(exports,"destination",{enumerable:true,get:function(){return _geo.destination}});Object.defineProperty(exports,"distanceMeters",{enumerable:true,get:function(){return _geo.distanceMeters}});Object.defineProperty(exports,"getLocationSnapshot",{enumerable:true,get:function(){return _store.getLocationSnapshot}});Object.defineProperty(exports,"installLocationAdapters",{enumerable:true,get:function(){return _adapters.installLocationAdapters}});Object.defineProperty(exports,"isLocationActive",{enumerable:true,get:function(){return _store.isLocationActive}});Object.defineProperty(exports,"locationSyncAdapter",{enumerable:true,get:function(){return _locationSyncAdapter.locationSyncAdapter}});Object.defineProperty(exports,"locationToolPreset",{enumerable:true,get:function(){return _preset.locationToolPreset}});Object.defineProperty(exports,"moveToRegion",{enumerable:true,get:function(){return _store.moveToRegion}});Object.defineProperty(exports,"parseCoordinate",{enumerable:true,get:function(){return _geo.parseCoordinate}});Object.defineProperty(exports,"pauseRoute",{enumerable:true,get:function(){return _store.pauseRoute}});Object.defineProperty(exports,"refreshLocationPermission",{enumerable:true,get:function(){return _store.refreshLocationPermission}});Object.defineProperty(exports,"registerLocationPlaces",{enumerable:true,get:function(){return _store.registerLocationPlaces}});Object.defineProperty(exports,"registerLocationRoutes",{enumerable:true,get:function(){return _store.registerLocationRoutes}});Object.defineProperty(exports,"resetLocation",{enumerable:true,get:function(){return _store.resetLocation}});Object.defineProperty(exports,"resumeRoute",{enumerable:true,get:function(){return _store.resumeRoute}});Object.defineProperty(exports,"seekRoute",{enumerable:true,get:function(){return _store.seekRoute}});Object.defineProperty(exports,"setConditions",{enumerable:true,get:function(){return _store.setConditions}});Object.defineProperty(exports,"setPlace",{enumerable:true,get:function(){return _store.setPlace}});Object.defineProperty(exports,"setRouteSpeed",{enumerable:true,get:function(){return _store.setRouteSpeed}});Object.defineProperty(exports,"setServices",{enumerable:true,get:function(){return _store.setServices}});Object.defineProperty(exports,"setSignal",{enumerable:true,get:function(){return _store.setSignal}});Object.defineProperty(exports,"startRoute",{enumerable:true,get:function(){return _store.startRoute}});Object.defineProperty(exports,"stopRoute",{enumerable:true,get:function(){return _store.stopRoute}});Object.defineProperty(exports,"subscribeLocation",{enumerable:true,get:function(){return _store.subscribeLocation}});Object.defineProperty(exports,"tuneOverride",{enumerable:true,get:function(){return _store.tuneOverride}});Object.defineProperty(exports,"useRealLocation",{enumerable:true,get:function(){return _store.useRealLocation}});var _store=require("./engine/store");var _adapters=require("./engine/adapters");var _LocationChip=require("./components/LocationChip");var _preset=require("./preset");var _LocationBody=require("./components/LocationBody");var _LocationToolView=require("./components/LocationToolView");var _sharedUi=require("@buoy-gg/shared-ui");var _locationSyncAdapter=require("./sync/locationSyncAdapter");var _fixtures=require("./engine/fixtures");var _geo=require("./engine/geo");const isReactNativeRuntime=typeof navigator!=="undefined"&&navigator.product==="ReactNative";const isCapacitorShell=(()=>{try{const e=globalThis.Capacitor;return e?.isNativePlatform?.()===true}catch{return false}})();if(isReactNativeRuntime||isCapacitorShell){(0,_LocationChip.watchLocationChip)();if(typeof __DEV__!=="undefined"&&__DEV__){(0,_adapters.installLocationAdapters)();(0,_store.bootLocation)()}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const BROWSER_LIBRARY="navigator.geolocation";export function installBrowserGeolocationAdapter(){return false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{addLog as p,currentFix as C,isLocationActive as h,realSetTimeout as g,registerAdapter as O,servicesEnabled as S,trackWatch as b,untrackWatch as E}from"../store";import{wrapMethod as v}from"./wrap";export const BROWSER_LIBRARY="navigator.geolocation";const T={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function I(t,r){return{code:t,message:r,...T}}export function browserPosition(t,r){const s={latitude:t.latitude,longitude:t.longitude,altitude:t.altitude,accuracy:t.accuracy,altitudeAccuracy:t.altitudeAccuracy,heading:t.heading,speed:t.speed};return{coords:{...s,toJSON:()=>s},timestamp:r,toJSON:()=>({coords:s,timestamp:r})}}function P(t,r){const s=()=>t.gen===r&&t.nativeId!==null;return[(...c)=>s()?t.success(...c):void 0,(...c)=>s()?t.error?.(...c):void 0]}const l=new Map;let _=1e6;let A=false;export function installBrowserGeolocationAdapter(){if(A)return true;const t=globalThis.navigator?.geolocation;if(!t||typeof t.getCurrentPosition!=="function")return false;A=true;let r=null;let s=null;const c=n=>b({library:BROWSER_LIBRARY,id:n.id,kind:"position",options:n.options,deliver:e=>n.success(browserPosition(e,Date.now())),fail:e=>n.error?.(I(2,e))});v(t,"getCurrentPosition",n=>(...e)=>{if(!h())return n(...e);const i=e[0];const o=e[1];if(!S()){p("request",BROWSER_LIBRARY,"getCurrentPosition \u2192 services off");g(()=>o?.(I(2,"Location services are disabled")),0);return void 0}const{fix:u}=C();if(!u){p("request",BROWSER_LIBRARY,"getCurrentPosition \u2192 no signal");g(()=>o?.(I(3,"Timeout expired")),1e3);return void 0}p("request",BROWSER_LIBRARY,`getCurrentPosition \u2192 ${u.latitude.toFixed(5)}, ${u.longitude.toFixed(5)}`);g(()=>i?.(browserPosition(u,Date.now())),0);return void 0});r=v(t,"watchPosition",n=>(...e)=>{const i=e[0];const o=e[1];const u=e[2]&&typeof e[2]==="object"?e[2]:{};if(!h()){const a={id:0,success:i,error:o,options:u,nativeId:null,gen:1};const[w,y]=P(a,1);const f=n(w,y,e[2]);a.id=f;a.nativeId=f;l.set(f,a);return f}const d={id:_++,success:i,error:o,options:u,nativeId:null,gen:1};l.set(d.id,d);c(d);return d.id});s=v(t,"clearWatch",n=>(...e)=>{const i=e[0];const o=l.get(i);if(!o)return n(...e);l.delete(i);o.gen++;E(BROWSER_LIBRARY,"position",i);if(o.nativeId!==null)return n(o.nativeId);return void 0});O({library:BROWSER_LIBRARY,onActiveChange(n){for(const e of l.values()){if(n&&e.nativeId!==null){e.gen++;s?.(e.nativeId);e.nativeId=null;c(e)}else if(!n&&e.nativeId===null){E(BROWSER_LIBRARY,"position",e.id);const i=++e.gen;const[o,u]=P(e,i);e.nativeId=r?.(o,u,e.options)??null}}}});return true}export function __resetBrowserGeolocationForTests(){l.clear();A=false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const CAPACITOR_LIBRARY="@capacitor/geolocation";export function installCapacitorGeolocationAdapter(){return false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{callCapacitorAsApp as C,callCapacitorNative as p,callCapacitorNativeCallback as I,capacitorPlatform as P,hasCapacitorPlugin as b,installCapacitorBridge as h,interceptCapacitor as l,makeCapacitorCallbackId as k}from"@buoy-gg/license";import{addLog as s,currentFix as A,isLocationActive as f,realSetTimeout as y,registerAdapter as L,servicesEnabled as N,trackWatch as W,untrackWatch as g}from"../store";export const CAPACITOR_LIBRARY="@capacitor/geolocation";const r="Geolocation";export function capacitorPosition(t,e){return{timestamp:e,coords:{latitude:t.latitude,longitude:t.longitude,accuracy:t.accuracy,altitude:t.altitude,altitudeAccuracy:t.altitudeAccuracy,speed:t.speed,heading:t.heading}}}function u(t){return new Error(t)}export function fromCapacitorPermission(t){if(!t||typeof t!=="object")return null;const e=t.location;const n=t.coarseLocation??e;const i=e==="granted"||n==="granted";const o=e==="denied"&&(n==="denied"||n===void 0);return{status:i?"granted":o?"denied":"undetermined",background:null,precision:e!=="granted"&&n==="granted"?"reduced":"full"}}function v(t,e){return(n,i)=>{if(t.gen===e&&t.nativeId!==null)t.callback(n,i)}}const a=new Map;let d=false;function m(t){W({library:CAPACITOR_LIBRARY,id:t.id,kind:"position",options:t.options,deliver:e=>t.callback(capacitorPosition(e,Date.now())),fail:e=>t.callback(null,u(e))})}function _(t){const e=++t.gen;t.nativeId=I(r,"watchPosition",t.options,v(t,e))}function F(t){t.gen++;if(t.nativeId===null)return;const e=t.nativeId;t.nativeId=null;void p(r,"clearWatch",{id:e}).catch(()=>{})}export function installCapacitorGeolocationAdapter(){if(d)return true;if(!P()||!b(r)||!h())return false;d=true;l({plugin:r,methods:["getCurrentPosition"],promise:(t,e)=>{if(!f())return e();if(!N()){s("request",CAPACITOR_LIBRARY,"getCurrentPosition \u2192 services off");return Promise.reject(u("Location services are not enabled"))}const{fix:n}=A();if(!n){s("request",CAPACITOR_LIBRARY,"getCurrentPosition \u2192 no signal");return new Promise((i,o)=>y(()=>o(u("Timeout")),1e3))}s("request",CAPACITOR_LIBRARY,`getCurrentPosition \u2192 ${n.latitude.toFixed(5)}, ${n.longitude.toFixed(5)}`);return capacitorPosition(n,Date.now())}});l({plugin:r,methods:["watchPosition"],callback:(t,e,n)=>{if(!f()){const o={id:"",options:t.options,callback:e,nativeId:null,gen:1};const c=n(v(o,1));if(c===null)return null;o.id=c;o.nativeId=c;a.set(c,o);return c}const i={id:k(),options:t.options,callback:e,nativeId:null,gen:1};a.set(i.id,i);m(i);return i.id}});l({plugin:r,methods:["clearWatch"],promise:(t,e)=>{const n=String(t.options.id??"");const i=a.get(n);if(!i)return e();a.delete(n);i.gen++;g(CAPACITOR_LIBRARY,"position",n);if(i.nativeId===null)return void 0;const o=i.nativeId;i.nativeId=null;return o===n?e():p(r,"clearWatch",{id:o})}});L({library:CAPACITOR_LIBRARY,onActiveChange(t){for(const e of a.values()){if(t&&e.nativeId!==null){F(e);m(e)}else if(!t&&e.nativeId===null){g(CAPACITOR_LIBRARY,"position",e.id);_(e)}}},async readPermission(){try{return fromCapacitorPermission(await C(r,"checkPermissions"))}catch{return null}}});return true}export function __resetCapacitorGeolocationForTests(){a.clear();d=false}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{installCommunityAdapters as
|
|
1
|
+
"use strict";import{installCommunityAdapters as t}from"./community";import{installExpoLocationAdapter as i}from"./expo";import{installCapacitorGeolocationAdapter as r}from"./capacitor";import{installBrowserGeolocationAdapter as a}from"./browser";let o=null;export function installLocationAdapters(){if(o)return o;o=[];if(i())o.push("expo-location");o.push(...t());if(r())o.push("@capacitor/geolocation");if(a())o.push("navigator.geolocation");return o}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export function readSavedSync(){return void 0}
|
|
1
|
+
"use strict";import{LOCATION_STORAGE_KEY as r,parseSaved as t}from"./persistence";export function readSavedSync(){try{const e=globalThis.localStorage;if(!e)return void 0;return t(e.getItem(r))}catch{return void 0}}
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{bootLocation as
|
|
1
|
+
"use strict";import{bootLocation as t}from"./engine/store";import{installLocationAdapters as e}from"./engine/adapters";import{watchLocationChip as i}from"./components/LocationChip";const r=typeof navigator!=="undefined"&&navigator.product==="ReactNative";const a=(()=>{try{const o=globalThis.Capacitor;return o?.isNativePlatform?.()===true}catch{return false}})();if(r||a){i();if(typeof __DEV__!=="undefined"&&__DEV__){e();t()}}export{locationToolPreset,createLocationTool}from"./preset";export{LocationBody}from"./components/LocationBody";export{LocationToolView}from"./components/LocationToolView";export{LocationChip,LOCATION_CHIP_ID}from"./components/LocationChip";export{LocationToolIcon,LOCATION_TOOL_ICON_COLOR}from"@buoy-gg/shared-ui";export{locationSyncAdapter}from"./sync/locationSyncAdapter";export{bootLocation,setPlace,startRoute,pauseRoute,resumeRoute,seekRoute,setRouteSpeed,tuneOverride,setSignal,setServices,setConditions,stopRoute,moveToRegion,useRealLocation,resetLocation,registerLocationPlaces,registerLocationRoutes,getLocationSnapshot,subscribeLocation,isLocationActive,refreshLocationPermission}from"./engine/store";export{installLocationAdapters}from"./engine/adapters";export{BUILT_IN_PLACES,ROUTE_PRESETS,buildPresetRoute}from"./engine/fixtures";export{distanceMeters,bearingDegrees,destination,parseCoordinate}from"./engine/geo";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Fix } from "../geo";
|
|
2
|
+
export declare const BROWSER_LIBRARY = "navigator.geolocation";
|
|
3
|
+
export declare function browserPosition(fix: Fix, timestamp: number): {
|
|
4
|
+
coords: {
|
|
5
|
+
toJSON: () => {
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
altitude: number | null;
|
|
9
|
+
accuracy: number;
|
|
10
|
+
altitudeAccuracy: number | null;
|
|
11
|
+
heading: number | null;
|
|
12
|
+
speed: number | null;
|
|
13
|
+
};
|
|
14
|
+
latitude: number;
|
|
15
|
+
longitude: number;
|
|
16
|
+
altitude: number | null;
|
|
17
|
+
accuracy: number;
|
|
18
|
+
altitudeAccuracy: number | null;
|
|
19
|
+
heading: number | null;
|
|
20
|
+
speed: number | null;
|
|
21
|
+
};
|
|
22
|
+
timestamp: number;
|
|
23
|
+
toJSON: () => {
|
|
24
|
+
coords: {
|
|
25
|
+
latitude: number;
|
|
26
|
+
longitude: number;
|
|
27
|
+
altitude: number | null;
|
|
28
|
+
accuracy: number;
|
|
29
|
+
altitudeAccuracy: number | null;
|
|
30
|
+
heading: number | null;
|
|
31
|
+
speed: number | null;
|
|
32
|
+
};
|
|
33
|
+
timestamp: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare function installBrowserGeolocationAdapter(): boolean;
|
|
37
|
+
export declare function __resetBrowserGeolocationForTests(): void;
|
|
38
|
+
//# sourceMappingURL=browser.web.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PermissionInfo } from "../store";
|
|
2
|
+
import type { Fix } from "../geo";
|
|
3
|
+
export declare const CAPACITOR_LIBRARY = "@capacitor/geolocation";
|
|
4
|
+
/** The plugin's Position shape. */
|
|
5
|
+
export declare function capacitorPosition(fix: Fix, timestamp: number): Record<string, unknown>;
|
|
6
|
+
type PermissionState = "granted" | "denied" | "prompt" | "prompt-with-rationale";
|
|
7
|
+
/** The plugin's `checkPermissions` answer, in the store's terms. */
|
|
8
|
+
export declare function fromCapacitorPermission(answer: {
|
|
9
|
+
location?: PermissionState;
|
|
10
|
+
coarseLocation?: PermissionState;
|
|
11
|
+
} | null | undefined): PermissionInfo | null;
|
|
12
|
+
/** Install on a Capacitor shell that ships the plugin. True when installed. */
|
|
13
|
+
export declare function installCapacitorGeolocationAdapter(): boolean;
|
|
14
|
+
export declare function __resetCapacitorGeolocationForTests(): void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=capacitor.web.d.ts.map
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
/**
|
|
1
|
+
import { type SavedLocation } from "./persistence";
|
|
2
|
+
/**
|
|
3
|
+
* The saved override, read synchronously. The web build's persistentStorage
|
|
4
|
+
* writes plain `localStorage`, so a saved location is in place before the
|
|
5
|
+
* app's own modules ask for one (the Capacitor case). `undefined` when there
|
|
6
|
+
* is no `localStorage`.
|
|
7
|
+
*/
|
|
3
8
|
export declare function readSavedSync(): SavedLocation | null | undefined;
|
|
4
9
|
//# sourceMappingURL=readSavedSync.web.d.ts.map
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";var Bt=Object.defineProperty;var si=Object.getOwnPropertyDescriptor;var ci=Object.getOwnPropertyNames;var ui=Object.prototype.hasOwnProperty;var di=(e,t)=>{for(var n in t)Bt(e,n,{get:t[n],enumerable:true})},jt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ci(t))!ui.call(e,o)&&o!==n&&Bt(e,o,{get:()=>t[o],enumerable:!(i=si(t,o))||i.enumerable});return e},pi=(e,t,n)=>(jt(e,t,"default"),n&&jt(n,t,"default"));var Ft=process.env.NODE_ENV!=="production";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{realNow as D}from"@buoy-gg/shared-ui/web";var _t=63710088e-1,Z=e=>e*Math.PI/180,ct=e=>e*180/Math.PI;function be(e){if(!e||typeof e!="object")return false;let{latitude:t,longitude:n}=e;return typeof t=="number"&&typeof n=="number"&&Number.isFinite(t)&&Number.isFinite(n)&&Math.abs(t)<=90&&Math.abs(n)<=180}function zt(e){let t=((e+180)%360+360)%360-180;return t===-180&&e>0?180:t}function U(e,t){let n=Z(t.latitude-e.latitude),i=Z(t.longitude-e.longitude),o=Math.sin(n/2)**2+Math.cos(Z(e.latitude))*Math.cos(Z(t.latitude))*Math.sin(i/2)**2;return 2*_t*Math.asin(Math.min(1,Math.sqrt(o)))}function qe(e,t){let n=Z(e.latitude),i=Z(t.latitude),o=Z(t.longitude-e.longitude),r=Math.sin(o)*Math.cos(i),l=Math.cos(n)*Math.sin(i)-Math.sin(n)*Math.cos(i)*Math.cos(o);return(ct(Math.atan2(r,l))+360)%360}function Re(e,t,n){let i=n/_t,o=Z(t),r=Z(e.latitude),l=Z(e.longitude),p=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(o)),f=l+Math.atan2(Math.sin(o)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(p));return{latitude:ct(p),longitude:zt(ct(f))}}function fi(e,t,n){if(n<=0)return{latitude:e.latitude,longitude:e.longitude};if(n>=1)return{latitude:t.latitude,longitude:t.longitude};let i=U(e,t);return i<1e-6?{latitude:e.latitude,longitude:e.longitude}:Re(e,qe(e,t),i*n)}function Wt(e){let t=[];for(let n=1;n<e.length;n++)t.push(U(e[n-1],e[n]));return t}function ut(e){return Wt(e).reduce((t,n)=>t+n,0)}function Ke(e,t){let{points:n}=e;if(n.length===0)throw new Error("A route needs at least one point.");let i=n[0];if(n.length===1)return{...i,along:0,heading:0,leg:0,finished:true,inGap:false};let o=Wt(n),r=o.reduce((y,T)=>y+T,0),l=Math.max(0,t),p=false;r<=0?(l=0,p=!e.loop):e.loop?l=l%r:l>=r&&(l=r,p=true);let f=(e.gaps??[]).some(([y,T])=>l>=y&&l<T),g=l;for(let y=0;y<o.length;y++){let T=o[y],S=n[y],C=n[y+1],F=y===o.length-1;if(g<T||F){let _=T>0?Math.min(1,g/T):1;return{...fi(S,C,_),along:l,heading:qe(S,C),leg:y,finished:p,inGap:f}}g-=T}return{...n[n.length-1],along:l,heading:0,leg:o.length-1,finished:p,inGap:f}}function gi(e,t,n){if(t<=0)return{latitude:e.latitude,longitude:e.longitude};let i=Ht(Math.sin(n*12.9898)*43758.5453),o=Ht(Math.sin(n*78.233)*12543.1234);return Re(e,i*360,Math.sqrt(o)*t)}function Ht(e){return e-Math.floor(e)}var hi=3e3;function mi(e){let t=Math.round(e.latitude/.03)*.03,n=.03/Math.max(.2,Math.cos(Z(t))),i=Math.round(e.longitude/n)*n;return{...e,latitude:Ut(t),longitude:Ut(zt(i)),accuracy:Math.max(e.accuracy,hi),heading:null,speed:null}}function Ut(e){return Math.round(e*1e6)/1e6}function yi(e,t){return U(e,t)<=e.radius}function bi(e,t,n){let i={},o=[];for(let r of e){let l=t[r.identifier]??"unknown",p=yi(r,n)?"inside":"outside";if(i[r.identifier]=p,l===p)continue;let f=p==="inside"?"enter":"exit",g=l==="unknown";(g||(f==="enter"?r.notifyOnEnter:r.notifyOnExit))&&o.push({identifier:r.identifier,kind:f,initial:g})}return{states:i,transitions:o}}function vi(e,t,n){if(t==="inside")return{latitude:e.latitude,longitude:e.longitude};let i=n&&U(e,n)>1?qe(e,n):0;return Re(e,i,e.radius+Math.max(50,e.radius*.25))}function Vt(e,t){if(!be(e))return null;let n=e,i=Number(n.radius);return!Number.isFinite(i)||i<=0?null:{identifier:typeof n.identifier=="string"&&n.identifier?n.identifier:`region-${t+1}`,latitude:n.latitude,longitude:n.longitude,radius:i,notifyOnEnter:n.notifyOnEnter!==false,notifyOnExit:n.notifyOnExit!==false}}function dt(e){let t=e.trim(),n=[/@(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)/,/[?&](?:q|ll|query|center)=(-?\d+(?:\.\d+)?)(?:,|%2C)\s*(-?\d+(?:\.\d+)?)/i,/^(-?\d+(?:\.\d+)?)\s*[,\s]\s*(-?\d+(?:\.\d+)?)$/];for(let i of n){let o=t.match(i);if(o){let r={latitude:Number(o[1]),longitude:Number(o[2])};if(be(r))return r}}return null}function Ne(e,t=5){return`${e.latitude.toFixed(t)}, ${e.longitude.toFixed(t)}`}var pt={persist:true,showChip:true},wi={latitude:37.3349,longitude:-122.009,label:"Apple Park"};function ft(){return{mode:"real",place:{...wi},altitude:30,accuracy:5,jitter:0,heading:null,route:null,playing:false,anchorReal:0,anchorMeters:0,signal:true,services:true,interval:1e3}}function Ee(e){return!!e&&(e.mode!=="real"||!e.signal||!e.services)}function ve(e){return!!e&&e.mode!=="real"}function ge(e,t,n=-1/0,i=1/0){let o=typeof e=="number"?e:Number(e);return Number.isFinite(o)?Math.min(i,Math.max(n,o)):t}function ki(e,t){if(e===null)return null;let n=typeof e=="number"?e:Number(e);return e!==void 0&&Number.isFinite(n)?n:t}function gt(e){if(!e||typeof e!="object")return null;let t=e,n=Array.isArray(t.points)?t.points.filter(be):[];if(n.length<2)return null;let i=Array.isArray(t.gaps)?t.gaps.filter(o=>Array.isArray(o)&&o.length===2&&o.every(r=>typeof r=="number"&&Number.isFinite(r))):void 0;return{id:typeof t.id=="string"?t.id:void 0,name:typeof t.name=="string"?t.name:void 0,points:n.map(o=>({latitude:o.latitude,longitude:o.longitude})),speed:ge(t.speed,1.4,.1,400),loop:t.loop===true,gaps:i&&i.length?i:void 0}}function Gt(e){if(!e||typeof e!="object")return null;let t=e,n=ft(),i=t.mode==="fixed"||t.mode==="route"?t.mode:"real",o=t.place,r=be(o)?{latitude:o.latitude,longitude:o.longitude,label:typeof o.label=="string"?o.label:void 0}:n.place,l=gt(t.route);return{mode:i==="route"&&!l?"fixed":i,place:r,altitude:ki(t.altitude,n.altitude),accuracy:ge(t.accuracy,n.accuracy,0,1e5),jitter:ge(t.jitter,0,0,1e4),heading:t.heading===null||t.heading===void 0?null:ge(t.heading,0,0,360)%360,route:l,playing:t.playing===true&&!!l,anchorReal:ge(t.anchorReal,0),anchorMeters:ge(t.anchorMeters,0,0),signal:t.signal!==false,services:t.services!==false,interval:ge(t.interval,n.interval,100,6e4)}}var qt={good:{accuracy:5,jitter:0,signal:true,services:true},weak:{accuracy:65,jitter:50,signal:true,services:true},"no-signal":{accuracy:5,jitter:0,signal:false,services:true},off:{accuracy:5,jitter:0,signal:true,services:false}};function xi(e){if(!e.services)return"off";if(!e.signal)return"no-signal";for(let t of["good","weak"]){let n=qt[t];if(e.accuracy===n.accuracy&&e.jitter===n.jitter)return t}return null}import{devToolsStorageKeys as Ti,persistentStorage as Kt}from"@buoy-gg/shared-ui/web";var Xt=Ti.location.state();function Si(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.name!="string"||!t.name||t.kind!=="geofencing"&&t.kind!=="locationUpdates"?null:{name:t.name,kind:t.kind,library:typeof t.library=="string"?t.library:"expo-location",options:t.options&&typeof t.options=="object"?t.options:{}}}function Ai(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let n=t.settings??{};return{v:1,override:Gt(t.override),settings:{persist:typeof n.persist=="boolean"?n.persist:pt.persist,showChip:typeof n.showChip=="boolean"?n.showChip:pt.showChip},tasks:Array.isArray(t.tasks)?t.tasks.map(Si).filter(i=>i!==null):[]}}catch{return null}}async function Ci(){try{return Ai(await Kt.getItem(Xt))}catch{return null}}var ht=Promise.resolve();function Ii(e){let t=JSON.stringify(e);return ht=ht.then(()=>Kt.setItem(Xt,t)).catch(()=>{}),ht.then(()=>{})}function Yt(){return globalThis.__buoyRealTimers??globalThis}function ie(e,t){return Yt().setTimeout(e,t)}function Li(e){Yt().clearTimeout(e)}var d=ft(),ce={...pt},we="full",ke=null,mt=false,Xe=false,xe=new Map,oe=new Map,O=new Map,Te=[],$i=0,Zt=null,Jt=1,De=[],Ye=[],Ze=new Set,Oe=null;function z(){Oe=null;for(let e of Array.from(Ze))try{e()}catch{}}function Be(e){return Ze.add(e),()=>{Ze.delete(e)}}var Qt=100;function I(e,t,n,i){Te.push({id:++$i,at:D(),kind:e,library:t,text:n,...i?{detail:i}:{}}),Te.length>Qt&&Te.splice(0,Te.length-Qt),z()}function N(){return Ee(d)}function je(){return d.services}function Mi(e){!e||e===we||(we=e,z())}function Pi(e){if(!e)return;let t=ke&&ke.status===e.status&&ke.background===e.background&&ke.precision===e.precision;e.precision!==we&&(we=e.precision),!t&&(ke=e,z())}function Se(e){return d.route?d.playing?d.anchorMeters+Math.max(0,e-d.anchorReal)/1e3*d.route.speed:d.anchorMeters:0}function he(e=D()){if(!d.services)return{fix:null,reason:"services"};if(!d.signal)return{fix:null,reason:"signal"};if(d.mode==="real")return{fix:null,reason:"real"};let t,n=d.heading,i=0;if(d.mode==="route"&&d.route){let r=Ke(d.route,Se(e));if(r.inGap)return{fix:null,reason:"gap"};t=r;let l=d.playing&&!r.finished;n=r.heading,i=l?d.route.speed:0}else t=d.place;d.jitter>0&&(t=gi(t,d.jitter,Math.floor(e/d.interval)+Jt));let o={latitude:t.latitude,longitude:t.longitude,altitude:d.altitude,accuracy:Math.max(d.accuracy,d.jitter),altitudeAccuracy:d.altitude===null?null:3,heading:n,speed:i};return we==="reduced"&&(o=mi(o)),{fix:o,reason:null}}var Ae=null,en=0;function Ri(){return ve(d)?oe.size>0||O.size>0?true:d.mode==="route"&&d.playing&&Ze.size>0:false}function Je(){Ae===null&&Ri()&&(Ae=ie(()=>{Ae=null,rn(),Je()},d.interval))}function tn(){Ae!==null&&Li(Ae),Ae=null}function nn(){tn(),rn(),Je()}function on(e,t){let n=Number(e.options[t]);return Number.isFinite(n)&&n>0?n:0}function rn(){let e=D(),{fix:t}=he(e);if(d.mode==="route"&&d.route&&d.playing){let n=Ke(d.route,Se(e));n.finished&&(d={...d,playing:false,anchorMeters:n.along,anchorReal:e},Ie())}t&&(an(t,false),ln(t)),e-en>5e3&&(en=e,Di()),z()}function an(e,t){for(let n of Array.from(oe.values())){if(n.kind==="heading"){let i=e.heading??0;if(!t&&n.lastHeading===i&&n.updates>0)continue;n.lastHeading=i}else{let i=on(n,"distanceInterval");if(!t&&n.last&&U(n.last,e)<Math.max(i,.01))continue;n.last={latitude:e.latitude,longitude:e.longitude}}n.updates+=1,Zt=D();try{n.deliver(e)}catch(i){I("error",n.library,`Watch ${n.id} callback threw: ${String(i?.message??i)}`)}}}function ln(e){for(let t of Array.from(O.values()))if(t.kind==="geofencing"){let{states:n,transitions:i}=bi(t.regions,t.states,e);t.states=n;for(let o of i)Ni(t,o)}else{let n=on(t,"distanceInterval");if(t.lastBatchAt&&U(t.lastBatchAt,e)<Math.max(n,.01))continue;t.lastBatchAt={latitude:e.latitude,longitude:e.longitude},sn(t,{locations:[e]},"a location update")}}function Ni(e,t){let n=e.regions.find(o=>o.identifier===t.identifier);if(!n)return;I(t.kind,e.library,`${t.kind==="enter"?"Entered":"Left"} ${et(n)??n.identifier}`,`${e.name} \xB7 region ${n.identifier}${t.initial?" \xB7 first check after monitoring started":""}`);let i=et(n)??n.identifier;sn(e,{eventType:t.kind==="enter"?1:2,region:n},`${t.kind==="enter"?"entering":"leaving"} ${i}`)}function sn(e,t,n){let i=xe.get(e.library);if(!i?.fireTask)return;e.runs+=1,e.kind==="locationUpdates"&&I("batch",e.library,"Sent a background location update",e.name),i.fireTask(e,t).then(o=>{I("task",e.library,`Task ran for ${n}`,o!=null?`${e.name} \xB7 returned ${Ei(o)}`:e.name)},o=>{I("error",e.library,`Task failed for ${n}`,`${e.name} \xB7 ${String(o?.message??o)}`)})}function Ei(e){try{let t=typeof e=="string"?e:JSON.stringify(e);return t.length>80?`${t.slice(0,77)}\u2026`:t}catch{return String(e)}}function Di(){Qe()}function Qe(){for(let e of xe.values())e.readPermission?.().then(Pi,()=>{})}function cn(e){xe.set(e.library,e),z()}function un(e){let t=`${e.library}:${e.kind}:${e.id}`;oe.set(t,{...e,key:t,since:D(),updates:0,last:null,lastHeading:null}),I("watch",e.library,e.kind==="heading"?"The app started watching the compass heading":"The app started watching location",`watch ${e.id} \xB7 ${e.library}`),ie(()=>{let n=oe.get(t);if(!n)return;let{fix:i,reason:o}=he();i?(an(i,false),z()):o==="services"&&n.fail?.("Location services are disabled")},0),Je()}function Fe(e,t,n){let i=`${e}:${t}:${n}`,o=oe.delete(i);return o&&I("watch",e,t==="heading"?"The app stopped watching the heading":"The app stopped watching location",`watch ${n} \xB7 ${e}`),o}function Oi(e,t,n){return oe.has(`${e}:${t}:${n}`)}function yt(e,t){let n=e.kind==="geofencing"?(e.options.regions??[]).map((i,o)=>Vt(i,o)).filter(i=>i!==null):[];O.set(e.name,{...e,regions:n,states:{},since:D(),runs:0,intercepted:t,lastBatchAt:null}),I("task",e.library,e.kind==="geofencing"?`The app started monitoring ${n.length} geofence${n.length===1?"":"s"}`:"The app started background location updates",e.name),Ie(),ve(d)&&ie(()=>{let{fix:i}=he(),o=O.get(e.name);i&&o&&(ln(i),z())},0),Je()}function bt(e){let t=O.get(e);return t?(O.delete(e),I("task",t.library,t.kind==="geofencing"?"The app stopped monitoring geofences":"The app stopped background updates",t.name),Ie(),t):null}function Ce(e){return O.get(e)??null}function vt(e){return Array.from(O.values()).filter(t=>!e||t.kind===e)}function dn(e,t){let n=O.get(e);n&&(n.intercepted=t,t||(n.states={}),Ie())}function Bi(e){for(let t of e){let n=De.findIndex(i=>i.label&&i.label===t.label);n>=0?De[n]={...t}:De.push({...t})}z()}function et(e){let t=null,n=1/0;for(let i of De){if(!i.label)continue;let o=U(i,e);o<=Math.max(50,e.radius)&&o<n&&(t=i,n=o)}return t?.label??null}function ji(e){for(let t of e){let n=gt(t);if(!n)continue;let i=Ye.findIndex(o=>(o.id??o.name)===(n.id??n.name));i>=0?Ye[i]=n:Ye.push(n)}z()}function V(e){d=e;let t=Ee(d);if(t!==Xe){Xe=t;for(let n of xe.values())try{n.onActiveChange?.(t)}catch(i){I("error",n.library,`Switching failed: ${String(i?.message??i)}`)}}return Ie(),ve(d)?nn():(tn(),z()),P()}function tt(e){return V({...d,mode:"fixed",place:{latitude:e.latitude,longitude:e.longitude,label:e.label},playing:false})}function _e(){return d.mode==="route"&&d.route?Ke(d.route,Se(D())):d.place}function pn(e){let t=gt(e);if(!t)throw new Error("A route needs two or more valid points.");return V({...d,mode:"route",route:t,playing:true,anchorReal:D(),anchorMeters:0})}function wt(){if(d.mode!=="route"||!d.playing)return P();let e=D();return V({...d,playing:false,anchorMeters:Se(e),anchorReal:e})}function kt(){if(d.mode!=="route"||!d.route)return P();let e=ut(d.route.points),t=!d.route.loop&&d.anchorMeters>=e?0:d.anchorMeters;return V({...d,playing:true,anchorReal:D(),anchorMeters:t})}function fn(e){if(d.mode!=="route"||!d.route)throw new Error("No route is playing.");return V({...d,anchorMeters:Math.max(0,e),anchorReal:D()})}function gn(e){if(!d.route)throw new Error("No route is loaded.");if(!Number.isFinite(e)||e<=0)throw new Error("Speed must be a positive number of m/s.");let t=D();return V({...d,route:{...d.route,speed:e},anchorMeters:Se(t),anchorReal:t})}function hn(e){let t=Gt({...d,...Fi(e)});return t?V({...t,anchorMeters:d.anchorMeters,anchorReal:d.anchorReal}):P()}function Fi(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}function mn(e){return V({...d,signal:e})}function yn(e){let t=V({...d,services:e});if(!e){for(let n of Array.from(oe.values()))n.kind==="position"&&n.fail?.("Location services are disabled");I("error","device","Location services switched off","open watches got an error")}return t}function bn(e){let t=qt[e];if(!t)throw new Error(`Unknown conditions "${String(e)}". Use good, weak, no-signal or off.`);let n=d.services,i=e==="good"||e==="weak"?t:{signal:t.signal,services:t.services},o=V({...d,...i});if(n&&!t.services){for(let r of Array.from(oe.values()))r.kind==="position"&&r.fail?.("Location services are disabled");I("error","device","Location services switched off","open watches got an error")}return o}function vn(){if(d.mode!=="route"||!d.route)return P();let e=_e();return tt({latitude:e.latitude,longitude:e.longitude})}function wn(){return V({...d,mode:"real",playing:false})}function xt(e,t,n){for(let i of O.values()){if(n&&i.name!==n)continue;let o=i.regions.find(p=>p.identifier===e);if(!o)continue;let r=vi(o,t,_e()),l=et(o)??o.identifier;return tt({...r,label:t==="inside"?`At ${l}`:`Outside ${l}`})}throw new Error(`No geofence region "${e}" is being monitored.`)}function Tt(){let e=ft();return V({...e,place:d.place})}function _i(e){return ce={persist:typeof e.persist=="boolean"?e.persist:ce.persist,showChip:typeof e.showChip=="boolean"?e.showChip:ce.showChip},Ie(),z(),P()}function zi(){return ce}function Wi(){return Te.length=0,z(),P()}function P(){if(Oe)return Oe;let e=D(),{fix:t,reason:n}=he(e),i=null;if(d.mode==="route"&&d.route){let l=Ke(d.route,Se(e)),p=ut(d.route.points);i={along:l.along,length:p,finished:l.finished,leg:l.leg,etaMs:d.playing&&!d.route.loop&&!l.finished?(p-l.along)/d.route.speed*1e3:null}}let o=ve(d)?_e():null,r=t??o;return Oe={active:Ee(d),simulating:ve(d),override:d,current:{fix:t,reason:n,precision:we},permission:ke,position:o?{latitude:o.latitude,longitude:o.longitude}:null,progress:i,watches:Array.from(oe.values()).map(l=>({key:l.key,library:l.library,id:l.id,kind:l.kind,options:l.options,since:l.since,updates:l.updates})),tasks:Array.from(O.values()).map(l=>({name:l.name,kind:l.kind,library:l.library,intercepted:l.intercepted,since:l.since,runs:l.runs,options:l.options,regions:l.regions.map(p=>({...p,label:et(p),state:l.states[p.identifier]??"unknown",distance:r?U(p,r):null}))})),log:Te.slice(-50),libraries:Array.from(xe.keys()),places:De.slice(),routes:Ye.slice(),settings:ce,lastDeliveryAt:Zt},Oe}function Ie(){if(!mt)return;let e={v:1,override:ce.persist&&Ee(d)?d:null,settings:ce,tasks:Array.from(O.values()).filter(t=>t.intercepted).map(({name:t,kind:n,library:i,options:o})=>({name:t,kind:n,library:i,options:o}))};Ii(e)}function kn(e){if(e){ce=e.settings;for(let t of e.tasks)O.has(t.name)||Hi(t);e.override&&Ee(e.override)&&(d=e.override,Xe=true)}}function Hi(e){let t=e.kind==="geofencing"?(e.options.regions??[]).map((n,i)=>Vt(n,i)).filter(n=>!!n):[];O.set(e.name,{...e,regions:t,states:{},since:D(),runs:0,intercepted:true,lastBatchAt:null})}function St(){if(mt)return;mt=true,Jt=Math.floor(Math.random()*1e3)+1;let e=void 0;if(e!==void 0){kn(e),xn();return}Ci().then(t=>{kn(t),xn()})}function xn(){for(let e of xe.values())e.onActiveChange?.(Xe);ve(d)?ie(nn,0):z()}var Tn="__buoyLocationNext";function L(e,t,n){let i=e[t];if(typeof i!="function")return null;let o=i[Tn]??i,r=(...p)=>o.apply(e,p),l=n(r);l[Tn]=o;try{e[t]=l}catch{return null}return e[t]===l?r:null}function Ui(e,t){let n=new Error(t);return n.code=e,n}var At={};di(At,{AccessibilityInfo:()=>Ki,ActivityIndicator:()=>zo,Alert:()=>Uo,Animated:()=>Xi,AppRegistry:()=>Zi,AppState:()=>Ji,Appearance:()=>Yi,BackHandler:()=>Qi,Button:()=>Wo,CheckBox:()=>ho,Clipboard:()=>eo,DeviceEventEmitter:()=>An,Dimensions:()=>to,Easing:()=>no,FlatList:()=>mo,I18nManager:()=>io,Image:()=>yo,ImageBackground:()=>bo,InteractionManager:()=>ro,Keyboard:()=>oo,KeyboardAvoidingView:()=>vo,LayoutAnimation:()=>ao,Linking:()=>lo,LogBox:()=>Mo,Modal:()=>Fo,NativeEventEmitter:()=>so,NativeModules:()=>qi,PanResponder:()=>co,Picker:()=>wo,PixelRatio:()=>uo,Platform:()=>Sn,Pressable:()=>jo,ProgressBar:()=>ko,RefreshControl:()=>xo,SafeAreaView:()=>To,ScrollView:()=>In,SectionList:()=>So,Share:()=>po,StatusBar:()=>Ao,StyleSheet:()=>re,Switch:()=>_o,Text:()=>A,TextInput:()=>Cn,Touchable:()=>Co,TouchableHighlight:()=>Oo,TouchableNativeFeedback:()=>Io,TouchableOpacity:()=>ae,TouchableWithoutFeedback:()=>Bo,UIManager:()=>fo,Vibration:()=>go,View:()=>v,VirtualizedList:()=>Lo,YellowBox:()=>$o,findNodeHandle:()=>Ho,unstable_createElement:()=>Gi,useColorScheme:()=>Po,useLocaleContext:()=>Ro,useWindowDimensions:()=>No});pi(At,Vi);import*as Vi from"react-native-web";import{unstable_createElement as Gi,NativeModules as qi,AccessibilityInfo as Ki,Animated as Xi,Appearance as Yi,AppRegistry as Zi,AppState as Ji,BackHandler as Qi,Clipboard as eo,Dimensions as to,Easing as no,I18nManager as io,Keyboard as oo,InteractionManager as ro,LayoutAnimation as ao,Linking as lo,NativeEventEmitter as so,PanResponder as co,PixelRatio as uo,Platform as Sn,Share as po,StyleSheet as re,UIManager as fo,Vibration as go,CheckBox as ho,FlatList as mo,Image as yo,ImageBackground as bo,KeyboardAvoidingView as vo,Picker as wo,ProgressBar as ko,RefreshControl as xo,SafeAreaView as To,SectionList as So,StatusBar as Ao,Touchable as Co,TouchableNativeFeedback as Io,VirtualizedList as Lo,YellowBox as $o,LogBox as Mo,DeviceEventEmitter as An,useColorScheme as Po,useLocaleContext as Ro,useWindowDimensions as No}from"react-native-web";import*as W from"react-native-web";import{createElement as Eo,forwardRef as Do}from"react";function G(e){let t=Do((i,o)=>{let{accessibilityState:r,accessibilityValue:l,...p}=i;for(let f of["busy","checked","disabled","expanded","selected"])r?.[f]!==void 0&&p[`aria-${f}`]===void 0&&(p[`aria-${f}`]=r[f]);for(let[f,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[f]!==void 0&&p[`aria-${g}`]===void 0&&(p[`aria-${g}`]=l[f]);return Eo(e,{...p,ref:o})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var v=G(W.View),A=G(W.Text),Cn=G(W.TextInput),ae=G(W.TouchableOpacity),Oo=G(W.TouchableHighlight),Bo=G(W.TouchableWithoutFeedback),jo=G(W.Pressable),In=G(W.ScrollView),Fo=G(W.Modal),_o=G(W.Switch),zo=G(W.ActivityIndicator),Wo=G(W.Button),Ho=W.findNodeHandle,Uo={alert(e,t,n,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(r),t){let g=document.createElement("p");g.textContent=t,g.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(g)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=n?.length?n:[{text:"OK"}],f=()=>{o.close?.(),o.remove()};for(let g of p){let y=document.createElement("button");y.type="button",y.textContent=g.text??"OK",y.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${g.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,y.onclick=()=>{f(),g.onPress?.()},l.appendChild(y)}o.addEventListener("cancel",g=>{g.preventDefault(),i?.cancelable!==false&&(f(),i?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var Vo=[{module:"RNCGeolocation",library:"@react-native-community/geolocation"},{module:"RNFusedLocation",library:"react-native-geolocation-service"}],Go={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function Ct(e,t){return{code:e,message:t,...Go}}function Ln(){return At}function qo(e){let t=Ln();if(!t)return null;let n=null;try{(globalThis.__turboModuleProxy!=null||typeof t.TurboModuleRegistry?.get=="function")&&(n=t.TurboModuleRegistry?.get?.(e))}catch{n=null}if(!n)try{n=t.NativeModules?.[e]}catch{n=null}return n&&typeof n=="object"?n:null}function $n(e,t,n){let i={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading??(t==="ios"?-1:0),speed:e.speed??(t==="ios"?-1:0)},timestamp:n};return t==="android"&&(i.mocked=false),i}var Ko=[];function Xo(e){let t=qo(e.module);if(!t||typeof t.getCurrentPosition!="function")return false;Ko.push(t);let n=Ln(),i=n?.Platform?.OS??"ios",o=(g,y)=>n?.DeviceEventEmitter?.emit(g,y),r={options:null,native:false,on:false},l=()=>un({library:e.library,id:"observer",kind:"position",options:r.options??{},deliver:g=>o("geolocationDidChange",$n(g,i,Date.now())),fail:g=>o("geolocationError",Ct(2,g))});L(t,"getCurrentPosition",g=>(...y)=>{if(!N())return g(...y);let T=y[1],S=y[2];if(!je()){I("request",e.library,"getCurrentPosition \u2192 services off"),S?.(Ct(2,"No location provider available."));return}let{fix:C}=he();if(!C){I("request",e.library,"getCurrentPosition \u2192 no signal"),ie(()=>S?.(Ct(3,"Unable to fetch location within 1.0s.")),1e3);return}I("request",e.library,`getCurrentPosition \u2192 ${C.latitude.toFixed(5)}, ${C.longitude.toFixed(5)}`),ie(()=>T?.($n(C,i,Date.now())),0)});let p=L(t,"startObserving",g=>(...y)=>{if(r.options=y[0]&&typeof y[0]=="object"?y[0]:{},r.on=true,!N())return r.native=true,g(...y);r.native=false,l()}),f=L(t,"stopObserving",g=>(...y)=>{if(r.on=false,Fe(e.library,"position","observer"),r.native)return r.native=false,g(...y)});return cn({library:e.library,onActiveChange(g){r.on&&(g&&r.native?(r.native=false,f?.(),l()):!g&&!r.native&&(Fe(e.library,"position","observer"),r.native=true,p?.(r.options??{})))}}),true}function Yo(){return Vo.filter(Xo).map(e=>e.library)}function Zo(e){return null}function Jo(e){return null}var E="expo-location";function Qo(){return Sn?.OS??"ios"}function Mn(e){try{let n=globalThis.expo?.modules?.[e];if(n&&typeof n=="object")return n}catch{}let t=Zo(e);return t&&typeof t=="object"?t:null}function It(e,t,n){let i=t==="ios",o={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude??(i?0:null),accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy??(i?-1:null),heading:e.heading??(i?-1:null),speed:e.speed??(i?-1:null)},timestamp:n};return t==="android"&&(o.mocked=false),o}function er(e,t,n){return n==="ios"?`Calling the '${e}' function has failed
|
|
1
|
+
"use client";var Kt=Object.defineProperty;var Ti=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Si=Object.prototype.hasOwnProperty;var Pi=(e,t)=>{for(var n in t)Kt(e,n,{get:t[n],enumerable:true})},Jt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ai(t))!Si.call(e,o)&&o!==n&&Kt(e,o,{get:()=>t[o],enumerable:!(i=Ti(t,o))||i.enumerable});return e},$i=(e,t,n)=>(Jt(e,t,"default"),n&&Jt(n,t,"default"));var Yt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{realNow as D}from"@buoy-gg/shared-ui/web";var Xt=63710088e-1,Z=e=>e*Math.PI/180,mt=e=>e*180/Math.PI;function Ie(e){if(!e||typeof e!="object")return false;let{latitude:t,longitude:n}=e;return typeof t=="number"&&typeof n=="number"&&Number.isFinite(t)&&Number.isFinite(n)&&Math.abs(t)<=90&&Math.abs(n)<=180}function Zt(e){let t=((e+180)%360+360)%360-180;return t===-180&&e>0?180:t}function V(e,t){let n=Z(t.latitude-e.latitude),i=Z(t.longitude-e.longitude),o=Math.sin(n/2)**2+Math.cos(Z(e.latitude))*Math.cos(Z(t.latitude))*Math.sin(i/2)**2;return 2*Xt*Math.asin(Math.min(1,Math.sqrt(o)))}function Ze(e,t){let n=Z(e.latitude),i=Z(t.latitude),o=Z(t.longitude-e.longitude),r=Math.sin(o)*Math.cos(i),a=Math.cos(n)*Math.sin(i)-Math.sin(n)*Math.cos(i)*Math.cos(o);return(mt(Math.atan2(r,a))+360)%360}function je(e,t,n){let i=n/Xt,o=Z(t),r=Z(e.latitude),a=Z(e.longitude),u=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(o)),p=a+Math.atan2(Math.sin(o)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(u));return{latitude:mt(u),longitude:Zt(mt(p))}}function Li(e,t,n){if(n<=0)return{latitude:e.latitude,longitude:e.longitude};if(n>=1)return{latitude:t.latitude,longitude:t.longitude};let i=V(e,t);return i<1e-6?{latitude:e.latitude,longitude:e.longitude}:je(e,Ze(e,t),i*n)}function Qt(e){let t=[];for(let n=1;n<e.length;n++)t.push(V(e[n-1],e[n]));return t}function yt(e){return Qt(e).reduce((t,n)=>t+n,0)}function Qe(e,t){let{points:n}=e;if(n.length===0)throw new Error("A route needs at least one point.");let i=n[0];if(n.length===1)return{...i,along:0,heading:0,leg:0,finished:true,inGap:false};let o=Qt(n),r=o.reduce((h,C)=>h+C,0),a=Math.max(0,t),u=false;r<=0?(a=0,u=!e.loop):e.loop?a=a%r:a>=r&&(a=r,u=true);let p=(e.gaps??[]).some(([h,C])=>a>=h&&a<C),g=a;for(let h=0;h<o.length;h++){let C=o[h],I=n[h],T=n[h+1],F=h===o.length-1;if(g<C||F){let _=C>0?Math.min(1,g/C):1;return{...Li(I,T,_),along:a,heading:Ze(I,T),leg:h,finished:u,inGap:p}}g-=C}return{...n[n.length-1],along:a,heading:0,leg:o.length-1,finished:u,inGap:p}}function Mi(e,t,n){if(t<=0)return{latitude:e.latitude,longitude:e.longitude};let i=en(Math.sin(n*12.9898)*43758.5453),o=en(Math.sin(n*78.233)*12543.1234);return je(e,i*360,Math.sqrt(o)*t)}function en(e){return e-Math.floor(e)}var Ri=3e3;function Ni(e){let t=Math.round(e.latitude/.03)*.03,n=.03/Math.max(.2,Math.cos(Z(t))),i=Math.round(e.longitude/n)*n;return{...e,latitude:tn(t),longitude:tn(Zt(i)),accuracy:Math.max(e.accuracy,Ri),heading:null,speed:null}}function tn(e){return Math.round(e*1e6)/1e6}function Ei(e,t){return V(e,t)<=e.radius}function Di(e,t,n){let i={},o=[];for(let r of e){let a=t[r.identifier]??"unknown",u=Ei(r,n)?"inside":"outside";if(i[r.identifier]=u,a===u)continue;let p=u==="inside"?"enter":"exit",g=a==="unknown";(g||(p==="enter"?r.notifyOnEnter:r.notifyOnExit))&&o.push({identifier:r.identifier,kind:p,initial:g})}return{states:i,transitions:o}}function Oi(e,t,n){if(t==="inside")return{latitude:e.latitude,longitude:e.longitude};let i=n&&V(e,n)>1?Ze(e,n):0;return je(e,i,e.radius+Math.max(50,e.radius*.25))}function nn(e,t){if(!Ie(e))return null;let n=e,i=Number(n.radius);return!Number.isFinite(i)||i<=0?null:{identifier:typeof n.identifier=="string"&&n.identifier?n.identifier:`region-${t+1}`,latitude:n.latitude,longitude:n.longitude,radius:i,notifyOnEnter:n.notifyOnEnter!==false,notifyOnExit:n.notifyOnExit!==false}}function bt(e){let t=e.trim(),n=[/@(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)/,/[?&](?:q|ll|query|center)=(-?\d+(?:\.\d+)?)(?:,|%2C)\s*(-?\d+(?:\.\d+)?)/i,/^(-?\d+(?:\.\d+)?)\s*[,\s]\s*(-?\d+(?:\.\d+)?)$/];for(let i of n){let o=t.match(i);if(o){let r={latitude:Number(o[1]),longitude:Number(o[2])};if(Ie(r))return r}}return null}function Fe(e,t=5){return`${e.latitude.toFixed(t)}, ${e.longitude.toFixed(t)}`}var vt={persist:true,showChip:true},Bi={latitude:37.3349,longitude:-122.009,label:"Apple Park"};function wt(){return{mode:"real",place:{...Bi},altitude:30,accuracy:5,jitter:0,heading:null,route:null,playing:false,anchorReal:0,anchorMeters:0,signal:true,services:true,interval:1e3}}function _e(e){return!!e&&(e.mode!=="real"||!e.signal||!e.services)}function Te(e){return!!e&&e.mode!=="real"}function ye(e,t,n=-1/0,i=1/0){let o=typeof e=="number"?e:Number(e);return Number.isFinite(o)?Math.min(i,Math.max(n,o)):t}function ji(e,t){if(e===null)return null;let n=typeof e=="number"?e:Number(e);return e!==void 0&&Number.isFinite(n)?n:t}function kt(e){if(!e||typeof e!="object")return null;let t=e,n=Array.isArray(t.points)?t.points.filter(Ie):[];if(n.length<2)return null;let i=Array.isArray(t.gaps)?t.gaps.filter(o=>Array.isArray(o)&&o.length===2&&o.every(r=>typeof r=="number"&&Number.isFinite(r))):void 0;return{id:typeof t.id=="string"?t.id:void 0,name:typeof t.name=="string"?t.name:void 0,points:n.map(o=>({latitude:o.latitude,longitude:o.longitude})),speed:ye(t.speed,1.4,.1,400),loop:t.loop===true,gaps:i&&i.length?i:void 0}}function on(e){if(!e||typeof e!="object")return null;let t=e,n=wt(),i=t.mode==="fixed"||t.mode==="route"?t.mode:"real",o=t.place,r=Ie(o)?{latitude:o.latitude,longitude:o.longitude,label:typeof o.label=="string"?o.label:void 0}:n.place,a=kt(t.route);return{mode:i==="route"&&!a?"fixed":i,place:r,altitude:ji(t.altitude,n.altitude),accuracy:ye(t.accuracy,n.accuracy,0,1e5),jitter:ye(t.jitter,0,0,1e4),heading:t.heading===null||t.heading===void 0?null:ye(t.heading,0,0,360)%360,route:a,playing:t.playing===true&&!!a,anchorReal:ye(t.anchorReal,0),anchorMeters:ye(t.anchorMeters,0,0),signal:t.signal!==false,services:t.services!==false,interval:ye(t.interval,n.interval,100,6e4)}}var rn={good:{accuracy:5,jitter:0,signal:true,services:true},weak:{accuracy:65,jitter:50,signal:true,services:true},"no-signal":{accuracy:5,jitter:0,signal:false,services:true},off:{accuracy:5,jitter:0,signal:true,services:false}};function Fi(e){if(!e.services)return"off";if(!e.signal)return"no-signal";for(let t of["good","weak"]){let n=rn[t];if(e.accuracy===n.accuracy&&e.jitter===n.jitter)return t}return null}import{devToolsStorageKeys as _i,persistentStorage as an}from"@buoy-gg/shared-ui/web";function zi(){try{let e=globalThis.localStorage;return e?ln(e.getItem(xt)):void 0}catch{return}}var xt=_i.location.state();function Wi(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.name!="string"||!t.name||t.kind!=="geofencing"&&t.kind!=="locationUpdates"?null:{name:t.name,kind:t.kind,library:typeof t.library=="string"?t.library:"expo-location",options:t.options&&typeof t.options=="object"?t.options:{}}}function ln(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1)return null;let n=t.settings??{};return{v:1,override:on(t.override),settings:{persist:typeof n.persist=="boolean"?n.persist:vt.persist,showChip:typeof n.showChip=="boolean"?n.showChip:vt.showChip},tasks:Array.isArray(t.tasks)?t.tasks.map(Wi).filter(i=>i!==null):[]}}catch{return null}}async function Ui(){try{return ln(await an.getItem(xt))}catch{return null}}var Ct=Promise.resolve();function Hi(e){let t=JSON.stringify(e);return Ct=Ct.then(()=>an.setItem(xt,t)).catch(()=>{}),Ct.then(()=>{})}function sn(){return globalThis.__buoyRealTimers??globalThis}function z(e,t){return sn().setTimeout(e,t)}function Vi(e){sn().clearTimeout(e)}var f=wt(),de={...vt},Ae="full",Se=null,It=false,et=false,Pe=new Map,oe=new Map,O=new Map,$e=[],qi=0,cn=null,un=1,ze=[],tt=[],nt=new Set,We=null;function W(){We=null;for(let e of Array.from(nt))try{e()}catch{}}function Ue(e){return nt.add(e),()=>{nt.delete(e)}}var dn=100;function S(e,t,n,i){$e.push({id:++qi,at:D(),kind:e,library:t,text:n,...i?{detail:i}:{}}),$e.length>dn&&$e.splice(0,$e.length-dn),W()}function $(){return _e(f)}function be(){return f.services}function Gi(e){!e||e===Ae||(Ae=e,W())}function Ki(e){if(!e)return;let t=Se&&Se.status===e.status&&Se.background===e.background&&Se.precision===e.precision;e.precision!==Ae&&(Ae=e.precision),!t&&(Se=e,W())}function Le(e){return f.route?f.playing?f.anchorMeters+Math.max(0,e-f.anchorReal)/1e3*f.route.speed:f.anchorMeters:0}function re(e=D()){if(!f.services)return{fix:null,reason:"services"};if(!f.signal)return{fix:null,reason:"signal"};if(f.mode==="real")return{fix:null,reason:"real"};let t,n=f.heading,i=0;if(f.mode==="route"&&f.route){let r=Qe(f.route,Le(e));if(r.inGap)return{fix:null,reason:"gap"};t=r;let a=f.playing&&!r.finished;n=r.heading,i=a?f.route.speed:0}else t=f.place;f.jitter>0&&(t=Mi(t,f.jitter,Math.floor(e/f.interval)+un));let o={latitude:t.latitude,longitude:t.longitude,altitude:f.altitude,accuracy:Math.max(f.accuracy,f.jitter),altitudeAccuracy:f.altitude===null?null:3,heading:n,speed:i};return Ae==="reduced"&&(o=Ni(o)),{fix:o,reason:null}}var Me=null,pn=0;function Ji(){return Te(f)?oe.size>0||O.size>0?true:f.mode==="route"&&f.playing&&nt.size>0:false}function it(){Me===null&&Ji()&&(Me=z(()=>{Me=null,mn(),it()},f.interval))}function fn(){Me!==null&&Vi(Me),Me=null}function gn(){fn(),mn(),it()}function hn(e,t){let n=Number(e.options[t]);return Number.isFinite(n)&&n>0?n:0}function mn(){let e=D(),{fix:t}=re(e);if(f.mode==="route"&&f.route&&f.playing){let n=Qe(f.route,Le(e));n.finished&&(f={...f,playing:false,anchorMeters:n.along,anchorReal:e},Ne())}t&&(yn(t,false),bn(t)),e-pn>5e3&&(pn=e,Zi()),W()}function yn(e,t){for(let n of Array.from(oe.values())){if(n.kind==="heading"){let i=e.heading??0;if(!t&&n.lastHeading===i&&n.updates>0)continue;n.lastHeading=i}else{let i=hn(n,"distanceInterval");if(!t&&n.last&&V(n.last,e)<Math.max(i,.01))continue;n.last={latitude:e.latitude,longitude:e.longitude}}n.updates+=1,cn=D();try{n.deliver(e)}catch(i){S("error",n.library,`Watch ${n.id} callback threw: ${String(i?.message??i)}`)}}}function bn(e){for(let t of Array.from(O.values()))if(t.kind==="geofencing"){let{states:n,transitions:i}=Di(t.regions,t.states,e);t.states=n;for(let o of i)Yi(t,o)}else{let n=hn(t,"distanceInterval");if(t.lastBatchAt&&V(t.lastBatchAt,e)<Math.max(n,.01))continue;t.lastBatchAt={latitude:e.latitude,longitude:e.longitude},vn(t,{locations:[e]},"a location update")}}function Yi(e,t){let n=e.regions.find(o=>o.identifier===t.identifier);if(!n)return;S(t.kind,e.library,`${t.kind==="enter"?"Entered":"Left"} ${lt(n)??n.identifier}`,`${e.name} \xB7 region ${n.identifier}${t.initial?" \xB7 first check after monitoring started":""}`);let i=lt(n)??n.identifier;vn(e,{eventType:t.kind==="enter"?1:2,region:n},`${t.kind==="enter"?"entering":"leaving"} ${i}`)}function vn(e,t,n){let i=Pe.get(e.library);if(!i?.fireTask)return;e.runs+=1,e.kind==="locationUpdates"&&S("batch",e.library,"Sent a background location update",e.name),i.fireTask(e,t).then(o=>{S("task",e.library,`Task ran for ${n}`,o!=null?`${e.name} \xB7 returned ${Xi(o)}`:e.name)},o=>{S("error",e.library,`Task failed for ${n}`,`${e.name} \xB7 ${String(o?.message??o)}`)})}function Xi(e){try{let t=typeof e=="string"?e:JSON.stringify(e);return t.length>80?`${t.slice(0,77)}\u2026`:t}catch{return String(e)}}function Zi(){ot()}function ot(){for(let e of Pe.values())e.readPermission?.().then(Ki,()=>{})}function rt(e){Pe.set(e.library,e),W()}function at(e){let t=`${e.library}:${e.kind}:${e.id}`;oe.set(t,{...e,key:t,since:D(),updates:0,last:null,lastHeading:null}),S("watch",e.library,e.kind==="heading"?"The app started watching the compass heading":"The app started watching location",`watch ${e.id} \xB7 ${e.library}`),z(()=>{let n=oe.get(t);if(!n)return;let{fix:i,reason:o}=re();i?(yn(i,false),W()):o==="services"&&n.fail?.("Location services are disabled")},0),it()}function ae(e,t,n){let i=`${e}:${t}:${n}`,o=oe.delete(i);return o&&S("watch",e,t==="heading"?"The app stopped watching the heading":"The app stopped watching location",`watch ${n} \xB7 ${e}`),o}function Qi(e,t,n){return oe.has(`${e}:${t}:${n}`)}function Tt(e,t){let n=e.kind==="geofencing"?(e.options.regions??[]).map((i,o)=>nn(i,o)).filter(i=>i!==null):[];O.set(e.name,{...e,regions:n,states:{},since:D(),runs:0,intercepted:t,lastBatchAt:null}),S("task",e.library,e.kind==="geofencing"?`The app started monitoring ${n.length} geofence${n.length===1?"":"s"}`:"The app started background location updates",e.name),Ne(),Te(f)&&z(()=>{let{fix:i}=re(),o=O.get(e.name);i&&o&&(bn(i),W())},0),it()}function At(e){let t=O.get(e);return t?(O.delete(e),S("task",t.library,t.kind==="geofencing"?"The app stopped monitoring geofences":"The app stopped background updates",t.name),Ne(),t):null}function Re(e){return O.get(e)??null}function St(e){return Array.from(O.values()).filter(t=>!e||t.kind===e)}function wn(e,t){let n=O.get(e);n&&(n.intercepted=t,t||(n.states={}),Ne())}function eo(e){for(let t of e){let n=ze.findIndex(i=>i.label&&i.label===t.label);n>=0?ze[n]={...t}:ze.push({...t})}W()}function lt(e){let t=null,n=1/0;for(let i of ze){if(!i.label)continue;let o=V(i,e);o<=Math.max(50,e.radius)&&o<n&&(t=i,n=o)}return t?.label??null}function to(e){for(let t of e){let n=kt(t);if(!n)continue;let i=tt.findIndex(o=>(o.id??o.name)===(n.id??n.name));i>=0?tt[i]=n:tt.push(n)}W()}function q(e){f=e;let t=_e(f);if(t!==et){et=t;for(let n of Pe.values())try{n.onActiveChange?.(t)}catch(i){S("error",n.library,`Switching failed: ${String(i?.message??i)}`)}}return Ne(),Te(f)?gn():(fn(),W()),R()}function st(e){return q({...f,mode:"fixed",place:{latitude:e.latitude,longitude:e.longitude,label:e.label},playing:false})}function He(){return f.mode==="route"&&f.route?Qe(f.route,Le(D())):f.place}function kn(e){let t=kt(e);if(!t)throw new Error("A route needs two or more valid points.");return q({...f,mode:"route",route:t,playing:true,anchorReal:D(),anchorMeters:0})}function Pt(){if(f.mode!=="route"||!f.playing)return R();let e=D();return q({...f,playing:false,anchorMeters:Le(e),anchorReal:e})}function $t(){if(f.mode!=="route"||!f.route)return R();let e=yt(f.route.points),t=!f.route.loop&&f.anchorMeters>=e?0:f.anchorMeters;return q({...f,playing:true,anchorReal:D(),anchorMeters:t})}function xn(e){if(f.mode!=="route"||!f.route)throw new Error("No route is playing.");return q({...f,anchorMeters:Math.max(0,e),anchorReal:D()})}function Cn(e){if(!f.route)throw new Error("No route is loaded.");if(!Number.isFinite(e)||e<=0)throw new Error("Speed must be a positive number of m/s.");let t=D();return q({...f,route:{...f.route,speed:e},anchorMeters:Le(t),anchorReal:t})}function In(e){let t=on({...f,...no(e)});return t?q({...t,anchorMeters:f.anchorMeters,anchorReal:f.anchorReal}):R()}function no(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}function Tn(e){return q({...f,signal:e})}function An(e){let t=q({...f,services:e});if(!e){for(let n of Array.from(oe.values()))n.kind==="position"&&n.fail?.("Location services are disabled");S("error","device","Location services switched off","open watches got an error")}return t}function Sn(e){let t=rn[e];if(!t)throw new Error(`Unknown conditions "${String(e)}". Use good, weak, no-signal or off.`);let n=f.services,i=e==="good"||e==="weak"?t:{signal:t.signal,services:t.services},o=q({...f,...i});if(n&&!t.services){for(let r of Array.from(oe.values()))r.kind==="position"&&r.fail?.("Location services are disabled");S("error","device","Location services switched off","open watches got an error")}return o}function Pn(){if(f.mode!=="route"||!f.route)return R();let e=He();return st({latitude:e.latitude,longitude:e.longitude})}function $n(){return q({...f,mode:"real",playing:false})}function Lt(e,t,n){for(let i of O.values()){if(n&&i.name!==n)continue;let o=i.regions.find(u=>u.identifier===e);if(!o)continue;let r=Oi(o,t,He()),a=lt(o)??o.identifier;return st({...r,label:t==="inside"?`At ${a}`:`Outside ${a}`})}throw new Error(`No geofence region "${e}" is being monitored.`)}function Mt(){let e=wt();return q({...e,place:f.place})}function io(e){return de={persist:typeof e.persist=="boolean"?e.persist:de.persist,showChip:typeof e.showChip=="boolean"?e.showChip:de.showChip},Ne(),W(),R()}function oo(){return de}function ro(){return $e.length=0,W(),R()}function R(){if(We)return We;let e=D(),{fix:t,reason:n}=re(e),i=null;if(f.mode==="route"&&f.route){let a=Qe(f.route,Le(e)),u=yt(f.route.points);i={along:a.along,length:u,finished:a.finished,leg:a.leg,etaMs:f.playing&&!f.route.loop&&!a.finished?(u-a.along)/f.route.speed*1e3:null}}let o=Te(f)?He():null,r=t??o;return We={active:_e(f),simulating:Te(f),override:f,current:{fix:t,reason:n,precision:Ae},permission:Se,position:o?{latitude:o.latitude,longitude:o.longitude}:null,progress:i,watches:Array.from(oe.values()).map(a=>({key:a.key,library:a.library,id:a.id,kind:a.kind,options:a.options,since:a.since,updates:a.updates})),tasks:Array.from(O.values()).map(a=>({name:a.name,kind:a.kind,library:a.library,intercepted:a.intercepted,since:a.since,runs:a.runs,options:a.options,regions:a.regions.map(u=>({...u,label:lt(u),state:a.states[u.identifier]??"unknown",distance:r?V(u,r):null}))})),log:$e.slice(-50),libraries:Array.from(Pe.keys()),places:ze.slice(),routes:tt.slice(),settings:de,lastDeliveryAt:cn},We}function Ne(){if(!It)return;let e={v:1,override:de.persist&&_e(f)?f:null,settings:de,tasks:Array.from(O.values()).filter(t=>t.intercepted).map(({name:t,kind:n,library:i,options:o})=>({name:t,kind:n,library:i,options:o}))};Hi(e)}function Ln(e){if(e){de=e.settings;for(let t of e.tasks)O.has(t.name)||ao(t);e.override&&_e(e.override)&&(f=e.override,et=true)}}function ao(e){let t=e.kind==="geofencing"?(e.options.regions??[]).map((n,i)=>nn(n,i)).filter(n=>!!n):[];O.set(e.name,{...e,regions:t,states:{},since:D(),runs:0,intercepted:true,lastBatchAt:null})}function Rt(){if(It)return;It=true,un=Math.floor(Math.random()*1e3)+1;let e=zi();if(e!==void 0){Ln(e),Mn();return}Ui().then(t=>{Ln(t),Mn()})}function Mn(){for(let e of Pe.values())e.onActiveChange?.(et);Te(f)?z(gn,0):W()}var Rn="__buoyLocationNext";function P(e,t,n){let i=e[t];if(typeof i!="function")return null;let o=i[Rn]??i,r=(...u)=>o.apply(e,u),a=n(r);a[Rn]=o;try{e[t]=a}catch{return null}return e[t]===a?r:null}function lo(e,t){let n=new Error(t);return n.code=e,n}var Nt={};Pi(Nt,{AccessibilityInfo:()=>po,ActivityIndicator:()=>or,Alert:()=>lr,Animated:()=>fo,AppRegistry:()=>ho,AppState:()=>mo,Appearance:()=>go,BackHandler:()=>yo,Button:()=>rr,CheckBox:()=>Ro,Clipboard:()=>bo,DeviceEventEmitter:()=>En,Dimensions:()=>vo,Easing:()=>wo,FlatList:()=>No,I18nManager:()=>ko,Image:()=>Eo,ImageBackground:()=>Do,InteractionManager:()=>Co,Keyboard:()=>xo,KeyboardAvoidingView:()=>Oo,LayoutAnimation:()=>Io,Linking:()=>To,LogBox:()=>Go,Modal:()=>nr,NativeEventEmitter:()=>Ao,NativeModules:()=>uo,PanResponder:()=>So,Picker:()=>Bo,PixelRatio:()=>Po,Platform:()=>Nn,Pressable:()=>tr,ProgressBar:()=>jo,RefreshControl:()=>Fo,SafeAreaView:()=>_o,ScrollView:()=>On,SectionList:()=>zo,Share:()=>$o,StatusBar:()=>Wo,StyleSheet:()=>le,Switch:()=>ir,Text:()=>A,TextInput:()=>Dn,Touchable:()=>Uo,TouchableHighlight:()=>Qo,TouchableNativeFeedback:()=>Ho,TouchableOpacity:()=>se,TouchableWithoutFeedback:()=>er,UIManager:()=>Lo,Vibration:()=>Mo,View:()=>v,VirtualizedList:()=>Vo,YellowBox:()=>qo,findNodeHandle:()=>ar,unstable_createElement:()=>co,useColorScheme:()=>Ko,useLocaleContext:()=>Jo,useWindowDimensions:()=>Yo});$i(Nt,so);import*as so from"react-native-web";import{unstable_createElement as co,NativeModules as uo,AccessibilityInfo as po,Animated as fo,Appearance as go,AppRegistry as ho,AppState as mo,BackHandler as yo,Clipboard as bo,Dimensions as vo,Easing as wo,I18nManager as ko,Keyboard as xo,InteractionManager as Co,LayoutAnimation as Io,Linking as To,NativeEventEmitter as Ao,PanResponder as So,PixelRatio as Po,Platform as Nn,Share as $o,StyleSheet as le,UIManager as Lo,Vibration as Mo,CheckBox as Ro,FlatList as No,Image as Eo,ImageBackground as Do,KeyboardAvoidingView as Oo,Picker as Bo,ProgressBar as jo,RefreshControl as Fo,SafeAreaView as _o,SectionList as zo,StatusBar as Wo,Touchable as Uo,TouchableNativeFeedback as Ho,VirtualizedList as Vo,YellowBox as qo,LogBox as Go,DeviceEventEmitter as En,useColorScheme as Ko,useLocaleContext as Jo,useWindowDimensions as Yo}from"react-native-web";import*as U from"react-native-web";import{createElement as Xo,forwardRef as Zo}from"react";function G(e){let t=Zo((i,o)=>{let{accessibilityState:r,accessibilityValue:a,...u}=i;for(let p of["busy","checked","disabled","expanded","selected"])r?.[p]!==void 0&&u[`aria-${p}`]===void 0&&(u[`aria-${p}`]=r[p]);for(let[p,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[p]!==void 0&&u[`aria-${g}`]===void 0&&(u[`aria-${g}`]=a[p]);return Xo(e,{...u,ref:o})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var v=G(U.View),A=G(U.Text),Dn=G(U.TextInput),se=G(U.TouchableOpacity),Qo=G(U.TouchableHighlight),er=G(U.TouchableWithoutFeedback),tr=G(U.Pressable),On=G(U.ScrollView),nr=G(U.Modal),ir=G(U.Switch),or=G(U.ActivityIndicator),rr=G(U.Button),ar=U.findNodeHandle,lr={alert(e,t,n,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(r),t){let g=document.createElement("p");g.textContent=t,g.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(g)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let u=n?.length?n:[{text:"OK"}],p=()=>{o.close?.(),o.remove()};for(let g of u){let h=document.createElement("button");h.type="button",h.textContent=g.text??"OK",h.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${g.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,h.onclick=()=>{p(),g.onPress?.()},a.appendChild(h)}o.addEventListener("cancel",g=>{g.preventDefault(),i?.cancelable!==false&&(p(),i?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var sr=[{module:"RNCGeolocation",library:"@react-native-community/geolocation"},{module:"RNFusedLocation",library:"react-native-geolocation-service"}],cr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function Et(e,t){return{code:e,message:t,...cr}}function Bn(){return Nt}function ur(e){let t=Bn();if(!t)return null;let n=null;try{(globalThis.__turboModuleProxy!=null||typeof t.TurboModuleRegistry?.get=="function")&&(n=t.TurboModuleRegistry?.get?.(e))}catch{n=null}if(!n)try{n=t.NativeModules?.[e]}catch{n=null}return n&&typeof n=="object"?n:null}function jn(e,t,n){let i={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading??(t==="ios"?-1:0),speed:e.speed??(t==="ios"?-1:0)},timestamp:n};return t==="android"&&(i.mocked=false),i}var dr=[];function pr(e){let t=ur(e.module);if(!t||typeof t.getCurrentPosition!="function")return false;dr.push(t);let n=Bn(),i=n?.Platform?.OS??"ios",o=(g,h)=>n?.DeviceEventEmitter?.emit(g,h),r={options:null,native:false,on:false},a=()=>at({library:e.library,id:"observer",kind:"position",options:r.options??{},deliver:g=>o("geolocationDidChange",jn(g,i,Date.now())),fail:g=>o("geolocationError",Et(2,g))});P(t,"getCurrentPosition",g=>(...h)=>{if(!$())return g(...h);let C=h[1],I=h[2];if(!be()){S("request",e.library,"getCurrentPosition \u2192 services off"),I?.(Et(2,"No location provider available."));return}let{fix:T}=re();if(!T){S("request",e.library,"getCurrentPosition \u2192 no signal"),z(()=>I?.(Et(3,"Unable to fetch location within 1.0s.")),1e3);return}S("request",e.library,`getCurrentPosition \u2192 ${T.latitude.toFixed(5)}, ${T.longitude.toFixed(5)}`),z(()=>C?.(jn(T,i,Date.now())),0)});let u=P(t,"startObserving",g=>(...h)=>{if(r.options=h[0]&&typeof h[0]=="object"?h[0]:{},r.on=true,!$())return r.native=true,g(...h);r.native=false,a()}),p=P(t,"stopObserving",g=>(...h)=>{if(r.on=false,ae(e.library,"position","observer"),r.native)return r.native=false,g(...h)});return rt({library:e.library,onActiveChange(g){r.on&&(g&&r.native?(r.native=false,p?.(),a()):!g&&!r.native&&(ae(e.library,"position","observer"),r.native=true,u?.(r.options??{})))}}),true}function fr(){return sr.filter(pr).map(e=>e.library)}function gr(e){return null}function hr(e){return null}var E="expo-location";function mr(){return Nn?.OS??"ios"}function Fn(e){try{let n=globalThis.expo?.modules?.[e];if(n&&typeof n=="object")return n}catch{}let t=gr(e);return t&&typeof t=="object"?t:null}function Dt(e,t,n){let i=t==="ios",o={coords:{latitude:e.latitude,longitude:e.longitude,altitude:e.altitude??(i?0:null),accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy??(i?-1:null),heading:e.heading??(i?-1:null),speed:e.speed??(i?-1:null)},timestamp:n};return t==="android"&&(o.mocked=false),o}function yr(e,t,n){return n==="ios"?`Calling the '${e}' function has failed
|
|
2
2
|
\u2192 Caused by: ${t}`:`Call to function 'ExpoLocation.${e}' has been rejected.
|
|
3
|
-
\u2192 Caused by: ${t}`}var Pn={denied:{ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},deniedBackground:{ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},services:{ios:{code:"ERR_LOCATION_SERVICES_DISABLED",reason:"Location services are disabled"},android:{code:"ERR_LOCATION_SETTINGS_UNSATISFIED",reason:"Location request failed due to unsatisfied device settings"}},unavailable:{ios:{code:"ERR_LOCATION_UNAVAILABLE",reason:"Cannot obtain current location"},android:{code:"ERR_CURRENT_LOCATION_IS_UNAVAILABLE",reason:"Current location is unavailable. Make sure that location services are enabled"}}};function le(e,t,n){let i=n==="android"?Pn[e].android:Pn[e].ios;return Promise.reject(Ui(i.code,er(t,i.reason,n)))}var Rn=false;function tr(){let e=Mn("ExpoLocation");if(!e||typeof e.getCurrentPositionAsync!="function")return false;let t=e,n=Mn("ExpoTaskManager"),i=Qo(),o=new Map,r={},l=()=>Date.now(),p=c=>s=>t.emit?.("Expo.locationChanged",{watchId:c,location:It(s,i,l())}),f=c=>s=>{let u=s.heading??0;t.emit?.("Expo.headingChanged",{watchId:c,heading:{trueHeading:u,magHeading:u,accuracy:3}})},g=c=>s=>t.emit?.("Expo.locationError",{watchId:c,reason:s});async function y(){let c=t.getForegroundPermissionsAsync,s={granted:true,status:"granted",precision:"full",reported:false};if(typeof c!="function")return s;try{let u=await c.call(t),w=u?.ios?.accuracy==="reduced"||u?.android?.accuracy==="coarse"?"reduced":"full";Mi(w);let x=u?.granted===true,ne=x?"granted":u?.status==="undetermined"?"undetermined":"denied";return{granted:x,status:ne,precision:w,reported:true}}catch{return s}}async function T(){let c=t.getBackgroundPermissionsAsync;if(typeof c!="function")return null;try{return(await c.call(t))?.granted===true}catch{return null}}async function S(){let c=t.getBackgroundPermissionsAsync;if(typeof c!="function")return true;try{return(await c.call(t))?.granted===true}catch{return true}}function C(c,s){un({library:E,id:c,kind:s.kind,options:s.options,deliver:s.kind==="position"?p(c):f(c),fail:g(c)})}r.getCurrentPositionAsync=L(t,"getCurrentPositionAsync",c=>async(...s)=>{if(!N())return c(...s);let u="getCurrentPositionAsync";if(!je())return I("request",E,"getCurrentPositionAsync \u2192 services off"),le("services",u,i);if(!(await y()).granted)return I("request",E,"getCurrentPositionAsync \u2192 permission denied"),le("denied",u,i);let{fix:w}=he();return w?(I("request",E,`getCurrentPositionAsync \u2192 ${w.latitude.toFixed(5)}, ${w.longitude.toFixed(5)}`),It(w,i,l())):(I("request",E,"getCurrentPositionAsync \u2192 no signal"),await new Promise(x=>ie(()=>x(null),1e3)),le("unavailable",u,i))}),r.getLastKnownPositionAsync=L(t,"getLastKnownPositionAsync",c=>async(...s)=>{if(!N())return c(...s);if(!(await y()).granted)return le("denied","getLastKnownPositionAsync",i);let{fix:u}=he();return I("request",E,`getLastKnownPositionAsync \u2192 ${u?"simulated":"null"}`),u?It(u,i,l()):null}),r.watchPositionImplAsync=L(t,"watchPositionImplAsync",c=>async(...s)=>{let u=Number(s[0]),w=s[1]&&typeof s[1]=="object"?s[1]:{};if(!N()){let ne=await c(...s),se={kind:"position",options:w,native:true};return o.set(u,se),N()&&ye(u,se),ne}if(!(await y()).granted)return le("denied","watchPositionImplAsync",i);if(!N())return o.set(u,{kind:"position",options:w,native:true}),c(...s);let x={kind:"position",options:w,native:false};o.set(u,x),C(u,x)}),r.watchDeviceHeading=L(t,"watchDeviceHeading",c=>async(...s)=>{let u=Number(s[0]);if(!N()){let x=await c(...s),ne={kind:"heading",options:{},native:true};return o.set(u,ne),N()&&ye(u,ne),x}if(!(await y()).granted)return le("denied","watchDeviceHeading",i);if(!N())return o.set(u,{kind:"heading",options:{},native:true}),c(...s);let w={kind:"heading",options:{},native:false};o.set(u,w),C(u,w)}),r.removeWatchAsync=L(t,"removeWatchAsync",c=>async(...s)=>{let u=Number(s[0]),w=o.get(u);if(o.delete(u),Fe(E,"position",u),Fe(E,"heading",u),!w||w.native)return c(...s)}),L(t,"hasServicesEnabledAsync",c=>async(...s)=>N()&&!je()?false:c(...s)),L(t,"getProviderStatusAsync",c=>async(...s)=>{let u=await c(...s);if(!N()||je())return u;let w={...u,locationServicesEnabled:false};for(let x of["gpsAvailable","networkAvailable","passiveAvailable"])x in w&&(w[x]=false);return w});let F=(c,s)=>L(t,s,u=>async(...w)=>{let x=String(w[0]),ne=w[1]&&typeof w[1]=="object"?w[1]:{},se={name:x,kind:c,library:E,options:ne};if(!N()){let st=await u(...w);return yt(se,false),N()&&b(true),st}if(c==="locationUpdates"&&!je())return le("services",s,i);if(!(await y()).granted)return le("denied",s,i);if(c==="geofencing"&&!await S())return le("deniedBackground",s,i);yt(se,true)});r.startLocationUpdatesAsync=F("locationUpdates","startLocationUpdatesAsync"),r.startGeofencingAsync=F("geofencing","startGeofencingAsync");let _=(c,s)=>L(t,s,u=>async(...w)=>{let x=Ce(String(w[0]));if(!(x&&x.kind===c&&(bt(x.name),x.intercepted)))return u(...w)});r.stopLocationUpdatesAsync=_("locationUpdates","stopLocationUpdatesAsync"),r.stopGeofencingAsync=_("geofencing","stopGeofencingAsync");let de=(c,s)=>L(t,s,u=>async(...w)=>{let x=Ce(String(w[0]));return x&&x.kind===c?true:u(...w)});de("locationUpdates","hasStartedLocationUpdatesAsync"),de("geofencing","hasStartedGeofencingAsync");let pe=new Map,lt=0,Ve={geofencing:"geofencing",locationUpdates:"location"};n&&(L(n,"notifyTaskFinishedAsync",c=>async(...s)=>{let u=s[1]??{},w=u.eventId?pe.get(u.eventId):void 0;if(w&&u.eventId){pe.delete(u.eventId),w(u.result);return}return c(...s)}),L(n,"isTaskRegisteredAsync",c=>async(...s)=>Ce(String(s[0]))?.intercepted?true:c(...s)),L(n,"getTaskOptionsAsync",c=>async(...s)=>{let u=Ce(String(s[0]));return u?.intercepted?u.options:c(...s)}),L(n,"getRegisteredTasksAsync",c=>async(...s)=>{let u=await c(...s)??[],w=vt().filter(x=>x.intercepted).map(x=>({taskName:x.name,taskType:Ve[x.kind],options:x.options}));return[...u,...w]}),L(n,"unregisterTaskAsync",c=>async(...s)=>{let u=Ce(String(s[0]));if(!(u&&(bt(u.name),u.intercepted)))return c(...s)}),L(n,"unregisterAllTasksAsync",c=>async(...s)=>{for(let u of vt())bt(u.name);return c(...s)}));function Pe(){if(!n)return null;if(n.__expo_module_name__&&typeof n.emit=="function")return(s,u)=>n.emit(s,u);let c=An;return c?(s,u)=>c.emit(s,u):null}async function fe(c){for(let s=0;s<5e3&&Jo(c)===false;s+=100)await new Promise(u=>ie(()=>u(null),100))}async function Ge(c,s){await fe(c.name);let u=Pe();if(!u)return Promise.reject(new Error("expo-task-manager is not installed"));let w=`buoy-location-${++lt}`,x=typeof n?.EVENT_NAME=="string"?n.EVENT_NAME:"TaskManager.executeTask";return new Promise((ne,se)=>{pe.set(w,ne),ie(()=>{pe.delete(w)&&se(new Error("did not finish within 30 s"))},3e4);try{u(x,{data:s,error:null,executionInfo:{eventId:w,taskName:c.name,appState:"active"}})}catch(st){pe.delete(w),se(st)}})}function ye(c,s){s.native&&(s.native=false,Promise.resolve(r.removeWatchAsync?.(c)).catch(()=>{}),C(c,s))}function b(c){for(let[s,u]of Array.from(o.entries()))if(c&&u.native)ye(s,u);else if(!c&&!u.native){Fe(E,u.kind,s);let w=u.kind==="position"?r.watchPositionImplAsync:r.watchDeviceHeading;u.native=true,Promise.resolve(u.kind==="position"?w?.(s,u.options):w?.(s)).catch(x=>{u.native=false,g(s)(String(x?.message??x))})}else c&&!u.native&&!Oi(E,u.kind,s)&&C(s,u);for(let s of vt()){if(s.library!==E)continue;let u=s.kind==="geofencing";if(c&&!s.intercepted){let w=u?r.stopGeofencingAsync:r.stopLocationUpdatesAsync;Promise.resolve(w?.(s.name)).catch(()=>{}),dn(s.name,true)}else if(!c&&s.intercepted){let w=u?r.startGeofencingAsync:r.startLocationUpdatesAsync;dn(s.name,false),Promise.resolve(w?.(s.name,s.options)).catch(x=>{I("error",E,`Could not restart ${s.name} natively: ${String(x?.message??x)}`)})}}}return cn({library:E,fireTask:Ge,onActiveChange:b,readPermission:async()=>{let c=await y();if(!c.reported)return null;let s=c.status==="granted"?await T():false;return{status:c.status,background:s,precision:c.precision}}}),Rn||(Rn=true,n&&typeof n.getRegisteredTasksAsync=="function"&&Promise.resolve(n.getRegisteredTasksAsync.call(n)).then(c=>{for(let s of c??[]){if(!s?.taskName||Ce(s.taskName))continue;let u=s.taskType==="geofencing"?"geofencing":s.taskType==="location"?"locationUpdates":null;u&&(yt({name:s.taskName,kind:u,library:E,options:s.options??{}},false),N()&&b(true))}}).catch(()=>{})),true}var ze=null;function Lt(){return ze||(ze=[],tr()&&ze.push("expo-location"),ze.push(...Yo()),ze)}import{useSyncExternalStore as nr}from"react";import{FloatingTool as ir,LocationToolIcon as Nn,Pause as or,Play as rr,RefreshCw as ar,X as lr,dismissFloatingTool as sr,getFloatingTools as cr,night as ue,openFloatingTool as ur}from"@buoy-gg/shared-ui/web";var dr=new Set(["US","GB","LR","MM"]),En=null;function pr(){try{let e=Intl.DateTimeFormat().resolvedOptions().locale,t=/[-_]([A-Z]{2})\b/.exec(e);return t?t[1]:null}catch{return null}}var $t=null;function Le(){return En!==null?En:($t===null&&($t=dr.has(pr()??"")),$t)}var Dn=3.28084,On=1609.344;function q(e){if(!Number.isFinite(e))return"\u2013";let t=Math.abs(e);if(Le()){let n=t/On;return n<.1?`${Math.round(t*Dn/10)*10} ft`:`${Bn(n)} mi`}return t<1e3?`${Math.round(t)} m`:`${Bn(t/1e3)} km`}function Bn(e){let t=Math.round(e*10)/10;return t<10?t.toFixed(1):Math.round(e).toLocaleString("en-US")}function jn(e){return Number.isFinite(e)?e>=1e3?`\xB1${q(e)}`:Le()?`\xB1${Math.round(e*Dn)} ft`:`\xB1${Math.round(e)} m`:"\u2013"}function Mt(e){if(e==null||e<0)return"\u2013";let t=Le()?e*3600/On:e*3.6,n=Le()?"mph":"km/h";return`${t<10?t.toFixed(1):Math.round(t)} ${n}`}function fr(e){if(!Number.isFinite(e)||e<0)return"\u2013";let t=Math.round(e/6e4);if(t<1)return`${Math.max(1,Math.round(e/1e3))} sec`;if(t<60)return`${t} min`;let n=Math.floor(t/60),i=t%60;return i?`${n} hr ${i} min`:`${n} hr`}function gr(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"now";if(n<60)return`${n}s ago`;try{return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{let i=new Date(e);return`${i.getHours()}:${String(i.getMinutes()).padStart(2,"0")}`}}function Fn(e){return e.override.services?e.override.signal?e.override.mode==="real"?"Real Location":e.override.mode==="route"?e.override.route?.name??"Route":e.override.place.label||"Dropped Pin":"No GPS Signal":"Location Services Off"}function hr(e){return!e.override.services||!e.override.signal?"broken":e.override.mode==="real"?"real":"simulated"}function mr(e){if(!e.override.services)return"The app is told location services are off";if(!e.override.signal)return"Updates stop and location requests fail";if(e.override.mode==="real")return"The app gets the device's location";let t=[];if(e.override.mode==="route"&&e.progress){let i=e.progress;i.finished?t.push("Arrived"):e.override.playing||t.push("Paused"),e.current.reason==="gap"&&t.push("no signal here"),i.finished||(t.push(`${q(i.along)} of ${q(i.length)}`),i.etaMs!=null?t.push(`${fr(i.etaMs)} left`):e.override.route?.loop&&t.push("on repeat"))}else t.push("Pinned");let n=e.current.fix;return n&&e.override.mode==="fixed"&&t.push(jn(n.accuracy)),e.current.precision==="reduced"&&t.push("approximate"),t.join(" \xB7 ")}function yr(e){return e.status==="denied"?"Not Allowed":e.status==="undetermined"?"Not Asked Yet":`${e.background?"Always":"While Using"} \xB7 ${e.precision==="reduced"?"Approximate":"Precise"}`}function br(e){if(!e.override.services)return"The app is told location is off";if(!e.override.signal)return"Updates stop, requests fail";if(e.override.mode==="route"&&e.progress){if(e.progress.finished)return"Arrived";let n=`${q(e.progress.along)} of ${q(e.progress.length)}`;return e.override.playing?n:`Paused \xB7 ${n}`}let t=e.current.fix;return t?`Pinned \xB7 ${Ne(t,3)}`:"Pinned"}import{jsx as H,jsxs as _n}from"react/jsx-runtime";var nt="location-chip",vr={id:nt,render:e=>H(Un,{...e})},wr=()=>cr().some(e=>e.id===nt),zn=false,Pt=false,Wn=null;function Hn(e){Pt!==e&&(Pt=e,Wn?.())}function kr(){if(zn)return;zn=true;let e=false,t=()=>{let n=P().active&&zi().showChip&&!Pt;n&&!e?ur(vr):!n&&wr()&&sr(nt),e=n};Wn=t,Be(t),t()}function Un({id:e,revealToken:t}){let n=nr(Be,P,P),i=Fn(n),o=n.override.mode==="route"&&n.progress,r=n.override.playing,l=!!o&&o.finished;return H(ir,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the location chip. ${i}`,handleAdornment:H(Nn,{size:12}),children:_n(v,{style:me.row,children:[H(Nn,{size:18}),_n(v,{style:me.text,children:[H(A,{style:me.title,numberOfLines:1,testID:"location-chip-title",children:i}),H(A,{style:me.detail,numberOfLines:1,testID:"location-chip-detail",children:br(n)})]}),o?H(ae,{testID:"location-chip-playpause",accessibilityRole:"button",accessibilityLabel:r?"Pause the route":l?"Play the route again":"Resume the route",onPress:()=>r?wt():kt(),style:me.pill,hitSlop:{top:8,bottom:8,left:4,right:4},children:r?H(or,{size:14,color:ue.color.accent}):l?H(ar,{size:14,color:ue.color.accent}):H(rr,{size:14,color:ue.color.accent})}):null,H(v,{style:me.separator}),H(ae,{testID:"location-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to the real location",onPress:()=>Tt(),style:me.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:H(lr,{size:16,color:ue.color.textSecondary})})]})})}var me=re.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:230,maxWidth:340},text:{flexShrink:1,minWidth:120},title:{color:ue.color.text,fontSize:14,fontWeight:"600"},detail:{color:ue.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},pill:{width:30,height:30,borderRadius:15,alignItems:"center",justifyContent:"center",backgroundColor:ue.color.accentFill},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:re.hairlineWidth,height:20,backgroundColor:ue.color.separator}});import{LocationToolIcon as xr,LOCATION_TOOL_ICON_COLOR as Tr,createToolFactory as Sr,defineToolPreset as Ar}from"@buoy-gg/shared-ui/web";import{useEffect as Cr,useState as Ir}from"react";import{FeatureGate as Lr}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as $r}from"@buoy-gg/shared-ui/web";var it=[{latitude:37.3349,longitude:-122.009,label:"Apple Park"},{latitude:37.422,longitude:-122.0841,label:"Googleplex"},{latitude:40.758,longitude:-73.9855,label:"Times Square"},{latitude:51.508,longitude:-.1281,label:"Trafalgar Square"},{latitude:48.8584,longitude:2.2945,label:"Eiffel Tower"},{latitude:35.6595,longitude:139.7005,label:"Shibuya Crossing"},{latitude:-33.8568,longitude:151.2153,label:"Sydney Opera House"},{latitude:-23.5614,longitude:-46.6559,label:"S\xE3o Paulo"},{latitude:0,longitude:0,label:"Null Island"}],$e=[{id:"walk",name:"Walk",description:"1 km north from here at walking pace",speed:1.4},{id:"run",name:"Run",description:"3 km north, then east, at running pace",speed:3.3},{id:"drive",name:"City Drive",description:"4 km of city streets with turns",speed:13.4},{id:"highway",name:"Highway",description:"30 km north at highway speed",speed:30},{id:"tunnel",name:"Tunnel",description:"3 km drive with no signal for 600 m in the middle",speed:13.4},{id:"loop",name:"Block Loop",description:"A 400 m block, walked on repeat",speed:1.4}];function Vn(e,t,n=0){let i=$e.find(g=>g.id===e);if(!i)throw new Error(`Unknown route preset "${e}". Use one of: ${$e.map(g=>g.id).join(", ")}.`);let o={latitude:t.latitude,longitude:t.longitude},r=(g,y,T)=>Re(g,n+y,T),l,p,f=false;switch(e){case"walk":l=[o,r(o,0,1e3)];break;case"run":l=[o,r(o,0,1500),r(r(o,0,1500),90,1500)];break;case"drive":{let g=r(o,0,1200),y=r(g,90,800),T=r(y,0,1e3),S=r(T,-90,1e3);l=[o,g,y,T,S];break}case"highway":l=[o,r(o,0,3e4)];break;case"tunnel":l=[o,r(o,0,3e3)],p=[[1200,1800]];break;case"loop":{let g=r(o,0,100),y=r(g,90,100),T=r(y,180,100);l=[o,g,y,T,o],f=true;break}}return{id:`preset:${e}`,name:i.name,points:l,speed:i.speed,loop:f,gaps:p}}function Mr(e,t,n){return{id:"line",name:t.label?`To ${t.label}`:"Straight line",points:[{latitude:e.latitude,longitude:e.longitude},{latitude:t.latitude,longitude:t.longitude}],speed:n}}function J(e){return e&&typeof e=="object"?e:{}}function We(e,...t){for(let n of t){let i=e[n];if(typeof i=="boolean")return i;if(i==="true"||i==="on")return true;if(i==="false"||i==="off")return false}}function K(e,...t){for(let n of t){let i=e[n];if(i==null||i==="")continue;let o=Number(i);if(Number.isFinite(o))return o}}function $(){return{...P(),builtInPlaces:it,presets:$e}}function Pr(e){let t=e.trim().toLowerCase(),n=[...P().places,...it];return n.find(i=>i.label?.toLowerCase()===t)??n.find(i=>i.label?.toLowerCase().includes(t))??null}function Gn(e){let t=typeof e.label=="string"?e.label:void 0,n=K(e,"latitude","lat"),i=K(e,"longitude","lon","lng");if(n!==void 0&&i!==void 0){let o={latitude:n,longitude:i};if(!be(o))throw new Error("latitude must be within \xB190 and longitude within \xB1180.");return{...o,label:t}}for(let o of["place","to","query","coordinate","at"]){let r=e[o];if(be(r))return{...r,label:r.label??t};if(typeof r=="string"&&r.trim()){let l=dt(r);if(l)return{...l,label:t};let p=Pr(r);if(p)return p;throw new Error(`No place called "${r}". Give latitude and longitude, or one of: ${Rr()}.`)}}return null}function Rr(){return[...P().places,...it].map(e=>e.label).filter(Boolean).join(", ")}function Nr(e){let t=K(e,"speed","metersPerSecond"),n=K(e,"heading","bearing")??0;if(Array.isArray(e.points))return{points:e.points,speed:t??1.4,loop:We(e,"loop")??false,name:typeof e.name=="string"?e.name:"Custom route",gaps:Array.isArray(e.gaps)?e.gaps:void 0};let i=typeof e.route=="string"?e.route:typeof e.routeId=="string"?e.routeId:typeof e.preset=="string"?e.preset:void 0;if(i){let r=P().routes.find(f=>f.id===i||f.name?.toLowerCase()===i.toLowerCase());if(r)return t?{...r,speed:t}:r;let l=$e.find(f=>f.id===i||f.name.toLowerCase()===i.toLowerCase());if(l){let f=Vn(l.id,_e(),n);return t?{...f,speed:t}:f}let p=[...P().routes.map(f=>f.id??f.name),...$e.map(f=>f.id)];throw new Error(`No route "${i}". Use one of: ${p.join(", ")}; or pass points.`)}let o=Gn(e);if(o)return Mr(_e(),o,t??1.4);throw new Error("startRoute needs `points` (two or more {latitude, longitude}), `route` (a preset or app route id), or `to` (a place).")}var Rt=$r({version:1,getSnapshot(){return $()},subscribe(e){return Be(e)},actions:{getState(){return $()},setLocation(e){let t=Gn(J(e));if(!t)throw new Error('setLocation needs `latitude` and `longitude`, `query` ("lat, lon" or a map link), or `place` (a place name).');return tt(t),$()},startRoute(e){return pn(Nr(J(e))),$()},stopRoute(){return vn(),$()},setConditions(e){let t=J(e),n=(typeof t.conditions=="string"?t.conditions:typeof t.preset=="string"?t.preset:"").trim().toLowerCase().replace(/[\s_]+/g,"-"),i={good:"good",weak:"weak","no-signal":"no-signal",nosignal:"no-signal",off:"off","services-off":"off","location-off":"off"}[n];if(!i)throw new Error("setConditions needs `conditions`: good, weak, no-signal or off.");return bn(i),$()},pauseRoute(){return wt(),$()},resumeRoute(){return kt(),$()},seekRoute(e){let t=J(e),n=K(t,"meters","along"),i=K(t,"fraction","progress"),o=P().progress?.length??0;if(n===void 0&&i===void 0)throw new Error("seekRoute needs `meters` or `fraction` (0 to 1).");return fn(n??(i??0)*o),$()},setSpeed(e){let t=K(J(e),"speed","metersPerSecond");if(t===void 0)throw new Error("setSpeed needs `speed` in meters per second.");return gn(t),$()},tune(e){let t=J(e);return hn({accuracy:K(t,"accuracy"),jitter:K(t,"jitter","drift"),altitude:t.altitude===null?null:K(t,"altitude"),heading:t.heading===null?null:K(t,"heading"),interval:K(t,"interval","intervalMs")}),$()},setSignal(e){let t=We(J(e),"on","signal","enabled");if(t===void 0)throw new Error("setSignal needs `on`: true or false.");return mn(t),$()},setServices(e){let t=We(J(e),"on","services","enabled");if(t===void 0)throw new Error("setServices needs `on`: true or false.");return yn(t),$()},enterRegion(e){let t=J(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("enterRegion needs `identifier` (a monitored geofence region).");return xt(n,"inside",typeof t.task=="string"?t.task:void 0),$()},exitRegion(e){let t=J(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("exitRegion needs `identifier` (a monitored geofence region).");return xt(n,"outside",typeof t.task=="string"?t.task:void 0),$()},useRealLocation(){return wn(),$()},reset(){return Tt(),$()},updateSettings(e){let t=J(e);return _i({persist:We(t,"persist"),showChip:We(t,"showChip")}),$()},clearLog(){return Wi(),$()}}});import{useEffect as Er,useState as Me}from"react";import{Check as Dr,ChevronLeft as Or,ChevronRight as Br,NightButton as qn,NightCard as R,NightFootnote as Q,NightRows as ee,NightSectionLabel as X,NightSegmented as Nt,NightSwitch as jr,Pause as Fr,Play as _r,RefreshCw as zr,copyToClipboard as Wr,monoFont as Hr,night as h,realNow as Et,useSafeAreaInsets as Ur,useToolScreenHeader as Vr}from"@buoy-gg/shared-ui/web";import{night as te}from"@buoy-gg/shared-ui/web";import{jsx as Y,jsxs as ot}from"react/jsx-runtime";var Kn="#F87171",He=1.8,Gr=6e4,qr=400;function Kr({snapshot:e,onPinPlace:t,onCrossRegion:n}){let i=e.position,o=e.override.mode==="route"?e.override.route:null,r=i??e.places[0]??Xr(e.tasks)??null;if(!r)return null;let l=b=>!i||U(i,b)<=Gr,p=e.places.filter(l),f=e.tasks.filter(b=>b.kind==="geofencing").flatMap(b=>b.regions.filter(l).map(c=>({task:b,region:c}))),g=e.places.length-p.length,y=Math.cos(r.latitude*Math.PI/180),T=b=>({x:(b.longitude-r.longitude)*111320*y,y:(b.latitude-r.latitude)*110540}),S=[];i&&S.push({...T(i),r:60});for(let b of o?.points??[])S.push({...T(b),r:0});for(let b of p)S.push({...T(b),r:60});for(let b of f)S.push({...T(b.region),r:b.region.radius});let C=1/0,F=-1/0,_=1/0,de=-1/0;for(let b of S)C=Math.min(C,b.x-b.r),F=Math.max(F,b.x+b.r),_=Math.min(_,b.y-b.r),de=Math.max(de,b.y+b.r);let pe=(C+F)/2,lt=(_+de)/2,Ve=Math.max(qr,(de-_)*1.35,(F-C)*1.2/He),Pe=Ve*He,fe=b=>{let c=T(b);return{x:.5+(c.x-pe)/Pe,y:.5-(c.y-lt)/Ve}},Ge=Zr(Pe),ye=e.override.mode==="fixed"?e.override.place.label:void 0;return Y(v,{children:ot(v,{style:M.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[Xn.map(b=>Y(v,{style:[M.gridV,{left:B(b)}]},`v${b}`)),Xn.map(b=>Y(v,{style:[M.gridH,{top:B(b)}]},`h${b}`)),f.map(({task:b,region:c})=>{let s=fe(c),u=2*c.radius/Pe,w=u*He,x=c.state==="inside";return Y(ae,{testID:`location-map-region-${Yn(c.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${x?"Leave":"Enter"} ${c.label??c.identifier}`,activeOpacity:.6,onPress:()=>n(b,c),style:[M.fence,x?M.fenceInside:null,{left:B(s.x-u/2),top:B(s.y-w/2),width:B(u),height:B(w)}]},`${b.name}:${c.identifier}`)}),o?Yr(o.points.map(fe)).map((b,c)=>Y(v,{pointerEvents:"none",style:[M.segment,{left:B(b.midX-b.length/2),top:B(b.midY),width:B(b.length),transform:[{rotate:`${b.angle}rad`}]}]},`seg${c}`)):null,p.map((b,c)=>{let s=fe(b),u=!!ye&&ye===b.label;return ot(ae,{testID:`location-map-place-${Yn(b.label??String(c))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${b.label??"this place"}`,activeOpacity:.6,onPress:()=>t(b),style:[M.placeHit,{left:B(s.x),top:B(s.y)}],children:[Y(v,{style:[M.placeDot,u?M.placeDotSelected:null]}),b.label?Y(A,{style:M.placeLabel,numberOfLines:1,children:b.label}):null]},`${b.label??c}`)}),i?ot(v,{pointerEvents:"none",style:[M.pinWrap,{left:B(fe(i).x),top:B(fe(i).y)}],children:[Y(v,{style:M.pinHalo}),Y(v,{style:[M.pin,e.current.reason==="gap"?M.pinHollow:null]})]}):null,ot(v,{style:M.scale,pointerEvents:"none",children:[Y(v,{style:[M.scaleBar,{width:B(Ge.fraction)}]}),Y(A,{style:M.scaleLabel,children:Ge.label})]}),g>0?Y(A,{style:M.offMap,pointerEvents:"none",children:`${g} more ${g===1?"place":"places"} off the map`}):null]})})}var Xn=[.2,.4,.6,.8];function B(e){return`${e*100}%`}function Xr(e){for(let t of e)if(t.regions[0])return t.regions[0];return null}function Yr(e){let t=[];for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n],r=o.x-i.x,l=(o.y-i.y)/He;t.push({midX:(i.x+o.x)/2,midY:(i.y+o.y)/2,length:Math.sqrt(r*r+l*l),angle:Math.atan2(l,r)})}return t}function Zr(e){let t=e/4,n=Le()?1609.344:1e3,i=Le()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(r=>r*n):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5],o=i[0];for(let r of i)r<=t&&(o=r);return{fraction:o/e,label:q(o)}}function Yn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var M=re.create({map:{width:"100%",aspectRatio:He,borderRadius:te.radius.card,borderWidth:1,borderColor:te.color.border,backgroundColor:te.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:re.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:re.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:te.color.accentBorderStrong,backgroundColor:te.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:te.color.textSecondary},placeDotSelected:{backgroundColor:te.color.text},placeLabel:{color:te.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:Kn,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:Kn},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:te.color.textTertiary},scaleLabel:{color:te.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:te.color.textTertiary,fontSize:10}});import{Fragment as Ue,jsx as a,jsxs as k}from"react/jsx-runtime";var Zn={places:"Other Location",routes:"Route",speed:"Speed",accuracy:"Accuracy & Drift",activity:"Activity",options:"Options"},Jr="#F87171",Jn=[{key:"1.4",label:"Walking"},{key:"3.3",label:"Running"},{key:"5.5",label:"Cycling"},{key:"13.4",label:"City Traffic"},{key:"30",label:"Highway"},{key:"250",label:"Airplane"}],Qn=[{key:"good",label:"Good"},{key:"weak",label:"Weak"},{key:"no-signal",label:"No Signal"},{key:"off",label:"Off"}],Qr={good:"Precise fixes, like outdoors with a clear sky.",weak:"Fixes are \xB165 m and wander by up to 50 m, like indoors or between tall buildings.","no-signal":"Watches get no updates and location requests fail.",off:"The app is told location services are turned off.",custom:"Custom accuracy and drift."},ei=[{key:"5",label:"5 m"},{key:"20",label:"20 m"},{key:"65",label:"65 m"},{key:"1000",label:"1 km"}],ti=[{key:"0",label:"Off"},{key:"10",label:"10 m"},{key:"50",label:"50 m"},{key:"200",label:"200 m"}],ea=4;function Dt(e){let[t,n]=Me(()=>Et());return Er(()=>{if(!e)return;let i=setInterval(()=>n(Et()),1e3);return()=>clearInterval(i)},[e]),t}function ni({snapshot:e,onAction:t}){let n=Ur({minBottom:16}),[i,o]=Me(null),[r,l]=Me("main"),p=()=>l("main"),f=Vr(r==="main"?null:{title:Zn[r],subtitle:"",onBack:p,searchable:false},[r]),g=(C,F)=>{o(null),t(C,F).catch(_=>{o(_ instanceof Error?_.message:String(_))})};if(!e)return a(v,{style:m.waiting,testID:"location-waiting",children:a(Q,{centered:true,children:"Waiting for the app\u2026"})});let y=i?a(Q,{tone:"danger",centered:true,children:a(A,{testID:"location-error",children:i})}):null,T=(C,F)=>{g(C,F),p()},S;switch(r){case"places":S=a(aa,{snapshot:e,pick:T});break;case"routes":S=a(ua,{snapshot:e,pick:T});break;case"speed":S=a(pa,{snapshot:e,pick:T});break;case"accuracy":S=a(ba,{snapshot:e,run:g});break;case"activity":S=a(wa,{snapshot:e,run:g});break;case"options":S=a(xa,{snapshot:e,run:g});break;default:S=k(Ue,{children:[a(ta,{snapshot:e,run:g}),y,a(ia,{snapshot:e,run:g}),a(oa,{snapshot:e,run:g,open:l}),a(sa,{snapshot:e,open:l}),a(ga,{snapshot:e,run:g}),a(ya,{snapshot:e,run:g,open:l}),a(va,{snapshot:e,open:l})]})}return k(In,{style:m.fill,contentContainerStyle:[m.content,{paddingBottom:n.bottom}],testID:"location-scroll",keyboardShouldPersistTaps:"handled",children:[r!=="main"&&!f?a(Ta,{title:Zn[r],onBack:p}):null,r!=="main"?y:null,S]},r)}function ta({snapshot:e,run:t}){let n=e.override,i=n.mode==="route"?n.route:null,o=e.progress;Dt(!!i&&n.playing);let r=hr(e),l=e.current.fix,p=o&&o.length>0?Math.min(1,o.along/o.length):0,[f,g]=Me(false);return k(R,{children:[k(v,{style:m.status,children:[a(A,{style:[m.statusTitle,r==="simulated"?m.titleSimulated:r==="broken"?m.titleBroken:null],testID:"location-hero-title",numberOfLines:1,adjustsFontSizeToFit:true,children:Fn(e)}),a(A,{style:m.statusLine,testID:"location-hero-status",children:mr(e)}),l&&e.simulating?a(ae,{testID:"location-copy-coordinates",accessibilityRole:"button",accessibilityLabel:"Copy coordinates",activeOpacity:.6,onPress:()=>{Wr(`${l.latitude}, ${l.longitude}`).then(y=>{y&&(g(true),setTimeout(()=>g(false),1500))})},children:a(A,{style:m.coordinates,children:f?"Copied":Ne(l,5)})}):null,i&&o?k(v,{style:m.progressTrack,testID:"location-route-progress",children:[a(v,{style:[m.progressFill,{width:`${p*100}%`}]}),(i.gaps??[]).map(([y,T],S)=>a(v,{style:[m.progressGap,{left:`${y/o.length*100}%`,width:`${(T-y)/o.length*100}%`}]},S))]}):null,e.active?k(v,{style:m.statusButtons,children:[i&&o?a(na,{testID:n.playing?"location-route-pause":"location-route-resume",label:n.playing?"Pause":o.finished?"Play again":"Resume",onPress:()=>t(n.playing?"pauseRoute":"resumeRoute"),children:n.playing?a(Fr,{size:18,color:h.color.onAccent}):o.finished?a(zr,{size:18,color:h.color.onAccent}):a(_r,{size:18,color:h.color.onAccent})}):null,a(v,{style:m.flex,children:a(qn,{label:"Use Real Location",size:"md",testID:"location-reset",onPress:()=>t("reset")})})]}):null]}),e.permission?k(v,{style:m.permission,testID:"location-permission",children:[k(v,{style:m.rowBetween,children:[a(A,{style:m.rowTitle,children:"Permission"}),a(A,{style:[m.rowValue,e.permission.status!=="granted"?m.valueWarning:null],testID:"location-permission-value",children:yr(e.permission)})]}),e.permission.status!=="granted"?a(A,{style:m.detail,children:"The app's location requests fail until it's allowed. Change it in Settings or the Permissions tool."}):null]}):null]})}function na({children:e,label:t,onPress:n,testID:i}){return a(ae,{testID:i,accessibilityRole:"button",accessibilityLabel:t,activeOpacity:.7,onPress:n,style:m.round,children:e})}function ia({snapshot:e,run:t}){return!!e.position||e.places.length>0||e.tasks.some(n=>n.regions.length>0)?k(v,{children:[a(Kr,{snapshot:e,onPinPlace:n=>t("setLocation",{latitude:n.latitude,longitude:n.longitude,label:n.label}),onCrossRegion:(n,i)=>t(i.state==="inside"?"exitRegion":"enterRegion",{identifier:i.identifier,task:n.name})}),a(Q,{children:"Map views in the app still show the device's own blue dot. Move the simulator's location for those."})]}):null}function oa({snapshot:e,run:t,open:n}){let i=e.places.length>0?e.places:e.builtInPlaces.slice(0,ea),o=e.override.mode==="fixed"?e.override.place:null,r=e.position,l=!!o&&!i.some(p=>rt(p,o));return k(v,{children:[a(X,{children:"Location"}),a(R,{children:k(ee,{children:[i.map((p,f)=>a(j,{title:p.label??Ne(p,4),value:r&&!(o&&rt(p,o))?ra(r,p):void 0,checked:!!o&&rt(p,o),testID:`location-place-${at(p.label??String(f))}`,onPress:()=>t("setLocation",{latitude:p.latitude,longitude:p.longitude,label:p.label})},`${p.label??f}`)),a(j,{title:"Other Location\u2026",value:l?o.label||Ne(o,3):void 0,chevron:true,testID:"location-other",onPress:()=>n("places")},"other")]})})]})}function ra(e,t){let n=U(e,t);return n<30?"Here":q(n)}function rt(e,t){return e.label&&t.label?e.label===t.label:U(e,t)<1}function aa({snapshot:e,pick:t}){let[n,i]=Me(""),o=dt(n),r=e.override.mode==="fixed"?e.override.place:null,l=()=>{o&&(t("setLocation",{query:n}),i(""))};return k(Ue,{children:[k(v,{children:[a(X,{children:"Coordinates"}),a(R,{children:k(v,{style:m.editor,children:[k(v,{style:m.inputRow,children:[a(Cn,{value:n,onChangeText:i,placeholder:"Coordinates or a Maps link",placeholderTextColor:h.color.placeholder,autoCapitalize:"none",autoCorrect:false,style:m.input,testID:"location-coordinate-input",accessibilityLabel:"Coordinates or a Maps link",returnKeyType:"done",onSubmitEditing:l}),a(qn,{label:"Pin",size:"md",variant:"primary",disabled:!o,testID:"location-coordinate-set",onPress:l})]}),n.length>0?a(A,{style:o?m.detail:m.warning,testID:"location-coordinate-preview",children:o?la(o):"Type a latitude and longitude, like 40.7580, -73.9855, or paste a Google or Apple Maps link."}):null]})})]}),k(v,{children:[a(X,{children:"Places"}),a(R,{children:a(ee,{children:e.builtInPlaces.map((p,f)=>a(j,{title:p.label??Ne(p,4),detail:p.label==="Null Island"?"0, 0: catches code that treats 0 as no location":void 0,checked:!!r&&rt(p,r),testID:`location-place-${at(p.label??String(f))}`,onPress:()=>t("setLocation",{latitude:p.latitude,longitude:p.longitude,label:p.label})},`${p.label??f}`))})}),e.places.length===0?a(Q,{children:"Add your own places, such as your stores, with registerLocationPlaces()."}):null]})]})}function la(e){let t=`${Math.abs(e.latitude).toFixed(4)}\xB0 ${e.latitude>=0?"N":"S"}`,n=`${Math.abs(e.longitude).toFixed(4)}\xB0 ${e.longitude>=0?"E":"W"}`;return`${t}, ${n}`}function sa({snapshot:e,open:t}){let n=e.override.mode==="route"?e.override.route:null;return k(v,{children:[a(X,{children:"Movement"}),a(R,{children:k(ee,{children:[a(j,{title:"Route",value:n?.name??"None",chevron:true,testID:"location-route",onPress:()=>t("routes")},"route"),n?a(j,{title:"Speed",value:ca(n.speed),chevron:true,testID:"location-speed",onPress:()=>t("speed")},"speed"):null]})})]})}function ca(e){let t=Jn.find(n=>Math.abs(Number(n.key)-e)<.05);return t?t.label:Mt(e)}function ua({snapshot:e,pick:t}){let n=e.override.mode==="route"?e.override.route:null,i=n?.id;return k(Ue,{children:[n?a(v,{children:a(R,{children:a(ee,{children:a(j,{title:"Stop Here",detail:"End the route and stay where it got to",testID:"location-route-stop",onPress:()=>t("stopRoute")},"stop")})})}):null,e.routes.length>0?k(v,{children:[a(X,{children:"This App"}),a(R,{children:a(ee,{children:e.routes.map((o,r)=>a(j,{title:o.name??o.id??`Route ${r+1}`,detail:`${q(ut(o.points))} at ${Mt(o.speed)}${o.loop?", on repeat":""}`,checked:!!i&&i===o.id,testID:`location-route-${at(o.id??o.name??String(r))}`,onPress:()=>t("startRoute",{route:o.id??o.name})},o.id??`${o.name}-${r}`))})})]}):null,k(v,{children:[a(X,{children:"From Here"}),a(R,{children:a(ee,{children:e.presets.map(o=>a(j,{title:o.name,detail:da(o.id)??o.description,checked:i===`preset:${o.id}`,testID:`location-preset-${o.id}`,onPress:()=>t("startRoute",{route:o.id})},o.id))})}),a(Q,{children:"These start where the app is now."})]})]})}function da(e){let t=q;switch(e){case"walk":return`${t(1e3)} north at walking pace`;case"run":return`${t(3e3)} north, then east, at running pace`;case"drive":return`${t(4e3)} of city streets with turns`;case"highway":return`${t(3e4)} north at highway speed`;case"tunnel":return`${t(3e3)} drive with no signal for ${t(600)} in the middle`;case"loop":return`A ${t(400)} block, walked on repeat`;default:return null}}function pa({snapshot:e,pick:t}){let n=e.override.route?.speed??0;return k(v,{children:[a(R,{children:a(ee,{children:Jn.map(i=>a(j,{title:i.label,value:Mt(Number(i.key)),checked:Math.abs(Number(i.key)-n)<.05,testID:`location-speed-${i.key}`,onPress:()=>t("setSpeed",{speed:Number(i.key)})},i.key))})}),a(Q,{children:"Heading and speed follow the route."})]})}var fa=1e4;function ga({snapshot:e,run:t}){let n=e.tasks.filter(f=>f.kind==="geofencing"&&f.regions.length>0),[i,o]=Me(null),r=Dt(!!i);if(n.length===0)return null;let l=n.length>1,p=n.map(f=>f.name).join(", ");return k(v,{children:[a(X,{children:"Geofences"}),a(R,{children:a(ee,{children:n.flatMap(f=>f.regions.map(g=>{let y=`${f.name}:${g.identifier}`,T=g.state==="inside",S=i?.key===y&&r-i.at<fa?i:null,C=[ha(g)];return l&&C.push(f.name),a(j,{title:g.label??g.identifier,detail:C.join(" \xB7 "),note:S?ma(e,f,S.at):void 0,action:T?"Leave":"Enter",testID:`location-region-${at(g.identifier)}`,onPress:()=>{o({key:y,at:Et()}),t(T?"exitRegion":"enterRegion",{identifier:g.identifier,task:f.name})}},y)}))})}),k(Q,{children:["Tap a region to cross its edge. ",l?"The app's tasks":`The app's ${p} task`," runs as it would from the OS."]})]})}function ha(e){return e.state==="inside"?"Inside":e.distance==null?`${q(e.radius)} radius`:`${q(Math.max(0,e.distance-e.radius))} away`}function ma(e,t,n){let i=e.log.filter(r=>r.at>=n-50&&(r.detail??"").startsWith(t.name)),o=i.find(r=>r.kind==="error");return o?{text:`Task failed: ${o.detail?.slice(t.name.length+3)??""}`,tone:"bad"}:i.find(r=>r.kind==="task")?{text:"Task ran",tone:"ok"}:i.find(r=>r.kind==="enter"||r.kind==="exit")?{text:"Running the app's task\u2026",tone:"wait"}:{text:"Already on this side",tone:"wait"}}function ya({snapshot:e,run:t,open:n}){let i=e.override,o=xi(i),r=e.simulating?Qn:Qn.filter(l=>l.key!=="weak");return k(v,{children:[a(X,{children:"Conditions"}),k(R,{children:[a(v,{style:m.segmentWrap,children:a(Nt,{tabs:r,activeKey:o??"",size:"sm",testIDPrefix:"location-conditions",onChange:l=>t("setConditions",{conditions:l})})}),e.simulating&&i.services&&i.signal?a(v,{style:m.separatorTop,children:a(j,{title:"Accuracy & Drift",value:`${jn(i.accuracy)}${i.jitter>0?` \xB7 drifts ${q(i.jitter)}`:""}`,chevron:true,testID:"location-accuracy",onPress:()=>n("accuracy")})}):null]}),a(Q,{children:Qr[o??"custom"]})]})}function ba({snapshot:e,run:t}){let n=e.override;return k(Ue,{children:[k(v,{children:[a(X,{children:"Accuracy"}),a(R,{children:a(v,{style:m.segmentWrap,children:a(Nt,{tabs:ei,activeKey:oi(ei,n.accuracy)??"",size:"sm",testIDPrefix:"location-accuracy",onChange:i=>t("tune",{accuracy:Number(i)})})})}),a(Q,{children:"The accuracy radius the app is given with each fix."})]}),k(v,{children:[a(X,{children:"Drift"}),a(R,{children:a(v,{style:m.segmentWrap,children:a(Nt,{tabs:ti,activeKey:oi(ti,n.jitter)??"0",size:"sm",testIDPrefix:"location-drift",onChange:i=>t("tune",{jitter:Number(i)})})})}),a(Q,{children:"Moves each fix by up to this much at random, the way a real fix wanders."})]})]})}function va({snapshot:e,open:t}){let n=e.log.length;return a(v,{children:a(R,{children:k(ee,{children:[a(j,{title:"Activity",value:n===0?"None":`${n} ${n===1?"event":"events"}`,chevron:true,testID:"location-activity",onPress:()=>t("activity")},"activity"),a(j,{title:"Options",chevron:true,testID:"location-options",onPress:()=>t("options")},"options")]})})})}function wa({snapshot:e,run:t}){let n=Dt(true),i=e.log.slice().reverse(),o=e.watches.filter(f=>f.kind==="position").length,r=e.tasks.filter(f=>f.kind==="locationUpdates").length,l=e.tasks.filter(f=>f.kind==="geofencing").reduce((f,g)=>f+g.regions.length,0),p=[o?`${o} location ${o===1?"watch":"watches"}`:null,l?`${l} ${l===1?"geofence":"geofences"}`:null,r?"background updates":null].filter(Boolean);return k(Ue,{children:[k(v,{children:[a(X,{children:"The App Is Using"}),a(R,{children:k(v,{style:m.editor,children:[a(A,{style:m.rowTitle,testID:"location-activity-summary",children:p.length?p.join(", "):"Nothing right now"}),a(A,{style:m.detail,children:e.libraries.length?`Through ${e.libraries.join(" and ")}.`:"No supported location library was found in this app."})]})})]}),k(v,{children:[a(X,{children:"Recent"}),a(R,{children:k(ee,{children:[i.length===0?a(v,{style:m.editor,children:a(A,{style:m.detail,children:"Location requests, watches and geofence crossings show up here."})},"empty"):i.map(f=>k(v,{style:m.logRow,testID:"location-log-entry",children:[a(v,{style:[m.logDot,ka(f.kind)]}),k(v,{style:m.flex,children:[a(A,{style:m.logText,children:f.text}),f.detail?a(A,{style:m.logDetail,numberOfLines:2,children:f.detail}):null]}),a(A,{style:m.logWhen,children:gr(f.at,n)})]},f.id)),i.length>0?a(j,{title:"Clear",tint:true,testID:"location-clear-log",onPress:()=>t("clearLog")},"clear"):null]})})]})]})}function ka(e){return e==="enter"?m.dotEnter:e==="exit"?m.dotExit:e==="error"?m.dotError:e==="task"?m.dotTask:null}function xa({snapshot:e,run:t}){return k(v,{children:[a(R,{children:k(ee,{children:[a(ii,{title:"Keep Across Reloads",value:e.settings.persist,testID:"location-setting-persist",onValueChange:n=>t("updateSettings",{persist:n})},"persist"),a(ii,{title:"Show Floating Status",value:e.settings.showChip,testID:"location-setting-showChip",onValueChange:n=>t("updateSettings",{showChip:n})},"chip")]})}),a(Q,{children:"The floating status stays on screen while the app is somewhere else, so a simulated location is never left on by accident."})]})}function Ta({title:e,onBack:t}){return k(ae,{testID:"location-back",accessibilityRole:"button",accessibilityLabel:"Back",activeOpacity:.6,onPress:t,style:m.backRow,children:[a(Or,{size:18,color:h.color.accent}),a(A,{style:m.backLabel,children:"Location"}),a(A,{style:m.backTitle,numberOfLines:1,children:e})]})}function j({title:e,detail:t,note:n,value:i,action:o,checked:r,chevron:l,tint:p,onPress:f,testID:g}){return k(ae,{testID:g,accessibilityRole:"button",accessibilityLabel:o?`${o} ${e}`:e,accessibilityState:r?{selected:true}:void 0,activeOpacity:.6,onPress:f,style:m.row,children:[k(v,{style:m.rowText,children:[a(A,{style:[m.rowTitle,p?m.titleTint:null],numberOfLines:1,children:e}),t?a(A,{style:m.detail,children:t}):null,n?a(A,{style:[m.note,n.tone==="ok"?m.noteOk:n.tone==="bad"?m.noteBad:null],testID:`${g}-result`,children:n.text}):null]}),i?a(A,{style:m.rowValue,numberOfLines:1,children:i}):null,o?a(A,{style:m.rowAction,children:o}):null,r?a(Dr,{size:18,color:h.color.accent}):null,l?a(Br,{size:16,color:h.color.textTertiary}):null]})}function ii({title:e,value:t,onValueChange:n,testID:i}){return k(v,{style:m.row,children:[a(v,{style:m.rowText,children:a(A,{style:m.rowTitle,children:e})}),a(jr,{value:t,testID:i,accessibilityLabel:e,onValueChange:n})]})}function oi(e,t){let n=null,i=1/0;for(let o of e){let r=Math.abs(Number(o.key)-t);r<i&&(n=o.key,i=r)}return n!==null&&i<=Math.max(.05,Number(n)*.05)?n:null}function at(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var m=re.create({fill:{flex:1},flex:{flex:1},content:{paddingHorizontal:h.gutter,paddingTop:8,gap:h.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},status:{padding:h.cardPad+2,gap:6},statusTitle:{color:h.color.text,fontSize:28,fontWeight:"600"},titleSimulated:{color:h.color.accent},titleBroken:{color:Jr},statusLine:{color:h.color.textSecondary,fontSize:h.font.row,fontVariant:["tabular-nums"]},coordinates:{color:h.color.textTertiary,fontSize:h.font.caption,fontFamily:Hr},statusButtons:{flexDirection:"row",alignItems:"center",gap:10,marginTop:10},round:{width:44,height:44,borderRadius:22,alignItems:"center",justifyContent:"center",backgroundColor:h.color.accent},progressTrack:{height:6,borderRadius:3,marginTop:8,backgroundColor:h.color.fillSecondary,overflow:"hidden"},progressFill:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:h.color.accent},progressGap:{position:"absolute",top:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.28)"},permission:{borderTopWidth:re.hairlineWidth,borderTopColor:h.color.separator,paddingHorizontal:h.rowPadH,paddingVertical:12,gap:4},rowBetween:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},valueWarning:{color:h.color.warning},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:48,paddingHorizontal:h.rowPadH,paddingVertical:10},rowText:{flex:1,gap:2},rowTitle:{color:h.color.text,fontSize:h.font.row},titleTint:{color:h.color.accent},rowValue:{color:h.color.textSecondary,fontSize:h.font.row,maxWidth:"50%"},rowAction:{color:h.color.accent,fontSize:h.font.row,fontWeight:"500"},detail:{color:h.color.textTertiary,fontSize:h.font.caption},note:{color:h.color.textSecondary,fontSize:h.font.caption,marginTop:2},noteOk:{color:h.color.accent},noteBad:{color:h.color.danger},warning:{color:h.color.warning,fontSize:h.font.caption},separatorTop:{borderTopWidth:re.hairlineWidth,borderTopColor:h.color.separator},segmentWrap:{flexDirection:"row",padding:10},editor:{paddingHorizontal:h.rowPadH,paddingVertical:14,gap:8},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:h.color.text,fontSize:h.font.body,backgroundColor:h.color.bg,borderRadius:h.radius.input,borderWidth:1,borderColor:h.color.border,paddingHorizontal:12,paddingVertical:9},backRow:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},backLabel:{color:h.color.accent,fontSize:h.font.row},backTitle:{flex:1,color:h.color.text,fontSize:h.font.row,fontWeight:"600",textAlign:"center",marginRight:70},logRow:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingHorizontal:h.rowPadH,paddingVertical:10},logDot:{width:8,height:8,borderRadius:4,marginTop:6,backgroundColor:h.color.textTertiary},dotEnter:{backgroundColor:h.color.accent},dotExit:{backgroundColor:h.color.warning},dotError:{backgroundColor:h.color.danger},dotTask:{backgroundColor:h.color.info},logText:{color:h.color.text,fontSize:h.font.body},logDetail:{color:h.color.textTertiary,fontSize:h.font.caption,marginTop:2},logWhen:{color:h.color.textTertiary,fontSize:h.font.caption,fontVariant:["tabular-nums"],marginTop:1}});import{jsx as ri}from"react/jsx-runtime";var Sa=Rt.actions;async function Aa(e,t){let n=Sa[e];if(!n)throw new Error(`Unknown location action: ${e}`);return n(t)}var Ot=()=>Rt.getSnapshot(),Ca=2e3;function ai(){let[e,t]=Ir(Ot);return Cr(()=>{Lt(),St(),t(Ot()),Hn(true),Qe();let n=setInterval(Qe,Ca),i=Be(()=>t(Ot()));return()=>{clearInterval(n),i(),Hn(false)}},[]),ri(Lr,{featureName:"Location",children:ri(ni,{snapshot:e,onAction:Aa})})}import{jsx as Ia}from"react/jsx-runtime";var li=Ar({id:"location",name:"LOCATION",description:"Pin the app anywhere, play routes, trigger geofences",slot:"both",color:Tr,icon:({size:e,color:t})=>Ia(xr,{size:e,color:t}),component:ai,modal:{subtitle:"simulate where the app is"}}),La=Sr(li);import{LocationToolIcon as $a,LOCATION_TOOL_ICON_COLOR as Ma}from"@buoy-gg/shared-ui/web";var Pa=typeof navigator<"u"&&navigator.product==="ReactNative";Pa&&(kr(),typeof Ft<"u"&&Ft&&(Lt(),St()));export{it as BUILT_IN_PLACES,nt as LOCATION_CHIP_ID,Ma as LOCATION_TOOL_ICON_COLOR,ai as LocationBody,Un as LocationChip,$a as LocationToolIcon,ni as LocationToolView,$e as ROUTE_PRESETS,qe as bearingDegrees,St as bootLocation,Vn as buildPresetRoute,La as createLocationTool,Re as destination,U as distanceMeters,P as getLocationSnapshot,Lt as installLocationAdapters,N as isLocationActive,Rt as locationSyncAdapter,li as locationToolPreset,xt as moveToRegion,dt as parseCoordinate,wt as pauseRoute,Qe as refreshLocationPermission,Bi as registerLocationPlaces,ji as registerLocationRoutes,Tt as resetLocation,kt as resumeRoute,fn as seekRoute,bn as setConditions,tt as setPlace,gn as setRouteSpeed,yn as setServices,mn as setSignal,pn as startRoute,vn as stopRoute,Be as subscribeLocation,hn as tuneOverride,wn as useRealLocation};
|
|
3
|
+
\u2192 Caused by: ${t}`}var _n={denied:{ios:{code:"ERR_DENIED_FOREGROUND_LOCATION_PERMISSION",reason:"Location permission is required to do this operation"},android:{code:"ERR_LOCATION_UNAUTHORIZED",reason:"Not authorized to use location services"}},deniedBackground:{ios:{code:"ERR_DENIED_BACKGROUND_LOCATION_PERMISSION",reason:"Background location permission is required to do this operation"},android:{code:"ERR_LOCATION_BACKGROUND_UNAUTHORIZED",reason:"Not authorized to use background location services"}},services:{ios:{code:"ERR_LOCATION_SERVICES_DISABLED",reason:"Location services are disabled"},android:{code:"ERR_LOCATION_SETTINGS_UNSATISFIED",reason:"Location request failed due to unsatisfied device settings"}},unavailable:{ios:{code:"ERR_LOCATION_UNAVAILABLE",reason:"Cannot obtain current location"},android:{code:"ERR_CURRENT_LOCATION_IS_UNAVAILABLE",reason:"Current location is unavailable. Make sure that location services are enabled"}}};function ce(e,t,n){let i=n==="android"?_n[e].android:_n[e].ios;return Promise.reject(lo(i.code,yr(t,i.reason,n)))}var zn=false;function br(){let e=Fn("ExpoLocation");if(!e||typeof e.getCurrentPositionAsync!="function")return false;let t=e,n=Fn("ExpoTaskManager"),i=mr(),o=new Map,r={},a=()=>Date.now(),u=c=>s=>t.emit?.("Expo.locationChanged",{watchId:c,location:Dt(s,i,a())}),p=c=>s=>{let d=s.heading??0;t.emit?.("Expo.headingChanged",{watchId:c,heading:{trueHeading:d,magHeading:d,accuracy:3}})},g=c=>s=>t.emit?.("Expo.locationError",{watchId:c,reason:s});async function h(){let c=t.getForegroundPermissionsAsync,s={granted:true,status:"granted",precision:"full",reported:false};if(typeof c!="function")return s;try{let d=await c.call(t),w=d?.ios?.accuracy==="reduced"||d?.android?.accuracy==="coarse"?"reduced":"full";Gi(w);let x=d?.granted===true,ie=x?"granted":d?.status==="undetermined"?"undetermined":"denied";return{granted:x,status:ie,precision:w,reported:true}}catch{return s}}async function C(){let c=t.getBackgroundPermissionsAsync;if(typeof c!="function")return null;try{return(await c.call(t))?.granted===true}catch{return null}}async function I(){let c=t.getBackgroundPermissionsAsync;if(typeof c!="function")return true;try{return(await c.call(t))?.granted===true}catch{return true}}function T(c,s){at({library:E,id:c,kind:s.kind,options:s.options,deliver:s.kind==="position"?u(c):p(c),fail:g(c)})}r.getCurrentPositionAsync=P(t,"getCurrentPositionAsync",c=>async(...s)=>{if(!$())return c(...s);let d="getCurrentPositionAsync";if(!be())return S("request",E,"getCurrentPositionAsync \u2192 services off"),ce("services",d,i);if(!(await h()).granted)return S("request",E,"getCurrentPositionAsync \u2192 permission denied"),ce("denied",d,i);let{fix:w}=re();return w?(S("request",E,`getCurrentPositionAsync \u2192 ${w.latitude.toFixed(5)}, ${w.longitude.toFixed(5)}`),Dt(w,i,a())):(S("request",E,"getCurrentPositionAsync \u2192 no signal"),await new Promise(x=>z(()=>x(null),1e3)),ce("unavailable",d,i))}),r.getLastKnownPositionAsync=P(t,"getLastKnownPositionAsync",c=>async(...s)=>{if(!$())return c(...s);if(!(await h()).granted)return ce("denied","getLastKnownPositionAsync",i);let{fix:d}=re();return S("request",E,`getLastKnownPositionAsync \u2192 ${d?"simulated":"null"}`),d?Dt(d,i,a()):null}),r.watchPositionImplAsync=P(t,"watchPositionImplAsync",c=>async(...s)=>{let d=Number(s[0]),w=s[1]&&typeof s[1]=="object"?s[1]:{};if(!$()){let ie=await c(...s),ue={kind:"position",options:w,native:true};return o.set(d,ue),$()&&Ce(d,ue),ie}if(!(await h()).granted)return ce("denied","watchPositionImplAsync",i);if(!$())return o.set(d,{kind:"position",options:w,native:true}),c(...s);let x={kind:"position",options:w,native:false};o.set(d,x),T(d,x)}),r.watchDeviceHeading=P(t,"watchDeviceHeading",c=>async(...s)=>{let d=Number(s[0]);if(!$()){let x=await c(...s),ie={kind:"heading",options:{},native:true};return o.set(d,ie),$()&&Ce(d,ie),x}if(!(await h()).granted)return ce("denied","watchDeviceHeading",i);if(!$())return o.set(d,{kind:"heading",options:{},native:true}),c(...s);let w={kind:"heading",options:{},native:false};o.set(d,w),T(d,w)}),r.removeWatchAsync=P(t,"removeWatchAsync",c=>async(...s)=>{let d=Number(s[0]),w=o.get(d);if(o.delete(d),ae(E,"position",d),ae(E,"heading",d),!w||w.native)return c(...s)}),P(t,"hasServicesEnabledAsync",c=>async(...s)=>$()&&!be()?false:c(...s)),P(t,"getProviderStatusAsync",c=>async(...s)=>{let d=await c(...s);if(!$()||be())return d;let w={...d,locationServicesEnabled:false};for(let x of["gpsAvailable","networkAvailable","passiveAvailable"])x in w&&(w[x]=false);return w});let F=(c,s)=>P(t,s,d=>async(...w)=>{let x=String(w[0]),ie=w[1]&&typeof w[1]=="object"?w[1]:{},ue={name:x,kind:c,library:E,options:ie};if(!$()){let ht=await d(...w);return Tt(ue,false),$()&&b(true),ht}if(c==="locationUpdates"&&!be())return ce("services",s,i);if(!(await h()).granted)return ce("denied",s,i);if(c==="geofencing"&&!await I())return ce("deniedBackground",s,i);Tt(ue,true)});r.startLocationUpdatesAsync=F("locationUpdates","startLocationUpdatesAsync"),r.startGeofencingAsync=F("geofencing","startGeofencingAsync");let _=(c,s)=>P(t,s,d=>async(...w)=>{let x=Re(String(w[0]));if(!(x&&x.kind===c&&(At(x.name),x.intercepted)))return d(...w)});r.stopLocationUpdatesAsync=_("locationUpdates","stopLocationUpdatesAsync"),r.stopGeofencingAsync=_("geofencing","stopGeofencingAsync");let ge=(c,s)=>P(t,s,d=>async(...w)=>{let x=Re(String(w[0]));return x&&x.kind===c?true:d(...w)});ge("locationUpdates","hasStartedLocationUpdatesAsync"),ge("geofencing","hasStartedGeofencingAsync");let he=new Map,gt=0,Ye={geofencing:"geofencing",locationUpdates:"location"};n&&(P(n,"notifyTaskFinishedAsync",c=>async(...s)=>{let d=s[1]??{},w=d.eventId?he.get(d.eventId):void 0;if(w&&d.eventId){he.delete(d.eventId),w(d.result);return}return c(...s)}),P(n,"isTaskRegisteredAsync",c=>async(...s)=>Re(String(s[0]))?.intercepted?true:c(...s)),P(n,"getTaskOptionsAsync",c=>async(...s)=>{let d=Re(String(s[0]));return d?.intercepted?d.options:c(...s)}),P(n,"getRegisteredTasksAsync",c=>async(...s)=>{let d=await c(...s)??[],w=St().filter(x=>x.intercepted).map(x=>({taskName:x.name,taskType:Ye[x.kind],options:x.options}));return[...d,...w]}),P(n,"unregisterTaskAsync",c=>async(...s)=>{let d=Re(String(s[0]));if(!(d&&(At(d.name),d.intercepted)))return c(...s)}),P(n,"unregisterAllTasksAsync",c=>async(...s)=>{for(let d of St())At(d.name);return c(...s)}));function Be(){if(!n)return null;if(n.__expo_module_name__&&typeof n.emit=="function")return(s,d)=>n.emit(s,d);let c=En;return c?(s,d)=>c.emit(s,d):null}async function me(c){for(let s=0;s<5e3&&hr(c)===false;s+=100)await new Promise(d=>z(()=>d(null),100))}async function Xe(c,s){await me(c.name);let d=Be();if(!d)return Promise.reject(new Error("expo-task-manager is not installed"));let w=`buoy-location-${++gt}`,x=typeof n?.EVENT_NAME=="string"?n.EVENT_NAME:"TaskManager.executeTask";return new Promise((ie,ue)=>{he.set(w,ie),z(()=>{he.delete(w)&&ue(new Error("did not finish within 30 s"))},3e4);try{d(x,{data:s,error:null,executionInfo:{eventId:w,taskName:c.name,appState:"active"}})}catch(ht){he.delete(w),ue(ht)}})}function Ce(c,s){s.native&&(s.native=false,Promise.resolve(r.removeWatchAsync?.(c)).catch(()=>{}),T(c,s))}function b(c){for(let[s,d]of Array.from(o.entries()))if(c&&d.native)Ce(s,d);else if(!c&&!d.native){ae(E,d.kind,s);let w=d.kind==="position"?r.watchPositionImplAsync:r.watchDeviceHeading;d.native=true,Promise.resolve(d.kind==="position"?w?.(s,d.options):w?.(s)).catch(x=>{d.native=false,g(s)(String(x?.message??x))})}else c&&!d.native&&!Qi(E,d.kind,s)&&T(s,d);for(let s of St()){if(s.library!==E)continue;let d=s.kind==="geofencing";if(c&&!s.intercepted){let w=d?r.stopGeofencingAsync:r.stopLocationUpdatesAsync;Promise.resolve(w?.(s.name)).catch(()=>{}),wn(s.name,true)}else if(!c&&s.intercepted){let w=d?r.startGeofencingAsync:r.startLocationUpdatesAsync;wn(s.name,false),Promise.resolve(w?.(s.name,s.options)).catch(x=>{S("error",E,`Could not restart ${s.name} natively: ${String(x?.message??x)}`)})}}}return rt({library:E,fireTask:Xe,onActiveChange:b,readPermission:async()=>{let c=await h();if(!c.reported)return null;let s=c.status==="granted"?await C():false;return{status:c.status,background:s,precision:c.precision}}}),zn||(zn=true,n&&typeof n.getRegisteredTasksAsync=="function"&&Promise.resolve(n.getRegisteredTasksAsync.call(n)).then(c=>{for(let s of c??[]){if(!s?.taskName||Re(s.taskName))continue;let d=s.taskType==="geofencing"?"geofencing":s.taskType==="location"?"locationUpdates":null;d&&(Tt({name:s.taskName,kind:d,library:E,options:s.options??{}},false),$()&&b(true))}}).catch(()=>{})),true}import{callCapacitorAsApp as vr,callCapacitorNative as Wn,callCapacitorNativeCallback as wr,capacitorPlatform as kr,hasCapacitorPlugin as xr,installCapacitorBridge as Cr,interceptCapacitor as Ot,makeCapacitorCallbackId as Ir}from"@buoy-gg/license/web";var ve="@capacitor/geolocation",pe="Geolocation";function Un(e,t){return{timestamp:t,coords:{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy,altitude:e.altitude,altitudeAccuracy:e.altitudeAccuracy,speed:e.speed,heading:e.heading}}}function Bt(e){return new Error(e)}function Tr(e){if(!e||typeof e!="object")return null;let t=e.location,n=e.coarseLocation??t;return{status:t==="granted"||n==="granted"?"granted":t==="denied"&&(n==="denied"||n===void 0)?"denied":"undetermined",background:null,precision:t!=="granted"&&n==="granted"?"reduced":"full"}}function Hn(e,t){return(n,i)=>{e.gen===t&&e.nativeId!==null&&e.callback(n,i)}}var Ve=new Map,Vn=false;function qn(e){at({library:ve,id:e.id,kind:"position",options:e.options,deliver:t=>e.callback(Un(t,Date.now())),fail:t=>e.callback(null,Bt(t))})}function Ar(e){let t=++e.gen;e.nativeId=wr(pe,"watchPosition",e.options,Hn(e,t))}function Sr(e){if(e.gen++,e.nativeId===null)return;let t=e.nativeId;e.nativeId=null,Wn(pe,"clearWatch",{id:t}).catch(()=>{})}function Pr(){return Vn?true:!kr()||!xr(pe)||!Cr()?false:(Vn=true,Ot({plugin:pe,methods:["getCurrentPosition"],promise:(e,t)=>{if(!$())return t();if(!be())return S("request",ve,"getCurrentPosition \u2192 services off"),Promise.reject(Bt("Location services are not enabled"));let{fix:n}=re();return n?(S("request",ve,`getCurrentPosition \u2192 ${n.latitude.toFixed(5)}, ${n.longitude.toFixed(5)}`),Un(n,Date.now())):(S("request",ve,"getCurrentPosition \u2192 no signal"),new Promise((i,o)=>z(()=>o(Bt("Timeout")),1e3)))}}),Ot({plugin:pe,methods:["watchPosition"],callback:(e,t,n)=>{if(!$()){let o={id:"",options:e.options,callback:t,nativeId:null,gen:1},r=n(Hn(o,1));return r===null?null:(o.id=r,o.nativeId=r,Ve.set(r,o),r)}let i={id:Ir(),options:e.options,callback:t,nativeId:null,gen:1};return Ve.set(i.id,i),qn(i),i.id}}),Ot({plugin:pe,methods:["clearWatch"],promise:(e,t)=>{let n=String(e.options.id??""),i=Ve.get(n);if(!i)return t();if(Ve.delete(n),i.gen++,ae(ve,"position",n),i.nativeId===null)return;let o=i.nativeId;return i.nativeId=null,o===n?t():Wn(pe,"clearWatch",{id:o})}}),rt({library:ve,onActiveChange(e){for(let t of Ve.values())e&&t.nativeId!==null?(Sr(t),qn(t)):!e&&t.nativeId===null&&(ae(ve,"position",t.id),Ar(t))},async readPermission(){try{return Tr(await vr(pe,"checkPermissions"))}catch{return null}}}),true)}var we="navigator.geolocation",$r={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function jt(e,t){return{code:e,message:t,...$r}}function Gn(e,t){let n={latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed};return{coords:{...n,toJSON:()=>n},timestamp:t,toJSON:()=>({coords:n,timestamp:t})}}function Kn(e,t){let n=()=>e.gen===t&&e.nativeId!==null;return[(...i)=>n()?e.success(...i):void 0,(...i)=>n()?e.error?.(...i):void 0]}var qe=new Map,Lr=1e6,Jn=false;function Mr(){if(Jn)return true;let e=globalThis.navigator?.geolocation;if(!e||typeof e.getCurrentPosition!="function")return false;Jn=true;let t=null,n=null,i=o=>at({library:we,id:o.id,kind:"position",options:o.options,deliver:r=>o.success(Gn(r,Date.now())),fail:r=>o.error?.(jt(2,r))});return P(e,"getCurrentPosition",o=>(...r)=>{if(!$())return o(...r);let a=r[0],u=r[1];if(!be()){S("request",we,"getCurrentPosition \u2192 services off"),z(()=>u?.(jt(2,"Location services are disabled")),0);return}let{fix:p}=re();if(!p){S("request",we,"getCurrentPosition \u2192 no signal"),z(()=>u?.(jt(3,"Timeout expired")),1e3);return}S("request",we,`getCurrentPosition \u2192 ${p.latitude.toFixed(5)}, ${p.longitude.toFixed(5)}`),z(()=>a?.(Gn(p,Date.now())),0)}),t=P(e,"watchPosition",o=>(...r)=>{let a=r[0],u=r[1],p=r[2]&&typeof r[2]=="object"?r[2]:{};if(!$()){let h={id:0,success:a,error:u,options:p,nativeId:null,gen:1},[C,I]=Kn(h,1),T=o(C,I,r[2]);return h.id=T,h.nativeId=T,qe.set(T,h),T}let g={id:Lr++,success:a,error:u,options:p,nativeId:null,gen:1};return qe.set(g.id,g),i(g),g.id}),n=P(e,"clearWatch",o=>(...r)=>{let a=r[0],u=qe.get(a);if(!u)return o(...r);if(qe.delete(a),u.gen++,ae(we,"position",a),u.nativeId!==null)return o(u.nativeId)}),rt({library:we,onActiveChange(o){for(let r of qe.values())if(o&&r.nativeId!==null)r.gen++,n?.(r.nativeId),r.nativeId=null,i(r);else if(!o&&r.nativeId===null){ae(we,"position",r.id);let a=++r.gen,[u,p]=Kn(r,a);r.nativeId=t?.(u,p,r.options)??null}}}),true}var ke=null;function Ft(){return ke||(ke=[],br()&&ke.push("expo-location"),ke.push(...fr()),Pr()&&ke.push("@capacitor/geolocation"),Mr()&&ke.push("navigator.geolocation"),ke)}import{useSyncExternalStore as Rr}from"react";import{FloatingTool as Nr,LocationToolIcon as Yn,Pause as Er,Play as Dr,RefreshCw as Or,X as Br,dismissFloatingTool as jr,getFloatingTools as Fr,night as fe,openFloatingTool as _r}from"@buoy-gg/shared-ui/web";var zr=new Set(["US","GB","LR","MM"]),Xn=null;function Wr(){try{let e=Intl.DateTimeFormat().resolvedOptions().locale,t=/[-_]([A-Z]{2})\b/.exec(e);return t?t[1]:null}catch{return null}}var _t=null;function Ee(){return Xn!==null?Xn:(_t===null&&(_t=zr.has(Wr()??"")),_t)}var Zn=3.28084,Qn=1609.344;function K(e){if(!Number.isFinite(e))return"\u2013";let t=Math.abs(e);if(Ee()){let n=t/Qn;return n<.1?`${Math.round(t*Zn/10)*10} ft`:`${ei(n)} mi`}return t<1e3?`${Math.round(t)} m`:`${ei(t/1e3)} km`}function ei(e){let t=Math.round(e*10)/10;return t<10?t.toFixed(1):Math.round(e).toLocaleString("en-US")}function ti(e){return Number.isFinite(e)?e>=1e3?`\xB1${K(e)}`:Ee()?`\xB1${Math.round(e*Zn)} ft`:`\xB1${Math.round(e)} m`:"\u2013"}function zt(e){if(e==null||e<0)return"\u2013";let t=Ee()?e*3600/Qn:e*3.6,n=Ee()?"mph":"km/h";return`${t<10?t.toFixed(1):Math.round(t)} ${n}`}function Ur(e){if(!Number.isFinite(e)||e<0)return"\u2013";let t=Math.round(e/6e4);if(t<1)return`${Math.max(1,Math.round(e/1e3))} sec`;if(t<60)return`${t} min`;let n=Math.floor(t/60),i=t%60;return i?`${n} hr ${i} min`:`${n} hr`}function Hr(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"now";if(n<60)return`${n}s ago`;try{return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{let i=new Date(e);return`${i.getHours()}:${String(i.getMinutes()).padStart(2,"0")}`}}function ni(e){return e.override.services?e.override.signal?e.override.mode==="real"?"Real Location":e.override.mode==="route"?e.override.route?.name??"Route":e.override.place.label||"Dropped Pin":"No GPS Signal":"Location Services Off"}function Vr(e){return!e.override.services||!e.override.signal?"broken":e.override.mode==="real"?"real":"simulated"}function qr(e){if(!e.override.services)return"The app is told location services are off";if(!e.override.signal)return"Updates stop and location requests fail";if(e.override.mode==="real")return"The app gets the device's location";let t=[];if(e.override.mode==="route"&&e.progress){let i=e.progress;i.finished?t.push("Arrived"):e.override.playing||t.push("Paused"),e.current.reason==="gap"&&t.push("no signal here"),i.finished||(t.push(`${K(i.along)} of ${K(i.length)}`),i.etaMs!=null?t.push(`${Ur(i.etaMs)} left`):e.override.route?.loop&&t.push("on repeat"))}else t.push("Pinned");let n=e.current.fix;return n&&e.override.mode==="fixed"&&t.push(ti(n.accuracy)),e.current.precision==="reduced"&&t.push("approximate"),t.join(" \xB7 ")}function Gr(e){return e.status==="denied"?"Not Allowed":e.status==="undetermined"?"Not Asked Yet":`${e.background?"Always":"While Using"} \xB7 ${e.precision==="reduced"?"Approximate":"Precise"}`}function Kr(e){if(!e.override.services)return"The app is told location is off";if(!e.override.signal)return"Updates stop, requests fail";if(e.override.mode==="route"&&e.progress){if(e.progress.finished)return"Arrived";let n=`${K(e.progress.along)} of ${K(e.progress.length)}`;return e.override.playing?n:`Paused \xB7 ${n}`}let t=e.current.fix;return t?`Pinned \xB7 ${Fe(t,3)}`:"Pinned"}import{jsx as H,jsxs as ii}from"react/jsx-runtime";var ct="location-chip",Jr={id:ct,render:e=>H(li,{...e})},Yr=()=>Fr().some(e=>e.id===ct),oi=false,Wt=false,ri=null;function ai(e){Wt!==e&&(Wt=e,ri?.())}function Xr(){if(oi)return;oi=true;let e=false,t=()=>{let n=R().active&&oo().showChip&&!Wt;n&&!e?_r(Jr):!n&&Yr()&&jr(ct),e=n};ri=t,Ue(t),t()}function li({id:e,revealToken:t}){let n=Rr(Ue,R,R),i=ni(n),o=n.override.mode==="route"&&n.progress,r=n.override.playing,a=!!o&&o.finished;return H(Nr,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the location chip. ${i}`,handleAdornment:H(Yn,{size:12}),children:ii(v,{style:xe.row,children:[H(Yn,{size:18}),ii(v,{style:xe.text,children:[H(A,{style:xe.title,numberOfLines:1,testID:"location-chip-title",children:i}),H(A,{style:xe.detail,numberOfLines:1,testID:"location-chip-detail",children:Kr(n)})]}),o?H(se,{testID:"location-chip-playpause",accessibilityRole:"button",accessibilityLabel:r?"Pause the route":a?"Play the route again":"Resume the route",onPress:()=>r?Pt():$t(),style:xe.pill,hitSlop:{top:8,bottom:8,left:4,right:4},children:r?H(Er,{size:14,color:fe.color.accent}):a?H(Or,{size:14,color:fe.color.accent}):H(Dr,{size:14,color:fe.color.accent})}):null,H(v,{style:xe.separator}),H(se,{testID:"location-chip-reset",accessibilityRole:"button",accessibilityLabel:"Back to the real location",onPress:()=>Mt(),style:xe.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:H(Br,{size:16,color:fe.color.textSecondary})})]})})}var xe=le.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingLeft:10,paddingRight:4,paddingVertical:6,minWidth:230,maxWidth:340},text:{flexShrink:1,minWidth:120},title:{color:fe.color.text,fontSize:14,fontWeight:"600"},detail:{color:fe.color.textSecondary,fontSize:11,fontVariant:["tabular-nums"]},pill:{width:30,height:30,borderRadius:15,alignItems:"center",justifyContent:"center",backgroundColor:fe.color.accentFill},button:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},separator:{width:le.hairlineWidth,height:20,backgroundColor:fe.color.separator}});import{LocationToolIcon as Zr,LOCATION_TOOL_ICON_COLOR as Qr,createToolFactory as ea,defineToolPreset as ta}from"@buoy-gg/shared-ui/web";import{useEffect as na,useState as ia}from"react";import{FeatureGate as oa}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as ra}from"@buoy-gg/shared-ui/web";var ut=[{latitude:37.3349,longitude:-122.009,label:"Apple Park"},{latitude:37.422,longitude:-122.0841,label:"Googleplex"},{latitude:40.758,longitude:-73.9855,label:"Times Square"},{latitude:51.508,longitude:-.1281,label:"Trafalgar Square"},{latitude:48.8584,longitude:2.2945,label:"Eiffel Tower"},{latitude:35.6595,longitude:139.7005,label:"Shibuya Crossing"},{latitude:-33.8568,longitude:151.2153,label:"Sydney Opera House"},{latitude:-23.5614,longitude:-46.6559,label:"S\xE3o Paulo"},{latitude:0,longitude:0,label:"Null Island"}],De=[{id:"walk",name:"Walk",description:"1 km north from here at walking pace",speed:1.4},{id:"run",name:"Run",description:"3 km north, then east, at running pace",speed:3.3},{id:"drive",name:"City Drive",description:"4 km of city streets with turns",speed:13.4},{id:"highway",name:"Highway",description:"30 km north at highway speed",speed:30},{id:"tunnel",name:"Tunnel",description:"3 km drive with no signal for 600 m in the middle",speed:13.4},{id:"loop",name:"Block Loop",description:"A 400 m block, walked on repeat",speed:1.4}];function si(e,t,n=0){let i=De.find(g=>g.id===e);if(!i)throw new Error(`Unknown route preset "${e}". Use one of: ${De.map(g=>g.id).join(", ")}.`);let o={latitude:t.latitude,longitude:t.longitude},r=(g,h,C)=>je(g,n+h,C),a,u,p=false;switch(e){case"walk":a=[o,r(o,0,1e3)];break;case"run":a=[o,r(o,0,1500),r(r(o,0,1500),90,1500)];break;case"drive":{let g=r(o,0,1200),h=r(g,90,800),C=r(h,0,1e3),I=r(C,-90,1e3);a=[o,g,h,C,I];break}case"highway":a=[o,r(o,0,3e4)];break;case"tunnel":a=[o,r(o,0,3e3)],u=[[1200,1800]];break;case"loop":{let g=r(o,0,100),h=r(g,90,100),C=r(h,180,100);a=[o,g,h,C,o],p=true;break}}return{id:`preset:${e}`,name:i.name,points:a,speed:i.speed,loop:p,gaps:u}}function aa(e,t,n){return{id:"line",name:t.label?`To ${t.label}`:"Straight line",points:[{latitude:e.latitude,longitude:e.longitude},{latitude:t.latitude,longitude:t.longitude}],speed:n}}function Q(e){return e&&typeof e=="object"?e:{}}function Ge(e,...t){for(let n of t){let i=e[n];if(typeof i=="boolean")return i;if(i==="true"||i==="on")return true;if(i==="false"||i==="off")return false}}function J(e,...t){for(let n of t){let i=e[n];if(i==null||i==="")continue;let o=Number(i);if(Number.isFinite(o))return o}}function L(){return{...R(),builtInPlaces:ut,presets:De}}function la(e){let t=e.trim().toLowerCase(),n=[...R().places,...ut];return n.find(i=>i.label?.toLowerCase()===t)??n.find(i=>i.label?.toLowerCase().includes(t))??null}function ci(e){let t=typeof e.label=="string"?e.label:void 0,n=J(e,"latitude","lat"),i=J(e,"longitude","lon","lng");if(n!==void 0&&i!==void 0){let o={latitude:n,longitude:i};if(!Ie(o))throw new Error("latitude must be within \xB190 and longitude within \xB1180.");return{...o,label:t}}for(let o of["place","to","query","coordinate","at"]){let r=e[o];if(Ie(r))return{...r,label:r.label??t};if(typeof r=="string"&&r.trim()){let a=bt(r);if(a)return{...a,label:t};let u=la(r);if(u)return u;throw new Error(`No place called "${r}". Give latitude and longitude, or one of: ${sa()}.`)}}return null}function sa(){return[...R().places,...ut].map(e=>e.label).filter(Boolean).join(", ")}function ca(e){let t=J(e,"speed","metersPerSecond"),n=J(e,"heading","bearing")??0;if(Array.isArray(e.points))return{points:e.points,speed:t??1.4,loop:Ge(e,"loop")??false,name:typeof e.name=="string"?e.name:"Custom route",gaps:Array.isArray(e.gaps)?e.gaps:void 0};let i=typeof e.route=="string"?e.route:typeof e.routeId=="string"?e.routeId:typeof e.preset=="string"?e.preset:void 0;if(i){let r=R().routes.find(p=>p.id===i||p.name?.toLowerCase()===i.toLowerCase());if(r)return t?{...r,speed:t}:r;let a=De.find(p=>p.id===i||p.name.toLowerCase()===i.toLowerCase());if(a){let p=si(a.id,He(),n);return t?{...p,speed:t}:p}let u=[...R().routes.map(p=>p.id??p.name),...De.map(p=>p.id)];throw new Error(`No route "${i}". Use one of: ${u.join(", ")}; or pass points.`)}let o=ci(e);if(o)return aa(He(),o,t??1.4);throw new Error("startRoute needs `points` (two or more {latitude, longitude}), `route` (a preset or app route id), or `to` (a place).")}var Ut=ra({version:1,getSnapshot(){return L()},subscribe(e){return Ue(e)},actions:{getState(){return L()},setLocation(e){let t=ci(Q(e));if(!t)throw new Error('setLocation needs `latitude` and `longitude`, `query` ("lat, lon" or a map link), or `place` (a place name).');return st(t),L()},startRoute(e){return kn(ca(Q(e))),L()},stopRoute(){return Pn(),L()},setConditions(e){let t=Q(e),n=(typeof t.conditions=="string"?t.conditions:typeof t.preset=="string"?t.preset:"").trim().toLowerCase().replace(/[\s_]+/g,"-"),i={good:"good",weak:"weak","no-signal":"no-signal",nosignal:"no-signal",off:"off","services-off":"off","location-off":"off"}[n];if(!i)throw new Error("setConditions needs `conditions`: good, weak, no-signal or off.");return Sn(i),L()},pauseRoute(){return Pt(),L()},resumeRoute(){return $t(),L()},seekRoute(e){let t=Q(e),n=J(t,"meters","along"),i=J(t,"fraction","progress"),o=R().progress?.length??0;if(n===void 0&&i===void 0)throw new Error("seekRoute needs `meters` or `fraction` (0 to 1).");return xn(n??(i??0)*o),L()},setSpeed(e){let t=J(Q(e),"speed","metersPerSecond");if(t===void 0)throw new Error("setSpeed needs `speed` in meters per second.");return Cn(t),L()},tune(e){let t=Q(e);return In({accuracy:J(t,"accuracy"),jitter:J(t,"jitter","drift"),altitude:t.altitude===null?null:J(t,"altitude"),heading:t.heading===null?null:J(t,"heading"),interval:J(t,"interval","intervalMs")}),L()},setSignal(e){let t=Ge(Q(e),"on","signal","enabled");if(t===void 0)throw new Error("setSignal needs `on`: true or false.");return Tn(t),L()},setServices(e){let t=Ge(Q(e),"on","services","enabled");if(t===void 0)throw new Error("setServices needs `on`: true or false.");return An(t),L()},enterRegion(e){let t=Q(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("enterRegion needs `identifier` (a monitored geofence region).");return Lt(n,"inside",typeof t.task=="string"?t.task:void 0),L()},exitRegion(e){let t=Q(e),n=typeof t.identifier=="string"?t.identifier:typeof t.region=="string"?t.region:void 0;if(!n)throw new Error("exitRegion needs `identifier` (a monitored geofence region).");return Lt(n,"outside",typeof t.task=="string"?t.task:void 0),L()},useRealLocation(){return $n(),L()},reset(){return Mt(),L()},updateSettings(e){let t=Q(e);return io({persist:Ge(t,"persist"),showChip:Ge(t,"showChip")}),L()},clearLog(){return ro(),L()}}});import{useEffect as ua,useState as Oe}from"react";import{Check as da,ChevronLeft as pa,ChevronRight as fa,NightButton as ui,NightCard as N,NightFootnote as ee,NightRows as te,NightSectionLabel as Y,NightSegmented as Ht,NightSwitch as ga,Pause as ha,Play as ma,RefreshCw as ya,copyToClipboard as ba,monoFont as va,night as m,realNow as Vt,useSafeAreaInsets as wa,useToolScreenHeader as ka}from"@buoy-gg/shared-ui/web";import{night as ne}from"@buoy-gg/shared-ui/web";import{jsx as X,jsxs as dt}from"react/jsx-runtime";var di="#F87171",Ke=1.8,xa=6e4,Ca=400;function Ia({snapshot:e,onPinPlace:t,onCrossRegion:n}){let i=e.position,o=e.override.mode==="route"?e.override.route:null,r=i??e.places[0]??Ta(e.tasks)??null;if(!r)return null;let a=b=>!i||V(i,b)<=xa,u=e.places.filter(a),p=e.tasks.filter(b=>b.kind==="geofencing").flatMap(b=>b.regions.filter(a).map(c=>({task:b,region:c}))),g=e.places.length-u.length,h=Math.cos(r.latitude*Math.PI/180),C=b=>({x:(b.longitude-r.longitude)*111320*h,y:(b.latitude-r.latitude)*110540}),I=[];i&&I.push({...C(i),r:60});for(let b of o?.points??[])I.push({...C(b),r:0});for(let b of u)I.push({...C(b),r:60});for(let b of p)I.push({...C(b.region),r:b.region.radius});let T=1/0,F=-1/0,_=1/0,ge=-1/0;for(let b of I)T=Math.min(T,b.x-b.r),F=Math.max(F,b.x+b.r),_=Math.min(_,b.y-b.r),ge=Math.max(ge,b.y+b.r);let he=(T+F)/2,gt=(_+ge)/2,Ye=Math.max(Ca,(ge-_)*1.35,(F-T)*1.2/Ke),Be=Ye*Ke,me=b=>{let c=C(b);return{x:.5+(c.x-he)/Be,y:.5-(c.y-gt)/Ye}},Xe=Sa(Be),Ce=e.override.mode==="fixed"?e.override.place.label:void 0;return X(v,{children:dt(v,{style:M.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[pi.map(b=>X(v,{style:[M.gridV,{left:B(b)}]},`v${b}`)),pi.map(b=>X(v,{style:[M.gridH,{top:B(b)}]},`h${b}`)),p.map(({task:b,region:c})=>{let s=me(c),d=2*c.radius/Be,w=d*Ke,x=c.state==="inside";return X(se,{testID:`location-map-region-${fi(c.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${x?"Leave":"Enter"} ${c.label??c.identifier}`,activeOpacity:.6,onPress:()=>n(b,c),style:[M.fence,x?M.fenceInside:null,{left:B(s.x-d/2),top:B(s.y-w/2),width:B(d),height:B(w)}]},`${b.name}:${c.identifier}`)}),o?Aa(o.points.map(me)).map((b,c)=>X(v,{pointerEvents:"none",style:[M.segment,{left:B(b.midX-b.length/2),top:B(b.midY),width:B(b.length),transform:[{rotate:`${b.angle}rad`}]}]},`seg${c}`)):null,u.map((b,c)=>{let s=me(b),d=!!Ce&&Ce===b.label;return dt(se,{testID:`location-map-place-${fi(b.label??String(c))}`,accessibilityRole:"button",accessibilityLabel:`Pin ${b.label??"this place"}`,activeOpacity:.6,onPress:()=>t(b),style:[M.placeHit,{left:B(s.x),top:B(s.y)}],children:[X(v,{style:[M.placeDot,d?M.placeDotSelected:null]}),b.label?X(A,{style:M.placeLabel,numberOfLines:1,children:b.label}):null]},`${b.label??c}`)}),i?dt(v,{pointerEvents:"none",style:[M.pinWrap,{left:B(me(i).x),top:B(me(i).y)}],children:[X(v,{style:M.pinHalo}),X(v,{style:[M.pin,e.current.reason==="gap"?M.pinHollow:null]})]}):null,dt(v,{style:M.scale,pointerEvents:"none",children:[X(v,{style:[M.scaleBar,{width:B(Xe.fraction)}]}),X(A,{style:M.scaleLabel,children:Xe.label})]}),g>0?X(A,{style:M.offMap,pointerEvents:"none",children:`${g} more ${g===1?"place":"places"} off the map`}):null]})})}var pi=[.2,.4,.6,.8];function B(e){return`${e*100}%`}function Ta(e){for(let t of e)if(t.regions[0])return t.regions[0];return null}function Aa(e){let t=[];for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n],r=o.x-i.x,a=(o.y-i.y)/Ke;t.push({midX:(i.x+o.x)/2,midY:(i.y+o.y)/2,length:Math.sqrt(r*r+a*a),angle:Math.atan2(a,r)})}return t}function Sa(e){let t=e/4,n=Ee()?1609.344:1e3,i=Ee()?[.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100].map(r=>r*n):[10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4,1e5],o=i[0];for(let r of i)r<=t&&(o=r);return{fraction:o/e,label:K(o)}}function fi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var M=le.create({map:{width:"100%",aspectRatio:Ke,borderRadius:ne.radius.card,borderWidth:1,borderColor:ne.color.border,backgroundColor:ne.color.surface,overflow:"hidden"},gridV:{position:"absolute",top:0,bottom:0,width:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},gridH:{position:"absolute",left:0,right:0,height:le.hairlineWidth,backgroundColor:"rgba(255, 255, 255, 0.04)"},fence:{position:"absolute",borderRadius:9999,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.22)",backgroundColor:"rgba(255, 255, 255, 0.04)",minWidth:10,minHeight:10},fenceInside:{borderColor:ne.color.accentBorderStrong,backgroundColor:ne.color.accentSoft},segment:{position:"absolute",height:3,marginTop:-1.5,borderRadius:1.5,backgroundColor:"rgba(248, 113, 113, 0.45)"},placeHit:{position:"absolute",flexDirection:"row",alignItems:"center",gap:4,height:24,marginTop:-12,marginLeft:-12,paddingLeft:8,paddingRight:4},placeDot:{width:8,height:8,borderRadius:4,backgroundColor:ne.color.textSecondary},placeDotSelected:{backgroundColor:ne.color.text},placeLabel:{color:ne.color.textSecondary,fontSize:10,fontWeight:"500",maxWidth:110},pinWrap:{position:"absolute",width:28,height:28,marginLeft:-14,marginTop:-14,alignItems:"center",justifyContent:"center"},pinHalo:{position:"absolute",width:28,height:28,borderRadius:14,backgroundColor:"rgba(248, 113, 113, 0.22)"},pin:{width:14,height:14,borderRadius:7,backgroundColor:di,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:di},scale:{position:"absolute",left:10,right:10,bottom:8,gap:3},scaleBar:{height:2,borderRadius:1,backgroundColor:ne.color.textTertiary},scaleLabel:{color:ne.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},offMap:{position:"absolute",right:10,bottom:8,color:ne.color.textTertiary,fontSize:10}});import{Fragment as Je,jsx as l,jsxs as k}from"react/jsx-runtime";var gi={places:"Other Location",routes:"Route",speed:"Speed",accuracy:"Accuracy & Drift",activity:"Activity",options:"Options"},Pa="#F87171",hi=[{key:"1.4",label:"Walking"},{key:"3.3",label:"Running"},{key:"5.5",label:"Cycling"},{key:"13.4",label:"City Traffic"},{key:"30",label:"Highway"},{key:"250",label:"Airplane"}],mi=[{key:"good",label:"Good"},{key:"weak",label:"Weak"},{key:"no-signal",label:"No Signal"},{key:"off",label:"Off"}],$a={good:"Precise fixes, like outdoors with a clear sky.",weak:"Fixes are \xB165 m and wander by up to 50 m, like indoors or between tall buildings.","no-signal":"Watches get no updates and location requests fail.",off:"The app is told location services are turned off.",custom:"Custom accuracy and drift."},yi=[{key:"5",label:"5 m"},{key:"20",label:"20 m"},{key:"65",label:"65 m"},{key:"1000",label:"1 km"}],bi=[{key:"0",label:"Off"},{key:"10",label:"10 m"},{key:"50",label:"50 m"},{key:"200",label:"200 m"}],La=4;function qt(e){let[t,n]=Oe(()=>Vt());return ua(()=>{if(!e)return;let i=setInterval(()=>n(Vt()),1e3);return()=>clearInterval(i)},[e]),t}function vi({snapshot:e,onAction:t}){let n=wa({minBottom:16}),[i,o]=Oe(null),[r,a]=Oe("main"),u=()=>a("main"),p=ka(r==="main"?null:{title:gi[r],subtitle:"",onBack:u,searchable:false},[r]),g=(T,F)=>{o(null),t(T,F).catch(_=>{o(_ instanceof Error?_.message:String(_))})};if(!e)return l(v,{style:y.waiting,testID:"location-waiting",children:l(ee,{centered:true,children:"Waiting for the app\u2026"})});let h=i?l(ee,{tone:"danger",centered:true,children:l(A,{testID:"location-error",children:i})}):null,C=(T,F)=>{g(T,F),u()},I;switch(r){case"places":I=l(Oa,{snapshot:e,pick:C});break;case"routes":I=l(_a,{snapshot:e,pick:C});break;case"speed":I=l(Wa,{snapshot:e,pick:C});break;case"accuracy":I=l(Ka,{snapshot:e,run:g});break;case"activity":I=l(Ya,{snapshot:e,run:g});break;case"options":I=l(Za,{snapshot:e,run:g});break;default:I=k(Je,{children:[l(Ma,{snapshot:e,run:g}),h,l(Na,{snapshot:e,run:g}),l(Ea,{snapshot:e,run:g,open:a}),l(ja,{snapshot:e,open:a}),l(Ha,{snapshot:e,run:g}),l(Ga,{snapshot:e,run:g,open:a}),l(Ja,{snapshot:e,open:a})]})}return k(On,{style:y.fill,contentContainerStyle:[y.content,{paddingBottom:n.bottom}],testID:"location-scroll",keyboardShouldPersistTaps:"handled",children:[r!=="main"&&!p?l(Qa,{title:gi[r],onBack:u}):null,r!=="main"?h:null,I]},r)}function Ma({snapshot:e,run:t}){let n=e.override,i=n.mode==="route"?n.route:null,o=e.progress;qt(!!i&&n.playing);let r=Vr(e),a=e.current.fix,u=o&&o.length>0?Math.min(1,o.along/o.length):0,[p,g]=Oe(false);return k(N,{children:[k(v,{style:y.status,children:[l(A,{style:[y.statusTitle,r==="simulated"?y.titleSimulated:r==="broken"?y.titleBroken:null],testID:"location-hero-title",numberOfLines:1,adjustsFontSizeToFit:true,children:ni(e)}),l(A,{style:y.statusLine,testID:"location-hero-status",children:qr(e)}),a&&e.simulating?l(se,{testID:"location-copy-coordinates",accessibilityRole:"button",accessibilityLabel:"Copy coordinates",activeOpacity:.6,onPress:()=>{ba(`${a.latitude}, ${a.longitude}`).then(h=>{h&&(g(true),setTimeout(()=>g(false),1500))})},children:l(A,{style:y.coordinates,children:p?"Copied":Fe(a,5)})}):null,i&&o?k(v,{style:y.progressTrack,testID:"location-route-progress",children:[l(v,{style:[y.progressFill,{width:`${u*100}%`}]}),(i.gaps??[]).map(([h,C],I)=>l(v,{style:[y.progressGap,{left:`${h/o.length*100}%`,width:`${(C-h)/o.length*100}%`}]},I))]}):null,e.active?k(v,{style:y.statusButtons,children:[i&&o?l(Ra,{testID:n.playing?"location-route-pause":"location-route-resume",label:n.playing?"Pause":o.finished?"Play again":"Resume",onPress:()=>t(n.playing?"pauseRoute":"resumeRoute"),children:n.playing?l(ha,{size:18,color:m.color.onAccent}):o.finished?l(ya,{size:18,color:m.color.onAccent}):l(ma,{size:18,color:m.color.onAccent})}):null,l(v,{style:y.flex,children:l(ui,{label:"Use Real Location",size:"md",testID:"location-reset",onPress:()=>t("reset")})})]}):null]}),e.permission?k(v,{style:y.permission,testID:"location-permission",children:[k(v,{style:y.rowBetween,children:[l(A,{style:y.rowTitle,children:"Permission"}),l(A,{style:[y.rowValue,e.permission.status!=="granted"?y.valueWarning:null],testID:"location-permission-value",children:Gr(e.permission)})]}),e.permission.status!=="granted"?l(A,{style:y.detail,children:"The app's location requests fail until it's allowed. Change it in Settings or the Permissions tool."}):null]}):null]})}function Ra({children:e,label:t,onPress:n,testID:i}){return l(se,{testID:i,accessibilityRole:"button",accessibilityLabel:t,activeOpacity:.7,onPress:n,style:y.round,children:e})}function Na({snapshot:e,run:t}){return!!e.position||e.places.length>0||e.tasks.some(n=>n.regions.length>0)?k(v,{children:[l(Ia,{snapshot:e,onPinPlace:n=>t("setLocation",{latitude:n.latitude,longitude:n.longitude,label:n.label}),onCrossRegion:(n,i)=>t(i.state==="inside"?"exitRegion":"enterRegion",{identifier:i.identifier,task:n.name})}),l(ee,{children:"Map views in the app still show the device's own blue dot. Move the simulator's location for those."})]}):null}function Ea({snapshot:e,run:t,open:n}){let i=e.places.length>0?e.places:e.builtInPlaces.slice(0,La),o=e.override.mode==="fixed"?e.override.place:null,r=e.position,a=!!o&&!i.some(u=>pt(u,o));return k(v,{children:[l(Y,{children:"Location"}),l(N,{children:k(te,{children:[i.map((u,p)=>l(j,{title:u.label??Fe(u,4),value:r&&!(o&&pt(u,o))?Da(r,u):void 0,checked:!!o&&pt(u,o),testID:`location-place-${ft(u.label??String(p))}`,onPress:()=>t("setLocation",{latitude:u.latitude,longitude:u.longitude,label:u.label})},`${u.label??p}`)),l(j,{title:"Other Location\u2026",value:a?o.label||Fe(o,3):void 0,chevron:true,testID:"location-other",onPress:()=>n("places")},"other")]})})]})}function Da(e,t){let n=V(e,t);return n<30?"Here":K(n)}function pt(e,t){return e.label&&t.label?e.label===t.label:V(e,t)<1}function Oa({snapshot:e,pick:t}){let[n,i]=Oe(""),o=bt(n),r=e.override.mode==="fixed"?e.override.place:null,a=()=>{o&&(t("setLocation",{query:n}),i(""))};return k(Je,{children:[k(v,{children:[l(Y,{children:"Coordinates"}),l(N,{children:k(v,{style:y.editor,children:[k(v,{style:y.inputRow,children:[l(Dn,{value:n,onChangeText:i,placeholder:"Coordinates or a Maps link",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false,style:y.input,testID:"location-coordinate-input",accessibilityLabel:"Coordinates or a Maps link",returnKeyType:"done",onSubmitEditing:a}),l(ui,{label:"Pin",size:"md",variant:"primary",disabled:!o,testID:"location-coordinate-set",onPress:a})]}),n.length>0?l(A,{style:o?y.detail:y.warning,testID:"location-coordinate-preview",children:o?Ba(o):"Type a latitude and longitude, like 40.7580, -73.9855, or paste a Google or Apple Maps link."}):null]})})]}),k(v,{children:[l(Y,{children:"Places"}),l(N,{children:l(te,{children:e.builtInPlaces.map((u,p)=>l(j,{title:u.label??Fe(u,4),detail:u.label==="Null Island"?"0, 0: catches code that treats 0 as no location":void 0,checked:!!r&&pt(u,r),testID:`location-place-${ft(u.label??String(p))}`,onPress:()=>t("setLocation",{latitude:u.latitude,longitude:u.longitude,label:u.label})},`${u.label??p}`))})}),e.places.length===0?l(ee,{children:"Add your own places, such as your stores, with registerLocationPlaces()."}):null]})]})}function Ba(e){let t=`${Math.abs(e.latitude).toFixed(4)}\xB0 ${e.latitude>=0?"N":"S"}`,n=`${Math.abs(e.longitude).toFixed(4)}\xB0 ${e.longitude>=0?"E":"W"}`;return`${t}, ${n}`}function ja({snapshot:e,open:t}){let n=e.override.mode==="route"?e.override.route:null;return k(v,{children:[l(Y,{children:"Movement"}),l(N,{children:k(te,{children:[l(j,{title:"Route",value:n?.name??"None",chevron:true,testID:"location-route",onPress:()=>t("routes")},"route"),n?l(j,{title:"Speed",value:Fa(n.speed),chevron:true,testID:"location-speed",onPress:()=>t("speed")},"speed"):null]})})]})}function Fa(e){let t=hi.find(n=>Math.abs(Number(n.key)-e)<.05);return t?t.label:zt(e)}function _a({snapshot:e,pick:t}){let n=e.override.mode==="route"?e.override.route:null,i=n?.id;return k(Je,{children:[n?l(v,{children:l(N,{children:l(te,{children:l(j,{title:"Stop Here",detail:"End the route and stay where it got to",testID:"location-route-stop",onPress:()=>t("stopRoute")},"stop")})})}):null,e.routes.length>0?k(v,{children:[l(Y,{children:"This App"}),l(N,{children:l(te,{children:e.routes.map((o,r)=>l(j,{title:o.name??o.id??`Route ${r+1}`,detail:`${K(yt(o.points))} at ${zt(o.speed)}${o.loop?", on repeat":""}`,checked:!!i&&i===o.id,testID:`location-route-${ft(o.id??o.name??String(r))}`,onPress:()=>t("startRoute",{route:o.id??o.name})},o.id??`${o.name}-${r}`))})})]}):null,k(v,{children:[l(Y,{children:"From Here"}),l(N,{children:l(te,{children:e.presets.map(o=>l(j,{title:o.name,detail:za(o.id)??o.description,checked:i===`preset:${o.id}`,testID:`location-preset-${o.id}`,onPress:()=>t("startRoute",{route:o.id})},o.id))})}),l(ee,{children:"These start where the app is now."})]})]})}function za(e){let t=K;switch(e){case"walk":return`${t(1e3)} north at walking pace`;case"run":return`${t(3e3)} north, then east, at running pace`;case"drive":return`${t(4e3)} of city streets with turns`;case"highway":return`${t(3e4)} north at highway speed`;case"tunnel":return`${t(3e3)} drive with no signal for ${t(600)} in the middle`;case"loop":return`A ${t(400)} block, walked on repeat`;default:return null}}function Wa({snapshot:e,pick:t}){let n=e.override.route?.speed??0;return k(v,{children:[l(N,{children:l(te,{children:hi.map(i=>l(j,{title:i.label,value:zt(Number(i.key)),checked:Math.abs(Number(i.key)-n)<.05,testID:`location-speed-${i.key}`,onPress:()=>t("setSpeed",{speed:Number(i.key)})},i.key))})}),l(ee,{children:"Heading and speed follow the route."})]})}var Ua=1e4;function Ha({snapshot:e,run:t}){let n=e.tasks.filter(p=>p.kind==="geofencing"&&p.regions.length>0),[i,o]=Oe(null),r=qt(!!i);if(n.length===0)return null;let a=n.length>1,u=n.map(p=>p.name).join(", ");return k(v,{children:[l(Y,{children:"Geofences"}),l(N,{children:l(te,{children:n.flatMap(p=>p.regions.map(g=>{let h=`${p.name}:${g.identifier}`,C=g.state==="inside",I=i?.key===h&&r-i.at<Ua?i:null,T=[Va(g)];return a&&T.push(p.name),l(j,{title:g.label??g.identifier,detail:T.join(" \xB7 "),note:I?qa(e,p,I.at):void 0,action:C?"Leave":"Enter",testID:`location-region-${ft(g.identifier)}`,onPress:()=>{o({key:h,at:Vt()}),t(C?"exitRegion":"enterRegion",{identifier:g.identifier,task:p.name})}},h)}))})}),k(ee,{children:["Tap a region to cross its edge. ",a?"The app's tasks":`The app's ${u} task`," runs as it would from the OS."]})]})}function Va(e){return e.state==="inside"?"Inside":e.distance==null?`${K(e.radius)} radius`:`${K(Math.max(0,e.distance-e.radius))} away`}function qa(e,t,n){let i=e.log.filter(r=>r.at>=n-50&&(r.detail??"").startsWith(t.name)),o=i.find(r=>r.kind==="error");return o?{text:`Task failed: ${o.detail?.slice(t.name.length+3)??""}`,tone:"bad"}:i.find(r=>r.kind==="task")?{text:"Task ran",tone:"ok"}:i.find(r=>r.kind==="enter"||r.kind==="exit")?{text:"Running the app's task\u2026",tone:"wait"}:{text:"Already on this side",tone:"wait"}}function Ga({snapshot:e,run:t,open:n}){let i=e.override,o=Fi(i),r=e.simulating?mi:mi.filter(a=>a.key!=="weak");return k(v,{children:[l(Y,{children:"Conditions"}),k(N,{children:[l(v,{style:y.segmentWrap,children:l(Ht,{tabs:r,activeKey:o??"",size:"sm",testIDPrefix:"location-conditions",onChange:a=>t("setConditions",{conditions:a})})}),e.simulating&&i.services&&i.signal?l(v,{style:y.separatorTop,children:l(j,{title:"Accuracy & Drift",value:`${ti(i.accuracy)}${i.jitter>0?` \xB7 drifts ${K(i.jitter)}`:""}`,chevron:true,testID:"location-accuracy",onPress:()=>n("accuracy")})}):null]}),l(ee,{children:$a[o??"custom"]})]})}function Ka({snapshot:e,run:t}){let n=e.override;return k(Je,{children:[k(v,{children:[l(Y,{children:"Accuracy"}),l(N,{children:l(v,{style:y.segmentWrap,children:l(Ht,{tabs:yi,activeKey:ki(yi,n.accuracy)??"",size:"sm",testIDPrefix:"location-accuracy",onChange:i=>t("tune",{accuracy:Number(i)})})})}),l(ee,{children:"The accuracy radius the app is given with each fix."})]}),k(v,{children:[l(Y,{children:"Drift"}),l(N,{children:l(v,{style:y.segmentWrap,children:l(Ht,{tabs:bi,activeKey:ki(bi,n.jitter)??"0",size:"sm",testIDPrefix:"location-drift",onChange:i=>t("tune",{jitter:Number(i)})})})}),l(ee,{children:"Moves each fix by up to this much at random, the way a real fix wanders."})]})]})}function Ja({snapshot:e,open:t}){let n=e.log.length;return l(v,{children:l(N,{children:k(te,{children:[l(j,{title:"Activity",value:n===0?"None":`${n} ${n===1?"event":"events"}`,chevron:true,testID:"location-activity",onPress:()=>t("activity")},"activity"),l(j,{title:"Options",chevron:true,testID:"location-options",onPress:()=>t("options")},"options")]})})})}function Ya({snapshot:e,run:t}){let n=qt(true),i=e.log.slice().reverse(),o=e.watches.filter(p=>p.kind==="position").length,r=e.tasks.filter(p=>p.kind==="locationUpdates").length,a=e.tasks.filter(p=>p.kind==="geofencing").reduce((p,g)=>p+g.regions.length,0),u=[o?`${o} location ${o===1?"watch":"watches"}`:null,a?`${a} ${a===1?"geofence":"geofences"}`:null,r?"background updates":null].filter(Boolean);return k(Je,{children:[k(v,{children:[l(Y,{children:"The App Is Using"}),l(N,{children:k(v,{style:y.editor,children:[l(A,{style:y.rowTitle,testID:"location-activity-summary",children:u.length?u.join(", "):"Nothing right now"}),l(A,{style:y.detail,children:e.libraries.length?`Through ${e.libraries.join(" and ")}.`:"No supported location library was found in this app."})]})})]}),k(v,{children:[l(Y,{children:"Recent"}),l(N,{children:k(te,{children:[i.length===0?l(v,{style:y.editor,children:l(A,{style:y.detail,children:"Location requests, watches and geofence crossings show up here."})},"empty"):i.map(p=>k(v,{style:y.logRow,testID:"location-log-entry",children:[l(v,{style:[y.logDot,Xa(p.kind)]}),k(v,{style:y.flex,children:[l(A,{style:y.logText,children:p.text}),p.detail?l(A,{style:y.logDetail,numberOfLines:2,children:p.detail}):null]}),l(A,{style:y.logWhen,children:Hr(p.at,n)})]},p.id)),i.length>0?l(j,{title:"Clear",tint:true,testID:"location-clear-log",onPress:()=>t("clearLog")},"clear"):null]})})]})]})}function Xa(e){return e==="enter"?y.dotEnter:e==="exit"?y.dotExit:e==="error"?y.dotError:e==="task"?y.dotTask:null}function Za({snapshot:e,run:t}){return k(v,{children:[l(N,{children:k(te,{children:[l(wi,{title:"Keep Across Reloads",value:e.settings.persist,testID:"location-setting-persist",onValueChange:n=>t("updateSettings",{persist:n})},"persist"),l(wi,{title:"Show Floating Status",value:e.settings.showChip,testID:"location-setting-showChip",onValueChange:n=>t("updateSettings",{showChip:n})},"chip")]})}),l(ee,{children:"The floating status stays on screen while the app is somewhere else, so a simulated location is never left on by accident."})]})}function Qa({title:e,onBack:t}){return k(se,{testID:"location-back",accessibilityRole:"button",accessibilityLabel:"Back",activeOpacity:.6,onPress:t,style:y.backRow,children:[l(pa,{size:18,color:m.color.accent}),l(A,{style:y.backLabel,children:"Location"}),l(A,{style:y.backTitle,numberOfLines:1,children:e})]})}function j({title:e,detail:t,note:n,value:i,action:o,checked:r,chevron:a,tint:u,onPress:p,testID:g}){return k(se,{testID:g,accessibilityRole:"button",accessibilityLabel:o?`${o} ${e}`:e,accessibilityState:r?{selected:true}:void 0,activeOpacity:.6,onPress:p,style:y.row,children:[k(v,{style:y.rowText,children:[l(A,{style:[y.rowTitle,u?y.titleTint:null],numberOfLines:1,children:e}),t?l(A,{style:y.detail,children:t}):null,n?l(A,{style:[y.note,n.tone==="ok"?y.noteOk:n.tone==="bad"?y.noteBad:null],testID:`${g}-result`,children:n.text}):null]}),i?l(A,{style:y.rowValue,numberOfLines:1,children:i}):null,o?l(A,{style:y.rowAction,children:o}):null,r?l(da,{size:18,color:m.color.accent}):null,a?l(fa,{size:16,color:m.color.textTertiary}):null]})}function wi({title:e,value:t,onValueChange:n,testID:i}){return k(v,{style:y.row,children:[l(v,{style:y.rowText,children:l(A,{style:y.rowTitle,children:e})}),l(ga,{value:t,testID:i,accessibilityLabel:e,onValueChange:n})]})}function ki(e,t){let n=null,i=1/0;for(let o of e){let r=Math.abs(Number(o.key)-t);r<i&&(n=o.key,i=r)}return n!==null&&i<=Math.max(.05,Number(n)*.05)?n:null}function ft(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var y=le.create({fill:{flex:1},flex:{flex:1},content:{paddingHorizontal:m.gutter,paddingTop:8,gap:m.groupGap},waiting:{flex:1,alignItems:"center",justifyContent:"center",padding:24},status:{padding:m.cardPad+2,gap:6},statusTitle:{color:m.color.text,fontSize:28,fontWeight:"600"},titleSimulated:{color:m.color.accent},titleBroken:{color:Pa},statusLine:{color:m.color.textSecondary,fontSize:m.font.row,fontVariant:["tabular-nums"]},coordinates:{color:m.color.textTertiary,fontSize:m.font.caption,fontFamily:va},statusButtons:{flexDirection:"row",alignItems:"center",gap:10,marginTop:10},round:{width:44,height:44,borderRadius:22,alignItems:"center",justifyContent:"center",backgroundColor:m.color.accent},progressTrack:{height:6,borderRadius:3,marginTop:8,backgroundColor:m.color.fillSecondary,overflow:"hidden"},progressFill:{position:"absolute",left:0,top:0,bottom:0,backgroundColor:m.color.accent},progressGap:{position:"absolute",top:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.28)"},permission:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator,paddingHorizontal:m.rowPadH,paddingVertical:12,gap:4},rowBetween:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},valueWarning:{color:m.color.warning},row:{flexDirection:"row",alignItems:"center",gap:10,minHeight:48,paddingHorizontal:m.rowPadH,paddingVertical:10},rowText:{flex:1,gap:2},rowTitle:{color:m.color.text,fontSize:m.font.row},titleTint:{color:m.color.accent},rowValue:{color:m.color.textSecondary,fontSize:m.font.row,maxWidth:"50%"},rowAction:{color:m.color.accent,fontSize:m.font.row,fontWeight:"500"},detail:{color:m.color.textTertiary,fontSize:m.font.caption},note:{color:m.color.textSecondary,fontSize:m.font.caption,marginTop:2},noteOk:{color:m.color.accent},noteBad:{color:m.color.danger},warning:{color:m.color.warning,fontSize:m.font.caption},separatorTop:{borderTopWidth:le.hairlineWidth,borderTopColor:m.color.separator},segmentWrap:{flexDirection:"row",padding:10},editor:{paddingHorizontal:m.rowPadH,paddingVertical:14,gap:8},inputRow:{flexDirection:"row",alignItems:"center",gap:8},input:{flex:1,color:m.color.text,fontSize:m.font.body,backgroundColor:m.color.bg,borderRadius:m.radius.input,borderWidth:1,borderColor:m.color.border,paddingHorizontal:12,paddingVertical:9},backRow:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},backLabel:{color:m.color.accent,fontSize:m.font.row},backTitle:{flex:1,color:m.color.text,fontSize:m.font.row,fontWeight:"600",textAlign:"center",marginRight:70},logRow:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingHorizontal:m.rowPadH,paddingVertical:10},logDot:{width:8,height:8,borderRadius:4,marginTop:6,backgroundColor:m.color.textTertiary},dotEnter:{backgroundColor:m.color.accent},dotExit:{backgroundColor:m.color.warning},dotError:{backgroundColor:m.color.danger},dotTask:{backgroundColor:m.color.info},logText:{color:m.color.text,fontSize:m.font.body},logDetail:{color:m.color.textTertiary,fontSize:m.font.caption,marginTop:2},logWhen:{color:m.color.textTertiary,fontSize:m.font.caption,fontVariant:["tabular-nums"],marginTop:1}});import{jsx as xi}from"react/jsx-runtime";var el=Ut.actions;async function tl(e,t){let n=el[e];if(!n)throw new Error(`Unknown location action: ${e}`);return n(t)}var Gt=()=>Ut.getSnapshot(),nl=2e3;function Ci(){let[e,t]=ia(Gt);return na(()=>{Ft(),Rt(),t(Gt()),ai(true),ot();let n=setInterval(ot,nl),i=Ue(()=>t(Gt()));return()=>{clearInterval(n),i(),ai(false)}},[]),xi(oa,{featureName:"Location",children:xi(vi,{snapshot:e,onAction:tl})})}import{jsx as il}from"react/jsx-runtime";var Ii=ta({id:"location",name:"LOCATION",description:"Pin the app anywhere, play routes, trigger geofences",slot:"both",color:Qr,icon:({size:e,color:t})=>il(Zr,{size:e,color:t}),component:Ci,modal:{subtitle:"simulate where the app is"}}),ol=ea(Ii);import{LocationToolIcon as rl,LOCATION_TOOL_ICON_COLOR as al}from"@buoy-gg/shared-ui/web";var ll=typeof navigator<"u"&&navigator.product==="ReactNative",sl=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(ll||sl)&&(Xr(),typeof Yt<"u"&&Yt&&(Ft(),Rt()));export{ut as BUILT_IN_PLACES,ct as LOCATION_CHIP_ID,al as LOCATION_TOOL_ICON_COLOR,Ci as LocationBody,li as LocationChip,rl as LocationToolIcon,vi as LocationToolView,De as ROUTE_PRESETS,Ze as bearingDegrees,Rt as bootLocation,si as buildPresetRoute,ol as createLocationTool,je as destination,V as distanceMeters,R as getLocationSnapshot,Ft as installLocationAdapters,$ as isLocationActive,Ut as locationSyncAdapter,Ii as locationToolPreset,Lt as moveToRegion,bt as parseCoordinate,Pt as pauseRoute,ot as refreshLocationPermission,eo as registerLocationPlaces,to as registerLocationRoutes,Mt as resetLocation,$t as resumeRoute,xn as seekRoute,Sn as setConditions,st as setPlace,Cn as setRouteSpeed,An as setServices,Tn as setSignal,kn as startRoute,Pn as stopRoute,Ue as subscribeLocation,In as tuneOverride,$n as useRealLocation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/location",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.58",
|
|
4
4
|
"description": "Location override for React Native: pin the app to any place, play routes with speed and heading, trigger geofences and test signal loss. Works with expo-location, @react-native-community/geolocation and react-native-geolocation-service.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
"./lib/web/**/*.mjs"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
20
|
+
"@buoy-gg/shared-ui": "^7.0.58"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
+
"@buoy-gg/license": "7.0.58",
|
|
23
24
|
"react": "*"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/react": "^19.1.0",
|
|
27
28
|
"@types/react-native": "^0.73.0",
|
|
28
|
-
"typescript": "~5.8.3"
|
|
29
|
+
"typescript": "~5.8.3",
|
|
30
|
+
"@buoy-gg/license": "^7.0.58"
|
|
29
31
|
},
|
|
30
32
|
"react-native-builder-bob": {
|
|
31
33
|
"source": "src",
|