@tempo-kit/plugin-spatial 0.0.0-stage → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +111 -2
- package/dist/index.d.ts +66 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +620 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +623 -0
- package/package.json +64 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the `@tempo-kit/plugin-spatial` project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-spatial` to `@tempo-kit/plugin-spatial`.
|
|
12
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
13
|
+
|
|
14
|
+
## [2.0.0] - 2026-11-27
|
|
15
|
+
|
|
16
|
+
### Breaking Changes
|
|
17
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-spatial` to `@tempo-kit/plugin-spatial`.
|
|
18
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
19
|
+
|
|
20
|
+
## [1.0.1] - 2026-10-03
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **Internal Cleanups & Compatibility**:
|
|
24
|
+
- Replaced prototype `Object.hasOwn` with the unified `hasOwn` helper from `@magmacomputing/tempo/plugin/sdk`.
|
|
25
|
+
- Added comprehensive documentation for geofencing, solar offset, navigation, and transit use cases.
|
|
26
|
+
|
|
27
|
+
## [1.0.0] - 2026-09-27
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **GIS & Spatial Navigation Plugin (`@tempo-kit/plugin-spatial`)**:
|
|
31
|
+
- `Tempo.spatial` Deep-Frozen Static Namespace:
|
|
32
|
+
- `distance(from, to, unit?)`: Great-Circle spherical distance calculation in `km`, `miles`, or `m` (Haversine formula).
|
|
33
|
+
- `bearing(from, to, options?)`: Initial forward azimuth compass bearing (0° to 360° True North).
|
|
34
|
+
- `midpoint(from, to)`: Great-Circle geographic midpoint with automatic hemisphere inference.
|
|
35
|
+
- `velocity(from, to, options?)`: Transit travel velocity between timestamped instances or coordinate objects in `km/h`, `mph`, or `m/s`.
|
|
36
|
+
- `isImpossibleTravel(from, to, options?)`: Physical travel feasibility evaluation against commercial aviation thresholds (default: 900 km/h) for cybersecurity anomaly detection.
|
|
37
|
+
- `isWithin(from, to, maxDistance, unit?)`: Radial proximity query evaluating whether coordinates are within a specified distance.
|
|
38
|
+
- `inBoundingBox(coords, bbox)`: Spatial containment query testing containment within rectangular bounding boxes (with antimeridian 180° wrap support).
|
|
39
|
+
- `solarOffset(coords, options?)`: Natural solar time offset between civil clock time and actual solar noon.
|
|
40
|
+
- Fluent `Tempo` OOP Instance Methods:
|
|
41
|
+
- `t.spatialDistance(to, unit?)`: Computes distance from current instance coordinates to target coordinates.
|
|
42
|
+
- `t.spatialBearing(to, options?)`: Computes compass bearing from current instance coordinates to target coordinates.
|
|
43
|
+
- `t.spatialVelocity(to, options?)`: Computes travel speed from current instance to target timestamped instance.
|
|
44
|
+
- `t.spatialSolarOffset(options?)`: Calculates solar time offset for current instance coordinates.
|
|
45
|
+
- `t.isWithin(to, maxDistance, unit?)`: Evaluates if current instance is within proximity radius of target coordinates.
|
|
46
|
+
- `t.inBoundingBox(bbox)`: Evaluates if current instance coordinates fall within bounding box.
|
|
47
|
+
- Side-Effect Auto-Installation Subpath:
|
|
48
|
+
- Dedicated `@tempo-kit/plugin-spatial/install` subpath for one-line side-effect installation (`import '@tempo-kit/plugin-spatial/install'`).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magma Computing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tempo-kit/plugin-spatial
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@tempo-kit/plugin-spatial"><img src="https://img.shields.io/npm/v/@tempo-kit/plugin-spatial?style=flat-square" alt="npm version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/tempo-kit"><img src="https://img.shields.io/npm/dependency-version/@tempo-kit/plugin-spatial/peer/tempo-kit?style=flat-square" alt="npm peer dependency version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@tempo-kit/plugin-spatial"><img src="https://img.shields.io/npm/l/@tempo-kit/plugin-spatial?style=flat-square" alt="License" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square" alt="TypeScript Ready" style="display: inline-block; margin: 0 4px;"></a> <a href="https://magmacomputing.github.io/magma/doc/9-plugins/spatial.index.html"><img src="https://img.shields.io/badge/Docs-VitePress-brightgreen?logo=vitepress&style=flat-square" alt="Documentation" style="display: inline-block; margin: 0 4px;"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
A Community plugin for the [Tempo](https://github.com/magmacomputing/magma) ecosystem providing GIS spatial geometry, Great-Circle navigation, transit velocity, impossible travel anomaly detection, spatial geofencing, and natural solar time offset calculations.
|
|
10
|
+
|
|
11
|
+
📖 **[Read the Official Spatial Plugin Documentation](https://magmacomputing.github.io/magma/doc/9-plugins/spatial.index.html)**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @tempo-kit/plugin-spatial
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Register Plugin
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Tempo } from 'tempo-kit';
|
|
29
|
+
import { SpatialPlugin } from '@tempo-kit/plugin-spatial';
|
|
30
|
+
|
|
31
|
+
Tempo.use(SpatialPlugin);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or with zero-boilerplate side-effect auto-installation:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import '@tempo-kit/plugin-spatial/install';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### 2. Static Namespace (`Tempo.spatial.*`)
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { Tempo } from 'tempo-kit';
|
|
46
|
+
|
|
47
|
+
const sydney = { lat: -33.8688, lng: 151.2093 };
|
|
48
|
+
const melbourne = { lat: -37.8136, lng: 144.9631 };
|
|
49
|
+
|
|
50
|
+
// Great-Circle Distance (Haversine formula)
|
|
51
|
+
const distKm = Tempo.spatial.distance(sydney, melbourne, 'km'); // 713.435 km
|
|
52
|
+
|
|
53
|
+
// Compass Bearing
|
|
54
|
+
const bearing = Tempo.spatial.bearing(sydney, melbourne); // 230.2° (SW)
|
|
55
|
+
|
|
56
|
+
// Geographic Midpoint
|
|
57
|
+
const mid = Tempo.spatial.midpoint(sydney, melbourne);
|
|
58
|
+
// { latitude: -35.856, longitude: 148.012, sphere: 'south' }
|
|
59
|
+
|
|
60
|
+
// Radial Proximity Geofencing
|
|
61
|
+
const nearby = Tempo.spatial.isWithin(sydney, melbourne, 800, 'km'); // true
|
|
62
|
+
|
|
63
|
+
// Bounding Box Containment (with Antimeridian wrap support)
|
|
64
|
+
const inside = Tempo.spatial.inBoundingBox(sydney, {
|
|
65
|
+
minLat: -40,
|
|
66
|
+
maxLat: -30,
|
|
67
|
+
minLng: 140,
|
|
68
|
+
maxLng: 160,
|
|
69
|
+
}); // true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> ⚡ **[Try this live in the interactive Tempo Sandbox ↗](https://magmacomputing.github.io/magma/repl/index.html?plugin=spatial)**
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 3. Transit Velocity & Impossible Travel Anomaly Detection
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const login1 = new Tempo('2026-06-21T10:00:00Z', {
|
|
80
|
+
geo: { lat: 51.5074, lng: -0.1278 }, // London
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const login2 = new Tempo('2026-06-21T11:00:00Z', {
|
|
84
|
+
geo: { lat: 40.7128, lng: -74.0060 }, // New York (1 hour later)
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Travel speed calculation
|
|
88
|
+
const speed = Tempo.spatial.velocity(login1, login2); // 5570.22 km/h
|
|
89
|
+
|
|
90
|
+
// Impossible travel anomaly detection against commercial aviation threshold (default: 900 km/h)
|
|
91
|
+
const isAnomalous = Tempo.spatial.isImpossibleTravel(login1, login2); // true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### 4. Fluent OOP Instance Methods
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const t1 = new Tempo('2026-06-21T12:00:00Z', {
|
|
100
|
+
geo: { lat: -33.8688, lng: 151.2093 },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const dist = t1.spatialDistance({ lat: -37.8136, lng: 144.9631 });
|
|
104
|
+
const bearing = t1.spatialBearing({ lat: -37.8136, lng: 144.9631 });
|
|
105
|
+
const isClose = t1.isWithin({ lat: -33.87, lng: 151.21 }, 5, 'km');
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
This is a **Community** plugin. It is completely free and open-source for personal and commercial use under the MIT license.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type TempoPlugin } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { haversineDistance, calculateBearing, calculateMidpoint, calculateVelocity, isImpossibleTravel, isWithin, inBoundingBox, solarOffset, resolveCulturalLocale, type DistanceUnit, type TimeUnit, type BearingOptions, type VelocityOptions, type ImpossibleTravelOptions, type BoundingBox, type SolarOffsetOptions, type SolarOffsetUnit, type GeoSphere, type CoordinateInput } from 'tempo-fns';
|
|
3
|
+
export { haversineDistance, calculateBearing, calculateMidpoint, calculateVelocity, isImpossibleTravel, isWithin, inBoundingBox, solarOffset, resolveCulturalLocale, };
|
|
4
|
+
export type { DistanceUnit, TimeUnit, BearingOptions, VelocityOptions, ImpossibleTravelOptions, BoundingBox, SolarOffsetOptions, SolarOffsetUnit, GeoSphere, CoordinateInput, };
|
|
5
|
+
/**
|
|
6
|
+
* Cohesive static namespace for GIS geometry, Great-Circle navigation, and spatial queries.
|
|
7
|
+
*/
|
|
8
|
+
export interface TempoSpatialNamespace {
|
|
9
|
+
/** Calculates the Great-Circle distance between two coordinates using the Haversine formula (km, miles, or m) */
|
|
10
|
+
readonly distance: typeof haversineDistance;
|
|
11
|
+
/** Computes the initial forward azimuth compass bearing in degrees (0° to 360° True North) along the Great-Circle route */
|
|
12
|
+
readonly bearing: typeof calculateBearing;
|
|
13
|
+
/** Computes the Great-Circle geographic midpoint between two coordinates with automatic hemisphere inference */
|
|
14
|
+
readonly midpoint: typeof calculateMidpoint;
|
|
15
|
+
/** Calculates the travel speed between two timestamped instances or coordinate objects (km/h, mph, or m/s) */
|
|
16
|
+
readonly velocity: typeof calculateVelocity;
|
|
17
|
+
/** Evaluates impossible travel anomalies between timestamped events based on commercial aviation velocity thresholds */
|
|
18
|
+
readonly isImpossibleTravel: typeof isImpossibleTravel;
|
|
19
|
+
/** Evaluates whether two coordinates are within a specified distance threshold */
|
|
20
|
+
readonly isWithin: typeof isWithin;
|
|
21
|
+
/** Evaluates whether coordinates fall within a rectangular geographic bounding box */
|
|
22
|
+
readonly inBoundingBox: typeof inBoundingBox;
|
|
23
|
+
/** Calculates natural solar time offset between civil clock time and actual solar noon */
|
|
24
|
+
readonly solarOffset: typeof solarOffset;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for configuring the Spatial plugin.
|
|
28
|
+
*/
|
|
29
|
+
export type SpatialPluginOptions = Record<string, any>;
|
|
30
|
+
/**
|
|
31
|
+
* SpatialPlugin installs GIS geometry, Great-Circle navigation, and spatial queries onto Tempo under the `Tempo.spatial` namespace.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SpatialPlugin: TempoPlugin<SpatialPluginOptions>;
|
|
34
|
+
export declare const spatialPlugin: TempoPlugin<SpatialPluginOptions>;
|
|
35
|
+
export default SpatialPlugin;
|
|
36
|
+
declare module 'tempo-kit' {
|
|
37
|
+
interface Tempo {
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the Great-Circle distance from this instance to target coordinates.
|
|
40
|
+
*/
|
|
41
|
+
spatialDistance(to: any, unit?: DistanceUnit): number;
|
|
42
|
+
/**
|
|
43
|
+
* Computes the initial forward compass bearing in degrees (0° to 360°) from this instance to target coordinates.
|
|
44
|
+
*/
|
|
45
|
+
spatialBearing(to: any, options?: BearingOptions): number;
|
|
46
|
+
/**
|
|
47
|
+
* Calculates travel velocity from this instance to target timestamped instance.
|
|
48
|
+
*/
|
|
49
|
+
spatialVelocity(to: any, options?: VelocityOptions): number;
|
|
50
|
+
/**
|
|
51
|
+
* Calculates natural solar time offset for this instance's coordinates.
|
|
52
|
+
*/
|
|
53
|
+
spatialSolarOffset(options?: SolarOffsetOptions): number;
|
|
54
|
+
/**
|
|
55
|
+
* Evaluates whether this instance is within a specified proximity distance to target coordinates.
|
|
56
|
+
*/
|
|
57
|
+
isWithin(to: any, maxDistance: number, unit?: DistanceUnit): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Evaluates whether this instance's coordinates fall within a rectangular bounding box.
|
|
60
|
+
*/
|
|
61
|
+
inBoundingBox(bbox: BoundingBox): boolean;
|
|
62
|
+
}
|
|
63
|
+
namespace Tempo {
|
|
64
|
+
let spatial: TempoSpatialNamespace;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Magma;((Magma||={}).plugins||={}).spatial=(()=>{var ce=Object.create;var Z=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var ue=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}},Q=(e,n)=>{for(var t in n)Z(e,t,{get:n[t],enumerable:!0})},w=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of fe(n))!de.call(e,r)&&r!==t&&Z(e,r,{get:()=>n[r],enumerable:!(o=le(n,r))||o.enumerable});return e},P=(e,n,t)=>(w(e,n,"default"),t&&w(t,n,"default")),ee=(e,n,t)=>(t=e!=null?ce(me(e)):{},w(n||!e||!e.__esModule?Z(t,"default",{value:e,enumerable:!0}):t,e)),pe=e=>w(Z({},"__esModule",{value:!0}),e);var G=ue((De,te)=>{"use strict";te.exports=window.Magma.pluginSdk});var Se={};Q(Se,{SpatialPlugin:()=>q,calculateBearing:()=>E,calculateMidpoint:()=>B,calculateVelocity:()=>N,default:()=>xe,haversineDistance:()=>S,inBoundingBox:()=>C,isImpossibleTravel:()=>U,isWithin:()=>R,resolveCulturalLocale:()=>W,solarOffset:()=>A,spatialPlugin:()=>Me});var g={};Q(g,{definePlugin:()=>k,defineTerm:()=>ge});P(g,ee(G()));var F=ee(G()),k=e=>(0,F.definePlugin)({...e,version:"2.0.0-rc.0"}),ge=e=>(0,F.defineTerm)({...e,version:"2.0.0-rc.0"});var s=e=>typeof e=="number"&&Number.isFinite(e),u=e=>typeof e=="string",Y=e=>u(e)&&e.trim().length>0,ne=e=>e===!0||e===!1,O=e=>typeof e=="function",x=e=>e==null,h=e=>!x(e),V=e=>e===void 0;var K=e=>e instanceof Date&&s(e.getTime()),he=e=>e===null||typeof e!="object"&&!O(e),z=e=>h(e)&&typeof e=="object"&&!Array.isArray(e),T=e=>!he(e);var L=e=>{if(x(e)||ne(e))return NaN;if(u(e)){let n=e.trim();return n.length>0?Number(n):NaN}return s(e)?e:NaN},oe=(e,n=!1)=>{let t=L(e);if(!(!s(t)||t<-90||t>90))return n?Math.round(t*1e3)/1e3:t},re=(e,n=!1)=>{let t=L(e);if(!(!s(t)||t<-180||t>180))return n?Math.round(t*1e3)/1e3:t},I=(e,n,t=!1)=>{let o=oe(e,t),r=re(n,t);return h(o)&&h(r)?{lat:o,lng:r}:void 0};function M(e,n){if(!x(e)){if(s(e)&&s(n)){let t=I(e,n,!1);return t?{...t,elevation:0}:void 0}if(u(e)&&e.includes(",")){let t=e.split(",").map(o=>o.trim());if(t.length>=2){let o=I(t[0],t[1],!1),r=t.length>=3?L(t[2]):void 0;return o?{...o,...s(r)?{elevation:r}:{}}:void 0}return}if(Array.isArray(e)&&e.length>=2){let t=I(e[0],e[1],!1),o=e.length>=3?L(e[2]):void 0;return t?{...t,...s(o)?{elevation:o}:{}}:void 0}if(T(e)||z(e)){let t=e.geo??e.config?.geo??e,o=e.config?.geo??e.config,r=(...c)=>{for(let m of c){let d=L(m);if(s(d))return d}},i=r(t?.latitude,t?.lat,e.latitude,e.lat,o?.latitude,o?.lat),a=r(t?.longitude,t?.lng,t?.lon,t?.long,e.longitude,e.lng,e.lon,e.long,o?.longitude,o?.lng,o?.lon,o?.long),l=r(t?.elevation,e.elevation,o?.elevation),f=I(i,a,!1);return f?{...f,...s(l)?{elevation:l}:{}}:void 0}}}function D(e){if(!x(e)){if(s(e))return e;if(K(e))return e.getTime();if(z(e)){if(s(e.epoch?.ms))return e.epoch.ms;if(s(e.epochMilliseconds))return e.epochMilliseconds;if(s(e.timestamp))return e.timestamp;if(K(e.date))return e.date.getTime();if(O(e.toInstant))try{let n=e.toInstant().epochMilliseconds;if(s(n))return n}catch{}if(O(e.getTime))try{let n=e.getTime();if(s(n))return n}catch{}}if(u(e)){let n=Date.parse(e.trim());if(s(n))return n}}}function ie(e){let n=M(e);if(V(n))return;let t=I(n.lat,n.lng,!0);if(V(t))return;let{lat:o,lng:r}=t,i=o>.001?"north":o<-.001?"south":"equator",a=T(e)?e.geo??e.config?.geo??e:{};return{latitude:o,longitude:r,sphere:a?.sphere??i,...u(a?.country)?{country:a.country}:{},...u(a?.city)?{city:a.city}:{},...s(a?.elevation)?{elevation:Math.round(a.elevation*1e3)/1e3}:{},...u(a?.timezone)?{timezone:a.timezone}:{}}}function b(e,n){let t=M(e),o=M(n);if(!t||!o||!s(t.lat)||!s(t.lng)||!s(o.lat)||!s(o.lng))return;let r=Math.PI/180,i=t.lat*r,a=t.lng*r,l=o.lat*r,f=o.lng*r;return{lat1:i,lat2:l,lng1:a,lng2:f,dLat:l-i,dLng:f-a}}function S(e,n,t="km"){let o=b(e,n);if(!o)return NaN;let{lat1:r,lat2:i,dLat:a,dLng:l}=o,f=Math.sin(a/2)**2+Math.cos(r)*Math.cos(i)*Math.sin(l/2)**2,c=2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),d=(t==="miles"?3958.7613:t==="m"?63710088e-1:6371.0088)*c;return t==="m"?Math.round(d):Math.round(d*1e3)/1e3}function E(e,n,t){let o=b(e,n);if(!o)return NaN;let{lat1:r,lat2:i,dLng:a}=o,l=Math.sin(a)*Math.cos(i),f=Math.cos(r)*Math.sin(i)-Math.sin(r)*Math.cos(i)*Math.cos(a),c=(Math.atan2(l,f)*(180/Math.PI)+360)%360,m=t?.precision??1,d=Math.pow(10,m);return Math.round(c*d)/d}function B(e,n){let t=b(e,n);if(!t)return;let{lat1:o,lat2:r,lng1:i,dLng:a}=t,l=Math.cos(r)*Math.cos(a),f=Math.cos(r)*Math.sin(a),c=Math.atan2(Math.sin(o)+Math.sin(r),Math.sqrt((Math.cos(o)+l)**2+f**2)),m=i+Math.atan2(f,Math.cos(o)+l),d=Math.round(c*180/Math.PI*1e3)/1e3,p=Math.round(((m*180/Math.PI+540)%360-180)*1e3)/1e3,y=d>.001?"north":d<-.001?"south":"equator";return{latitude:d,longitude:p,sphere:y}}function N(e,n,t){let o=u(t)?{unit:t}:t??{},r=o.unit??"km",i=o.timeUnit??"hh",a=S(e,n,r);if(isNaN(a))return NaN;let l=D(e),f=D(n);if(!s(l)||!s(f))return NaN;let c=Math.abs(f-l);if(c===0)return a===0?0:1/0;let m;i==="ss"||i==="s"||i==="seconds"||i==="second"?m=c/1e3:i==="mi"||i==="m"||i==="minutes"||i==="minute"?m=c/6e4:m=c/36e5;let d=a/m,p=o.precision??2,y=Math.pow(10,p);return Math.round(d*y)/y}function U(e,n,t){let o=t?.unit??"km",r=o==="miles"?560:o==="m"?250:900,i;h(t?.maxCommercialSpeedKmH)?o==="miles"?i=t.maxCommercialSpeedKmH*.621371:o==="m"?i=t.maxCommercialSpeedKmH*1e3/3600:i=t.maxCommercialSpeedKmH:i=r;let a=t?.maxSpeed??i;return N(e,n,{unit:o,timeUnit:o==="m"?"ss":"hh"})>a}function R(e,n,t,o="km"){if(!s(t)||t<0)return!1;let r=M(e),i=M(n);if(!r||!i||!s(r.lat)||!s(r.lng)||!s(i.lat)||!s(i.lng))return!1;let a=Math.PI/180,l=r.lat*a,f=r.lng*a,c=i.lat*a,m=i.lng*a,d=c-l,p=m-f,y=Math.sin(d/2)*Math.sin(d/2)+Math.cos(l)*Math.cos(c)*Math.sin(p/2)*Math.sin(p/2),v=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y));return(o==="miles"?3958.7613:o==="m"?63710088e-1:6371.0088)*v<=t}function C(e,n){let t=M(e);if(!t||!s(t.lat)||!s(t.lng)||x(n))return!1;let o,r,i,a;if(Array.isArray(n)&&n.length>=4)o=n[0],i=n[1],r=n[2],a=n[3];else if(T(n)){let c=n;o=c.minLat??c.minLatitude,r=c.maxLat??c.maxLatitude,i=c.minLng??c.minLongitude,a=c.maxLng??c.maxLongitude}if(!s(o)||!s(r)||!s(i)||!s(a))return!1;let l=t.lat,f=t.lng;return l<o||l>r?!1:i<=a?f>=i&&f<=a:f>=i||f<=a}var ye=/GMT([+-])(\d{2}):(\d{2})/,Te=(e,n)=>{try{let t=globalThis.Temporal;if(t&&O(t.Instant?.fromEpochMilliseconds))return t.Instant.fromEpochMilliseconds(n).toZonedDateTimeISO(e).offsetNanoseconds/6e10;let r=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset",year:"numeric"}).formatToParts(new Date(n)).find(i=>i.type==="timeZoneName")?.value;if(r){if(r==="GMT"||r==="UTC")return 0;let i=r.match(ye);if(i)return(i[1]==="-"?-1:1)*(parseInt(i[2],10)*60+parseInt(i[3],10))}}catch{}};function A(e,n){let t=ie(e);if(!t||!s(t.latitude)||!s(t.longitude))return NaN;let o=t.longitude,r=n?.timeZone??(T(e)?e.timezone??e.tz:void 0)??t.timezone,i=n?.date??(T(e)?D(e):void 0),a=h(i)?D(i):Date.now();if(!s(a))return NaN;let l=Y(r)?Te(r,a):void 0,f=h(l)?l/60*15:Math.round(o/15)*15,m=(o-f)*4;if(n?.apparent){let X=new Date(a),J=Date.UTC(X.getUTCFullYear(),0,1),ae=Math.floor((a-J)/864e5)+1,_=2*Math.PI/365*(ae-1),se=229.18*(75e-6+.001868*Math.cos(_)-.032077*Math.sin(_)-.014615*Math.cos(2*_)-.040849*Math.sin(2*_));m+=se}let d=n?.unit??"mi",p;d==="ss"||d==="seconds"?p=m*60:d==="hh"||d==="hours"?p=m/60:p=m;let y=n?.precision??2,v=Math.pow(10,y);return Math.round(p*v)/v}var j={australia:"AU","united states":"US","united kingdom":"GB","great britain":"GB",france:"FR",germany:"DE",italy:"IT",spain:"ES",japan:"JP",china:"CN",canada:"CA",brazil:"BR",egypt:"EG","saudi arabia":"SA",russia:"RU",india:"IN",mexico:"MX","new zealand":"NZ",netherlands:"NL",switzerland:"CH",austria:"AT",belgium:"BE",sweden:"SE",norway:"NO",denmark:"DK",finland:"FI",poland:"PL",turkey:"TR",greece:"GR",israel:"IL",thailand:"TH",vietnam:"VN",indonesia:"ID",malaysia:"MY",philippines:"PH","south africa":"ZA","south korea":"KR",korea:"KR",ireland:"IE",portugal:"PT",argentina:"AR"},$={AU:"en-AU",US:"en-US",GB:"en-GB",CA:"en-CA",NZ:"en-NZ",IE:"en-IE",SA:"ar-SA",AE:"ar-AE",EG:"ar-EG",JP:"ja-JP",CN:"zh-CN",TW:"zh-TW",HK:"zh-HK",KR:"ko-KR",FR:"fr-FR",DE:"de-DE",IT:"it-IT",ES:"es-ES",MX:"es-MX",AR:"es-AR",BR:"pt-BR",PT:"pt-PT",RU:"ru-RU",IN:"hi-IN",NL:"nl-NL",SE:"sv-SE",NO:"nb-NO",DK:"da-DK",FI:"fi-FI",PL:"pl-PL",TR:"tr-TR",GR:"el-GR",IL:"he-IL",TH:"th-TH",VN:"vi-VN",ID:"id-ID",MY:"ms-MY",PH:"fil-PH",ZA:"en-ZA",CH:"de-CH",AT:"de-AT",BE:"nl-BE"};function H(e){try{let n=new Intl.Locale(e);return{language:n.language,script:n.script||void 0,baseName:n.baseName}}catch{let n=e.split("-");return{language:n[0]?.toLowerCase(),script:n.length>2?n[1]:void 0,baseName:e}}}function W(e,n,t=!0){if(t===!1||t==="none"||t==="off")return;let o=c=>{let m=c.trim();return m.length===2?m.toUpperCase():j[m.toLowerCase()]},r;if(Array.isArray(n)){for(let c of n)if(u(c)){let m=o(c);if(m){r=m;break}}}else u(n)&&(r=o(n));if(u(t)&&t!=="regional"&&t!=="region"&&t!=="native"&&t!=="full")return H(t)?.baseName??t;if(!r)return;if(t==="native"||t==="full"){let c=$[r]??`en-${r}`;return H(c)?.baseName??c}let i="en",a;if(Y(e)){let c=H(e);i=c?.language??e.split("-")[0]??"en",c?.script&&(a=c.script)}let l=a?`${i}-${a}-${r}`:`${i}-${r}`;return H(l)?.baseName??l}var q=k({name:"spatial",install(e){let n=e||this;(0,g.hasOwn)(n,"spatial")||Object.defineProperty(n,"spatial",{value:(0,g.deepFreeze)({distance:S,bearing:E,midpoint:B,velocity:N,isImpossibleTravel:U,isWithin:R,inBoundingBox:C,solarOffset:A}),writable:!1,configurable:!1,enumerable:!1}),e.prototype.spatialDistance=function(t,o="km"){return S(this,t,o)},e.prototype.spatialBearing=function(t,o){return E(this,t,o)},e.prototype.spatialVelocity=function(t,o){return N(this,t,o)},e.prototype.spatialSolarOffset=function(t){return A(this,t)},e.prototype.isWithin=function(t,o,r="km"){return R(this,t,o,r)},e.prototype.inBoundingBox=function(t){return C(this,t)}}}),Me=q,xe=q;return pe(Se);})();
|