@buoy-gg/location 7.0.63 → 7.0.64
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/web/index.mjs +2 -2
- package/package.json +4 -4
package/lib/web/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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
|
|
1
|
+
"use client";var Yt=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var Ri=Object.prototype.hasOwnProperty;var Ni=(e,t)=>{for(var n in t)Yt(e,n,{get:t[n],enumerable:true})},Qt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ei(t))!Ri.call(e,o)&&o!==n&&Yt(e,o,{get:()=>t[o],enumerable:!(i=Mi(t,o))||i.enumerable});return e},Oi=(e,t,n)=>(Qt(e,t,"default"),n&&Qt(n,t,"default"));var Xt=(()=>{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 O}from"@buoy-gg/shared-ui/web";var Zt=63710088e-1,X=e=>e*Math.PI/180,yt=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 en(e){let t=((e+180)%360+360)%360-180;return t===-180&&e>0?180:t}function V(e,t){let n=X(t.latitude-e.latitude),i=X(t.longitude-e.longitude),o=Math.sin(n/2)**2+Math.cos(X(e.latitude))*Math.cos(X(t.latitude))*Math.sin(i/2)**2;return 2*Zt*Math.asin(Math.min(1,Math.sqrt(o)))}function Ze(e,t){let n=X(e.latitude),i=X(t.latitude),o=X(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(yt(Math.atan2(r,a))+360)%360}function je(e,t,n){let i=n/Zt,o=X(t),r=X(e.latitude),a=X(e.longitude),c=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(o)),d=a+Math.atan2(Math.sin(o)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(c));return{latitude:yt(c),longitude:en(yt(d))}}function Di(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 tn(e){let t=[];for(let n=1;n<e.length;n++)t.push(V(e[n-1],e[n]));return t}function bt(e){return tn(e).reduce((t,n)=>t+n,0)}function et(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=tn(n),r=o.reduce((p,x)=>p+x,0),a=Math.max(0,t),c=false;r<=0?(a=0,c=!e.loop):e.loop?a=a%r:a>=r&&(a=r,c=true);let d=(e.gaps??[]).some(([p,x])=>a>=p&&a<x),h=a;for(let p=0;p<o.length;p++){let x=o[p],I=n[p],A=n[p+1],F=p===o.length-1;if(h<x||F){let _=x>0?Math.min(1,h/x):1;return{...Di(I,A,_),along:a,heading:Ze(I,A),leg:p,finished:c,inGap:d}}h-=x}return{...n[n.length-1],along:a,heading:0,leg:o.length-1,finished:c,inGap:d}}function Bi(e,t,n){if(t<=0)return{latitude:e.latitude,longitude:e.longitude};let i=nn(Math.sin(n*12.9898)*43758.5453),o=nn(Math.sin(n*78.233)*12543.1234);return je(e,i*360,Math.sqrt(o)*t)}function nn(e){return e-Math.floor(e)}var ji=3e3;function Fi(e){let t=Math.round(e.latitude/.03)*.03,n=.03/Math.max(.2,Math.cos(X(t))),i=Math.round(e.longitude/n)*n;return{...e,latitude:on(t),longitude:on(en(i)),accuracy:Math.max(e.accuracy,ji),heading:null,speed:null}}function on(e){return Math.round(e*1e6)/1e6}function _i(e,t){return V(e,t)<=e.radius}function zi(e,t,n){let i={},o=[];for(let r of e){let a=t[r.identifier]??"unknown",c=_i(r,n)?"inside":"outside";if(i[r.identifier]=c,a===c)continue;let d=c==="inside"?"enter":"exit",h=a==="unknown";(h||(d==="enter"?r.notifyOnEnter:r.notifyOnExit))&&o.push({identifier:r.identifier,kind:d,initial:h})}return{states:i,transitions:o}}function Wi(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 rn(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 vt(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 wt={persist:true,showChip:true},Ui={latitude:37.3349,longitude:-122.009,label:"Apple Park"};function kt(){return{mode:"real",place:{...Ui},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 Ae(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 Hi(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 xt(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 an(e){if(!e||typeof e!="object")return null;let t=e,n=kt(),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=xt(t.route);return{mode:i==="route"&&!a?"fixed":i,place:r,altitude:Hi(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 ln={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 Vi(e){if(!e.services)return"off";if(!e.signal)return"no-signal";for(let t of["good","weak"]){let n=ln[t];if(e.accuracy===n.accuracy&&e.jitter===n.jitter)return t}return null}import{devToolsStorageKeys as qi,persistentStorage as sn}from"@buoy-gg/shared-ui/web";function Gi(){try{let e=globalThis.localStorage;return e?cn(e.getItem(Ct)):void 0}catch{return}}var Ct=qi.location.state();function Ki(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 cn(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:an(t.override),settings:{persist:typeof n.persist=="boolean"?n.persist:wt.persist,showChip:typeof n.showChip=="boolean"?n.showChip:wt.showChip},tasks:Array.isArray(t.tasks)?t.tasks.map(Ki).filter(i=>i!==null):[]}}catch{return null}}async function Ji(){try{return cn(await sn.getItem(Ct))}catch{return null}}var It=Promise.resolve();function Yi(e){let t=JSON.stringify(e);return It=It.then(()=>sn.setItem(Ct,t)).catch(()=>{}),It.then(()=>{})}function un(){return globalThis.__buoyRealTimers??globalThis}function z(e,t){return un().setTimeout(e,t)}function Qi(e){un().clearTimeout(e)}var g=kt(),de={...wt},Te="full",Se=null,At=false,tt=false,Le=new Map,oe=new Map,D=new Map,Pe=[],Xi=0,dn=null,pn=1,ze=[],nt=[],it=new Set,We=null;function W(){We=null;for(let e of Array.from(it))try{e()}catch{}}function Ue(e){return it.add(e),()=>{it.delete(e)}}var fn=100;function S(e,t,n,i){Pe.push({id:++Xi,at:O(),kind:e,library:t,text:n,...i?{detail:i}:{}}),Pe.length>fn&&Pe.splice(0,Pe.length-fn),W()}function P(){return _e(g)}function be(){return g.services}function Zi(e){!e||e===Te||(Te=e,W())}function eo(e){if(!e)return;let t=Se&&Se.status===e.status&&Se.background===e.background&&Se.precision===e.precision;e.precision!==Te&&(Te=e.precision),!t&&(Se=e,W())}function $e(e){return g.route?g.playing?g.anchorMeters+Math.max(0,e-g.anchorReal)/1e3*g.route.speed:g.anchorMeters:0}function re(e=O()){if(!g.services)return{fix:null,reason:"services"};if(!g.signal)return{fix:null,reason:"signal"};if(g.mode==="real")return{fix:null,reason:"real"};let t,n=g.heading,i=0;if(g.mode==="route"&&g.route){let r=et(g.route,$e(e));if(r.inGap)return{fix:null,reason:"gap"};t=r;let a=g.playing&&!r.finished;n=r.heading,i=a?g.route.speed:0}else t=g.place;g.jitter>0&&(t=Bi(t,g.jitter,Math.floor(e/g.interval)+pn));let o={latitude:t.latitude,longitude:t.longitude,altitude:g.altitude,accuracy:Math.max(g.accuracy,g.jitter),altitudeAccuracy:g.altitude===null?null:3,heading:n,speed:i};return Te==="reduced"&&(o=Fi(o)),{fix:o,reason:null}}var Me=null,gn=0;function to(){return Ae(g)?oe.size>0||D.size>0?true:g.mode==="route"&&g.playing&&it.size>0:false}function ot(){Me===null&&to()&&(Me=z(()=>{Me=null,bn(),ot()},g.interval))}function hn(){Me!==null&&Qi(Me),Me=null}function mn(){hn(),bn(),ot()}function yn(e,t){let n=Number(e.options[t]);return Number.isFinite(n)&&n>0?n:0}function bn(){let e=O(),{fix:t}=re(e);if(g.mode==="route"&&g.route&&g.playing){let n=et(g.route,$e(e));n.finished&&(g={...g,playing:false,anchorMeters:n.along,anchorReal:e},Re())}t&&(vn(t,false),wn(t)),e-gn>5e3&&(gn=e,oo()),W()}function vn(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=yn(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,dn=O();try{n.deliver(e)}catch(i){S("error",n.library,`Watch ${n.id} callback threw: ${String(i?.message??i)}`)}}}function wn(e){for(let t of Array.from(D.values()))if(t.kind==="geofencing"){let{states:n,transitions:i}=zi(t.regions,t.states,e);t.states=n;for(let o of i)no(t,o)}else{let n=yn(t,"distanceInterval");if(t.lastBatchAt&&V(t.lastBatchAt,e)<Math.max(n,.01))continue;t.lastBatchAt={latitude:e.latitude,longitude:e.longitude},kn(t,{locations:[e]},"a location update")}}function no(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"} ${st(n)??n.identifier}`,`${e.name} \xB7 region ${n.identifier}${t.initial?" \xB7 first check after monitoring started":""}`);let i=st(n)??n.identifier;kn(e,{eventType:t.kind==="enter"?1:2,region:n},`${t.kind==="enter"?"entering":"leaving"} ${i}`)}function kn(e,t,n){let i=Le.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 ${io(o)}`:e.name)},o=>{S("error",e.library,`Task failed for ${n}`,`${e.name} \xB7 ${String(o?.message??o)}`)})}function io(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 oo(){rt()}function rt(){for(let e of Le.values())e.readPermission?.().then(eo,()=>{})}function at(e){Le.set(e.library,e),W()}function lt(e){let t=`${e.library}:${e.kind}:${e.id}`;oe.set(t,{...e,key:t,since:O(),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?(vn(i,false),W()):o==="services"&&n.fail?.("Location services are disabled")},0),ot()}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 ro(e,t,n){return oe.has(`${e}:${t}:${n}`)}function Tt(e,t){let n=e.kind==="geofencing"?(e.options.regions??[]).map((i,o)=>rn(i,o)).filter(i=>i!==null):[];D.set(e.name,{...e,regions:n,states:{},since:O(),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),Re(),Ae(g)&&z(()=>{let{fix:i}=re(),o=D.get(e.name);i&&o&&(wn(i),W())},0),ot()}function St(e){let t=D.get(e);return t?(D.delete(e),S("task",t.library,t.kind==="geofencing"?"The app stopped monitoring geofences":"The app stopped background updates",t.name),Re(),t):null}function Ee(e){return D.get(e)??null}function Lt(e){return Array.from(D.values()).filter(t=>!e||t.kind===e)}function xn(e,t){let n=D.get(e);n&&(n.intercepted=t,t||(n.states={}),Re())}function ao(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 st(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 lo(e){for(let t of e){let n=xt(t);if(!n)continue;let i=nt.findIndex(o=>(o.id??o.name)===(n.id??n.name));i>=0?nt[i]=n:nt.push(n)}W()}function q(e){g=e;let t=_e(g);if(t!==tt){tt=t;for(let n of Le.values())try{n.onActiveChange?.(t)}catch(i){S("error",n.library,`Switching failed: ${String(i?.message??i)}`)}}return Re(),Ae(g)?mn():(hn(),W()),E()}function ct(e){return q({...g,mode:"fixed",place:{latitude:e.latitude,longitude:e.longitude,label:e.label},playing:false})}function He(){return g.mode==="route"&&g.route?et(g.route,$e(O())):g.place}function Cn(e){let t=xt(e);if(!t)throw new Error("A route needs two or more valid points.");return q({...g,mode:"route",route:t,playing:true,anchorReal:O(),anchorMeters:0})}function Pt(){if(g.mode!=="route"||!g.playing)return E();let e=O();return q({...g,playing:false,anchorMeters:$e(e),anchorReal:e})}function $t(){if(g.mode!=="route"||!g.route)return E();let e=bt(g.route.points),t=!g.route.loop&&g.anchorMeters>=e?0:g.anchorMeters;return q({...g,playing:true,anchorReal:O(),anchorMeters:t})}function In(e){if(g.mode!=="route"||!g.route)throw new Error("No route is playing.");return q({...g,anchorMeters:Math.max(0,e),anchorReal:O()})}function An(e){if(!g.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=O();return q({...g,route:{...g.route,speed:e},anchorMeters:$e(t),anchorReal:t})}function Tn(e){let t=an({...g,...so(e)});return t?q({...t,anchorMeters:g.anchorMeters,anchorReal:g.anchorReal}):E()}function so(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}function Sn(e){return q({...g,signal:e})}function Ln(e){let t=q({...g,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 Pn(e){let t=ln[e];if(!t)throw new Error(`Unknown conditions "${String(e)}". Use good, weak, no-signal or off.`);let n=g.services,i=e==="good"||e==="weak"?t:{signal:t.signal,services:t.services},o=q({...g,...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 $n(){if(g.mode!=="route"||!g.route)return E();let e=He();return ct({latitude:e.latitude,longitude:e.longitude})}function Mn(){return q({...g,mode:"real",playing:false})}function Mt(e,t,n){for(let i of D.values()){if(n&&i.name!==n)continue;let o=i.regions.find(c=>c.identifier===e);if(!o)continue;let r=Wi(o,t,He()),a=st(o)??o.identifier;return ct({...r,label:t==="inside"?`At ${a}`:`Outside ${a}`})}throw new Error(`No geofence region "${e}" is being monitored.`)}function Et(){let e=kt();return q({...e,place:g.place})}function co(e){return de={persist:typeof e.persist=="boolean"?e.persist:de.persist,showChip:typeof e.showChip=="boolean"?e.showChip:de.showChip},Re(),W(),E()}function uo(){return de}function po(){return Pe.length=0,W(),E()}function E(){if(We)return We;let e=O(),{fix:t,reason:n}=re(e),i=null;if(g.mode==="route"&&g.route){let a=et(g.route,$e(e)),c=bt(g.route.points);i={along:a.along,length:c,finished:a.finished,leg:a.leg,etaMs:g.playing&&!g.route.loop&&!a.finished?(c-a.along)/g.route.speed*1e3:null}}let o=Ae(g)?He():null,r=t??o;return We={active:_e(g),simulating:Ae(g),override:g,current:{fix:t,reason:n,precision:Te},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(D.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(c=>({...c,label:st(c),state:a.states[c.identifier]??"unknown",distance:r?V(c,r):null}))})),log:Pe.slice(-50),libraries:Array.from(Le.keys()),places:ze.slice(),routes:nt.slice(),settings:de,lastDeliveryAt:dn},We}function Re(){if(!At)return;let e={v:1,override:de.persist&&_e(g)?g:null,settings:de,tasks:Array.from(D.values()).filter(t=>t.intercepted).map(({name:t,kind:n,library:i,options:o})=>({name:t,kind:n,library:i,options:o}))};Yi(e)}function En(e){if(e){de=e.settings;for(let t of e.tasks)D.has(t.name)||fo(t);e.override&&_e(e.override)&&(g=e.override,tt=true)}}function fo(e){let t=e.kind==="geofencing"?(e.options.regions??[]).map((n,i)=>rn(n,i)).filter(n=>!!n):[];D.set(e.name,{...e,regions:t,states:{},since:O(),runs:0,intercepted:true,lastBatchAt:null})}function Rt(){if(At)return;At=true,pn=Math.floor(Math.random()*1e3)+1;let e=Gi();if(e!==void 0){En(e),Rn();return}Ji().then(t=>{En(t),Rn()})}function Rn(){for(let e of Le.values())e.onActiveChange?.(tt);Ae(g)?z(mn,0):W()}var Nn="__buoyLocationNext";function L(e,t,n){let i=e[t];if(typeof i!="function")return null;let o=i[Nn]??i,r=(...c)=>o.apply(e,c),a=n(r);a[Nn]=o;try{e[t]=a}catch{return null}return e[t]===a?r:null}function go(e,t){let n=new Error(t);return n.code=e,n}var Nt={};Ni(Nt,{AccessibilityInfo:()=>bo,ActivityIndicator:()=>mr,Alert:()=>vr,Animated:()=>vo,AppRegistry:()=>ko,AppState:()=>xo,Appearance:()=>wo,BackHandler:()=>Co,Button:()=>yr,CheckBox:()=>jo,Clipboard:()=>Io,DeviceEventEmitter:()=>Dn,Dimensions:()=>Ao,Easing:()=>To,FlatList:()=>Fo,I18nManager:()=>So,Image:()=>_o,ImageBackground:()=>zo,InteractionManager:()=>Po,Keyboard:()=>Lo,KeyboardAvoidingView:()=>Wo,LayoutAnimation:()=>$o,Linking:()=>Mo,LogBox:()=>Zo,Modal:()=>gr,NativeEventEmitter:()=>Eo,NativeModules:()=>yo,PanResponder:()=>Ro,Picker:()=>Uo,PixelRatio:()=>No,Platform:()=>On,Pressable:()=>fr,ProgressBar:()=>Ho,RefreshControl:()=>Vo,SafeAreaView:()=>qo,ScrollView:()=>zn,SectionList:()=>Go,Share:()=>Oo,StatusBar:()=>Ko,StyleSheet:()=>le,Switch:()=>hr,Text:()=>T,TextInput:()=>_n,Touchable:()=>Jo,TouchableHighlight:()=>dr,TouchableNativeFeedback:()=>Yo,TouchableOpacity:()=>se,TouchableWithoutFeedback:()=>pr,UIManager:()=>Do,Vibration:()=>Bo,View:()=>v,VirtualizedList:()=>Qo,YellowBox:()=>Xo,findNodeHandle:()=>br,unstable_createElement:()=>mo,useColorScheme:()=>er,useLocaleContext:()=>tr,useWindowDimensions:()=>nr});Oi(Nt,ho);import*as ho from"react-native-web";import{unstable_createElement as mo,NativeModules as yo,AccessibilityInfo as bo,Animated as vo,Appearance as wo,AppRegistry as ko,AppState as xo,BackHandler as Co,Clipboard as Io,Dimensions as Ao,Easing as To,I18nManager as So,Keyboard as Lo,InteractionManager as Po,LayoutAnimation as $o,Linking as Mo,NativeEventEmitter as Eo,PanResponder as Ro,PixelRatio as No,Platform as On,Share as Oo,StyleSheet as le,UIManager as Do,Vibration as Bo,CheckBox as jo,FlatList as Fo,Image as _o,ImageBackground as zo,KeyboardAvoidingView as Wo,Picker as Uo,ProgressBar as Ho,RefreshControl as Vo,SafeAreaView as qo,SectionList as Go,StatusBar as Ko,Touchable as Jo,TouchableNativeFeedback as Yo,VirtualizedList as Qo,YellowBox as Xo,LogBox as Zo,DeviceEventEmitter as Dn,useColorScheme as er,useLocaleContext as tr,useWindowDimensions as nr}from"react-native-web";import*as U from"react-native-web";import{createElement as Ot,forwardRef as Bn,useCallback as ir,useRef as or}from"react";import{useEffect as rr,useState as ar}from"react";import{createPortal as lr}from"react-dom";var sr='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as cr}from"react/jsx-runtime";var Ve=Symbol.for("@buoy-gg/portal-host"),jn=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Fn(){let e=document;if(e[Ve])return e[Ve].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:sr});let n=()=>{let p=document.fullscreenElement,x=p&&p.tagName!=="CANVAS"?p:document.body;t.parentElement!==x&&x.appendChild(t)},i=new Map,o=p=>{(!t.contains(p.target)||!jn(p.target))&&i.set(p.code||p.key,{key:p.key,code:p.code,location:p.location,keyCode:p.keyCode,which:p.which,altKey:p.altKey,ctrlKey:p.ctrlKey,metaKey:p.metaKey,shiftKey:p.shiftKey})},r=p=>{i.delete(p.code||p.key)},a=()=>i.clear(),c=()=>{let p=[...i.values()];i.clear();for(let x of p)document.dispatchEvent(new KeyboardEvent("keyup",{...x,bubbles:true}))},d=p=>{jn(p.target)&&p.stopPropagation()},h=p=>p.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",o,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",a),t.addEventListener("focusin",c),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",h,{passive:true}),e[Ve]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",a),t.remove(),delete e[Ve]}},t}function ur({children:e}){let[t,n]=ar(null);return rr(()=>{let i=Fn(),o=document[Ve];return o.users++,n(i),()=>{--o.users===0&&o.dispose()}},[]),t?lr(cr("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function G(e){let t=Bn((i,o)=>{let{accessibilityState:r,accessibilityValue:a,...c}=i;for(let d of["busy","checked","disabled","expanded","selected"])r?.[d]!==void 0&&c[`aria-${d}`]===void 0&&(c[`aria-${d}`]=r[d]);for(let[d,h]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[d]!==void 0&&c[`aria-${h}`]===void 0&&(c[`aria-${h}`]=a[d]);return Ot(e,{...c,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),T=G(U.Text),_n=G(U.TextInput),se=G(U.TouchableOpacity),dr=G(U.TouchableHighlight),pr=G(U.TouchableWithoutFeedback),fr=G(U.Pressable),zn=G(U.ScrollView),Wn=Bn((e,t)=>{let n=or(null),i=ir(o=>{if(o){let r=o;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(n.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Fn().appendChild(r))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Ot(ur,null,Ot(U.Modal,{...e,ref:i}))});Wn.displayName="Modal";var gr=G(Wn),hr=G(U.Switch),mr=G(U.ActivityIndicator),yr=G(U.Button),br=U.findNodeHandle,vr={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 h=document.createElement("p");h.textContent=t,h.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(h)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let c=n?.length?n:[{text:"OK"}],d=()=>{o.close?.(),o.remove()};for(let h of c){let p=document.createElement("button");p.type="button",p.textContent=h.text??"OK",p.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${h.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,p.onclick=()=>{d(),h.onPress?.()},a.appendChild(p)}o.addEventListener("cancel",h=>{h.preventDefault(),i?.cancelable!==false&&(d(),i?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};var wr=[{module:"RNCGeolocation",library:"@react-native-community/geolocation"},{module:"RNFusedLocation",library:"react-native-geolocation-service"}],kr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function Dt(e,t){return{code:e,message:t,...kr}}function Un(){return Nt}function xr(e){let t=Un();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 Hn(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 Cr=[];function Ir(e){let t=xr(e.module);if(!t||typeof t.getCurrentPosition!="function")return false;Cr.push(t);let n=Un(),i=n?.Platform?.OS??"ios",o=(h,p)=>n?.DeviceEventEmitter?.emit(h,p),r={options:null,native:false,on:false},a=()=>lt({library:e.library,id:"observer",kind:"position",options:r.options??{},deliver:h=>o("geolocationDidChange",Hn(h,i,Date.now())),fail:h=>o("geolocationError",Dt(2,h))});L(t,"getCurrentPosition",h=>(...p)=>{if(!P())return h(...p);let x=p[1],I=p[2];if(!be()){S("request",e.library,"getCurrentPosition \u2192 services off"),I?.(Dt(2,"No location provider available."));return}let{fix:A}=re();if(!A){S("request",e.library,"getCurrentPosition \u2192 no signal"),z(()=>I?.(Dt(3,"Unable to fetch location within 1.0s.")),1e3);return}S("request",e.library,`getCurrentPosition \u2192 ${A.latitude.toFixed(5)}, ${A.longitude.toFixed(5)}`),z(()=>x?.(Hn(A,i,Date.now())),0)});let c=L(t,"startObserving",h=>(...p)=>{if(r.options=p[0]&&typeof p[0]=="object"?p[0]:{},r.on=true,!P())return r.native=true,h(...p);r.native=false,a()}),d=L(t,"stopObserving",h=>(...p)=>{if(r.on=false,ae(e.library,"position","observer"),r.native)return r.native=false,h(...p)});return at({library:e.library,onActiveChange(h){r.on&&(h&&r.native?(r.native=false,d?.(),a()):!h&&!r.native&&(ae(e.library,"position","observer"),r.native=true,c?.(r.options??{})))}}),true}function Ar(){return wr.filter(Ir).map(e=>e.library)}function Tr(e){return null}function Sr(e){return null}var N="expo-location";function Lr(){return On?.OS??"ios"}function Vn(e){try{let n=globalThis.expo?.modules?.[e];if(n&&typeof n=="object")return n}catch{}let t=Tr(e);return t&&typeof t=="object"?t:null}function Bt(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 Pr(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 _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};
|
|
3
|
+
\u2192 Caused by: ${t}`}var qn={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"?qn[e].android:qn[e].ios;return Promise.reject(go(i.code,Pr(t,i.reason,n)))}var Gn=false;function $r(){let e=Vn("ExpoLocation");if(!e||typeof e.getCurrentPositionAsync!="function")return false;let t=e,n=Vn("ExpoTaskManager"),i=Lr(),o=new Map,r={},a=()=>Date.now(),c=u=>s=>t.emit?.("Expo.locationChanged",{watchId:u,location:Bt(s,i,a())}),d=u=>s=>{let f=s.heading??0;t.emit?.("Expo.headingChanged",{watchId:u,heading:{trueHeading:f,magHeading:f,accuracy:3}})},h=u=>s=>t.emit?.("Expo.locationError",{watchId:u,reason:s});async function p(){let u=t.getForegroundPermissionsAsync,s={granted:true,status:"granted",precision:"full",reported:false};if(typeof u!="function")return s;try{let f=await u.call(t),w=f?.ios?.accuracy==="reduced"||f?.android?.accuracy==="coarse"?"reduced":"full";Zi(w);let C=f?.granted===true,ie=C?"granted":f?.status==="undetermined"?"undetermined":"denied";return{granted:C,status:ie,precision:w,reported:true}}catch{return s}}async function x(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return null;try{return(await u.call(t))?.granted===true}catch{return null}}async function I(){let u=t.getBackgroundPermissionsAsync;if(typeof u!="function")return true;try{return(await u.call(t))?.granted===true}catch{return true}}function A(u,s){lt({library:N,id:u,kind:s.kind,options:s.options,deliver:s.kind==="position"?c(u):d(u),fail:h(u)})}r.getCurrentPositionAsync=L(t,"getCurrentPositionAsync",u=>async(...s)=>{if(!P())return u(...s);let f="getCurrentPositionAsync";if(!be())return S("request",N,"getCurrentPositionAsync \u2192 services off"),ce("services",f,i);if(!(await p()).granted)return S("request",N,"getCurrentPositionAsync \u2192 permission denied"),ce("denied",f,i);let{fix:w}=re();return w?(S("request",N,`getCurrentPositionAsync \u2192 ${w.latitude.toFixed(5)}, ${w.longitude.toFixed(5)}`),Bt(w,i,a())):(S("request",N,"getCurrentPositionAsync \u2192 no signal"),await new Promise(C=>z(()=>C(null),1e3)),ce("unavailable",f,i))}),r.getLastKnownPositionAsync=L(t,"getLastKnownPositionAsync",u=>async(...s)=>{if(!P())return u(...s);if(!(await p()).granted)return ce("denied","getLastKnownPositionAsync",i);let{fix:f}=re();return S("request",N,`getLastKnownPositionAsync \u2192 ${f?"simulated":"null"}`),f?Bt(f,i,a()):null}),r.watchPositionImplAsync=L(t,"watchPositionImplAsync",u=>async(...s)=>{let f=Number(s[0]),w=s[1]&&typeof s[1]=="object"?s[1]:{};if(!P()){let ie=await u(...s),ue={kind:"position",options:w,native:true};return o.set(f,ue),P()&&Ce(f,ue),ie}if(!(await p()).granted)return ce("denied","watchPositionImplAsync",i);if(!P())return o.set(f,{kind:"position",options:w,native:true}),u(...s);let C={kind:"position",options:w,native:false};o.set(f,C),A(f,C)}),r.watchDeviceHeading=L(t,"watchDeviceHeading",u=>async(...s)=>{let f=Number(s[0]);if(!P()){let C=await u(...s),ie={kind:"heading",options:{},native:true};return o.set(f,ie),P()&&Ce(f,ie),C}if(!(await p()).granted)return ce("denied","watchDeviceHeading",i);if(!P())return o.set(f,{kind:"heading",options:{},native:true}),u(...s);let w={kind:"heading",options:{},native:false};o.set(f,w),A(f,w)}),r.removeWatchAsync=L(t,"removeWatchAsync",u=>async(...s)=>{let f=Number(s[0]),w=o.get(f);if(o.delete(f),ae(N,"position",f),ae(N,"heading",f),!w||w.native)return u(...s)}),L(t,"hasServicesEnabledAsync",u=>async(...s)=>P()&&!be()?false:u(...s)),L(t,"getProviderStatusAsync",u=>async(...s)=>{let f=await u(...s);if(!P()||be())return f;let w={...f,locationServicesEnabled:false};for(let C of["gpsAvailable","networkAvailable","passiveAvailable"])C in w&&(w[C]=false);return w});let F=(u,s)=>L(t,s,f=>async(...w)=>{let C=String(w[0]),ie=w[1]&&typeof w[1]=="object"?w[1]:{},ue={name:C,kind:u,library:N,options:ie};if(!P()){let mt=await f(...w);return Tt(ue,false),P()&&b(true),mt}if(u==="locationUpdates"&&!be())return ce("services",s,i);if(!(await p()).granted)return ce("denied",s,i);if(u==="geofencing"&&!await I())return ce("deniedBackground",s,i);Tt(ue,true)});r.startLocationUpdatesAsync=F("locationUpdates","startLocationUpdatesAsync"),r.startGeofencingAsync=F("geofencing","startGeofencingAsync");let _=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));if(!(C&&C.kind===u&&(St(C.name),C.intercepted)))return f(...w)});r.stopLocationUpdatesAsync=_("locationUpdates","stopLocationUpdatesAsync"),r.stopGeofencingAsync=_("geofencing","stopGeofencingAsync");let ge=(u,s)=>L(t,s,f=>async(...w)=>{let C=Ee(String(w[0]));return C&&C.kind===u?true:f(...w)});ge("locationUpdates","hasStartedLocationUpdatesAsync"),ge("geofencing","hasStartedGeofencingAsync");let he=new Map,ht=0,Qe={geofencing:"geofencing",locationUpdates:"location"};n&&(L(n,"notifyTaskFinishedAsync",u=>async(...s)=>{let f=s[1]??{},w=f.eventId?he.get(f.eventId):void 0;if(w&&f.eventId){he.delete(f.eventId),w(f.result);return}return u(...s)}),L(n,"isTaskRegisteredAsync",u=>async(...s)=>Ee(String(s[0]))?.intercepted?true:u(...s)),L(n,"getTaskOptionsAsync",u=>async(...s)=>{let f=Ee(String(s[0]));return f?.intercepted?f.options:u(...s)}),L(n,"getRegisteredTasksAsync",u=>async(...s)=>{let f=await u(...s)??[],w=Lt().filter(C=>C.intercepted).map(C=>({taskName:C.name,taskType:Qe[C.kind],options:C.options}));return[...f,...w]}),L(n,"unregisterTaskAsync",u=>async(...s)=>{let f=Ee(String(s[0]));if(!(f&&(St(f.name),f.intercepted)))return u(...s)}),L(n,"unregisterAllTasksAsync",u=>async(...s)=>{for(let f of Lt())St(f.name);return u(...s)}));function Be(){if(!n)return null;if(n.__expo_module_name__&&typeof n.emit=="function")return(s,f)=>n.emit(s,f);let u=Dn;return u?(s,f)=>u.emit(s,f):null}async function me(u){for(let s=0;s<5e3&&Sr(u)===false;s+=100)await new Promise(f=>z(()=>f(null),100))}async function Xe(u,s){await me(u.name);let f=Be();if(!f)return Promise.reject(new Error("expo-task-manager is not installed"));let w=`buoy-location-${++ht}`,C=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{f(C,{data:s,error:null,executionInfo:{eventId:w,taskName:u.name,appState:"active"}})}catch(mt){he.delete(w),ue(mt)}})}function Ce(u,s){s.native&&(s.native=false,Promise.resolve(r.removeWatchAsync?.(u)).catch(()=>{}),A(u,s))}function b(u){for(let[s,f]of Array.from(o.entries()))if(u&&f.native)Ce(s,f);else if(!u&&!f.native){ae(N,f.kind,s);let w=f.kind==="position"?r.watchPositionImplAsync:r.watchDeviceHeading;f.native=true,Promise.resolve(f.kind==="position"?w?.(s,f.options):w?.(s)).catch(C=>{f.native=false,h(s)(String(C?.message??C))})}else u&&!f.native&&!ro(N,f.kind,s)&&A(s,f);for(let s of Lt()){if(s.library!==N)continue;let f=s.kind==="geofencing";if(u&&!s.intercepted){let w=f?r.stopGeofencingAsync:r.stopLocationUpdatesAsync;Promise.resolve(w?.(s.name)).catch(()=>{}),xn(s.name,true)}else if(!u&&s.intercepted){let w=f?r.startGeofencingAsync:r.startLocationUpdatesAsync;xn(s.name,false),Promise.resolve(w?.(s.name,s.options)).catch(C=>{S("error",N,`Could not restart ${s.name} natively: ${String(C?.message??C)}`)})}}}return at({library:N,fireTask:Xe,onActiveChange:b,readPermission:async()=>{let u=await p();if(!u.reported)return null;let s=u.status==="granted"?await x():false;return{status:u.status,background:s,precision:u.precision}}}),Gn||(Gn=true,n&&typeof n.getRegisteredTasksAsync=="function"&&Promise.resolve(n.getRegisteredTasksAsync.call(n)).then(u=>{for(let s of u??[]){if(!s?.taskName||Ee(s.taskName))continue;let f=s.taskType==="geofencing"?"geofencing":s.taskType==="location"?"locationUpdates":null;f&&(Tt({name:s.taskName,kind:f,library:N,options:s.options??{}},false),P()&&b(true))}}).catch(()=>{})),true}import{callCapacitorAsApp as Mr,callCapacitorNative as Kn,callCapacitorNativeCallback as Er,capacitorPlatform as Rr,hasCapacitorPlugin as Nr,installCapacitorBridge as Or,interceptCapacitor as jt,makeCapacitorCallbackId as Dr}from"@buoy-gg/license/web";var ve="@capacitor/geolocation",pe="Geolocation";function Jn(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 Ft(e){return new Error(e)}function Br(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 Yn(e,t){return(n,i)=>{e.gen===t&&e.nativeId!==null&&e.callback(n,i)}}var qe=new Map,Qn=false;function Xn(e){lt({library:ve,id:e.id,kind:"position",options:e.options,deliver:t=>e.callback(Jn(t,Date.now())),fail:t=>e.callback(null,Ft(t))})}function jr(e){let t=++e.gen;e.nativeId=Er(pe,"watchPosition",e.options,Yn(e,t))}function Fr(e){if(e.gen++,e.nativeId===null)return;let t=e.nativeId;e.nativeId=null,Kn(pe,"clearWatch",{id:t}).catch(()=>{})}function _r(){return Qn?true:!Rr()||!Nr(pe)||!Or()?false:(Qn=true,jt({plugin:pe,methods:["getCurrentPosition"],promise:(e,t)=>{if(!P())return t();if(!be())return S("request",ve,"getCurrentPosition \u2192 services off"),Promise.reject(Ft("Location services are not enabled"));let{fix:n}=re();return n?(S("request",ve,`getCurrentPosition \u2192 ${n.latitude.toFixed(5)}, ${n.longitude.toFixed(5)}`),Jn(n,Date.now())):(S("request",ve,"getCurrentPosition \u2192 no signal"),new Promise((i,o)=>z(()=>o(Ft("Timeout")),1e3)))}}),jt({plugin:pe,methods:["watchPosition"],callback:(e,t,n)=>{if(!P()){let o={id:"",options:e.options,callback:t,nativeId:null,gen:1},r=n(Yn(o,1));return r===null?null:(o.id=r,o.nativeId=r,qe.set(r,o),r)}let i={id:Dr(),options:e.options,callback:t,nativeId:null,gen:1};return qe.set(i.id,i),Xn(i),i.id}}),jt({plugin:pe,methods:["clearWatch"],promise:(e,t)=>{let n=String(e.options.id??""),i=qe.get(n);if(!i)return t();if(qe.delete(n),i.gen++,ae(ve,"position",n),i.nativeId===null)return;let o=i.nativeId;return i.nativeId=null,o===n?t():Kn(pe,"clearWatch",{id:o})}}),at({library:ve,onActiveChange(e){for(let t of qe.values())e&&t.nativeId!==null?(Fr(t),Xn(t)):!e&&t.nativeId===null&&(ae(ve,"position",t.id),jr(t))},async readPermission(){try{return Br(await Mr(pe,"checkPermissions"))}catch{return null}}}),true)}var we="navigator.geolocation",zr={PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3};function _t(e,t){return{code:e,message:t,...zr}}function Zn(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 ei(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 Ge=new Map,Wr=1e6,ti=false;function Ur(){if(ti)return true;let e=globalThis.navigator?.geolocation;if(!e||typeof e.getCurrentPosition!="function")return false;ti=true;let t=null,n=null,i=o=>lt({library:we,id:o.id,kind:"position",options:o.options,deliver:r=>o.success(Zn(r,Date.now())),fail:r=>o.error?.(_t(2,r))});return L(e,"getCurrentPosition",o=>(...r)=>{if(!P())return o(...r);let a=r[0],c=r[1];if(!be()){S("request",we,"getCurrentPosition \u2192 services off"),z(()=>c?.(_t(2,"Location services are disabled")),0);return}let{fix:d}=re();if(!d){S("request",we,"getCurrentPosition \u2192 no signal"),z(()=>c?.(_t(3,"Timeout expired")),1e3);return}S("request",we,`getCurrentPosition \u2192 ${d.latitude.toFixed(5)}, ${d.longitude.toFixed(5)}`),z(()=>a?.(Zn(d,Date.now())),0)}),t=L(e,"watchPosition",o=>(...r)=>{let a=r[0],c=r[1],d=r[2]&&typeof r[2]=="object"?r[2]:{};if(!P()){let p={id:0,success:a,error:c,options:d,nativeId:null,gen:1},[x,I]=ei(p,1),A=o(x,I,r[2]);return p.id=A,p.nativeId=A,Ge.set(A,p),A}let h={id:Wr++,success:a,error:c,options:d,nativeId:null,gen:1};return Ge.set(h.id,h),i(h),h.id}),n=L(e,"clearWatch",o=>(...r)=>{let a=r[0],c=Ge.get(a);if(!c)return o(...r);if(Ge.delete(a),c.gen++,ae(we,"position",a),c.nativeId!==null)return o(c.nativeId)}),at({library:we,onActiveChange(o){for(let r of Ge.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,[c,d]=ei(r,a);r.nativeId=t?.(c,d,r.options)??null}}}),true}var ke=null;function zt(){return ke||(ke=[],$r()&&ke.push("expo-location"),ke.push(...Ar()),_r()&&ke.push("@capacitor/geolocation"),Ur()&&ke.push("navigator.geolocation"),ke)}import{useSyncExternalStore as Hr}from"react";import{FloatingTool as Vr,LocationToolIcon as ni,Pause as qr,Play as Gr,RefreshCw as Kr,X as Jr,dismissFloatingTool as Yr,getFloatingTools as Qr,night as fe,openFloatingTool as Xr}from"@buoy-gg/shared-ui/web";var Zr=new Set(["US","GB","LR","MM"]),ii=null;function ea(){try{let e=Intl.DateTimeFormat().resolvedOptions().locale,t=/[-_]([A-Z]{2})\b/.exec(e);return t?t[1]:null}catch{return null}}var Wt=null;function Ne(){return ii!==null?ii:(Wt===null&&(Wt=Zr.has(ea()??"")),Wt)}var oi=3.28084,ri=1609.344;function K(e){if(!Number.isFinite(e))return"\u2013";let t=Math.abs(e);if(Ne()){let n=t/ri;return n<.1?`${Math.round(t*oi/10)*10} ft`:`${ai(n)} mi`}return t<1e3?`${Math.round(t)} m`:`${ai(t/1e3)} km`}function ai(e){let t=Math.round(e*10)/10;return t<10?t.toFixed(1):Math.round(e).toLocaleString("en-US")}function li(e){return Number.isFinite(e)?e>=1e3?`\xB1${K(e)}`:Ne()?`\xB1${Math.round(e*oi)} ft`:`\xB1${Math.round(e)} m`:"\u2013"}function Ut(e){if(e==null||e<0)return"\u2013";let t=Ne()?e*3600/ri:e*3.6,n=Ne()?"mph":"km/h";return`${t<10?t.toFixed(1):Math.round(t)} ${n}`}function ta(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 na(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 si(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 ia(e){return!e.override.services||!e.override.signal?"broken":e.override.mode==="real"?"real":"simulated"}function oa(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(`${ta(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(li(n.accuracy)),e.current.precision==="reduced"&&t.push("approximate"),t.join(" \xB7 ")}function ra(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 aa(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 ci}from"react/jsx-runtime";var ut="location-chip",la={id:ut,render:e=>H(fi,{...e})},sa=()=>Qr().some(e=>e.id===ut),ui=false,Ht=false,di=null;function pi(e){Ht!==e&&(Ht=e,di?.())}function ca(){if(ui)return;ui=true;let e=false,t=()=>{let n=E().active&&uo().showChip&&!Ht;n&&!e?Xr(la):!n&&sa()&&Yr(ut),e=n};di=t,Ue(t),t()}function fi({id:e,revealToken:t}){let n=Hr(Ue,E,E),i=si(n),o=n.override.mode==="route"&&n.progress,r=n.override.playing,a=!!o&&o.finished;return H(Vr,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"top",accessibilityLabel:`Move or hide the location chip. ${i}`,handleAdornment:H(ni,{size:12}),children:ci(v,{style:xe.row,children:[H(ni,{size:18}),ci(v,{style:xe.text,children:[H(T,{style:xe.title,numberOfLines:1,testID:"location-chip-title",children:i}),H(T,{style:xe.detail,numberOfLines:1,testID:"location-chip-detail",children:aa(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(qr,{size:14,color:fe.color.accent}):a?H(Kr,{size:14,color:fe.color.accent}):H(Gr,{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:()=>Et(),style:xe.button,hitSlop:{top:8,bottom:8,left:4,right:8},children:H(Jr,{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 ua,LOCATION_TOOL_ICON_COLOR as da,createToolFactory as pa,defineToolPreset as fa}from"@buoy-gg/shared-ui/web";import{useEffect as ga,useState as ha}from"react";import{FeatureGate as ma}from"@buoy-gg/shared-ui/web";import{createSyncAdapter as ya}from"@buoy-gg/shared-ui/web";var dt=[{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"}],Oe=[{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 gi(e,t,n=0){let i=Oe.find(h=>h.id===e);if(!i)throw new Error(`Unknown route preset "${e}". Use one of: ${Oe.map(h=>h.id).join(", ")}.`);let o={latitude:t.latitude,longitude:t.longitude},r=(h,p,x)=>je(h,n+p,x),a,c,d=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 h=r(o,0,1200),p=r(h,90,800),x=r(p,0,1e3),I=r(x,-90,1e3);a=[o,h,p,x,I];break}case"highway":a=[o,r(o,0,3e4)];break;case"tunnel":a=[o,r(o,0,3e3)],c=[[1200,1800]];break;case"loop":{let h=r(o,0,100),p=r(h,90,100),x=r(p,180,100);a=[o,h,p,x,o],d=true;break}}return{id:`preset:${e}`,name:i.name,points:a,speed:i.speed,loop:d,gaps:c}}function ba(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 Z(e){return e&&typeof e=="object"?e:{}}function Ke(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 $(){return{...E(),builtInPlaces:dt,presets:Oe}}function va(e){let t=e.trim().toLowerCase(),n=[...E().places,...dt];return n.find(i=>i.label?.toLowerCase()===t)??n.find(i=>i.label?.toLowerCase().includes(t))??null}function hi(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=vt(r);if(a)return{...a,label:t};let c=va(r);if(c)return c;throw new Error(`No place called "${r}". Give latitude and longitude, or one of: ${wa()}.`)}}return null}function wa(){return[...E().places,...dt].map(e=>e.label).filter(Boolean).join(", ")}function ka(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:Ke(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=E().routes.find(d=>d.id===i||d.name?.toLowerCase()===i.toLowerCase());if(r)return t?{...r,speed:t}:r;let a=Oe.find(d=>d.id===i||d.name.toLowerCase()===i.toLowerCase());if(a){let d=gi(a.id,He(),n);return t?{...d,speed:t}:d}let c=[...E().routes.map(d=>d.id??d.name),...Oe.map(d=>d.id)];throw new Error(`No route "${i}". Use one of: ${c.join(", ")}; or pass points.`)}let o=hi(e);if(o)return ba(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 Vt=ya({version:1,getSnapshot(){return $()},subscribe(e){return Ue(e)},actions:{getState(){return $()},setLocation(e){let t=hi(Z(e));if(!t)throw new Error('setLocation needs `latitude` and `longitude`, `query` ("lat, lon" or a map link), or `place` (a place name).');return ct(t),$()},startRoute(e){return Cn(ka(Z(e))),$()},stopRoute(){return $n(),$()},setConditions(e){let t=Z(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 Pn(i),$()},pauseRoute(){return Pt(),$()},resumeRoute(){return $t(),$()},seekRoute(e){let t=Z(e),n=J(t,"meters","along"),i=J(t,"fraction","progress"),o=E().progress?.length??0;if(n===void 0&&i===void 0)throw new Error("seekRoute needs `meters` or `fraction` (0 to 1).");return In(n??(i??0)*o),$()},setSpeed(e){let t=J(Z(e),"speed","metersPerSecond");if(t===void 0)throw new Error("setSpeed needs `speed` in meters per second.");return An(t),$()},tune(e){let t=Z(e);return Tn({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")}),$()},setSignal(e){let t=Ke(Z(e),"on","signal","enabled");if(t===void 0)throw new Error("setSignal needs `on`: true or false.");return Sn(t),$()},setServices(e){let t=Ke(Z(e),"on","services","enabled");if(t===void 0)throw new Error("setServices needs `on`: true or false.");return Ln(t),$()},enterRegion(e){let t=Z(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 Mt(n,"inside",typeof t.task=="string"?t.task:void 0),$()},exitRegion(e){let t=Z(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 Mt(n,"outside",typeof t.task=="string"?t.task:void 0),$()},useRealLocation(){return Mn(),$()},reset(){return Et(),$()},updateSettings(e){let t=Z(e);return co({persist:Ke(t,"persist"),showChip:Ke(t,"showChip")}),$()},clearLog(){return po(),$()}}});import{useEffect as xa,useState as De}from"react";import{Check as Ca,ChevronLeft as Ia,ChevronRight as Aa,NightButton as mi,NightCard as R,NightFootnote as ee,NightRows as te,NightSectionLabel as Y,NightSegmented as qt,NightSwitch as Ta,Pause as Sa,Play as La,RefreshCw as Pa,copyToClipboard as $a,monoFont as Ma,night as m,realNow as Gt,useSafeAreaInsets as Ea,useToolScreenHeader as Ra}from"@buoy-gg/shared-ui/web";import{night as ne}from"@buoy-gg/shared-ui/web";import{jsx as Q,jsxs as pt}from"react/jsx-runtime";var yi="#F87171",Je=1.8,Na=6e4,Oa=400;function Da({snapshot:e,onPinPlace:t,onCrossRegion:n}){let i=e.position,o=e.override.mode==="route"?e.override.route:null,r=i??e.places[0]??Ba(e.tasks)??null;if(!r)return null;let a=b=>!i||V(i,b)<=Na,c=e.places.filter(a),d=e.tasks.filter(b=>b.kind==="geofencing").flatMap(b=>b.regions.filter(a).map(u=>({task:b,region:u}))),h=e.places.length-c.length,p=Math.cos(r.latitude*Math.PI/180),x=b=>({x:(b.longitude-r.longitude)*111320*p,y:(b.latitude-r.latitude)*110540}),I=[];i&&I.push({...x(i),r:60});for(let b of o?.points??[])I.push({...x(b),r:0});for(let b of c)I.push({...x(b),r:60});for(let b of d)I.push({...x(b.region),r:b.region.radius});let A=1/0,F=-1/0,_=1/0,ge=-1/0;for(let b of I)A=Math.min(A,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=(A+F)/2,ht=(_+ge)/2,Qe=Math.max(Oa,(ge-_)*1.35,(F-A)*1.2/Je),Be=Qe*Je,me=b=>{let u=x(b);return{x:.5+(u.x-he)/Be,y:.5-(u.y-ht)/Qe}},Xe=Fa(Be),Ce=e.override.mode==="fixed"?e.override.place.label:void 0;return Q(v,{children:pt(v,{style:M.map,testID:"location-map",accessibilityLabel:"Map of places, geofences and the simulated position",children:[bi.map(b=>Q(v,{style:[M.gridV,{left:B(b)}]},`v${b}`)),bi.map(b=>Q(v,{style:[M.gridH,{top:B(b)}]},`h${b}`)),d.map(({task:b,region:u})=>{let s=me(u),f=2*u.radius/Be,w=f*Je,C=u.state==="inside";return Q(se,{testID:`location-map-region-${vi(u.identifier)}`,accessibilityRole:"button",accessibilityLabel:`${C?"Leave":"Enter"} ${u.label??u.identifier}`,activeOpacity:.6,onPress:()=>n(b,u),style:[M.fence,C?M.fenceInside:null,{left:B(s.x-f/2),top:B(s.y-w/2),width:B(f),height:B(w)}]},`${b.name}:${u.identifier}`)}),o?ja(o.points.map(me)).map((b,u)=>Q(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${u}`)):null,c.map((b,u)=>{let s=me(b),f=!!Ce&&Ce===b.label;return pt(se,{testID:`location-map-place-${vi(b.label??String(u))}`,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:[Q(v,{style:[M.placeDot,f?M.placeDotSelected:null]}),b.label?Q(T,{style:M.placeLabel,numberOfLines:1,children:b.label}):null]},`${b.label??u}`)}),i?pt(v,{pointerEvents:"none",style:[M.pinWrap,{left:B(me(i).x),top:B(me(i).y)}],children:[Q(v,{style:M.pinHalo}),Q(v,{style:[M.pin,e.current.reason==="gap"?M.pinHollow:null]})]}):null,pt(v,{style:M.scale,pointerEvents:"none",children:[Q(v,{style:[M.scaleBar,{width:B(Xe.fraction)}]}),Q(T,{style:M.scaleLabel,children:Xe.label})]}),h>0?Q(T,{style:M.offMap,pointerEvents:"none",children:`${h} more ${h===1?"place":"places"} off the map`}):null]})})}var bi=[.2,.4,.6,.8];function B(e){return`${e*100}%`}function Ba(e){for(let t of e)if(t.regions[0])return t.regions[0];return null}function ja(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)/Je;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 Fa(e){let t=e/4,n=Ne()?1609.344:1e3,i=Ne()?[.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 vi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var M=le.create({map:{width:"100%",aspectRatio:Je,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:yi,borderWidth:2,borderColor:"#FFFFFF"},pinHollow:{backgroundColor:"transparent",borderColor:yi},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 Ye,jsx as l,jsxs as k}from"react/jsx-runtime";var wi={places:"Other Location",routes:"Route",speed:"Speed",accuracy:"Accuracy & Drift",activity:"Activity",options:"Options"},_a="#F87171",ki=[{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"}],xi=[{key:"good",label:"Good"},{key:"weak",label:"Weak"},{key:"no-signal",label:"No Signal"},{key:"off",label:"Off"}],za={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."},Ci=[{key:"5",label:"5 m"},{key:"20",label:"20 m"},{key:"65",label:"65 m"},{key:"1000",label:"1 km"}],Ii=[{key:"0",label:"Off"},{key:"10",label:"10 m"},{key:"50",label:"50 m"},{key:"200",label:"200 m"}],Wa=4;function Kt(e){let[t,n]=De(()=>Gt());return xa(()=>{if(!e)return;let i=setInterval(()=>n(Gt()),1e3);return()=>clearInterval(i)},[e]),t}function Ai({snapshot:e,onAction:t}){let n=Ea({minBottom:16}),[i,o]=De(null),[r,a]=De("main"),c=()=>a("main"),d=Ra(r==="main"?null:{title:wi[r],subtitle:"",onBack:c,searchable:false},[r]),h=(A,F)=>{o(null),t(A,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 p=i?l(ee,{tone:"danger",centered:true,children:l(T,{testID:"location-error",children:i})}):null,x=(A,F)=>{h(A,F),c()},I;switch(r){case"places":I=l(Ka,{snapshot:e,pick:x});break;case"routes":I=l(Xa,{snapshot:e,pick:x});break;case"speed":I=l(el,{snapshot:e,pick:x});break;case"accuracy":I=l(al,{snapshot:e,run:h});break;case"activity":I=l(sl,{snapshot:e,run:h});break;case"options":I=l(ul,{snapshot:e,run:h});break;default:I=k(Ye,{children:[l(Ua,{snapshot:e,run:h}),p,l(Va,{snapshot:e,run:h}),l(qa,{snapshot:e,run:h,open:a}),l(Ya,{snapshot:e,open:a}),l(nl,{snapshot:e,run:h}),l(rl,{snapshot:e,run:h,open:a}),l(ll,{snapshot:e,open:a})]})}return k(zn,{style:y.fill,contentContainerStyle:[y.content,{paddingBottom:n.bottom}],testID:"location-scroll",keyboardShouldPersistTaps:"handled",children:[r!=="main"&&!d?l(dl,{title:wi[r],onBack:c}):null,r!=="main"?p:null,I]},r)}function Ua({snapshot:e,run:t}){let n=e.override,i=n.mode==="route"?n.route:null,o=e.progress;Kt(!!i&&n.playing);let r=ia(e),a=e.current.fix,c=o&&o.length>0?Math.min(1,o.along/o.length):0,[d,h]=De(false);return k(R,{children:[k(v,{style:y.status,children:[l(T,{style:[y.statusTitle,r==="simulated"?y.titleSimulated:r==="broken"?y.titleBroken:null],testID:"location-hero-title",numberOfLines:1,adjustsFontSizeToFit:true,children:si(e)}),l(T,{style:y.statusLine,testID:"location-hero-status",children:oa(e)}),a&&e.simulating?l(se,{testID:"location-copy-coordinates",accessibilityRole:"button",accessibilityLabel:"Copy coordinates",activeOpacity:.6,onPress:()=>{$a(`${a.latitude}, ${a.longitude}`).then(p=>{p&&(h(true),setTimeout(()=>h(false),1500))})},children:l(T,{style:y.coordinates,children:d?"Copied":Fe(a,5)})}):null,i&&o?k(v,{style:y.progressTrack,testID:"location-route-progress",children:[l(v,{style:[y.progressFill,{width:`${c*100}%`}]}),(i.gaps??[]).map(([p,x],I)=>l(v,{style:[y.progressGap,{left:`${p/o.length*100}%`,width:`${(x-p)/o.length*100}%`}]},I))]}):null,e.active?k(v,{style:y.statusButtons,children:[i&&o?l(Ha,{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(Sa,{size:18,color:m.color.onAccent}):o.finished?l(Pa,{size:18,color:m.color.onAccent}):l(La,{size:18,color:m.color.onAccent})}):null,l(v,{style:y.flex,children:l(mi,{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(T,{style:y.rowTitle,children:"Permission"}),l(T,{style:[y.rowValue,e.permission.status!=="granted"?y.valueWarning:null],testID:"location-permission-value",children:ra(e.permission)})]}),e.permission.status!=="granted"?l(T,{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 Ha({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 Va({snapshot:e,run:t}){return!!e.position||e.places.length>0||e.tasks.some(n=>n.regions.length>0)?k(v,{children:[l(Da,{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 qa({snapshot:e,run:t,open:n}){let i=e.places.length>0?e.places:e.builtInPlaces.slice(0,Wa),o=e.override.mode==="fixed"?e.override.place:null,r=e.position,a=!!o&&!i.some(c=>ft(c,o));return k(v,{children:[l(Y,{children:"Location"}),l(R,{children:k(te,{children:[i.map((c,d)=>l(j,{title:c.label??Fe(c,4),value:r&&!(o&&ft(c,o))?Ga(r,c):void 0,checked:!!o&&ft(c,o),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`)),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 Ga(e,t){let n=V(e,t);return n<30?"Here":K(n)}function ft(e,t){return e.label&&t.label?e.label===t.label:V(e,t)<1}function Ka({snapshot:e,pick:t}){let[n,i]=De(""),o=vt(n),r=e.override.mode==="fixed"?e.override.place:null,a=()=>{o&&(t("setLocation",{query:n}),i(""))};return k(Ye,{children:[k(v,{children:[l(Y,{children:"Coordinates"}),l(R,{children:k(v,{style:y.editor,children:[k(v,{style:y.inputRow,children:[l(_n,{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(mi,{label:"Pin",size:"md",variant:"primary",disabled:!o,testID:"location-coordinate-set",onPress:a})]}),n.length>0?l(T,{style:o?y.detail:y.warning,testID:"location-coordinate-preview",children:o?Ja(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(R,{children:l(te,{children:e.builtInPlaces.map((c,d)=>l(j,{title:c.label??Fe(c,4),detail:c.label==="Null Island"?"0, 0: catches code that treats 0 as no location":void 0,checked:!!r&&ft(c,r),testID:`location-place-${gt(c.label??String(d))}`,onPress:()=>t("setLocation",{latitude:c.latitude,longitude:c.longitude,label:c.label})},`${c.label??d}`))})}),e.places.length===0?l(ee,{children:"Add your own places, such as your stores, with registerLocationPlaces()."}):null]})]})}function Ja(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 Ya({snapshot:e,open:t}){let n=e.override.mode==="route"?e.override.route:null;return k(v,{children:[l(Y,{children:"Movement"}),l(R,{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:Qa(n.speed),chevron:true,testID:"location-speed",onPress:()=>t("speed")},"speed"):null]})})]})}function Qa(e){let t=ki.find(n=>Math.abs(Number(n.key)-e)<.05);return t?t.label:Ut(e)}function Xa({snapshot:e,pick:t}){let n=e.override.mode==="route"?e.override.route:null,i=n?.id;return k(Ye,{children:[n?l(v,{children:l(R,{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(R,{children:l(te,{children:e.routes.map((o,r)=>l(j,{title:o.name??o.id??`Route ${r+1}`,detail:`${K(bt(o.points))} at ${Ut(o.speed)}${o.loop?", on repeat":""}`,checked:!!i&&i===o.id,testID:`location-route-${gt(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(R,{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 el({snapshot:e,pick:t}){let n=e.override.route?.speed??0;return k(v,{children:[l(R,{children:l(te,{children:ki.map(i=>l(j,{title:i.label,value:Ut(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 tl=1e4;function nl({snapshot:e,run:t}){let n=e.tasks.filter(d=>d.kind==="geofencing"&&d.regions.length>0),[i,o]=De(null),r=Kt(!!i);if(n.length===0)return null;let a=n.length>1,c=n.map(d=>d.name).join(", ");return k(v,{children:[l(Y,{children:"Geofences"}),l(R,{children:l(te,{children:n.flatMap(d=>d.regions.map(h=>{let p=`${d.name}:${h.identifier}`,x=h.state==="inside",I=i?.key===p&&r-i.at<tl?i:null,A=[il(h)];return a&&A.push(d.name),l(j,{title:h.label??h.identifier,detail:A.join(" \xB7 "),note:I?ol(e,d,I.at):void 0,action:x?"Leave":"Enter",testID:`location-region-${gt(h.identifier)}`,onPress:()=>{o({key:p,at:Gt()}),t(x?"exitRegion":"enterRegion",{identifier:h.identifier,task:d.name})}},p)}))})}),k(ee,{children:["Tap a region to cross its edge. ",a?"The app's tasks":`The app's ${c} task`," runs as it would from the OS."]})]})}function il(e){return e.state==="inside"?"Inside":e.distance==null?`${K(e.radius)} radius`:`${K(Math.max(0,e.distance-e.radius))} away`}function ol(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 rl({snapshot:e,run:t,open:n}){let i=e.override,o=Vi(i),r=e.simulating?xi:xi.filter(a=>a.key!=="weak");return k(v,{children:[l(Y,{children:"Conditions"}),k(R,{children:[l(v,{style:y.segmentWrap,children:l(qt,{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:`${li(i.accuracy)}${i.jitter>0?` \xB7 drifts ${K(i.jitter)}`:""}`,chevron:true,testID:"location-accuracy",onPress:()=>n("accuracy")})}):null]}),l(ee,{children:za[o??"custom"]})]})}function al({snapshot:e,run:t}){let n=e.override;return k(Ye,{children:[k(v,{children:[l(Y,{children:"Accuracy"}),l(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ci,activeKey:Si(Ci,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(R,{children:l(v,{style:y.segmentWrap,children:l(qt,{tabs:Ii,activeKey:Si(Ii,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 ll({snapshot:e,open:t}){let n=e.log.length;return l(v,{children:l(R,{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 sl({snapshot:e,run:t}){let n=Kt(true),i=e.log.slice().reverse(),o=e.watches.filter(d=>d.kind==="position").length,r=e.tasks.filter(d=>d.kind==="locationUpdates").length,a=e.tasks.filter(d=>d.kind==="geofencing").reduce((d,h)=>d+h.regions.length,0),c=[o?`${o} location ${o===1?"watch":"watches"}`:null,a?`${a} ${a===1?"geofence":"geofences"}`:null,r?"background updates":null].filter(Boolean);return k(Ye,{children:[k(v,{children:[l(Y,{children:"The App Is Using"}),l(R,{children:k(v,{style:y.editor,children:[l(T,{style:y.rowTitle,testID:"location-activity-summary",children:c.length?c.join(", "):"Nothing right now"}),l(T,{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(R,{children:k(te,{children:[i.length===0?l(v,{style:y.editor,children:l(T,{style:y.detail,children:"Location requests, watches and geofence crossings show up here."})},"empty"):i.map(d=>k(v,{style:y.logRow,testID:"location-log-entry",children:[l(v,{style:[y.logDot,cl(d.kind)]}),k(v,{style:y.flex,children:[l(T,{style:y.logText,children:d.text}),d.detail?l(T,{style:y.logDetail,numberOfLines:2,children:d.detail}):null]}),l(T,{style:y.logWhen,children:na(d.at,n)})]},d.id)),i.length>0?l(j,{title:"Clear",tint:true,testID:"location-clear-log",onPress:()=>t("clearLog")},"clear"):null]})})]})]})}function cl(e){return e==="enter"?y.dotEnter:e==="exit"?y.dotExit:e==="error"?y.dotError:e==="task"?y.dotTask:null}function ul({snapshot:e,run:t}){return k(v,{children:[l(R,{children:k(te,{children:[l(Ti,{title:"Keep Across Reloads",value:e.settings.persist,testID:"location-setting-persist",onValueChange:n=>t("updateSettings",{persist:n})},"persist"),l(Ti,{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 dl({title:e,onBack:t}){return k(se,{testID:"location-back",accessibilityRole:"button",accessibilityLabel:"Back",activeOpacity:.6,onPress:t,style:y.backRow,children:[l(Ia,{size:18,color:m.color.accent}),l(T,{style:y.backLabel,children:"Location"}),l(T,{style:y.backTitle,numberOfLines:1,children:e})]})}function j({title:e,detail:t,note:n,value:i,action:o,checked:r,chevron:a,tint:c,onPress:d,testID:h}){return k(se,{testID:h,accessibilityRole:"button",accessibilityLabel:o?`${o} ${e}`:e,accessibilityState:r?{selected:true}:void 0,activeOpacity:.6,onPress:d,style:y.row,children:[k(v,{style:y.rowText,children:[l(T,{style:[y.rowTitle,c?y.titleTint:null],numberOfLines:1,children:e}),t?l(T,{style:y.detail,children:t}):null,n?l(T,{style:[y.note,n.tone==="ok"?y.noteOk:n.tone==="bad"?y.noteBad:null],testID:`${h}-result`,children:n.text}):null]}),i?l(T,{style:y.rowValue,numberOfLines:1,children:i}):null,o?l(T,{style:y.rowAction,children:o}):null,r?l(Ca,{size:18,color:m.color.accent}):null,a?l(Aa,{size:16,color:m.color.textTertiary}):null]})}function Ti({title:e,value:t,onValueChange:n,testID:i}){return k(v,{style:y.row,children:[l(v,{style:y.rowText,children:l(T,{style:y.rowTitle,children:e})}),l(Ta,{value:t,testID:i,accessibilityLabel:e,onValueChange:n})]})}function Si(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 gt(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:_a},statusLine:{color:m.color.textSecondary,fontSize:m.font.row,fontVariant:["tabular-nums"]},coordinates:{color:m.color.textTertiary,fontSize:m.font.caption,fontFamily:Ma},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 Li}from"react/jsx-runtime";var pl=Vt.actions;async function fl(e,t){let n=pl[e];if(!n)throw new Error(`Unknown location action: ${e}`);return n(t)}var Jt=()=>Vt.getSnapshot(),gl=2e3;function Pi(){let[e,t]=ha(Jt);return ga(()=>{zt(),Rt(),t(Jt()),pi(true),rt();let n=setInterval(rt,gl),i=Ue(()=>t(Jt()));return()=>{clearInterval(n),i(),pi(false)}},[]),Li(ma,{featureName:"Location",children:Li(Ai,{snapshot:e,onAction:fl})})}import{jsx as hl}from"react/jsx-runtime";var $i=fa({id:"location",name:"LOCATION",description:"Pin the app anywhere, play routes, trigger geofences",slot:"both",color:da,icon:({size:e,color:t})=>hl(ua,{size:e,color:t}),component:Pi,modal:{subtitle:"simulate where the app is"}}),ml=pa($i);import{LocationToolIcon as yl,LOCATION_TOOL_ICON_COLOR as bl}from"@buoy-gg/shared-ui/web";var vl=typeof navigator<"u"&&navigator.product==="ReactNative",wl=(()=>{try{return globalThis.Capacitor?.isNativePlatform?.()===true}catch{return false}})();(vl||wl)&&(ca(),typeof Xt<"u"&&Xt&&(zt(),Rt()));export{dt as BUILT_IN_PLACES,ut as LOCATION_CHIP_ID,bl as LOCATION_TOOL_ICON_COLOR,Pi as LocationBody,fi as LocationChip,yl as LocationToolIcon,Ai as LocationToolView,Oe as ROUTE_PRESETS,Ze as bearingDegrees,Rt as bootLocation,gi as buildPresetRoute,ml as createLocationTool,je as destination,V as distanceMeters,E as getLocationSnapshot,zt as installLocationAdapters,P as isLocationActive,Vt as locationSyncAdapter,$i as locationToolPreset,Mt as moveToRegion,vt as parseCoordinate,Pt as pauseRoute,rt as refreshLocationPermission,ao as registerLocationPlaces,lo as registerLocationRoutes,Et as resetLocation,$t as resumeRoute,In as seekRoute,Pn as setConditions,ct as setPlace,An as setRouteSpeed,Ln as setServices,Sn as setSignal,Cn as startRoute,$n as stopRoute,Ue as subscribeLocation,Tn as tuneOverride,Mn 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.64",
|
|
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,17 +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.64"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@buoy-gg/license": "7.0.
|
|
23
|
+
"@buoy-gg/license": "7.0.64",
|
|
24
24
|
"react": "*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/react": "^19.1.0",
|
|
28
28
|
"@types/react-native": "^0.73.0",
|
|
29
29
|
"typescript": "~5.8.3",
|
|
30
|
-
"@buoy-gg/license": "^7.0.
|
|
30
|
+
"@buoy-gg/license": "^7.0.64"
|
|
31
31
|
},
|
|
32
32
|
"react-native-builder-bob": {
|
|
33
33
|
"source": "src",
|