atriusmaps-node-sdk 3.3.196 → 3.3.225

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/cjs/_virtual/_empty_module_placeholder.js +2 -2
  2. package/dist/cjs/deploy/prepareSDKConfig.js +152 -2
  3. package/dist/cjs/nodesdk/nodeEntry.js +109 -0
  4. package/dist/cjs/package.json.js +190 -14
  5. package/dist/cjs/plugins/clientAPI/src/clientAPI.js +11 -2
  6. package/dist/cjs/plugins/dynamicPois/src/dynamicPois.js +218 -21
  7. package/dist/cjs/plugins/poiDataManager/src/poiDataManager.js +292 -21
  8. package/dist/cjs/plugins/sdkServer/src/sdkHeadless.js +99 -20
  9. package/dist/cjs/plugins/sdkServer/src/sdkServer.js +219 -2
  10. package/dist/cjs/plugins/sdkServer/src/util.js +16 -3
  11. package/dist/cjs/plugins/searchService/src/poiSearch.js +57 -19
  12. package/dist/cjs/plugins/searchService/src/searchService.js +246 -21
  13. package/dist/cjs/plugins/searchService/src/searchTypeahead.js +60 -3
  14. package/dist/cjs/plugins/searchService/src/utils.js +23 -4
  15. package/dist/cjs/plugins/venueDataLoader/src/venueDataLoader.js +472 -21
  16. package/dist/cjs/plugins/venueDataLoader/src/venueLoadingUtils.js +191 -23
  17. package/dist/cjs/plugins/wayfinder/src/findRoute.js +147 -19
  18. package/dist/cjs/plugins/wayfinder/src/minPriorityQueue.js +88 -2
  19. package/dist/cjs/plugins/wayfinder/src/navGraph.js +393 -5
  20. package/dist/cjs/plugins/wayfinder/src/navGraphDebug.js +110 -20
  21. package/dist/cjs/plugins/wayfinder/src/segmentBadges.js +28 -2
  22. package/dist/cjs/plugins/wayfinder/src/segmentBuilder.js +257 -19
  23. package/dist/cjs/plugins/wayfinder/src/segmentCategories.js +29 -2
  24. package/dist/cjs/plugins/wayfinder/src/stepBuilder.js +238 -3
  25. package/dist/cjs/plugins/wayfinder/src/wayfinder.js +597 -22
  26. package/dist/cjs/src/app.js +191 -25
  27. package/dist/cjs/src/configs/postproc-mol-url-parms.js +58 -2
  28. package/dist/cjs/src/configs/postproc-stateTracking.js +53 -19
  29. package/dist/cjs/src/controller.js +43 -4
  30. package/dist/cjs/src/debugTools.js +128 -23
  31. package/dist/cjs/src/env.js +17 -2
  32. package/dist/cjs/src/extModules/bustle.js +128 -4
  33. package/dist/cjs/src/extModules/flexapi/src/help.js +23 -4
  34. package/dist/cjs/src/extModules/flexapi/src/index.js +65 -4
  35. package/dist/cjs/src/extModules/flexapi/src/validate.js +133 -5
  36. package/dist/cjs/src/extModules/geohasher.js +90 -3
  37. package/dist/cjs/src/extModules/log.js +69 -2
  38. package/dist/cjs/src/historyManager.js +29 -2
  39. package/dist/cjs/src/utils/bounds.js +22 -4
  40. package/dist/cjs/src/utils/buildStructureLookup.js +31 -19
  41. package/dist/cjs/src/utils/configUtils.js +71 -3
  42. package/dist/cjs/src/utils/dom.js +48 -5
  43. package/dist/cjs/src/utils/funcs.js +30 -3
  44. package/dist/cjs/src/utils/geodesy.js +35 -3
  45. package/dist/cjs/src/utils/geom.js +209 -27
  46. package/dist/cjs/src/utils/i18n.js +69 -5
  47. package/dist/cjs/src/utils/observable.js +73 -2
  48. package/dist/cjs/src/utils/rand.js +82 -3
  49. package/dist/nodesdk/nodeEntry.js +1 -0
  50. package/dist/package.json.js +1 -0
  51. package/dist/plugins/searchService/src/searchService.js +1 -0
  52. package/dist/plugins/venueDataLoader/src/venueDataLoader.js +1 -0
  53. package/dist/plugins/venueDataLoader/src/venueLoadingUtils.js +1 -0
  54. package/dist/src/app.js +1 -0
  55. package/package.json +13 -9
  56. package/.yarnrc.yml +0 -1
  57. package/config/rollup.config.cjs.js +0 -31
  58. package/dist/cjs/deploy/nodeEntry.js +0 -20
  59. package/dist/cjs/src/auth/Auth.js +0 -23
  60. package/lib/deploy/nodeEntry.js +0 -1
  61. package/lib/package.json.js +0 -1
  62. package/lib/plugins/searchService/src/searchService.js +0 -1
  63. package/lib/plugins/venueDataLoader/src/venueDataLoader.js +0 -1
  64. package/lib/plugins/venueDataLoader/src/venueLoadingUtils.js +0 -1
  65. package/lib/src/app.js +0 -1
  66. package/lib/src/configs/sdkHeadless.json +0 -28
  67. /package/{lib → dist}/_virtual/_empty_module_placeholder.js +0 -0
  68. /package/{lib → dist}/deploy/prepareSDKConfig.js +0 -0
  69. /package/{lib → dist}/plugins/clientAPI/src/clientAPI.js +0 -0
  70. /package/{lib → dist}/plugins/dynamicPois/src/dynamicPois.js +0 -0
  71. /package/{lib → dist}/plugins/poiDataManager/src/poiDataManager.js +0 -0
  72. /package/{lib → dist}/plugins/sdkServer/src/sdkHeadless.js +0 -0
  73. /package/{lib → dist}/plugins/sdkServer/src/sdkServer.js +0 -0
  74. /package/{lib → dist}/plugins/sdkServer/src/util.js +0 -0
  75. /package/{lib → dist}/plugins/searchService/src/poiSearch.js +0 -0
  76. /package/{lib → dist}/plugins/searchService/src/searchTypeahead.js +0 -0
  77. /package/{lib → dist}/plugins/searchService/src/utils.js +0 -0
  78. /package/{lib → dist}/plugins/wayfinder/src/findRoute.js +0 -0
  79. /package/{lib → dist}/plugins/wayfinder/src/minPriorityQueue.js +0 -0
  80. /package/{lib → dist}/plugins/wayfinder/src/navGraph.js +0 -0
  81. /package/{lib → dist}/plugins/wayfinder/src/navGraphDebug.js +0 -0
  82. /package/{lib → dist}/plugins/wayfinder/src/segmentBadges.js +0 -0
  83. /package/{lib → dist}/plugins/wayfinder/src/segmentBuilder.js +0 -0
  84. /package/{lib → dist}/plugins/wayfinder/src/segmentCategories.js +0 -0
  85. /package/{lib → dist}/plugins/wayfinder/src/stepBuilder.js +0 -0
  86. /package/{lib → dist}/plugins/wayfinder/src/wayfinder.js +0 -0
  87. /package/{lib → dist}/src/configs/postproc-mol-url-parms.js +0 -0
  88. /package/{lib → dist}/src/configs/postproc-stateTracking.js +0 -0
  89. /package/{lib → dist}/src/configs/sdkHeadless.json.js +0 -0
  90. /package/{lib → dist}/src/controller.js +0 -0
  91. /package/{lib → dist}/src/debugTools.js +0 -0
  92. /package/{lib → dist}/src/env.js +0 -0
  93. /package/{lib → dist}/src/extModules/bustle.js +0 -0
  94. /package/{lib → dist}/src/extModules/flexapi/src/help.js +0 -0
  95. /package/{lib → dist}/src/extModules/flexapi/src/index.js +0 -0
  96. /package/{lib → dist}/src/extModules/flexapi/src/validate.js +0 -0
  97. /package/{lib → dist}/src/extModules/geohasher.js +0 -0
  98. /package/{lib → dist}/src/extModules/log.js +0 -0
  99. /package/{lib → dist}/src/historyManager.js +0 -0
  100. /package/{lib → dist}/src/utils/bounds.js +0 -0
  101. /package/{lib → dist}/src/utils/buildStructureLookup.js +0 -0
  102. /package/{lib → dist}/src/utils/configUtils.js +0 -0
  103. /package/{lib → dist}/src/utils/dom.js +0 -0
  104. /package/{lib → dist}/src/utils/funcs.js +0 -0
  105. /package/{lib → dist}/src/utils/geodesy.js +0 -0
  106. /package/{lib → dist}/src/utils/geom.js +0 -0
  107. /package/{lib → dist}/src/utils/i18n.js +0 -0
  108. /package/{lib → dist}/src/utils/observable.js +0 -0
  109. /package/{lib → dist}/src/utils/rand.js +0 -0
@@ -2,28 +2,40 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var e = require('ramda');
5
+ var R = require('ramda');
6
6
 
7
7
  function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
23
  }
24
24
 
25
- var e__namespace = /*#__PURE__*/_interopNamespace(e);
25
+ var R__namespace = /*#__PURE__*/_interopNamespace(R);
26
26
 
27
- const r=r=>{const p=e__namespace.mergeAll(r.map(e__namespace.prop("levels"))),l=o=>p[o],e=p=>e__namespace.find(e__namespace.path(["levels",p]),r);return {floorIdToOrdinal:e__namespace.pipe(l,e__namespace.prop("ordinal")),floorIdToFloor:l,floorIdToStructureId:e__namespace.pipe(e,e__namespace.prop("id")),floorIdToStructure:e}};
27
+ const buildStructuresLookup = (structures) => {
28
+ const floors = R__namespace.mergeAll(structures.map(R__namespace.prop('levels')));
29
+ const floorIdToFloor = floorId => floors[floorId];
30
+ const floorIdToOrdinal = R__namespace.pipe(floorIdToFloor, R__namespace.prop('ordinal'));
31
+ const floorIdToStructure = floorId => R__namespace.find(R__namespace.path(['levels', floorId]), structures);
32
+ const floorIdToStructureId = R__namespace.pipe(floorIdToStructure, R__namespace.prop('id'));
33
+ return {
34
+ floorIdToOrdinal,
35
+ floorIdToFloor,
36
+ floorIdToStructureId,
37
+ floorIdToStructure
38
+ }
39
+ };
28
40
 
29
- exports.buildStructuresLookup = r;
41
+ exports.buildStructuresLookup = buildStructuresLookup;
@@ -2,7 +2,75 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function n(t,e,o,r){let u=e;o&&(u+="-"+o);const i=t[u];return i||(o?o.indexOf("-")>0?n(t,e,o.substring(0,o.indexOf("-")),r):n(t,e,null,r):r)}function t(n,t){if(!n.config.debug)return !1;let e=n.config.debug[t];return null!=e&&!1!==e&&(!0===e||(e=e.toLowerCase?e.toLowerCase():e,"no"!==e&&"false"!==e))}exports.global = void 0;try{exports.global=Function("return this")();}catch(n){exports.global=window;}
5
+ /**
6
+ * Follows a localization scheme of checking for named values with locales appended,
7
+ * and checking more generally if values not found.
8
+ *
9
+ * For example, calling getLocalized("foo", "es-MX", "bar") would check the following keys in this order:
10
+ * "foo-es-MX"
11
+ * "foo-es"
12
+ * "foo"
13
+ *
14
+ * As soon as a value is found, it is returned, else the checks continue. If no value is found from any of these,
15
+ * the def value is returned. (If def is undefined, the undefined is returned)
16
+ *
17
+ * @param {object} config the configuration to inspect
18
+ * @param {string} name root key name to look up
19
+ * @param {string} lang language code
20
+ * @param {any} def default value to return if no value is found through localized checks
21
+ */
22
+ function getLocalized (config, name, lang, def) {
23
+ let key = name;
24
+ if (lang)
25
+ key += '-' + lang;
6
26
 
7
- exports.debugIsTrue = t;
8
- exports.getLocalized = n;
27
+ const value = config[key];
28
+
29
+ if (value)
30
+ return value
31
+
32
+ if (lang) {
33
+ if (lang.indexOf('-') > 0) // we have sublocales, so strip last one and try again
34
+ return getLocalized(config, name, lang.substring(0, lang.indexOf('-')), def)
35
+ else // no sublanguage, so next is try the name on its own
36
+ return getLocalized(config, name, null, def)
37
+ }
38
+
39
+ // we are here means we just checked the name (no lang arg) and there was no value found, so
40
+ // we simply return the def
41
+ return def
42
+ }
43
+
44
+ // A debug property is considered "true" if:
45
+ // The key is defined as a property within the debug object AND
46
+ // the value of that key is not "no" or "false" or false (boolean) or undefined or null
47
+ // Any other value will be considered true - even 0 and ""
48
+ function debugIsTrue (app, key) {
49
+ if (!app.config.debug)
50
+ return false
51
+
52
+ let value = app.config.debug[key];
53
+
54
+ if (value === undefined || value === null || value === false)
55
+ return false
56
+
57
+ if (value === true)
58
+ return true
59
+
60
+ value = value.toLowerCase ? value.toLowerCase() : value; // lower case it if possible
61
+
62
+ return value !== 'no' && value !== 'false'
63
+ }
64
+
65
+ // import this global to access to the "window" or "global" variables from
66
+ // the browser or node. (This approach is considered more robust and ensures consistency)
67
+ exports.global = void 0;
68
+ try {
69
+ // eslint-disable-next-line no-new-func
70
+ exports.global = Function('return this')();
71
+ } catch (e) {
72
+ exports.global = window;
73
+ }
74
+
75
+ exports.debugIsTrue = debugIsTrue;
76
+ exports.getLocalized = getLocalized;
@@ -2,9 +2,52 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const t=(t,e)=>"string"==typeof t?(e||document).querySelector(t):t||null,e=(t,e)=>Array.prototype.slice.call((e||document).querySelectorAll(t));function n(t,e){const n=t||{};e=e?"string"==typeof e?document.querySelector(e):e:document.body;let l="div";n.tag&&(l=n.tag);const s=document.createElement(l);for(const t in n)null!=n[t]&&("klass"===t?s.setAttribute("class",n.klass):"tag"===t||("styles"===t?o(s,n.styles):"text"===t?s.textContent=n.text:"html"===t?s.innerHTML=n.html:s.setAttribute(t,n[t])));return e.appendChild(s),s}const o=(t,e)=>{for(const n in e)t.style[n]=e[n];};
5
+ const $ = (expr, container) => typeof expr === 'string' ? (container || document).querySelector(expr) : expr || null;
6
+ const $$ = (expr, container) => Array.prototype.slice.call((container || document).querySelectorAll(expr));
6
7
 
7
- exports.$ = t;
8
- exports.$$ = e;
9
- exports.ad = n;
10
- exports.setStyles = o;
8
+ // adds an element (default: div) defined in eConf to parent element (default: body) - returns element
9
+ // i.e.
10
+ // const newDiv = ad() = creates a new div, adds to end of page and returns it
11
+ // const newDiv = ad({klass: "foo"}) = same as above with class of "foo"
12
+ // const newImg = ad({tag: "img", src: "test.png"}, "#top") = image at end of top
13
+ function ad (eConf, parent) {
14
+ const c = eConf || {};
15
+ parent = parent ? (typeof parent === 'string' ? document.querySelector(parent) : parent) : document.body;
16
+
17
+ let tag = 'div';
18
+
19
+ if (c.tag)
20
+ tag = c.tag;
21
+
22
+ const node = document.createElement(tag);
23
+
24
+ for (const cc in c) {
25
+ if (c[cc] != null) // null or undefined
26
+ if (cc === 'klass')
27
+ node.setAttribute('class', c.klass);
28
+ else if (cc === 'tag')
29
+ ; // already swallowed this
30
+ else if (cc === 'styles')
31
+ setStyles(node, c.styles);
32
+ else if (cc === 'text')
33
+ node.textContent = c.text;
34
+ else if (cc === 'html')
35
+ node.innerHTML = c.html;
36
+ else
37
+ node.setAttribute(cc, c[cc]);
38
+ }
39
+
40
+ parent.appendChild(node);
41
+
42
+ return node
43
+ }
44
+
45
+ const setStyles = (node, styles) => {
46
+ for (const style in styles)
47
+ node.style[style] = styles[style];
48
+ };
49
+
50
+ exports.$ = $;
51
+ exports.$$ = $$;
52
+ exports.ad = ad;
53
+ exports.setStyles = setStyles;
@@ -5,7 +5,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  require('ramda');
6
6
  require('zousan');
7
7
 
8
- let n=null;const t=t=>function(){return n=n?n.then((()=>t.apply(null,arguments))):t.apply(null,arguments),n};function l(n,t){const l={};return Object.keys(t).forEach((o=>{n(o,t[o])&&(l[o]=t[o]);})),l}
8
+ // Ensures only a single asynchronous function wrapped in this function runs at a time.
9
+ let lastFn = null;
10
+ const singleFile = fn => function () {
11
+ if (lastFn)
12
+ lastFn = lastFn.then(() => fn.apply(null, arguments));
13
+ else
14
+ lastFn = fn.apply(null, arguments);
9
15
 
10
- exports.filterOb = l;
11
- exports.singleFile = t;
16
+ return lastFn
17
+ };
18
+
19
+ /**
20
+ * returns a copy of an object with any (top-level) properties that do not
21
+ * return truthy from the specified function stripped. So it works just like
22
+ * the Array.filter, but for objects.
23
+ * @param {function} fn A filter predicate - will be passed (key,object)
24
+ * @param {object} ob The object to filter (top level properties only)
25
+ * @returns (object) The newly created object with filtered properties
26
+ */
27
+ function filterOb (fn, ob) {
28
+ const ret = { };
29
+ Object.keys(ob)
30
+ .forEach(key => {
31
+ if (fn(key, ob[key]))
32
+ ret[key] = ob[key];
33
+ });
34
+ return ret
35
+ }
36
+
37
+ exports.filterOb = filterOb;
38
+ exports.singleFile = singleFile;
@@ -2,7 +2,39 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const t=t=>t*Math.PI/180;function a(a,h,n,s){const M=t(a),o=t(n),c=t(n-a),i=t(s-h),r=Math.sin(c/2)*Math.sin(c/2)+Math.cos(M)*Math.cos(o)*Math.sin(i/2)*Math.sin(i/2);return 6371e3*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}
5
+ /*
6
+ This utility module contains a set of functions dealing with "Geodesy" - measurements of
7
+ the earth, its surface and related geometry.
6
8
 
7
- exports.distance = a;
8
- exports.toRadians = t;
9
+ For a more cohesive set of functions, see https://github.com/chrisveness/geodesy
10
+ */
11
+
12
+ // degrees to radians
13
+ const toRadians = d => d * Math.PI / 180;
14
+
15
+ /**
16
+ * Haversine formula for finding distance between two lat/lng points.
17
+ * from https://www.movable-type.co.uk/scripts/latlong.html
18
+ * @param {float} lat1 latitutde of point 1
19
+ * @param {float} lng1 longitude of point 1
20
+ * @param {float} lat2 latitutde of point 2
21
+ * @param {float} lng2 longitude of point 2
22
+ * @returns number (in meters) between p1 and p2
23
+ */
24
+ function distance (lat1, lng1, lat2, lng2) {
25
+ const R = 6371000; // approx. earth radius (meters)
26
+ const φ1 = toRadians(lat1);
27
+ const φ2 = toRadians(lat2);
28
+ const Δφ = toRadians(lat2 - lat1);
29
+ const Δλ = toRadians(lng2 - lng1);
30
+
31
+ const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
32
+ Math.cos(φ1) * Math.cos(φ2) *
33
+ Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
34
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
35
+
36
+ return R * c
37
+ }
38
+
39
+ exports.distance = distance;
40
+ exports.toRadians = toRadians;
@@ -3,38 +3,220 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var helpers = require('@turf/helpers');
6
- var e$1 = require('@turf/point-to-line-distance');
7
- var e = require('ramda');
6
+ var pointToLineDistance = require('@turf/point-to-line-distance');
7
+ var R = require('ramda');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
11
  function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n["default"] = e;
26
+ return Object.freeze(n);
27
27
  }
28
28
 
29
- var e__default = /*#__PURE__*/_interopDefaultLegacy(e$1);
30
- var e__namespace = /*#__PURE__*/_interopNamespace(e);
29
+ var pointToLineDistance__default = /*#__PURE__*/_interopDefaultLegacy(pointToLineDistance);
30
+ var R__namespace = /*#__PURE__*/_interopNamespace(R);
31
31
 
32
- const l=(n,t)=>{const e=n[0],r=n[1];let l=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const u=t[n][0],s=t[n][1],i=t[o][0],f=t[o][1];s>r!=f>r&&e<(i-u)*(r-s)/(f-s)+u&&(l=!l);}return l},o=n=>{const{n:t,s:e,e:r,w:l}=n.bounds;return [[t,r],[t,l],[e,l],[e,r],[t,r]]};function u(n,t,e,u){if(!e__namespace.length(n))return null;const s=(n=n.filter((n=>null==n.shouldDisplay||!0===n.shouldDisplay))).filter((n=>l([t,e],o(n))));if(0===s.length)return null;if(1===s.length&&!u)return e__namespace.head(s);const i=s.filter((n=>l([t,e],n.boundsPolygon)));if(1===i.length)return e__namespace.head(i);if(i.length)return h(s);if(u)return null;const c=s.map((n=>f(t,e,n))),d=Math.min.apply(null,c);return s[c.indexOf(d)]}const s=n=>helpers.lineString(n.boundsPolygon.map((n=>d(n)))),i={},f=(n,t,e)=>{for(let r=0;r<99;r++)c(n,t,e);return c(n,t,e)},c=(t,r,l)=>{const o=helpers.point([r,t]),u=(n=>{let t=i[n.id];return t||(t=s(n),i[n.id]=t),t})(l);return e__default["default"](o,u)},d=n=>[n[1],n[0]],a=n=>{if(!n.bounds)return 0;const{n:t,s:e,e:r,w:l}=n.bounds;return Math.abs((t-e)*(r-l))},h=n=>{return n.reduce((t=a,(n,e)=>t(n)<t(e)?n:e));var t;},p=(n,t)=>Object.values(n.levels).reduce(((n,e)=>e.ordinal===t?e:n),void 0),g=(n,t)=>n.reduce(((n,e)=>Object.values(e.levels).reduce(((n,e)=>e.id===t?e:n),null)||n),void 0);function m(n,t,e,r,l){const o=u(n,t,e,l);return {building:o,floor:o?p(o,r):null}}const b=(n,t,e,r,l)=>m(n,t,e,r,l).floor;function v(n,t,e,r,l,o,u,s){let i=0,f=0,c=0,d=0,a=0;const h=[{x:n,y:t}];for(let p=1,g=0;p<=20;++p)g=p/20,i=1-g,f=i*i,c=f*i,d=g*g,a=d*g,h.push({x:c*n+3*f*g*e+3*i*d*l+a*u,y:c*t+3*f*g*r+3*i*d*o+a*s});return h}
32
+ // https://stackoverflow.com/questions/22521982/check-if-point-inside-a-polygon
33
+ const pointInPolygon = (point, vs) => {
34
+ const x = point[0];
35
+ const y = point[1];
33
36
 
34
- exports.bezierCurveTo = v;
35
- exports.getBuildingAndFloorAtPoint = m;
36
- exports.getFloor = g;
37
- exports.getFloorAt = b;
38
- exports.getStructureAtPoint = u;
39
- exports.ordToFloor = p;
40
- exports.pointInPolygon = l;
37
+ let inside = false;
38
+ for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
39
+ const xi = vs[i][0];
40
+ const yi = vs[i][1];
41
+ const xj = vs[j][0];
42
+ const yj = vs[j][1];
43
+ const intersect = ((yi > y) !== (yj > y)) &&
44
+ (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
45
+ if (intersect) {
46
+ inside = !inside;
47
+ }
48
+ }
49
+
50
+ return inside
51
+ };
52
+
53
+ const getBoundsCoords = building => {
54
+ const { n, s, e, w } = building.bounds;
55
+ return [[n, e], [n, w], [s, w], [s, e], [n, e]]
56
+ };
57
+
58
+ /**
59
+ * Pass in a buildings array and a lat,lng and this will return the building at that point
60
+ * or undefined if no building exists at that point. This runs very quickly as we very often
61
+ * can skip the slowest path (which runs pointInPolygon). Without preciseFlag we sometimes return
62
+ * a building when the point falls outside it - but won't return a wrong building. In some cases this
63
+ * is actually desired behavior anyway (such as building selector)
64
+ * @param {Array.Object} buildings
65
+ * @param {float} lat latitude of point to check
66
+ * @param {float} lng longitude of point to check
67
+ * @param {boolean} preciseFlag if not true we take a shortcut when a single building falls within bounding box (very common case)
68
+ * @returns {object} building that contains the point passed, or undefined if none
69
+ */
70
+ function getStructureAtPoint (buildings, lat, lng, preciseFlag) {
71
+ if (!R__namespace.length(buildings)) return null
72
+
73
+ buildings = buildings.filter(b => b.shouldDisplay == null || b.shouldDisplay === true);
74
+
75
+ const buildingsWithinBoundingBox = buildings.filter(b =>
76
+ pointInPolygon([lat, lng], getBoundsCoords(b)));
77
+
78
+ if (buildingsWithinBoundingBox.length === 0) return null
79
+ if (buildingsWithinBoundingBox.length === 1 && !preciseFlag)
80
+ return R__namespace.head(buildingsWithinBoundingBox)
81
+
82
+ const buildingsWithinBoundsPolygon = buildingsWithinBoundingBox
83
+ .filter(b => pointInPolygon([lat, lng], b.boundsPolygon));
84
+
85
+ if (buildingsWithinBoundsPolygon.length === 1)
86
+ return R__namespace.head(buildingsWithinBoundsPolygon)
87
+
88
+ // If we are within more than 1 building (WTF?) then return the smaller one
89
+ if (buildingsWithinBoundsPolygon.length)
90
+ return findBuildingWithMinArea(buildingsWithinBoundingBox)
91
+
92
+ if (preciseFlag) // technically, point is not above any building...
93
+ return null
94
+
95
+ const distancesToBuildings = buildingsWithinBoundingBox.map(building => distanceFromPointToBuilding(lat, lng, building));
96
+ const shortestDistance = Math.min.apply(null, distancesToBuildings);
97
+ const closestBuilding = buildingsWithinBoundingBox[distancesToBuildings.indexOf(shortestDistance)];
98
+
99
+ return closestBuilding
100
+ }
101
+
102
+ // a Turf linestring is a multi-edge line defined by a series of vertices
103
+ // (basiclly what we call a boundsPolygon - but we need to construct via the library)
104
+ const buildingToTurfLineString = building =>
105
+ helpers.lineString(building.boundsPolygon.map(v => swap(v))); // turf uses [lng,lat] so we need to swap em
106
+
107
+ const lineStrings = { }; // building id => lineString object
108
+
109
+ // this function constructs a lineString (https://turfjs.org/docs/#lineString) from a building
110
+ // boundsPolygon which can be used to work with the Turf library. There is some cost in generating it
111
+ // so we cache the object for future use.
112
+ const getLineString = building => {
113
+ let lineString = lineStrings[building.id];
114
+ if (!lineString) {
115
+ lineString = buildingToTurfLineString(building);
116
+ lineStrings[building.id] = lineString;
117
+ }
118
+
119
+ return lineString
120
+ };
121
+
122
+ const distanceFromPointToBuilding = (lat, lng, building) => {
123
+ for (let i = 0; i < 99; i++)
124
+ distanceFromPointToBuildingImp(lat, lng, building);
125
+
126
+ return distanceFromPointToBuildingImp(lat, lng, building)
127
+ };
128
+
129
+ const distanceFromPointToBuildingImp = (lat, lng, building) => {
130
+ // First, create an array of distances of the lat,lng to each edge in the polygon - then return the minimum value in the array
131
+ const pt = helpers.point([lng, lat]);
132
+
133
+ const lineString = getLineString(building);
134
+ return pointToLineDistance__default["default"](pt, lineString) // distance in kilometers
135
+ };
136
+
137
+ const swap = ar => [ar[1], ar[0]];
138
+
139
+ const calcBuildingArea = currentBuilding => {
140
+ if (!currentBuilding.bounds) return 0
141
+ const { n, s, e, w } = currentBuilding.bounds;
142
+ return Math.abs((n - s) * (e - w))
143
+ };
144
+
145
+ // takes a function and two objects and returns the object that evaluates less against the function
146
+ const less = fn => (o1, o2) => fn(o1) < fn(o2) ? o1 : o2;
147
+ const findBuildingWithMinArea = ba => ba.reduce(less(calcBuildingArea)); // returns the building with least area within bounding
148
+
149
+ /**
150
+ * given a building and ord, return the floor (or undefined if doesn't exist)
151
+ */
152
+ const ordToFloor = (building, ord) =>
153
+ Object.values(building.levels).reduce((matchedFloor, floor) =>
154
+ floor.ordinal === ord ? floor : matchedFloor, undefined);
155
+
156
+ /**
157
+ * Return the floor based on its ID (pass in buildings array and floorId)
158
+ */
159
+ const getFloor = (buildings, selectedLevelId) =>
160
+ buildings.reduce((fmatch, building) =>
161
+ Object.values(building.levels).reduce((fmatch, floor) =>
162
+ floor.id === selectedLevelId ? floor : fmatch, null) || fmatch, undefined);
163
+
164
+ function getBuildingAndFloorAtPoint (buildings, lat, lng, ord, preciseFlag) {
165
+ const building = getStructureAtPoint(buildings, lat, lng, preciseFlag);
166
+ const floor = building
167
+ ? ordToFloor(building, ord)
168
+ : null;
169
+ return { building, floor }
170
+ }
171
+
172
+ const getFloorAt = (buildings, lat, lng, ord, preciseFlag) => getBuildingAndFloorAtPoint(buildings, lat, lng, ord, preciseFlag).floor;
173
+
174
+ /**
175
+ * Calculate the points for a bezier cubic curve
176
+ *
177
+ * @param {number} fromX - Starting point x
178
+ * @param {number} fromY - Starting point y
179
+ * @param {number} cpX - Control point x
180
+ * @param {number} cpY - Control point y
181
+ * @param {number} cpX2 - Second Control point x
182
+ * @param {number} cpY2 - Second Control point y
183
+ * @param {number} toX - Destination point x
184
+ * @param {number} toY - Destination point y
185
+ * @return {Object[]} Array of points of the curve
186
+ */
187
+ function bezierCurveTo (fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) {
188
+ const n = 20; // controls smoothness of line
189
+ let dt = 0;
190
+ let dt2 = 0;
191
+ let dt3 = 0;
192
+ let t2 = 0;
193
+ let t3 = 0;
194
+
195
+ const path = [{ x: fromX, y: fromY }];
196
+
197
+ for (let i = 1, j = 0; i <= n; ++i) {
198
+ j = i / n;
199
+
200
+ dt = (1 - j);
201
+ dt2 = dt * dt;
202
+ dt3 = dt2 * dt;
203
+
204
+ t2 = j * j;
205
+ t3 = t2 * j;
206
+
207
+ path.push({
208
+ x: (dt3 * fromX) + (3 * dt2 * j * cpX) + (3 * dt * t2 * cpX2) + (t3 * toX),
209
+ y: (dt3 * fromY) + (3 * dt2 * j * cpY) + (3 * dt * t2 * cpY2) + (t3 * toY)
210
+ });
211
+ }
212
+
213
+ return path
214
+ }
215
+
216
+ exports.bezierCurveTo = bezierCurveTo;
217
+ exports.getBuildingAndFloorAtPoint = getBuildingAndFloorAtPoint;
218
+ exports.getFloor = getFloor;
219
+ exports.getFloorAt = getFloorAt;
220
+ exports.getStructureAtPoint = getStructureAtPoint;
221
+ exports.ordToFloor = ordToFloor;
222
+ exports.pointInPolygon = pointInPolygon;
@@ -2,13 +2,77 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var n = require('i18next');
5
+ var i18next = require('i18next');
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var n__default = /*#__PURE__*/_interopDefaultLegacy(n);
9
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
10
10
 
11
- async function e(e,{debugMode:t,fallbackLng:o}={}){const a=n__default["default"].createInstance();return a.init({debug:t,interpolation:{escapeValue:!1},resources:{en:{translation:{"Proceed xx minutes to":"Proceed {{count}} minute to","Proceed xx minutes to_plural":"Proceed {{count}} minutes to"}}},fallbackLng:void 0===o?"en":o,lng:e,postProcess:["pseudoTrans"]}).then((()=>(t&&a.on("missingKey",(function(n,e,t,o){console.error("i18nNext: key not found. Language: "+a.language+", Key: "+t+", namespace: "+e+", lngs: ",n);})),a)))}const t={ar:"بال عن أمام الأخذ البرية. ثم كما وقام شاسعة الجنوبي, أمدها الإمداد عن انه. ٣٠ فكانت والكساد انه. أساسي الشمال الإتفاقية بال أم. زهاء المؤلّفة حين عل, سكان قررت هذه ان, شعار باستخدام ولم مع.\n\nدول الأمور الصفحة الأوروبية قد. تم حدى فاتّبع الهجوم, ما أوسع معاملة فعل, خلاف الأوروبية، إيو كل. تُصب واندونيسيا، حين قد. أي حاول حقول وهولندا، هذا, بين عن لهيمنة بالسيطرة.\n\nأعمال الإتحاد العمليات من وصل. وقوعها، باستخدام قد أخر, بل حتى علاقة التبرعات. فقد لم الأرض استبدال. حتى الخاسر اقتصادية بـ. أصقاع أعلنت اتفاقية تلك بل, كان إذ بحشد أخرى ليبين. الشتاء، اليابان، مكن أم, به، قد العالم، أوراقهم, بل لعدم لغزو أواخر مكن.\n",ja:"私は場合いよいよある所有らってのの末がしたた。無論結果に圧迫顔もよくその発展ないですまでを決するてみるでしでも発展云いませたから、そうには描いたないたた。機会へ載っない方は別に今をひょろひょろでずまし。むしろ嘉納さんを意味方面そう#「を積んない権力この自分何か記念をというおお尋ねだろででですで、ある今はこれか頼み例があるで、ネルソンさんののの引込のあなたにもっともお努力といと私赤に実建設が起っようにとやかくご附随を描いですましから、どうもとにかく相違に云おでてならますのが行っないませ。"},o=(n,e)=>"en"===e?n:a(n,t[e]),a=(n,e)=>n.length<e.length?e.substring(0,n.length):e;
11
+ async function init (langOverride, { debugMode, fallbackLng } = {}) {
12
+ const i18n = i18next__default["default"].createInstance();
13
+ return i18n
14
+ // .use(dashEmAll)
15
+ // .use(pseudoTrans)
16
+ .init({
17
+ debug: debugMode,
18
+ interpolation: {
19
+ escapeValue: false
20
+ },
21
+ resources: {
22
+ en: {
23
+ translation: {
24
+ 'Proceed xx minutes to': 'Proceed {{count}} minute to',
25
+ 'Proceed xx minutes to_plural': 'Proceed {{count}} minutes to'
26
+ }
27
+ }
28
+ },
29
+ fallbackLng: fallbackLng === undefined ? 'en' : fallbackLng,
30
+ // ns: ['common', 'banner', 'common', 'directions', 'failure', 'flights', 'legal', 'navigation', 'poi', 'search', 'security', 'time', 'tooltip'],
31
+ // defaultNS: 'common',
32
+ lng: langOverride, /* , interpolation: {
33
+ escapeValue: true
34
+ } */
35
+ postProcess: ['pseudoTrans']
36
+ })
37
+ .then(() => {
38
+ if (debugMode) {
39
+ i18n.on('missingKey', function (lngs, namespace, key, res) {
40
+ console.error('i18nNext: key not found. Language: ' + i18n.language + ', Key: ' + key + ', namespace: ' + namespace + ', lngs: ', lngs);
41
+ });
42
+ }
12
43
 
13
- exports["default"] = e;
14
- exports.toLang = o;
44
+ // i18n.changeLanguage(lng, callback)
45
+ // i18n.t(key, interpolation)
46
+
47
+ return i18n
48
+ })
49
+ }
50
+
51
+ // A postprocessor plugin for i18next that replaces all words with dashes - this helps identify untranslated strings
52
+ // const dashEmAll = {
53
+ // name: 'dashEmAll',
54
+ // type: 'postProcessor',
55
+ // process: (value, key, options, translator) => value.replace(/[^ .-_,]/g, '-')
56
+ // }
57
+
58
+ // const pseudoTrans = {
59
+ // name: 'pseudoTrans',
60
+ // type: 'postProcessor',
61
+ // process: (value, key, options, translator) => toLang(value, translator.language)
62
+ // }
63
+
64
+ const loremIpsum = {
65
+ ar: `بال عن أمام الأخذ البرية. ثم كما وقام شاسعة الجنوبي, أمدها الإمداد عن انه. ٣٠ فكانت والكساد انه. أساسي الشمال الإتفاقية بال أم. زهاء المؤلّفة حين عل, سكان قررت هذه ان, شعار باستخدام ولم مع.
66
+
67
+ دول الأمور الصفحة الأوروبية قد. تم حدى فاتّبع الهجوم, ما أوسع معاملة فعل, خلاف الأوروبية، إيو كل. تُصب واندونيسيا، حين قد. أي حاول حقول وهولندا، هذا, بين عن لهيمنة بالسيطرة.
68
+
69
+ أعمال الإتحاد العمليات من وصل. وقوعها، باستخدام قد أخر, بل حتى علاقة التبرعات. فقد لم الأرض استبدال. حتى الخاسر اقتصادية بـ. أصقاع أعلنت اتفاقية تلك بل, كان إذ بحشد أخرى ليبين. الشتاء، اليابان، مكن أم, به، قد العالم، أوراقهم, بل لعدم لغزو أواخر مكن.
70
+ `,
71
+ ja: '私は場合いよいよある所有らってのの末がしたた。無論結果に圧迫顔もよくその発展ないですまでを決するてみるでしでも発展云いませたから、そうには描いたないたた。機会へ載っない方は別に今をひょろひょろでずまし。むしろ嘉納さんを意味方面そう#「を積んない権力この自分何か記念をというおお尋ねだろででですで、ある今はこれか頼み例があるで、ネルソンさんののの引込のあなたにもっともお努力といと私赤に実建設が起っようにとやかくご附随を描いですましから、どうもとにかく相違に云おでてならますのが行っないませ。'
72
+ };
73
+
74
+ const toLang = (str, lang) => lang === 'en' ? str : repl(str, loremIpsum[lang]);
75
+ const repl = (str, r) => str.length < r.length ? r.substring(0, str.length) : r;
76
+
77
+ exports["default"] = init;
78
+ exports.toLang = toLang;