@everyonesoftware/common 6.0.0 → 7.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.
- package/outputs/{characterWriteStream-DUlG_bx_.d.cts → characterWriteStream-ogvZec-U.d.cts} +25 -22
- package/outputs/{characterWriteStream-DUlG_bx_.d.ts → characterWriteStream-ogvZec-U.d.ts} +25 -22
- package/outputs/{chunk-5Z677JON.js → chunk-MMAX3IZF.js} +7694 -3814
- package/outputs/chunk-MMAX3IZF.js.map +1 -0
- package/outputs/{chunk-CHBOMCYM.js → chunk-VF6FBNAU.js} +444 -227
- package/outputs/chunk-VF6FBNAU.js.map +1 -0
- package/outputs/sourceIndex.cjs +925 -559
- package/outputs/sourceIndex.cjs.map +1 -1
- package/outputs/sourceIndex.d.cts +122 -33
- package/outputs/sourceIndex.d.ts +122 -33
- package/outputs/sourceIndex.js +53 -1094
- package/outputs/sourceIndex.js.map +1 -1
- package/outputs/testIndex.cjs +1816 -1126
- package/outputs/testIndex.cjs.map +1 -1
- package/outputs/testIndex.d.cts +112 -64
- package/outputs/testIndex.d.ts +112 -64
- package/outputs/testIndex.js +2 -2
- package/outputs/tests.cjs +13935 -12780
- package/outputs/tests.cjs.map +1 -1
- package/outputs/tests.js +2795 -2250
- package/outputs/tests.js.map +1 -1
- package/package.json +1 -1
- package/outputs/chunk-5Z677JON.js.map +0 -1
- package/outputs/chunk-6V7JRJ7P.js +0 -2469
- package/outputs/chunk-6V7JRJ7P.js.map +0 -1
- package/outputs/chunk-CHBOMCYM.js.map +0 -1
|
@@ -1,2469 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CharacterWriteStream,
|
|
3
|
-
Comparer,
|
|
4
|
-
EmptyError,
|
|
5
|
-
FetchHttpClient,
|
|
6
|
-
HttpOutgoingRequest,
|
|
7
|
-
Iterable,
|
|
8
|
-
Iterator,
|
|
9
|
-
List,
|
|
10
|
-
Map,
|
|
11
|
-
MutableMap,
|
|
12
|
-
NotFoundError,
|
|
13
|
-
PreCondition,
|
|
14
|
-
PromiseAsyncResult,
|
|
15
|
-
Set,
|
|
16
|
-
SyncResult,
|
|
17
|
-
getLength,
|
|
18
|
-
hasProperty,
|
|
19
|
-
isArray,
|
|
20
|
-
isJavascriptIterable,
|
|
21
|
-
isNumber,
|
|
22
|
-
isObject,
|
|
23
|
-
isString,
|
|
24
|
-
isUndefinedOrNull,
|
|
25
|
-
join
|
|
26
|
-
} from "./chunk-5Z677JON.js";
|
|
27
|
-
|
|
28
|
-
// sources/basicDisposable.ts
|
|
29
|
-
var SyncDisposable = class _SyncDisposable {
|
|
30
|
-
disposedFunction;
|
|
31
|
-
disposed;
|
|
32
|
-
constructor(disposedFunction) {
|
|
33
|
-
PreCondition.assertNotUndefinedAndNotNull(disposedFunction, "disposedFunction");
|
|
34
|
-
this.disposedFunction = disposedFunction;
|
|
35
|
-
this.disposed = false;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Create a new {@link Disposable} that will invoke the provided {@link Function} when it is
|
|
39
|
-
* disposed.
|
|
40
|
-
* @param disposedFunction The function to invoke when the returned {@link Disposable} is
|
|
41
|
-
* disposed.
|
|
42
|
-
*/
|
|
43
|
-
static create(disposedFunction) {
|
|
44
|
-
return new _SyncDisposable(disposedFunction);
|
|
45
|
-
}
|
|
46
|
-
dispose() {
|
|
47
|
-
return SyncResult.create(() => {
|
|
48
|
-
const result = !this.disposed;
|
|
49
|
-
if (result) {
|
|
50
|
-
try {
|
|
51
|
-
this.disposedFunction();
|
|
52
|
-
} finally {
|
|
53
|
-
this.disposed = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
isDisposed() {
|
|
60
|
-
return this.disposed;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// sources/byteList.ts
|
|
65
|
-
var ByteList = class _ByteList {
|
|
66
|
-
bytes;
|
|
67
|
-
count;
|
|
68
|
-
constructor() {
|
|
69
|
-
this.bytes = new Uint8Array(0);
|
|
70
|
-
this.count = 0;
|
|
71
|
-
}
|
|
72
|
-
static create(initialValues) {
|
|
73
|
-
const result = new _ByteList();
|
|
74
|
-
if (initialValues) {
|
|
75
|
-
result.addAll(initialValues);
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
add(value) {
|
|
80
|
-
return List.add(this, value);
|
|
81
|
-
}
|
|
82
|
-
addAll(values) {
|
|
83
|
-
return List.addAll(this, values);
|
|
84
|
-
}
|
|
85
|
-
insert(index, value) {
|
|
86
|
-
PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
|
|
87
|
-
PreCondition.assertByte(value, "value");
|
|
88
|
-
if (this.count < this.bytes.length) {
|
|
89
|
-
if (index < this.count) {
|
|
90
|
-
this.bytes.copyWithin(index + 1, index, this.count);
|
|
91
|
-
}
|
|
92
|
-
this.bytes[index] = value;
|
|
93
|
-
} else {
|
|
94
|
-
const newCapacity = this.bytes.length * 2 + 1;
|
|
95
|
-
const newBytes = new Uint8Array(newCapacity);
|
|
96
|
-
if (index > 0) {
|
|
97
|
-
newBytes.set(this.bytes.subarray(0, index));
|
|
98
|
-
}
|
|
99
|
-
newBytes[index] = value;
|
|
100
|
-
if (index < this.count) {
|
|
101
|
-
newBytes.set(this.bytes.subarray(index), index + 1);
|
|
102
|
-
}
|
|
103
|
-
this.bytes = newBytes;
|
|
104
|
-
}
|
|
105
|
-
this.count++;
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
insertAll(index, values) {
|
|
109
|
-
return List.insertAll(this, index, values);
|
|
110
|
-
}
|
|
111
|
-
remove(value, equalFunctions) {
|
|
112
|
-
PreCondition.assertByte(value, "value");
|
|
113
|
-
return List.remove(this, value, equalFunctions);
|
|
114
|
-
}
|
|
115
|
-
removeAt(index) {
|
|
116
|
-
PreCondition.assertAccessIndex(index, this.count, "index");
|
|
117
|
-
const result = this.bytes[index];
|
|
118
|
-
this.bytes.copyWithin(index, index + 1, this.count);
|
|
119
|
-
this.count--;
|
|
120
|
-
return SyncResult.value(result);
|
|
121
|
-
}
|
|
122
|
-
removeFirst() {
|
|
123
|
-
return List.removeFirst(this);
|
|
124
|
-
}
|
|
125
|
-
removeLast() {
|
|
126
|
-
return List.removeLast(this);
|
|
127
|
-
}
|
|
128
|
-
set(index, value) {
|
|
129
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
130
|
-
PreCondition.assertByte(value, "value");
|
|
131
|
-
this.bytes[index] = value;
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
iterate() {
|
|
135
|
-
return Iterator.create(this.bytes[Symbol.iterator]().take(this.count));
|
|
136
|
-
}
|
|
137
|
-
get(index) {
|
|
138
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
139
|
-
return SyncResult.value(this.bytes.at(index));
|
|
140
|
-
}
|
|
141
|
-
toArray() {
|
|
142
|
-
return List.toArray(this);
|
|
143
|
-
}
|
|
144
|
-
any() {
|
|
145
|
-
return this.getCount().then((count) => count > 0);
|
|
146
|
-
}
|
|
147
|
-
getCount() {
|
|
148
|
-
return SyncResult.value(this.count);
|
|
149
|
-
}
|
|
150
|
-
equals(right, equalFunctions) {
|
|
151
|
-
return List.equals(this, right, equalFunctions);
|
|
152
|
-
}
|
|
153
|
-
toString(toStringFunctions) {
|
|
154
|
-
return List.toString(this, toStringFunctions);
|
|
155
|
-
}
|
|
156
|
-
concatenate(...toConcatenate) {
|
|
157
|
-
return List.concatenate(this, ...toConcatenate);
|
|
158
|
-
}
|
|
159
|
-
map(mapping) {
|
|
160
|
-
return List.map(this, mapping);
|
|
161
|
-
}
|
|
162
|
-
flatMap(mapping) {
|
|
163
|
-
return List.flatMap(this, mapping);
|
|
164
|
-
}
|
|
165
|
-
where(condition) {
|
|
166
|
-
return List.where(this, condition);
|
|
167
|
-
}
|
|
168
|
-
instanceOf(typeOrTypeCheck) {
|
|
169
|
-
return List.instanceOf(this, typeOrTypeCheck);
|
|
170
|
-
}
|
|
171
|
-
first(condition) {
|
|
172
|
-
return List.first(this, condition);
|
|
173
|
-
}
|
|
174
|
-
last(condition) {
|
|
175
|
-
return List.last(this, condition);
|
|
176
|
-
}
|
|
177
|
-
contains(value, equalFunctions) {
|
|
178
|
-
return List.contains(this, value, equalFunctions);
|
|
179
|
-
}
|
|
180
|
-
[Symbol.iterator]() {
|
|
181
|
-
return List[Symbol.iterator](this);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// sources/byteListStream.ts
|
|
186
|
-
var ByteListStream = class _ByteListStream {
|
|
187
|
-
list;
|
|
188
|
-
constructor() {
|
|
189
|
-
this.list = ByteList.create();
|
|
190
|
-
}
|
|
191
|
-
static create(initialValues) {
|
|
192
|
-
const result = new _ByteListStream();
|
|
193
|
-
if (initialValues) {
|
|
194
|
-
result.writeBytes(initialValues).await();
|
|
195
|
-
}
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get the number of bytes that are available to be read.
|
|
200
|
-
*/
|
|
201
|
-
getAvailableByteCount() {
|
|
202
|
-
return this.list.getCount().await();
|
|
203
|
-
}
|
|
204
|
-
writeBytes(bytes, startIndex, length) {
|
|
205
|
-
PreCondition.assertNotUndefinedAndNotNull(bytes, "bytes");
|
|
206
|
-
if (isArray(bytes)) {
|
|
207
|
-
bytes = new Uint8Array(bytes);
|
|
208
|
-
}
|
|
209
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
210
|
-
startIndex = 0;
|
|
211
|
-
}
|
|
212
|
-
if (isUndefinedOrNull(length)) {
|
|
213
|
-
length = bytes.length - startIndex;
|
|
214
|
-
}
|
|
215
|
-
PreCondition.assertInsertIndex(startIndex, bytes.length, "startIndex");
|
|
216
|
-
PreCondition.assertBetween(0, length, bytes.length - startIndex, "length");
|
|
217
|
-
this.list.addAll(bytes.subarray(startIndex, length + startIndex));
|
|
218
|
-
return SyncResult.value(length);
|
|
219
|
-
}
|
|
220
|
-
readBytes(countOrOutput, startIndex, count) {
|
|
221
|
-
let result;
|
|
222
|
-
if (isNumber(countOrOutput)) {
|
|
223
|
-
PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
|
|
224
|
-
if (!this.list.any().await()) {
|
|
225
|
-
result = SyncResult.error(new EmptyError());
|
|
226
|
-
} else {
|
|
227
|
-
const bytesReadCount = Math.min(countOrOutput, this.list.getCount().await());
|
|
228
|
-
const output = new Uint8Array(bytesReadCount);
|
|
229
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
230
|
-
output[i] = this.list.removeFirst().await();
|
|
231
|
-
}
|
|
232
|
-
result = SyncResult.value(output);
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
|
|
236
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
237
|
-
startIndex = 0;
|
|
238
|
-
}
|
|
239
|
-
if (isUndefinedOrNull(count)) {
|
|
240
|
-
count = countOrOutput.length - startIndex;
|
|
241
|
-
}
|
|
242
|
-
PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
|
|
243
|
-
PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
|
|
244
|
-
if (!this.list.any().await()) {
|
|
245
|
-
result = SyncResult.error(new EmptyError());
|
|
246
|
-
} else {
|
|
247
|
-
const bytesReadCount = Math.min(count, this.list.getCount().await());
|
|
248
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
249
|
-
countOrOutput[startIndex + i] = this.list.removeFirst().await();
|
|
250
|
-
}
|
|
251
|
-
result = SyncResult.value(bytesReadCount);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return result;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// sources/stringIterator.ts
|
|
259
|
-
var StringIterator = class _StringIterator {
|
|
260
|
-
value;
|
|
261
|
-
currentIndex;
|
|
262
|
-
started;
|
|
263
|
-
constructor(value) {
|
|
264
|
-
this.value = value;
|
|
265
|
-
this.currentIndex = 0;
|
|
266
|
-
this.started = false;
|
|
267
|
-
}
|
|
268
|
-
static create(value) {
|
|
269
|
-
PreCondition.assertNotUndefinedAndNotNull(value, "value");
|
|
270
|
-
return new _StringIterator(value);
|
|
271
|
-
}
|
|
272
|
-
getCurrentIndex() {
|
|
273
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
274
|
-
return this.currentIndex;
|
|
275
|
-
}
|
|
276
|
-
next() {
|
|
277
|
-
return SyncResult.create(() => {
|
|
278
|
-
if (!this.hasStarted()) {
|
|
279
|
-
this.started = true;
|
|
280
|
-
} else if (this.hasCurrent()) {
|
|
281
|
-
this.currentIndex++;
|
|
282
|
-
}
|
|
283
|
-
return this.hasCurrent();
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
hasStarted() {
|
|
287
|
-
return this.started;
|
|
288
|
-
}
|
|
289
|
-
hasCurrent() {
|
|
290
|
-
return this.hasStarted() && this.currentIndex < this.value.length;
|
|
291
|
-
}
|
|
292
|
-
getCurrent() {
|
|
293
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
294
|
-
return this.value[this.currentIndex];
|
|
295
|
-
}
|
|
296
|
-
start() {
|
|
297
|
-
return Iterator.start(this);
|
|
298
|
-
}
|
|
299
|
-
takeCurrent() {
|
|
300
|
-
return Iterator.takeCurrent(this);
|
|
301
|
-
}
|
|
302
|
-
any() {
|
|
303
|
-
return Iterator.any(this);
|
|
304
|
-
}
|
|
305
|
-
getCount() {
|
|
306
|
-
return Iterator.getCount(this);
|
|
307
|
-
}
|
|
308
|
-
toArray() {
|
|
309
|
-
return Iterator.toArray(this);
|
|
310
|
-
}
|
|
311
|
-
concatenate(...toConcatenate) {
|
|
312
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
313
|
-
}
|
|
314
|
-
map(mapping) {
|
|
315
|
-
return Iterator.map(this, mapping);
|
|
316
|
-
}
|
|
317
|
-
flatMap(mapping) {
|
|
318
|
-
return Iterator.flatMap(this, mapping);
|
|
319
|
-
}
|
|
320
|
-
first() {
|
|
321
|
-
return Iterator.first(this);
|
|
322
|
-
}
|
|
323
|
-
last() {
|
|
324
|
-
return Iterator.last(this);
|
|
325
|
-
}
|
|
326
|
-
where(condition) {
|
|
327
|
-
return Iterator.where(this, condition);
|
|
328
|
-
}
|
|
329
|
-
whereInstanceOf(typeCheck) {
|
|
330
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
331
|
-
}
|
|
332
|
-
whereInstanceOfType(type) {
|
|
333
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
334
|
-
}
|
|
335
|
-
take(maximumToTake) {
|
|
336
|
-
return Iterator.take(this, maximumToTake);
|
|
337
|
-
}
|
|
338
|
-
skip(maximumToSkip) {
|
|
339
|
-
return Iterator.skip(this, maximumToSkip);
|
|
340
|
-
}
|
|
341
|
-
[Symbol.iterator]() {
|
|
342
|
-
return Iterator[Symbol.iterator](this);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
// sources/characterList.ts
|
|
347
|
-
var CharacterList = class _CharacterList {
|
|
348
|
-
characters;
|
|
349
|
-
constructor(values) {
|
|
350
|
-
if (isString(values)) {
|
|
351
|
-
this.characters = values;
|
|
352
|
-
} else if (values) {
|
|
353
|
-
this.characters = join("", values);
|
|
354
|
-
} else {
|
|
355
|
-
this.characters = "";
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
static create(values) {
|
|
359
|
-
return new _CharacterList(values);
|
|
360
|
-
}
|
|
361
|
-
getCount() {
|
|
362
|
-
return SyncResult.value(this.characters.length);
|
|
363
|
-
}
|
|
364
|
-
insert(index, value) {
|
|
365
|
-
PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
|
|
366
|
-
PreCondition.assertCharacter(value, "value");
|
|
367
|
-
if (index === 0) {
|
|
368
|
-
this.characters = value + this.characters;
|
|
369
|
-
} else if (index === this.getCount().await()) {
|
|
370
|
-
this.characters += value;
|
|
371
|
-
} else {
|
|
372
|
-
this.characters = this.characters.slice(0, index) + value + this.characters.slice(index);
|
|
373
|
-
}
|
|
374
|
-
return this;
|
|
375
|
-
}
|
|
376
|
-
removeAt(index) {
|
|
377
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
378
|
-
const result = this.get(index).await();
|
|
379
|
-
this.characters = (index === 0 ? "" : this.characters.slice(0, index)) + (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
|
|
380
|
-
return SyncResult.value(result);
|
|
381
|
-
}
|
|
382
|
-
set(index, value) {
|
|
383
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
384
|
-
PreCondition.assertCharacter(value, "value");
|
|
385
|
-
this.characters = (index === 0 ? "" : this.characters.slice(0, index)) + value + (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
|
|
386
|
-
return this;
|
|
387
|
-
}
|
|
388
|
-
iterate() {
|
|
389
|
-
return StringIterator.create(this.characters);
|
|
390
|
-
}
|
|
391
|
-
get(index) {
|
|
392
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
393
|
-
return SyncResult.value(this.characters.charAt(index));
|
|
394
|
-
}
|
|
395
|
-
add(value) {
|
|
396
|
-
return List.add(this, value);
|
|
397
|
-
}
|
|
398
|
-
addAll(values) {
|
|
399
|
-
return List.addAll(this, values);
|
|
400
|
-
}
|
|
401
|
-
insertAll(index, values) {
|
|
402
|
-
return List.insertAll(this, index, values);
|
|
403
|
-
}
|
|
404
|
-
remove(value, equalFunctions) {
|
|
405
|
-
return List.remove(this, value, equalFunctions);
|
|
406
|
-
}
|
|
407
|
-
removeFirst() {
|
|
408
|
-
return List.removeFirst(this);
|
|
409
|
-
}
|
|
410
|
-
removeLast() {
|
|
411
|
-
return List.removeLast(this);
|
|
412
|
-
}
|
|
413
|
-
toArray() {
|
|
414
|
-
return List.toArray(this);
|
|
415
|
-
}
|
|
416
|
-
any() {
|
|
417
|
-
return List.any(this);
|
|
418
|
-
}
|
|
419
|
-
equals(right, equalFunctions) {
|
|
420
|
-
return List.equals(this, right, equalFunctions);
|
|
421
|
-
}
|
|
422
|
-
toString(toStringFunctions) {
|
|
423
|
-
return List.toString(this, toStringFunctions);
|
|
424
|
-
}
|
|
425
|
-
concatenate(...toConcatenate) {
|
|
426
|
-
return List.concatenate(this, ...toConcatenate);
|
|
427
|
-
}
|
|
428
|
-
map(mapping) {
|
|
429
|
-
return List.map(this, mapping);
|
|
430
|
-
}
|
|
431
|
-
flatMap(mapping) {
|
|
432
|
-
return List.flatMap(this, mapping);
|
|
433
|
-
}
|
|
434
|
-
where(condition) {
|
|
435
|
-
return List.where(this, condition);
|
|
436
|
-
}
|
|
437
|
-
instanceOf(typeOrTypeCheck) {
|
|
438
|
-
return List.instanceOf(this, typeOrTypeCheck);
|
|
439
|
-
}
|
|
440
|
-
first(condition) {
|
|
441
|
-
return List.first(this, condition);
|
|
442
|
-
}
|
|
443
|
-
last(condition) {
|
|
444
|
-
return List.last(this, condition);
|
|
445
|
-
}
|
|
446
|
-
contains(value, equalFunctions) {
|
|
447
|
-
return List.contains(this, value, equalFunctions);
|
|
448
|
-
}
|
|
449
|
-
[Symbol.iterator]() {
|
|
450
|
-
return List[Symbol.iterator](this);
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// sources/characterReadStream.ts
|
|
455
|
-
var CharacterReadStream = class _CharacterReadStream {
|
|
456
|
-
readCharacters(count) {
|
|
457
|
-
return _CharacterReadStream.readCharacters(this, count);
|
|
458
|
-
}
|
|
459
|
-
static readCharacters(readStream, count) {
|
|
460
|
-
let characters = "";
|
|
461
|
-
function readUntilCount(countRemaining) {
|
|
462
|
-
return readStream.readCharacter().then((character) => {
|
|
463
|
-
characters += character;
|
|
464
|
-
return countRemaining === 0 ? SyncResult.value(characters) : readUntilCount(countRemaining - 1);
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
return readUntilCount(count);
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Read characters from this stream until the provided {@link searchString} is found or the end
|
|
471
|
-
* of the stream is reached. The {@link searchString} will be included in the returned string if
|
|
472
|
-
* it is found..
|
|
473
|
-
* @param searchString The string to search for.
|
|
474
|
-
*/
|
|
475
|
-
readUntil(searchString) {
|
|
476
|
-
return _CharacterReadStream.readUntil(this, searchString);
|
|
477
|
-
}
|
|
478
|
-
static readUntil(readStream, searchString) {
|
|
479
|
-
PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
|
|
480
|
-
PreCondition.assertNotEmpty(searchString, "searchString");
|
|
481
|
-
let characters = "";
|
|
482
|
-
function readUntilSearchString() {
|
|
483
|
-
return readStream.readCharacter().then((character) => {
|
|
484
|
-
characters += character;
|
|
485
|
-
return characters.endsWith(searchString) ? SyncResult.value(characters) : readUntilSearchString();
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
return readUntilSearchString();
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Read a sequence of characters from this stream until either a newline character ('\\n') or
|
|
492
|
-
* the end of the stream is reached. Terminating newline characters will be included in the
|
|
493
|
-
* returned string.
|
|
494
|
-
*/
|
|
495
|
-
readLine() {
|
|
496
|
-
return _CharacterReadStream.readLine(this);
|
|
497
|
-
}
|
|
498
|
-
static readLine(readStream) {
|
|
499
|
-
PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
|
|
500
|
-
return readStream.readUntil("\n");
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
// sources/characterListStream.ts
|
|
505
|
-
var CharacterListStream = class _CharacterListStream {
|
|
506
|
-
list;
|
|
507
|
-
constructor() {
|
|
508
|
-
this.list = CharacterList.create();
|
|
509
|
-
}
|
|
510
|
-
static create(initialValues) {
|
|
511
|
-
const result = new _CharacterListStream();
|
|
512
|
-
if (initialValues) {
|
|
513
|
-
result.writeCharacters(initialValues).await();
|
|
514
|
-
}
|
|
515
|
-
return result;
|
|
516
|
-
}
|
|
517
|
-
writeCharacters(characters, startIndex, length) {
|
|
518
|
-
PreCondition.assertNotUndefinedAndNotNull(characters, "characters");
|
|
519
|
-
const characterString = isString(characters) ? characters : join("", characters);
|
|
520
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
521
|
-
startIndex = 0;
|
|
522
|
-
}
|
|
523
|
-
if (isUndefinedOrNull(length)) {
|
|
524
|
-
length = characterString.length - startIndex;
|
|
525
|
-
}
|
|
526
|
-
PreCondition.assertInsertIndex(startIndex, characterString.length, "startIndex");
|
|
527
|
-
PreCondition.assertBetween(0, length, characterString.length - startIndex, "length");
|
|
528
|
-
this.list.addAll(characterString.slice(startIndex, length + startIndex));
|
|
529
|
-
return SyncResult.value(length);
|
|
530
|
-
}
|
|
531
|
-
writeString(text) {
|
|
532
|
-
this.list.addAll(text);
|
|
533
|
-
return SyncResult.value(text.length);
|
|
534
|
-
}
|
|
535
|
-
writeLine(text) {
|
|
536
|
-
return CharacterWriteStream.writeLine(this, text);
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Get the number of characters that are available to be read.
|
|
540
|
-
*/
|
|
541
|
-
getAvailableCharacterCount() {
|
|
542
|
-
return this.list.getCount().await();
|
|
543
|
-
}
|
|
544
|
-
readCharacter() {
|
|
545
|
-
return !this.list.any().await() ? SyncResult.error(new EmptyError()) : SyncResult.value(this.list.removeFirst().await());
|
|
546
|
-
}
|
|
547
|
-
readCharacters(countOrOutput, startIndex, count) {
|
|
548
|
-
let result;
|
|
549
|
-
if (isNumber(countOrOutput)) {
|
|
550
|
-
PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
|
|
551
|
-
if (!this.list.any().await()) {
|
|
552
|
-
result = SyncResult.error(new EmptyError());
|
|
553
|
-
} else {
|
|
554
|
-
const bytesReadCount = Math.min(countOrOutput, this.list.getCount().await());
|
|
555
|
-
let output = "";
|
|
556
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
557
|
-
output += this.list.removeFirst().await();
|
|
558
|
-
}
|
|
559
|
-
result = SyncResult.value(output);
|
|
560
|
-
}
|
|
561
|
-
} else {
|
|
562
|
-
PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
|
|
563
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
564
|
-
startIndex = 0;
|
|
565
|
-
}
|
|
566
|
-
if (isUndefinedOrNull(count)) {
|
|
567
|
-
count = countOrOutput.length - startIndex;
|
|
568
|
-
}
|
|
569
|
-
PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
|
|
570
|
-
PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
|
|
571
|
-
if (!this.list.any().await()) {
|
|
572
|
-
result = SyncResult.error(new EmptyError());
|
|
573
|
-
} else {
|
|
574
|
-
const bytesReadCount = Math.min(count, this.list.getCount().await());
|
|
575
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
576
|
-
countOrOutput[startIndex + i] = this.list.removeFirst().await();
|
|
577
|
-
}
|
|
578
|
-
result = SyncResult.value(bytesReadCount);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return result;
|
|
582
|
-
}
|
|
583
|
-
readUntil(searchString) {
|
|
584
|
-
return CharacterReadStream.readUntil(this, searchString);
|
|
585
|
-
}
|
|
586
|
-
readLine() {
|
|
587
|
-
return CharacterReadStream.readLine(this);
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
// sources/luxonDateTime.ts
|
|
592
|
-
import * as luxon from "luxon";
|
|
593
|
-
|
|
594
|
-
// sources/dateTime.ts
|
|
595
|
-
var DateTime = class _DateTime {
|
|
596
|
-
static parse(text) {
|
|
597
|
-
return LuxonDateTime.parse(text);
|
|
598
|
-
}
|
|
599
|
-
static now() {
|
|
600
|
-
return LuxonDateTime.now();
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Compare this {@link DateTime} to the provided {@link DateTime}. If this {@link DateTime} is
|
|
604
|
-
* less than the provided {@link DateTime}, then a negative number will be returned, 0 if
|
|
605
|
-
* they're equal, or a positive number if this {@link DateTime} is greater than the provided
|
|
606
|
-
* {@link DateTime}.
|
|
607
|
-
* @param dateTime The {@link DateTime} to compare to this {@link DateTime}.
|
|
608
|
-
*/
|
|
609
|
-
compareTo(dateTime, compareTimes) {
|
|
610
|
-
return _DateTime.compareTo(this, dateTime, compareTimes);
|
|
611
|
-
}
|
|
612
|
-
static compareTo(left, right, compareTimes) {
|
|
613
|
-
let result = left.getYear() - right.getYear();
|
|
614
|
-
if (result === 0) {
|
|
615
|
-
result = left.getMonth() - right.getMonth();
|
|
616
|
-
if (result === 0) {
|
|
617
|
-
result = left.getDay() - right.getDay();
|
|
618
|
-
if (compareTimes && result === 0) {
|
|
619
|
-
result = left.getHour() - right.getHour();
|
|
620
|
-
if (result === 0) {
|
|
621
|
-
result = left.getMinute() - right.getMinute();
|
|
622
|
-
if (result === 0) {
|
|
623
|
-
result = left.getSecond();
|
|
624
|
-
-right.getSecond();
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return result;
|
|
631
|
-
}
|
|
632
|
-
lessThan(dateTime, compareTimes) {
|
|
633
|
-
return _DateTime.lessThan(this, dateTime, compareTimes);
|
|
634
|
-
}
|
|
635
|
-
static lessThan(left, right, compareTimes) {
|
|
636
|
-
return left.compareTo(right, compareTimes) < 0;
|
|
637
|
-
}
|
|
638
|
-
lessThanOrEqualTo(dateTime, compareTimes) {
|
|
639
|
-
return _DateTime.lessThanOrEqualTo(this, dateTime, compareTimes);
|
|
640
|
-
}
|
|
641
|
-
static lessThanOrEqualTo(left, right, compareTimes) {
|
|
642
|
-
return left.compareTo(right, compareTimes) <= 0;
|
|
643
|
-
}
|
|
644
|
-
equals(dateTime, compareTimes) {
|
|
645
|
-
return _DateTime.equals(this, dateTime, compareTimes);
|
|
646
|
-
}
|
|
647
|
-
static equals(left, right, compareTimes) {
|
|
648
|
-
return left.compareTo(right, compareTimes) === 0;
|
|
649
|
-
}
|
|
650
|
-
greaterThanOrEqualTo(dateTime, compareTimes) {
|
|
651
|
-
return _DateTime.greaterThanOrEqualTo(this, dateTime, compareTimes);
|
|
652
|
-
}
|
|
653
|
-
static greaterThanOrEqualTo(left, right, compareTimes) {
|
|
654
|
-
return left.compareTo(right, compareTimes) >= 0;
|
|
655
|
-
}
|
|
656
|
-
greaterThan(dateTime, compareTimes) {
|
|
657
|
-
return _DateTime.greaterThan(this, dateTime, compareTimes);
|
|
658
|
-
}
|
|
659
|
-
static greaterThan(left, right, compareTimes) {
|
|
660
|
-
return left.compareTo(right, compareTimes) > 0;
|
|
661
|
-
}
|
|
662
|
-
get debug() {
|
|
663
|
-
return _DateTime.debug(this);
|
|
664
|
-
}
|
|
665
|
-
static debug(dateTime) {
|
|
666
|
-
return dateTime.toString();
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
// sources/luxonDateTime.ts
|
|
671
|
-
var pctTimeZone = "America/Los_Angeles";
|
|
672
|
-
var LuxonDateTime = class _LuxonDateTime {
|
|
673
|
-
dateTime;
|
|
674
|
-
constructor(dateTime) {
|
|
675
|
-
this.dateTime = dateTime;
|
|
676
|
-
}
|
|
677
|
-
static create(dateTime) {
|
|
678
|
-
return new _LuxonDateTime(dateTime);
|
|
679
|
-
}
|
|
680
|
-
static parse(text) {
|
|
681
|
-
return _LuxonDateTime.create(luxon.DateTime.fromISO(text, { zone: pctTimeZone }));
|
|
682
|
-
}
|
|
683
|
-
static now() {
|
|
684
|
-
return _LuxonDateTime.create(luxon.DateTime.now().setZone(pctTimeZone));
|
|
685
|
-
}
|
|
686
|
-
getYear() {
|
|
687
|
-
return this.dateTime.year;
|
|
688
|
-
}
|
|
689
|
-
getMonth() {
|
|
690
|
-
return this.dateTime.month;
|
|
691
|
-
}
|
|
692
|
-
getDay() {
|
|
693
|
-
return this.dateTime.day;
|
|
694
|
-
}
|
|
695
|
-
getHour() {
|
|
696
|
-
return this.dateTime.hour;
|
|
697
|
-
}
|
|
698
|
-
getMinute() {
|
|
699
|
-
return this.dateTime.minute;
|
|
700
|
-
}
|
|
701
|
-
getSecond() {
|
|
702
|
-
return this.dateTime.second;
|
|
703
|
-
}
|
|
704
|
-
addDays(days) {
|
|
705
|
-
return _LuxonDateTime.create(this.dateTime.plus({ days }));
|
|
706
|
-
}
|
|
707
|
-
toString() {
|
|
708
|
-
return this.dateTime.toISO();
|
|
709
|
-
}
|
|
710
|
-
toDateString() {
|
|
711
|
-
return this.dateTime.toISODate();
|
|
712
|
-
}
|
|
713
|
-
compareTo(dateTime, compareTimes) {
|
|
714
|
-
return DateTime.compareTo(this, dateTime, compareTimes);
|
|
715
|
-
}
|
|
716
|
-
lessThan(dateTime, compareTimes) {
|
|
717
|
-
return DateTime.lessThan(this, dateTime, compareTimes);
|
|
718
|
-
}
|
|
719
|
-
lessThanOrEqualTo(dateTime, compareTimes) {
|
|
720
|
-
return DateTime.lessThanOrEqualTo(this, dateTime, compareTimes);
|
|
721
|
-
}
|
|
722
|
-
equals(dateTime, compareTimes) {
|
|
723
|
-
return DateTime.equals(this, dateTime, compareTimes);
|
|
724
|
-
}
|
|
725
|
-
greaterThanOrEqualTo(dateTime, compareTimes) {
|
|
726
|
-
return DateTime.greaterThanOrEqualTo(this, dateTime, compareTimes);
|
|
727
|
-
}
|
|
728
|
-
greaterThan(dateTime, compareTimes) {
|
|
729
|
-
return DateTime.greaterThan(this, dateTime, compareTimes);
|
|
730
|
-
}
|
|
731
|
-
get debug() {
|
|
732
|
-
return DateTime.debug(this);
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// sources/listStack.ts
|
|
737
|
-
var ListStack = class _ListStack {
|
|
738
|
-
list;
|
|
739
|
-
constructor(list) {
|
|
740
|
-
this.list = list ?? List.create();
|
|
741
|
-
}
|
|
742
|
-
static create(list) {
|
|
743
|
-
return new _ListStack(list);
|
|
744
|
-
}
|
|
745
|
-
any() {
|
|
746
|
-
return this.list.any();
|
|
747
|
-
}
|
|
748
|
-
add(value) {
|
|
749
|
-
return SyncResult.create(() => {
|
|
750
|
-
this.list.add(value);
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
addAll(values) {
|
|
754
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
755
|
-
return SyncResult.create(() => {
|
|
756
|
-
this.list.addAll(values);
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
remove() {
|
|
760
|
-
return SyncResult.create(() => {
|
|
761
|
-
if (!this.any().await()) {
|
|
762
|
-
throw new EmptyError();
|
|
763
|
-
}
|
|
764
|
-
return this.list.removeLast().await();
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
contains(value, equalFunctions) {
|
|
768
|
-
return this.list.contains(value, equalFunctions);
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
// sources/stack.ts
|
|
773
|
-
var Stack = class {
|
|
774
|
-
/**
|
|
775
|
-
* Create an instance of the default {@link Stack} implementation.
|
|
776
|
-
* @returns A new {@link Stack} object.
|
|
777
|
-
*/
|
|
778
|
-
static create() {
|
|
779
|
-
return ListStack.create();
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
// sources/depthFirstSearch.ts
|
|
784
|
-
var SearchBreakError = class extends Error {
|
|
785
|
-
};
|
|
786
|
-
var DepthFirstSearch = class _DepthFirstSearch {
|
|
787
|
-
searchAction;
|
|
788
|
-
toVisit;
|
|
789
|
-
visited;
|
|
790
|
-
results;
|
|
791
|
-
started;
|
|
792
|
-
done;
|
|
793
|
-
constructor(initialToVisit, searchAction) {
|
|
794
|
-
PreCondition.assertNotEmpty(initialToVisit, "initialToVisit");
|
|
795
|
-
PreCondition.assertNotUndefinedAndNotNull(searchAction, "searchAction");
|
|
796
|
-
this.searchAction = searchAction;
|
|
797
|
-
this.toVisit = Stack.create();
|
|
798
|
-
this.toVisit.addAll(initialToVisit).await();
|
|
799
|
-
this.visited = Set.create();
|
|
800
|
-
this.results = List.create();
|
|
801
|
-
this.started = false;
|
|
802
|
-
this.done = false;
|
|
803
|
-
}
|
|
804
|
-
static create(initialToVisit, searchAction) {
|
|
805
|
-
return new _DepthFirstSearch(initialToVisit, searchAction);
|
|
806
|
-
}
|
|
807
|
-
addToVisit(toVisit) {
|
|
808
|
-
if (!this.hasVisited(toVisit)) {
|
|
809
|
-
this.toVisit.add(toVisit);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
addAllToVisit(values) {
|
|
813
|
-
for (const value of values) {
|
|
814
|
-
this.addToVisit(value);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
hasVisited(toVisit) {
|
|
818
|
-
return this.visited.contains(toVisit).await();
|
|
819
|
-
}
|
|
820
|
-
addResult(result) {
|
|
821
|
-
this.results.add(result);
|
|
822
|
-
}
|
|
823
|
-
addResults(results) {
|
|
824
|
-
this.results.addAll(results);
|
|
825
|
-
}
|
|
826
|
-
break() {
|
|
827
|
-
throw new SearchBreakError();
|
|
828
|
-
}
|
|
829
|
-
next() {
|
|
830
|
-
return SyncResult.create(() => {
|
|
831
|
-
let result = false;
|
|
832
|
-
if (!this.done) {
|
|
833
|
-
if (!this.started) {
|
|
834
|
-
this.started = true;
|
|
835
|
-
} else {
|
|
836
|
-
this.results.removeFirst().await();
|
|
837
|
-
}
|
|
838
|
-
while (!this.hasCurrent() && this.toVisit.any().await()) {
|
|
839
|
-
const current = this.toVisit.remove().await();
|
|
840
|
-
this.visited.add(current);
|
|
841
|
-
this.searchAction(this, current);
|
|
842
|
-
}
|
|
843
|
-
result = this.hasCurrent();
|
|
844
|
-
this.done = !result;
|
|
845
|
-
}
|
|
846
|
-
return result;
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
hasStarted() {
|
|
850
|
-
return this.started;
|
|
851
|
-
}
|
|
852
|
-
hasCurrent() {
|
|
853
|
-
return this.results.any().await();
|
|
854
|
-
}
|
|
855
|
-
getCurrent() {
|
|
856
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
857
|
-
return this.results.first().await();
|
|
858
|
-
}
|
|
859
|
-
start() {
|
|
860
|
-
return Iterator.start(this);
|
|
861
|
-
}
|
|
862
|
-
takeCurrent() {
|
|
863
|
-
return Iterator.takeCurrent(this);
|
|
864
|
-
}
|
|
865
|
-
any() {
|
|
866
|
-
return Iterator.any(this);
|
|
867
|
-
}
|
|
868
|
-
getCount() {
|
|
869
|
-
return Iterator.getCount(this);
|
|
870
|
-
}
|
|
871
|
-
toArray() {
|
|
872
|
-
return Iterator.toArray(this);
|
|
873
|
-
}
|
|
874
|
-
concatenate(...toConcatenate) {
|
|
875
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
876
|
-
}
|
|
877
|
-
where(condition) {
|
|
878
|
-
return Iterator.where(this, condition);
|
|
879
|
-
}
|
|
880
|
-
map(mapping) {
|
|
881
|
-
return Iterator.map(this, mapping);
|
|
882
|
-
}
|
|
883
|
-
flatMap(mapping) {
|
|
884
|
-
return Iterator.flatMap(this, mapping);
|
|
885
|
-
}
|
|
886
|
-
whereInstanceOf(typeCheck) {
|
|
887
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
888
|
-
}
|
|
889
|
-
whereInstanceOfType(type) {
|
|
890
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
891
|
-
}
|
|
892
|
-
first(condition) {
|
|
893
|
-
return Iterator.first(this, condition);
|
|
894
|
-
}
|
|
895
|
-
last(condition) {
|
|
896
|
-
return Iterator.last(this, condition);
|
|
897
|
-
}
|
|
898
|
-
take(maximumToTake) {
|
|
899
|
-
return Iterator.take(this, maximumToTake);
|
|
900
|
-
}
|
|
901
|
-
skip(maximumToSkip) {
|
|
902
|
-
return Iterator.skip(this, maximumToSkip);
|
|
903
|
-
}
|
|
904
|
-
[Symbol.iterator]() {
|
|
905
|
-
return Iterator[Symbol.iterator](this);
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
function depthFirstSearch(parametersOrInitialToVisit, searchAction) {
|
|
909
|
-
let initialToVisit;
|
|
910
|
-
if (isJavascriptIterable(parametersOrInitialToVisit)) {
|
|
911
|
-
initialToVisit = parametersOrInitialToVisit;
|
|
912
|
-
searchAction = searchAction;
|
|
913
|
-
} else {
|
|
914
|
-
PreCondition.assertNotUndefinedAndNotNull(parametersOrInitialToVisit, "parameters");
|
|
915
|
-
initialToVisit = parametersOrInitialToVisit.initialToVisit;
|
|
916
|
-
searchAction = parametersOrInitialToVisit.searchAction;
|
|
917
|
-
}
|
|
918
|
-
PreCondition.assertNotUndefinedAndNotNull(initialToVisit, "initialToVisit");
|
|
919
|
-
PreCondition.assertNotUndefinedAndNotNull(searchAction, "searchAction");
|
|
920
|
-
return DepthFirstSearch.create(initialToVisit, searchAction);
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
// sources/disposable.ts
|
|
924
|
-
var Disposable = class {
|
|
925
|
-
/**
|
|
926
|
-
* Create a new {@link Disposable} that will invoke the provided {@link Function} when it is
|
|
927
|
-
* disposed.
|
|
928
|
-
* @param disposedFunction The function to invoke when the returned {@link Disposable} is
|
|
929
|
-
* disposed.
|
|
930
|
-
*/
|
|
931
|
-
static create(disposedFunction) {
|
|
932
|
-
return SyncDisposable.create(disposedFunction);
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
// sources/generator.ts
|
|
937
|
-
var InnerGeneratorControl = class _InnerGeneratorControl {
|
|
938
|
-
returnValues;
|
|
939
|
-
done;
|
|
940
|
-
constructor() {
|
|
941
|
-
this.returnValues = List.create();
|
|
942
|
-
this.done = false;
|
|
943
|
-
}
|
|
944
|
-
static create() {
|
|
945
|
-
return new _InnerGeneratorControl();
|
|
946
|
-
}
|
|
947
|
-
addValue(returnValue) {
|
|
948
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
949
|
-
this.returnValues.add(returnValue);
|
|
950
|
-
}
|
|
951
|
-
addValues(returnValues) {
|
|
952
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
953
|
-
this.returnValues.addAll(returnValues);
|
|
954
|
-
}
|
|
955
|
-
hasCurrent() {
|
|
956
|
-
return this.returnValues.any().await();
|
|
957
|
-
}
|
|
958
|
-
getCurrent() {
|
|
959
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
960
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
961
|
-
return this.returnValues.first().await();
|
|
962
|
-
}
|
|
963
|
-
removeCurrent() {
|
|
964
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
965
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
966
|
-
this.returnValues.removeFirst().await();
|
|
967
|
-
}
|
|
968
|
-
setDone() {
|
|
969
|
-
PreCondition.assertFalse(this.hasCurrent(), "this.hasCurrent()");
|
|
970
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
971
|
-
this.done = true;
|
|
972
|
-
}
|
|
973
|
-
isDone() {
|
|
974
|
-
return this.done;
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
var Generator = class _Generator {
|
|
978
|
-
control;
|
|
979
|
-
generatorAction;
|
|
980
|
-
started;
|
|
981
|
-
constructor(generatorAction) {
|
|
982
|
-
PreCondition.assertNotUndefinedAndNotNull(generatorAction, "generatorAction");
|
|
983
|
-
this.control = InnerGeneratorControl.create();
|
|
984
|
-
this.generatorAction = generatorAction;
|
|
985
|
-
this.started = false;
|
|
986
|
-
}
|
|
987
|
-
static create(generatorAction) {
|
|
988
|
-
return new _Generator(generatorAction);
|
|
989
|
-
}
|
|
990
|
-
next() {
|
|
991
|
-
return SyncResult.create(() => {
|
|
992
|
-
if (!this.control.isDone()) {
|
|
993
|
-
if (!this.hasStarted()) {
|
|
994
|
-
this.started = true;
|
|
995
|
-
} else {
|
|
996
|
-
this.control.removeCurrent();
|
|
997
|
-
}
|
|
998
|
-
if (!this.control.hasCurrent()) {
|
|
999
|
-
const actionResult = this.generatorAction(this.control);
|
|
1000
|
-
if (actionResult !== void 0) {
|
|
1001
|
-
this.control.addValue(actionResult);
|
|
1002
|
-
}
|
|
1003
|
-
if (!this.control.hasCurrent()) {
|
|
1004
|
-
this.control.setDone();
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
return this.hasCurrent();
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
hasStarted() {
|
|
1012
|
-
return this.started;
|
|
1013
|
-
}
|
|
1014
|
-
hasCurrent() {
|
|
1015
|
-
return this.control.hasCurrent();
|
|
1016
|
-
}
|
|
1017
|
-
getCurrent() {
|
|
1018
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
1019
|
-
return this.control.getCurrent();
|
|
1020
|
-
}
|
|
1021
|
-
start() {
|
|
1022
|
-
return Iterator.start(this);
|
|
1023
|
-
}
|
|
1024
|
-
takeCurrent() {
|
|
1025
|
-
return Iterator.takeCurrent(this);
|
|
1026
|
-
}
|
|
1027
|
-
any() {
|
|
1028
|
-
return Iterator.any(this);
|
|
1029
|
-
}
|
|
1030
|
-
getCount() {
|
|
1031
|
-
return Iterator.getCount(this);
|
|
1032
|
-
}
|
|
1033
|
-
toArray() {
|
|
1034
|
-
return Iterator.toArray(this);
|
|
1035
|
-
}
|
|
1036
|
-
concatenate(...toConcatenate) {
|
|
1037
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
1038
|
-
}
|
|
1039
|
-
where(condition) {
|
|
1040
|
-
return Iterator.where(this, condition);
|
|
1041
|
-
}
|
|
1042
|
-
map(mapping) {
|
|
1043
|
-
return Iterator.map(this, mapping);
|
|
1044
|
-
}
|
|
1045
|
-
flatMap(mapping) {
|
|
1046
|
-
return Iterator.flatMap(this, mapping);
|
|
1047
|
-
}
|
|
1048
|
-
whereInstanceOf(typeCheck) {
|
|
1049
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
1050
|
-
}
|
|
1051
|
-
whereInstanceOfType(type) {
|
|
1052
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
1053
|
-
}
|
|
1054
|
-
first(condition) {
|
|
1055
|
-
return Iterator.first(this, condition);
|
|
1056
|
-
}
|
|
1057
|
-
last(condition) {
|
|
1058
|
-
return Iterator.last(this, condition);
|
|
1059
|
-
}
|
|
1060
|
-
take(maximumToTake) {
|
|
1061
|
-
return Iterator.take(this, maximumToTake);
|
|
1062
|
-
}
|
|
1063
|
-
skip(maximumToSkip) {
|
|
1064
|
-
return Iterator.skip(this, maximumToSkip);
|
|
1065
|
-
}
|
|
1066
|
-
[Symbol.iterator]() {
|
|
1067
|
-
return Iterator[Symbol.iterator](this);
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
// sources/httpClient.ts
|
|
1072
|
-
var HttpClient = class _HttpClient {
|
|
1073
|
-
static create() {
|
|
1074
|
-
return FetchHttpClient.create();
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Send a GET {@link HttpOutgoingRequest} to the provided URL.
|
|
1078
|
-
* @param url The URL to send the GET {@link HttpOutgoingRequest} to.
|
|
1079
|
-
*/
|
|
1080
|
-
sendGetRequest(url) {
|
|
1081
|
-
return _HttpClient.sendGetRequest(this, url);
|
|
1082
|
-
}
|
|
1083
|
-
static sendGetRequest(httpClient, url) {
|
|
1084
|
-
return httpClient.sendRequest(HttpOutgoingRequest.create(0 /* GET */, url));
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
|
|
1088
|
-
// sources/inMemoryCharacterWriteStream.ts
|
|
1089
|
-
var InMemoryCharacterWriteStream = class _InMemoryCharacterWriteStream extends CharacterWriteStream {
|
|
1090
|
-
writtenText;
|
|
1091
|
-
newlineSequence;
|
|
1092
|
-
constructor() {
|
|
1093
|
-
super();
|
|
1094
|
-
this.writtenText = "";
|
|
1095
|
-
this.newlineSequence = "\n";
|
|
1096
|
-
}
|
|
1097
|
-
static create() {
|
|
1098
|
-
return new _InMemoryCharacterWriteStream();
|
|
1099
|
-
}
|
|
1100
|
-
getNewlineSequence() {
|
|
1101
|
-
return this.newlineSequence;
|
|
1102
|
-
}
|
|
1103
|
-
setNewlineSequence(newlineSequence) {
|
|
1104
|
-
PreCondition.assertNotUndefinedAndNotNull(newlineSequence, "newlineSequence");
|
|
1105
|
-
this.newlineSequence = newlineSequence;
|
|
1106
|
-
return this;
|
|
1107
|
-
}
|
|
1108
|
-
getWrittenText() {
|
|
1109
|
-
return this.writtenText;
|
|
1110
|
-
}
|
|
1111
|
-
clearWrittenText() {
|
|
1112
|
-
this.writtenText = "";
|
|
1113
|
-
return this;
|
|
1114
|
-
}
|
|
1115
|
-
writeString(text) {
|
|
1116
|
-
return SyncResult.create(() => {
|
|
1117
|
-
if (text) {
|
|
1118
|
-
this.writtenText += text;
|
|
1119
|
-
}
|
|
1120
|
-
return getLength(text);
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
writeLine(text) {
|
|
1124
|
-
return SyncResult.create(() => {
|
|
1125
|
-
let result = 0;
|
|
1126
|
-
if (text) {
|
|
1127
|
-
result += this.writeString(text).await();
|
|
1128
|
-
}
|
|
1129
|
-
if (this.newlineSequence) {
|
|
1130
|
-
result += this.writeString(this.newlineSequence).await();
|
|
1131
|
-
}
|
|
1132
|
-
return result;
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
// sources/listQueue.ts
|
|
1138
|
-
var ListQueue = class _ListQueue {
|
|
1139
|
-
list;
|
|
1140
|
-
constructor(list) {
|
|
1141
|
-
this.list = list ?? List.create();
|
|
1142
|
-
}
|
|
1143
|
-
static create(list) {
|
|
1144
|
-
return new _ListQueue(list);
|
|
1145
|
-
}
|
|
1146
|
-
any() {
|
|
1147
|
-
return this.list.any();
|
|
1148
|
-
}
|
|
1149
|
-
add(value) {
|
|
1150
|
-
return SyncResult.create(() => {
|
|
1151
|
-
this.list.add(value);
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
addAll(values) {
|
|
1155
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
1156
|
-
return SyncResult.create(() => {
|
|
1157
|
-
this.list.addAll(values);
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
remove() {
|
|
1161
|
-
return SyncResult.create(() => {
|
|
1162
|
-
if (!this.any().await()) {
|
|
1163
|
-
throw new EmptyError();
|
|
1164
|
-
}
|
|
1165
|
-
return this.list.removeLast().await();
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
contains(value, equalFunctions) {
|
|
1169
|
-
return this.list.contains(value, equalFunctions);
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
// sources/node.ts
|
|
1174
|
-
var Node = class _Node {
|
|
1175
|
-
value;
|
|
1176
|
-
connectedNodes;
|
|
1177
|
-
constructor(value) {
|
|
1178
|
-
this.value = value;
|
|
1179
|
-
this.connectedNodes = Set.create();
|
|
1180
|
-
}
|
|
1181
|
-
static create(value) {
|
|
1182
|
-
return new _Node(value);
|
|
1183
|
-
}
|
|
1184
|
-
getValue() {
|
|
1185
|
-
return this.value;
|
|
1186
|
-
}
|
|
1187
|
-
iterateConnectedNodes() {
|
|
1188
|
-
return this.connectedNodes.iterate();
|
|
1189
|
-
}
|
|
1190
|
-
addConnectedNode(node) {
|
|
1191
|
-
PreCondition.assertNotUndefinedAndNotNull(node, "node");
|
|
1192
|
-
this.connectedNodes.add(node);
|
|
1193
|
-
}
|
|
1194
|
-
};
|
|
1195
|
-
|
|
1196
|
-
// sources/queue.ts
|
|
1197
|
-
var Queue = class {
|
|
1198
|
-
/**
|
|
1199
|
-
* Create an instance of the default {@link Queue} implementation.
|
|
1200
|
-
* @returns A new {@link Queue} object.
|
|
1201
|
-
*/
|
|
1202
|
-
static create() {
|
|
1203
|
-
return ListQueue.create();
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
|
|
1207
|
-
// sources/recreationDotGovClient.ts
|
|
1208
|
-
var RecreationDotGovDivisionAvailability = class _RecreationDotGovDivisionAvailability {
|
|
1209
|
-
json;
|
|
1210
|
-
minimumGroupSize;
|
|
1211
|
-
maximumGroupSize;
|
|
1212
|
-
dayAvailabilities;
|
|
1213
|
-
constructor(json) {
|
|
1214
|
-
PreCondition.assertNotUndefinedAndNotNull(json, "json");
|
|
1215
|
-
this.json = json;
|
|
1216
|
-
const minGroupSize = "MinGroupSize".toLowerCase();
|
|
1217
|
-
const maxGroupSize = "MaxGroupSize".toLowerCase();
|
|
1218
|
-
for (const rule of json.rules) {
|
|
1219
|
-
switch (rule.name.toLowerCase()) {
|
|
1220
|
-
case minGroupSize:
|
|
1221
|
-
this.minimumGroupSize = rule.value;
|
|
1222
|
-
break;
|
|
1223
|
-
case maxGroupSize:
|
|
1224
|
-
this.maximumGroupSize = rule.value;
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
const dayAvailabilities = List.create();
|
|
1229
|
-
const quotaUsageByMemberDaily = json.quota_type_maps?.QuotaUsageByMemberDaily;
|
|
1230
|
-
if (quotaUsageByMemberDaily) {
|
|
1231
|
-
for (const quotaUsage of Object.entries(quotaUsageByMemberDaily)) {
|
|
1232
|
-
const dateString = quotaUsage[0];
|
|
1233
|
-
const usageData = quotaUsage[1];
|
|
1234
|
-
let walkup = false;
|
|
1235
|
-
let reservationsRemaining = 0;
|
|
1236
|
-
const boolsEntry = json.bools[dateString];
|
|
1237
|
-
if (boolsEntry) {
|
|
1238
|
-
walkup = usageData.show_walkup;
|
|
1239
|
-
reservationsRemaining = usageData.remaining;
|
|
1240
|
-
}
|
|
1241
|
-
dayAvailabilities.add({
|
|
1242
|
-
date: DateTime.parse(dateString),
|
|
1243
|
-
totalSpots: usageData.total,
|
|
1244
|
-
walkup,
|
|
1245
|
-
reservationsRemaining
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
this.dayAvailabilities = dayAvailabilities;
|
|
1250
|
-
}
|
|
1251
|
-
static create(json) {
|
|
1252
|
-
return new _RecreationDotGovDivisionAvailability(json);
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
var RecreationDotGovError = class extends Error {
|
|
1256
|
-
constructor(message) {
|
|
1257
|
-
super(message);
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
var RecreationDotGovClient = class _RecreationDotGovClient {
|
|
1261
|
-
httpClient;
|
|
1262
|
-
constructor(httpClient) {
|
|
1263
|
-
PreCondition.assertNotUndefinedAndNotNull(httpClient, "httpClient");
|
|
1264
|
-
this.httpClient = httpClient;
|
|
1265
|
-
}
|
|
1266
|
-
static create(httpClient) {
|
|
1267
|
-
return new _RecreationDotGovClient(httpClient);
|
|
1268
|
-
}
|
|
1269
|
-
sendRequest(request) {
|
|
1270
|
-
return this.httpClient.sendRequest(request);
|
|
1271
|
-
}
|
|
1272
|
-
sendGetRequest(url) {
|
|
1273
|
-
return HttpClient.sendGetRequest(this, url);
|
|
1274
|
-
}
|
|
1275
|
-
getPermitItinerary(permitItineraryId) {
|
|
1276
|
-
PreCondition.assertNotEmpty(permitItineraryId, "permitItineraryId");
|
|
1277
|
-
return PromiseAsyncResult.create(async () => {
|
|
1278
|
-
const response = await this.sendGetRequest(`https://www.recreation.gov/api/permitcontent/${permitItineraryId}`);
|
|
1279
|
-
const responseBody = await response.getBody();
|
|
1280
|
-
const statusCode = response.getStatusCode();
|
|
1281
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
1282
|
-
const responseBodyJson2 = JSON.parse(responseBody);
|
|
1283
|
-
const errorMessage = responseBodyJson2.error;
|
|
1284
|
-
switch (errorMessage.toLowerCase()) {
|
|
1285
|
-
case "permit not found":
|
|
1286
|
-
throw new RecreationDotGovError(`No permit itinerary found for id: ${JSON.stringify(permitItineraryId)}`);
|
|
1287
|
-
default:
|
|
1288
|
-
throw new RecreationDotGovError(`Unrecognized error: ${JSON.stringify(errorMessage)}`);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
const responseBodyJson = JSON.parse(responseBody);
|
|
1292
|
-
return responseBodyJson.payload;
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
getDivisionAvailability(permitItineraryId, divisionId, month, year, earlyAccessPermitLotteryId) {
|
|
1296
|
-
PreCondition.assertNotEmpty(permitItineraryId, "permitItineraryId");
|
|
1297
|
-
PreCondition.assertNotEmpty(divisionId, "divisionId");
|
|
1298
|
-
PreCondition.assertBetween(1, month, 12, "month");
|
|
1299
|
-
return PromiseAsyncResult.create(async () => {
|
|
1300
|
-
const url = earlyAccessPermitLotteryId ? `https://www.recreation.gov/api/permititinerary/${permitItineraryId}/division/${divisionId}/eapavailability/month/${earlyAccessPermitLotteryId}?month=${month}&year=${year}` : `https://www.recreation.gov/api/permititinerary/${permitItineraryId}/division/${divisionId}/availability/month?month=${month}&year=${year}`;
|
|
1301
|
-
const response = await this.sendGetRequest(url);
|
|
1302
|
-
let responseBody = await response.getBody();
|
|
1303
|
-
const statusCode = response.getStatusCode();
|
|
1304
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
1305
|
-
const responseBodyJson2 = JSON.parse(responseBody);
|
|
1306
|
-
const errorMessage = responseBodyJson2.error;
|
|
1307
|
-
switch (errorMessage.toLowerCase()) {
|
|
1308
|
-
case "invalid permit id":
|
|
1309
|
-
throw new RecreationDotGovError(`No permit itinerary found for id: ${JSON.stringify(permitItineraryId)}`);
|
|
1310
|
-
case "request year is missing or invalid":
|
|
1311
|
-
const emptyResponseBody = {
|
|
1312
|
-
payload: {
|
|
1313
|
-
bools: {},
|
|
1314
|
-
rules: [],
|
|
1315
|
-
quota_type_maps: {}
|
|
1316
|
-
}
|
|
1317
|
-
};
|
|
1318
|
-
responseBody = JSON.stringify(emptyResponseBody);
|
|
1319
|
-
break;
|
|
1320
|
-
default:
|
|
1321
|
-
throw new RecreationDotGovError(`Unrecognized error: ${JSON.stringify(errorMessage)}`);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
const responseBodyJson = JSON.parse(responseBody);
|
|
1325
|
-
return RecreationDotGovDivisionAvailability.create(responseBodyJson.payload);
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
// sources/stringComparer.ts
|
|
1331
|
-
var StringComparer = class _StringComparer extends Comparer {
|
|
1332
|
-
constructor() {
|
|
1333
|
-
super();
|
|
1334
|
-
}
|
|
1335
|
-
static create() {
|
|
1336
|
-
return new _StringComparer();
|
|
1337
|
-
}
|
|
1338
|
-
compare(left, right) {
|
|
1339
|
-
return _StringComparer.compare(left, right);
|
|
1340
|
-
}
|
|
1341
|
-
static compare(left, right) {
|
|
1342
|
-
let result = Comparer.compareSameUndefinedNull(left, right);
|
|
1343
|
-
if (result === void 0) {
|
|
1344
|
-
result = left < right ? 0 /* LessThan */ : 2 /* GreaterThan */;
|
|
1345
|
-
}
|
|
1346
|
-
return result;
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
// sources/wonderlandTrailClient.ts
|
|
1351
|
-
function isWonderlandTrailLocation(value) {
|
|
1352
|
-
return isObject(value) && hasProperty(value, "name") && hasProperty(value, "trailhead") && hasProperty(value, "foodCacheStorage") && hasProperty(value, "divisionId") && hasProperty(value, "groupSiteDivisionId");
|
|
1353
|
-
}
|
|
1354
|
-
var WonderlandTrailLocations = class {
|
|
1355
|
-
static graniteCreek = {
|
|
1356
|
-
name: "Granite Creek",
|
|
1357
|
-
trailhead: false,
|
|
1358
|
-
foodCacheStorage: false,
|
|
1359
|
-
divisionId: "46753170009",
|
|
1360
|
-
groupSiteDivisionId: "46753170010",
|
|
1361
|
-
latitude: 46.92058,
|
|
1362
|
-
longitude: -121.708,
|
|
1363
|
-
elevationFeet: 5851
|
|
1364
|
-
};
|
|
1365
|
-
static sunriseCamp = {
|
|
1366
|
-
name: "Sunrise Camp",
|
|
1367
|
-
trailhead: false,
|
|
1368
|
-
foodCacheStorage: false,
|
|
1369
|
-
divisionId: "46753170058",
|
|
1370
|
-
groupSiteDivisionId: "46753170059",
|
|
1371
|
-
latitude: 46.91129,
|
|
1372
|
-
longitude: -121.66002,
|
|
1373
|
-
elevationFeet: 6258
|
|
1374
|
-
};
|
|
1375
|
-
static sunriseVisitorCenter = {
|
|
1376
|
-
name: "Sunrise Visitor Center",
|
|
1377
|
-
trailhead: true,
|
|
1378
|
-
foodCacheStorage: true,
|
|
1379
|
-
divisionId: "",
|
|
1380
|
-
groupSiteDivisionId: "",
|
|
1381
|
-
latitude: 46.91448,
|
|
1382
|
-
longitude: -121.64337,
|
|
1383
|
-
elevationFeet: 6410
|
|
1384
|
-
};
|
|
1385
|
-
static whiteRiver = {
|
|
1386
|
-
name: "White River",
|
|
1387
|
-
trailhead: true,
|
|
1388
|
-
foodCacheStorage: true,
|
|
1389
|
-
divisionId: "46753170066",
|
|
1390
|
-
groupSiteDivisionId: "46753170067",
|
|
1391
|
-
latitude: 46.90255,
|
|
1392
|
-
longitude: -121.63869,
|
|
1393
|
-
elevationFeet: 4229
|
|
1394
|
-
};
|
|
1395
|
-
static fryingPanCreek = {
|
|
1396
|
-
name: "Fryingpan Creek",
|
|
1397
|
-
trailhead: true,
|
|
1398
|
-
foodCacheStorage: false,
|
|
1399
|
-
divisionId: "",
|
|
1400
|
-
groupSiteDivisionId: "",
|
|
1401
|
-
latitude: 46.88809,
|
|
1402
|
-
longitude: -121.61019,
|
|
1403
|
-
elevationFeet: 3835
|
|
1404
|
-
};
|
|
1405
|
-
static summerland = {
|
|
1406
|
-
name: "Summerland",
|
|
1407
|
-
trailhead: false,
|
|
1408
|
-
foodCacheStorage: false,
|
|
1409
|
-
divisionId: "46753170056",
|
|
1410
|
-
groupSiteDivisionId: "46753170057",
|
|
1411
|
-
latitude: 46.86616,
|
|
1412
|
-
longitude: -121.65843,
|
|
1413
|
-
elevationFeet: 5988
|
|
1414
|
-
};
|
|
1415
|
-
static indianBar = {
|
|
1416
|
-
name: "Indian Bar",
|
|
1417
|
-
trailhead: false,
|
|
1418
|
-
foodCacheStorage: false,
|
|
1419
|
-
divisionId: "46753170046",
|
|
1420
|
-
groupSiteDivisionId: "46753170047",
|
|
1421
|
-
latitude: 46.82593,
|
|
1422
|
-
longitude: -121.63942,
|
|
1423
|
-
elevationFeet: 5101
|
|
1424
|
-
};
|
|
1425
|
-
static nickelCreek = {
|
|
1426
|
-
name: "Nickel Creek",
|
|
1427
|
-
trailhead: false,
|
|
1428
|
-
foodCacheStorage: false,
|
|
1429
|
-
divisionId: "46753170051",
|
|
1430
|
-
groupSiteDivisionId: "46753170052",
|
|
1431
|
-
latitude: 46.77204,
|
|
1432
|
-
longitude: -121.62402,
|
|
1433
|
-
elevationFeet: 3383
|
|
1434
|
-
};
|
|
1435
|
-
static boxCanyon = {
|
|
1436
|
-
name: "Box Canyon",
|
|
1437
|
-
trailhead: true,
|
|
1438
|
-
foodCacheStorage: false,
|
|
1439
|
-
divisionId: "",
|
|
1440
|
-
groupSiteDivisionId: "",
|
|
1441
|
-
latitude: 46.7657,
|
|
1442
|
-
longitude: -121.63517,
|
|
1443
|
-
elevationFeet: 3025
|
|
1444
|
-
};
|
|
1445
|
-
static mapleCreek = {
|
|
1446
|
-
name: "Maple Creek",
|
|
1447
|
-
trailhead: false,
|
|
1448
|
-
foodCacheStorage: false,
|
|
1449
|
-
divisionId: "46753170027",
|
|
1450
|
-
groupSiteDivisionId: "46753170028",
|
|
1451
|
-
latitude: 46.75745,
|
|
1452
|
-
longitude: -121.65764,
|
|
1453
|
-
elevationFeet: 2806
|
|
1454
|
-
};
|
|
1455
|
-
static reflectionLakes = {
|
|
1456
|
-
name: "Reflection Lakes",
|
|
1457
|
-
trailhead: true,
|
|
1458
|
-
foodCacheStorage: false,
|
|
1459
|
-
divisionId: "",
|
|
1460
|
-
groupSiteDivisionId: "",
|
|
1461
|
-
latitude: 46.76824,
|
|
1462
|
-
longitude: -121.7289,
|
|
1463
|
-
elevationFeet: 4862
|
|
1464
|
-
};
|
|
1465
|
-
static paradiseRiver = {
|
|
1466
|
-
name: "Paradise River",
|
|
1467
|
-
trailhead: false,
|
|
1468
|
-
foodCacheStorage: false,
|
|
1469
|
-
divisionId: "46753170031",
|
|
1470
|
-
groupSiteDivisionId: "46753170032",
|
|
1471
|
-
latitude: 46.77076,
|
|
1472
|
-
longitude: -121.75909,
|
|
1473
|
-
elevationFeet: 3960
|
|
1474
|
-
};
|
|
1475
|
-
static longmire = {
|
|
1476
|
-
name: "Longmire",
|
|
1477
|
-
trailhead: true,
|
|
1478
|
-
foodCacheStorage: true,
|
|
1479
|
-
divisionId: "",
|
|
1480
|
-
groupSiteDivisionId: "",
|
|
1481
|
-
latitude: 46.75011,
|
|
1482
|
-
longitude: -121.81253,
|
|
1483
|
-
elevationFeet: 2750
|
|
1484
|
-
};
|
|
1485
|
-
static pyramidCreek = {
|
|
1486
|
-
name: "Pyramid Creek",
|
|
1487
|
-
trailhead: false,
|
|
1488
|
-
foodCacheStorage: false,
|
|
1489
|
-
divisionId: "46753170033",
|
|
1490
|
-
groupSiteDivisionId: "",
|
|
1491
|
-
latitude: 46.77832,
|
|
1492
|
-
longitude: -121.80963,
|
|
1493
|
-
elevationFeet: 3721
|
|
1494
|
-
};
|
|
1495
|
-
static devilsDream = {
|
|
1496
|
-
name: "Devil's Dream",
|
|
1497
|
-
trailhead: false,
|
|
1498
|
-
foodCacheStorage: false,
|
|
1499
|
-
divisionId: "46753170040",
|
|
1500
|
-
groupSiteDivisionId: "46753170041",
|
|
1501
|
-
latitude: 46.78196,
|
|
1502
|
-
longitude: -121.83297,
|
|
1503
|
-
elevationFeet: 4929
|
|
1504
|
-
};
|
|
1505
|
-
static southPuyallupRiver = {
|
|
1506
|
-
name: "South Puyallup River",
|
|
1507
|
-
trailhead: false,
|
|
1508
|
-
foodCacheStorage: false,
|
|
1509
|
-
divisionId: "46753170035",
|
|
1510
|
-
groupSiteDivisionId: "46753170036",
|
|
1511
|
-
latitude: 46.81331,
|
|
1512
|
-
longitude: -121.86445,
|
|
1513
|
-
elevationFeet: 4183
|
|
1514
|
-
};
|
|
1515
|
-
static klapatchePark = {
|
|
1516
|
-
name: "Klapatche Park",
|
|
1517
|
-
trailhead: false,
|
|
1518
|
-
foodCacheStorage: false,
|
|
1519
|
-
divisionId: "46753170024",
|
|
1520
|
-
groupSiteDivisionId: "",
|
|
1521
|
-
latitude: 46.83571,
|
|
1522
|
-
longitude: -121.87752,
|
|
1523
|
-
elevationFeet: 5496
|
|
1524
|
-
};
|
|
1525
|
-
static northPuyallupRiver = {
|
|
1526
|
-
name: "North Puyallup River",
|
|
1527
|
-
trailhead: false,
|
|
1528
|
-
foodCacheStorage: false,
|
|
1529
|
-
divisionId: "46753170029",
|
|
1530
|
-
groupSiteDivisionId: "46753170030",
|
|
1531
|
-
latitude: 46.84751,
|
|
1532
|
-
longitude: -121.87005,
|
|
1533
|
-
elevationFeet: 3733
|
|
1534
|
-
};
|
|
1535
|
-
static goldenLakes = {
|
|
1536
|
-
name: "Golden Lakes",
|
|
1537
|
-
trailhead: false,
|
|
1538
|
-
foodCacheStorage: false,
|
|
1539
|
-
divisionId: "46753170022",
|
|
1540
|
-
groupSiteDivisionId: "46753170023",
|
|
1541
|
-
latitude: 46.88327,
|
|
1542
|
-
longitude: -121.89919,
|
|
1543
|
-
elevationFeet: 4927
|
|
1544
|
-
};
|
|
1545
|
-
static southMowichRiver = {
|
|
1546
|
-
name: "South Mowich River",
|
|
1547
|
-
trailhead: false,
|
|
1548
|
-
foodCacheStorage: false,
|
|
1549
|
-
divisionId: "46753170019",
|
|
1550
|
-
groupSiteDivisionId: "46753170020",
|
|
1551
|
-
latitude: 46.91146,
|
|
1552
|
-
longitude: -121.89314,
|
|
1553
|
-
elevationFeet: 2686
|
|
1554
|
-
};
|
|
1555
|
-
static mowichLake = {
|
|
1556
|
-
name: "Mowich Lake",
|
|
1557
|
-
trailhead: false,
|
|
1558
|
-
foodCacheStorage: false,
|
|
1559
|
-
divisionId: "46753170015",
|
|
1560
|
-
groupSiteDivisionId: "46753170016",
|
|
1561
|
-
latitude: 46.93204,
|
|
1562
|
-
longitude: -121.86351,
|
|
1563
|
-
elevationFeet: 4868
|
|
1564
|
-
};
|
|
1565
|
-
static eaglesRoost = {
|
|
1566
|
-
name: "Eagle's Roost",
|
|
1567
|
-
trailhead: false,
|
|
1568
|
-
foodCacheStorage: false,
|
|
1569
|
-
divisionId: "46753170006",
|
|
1570
|
-
groupSiteDivisionId: "",
|
|
1571
|
-
latitude: 46.91529,
|
|
1572
|
-
longitude: -121.84816,
|
|
1573
|
-
elevationFeet: 4834
|
|
1574
|
-
};
|
|
1575
|
-
static cataractValley = {
|
|
1576
|
-
name: "Cataract Valley",
|
|
1577
|
-
trailhead: false,
|
|
1578
|
-
foodCacheStorage: false,
|
|
1579
|
-
divisionId: "46753170003",
|
|
1580
|
-
groupSiteDivisionId: "46753170004",
|
|
1581
|
-
latitude: 46.94049,
|
|
1582
|
-
longitude: -121.80486,
|
|
1583
|
-
elevationFeet: 4488
|
|
1584
|
-
};
|
|
1585
|
-
static ipsutCreek = {
|
|
1586
|
-
name: "Ipsut Creek",
|
|
1587
|
-
trailhead: false,
|
|
1588
|
-
foodCacheStorage: false,
|
|
1589
|
-
divisionId: "46753170011",
|
|
1590
|
-
groupSiteDivisionId: "46753170012",
|
|
1591
|
-
latitude: 46.97615,
|
|
1592
|
-
longitude: -121.83022,
|
|
1593
|
-
elevationFeet: 2359
|
|
1594
|
-
};
|
|
1595
|
-
static carbonRiver = {
|
|
1596
|
-
name: "Carbon River",
|
|
1597
|
-
trailhead: false,
|
|
1598
|
-
foodCacheStorage: false,
|
|
1599
|
-
divisionId: "46753170001",
|
|
1600
|
-
groupSiteDivisionId: "46753170002",
|
|
1601
|
-
latitude: 46.95063,
|
|
1602
|
-
longitude: -121.79991,
|
|
1603
|
-
elevationFeet: 3255
|
|
1604
|
-
};
|
|
1605
|
-
static dickCreek = {
|
|
1606
|
-
name: "Dick Creek",
|
|
1607
|
-
trailhead: false,
|
|
1608
|
-
foodCacheStorage: false,
|
|
1609
|
-
divisionId: "46753170005",
|
|
1610
|
-
groupSiteDivisionId: "",
|
|
1611
|
-
latitude: 46.94071,
|
|
1612
|
-
longitude: -121.78431,
|
|
1613
|
-
elevationFeet: 4114
|
|
1614
|
-
};
|
|
1615
|
-
static mysticLake = {
|
|
1616
|
-
name: "Mystic Lake",
|
|
1617
|
-
trailhead: false,
|
|
1618
|
-
foodCacheStorage: false,
|
|
1619
|
-
divisionId: "46753170017",
|
|
1620
|
-
groupSiteDivisionId: "46753170018",
|
|
1621
|
-
latitude: 46.9157,
|
|
1622
|
-
longitude: -121.75045,
|
|
1623
|
-
elevationFeet: 5538
|
|
1624
|
-
};
|
|
1625
|
-
static getLocations() {
|
|
1626
|
-
return Iterable.create([
|
|
1627
|
-
this.graniteCreek,
|
|
1628
|
-
this.sunriseCamp,
|
|
1629
|
-
this.sunriseVisitorCenter,
|
|
1630
|
-
this.whiteRiver,
|
|
1631
|
-
this.fryingPanCreek,
|
|
1632
|
-
this.summerland,
|
|
1633
|
-
this.indianBar,
|
|
1634
|
-
this.nickelCreek,
|
|
1635
|
-
this.boxCanyon,
|
|
1636
|
-
this.mapleCreek,
|
|
1637
|
-
this.reflectionLakes,
|
|
1638
|
-
this.paradiseRiver,
|
|
1639
|
-
this.longmire,
|
|
1640
|
-
this.pyramidCreek,
|
|
1641
|
-
this.devilsDream,
|
|
1642
|
-
this.southPuyallupRiver,
|
|
1643
|
-
this.klapatchePark,
|
|
1644
|
-
this.northPuyallupRiver,
|
|
1645
|
-
this.goldenLakes,
|
|
1646
|
-
this.southMowichRiver,
|
|
1647
|
-
this.mowichLake,
|
|
1648
|
-
this.eaglesRoost,
|
|
1649
|
-
this.cataractValley,
|
|
1650
|
-
this.ipsutCreek,
|
|
1651
|
-
this.carbonRiver,
|
|
1652
|
-
this.dickCreek,
|
|
1653
|
-
this.mysticLake
|
|
1654
|
-
]);
|
|
1655
|
-
}
|
|
1656
|
-
static getTrailheads() {
|
|
1657
|
-
return this.getLocations().where((location) => location.trailhead);
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
var WonderlandTrailReservationType = /* @__PURE__ */ ((WonderlandTrailReservationType2) => {
|
|
1661
|
-
WonderlandTrailReservationType2[WonderlandTrailReservationType2["Reserved"] = 0] = "Reserved";
|
|
1662
|
-
WonderlandTrailReservationType2[WonderlandTrailReservationType2["Walkup"] = 1] = "Walkup";
|
|
1663
|
-
return WonderlandTrailReservationType2;
|
|
1664
|
-
})(WonderlandTrailReservationType || {});
|
|
1665
|
-
var WonderlandTrailAvailability = class _WonderlandTrailAvailability {
|
|
1666
|
-
availabilityMap;
|
|
1667
|
-
constructor() {
|
|
1668
|
-
this.availabilityMap = Map.create();
|
|
1669
|
-
}
|
|
1670
|
-
static create() {
|
|
1671
|
-
return new _WonderlandTrailAvailability();
|
|
1672
|
-
}
|
|
1673
|
-
any() {
|
|
1674
|
-
return this.availabilityMap.any().await();
|
|
1675
|
-
}
|
|
1676
|
-
addAvailability(location, date, individualSite, groupSite) {
|
|
1677
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
1678
|
-
PreCondition.assertNotUndefinedAndNotNull(date, "date");
|
|
1679
|
-
const locationAvailability = this.getAvailability(location);
|
|
1680
|
-
const dateString = date.toDateString();
|
|
1681
|
-
const locationDayAvailability = locationAvailability.getOrSet(dateString, () => {
|
|
1682
|
-
return {};
|
|
1683
|
-
}).await();
|
|
1684
|
-
locationAvailability.set(dateString, {
|
|
1685
|
-
individualSite: individualSite ?? locationDayAvailability.individualSite,
|
|
1686
|
-
groupSite: groupSite ?? locationDayAvailability.groupSite
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1689
|
-
getAvailability(location) {
|
|
1690
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
1691
|
-
return this.availabilityMap.getOrSet(location, () => MutableMap.create()).await();
|
|
1692
|
-
}
|
|
1693
|
-
getDayAvailability(location, date) {
|
|
1694
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
1695
|
-
PreCondition.assertNotUndefinedAndNotNull(date, "date");
|
|
1696
|
-
return this.getAvailability(location).get(date.toDateString()).convertError(NotFoundError, () => new NotFoundError(`No availability was found for ${location.name} on ${date.toDateString()}.`));
|
|
1697
|
-
}
|
|
1698
|
-
};
|
|
1699
|
-
var WonderlandTrailDirection = class _WonderlandTrailDirection {
|
|
1700
|
-
value;
|
|
1701
|
-
constructor(value) {
|
|
1702
|
-
PreCondition.assertNotEmpty(value, "value");
|
|
1703
|
-
this.value = value;
|
|
1704
|
-
}
|
|
1705
|
-
static clockwise = new _WonderlandTrailDirection("Clockwise");
|
|
1706
|
-
static counterClockwise = new _WonderlandTrailDirection("CounterClockwise");
|
|
1707
|
-
toString() {
|
|
1708
|
-
return this.value;
|
|
1709
|
-
}
|
|
1710
|
-
reverse() {
|
|
1711
|
-
return this === _WonderlandTrailDirection.clockwise ? _WonderlandTrailDirection.counterClockwise : _WonderlandTrailDirection.clockwise;
|
|
1712
|
-
}
|
|
1713
|
-
};
|
|
1714
|
-
var WonderlandTrailConnection = class _WonderlandTrailConnection {
|
|
1715
|
-
startLocation;
|
|
1716
|
-
endLocation;
|
|
1717
|
-
distanceMiles;
|
|
1718
|
-
ascentFeet;
|
|
1719
|
-
descentFeet;
|
|
1720
|
-
direction;
|
|
1721
|
-
intermediateLocations;
|
|
1722
|
-
constructor(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations) {
|
|
1723
|
-
PreCondition.assertNotUndefinedAndNotNull(startLocation, "startLocation");
|
|
1724
|
-
PreCondition.assertNotUndefinedAndNotNull(endLocation, "endLocation");
|
|
1725
|
-
PreCondition.assertGreaterThanOrEqualTo(distanceMiles, 0, "distanceMiles");
|
|
1726
|
-
PreCondition.assertGreaterThanOrEqualTo(ascentFeet, 0, "ascentFeet");
|
|
1727
|
-
PreCondition.assertGreaterThanOrEqualTo(descentFeet, 0, "descentFeet");
|
|
1728
|
-
PreCondition.assertNotUndefinedAndNotNull(intermediateLocations, "intermediateLocations");
|
|
1729
|
-
this.startLocation = startLocation;
|
|
1730
|
-
this.endLocation = endLocation;
|
|
1731
|
-
this.distanceMiles = distanceMiles;
|
|
1732
|
-
this.ascentFeet = ascentFeet;
|
|
1733
|
-
this.descentFeet = descentFeet;
|
|
1734
|
-
this.direction = direction;
|
|
1735
|
-
this.intermediateLocations = intermediateLocations;
|
|
1736
|
-
}
|
|
1737
|
-
static create(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations) {
|
|
1738
|
-
return new _WonderlandTrailConnection(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations);
|
|
1739
|
-
}
|
|
1740
|
-
getLocations() {
|
|
1741
|
-
const result = List.create();
|
|
1742
|
-
_WonderlandTrailConnection.ensureExists(result, this.startLocation);
|
|
1743
|
-
_WonderlandTrailConnection.ensureAllExist(result, this.intermediateLocations);
|
|
1744
|
-
_WonderlandTrailConnection.ensureExists(result, this.endLocation);
|
|
1745
|
-
return result;
|
|
1746
|
-
}
|
|
1747
|
-
static ensureExists(list, location) {
|
|
1748
|
-
if (!list.contains(location).await()) {
|
|
1749
|
-
list.add(location);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
static ensureAllExist(list, locations) {
|
|
1753
|
-
for (const location of locations) {
|
|
1754
|
-
_WonderlandTrailConnection.ensureExists(list, location);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
reverseDirection() {
|
|
1758
|
-
return _WonderlandTrailConnection.create(
|
|
1759
|
-
this.endLocation,
|
|
1760
|
-
this.startLocation,
|
|
1761
|
-
this.distanceMiles,
|
|
1762
|
-
this.descentFeet,
|
|
1763
|
-
this.ascentFeet,
|
|
1764
|
-
this.direction.reverse(),
|
|
1765
|
-
this.intermediateLocations
|
|
1766
|
-
);
|
|
1767
|
-
}
|
|
1768
|
-
join(connection) {
|
|
1769
|
-
const intermediateLocations = List.create();
|
|
1770
|
-
_WonderlandTrailConnection.ensureAllExist(intermediateLocations, this.intermediateLocations);
|
|
1771
|
-
_WonderlandTrailConnection.ensureExists(intermediateLocations, this.endLocation);
|
|
1772
|
-
_WonderlandTrailConnection.ensureExists(intermediateLocations, connection.startLocation);
|
|
1773
|
-
_WonderlandTrailConnection.ensureAllExist(intermediateLocations, connection.intermediateLocations);
|
|
1774
|
-
return _WonderlandTrailConnection.create(
|
|
1775
|
-
this.startLocation,
|
|
1776
|
-
connection.endLocation,
|
|
1777
|
-
this.distanceMiles + connection.distanceMiles,
|
|
1778
|
-
this.ascentFeet + connection.ascentFeet,
|
|
1779
|
-
this.descentFeet + connection.descentFeet,
|
|
1780
|
-
this.direction,
|
|
1781
|
-
intermediateLocations
|
|
1782
|
-
);
|
|
1783
|
-
}
|
|
1784
|
-
containsLocation(location) {
|
|
1785
|
-
return this.getLocations().contains(location).await();
|
|
1786
|
-
}
|
|
1787
|
-
isLoop() {
|
|
1788
|
-
return this.startLocation === this.endLocation;
|
|
1789
|
-
}
|
|
1790
|
-
};
|
|
1791
|
-
var WonderlandTrailConnections = class _WonderlandTrailConnections {
|
|
1792
|
-
connections;
|
|
1793
|
-
addReverseConnectionDefault;
|
|
1794
|
-
constructor(addReverseConnectionDefault) {
|
|
1795
|
-
this.connections = Map.create();
|
|
1796
|
-
this.addReverseConnectionDefault = addReverseConnectionDefault;
|
|
1797
|
-
}
|
|
1798
|
-
static create(addReverseConnectionDefault) {
|
|
1799
|
-
return new _WonderlandTrailConnections(!!addReverseConnectionDefault);
|
|
1800
|
-
}
|
|
1801
|
-
static createDefault() {
|
|
1802
|
-
return _WonderlandTrailConnections.create(true).addConnection({
|
|
1803
|
-
startLocation: WonderlandTrailLocations.whiteRiver,
|
|
1804
|
-
endLocation: WonderlandTrailLocations.fryingPanCreek,
|
|
1805
|
-
distanceMiles: 2.7,
|
|
1806
|
-
ascentFeet: 100,
|
|
1807
|
-
descentFeet: 600
|
|
1808
|
-
}).addConnection({
|
|
1809
|
-
startLocation: WonderlandTrailLocations.fryingPanCreek,
|
|
1810
|
-
endLocation: WonderlandTrailLocations.summerland,
|
|
1811
|
-
distanceMiles: 4.3,
|
|
1812
|
-
ascentFeet: 2200,
|
|
1813
|
-
descentFeet: 100
|
|
1814
|
-
}).addConnection({
|
|
1815
|
-
startLocation: WonderlandTrailLocations.summerland,
|
|
1816
|
-
endLocation: WonderlandTrailLocations.indianBar,
|
|
1817
|
-
distanceMiles: 4.7,
|
|
1818
|
-
ascentFeet: 1200,
|
|
1819
|
-
descentFeet: 2100
|
|
1820
|
-
}).addConnection({
|
|
1821
|
-
startLocation: WonderlandTrailLocations.indianBar,
|
|
1822
|
-
endLocation: WonderlandTrailLocations.nickelCreek,
|
|
1823
|
-
distanceMiles: 6.8,
|
|
1824
|
-
ascentFeet: 1400,
|
|
1825
|
-
descentFeet: 3200
|
|
1826
|
-
}).addConnection({
|
|
1827
|
-
startLocation: WonderlandTrailLocations.nickelCreek,
|
|
1828
|
-
endLocation: WonderlandTrailLocations.boxCanyon,
|
|
1829
|
-
distanceMiles: 0.9,
|
|
1830
|
-
ascentFeet: 100,
|
|
1831
|
-
descentFeet: 400
|
|
1832
|
-
}).addConnection({
|
|
1833
|
-
startLocation: WonderlandTrailLocations.boxCanyon,
|
|
1834
|
-
endLocation: WonderlandTrailLocations.mapleCreek,
|
|
1835
|
-
distanceMiles: 2.7,
|
|
1836
|
-
ascentFeet: 500,
|
|
1837
|
-
descentFeet: 700
|
|
1838
|
-
}).addConnection({
|
|
1839
|
-
startLocation: WonderlandTrailLocations.mapleCreek,
|
|
1840
|
-
endLocation: WonderlandTrailLocations.reflectionLakes,
|
|
1841
|
-
distanceMiles: 4.7,
|
|
1842
|
-
ascentFeet: 2300,
|
|
1843
|
-
descentFeet: 200
|
|
1844
|
-
}).addConnection({
|
|
1845
|
-
startLocation: WonderlandTrailLocations.reflectionLakes,
|
|
1846
|
-
endLocation: WonderlandTrailLocations.paradiseRiver,
|
|
1847
|
-
distanceMiles: 2.6,
|
|
1848
|
-
ascentFeet: 200,
|
|
1849
|
-
descentFeet: 1200
|
|
1850
|
-
}).addConnection({
|
|
1851
|
-
startLocation: WonderlandTrailLocations.paradiseRiver,
|
|
1852
|
-
endLocation: WonderlandTrailLocations.longmire,
|
|
1853
|
-
distanceMiles: 3.6,
|
|
1854
|
-
ascentFeet: 100,
|
|
1855
|
-
descentFeet: 1200
|
|
1856
|
-
}).addConnection({
|
|
1857
|
-
startLocation: WonderlandTrailLocations.longmire,
|
|
1858
|
-
endLocation: WonderlandTrailLocations.pyramidCreek,
|
|
1859
|
-
distanceMiles: 3.3,
|
|
1860
|
-
ascentFeet: 1400,
|
|
1861
|
-
descentFeet: 400
|
|
1862
|
-
}).addConnection({
|
|
1863
|
-
startLocation: WonderlandTrailLocations.pyramidCreek,
|
|
1864
|
-
endLocation: WonderlandTrailLocations.devilsDream,
|
|
1865
|
-
distanceMiles: 2.5,
|
|
1866
|
-
ascentFeet: 1400,
|
|
1867
|
-
descentFeet: 100
|
|
1868
|
-
}).addConnection({
|
|
1869
|
-
startLocation: WonderlandTrailLocations.devilsDream,
|
|
1870
|
-
endLocation: WonderlandTrailLocations.southPuyallupRiver,
|
|
1871
|
-
distanceMiles: 6.5,
|
|
1872
|
-
ascentFeet: 1900,
|
|
1873
|
-
descentFeet: 2700
|
|
1874
|
-
}).addConnection({
|
|
1875
|
-
startLocation: WonderlandTrailLocations.southPuyallupRiver,
|
|
1876
|
-
endLocation: WonderlandTrailLocations.klapatchePark,
|
|
1877
|
-
distanceMiles: 4.1,
|
|
1878
|
-
ascentFeet: 2100,
|
|
1879
|
-
descentFeet: 800
|
|
1880
|
-
}).addConnection({
|
|
1881
|
-
startLocation: WonderlandTrailLocations.klapatchePark,
|
|
1882
|
-
endLocation: WonderlandTrailLocations.northPuyallupRiver,
|
|
1883
|
-
distanceMiles: 2.6,
|
|
1884
|
-
ascentFeet: 100,
|
|
1885
|
-
descentFeet: 1900
|
|
1886
|
-
}).addConnection({
|
|
1887
|
-
startLocation: WonderlandTrailLocations.northPuyallupRiver,
|
|
1888
|
-
endLocation: WonderlandTrailLocations.goldenLakes,
|
|
1889
|
-
distanceMiles: 5.1,
|
|
1890
|
-
ascentFeet: 1900,
|
|
1891
|
-
descentFeet: 600
|
|
1892
|
-
}).addConnection({
|
|
1893
|
-
startLocation: WonderlandTrailLocations.goldenLakes,
|
|
1894
|
-
endLocation: WonderlandTrailLocations.southMowichRiver,
|
|
1895
|
-
distanceMiles: 5.8,
|
|
1896
|
-
ascentFeet: 200,
|
|
1897
|
-
descentFeet: 2400
|
|
1898
|
-
}).addConnection({
|
|
1899
|
-
startLocation: WonderlandTrailLocations.southMowichRiver,
|
|
1900
|
-
endLocation: WonderlandTrailLocations.mowichLake,
|
|
1901
|
-
distanceMiles: 4.4,
|
|
1902
|
-
ascentFeet: 2400,
|
|
1903
|
-
descentFeet: 300
|
|
1904
|
-
}).addConnection({
|
|
1905
|
-
startLocation: WonderlandTrailLocations.mowichLake,
|
|
1906
|
-
endLocation: WonderlandTrailLocations.ipsutCreek,
|
|
1907
|
-
distanceMiles: 5.6,
|
|
1908
|
-
ascentFeet: 400,
|
|
1909
|
-
descentFeet: 3e3
|
|
1910
|
-
}).addConnection({
|
|
1911
|
-
startLocation: WonderlandTrailLocations.ipsutCreek,
|
|
1912
|
-
endLocation: WonderlandTrailLocations.carbonRiver,
|
|
1913
|
-
distanceMiles: 4,
|
|
1914
|
-
ascentFeet: 1300,
|
|
1915
|
-
descentFeet: 400
|
|
1916
|
-
}).addConnection({
|
|
1917
|
-
startLocation: WonderlandTrailLocations.mowichLake,
|
|
1918
|
-
endLocation: WonderlandTrailLocations.eaglesRoost,
|
|
1919
|
-
distanceMiles: 2,
|
|
1920
|
-
ascentFeet: 500,
|
|
1921
|
-
descentFeet: 600
|
|
1922
|
-
}).addConnection({
|
|
1923
|
-
startLocation: WonderlandTrailLocations.eaglesRoost,
|
|
1924
|
-
endLocation: WonderlandTrailLocations.cataractValley,
|
|
1925
|
-
distanceMiles: 12.4,
|
|
1926
|
-
ascentFeet: 3300,
|
|
1927
|
-
descentFeet: 3700
|
|
1928
|
-
}).addConnection({
|
|
1929
|
-
startLocation: WonderlandTrailLocations.cataractValley,
|
|
1930
|
-
endLocation: WonderlandTrailLocations.carbonRiver,
|
|
1931
|
-
distanceMiles: 1.6,
|
|
1932
|
-
ascentFeet: 100,
|
|
1933
|
-
descentFeet: 1300
|
|
1934
|
-
}).addConnection({
|
|
1935
|
-
startLocation: WonderlandTrailLocations.carbonRiver,
|
|
1936
|
-
endLocation: WonderlandTrailLocations.dickCreek,
|
|
1937
|
-
distanceMiles: 1.3,
|
|
1938
|
-
ascentFeet: 1e3,
|
|
1939
|
-
descentFeet: 100
|
|
1940
|
-
}).addConnection({
|
|
1941
|
-
startLocation: WonderlandTrailLocations.dickCreek,
|
|
1942
|
-
endLocation: WonderlandTrailLocations.mysticLake,
|
|
1943
|
-
distanceMiles: 3.7,
|
|
1944
|
-
ascentFeet: 2100,
|
|
1945
|
-
descentFeet: 600
|
|
1946
|
-
}).addConnection({
|
|
1947
|
-
startLocation: WonderlandTrailLocations.mysticLake,
|
|
1948
|
-
endLocation: WonderlandTrailLocations.graniteCreek,
|
|
1949
|
-
distanceMiles: 4.1,
|
|
1950
|
-
ascentFeet: 1500,
|
|
1951
|
-
descentFeet: 1200
|
|
1952
|
-
}).addConnection({
|
|
1953
|
-
startLocation: WonderlandTrailLocations.graniteCreek,
|
|
1954
|
-
endLocation: WonderlandTrailLocations.sunriseCamp,
|
|
1955
|
-
distanceMiles: 4.6,
|
|
1956
|
-
ascentFeet: 1400,
|
|
1957
|
-
descentFeet: 1e3
|
|
1958
|
-
}).addConnection({
|
|
1959
|
-
startLocation: WonderlandTrailLocations.sunriseCamp,
|
|
1960
|
-
endLocation: WonderlandTrailLocations.whiteRiver,
|
|
1961
|
-
distanceMiles: 3.5,
|
|
1962
|
-
ascentFeet: 100,
|
|
1963
|
-
descentFeet: 2100
|
|
1964
|
-
}).addConnection({
|
|
1965
|
-
startLocation: WonderlandTrailLocations.sunriseCamp,
|
|
1966
|
-
endLocation: WonderlandTrailLocations.sunriseVisitorCenter,
|
|
1967
|
-
distanceMiles: 1.4,
|
|
1968
|
-
ascentFeet: 400,
|
|
1969
|
-
descentFeet: 200
|
|
1970
|
-
}).addConnection({
|
|
1971
|
-
startLocation: WonderlandTrailLocations.sunriseVisitorCenter,
|
|
1972
|
-
endLocation: WonderlandTrailLocations.whiteRiver,
|
|
1973
|
-
distanceMiles: 3.1,
|
|
1974
|
-
ascentFeet: 0,
|
|
1975
|
-
descentFeet: 2200
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
iterateConnections(startLocationOrProperties, endLocation, direction) {
|
|
1979
|
-
let startLocation;
|
|
1980
|
-
if (isWonderlandTrailLocation(startLocationOrProperties)) {
|
|
1981
|
-
startLocation = startLocationOrProperties;
|
|
1982
|
-
} else if (startLocationOrProperties) {
|
|
1983
|
-
startLocation = startLocationOrProperties.startLocation;
|
|
1984
|
-
endLocation = startLocationOrProperties.endLocation;
|
|
1985
|
-
direction = startLocationOrProperties.direction;
|
|
1986
|
-
}
|
|
1987
|
-
let result;
|
|
1988
|
-
if (!startLocation) {
|
|
1989
|
-
result = this.connections.iterateValues().flatMap((x) => x);
|
|
1990
|
-
} else {
|
|
1991
|
-
result = this.connections.get(startLocation).catch(NotFoundError, () => Iterable.create()).await().iterate();
|
|
1992
|
-
}
|
|
1993
|
-
if (endLocation) {
|
|
1994
|
-
result = result.where((connection) => connection.endLocation == endLocation);
|
|
1995
|
-
}
|
|
1996
|
-
if (direction != null) {
|
|
1997
|
-
result = result.where((connection) => connection.direction == direction);
|
|
1998
|
-
}
|
|
1999
|
-
return result;
|
|
2000
|
-
}
|
|
2001
|
-
addConnectionInner(connection) {
|
|
2002
|
-
const startLocationConnections = this.connections.getOrSet(connection.startLocation, () => List.create()).await();
|
|
2003
|
-
startLocationConnections.add(connection);
|
|
2004
|
-
}
|
|
2005
|
-
addConnection(connectionStartLocationOrProperties, addReverseConnectionOrEndLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations, addReverseConnection) {
|
|
2006
|
-
let startLocation;
|
|
2007
|
-
let endLocation;
|
|
2008
|
-
if (isWonderlandTrailLocation(connectionStartLocationOrProperties)) {
|
|
2009
|
-
startLocation = connectionStartLocationOrProperties;
|
|
2010
|
-
} else if (connectionStartLocationOrProperties instanceof WonderlandTrailConnection) {
|
|
2011
|
-
startLocation = connectionStartLocationOrProperties.startLocation;
|
|
2012
|
-
endLocation = connectionStartLocationOrProperties.endLocation;
|
|
2013
|
-
distanceMiles = connectionStartLocationOrProperties.distanceMiles;
|
|
2014
|
-
ascentFeet = connectionStartLocationOrProperties.ascentFeet;
|
|
2015
|
-
descentFeet = connectionStartLocationOrProperties.descentFeet;
|
|
2016
|
-
direction = connectionStartLocationOrProperties.direction;
|
|
2017
|
-
intermediateLocations = connectionStartLocationOrProperties.intermediateLocations;
|
|
2018
|
-
addReverseConnection = !!addReverseConnectionOrEndLocation;
|
|
2019
|
-
} else {
|
|
2020
|
-
startLocation = connectionStartLocationOrProperties.startLocation;
|
|
2021
|
-
endLocation = connectionStartLocationOrProperties.endLocation;
|
|
2022
|
-
distanceMiles = connectionStartLocationOrProperties.distanceMiles;
|
|
2023
|
-
ascentFeet = connectionStartLocationOrProperties.ascentFeet;
|
|
2024
|
-
descentFeet = connectionStartLocationOrProperties.descentFeet;
|
|
2025
|
-
direction = connectionStartLocationOrProperties.direction;
|
|
2026
|
-
intermediateLocations = connectionStartLocationOrProperties.intermediateLocations;
|
|
2027
|
-
addReverseConnection = connectionStartLocationOrProperties.addReverseConnection;
|
|
2028
|
-
}
|
|
2029
|
-
const connection = WonderlandTrailConnection.create(
|
|
2030
|
-
startLocation,
|
|
2031
|
-
endLocation,
|
|
2032
|
-
distanceMiles,
|
|
2033
|
-
ascentFeet,
|
|
2034
|
-
descentFeet,
|
|
2035
|
-
direction ?? WonderlandTrailDirection.clockwise,
|
|
2036
|
-
intermediateLocations ?? Iterable.create()
|
|
2037
|
-
);
|
|
2038
|
-
this.addConnectionInner(connection);
|
|
2039
|
-
if (addReverseConnection ?? this.addReverseConnectionDefault) {
|
|
2040
|
-
this.addConnectionInner(connection.reverseDirection());
|
|
2041
|
-
}
|
|
2042
|
-
return this;
|
|
2043
|
-
}
|
|
2044
|
-
containsConnection(connection) {
|
|
2045
|
-
PreCondition.assertNotUndefinedAndNotNull(connection, "connection");
|
|
2046
|
-
const startLocationConnections = this.connections.get(connection.startLocation).catch(() => void 0).await();
|
|
2047
|
-
return startLocationConnections?.contains(connection)?.await() === true;
|
|
2048
|
-
}
|
|
2049
|
-
reverseDirection() {
|
|
2050
|
-
const result = _WonderlandTrailConnections.create(this.addReverseConnectionDefault);
|
|
2051
|
-
for (const connection of this.iterateConnections()) {
|
|
2052
|
-
result.addConnection(connection.reverseDirection());
|
|
2053
|
-
}
|
|
2054
|
-
return result;
|
|
2055
|
-
}
|
|
2056
|
-
expandConnections(startLocation, endLocation, direction) {
|
|
2057
|
-
if (isUndefinedOrNull(direction)) {
|
|
2058
|
-
direction = WonderlandTrailDirection.clockwise;
|
|
2059
|
-
}
|
|
2060
|
-
const result = _WonderlandTrailConnections.create(this.addReverseConnectionDefault);
|
|
2061
|
-
const toVisit = Stack.create();
|
|
2062
|
-
toVisit.addAll(this.iterateConnections(startLocation, void 0, direction));
|
|
2063
|
-
while (toVisit.any().await()) {
|
|
2064
|
-
const currentConnection = toVisit.remove().await();
|
|
2065
|
-
result.addConnection(currentConnection, false);
|
|
2066
|
-
if (!currentConnection.isLoop() && currentConnection.endLocation !== endLocation) {
|
|
2067
|
-
for (const endLocationConnection of this.iterateConnections(currentConnection.endLocation, void 0, direction)) {
|
|
2068
|
-
if (!result.containsConnection(endLocationConnection) && !toVisit.contains(endLocationConnection)) {
|
|
2069
|
-
toVisit.add(endLocationConnection);
|
|
2070
|
-
}
|
|
2071
|
-
if (!currentConnection.intermediateLocations.contains(endLocationConnection.endLocation)) {
|
|
2072
|
-
toVisit.add(currentConnection.join(endLocationConnection));
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
return result;
|
|
2078
|
-
}
|
|
2079
|
-
};
|
|
2080
|
-
var WonderlandTrailItinerary = class _WonderlandTrailItinerary {
|
|
2081
|
-
startDay;
|
|
2082
|
-
connections;
|
|
2083
|
-
availabilityTypes;
|
|
2084
|
-
constructor(startDay) {
|
|
2085
|
-
PreCondition.assertNotUndefinedAndNotNull(startDay, "startDay");
|
|
2086
|
-
this.startDay = startDay;
|
|
2087
|
-
this.connections = List.create();
|
|
2088
|
-
this.availabilityTypes = List.create();
|
|
2089
|
-
}
|
|
2090
|
-
static create(startDay) {
|
|
2091
|
-
return new _WonderlandTrailItinerary(startDay);
|
|
2092
|
-
}
|
|
2093
|
-
clone() {
|
|
2094
|
-
return _WonderlandTrailItinerary.create(this.startDay).addConnections(this.connections).addAvailabilityTypes(this.availabilityTypes);
|
|
2095
|
-
}
|
|
2096
|
-
getConnections() {
|
|
2097
|
-
return this.connections;
|
|
2098
|
-
}
|
|
2099
|
-
getEndDay() {
|
|
2100
|
-
return this.startDay.addDays(this.getDayCount() - 1);
|
|
2101
|
-
}
|
|
2102
|
-
getDayCount() {
|
|
2103
|
-
return this.connections.getCount().await();
|
|
2104
|
-
}
|
|
2105
|
-
getStartLocation() {
|
|
2106
|
-
return this.connections.first().then((firstConnection) => firstConnection.startLocation);
|
|
2107
|
-
}
|
|
2108
|
-
getIntermediateLocations() {
|
|
2109
|
-
const result = List.create();
|
|
2110
|
-
for (const connection of this.connections) {
|
|
2111
|
-
if (result.any().await()) {
|
|
2112
|
-
result.add(connection.startLocation);
|
|
2113
|
-
}
|
|
2114
|
-
result.addAll(connection.intermediateLocations);
|
|
2115
|
-
}
|
|
2116
|
-
return result;
|
|
2117
|
-
}
|
|
2118
|
-
getEndLocation() {
|
|
2119
|
-
return this.connections.last().then((lastConnection) => lastConnection.endLocation);
|
|
2120
|
-
}
|
|
2121
|
-
getPath() {
|
|
2122
|
-
const result = List.create();
|
|
2123
|
-
for (const connection of this.connections) {
|
|
2124
|
-
if (!result.any().await()) {
|
|
2125
|
-
result.add(connection.startLocation);
|
|
2126
|
-
}
|
|
2127
|
-
result.add(connection.endLocation);
|
|
2128
|
-
}
|
|
2129
|
-
return result;
|
|
2130
|
-
}
|
|
2131
|
-
getPathStrings(includeAvailabilityTypes) {
|
|
2132
|
-
includeAvailabilityTypes = includeAvailabilityTypes ?? true;
|
|
2133
|
-
const result = List.create();
|
|
2134
|
-
let availabilityTypeIndex = 0;
|
|
2135
|
-
const availabilityTypeCount = this.availabilityTypes.getCount().await();
|
|
2136
|
-
for (const connection of this.connections) {
|
|
2137
|
-
if (!result.any().await()) {
|
|
2138
|
-
result.add(connection.startLocation.name);
|
|
2139
|
-
}
|
|
2140
|
-
let pathString = connection.endLocation.name;
|
|
2141
|
-
if (includeAvailabilityTypes && availabilityTypeIndex < availabilityTypeCount) {
|
|
2142
|
-
pathString += " ";
|
|
2143
|
-
const availabilityType = this.availabilityTypes.get(availabilityTypeIndex).await();
|
|
2144
|
-
availabilityTypeIndex++;
|
|
2145
|
-
if (availabilityType.individualSite !== void 0) {
|
|
2146
|
-
if (availabilityType.groupSite !== void 0) {
|
|
2147
|
-
pathString += `(Individual ${availabilityType.individualSite}/Group ${availabilityType.groupSite})`;
|
|
2148
|
-
} else {
|
|
2149
|
-
pathString += `(Individual ${availabilityType.individualSite})`;
|
|
2150
|
-
}
|
|
2151
|
-
} else {
|
|
2152
|
-
pathString += `(Group ${availabilityType.groupSite})`;
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
result.add(pathString);
|
|
2156
|
-
}
|
|
2157
|
-
return result;
|
|
2158
|
-
}
|
|
2159
|
-
contains(parameters) {
|
|
2160
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
2161
|
-
const location = parameters.location;
|
|
2162
|
-
const checkItineraryStartLocation = parameters.checkItineraryStartLocation ?? true;
|
|
2163
|
-
const checkItineraryIntermediateLocations = parameters.checkItineraryIntermediateLocations ?? true;
|
|
2164
|
-
const checkItineraryEndLocation = parameters.checkItineraryEndLocation ?? true;
|
|
2165
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
2166
|
-
let result = false;
|
|
2167
|
-
const connectionCount = this.connections.getCount().await();
|
|
2168
|
-
for (let i = 0; i < connectionCount; i++) {
|
|
2169
|
-
if (i !== 0 || checkItineraryStartLocation) {
|
|
2170
|
-
result = this.connections.get(i).await().startLocation === location;
|
|
2171
|
-
if (result) {
|
|
2172
|
-
break;
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
if (checkItineraryIntermediateLocations) {
|
|
2176
|
-
result = this.connections.get(i).await().intermediateLocations.contains(location).await();
|
|
2177
|
-
if (result) {
|
|
2178
|
-
break;
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
if (i === connectionCount - 1 && checkItineraryEndLocation) {
|
|
2182
|
-
result = this.connections.get(i).await().endLocation === location;
|
|
2183
|
-
if (result) {
|
|
2184
|
-
break;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
return result;
|
|
2189
|
-
}
|
|
2190
|
-
containsAny(parameters) {
|
|
2191
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
2192
|
-
const connection = parameters.connection;
|
|
2193
|
-
const checkConnectionStartLocation = parameters.checkConnectionStartLocation ?? true;
|
|
2194
|
-
const checkConnectionIntermediateLocations = parameters.checkConnectionIntermediateLocations ?? true;
|
|
2195
|
-
const checkConnectionEndLocation = parameters.checkConnectionEndLocation ?? true;
|
|
2196
|
-
const checkItineraryStartLocation = parameters.checkItineraryStartLocation ?? true;
|
|
2197
|
-
const checkItineraryIntermediateLocations = parameters.checkItineraryIntermediateLocations ?? true;
|
|
2198
|
-
const checkItineraryEndLocation = parameters.checkItineraryEndLocation ?? true;
|
|
2199
|
-
PreCondition.assertNotUndefinedAndNotNull(connection, "connection");
|
|
2200
|
-
let result = false;
|
|
2201
|
-
if (!result && checkConnectionStartLocation) {
|
|
2202
|
-
result = this.contains({
|
|
2203
|
-
location: connection.startLocation,
|
|
2204
|
-
checkItineraryStartLocation,
|
|
2205
|
-
checkItineraryIntermediateLocations,
|
|
2206
|
-
checkItineraryEndLocation
|
|
2207
|
-
});
|
|
2208
|
-
}
|
|
2209
|
-
if (!result && checkConnectionIntermediateLocations) {
|
|
2210
|
-
for (const connectionIntermediateLocation of connection.intermediateLocations) {
|
|
2211
|
-
result = this.contains({
|
|
2212
|
-
location: connectionIntermediateLocation,
|
|
2213
|
-
checkItineraryStartLocation,
|
|
2214
|
-
checkItineraryIntermediateLocations,
|
|
2215
|
-
checkItineraryEndLocation
|
|
2216
|
-
});
|
|
2217
|
-
if (result) {
|
|
2218
|
-
break;
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
if (!result && checkConnectionEndLocation) {
|
|
2223
|
-
result = this.contains({
|
|
2224
|
-
location: connection.endLocation,
|
|
2225
|
-
checkItineraryStartLocation,
|
|
2226
|
-
checkItineraryIntermediateLocations,
|
|
2227
|
-
checkItineraryEndLocation
|
|
2228
|
-
});
|
|
2229
|
-
}
|
|
2230
|
-
return result;
|
|
2231
|
-
}
|
|
2232
|
-
addConnection(connection) {
|
|
2233
|
-
PreCondition.assertNotUndefinedAndNotNull(connection, "connection");
|
|
2234
|
-
this.connections.add(connection);
|
|
2235
|
-
return this;
|
|
2236
|
-
}
|
|
2237
|
-
addConnections(connections) {
|
|
2238
|
-
PreCondition.assertNotUndefinedAndNotNull(connections, "connections");
|
|
2239
|
-
this.connections.addAll(connections);
|
|
2240
|
-
return this;
|
|
2241
|
-
}
|
|
2242
|
-
addAvailabilityType(availabilityType) {
|
|
2243
|
-
PreCondition.assertNotUndefinedAndNotNull(availabilityType, "availabilityType");
|
|
2244
|
-
this.availabilityTypes.add(availabilityType);
|
|
2245
|
-
return this;
|
|
2246
|
-
}
|
|
2247
|
-
addAvailabilityTypes(availabilityTypes) {
|
|
2248
|
-
PreCondition.assertNotUndefinedAndNotNull(availabilityTypes, "availabilityTypes");
|
|
2249
|
-
this.availabilityTypes.addAll(availabilityTypes);
|
|
2250
|
-
return this;
|
|
2251
|
-
}
|
|
2252
|
-
toString(includeAvailabilityTypes) {
|
|
2253
|
-
includeAvailabilityTypes = includeAvailabilityTypes ?? true;
|
|
2254
|
-
return `startDay:${this.startDay.toDateString()},path:${this.getPathStrings(includeAvailabilityTypes)}`;
|
|
2255
|
-
}
|
|
2256
|
-
};
|
|
2257
|
-
var WonderlandTrailClient = class _WonderlandTrailClient {
|
|
2258
|
-
static permitItineraryId = "4675317";
|
|
2259
|
-
httpClient;
|
|
2260
|
-
recreationDotGovClient;
|
|
2261
|
-
constructor(httpClient) {
|
|
2262
|
-
PreCondition.assertNotUndefinedAndNotNull(httpClient, "httpClient");
|
|
2263
|
-
this.httpClient = httpClient;
|
|
2264
|
-
this.recreationDotGovClient = RecreationDotGovClient.create(httpClient);
|
|
2265
|
-
}
|
|
2266
|
-
static create(httpClient) {
|
|
2267
|
-
return new _WonderlandTrailClient(httpClient);
|
|
2268
|
-
}
|
|
2269
|
-
sendRequest(request) {
|
|
2270
|
-
return this.httpClient.sendRequest(request);
|
|
2271
|
-
}
|
|
2272
|
-
sendGetRequest(url) {
|
|
2273
|
-
return HttpClient.sendGetRequest(this, url);
|
|
2274
|
-
}
|
|
2275
|
-
getAvailability(monthOrOptions, year, allowWalkupPermits, allowIndividualSites, allowGroupSites, earlyAccessPermitLotteryId) {
|
|
2276
|
-
let month;
|
|
2277
|
-
if (isNumber(monthOrOptions)) {
|
|
2278
|
-
month = monthOrOptions;
|
|
2279
|
-
year = year;
|
|
2280
|
-
allowWalkupPermits = allowWalkupPermits;
|
|
2281
|
-
allowIndividualSites = allowIndividualSites;
|
|
2282
|
-
allowGroupSites = allowGroupSites;
|
|
2283
|
-
} else {
|
|
2284
|
-
month = monthOrOptions.month;
|
|
2285
|
-
year = monthOrOptions.year;
|
|
2286
|
-
allowWalkupPermits = monthOrOptions.allowWalkupPermits;
|
|
2287
|
-
allowIndividualSites = monthOrOptions.allowIndividualSites;
|
|
2288
|
-
allowGroupSites = monthOrOptions.allowGroupSites;
|
|
2289
|
-
earlyAccessPermitLotteryId = monthOrOptions.earlyAccessPermitLotteryId;
|
|
2290
|
-
}
|
|
2291
|
-
return PromiseAsyncResult.create(async () => {
|
|
2292
|
-
const result = WonderlandTrailAvailability.create();
|
|
2293
|
-
for (const location of WonderlandTrailLocations.getLocations()) {
|
|
2294
|
-
if (allowIndividualSites && location.divisionId) {
|
|
2295
|
-
const divisionAvailability = await this.recreationDotGovClient.getDivisionAvailability(
|
|
2296
|
-
_WonderlandTrailClient.permitItineraryId,
|
|
2297
|
-
location.divisionId,
|
|
2298
|
-
month,
|
|
2299
|
-
year,
|
|
2300
|
-
earlyAccessPermitLotteryId
|
|
2301
|
-
);
|
|
2302
|
-
const divisionDayAvailabilities = divisionAvailability.dayAvailabilities;
|
|
2303
|
-
if (divisionDayAvailabilities) {
|
|
2304
|
-
for (const divisionDayAvailability of divisionDayAvailabilities) {
|
|
2305
|
-
const hasWalkupPermits = allowWalkupPermits && divisionDayAvailability.walkup;
|
|
2306
|
-
const hasReservationPermits = divisionDayAvailability.reservationsRemaining > 0;
|
|
2307
|
-
if (hasWalkupPermits || hasReservationPermits) {
|
|
2308
|
-
result.addAvailability(
|
|
2309
|
-
location,
|
|
2310
|
-
divisionDayAvailability.date,
|
|
2311
|
-
hasWalkupPermits ? 1 /* Walkup */ : 0 /* Reserved */,
|
|
2312
|
-
void 0
|
|
2313
|
-
);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
if (allowGroupSites && location.groupSiteDivisionId) {
|
|
2319
|
-
const groupSiteDivisionAvailability = await this.recreationDotGovClient.getDivisionAvailability(
|
|
2320
|
-
_WonderlandTrailClient.permitItineraryId,
|
|
2321
|
-
location.groupSiteDivisionId,
|
|
2322
|
-
month,
|
|
2323
|
-
year,
|
|
2324
|
-
earlyAccessPermitLotteryId
|
|
2325
|
-
);
|
|
2326
|
-
const groupSiteDivisionDayAvailabilities = groupSiteDivisionAvailability.dayAvailabilities;
|
|
2327
|
-
if (groupSiteDivisionDayAvailabilities) {
|
|
2328
|
-
for (const groupSiteDayAvailability of groupSiteDivisionDayAvailabilities) {
|
|
2329
|
-
const hasWalkupPermits = allowWalkupPermits && groupSiteDayAvailability.walkup;
|
|
2330
|
-
const hasReservationPermits = groupSiteDayAvailability.reservationsRemaining > 0;
|
|
2331
|
-
if (hasWalkupPermits || hasReservationPermits) {
|
|
2332
|
-
result.addAvailability(
|
|
2333
|
-
location,
|
|
2334
|
-
groupSiteDayAvailability.date,
|
|
2335
|
-
void 0,
|
|
2336
|
-
hasWalkupPermits ? 1 /* Walkup */ : 0 /* Reserved */
|
|
2337
|
-
);
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
return result;
|
|
2344
|
-
});
|
|
2345
|
-
}
|
|
2346
|
-
findItineraries(parameters) {
|
|
2347
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
2348
|
-
const availability = parameters.availability;
|
|
2349
|
-
const startDate = parameters.startDate;
|
|
2350
|
-
const startLocation = parameters.startLocation;
|
|
2351
|
-
const endLocation = parameters.endLocation;
|
|
2352
|
-
const direction = parameters.direction;
|
|
2353
|
-
const maximumDayDistanceMiles = parameters.maximumDayDistanceMiles;
|
|
2354
|
-
const maximumItineraryDays = parameters.maximumItineraryDays;
|
|
2355
|
-
const campsitesToAvoid = Iterable.create(parameters.campsitesToAvoid ?? []);
|
|
2356
|
-
const result = List.create();
|
|
2357
|
-
const connections = WonderlandTrailConnections.createDefault().expandConnections(startLocation, endLocation, direction);
|
|
2358
|
-
let startLocationConnections = connections.iterateConnections(startLocation, void 0, direction);
|
|
2359
|
-
if (!isUndefinedOrNull(maximumDayDistanceMiles)) {
|
|
2360
|
-
startLocationConnections = startLocationConnections.where((connection) => connection.distanceMiles <= maximumDayDistanceMiles);
|
|
2361
|
-
}
|
|
2362
|
-
const possibleItineraries = Stack.create();
|
|
2363
|
-
possibleItineraries.addAll(startLocationConnections.map((c) => WonderlandTrailItinerary.create(startDate).addConnection(c)));
|
|
2364
|
-
while (possibleItineraries.any().await()) {
|
|
2365
|
-
const currentItinerary = possibleItineraries.remove().await();
|
|
2366
|
-
const currentItineraryEndLocation = currentItinerary.getEndLocation().await();
|
|
2367
|
-
if ((maximumItineraryDays === void 0 || currentItinerary.getDayCount() <= maximumItineraryDays) && (startLocation === currentItineraryEndLocation || endLocation === currentItineraryEndLocation || !campsitesToAvoid.contains(currentItineraryEndLocation).await())) {
|
|
2368
|
-
if (currentItineraryEndLocation === endLocation) {
|
|
2369
|
-
result.add(currentItinerary);
|
|
2370
|
-
} else {
|
|
2371
|
-
const dayAvailability = availability.getDayAvailability(currentItineraryEndLocation, currentItinerary.getEndDay()).catch(() => void 0).await();
|
|
2372
|
-
if (dayAvailability) {
|
|
2373
|
-
currentItinerary.addAvailabilityType(dayAvailability);
|
|
2374
|
-
for (const nextDayConnection of connections.iterateConnections(currentItineraryEndLocation, void 0, direction)) {
|
|
2375
|
-
if (!currentItinerary.containsAny({
|
|
2376
|
-
connection: nextDayConnection,
|
|
2377
|
-
checkConnectionStartLocation: false,
|
|
2378
|
-
checkItineraryStartLocation: false,
|
|
2379
|
-
checkItineraryEndLocation: false
|
|
2380
|
-
})) {
|
|
2381
|
-
if (maximumDayDistanceMiles === void 0 || nextDayConnection.distanceMiles <= maximumDayDistanceMiles) {
|
|
2382
|
-
possibleItineraries.add(currentItinerary.clone().addConnection(nextDayConnection));
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
return result;
|
|
2391
|
-
}
|
|
2392
|
-
findItinerariesAsync(parameters) {
|
|
2393
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
2394
|
-
const startDay = parameters.startDay;
|
|
2395
|
-
const startLocation = parameters.startLocation;
|
|
2396
|
-
const endLocation = parameters.endLocation;
|
|
2397
|
-
const direction = parameters.direction;
|
|
2398
|
-
const maximumDayDistanceMiles = parameters.maximumDayDistanceMiles;
|
|
2399
|
-
const maximumItineraryDays = parameters.maximumItineraryDays;
|
|
2400
|
-
const allowWalkupPermits = parameters.allowWalkupPermits ?? true;
|
|
2401
|
-
const allowIndividualSites = parameters.allowIndividualSites ?? true;
|
|
2402
|
-
const allowGroupSites = parameters.allowGroupSites ?? false;
|
|
2403
|
-
const campsitesToAvoid = parameters.campsitesToAvoid ?? [];
|
|
2404
|
-
PreCondition.assertNotUndefinedAndNotNull(startDay, "startDay");
|
|
2405
|
-
return PromiseAsyncResult.create(async () => {
|
|
2406
|
-
const result = List.create();
|
|
2407
|
-
const startLocationsToCheck = !isUndefinedOrNull(startLocation) ? Iterable.create([startLocation]) : WonderlandTrailLocations.getTrailheads();
|
|
2408
|
-
const directionsToCheck = !isUndefinedOrNull(direction) ? Iterable.create([direction]) : Iterable.create([WonderlandTrailDirection.clockwise, WonderlandTrailDirection.counterClockwise]);
|
|
2409
|
-
const availability = await this.getAvailability(
|
|
2410
|
-
startDay.getMonth(),
|
|
2411
|
-
startDay.getYear(),
|
|
2412
|
-
allowWalkupPermits,
|
|
2413
|
-
allowIndividualSites,
|
|
2414
|
-
allowGroupSites
|
|
2415
|
-
);
|
|
2416
|
-
for (const startLocationToCheck of startLocationsToCheck) {
|
|
2417
|
-
for (const directionToCheck of directionsToCheck) {
|
|
2418
|
-
result.addAll(this.findItineraries({
|
|
2419
|
-
availability,
|
|
2420
|
-
startDate: startDay,
|
|
2421
|
-
startLocation: startLocationToCheck,
|
|
2422
|
-
endLocation: endLocation ?? startLocationToCheck,
|
|
2423
|
-
direction: directionToCheck,
|
|
2424
|
-
maximumDayDistanceMiles,
|
|
2425
|
-
maximumItineraryDays,
|
|
2426
|
-
campsitesToAvoid
|
|
2427
|
-
}));
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
return result;
|
|
2431
|
-
});
|
|
2432
|
-
}
|
|
2433
|
-
};
|
|
2434
|
-
|
|
2435
|
-
export {
|
|
2436
|
-
SyncDisposable,
|
|
2437
|
-
ByteList,
|
|
2438
|
-
ByteListStream,
|
|
2439
|
-
StringIterator,
|
|
2440
|
-
CharacterList,
|
|
2441
|
-
CharacterReadStream,
|
|
2442
|
-
CharacterListStream,
|
|
2443
|
-
LuxonDateTime,
|
|
2444
|
-
DateTime,
|
|
2445
|
-
ListStack,
|
|
2446
|
-
Stack,
|
|
2447
|
-
depthFirstSearch,
|
|
2448
|
-
Disposable,
|
|
2449
|
-
Generator,
|
|
2450
|
-
HttpClient,
|
|
2451
|
-
InMemoryCharacterWriteStream,
|
|
2452
|
-
ListQueue,
|
|
2453
|
-
Node,
|
|
2454
|
-
Queue,
|
|
2455
|
-
RecreationDotGovDivisionAvailability,
|
|
2456
|
-
RecreationDotGovError,
|
|
2457
|
-
RecreationDotGovClient,
|
|
2458
|
-
StringComparer,
|
|
2459
|
-
isWonderlandTrailLocation,
|
|
2460
|
-
WonderlandTrailLocations,
|
|
2461
|
-
WonderlandTrailReservationType,
|
|
2462
|
-
WonderlandTrailAvailability,
|
|
2463
|
-
WonderlandTrailDirection,
|
|
2464
|
-
WonderlandTrailConnection,
|
|
2465
|
-
WonderlandTrailConnections,
|
|
2466
|
-
WonderlandTrailItinerary,
|
|
2467
|
-
WonderlandTrailClient
|
|
2468
|
-
};
|
|
2469
|
-
//# sourceMappingURL=chunk-6V7JRJ7P.js.map
|