@glandais/vcyclist-engine 0.0.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.
@@ -0,0 +1,2373 @@
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd)
3
+ define(['exports', './kotlin-kotlin-stdlib.js', './kotlinx-coroutines-core.js'], factory);
4
+ else if (typeof exports === 'object')
5
+ factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js'));
6
+ else {
7
+ if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
8
+ throw new Error("Error loading module 'vcyclist-elevation'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'vcyclist-elevation'.");
9
+ }
10
+ if (typeof globalThis['kotlinx-coroutines-core'] === 'undefined') {
11
+ throw new Error("Error loading module 'vcyclist-elevation'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'vcyclist-elevation'.");
12
+ }
13
+ globalThis['vcyclist-elevation'] = factory(typeof globalThis['vcyclist-elevation'] === 'undefined' ? {} : globalThis['vcyclist-elevation'], globalThis['kotlin-kotlin-stdlib'], globalThis['kotlinx-coroutines-core']);
14
+ }
15
+ }(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
16
+ 'use strict';
17
+ //region block: imports
18
+ var imul = Math.imul;
19
+ var hypot = Math.hypot;
20
+ var VOID = kotlin_kotlin.$_$.a;
21
+ var protoOf = kotlin_kotlin.$_$.e5;
22
+ var getNumberHashCode = kotlin_kotlin.$_$.o4;
23
+ var getBooleanHashCode = kotlin_kotlin.$_$.n4;
24
+ var equals = kotlin_kotlin.$_$.m4;
25
+ var initMetadataForClass = kotlin_kotlin.$_$.s4;
26
+ var numberToLong = kotlin_kotlin.$_$.a4;
27
+ var toNumber = kotlin_kotlin.$_$.c4;
28
+ var CoroutineImpl = kotlin_kotlin.$_$.m3;
29
+ var Unit_instance = kotlin_kotlin.$_$.g;
30
+ var THROW_CCE = kotlin_kotlin.$_$.o6;
31
+ var MutableEntry = kotlin_kotlin.$_$.z1;
32
+ var isInterface = kotlin_kotlin.$_$.a5;
33
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.x2;
34
+ var initMetadataForLambda = kotlin_kotlin.$_$.x4;
35
+ var emptyList = kotlin_kotlin.$_$.j2;
36
+ var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.n;
37
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j;
38
+ var toList = kotlin_kotlin.$_$.v2;
39
+ var KtList = kotlin_kotlin.$_$.x1;
40
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.u4;
41
+ var toString = kotlin_kotlin.$_$.g5;
42
+ var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.y;
43
+ var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i;
44
+ var listOf = kotlin_kotlin.$_$.q2;
45
+ var numberToInt = kotlin_kotlin.$_$.c5;
46
+ var initMetadataForObject = kotlin_kotlin.$_$.y4;
47
+ var toList_0 = kotlin_kotlin.$_$.u2;
48
+ var get_lastIndex = kotlin_kotlin.$_$.o2;
49
+ var checkBuilderCapacity = kotlin_kotlin.$_$.b2;
50
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.b1;
51
+ var coerceIn = kotlin_kotlin.$_$.m5;
52
+ var initMetadataForFunctionReference = kotlin_kotlin.$_$.v4;
53
+ var getStringHashCode = kotlin_kotlin.$_$.q4;
54
+ var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
55
+ var Semaphore = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.f;
56
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.c2;
57
+ var async = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.i;
58
+ var awaitAll = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b;
59
+ var coroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d;
60
+ var CompletableDeferred = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g;
61
+ var KtMap = kotlin_kotlin.$_$.y1;
62
+ var Mutex = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e;
63
+ var contentEquals = kotlin_kotlin.$_$.d2;
64
+ var contentHashCode = kotlin_kotlin.$_$.e2;
65
+ var objectCreate = kotlin_kotlin.$_$.d5;
66
+ var round = kotlin_kotlin.$_$.i5;
67
+ var initMetadataForCompanion = kotlin_kotlin.$_$.t4;
68
+ var isNaN_0 = kotlin_kotlin.$_$.u6;
69
+ var replace = kotlin_kotlin.$_$.w5;
70
+ var coerceIn_0 = kotlin_kotlin.$_$.l5;
71
+ var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
72
+ var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
73
+ var await_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c;
74
+ var IllegalStateException_init_$Create$_0 = kotlin_kotlin.$_$.a1;
75
+ //endregion
76
+ //region block: pre-declaration
77
+ initMetadataForClass(SmoothingOptions, 'SmoothingOptions', SmoothingOptions);
78
+ initMetadataForClass(FilterOptions, 'FilterOptions', FilterOptions);
79
+ initMetadataForLambda(BatchCalculator$setElevations$slambda, CoroutineImpl, VOID, [1]);
80
+ initMetadataForCoroutine($setElevationsCOROUTINE$, CoroutineImpl);
81
+ initMetadataForCoroutine($getElevationsAlongCOROUTINE$, CoroutineImpl);
82
+ initMetadataForClass(BatchCalculator, 'BatchCalculator', VOID, VOID, VOID, [4, 7]);
83
+ initMetadataForObject(MathConstants, 'MathConstants');
84
+ initMetadataForClass(LatLon, 'LatLon');
85
+ initMetadataForClass(LatLonElevation, 'LatLonElevation');
86
+ initMetadataForObject(Distance, 'Distance');
87
+ initMetadataForObject(DouglasPeucker, 'DouglasPeucker');
88
+ initMetadataForObject(EcefConverter, 'EcefConverter');
89
+ initMetadataForCoroutine($getElevationCOROUTINE$, CoroutineImpl);
90
+ initMetadataForCoroutine($getInterpolatedElevationCOROUTINE$, CoroutineImpl);
91
+ initMetadataForCoroutine($elevationFromPixelCOROUTINE$, CoroutineImpl);
92
+ initMetadataForClass(ElevationCalculator, 'ElevationCalculator', VOID, VOID, VOID, [3, 2, 1]);
93
+ initMetadataForObject(ElevationFunctions, 'ElevationFunctions');
94
+ initMetadataForFunctionReference(fetchAndDecodeTile$ref, VOID, VOID, [1]);
95
+ initMetadataForClass(ElevationProvider, 'ElevationProvider', ElevationProvider, VOID, VOID, [3, 2, 6]);
96
+ initMetadataForClass(ElevationProviderConfig, 'ElevationProviderConfig', ElevationProviderConfig);
97
+ initMetadataForClass(Attribution, 'Attribution');
98
+ initMetadataForObject(ElevationSmoother, 'ElevationSmoother');
99
+ initMetadataForLambda(Flux$forEachParallel$slambda$slambda, CoroutineImpl, VOID, [1]);
100
+ initMetadataForLambda(Flux$forEachParallel$slambda, CoroutineImpl, VOID, [1]);
101
+ initMetadataForCoroutine($forEachParallelCOROUTINE$, CoroutineImpl);
102
+ initMetadataForObject(Flux, 'Flux', VOID, VOID, VOID, [3]);
103
+ initMetadataForCoroutine($getCOROUTINE$, CoroutineImpl);
104
+ initMetadataForClass(LruCache, 'LruCache', VOID, VOID, VOID, [1, 0]);
105
+ initMetadataForClass(RawTile, 'RawTile');
106
+ initMetadataForCompanion(Companion);
107
+ initMetadataForClass(Tile, 'Tile');
108
+ initMetadataForFunctionReference(fetchAndDecodeTile$ref_1, VOID, VOID, [1]);
109
+ initMetadataForLambda(TileManager$cache$slambda, CoroutineImpl, VOID, [1]);
110
+ initMetadataForClass(TileManager, 'TileManager', VOID, VOID, VOID, [1, 0]);
111
+ initMetadataForClass(TileCoordinates, 'TileCoordinates');
112
+ initMetadataForClass(Pixel, 'Pixel');
113
+ initMetadataForClass(PixelFloat, 'PixelFloat');
114
+ initMetadataForClass(TileCoordinatesFloat, 'TileCoordinatesFloat');
115
+ initMetadataForCompanion(Companion_0);
116
+ initMetadataForClass(Vector3D, 'Vector3D');
117
+ initMetadataForLambda(getElevation$slambda, CoroutineImpl, VOID, [1]);
118
+ initMetadataForLambda(getElevationsAlong$slambda, CoroutineImpl, VOID, [1]);
119
+ initMetadataForCoroutine($fetchAndDecodeTileCOROUTINE$, CoroutineImpl);
120
+ //endregion
121
+ function SmoothingOptions(windowSize, enabled) {
122
+ windowSize = windowSize === VOID ? 50.0 : windowSize;
123
+ enabled = enabled === VOID ? false : enabled;
124
+ this.fs_1 = windowSize;
125
+ this.gs_1 = enabled;
126
+ }
127
+ protoOf(SmoothingOptions).toString = function () {
128
+ return 'SmoothingOptions(windowSize=' + this.fs_1 + ', enabled=' + this.gs_1 + ')';
129
+ };
130
+ protoOf(SmoothingOptions).hashCode = function () {
131
+ var result = this.fs_1 == null ? 0 : getNumberHashCode(this.fs_1);
132
+ result = imul(result, 31) + getBooleanHashCode(this.gs_1) | 0;
133
+ return result;
134
+ };
135
+ protoOf(SmoothingOptions).equals = function (other) {
136
+ if (this === other)
137
+ return true;
138
+ if (!(other instanceof SmoothingOptions))
139
+ return false;
140
+ if (!equals(this.fs_1, other.fs_1))
141
+ return false;
142
+ if (!(this.gs_1 === other.gs_1))
143
+ return false;
144
+ return true;
145
+ };
146
+ function FilterOptions(tolerance, zExaggeration, enabled) {
147
+ tolerance = tolerance === VOID ? 10.0 : tolerance;
148
+ zExaggeration = zExaggeration === VOID ? 3.0 : zExaggeration;
149
+ enabled = enabled === VOID ? false : enabled;
150
+ this.hs_1 = tolerance;
151
+ this.is_1 = zExaggeration;
152
+ this.js_1 = enabled;
153
+ }
154
+ protoOf(FilterOptions).toString = function () {
155
+ return 'FilterOptions(tolerance=' + this.hs_1 + ', zExaggeration=' + this.is_1 + ', enabled=' + this.js_1 + ')';
156
+ };
157
+ protoOf(FilterOptions).hashCode = function () {
158
+ var result = this.hs_1 == null ? 0 : getNumberHashCode(this.hs_1);
159
+ result = imul(result, 31) + (this.is_1 == null ? 0 : getNumberHashCode(this.is_1)) | 0;
160
+ result = imul(result, 31) + getBooleanHashCode(this.js_1) | 0;
161
+ return result;
162
+ };
163
+ protoOf(FilterOptions).equals = function (other) {
164
+ if (this === other)
165
+ return true;
166
+ if (!(other instanceof FilterOptions))
167
+ return false;
168
+ if (!equals(this.hs_1, other.hs_1))
169
+ return false;
170
+ if (!equals(this.is_1, other.is_1))
171
+ return false;
172
+ if (!(this.js_1 === other.js_1))
173
+ return false;
174
+ return true;
175
+ };
176
+ function formatNumber($this, d) {
177
+ var asLong = numberToLong(d);
178
+ return toNumber(asLong) === d ? asLong.toString() : d.toString();
179
+ }
180
+ function BatchCalculator$setElevations$slambda($coordinates, this$0, $zoomLevel, $interpolation, $results, resultContinuation) {
181
+ this.ss_1 = $coordinates;
182
+ this.ts_1 = this$0;
183
+ this.us_1 = $zoomLevel;
184
+ this.vs_1 = $interpolation;
185
+ this.ws_1 = $results;
186
+ CoroutineImpl.call(this, resultContinuation);
187
+ }
188
+ protoOf(BatchCalculator$setElevations$slambda).bt = function (_destruct__k2r9zo, $completion) {
189
+ var tmp = this.ct(_destruct__k2r9zo, $completion);
190
+ tmp.w5_1 = Unit_instance;
191
+ tmp.x5_1 = null;
192
+ return tmp.c6();
193
+ };
194
+ protoOf(BatchCalculator$setElevations$slambda).k6 = function (p1, $completion) {
195
+ return this.bt((!(p1 == null) ? isInterface(p1, MutableEntry) : false) ? p1 : THROW_CCE(), $completion);
196
+ };
197
+ protoOf(BatchCalculator$setElevations$slambda).c6 = function () {
198
+ var suspendResult = this.w5_1;
199
+ $sm: do
200
+ try {
201
+ var tmp = this.u5_1;
202
+ switch (tmp) {
203
+ case 0:
204
+ this.v5_1 = 4;
205
+ var indices = this.xs_1.f1();
206
+ this.at_1 = indices.i();
207
+ this.u5_1 = 1;
208
+ continue $sm;
209
+ case 1:
210
+ if (!this.at_1.j()) {
211
+ this.u5_1 = 3;
212
+ continue $sm;
213
+ }
214
+
215
+ this.zs_1 = this.at_1.k();
216
+ this.ys_1 = this.ss_1.m(this.zs_1);
217
+ this.u5_1 = 2;
218
+ suspendResult = this.ts_1.dt_1.gt(this.ys_1, this.us_1, this.vs_1, this);
219
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
220
+ return suspendResult;
221
+ }
222
+
223
+ continue $sm;
224
+ case 2:
225
+ var ele = suspendResult;
226
+ this.ws_1[this.zs_1] = new LatLonElevation(this.ys_1.ht(), this.ys_1.it(), ele);
227
+ this.u5_1 = 1;
228
+ continue $sm;
229
+ case 3:
230
+ return Unit_instance;
231
+ case 4:
232
+ throw this.x5_1;
233
+ }
234
+ } catch ($p) {
235
+ var e = $p;
236
+ if (this.v5_1 === 4) {
237
+ throw e;
238
+ } else {
239
+ this.u5_1 = this.v5_1;
240
+ this.x5_1 = e;
241
+ }
242
+ }
243
+ while (true);
244
+ };
245
+ protoOf(BatchCalculator$setElevations$slambda).ct = function (_destruct__k2r9zo, completion) {
246
+ var i = new BatchCalculator$setElevations$slambda(this.ss_1, this.ts_1, this.us_1, this.vs_1, this.ws_1, completion);
247
+ i.xs_1 = _destruct__k2r9zo;
248
+ return i;
249
+ };
250
+ function BatchCalculator$setElevations$slambda_0($coordinates, this$0, $zoomLevel, $interpolation, $results, resultContinuation) {
251
+ var i = new BatchCalculator$setElevations$slambda($coordinates, this$0, $zoomLevel, $interpolation, $results, resultContinuation);
252
+ var l = function (_destruct__k2r9zo, $completion) {
253
+ return i.bt(_destruct__k2r9zo, $completion);
254
+ };
255
+ l.$arity = 1;
256
+ return l;
257
+ }
258
+ function $setElevationsCOROUTINE$(_this__u8e3s4, coordinates, zoomLevel, interpolation, maxParallelTiles, resultContinuation) {
259
+ CoroutineImpl.call(this, resultContinuation);
260
+ this.rt_1 = _this__u8e3s4;
261
+ this.st_1 = coordinates;
262
+ this.tt_1 = zoomLevel;
263
+ this.ut_1 = interpolation;
264
+ this.vt_1 = maxParallelTiles;
265
+ }
266
+ protoOf($setElevationsCOROUTINE$).c6 = function () {
267
+ var suspendResult = this.w5_1;
268
+ $sm: do
269
+ try {
270
+ var tmp = this.u5_1;
271
+ switch (tmp) {
272
+ case 0:
273
+ this.v5_1 = 2;
274
+ if (this.st_1.n())
275
+ return emptyList();
276
+ var tmp_0 = this;
277
+ var size = this.st_1.l();
278
+ tmp_0.wt_1 = Array(size);
279
+ var byTile = LinkedHashMap_init_$Create$();
280
+ var iterator = this.st_1.i();
281
+ var index = 0;
282
+ while (iterator.j()) {
283
+ var i = index;
284
+ index = index + 1 | 0;
285
+ var p = iterator.k();
286
+ var tile = ElevationFunctions_instance.xt(p, this.tt_1);
287
+ var key = '' + tile.au_1 + '/' + tile.yt_1 + '/' + tile.zt_1;
288
+ var value = byTile.h1(key);
289
+ var tmp_1;
290
+ if (value == null) {
291
+ var answer = ArrayList_init_$Create$();
292
+ byTile.p2(key, answer);
293
+ tmp_1 = answer;
294
+ } else {
295
+ tmp_1 = value;
296
+ }
297
+ tmp_1.h(i);
298
+ }
299
+
300
+ this.u5_1 = 1;
301
+ var tmp_2 = Flux_instance;
302
+ var tmp_3 = byTile.j1();
303
+ suspendResult = tmp_2.bu(tmp_3, this.vt_1, BatchCalculator$setElevations$slambda_0(this.st_1, this.rt_1, this.tt_1, this.ut_1, this.wt_1, null), this);
304
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
305
+ return suspendResult;
306
+ }
307
+
308
+ continue $sm;
309
+ case 1:
310
+ var tmp_4 = toList(this.wt_1);
311
+ return isInterface(tmp_4, KtList) ? tmp_4 : THROW_CCE();
312
+ case 2:
313
+ throw this.x5_1;
314
+ }
315
+ } catch ($p) {
316
+ var e = $p;
317
+ if (this.v5_1 === 2) {
318
+ throw e;
319
+ } else {
320
+ this.u5_1 = this.v5_1;
321
+ this.x5_1 = e;
322
+ }
323
+ }
324
+ while (true);
325
+ };
326
+ function $getElevationsAlongCOROUTINE$(_this__u8e3s4, path, zoomLevel, step, minDistance, interpolation, smoothingOptions, filterOptions, resultContinuation) {
327
+ CoroutineImpl.call(this, resultContinuation);
328
+ this.ku_1 = _this__u8e3s4;
329
+ this.lu_1 = path;
330
+ this.mu_1 = zoomLevel;
331
+ this.nu_1 = step;
332
+ this.ou_1 = minDistance;
333
+ this.pu_1 = interpolation;
334
+ this.qu_1 = smoothingOptions;
335
+ this.ru_1 = filterOptions;
336
+ }
337
+ protoOf($getElevationsAlongCOROUTINE$).c6 = function () {
338
+ var suspendResult = this.w5_1;
339
+ $sm: do
340
+ try {
341
+ var tmp = this.u5_1;
342
+ switch (tmp) {
343
+ case 0:
344
+ this.v5_1 = 2;
345
+ if (!(this.lu_1.l() >= 2)) {
346
+ var message = 'Path must contain at least 2 coordinates';
347
+ throw IllegalArgumentException_init_$Create$(toString(message));
348
+ }
349
+
350
+ if (!(this.nu_1 > 1.0)) {
351
+ var message_0 = 'Step is too small: ' + formatNumber(this.ku_1, this.nu_1) + ' meters';
352
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
353
+ }
354
+
355
+ var densified = this.ku_1.su(this.lu_1, this.nu_1, this.ou_1);
356
+ this.u5_1 = 1;
357
+ suspendResult = this.ku_1.tu(densified, this.mu_1, this.pu_1, VOID, this);
358
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
359
+ return suspendResult;
360
+ }
361
+
362
+ continue $sm;
363
+ case 1:
364
+ var withElevation = suspendResult;
365
+ var tmp_0;
366
+ var tmp1_safe_receiver = this.qu_1;
367
+ if ((tmp1_safe_receiver == null ? null : tmp1_safe_receiver.gs_1) === true) {
368
+ tmp_0 = withElevation.l() >= 3;
369
+ } else {
370
+ tmp_0 = false;
371
+ }
372
+
373
+ if (tmp_0) {
374
+ var tmp_1 = ElevationSmoother_instance;
375
+ var tmp_2 = withElevation;
376
+ var tmp0_elvis_lhs = this.qu_1.fs_1;
377
+ withElevation = tmp_1.uu(tmp_2, tmp0_elvis_lhs == null ? 50.0 : tmp0_elvis_lhs);
378
+ }
379
+
380
+ var tmp_3;
381
+ var tmp4_safe_receiver = this.ru_1;
382
+ if ((tmp4_safe_receiver == null ? null : tmp4_safe_receiver.js_1) === true) {
383
+ tmp_3 = withElevation.l() > 2;
384
+ } else {
385
+ tmp_3 = false;
386
+ }
387
+
388
+ if (tmp_3) {
389
+ var tmp_4 = DouglasPeucker_instance;
390
+ var tmp_5 = withElevation;
391
+ var tmp2_elvis_lhs = this.ru_1.hs_1;
392
+ var tmp_6 = tmp2_elvis_lhs == null ? 10.0 : tmp2_elvis_lhs;
393
+ var tmp3_elvis_lhs = this.ru_1.is_1;
394
+ withElevation = tmp_4.vu(tmp_5, tmp_6, tmp3_elvis_lhs == null ? 3.0 : tmp3_elvis_lhs);
395
+ }
396
+
397
+ return withElevation;
398
+ case 2:
399
+ throw this.x5_1;
400
+ }
401
+ } catch ($p) {
402
+ var e = $p;
403
+ if (this.v5_1 === 2) {
404
+ throw e;
405
+ } else {
406
+ this.u5_1 = this.v5_1;
407
+ this.x5_1 = e;
408
+ }
409
+ }
410
+ while (true);
411
+ };
412
+ function BatchCalculator(calculator) {
413
+ this.dt_1 = calculator;
414
+ }
415
+ protoOf(BatchCalculator).wu = function (coordinates, zoomLevel, interpolation, maxParallelTiles, $completion) {
416
+ var tmp = new $setElevationsCOROUTINE$(this, coordinates, zoomLevel, interpolation, maxParallelTiles, $completion);
417
+ tmp.w5_1 = Unit_instance;
418
+ tmp.x5_1 = null;
419
+ return tmp.c6();
420
+ };
421
+ protoOf(BatchCalculator).tu = function (coordinates, zoomLevel, interpolation, maxParallelTiles, $completion, $super) {
422
+ maxParallelTiles = maxParallelTiles === VOID ? 10 : maxParallelTiles;
423
+ return $super === VOID ? this.wu(coordinates, zoomLevel, interpolation, maxParallelTiles, $completion) : $super.wu.call(this, coordinates, zoomLevel, interpolation, maxParallelTiles, $completion);
424
+ };
425
+ protoOf(BatchCalculator).xu = function (path, zoomLevel, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion) {
426
+ var tmp = new $getElevationsAlongCOROUTINE$(this, path, zoomLevel, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion);
427
+ tmp.w5_1 = Unit_instance;
428
+ tmp.x5_1 = null;
429
+ return tmp.c6();
430
+ };
431
+ protoOf(BatchCalculator).su = function (path, step, minDistance) {
432
+ if (path.n())
433
+ return emptyList();
434
+ var out = ArrayList_init_$Create$_0(imul(path.l(), 2));
435
+ // Inline function 'kotlin.collections.plusAssign' call
436
+ var element = path.m(0);
437
+ out.h(element);
438
+ var inductionVariable = 0;
439
+ var last = path.l() - 1 | 0;
440
+ if (inductionVariable < last)
441
+ $l$loop: do {
442
+ var i = inductionVariable;
443
+ inductionVariable = inductionVariable + 1 | 0;
444
+ var a = path.m(i);
445
+ var b = path.m(i + 1 | 0);
446
+ var d = Distance_instance.yu(a, b);
447
+ if (d < minDistance)
448
+ continue $l$loop;
449
+ var between = this.zu(a, b, step, d);
450
+ var inductionVariable_0 = 1;
451
+ var last_0 = between.l();
452
+ if (inductionVariable_0 < last_0)
453
+ do {
454
+ var j = inductionVariable_0;
455
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
456
+ // Inline function 'kotlin.collections.plusAssign' call
457
+ var element_0 = between.m(j);
458
+ out.h(element_0);
459
+ }
460
+ while (inductionVariable_0 < last_0);
461
+ }
462
+ while (inductionVariable < last);
463
+ return out;
464
+ };
465
+ protoOf(BatchCalculator).zu = function (a, b, step, distance) {
466
+ if (distance <= step)
467
+ return listOf([a, b]);
468
+ var numSteps = numberToInt(distance / step);
469
+ var out = ArrayList_init_$Create$_0(numSteps + 2 | 0);
470
+ // Inline function 'kotlin.collections.plusAssign' call
471
+ out.h(a);
472
+ var latDiff = b.ht() - a.ht();
473
+ var lonDiff = b.it() - a.it();
474
+ var inductionVariable = 1;
475
+ if (inductionVariable <= numSteps)
476
+ do {
477
+ var i = inductionVariable;
478
+ inductionVariable = inductionVariable + 1 | 0;
479
+ var f = i * step / distance;
480
+ // Inline function 'kotlin.collections.plusAssign' call
481
+ var element = new LatLon(a.ht() + latDiff * f, a.it() + lonDiff * f);
482
+ out.h(element);
483
+ }
484
+ while (!(i === numSteps));
485
+ // Inline function 'kotlin.collections.plusAssign' call
486
+ out.h(b);
487
+ return out;
488
+ };
489
+ function MathConstants() {
490
+ MathConstants_instance = this;
491
+ this.av_1 = 3.141592653589793 / 180.0;
492
+ this.bv_1 = 180.0 / 3.141592653589793;
493
+ }
494
+ var MathConstants_instance;
495
+ function MathConstants_getInstance() {
496
+ if (MathConstants_instance == null)
497
+ new MathConstants();
498
+ return MathConstants_instance;
499
+ }
500
+ function LatLon(latitude, longitude, elevation) {
501
+ elevation = elevation === VOID ? null : elevation;
502
+ this.cv_1 = latitude;
503
+ this.dv_1 = longitude;
504
+ this.ev_1 = elevation;
505
+ }
506
+ protoOf(LatLon).ht = function () {
507
+ return this.cv_1;
508
+ };
509
+ protoOf(LatLon).it = function () {
510
+ return this.dv_1;
511
+ };
512
+ protoOf(LatLon).fv = function () {
513
+ return this.ev_1;
514
+ };
515
+ protoOf(LatLon).toString = function () {
516
+ return 'LatLon(latitude=' + this.cv_1 + ', longitude=' + this.dv_1 + ', elevation=' + this.ev_1 + ')';
517
+ };
518
+ protoOf(LatLon).hashCode = function () {
519
+ var result = getNumberHashCode(this.cv_1);
520
+ result = imul(result, 31) + getNumberHashCode(this.dv_1) | 0;
521
+ result = imul(result, 31) + (this.ev_1 == null ? 0 : getNumberHashCode(this.ev_1)) | 0;
522
+ return result;
523
+ };
524
+ protoOf(LatLon).equals = function (other) {
525
+ if (this === other)
526
+ return true;
527
+ if (!(other instanceof LatLon))
528
+ return false;
529
+ if (!equals(this.cv_1, other.cv_1))
530
+ return false;
531
+ if (!equals(this.dv_1, other.dv_1))
532
+ return false;
533
+ if (!equals(this.ev_1, other.ev_1))
534
+ return false;
535
+ return true;
536
+ };
537
+ function LatLonElevation(latitude, longitude, elevation) {
538
+ this.gv_1 = latitude;
539
+ this.hv_1 = longitude;
540
+ this.iv_1 = elevation;
541
+ }
542
+ protoOf(LatLonElevation).ht = function () {
543
+ return this.gv_1;
544
+ };
545
+ protoOf(LatLonElevation).it = function () {
546
+ return this.hv_1;
547
+ };
548
+ protoOf(LatLonElevation).fv = function () {
549
+ return this.iv_1;
550
+ };
551
+ protoOf(LatLonElevation).toString = function () {
552
+ return 'LatLonElevation(latitude=' + this.gv_1 + ', longitude=' + this.hv_1 + ', elevation=' + this.iv_1 + ')';
553
+ };
554
+ protoOf(LatLonElevation).hashCode = function () {
555
+ var result = getNumberHashCode(this.gv_1);
556
+ result = imul(result, 31) + getNumberHashCode(this.hv_1) | 0;
557
+ result = imul(result, 31) + getNumberHashCode(this.iv_1) | 0;
558
+ return result;
559
+ };
560
+ protoOf(LatLonElevation).equals = function (other) {
561
+ if (this === other)
562
+ return true;
563
+ if (!(other instanceof LatLonElevation))
564
+ return false;
565
+ if (!equals(this.gv_1, other.gv_1))
566
+ return false;
567
+ if (!equals(this.hv_1, other.hv_1))
568
+ return false;
569
+ if (!equals(this.iv_1, other.iv_1))
570
+ return false;
571
+ return true;
572
+ };
573
+ function Distance() {
574
+ }
575
+ protoOf(Distance).yu = function (coord1, coord2) {
576
+ var lat1Rad = coord1.ht() * MathConstants_getInstance().av_1;
577
+ var lat2Rad = coord2.ht() * MathConstants_getInstance().av_1;
578
+ var deltaLat = (coord2.ht() - coord1.ht()) * MathConstants_getInstance().av_1;
579
+ var deltaLon = (coord2.it() - coord1.it()) * MathConstants_getInstance().av_1;
580
+ // Inline function 'kotlin.math.sin' call
581
+ var x = deltaLat / 2.0;
582
+ var sinHalfLat = Math.sin(x);
583
+ // Inline function 'kotlin.math.sin' call
584
+ var x_0 = deltaLon / 2.0;
585
+ var sinHalfLon = Math.sin(x_0);
586
+ var tmp = sinHalfLat * sinHalfLat;
587
+ // Inline function 'kotlin.math.cos' call
588
+ var tmp_0 = Math.cos(lat1Rad);
589
+ // Inline function 'kotlin.math.cos' call
590
+ var a = tmp + tmp_0 * Math.cos(lat2Rad) * sinHalfLon * sinHalfLon;
591
+ // Inline function 'kotlin.math.sqrt' call
592
+ var tmp0 = Math.sqrt(a);
593
+ // Inline function 'kotlin.math.sqrt' call
594
+ var x_1 = 1.0 - a;
595
+ // Inline function 'kotlin.math.atan2' call
596
+ var x_2 = Math.sqrt(x_1);
597
+ var c = 2.0 * Math.atan2(tmp0, x_2);
598
+ return 6371000.0 * c;
599
+ };
600
+ protoOf(Distance).jv = function (points) {
601
+ if (points.n()) {
602
+ // Inline function 'kotlin.doubleArrayOf' call
603
+ return new Float64Array([0.0]);
604
+ }
605
+ var out = new Float64Array(points.l());
606
+ var inductionVariable = 1;
607
+ var last = points.l();
608
+ if (inductionVariable < last)
609
+ do {
610
+ var i = inductionVariable;
611
+ inductionVariable = inductionVariable + 1 | 0;
612
+ out[i] = out[i - 1 | 0] + this.yu(points.m(i - 1 | 0), points.m(i));
613
+ }
614
+ while (inductionVariable < last);
615
+ return out;
616
+ };
617
+ var Distance_instance;
618
+ function Distance_getInstance() {
619
+ return Distance_instance;
620
+ }
621
+ function simplifyRecursive($this, points, firstIndex, lastIndex, tolerance, zExaggeration, out) {
622
+ var firstEcef = EcefConverter_instance.kv(points.m(firstIndex), zExaggeration);
623
+ var lastEcef = EcefConverter_instance.kv(points.m(lastIndex), zExaggeration);
624
+ var maxDistance = 0.0;
625
+ var maxIndex = -1;
626
+ var inductionVariable = firstIndex + 1 | 0;
627
+ if (inductionVariable < lastIndex)
628
+ do {
629
+ var i = inductionVariable;
630
+ inductionVariable = inductionVariable + 1 | 0;
631
+ var d = EcefConverter_instance.kv(points.m(i), zExaggeration).ov(firstEcef, lastEcef);
632
+ if (d > maxDistance) {
633
+ maxDistance = d;
634
+ maxIndex = i;
635
+ }
636
+ }
637
+ while (inductionVariable < lastIndex);
638
+ if (maxDistance > tolerance && !(maxIndex === -1)) {
639
+ if ((maxIndex - firstIndex | 0) > 1) {
640
+ simplifyRecursive($this, points, firstIndex, maxIndex, tolerance, zExaggeration, out);
641
+ }
642
+ out.h(points.m(maxIndex));
643
+ if ((lastIndex - maxIndex | 0) > 1) {
644
+ simplifyRecursive($this, points, maxIndex, lastIndex, tolerance, zExaggeration, out);
645
+ }
646
+ }
647
+ }
648
+ function DouglasPeucker() {
649
+ }
650
+ protoOf(DouglasPeucker).vu = function (points, tolerance, zExaggeration) {
651
+ if (points.l() <= 2)
652
+ return toList_0(points);
653
+ var lastIndex = get_lastIndex(points);
654
+ // Inline function 'kotlin.collections.buildList' call
655
+ // Inline function 'kotlin.collections.buildListInternal' call
656
+ var capacity = points.l();
657
+ checkBuilderCapacity(capacity);
658
+ // Inline function 'kotlin.apply' call
659
+ var this_0 = ArrayList_init_$Create$_0(capacity);
660
+ this_0.h(points.m(0));
661
+ simplifyRecursive(DouglasPeucker_instance, points, 0, lastIndex, tolerance, zExaggeration, this_0);
662
+ this_0.h(points.m(lastIndex));
663
+ return this_0.c3();
664
+ };
665
+ var DouglasPeucker_instance;
666
+ function DouglasPeucker_getInstance() {
667
+ return DouglasPeucker_instance;
668
+ }
669
+ function EcefConverter() {
670
+ }
671
+ protoOf(EcefConverter).kv = function (coordinates, zExaggeration) {
672
+ var latRad = coordinates.ht() * MathConstants_getInstance().av_1;
673
+ var lonRad = coordinates.it() * MathConstants_getInstance().av_1;
674
+ var tmp0_elvis_lhs = coordinates.fv();
675
+ var elevationExaggerated = zExaggeration * (tmp0_elvis_lhs == null ? 0.0 : tmp0_elvis_lhs);
676
+ // Inline function 'kotlin.math.sin' call
677
+ var sinLat = Math.sin(latRad);
678
+ // Inline function 'kotlin.math.sqrt' call
679
+ var x = 1.0 - 0.00669437999014 * sinLat * sinLat;
680
+ var n = 6378137.0 / Math.sqrt(x);
681
+ // Inline function 'kotlin.math.cos' call
682
+ var cosLat = Math.cos(latRad);
683
+ // Inline function 'kotlin.math.cos' call
684
+ var cosLon = Math.cos(lonRad);
685
+ // Inline function 'kotlin.math.sin' call
686
+ var sinLon = Math.sin(lonRad);
687
+ var x_0 = (n + elevationExaggerated) * cosLat * cosLon;
688
+ var y = (n + elevationExaggerated) * cosLat * sinLon;
689
+ var z = (n * (1.0 - 0.00669437999014) + elevationExaggerated) * sinLat;
690
+ return new Vector3D(x_0, y, z);
691
+ };
692
+ var EcefConverter_instance;
693
+ function EcefConverter_getInstance() {
694
+ return EcefConverter_instance;
695
+ }
696
+ function getInterpolatedElevation($this, coords, zoomLevel, $completion) {
697
+ var tmp = new $getInterpolatedElevationCOROUTINE$($this, coords, zoomLevel, $completion);
698
+ tmp.w5_1 = Unit_instance;
699
+ tmp.x5_1 = null;
700
+ return tmp.c6();
701
+ }
702
+ function elevationFromPixel($this, pixel, $completion) {
703
+ var tmp = new $elevationFromPixelCOROUTINE$($this, pixel, $completion);
704
+ tmp.w5_1 = Unit_instance;
705
+ tmp.x5_1 = null;
706
+ return tmp.c6();
707
+ }
708
+ function $getElevationCOROUTINE$(_this__u8e3s4, coords, zoomLevel, interpolation, resultContinuation) {
709
+ CoroutineImpl.call(this, resultContinuation);
710
+ this.cx_1 = _this__u8e3s4;
711
+ this.dx_1 = coords;
712
+ this.ex_1 = zoomLevel;
713
+ this.fx_1 = interpolation;
714
+ }
715
+ protoOf($getElevationCOROUTINE$).c6 = function () {
716
+ var suspendResult = this.w5_1;
717
+ $sm: do
718
+ try {
719
+ var tmp = this.u5_1;
720
+ switch (tmp) {
721
+ case 0:
722
+ this.v5_1 = 5;
723
+ this.v5_1 = 4;
724
+ if (this.fx_1) {
725
+ this.u5_1 = 2;
726
+ suspendResult = getInterpolatedElevation(this.cx_1, this.dx_1, this.ex_1, this);
727
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
728
+ return suspendResult;
729
+ }
730
+ continue $sm;
731
+ } else {
732
+ var pixel = ElevationFunctions_instance.ix(this.dx_1, this.ex_1, this.cx_1.ft_1);
733
+ this.u5_1 = 1;
734
+ suspendResult = elevationFromPixel(this.cx_1, pixel, this);
735
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
736
+ return suspendResult;
737
+ }
738
+ continue $sm;
739
+ }
740
+
741
+ case 1:
742
+ this.hx_1 = suspendResult;
743
+ this.u5_1 = 3;
744
+ continue $sm;
745
+ case 2:
746
+ this.hx_1 = suspendResult;
747
+ this.u5_1 = 3;
748
+ continue $sm;
749
+ case 3:
750
+ this.gx_1 = this.hx_1;
751
+ this.v5_1 = 5;
752
+ this.u5_1 = 6;
753
+ continue $sm;
754
+ case 4:
755
+ this.v5_1 = 5;
756
+ var tmp_0 = this.x5_1;
757
+ if (tmp_0 instanceof Error) {
758
+ var t = this.x5_1;
759
+ var tmp_1 = this;
760
+ throw IllegalStateException_init_$Create$('Failed to get elevation: ' + t.message, t);
761
+ } else {
762
+ throw this.x5_1;
763
+ }
764
+
765
+ case 5:
766
+ throw this.x5_1;
767
+ case 6:
768
+ this.v5_1 = 5;
769
+ return this.gx_1;
770
+ }
771
+ } catch ($p) {
772
+ var e = $p;
773
+ if (this.v5_1 === 5) {
774
+ throw e;
775
+ } else {
776
+ this.u5_1 = this.v5_1;
777
+ this.x5_1 = e;
778
+ }
779
+ }
780
+ while (true);
781
+ };
782
+ function $getInterpolatedElevationCOROUTINE$(_this__u8e3s4, coords, zoomLevel, resultContinuation) {
783
+ CoroutineImpl.call(this, resultContinuation);
784
+ this.xv_1 = _this__u8e3s4;
785
+ this.yv_1 = coords;
786
+ this.zv_1 = zoomLevel;
787
+ }
788
+ protoOf($getInterpolatedElevationCOROUTINE$).c6 = function () {
789
+ var suspendResult = this.w5_1;
790
+ $sm: do
791
+ try {
792
+ var tmp = this.u5_1;
793
+ switch (tmp) {
794
+ case 0:
795
+ this.v5_1 = 5;
796
+ this.hw_1 = ElevationFunctions_instance.jx(this.yv_1, this.zv_1, this.xv_1.ft_1);
797
+ var tmp_0 = this;
798
+ var x = this.hw_1.lx_1;
799
+ tmp_0.iw_1 = numberToInt(Math.floor(x));
800
+ var tmp_1 = this;
801
+ var x_0 = this.hw_1.mx_1;
802
+ tmp_1.jw_1 = numberToInt(Math.floor(x_0));
803
+ this.gw_1 = this.iw_1 + 1 | 0;
804
+ this.fw_1 = this.jw_1 + 1 | 0;
805
+ this.bw_1 = this.hw_1.lx_1 - this.iw_1;
806
+ this.aw_1 = this.hw_1.mx_1 - this.jw_1;
807
+ this.u5_1 = 1;
808
+ suspendResult = elevationFromPixel(this.xv_1, ElevationFunctions_instance.nx(new Pixel(this.hw_1.kx_1, this.iw_1, this.jw_1), this.xv_1.ft_1), this);
809
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
810
+ return suspendResult;
811
+ }
812
+
813
+ continue $sm;
814
+ case 1:
815
+ this.ew_1 = suspendResult;
816
+ this.u5_1 = 2;
817
+ suspendResult = elevationFromPixel(this.xv_1, ElevationFunctions_instance.nx(new Pixel(this.hw_1.kx_1, this.gw_1, this.jw_1), this.xv_1.ft_1), this);
818
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
819
+ return suspendResult;
820
+ }
821
+
822
+ continue $sm;
823
+ case 2:
824
+ this.dw_1 = suspendResult;
825
+ this.u5_1 = 3;
826
+ suspendResult = elevationFromPixel(this.xv_1, ElevationFunctions_instance.nx(new Pixel(this.hw_1.kx_1, this.iw_1, this.fw_1), this.xv_1.ft_1), this);
827
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
828
+ return suspendResult;
829
+ }
830
+
831
+ continue $sm;
832
+ case 3:
833
+ this.cw_1 = suspendResult;
834
+ this.u5_1 = 4;
835
+ suspendResult = elevationFromPixel(this.xv_1, ElevationFunctions_instance.nx(new Pixel(this.hw_1.kx_1, this.gw_1, this.fw_1), this.xv_1.ft_1), this);
836
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
837
+ return suspendResult;
838
+ }
839
+
840
+ continue $sm;
841
+ case 4:
842
+ var p11 = suspendResult;
843
+ var top = this.ew_1 * (1.0 - this.bw_1) + this.dw_1 * this.bw_1;
844
+ var bottom = this.cw_1 * (1.0 - this.bw_1) + p11 * this.bw_1;
845
+ return top * (1.0 - this.aw_1) + bottom * this.aw_1;
846
+ case 5:
847
+ throw this.x5_1;
848
+ }
849
+ } catch ($p) {
850
+ var e = $p;
851
+ if (this.v5_1 === 5) {
852
+ throw e;
853
+ } else {
854
+ this.u5_1 = this.v5_1;
855
+ this.x5_1 = e;
856
+ }
857
+ }
858
+ while (true);
859
+ };
860
+ function $elevationFromPixelCOROUTINE$(_this__u8e3s4, pixel, resultContinuation) {
861
+ CoroutineImpl.call(this, resultContinuation);
862
+ this.sw_1 = _this__u8e3s4;
863
+ this.tw_1 = pixel;
864
+ }
865
+ protoOf($elevationFromPixelCOROUTINE$).c6 = function () {
866
+ var suspendResult = this.w5_1;
867
+ $sm: do
868
+ try {
869
+ var tmp = this.u5_1;
870
+ switch (tmp) {
871
+ case 0:
872
+ this.v5_1 = 2;
873
+ this.u5_1 = 1;
874
+ suspendResult = this.sw_1.et_1.ux(this.tw_1.ox_1, this);
875
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
876
+ return suspendResult;
877
+ }
878
+
879
+ continue $sm;
880
+ case 1:
881
+ return suspendResult.ay(this.tw_1);
882
+ case 2:
883
+ throw this.x5_1;
884
+ }
885
+ } catch ($p) {
886
+ var e = $p;
887
+ if (this.v5_1 === 2) {
888
+ throw e;
889
+ } else {
890
+ this.u5_1 = this.v5_1;
891
+ this.x5_1 = e;
892
+ }
893
+ }
894
+ while (true);
895
+ };
896
+ function ElevationCalculator(tileManager, tileSize) {
897
+ tileSize = tileSize === VOID ? 256 : tileSize;
898
+ this.et_1 = tileManager;
899
+ this.ft_1 = tileSize;
900
+ }
901
+ protoOf(ElevationCalculator).gt = function (coords, zoomLevel, interpolation, $completion) {
902
+ var tmp = new $getElevationCOROUTINE$(this, coords, zoomLevel, interpolation, $completion);
903
+ tmp.w5_1 = Unit_instance;
904
+ tmp.x5_1 = null;
905
+ return tmp.c6();
906
+ };
907
+ function formatNumber_0($this, d) {
908
+ var asLong = numberToLong(d);
909
+ return toNumber(asLong) === d ? asLong.toString() : d.toString();
910
+ }
911
+ function ElevationFunctions() {
912
+ }
913
+ protoOf(ElevationFunctions).by = function (degrees) {
914
+ return degrees * MathConstants_getInstance().av_1;
915
+ };
916
+ protoOf(ElevationFunctions).cy = function (lat) {
917
+ return lat >= -85.0511 && lat <= 85.0511;
918
+ };
919
+ protoOf(ElevationFunctions).dy = function (lon) {
920
+ return -180.0 <= lon ? lon <= 180.0 : false;
921
+ };
922
+ protoOf(ElevationFunctions).ey = function (zoom) {
923
+ return 0 <= zoom ? zoom <= 15 : false;
924
+ };
925
+ protoOf(ElevationFunctions).nx = function (pixel, tileSize) {
926
+ var x = pixel.px_1;
927
+ var y = pixel.qx_1;
928
+ var tileX = pixel.ox_1.yt_1;
929
+ var tileY = pixel.ox_1.zt_1;
930
+ var z = pixel.ox_1.au_1;
931
+ if (x < 0) {
932
+ x = x + tileSize | 0;
933
+ tileX = tileX - 1 | 0;
934
+ }
935
+ if (x >= tileSize) {
936
+ x = x - tileSize | 0;
937
+ tileX = tileX + 1 | 0;
938
+ }
939
+ if (y < 0) {
940
+ y = y + tileSize | 0;
941
+ tileY = tileY - 1 | 0;
942
+ }
943
+ if (y >= tileSize) {
944
+ y = y - tileSize | 0;
945
+ tileY = tileY + 1 | 0;
946
+ }
947
+ var maxTile = (1 << z) - 1 | 0;
948
+ tileX = coerceIn(tileX, 0, maxTile);
949
+ tileY = coerceIn(tileY, 0, maxTile);
950
+ return new Pixel(new TileCoordinates(tileX, tileY, z), x, y);
951
+ };
952
+ protoOf(ElevationFunctions).fy = function (coords, z) {
953
+ // Inline function 'kotlin.require' call
954
+ if (!this.cy(coords.ht())) {
955
+ var message = 'Invalid latitude: ' + formatNumber_0(ElevationFunctions_instance, coords.ht()) + '. Must be between -85.0511 and 85.0511';
956
+ throw IllegalArgumentException_init_$Create$(toString(message));
957
+ }
958
+ // Inline function 'kotlin.require' call
959
+ if (!this.dy(coords.it())) {
960
+ var message_0 = 'Invalid longitude: ' + formatNumber_0(ElevationFunctions_instance, coords.it()) + '. Must be between -180 and 180';
961
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
962
+ }
963
+ // Inline function 'kotlin.require' call
964
+ if (!this.ey(z)) {
965
+ var message_1 = 'Invalid zoom level: ' + z + '. Must be between 0 and 15';
966
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
967
+ }
968
+ var lat = this.by(coords.ht());
969
+ var n = 1 << z;
970
+ var xFloat = (coords.it() + 180.0) / 360.0 * n;
971
+ // Inline function 'kotlin.math.tan' call
972
+ var tmp = Math.tan(lat);
973
+ // Inline function 'kotlin.math.cos' call
974
+ // Inline function 'kotlin.math.ln' call
975
+ var x = tmp + 1.0 / Math.cos(lat);
976
+ var yFloat = (1.0 - Math.log(x) / 3.141592653589793) / 2.0 * n;
977
+ var maxTile = (1 << z) - 1 | 0;
978
+ // Inline function 'kotlin.math.floor' call
979
+ var tmp$ret$9 = Math.floor(xFloat);
980
+ var x_0 = coerceIn(numberToInt(tmp$ret$9), 0, maxTile);
981
+ // Inline function 'kotlin.math.floor' call
982
+ var tmp$ret$10 = Math.floor(yFloat);
983
+ var y = coerceIn(numberToInt(tmp$ret$10), 0, maxTile);
984
+ return new TileCoordinatesFloat(x_0, y, xFloat, yFloat, z);
985
+ };
986
+ protoOf(ElevationFunctions).xt = function (coords, z) {
987
+ var tile = this.fy(coords, z);
988
+ return new TileCoordinates(tile.gy_1, tile.hy_1, tile.ky_1);
989
+ };
990
+ protoOf(ElevationFunctions).ix = function (coords, z, tileSize) {
991
+ var tile = this.fy(coords, z);
992
+ // Inline function 'kotlin.math.floor' call
993
+ var x = (tile.iy_1 - tile.gy_1) * tileSize;
994
+ var tmp$ret$0 = Math.floor(x);
995
+ var px = coerceIn(numberToInt(tmp$ret$0), 0, tileSize - 1 | 0);
996
+ // Inline function 'kotlin.math.floor' call
997
+ var x_0 = (tile.jy_1 - tile.hy_1) * tileSize;
998
+ var tmp$ret$1 = Math.floor(x_0);
999
+ var py = coerceIn(numberToInt(tmp$ret$1), 0, tileSize - 1 | 0);
1000
+ return new Pixel(new TileCoordinates(tile.gy_1, tile.hy_1, z), px, py);
1001
+ };
1002
+ protoOf(ElevationFunctions).jx = function (coords, z, tileSize) {
1003
+ var tile = this.fy(coords, z);
1004
+ var px = (tile.iy_1 - tile.gy_1) * tileSize;
1005
+ var py = (tile.jy_1 - tile.hy_1) * tileSize;
1006
+ return new PixelFloat(new TileCoordinates(tile.gy_1, tile.hy_1, z), px, py);
1007
+ };
1008
+ var ElevationFunctions_instance;
1009
+ function ElevationFunctions_getInstance() {
1010
+ return ElevationFunctions_instance;
1011
+ }
1012
+ function fetchAndDecodeTile$ref() {
1013
+ }
1014
+ protoOf(fetchAndDecodeTile$ref).ly = function (p0, $completion) {
1015
+ return fetchAndDecodeTile(p0, $completion);
1016
+ };
1017
+ protoOf(fetchAndDecodeTile$ref).k6 = function (p1, $completion) {
1018
+ return this.ly((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1019
+ };
1020
+ function fetchAndDecodeTile$ref_0() {
1021
+ var i = new fetchAndDecodeTile$ref();
1022
+ var l = function (p0, $completion) {
1023
+ return i.ly(p0, $completion);
1024
+ };
1025
+ l.callableName = 'fetchAndDecodeTile';
1026
+ l.$arity = 1;
1027
+ return l;
1028
+ }
1029
+ function ElevationProvider(config, fetcher) {
1030
+ config = config === VOID ? new ElevationProviderConfig() : config;
1031
+ var tmp;
1032
+ if (fetcher === VOID) {
1033
+ tmp = fetchAndDecodeTile$ref_0();
1034
+ } else {
1035
+ tmp = fetcher;
1036
+ }
1037
+ fetcher = tmp;
1038
+ this.my_1 = config;
1039
+ var containsArg = this.my_1.qy_1;
1040
+ // Inline function 'kotlin.require' call
1041
+ if (!(0 <= containsArg ? containsArg <= 15 : false)) {
1042
+ var message = 'Invalid zoom level: ' + this.my_1.qy_1 + '. Must be an integer between 0 and 15';
1043
+ throw IllegalArgumentException_init_$Create$(toString(message));
1044
+ }
1045
+ // Inline function 'kotlin.require' call
1046
+ if (!(this.my_1.ry_1 > 0)) {
1047
+ var message_0 = 'Invalid cache size: ' + this.my_1.ry_1 + '. Must be a positive integer';
1048
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
1049
+ }
1050
+ // Inline function 'kotlin.require' call
1051
+ if (!(this.my_1.ty_1 > 0 && (this.my_1.ty_1 & (this.my_1.ty_1 - 1 | 0)) === 0)) {
1052
+ var message_1 = 'Invalid tile size: ' + this.my_1.ty_1 + '. Must be a positive power of 2';
1053
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
1054
+ }
1055
+ this.ny_1 = new TileManager(this.my_1.sy_1, this.my_1.ry_1, fetcher);
1056
+ this.oy_1 = new ElevationCalculator(this.ny_1, this.my_1.ty_1);
1057
+ this.py_1 = new BatchCalculator(this.oy_1);
1058
+ }
1059
+ protoOf(ElevationProvider).vy = function (latitude, longitude, interpolation, $completion) {
1060
+ return this.oy_1.gt(new LatLon(latitude, longitude), this.my_1.qy_1, interpolation, $completion);
1061
+ };
1062
+ protoOf(ElevationProvider).wy = function (coordinates, interpolation, $completion) {
1063
+ return this.py_1.tu(coordinates, this.my_1.qy_1, interpolation, VOID, $completion);
1064
+ };
1065
+ protoOf(ElevationProvider).xy = function (coordinates, interpolation, $completion, $super) {
1066
+ interpolation = interpolation === VOID ? true : interpolation;
1067
+ return $super === VOID ? this.wy(coordinates, interpolation, $completion) : $super.wy.call(this, coordinates, interpolation, $completion);
1068
+ };
1069
+ protoOf(ElevationProvider).yy = function (path, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion) {
1070
+ return this.py_1.xu(path, this.my_1.qy_1, step, minDistance, interpolation, smoothingOptions, filterOptions, $completion);
1071
+ };
1072
+ function ElevationProviderConfig(zoomLevel, cacheSize, tileUrlTemplate, tileSize, attribution) {
1073
+ zoomLevel = zoomLevel === VOID ? 12 : zoomLevel;
1074
+ cacheSize = cacheSize === VOID ? 100 : cacheSize;
1075
+ tileUrlTemplate = tileUrlTemplate === VOID ? 'https://tiles.mapterhorn.com/{z}/{x}/{y}.webp' : tileUrlTemplate;
1076
+ tileSize = tileSize === VOID ? 512 : tileSize;
1077
+ attribution = attribution === VOID ? new Attribution('Mapterhorn elevation data. See mapterhorn.com/attribution/ for details.', 'https://mapterhorn.com/attribution/') : attribution;
1078
+ this.qy_1 = zoomLevel;
1079
+ this.ry_1 = cacheSize;
1080
+ this.sy_1 = tileUrlTemplate;
1081
+ this.ty_1 = tileSize;
1082
+ this.uy_1 = attribution;
1083
+ }
1084
+ protoOf(ElevationProviderConfig).toString = function () {
1085
+ return 'ElevationProviderConfig(zoomLevel=' + this.qy_1 + ', cacheSize=' + this.ry_1 + ', tileUrlTemplate=' + this.sy_1 + ', tileSize=' + this.ty_1 + ', attribution=' + this.uy_1.toString() + ')';
1086
+ };
1087
+ protoOf(ElevationProviderConfig).hashCode = function () {
1088
+ var result = this.qy_1;
1089
+ result = imul(result, 31) + this.ry_1 | 0;
1090
+ result = imul(result, 31) + getStringHashCode(this.sy_1) | 0;
1091
+ result = imul(result, 31) + this.ty_1 | 0;
1092
+ result = imul(result, 31) + this.uy_1.hashCode() | 0;
1093
+ return result;
1094
+ };
1095
+ protoOf(ElevationProviderConfig).equals = function (other) {
1096
+ if (this === other)
1097
+ return true;
1098
+ if (!(other instanceof ElevationProviderConfig))
1099
+ return false;
1100
+ if (!(this.qy_1 === other.qy_1))
1101
+ return false;
1102
+ if (!(this.ry_1 === other.ry_1))
1103
+ return false;
1104
+ if (!(this.sy_1 === other.sy_1))
1105
+ return false;
1106
+ if (!(this.ty_1 === other.ty_1))
1107
+ return false;
1108
+ if (!this.uy_1.equals(other.uy_1))
1109
+ return false;
1110
+ return true;
1111
+ };
1112
+ function Attribution(text, url) {
1113
+ url = url === VOID ? null : url;
1114
+ this.zy_1 = text;
1115
+ this.az_1 = url;
1116
+ }
1117
+ protoOf(Attribution).toString = function () {
1118
+ return 'Attribution(text=' + this.zy_1 + ', url=' + this.az_1 + ')';
1119
+ };
1120
+ protoOf(Attribution).hashCode = function () {
1121
+ var result = getStringHashCode(this.zy_1);
1122
+ result = imul(result, 31) + (this.az_1 == null ? 0 : getStringHashCode(this.az_1)) | 0;
1123
+ return result;
1124
+ };
1125
+ protoOf(Attribution).equals = function (other) {
1126
+ if (this === other)
1127
+ return true;
1128
+ if (!(other instanceof Attribution))
1129
+ return false;
1130
+ if (!(this.zy_1 === other.zy_1))
1131
+ return false;
1132
+ if (!(this.az_1 == other.az_1))
1133
+ return false;
1134
+ return true;
1135
+ };
1136
+ function computeSmoothedValue($this, index, points, distances, windowSize) {
1137
+ var current = distances[index];
1138
+ var startIndex = index;
1139
+ while (startIndex > 0 && current - distances[startIndex - 1 | 0] <= windowSize) {
1140
+ startIndex = startIndex - 1 | 0;
1141
+ }
1142
+ var endIndex = index;
1143
+ while (endIndex < (points.l() - 1 | 0) && distances[endIndex + 1 | 0] - current <= windowSize) {
1144
+ endIndex = endIndex + 1 | 0;
1145
+ }
1146
+ var totalWeight = 0.0;
1147
+ var weightedSum = 0.0;
1148
+ var inductionVariable = startIndex;
1149
+ var last = endIndex;
1150
+ if (inductionVariable <= last)
1151
+ do {
1152
+ var j = inductionVariable;
1153
+ inductionVariable = inductionVariable + 1 | 0;
1154
+ // Inline function 'kotlin.math.absoluteValue' call
1155
+ var this_0 = distances[j] - current;
1156
+ var d = Math.abs(this_0);
1157
+ var weight = 1.0 - d / windowSize;
1158
+ totalWeight = totalWeight + weight;
1159
+ weightedSum = weightedSum + points.m(j).fv() * weight;
1160
+ }
1161
+ while (!(j === last));
1162
+ return totalWeight > 0.0 ? weightedSum / totalWeight : points.m(index).fv();
1163
+ }
1164
+ function formatWindow($this, w) {
1165
+ var asLong = numberToLong(w);
1166
+ return toNumber(asLong) === w ? asLong.toString() : w.toString();
1167
+ }
1168
+ function ElevationSmoother() {
1169
+ }
1170
+ protoOf(ElevationSmoother).uu = function (points, windowSize) {
1171
+ if (points.l() < 3)
1172
+ return points;
1173
+ // Inline function 'kotlin.require' call
1174
+ if (!(windowSize > 0.0)) {
1175
+ var message = 'Invalid window size: ' + formatWindow(ElevationSmoother_instance, windowSize) + '. Must be positive';
1176
+ throw IllegalArgumentException_init_$Create$(toString(message));
1177
+ }
1178
+ var distances = Distance_instance.jv(points);
1179
+ // Inline function 'kotlin.collections.List' call
1180
+ // Inline function 'kotlin.collections.MutableList' call
1181
+ var size = points.l();
1182
+ var list = ArrayList_init_$Create$_0(size);
1183
+ // Inline function 'kotlin.repeat' call
1184
+ var inductionVariable = 0;
1185
+ if (inductionVariable < size)
1186
+ do {
1187
+ var index = inductionVariable;
1188
+ inductionVariable = inductionVariable + 1 | 0;
1189
+ var smoothed = computeSmoothedValue(ElevationSmoother_instance, index, points, distances, windowSize);
1190
+ var tmp$ret$6 = new LatLonElevation(points.m(index).ht(), points.m(index).it(), smoothed);
1191
+ list.h(tmp$ret$6);
1192
+ }
1193
+ while (inductionVariable < size);
1194
+ return list;
1195
+ };
1196
+ var ElevationSmoother_instance;
1197
+ function ElevationSmoother_getInstance() {
1198
+ return ElevationSmoother_instance;
1199
+ }
1200
+ function Flux$forEachParallel$slambda$slambda($semaphore, $action, $item, resultContinuation) {
1201
+ this.jz_1 = $semaphore;
1202
+ this.kz_1 = $action;
1203
+ this.lz_1 = $item;
1204
+ CoroutineImpl.call(this, resultContinuation);
1205
+ }
1206
+ protoOf(Flux$forEachParallel$slambda$slambda).pz = function ($this$async, $completion) {
1207
+ var tmp = this.qz($this$async, $completion);
1208
+ tmp.w5_1 = Unit_instance;
1209
+ tmp.x5_1 = null;
1210
+ return tmp.c6();
1211
+ };
1212
+ protoOf(Flux$forEachParallel$slambda$slambda).k6 = function (p1, $completion) {
1213
+ return this.pz((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1214
+ };
1215
+ protoOf(Flux$forEachParallel$slambda$slambda).c6 = function () {
1216
+ var suspendResult = this.w5_1;
1217
+ $sm: do
1218
+ try {
1219
+ var tmp = this.u5_1;
1220
+ switch (tmp) {
1221
+ case 0:
1222
+ this.v5_1 = 6;
1223
+ this.nz_1 = this.jz_1;
1224
+ this.u5_1 = 1;
1225
+ suspendResult = this.nz_1.nq(this);
1226
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1227
+ return suspendResult;
1228
+ }
1229
+
1230
+ continue $sm;
1231
+ case 1:
1232
+ this.oz_1 = Unit_instance;
1233
+ this.u5_1 = 2;
1234
+ continue $sm;
1235
+ case 2:
1236
+ this.v5_1 = 5;
1237
+ this.u5_1 = 3;
1238
+ suspendResult = this.kz_1(this.lz_1, this);
1239
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1240
+ return suspendResult;
1241
+ }
1242
+
1243
+ continue $sm;
1244
+ case 3:
1245
+ this.oz_1 = Unit_instance;
1246
+ this.v5_1 = 6;
1247
+ this.u5_1 = 4;
1248
+ continue $sm;
1249
+ case 4:
1250
+ this.oz_1;
1251
+ this.v5_1 = 6;
1252
+ this.nz_1.hq();
1253
+ return Unit_instance;
1254
+ case 5:
1255
+ this.v5_1 = 6;
1256
+ var t = this.x5_1;
1257
+ this.nz_1.hq();
1258
+ throw t;
1259
+ case 6:
1260
+ throw this.x5_1;
1261
+ }
1262
+ } catch ($p) {
1263
+ var e = $p;
1264
+ if (this.v5_1 === 6) {
1265
+ throw e;
1266
+ } else {
1267
+ this.u5_1 = this.v5_1;
1268
+ this.x5_1 = e;
1269
+ }
1270
+ }
1271
+ while (true);
1272
+ };
1273
+ protoOf(Flux$forEachParallel$slambda$slambda).qz = function ($this$async, completion) {
1274
+ var i = new Flux$forEachParallel$slambda$slambda(this.jz_1, this.kz_1, this.lz_1, completion);
1275
+ i.mz_1 = $this$async;
1276
+ return i;
1277
+ };
1278
+ function Flux$forEachParallel$slambda$slambda_0($semaphore, $action, $item, resultContinuation) {
1279
+ var i = new Flux$forEachParallel$slambda$slambda($semaphore, $action, $item, resultContinuation);
1280
+ var l = function ($this$async, $completion) {
1281
+ return i.pz($this$async, $completion);
1282
+ };
1283
+ l.$arity = 1;
1284
+ return l;
1285
+ }
1286
+ function Flux$forEachParallel$slambda($maxParallel, $items, $action, resultContinuation) {
1287
+ this.zz_1 = $maxParallel;
1288
+ this.a10_1 = $items;
1289
+ this.b10_1 = $action;
1290
+ CoroutineImpl.call(this, resultContinuation);
1291
+ }
1292
+ protoOf(Flux$forEachParallel$slambda).d10 = function ($this$coroutineScope, $completion) {
1293
+ var tmp = this.qz($this$coroutineScope, $completion);
1294
+ tmp.w5_1 = Unit_instance;
1295
+ tmp.x5_1 = null;
1296
+ return tmp.c6();
1297
+ };
1298
+ protoOf(Flux$forEachParallel$slambda).k6 = function (p1, $completion) {
1299
+ return this.d10((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
1300
+ };
1301
+ protoOf(Flux$forEachParallel$slambda).c6 = function () {
1302
+ var suspendResult = this.w5_1;
1303
+ $sm: do
1304
+ try {
1305
+ var tmp = this.u5_1;
1306
+ switch (tmp) {
1307
+ case 0:
1308
+ this.v5_1 = 2;
1309
+ var semaphore = Semaphore(this.zz_1);
1310
+ this.u5_1 = 1;
1311
+ var this_0 = this.a10_1;
1312
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1313
+ var _iterator__ex2g4s = this_0.i();
1314
+ while (_iterator__ex2g4s.j()) {
1315
+ var item = _iterator__ex2g4s.k();
1316
+ destination.h(async(this.c10_1, VOID, VOID, Flux$forEachParallel$slambda$slambda_0(semaphore, this.b10_1, item, null)));
1317
+ }
1318
+
1319
+ suspendResult = awaitAll(destination, this);
1320
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1321
+ return suspendResult;
1322
+ }
1323
+
1324
+ continue $sm;
1325
+ case 1:
1326
+ return suspendResult;
1327
+ case 2:
1328
+ throw this.x5_1;
1329
+ }
1330
+ } catch ($p) {
1331
+ var e = $p;
1332
+ if (this.v5_1 === 2) {
1333
+ throw e;
1334
+ } else {
1335
+ this.u5_1 = this.v5_1;
1336
+ this.x5_1 = e;
1337
+ }
1338
+ }
1339
+ while (true);
1340
+ };
1341
+ protoOf(Flux$forEachParallel$slambda).qz = function ($this$coroutineScope, completion) {
1342
+ var i = new Flux$forEachParallel$slambda(this.zz_1, this.a10_1, this.b10_1, completion);
1343
+ i.c10_1 = $this$coroutineScope;
1344
+ return i;
1345
+ };
1346
+ function Flux$forEachParallel$slambda_0($maxParallel, $items, $action, resultContinuation) {
1347
+ var i = new Flux$forEachParallel$slambda($maxParallel, $items, $action, resultContinuation);
1348
+ var l = function ($this$coroutineScope, $completion) {
1349
+ return i.d10($this$coroutineScope, $completion);
1350
+ };
1351
+ l.$arity = 1;
1352
+ return l;
1353
+ }
1354
+ function $forEachParallelCOROUTINE$(_this__u8e3s4, items, maxParallel, action, resultContinuation) {
1355
+ CoroutineImpl.call(this, resultContinuation);
1356
+ this.m10_1 = _this__u8e3s4;
1357
+ this.n10_1 = items;
1358
+ this.o10_1 = maxParallel;
1359
+ this.p10_1 = action;
1360
+ }
1361
+ protoOf($forEachParallelCOROUTINE$).c6 = function () {
1362
+ var suspendResult = this.w5_1;
1363
+ $sm: do
1364
+ try {
1365
+ var tmp = this.u5_1;
1366
+ switch (tmp) {
1367
+ case 0:
1368
+ this.v5_1 = 2;
1369
+ if (!(this.o10_1 >= 1)) {
1370
+ var message = 'maxParallel must be >= 1, got ' + this.o10_1;
1371
+ throw IllegalArgumentException_init_$Create$(toString(message));
1372
+ }
1373
+
1374
+ this.u5_1 = 1;
1375
+ suspendResult = coroutineScope(Flux$forEachParallel$slambda_0(this.o10_1, this.n10_1, this.p10_1, null), this);
1376
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1377
+ return suspendResult;
1378
+ }
1379
+
1380
+ continue $sm;
1381
+ case 1:
1382
+ return Unit_instance;
1383
+ case 2:
1384
+ throw this.x5_1;
1385
+ }
1386
+ } catch ($p) {
1387
+ var e = $p;
1388
+ if (this.v5_1 === 2) {
1389
+ throw e;
1390
+ } else {
1391
+ this.u5_1 = this.v5_1;
1392
+ this.x5_1 = e;
1393
+ }
1394
+ }
1395
+ while (true);
1396
+ };
1397
+ function Flux() {
1398
+ }
1399
+ protoOf(Flux).bu = function (items, maxParallel, action, $completion) {
1400
+ var tmp = new $forEachParallelCOROUTINE$(this, items, maxParallel, action, $completion);
1401
+ tmp.w5_1 = Unit_instance;
1402
+ tmp.x5_1 = null;
1403
+ return tmp.c6();
1404
+ };
1405
+ var Flux_instance;
1406
+ function Flux_getInstance() {
1407
+ return Flux_instance;
1408
+ }
1409
+ function $getCOROUTINE$(_this__u8e3s4, key, resultContinuation) {
1410
+ CoroutineImpl.call(this, resultContinuation);
1411
+ this.y10_1 = _this__u8e3s4;
1412
+ this.z10_1 = key;
1413
+ }
1414
+ protoOf($getCOROUTINE$).c6 = function () {
1415
+ var suspendResult = this.w5_1;
1416
+ $sm: do
1417
+ try {
1418
+ var tmp = this.u5_1;
1419
+ switch (tmp) {
1420
+ case 0:
1421
+ this.v5_1 = 12;
1422
+ this.l11_1 = this.y10_1.p11_1;
1423
+ this.k11_1 = null;
1424
+ this.u5_1 = 1;
1425
+ suspendResult = this.l11_1.fq(this.k11_1, this);
1426
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1427
+ return suspendResult;
1428
+ }
1429
+
1430
+ continue $sm;
1431
+ case 1:
1432
+ var tmp$ret$2 = Unit_instance;
1433
+ l$ret$3: do {
1434
+ var tmp$ret$0;
1435
+ l$ret$1: do {
1436
+ var tmp_0;
1437
+ try {
1438
+ var tmp0_safe_receiver = this.y10_1.q11_1.q2(this.z10_1);
1439
+ if (tmp0_safe_receiver == null)
1440
+ null;
1441
+ else {
1442
+ var tmp0 = this.y10_1.q11_1;
1443
+ var key = this.z10_1;
1444
+ tmp0.p2(key, tmp0_safe_receiver);
1445
+ tmp$ret$0 = tmp0_safe_receiver;
1446
+ break l$ret$1;
1447
+ }
1448
+ tmp$ret$2 = this.y10_1.r11_1.h1(this.z10_1);
1449
+ break l$ret$3;
1450
+ } catch ($p) {
1451
+ var tmp_1;
1452
+ var t = $p;
1453
+ this.l11_1.rp(this.k11_1);
1454
+ throw t;
1455
+ }
1456
+ }
1457
+ while (false);
1458
+ var tmp_2 = tmp$ret$0;
1459
+ this.l11_1.rp(this.k11_1);
1460
+ return tmp_2;
1461
+ }
1462
+ while (false);
1463
+ var tmp_3 = tmp$ret$2;
1464
+ this.l11_1.rp(this.k11_1);
1465
+ var existing = tmp_3;
1466
+ if (!(existing == null)) {
1467
+ this.u5_1 = 11;
1468
+ suspendResult = existing.zh(this);
1469
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1470
+ return suspendResult;
1471
+ }
1472
+ continue $sm;
1473
+ } else {
1474
+ this.u5_1 = 2;
1475
+ continue $sm;
1476
+ }
1477
+
1478
+ case 2:
1479
+ this.b11_1 = CompletableDeferred();
1480
+ this.j11_1 = this.y10_1.p11_1;
1481
+ this.i11_1 = null;
1482
+ this.u5_1 = 3;
1483
+ suspendResult = this.j11_1.fq(this.i11_1, this);
1484
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1485
+ return suspendResult;
1486
+ }
1487
+
1488
+ continue $sm;
1489
+ case 3:
1490
+ var tmp$ret$6 = Unit_instance;
1491
+ l$ret$7: do {
1492
+ var tmp$ret$4;
1493
+ l$ret$5: do {
1494
+ var tmp_4;
1495
+ try {
1496
+ var tmp0_safe_receiver_0 = this.y10_1.q11_1.q2(this.z10_1);
1497
+ if (tmp0_safe_receiver_0 == null)
1498
+ null;
1499
+ else {
1500
+ var tmp0_0 = this.y10_1.q11_1;
1501
+ var key_0 = this.z10_1;
1502
+ tmp0_0.p2(key_0, tmp0_safe_receiver_0);
1503
+ tmp$ret$4 = tmp0_safe_receiver_0;
1504
+ break l$ret$5;
1505
+ }
1506
+ var raced = this.y10_1.r11_1.h1(this.z10_1);
1507
+ var tmp_5;
1508
+ if (!(raced == null)) {
1509
+ tmp_5 = raced;
1510
+ } else {
1511
+ var tmp0_1 = this.y10_1.r11_1;
1512
+ var tmp2 = this.z10_1;
1513
+ var value = this.b11_1;
1514
+ tmp0_1.p2(tmp2, value);
1515
+ tmp_5 = null;
1516
+ }
1517
+ tmp$ret$6 = tmp_5;
1518
+ break l$ret$7;
1519
+ } catch ($p) {
1520
+ var tmp_6;
1521
+ var t_0 = $p;
1522
+ this.j11_1.rp(this.i11_1);
1523
+ throw t_0;
1524
+ }
1525
+ }
1526
+ while (false);
1527
+ var tmp_7 = tmp$ret$4;
1528
+ this.j11_1.rp(this.i11_1);
1529
+ return tmp_7;
1530
+ }
1531
+ while (false);
1532
+ var tmp_8 = tmp$ret$6;
1533
+ this.j11_1.rp(this.i11_1);
1534
+ var awaitInstead = tmp_8;
1535
+ if (!(awaitInstead == null)) {
1536
+ this.u5_1 = 10;
1537
+ suspendResult = awaitInstead.zh(this);
1538
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1539
+ return suspendResult;
1540
+ }
1541
+ continue $sm;
1542
+ } else {
1543
+ this.u5_1 = 4;
1544
+ continue $sm;
1545
+ }
1546
+
1547
+ case 4:
1548
+ this.v5_1 = 6;
1549
+ this.u5_1 = 5;
1550
+ suspendResult = this.y10_1.n11_1(this.z10_1, this);
1551
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1552
+ return suspendResult;
1553
+ }
1554
+
1555
+ continue $sm;
1556
+ case 5:
1557
+ this.e11_1 = suspendResult;
1558
+ this.v5_1 = 12;
1559
+ this.u5_1 = 8;
1560
+ continue $sm;
1561
+ case 6:
1562
+ this.v5_1 = 12;
1563
+ var tmp_9 = this.x5_1;
1564
+ if (tmp_9 instanceof Error) {
1565
+ this.f11_1 = this.x5_1;
1566
+ this.h11_1 = this.y10_1.p11_1;
1567
+ this.g11_1 = null;
1568
+ this.u5_1 = 7;
1569
+ suspendResult = this.h11_1.fq(this.g11_1, this);
1570
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1571
+ return suspendResult;
1572
+ }
1573
+ continue $sm;
1574
+ } else {
1575
+ throw this.x5_1;
1576
+ }
1577
+
1578
+ case 7:
1579
+ l$ret$9: do {
1580
+ var tmp_10;
1581
+ try {
1582
+ this.y10_1.r11_1.q2(this.z10_1);
1583
+ break l$ret$9;
1584
+ } catch ($p) {
1585
+ var tmp_11;
1586
+ var t_1 = $p;
1587
+ this.h11_1.rp(this.g11_1);
1588
+ throw t_1;
1589
+ }
1590
+ }
1591
+ while (false);
1592
+ this.h11_1.rp(this.g11_1);
1593
+ this.b11_1.xk(this.f11_1);
1594
+ var tmp_12 = this;
1595
+ throw this.f11_1;
1596
+ case 8:
1597
+ this.v5_1 = 12;
1598
+ this.a11_1 = this.e11_1;
1599
+ this.d11_1 = this.y10_1.p11_1;
1600
+ this.c11_1 = null;
1601
+ this.u5_1 = 9;
1602
+ suspendResult = this.d11_1.fq(this.c11_1, this);
1603
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1604
+ return suspendResult;
1605
+ }
1606
+
1607
+ continue $sm;
1608
+ case 9:
1609
+ l$ret$11: do {
1610
+ var tmp_13;
1611
+ try {
1612
+ this.y10_1.r11_1.q2(this.z10_1);
1613
+ var tmp_14;
1614
+ if (this.y10_1.q11_1.l() >= this.y10_1.m11_1) {
1615
+ var tmp0_2 = this.y10_1.q11_1;
1616
+ var key_1 = this.z10_1;
1617
+ tmp_14 = !(isInterface(tmp0_2, KtMap) ? tmp0_2 : THROW_CCE()).g1(key_1);
1618
+ } else {
1619
+ tmp_14 = false;
1620
+ }
1621
+ if (tmp_14) {
1622
+ var iter = this.y10_1.q11_1.j1().i();
1623
+ var oldest = iter.k();
1624
+ var oldestValue = oldest.f1();
1625
+ iter.d2();
1626
+ var tmp0_safe_receiver_1 = this.y10_1.o11_1;
1627
+ if (tmp0_safe_receiver_1 == null)
1628
+ null;
1629
+ else
1630
+ tmp0_safe_receiver_1(oldestValue);
1631
+ }
1632
+ var tmp0_3 = this.y10_1.q11_1;
1633
+ var tmp2_0 = this.z10_1;
1634
+ var value_0 = this.a11_1;
1635
+ tmp0_3.p2(tmp2_0, value_0);
1636
+ break l$ret$11;
1637
+ } catch ($p) {
1638
+ var tmp_15;
1639
+ var t_2 = $p;
1640
+ this.d11_1.rp(this.c11_1);
1641
+ throw t_2;
1642
+ }
1643
+ }
1644
+ while (false);
1645
+ this.d11_1.rp(this.c11_1);
1646
+ this.b11_1.wk(this.a11_1);
1647
+ return this.a11_1;
1648
+ case 10:
1649
+ return suspendResult;
1650
+ case 11:
1651
+ return suspendResult;
1652
+ case 12:
1653
+ throw this.x5_1;
1654
+ }
1655
+ } catch ($p) {
1656
+ var e = $p;
1657
+ if (this.v5_1 === 12) {
1658
+ throw e;
1659
+ } else {
1660
+ this.u5_1 = this.v5_1;
1661
+ this.x5_1 = e;
1662
+ }
1663
+ }
1664
+ while (true);
1665
+ };
1666
+ function LruCache(maxSize, loader, onEvict) {
1667
+ onEvict = onEvict === VOID ? null : onEvict;
1668
+ this.m11_1 = maxSize;
1669
+ this.n11_1 = loader;
1670
+ this.o11_1 = onEvict;
1671
+ // Inline function 'kotlin.require' call
1672
+ if (!(this.m11_1 > 0)) {
1673
+ var message = 'Cache size must be greater than 0';
1674
+ throw IllegalArgumentException_init_$Create$(toString(message));
1675
+ }
1676
+ this.p11_1 = Mutex();
1677
+ this.q11_1 = LinkedHashMap_init_$Create$();
1678
+ var tmp = this;
1679
+ // Inline function 'kotlin.collections.mutableMapOf' call
1680
+ tmp.r11_1 = LinkedHashMap_init_$Create$();
1681
+ }
1682
+ protoOf(LruCache).s11 = function (key, $completion) {
1683
+ var tmp = new $getCOROUTINE$(this, key, $completion);
1684
+ tmp.w5_1 = Unit_instance;
1685
+ tmp.x5_1 = null;
1686
+ return tmp.c6();
1687
+ };
1688
+ function RawTile(width, height, rgba) {
1689
+ this.t11_1 = width;
1690
+ this.u11_1 = height;
1691
+ this.v11_1 = rgba;
1692
+ // Inline function 'kotlin.require' call
1693
+ if (!(this.v11_1.length === imul(imul(this.t11_1, this.u11_1), 4))) {
1694
+ var message = 'rgba size ' + this.v11_1.length + ' does not match width*height*4 (' + imul(imul(this.t11_1, this.u11_1), 4) + ')';
1695
+ throw IllegalArgumentException_init_$Create$(toString(message));
1696
+ }
1697
+ }
1698
+ protoOf(RawTile).equals = function (other) {
1699
+ if (this === other)
1700
+ return true;
1701
+ if (!(other instanceof RawTile))
1702
+ return false;
1703
+ return this.t11_1 === other.t11_1 && this.u11_1 === other.u11_1 && contentEquals(this.v11_1, other.v11_1);
1704
+ };
1705
+ protoOf(RawTile).hashCode = function () {
1706
+ var result = this.t11_1;
1707
+ result = imul(31, result) + this.u11_1 | 0;
1708
+ result = imul(31, result) + contentHashCode(this.v11_1) | 0;
1709
+ return result;
1710
+ };
1711
+ function Tile_init_$Init$(raw, $this) {
1712
+ Tile.call($this, raw.t11_1, raw.u11_1, raw.v11_1);
1713
+ return $this;
1714
+ }
1715
+ function Tile_init_$Create$(raw) {
1716
+ return Tile_init_$Init$(raw, objectCreate(protoOf(Tile)));
1717
+ }
1718
+ function Companion() {
1719
+ }
1720
+ protoOf(Companion).w11 = function (r, g, b) {
1721
+ var raw = r * 256.0 + g + b / 256.0 - 32768.0;
1722
+ return round(raw * 100.0) / 100.0;
1723
+ };
1724
+ var Companion_instance;
1725
+ function Companion_getInstance() {
1726
+ return Companion_instance;
1727
+ }
1728
+ function Tile(width, height, rgba) {
1729
+ this.vx_1 = width;
1730
+ this.wx_1 = height;
1731
+ this.xx_1 = rgba;
1732
+ var tmp = this;
1733
+ var tmp_0 = 0;
1734
+ var tmp_1 = imul(this.vx_1, this.wx_1);
1735
+ var tmp_2 = new Float64Array(tmp_1);
1736
+ while (tmp_0 < tmp_1) {
1737
+ tmp_2[tmp_0] = NaN;
1738
+ tmp_0 = tmp_0 + 1 | 0;
1739
+ }
1740
+ tmp.yx_1 = tmp_2;
1741
+ this.zx_1 = 0;
1742
+ }
1743
+ protoOf(Tile).ay = function (pixel) {
1744
+ var containsUpper = this.vx_1;
1745
+ var containsArg = pixel.px_1;
1746
+ // Inline function 'kotlin.require' call
1747
+ if (!(0 <= containsArg ? containsArg < containsUpper : false)) {
1748
+ var message = 'Invalid x position: ' + pixel.px_1 + '. Must be between 0 and ' + (this.vx_1 - 1 | 0);
1749
+ throw IllegalArgumentException_init_$Create$(toString(message));
1750
+ }
1751
+ var containsUpper_0 = this.wx_1;
1752
+ var containsArg_0 = pixel.qx_1;
1753
+ // Inline function 'kotlin.require' call
1754
+ if (!(0 <= containsArg_0 ? containsArg_0 < containsUpper_0 : false)) {
1755
+ var message_0 = 'Invalid y position: ' + pixel.qx_1 + '. Must be between 0 and ' + (this.wx_1 - 1 | 0);
1756
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
1757
+ }
1758
+ var idx = imul(pixel.qx_1, this.vx_1) + pixel.px_1 | 0;
1759
+ var cached = this.yx_1[idx];
1760
+ if (!isNaN_0(cached))
1761
+ return cached;
1762
+ var byteOffset = imul(idx, 4);
1763
+ var r = this.xx_1[byteOffset] & 255;
1764
+ var g = this.xx_1[byteOffset + 1 | 0] & 255;
1765
+ var b = this.xx_1[byteOffset + 2 | 0] & 255;
1766
+ var elevation = Companion_instance.w11(r, g, b);
1767
+ this.yx_1[idx] = elevation;
1768
+ this.zx_1 = this.zx_1 + 1 | 0;
1769
+ return elevation;
1770
+ };
1771
+ function buildUrl($this, tc) {
1772
+ return replace(replace(replace($this.rx_1, '{z}', tc.au_1.toString()), '{x}', tc.yt_1.toString()), '{y}', tc.zt_1.toString());
1773
+ }
1774
+ function fetchAndDecodeTile$ref_1() {
1775
+ }
1776
+ protoOf(fetchAndDecodeTile$ref_1).ly = function (p0, $completion) {
1777
+ return fetchAndDecodeTile(p0, $completion);
1778
+ };
1779
+ protoOf(fetchAndDecodeTile$ref_1).k6 = function (p1, $completion) {
1780
+ return this.ly((!(p1 == null) ? typeof p1 === 'string' : false) ? p1 : THROW_CCE(), $completion);
1781
+ };
1782
+ function fetchAndDecodeTile$ref_2() {
1783
+ var i = new fetchAndDecodeTile$ref_1();
1784
+ var l = function (p0, $completion) {
1785
+ return i.ly(p0, $completion);
1786
+ };
1787
+ l.callableName = 'fetchAndDecodeTile';
1788
+ l.$arity = 1;
1789
+ return l;
1790
+ }
1791
+ function TileManager$cache$slambda(this$0, resultContinuation) {
1792
+ this.f12_1 = this$0;
1793
+ CoroutineImpl.call(this, resultContinuation);
1794
+ }
1795
+ protoOf(TileManager$cache$slambda).h12 = function (tc, $completion) {
1796
+ var tmp = this.i12(tc, $completion);
1797
+ tmp.w5_1 = Unit_instance;
1798
+ tmp.x5_1 = null;
1799
+ return tmp.c6();
1800
+ };
1801
+ protoOf(TileManager$cache$slambda).k6 = function (p1, $completion) {
1802
+ return this.h12(p1 instanceof TileCoordinates ? p1 : THROW_CCE(), $completion);
1803
+ };
1804
+ protoOf(TileManager$cache$slambda).c6 = function () {
1805
+ var suspendResult = this.w5_1;
1806
+ $sm: do
1807
+ try {
1808
+ var tmp = this.u5_1;
1809
+ switch (tmp) {
1810
+ case 0:
1811
+ this.v5_1 = 2;
1812
+ this.u5_1 = 1;
1813
+ suspendResult = this.f12_1.sx_1(buildUrl(this.f12_1, this.g12_1), this);
1814
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1815
+ return suspendResult;
1816
+ }
1817
+
1818
+ continue $sm;
1819
+ case 1:
1820
+ var ARGUMENT = suspendResult;
1821
+ return Tile_init_$Create$(ARGUMENT);
1822
+ case 2:
1823
+ throw this.x5_1;
1824
+ }
1825
+ } catch ($p) {
1826
+ var e = $p;
1827
+ if (this.v5_1 === 2) {
1828
+ throw e;
1829
+ } else {
1830
+ this.u5_1 = this.v5_1;
1831
+ this.x5_1 = e;
1832
+ }
1833
+ }
1834
+ while (true);
1835
+ };
1836
+ protoOf(TileManager$cache$slambda).i12 = function (tc, completion) {
1837
+ var i = new TileManager$cache$slambda(this.f12_1, completion);
1838
+ i.g12_1 = tc;
1839
+ return i;
1840
+ };
1841
+ function TileManager$cache$slambda_0(this$0, resultContinuation) {
1842
+ var i = new TileManager$cache$slambda(this$0, resultContinuation);
1843
+ var l = function (tc, $completion) {
1844
+ return i.h12(tc, $completion);
1845
+ };
1846
+ l.$arity = 1;
1847
+ return l;
1848
+ }
1849
+ function TileManager(urlTemplate, cacheSize, fetcher) {
1850
+ var tmp;
1851
+ if (fetcher === VOID) {
1852
+ tmp = fetchAndDecodeTile$ref_2();
1853
+ } else {
1854
+ tmp = fetcher;
1855
+ }
1856
+ fetcher = tmp;
1857
+ this.rx_1 = urlTemplate;
1858
+ this.sx_1 = fetcher;
1859
+ var tmp_0 = this;
1860
+ tmp_0.tx_1 = new LruCache(cacheSize, TileManager$cache$slambda_0(this, null));
1861
+ }
1862
+ protoOf(TileManager).ux = function (tileCoords, $completion) {
1863
+ return this.tx_1.s11(tileCoords, $completion);
1864
+ };
1865
+ function TileCoordinates(x, y, z) {
1866
+ this.yt_1 = x;
1867
+ this.zt_1 = y;
1868
+ this.au_1 = z;
1869
+ }
1870
+ protoOf(TileCoordinates).toString = function () {
1871
+ return 'TileCoordinates(x=' + this.yt_1 + ', y=' + this.zt_1 + ', z=' + this.au_1 + ')';
1872
+ };
1873
+ protoOf(TileCoordinates).hashCode = function () {
1874
+ var result = this.yt_1;
1875
+ result = imul(result, 31) + this.zt_1 | 0;
1876
+ result = imul(result, 31) + this.au_1 | 0;
1877
+ return result;
1878
+ };
1879
+ protoOf(TileCoordinates).equals = function (other) {
1880
+ if (this === other)
1881
+ return true;
1882
+ if (!(other instanceof TileCoordinates))
1883
+ return false;
1884
+ if (!(this.yt_1 === other.yt_1))
1885
+ return false;
1886
+ if (!(this.zt_1 === other.zt_1))
1887
+ return false;
1888
+ if (!(this.au_1 === other.au_1))
1889
+ return false;
1890
+ return true;
1891
+ };
1892
+ function Pixel(tile, x, y) {
1893
+ this.ox_1 = tile;
1894
+ this.px_1 = x;
1895
+ this.qx_1 = y;
1896
+ }
1897
+ protoOf(Pixel).toString = function () {
1898
+ return 'Pixel(tile=' + this.ox_1.toString() + ', x=' + this.px_1 + ', y=' + this.qx_1 + ')';
1899
+ };
1900
+ protoOf(Pixel).hashCode = function () {
1901
+ var result = this.ox_1.hashCode();
1902
+ result = imul(result, 31) + this.px_1 | 0;
1903
+ result = imul(result, 31) + this.qx_1 | 0;
1904
+ return result;
1905
+ };
1906
+ protoOf(Pixel).equals = function (other) {
1907
+ if (this === other)
1908
+ return true;
1909
+ if (!(other instanceof Pixel))
1910
+ return false;
1911
+ if (!this.ox_1.equals(other.ox_1))
1912
+ return false;
1913
+ if (!(this.px_1 === other.px_1))
1914
+ return false;
1915
+ if (!(this.qx_1 === other.qx_1))
1916
+ return false;
1917
+ return true;
1918
+ };
1919
+ function PixelFloat(tile, x, y) {
1920
+ this.kx_1 = tile;
1921
+ this.lx_1 = x;
1922
+ this.mx_1 = y;
1923
+ }
1924
+ protoOf(PixelFloat).toString = function () {
1925
+ return 'PixelFloat(tile=' + this.kx_1.toString() + ', x=' + this.lx_1 + ', y=' + this.mx_1 + ')';
1926
+ };
1927
+ protoOf(PixelFloat).hashCode = function () {
1928
+ var result = this.kx_1.hashCode();
1929
+ result = imul(result, 31) + getNumberHashCode(this.lx_1) | 0;
1930
+ result = imul(result, 31) + getNumberHashCode(this.mx_1) | 0;
1931
+ return result;
1932
+ };
1933
+ protoOf(PixelFloat).equals = function (other) {
1934
+ if (this === other)
1935
+ return true;
1936
+ if (!(other instanceof PixelFloat))
1937
+ return false;
1938
+ if (!this.kx_1.equals(other.kx_1))
1939
+ return false;
1940
+ if (!equals(this.lx_1, other.lx_1))
1941
+ return false;
1942
+ if (!equals(this.mx_1, other.mx_1))
1943
+ return false;
1944
+ return true;
1945
+ };
1946
+ function TileCoordinatesFloat(x, y, xFloat, yFloat, z) {
1947
+ this.gy_1 = x;
1948
+ this.hy_1 = y;
1949
+ this.iy_1 = xFloat;
1950
+ this.jy_1 = yFloat;
1951
+ this.ky_1 = z;
1952
+ }
1953
+ protoOf(TileCoordinatesFloat).toString = function () {
1954
+ return 'TileCoordinatesFloat(x=' + this.gy_1 + ', y=' + this.hy_1 + ', xFloat=' + this.iy_1 + ', yFloat=' + this.jy_1 + ', z=' + this.ky_1 + ')';
1955
+ };
1956
+ protoOf(TileCoordinatesFloat).hashCode = function () {
1957
+ var result = this.gy_1;
1958
+ result = imul(result, 31) + this.hy_1 | 0;
1959
+ result = imul(result, 31) + getNumberHashCode(this.iy_1) | 0;
1960
+ result = imul(result, 31) + getNumberHashCode(this.jy_1) | 0;
1961
+ result = imul(result, 31) + this.ky_1 | 0;
1962
+ return result;
1963
+ };
1964
+ protoOf(TileCoordinatesFloat).equals = function (other) {
1965
+ if (this === other)
1966
+ return true;
1967
+ if (!(other instanceof TileCoordinatesFloat))
1968
+ return false;
1969
+ if (!(this.gy_1 === other.gy_1))
1970
+ return false;
1971
+ if (!(this.hy_1 === other.hy_1))
1972
+ return false;
1973
+ if (!equals(this.iy_1, other.iy_1))
1974
+ return false;
1975
+ if (!equals(this.jy_1, other.jy_1))
1976
+ return false;
1977
+ if (!(this.ky_1 === other.ky_1))
1978
+ return false;
1979
+ return true;
1980
+ };
1981
+ function Companion_0() {
1982
+ Companion_instance_0 = this;
1983
+ this.j12_1 = new Vector3D(0.0, 0.0, 0.0);
1984
+ }
1985
+ var Companion_instance_0;
1986
+ function Companion_getInstance_0() {
1987
+ if (Companion_instance_0 == null)
1988
+ new Companion_0();
1989
+ return Companion_instance_0;
1990
+ }
1991
+ function Vector3D(x, y, z) {
1992
+ Companion_getInstance_0();
1993
+ this.lv_1 = x;
1994
+ this.mv_1 = y;
1995
+ this.nv_1 = z;
1996
+ }
1997
+ protoOf(Vector3D).k12 = function (other) {
1998
+ var tmp0 = this.lv_1 - other.lv_1;
1999
+ // Inline function 'kotlin.math.hypot' call
2000
+ var y = this.mv_1 - other.mv_1;
2001
+ var tmp0_0 = hypot(tmp0, y);
2002
+ // Inline function 'kotlin.math.hypot' call
2003
+ var y_0 = this.nv_1 - other.nv_1;
2004
+ return hypot(tmp0_0, y_0);
2005
+ };
2006
+ protoOf(Vector3D).l12 = function (other) {
2007
+ return new Vector3D(this.lv_1 - other.lv_1, this.mv_1 - other.mv_1, this.nv_1 - other.nv_1);
2008
+ };
2009
+ protoOf(Vector3D).m12 = function (other) {
2010
+ return new Vector3D(this.lv_1 + other.lv_1, this.mv_1 + other.mv_1, this.nv_1 + other.nv_1);
2011
+ };
2012
+ protoOf(Vector3D).n12 = function (scalar) {
2013
+ return new Vector3D(this.lv_1 * scalar, this.mv_1 * scalar, this.nv_1 * scalar);
2014
+ };
2015
+ protoOf(Vector3D).o12 = function (other) {
2016
+ return this.lv_1 * other.lv_1 + this.mv_1 * other.mv_1 + this.nv_1 * other.nv_1;
2017
+ };
2018
+ protoOf(Vector3D).ov = function (segmentStart, segmentEnd) {
2019
+ var segmentVector = segmentEnd.l12(segmentStart);
2020
+ var segmentLengthSq = segmentVector.o12(segmentVector);
2021
+ if (segmentLengthSq === 0.0)
2022
+ return this.k12(segmentStart);
2023
+ var pointVector = this.l12(segmentStart);
2024
+ var projection = pointVector.o12(segmentVector) / segmentLengthSq;
2025
+ var clamped = coerceIn_0(projection, 0.0, 1.0);
2026
+ var closest = segmentStart.m12(segmentVector.n12(clamped));
2027
+ return this.k12(closest);
2028
+ };
2029
+ protoOf(Vector3D).toString = function () {
2030
+ return 'Vector3D(x=' + this.lv_1 + ', y=' + this.mv_1 + ', z=' + this.nv_1 + ')';
2031
+ };
2032
+ protoOf(Vector3D).hashCode = function () {
2033
+ var result = getNumberHashCode(this.lv_1);
2034
+ result = imul(result, 31) + getNumberHashCode(this.mv_1) | 0;
2035
+ result = imul(result, 31) + getNumberHashCode(this.nv_1) | 0;
2036
+ return result;
2037
+ };
2038
+ protoOf(Vector3D).equals = function (other) {
2039
+ if (this === other)
2040
+ return true;
2041
+ if (!(other instanceof Vector3D))
2042
+ return false;
2043
+ if (!equals(this.lv_1, other.lv_1))
2044
+ return false;
2045
+ if (!equals(this.mv_1, other.mv_1))
2046
+ return false;
2047
+ if (!equals(this.nv_1, other.nv_1))
2048
+ return false;
2049
+ return true;
2050
+ };
2051
+ function newElevationProvider(configDto) {
2052
+ var defaults = new ElevationProviderConfig();
2053
+ var tmp1_elvis_lhs = configDto == null ? null : configDto.zoomLevel;
2054
+ var tmp = tmp1_elvis_lhs == null ? defaults.qy_1 : tmp1_elvis_lhs;
2055
+ var tmp3_elvis_lhs = configDto == null ? null : configDto.cacheSize;
2056
+ var tmp_0 = tmp3_elvis_lhs == null ? defaults.ry_1 : tmp3_elvis_lhs;
2057
+ var tmp5_elvis_lhs = configDto == null ? null : configDto.tileUrlTemplate;
2058
+ var tmp_1 = tmp5_elvis_lhs == null ? defaults.sy_1 : tmp5_elvis_lhs;
2059
+ var tmp7_elvis_lhs = configDto == null ? null : configDto.tileSize;
2060
+ var cfg = new ElevationProviderConfig(tmp, tmp_0, tmp_1, tmp7_elvis_lhs == null ? defaults.ty_1 : tmp7_elvis_lhs, defaults.uy_1);
2061
+ return new ElevationProvider(cfg);
2062
+ }
2063
+ function getElevation(provider, latitude, longitude, interpolation) {
2064
+ var tmp = GlobalScope_instance;
2065
+ return promise(tmp, VOID, VOID, getElevation$slambda_0(provider, latitude, longitude, interpolation, null));
2066
+ }
2067
+ function getElevationsAlong(provider, path, options) {
2068
+ var tmp = GlobalScope_instance;
2069
+ return promise(tmp, VOID, VOID, getElevationsAlong$slambda_0(path, provider, options, null));
2070
+ }
2071
+ function toKotlin(_this__u8e3s4) {
2072
+ return new SmoothingOptions(_this__u8e3s4.windowSize, _this__u8e3s4.enabled);
2073
+ }
2074
+ function toKotlin_0(_this__u8e3s4) {
2075
+ return new FilterOptions(_this__u8e3s4.tolerance, _this__u8e3s4.zExaggeration, _this__u8e3s4.enabled);
2076
+ }
2077
+ function coordsEle(latitude, longitude, elevation) {
2078
+ var o = {};
2079
+ o.latitude = latitude;
2080
+ o.longitude = longitude;
2081
+ o.elevation = elevation;
2082
+ // Inline function 'kotlin.js.unsafeCast' call
2083
+ return o;
2084
+ }
2085
+ function getElevation$slambda($provider, $latitude, $longitude, $interpolation, resultContinuation) {
2086
+ this.x12_1 = $provider;
2087
+ this.y12_1 = $latitude;
2088
+ this.z12_1 = $longitude;
2089
+ this.a13_1 = $interpolation;
2090
+ CoroutineImpl.call(this, resultContinuation);
2091
+ }
2092
+ protoOf(getElevation$slambda).c13 = function ($this$promise, $completion) {
2093
+ var tmp = this.qz($this$promise, $completion);
2094
+ tmp.w5_1 = Unit_instance;
2095
+ tmp.x5_1 = null;
2096
+ return tmp.c6();
2097
+ };
2098
+ protoOf(getElevation$slambda).k6 = function (p1, $completion) {
2099
+ return this.c13((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
2100
+ };
2101
+ protoOf(getElevation$slambda).c6 = function () {
2102
+ var suspendResult = this.w5_1;
2103
+ $sm: do
2104
+ try {
2105
+ var tmp = this.u5_1;
2106
+ switch (tmp) {
2107
+ case 0:
2108
+ this.v5_1 = 2;
2109
+ this.u5_1 = 1;
2110
+ suspendResult = this.x12_1.vy(this.y12_1, this.z12_1, this.a13_1, this);
2111
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2112
+ return suspendResult;
2113
+ }
2114
+
2115
+ continue $sm;
2116
+ case 1:
2117
+ return suspendResult;
2118
+ case 2:
2119
+ throw this.x5_1;
2120
+ }
2121
+ } catch ($p) {
2122
+ var e = $p;
2123
+ if (this.v5_1 === 2) {
2124
+ throw e;
2125
+ } else {
2126
+ this.u5_1 = this.v5_1;
2127
+ this.x5_1 = e;
2128
+ }
2129
+ }
2130
+ while (true);
2131
+ };
2132
+ protoOf(getElevation$slambda).qz = function ($this$promise, completion) {
2133
+ var i = new getElevation$slambda(this.x12_1, this.y12_1, this.z12_1, this.a13_1, completion);
2134
+ i.b13_1 = $this$promise;
2135
+ return i;
2136
+ };
2137
+ function getElevation$slambda_0($provider, $latitude, $longitude, $interpolation, resultContinuation) {
2138
+ var i = new getElevation$slambda($provider, $latitude, $longitude, $interpolation, resultContinuation);
2139
+ var l = function ($this$promise, $completion) {
2140
+ return i.c13($this$promise, $completion);
2141
+ };
2142
+ l.$arity = 1;
2143
+ return l;
2144
+ }
2145
+ function getElevationsAlong$slambda($path, $provider, $options, resultContinuation) {
2146
+ this.l13_1 = $path;
2147
+ this.m13_1 = $provider;
2148
+ this.n13_1 = $options;
2149
+ CoroutineImpl.call(this, resultContinuation);
2150
+ }
2151
+ protoOf(getElevationsAlong$slambda).p13 = function ($this$promise, $completion) {
2152
+ var tmp = this.qz($this$promise, $completion);
2153
+ tmp.w5_1 = Unit_instance;
2154
+ tmp.x5_1 = null;
2155
+ return tmp.c6();
2156
+ };
2157
+ protoOf(getElevationsAlong$slambda).k6 = function (p1, $completion) {
2158
+ return this.p13((!(p1 == null) ? isInterface(p1, CoroutineScope) : false) ? p1 : THROW_CCE(), $completion);
2159
+ };
2160
+ protoOf(getElevationsAlong$slambda).c6 = function () {
2161
+ var suspendResult = this.w5_1;
2162
+ $sm: do
2163
+ try {
2164
+ var tmp = this.u5_1;
2165
+ switch (tmp) {
2166
+ case 0:
2167
+ this.v5_1 = 2;
2168
+ var this_0 = this.l13_1;
2169
+ var destination = ArrayList_init_$Create$_0(this_0.length);
2170
+ var inductionVariable = 0;
2171
+ var last = this_0.length;
2172
+ while (inductionVariable < last) {
2173
+ var item = this_0[inductionVariable];
2174
+ inductionVariable = inductionVariable + 1 | 0;
2175
+ destination.h(new LatLon(item.latitude, item.longitude));
2176
+ }
2177
+
2178
+ var coords = destination;
2179
+ this.u5_1 = 1;
2180
+ var tmp0_safe_receiver = this.n13_1;
2181
+ var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.step;
2182
+ var tmp_0 = tmp1_elvis_lhs == null ? 10.0 : tmp1_elvis_lhs;
2183
+ var tmp2_safe_receiver = this.n13_1;
2184
+ var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.minDistance;
2185
+ var tmp_1 = tmp3_elvis_lhs == null ? 1.0 : tmp3_elvis_lhs;
2186
+ var tmp4_safe_receiver = this.n13_1;
2187
+ var tmp5_elvis_lhs = tmp4_safe_receiver == null ? null : tmp4_safe_receiver.interpolation;
2188
+ var tmp_2 = tmp5_elvis_lhs == null ? true : tmp5_elvis_lhs;
2189
+ var tmp6_safe_receiver = this.n13_1;
2190
+ var tmp7_safe_receiver = tmp6_safe_receiver == null ? null : tmp6_safe_receiver.smoothingOptions;
2191
+ var tmp_3 = tmp7_safe_receiver == null ? null : toKotlin(tmp7_safe_receiver);
2192
+ var tmp8_safe_receiver = this.n13_1;
2193
+ var tmp9_safe_receiver = tmp8_safe_receiver == null ? null : tmp8_safe_receiver.filterOptions;
2194
+ suspendResult = this.m13_1.yy(coords, tmp_0, tmp_1, tmp_2, tmp_3, tmp9_safe_receiver == null ? null : toKotlin_0(tmp9_safe_receiver), this);
2195
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2196
+ return suspendResult;
2197
+ }
2198
+
2199
+ continue $sm;
2200
+ case 1:
2201
+ var results = suspendResult;
2202
+ var tmp_4 = 0;
2203
+ var tmp_5 = results.l();
2204
+ var tmp_6 = Array(tmp_5);
2205
+ while (tmp_4 < tmp_5) {
2206
+ var tmp_7 = tmp_4;
2207
+ var c = results.m(tmp_7);
2208
+ tmp_6[tmp_7] = coordsEle(c.ht(), c.it(), c.fv());
2209
+ tmp_4 = tmp_4 + 1 | 0;
2210
+ }
2211
+
2212
+ return tmp_6;
2213
+ case 2:
2214
+ throw this.x5_1;
2215
+ }
2216
+ } catch ($p) {
2217
+ var e = $p;
2218
+ if (this.v5_1 === 2) {
2219
+ throw e;
2220
+ } else {
2221
+ this.u5_1 = this.v5_1;
2222
+ this.x5_1 = e;
2223
+ }
2224
+ }
2225
+ while (true);
2226
+ };
2227
+ protoOf(getElevationsAlong$slambda).qz = function ($this$promise, completion) {
2228
+ var i = new getElevationsAlong$slambda(this.l13_1, this.m13_1, this.n13_1, completion);
2229
+ i.o13_1 = $this$promise;
2230
+ return i;
2231
+ };
2232
+ function getElevationsAlong$slambda_0($path, $provider, $options, resultContinuation) {
2233
+ var i = new getElevationsAlong$slambda($path, $provider, $options, resultContinuation);
2234
+ var l = function ($this$promise, $completion) {
2235
+ return i.p13($this$promise, $completion);
2236
+ };
2237
+ l.$arity = 1;
2238
+ return l;
2239
+ }
2240
+ function fetchAndDecodeTile(url, $completion) {
2241
+ var tmp = new $fetchAndDecodeTileCOROUTINE$(url, $completion);
2242
+ tmp.w5_1 = Unit_instance;
2243
+ tmp.x5_1 = null;
2244
+ return tmp.c6();
2245
+ }
2246
+ function fetchUrl(url) {
2247
+ // Inline function 'kotlin.js.unsafeCast' call
2248
+ return fetch(url);
2249
+ }
2250
+ function $fetchAndDecodeTileCOROUTINE$(url, resultContinuation) {
2251
+ CoroutineImpl.call(this, resultContinuation);
2252
+ this.y13_1 = url;
2253
+ }
2254
+ protoOf($fetchAndDecodeTileCOROUTINE$).c6 = function () {
2255
+ var suspendResult = this.w5_1;
2256
+ $sm: do
2257
+ try {
2258
+ var tmp = this.u5_1;
2259
+ switch (tmp) {
2260
+ case 0:
2261
+ this.v5_1 = 4;
2262
+ this.u5_1 = 1;
2263
+ suspendResult = await_0(fetchUrl(this.y13_1), this);
2264
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2265
+ return suspendResult;
2266
+ }
2267
+
2268
+ continue $sm;
2269
+ case 1:
2270
+ var res = suspendResult;
2271
+ if (!res.ok) {
2272
+ var message = 'Tile fetch failed for ' + this.y13_1 + ': HTTP ' + res.status;
2273
+ throw IllegalStateException_init_$Create$_0(toString(message));
2274
+ }
2275
+
2276
+ this.u5_1 = 2;
2277
+ suspendResult = await_0(res.blob(), this);
2278
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2279
+ return suspendResult;
2280
+ }
2281
+
2282
+ continue $sm;
2283
+ case 2:
2284
+ var blob = suspendResult;
2285
+ this.u5_1 = 3;
2286
+ suspendResult = await_0(window.createImageBitmap(blob), this);
2287
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2288
+ return suspendResult;
2289
+ }
2290
+
2291
+ continue $sm;
2292
+ case 3:
2293
+ var bitmap = suspendResult;
2294
+ l$ret$3: do {
2295
+ var tmp$ret$0;
2296
+ l$ret$1: do {
2297
+ var tmp_0;
2298
+ try {
2299
+ var tmp_1 = document.createElement('canvas');
2300
+ var canvas = tmp_1 instanceof HTMLCanvasElement ? tmp_1 : THROW_CCE();
2301
+ canvas.width = bitmap.width;
2302
+ canvas.height = bitmap.height;
2303
+ var tmp_2 = canvas.getContext('2d');
2304
+ var ctx = tmp_2 instanceof CanvasRenderingContext2D ? tmp_2 : THROW_CCE();
2305
+ ctx.drawImage(bitmap, 0.0, 0.0);
2306
+ var data = ctx.getImageData(0.0, 0.0, bitmap.width, bitmap.height);
2307
+ var src = data.data;
2308
+ var int8 = new Int8Array(src.buffer, src.byteOffset, src.byteLength);
2309
+ var rgba = int8;
2310
+ tmp$ret$0 = new RawTile(bitmap.width, bitmap.height, rgba);
2311
+ break l$ret$1;
2312
+ } catch ($p) {
2313
+ var tmp_3;
2314
+ var t = $p;
2315
+ bitmap.close();
2316
+ throw t;
2317
+ }
2318
+ }
2319
+ while (false);
2320
+ var tmp_4 = tmp$ret$0;
2321
+ bitmap.close();
2322
+ return tmp_4;
2323
+ }
2324
+ while (false);
2325
+ bitmap.close();
2326
+ return Unit_instance;
2327
+ case 4:
2328
+ throw this.x5_1;
2329
+ }
2330
+ } catch ($p) {
2331
+ var e = $p;
2332
+ if (this.v5_1 === 4) {
2333
+ throw e;
2334
+ } else {
2335
+ this.u5_1 = this.v5_1;
2336
+ this.x5_1 = e;
2337
+ }
2338
+ }
2339
+ while (true);
2340
+ };
2341
+ //region block: init
2342
+ Distance_instance = new Distance();
2343
+ DouglasPeucker_instance = new DouglasPeucker();
2344
+ EcefConverter_instance = new EcefConverter();
2345
+ ElevationFunctions_instance = new ElevationFunctions();
2346
+ ElevationSmoother_instance = new ElevationSmoother();
2347
+ Flux_instance = new Flux();
2348
+ Companion_instance = new Companion();
2349
+ //endregion
2350
+ //region block: exports
2351
+ function $jsExportAll$(_) {
2352
+ var io = _.io || (_.io = {});
2353
+ var github = io.github || (io.github = {});
2354
+ var glandais = github.glandais || (github.glandais = {});
2355
+ var elevation = glandais.elevation || (glandais.elevation = {});
2356
+ elevation.newElevationProvider = newElevationProvider;
2357
+ elevation.getElevation = getElevation;
2358
+ elevation.getElevationsAlong = getElevationsAlong;
2359
+ }
2360
+ $jsExportAll$(_);
2361
+ _.$jsExportAll$ = $jsExportAll$;
2362
+ _.$_$ = _.$_$ || {};
2363
+ _.$_$.a = Distance_instance;
2364
+ _.$_$.b = DouglasPeucker_instance;
2365
+ _.$_$.c = ElevationSmoother_instance;
2366
+ _.$_$.d = MathConstants_getInstance;
2367
+ _.$_$.e = LatLonElevation;
2368
+ _.$_$.f = LatLon;
2369
+ //endregion
2370
+ return _;
2371
+ }));
2372
+
2373
+ //# sourceMappingURL=vcyclist-elevation.js.map