@glandais/vcyclist-engine 2.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vcyclist-fit.js CHANGED
@@ -1,99 +1,156 @@
1
1
  (function (factory) {
2
2
  if (typeof define === 'function' && define.amd)
3
- define(['exports', '@garmin/fitsdk', './kotlin-kotlin-stdlib.js', './vcyclist-elevation.js'], factory);
3
+ define(['exports', './kotlin-kotlin-stdlib.js', './fit-kotlin-sdk.js'], factory);
4
4
  else if (typeof exports === 'object')
5
- factory(module.exports, require('@garmin/fitsdk'), require('./kotlin-kotlin-stdlib.js'), require('./vcyclist-elevation.js'));
5
+ factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./fit-kotlin-sdk.js'));
6
6
  else {
7
- if (typeof FitSdk === 'undefined') {
8
- throw new Error("Error loading module 'vcyclist-fit'. Its dependency '@garmin/fitsdk' was not found. Please, check whether '@garmin/fitsdk' is loaded prior to 'vcyclist-fit'.");
9
- }
10
7
  if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
11
8
  throw new Error("Error loading module 'vcyclist-fit'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'vcyclist-fit'.");
12
9
  }
13
- if (typeof globalThis['vcyclist-elevation'] === 'undefined') {
14
- throw new Error("Error loading module 'vcyclist-fit'. Its dependency 'vcyclist-elevation' was not found. Please, check whether 'vcyclist-elevation' is loaded prior to 'vcyclist-fit'.");
10
+ if (typeof globalThis['fit-kotlin-sdk'] === 'undefined') {
11
+ throw new Error("Error loading module 'vcyclist-fit'. Its dependency 'fit-kotlin-sdk' was not found. Please, check whether 'fit-kotlin-sdk' is loaded prior to 'vcyclist-fit'.");
15
12
  }
16
- globalThis['vcyclist-fit'] = factory(typeof globalThis['vcyclist-fit'] === 'undefined' ? {} : globalThis['vcyclist-fit'], FitSdk, globalThis['kotlin-kotlin-stdlib'], globalThis['vcyclist-elevation']);
13
+ globalThis['vcyclist-fit'] = factory(typeof globalThis['vcyclist-fit'] === 'undefined' ? {} : globalThis['vcyclist-fit'], globalThis['kotlin-kotlin-stdlib'], globalThis['fit-kotlin-sdk']);
17
14
  }
18
- }(function (_, FitSdk, kotlin_kotlin, kotlin_io_github_glandais_elevation) {
15
+ }(function (_, kotlin_kotlin, kotlin_io_github_glandais_fit_kotlin_sdk) {
19
16
  'use strict';
20
17
  //region block: imports
21
18
  var imul = Math.imul;
22
- var Unit_instance = kotlin_kotlin.$_$.t;
23
- var Enum = kotlin_kotlin.$_$.x7;
24
- var protoOf = kotlin_kotlin.$_$.y5;
25
- var initMetadataForClass = kotlin_kotlin.$_$.j5;
19
+ var Unit_instance = kotlin_kotlin.$_$.f1;
20
+ var Enum = kotlin_kotlin.$_$.v8;
21
+ var protoOf = kotlin_kotlin.$_$.t6;
22
+ var initMetadataForClass = kotlin_kotlin.$_$.e6;
26
23
  var VOID = kotlin_kotlin.$_$.a;
27
- var toString = kotlin_kotlin.$_$.a6;
28
- var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.m1;
29
- var getStringHashCode = kotlin_kotlin.$_$.h5;
30
- var hashCode = kotlin_kotlin.$_$.i5;
31
- var equals = kotlin_kotlin.$_$.d5;
32
- var getNumberHashCode = kotlin_kotlin.$_$.f5;
33
- var Long = kotlin_kotlin.$_$.b8;
34
- var roundToInt = kotlin_kotlin.$_$.b6;
35
- var initMetadataForObject = kotlin_kotlin.$_$.p5;
36
- var ArrayList_init_$Create$ = kotlin_kotlin.$_$.w;
37
- var Companion_getInstance = kotlin_kotlin.$_$.q;
38
- var numberToLong = kotlin_kotlin.$_$.q4;
39
- var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.u;
40
- var toDuration = kotlin_kotlin.$_$.u7;
41
- var MathConstants_getInstance = kotlin_io_github_glandais_elevation.$_$.d;
42
- var isNaN_0 = kotlin_kotlin.$_$.n8;
43
- var until = kotlin_kotlin.$_$.l6;
44
- var toNumber = kotlin_kotlin.$_$.s4;
45
- var first = kotlin_kotlin.$_$.s2;
46
- var round = kotlin_kotlin.$_$.d6;
47
- var numberToInt = kotlin_kotlin.$_$.w5;
48
- var last = kotlin_kotlin.$_$.y2;
24
+ var initMetadataForCompanion = kotlin_kotlin.$_$.f6;
25
+ var toString = kotlin_kotlin.$_$.w6;
26
+ var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.y1;
27
+ var Collection = kotlin_kotlin.$_$.l2;
28
+ var isInterface = kotlin_kotlin.$_$.m6;
29
+ var getStringHashCode = kotlin_kotlin.$_$.c6;
30
+ var hashCode = kotlin_kotlin.$_$.d6;
31
+ var equals = kotlin_kotlin.$_$.x5;
32
+ var getNumberHashCode = kotlin_kotlin.$_$.a6;
33
+ var FileIdMesg_init_$Create$ = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.n;
34
+ var File_COURSE_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.f;
35
+ var Manufacturer_DYNASTREAM_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.g;
36
+ var _UShort___init__impl__jigrne = kotlin_kotlin.$_$.t;
37
+ var _UInt___init__impl__l7qpdl = kotlin_kotlin.$_$.p;
38
+ var toShort = kotlin_kotlin.$_$.v6;
39
+ var CourseMesg_init_$Create$ = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.l;
40
+ var LapMesg_init_$Create$ = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.o;
41
+ var RecordMesg_init_$Create$ = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.p;
42
+ var toByte = kotlin_kotlin.$_$.u6;
43
+ var _UByte___init__impl__g9hnc4 = kotlin_kotlin.$_$.m;
44
+ var roundToInt = kotlin_kotlin.$_$.x6;
45
+ var EventMesg_init_$Create$ = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.m;
46
+ var Event_TIMER_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.b;
47
+ var Sport_CYCLING_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.h;
48
+ var Sport_RUNNING_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.j;
49
+ var Sport_GENERIC_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.i;
50
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.r9;
51
+ var Companion_getInstance = kotlin_kotlin.$_$.b1;
52
+ var numberToLong = kotlin_kotlin.$_$.h5;
53
+ var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.v;
54
+ var toDuration = kotlin_kotlin.$_$.s8;
55
+ var Endianness_LITTLE_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.k;
56
+ var FitEncoder = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.a;
57
+ var get_lastIndex = kotlin_kotlin.$_$.j3;
58
+ var first = kotlin_kotlin.$_$.f3;
59
+ var EventType_START_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.c;
60
+ var last = kotlin_kotlin.$_$.l3;
61
+ var EventType_STOP_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.e;
62
+ var EventType_STOP_ALL_getInstance = kotlin_io_github_glandais_fit_kotlin_sdk.$_$.d;
63
+ var initMetadataForObject = kotlin_kotlin.$_$.k6;
64
+ var Long = kotlin_kotlin.$_$.z8;
65
+ var listOf = kotlin_kotlin.$_$.m3;
66
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.v2;
67
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.h1;
68
+ var isNaN_0 = kotlin_kotlin.$_$.p9;
69
+ var until = kotlin_kotlin.$_$.h7;
49
70
  //endregion
50
71
  //region block: pre-declaration
51
72
  initMetadataForClass(FitSport, 'FitSport', VOID, Enum);
73
+ initMetadataForCompanion(Companion);
52
74
  initMetadataForClass(FitCourse, 'FitCourse');
75
+ initMetadataForClass(FitSegment, 'FitSegment');
53
76
  initMetadataForClass(FitRecord, 'FitRecord');
54
77
  initMetadataForClass(FitLap, 'FitLap');
78
+ initMetadataForObject(FitEncoder_0, 'FitEncoder');
55
79
  initMetadataForObject(FitUnits, 'FitUnits');
56
- initMetadataForObject(FitEncoder, 'FitEncoder');
57
80
  //endregion
58
- var FitSport_CYCLING_instance;
59
- var FitSport_RUNNING_instance;
60
- var FitSport_GENERIC_instance;
61
- var FitSport_entriesInitialized;
62
- function FitSport_initEntries() {
63
- if (FitSport_entriesInitialized)
81
+ var static_init_called;
82
+ function static_init() {
83
+ if (static_init_called)
64
84
  return Unit_instance;
65
- FitSport_entriesInitialized = true;
85
+ static_init_called = true;
66
86
  FitSport_CYCLING_instance = new FitSport('CYCLING', 0, 2);
67
87
  FitSport_RUNNING_instance = new FitSport('RUNNING', 1, 1);
68
88
  FitSport_GENERIC_instance = new FitSport('GENERIC', 2, 0);
69
89
  }
90
+ var FitSport_CYCLING_instance;
91
+ var FitSport_RUNNING_instance;
92
+ var FitSport_GENERIC_instance;
70
93
  function FitSport(name, ordinal, value) {
71
94
  Enum.call(this, name, ordinal);
72
- this.y1w_1 = value;
95
+ this.value_1 = value;
73
96
  }
74
- function FitCourse(name, startTime, records, lap, sport) {
97
+ function Companion() {
98
+ }
99
+ var Companion_instance;
100
+ function Companion_getInstance_0() {
101
+ return Companion_instance;
102
+ }
103
+ function FitCourse(name, startTime, segments, sport) {
75
104
  sport = sport === VOID ? FitSport_CYCLING_getInstance() : sport;
76
- this.z1w_1 = name;
77
- this.a1x_1 = startTime;
78
- this.b1x_1 = records;
79
- this.c1x_1 = lap;
80
- this.d1x_1 = sport;
105
+ this.name_1 = name;
106
+ this.startTime_1 = startTime;
107
+ this.segments_1 = segments;
108
+ this.sport_1 = sport;
81
109
  // Inline function 'kotlin.collections.isNotEmpty' call
82
110
  // Inline function 'kotlin.require' call
83
- if (!!this.b1x_1.n()) {
84
- var message = 'A FIT course needs at least one record';
111
+ if (!!this.segments_1.isEmpty_y1axqb_k$()) {
112
+ var message = 'A FIT course needs at least one segment';
85
113
  throw IllegalArgumentException_init_$Create$(toString(message));
86
114
  }
115
+ var tmp0 = this.segments_1;
116
+ var tmp$ret$3;
117
+ $l$block_0: {
118
+ // Inline function 'kotlin.collections.all' call
119
+ var tmp;
120
+ if (isInterface(tmp0, Collection)) {
121
+ tmp = tmp0.isEmpty_y1axqb_k$();
122
+ } else {
123
+ tmp = false;
124
+ }
125
+ if (tmp) {
126
+ tmp$ret$3 = true;
127
+ break $l$block_0;
128
+ }
129
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
130
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
131
+ var element = _iterator__ex2g4s.next_20eer_k$();
132
+ // Inline function 'kotlin.collections.isNotEmpty' call
133
+ if (!!element.records_1.isEmpty_y1axqb_k$()) {
134
+ tmp$ret$3 = false;
135
+ break $l$block_0;
136
+ }
137
+ }
138
+ tmp$ret$3 = true;
139
+ }
140
+ // Inline function 'kotlin.require' call
141
+ if (!tmp$ret$3) {
142
+ var message_0 = 'A FIT course segment needs at least one record';
143
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
144
+ }
87
145
  }
88
146
  protoOf(FitCourse).toString = function () {
89
- return 'FitCourse(name=' + this.z1w_1 + ', startTime=' + this.a1x_1.toString() + ', records=' + toString(this.b1x_1) + ', lap=' + this.c1x_1.toString() + ', sport=' + this.d1x_1.toString() + ')';
147
+ return 'FitCourse(name=' + this.name_1 + ', startTime=' + this.startTime_1.toString() + ', segments=' + toString(this.segments_1) + ', sport=' + this.sport_1.toString() + ')';
90
148
  };
91
149
  protoOf(FitCourse).hashCode = function () {
92
- var result = getStringHashCode(this.z1w_1);
93
- result = imul(result, 31) + this.a1x_1.hashCode() | 0;
94
- result = imul(result, 31) + hashCode(this.b1x_1) | 0;
95
- result = imul(result, 31) + this.c1x_1.hashCode() | 0;
96
- result = imul(result, 31) + this.d1x_1.hashCode() | 0;
150
+ var result = getStringHashCode(this.name_1);
151
+ result = imul(result, 31) + this.startTime_1.hashCode() | 0;
152
+ result = imul(result, 31) + hashCode(this.segments_1) | 0;
153
+ result = imul(result, 31) + this.sport_1.hashCode() | 0;
97
154
  return result;
98
155
  };
99
156
  protoOf(FitCourse).equals = function (other) {
@@ -101,15 +158,36 @@
101
158
  return true;
102
159
  if (!(other instanceof FitCourse))
103
160
  return false;
104
- if (!(this.z1w_1 === other.z1w_1))
161
+ if (!(this.name_1 === other.name_1))
105
162
  return false;
106
- if (!this.a1x_1.equals(other.a1x_1))
163
+ if (!this.startTime_1.equals(other.startTime_1))
107
164
  return false;
108
- if (!equals(this.b1x_1, other.b1x_1))
165
+ if (!equals(this.segments_1, other.segments_1))
109
166
  return false;
110
- if (!this.c1x_1.equals(other.c1x_1))
167
+ if (!this.sport_1.equals(other.sport_1))
111
168
  return false;
112
- if (!this.d1x_1.equals(other.d1x_1))
169
+ return true;
170
+ };
171
+ function FitSegment(records, lap) {
172
+ this.records_1 = records;
173
+ this.lap_1 = lap;
174
+ }
175
+ protoOf(FitSegment).toString = function () {
176
+ return 'FitSegment(records=' + toString(this.records_1) + ', lap=' + this.lap_1.toString() + ')';
177
+ };
178
+ protoOf(FitSegment).hashCode = function () {
179
+ var result = hashCode(this.records_1);
180
+ result = imul(result, 31) + this.lap_1.hashCode() | 0;
181
+ return result;
182
+ };
183
+ protoOf(FitSegment).equals = function (other) {
184
+ if (this === other)
185
+ return true;
186
+ if (!(other instanceof FitSegment))
187
+ return false;
188
+ if (!equals(this.records_1, other.records_1))
189
+ return false;
190
+ if (!this.lap_1.equals(other.lap_1))
113
191
  return false;
114
192
  return true;
115
193
  };
@@ -120,31 +198,31 @@
120
198
  heartRate = heartRate === VOID ? null : heartRate;
121
199
  cadence = cadence === VOID ? null : cadence;
122
200
  temperatureC = temperatureC === VOID ? null : temperatureC;
123
- this.e1x_1 = timestamp;
124
- this.f1x_1 = latitudeDeg;
125
- this.g1x_1 = longitudeDeg;
126
- this.h1x_1 = altitudeM;
127
- this.i1x_1 = distanceM;
128
- this.j1x_1 = speedMs;
129
- this.k1x_1 = powerW;
130
- this.l1x_1 = heartRate;
131
- this.m1x_1 = cadence;
132
- this.n1x_1 = temperatureC;
201
+ this.timestamp_1 = timestamp;
202
+ this.latitudeDeg_1 = latitudeDeg;
203
+ this.longitudeDeg_1 = longitudeDeg;
204
+ this.altitudeM_1 = altitudeM;
205
+ this.distanceM_1 = distanceM;
206
+ this.speedMs_1 = speedMs;
207
+ this.powerW_1 = powerW;
208
+ this.heartRate_1 = heartRate;
209
+ this.cadence_1 = cadence;
210
+ this.temperatureC_1 = temperatureC;
133
211
  }
134
212
  protoOf(FitRecord).toString = function () {
135
- return 'FitRecord(timestamp=' + this.e1x_1.toString() + ', latitudeDeg=' + this.f1x_1 + ', longitudeDeg=' + this.g1x_1 + ', altitudeM=' + this.h1x_1 + ', distanceM=' + this.i1x_1 + ', speedMs=' + this.j1x_1 + ', powerW=' + this.k1x_1 + ', heartRate=' + this.l1x_1 + ', cadence=' + this.m1x_1 + ', temperatureC=' + this.n1x_1 + ')';
213
+ return 'FitRecord(timestamp=' + this.timestamp_1.toString() + ', latitudeDeg=' + this.latitudeDeg_1 + ', longitudeDeg=' + this.longitudeDeg_1 + ', altitudeM=' + this.altitudeM_1 + ', distanceM=' + this.distanceM_1 + ', speedMs=' + this.speedMs_1 + ', powerW=' + this.powerW_1 + ', heartRate=' + this.heartRate_1 + ', cadence=' + this.cadence_1 + ', temperatureC=' + this.temperatureC_1 + ')';
136
214
  };
137
215
  protoOf(FitRecord).hashCode = function () {
138
- var result = this.e1x_1.hashCode();
139
- result = imul(result, 31) + getNumberHashCode(this.f1x_1) | 0;
140
- result = imul(result, 31) + getNumberHashCode(this.g1x_1) | 0;
141
- result = imul(result, 31) + (this.h1x_1 == null ? 0 : getNumberHashCode(this.h1x_1)) | 0;
142
- result = imul(result, 31) + getNumberHashCode(this.i1x_1) | 0;
143
- result = imul(result, 31) + (this.j1x_1 == null ? 0 : getNumberHashCode(this.j1x_1)) | 0;
144
- result = imul(result, 31) + (this.k1x_1 == null ? 0 : this.k1x_1) | 0;
145
- result = imul(result, 31) + (this.l1x_1 == null ? 0 : this.l1x_1) | 0;
146
- result = imul(result, 31) + (this.m1x_1 == null ? 0 : this.m1x_1) | 0;
147
- result = imul(result, 31) + (this.n1x_1 == null ? 0 : getNumberHashCode(this.n1x_1)) | 0;
216
+ var result = this.timestamp_1.hashCode();
217
+ result = imul(result, 31) + getNumberHashCode(this.latitudeDeg_1) | 0;
218
+ result = imul(result, 31) + getNumberHashCode(this.longitudeDeg_1) | 0;
219
+ result = imul(result, 31) + (this.altitudeM_1 == null ? 0 : getNumberHashCode(this.altitudeM_1)) | 0;
220
+ result = imul(result, 31) + getNumberHashCode(this.distanceM_1) | 0;
221
+ result = imul(result, 31) + (this.speedMs_1 == null ? 0 : getNumberHashCode(this.speedMs_1)) | 0;
222
+ result = imul(result, 31) + (this.powerW_1 == null ? 0 : this.powerW_1) | 0;
223
+ result = imul(result, 31) + (this.heartRate_1 == null ? 0 : this.heartRate_1) | 0;
224
+ result = imul(result, 31) + (this.cadence_1 == null ? 0 : this.cadence_1) | 0;
225
+ result = imul(result, 31) + (this.temperatureC_1 == null ? 0 : getNumberHashCode(this.temperatureC_1)) | 0;
148
226
  return result;
149
227
  };
150
228
  protoOf(FitRecord).equals = function (other) {
@@ -152,25 +230,25 @@
152
230
  return true;
153
231
  if (!(other instanceof FitRecord))
154
232
  return false;
155
- if (!this.e1x_1.equals(other.e1x_1))
233
+ if (!this.timestamp_1.equals(other.timestamp_1))
156
234
  return false;
157
- if (!equals(this.f1x_1, other.f1x_1))
235
+ if (!equals(this.latitudeDeg_1, other.latitudeDeg_1))
158
236
  return false;
159
- if (!equals(this.g1x_1, other.g1x_1))
237
+ if (!equals(this.longitudeDeg_1, other.longitudeDeg_1))
160
238
  return false;
161
- if (!equals(this.h1x_1, other.h1x_1))
239
+ if (!equals(this.altitudeM_1, other.altitudeM_1))
162
240
  return false;
163
- if (!equals(this.i1x_1, other.i1x_1))
241
+ if (!equals(this.distanceM_1, other.distanceM_1))
164
242
  return false;
165
- if (!equals(this.j1x_1, other.j1x_1))
243
+ if (!equals(this.speedMs_1, other.speedMs_1))
166
244
  return false;
167
- if (!(this.k1x_1 == other.k1x_1))
245
+ if (!(this.powerW_1 == other.powerW_1))
168
246
  return false;
169
- if (!(this.l1x_1 == other.l1x_1))
247
+ if (!(this.heartRate_1 == other.heartRate_1))
170
248
  return false;
171
- if (!(this.m1x_1 == other.m1x_1))
249
+ if (!(this.cadence_1 == other.cadence_1))
172
250
  return false;
173
- if (!equals(this.n1x_1, other.n1x_1))
251
+ if (!equals(this.temperatureC_1, other.temperatureC_1))
174
252
  return false;
175
253
  return true;
176
254
  };
@@ -182,37 +260,37 @@
182
260
  startLongitudeDeg = startLongitudeDeg === VOID ? null : startLongitudeDeg;
183
261
  endLatitudeDeg = endLatitudeDeg === VOID ? null : endLatitudeDeg;
184
262
  endLongitudeDeg = endLongitudeDeg === VOID ? null : endLongitudeDeg;
185
- this.o1x_1 = startTime;
186
- this.p1x_1 = totalElapsedTimeS;
187
- this.q1x_1 = totalTimerTimeS;
188
- this.r1x_1 = totalDistanceM;
189
- this.s1x_1 = totalAscentM;
190
- this.t1x_1 = totalDescentM;
191
- this.u1x_1 = maxSpeedMs;
192
- this.v1x_1 = minAltitudeM;
193
- this.w1x_1 = maxAltitudeM;
194
- this.x1x_1 = startLatitudeDeg;
195
- this.y1x_1 = startLongitudeDeg;
196
- this.z1x_1 = endLatitudeDeg;
197
- this.a1y_1 = endLongitudeDeg;
263
+ this.startTime_1 = startTime;
264
+ this.totalElapsedTimeS_1 = totalElapsedTimeS;
265
+ this.totalTimerTimeS_1 = totalTimerTimeS;
266
+ this.totalDistanceM_1 = totalDistanceM;
267
+ this.totalAscentM_1 = totalAscentM;
268
+ this.totalDescentM_1 = totalDescentM;
269
+ this.maxSpeedMs_1 = maxSpeedMs;
270
+ this.minAltitudeM_1 = minAltitudeM;
271
+ this.maxAltitudeM_1 = maxAltitudeM;
272
+ this.startLatitudeDeg_1 = startLatitudeDeg;
273
+ this.startLongitudeDeg_1 = startLongitudeDeg;
274
+ this.endLatitudeDeg_1 = endLatitudeDeg;
275
+ this.endLongitudeDeg_1 = endLongitudeDeg;
198
276
  }
199
277
  protoOf(FitLap).toString = function () {
200
- return 'FitLap(startTime=' + this.o1x_1.toString() + ', totalElapsedTimeS=' + this.p1x_1 + ', totalTimerTimeS=' + this.q1x_1 + ', totalDistanceM=' + this.r1x_1 + ', totalAscentM=' + this.s1x_1 + ', totalDescentM=' + this.t1x_1 + ', maxSpeedMs=' + this.u1x_1 + ', minAltitudeM=' + this.v1x_1 + ', maxAltitudeM=' + this.w1x_1 + ', startLatitudeDeg=' + this.x1x_1 + ', startLongitudeDeg=' + this.y1x_1 + ', endLatitudeDeg=' + this.z1x_1 + ', endLongitudeDeg=' + this.a1y_1 + ')';
278
+ return 'FitLap(startTime=' + this.startTime_1.toString() + ', totalElapsedTimeS=' + this.totalElapsedTimeS_1 + ', totalTimerTimeS=' + this.totalTimerTimeS_1 + ', totalDistanceM=' + this.totalDistanceM_1 + ', totalAscentM=' + this.totalAscentM_1 + ', totalDescentM=' + this.totalDescentM_1 + ', maxSpeedMs=' + this.maxSpeedMs_1 + ', minAltitudeM=' + this.minAltitudeM_1 + ', maxAltitudeM=' + this.maxAltitudeM_1 + ', startLatitudeDeg=' + this.startLatitudeDeg_1 + ', startLongitudeDeg=' + this.startLongitudeDeg_1 + ', endLatitudeDeg=' + this.endLatitudeDeg_1 + ', endLongitudeDeg=' + this.endLongitudeDeg_1 + ')';
201
279
  };
202
280
  protoOf(FitLap).hashCode = function () {
203
- var result = this.o1x_1.hashCode();
204
- result = imul(result, 31) + getNumberHashCode(this.p1x_1) | 0;
205
- result = imul(result, 31) + getNumberHashCode(this.q1x_1) | 0;
206
- result = imul(result, 31) + getNumberHashCode(this.r1x_1) | 0;
207
- result = imul(result, 31) + this.s1x_1 | 0;
208
- result = imul(result, 31) + this.t1x_1 | 0;
209
- result = imul(result, 31) + (this.u1x_1 == null ? 0 : getNumberHashCode(this.u1x_1)) | 0;
210
- result = imul(result, 31) + (this.v1x_1 == null ? 0 : getNumberHashCode(this.v1x_1)) | 0;
211
- result = imul(result, 31) + (this.w1x_1 == null ? 0 : getNumberHashCode(this.w1x_1)) | 0;
212
- result = imul(result, 31) + (this.x1x_1 == null ? 0 : getNumberHashCode(this.x1x_1)) | 0;
213
- result = imul(result, 31) + (this.y1x_1 == null ? 0 : getNumberHashCode(this.y1x_1)) | 0;
214
- result = imul(result, 31) + (this.z1x_1 == null ? 0 : getNumberHashCode(this.z1x_1)) | 0;
215
- result = imul(result, 31) + (this.a1y_1 == null ? 0 : getNumberHashCode(this.a1y_1)) | 0;
281
+ var result = this.startTime_1.hashCode();
282
+ result = imul(result, 31) + getNumberHashCode(this.totalElapsedTimeS_1) | 0;
283
+ result = imul(result, 31) + getNumberHashCode(this.totalTimerTimeS_1) | 0;
284
+ result = imul(result, 31) + getNumberHashCode(this.totalDistanceM_1) | 0;
285
+ result = imul(result, 31) + this.totalAscentM_1 | 0;
286
+ result = imul(result, 31) + this.totalDescentM_1 | 0;
287
+ result = imul(result, 31) + (this.maxSpeedMs_1 == null ? 0 : getNumberHashCode(this.maxSpeedMs_1)) | 0;
288
+ result = imul(result, 31) + (this.minAltitudeM_1 == null ? 0 : getNumberHashCode(this.minAltitudeM_1)) | 0;
289
+ result = imul(result, 31) + (this.maxAltitudeM_1 == null ? 0 : getNumberHashCode(this.maxAltitudeM_1)) | 0;
290
+ result = imul(result, 31) + (this.startLatitudeDeg_1 == null ? 0 : getNumberHashCode(this.startLatitudeDeg_1)) | 0;
291
+ result = imul(result, 31) + (this.startLongitudeDeg_1 == null ? 0 : getNumberHashCode(this.startLongitudeDeg_1)) | 0;
292
+ result = imul(result, 31) + (this.endLatitudeDeg_1 == null ? 0 : getNumberHashCode(this.endLatitudeDeg_1)) | 0;
293
+ result = imul(result, 31) + (this.endLongitudeDeg_1 == null ? 0 : getNumberHashCode(this.endLongitudeDeg_1)) | 0;
216
294
  return result;
217
295
  };
218
296
  protoOf(FitLap).equals = function (other) {
@@ -220,49 +298,270 @@
220
298
  return true;
221
299
  if (!(other instanceof FitLap))
222
300
  return false;
223
- if (!this.o1x_1.equals(other.o1x_1))
301
+ if (!this.startTime_1.equals(other.startTime_1))
224
302
  return false;
225
- if (!equals(this.p1x_1, other.p1x_1))
303
+ if (!equals(this.totalElapsedTimeS_1, other.totalElapsedTimeS_1))
226
304
  return false;
227
- if (!equals(this.q1x_1, other.q1x_1))
305
+ if (!equals(this.totalTimerTimeS_1, other.totalTimerTimeS_1))
228
306
  return false;
229
- if (!equals(this.r1x_1, other.r1x_1))
307
+ if (!equals(this.totalDistanceM_1, other.totalDistanceM_1))
230
308
  return false;
231
- if (!(this.s1x_1 === other.s1x_1))
309
+ if (!(this.totalAscentM_1 === other.totalAscentM_1))
232
310
  return false;
233
- if (!(this.t1x_1 === other.t1x_1))
311
+ if (!(this.totalDescentM_1 === other.totalDescentM_1))
234
312
  return false;
235
- if (!equals(this.u1x_1, other.u1x_1))
313
+ if (!equals(this.maxSpeedMs_1, other.maxSpeedMs_1))
236
314
  return false;
237
- if (!equals(this.v1x_1, other.v1x_1))
315
+ if (!equals(this.minAltitudeM_1, other.minAltitudeM_1))
238
316
  return false;
239
- if (!equals(this.w1x_1, other.w1x_1))
317
+ if (!equals(this.maxAltitudeM_1, other.maxAltitudeM_1))
240
318
  return false;
241
- if (!equals(this.x1x_1, other.x1x_1))
319
+ if (!equals(this.startLatitudeDeg_1, other.startLatitudeDeg_1))
242
320
  return false;
243
- if (!equals(this.y1x_1, other.y1x_1))
321
+ if (!equals(this.startLongitudeDeg_1, other.startLongitudeDeg_1))
244
322
  return false;
245
- if (!equals(this.z1x_1, other.z1x_1))
323
+ if (!equals(this.endLatitudeDeg_1, other.endLatitudeDeg_1))
246
324
  return false;
247
- if (!equals(this.a1y_1, other.a1y_1))
325
+ if (!equals(this.endLongitudeDeg_1, other.endLongitudeDeg_1))
248
326
  return false;
249
327
  return true;
250
328
  };
251
329
  function FitSport_CYCLING_getInstance() {
252
- FitSport_initEntries();
330
+ static_init();
253
331
  return FitSport_CYCLING_instance;
254
332
  }
333
+ function fileIdMesg($this, course) {
334
+ // Inline function 'kotlin.apply' call
335
+ var this_0 = FileIdMesg_init_$Create$();
336
+ this_0.set_type_p09upi_k$(File_COURSE_getInstance());
337
+ this_0.set_manufacturer_o24uie_k$(Manufacturer_DYNASTREAM_getInstance());
338
+ this_0.set_product_ocp49n_k$(_UShort___init__impl__jigrne(12345));
339
+ this_0.set_serialNumber_x7w2s6_k$(_UInt___init__impl__l7qpdl(12345));
340
+ // Inline function 'kotlin.toUShort' call
341
+ var this_1 = getStringHashCode(course.name_1) & 65535;
342
+ var tmp$ret$2 = _UShort___init__impl__jigrne(toShort(this_1));
343
+ this_0.set_number_htl6z3_k$(tmp$ret$2);
344
+ this_0.set_timeCreated_hwevrz_k$(course.startTime_1);
345
+ return this_0;
346
+ }
347
+ function courseMesg($this, course) {
348
+ // Inline function 'kotlin.apply' call
349
+ var this_0 = CourseMesg_init_$Create$();
350
+ this_0.set_name_wkmnld_k$(course.name_1);
351
+ this_0.set_sport_ql7rac_k$(toSdkSport(FitEncoder_getInstance(), course.sport_1));
352
+ return this_0;
353
+ }
354
+ function lapMesg($this, lap) {
355
+ // Inline function 'kotlin.apply' call
356
+ var this_0 = LapMesg_init_$Create$();
357
+ this_0.set_startTime_gpvleb_k$(lap.startTime_1);
358
+ this_0.set_timestamp_g7bday_k$(lap.startTime_1.plus_tegsqz_k$(secondsAsDuration(FitEncoder_getInstance(), lap.totalElapsedTimeS_1)));
359
+ this_0.set_totalElapsedTime_5may4p_k$(lap.totalElapsedTimeS_1);
360
+ this_0.set_totalTimerTime_is2q9s_k$(lap.totalTimerTimeS_1);
361
+ this_0.set_totalDistance_u680xd_k$(lap.totalDistanceM_1);
362
+ // Inline function 'kotlin.toUShort' call
363
+ var this_1 = lap.totalAscentM_1;
364
+ var tmp$ret$2 = _UShort___init__impl__jigrne(toShort(this_1));
365
+ this_0.set_totalAscent_h748uu_k$(tmp$ret$2);
366
+ // Inline function 'kotlin.toUShort' call
367
+ var this_2 = lap.totalDescentM_1;
368
+ var tmp$ret$3 = _UShort___init__impl__jigrne(toShort(this_2));
369
+ this_0.set_totalDescent_xazvo_k$(tmp$ret$3);
370
+ if (lap.totalTimerTimeS_1 > 0.0) {
371
+ this_0.set_avgSpeed_wl7p6h_k$(lap.totalDistanceM_1 / lap.totalTimerTimeS_1);
372
+ }
373
+ var tmp0_safe_receiver = lap.maxSpeedMs_1;
374
+ if (tmp0_safe_receiver == null)
375
+ null;
376
+ else {
377
+ // Inline function 'kotlin.let' call
378
+ this_0.set_maxSpeed_zf8xrp_k$(tmp0_safe_receiver);
379
+ }
380
+ var tmp1_safe_receiver = lap.minAltitudeM_1;
381
+ if (tmp1_safe_receiver == null)
382
+ null;
383
+ else {
384
+ // Inline function 'kotlin.let' call
385
+ this_0.set_minAltitude_th05po_k$(tmp1_safe_receiver);
386
+ }
387
+ var tmp2_safe_receiver = lap.maxAltitudeM_1;
388
+ if (tmp2_safe_receiver == null)
389
+ null;
390
+ else {
391
+ // Inline function 'kotlin.let' call
392
+ this_0.set_maxAltitude_o8im4i_k$(tmp2_safe_receiver);
393
+ }
394
+ var tmp3_safe_receiver = lap.startLatitudeDeg_1;
395
+ if (tmp3_safe_receiver == null)
396
+ null;
397
+ else {
398
+ // Inline function 'kotlin.let' call
399
+ this_0.set_startPositionLat_i4v4h6_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(tmp3_safe_receiver));
400
+ }
401
+ var tmp4_safe_receiver = lap.startLongitudeDeg_1;
402
+ if (tmp4_safe_receiver == null)
403
+ null;
404
+ else {
405
+ // Inline function 'kotlin.let' call
406
+ this_0.set_startPositionLong_856b8x_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(tmp4_safe_receiver));
407
+ }
408
+ var tmp5_safe_receiver = lap.endLatitudeDeg_1;
409
+ if (tmp5_safe_receiver == null)
410
+ null;
411
+ else {
412
+ // Inline function 'kotlin.let' call
413
+ this_0.set_endPositionLat_fik6v1_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(tmp5_safe_receiver));
414
+ }
415
+ var tmp6_safe_receiver = lap.endLongitudeDeg_1;
416
+ if (tmp6_safe_receiver == null)
417
+ null;
418
+ else {
419
+ // Inline function 'kotlin.let' call
420
+ this_0.set_endPositionLong_ufoddk_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(tmp6_safe_receiver));
421
+ }
422
+ return this_0;
423
+ }
424
+ function recordMesg($this, record) {
425
+ // Inline function 'kotlin.apply' call
426
+ var this_0 = RecordMesg_init_$Create$();
427
+ this_0.set_timestamp_g7bday_k$(record.timestamp_1);
428
+ this_0.set_positionLat_45irwe_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(record.latitudeDeg_1));
429
+ this_0.set_positionLong_ribzbt_k$(FitUnits_getInstance().degreesToSemicircles_1s9utv_k$(record.longitudeDeg_1));
430
+ this_0.set_distance_unowtj_k$(record.distanceM_1);
431
+ var tmp0_safe_receiver = record.altitudeM_1;
432
+ if (tmp0_safe_receiver == null)
433
+ null;
434
+ else {
435
+ // Inline function 'kotlin.let' call
436
+ this_0.set_altitude_n5x9g4_k$(tmp0_safe_receiver);
437
+ }
438
+ var tmp1_safe_receiver = record.speedMs_1;
439
+ if (tmp1_safe_receiver == null)
440
+ null;
441
+ else {
442
+ // Inline function 'kotlin.let' call
443
+ this_0.set_speed_8oaspt_k$(tmp1_safe_receiver);
444
+ }
445
+ var tmp2_safe_receiver = record.powerW_1;
446
+ if (tmp2_safe_receiver == null)
447
+ null;
448
+ else {
449
+ // Inline function 'kotlin.let' call
450
+ // Inline function 'kotlin.toUShort' call
451
+ var tmp$ret$8 = _UShort___init__impl__jigrne(toShort(tmp2_safe_receiver));
452
+ this_0.set_power_jxusa9_k$(tmp$ret$8);
453
+ }
454
+ var tmp3_safe_receiver = record.heartRate_1;
455
+ if (tmp3_safe_receiver == null)
456
+ null;
457
+ else {
458
+ // Inline function 'kotlin.let' call
459
+ // Inline function 'kotlin.toUByte' call
460
+ var tmp$ret$11 = _UByte___init__impl__g9hnc4(toByte(tmp3_safe_receiver));
461
+ this_0.set_heartRate_7mkxew_k$(tmp$ret$11);
462
+ }
463
+ var tmp4_safe_receiver = record.cadence_1;
464
+ if (tmp4_safe_receiver == null)
465
+ null;
466
+ else {
467
+ // Inline function 'kotlin.let' call
468
+ // Inline function 'kotlin.toUByte' call
469
+ var tmp$ret$14 = _UByte___init__impl__g9hnc4(toByte(tmp4_safe_receiver));
470
+ this_0.set_cadence_i2hkh9_k$(tmp$ret$14);
471
+ }
472
+ var tmp5_safe_receiver = record.temperatureC_1;
473
+ if (tmp5_safe_receiver == null)
474
+ null;
475
+ else {
476
+ // Inline function 'kotlin.let' call
477
+ this_0.set_temperature_nnz6s4_k$(toByte(roundToInt(tmp5_safe_receiver)));
478
+ }
479
+ return this_0;
480
+ }
481
+ function timerEvent($this, at, type) {
482
+ // Inline function 'kotlin.apply' call
483
+ var this_0 = EventMesg_init_$Create$();
484
+ this_0.set_event_s3s3to_k$(Event_TIMER_getInstance());
485
+ this_0.set_eventType_1ujcik_k$(type);
486
+ this_0.set_eventGroup_4wrvtr_k$(_UByte___init__impl__g9hnc4(0));
487
+ this_0.set_timestamp_g7bday_k$(at);
488
+ return this_0;
489
+ }
490
+ function toSdkSport($this, $receiver) {
491
+ var tmp;
492
+ switch ($receiver.ordinal_1) {
493
+ case 0:
494
+ tmp = Sport_CYCLING_getInstance();
495
+ break;
496
+ case 1:
497
+ tmp = Sport_RUNNING_getInstance();
498
+ break;
499
+ case 2:
500
+ tmp = Sport_GENERIC_getInstance();
501
+ break;
502
+ default:
503
+ noWhenBranchMatchedException();
504
+ break;
505
+ }
506
+ return tmp;
507
+ }
508
+ function secondsAsDuration($this, $receiver) {
509
+ Companion_getInstance();
510
+ // Inline function 'kotlin.time.Companion.milliseconds' call
511
+ var this_0 = numberToLong($receiver * 1000.0);
512
+ return toDuration(this_0, DurationUnit_MILLISECONDS_getInstance());
513
+ }
514
+ function FitEncoder_0() {
515
+ FitEncoder_instance = this;
516
+ this.PRODUCT_ID_1 = _UShort___init__impl__jigrne(12345);
517
+ this.SERIAL_NUMBER_1 = _UInt___init__impl__l7qpdl(12345);
518
+ }
519
+ protoOf(FitEncoder_0).encode_5fozs1_k$ = function (course) {
520
+ // Inline function 'com.garmin.fit.encodeFit' call
521
+ var endianness = Endianness_LITTLE_getInstance();
522
+ // Inline function 'kotlin.apply' call
523
+ var this_0 = new FitEncoder(VOID, VOID, endianness);
524
+ this_0.write_h1oj8u_k$(fileIdMesg(FitEncoder_getInstance(), course));
525
+ this_0.write_h1oj8u_k$(courseMesg(FitEncoder_getInstance(), course));
526
+ var _iterator__ex2g4s = course.segments_1.iterator_jk1svi_k$();
527
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
528
+ var segment = _iterator__ex2g4s.next_20eer_k$();
529
+ this_0.write_h1oj8u_k$(lapMesg(FitEncoder_getInstance(), segment.lap_1));
530
+ }
531
+ var iterator = course.segments_1.iterator_jk1svi_k$();
532
+ var index = 0;
533
+ while (iterator.hasNext_bitz1p_k$()) {
534
+ var index_0 = index;
535
+ index = index + 1 | 0;
536
+ var segment_0 = iterator.next_20eer_k$();
537
+ var isLast = index_0 === get_lastIndex(course.segments_1);
538
+ this_0.write_h1oj8u_k$(timerEvent(FitEncoder_getInstance(), first(segment_0.records_1).timestamp_1, EventType_START_getInstance()));
539
+ var _iterator__ex2g4s_0 = segment_0.records_1.iterator_jk1svi_k$();
540
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
541
+ var record = _iterator__ex2g4s_0.next_20eer_k$();
542
+ this_0.write_h1oj8u_k$(recordMesg(FitEncoder_getInstance(), record));
543
+ }
544
+ this_0.write_h1oj8u_k$(timerEvent(FitEncoder_getInstance(), last(segment_0.records_1).timestamp_1, isLast ? EventType_STOP_ALL_getInstance() : EventType_STOP_getInstance()));
545
+ }
546
+ return this_0.close_1keygo_k$();
547
+ };
548
+ var FitEncoder_instance;
549
+ function FitEncoder_getInstance() {
550
+ if (FitEncoder_instance == null)
551
+ new FitEncoder_0();
552
+ return FitEncoder_instance;
553
+ }
255
554
  function FitUnits() {
256
555
  FitUnits_instance = this;
257
- this.b1y_1 = new Long(-294592512, 146);
258
- this.c1y_1 = new Long(631065600, 0);
259
- this.d1y_1 = 1.1930464711111112E7;
260
- this.e1y_1 = 5.0;
261
- this.f1y_1 = 500.0;
262
- this.g1y_1 = 100.0;
263
- this.h1y_1 = 1000.0;
556
+ this.FIT_EPOCH_OFFSET_MS_1 = new Long(-294592512, 146);
557
+ this.FIT_EPOCH_OFFSET_S_1 = new Long(631065600, 0);
558
+ this.SEMICIRCLES_PER_DEGREE_1 = 1.1930464711111112E7;
559
+ this.ALTITUDE_SCALE_1 = 5.0;
560
+ this.ALTITUDE_OFFSET_M_1 = 500.0;
561
+ this.DISTANCE_SCALE_1 = 100.0;
562
+ this.SPEED_SCALE_1 = 1000.0;
264
563
  }
265
- protoOf(FitUnits).i1y = function (degrees) {
564
+ protoOf(FitUnits).degreesToSemicircles_1s9utv_k$ = function (degrees) {
266
565
  return roundToInt(degrees * 1.1930464711111112E7);
267
566
  };
268
567
  var FitUnits_instance;
@@ -273,34 +572,102 @@
273
572
  }
274
573
  function toFitBytes(_this__u8e3s4, name, startTime, sport) {
275
574
  sport = sport === VOID ? FitSport_CYCLING_getInstance() : sport;
276
- return FitEncoder_instance.l1y(toFitCourse(_this__u8e3s4, name, startTime, sport));
575
+ return FitEncoder_getInstance().encode_5fozs1_k$(toFitCourse(_this__u8e3s4, name, startTime, sport));
576
+ }
577
+ function toFitBytes_0(_this__u8e3s4, name, startTime, sport, interPathGap) {
578
+ sport = sport === VOID ? FitSport_CYCLING_getInstance() : sport;
579
+ interPathGap = interPathGap === VOID ? Companion_getInstance().ZERO_1 : interPathGap;
580
+ return FitEncoder_getInstance().encode_5fozs1_k$(toFitCourse_0(_this__u8e3s4, name, startTime, sport, interPathGap));
277
581
  }
278
582
  function toFitCourse(_this__u8e3s4, name, startTime, sport) {
279
583
  sport = sport === VOID ? FitSport_CYCLING_getInstance() : sport;
584
+ return toFitCourse_0(listOf(_this__u8e3s4), name, startTime, sport);
585
+ }
586
+ function toFitCourse_0(_this__u8e3s4, name, startTime, sport, interPathGap) {
587
+ sport = sport === VOID ? FitSport_CYCLING_getInstance() : sport;
588
+ interPathGap = interPathGap === VOID ? Companion_getInstance().ZERO_1 : interPathGap;
589
+ // Inline function 'kotlin.collections.isNotEmpty' call
280
590
  // Inline function 'kotlin.require' call
281
- if (!(_this__u8e3s4.u1q_1 > 0)) {
282
- var message = 'Cannot build a FIT course from an empty Path';
591
+ if (!!_this__u8e3s4.isEmpty_y1axqb_k$()) {
592
+ var message = 'Cannot build a FIT course from an empty list of paths';
283
593
  throw IllegalArgumentException_init_$Create$(toString(message));
284
594
  }
595
+ var tmp$ret$3;
596
+ $l$block_0: {
597
+ // Inline function 'kotlin.collections.all' call
598
+ var tmp;
599
+ if (isInterface(_this__u8e3s4, Collection)) {
600
+ tmp = _this__u8e3s4.isEmpty_y1axqb_k$();
601
+ } else {
602
+ tmp = false;
603
+ }
604
+ if (tmp) {
605
+ tmp$ret$3 = true;
606
+ break $l$block_0;
607
+ }
608
+ var _iterator__ex2g4s = _this__u8e3s4.iterator_jk1svi_k$();
609
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
610
+ var element = _iterator__ex2g4s.next_20eer_k$();
611
+ if (!(element.size_1 > 0)) {
612
+ tmp$ret$3 = false;
613
+ break $l$block_0;
614
+ }
615
+ }
616
+ tmp$ret$3 = true;
617
+ }
618
+ // Inline function 'kotlin.require' call
619
+ if (!tmp$ret$3) {
620
+ var message_0 = 'Cannot build a FIT course from an empty Path';
621
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
622
+ }
623
+ var segmentStart = startTime;
624
+ // Inline function 'kotlin.collections.map' call
625
+ // Inline function 'kotlin.collections.mapTo' call
626
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(_this__u8e3s4, 10));
627
+ var _iterator__ex2g4s_0 = _this__u8e3s4.iterator_jk1svi_k$();
628
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
629
+ var item = _iterator__ex2g4s_0.next_20eer_k$();
630
+ var segment = toFitSegment(item, segmentStart);
631
+ segmentStart = last(segment.records_1).timestamp_1.plus_tegsqz_k$(interPathGap);
632
+ destination.add_utx5q5_k$(segment);
633
+ }
634
+ var segments = destination;
635
+ return new FitCourse(name, startTime, segments, sport);
636
+ }
637
+ function toFitSegment(_this__u8e3s4, startTime) {
638
+ var t0 = _this__u8e3s4.time_ryc845_k$(0);
639
+ var inductionVariable = 1;
640
+ var last = _this__u8e3s4.size_1;
641
+ if (inductionVariable < last)
642
+ do {
643
+ var i = inductionVariable;
644
+ inductionVariable = inductionVariable + 1 | 0;
645
+ // Inline function 'kotlin.require' call
646
+ if (!(_this__u8e3s4.time_ryc845_k$(i) >= _this__u8e3s4.time_ryc845_k$(i - 1 | 0))) {
647
+ var message = 'Path time must be monotonic to encode a FIT file, but time(' + i + ') = ' + _this__u8e3s4.time_ryc845_k$(i) + ' < time(' + (i - 1 | 0) + ') = ' + _this__u8e3s4.time_ryc845_k$(i - 1 | 0);
648
+ throw IllegalArgumentException_init_$Create$(toString(message));
649
+ }
650
+ }
651
+ while (inductionVariable < last);
285
652
  // Inline function 'kotlin.collections.List' call
286
653
  // Inline function 'kotlin.collections.MutableList' call
287
- var size = _this__u8e3s4.u1q_1;
654
+ var size = _this__u8e3s4.size_1;
288
655
  var list = ArrayList_init_$Create$(size);
289
656
  // Inline function 'kotlin.repeat' call
290
- var inductionVariable = 0;
291
- if (inductionVariable < size)
657
+ var inductionVariable_0 = 0;
658
+ if (inductionVariable_0 < size)
292
659
  do {
293
- var index = inductionVariable;
294
- inductionVariable = inductionVariable + 1 | 0;
660
+ var index = inductionVariable_0;
661
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
295
662
  Companion_getInstance();
296
663
  // Inline function 'kotlin.time.Companion.milliseconds' call
297
- var this_0 = numberToLong(_this__u8e3s4.z1q(index));
664
+ var this_0 = numberToLong(_this__u8e3s4.time_ryc845_k$(index) - t0);
298
665
  var tmp$ret$7 = toDuration(this_0, DurationUnit_MILLISECONDS_getInstance());
299
- var tmp = startTime.vd(tmp$ret$7);
300
- var tmp_0 = _this__u8e3s4.w1q(index) * MathConstants_getInstance().uw_1;
301
- var tmp_1 = _this__u8e3s4.x1q(index) * MathConstants_getInstance().uw_1;
666
+ var tmp = startTime.plus_tegsqz_k$(tmp$ret$7);
667
+ var tmp_0 = _this__u8e3s4.latitude_gb4iok_k$(index) * 57.29577951308232;
668
+ var tmp_1 = _this__u8e3s4.longitude_a9xl_k$(index) * 57.29577951308232;
302
669
  // Inline function 'kotlin.takeUnless' call
303
- var this_1 = _this__u8e3s4.y1q(index);
670
+ var this_1 = _this__u8e3s4.elevation_iziwkb_k$(index);
304
671
  var tmp_2;
305
672
  if (!isNaN_0(this_1)) {
306
673
  tmp_2 = this_1;
@@ -308,9 +675,9 @@
308
675
  tmp_2 = null;
309
676
  }
310
677
  var tmp_3 = tmp_2;
311
- var tmp_4 = _this__u8e3s4.k1u(index);
678
+ var tmp_4 = _this__u8e3s4.distance_5s4s77_k$(index);
312
679
  // Inline function 'kotlin.takeUnless' call
313
- var this_2 = _this__u8e3s4.m1v(index);
680
+ var this_2 = _this__u8e3s4.speed_npav2n_k$(index);
314
681
  var tmp_5;
315
682
  if (!isNaN_0(this_2)) {
316
683
  tmp_5 = this_2;
@@ -318,35 +685,35 @@
318
685
  tmp_5 = null;
319
686
  }
320
687
  var tmp_6 = tmp_5;
321
- var tmp0_safe_receiver = optionalComputed(_this__u8e3s4.k1v(index));
688
+ var tmp0_safe_receiver = optionalComputed(_this__u8e3s4.pComputedPower_g6dnn4_k$(index));
322
689
  var tmp_7 = tmp0_safe_receiver == null ? null : roundToInt(tmp0_safe_receiver);
323
- var tmp1_safe_receiver = optionalSensor(_this__u8e3s4.a1r(index));
690
+ var tmp1_safe_receiver = optionalSensor(_this__u8e3s4.heartRate_qiaqfm_k$(index));
324
691
  var tmp_8 = tmp1_safe_receiver == null ? null : roundToInt(tmp1_safe_receiver);
325
- var tmp2_safe_receiver = optionalSensor(_this__u8e3s4.b1r(index));
326
- var tmp$ret$6 = new FitRecord(tmp, tmp_0, tmp_1, tmp_3, tmp_4, tmp_6, tmp_7, tmp_8, tmp2_safe_receiver == null ? null : roundToInt(tmp2_safe_receiver), optionalSensor(_this__u8e3s4.c1r(index)));
327
- list.h(tmp$ret$6);
692
+ var tmp2_safe_receiver = optionalSensor(_this__u8e3s4.cadence_h3r7af_k$(index));
693
+ var tmp$ret$6 = new FitRecord(tmp, tmp_0, tmp_1, tmp_3, tmp_4, tmp_6, tmp_7, tmp_8, tmp2_safe_receiver == null ? null : roundToInt(tmp2_safe_receiver), optionalSensor(_this__u8e3s4.temperature_6yw0ik_k$(index)));
694
+ list.add_utx5q5_k$(tmp$ret$6);
328
695
  }
329
- while (inductionVariable < size);
696
+ while (inductionVariable_0 < size);
330
697
  var records = list;
331
- var tmp_9 = _this__u8e3s4.c1s_1 / 1000.0;
332
- var tmp_10 = _this__u8e3s4.c1s_1 / 1000.0;
333
- var tmp_11 = _this__u8e3s4.x1r_1;
334
- var tmp_12 = roundToIntOrZero(_this__u8e3s4.a1s_1);
335
- var tmp_13 = roundToIntOrZero(-_this__u8e3s4.b1s_1);
336
- var tmp0 = until(0, _this__u8e3s4.u1q_1);
698
+ var tmp_9 = _this__u8e3s4.durationMs_1 / 1000.0;
699
+ var tmp_10 = _this__u8e3s4.durationMs_1 / 1000.0;
700
+ var tmp_11 = _this__u8e3s4.totalDistance_1;
701
+ var tmp_12 = roundToIntOrZero(_this__u8e3s4.elevationGain_1);
702
+ var tmp_13 = roundToIntOrZero(-_this__u8e3s4.elevationLoss_1);
703
+ var tmp0 = until(0, _this__u8e3s4.size_1);
337
704
  var tmp$ret$12;
338
705
  $l$block: {
339
706
  // Inline function 'kotlin.collections.maxOfOrNull' call
340
- var iterator = tmp0.i();
341
- if (!iterator.j()) {
707
+ var iterator = tmp0.iterator_jk1svi_k$();
708
+ if (!iterator.hasNext_bitz1p_k$()) {
342
709
  tmp$ret$12 = null;
343
710
  break $l$block;
344
711
  }
345
- var it = iterator.k();
346
- var maxValue = _this__u8e3s4.m1v(it);
347
- while (iterator.j()) {
348
- var it_0 = iterator.k();
349
- var v = _this__u8e3s4.m1v(it_0);
712
+ var it = iterator.next_20eer_k$();
713
+ var maxValue = _this__u8e3s4.speed_npav2n_k$(it);
714
+ while (iterator.hasNext_bitz1p_k$()) {
715
+ var it_0 = iterator.next_20eer_k$();
716
+ var v = _this__u8e3s4.speed_npav2n_k$(it_0);
350
717
  // Inline function 'kotlin.comparisons.maxOf' call
351
718
  var a = maxValue;
352
719
  maxValue = Math.max(a, v);
@@ -368,20 +735,20 @@
368
735
  tmp_14 = tmp_15;
369
736
  }
370
737
  var tmp_16 = tmp_14;
371
- var tmp0_0 = until(0, _this__u8e3s4.u1q_1);
738
+ var tmp0_0 = until(0, _this__u8e3s4.size_1);
372
739
  var tmp$ret$18;
373
740
  $l$block_0: {
374
741
  // Inline function 'kotlin.collections.minOfOrNull' call
375
- var iterator_0 = tmp0_0.i();
376
- if (!iterator_0.j()) {
742
+ var iterator_0 = tmp0_0.iterator_jk1svi_k$();
743
+ if (!iterator_0.hasNext_bitz1p_k$()) {
377
744
  tmp$ret$18 = null;
378
745
  break $l$block_0;
379
746
  }
380
- var it_1 = iterator_0.k();
381
- var minValue = _this__u8e3s4.y1q(it_1);
382
- while (iterator_0.j()) {
383
- var it_2 = iterator_0.k();
384
- var v_0 = _this__u8e3s4.y1q(it_2);
747
+ var it_1 = iterator_0.next_20eer_k$();
748
+ var minValue = _this__u8e3s4.elevation_iziwkb_k$(it_1);
749
+ while (iterator_0.hasNext_bitz1p_k$()) {
750
+ var it_2 = iterator_0.next_20eer_k$();
751
+ var v_0 = _this__u8e3s4.elevation_iziwkb_k$(it_2);
385
752
  // Inline function 'kotlin.comparisons.minOf' call
386
753
  var a_0 = minValue;
387
754
  minValue = Math.min(a_0, v_0);
@@ -403,20 +770,20 @@
403
770
  tmp_17 = tmp_18;
404
771
  }
405
772
  var tmp_19 = tmp_17;
406
- var tmp0_1 = until(0, _this__u8e3s4.u1q_1);
773
+ var tmp0_1 = until(0, _this__u8e3s4.size_1);
407
774
  var tmp$ret$24;
408
775
  $l$block_1: {
409
776
  // Inline function 'kotlin.collections.maxOfOrNull' call
410
- var iterator_1 = tmp0_1.i();
411
- if (!iterator_1.j()) {
777
+ var iterator_1 = tmp0_1.iterator_jk1svi_k$();
778
+ if (!iterator_1.hasNext_bitz1p_k$()) {
412
779
  tmp$ret$24 = null;
413
780
  break $l$block_1;
414
781
  }
415
- var it_3 = iterator_1.k();
416
- var maxValue_0 = _this__u8e3s4.y1q(it_3);
417
- while (iterator_1.j()) {
418
- var it_4 = iterator_1.k();
419
- var v_1 = _this__u8e3s4.y1q(it_4);
782
+ var it_3 = iterator_1.next_20eer_k$();
783
+ var maxValue_0 = _this__u8e3s4.elevation_iziwkb_k$(it_3);
784
+ while (iterator_1.hasNext_bitz1p_k$()) {
785
+ var it_4 = iterator_1.next_20eer_k$();
786
+ var v_1 = _this__u8e3s4.elevation_iziwkb_k$(it_4);
420
787
  // Inline function 'kotlin.comparisons.maxOf' call
421
788
  var a_1 = maxValue_0;
422
789
  maxValue_0 = Math.max(a_1, v_1);
@@ -437,8 +804,7 @@
437
804
  }
438
805
  tmp_20 = tmp_21;
439
806
  }
440
- var tmp3_lap = new FitLap(startTime, tmp_9, tmp_10, tmp_11, tmp_12, tmp_13, tmp_16, tmp_19, tmp_20, _this__u8e3s4.w1q(0) * MathConstants_getInstance().uw_1, _this__u8e3s4.x1q(0) * MathConstants_getInstance().uw_1, _this__u8e3s4.w1q(_this__u8e3s4.u1q_1 - 1 | 0) * MathConstants_getInstance().uw_1, _this__u8e3s4.x1q(_this__u8e3s4.u1q_1 - 1 | 0) * MathConstants_getInstance().uw_1);
441
- return new FitCourse(name, startTime, records, tmp3_lap, sport);
807
+ return new FitSegment(records, new FitLap(startTime, tmp_9, tmp_10, tmp_11, tmp_12, tmp_13, tmp_16, tmp_19, tmp_20, _this__u8e3s4.latitude_gb4iok_k$(0) * 57.29577951308232, _this__u8e3s4.longitude_a9xl_k$(0) * 57.29577951308232, _this__u8e3s4.latitude_gb4iok_k$(_this__u8e3s4.size_1 - 1 | 0) * 57.29577951308232, _this__u8e3s4.longitude_a9xl_k$(_this__u8e3s4.size_1 - 1 | 0) * 57.29577951308232));
442
808
  }
443
809
  function optionalComputed(_this__u8e3s4) {
444
810
  // Inline function 'kotlin.takeUnless' call
@@ -463,192 +829,13 @@
463
829
  function roundToIntOrZero(_this__u8e3s4) {
464
830
  return isNaN_0(_this__u8e3s4) ? 0 : roundToInt(_this__u8e3s4);
465
831
  }
466
- function timerEvent($this, at, eventType) {
467
- // Inline function 'io.github.glandais.fit.FitEncoder.mesg' call
468
- var o = {};
469
- o['mesgNum'] = 21;
470
- o['event'] = 0;
471
- o['eventType'] = eventType;
472
- o['eventGroup'] = 0;
473
- o['timestamp'] = toJsDate(FitEncoder_instance, at);
474
- return o;
475
- }
476
- function toByteArray($this, $receiver) {
477
- var tmp = 0;
478
- var tmp_0 = $receiver.length;
479
- var tmp_1 = new Int8Array(tmp_0);
480
- while (tmp < tmp_0) {
481
- var tmp_2 = tmp;
482
- // Inline function 'org.khronos.webgl.get' call
483
- // Inline function 'kotlin.js.asDynamic' call
484
- tmp_1[tmp_2] = $receiver[tmp_2];
485
- tmp = tmp + 1 | 0;
486
- }
487
- return tmp_1;
488
- }
489
- function toJsDate($this, $receiver) {
490
- return new Date(toNumber($receiver.ud()));
491
- }
492
- function seconds($this, $receiver) {
493
- Companion_getInstance();
494
- // Inline function 'kotlin.time.Companion.milliseconds' call
495
- var this_0 = numberToLong($receiver * 1000.0);
496
- return toDuration(this_0, DurationUnit_MILLISECONDS_getInstance());
497
- }
498
- function FitEncoder() {
499
- this.j1y_1 = 12345;
500
- this.k1y_1 = 12345.0;
501
- }
502
- protoOf(FitEncoder).l1y = function (course) {
503
- var encoder = new FitSdk.Encoder();
504
- // Inline function 'io.github.glandais.fit.FitEncoder.mesg' call
505
- var o = {};
506
- o['mesgNum'] = 0;
507
- o['type'] = 6;
508
- o['manufacturer'] = 15;
509
- o['product'] = 12345;
510
- o['serialNumber'] = 12345.0;
511
- o['number'] = getStringHashCode(course.z1w_1) & 65535;
512
- o['timeCreated'] = toJsDate(FitEncoder_instance, course.a1x_1);
513
- encoder.writeMesg(o);
514
- // Inline function 'io.github.glandais.fit.FitEncoder.mesg' call
515
- var o_0 = {};
516
- o_0['mesgNum'] = 31;
517
- o_0['name'] = course.z1w_1;
518
- o_0['sport'] = course.d1x_1.y1w_1;
519
- encoder.writeMesg(o_0);
520
- var lap = course.c1x_1;
521
- // Inline function 'io.github.glandais.fit.FitEncoder.mesg' call
522
- var o_1 = {};
523
- o_1['mesgNum'] = 19;
524
- o_1['startTime'] = toJsDate(FitEncoder_instance, lap.o1x_1);
525
- o_1['timestamp'] = toJsDate(FitEncoder_instance, lap.o1x_1.vd(seconds(FitEncoder_instance, lap.p1x_1)));
526
- o_1['totalElapsedTime'] = lap.p1x_1;
527
- o_1['totalTimerTime'] = lap.q1x_1;
528
- o_1['totalDistance'] = lap.r1x_1;
529
- o_1['totalAscent'] = lap.s1x_1;
530
- o_1['totalDescent'] = lap.t1x_1;
531
- if (lap.q1x_1 > 0.0) {
532
- o_1['avgSpeed'] = lap.r1x_1 / lap.q1x_1;
533
- }
534
- var tmp0_safe_receiver = lap.u1x_1;
535
- if (tmp0_safe_receiver == null)
536
- null;
537
- else {
538
- // Inline function 'kotlin.let' call
539
- o_1['maxSpeed'] = tmp0_safe_receiver;
540
- }
541
- var tmp1_safe_receiver = lap.v1x_1;
542
- if (tmp1_safe_receiver == null)
543
- null;
544
- else {
545
- // Inline function 'kotlin.let' call
546
- o_1['minAltitude'] = tmp1_safe_receiver;
547
- }
548
- var tmp2_safe_receiver = lap.w1x_1;
549
- if (tmp2_safe_receiver == null)
550
- null;
551
- else {
552
- // Inline function 'kotlin.let' call
553
- o_1['maxAltitude'] = tmp2_safe_receiver;
554
- }
555
- var tmp3_safe_receiver = lap.x1x_1;
556
- if (tmp3_safe_receiver == null)
557
- null;
558
- else {
559
- // Inline function 'kotlin.let' call
560
- o_1['startPositionLat'] = FitUnits_getInstance().i1y(tmp3_safe_receiver);
561
- }
562
- var tmp4_safe_receiver = lap.y1x_1;
563
- if (tmp4_safe_receiver == null)
564
- null;
565
- else {
566
- // Inline function 'kotlin.let' call
567
- o_1['startPositionLong'] = FitUnits_getInstance().i1y(tmp4_safe_receiver);
568
- }
569
- var tmp5_safe_receiver = lap.z1x_1;
570
- if (tmp5_safe_receiver == null)
571
- null;
572
- else {
573
- // Inline function 'kotlin.let' call
574
- o_1['endPositionLat'] = FitUnits_getInstance().i1y(tmp5_safe_receiver);
575
- }
576
- var tmp6_safe_receiver = lap.a1y_1;
577
- if (tmp6_safe_receiver == null)
578
- null;
579
- else {
580
- // Inline function 'kotlin.let' call
581
- o_1['endPositionLong'] = FitUnits_getInstance().i1y(tmp6_safe_receiver);
582
- }
583
- encoder.writeMesg(o_1);
584
- encoder.writeMesg(timerEvent(this, first(course.b1x_1).e1x_1, 0));
585
- var _iterator__ex2g4s = course.b1x_1.i();
586
- while (_iterator__ex2g4s.j()) {
587
- var record = _iterator__ex2g4s.k();
588
- // Inline function 'io.github.glandais.fit.FitEncoder.mesg' call
589
- var o_2 = {};
590
- o_2['mesgNum'] = 20;
591
- o_2['timestamp'] = toJsDate(FitEncoder_instance, record.e1x_1);
592
- o_2['positionLat'] = FitUnits_getInstance().i1y(record.f1x_1);
593
- o_2['positionLong'] = FitUnits_getInstance().i1y(record.g1x_1);
594
- o_2['distance'] = record.i1x_1;
595
- var tmp0_safe_receiver_0 = record.h1x_1;
596
- if (tmp0_safe_receiver_0 == null)
597
- null;
598
- else {
599
- // Inline function 'kotlin.let' call
600
- o_2['altitude'] = tmp0_safe_receiver_0;
601
- }
602
- var tmp1_safe_receiver_0 = record.j1x_1;
603
- if (tmp1_safe_receiver_0 == null)
604
- null;
605
- else {
606
- // Inline function 'kotlin.let' call
607
- o_2['speed'] = tmp1_safe_receiver_0;
608
- }
609
- var tmp2_safe_receiver_0 = record.k1x_1;
610
- if (tmp2_safe_receiver_0 == null)
611
- null;
612
- else {
613
- // Inline function 'kotlin.let' call
614
- o_2['power'] = tmp2_safe_receiver_0;
615
- }
616
- var tmp3_safe_receiver_0 = record.l1x_1;
617
- if (tmp3_safe_receiver_0 == null)
618
- null;
619
- else {
620
- // Inline function 'kotlin.let' call
621
- o_2['heartRate'] = tmp3_safe_receiver_0;
622
- }
623
- var tmp4_safe_receiver_0 = record.m1x_1;
624
- if (tmp4_safe_receiver_0 == null)
625
- null;
626
- else {
627
- // Inline function 'kotlin.let' call
628
- o_2['cadence'] = tmp4_safe_receiver_0;
629
- }
630
- var tmp5_safe_receiver_0 = record.n1x_1;
631
- if (tmp5_safe_receiver_0 == null)
632
- null;
633
- else {
634
- // Inline function 'kotlin.let' call
635
- o_2['temperature'] = numberToInt(round(tmp5_safe_receiver_0));
636
- }
637
- encoder.writeMesg(o_2);
638
- }
639
- encoder.writeMesg(timerEvent(this, last(course.b1x_1).e1x_1, 4));
640
- return toByteArray(this, encoder.close());
641
- };
642
- var FitEncoder_instance;
643
- function FitEncoder_getInstance() {
644
- return FitEncoder_instance;
645
- }
646
832
  //region block: init
647
- FitEncoder_instance = new FitEncoder();
833
+ Companion_instance = new Companion();
648
834
  //endregion
649
835
  //region block: exports
650
836
  _.$_$ = _.$_$ || {};
651
837
  _.$_$.a = toFitBytes;
838
+ _.$_$.b = toFitBytes_0;
652
839
  //endregion
653
840
  return _;
654
841
  }));